(()=>{"use strict";var e,t,r,n={54102:(e,t,r)=>{var n=r(49584),i=r(53334);const a='';var s,o=r(85471),l=r(61338),d=r(85168),c=r(54332),m=r(4604),u=r(31126),f=r(94219),p=r(52201);!function(e){e.LaterToday="later-today",e.Tomorrow="tomorrow",e.ThisWeekend="this-weekend",e.NextWeek="next-week"}(s||(s={}));const g=()=>{const e=new Date;return e.setHours(0,0,0,0),e.setDate(e.getDate()-e.getDay()+1),new Date(e)},h=e=>{new Date(e).setHours(0,0,0,0);const t=new Date(e.getFullYear(),0,1,0,0,0,0),r=(e.getTime()-t.getTime())/864e5;return Math.ceil((r+t.getDay()+1)/7)},A=e=>({[s.LaterToday]:()=>{const e=new Date,t=new Date;t.setHours(18,0,0,0);const r=new Date;return r.setHours(17,0,0,0),e>=r?null:t},[s.Tomorrow]:()=>{const e=new Date,t=new Date;return t.setDate(e.getDate()+1),t.setHours(8,0,0,0),t},[s.ThisWeekend]:()=>{const e=new Date;if([5,6,0].includes(e.getDay()))return null;const t=new Date,r=g();return t.setDate(r.getDate()+5),t.setHours(8,0,0,0),t},[s.NextWeek]:()=>{if(0===(new Date).getDay())return null;const e=new Date,t=g();return e.setDate(t.getDate()+7),e.setHours(8,0,0,0),e}}[e]()),v=e=>{let t={hour:"numeric",minute:"2-digit"};const r=new Date;var n,a;return a=r,((n=e).getDate()!==a.getDate()||n.getMonth()!==a.getMonth()||n.getFullYear()!==a.getFullYear())&&(t={...t,weekday:"short"}),((e,t)=>h(e)===h(t)&&e.getFullYear()===t.getFullYear())(e,r)||(t={...t,month:"short",day:"numeric"}),e.getFullYear()!==r.getFullYear()&&(t={...t,year:"numeric"}),e.toLocaleString((0,i.lO)(),t)},b=e=>{let t={month:"long",day:"numeric",weekday:"long",hour:"numeric",minute:"2-digit"};const r=new Date;return e.getFullYear()!==r.getFullYear()&&(t={...t,year:"numeric"}),e.toLocaleString((0,i.lO)(),t)},w=(0,r(35947).YK)().setApp("files_reminders").detectUser().build();var D=r(65043),y=r(63814);const C=async(e,t)=>{const r=(0,y.KT)("/apps/files_reminders/api/v1/{fileId}",{fileId:e});return(await D.Ay.put(r,{dueDate:t.toISOString()})).data.ocs.data},T=async e=>{const t=(0,y.KT)("/apps/files_reminders/api/v1/{fileId}",{fileId:e});return(await D.Ay.delete(t)).data.ocs.data},_=o.Ay.extend({name:"SetCustomReminderModal",components:{NcButton:c.A,NcDateTime:m.A,NcDateTimePickerNative:u.A,NcDialog:f.A,NcNoteCard:p.A},data:()=>({node:void 0,hasDueDate:!1,opened:!1,isValid:!0,customDueDate:null,nowDate:new Date}),computed:{fileId(){return this.node.fileid},fileName(){return this.node.basename},name(){return(0,i.Tl)("files_reminders",'Set reminder for "{fileName}"',{fileName:this.fileName})},label:()=>(0,i.Tl)("files_reminders","Set reminder at custom date & time"),clearAriaLabel:()=>(0,i.Tl)("files_reminders","Clear reminder")},methods:{t:i.Tl,getDateString:v,open(e){const t=e.attributes["reminder-due-date"]?new Date(e.attributes["reminder-due-date"]):null;this.node=e,this.hasDueDate=Boolean(t),this.isValid=!0,this.opened=!0,this.customDueDate=null!=t?t:(()=>{const e=new Date,t=new Date;return t.setHours(e.getHours()+2,0,0,0),t})(),this.nowDate=new Date,setTimeout((()=>{const e=document.getElementById("set-custom-reminder");e.focus(),this.hasDueDate||e.showPicker()}),300)},async setCustom(){if(this.customDueDate instanceof Date&&!isNaN(this.customDueDate))try{await C(this.fileId,this.customDueDate),o.Ay.set(this.node.attributes,"reminder-due-date",this.customDueDate.toISOString()),(0,l.Ic)("files:node:updated",this.node),(0,d.Te)((0,i.Tl)("files_reminders",'Reminder set for "{fileName}"',{fileName:this.fileName})),this.onClose()}catch(e){w.error("Failed to set reminder",{error:e}),(0,d.Qg)((0,i.Tl)("files_reminders","Failed to set reminder"))}else(0,d.Qg)((0,i.Tl)("files_reminders","Please choose a valid date & time"))},async clear(){try{await T(this.fileId),o.Ay.set(this.node.attributes,"reminder-due-date",""),(0,l.Ic)("files:node:updated",this.node),(0,d.Te)((0,i.Tl)("files_reminders",'Reminder cleared for "{fileName}"',{fileName:this.fileName})),this.onClose()}catch(e){w.error("Failed to clear reminder",{error:e}),(0,d.Qg)((0,i.Tl)("files_reminders","Failed to clear reminder"))}},onClose(){this.opened=!1,this.$emit("close")},onInput(){const e=document.getElementById("set-custom-reminder");this.isValid=e.checkValidity()}}});var S=r(85072),x=r.n(S),L=r(97825),N=r.n(L),k=r(77659),I=r.n(k),P=r(55056),M=r.n(P),O=r(10540),H=r.n(O),F=r(41113),B=r.n(F),V=r(2383),Y={};Y.styleTagTransform=B(),Y.setAttributes=M(),Y.insert=I().bind(null,"head"),Y.domAPI=N(),Y.insertStyleElement=H(),x()(V.A,Y),V.A&&V.A.locals&&V.A.locals;const E=(0,r(14486).A)(_,(function(){var e=this,t=e._self._c;return e._self._setupProxy,e.opened?t("NcDialog",{attrs:{name:e.name,"out-transition":!0,size:"small","close-on-click-outside":""},on:{closing:e.onClose},scopedSlots:e._u([{key:"actions",fn:function(){return[t("NcButton",{attrs:{type:"tertiary"},on:{click:e.onClose}},[e._v("\n\t\t\t"+e._s(e.t("files_reminders","Cancel"))+"\n\t\t")]),e._v(" "),e.hasDueDate?t("NcButton",{on:{click:e.clear}},[e._v("\n\t\t\t"+e._s(e.t("files_reminders","Clear reminder"))+"\n\t\t")]):e._e(),e._v(" "),t("NcButton",{attrs:{disabled:!e.isValid,type:"primary",form:"set-custom-reminder-form","native-type":"submit"}},[e._v("\n\t\t\t"+e._s(e.t("files_reminders","Set reminder"))+"\n\t\t")])]},proxy:!0}],null,!1,2766788902)},[t("form",{staticClass:"custom-reminder-modal",attrs:{id:"set-custom-reminder-form"},on:{submit:function(t){return t.preventDefault(),e.setCustom.apply(null,arguments)}}},[t("NcDateTimePickerNative",{attrs:{id:"set-custom-reminder",label:e.label,min:e.nowDate,required:!0,type:"datetime-local"},on:{input:e.onInput},model:{value:e.customDueDate,callback:function(t){e.customDueDate=t},expression:"customDueDate"}}),e._v(" "),e.isValid?t("NcNoteCard",{attrs:{type:"info"}},[e._v("\n\t\t\t"+e._s(e.t("files_reminders","We will remind you of this file"))+"\n\t\t\t"),t("NcDateTime",{attrs:{timestamp:e.customDueDate}})],1):t("NcNoteCard",{attrs:{type:"error"}},[e._v("\n\t\t\t"+e._s(e.t("files_reminders","Please choose a valid date & time"))+"\n\t\t")])],1)]):e._e()}),[],!1,null,"917edf70",null).exports,j=o.Ay.extend(E),R=document.createElement("div");R.id="set-custom-reminder-modal",document.body.appendChild(R);const G=new j({name:"SetCustomReminderModal",el:R}),W=e=>(G.open(e),new Promise((e=>{G.$once("close",e)}))),Q=new n.hY({id:"reminder-status",inline:()=>!0,displayName:()=>"",title:e=>{const t=e.at(0),r=new Date(t.attributes["reminder-due-date"]);return"".concat((0,i.Tl)("files_reminders","Reminder set")," – ").concat(b(r))},iconSvgInline:()=>a,enabled:e=>{if(1!==e.length)return!1;const t=e.at(0).attributes["reminder-due-date"];return Boolean(t)},exec:async e=>(W(e),null),order:-15}),$=new n.hY({id:"clear-reminder",displayName:()=>(0,i.Tl)("files_reminders","Clear reminder"),title:e=>{const t=e.at(0),r=new Date(t.attributes["reminder-due-date"]);return"".concat((0,i.Tl)("files_reminders","Clear reminder")," – ").concat(b(r))},iconSvgInline:()=>'',enabled:e=>{if(1!==e.length)return!1;const t=e.at(0).attributes["reminder-due-date"];return Boolean(t)},async exec(e){if(e.fileid)try{return await T(e.fileid),o.Ay.set(e.attributes,"reminder-due-date",""),(0,l.Ic)("files:node:updated",e),!0}catch(e){return!1}return null},order:19}),K="set-reminder-menu",U=new n.hY({id:K,displayName:()=>(0,i.Tl)("files_reminders","Set reminder"),iconSvgInline:()=>a,enabled:(e,t)=>"trashbin"!==t.id,exec:async()=>null,order:20});var Z=r(19672),q={};q.styleTagTransform=B(),q.setAttributes=M(),q.insert=I().bind(null,"head"),q.domAPI=N(),q.insertStyleElement=H(),x()(Z.A,q),Z.A&&Z.A.locals&&Z.A.locals;const X={dateTimePreset:s.LaterToday,label:(0,i.Tl)("files_reminders","Later today"),ariaLabel:(0,i.Tl)("files_reminders","Set reminder for later today"),dateString:"",verboseDateString:""},z={dateTimePreset:s.Tomorrow,label:(0,i.Tl)("files_reminders","Tomorrow"),ariaLabel:(0,i.Tl)("files_reminders","Set reminder for tomorrow"),dateString:"",verboseDateString:""},J={dateTimePreset:s.ThisWeekend,label:(0,i.Tl)("files_reminders","This weekend"),ariaLabel:(0,i.Tl)("files_reminders","Set reminder for this weekend"),dateString:"",verboseDateString:""},ee={dateTimePreset:s.NextWeek,label:(0,i.Tl)("files_reminders","Next week"),ariaLabel:(0,i.Tl)("files_reminders","Set reminder for next week"),dateString:"",verboseDateString:""};[X,z,J,ee].forEach((e=>{const t=A(e.dateTimePreset);t&&(e.dateString=v(t),e.verboseDateString=b(t),setInterval((()=>{const t=A(e.dateTimePreset);t&&(e.dateString=v(t),e.verboseDateString=b(t))}),18e5))}));const te=[X,z,J,ee].map((e=>new n.hY({id:"set-reminder-".concat(e.dateTimePreset),displayName:()=>"".concat(e.label," – ").concat(e.dateString),title:()=>"".concat(e.ariaLabel," – ").concat(e.verboseDateString),iconSvgInline:()=>"",enabled:(t,r)=>"trashbin"!==r.id&&Boolean(A(e.dateTimePreset)),parent:K,async exec(t){if(!t.fileid)return w.error("Failed to set reminder, missing file id"),(0,d.Qg)((0,i.Tl)("files_reminders","Failed to set reminder")),null;try{const r=A(e.dateTimePreset);await C(t.fileid,r),o.Ay.set(t.attributes,"reminder-due-date",r.toISOString()),(0,l.Ic)("files:node:updated",t),(0,d.Te)((0,i.Tl)("files_reminders",'Reminder set for "{fileName}"',{fileName:t.basename}))}catch(e){w.error("Failed to set reminder",{error:e}),(0,d.Qg)((0,i.Tl)("files_reminders","Failed to set reminder"))}return null},order:21}))),re=new n.hY({id:"set-reminder-custom",displayName:()=>(0,i.Tl)("files_reminders","Set custom reminder"),title:()=>(0,i.Tl)("files_reminders","Set reminder at custom date & time"),iconSvgInline:()=>'',enabled:(e,t)=>"trashbin"!==t.id,parent:K,exec:async e=>(W(e),null),order:22});(0,n.Yc)("nc:reminder-due-date",{nc:"http://nextcloud.org/ns"}),(0,n.Gg)(Q),(0,n.Gg)($),(0,n.Gg)(U),(0,n.Gg)(re),te.forEach((e=>(0,n.Gg)(e)))},19672:(e,t,r)=>{r.d(t,{A:()=>o});var n=r(71354),i=r.n(n),a=r(76314),s=r.n(a)()(i());s.push([e.id,'.files-list__row-action-set-reminder-custom{margin-top:13px;position:relative}.files-list__row-action-set-reminder-custom::before{content:"";margin:3px 10px 3px 15px;border-bottom:1px solid var(--color-border-dark);cursor:default;display:flex;height:0;position:absolute;left:0;right:0;top:-10px}',"",{version:3,sources:["webpack://./apps/files_reminders/src/actions/setReminderSuggestionActions.scss"],names:[],mappings:"AAMA,4CACC,eAAA,CACA,iBAAA,CAEA,oDACC,UAAA,CACA,wBAAA,CACA,gDAAA,CACA,cAAA,CACA,YAAA,CACA,QAAA,CACA,iBAAA,CACA,MAAA,CACA,OAAA,CACA,SAAA",sourcesContent:['/**\n * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors\n * SPDX-License-Identifier: AGPL-3.0-or-later\n */\n // TODO: remove when/if the actions API supports a separator\n // This the last preset action, so we need to add a separator\n.files-list__row-action-set-reminder-custom {\n\tmargin-top: 13px;\n\tposition: relative;\n\n\t&::before {\n\t\tcontent: "";\n\t\tmargin: 3px 10px 3px 15px;\n\t\tborder-bottom: 1px solid var(--color-border-dark);\n\t\tcursor: default;\n\t\tdisplay: flex;\n\t\theight: 0;\n\t\tposition: absolute;\n\t\tleft: 0;\n\t\tright: 0;\n\t\ttop: -10px;\n\t}\n}\n'],sourceRoot:""}]);const o=s},2383:(e,t,r)=>{r.d(t,{A:()=>o});var n=r(71354),i=r.n(n),a=r(76314),s=r.n(a)()(i());s.push([e.id,".custom-reminder-modal[data-v-917edf70]{margin:0 12px}","",{version:3,sources:["webpack://./apps/files_reminders/src/components/SetCustomReminderModal.vue"],names:[],mappings:"AACA,wCACC,aAAA",sourcesContent:["\n.custom-reminder-modal {\n\tmargin: 0 12px;\n}\n"],sourceRoot:""}]);const o=s}},i={};function a(e){var t=i[e];if(void 0!==t)return t.exports;var r=i[e]={id:e,loaded:!1,exports:{}};return n[e].call(r.exports,r,r.exports,a),r.loaded=!0,r.exports}a.m=n,e=[],a.O=(t,r,n,i)=>{if(!r){var s=1/0;for(c=0;c=i)&&Object.keys(a.O).every((e=>a.O[e](r[l])))?r.splice(l--,1):(o=!1,i0&&e[c-1][2]>i;c--)e[c]=e[c-1];e[c]=[r,n,i]},a.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return a.d(t,{a:t}),t},a.d=(e,t)=>{for(var r in t)a.o(t,r)&&!a.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},a.f={},a.e=e=>Promise.all(Object.keys(a.f).reduce(((t,r)=>(a.f[r](e,t),t)),[])),a.u=e=>e+"-"+e+".js?v="+{4254:"5c2324570f66dff0c8a1",9480:"f3ebcf41e93bbd8cd678"}[e],a.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),a.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),t={},r="nextcloud:",a.l=(e,n,i,s)=>{if(t[e])t[e].push(n);else{var o,l;if(void 0!==i)for(var d=document.getElementsByTagName("script"),c=0;c{o.onerror=o.onload=null,clearTimeout(f);var i=t[e];if(delete t[e],o.parentNode&&o.parentNode.removeChild(o),i&&i.forEach((e=>e(n))),r)return r(n)},f=setTimeout(u.bind(null,void 0,{type:"timeout",target:o}),12e4);o.onerror=u.bind(null,o.onerror),o.onload=u.bind(null,o.onload),l&&document.head.appendChild(o)}},a.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},a.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),a.j=9735,(()=>{var e;a.g.importScripts&&(e=a.g.location+"");var t=a.g.document;if(!e&&t&&(t.currentScript&&(e=t.currentScript.src),!e)){var r=t.getElementsByTagName("script");if(r.length)for(var n=r.length-1;n>-1&&(!e||!/^http(s?):/.test(e));)e=r[n--].src}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),a.p=e})(),(()=>{a.b=document.baseURI||self.location.href;var e={9735:0};a.f.j=(t,r)=>{var n=a.o(e,t)?e[t]:void 0;if(0!==n)if(n)r.push(n[2]);else{var i=new Promise(((r,i)=>n=e[t]=[r,i]));r.push(n[2]=i);var s=a.p+a.u(t),o=new Error;a.l(s,(r=>{if(a.o(e,t)&&(0!==(n=e[t])&&(e[t]=void 0),n)){var i=r&&("load"===r.type?"missing":r.type),s=r&&r.target&&r.target.src;o.message="Loading chunk "+t+" failed.\n("+i+": "+s+")",o.name="ChunkLoadError",o.type=i,o.request=s,n[1](o)}}),"chunk-"+t,t)}},a.O.j=t=>0===e[t];var t=(t,r)=>{var n,i,s=r[0],o=r[1],l=r[2],d=0;if(s.some((t=>0!==e[t]))){for(n in o)a.o(o,n)&&(a.m[n]=o[n]);if(l)var c=l(a)}for(t&&t(r);da(54102)));s=a.O(s)})(); //# sourceMappingURL=files_reminders-init.js.map?v=91141afac27a8e494288