From 43a0f5087bc7510d3a8c4c9b4c37b2c0066acec8 Mon Sep 17 00:00:00 2001 From: strukturart Date: Sun, 20 Oct 2024 21:57:58 +0200 Subject: [PATCH] calendar names --- application/app.js | 67 +++++++++++++++++++++----------- application/manifest.webmanifest | 2 +- docs/index.013d44c9.js | 2 +- docs/index.2ef9694f.js | 2 +- docs/manifest.webmanifest | 2 +- 5 files changed, 48 insertions(+), 27 deletions(-) diff --git a/application/app.js b/application/app.js index 94bcfdda..67117e6d 100644 --- a/application/app.js +++ b/application/app.js @@ -42,8 +42,8 @@ localforage.setDriver(localforage.INDEXEDDB); const google_oauth_url = 'https://accounts.google.com/o/oauth2/v2/auth?client_id=' + process.env.clientId + - '&response_type=code&state=state_parameter_passthrough_value&scope=https://www.googleapis.com/auth/calendar%20https://www.googleapis.com/auth/calendar.calendarlist&redirect_uri=' + - process.env.redirect_url + + '&response_type=code&state=state_parameter_passthrough_value&scope=https://www.googleapis.com/auth/calendar&redirect_uri=' + + encodeURIComponent(process.env.redirect_url) + '&access_type=offline&prompt=consent'; export let parsed_events = []; @@ -110,8 +110,9 @@ const oauthRedirect = async () => { tokens, authorizationCode, name: 'Google', - id: uid(32), // Assuming uid function is defined + id: uid(32), type: 'oauth', + calendars: [], }); await localforage.setItem('accounts', accounts); @@ -128,14 +129,11 @@ const oauthRedirect = async () => { const authorizationCode = getAuthorizationCode(); if (!authorizationCode) { return false; - //throw new Error('Authorization code is missing'); } const tokens = await getToken(authorizationCode); await saveAccount(tokens, authorizationCode); - } catch (error) { - // alert('OAuth process failed: ' + error.message); - } + } catch (error) {} }; //open KaiOS app @@ -147,10 +145,7 @@ let app_launcher = () => { const urlParams = new URLSearchParams(window.location.search); let result = urlParams.get('code'); - /* - const params = new URLSearchParams(currentUrl.split('?')[1]); - const code = params.get('code'); - */ + if (!result) return false; // let result = code.split('#')[0]; @@ -355,6 +350,35 @@ if ('b2g' in navigator) { //load calendar names let calendar_not_visible = []; + +async function loadCalendarNames() { + try { + const calendarData = await localforage.getItem('calendarNames'); + + // Set local calendar as default if 'calendarNames' is not found + if (!calendarData) { + calendar_names = [ + { + name: 'local', + id: 'local-id', + data: [], + type: 'local', + view: true, + }, + ]; + } else { + calendar_names = calendarData; + // Process visibility + calendar_names.forEach((e) => { + if (!e.view) calendar_not_visible.push(e.name); + }); + } + } catch (err) { + console.error('Error loading calendar names:', err); + } +} + +/* async function loadCalendarNames() { try { const keys = await localforage.keys(); @@ -379,7 +403,7 @@ async function loadCalendarNames() { }); } } catch (err) {} -} +}*/ //load accounts data //test whether there are updates in the remote @@ -589,11 +613,10 @@ async function load_caldav(callback = false, account_to_update = false) { let calendars; try { calendars = await client.fetchCalendars(); - console.log(calendars); } catch (fetchCalendarsError) { console.log(fetchCalendarsError); - - continue; // Skip to the next account in case of fetch failure + // Skip to the next account in case of fetch failure + continue; } if (m.route.get() === '/page_calendar') { @@ -740,7 +763,7 @@ export let sync_caldav = async function (callback) { const calendars = await client.fetchCalendars(); for (let i = 0; i < calendars.length; i++) { - const objects = await client.fetchCalendarObjects({ + await client.fetchCalendarObjects({ calendar: calendars[i], }); cn.push({ @@ -792,18 +815,14 @@ export let sync_caldav = async function (callback) { } } + //update new calendars with old calendar view attribut + if (JSON.stringify(cn) != JSON.stringify(calendar_names)) { - //update new calendars with old calendar view attribut try { cn.forEach((e) => { let matchingCalendar; if (Array.isArray(calendar_names)) { matchingCalendar = calendar_names.find((a) => a.name === e.name); - - // Rest of your code using matchingCalendar - } else { - console.error('calendar_names is not an array or is undefined'); - // Handle the case where calendar_names is not an array or is undefined } if (matchingCalendar) { @@ -831,7 +850,7 @@ const load_cached_caldav = async () => { try { const w = await localforage.getItem(item.id); // Load content if never cached - if (w === null) { + if (!w) { try { load_caldav(false, item.id); } catch (e) { @@ -5609,12 +5628,14 @@ let oauthRedirect_kaios = async (authorizationCode) => { name: 'Google', id: uid(32), type: 'oauth', + calendars: [], }); await localforage.setItem('accounts', accounts); setTimeout(() => { show_success_animation(); + load_caldav(true, false); localStorage.setItem('oauth_callback', 'true'); }, 3000); } catch (error) { diff --git a/application/manifest.webmanifest b/application/manifest.webmanifest index 84722bf7..f1121b13 100644 --- a/application/manifest.webmanifest +++ b/application/manifest.webmanifest @@ -24,7 +24,7 @@ ], "b2g_features": { - "version": "3.0.679", + "version": "3.0.683", "id": "greg", "subtitle": "easy to use calendar", "core": true, diff --git a/docs/index.013d44c9.js b/docs/index.013d44c9.js index 8202d93e..590e1ed7 100644 --- a/docs/index.013d44c9.js +++ b/docs/index.013d44c9.js @@ -3,4 +3,4 @@ function M(M,b,e,z){Object.defineProperty(M,b,{get:e,set:z,enumerable:!0,configu * * @author Jerry Bendy (https://github.com/jerrybendy) * @licence MIT - */function(M){var b,e,z=function(){try{if(M.URLSearchParams&&"bar"===new M.URLSearchParams("foo=bar").get("foo"))return M.URLSearchParams}catch(M){}return null}(),o=z&&"a=1"===new z({a:1}).toString(),p=z&&"+"===new z("s=%2B").get("s"),c=z&&"size"in z.prototype,t="__URLSearchParams__",n=!z||((b=new z).append("s"," &"),"s=+%26"===b.toString()),O=A.prototype,r=!!(M.Symbol&&M.Symbol.iterator);if(!z||!o||!p||!n||!c){O.append=function(M,b){l(this[t],M,b)},O.delete=function(M){delete this[t][M]},O.get=function(M){var b=this[t];return this.has(M)?b[M][0]:null},O.getAll=function(M){var b=this[t];return this.has(M)?b[M].slice(0):[]},O.has=function(M){return W(this[t],M)},O.set=function(M,b){this[t][M]=[""+b]},O.toString=function(){var M,b,e,z,o=this[t],p=[];for(b in o)for(M=0,e=d(b),z=o[b];M *");document.querySelector("#KaiOsAds-Wrapper").style.margin="0px 0px 30px 0",M.forEach(function(M){M.addEventListener("focus",function(M){MY("","open ads","")})})}catch(M){console.log(M)}}),M.call("display",{navClass:"item",display:"block"})}})},document.head.appendChild(M)},o_={},ML=Ms("h1KY3");o_=function(M){var b={};function e(z){if(b[z])return b[z].exports;var o=b[z]={i:z,l:!1,exports:{}};return M[z].call(o.exports,o,o.exports,e),o.l=!0,o.exports}return e.m=M,e.c=b,e.d=function(M,b,z){e.o(M,b)||Object.defineProperty(M,b,{enumerable:!0,get:z})},e.r=function(M){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(M,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(M,"__esModule",{value:!0})},e.t=function(M,b){if(1&b&&(M=e(M)),8&b||4&b&&"object"==typeof M&&M&&M.__esModule)return M;var z=Object.create(null);if(e.r(z),Object.defineProperty(z,"default",{enumerable:!0,value:M}),2&b&&"string"!=typeof M)for(var o in M)e.d(z,o,(function(b){return M[b]}).bind(null,o));return z},e.n=function(M){var b=M&&M.__esModule?function(){return M.default}:function(){return M};return e.d(b,"a",b),b},e.o=function(M,b){return Object.prototype.hasOwnProperty.call(M,b)},e.p="",e(e.s=0)}([function(M,b,e){function z(M){return(z="function"==typeof Symbol&&"symbol"==(0,ML._)(Symbol.iterator)?function(M){return void 0===M?"undefined":(0,ML._)(M)}:function(M){return M&&"function"==typeof Symbol&&M.constructor===Symbol&&M!==Symbol.prototype?"symbol":void 0===M?"undefined":(0,ML._)(M)})(M)}function o(M){var b;switch(z(M)){case"string":return/Z$/.test(M)?0:(b=/([+-])(\d{2}):?(\d{2})/.exec(M))&&(+b[3]+60*b[2])*("+"===b[1]?1:-1);case"number":return Number.isNaN(M)?null:16>Math.abs(M)?60*M:M;default:return null}}e.r(b);var p=function(M,b,e){var z=String(M);return!z||z.length>=b?M:"".concat(Array(b+1-z.length).join(e)).concat(M)},c=function(M){var b=Math.abs(M);return"".concat(M<=0?"+":"-").concat(p(Math.floor(b/60),2,"0"),":").concat(p(b%60,2,"0"))};function t(M,b){for(var e=0;e1&&void 0!==arguments[1]?arguments[1]:n))}var a=function(){var M,b;function e(){var M=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new Date,b=arguments.length>1&&void 0!==arguments[1]?arguments[1]:M.getTimezoneOffset();(function(M,b){if(!(M instanceof b))throw TypeError("Cannot call a class as a function")})(this,e),this.$d=new Date(M.getTime()-r(b)),this.$timezoneOffset=b}return M=[{key:"getTimezoneOffset",value:function(){return this.$timezoneOffset}},{key:"setTimezoneOffset",value:function(){var M=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.$timezoneOffset;this.$d.setTime(this.$d.getTime()+r(this.$timezoneOffset,M)),this.$timezoneOffset=M}}],t(e.prototype,M),b&&t(e,b),e}();["toDateString","toLocaleString","toLocaleDateString","toLocaleTimeString","setDate","setFullYear","setHours","setMilliseconds","setMinutes","setMonth","setSeconds","setTime","setYear","getDate","getDay","getFullYear","getHours","getMilliseconds","getMinutes","getMonth","getSeconds","getYear"].forEach(function(M){a.prototype[M]=function(){return O[M].apply(this.$d,arguments)}}),["toISOString","toUTCString","toGMTString","toJSON","getUTCDate","getUTCDay","getUTCFullYear","getUTCHours","getUTCMilliseconds","getUTCMinutes","getUTCMonth","getUTCSeconds","valueOf","getTime"].forEach(function(M){a.prototype[M]=function(){return O[M].apply(new Date(this.$d.getTime()+r(this.$timezoneOffset)),arguments)}}),["setUTCDate","setUTCFullYear","setUTCHours","setUTCMilliseconds","setUTCMinutes","setUTCMonth","setUTCSeconds"].forEach(function(M){a.prototype[M]=function(){var b=new Date(this.$d.getTime()+r(this.$timezoneOffset));O[M].apply(b,arguments),b.setTime(b.getTime()-r(this.$timezoneOffset)),this.$d=b}}),["toString","toTimeString"].forEach(function(M){a.prototype[M]=function(){return O[M].apply(this.$d,arguments).replace(/GMT(.*)$/,"GMT".concat(c(this.$timezoneOffset)))}});var i=!1,A=function(M,b){["clone","add","subtract","startOf"].forEach(function(e){M[e]=function(){var M=this.utcOffset();return b[e].apply(this,arguments).utcOffset(M)}}),M.utc=function(){return this.utcOffset(0)},M.local=function(){return this.utcOffset(-n)},M.utcOffset=function(M){if(void 0===M){var b=this.$d.getTimezoneOffset();return 0===b?0:-b}return null!==o(M)&&(this.$d.setTimezoneOffset(-o(M)),this.init()),this},M.toDate=function(){return new Date(this.$d.getTime())},M.isLocal=function(){return this.$d.getTimezoneOffset()===n},M.isUTC=function(){return 0===this.$d.getTimezoneOffset()},M.$set=function(){for(var M,e=this.$d.getTimezoneOffset(),z=arguments.length,o=Array(z),p=0;p0&&void 0!==arguments[0]?arguments[0]:{},b=arguments.length>1?arguments[1]:void 0,e=arguments.length>2?arguments[2]:void 0;i=!!M.parseToLocal;var z=b.prototype,p=function(){};p.prototype=z;var c=new p;A(c,z),c.constructor=b.constructor,b.prototype=c,e.utc=function(M){var b=this(M);return"string"==typeof M&&null===o(M)&&(b.$d.$timezoneOffset=0),b.utc()}}}]),b(Mw).extend(b(o_));var oS={};(oS=Ms("5labU")).tz.load(Ms("8zdtp"));var oD=new BroadcastChannel("sw-messages");b(Mv).setDriver(b(Mv).INDEXEDDB);var oP=[],ox=[],oI=[],oU=!1,oj=60,oF=localStorage.getItem("last_sync")||"",oY=[];b(Mv).getItem("subscriptions").then(function(M){console.log(M)});var oH=(E=Ml(function(){var M,e,z,o,p;return(0,MB.__generator)(this,function(c){switch(c.label){case 0:var t,n;M=function(){return new URLSearchParams(window.location.search).get("code")},t=Ml(function(M){var b,e,z,o,p;return(0,MB.__generator)(this,function(c){switch(c.label){case 0:(b=new Headers).append("Content-Type","application/x-www-form-urlencoded"),(e=new URLSearchParams).append("code",M),e.append("grant_type","authorization_code"),e.append("redirect_uri","https://greg.strukturart.com/index.html"),e.append("client_id","762086220505-f0kij4nt279nqn21ukokm06j0jge2ngl.apps.googleusercontent.com"),e.append("client_secret","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"),z={method:"POST",headers:b,body:e,redirect:"follow"},c.label=1;case 1:return c.trys.push([1,4,,5]),[4,fetch("https://oauth2.googleapis.com/token",z)];case 2:if(!(o=c.sent()).ok)throw Error("Token exchange failed: ".concat(o.statusText));return[4,o.json()];case 3:return[2,c.sent()];case 4:throw console.error("Error fetching the token:",p=c.sent()),p;case 5:return[2]}})}),e=function(M){return t.apply(this,arguments)},n=Ml(function(M,e){var z,o;return(0,MB.__generator)(this,function(p){switch(p.label){case 0:return p.trys.push([0,3,,4]),[4,b(Mv).getItem("accounts")];case 1:return(z=p.sent()||[]).push({server_url:"https://apidata.googleusercontent.com/caldav/v2/",tokens:M,authorizationCode:e,name:"Google",id:MT(32),type:"oauth"}),[4,b(Mv).setItem("accounts",z)];case 2:return p.sent(),setTimeout(function(){window.close()},3e3),[3,4];case 3:return o=p.sent(),alert("Error saving account: "+o.message),[3,4];case 4:return[2]}})}),z=function(M,b){return n.apply(this,arguments)},c.label=1;case 1:if(c.trys.push([1,4,,5]),!(o=M()))return[2,!1];return[4,e(o)];case 2:return p=c.sent(),[4,z(p,o)];case 3:case 4:return c.sent(),[3,5];case 5:return[2]}})}),function(){return E.apply(this,arguments)});"b2g"in navigator||"navigator.mozApps"in navigator?function(){if(!window.location.href.includes("code="))return!1;var M=new URLSearchParams(window.location.search).get("code");if(!M)return!1;setTimeout(function(){try{var b=new MozActivity({name:"greg-oauth",data:M});b.onsuccess=function(){console.log("Activity successfuly handled")},b.onerror=function(){console.log("The activity encouter en error: "+this.error),alert(this.error)}}catch(M){}if("b2g"in navigator)try{new WebActivity("greg-oauth",{name:"greg-oauth",type:"string",data:M}).start().then(function(M){window.close(),console.log("Results passed back from activity handler:"),console.log(M)},function(M){alert(M)})}catch(M){}},4e3)}():oH();var oV=function(){document.querySelector("#intro").classList.add("intro-animation"),document.querySelector("#version").classList.add("intro-version-animation"),document.querySelector("#intro img").classList.add("intro-img-anmation")},oG=function(){setTimeout(function(){document.querySelector(".success-checkmark").style.display="block"},2e3),setTimeout(function(){document.querySelector(".success-checkmark").style.display="none"},4e3)},oK=[],oQ=function(){oK.push(b(M3).route.get())},oJ=function(){setTimeout(function(){b(M3).route.set(oK[oK.length-2])},1e3)};MH();var o$="",oZ=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],o0=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],o1={selected_day:b(Mw)().format("YYYY-MM-DD"),selected_day_id:"",visible:!1,update_event_id:"",event_calendar_changed:!1,startup:!1,sortEvents:"startDate",shortCut:!1,background_sync_running:!1,version:localStorage.getItem("version")||"time is relative",notKaiOS:!0,debug:!1},o2={default_notification:"none",ads:!0,timezone:oS.tz.guess(),dateformat:"YYYY-MM-DD",firstday:"sunday",background_sync:"No",default_duration:30};("b2g"in navigator||"navigator.mozApps"in navigator)&&(o1.notKaiOS=!1),o1.notKaiOS||["http://127.0.0.1/api/v1/shared/core.js","http://127.0.0.1/api/v1/shared/session.js","http://127.0.0.1/api/v1/apps/service.js","http://127.0.0.1/api/v1/audiovolumemanager/service.js","./assets/js/kaiads.v5.min.js"].forEach(function(M){var b=document.createElement("script");b.type="text/javascript",b.src=M,document.head.appendChild(b)}),function(){try{if("No"==localStorage.getItem("background_sync"))return!1;var M=navigator.mozAlarms.getAll();M.onsuccess=function(){this.result.forEach(function(M){"keep alive"==M.data.note&&MQ()})},M.onerror=function(){console.log("An error occurred:",this.error.name)}}catch(M){}}();var o3={};if(o3=Ms("6JduE").getBundleURL("dK21l")+"sw.js","b2g"in navigator)try{navigator.serviceWorker.register(o3).then(function(M){M.waiting&&setTimeout(function(){window.location.reload(!0)},1e3),M.systemMessageManager.subscribe("alarm").then(function(M){console.log('Successfully subscribe system messages of name "alarm".')},function(M){console.log("Fail to subscribe system message, error: "+M)}),M.systemMessageManager.subscribe("activity").then(function(M){},function(M){})})}catch(M){console.log(M)}else if("serviceWorker"in navigator&&navigator.serviceWorker.controller)console.log("Service worker found");else try{console.log("Try to register service worker"),navigator.serviceWorker.register(o3).then(function(M){M.waiting&&setTimeout(function(){window.location.reload(!0)},1e3)})}catch(M){console.error("Error during service worker registration:",M)}var o4=[];function o5(){return o6.apply(this,arguments)}function o6(){return(o6=Ml(function(){return(0,MB.__generator)(this,function(M){switch(M.label){case 0:return M.trys.push([0,2,,3]),[4,b(Mv).keys()];case 1:return -1==M.sent().indexOf("calendarNames")?Mp=[{name:"local",id:"local-id",data:[],type:"local",view:!0}]:b(Mv).getItem("calendarNames").then(function(M){(Mp=M).forEach(function(M){!1==M.view&&o4.push(M.name)})}),[3,3];case 2:return M.sent(),[3,3];case 3:return[2]}})})).apply(this,arguments)}var o8=function(){b(Mv).getItem("accounts").then(function(M){oV(),ox=M,o5(),null!=ox&&pr().then(function(){pO(pu)})}).catch(function(){console.log("no accounts")})};o8();var o7={data:[],calendar_name:"local",calendar_id:"local-id"};b(Mv).getItem("local_account").then(function(M){null!=M?(o7.data=M.data,o7.data.forEach(function(M){try{navigator.serviceWorker.controller.postMessage({type:"parse",t:M,e:"local-id",callback:!1,store:!1})}catch(M){console.log("send to sw")}})):b(Mv).setItem("local_account",o7).then(function(){console.log("Local account created:",o7)}).catch(function(M){console.error("Error creating local account:",M)})}).catch(function(M){console.error("Error loading local account:",M)});var o9=function(){b(Mv).getItem("settings").then(function(M){null!=M&&(o2=M,localStorage.setItem("background_sync",o2.background_sync),o0="sunday"==o2.firstday||void 0==o2.firstday?["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]:["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],void 0==o2.dateformat&&(o2.dateformat="YYYY-MM-DD"),document.querySelectorAll(".calendar-head div").forEach(function(M,b){M.innerText=o0[b]}))}).catch(function(M){})};o9();var pM=function(){try{document.querySelectorAll("div.calendar-cell").forEach(function(M){var b=M.getAttribute("data-date");!0==pB(b).event?(M.classList.add("event"),!0==pB(b).multidayevent&&M.classList.add("multievent")):M.classList.contains("event")&&M.classList.remove("event"),!0==pv(b).rrule&&(M.classList.add("rrule"),pv(b).count>1&&M.classList.add("multievent"))})}catch(M){console.log(M)}},pb={},pe={};function pz(M){return po.apply(this,arguments)}function po(){return(po=Ml(function(M){return(0,MB.__generator)(this,function(b){try{return pb[M.id]||("oauth"===M.type&&(pb[M.id]=new ok({serverUrl:M.server_url,credentials:{tokenUrl:"https://oauth2.googleapis.com/token",refreshToken:M.tokens.refresh_token,clientId:"762086220505-f0kij4nt279nqn21ukokm06j0jge2ngl.apps.googleusercontent.com",clientSecret:"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",authorizationCode:M.authorizationCode,redirectUrl:"https://greg.strukturart.com/index.html"},authMethod:"Oauth",defaultAccountType:"caldav"})),"basic"===M.type&&(pb[M.id]=new ok({serverUrl:M.server_url,credentials:{username:M.user,password:M.password},authMethod:"Basic",defaultAccountType:"caldav"}))),[2,pb[M.id]]}catch(M){throw console.error("Error occurred while creating DAVClient instance:",M),M}return[2]})})).apply(this,arguments)}function pp(){return pc.apply(this,arguments)}function pc(){return(pc=Ml(function(){var M,e,z,o,p,c,t,n,O,r,a,i,A,d,s,q,u,l,f,W,h,R,m,L,B,v,g=arguments;return(0,MB.__generator)(this,function(N){switch(N.label){case 0:if(M=g.length>0&&void 0!==g[0]&&g[0],e=g.length>1&&void 0!==g[1]&&g[1],!navigator.onLine)return[2,!1];if(oU=!0,e)try{oP=oP.filter(function(M){return M.id==M.account_to_update})}catch(M){console.log(M)}else try{oP=oP.filter(function(M){return!M.isCaldav})}catch(M){console.log(M)}z=!0,o=!1,p=void 0,N.label=1;case 1:N.trys.push([1,30,31,32]),c=ox[Symbol.iterator](),N.label=2;case 2:if(z=(t=c.next()).done)return[3,29];if(n=t.value,!1!=e&&e!==n)return[3,28];return[4,pz(n)];case 3:O=N.sent(),N.label=4;case 4:if(N.trys.push([4,27,,28]),pe[n.id])return[3,9];N.label=5;case 5:return N.trys.push([5,7,,8]),[4,O.login()];case 6:return N.sent(),pe[n.id]=!0,console.log("login successfull"),[3,8];case 7:return console.log("cant login"+N.sent()),pe[n.id]=!1,[3,28];case 8:return[3,10];case 9:console.log("login"),N.label=10;case 10:r=void 0,N.label=11;case 11:return N.trys.push([11,13,,14]),[4,O.fetchCalendars()];case 12:return console.log(r=N.sent()),[3,14];case 13:return console.log(N.sent()),[3,28];case 14:"/page_calendar"===b(M3).route.get()&&(document.getElementById("icon-loading").style.visibility="visible"),a=[],i=!0,A=!1,d=void 0,N.label=15;case 15:N.trys.push([15,24,25,26]),s=r[Symbol.iterator](),N.label=16;case 16:if(i=(q=s.next()).done)return[3,23];return u=q.value,[4,O.fetchCalendarObjects({calendar:u})];case 17:l=N.sent(),f={displayName:u.displayName,syncToken:u.syncToken,ctag:u.ctag,url:u.url,objects:l},a.push(f),N.label=18;case 18:return N.trys.push([18,20,,21]),[4,b(Mv).setItem(n.id,a)];case 19:return N.sent(),console.log("Data cached"),[3,21];case 20:return console.log(N.sent()),oU=!1,[3,21];case 21:W=!0,h=!1,R=void 0;try{for(m=l[Symbol.iterator]();!(W=(L=m.next()).done);W=!0)B=L.value,"serviceWorker"in navigator&&navigator.serviceWorker.controller&&navigator.serviceWorker.controller.postMessage({type:"parse",t:B,e:n.id,callback:!1,store:!1})}catch(M){h=!0,R=M}finally{try{W||null==m.return||m.return()}finally{if(h)throw R}}N.label=22;case 22:return i=!0,[3,16];case 23:return[3,26];case 24:return v=N.sent(),A=!0,d=v,[3,26];case 25:try{i||null==s.return||s.return()}finally{if(A)throw d}return[7];case 26:try{document.getElementById("icon-loading").style.visibility="hidden",document.getElementById("icon-waiting").style.visibility="hidden"}catch(M){console.log(M)}return M&&Mj("all event reloaded",2e3),oU=!1,[3,28];case 27:N.sent(),oU=!1;try{document.getElementById("icon-loading").style.visibility="hidden",document.getElementById("icon-waiting").style.visibility="hidden"}catch(M){console.log(M)}return[3,28];case 28:return z=!0,[3,2];case 29:return[3,32];case 30:return v=N.sent(),o=!0,p=v,[3,32];case 31:try{z||null==c.return||c.return()}finally{if(o)throw p}return[7];case 32:return[2]}})})).apply(this,arguments)}var pt=(_=Ml(function(){var M,e,z,o,p,c,t,n,O;return(0,MB.__generator)(this,function(r){switch(r.label){case 0:oU=!0,e=!0,z=!1,o=void 0,r.label=1;case 1:r.trys.push([1,6,7,8]),p=function(){var e,z,o,p,c,n;return(0,MB.__generator)(this,function(O){switch(O.label){case 0:return[4,pz(e=t.value)];case 1:z=O.sent(),O.label=2;case 2:return O.trys.push([2,8,,9]),[4,z.fetchCalendars()];case 3:o=O.sent(),p=[],c=0,O.label=4;case 4:if(!(c0)return M(t),[3,18];return[3,17];case 16:return q.sent(),navigator.onLine||MS("greg","device offline"),[3,17];case 17:return i++,[3,13];case 18:return[3,20];case 19:return q.sent(),navigator.onLine||MS("greg","device offline"),[3,20];case 20:return e=!0,[3,2];case 21:return[3,24];case 22:return s=q.sent(),z=!0,o=s,[3,24];case 23:try{e||null==p.return||p.return()}finally{if(z)throw o}return[7];case 24:if(JSON.stringify(pn)!=JSON.stringify(Mp)){try{pn.forEach(function(M){var b;Array.isArray(Mp)?b=Mp.find(function(b){return b.name===M.name}):console.error("calendar_names is not an array or is undefined"),b&&(M.view=b.view)})}catch(M){console.log(M)}b(Mv).setItem("calendarNames",pn).then(function(){o5()})}return[2]}})}),function(M){return S.apply(this,arguments)}),pr=(D=Ml(function(){var M,e,z,o,p,c,t,n,O,r,a,i,A,d,s,q,u,l,f,W;return(0,MB.__generator)(this,function(h){switch(h.label){case 0:if(!ox)return[2,!1];M=!0,e=!1,z=void 0,h.label=1;case 1:h.trys.push([1,8,9,10]),o=ox[Symbol.iterator](),h.label=2;case 2:if(M=(p=o.next()).done)return[3,7];c=p.value,h.label=3;case 3:return h.trys.push([3,5,,6]),[4,b(Mv).getItem(c.id)];case 4:if(null===(t=h.sent()))try{pp(!1,c.id)}catch(M){console.log(M)}n=!0,O=!1,r=void 0,a=!0,i=!1,A=void 0;try{for(d=t[Symbol.iterator]();!(a=(s=d.next()).done);a=!0){q=s.value;try{for(u=q.objects[Symbol.iterator]();!(n=(l=u.next()).done);n=!0)if(f=l.value,"serviceWorker"in navigator&&navigator.serviceWorker.controller)try{navigator.serviceWorker.controller.postMessage({type:"parse",t:f,e:c.id,callback:!1,store:!1})}catch(M){console.log("send to sw")}else console.log("no sw")}catch(M){O=!0,r=M}finally{try{n||null==u.return||u.return()}finally{if(O)throw r}}}}catch(M){i=!0,A=M}finally{try{a||null==d.return||d.return()}finally{if(i)throw A}}return[3,6];case 5:return console.log(h.sent()),[3,6];case 6:return M=!0,[3,2];case 7:return[3,10];case 8:return W=h.sent(),e=!0,z=W,[3,10];case 9:try{M||null==o.return||o.return()}finally{if(e)throw z}return[7];case 10:return[2]}})}),function(){return D.apply(this,arguments)}),pa=(P=Ml(function(M,b,e,z,o){var p,c,t,n,O;return(0,MB.__generator)(this,function(r){switch(r.label){case 0:if(!navigator.onLine)return[2,!1];if(document.querySelector(".loading-spinner").style.display="block",!(p=ox.find(function(M){return M.id===b})))return[3,14];return[4,pz(p)];case 1:c=r.sent(),r.label=2;case 2:if(r.trys.push([2,13,,14]),pe[p.id])return[3,4];return[4,c.login()];case 3:r.sent(),pe[p.id]=!0,r.label=4;case 4:return[4,c.fetchCalendars()];case 5:if(!(t=r.sent().find(function(M){return M.displayName===e})))return[3,12];return[4,c.createCalendarObject({calendar:t,filename:o+".ics",iCalString:M,headers:c.authHeaders})];case 6:if(!(n=r.sent()).ok)return[3,11];r.label=7;case 7:return r.trys.push([7,9,,10]),[4,c.propfind({url:n.url,props:Mf({},"".concat(J.DAV,":getetag"),{}),depth:"0",headers:c.authHeaders})];case 8:return O=MR.apply(void 0,[r.sent(),1])[0],z.etag=O.props.getetag,z.url=n.url,z.isCaldav=!0,z.id=b,z.calendar_name=e,document.querySelector(".loading-spinner").style.display="none",pt().then(function(M){}),[2,z];case 9:return console.log(r.sent()),[3,10];case 10:return[3,12];case 11:document.querySelector(".loading-spinner").style.display="none",Mj("There was a problem saving, please try again later.",5e3),r.label=12;case 12:return[3,14];case 13:return console.log(r.sent()),[3,14];case 14:return[2]}})}),function(M,b,e,z,o){return P.apply(this,arguments)}),pi=(x=Ml(function(M,b,e,z){var o,p,c,t;return(0,MB.__generator)(this,function(n){switch(n.label){case 0:if(console.log(oP),!navigator.onLine)return[2,!1];if(document.querySelector(".loading-spinner").style.display="block",console.log("hey"+(o=ox.find(function(M){return M.id===e}))),void 0==o)return document.querySelector(".loading-spinner").style.display="none",Mj("There was a problem deleting, please try again later.",5e3),[2,!1];if(!o)return[3,7];return[4,pz(o)];case 1:p=n.sent(),n.label=2;case 2:if(n.trys.push([2,6,,7]),pe[o.id])return[3,4];return[4,p.login()];case 3:n.sent(),pe[o.id]=!0,n.label=4;case 4:return[4,p.deleteCalendarObject({calendarObject:{url:b,etag:M},headers:p.authHeaders})];case 5:if(!n.sent().ok)return oJ(),Mj("There was a problem deleting, please try again later.",5e3),[2,"error"];if(-1!==(c=oP.findIndex(function(M){return M.UID===z}))){if(oP.splice(c,1),pt(),p2(z),pC(),pM(pR,ph),document.querySelector(".loading-spinner").style.display="none",!1==o1.shortCut)return oJ(),[2,"success"];return oG(),[2,"success"]}return[3,7];case 6:return t=n.sent(),oJ(),Mj("There was a problem deleting, please try again later.",5e3),[2,t];case 7:return[2]}})}),function(M,b,e,z){return x.apply(this,arguments)}),pA=(I=Ml(function(M,b,e,z){var o,p,c,t,n;return(0,MB.__generator)(this,function(O){switch(O.label){case 0:if(!navigator.onLine)return[2,!1];if(document.querySelector(".loading-spinner").style.display="block",void 0==(o=ox.find(function(M){return M.id===z})))return document.querySelector(".loading-spinner").style.display="none",Mj("There was a problem saving, please try again later.",5e3),[2,!1];if(!o)return[3,13];return[4,pz(o)];case 1:p=O.sent(),O.label=2;case 2:if(O.trys.push([2,12,,13]),pe[o.id])return[3,4];return[4,p.login()];case 3:O.sent(),pe[o.id]=!0,O.label=4;case 4:return[4,p.updateCalendarObject({calendarObject:{url:b,data:e,etag:M},headers:p.authHeaders})];case 5:if(!(c=O.sent()).ok)return[3,10];document.querySelector(".loading-spinner").style.display="none",O.label=6;case 6:return O.trys.push([6,8,,9]),[4,p.propfind({url:c.url,props:Mf({},"".concat(J.DAV,":getetag"),{}),depth:"0",headers:p.authHeaders})];case 7:return t=MR.apply(void 0,[O.sent(),1])[0],(n={}).etag=t.props.getetag,n.url=c.url,pt(),[2,n];case 8:return console.log(O.sent()),document.querySelector(".loading-spinner").style.display="none",[3,9];case 9:return[3,11];case 10:document.querySelector(".loading-spinner").style.display="none",Mj("There was a problem saving, please try again later.",5e3),O.label=11;case 11:return[3,13];case 12:return O.sent(),document.querySelector(".loading-spinner").style.display="none",Mj("There was a problem saving, please try again later.",5e3),[3,13];case 13:return[2]}})}),function(M,b,e,z){return I.apply(this,arguments)}),pd=function(M,b){var e=new XMLHttpRequest({mozSystem:!0});e.open("GET",M+"?time="+new Date().getTime(),!0),e.timeout=2e3,e.onload=function(){e.status>=200&&e.status<300?b(e.responseText,M):b(Error("Request failed with status "+e.status))},e.onerror=function(){b(Error("XMLHttpRequest error"),null)},e.ontimeout=function(){b(Error("XMLHttpRequest timed out"),null)},e.send()},ps=function(M,b){try{navigator.serviceWorker.controller.postMessage({type:"parse",t:{uid:"",data:M,url:b,etag:""},e:"subscription",callback:!1,store:!1})}catch(M){console.log(M)}},pq=(U=Ml(function(){var M,b,e,z,o,p;return(0,MB.__generator)(this,function(c){M=!0,b=!1,e=void 0;try{for(z=oY[Symbol.iterator]();!(M=(o=z.next()).done);M=!0)p=o.value,pd(p.url,ps)}catch(M){b=!0,e=M}finally{try{M||null==z.return||z.return()}finally{if(b)throw e}}return[2]})}),function(){return U.apply(this,arguments)}),pu=function(M){pp(!1,M).then(function(){})},pl=function(){o1.selected_day_id=document.activeElement.getAttribute("data-id"),Mc=oP.filter(function(M){return M.UID==o1.selected_day_id})[0]};b(Mv).getItem("event_templates").then(function(M){if(null==M)return oI=[],!1;oI=M}).catch(function(M){console.log(M)});var pf=function(M,e,z,o){var p={id:MT(32),title:M,description:e,location:z,category:o};oI.push(p),b(Mv).setItem("event_templates",oI).then(function(M){Mj("template saved",2e3),oJ()}).catch(function(M){console.log(M)})},pW=new Date,ph=pW.getMonth(),pR=pW.getFullYear(),pm=pW.getDate(),pL=function(M){var e=M?b(Mw)().unix():b(Mw)(o1.selected_day).unix();if(0===oP.length)return document.getElementById("events-wrapper").innerHTML="You haven't made any calendar entries yet.",!1;var z=0,o=function(){setTimeout(function(){document.querySelectorAll('div#events-wrapper article[data-id="'+z+'"]')[0].focus();var M=document.activeElement.getBoundingClientRect(),b=M.top-document.body.getBoundingClientRect().top+M.height/2;document.activeElement.parentNode.scrollBy({left:0,top:b-window.innerHeight/2,behavior:"smooth"})},1e3)};try{var p=oP.findIndex(function(M){return M.dateStartUnix===e});z=oP[p-1].UID,o()}catch(M){!function(){try{var M=oP.findIndex(function(M){return M.dateStartUnix=o&&!b.RRULE.freq});if(b.event=e.length>0,b.event_data=e,e.length>1){for(var z=e.sort(function(M,b){return new Date(M.dateStart).getTime()-new Date(b.dateStart).getTime()}),o=1;o=new Date(z[o].dateStart).getTime()){b.multidayevent=!0,b.event_data=e;break}}return b},pv=function(M){var b={date:"",event:!1,subscription:!1,multidayevent:!1,rrule:"none",event_data:""},e=!0,z=!1,o=void 0;try{for(var p,c=oP[Symbol.iterator]();!(e=(p=c.next()).done);e=!0){var t=p.value;if("object"==typeof t){b.event=!1,b.multidayevent=!1,b.rrule=!1,b.date=M,b.event_data="";var n=new Date(t.dateStart).getTime(),O=new Date(t.dateEnd).getTime(),r=new Date(M).getTime(),a=t.RRULE.freq;if(void 0!==t.RRULE&&null!==t.RRULE&&(void 0==t.RRULE.until&&void 0==t.RRULE.count&&(O=new Date("3000-01-01").getTime()),n===r||nr))switch(b.event_data=t,a){case"MONTHLY":if(new Date(t.dateStart).getDate()===new Date(M).getDate())return b.event=!0,b.rrule=!0,b;break;case"WEEKLY":if(new Date(t.dateStart).getDay()===new Date(M).getDay())return b.rrule=!0,b.event=!0,b;break;case"BIWEEKLY":if(Math.floor((r-n)/864e5)%14==0)return b.rrule=!0,b.event=!0,b;break;case"YEARLY":var i=new Date(t.dateStart),A=new Date(M);if(i.getDate()===A.getDate()&&i.getMonth()===A.getMonth())return b.rrule=!0,b.event=!0,b}}}}catch(M){z=!0,o=M}finally{try{e||null==c.return||c.return()}finally{if(z)throw o}}return b},pg=[],pN=0,py=function(){++pN>document.querySelectorAll("div#event-slider article").length-1&&(pN=0);var M=document.querySelectorAll("div#event-slider-indicator div div");document.querySelectorAll("div#event-slider article").forEach(function(M){M.style.display="none"}),document.querySelectorAll("div#event-slider article")[pN].style.display="block",M.forEach(function(M){M.classList.remove("active")}),M[pN].classList.add("active")},pX=function(M){pg=[];var e=document.querySelector("div#event-slider-indicator div");e.innerHTML="",document.querySelector("div#event-slider").innerHTML="";for(var z=0;z=c)&&pg.push(oP[z]);else if(null!=oP[z].RRULE&&void 0==oP[z].RRULE.until&&void 0==oP[z].RRULE.count&&(p=new Date("3000-01-01").getTime()),o===c||p===c||oc){if("YEARLY"==t){var n=new Date(oP[z].dateStart),O=new Date(M);n.getDate()+"-"+n.getMonth()==O.getDate()+"-"+O.getMonth()&&pg.push(oP[z])}"WEEKLY"==t&&new Date(oP[z].dateStart).getDay()==new Date(M).getDay()&&pg.push(oP[z]),"BIWEEKLY"==t&&Math.floor((c-o)/864e5)%14==0&&pg.push(oP[z]),"MONTHLY"==t&&new Date(oP[z].dateStart).getDate()==new Date(M).getDate()&&pg.push(oP[z]),"DAILY"==t&&(o===c||p===c||oc)&&pg.push(oP[z])}}if(pg.length>=0&&(pg.forEach(function(M){e.insertAdjacentHTML("beforeend","
");var z="";M.allDay||(z=b(Mw).unix(M.dateStartUnix).format("HH:mm")),document.querySelector("div#event-slider").insertAdjacentHTML("beforeend","
"+M.SUMMARY+"
"+z+"
")}),pg.length>0))try{document.querySelectorAll("div#event-slider article")[0].style.display="block"}catch(M){console.log(M)}document.querySelectorAll("div.indicator").length<=1||void 0==document.querySelectorAll("div.indicator").length?document.getElementById("event-slider-indicator").style.opacity=0:(document.getElementById("event-slider-indicator").style.opacity=1,document.querySelector("div#event-slider article").style.display="block",document.querySelectorAll("div#event-slider .indicator")[0].style.classList.add("active"))},pT=function(){ph=pW.getMonth(),pR=pW.getFullYear(),pk(ph,pR),setTimeout(function(){o1.selected_day=b(Mw)().format("YYYY-MM-DD"),pX(o1.selected_day)},1e3)},pw=function(){if("/page_calendar"!=b(M3).route.get())return!1;setTimeout(function(){document.querySelectorAll("div#calendar div.calendar-head div").forEach(function(M){M.classList.remove("active")}),document.querySelectorAll("span.weeknumber").forEach(function(M){M.classList.remove("active")});var M=new Date(document.activeElement.getAttribute("data-date")).getDay();document.activeElement.closest("div.row").querySelector("span.weeknumber").classList.add("active"),"monday"==o2.firstday&&-1==(M-=1)&&(M=6),document.querySelectorAll("div#calendar div.calendar-head div")[M].classList.add("active")},200)};Date.prototype.getWeek=function(){var M=new Date(this.getTime());M.setHours(0,0,0,0),M.setDate(M.getDate()+3-(M.getDay()+6)%7);var b=new Date(M.getFullYear(),0,4);return 1+Math.round(((M.getTime()-b.getTime())/864e5-3+(b.getDay()+6)%7)/7)};var pk=function(M,b){document.getElementById("monthAndYear").textContent=oZ[M]+" "+b;var e=new Date(b,M).getDay();"monday"==o2.firstday&&(0==e?e=6:e-=1);var z=32-new Date(b,M,32).getDate(),o=document.getElementById("calendar-body");o.innerHTML="";for(var p=1,c=0;c<6;c++)!function(c){var t=document.createElement("div");t.classList.add("flex"),t.classList.add("row"),t.setAttribute("data-weeknumber",c),t.classList.add("width-100");for(var n=0;n<7;n++)if(0===c&&nz)break;else{var a=document.createElement("div"),i=document.createElement("span"),A=document.createElement("div"),d=document.createTextNode(p);a.appendChild(d),a.appendChild(i),a.setAttribute("tabindex",p-1),a.classList.add("calendar-cell");var s=b+"-"+"0".concat(M+1).slice(-2)+"-"+"0".concat(p).slice(-2);A.classList.add("moon-phase-"+function(M,b,e){var z,o,p,c=p=o=z=0;return b<3&&(M--,b+=12),++b,z=parseInt(o=((c=365.25*M)+(p=30.6*b)+e-694039.09)/29.5305882),o-=z,(z=Math.round(8*o))>=8&&(z=0),z}(b,M,p)),a.appendChild(A),a.setAttribute("data-date",s),a.classList.add("item"),t.appendChild(a),p++}var q=document.createElement("span");q.classList.add("weeknumber");var u=document.createTextNode("monday"==o2.firstday?new Date(b,M,p-1).getWeek():new Date(b,M,p).getWeek());q.appendChild(u),t.appendChild(q),o.appendChild(t)}(c);document.querySelectorAll(".item")[0].focus(),o1.selected_day=document.activeElement.getAttribute("data-date"),pW.getMonth()==M&&pW.getFullYear()==b&&(document.querySelectorAll(".item")[pm-1].focus(),document.querySelectorAll(".item")[pm-1].classList.add("today")),pw(),pM(pR,ph)},pC=function(){document.querySelectorAll("div#add-edit-event input").forEach(function(M){M.value=""})},pE=function(M){var b=M.toUpperCase();if(b.length<1)return!1;document.querySelectorAll("#events-wrapper article").forEach(function(M){M.getAttribute("data-summary").indexOf(b)>=0||M.getAttribute("data-category").indexOf(b)>=0?M.style.display="block":M.style.display="none"}),cM()},p_=function(M){var b=M.toUpperCase();document.querySelectorAll("#events-wrapper article").forEach(function(M){M.getAttribute("data-category").indexOf(b)>=0?M.style.display="block":M.style.display="none"}),cM(),document.getElementById("search").focus()},pS=function(){if(null==document.querySelectorAll(".select-box"))return!1;document.querySelectorAll(".select-box").forEach(function(M){M.addEventListener("blur",function(b){setTimeout(function(){M.parentElement.focus()},200)})})},pD=document.getElementById("app"),pP="",px=null,pI=function(M){document.getElementById(px).value=M},pU=[],pj=function(M){pU.push(M)},pF=function(M){try{"serviceWorker"in navigator&&navigator.serviceWorker.controller&&(collectionOfData={data:M,etag:"",url:""},navigator.serviceWorker.controller.postMessage({type:"parse",t:collectionOfData,e:"local-id",callback:!0,store:!0}))}catch(M){alert("event could not be imported because the file content is invalid"+M)}};!1==o1.background_sync_running&&(b(M3).route(pD,"/page_calendar",{"/page_calendar":{view:function(){return b(M3)("div",{class:"width-100 height-100",id:"calendar",oninit:function(){oQ(),o9(),pC(),MJ(),document.querySelector("#version").textContent=localStorage.getItem("version")}},[b(M3)("div",{class:"flex justify-content-spacebetween",id:""},[b(M3)("h3",{class:"card-header",id:"monthAndYear"},""),b(M3)("img",{id:"icon-loading",src:"./assets/image/E252.svg",alt:"loading"}),b(M3)("img",{id:"icon-waiting",src:"./assets/image/waiting.png",alt:"loading"}),b(M3)("div",{id:"time",oncreate:function(){document.getElementById("time").innerText=b(Mw)().format("HH:mm")}},o1.version)]),b(M3)("div",{class:"calendar-head flex width-100"},[b(M3)("div",o0[0]),b(M3)("div",o0[1]),b(M3)("div",o0[2]),b(M3)("div",o0[3]),b(M3)("div",o0[4]),b(M3)("div",o0[5]),b(M3)("div",o0[6])]),b(M3)("div",{id:"calendar-body"}),b(M3)("div",{id:"event-slider-indicator",class:"flex width-100 justify-content-spacearound"},[b(M3)("div",{class:"flex justify-content-spacearound"})]),b(M3)("div",{id:"event-slider",class:"flex "},[b(M3)("div",{id:"slider-inner",class:"flex width-100 justify-content-spacearound"})])])},onbeforeremove:function(){o1.selected_day=document.activeElement.getAttribute("data-date")},oncreate:function(){setTimeout(function(){document.activeElement.hasAttribute("data-date")&&(o1.selected_day=document.activeElement.getAttribute("data-date")),MY("","","");var M=new Date(o1.selected_day);ph=M.getMonth(),pR=M.getFullYear(),pk(ph,pR),document.querySelectorAll("div#calendar-body div.item").forEach(function(M){if(M.getAttribute("data-date")==o1.selected_day){M.focus(),pX(o1.selected_day);return}}),!1==o1.startup&&(pX(o1.selected_day),pT(),o1.startup=!0)},200)}},"/page_events":{view:function(){return b(M3)("div",{class:"flex",id:"events-wrapper",oninit:function(){document.querySelector(".loading-spinner").style.display="block",oQ(),o1.shortCut=!1},onremove:function(){o1.selected_day=document.activeElement.getAttribute("data-date"),o1.selected_day_id=document.activeElement.getAttribute("data-id")},oncreate:function(){document.querySelector(".loading-spinner").style.display="none",pL(),MY("","","")}},b(M3)("input",{type:"search",class:"width-98 item",id:"search",tabIndex:0,onfocus:function(){window.scroll({top:20,left:0,behavior:"smooth"})},oninput:function(){pE(document.activeElement.value)}}),b(M3)("div",{id:"filter-menu",class:"flex justify-content-spacearound",oncreate:function(M){M.dom.style.display="none"},onfocus:function(){window.scroll({top:20,left:0,behavior:"smooth"})}},[b(M3)("button",{class:"item",tabindex:0,"data-action":"filter-last-modified",oncreate:function(M){M.dom.style.display="none"}},"last edited"),b(M3)("button",{class:"item",tabindex:0,"data-action":"filter-desc",oncreate:function(M){M.dom.style.display="none"}},"the latest"),b(M3)("button",{class:"item",tabindex:0,"data-action":"filter-asc",oncreate:function(M){M.dom.style.display="none"}},"the oldest"),b(M3)("button",{class:"item category-filter-button",tabindex:0,"data-action":"filter-category",oncreate:function(M){M.dom.style.display="none",void 0!==o2.eventsfilter&&(document.querySelector(".category-filter-button").style.display="flex")}},"show only category: "+o2.eventsfilter)]),[oP.map(function(M,e){var z,o="";o=M.allDay?"all day":b(Mw)(1e3*M.dateStartUnix).format("HH:mm");var p="sunday"==o2.firstday?o0[b(Mw)(1e3*M.dateStartUnix).day()]:o0[b(Mw)(1e3*M.dateStartUnix).day()-1];void 0==p&&(p=""),z=null==M.dateStartUnix||null==M.dateEndUnix||b(Mw)(1e3*M.dateStartUnix).format(o2.dateformat)==b(Mw)(1e3*M.dateEndUnix).format(o2.dateformat)||M.allDay?b(Mw)(1e3*M.dateStartUnix).format(o2.dateformat)+" | "+p:b(Mw)(1e3*M.dateStartUnix).format(o2.dateformat)+" - "+b(Mw)(1e3*M.dateEndUnix).format(o2.dateformat);var c="";M.RRULE&&M.RRULE.freq&&(c=M.RRULE.freq.toLowerCase());var t=M.isSubscription?"subscription":"",n=M.allDay?"allDay":"";return b(M3)("article",{class:"item events "+t+" "+n,tabindex:0,"data-id":M.UID,"data-date":b(Mw)(1e3*M.dateStartUnix).format("YYYY-MM-DD"),"data-category":(M.CATEGORIES||"").toUpperCase(),"data-summary":(M.SUMMARY||"").toUpperCase(),"data-calendar-name":M.calendar_name||""},[b(M3)("div",{class:"icons-bar"},[b(M3)("div",{class:"date"},z),b(M3)("div",{class:"time"},o),b(M3)("div",{class:"rrule-freq"},c),b(M3)("h2",{class:"summary"},M.SUMMARY),b(M3)("div",{class:"location"},M.LOCATION),b(M3)("div",{class:"description"},M.DESCRIPTION)])])})])}},"/page_options":{view:function(){return b(M3)("div",{id:"options",oninit:function(){oQ(),o1.shortCut=!1},oncreate:function(){o1.notKaiOS||oE(),MY("","","")}},[b(M3)("h2",{class:"item",tabIndex:0},"Key assignment"),b(M3)("ul",{id:"keys",class:"item width-100",tabindex:"1",oncreate:function(M){var b=M.dom;MY("","",""),document.querySelectorAll(".select-box").forEach(function(M){M.addEventListener("keypress",function(){setTimeout(function(){M.parentElement.focus()},200)})}),b.focus()}},[b(M3)("li",{class:"flex justify-content-spacebetween"},[b(M3)("kbd","1 & 3"),b(M3)("div","Month")]),b(M3)("li",{class:"flex justify-content-spacebetween"},[b(M3)("kbd","2"),b(M3)("div","Event slider")]),b(M3)("li",{class:"width-100 flex justify-content-spacebetween"},[b(M3)("kbd","5"),b(M3)("div","Edit event")]),b(M3)("li",{class:"width-100 flex justify-content-spacebetween"},[b(M3)("kbd","Enter"),b(M3)("div","Events/Month")]),b(M3)("li",{class:"width-100 flex justify-content-spacebetween"},[b(M3)("kbd","0"),b(M3)("div","Events filtered by category")]),b(M3)("li",{class:"width-100 flex justify-content-spacebetween"},[b(M3)("kbd","#"),b(M3)("div","Moon")]),b(M3)("li",{class:"width-100 flex justify-content-spacebetween"},[b(M3)("kbd","*"),b(M3)("div","Today")]),b(M3)("li",{class:"width-100 flex justify-content-spacebetween"},[b(M3)("kbd","SoftLeft longpress"),b(M3)("div",{},"create event from template")]),b(M3)("li",{class:"width-100 flex justify-content-spacebetween"},[b(M3)("span",{class:"keys-day-event"}),b(M3)("span","day with event")]),b(M3)("li",{class:"width-100 flex justify-content-spacebetween"},[b(M3)("span",{class:"keys-day-multi-event"}),b(M3)("span","day with several events")]),b(M3)("li",{class:"width-100 flex justify-content-spacebetween"},[b(M3)("span",{class:"keys-day-rrule-event"}),b(M3)("span","day with reccurence")])]),b(M3)("h2",{class:"item",tabindex:"2"},"Settings"),b(M3)("div",{class:"text-center"},"Timezone: "+o2.timezone),b(M3)("div",{class:"item input-parent",id:"event-date-format-box",tabindex:"3"},[b(M3)("label",{for:"event-date-format"},"dateformat"),b(M3)("select",{id:"event-date-format",class:"select-box",onchange:function(){pY()},oncreate:function(){o9(),setTimeout(function(){pS(),""==o2.dateformat?document.querySelector("#event-date-format").value="YYYY-MM-DD":document.querySelector("#event-date-format").value=o2.dateformat},1e3)}},[b(M3)("option",{value:"YYYY-MM-DD"},"YYYY-MM-DD"),b(M3)("option",{value:"DD.MM.YYYY"},"DD.MM.YYYY")])]),b(M3)("div",{class:"item input-parent",id:"background-sync-box",tabindex:"3"},[b(M3)("label",{for:"background-syn-box"},"Background sync ?"),b(M3)("select",{id:"background-sync",class:"select-box",onchange:function(){pY()},oncreate:function(){"b2g"in navigator&&(document.getElementById("background-sync-box").style.display="none"),o9(),setTimeout(function(){pS(),"No"==o2.background_sync?document.querySelector("#background-sync").value="No":document.querySelector("#background-sync").value="Yes"},1e3)}},[b(M3)("option",{value:"Yes"},"Yes"),b(M3)("option",{value:"No"},"No")]),b(M3)("div",{class:"last-sync-info"},"last sync: "+oF)]),b(M3)("div",{class:"item input-parent",id:"firs-day-of-the-week-box",tabindex:"4"},[b(M3)("label",{for:"first-day-of-the-week"},"first day of the week"),b(M3)("select",{id:"first-day-of-the-week",class:"select-box",onchange:function(){pY()},oncreate:function(){setTimeout(function(){pS(),""==o2.firstday||void 0==o2.firstday?document.querySelector("#first-day-of-the-week").value="sunday":document.querySelector("#first-day-of-the-week").value=o2.firstday},1e3)}},[b(M3)("option",{value:"sunday"},"Sunday"),b(M3)("option",{value:"monday"},"Monday")])]),b(M3)("div",{class:"item input-parent",id:"event-duration-wrapper",tabindex:"5"},[b(M3)("label",{for:"default-duration-time"},"default Duration"),b(M3)("select",{id:"default-duration-time",class:"select-box",onchange:function(){pY()},oncreate:function(){o9(),setTimeout(function(){pS(),document.querySelector("#default-duration-time").value=o2.default_duration},1e3)}},[b(M3)("option",{value:"30"},"30 minutes"),b(M3)("option",{value:"60"},"60 minutes"),b(M3)("option",{value:"120"},"120 minutes"),b(M3)("option",{value:"240"},"240 minutes")])]),b(M3)("div",{class:"item input-parent",id:"event-notification-time-wrapper",tabindex:"5"},[b(M3)("label",{for:"default-notification"},"default Notification"),b(M3)("select",{id:"default-notification-time",class:"select-box",onchange:function(){pY()},oncreate:function(){o9(),setTimeout(function(){pS(),""==o2.default_notification?document.querySelector("#default-notification-time").value="none":document.querySelector("#default-notification-time").value=o2.default_notification},1e3)}},[b(M3)("option",{value:"none"},"none"),b(M3)("option",{value:"5"},"5 minutes"),b(M3)("option",{value:"10"},"10 minutes"),b(M3)("option",{value:"30"},"30 minutes"),b(M3)("option",{value:"1440"},"1 Day")])]),b(M3)("button",{class:"item",tabindex:"6",oncreate:function(){pU=[],MV("ics",pj)},onclick:function(){b(M3).route.set("/page_list_files")}},"Import events"),b(M3)("button",{class:"item",tabindex:"7",onclick:function(){setTimeout(function(){pp(!0,!1)},1e3),Mj("the big loading has begun",2e3)}},"Reload all events"),b(M3)("h2","Subscriptions"),b(M3)("button",{class:"item",tabindex:"8",onclick:function(){b(M3).route.set("/page_subscriptions")}},"add subscription"),b(M3)("div",{id:"subscription-text"},"Your subscriptions"),null!=oY?oY.map(function(M,e){return b(M3)("button",{class:"item subscriptions-item","data-id":M.id,"data-action":"delete-subscription",tabindex:e+8,onfocus:function(){MY("","","")},onblur:function(){MY("","","")}},M.name)}):b(M3)("div",{class:"text-center"},"No subscriptions available"),b(M3)("h2","Category view"),b(M3)("div",{class:"item input-parent",id:"events-category-filter-wrapper",tabindex:""},[b(M3)("label",{for:"events-category-filter"},"Select the category"),b(M3)("select",{id:"events-category-filter",class:"select-box",onchange:function(){pY()},oncreate:function(){setTimeout(function(){pS(),document.querySelector("#events-category-filter").value=o2.eventsfilter},1e3)}},oP.length>0?[b(M3)("option",{value:"-"},"-")].concat(Mm(oP.map(function(M){return M.CATEGORIES}).filter(function(M,b,e){return""!==M&&e.indexOf(M)===b}).map(function(M){return b(M3)("option",{value:M},M)}))):[b(M3)("option",{value:"-"},"No categories available")])]),b(M3)("h2","Calendars"),null!=Mp?Mp.map(function(M){return b(M3)("button",{class:"item","data-calendar-name":M.name,oncreate:function(b){var e=b.dom;!1==M.view&&e.classList.add("active"),"local"==M.name&&(e.style.display="none")},onclick:function(){Mp.forEach(function(M){M.name==document.activeElement.getAttribute("data-calendar-name")&&(M.view=!M.view)}),document.activeElement.classList.toggle("active"),b(Mv).setItem("calendarNames",Mp).then(function(){o5(),Mj("will be applied the next time the app is started",2e3)})}},M.name)}):"",,b(M3)("h2","Accounts"),b(M3)("button",{class:"item google-button caldav-button",onclick:function(){b(M3).route.set("/page_accounts")}},[b(M3)("div",{class:"flex align-item-center justify-content-spacebetween "},[b(M3)("img",{src:"assets/image/caldav.png"}),b(M3)("span","CalDAV Account")])]),b(M3)("button",{class:"item google-button",onclick:function(){o$=setInterval(function(){"true"==localStorage.getItem("oauth_callback")&&(b(M3).route.set("/page_calendar"),clearInterval(o$),setTimeout(function(){ox=[],b(Mv).getItem("accounts").then(function(M){if(null==M)return ox=[],!1;ox=M,pp(!1,!1)}).catch(function(M){console.log(M)})},5e3))},1e3),window.open("https://accounts.google.com/o/oauth2/v2/auth?client_id=762086220505-f0kij4nt279nqn21ukokm06j0jge2ngl.apps.googleusercontent.com&response_type=code&state=state_parameter_passthrough_value&scope=https://www.googleapis.com/auth/calendar&redirect_uri=https://greg.strukturart.com/index.html&access_type=offline&prompt=consent")}},[b(M3)("div",{class:"flex justify-content-spacebetween align-item-center "},[b(M3)("img",{src:"assets/image/google_button.png"}),b(M3)("span","Sign in with Google")])]),null!=ox?b(M3)("div",{id:"subscription-text"},"Your accounts"):"",null!=ox?ox.map(function(M){return b(M3)("button",{class:"item subscriptions-item","data-id":M.id,"data-account-type":M.type,"data-action":"edit-delete-account",onblur:function(){MY("","","")},onfocus:function(){"oauth"==M.type?MY("","",""):MY("","","")}},M.name)}):"",b(M3)("h2",{class:"ads-title"},"Ads"),b(M3)("div",{id:"KaiOsAds-Wrapper",class:"flex justify-content-spacearound",oninit:function(){o2.ads||document.querySelector("h2.ads-title").remove()},oncreate:function(){},onfocus:function(){MY("","open ads","")},onblur:function(){MY("","open ads","")}})])}},"/page_add_event":{view:function(){return b(M3)("div",{id:"add-edit-event",tabindex:"0",oninit:function(){oQ(),o1.shortCut=!1}},[b(M3)("div",{class:"item input-parent",tabindex:0,oncreate:function(M){var b=M.dom;setTimeout(function(){b.focus(),MY("","","")},500)}},[b(M3)("label",{for:"event-title"},"Title"),b(M3)("input",{placeholder:"",type:"text",id:"event-title",oncreate:function(){o9(),pZ()},onfocus:function(){px="event-title",MY("","","")},onblur:function(){px="event-title",MY("","","")}})]),b(M3)("div",{class:"item input-parent",tabindex:"1"},[b(M3)("label",{for:"event-location"},"Location"),b(M3)("input",{placeholder:"",type:"text",id:"event-location",oninput:function(M){Mk(M.target.value,"LOCATION")}})]),b(M3)("div",{id:"search-result"}),b(M3)("div",{class:"item input-parent",tabindex:"2",onfocus:function(){Mk("close")}},[b(M3)("label",{for:"event-date"},"Start Date"),b(M3)("input",{placeholder:o2.dateformat,type:"date",id:"event-date",class:"select-box",oncreate:function(M){M.dom.value=o1.selected_day}})]),b(M3)("div",{class:"item input-parent",tabindex:"3"},[b(M3)("label",{for:"event-date-end"},"End Date"),b(M3)("input",{placeholder:o2.dateformat,type:"date",id:"event-date-end",class:"select-box",oncreate:function(M){M.dom.min=o1.selected_day}})]),b(M3)("div",{class:"item input-parent flex justify-content-center",tabindex:"4"},[b(M3)("label",{for:"event-all-day"},"All Day"),b(M3)("input",{type:"checkbox",id:"event-all-day",class:"check-box",onfocus:function(M){!1==M.target.checked?(setTimeout(function(){document.querySelector(".check-box").parentElement.focus()},300),document.querySelectorAll(".time").forEach(function(M){document.querySelector("#event-time-start").value="01:00",document.querySelector("#event-time-end").value="01:00",M.style.display="none",M.classList.remove("item"),cM()})):(setTimeout(function(){document.querySelector(".check-box").parentElement.focus()},300),document.querySelectorAll(".time").forEach(function(M){M.style.display="block",M.classList.add("item"),cM()}))}}),b(M3)("div",{class:"ckb-wrapper"},[b(M3)("div",{class:"ckb-icon"}),b(M3)("div",{class:"toogle-button"})])]),b(M3)("div",{class:"item input-parent time",tabindex:"4"},[b(M3)("label",{for:"event-time-start"},"Start Time"),b(M3)("input",{placeholder:"hh:mm",type:"time",id:"event-time-start",class:"select-box",oncreate:function(M){M.dom.value=b(Mw)().format("HH:mm")}})]),b(M3)("div",{class:"item input-parent time",tabindex:"5"},[b(M3)("label",{for:"event-time-end"},"End Time"),b(M3)("input",{placeholder:"hh:mm",type:"time",id:"event-time-end",class:"select-box",onblur:function(M){var e=document.querySelector("#event-date").value,z=""!=document.querySelector("#event-date-end").value?document.querySelector("#event-date-end").value:document.querySelector("#event-date").value,o=b(Mw)(e+" "+document.querySelector("#event-time-start").value);!1==b(Mw)(z+" "+M.target.value).isAfter(o)&&Mj("something is wrong with the time",2e3)},oncreate:function(M){var e=M.dom;console.log(o2.default_duration),e.value=b(Mw)().add(o2.default_duration,"minutes").format("HH:mm")}})]),b(M3)("div",{class:"item input-parent",tabindex:"6"},[b(M3)("label",{for:"event-description"},"Description"),b(M3)("input",{placeholder:"",type:"text",id:"event-description"})]),b(M3)("div",{class:"item input-parent",tabindex:"6"},[b(M3)("label",{for:"event-category"},"Category"),b(M3)("input",{placeholder:"",type:"text",id:"event-category"})]),b(M3)("div",{class:"item input-parent",id:"event-notification-time-wrapper",tabindex:"7"},[b(M3)("label",{for:"notification"},"Notification"),b(M3)("select",{id:"event-notification-time",class:"select-box",oncreate:function(){setTimeout(function(){document.querySelector("#event-notification-time").value=o2.default_notification},2e3)}},[b(M3)("option",{value:"none"},"none"),b(M3)("option",{value:"5"},"5 minutes"),b(M3)("option",{value:"10"},"10 minutes"),b(M3)("option",{value:"30"},"30 minutes"),b(M3)("option",{value:"60"},"60 minutes"),b(M3)("option",{value:"1440"},"1 Day")])]),b(M3)("div",{class:"item input-parent",id:"event-recur-wrapper",tabindex:"8",oncreate:function(){setTimeout(function(){document.querySelector("#event-recur").value="none"},1e3)}},[b(M3)("label",{for:"event-recur"},"Recur"),b(M3)("select",{id:"event-recur",class:"select-box"},[b(M3)("option",{value:"none"},"none"),b(M3)("option",{value:"DAILY"},"Daily"),b(M3)("option",{value:"WEEKLY"},"Weekly"),b(M3)("option",{value:"BIWEEKLY"},"Biweekly"),b(M3)("option",{value:"MONTHLY"},"Monthly"),b(M3)("option",{value:"YEARLY"},"Yearly")])]),b(M3)("div",{class:"item input-parent",id:"event-calendar-wrapper",tabindex:"9"},[b(M3)("label",{for:"event-calendar"},"Calendars"),b(M3)("select",{id:"event-calendar",class:"select-box"},[Mp.map(function(M){return b(M3)("option",{value:M.id,"data-calendar-data":M.data},M.name)})])]),b(M3)("button",{tabindex:"10",id:"save-event",class:"item save-button",oncreate:function(){pS(),cM()},onclick:function(){var M=document.getElementById("event-calendar");p8(M.options[M.selectedIndex].value,M.options[M.selectedIndex].text)}},"save")])},oncreate:function(){MY("","","")}},"/page_edit_event":{view:function(){var M;return b(M3)("div",{id:"add-edit-event",oninit:function(){},omcreate:function(){oQ(),o1.shortCut=!1}},[b(M3)("div",{class:"item input-parent",tabindex:0,oncreate:function(M){var b=M.dom;setTimeout(function(){b.focus(),MY("","","")},500)}},[b(M3)("label",{for:"event-title"},"Title"),b(M3)("input",{placeholder:"",type:"text",id:"event-title",value:Mc.SUMMARY})]),b(M3)("div",{class:"item input-parent",tabindex:"1"},[b(M3)("label",{for:"event-location"},"Location"),b(M3)("input",{placeholder:"",type:"text",id:"event-location",value:Mc.LOCATION})]),b(M3)("div",{class:"item input-parent",tabindex:"2"},[b(M3)("label",{for:"event-date"},"Start Date"),b(M3)("input",{placeholder:o2.dateformat,type:"date",id:"event-date",class:"select-box",oncreate:function(M){M.dom.value=Mc.dateStart}})]),b(M3)("div",{class:"item input-parent",tabindex:"3"},[b(M3)("label",{for:"event-date-end"},"End Date"),b(M3)("input",{placeholder:o2.dateformat,type:"date",id:"event-date-end",class:"select-box",oncreate:function(M){M.dom.value=Mc.dateEnd}})]),b(M3)("div",{class:"item input-parent",tabindex:"4"},[b(M3)("label",{for:"event-all-day"},"All Day"),b(M3)("input",{type:"checkbox",id:"event-all-day",class:"check-box",oncreate:function(){!0==Mc.allDay&&(document.querySelector("#event-all-day").checked=!0,document.querySelectorAll(".time").forEach(function(M){M.style.display="none",M.classList.remove("item"),cM()}))},onfocus:function(M){!1==M.target.checked?(setTimeout(function(){M.focus()},300),document.querySelectorAll(".time").forEach(function(M){M.style.display="none",M.classList.remove("item"),document.querySelector("#event-time-start").value="01:00",document.querySelector("#event-time-end").value="01:00",cM()})):(setTimeout(function(){M.focus()},300),document.querySelectorAll(".time").forEach(function(M){M.style.display="block",M.classList.add("item"),cM()}))}}),b(M3)("div",{class:"ckb-wrapper"},[b(M3)("div",{class:"ckb-icon"}),b(M3)("div",{class:"toogle-button"})])]),b(M3)("div",{class:"item input-parent time",tabindex:"4"},[b(M3)("label",{for:"event-time-start"},"Start Time"),b(M3)("input",{placeholder:"HH:mm",type:"time",id:"event-time-start",class:"select-box",value:8==Mc.time_start.length?Mc.time_start.slice(0,-3):Mc.time_start})]),b(M3)("div",{class:"item input-parent time",tabindex:"5"},[b(M3)("label",{for:"event-time-end"},"End Time"),b(M3)("input",{placeholder:"hh:mm",type:"time",id:"event-time-end",class:"select-box",value:8==Mc.time_end.length?Mc.time_end.slice(0,-3):Mc.time_end})]),b(M3)("div",{class:"item input-parent",tabindex:"6"},[b(M3)("label",{for:"event-description"},"Description"),b(M3)("input",{placeholder:"",type:"text",id:"event-description",value:Mc.DESCRIPTION})]),b(M3)("div",{class:"item input-parent",tabindex:"6"},[b(M3)("label",{for:"event-category"},"Category"),b(M3)("input",{placeholder:"",type:"text",id:"event-category",value:Mc.CATEGORIES})]),b(M3)("div",{class:"item input-parent",id:"event-notification-time-wrapper",tabindex:"7"},[b(M3)("label",{for:"notification"},"Notification"),b(M3)("select",{id:"event-notification-time",class:"select-box"},[b(M3)("option",{value:"none"},"none"),b(M3)("option",{value:"5"},"5 minutes"),b(M3)("option",{value:"10"},"10 minutes"),b(M3)("option",{value:"30"},"30 minutes"),b(M3)("option",{value:"60"},"60 minutes"),b(M3)("option",{value:"1440"},"1 Day")])]),b(M3)("div",{class:"item input-parent",id:"event-calendar-wrapper",tabindex:"9"},[b(M3)("label",{for:"event-calendar"},"Calendars"),b(M3)("select",{id:"event-calendar",class:"select-box",onchange:function(){o1.event_calendar_changed=!0}},[Mp.map(function(M){var e="";return Mc.calendar_name==M.name&&(e="selected"),b(M3)("option",{value:M.id,selected:e,"data-calendar-data":M.data},M.name)})])]),b(M3)("div",{class:"item input-parent",id:"event-recur-wrapper",tabindex:"8",oncreate:function(){document.querySelector("#event-notification-time").value=Mc.alarm}},[b(M3)("label",{for:"event-recur"},"Recur"),b(M3)("select",{id:"event-recur",value:null!==(M=Mc.RRULE.freq)&&void 0!==M?M:"none",class:"select-box"},[b(M3)("option",{value:"none"},"none"),b(M3)("option",{value:"DAILY"},"Daily"),b(M3)("option",{value:"WEEKLY"},"Weekly"),b(M3)("option",{value:"BIWEEKLY"},"Biweekly"),b(M3)("option",{value:"MONTHLY"},"Monthly"),b(M3)("option",{value:"YEARLY"},"Yearly")])]),b(M3)("button",{tabindex:"9",id:"delete-event",class:"item",onclick:function(){p9(Mc.etag,Mc.url,Mc.id,Mc.UID)}},"delete"),b(M3)("button",{tabindex:"10",id:"save-event",class:"item save-button",oncreate:function(){pS()},onclick:function(){if(o1.event_calendar_changed||p7(Mc.etag,Mc.url,Mc.id,Mc.UID,Mc.calendar_name),o1.event_calendar_changed){var M=document.getElementById("event-calendar");p9(Mc.etag,Mc.url,Mc.id,Mc.UID),p8(M.options[M.selectedIndex].value,M.options[M.selectedIndex].text)}}},"update"),b(M3)("button",{tabindex:"11",id:"save-event-as-template",class:"item save-template-button",oncreate:function(){pS()},onclick:function(){pf(document.getElementById("event-title").value,document.getElementById("event-description").value,document.getElementById("event-location").value,document.getElementById("event-category").value)}},"save as template")])}},"/page_subscriptions":{view:function(){return b(M3)("div",{id:"subscription-form"},[b(M3)("div",{class:"item input-parent",tabindex:"0",oninit:function(){MY("","",""),oQ(),o1.shortCut=!1},oncreate:function(M){M.dom.focus()}},[b(M3)("label",{for:"description"},"subscription name"),b(M3)("input",{placeholder:"Name",type:"text",id:"cal-subs-name"})]),b(M3)("div",{class:"item input-parent",tabindex:"1",onblur:function(){MY("","","")}},[b(M3)("label",{for:"description"},"subscription url"),b(M3)("input",{placeholder:"URL",type:"text",id:"cal-subs-url","data-scan-action":"true",onfocus:function(){MY("","","")},oncreate:function(){setTimeout(function(){document.getElementById("cal-subs-url").value=pP},1e3)},onblur:function(){MY("","","")}})]),b(M3)("button",{class:"item save-button",tabindex:"2",onclick:function(){pV()}},"save")])}},"/page_accounts":{view:function(){return b(M3)("div",{id:"account-form"},[b(M3)("div",{class:"item input-parent",tabindex:"0",oninit:function(){oQ()},oncreate:function(M){M.dom.focus()}},[b(M3)("label",{for:"description"},"account name"),b(M3)("input",{placeholder:"Name",type:"text",id:"account-name"})]),b(M3)("div",{class:"item input-parent",tabindex:"1",onblur:function(){MY("","","")}},[b(M3)("label",{for:"description"},"server"),b(M3)("input",{placeholder:"URL",type:"text",id:"account-url","data-scan-action":"true",onfocus:function(){MY("","","")},onblur:function(){MY("","","")}})]),b(M3)("div",{class:"item input-parent",tabindex:"2",onblur:function(){MY("","","")}},[b(M3)("label",{for:"description"},"username"),b(M3)("input",{placeholder:"username",type:"url",id:"account-username","data-scan-action":"true",onfocus:function(){MY("","","")},onblur:function(){MY("","","")}})]),b(M3)("div",{class:"item input-parent",tabindex:"3",onblur:function(){MY("","","")}},[b(M3)("label",{for:"description"},"password"),b(M3)("input",{placeholder:"password",type:"password",id:"account-password","data-scan-action":"true",onfocus:function(){MY("","","")},onblur:function(){MY("","","")}})]),b(M3)("button",{class:"item save-button",tabindex:"4",onclick:function(){pG()}},"save")])}},"/page_edit_account":{view:function(){return b(M3)("div",{id:"account-form"},[b(M3)("div",{class:"item input-parent",tabindex:"0",oninit:function(){},oncreate:function(M){M.dom.focus(),oQ(),o1.shortCut=!1}},[b(M3)("label",{for:"description"},"account name"),b(M3)("input",{placeholder:"Name",type:"text",id:"account-name",value:Mt.name})]),b(M3)("div",{class:"item input-parent",tabindex:"1",onblur:function(){MY("","","")}},[b(M3)("label",{for:"description"},"server"),b(M3)("input",{placeholder:"URL",type:"text",id:"account-url","data-scan-action":"true",value:Mt.server_url,onfocus:function(){MY("","","")},onblur:function(){MY("","","")}})]),b(M3)("div",{class:"item input-parent",tabindex:"2",onblur:function(){MY("","","")}},[b(M3)("label",{for:"description"},"username"),b(M3)("input",{placeholder:"username",type:"url",id:"account-username",value:Mt.user,"data-scan-action":"true",onfocus:function(){MY("","","")},onblur:function(){MY("","","")}})]),b(M3)("div",{class:"item input-parent",tabindex:"3",onblur:function(){MY("","","")}},[b(M3)("label",{for:"description"},"password"),b(M3)("input",{placeholder:"password",type:"password",id:"account-password","data-scan-action":"true",value:Mt.password,onfocus:function(){MY("","","")},onblur:function(){MY("","","")}})]),b(M3)("button",{class:"item save-button",tabindex:"4",onclick:function(){pG(!0,o1.edit_account_id)}},"update")])}},"/page_event_templates":{view:function(){return b(M3)("div",{id:"options",oninit:function(){oQ()},oncreate:function(){MY("","","")}},[b(M3)("h2",{class:"text-center"},"Templates"),oI.map(function(M,e){return b(M3)("button",{class:"item",onclick:function(){Mn=M.id,b(M3).route.set("/page_add_event")},oncreate:function(M){M.dom},tabIndex:e,"data-id":M.id},M.title)})])}},"/page_list_files":{view:function(){return b(M3)("div",{id:"options",oninit:function(){oQ()}},[b(M3)("h2",{class:"text-center",id:"file-head"},"files"),pU.map(function(M,e){var z=M.split("/");return z=z[z.length-1],b(M3)("button",{class:"item",oncreate:function(M){var b=M.dom;0==e&&b.focus()},tabIndex:e,onclick:function(){!function(M,b){try{var e=navigator.getDeviceStorage("sdcard"),z=e.get(M);z.onsuccess=function(){var M=this.result,e=new FileReader;e.onerror=function(M){helper.toaster("can't read file",3e3),e.abort()},e.onloadend=function(M){b(e.result)},e.readAsText(M)},z.onerror=function(){alert("Unable to get the file: "+this.error)}}catch(M){console.log(M)}if("b2g"in navigator)try{var e=navigator.b2g.getDeviceStorage("sdcard"),z=e.get(M).then(function(M){var e=new FileReader;e.onerror=function(M){console.log("filereader error: "+M),e.abort()},e.onloadend=function(M){b(e.result)},e.readAsText(M)})}catch(M){alert(M)}}(M,pF)}},z)})])}},"/page_events_filtered":{view:function(){var M=b(M3).route.param("query"),e=0;return b(M3)("div",{class:"flex",id:"events-wrapper",onremove:function(){o1.selected_day=document.activeElement.getAttribute("data-date"),o1.selected_day_id=document.activeElement.getAttribute("data-id")},oninit:function(){oQ(),o1.shortCut=!1,Mj("Category: "+M,8e3)},oncreate:function(){document.querySelectorAll(".item")[0].focus(),MY("","","")}},[oP.map(function(z){if(z.CATEGORIES&&z.CATEGORIES.toLowerCase()===M.toLowerCase()){e++;var o,p="";p=z.allDay?"all day":b(Mw)(1e3*z.dateStartUnix).format("HH:mm"),o=null==z.dateStartUnix||null==z.dateEndUnix||b(Mw)(1e3*z.dateStartUnix).format(o2.dateformat)==b(Mw)(1e3*z.dateStartUnix).format(o2.dateformat)||z.allDay?b(Mw)(1e3*z.dateStartUnix).format(o2.dateformat):b(Mw)(1e3*z.dateStartUnix).format(o2.dateformat)+" - "+b(Mw)(1e3*z.dateStartUnix).format(o2.dateformat);var c=z.isSubscription?"subscription":"",t=z.allDay?"allDay":"";return b(M3)("article",{class:"item events "+c+" "+t,tabindex:e,"data-id":z.UID,"data-date":b(Mw)(1e3*z.dateStartUnix).format("YYYY-MM-DD"),"data-category":(z.CATEGORIES||"").toUpperCase(),"data-summary":(z.SUMMARY||"").toUpperCase()},[b(M3)("div",{class:"icons-bar"},[b(M3)("div",{class:"date"},o),b(M3)("div",{class:"time"},p),b(M3)("h2",{class:"summary"},z.SUMMARY),b(M3)("div",{class:"location"},z.LOCATION),b(M3)("div",{class:"description"},z.DESCRIPTION)])])}})])}}}),b(M3).route.prefix="#");var pY=function(){o2.default_notification=document.getElementById("default-notification-time").value,o2.default_duration=document.getElementById("default-duration-time").value,o2.dateformat=document.getElementById("event-date-format").value,o2.firstday=document.getElementById("first-day-of-the-week").value,o2.eventsfilter=document.getElementById("events-category-filter").value,o2.background_sync=document.getElementById("background-sync").value,"Yes"==o2.background_sync?MQ():MK(),b(Mv).setItem("settings",o2).then(function(){o9()}).catch(function(M){console.log(M)})},pH=function(M){document.activeElement.value=M},pV=function(){var M;null==oY&&(oY=[]),MD(document.getElementById("cal-subs-url").value)&&""!=document.getElementById("cal-subs-name").value?(M=MT(32),oY.push({url:document.getElementById("cal-subs-url").value,name:document.getElementById("cal-subs-name").value,id:M}),document.querySelector("input#cal-subs-name").value="",document.querySelector("input#cal-subs-url").value="",b(Mv).setItem("subscriptions",oY).then(function(M){b(M3).route.set("/page_options")}),b(Mv).setItem(M,"").then(function(M){Mj("subscription added",4e3),pq()}).catch(function(M){console.log(M)})):Mj("Please enter a name and a valid url",2e3)},pG=function(M,e){MD(document.getElementById("account-url").value)&&""!=document.getElementById("account-name").value&&""!=document.getElementById("account-username").value&&""!=document.getElementById("account-password").value?(M?(ox=ox.filter(function(M){return M.id!==e})).push({server_url:document.getElementById("account-url").value,user:document.getElementById("account-username").value,password:document.getElementById("account-password").value,name:document.getElementById("account-name").value,id:e,type:"basic"}):(null==ox&&(ox=[]),ox.push({server_url:document.getElementById("account-url").value,user:document.getElementById("account-username").value,password:document.getElementById("account-password").value,name:document.getElementById("account-name").value,id:MT(32),type:"basic"})),b(Mv).setItem("accounts",ox).then(function(M){o8(),pp(!0,!1),b(M3).route.set("/page_options")}).catch(function(M){console.log(M)})):Mx("Please enter a name and a valid url",2e3)},pK=function(){var M=oY.filter(function(M){return M.id!=document.activeElement.getAttribute("data-id")});b(Mv).removeItem(document.activeElement.getAttribute("data-id")).then(function(){Mx("subscription removed",4e3)}).catch(function(M){console.log(M)}),b(Mv).setItem("subscriptions",M).then(function(M){Mj("subscription deleted",2e3)}).catch(function(M){Mx(M,2e3)}),document.activeElement.remove()},pQ=function(){var M=ox.filter(function(M){return M.id!=document.activeElement.getAttribute("data-id")});b(Mv).setItem("accounts",M).then(function(M){Mj("account deleted",2e3),document.activeElement.remove(),MY("","","")}).catch(function(M){Mx(M,2e3)}),b(Mv).removeItem(document.activeElement.getAttribute("data-id")).then(function(){}).catch(function(M){console.log(M)})};function pJ(){"hidden"===document.visibilityState?o1.visible=!1:setTimeout(function(){o1.visible=!0},1e3)}b(Mv).getItem("subscriptions").then(function(M){oY=M,pq()}).catch(function(M){}),pJ();var p$=function(M){oI=oI.filter(function(b){return b.id!=M}),b(Mv).setItem("event_templates",oI).then(function(M){Mj("template deleted",2e3),b(M3).route.set("/page_calendar")}).catch(function(M){console.log(M)})},pZ=function(){oI.forEach(function(M){M.id==Mn&&(document.getElementById("event-title").value=M.title,document.getElementById("event-description").value=M.description,document.getElementById("event-location").value=M.location,document.getElementById("event-category").value=M.category,Mn="")})},p0=function(M){if(pw(),cM(),"SELECT"==document.activeElement.nodeName||"date"==document.activeElement.type||"time"==document.activeElement.type)return!1;var e=document.activeElement.tabIndex+M,z=0,o=document.activeElement.parentNode.parentNode;if(z=o.querySelectorAll('.item:not([style*="display: none"]'),("/page_calendar"==b(M3).route.get()||"/page_options"==b(M3).route.get()||"/page_events"==b(M3).route.get()||"/page_event_templates"==b(M3).route.get()||"/page_list_files"==b(M3).route.get()||b(M3).route.get().startsWith("/page_events"))&&(z=document.activeElement.parentNode.parentNode.querySelectorAll('.item:not([style*="display: none"]'),o1.shortCut=!1),"/page_calendar"==b(M3).route.get()&&(o1.shortCut=!1,MY("","","")),("/page_subscriptions"==b(M3).route.get()||"/page_accounts"==b(M3).route.get()||"/page_edit_account"==b(M3).route.get())&&(z=o.querySelectorAll('.item:not([style*="display: none"]'),z=o.querySelectorAll(".item")),"/page_add_event"==b(M3).route.get()||"/page_edit_event"==b(M3).route.get()){if(z=o.querySelectorAll('.item:not([style*="display: none"]'),document.activeElement.parentNode.classList.contains("input-parent"))return document.activeElement.parentNode.focus(),!0;document.getElementById("add-edit-event").firstElementChild.focus()}var p=0;e<=z.length&&(p=z[e]).focus(),e==z.length&&(p=z[0]).focus();for(var c=document.activeElement.getBoundingClientRect(),t=c.top-document.body.getBoundingClientRect().top+c.height/2,n=document.activeElement.parentNode;n&&!(n.scrollHeight>n.clientHeight)&&!(n.scrollWidth>n.clientWidth);)n=n.parentNode;if(n?n.scrollBy({left:0,top:t-window.innerHeight/2,behavior:"smooth"}):document.body.scrollBy({left:0,top:t-window.innerHeight/2,behavior:"smooth"}),"/page_calendar"==b(M3).route.get()||"/page_events"==b(M3).route.get()||b(M3).route.get().startsWith("/page_events"))try{o1.selected_day=p.getAttribute("data-date"),o1.selected_day_id=p.getAttribute("data-id"),pX(o1.selected_day)}catch(M){}},p1=function(M,b,e,z){if("mozAlarms"in navigator){var o=navigator.mozAlarms.add(M,"honorTimezone",{note:b,event_id:e,type:z});o.onsuccess=function(){console.log("alarm set")},o.onerror=function(){console.log("An error occurred: "+this.error.name)}}if("b2g"in navigator)try{navigator.b2g.alarmManager.add({date:M,data:{note:b,type:z},ignoreTimezone:!1}).then(function(M){return console.log("add id: "+M)},function(M){return console.log("add err: "+M)})}catch(M){console.log(M)}},p2=function(M){if(navigator.mozAlarms){var b=navigator.mozAlarms.getAll();b.onsuccess=function(){this.result.forEach(function(b){if(b.data.event_id==M){var e=navigator.mozAlarms.remove(b.id);e.onsuccess=function(){console.log("removed")},e.onerror=function(){console.log("An error occurred: "+this.error.name)}}})},b.onerror=function(){console.log("An error occurred:",this.error.name)}}if("b2g"in navigator)try{navigator.b2g.alarmManager.getAll().onsuccess=function(){this.result.forEach(function(b){if(b.data.event_id==M){var e=navigator.b2g.alarmManager.remove(b.id);e.onsuccess=function(){console.log("removed")},e.onerror=function(){console.log("An error occurred: "+this.error.name)}}})}}catch(M){console.log(M)}},p3=function(M,e,z){var o=b(Mw)(M).format("YYYYMMDDTHHmmss");return o=e?";VALUE=DATE:"+b(Mw)(M).format("YYYYMMDD"):":"+o,z&&(o=b(Mw)(M).format("YYYYMMDDTHHmmss")),o},p4=["SU","MO","TU","WE","TH","FR","SA"],p5=function(M,b,e){if("none"===M)return"";var z=p4[new Date(e).getDay()];return"WEEKLY"===M?"FREQ=".concat(M,";INTERVAL=1;BYDAY=").concat(z,";UNTIL=").concat(p3(b,!1,!0)):"FREQ=".concat(M,";UNTIL=").concat(p3(b,!1,!0))},p6=[],p8=function(M,e){var z,o,p=!0,c=!1;!0===document.getElementById("event-all-day").checked&&(c=!0),""===document.getElementById("event-title").value&&(Mx("Title can't be empty",2e3),p=!1),"none"!=document.getElementById("event-recur").value&&""==document.getElementById("event-date-end").value&&(Mx("An end date is required for a recurrence",2e3),p=!1);var t=document.getElementById("event-time-start"),n=t.value?"".concat(t.value,":00"):"00:00:00",O=document.getElementById("event-time-end"),r=O.value?"".concat(O.value,":00"):"00:00:00",a=new Date("01/01/2000 "+n),i=new Date("01/01/2000 "+r),A=document.getElementById("event-date").value+" "+n;""==document.getElementById("event-date-end").value&&(document.getElementById("event-date-end").value=document.getElementById("event-date").value);var d=document.getElementById("event-date-end").value+" "+r;c&&(d=b(Mw)(document.getElementById("event-date-end").value+" "+r).add(1,"day").format("YYYY-MM-DD hh:mm:ss"));var s=document.getElementById("event-date").value+" "+r,q=document.getElementById("event-notification-time").value;if("none"!==q&&((z=new Date(A)).setMinutes(z.getMinutes()-q),q=p3(z.toISOString())),""!=n&&""!=r){var a=new Date(document.getElementById("event-date").value+" "+n),i=new Date(document.getElementById("event-date-end").value+" "+r);i","",""));break;case"#":document.querySelectorAll("div#calendar div#calendar-body div div [class^='moon-phase-']").forEach(function(M){M.classList.toggle("active")});break;case"SoftRight":case"Alt":case"m":if(cz("page_events_filtered"))return b(M3).route.set("/page_events");if(ce("page_calendar")&&o1.shortCut){var e="",z=document.querySelectorAll("#event-slider article");return z.forEach(function(M,b){"block"==M.style.display&&(e=M),z.length-1==b&&(void 0==(Mc=oP.filter(function(M){return!0!=M.isSubscription&&M.UID==e.getAttribute("data-uid")})[0])?Mj("subscriptions events cannot be edited",4e3):p9(Mc.etag,Mc.url,Mc.id,Mc.UID))})}if(ce("page_calendar")&&!o1.shortCut)return b(M3).route.set("/page_options");if(cz("page_events"))return document.querySelectorAll("#filter-menu button").forEach(function(M){M.style.display="block"}),document.querySelector("#filter-menu").style.display="flex",document.querySelector("#filter-menu").firstChild.focus(),document.querySelector("#search").focus();cz("page_add_event")&&M_(pI),"edit-delete-account"==document.activeElement.getAttribute("data-action")&&"oauth"!=document.activeElement.getAttribute("data-account-type")&&(o1.edit_account_id=document.activeElement.getAttribute("data-id"),Mt=ox.filter(function(M){return M.id==o1.edit_account_id})[0],b(M3).route.set("/page_edit_account"));break;case"SoftLeft":case"Control":if(ce("page_event_templates")&&p$(document.activeElement.getAttribute("data-id")),cz("page_events")){if(document.activeElement.classList.contains("subscription"))return Mj("subscriptions events cannot be edited",4e3);return pl(),document.activeElement.classList.contains("events")&&b(M3).route.set("/page_edit_event")}if(ce("page_subscriptions")||ce("page_accounts"))return"true"==document.activeElement.getAttribute("data-scan-action")&&M2(pH);if(ce("page_options")&&("delete-subscription"==document.activeElement.getAttribute("data-action")&&pK(),"edit-delete-account"==document.activeElement.getAttribute("data-action")&&pQ()),ce("page_calendar")&&o1.shortCut){var o="",p=document.querySelectorAll("#event-slider article");return p.forEach(function(M,e){"block"==M.style.display&&(o=M),p.length-1==e&&(void 0==(Mc=oP.filter(function(M){return!M.isSubscription&&M.UID==o.getAttribute("data-uid")})[0])?Mj("subscriptions events cannot be edited",4e3):b(M3).route.set("/page_edit_event"))})}if(ce("page_calendar"))return b(M3).route.set("/page_add_event");break;case"Enter":if(!o1.visible)return;if(document.activeElement.classList.contains("input-parent"))return document.activeElement.children[1].focus(),document.activeElement.classList.contains("check-box")&&(!0==document.activeElement.checked?document.activeElement.checked=!1:document.activeElement.checked=!0);if(document.activeElement.classList.contains("search-item"))return Mk("click");if("export-event"==document.activeElement.id)return oP.forEach(function(M){M.UID==o1.selected_day_id&&p6.push(M.data)}),M$(p6[0].UID+".ics",p6,function(M){Mj(M,3e3)}),Mj("event exported",5e3);if(oP.length>0||null==oP){if(cz("page_calendar")&&(document.querySelector(".loading-spinner").style.display="block"),cz("page_events")){if("BUTTON"!==document.activeElement.tagName&&b(M3).route.set("/page_calendar"),"BUTTON"===document.activeElement.tagName){var c=document.activeElement.getAttribute("data-action");document.querySelectorAll("#events-wrapper article").forEach(function(M){M.style.display="block"}),"filter-category"==c&&p_(o2.eventsfilter),"filter-last-modified"==c&&MC(oP,"lastmod","date","asc").then(function(){document.querySelector("#search").focus(),cM()}),"filter-asc"==c&&MC(oP,"dateStartUnix","date","asc").then(function(){document.querySelector("#search").focus(),cM()}),"filter-desc"==c&&MC(oP,"dateStartUnix","date","desc").then(function(){document.querySelector("#search").focus(),cM()}),document.querySelector("#filter-menu").style.display="none",document.querySelectorAll("#filter-menu button").forEach(function(M){M.style.display="none"})}"INPUT"===document.activeElement.tagName&&setTimeout(pT,1e3)}else(ce("page_calendar")||ce("page_events"))&&b(M3).route.set(ce("page_calendar")?"/page_events":"/page_calendar")}else ce("page_calendar")&&Mj("There are no calendar entries to display",3e3);break;case"Backspace":ce("page_add_event")&&"INPUT"!=document.activeElement.tagName&&b(M3).route.set("/page_calendar"),ce("page_events_filtered")&&b(M3).route.set("/page_calendar"),ce("page_edit_event")&&"INPUT"!=document.activeElement.tagName&&b(M3).route.set("/page_calendar"),ce("page_options")&&b(M3).route.set("/page_calendar"),ce("page_event_templates")&&b(M3).route.set("/page_calendar"),(ce("page_subscriptions")||ce("page_accounts")||ce("page_edit_account")||ce("page_list_files"))&&(b(M3).route.set("/page_options"),"block"==document.getElementById("qr-screen").style&&(document.getElementById("qr-screen").style="none"),M1(cb));break;case"0":if(ce("page_calendar")||ce("page_events")){if(o2.eventsfilter||Mj("no category selected, you can do that in the settings",4e3),"INPUT"==document.activeElement.tagName)return;b(M3).route.set("/page_events_filtered",{query:o2.eventsfilter})}}}(M)}),document.addEventListener("visibilitychange",pJ,!1),o1.debug&&(window.onerror=function(M,b,e){return alert("Error message: "+M+"\nURL: "+b+"\nLine Number: "+e),!0});var cp=(j=Ml(function(M){var e,z,o,p;return(0,MB.__generator)(this,function(c){switch(c.label){case 0:var t,n;t=Ml(function(M){var b,e,z,o,p,c;return(0,MB.__generator)(this,function(t){switch(t.label){case 0:(b=new Headers).append("Content-Type","application/x-www-form-urlencoded"),(e=new URLSearchParams).append("code",M),e.append("grant_type","authorization_code"),e.append("redirect_uri","https://greg.strukturart.com/index.html"),e.append("client_id","762086220505-f0kij4nt279nqn21ukokm06j0jge2ngl.apps.googleusercontent.com"),e.append("client_secret","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"),z={method:"POST",headers:b,body:e,redirect:"follow"},t.label=1;case 1:return t.trys.push([1,6,,7]),[4,fetch("https://oauth2.googleapis.com/token",z)];case 2:if((o=t.sent()).ok)return[3,4];return[4,o.text()];case 3:throw p=t.sent(),Error("Token exchange failed: ".concat(o.statusText,". Details: ").concat(p));case 4:return[4,o.json()];case 5:return[2,t.sent()];case 6:throw console.error("Error fetching the token:",c=t.sent()),c;case 7:return[2]}})}),e=function(M){return t.apply(this,arguments)},n=Ml(function(M,e){var z,o;return(0,MB.__generator)(this,function(p){switch(p.label){case 0:return p.trys.push([0,3,,4]),[4,b(Mv).getItem("accounts")];case 1:return(z=p.sent()||[]).push({server_url:"https://apidata.googleusercontent.com/caldav/v2/",tokens:M,authorizationCode:e,name:"Google",id:MT(32),type:"oauth"}),[4,b(Mv).setItem("accounts",z)];case 2:return p.sent(),setTimeout(function(){oG(),localStorage.setItem("oauth_callback","true")},3e3),[3,4];case 3:return o=p.sent(),alert("Error saving account: "+o.message),[3,4];case 4:return[2]}})}),z=function(M,b){return n.apply(this,arguments)},c.label=1;case 1:return c.trys.push([1,4,,5]),[4,e(M)];case 2:return o=c.sent(),[4,z(o,M)];case 3:return c.sent(),[3,5];case 4:return p=c.sent(),alert("OAuth process failed: "+p.message),[3,5];case 5:return[2]}})}),function(M){return j.apply(this,arguments)}),cc=!1,ct=!1;oD.addEventListener("message",function(M){if(M.data.oauth_success){var e=M.data.oauth_success.data;e&&cp(e)}if("parse"==M.data.action){Ma=Date.now(),ct=!0;try{document.getElementById("icon-waiting").style.visibility="visible"}catch(M){}!1!==M.data.content.parsed_data&&(0===o4.length||-1===o4.indexOf(M.data.content.parsed_data.calendar_name))&&(oP.push(M.data.content.parsed_data),M.data.content.callback&&oG(),M.data.content.raw_data&&(o7.data.push({uid:M.data.content.uid,data:M.data.content.raw_data}),b(Mv).setItem("local_account",o7).then(function(){oG()}).catch(function(){}))),!1==cc&&cn()}if("error"==M.data.action)try{document.getElementById("icon-waiting").style.visibility="hidden"}catch(M){}});var cn=function(){Mr=setInterval(function(){if(cc=!0,!ct)return!1;if(Date.now()-Ma>=400){try{document.getElementById("icon-waiting").style.visibility="hidden"}catch(M){}ct=!1,cc=!1,pM(pR,ph),MC(oP,"dateStartUnix","number"),clearInterval(Mr)}},100)};try{navigator.mozSetMessageHandler("activity",function(M){var b=M.source;"view"==b.name&&(pP=b.data.url,Mj("please open the subscriptions page and store the values",15e3),MH())})}catch(M){} \ No newline at end of file + */function(M){var b,e,z=function(){try{if(M.URLSearchParams&&"bar"===new M.URLSearchParams("foo=bar").get("foo"))return M.URLSearchParams}catch(M){}return null}(),o=z&&"a=1"===new z({a:1}).toString(),p=z&&"+"===new z("s=%2B").get("s"),c=z&&"size"in z.prototype,t="__URLSearchParams__",n=!z||((b=new z).append("s"," &"),"s=+%26"===b.toString()),O=A.prototype,r=!!(M.Symbol&&M.Symbol.iterator);if(!z||!o||!p||!n||!c){O.append=function(M,b){l(this[t],M,b)},O.delete=function(M){delete this[t][M]},O.get=function(M){var b=this[t];return this.has(M)?b[M][0]:null},O.getAll=function(M){var b=this[t];return this.has(M)?b[M].slice(0):[]},O.has=function(M){return W(this[t],M)},O.set=function(M,b){this[t][M]=[""+b]},O.toString=function(){var M,b,e,z,o=this[t],p=[];for(b in o)for(M=0,e=d(b),z=o[b];M *");document.querySelector("#KaiOsAds-Wrapper").style.margin="0px 0px 30px 0",M.forEach(function(M){M.addEventListener("focus",function(M){MY("","open ads","")})})}catch(M){console.log(M)}}),M.call("display",{navClass:"item",display:"block"})}})},document.head.appendChild(M)},o_={},ML=Ms("h1KY3");o_=function(M){var b={};function e(z){if(b[z])return b[z].exports;var o=b[z]={i:z,l:!1,exports:{}};return M[z].call(o.exports,o,o.exports,e),o.l=!0,o.exports}return e.m=M,e.c=b,e.d=function(M,b,z){e.o(M,b)||Object.defineProperty(M,b,{enumerable:!0,get:z})},e.r=function(M){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(M,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(M,"__esModule",{value:!0})},e.t=function(M,b){if(1&b&&(M=e(M)),8&b||4&b&&"object"==typeof M&&M&&M.__esModule)return M;var z=Object.create(null);if(e.r(z),Object.defineProperty(z,"default",{enumerable:!0,value:M}),2&b&&"string"!=typeof M)for(var o in M)e.d(z,o,(function(b){return M[b]}).bind(null,o));return z},e.n=function(M){var b=M&&M.__esModule?function(){return M.default}:function(){return M};return e.d(b,"a",b),b},e.o=function(M,b){return Object.prototype.hasOwnProperty.call(M,b)},e.p="",e(e.s=0)}([function(M,b,e){function z(M){return(z="function"==typeof Symbol&&"symbol"==(0,ML._)(Symbol.iterator)?function(M){return void 0===M?"undefined":(0,ML._)(M)}:function(M){return M&&"function"==typeof Symbol&&M.constructor===Symbol&&M!==Symbol.prototype?"symbol":void 0===M?"undefined":(0,ML._)(M)})(M)}function o(M){var b;switch(z(M)){case"string":return/Z$/.test(M)?0:(b=/([+-])(\d{2}):?(\d{2})/.exec(M))&&(+b[3]+60*b[2])*("+"===b[1]?1:-1);case"number":return Number.isNaN(M)?null:16>Math.abs(M)?60*M:M;default:return null}}e.r(b);var p=function(M,b,e){var z=String(M);return!z||z.length>=b?M:"".concat(Array(b+1-z.length).join(e)).concat(M)},c=function(M){var b=Math.abs(M);return"".concat(M<=0?"+":"-").concat(p(Math.floor(b/60),2,"0"),":").concat(p(b%60,2,"0"))};function t(M,b){for(var e=0;e1&&void 0!==arguments[1]?arguments[1]:n))}var a=function(){var M,b;function e(){var M=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new Date,b=arguments.length>1&&void 0!==arguments[1]?arguments[1]:M.getTimezoneOffset();(function(M,b){if(!(M instanceof b))throw TypeError("Cannot call a class as a function")})(this,e),this.$d=new Date(M.getTime()-r(b)),this.$timezoneOffset=b}return M=[{key:"getTimezoneOffset",value:function(){return this.$timezoneOffset}},{key:"setTimezoneOffset",value:function(){var M=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.$timezoneOffset;this.$d.setTime(this.$d.getTime()+r(this.$timezoneOffset,M)),this.$timezoneOffset=M}}],t(e.prototype,M),b&&t(e,b),e}();["toDateString","toLocaleString","toLocaleDateString","toLocaleTimeString","setDate","setFullYear","setHours","setMilliseconds","setMinutes","setMonth","setSeconds","setTime","setYear","getDate","getDay","getFullYear","getHours","getMilliseconds","getMinutes","getMonth","getSeconds","getYear"].forEach(function(M){a.prototype[M]=function(){return O[M].apply(this.$d,arguments)}}),["toISOString","toUTCString","toGMTString","toJSON","getUTCDate","getUTCDay","getUTCFullYear","getUTCHours","getUTCMilliseconds","getUTCMinutes","getUTCMonth","getUTCSeconds","valueOf","getTime"].forEach(function(M){a.prototype[M]=function(){return O[M].apply(new Date(this.$d.getTime()+r(this.$timezoneOffset)),arguments)}}),["setUTCDate","setUTCFullYear","setUTCHours","setUTCMilliseconds","setUTCMinutes","setUTCMonth","setUTCSeconds"].forEach(function(M){a.prototype[M]=function(){var b=new Date(this.$d.getTime()+r(this.$timezoneOffset));O[M].apply(b,arguments),b.setTime(b.getTime()-r(this.$timezoneOffset)),this.$d=b}}),["toString","toTimeString"].forEach(function(M){a.prototype[M]=function(){return O[M].apply(this.$d,arguments).replace(/GMT(.*)$/,"GMT".concat(c(this.$timezoneOffset)))}});var i=!1,A=function(M,b){["clone","add","subtract","startOf"].forEach(function(e){M[e]=function(){var M=this.utcOffset();return b[e].apply(this,arguments).utcOffset(M)}}),M.utc=function(){return this.utcOffset(0)},M.local=function(){return this.utcOffset(-n)},M.utcOffset=function(M){if(void 0===M){var b=this.$d.getTimezoneOffset();return 0===b?0:-b}return null!==o(M)&&(this.$d.setTimezoneOffset(-o(M)),this.init()),this},M.toDate=function(){return new Date(this.$d.getTime())},M.isLocal=function(){return this.$d.getTimezoneOffset()===n},M.isUTC=function(){return 0===this.$d.getTimezoneOffset()},M.$set=function(){for(var M,e=this.$d.getTimezoneOffset(),z=arguments.length,o=Array(z),p=0;p0&&void 0!==arguments[0]?arguments[0]:{},b=arguments.length>1?arguments[1]:void 0,e=arguments.length>2?arguments[2]:void 0;i=!!M.parseToLocal;var z=b.prototype,p=function(){};p.prototype=z;var c=new p;A(c,z),c.constructor=b.constructor,b.prototype=c,e.utc=function(M){var b=this(M);return"string"==typeof M&&null===o(M)&&(b.$d.$timezoneOffset=0),b.utc()}}}]),b(Mw).extend(b(o_));var oS={};(oS=Ms("5labU")).tz.load(Ms("8zdtp"));var oD=new BroadcastChannel("sw-messages");b(Mv).setDriver(b(Mv).INDEXEDDB);var oP=[],ox=[],oI=[],oU=!1,oj=60,oF=localStorage.getItem("last_sync")||"",oY=[];b(Mv).getItem("subscriptions").then(function(M){console.log(M)});var oH=(E=Ml(function(){var M,e,z,o,p;return(0,MB.__generator)(this,function(c){switch(c.label){case 0:var t,n;M=function(){return new URLSearchParams(window.location.search).get("code")},t=Ml(function(M){var b,e,z,o,p;return(0,MB.__generator)(this,function(c){switch(c.label){case 0:(b=new Headers).append("Content-Type","application/x-www-form-urlencoded"),(e=new URLSearchParams).append("code",M),e.append("grant_type","authorization_code"),e.append("redirect_uri","https://greg.strukturart.com/index.html"),e.append("client_id","762086220505-f0kij4nt279nqn21ukokm06j0jge2ngl.apps.googleusercontent.com"),e.append("client_secret","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"),z={method:"POST",headers:b,body:e,redirect:"follow"},c.label=1;case 1:return c.trys.push([1,4,,5]),[4,fetch("https://oauth2.googleapis.com/token",z)];case 2:if(!(o=c.sent()).ok)throw Error("Token exchange failed: ".concat(o.statusText));return[4,o.json()];case 3:return[2,c.sent()];case 4:throw console.error("Error fetching the token:",p=c.sent()),p;case 5:return[2]}})}),e=function(M){return t.apply(this,arguments)},n=Ml(function(M,e){var z,o;return(0,MB.__generator)(this,function(p){switch(p.label){case 0:return p.trys.push([0,3,,4]),[4,b(Mv).getItem("accounts")];case 1:return(z=p.sent()||[]).push({server_url:"https://apidata.googleusercontent.com/caldav/v2/",tokens:M,authorizationCode:e,name:"Google",id:MT(32),type:"oauth"}),[4,b(Mv).setItem("accounts",z)];case 2:return p.sent(),setTimeout(function(){window.close()},3e3),[3,4];case 3:return o=p.sent(),alert("Error saving account: "+o.message),[3,4];case 4:return[2]}})}),z=function(M,b){return n.apply(this,arguments)},c.label=1;case 1:if(c.trys.push([1,4,,5]),!(o=M()))return[2,!1];return[4,e(o)];case 2:return p=c.sent(),[4,z(p,o)];case 3:case 4:return c.sent(),[3,5];case 5:return[2]}})}),function(){return E.apply(this,arguments)});"b2g"in navigator||"navigator.mozApps"in navigator?function(){if(!window.location.href.includes("code="))return!1;var M=new URLSearchParams(window.location.search).get("code");if(!M)return!1;setTimeout(function(){try{var b=new MozActivity({name:"greg-oauth",data:M});b.onsuccess=function(){console.log("Activity successfuly handled")},b.onerror=function(){console.log("The activity encouter en error: "+this.error),alert(this.error)}}catch(M){}if("b2g"in navigator)try{new WebActivity("greg-oauth",{name:"greg-oauth",type:"string",data:M}).start().then(function(M){window.close(),console.log("Results passed back from activity handler:"),console.log(M)},function(M){alert(M)})}catch(M){}},4e3)}():oH();var oV=function(){document.querySelector("#intro").classList.add("intro-animation"),document.querySelector("#version").classList.add("intro-version-animation"),document.querySelector("#intro img").classList.add("intro-img-anmation")},oG=function(){setTimeout(function(){document.querySelector(".success-checkmark").style.display="block"},2e3),setTimeout(function(){document.querySelector(".success-checkmark").style.display="none"},4e3)},oK=[],oQ=function(){oK.push(b(M3).route.get())},oJ=function(){setTimeout(function(){b(M3).route.set(oK[oK.length-2])},1e3)};MH();var o$="",oZ=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],o0=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],o1={selected_day:b(Mw)().format("YYYY-MM-DD"),selected_day_id:"",visible:!1,update_event_id:"",event_calendar_changed:!1,startup:!1,sortEvents:"startDate",shortCut:!1,background_sync_running:!1,version:localStorage.getItem("version")||"time is relative",notKaiOS:!0,debug:!1},o2={default_notification:"none",ads:!0,timezone:oS.tz.guess(),dateformat:"YYYY-MM-DD",firstday:"sunday",background_sync:"No",default_duration:30};("b2g"in navigator||"navigator.mozApps"in navigator)&&(o1.notKaiOS=!1),o1.notKaiOS||["http://127.0.0.1/api/v1/shared/core.js","http://127.0.0.1/api/v1/shared/session.js","http://127.0.0.1/api/v1/apps/service.js","http://127.0.0.1/api/v1/audiovolumemanager/service.js","./assets/js/kaiads.v5.min.js"].forEach(function(M){var b=document.createElement("script");b.type="text/javascript",b.src=M,document.head.appendChild(b)}),function(){try{if("No"==localStorage.getItem("background_sync"))return!1;var M=navigator.mozAlarms.getAll();M.onsuccess=function(){this.result.forEach(function(M){"keep alive"==M.data.note&&MQ()})},M.onerror=function(){console.log("An error occurred:",this.error.name)}}catch(M){}}();var o3={};if(o3=Ms("6JduE").getBundleURL("dK21l")+"sw.js","b2g"in navigator)try{navigator.serviceWorker.register(o3).then(function(M){M.waiting&&setTimeout(function(){window.location.reload(!0)},1e3),M.systemMessageManager.subscribe("alarm").then(function(M){console.log('Successfully subscribe system messages of name "alarm".')},function(M){console.log("Fail to subscribe system message, error: "+M)}),M.systemMessageManager.subscribe("activity").then(function(M){},function(M){})})}catch(M){console.log(M)}else if("serviceWorker"in navigator&&navigator.serviceWorker.controller)console.log("Service worker found");else try{console.log("Try to register service worker"),navigator.serviceWorker.register(o3).then(function(M){M.waiting&&setTimeout(function(){window.location.reload(!0)},1e3)})}catch(M){console.error("Error during service worker registration:",M)}var o4=[];function o5(){return o6.apply(this,arguments)}function o6(){return(o6=Ml(function(){return(0,MB.__generator)(this,function(M){switch(M.label){case 0:return M.trys.push([0,2,,3]),[4,b(Mv).keys()];case 1:return -1==M.sent().indexOf("calendarNames")?Mp=[{name:"local",id:"local-id",data:[],type:"local",view:!0}]:b(Mv).getItem("calendarNames").then(function(M){(Mp=M).forEach(function(M){!1==M.view&&o4.push(M.name)})}),[3,3];case 2:return M.sent(),[3,3];case 3:return[2]}})})).apply(this,arguments)}var o8=function(){b(Mv).getItem("accounts").then(function(M){oV(),ox=M,o5(),null!=ox&&pr().then(function(){pO(pu)})}).catch(function(){console.log("no accounts")})};o8();var o7={data:[],calendar_name:"local",calendar_id:"local-id"};b(Mv).getItem("local_account").then(function(M){null!=M?(o7.data=M.data,o7.data.forEach(function(M){try{navigator.serviceWorker.controller.postMessage({type:"parse",t:M,e:"local-id",callback:!1,store:!1})}catch(M){console.log("send to sw")}})):b(Mv).setItem("local_account",o7).then(function(){console.log("Local account created:",o7)}).catch(function(M){console.error("Error creating local account:",M)})}).catch(function(M){console.error("Error loading local account:",M)});var o9=function(){b(Mv).getItem("settings").then(function(M){null!=M&&(o2=M,localStorage.setItem("background_sync",o2.background_sync),o0="sunday"==o2.firstday||void 0==o2.firstday?["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]:["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],void 0==o2.dateformat&&(o2.dateformat="YYYY-MM-DD"),document.querySelectorAll(".calendar-head div").forEach(function(M,b){M.innerText=o0[b]}))}).catch(function(M){})};o9();var pM=function(){try{document.querySelectorAll("div.calendar-cell").forEach(function(M){var b=M.getAttribute("data-date");!0==pB(b).event?(M.classList.add("event"),!0==pB(b).multidayevent&&M.classList.add("multievent")):M.classList.contains("event")&&M.classList.remove("event"),!0==pv(b).rrule&&(M.classList.add("rrule"),pv(b).count>1&&M.classList.add("multievent"))})}catch(M){console.log(M)}},pb={},pe={};function pz(M){return po.apply(this,arguments)}function po(){return(po=Ml(function(M){return(0,MB.__generator)(this,function(b){try{return pb[M.id]||("oauth"===M.type&&(pb[M.id]=new ok({serverUrl:M.server_url,credentials:{tokenUrl:"https://oauth2.googleapis.com/token",refreshToken:M.tokens.refresh_token,clientId:"762086220505-f0kij4nt279nqn21ukokm06j0jge2ngl.apps.googleusercontent.com",clientSecret:"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",authorizationCode:M.authorizationCode,redirectUrl:"https://greg.strukturart.com/index.html"},authMethod:"Oauth",defaultAccountType:"caldav"})),"basic"===M.type&&(pb[M.id]=new ok({serverUrl:M.server_url,credentials:{username:M.user,password:M.password},authMethod:"Basic",defaultAccountType:"caldav"}))),[2,pb[M.id]]}catch(M){throw console.error("Error occurred while creating DAVClient instance:",M),M}return[2]})})).apply(this,arguments)}function pp(){return pc.apply(this,arguments)}function pc(){return(pc=Ml(function(){var M,e,z,o,p,c,t,n,O,r,a,i,A,d,s,q,u,l,f,W,h,R,m,L,B,v,g=arguments;return(0,MB.__generator)(this,function(N){switch(N.label){case 0:if(M=g.length>0&&void 0!==g[0]&&g[0],e=g.length>1&&void 0!==g[1]&&g[1],!navigator.onLine)return[2,!1];if(oU=!0,e)try{oP=oP.filter(function(M){return M.id==M.account_to_update})}catch(M){console.log(M)}else try{oP=oP.filter(function(M){return!M.isCaldav})}catch(M){console.log(M)}z=!0,o=!1,p=void 0,N.label=1;case 1:N.trys.push([1,30,31,32]),c=ox[Symbol.iterator](),N.label=2;case 2:if(z=(t=c.next()).done)return[3,29];if(n=t.value,!1!=e&&e!==n)return[3,28];return[4,pz(n)];case 3:O=N.sent(),N.label=4;case 4:if(N.trys.push([4,27,,28]),pe[n.id])return[3,9];N.label=5;case 5:return N.trys.push([5,7,,8]),[4,O.login()];case 6:return N.sent(),pe[n.id]=!0,console.log("login successfull"),[3,8];case 7:return console.log("cant login"+N.sent()),pe[n.id]=!1,[3,28];case 8:return[3,10];case 9:console.log("login"),N.label=10;case 10:r=void 0,N.label=11;case 11:return N.trys.push([11,13,,14]),[4,O.fetchCalendars()];case 12:return console.log(r=N.sent()),[3,14];case 13:return console.log(N.sent()),[3,28];case 14:"/page_calendar"===b(M3).route.get()&&(document.getElementById("icon-loading").style.visibility="visible"),a=[],i=!0,A=!1,d=void 0,N.label=15;case 15:N.trys.push([15,24,25,26]),s=r[Symbol.iterator](),N.label=16;case 16:if(i=(q=s.next()).done)return[3,23];return u=q.value,[4,O.fetchCalendarObjects({calendar:u})];case 17:l=N.sent(),f={displayName:u.displayName,syncToken:u.syncToken,ctag:u.ctag,url:u.url,objects:l},a.push(f),N.label=18;case 18:return N.trys.push([18,20,,21]),[4,b(Mv).setItem(n.id,a)];case 19:return N.sent(),console.log("Data cached"),[3,21];case 20:return console.log(N.sent()),oU=!1,[3,21];case 21:W=!0,h=!1,R=void 0;try{for(m=l[Symbol.iterator]();!(W=(L=m.next()).done);W=!0)B=L.value,"serviceWorker"in navigator&&navigator.serviceWorker.controller&&navigator.serviceWorker.controller.postMessage({type:"parse",t:B,e:n.id,callback:!1,store:!1})}catch(M){h=!0,R=M}finally{try{W||null==m.return||m.return()}finally{if(h)throw R}}N.label=22;case 22:return i=!0,[3,16];case 23:return[3,26];case 24:return v=N.sent(),A=!0,d=v,[3,26];case 25:try{i||null==s.return||s.return()}finally{if(A)throw d}return[7];case 26:try{document.getElementById("icon-loading").style.visibility="hidden",document.getElementById("icon-waiting").style.visibility="hidden"}catch(M){console.log(M)}return M&&Mj("all event reloaded",2e3),oU=!1,[3,28];case 27:N.sent(),oU=!1;try{document.getElementById("icon-loading").style.visibility="hidden",document.getElementById("icon-waiting").style.visibility="hidden"}catch(M){console.log(M)}return[3,28];case 28:return z=!0,[3,2];case 29:return[3,32];case 30:return v=N.sent(),o=!0,p=v,[3,32];case 31:try{z||null==c.return||c.return()}finally{if(o)throw p}return[7];case 32:return[2]}})})).apply(this,arguments)}var pt=(_=Ml(function(){var M,e,z,o,p,c,t,n,O;return(0,MB.__generator)(this,function(r){switch(r.label){case 0:oU=!0,e=!0,z=!1,o=void 0,r.label=1;case 1:r.trys.push([1,6,7,8]),p=function(){var e,z,o,p,c,n;return(0,MB.__generator)(this,function(O){switch(O.label){case 0:return[4,pz(e=t.value)];case 1:z=O.sent(),O.label=2;case 2:return O.trys.push([2,8,,9]),[4,z.fetchCalendars()];case 3:o=O.sent(),p=[],c=0,O.label=4;case 4:if(!(c0)return M(t),[3,18];return[3,17];case 16:return q.sent(),navigator.onLine||MS("greg","device offline"),[3,17];case 17:return i++,[3,13];case 18:return[3,20];case 19:return q.sent(),navigator.onLine||MS("greg","device offline"),[3,20];case 20:return e=!0,[3,2];case 21:return[3,24];case 22:return s=q.sent(),z=!0,o=s,[3,24];case 23:try{e||null==p.return||p.return()}finally{if(z)throw o}return[7];case 24:if(JSON.stringify(pn)!=JSON.stringify(Mp)){try{pn.forEach(function(M){var b;Array.isArray(Mp)?b=Mp.find(function(b){return b.name===M.name}):console.error("calendar_names is not an array or is undefined"),b&&(M.view=b.view)})}catch(M){console.log(M)}b(Mv).setItem("calendarNames",pn).then(function(){o5()})}return[2]}})}),function(M){return S.apply(this,arguments)}),pr=(D=Ml(function(){var M,e,z,o,p,c,t,n,O,r,a,i,A,d,s,q,u,l,f,W;return(0,MB.__generator)(this,function(h){switch(h.label){case 0:if(!ox)return[2,!1];M=!0,e=!1,z=void 0,h.label=1;case 1:h.trys.push([1,8,9,10]),o=ox[Symbol.iterator](),h.label=2;case 2:if(M=(p=o.next()).done)return[3,7];c=p.value,h.label=3;case 3:return h.trys.push([3,5,,6]),[4,b(Mv).getItem(c.id)];case 4:if(null===(t=h.sent()))try{pp(!1,c.id)}catch(M){console.log(M)}n=!0,O=!1,r=void 0,a=!0,i=!1,A=void 0;try{for(d=t[Symbol.iterator]();!(a=(s=d.next()).done);a=!0){q=s.value;try{for(u=q.objects[Symbol.iterator]();!(n=(l=u.next()).done);n=!0)if(f=l.value,"serviceWorker"in navigator&&navigator.serviceWorker.controller)try{navigator.serviceWorker.controller.postMessage({type:"parse",t:f,e:c.id,callback:!1,store:!1})}catch(M){console.log("send to sw")}else console.log("no sw")}catch(M){O=!0,r=M}finally{try{n||null==u.return||u.return()}finally{if(O)throw r}}}}catch(M){i=!0,A=M}finally{try{a||null==d.return||d.return()}finally{if(i)throw A}}return[3,6];case 5:return console.log(h.sent()),[3,6];case 6:return M=!0,[3,2];case 7:return[3,10];case 8:return W=h.sent(),e=!0,z=W,[3,10];case 9:try{M||null==o.return||o.return()}finally{if(e)throw z}return[7];case 10:return[2]}})}),function(){return D.apply(this,arguments)}),pa=(P=Ml(function(M,b,e,z,o){var p,c,t,n,O;return(0,MB.__generator)(this,function(r){switch(r.label){case 0:if(!navigator.onLine)return[2,!1];if(document.querySelector(".loading-spinner").style.display="block",!(p=ox.find(function(M){return M.id===b})))return[3,14];return[4,pz(p)];case 1:c=r.sent(),r.label=2;case 2:if(r.trys.push([2,13,,14]),pe[p.id])return[3,4];return[4,c.login()];case 3:r.sent(),pe[p.id]=!0,r.label=4;case 4:return[4,c.fetchCalendars()];case 5:if(!(t=r.sent().find(function(M){return M.displayName===e})))return[3,12];return[4,c.createCalendarObject({calendar:t,filename:o+".ics",iCalString:M,headers:c.authHeaders})];case 6:if(!(n=r.sent()).ok)return[3,11];r.label=7;case 7:return r.trys.push([7,9,,10]),[4,c.propfind({url:n.url,props:Mf({},"".concat(J.DAV,":getetag"),{}),depth:"0",headers:c.authHeaders})];case 8:return O=MR.apply(void 0,[r.sent(),1])[0],z.etag=O.props.getetag,z.url=n.url,z.isCaldav=!0,z.id=b,z.calendar_name=e,document.querySelector(".loading-spinner").style.display="none",pt().then(function(M){}),[2,z];case 9:return console.log(r.sent()),[3,10];case 10:return[3,12];case 11:document.querySelector(".loading-spinner").style.display="none",Mj("There was a problem saving, please try again later.",5e3),r.label=12;case 12:return[3,14];case 13:return console.log(r.sent()),[3,14];case 14:return[2]}})}),function(M,b,e,z,o){return P.apply(this,arguments)}),pi=(x=Ml(function(M,b,e,z){var o,p,c,t;return(0,MB.__generator)(this,function(n){switch(n.label){case 0:if(console.log(oP),!navigator.onLine)return[2,!1];if(document.querySelector(".loading-spinner").style.display="block",console.log("hey"+(o=ox.find(function(M){return M.id===e}))),void 0==o)return document.querySelector(".loading-spinner").style.display="none",Mj("There was a problem deleting, please try again later.",5e3),[2,!1];if(!o)return[3,7];return[4,pz(o)];case 1:p=n.sent(),n.label=2;case 2:if(n.trys.push([2,6,,7]),pe[o.id])return[3,4];return[4,p.login()];case 3:n.sent(),pe[o.id]=!0,n.label=4;case 4:return[4,p.deleteCalendarObject({calendarObject:{url:b,etag:M},headers:p.authHeaders})];case 5:if(!n.sent().ok)return oJ(),Mj("There was a problem deleting, please try again later.",5e3),[2,"error"];if(-1!==(c=oP.findIndex(function(M){return M.UID===z}))){if(oP.splice(c,1),pt(),p2(z),pC(),pM(pR,ph),document.querySelector(".loading-spinner").style.display="none",!1==o1.shortCut)return oJ(),[2,"success"];return oG(),[2,"success"]}return[3,7];case 6:return t=n.sent(),oJ(),Mj("There was a problem deleting, please try again later.",5e3),[2,t];case 7:return[2]}})}),function(M,b,e,z){return x.apply(this,arguments)}),pA=(I=Ml(function(M,b,e,z){var o,p,c,t,n;return(0,MB.__generator)(this,function(O){switch(O.label){case 0:if(!navigator.onLine)return[2,!1];if(document.querySelector(".loading-spinner").style.display="block",void 0==(o=ox.find(function(M){return M.id===z})))return document.querySelector(".loading-spinner").style.display="none",Mj("There was a problem saving, please try again later.",5e3),[2,!1];if(!o)return[3,13];return[4,pz(o)];case 1:p=O.sent(),O.label=2;case 2:if(O.trys.push([2,12,,13]),pe[o.id])return[3,4];return[4,p.login()];case 3:O.sent(),pe[o.id]=!0,O.label=4;case 4:return[4,p.updateCalendarObject({calendarObject:{url:b,data:e,etag:M},headers:p.authHeaders})];case 5:if(!(c=O.sent()).ok)return[3,10];document.querySelector(".loading-spinner").style.display="none",O.label=6;case 6:return O.trys.push([6,8,,9]),[4,p.propfind({url:c.url,props:Mf({},"".concat(J.DAV,":getetag"),{}),depth:"0",headers:p.authHeaders})];case 7:return t=MR.apply(void 0,[O.sent(),1])[0],(n={}).etag=t.props.getetag,n.url=c.url,pt(),[2,n];case 8:return console.log(O.sent()),document.querySelector(".loading-spinner").style.display="none",[3,9];case 9:return[3,11];case 10:document.querySelector(".loading-spinner").style.display="none",Mj("There was a problem saving, please try again later.",5e3),O.label=11;case 11:return[3,13];case 12:return O.sent(),document.querySelector(".loading-spinner").style.display="none",Mj("There was a problem saving, please try again later.",5e3),[3,13];case 13:return[2]}})}),function(M,b,e,z){return I.apply(this,arguments)}),pd=function(M,b){var e=new XMLHttpRequest({mozSystem:!0});e.open("GET",M+"?time="+new Date().getTime(),!0),e.timeout=2e3,e.onload=function(){e.status>=200&&e.status<300?b(e.responseText,M):b(Error("Request failed with status "+e.status))},e.onerror=function(){b(Error("XMLHttpRequest error"),null)},e.ontimeout=function(){b(Error("XMLHttpRequest timed out"),null)},e.send()},ps=function(M,b){try{navigator.serviceWorker.controller.postMessage({type:"parse",t:{uid:"",data:M,url:b,etag:""},e:"subscription",callback:!1,store:!1})}catch(M){console.log(M)}},pq=(U=Ml(function(){var M,b,e,z,o,p;return(0,MB.__generator)(this,function(c){M=!0,b=!1,e=void 0;try{for(z=oY[Symbol.iterator]();!(M=(o=z.next()).done);M=!0)p=o.value,pd(p.url,ps)}catch(M){b=!0,e=M}finally{try{M||null==z.return||z.return()}finally{if(b)throw e}}return[2]})}),function(){return U.apply(this,arguments)}),pu=function(M){pp(!1,M).then(function(){})},pl=function(){o1.selected_day_id=document.activeElement.getAttribute("data-id"),Mc=oP.filter(function(M){return M.UID==o1.selected_day_id})[0]};b(Mv).getItem("event_templates").then(function(M){if(null==M)return oI=[],!1;oI=M}).catch(function(M){console.log(M)});var pf=function(M,e,z,o){var p={id:MT(32),title:M,description:e,location:z,category:o};oI.push(p),b(Mv).setItem("event_templates",oI).then(function(M){Mj("template saved",2e3),oJ()}).catch(function(M){console.log(M)})},pW=new Date,ph=pW.getMonth(),pR=pW.getFullYear(),pm=pW.getDate(),pL=function(M){var e=M?b(Mw)().unix():b(Mw)(o1.selected_day).unix();if(0===oP.length)return document.getElementById("events-wrapper").innerHTML="You haven't made any calendar entries yet.",!1;var z=0,o=function(){setTimeout(function(){document.querySelectorAll('div#events-wrapper article[data-id="'+z+'"]')[0].focus();var M=document.activeElement.getBoundingClientRect(),b=M.top-document.body.getBoundingClientRect().top+M.height/2;document.activeElement.parentNode.scrollBy({left:0,top:b-window.innerHeight/2,behavior:"smooth"})},1e3)};try{var p=oP.findIndex(function(M){return M.dateStartUnix===e});z=oP[p-1].UID,o()}catch(M){!function(){try{var M=oP.findIndex(function(M){return M.dateStartUnix=o&&!b.RRULE.freq});if(b.event=e.length>0,b.event_data=e,e.length>1){for(var z=e.sort(function(M,b){return new Date(M.dateStart).getTime()-new Date(b.dateStart).getTime()}),o=1;o=new Date(z[o].dateStart).getTime()){b.multidayevent=!0,b.event_data=e;break}}return b},pv=function(M){var b={date:"",event:!1,subscription:!1,multidayevent:!1,rrule:"none",event_data:""},e=!0,z=!1,o=void 0;try{for(var p,c=oP[Symbol.iterator]();!(e=(p=c.next()).done);e=!0){var t=p.value;if("object"==typeof t){b.event=!1,b.multidayevent=!1,b.rrule=!1,b.date=M,b.event_data="";var n=new Date(t.dateStart).getTime(),O=new Date(t.dateEnd).getTime(),r=new Date(M).getTime(),a=t.RRULE.freq;if(void 0!==t.RRULE&&null!==t.RRULE&&(void 0==t.RRULE.until&&void 0==t.RRULE.count&&(O=new Date("3000-01-01").getTime()),n===r||nr))switch(b.event_data=t,a){case"MONTHLY":if(new Date(t.dateStart).getDate()===new Date(M).getDate())return b.event=!0,b.rrule=!0,b;break;case"WEEKLY":if(new Date(t.dateStart).getDay()===new Date(M).getDay())return b.rrule=!0,b.event=!0,b;break;case"BIWEEKLY":if(Math.floor((r-n)/864e5)%14==0)return b.rrule=!0,b.event=!0,b;break;case"YEARLY":var i=new Date(t.dateStart),A=new Date(M);if(i.getDate()===A.getDate()&&i.getMonth()===A.getMonth())return b.rrule=!0,b.event=!0,b}}}}catch(M){z=!0,o=M}finally{try{e||null==c.return||c.return()}finally{if(z)throw o}}return b},pg=[],pN=0,py=function(){++pN>document.querySelectorAll("div#event-slider article").length-1&&(pN=0);var M=document.querySelectorAll("div#event-slider-indicator div div");document.querySelectorAll("div#event-slider article").forEach(function(M){M.style.display="none"}),document.querySelectorAll("div#event-slider article")[pN].style.display="block",M.forEach(function(M){M.classList.remove("active")}),M[pN].classList.add("active")},pX=function(M){pg=[];var e=document.querySelector("div#event-slider-indicator div");e.innerHTML="",document.querySelector("div#event-slider").innerHTML="";for(var z=0;z=c)&&pg.push(oP[z]);else if(null!=oP[z].RRULE&&void 0==oP[z].RRULE.until&&void 0==oP[z].RRULE.count&&(p=new Date("3000-01-01").getTime()),o===c||p===c||oc){if("YEARLY"==t){var n=new Date(oP[z].dateStart),O=new Date(M);n.getDate()+"-"+n.getMonth()==O.getDate()+"-"+O.getMonth()&&pg.push(oP[z])}"WEEKLY"==t&&new Date(oP[z].dateStart).getDay()==new Date(M).getDay()&&pg.push(oP[z]),"BIWEEKLY"==t&&Math.floor((c-o)/864e5)%14==0&&pg.push(oP[z]),"MONTHLY"==t&&new Date(oP[z].dateStart).getDate()==new Date(M).getDate()&&pg.push(oP[z]),"DAILY"==t&&(o===c||p===c||oc)&&pg.push(oP[z])}}if(pg.length>=0&&(pg.forEach(function(M){e.insertAdjacentHTML("beforeend","
");var z="";M.allDay||(z=b(Mw).unix(M.dateStartUnix).format("HH:mm")),document.querySelector("div#event-slider").insertAdjacentHTML("beforeend","
"+M.SUMMARY+"
"+z+"
")}),pg.length>0))try{document.querySelectorAll("div#event-slider article")[0].style.display="block"}catch(M){console.log(M)}document.querySelectorAll("div.indicator").length<=1||void 0==document.querySelectorAll("div.indicator").length?document.getElementById("event-slider-indicator").style.opacity=0:(document.getElementById("event-slider-indicator").style.opacity=1,document.querySelector("div#event-slider article").style.display="block",document.querySelectorAll("div#event-slider .indicator")[0].style.classList.add("active"))},pT=function(){ph=pW.getMonth(),pR=pW.getFullYear(),pk(ph,pR),setTimeout(function(){o1.selected_day=b(Mw)().format("YYYY-MM-DD"),pX(o1.selected_day)},1e3)},pw=function(){if("/page_calendar"!=b(M3).route.get())return!1;setTimeout(function(){document.querySelectorAll("div#calendar div.calendar-head div").forEach(function(M){M.classList.remove("active")}),document.querySelectorAll("span.weeknumber").forEach(function(M){M.classList.remove("active")});var M=new Date(document.activeElement.getAttribute("data-date")).getDay();document.activeElement.closest("div.row").querySelector("span.weeknumber").classList.add("active"),"monday"==o2.firstday&&-1==(M-=1)&&(M=6),document.querySelectorAll("div#calendar div.calendar-head div")[M].classList.add("active")},200)};Date.prototype.getWeek=function(){var M=new Date(this.getTime());M.setHours(0,0,0,0),M.setDate(M.getDate()+3-(M.getDay()+6)%7);var b=new Date(M.getFullYear(),0,4);return 1+Math.round(((M.getTime()-b.getTime())/864e5-3+(b.getDay()+6)%7)/7)};var pk=function(M,b){document.getElementById("monthAndYear").textContent=oZ[M]+" "+b;var e=new Date(b,M).getDay();"monday"==o2.firstday&&(0==e?e=6:e-=1);var z=32-new Date(b,M,32).getDate(),o=document.getElementById("calendar-body");o.innerHTML="";for(var p=1,c=0;c<6;c++)!function(c){var t=document.createElement("div");t.classList.add("flex"),t.classList.add("row"),t.setAttribute("data-weeknumber",c),t.classList.add("width-100");for(var n=0;n<7;n++)if(0===c&&nz)break;else{var a=document.createElement("div"),i=document.createElement("span"),A=document.createElement("div"),d=document.createTextNode(p);a.appendChild(d),a.appendChild(i),a.setAttribute("tabindex",p-1),a.classList.add("calendar-cell");var s=b+"-"+"0".concat(M+1).slice(-2)+"-"+"0".concat(p).slice(-2);A.classList.add("moon-phase-"+function(M,b,e){var z,o,p,c=p=o=z=0;return b<3&&(M--,b+=12),++b,z=parseInt(o=((c=365.25*M)+(p=30.6*b)+e-694039.09)/29.5305882),o-=z,(z=Math.round(8*o))>=8&&(z=0),z}(b,M,p)),a.appendChild(A),a.setAttribute("data-date",s),a.classList.add("item"),t.appendChild(a),p++}var q=document.createElement("span");q.classList.add("weeknumber");var u=document.createTextNode("monday"==o2.firstday?new Date(b,M,p-1).getWeek():new Date(b,M,p).getWeek());q.appendChild(u),t.appendChild(q),o.appendChild(t)}(c);document.querySelectorAll(".item")[0].focus(),o1.selected_day=document.activeElement.getAttribute("data-date"),pW.getMonth()==M&&pW.getFullYear()==b&&(document.querySelectorAll(".item")[pm-1].focus(),document.querySelectorAll(".item")[pm-1].classList.add("today")),pw(),pM(pR,ph)},pC=function(){document.querySelectorAll("div#add-edit-event input").forEach(function(M){M.value=""})},pE=function(M){var b=M.toUpperCase();if(b.length<1)return!1;document.querySelectorAll("#events-wrapper article").forEach(function(M){M.getAttribute("data-summary").indexOf(b)>=0||M.getAttribute("data-category").indexOf(b)>=0?M.style.display="block":M.style.display="none"}),cM()},p_=function(M){var b=M.toUpperCase();document.querySelectorAll("#events-wrapper article").forEach(function(M){M.getAttribute("data-category").indexOf(b)>=0?M.style.display="block":M.style.display="none"}),cM(),document.getElementById("search").focus()},pS=function(){if(null==document.querySelectorAll(".select-box"))return!1;document.querySelectorAll(".select-box").forEach(function(M){M.addEventListener("blur",function(b){setTimeout(function(){M.parentElement.focus()},200)})})},pD=document.getElementById("app"),pP="",px=null,pI=function(M){document.getElementById(px).value=M},pU=[],pj=function(M){pU.push(M)},pF=function(M){try{"serviceWorker"in navigator&&navigator.serviceWorker.controller&&(collectionOfData={data:M,etag:"",url:""},navigator.serviceWorker.controller.postMessage({type:"parse",t:collectionOfData,e:"local-id",callback:!0,store:!0}))}catch(M){alert("event could not be imported because the file content is invalid"+M)}};!1==o1.background_sync_running&&(b(M3).route(pD,"/page_calendar",{"/page_calendar":{view:function(){return b(M3)("div",{class:"width-100 height-100",id:"calendar",oninit:function(){oQ(),o9(),pC(),MJ(),document.querySelector("#version").textContent=localStorage.getItem("version")}},[b(M3)("div",{class:"flex justify-content-spacebetween",id:""},[b(M3)("h3",{class:"card-header",id:"monthAndYear"},""),b(M3)("img",{id:"icon-loading",src:"./assets/image/E252.svg",alt:"loading"}),b(M3)("img",{id:"icon-waiting",src:"./assets/image/waiting.png",alt:"loading"}),b(M3)("div",{id:"time",oncreate:function(){document.getElementById("time").innerText=b(Mw)().format("HH:mm")}},o1.version)]),b(M3)("div",{class:"calendar-head flex width-100"},[b(M3)("div",o0[0]),b(M3)("div",o0[1]),b(M3)("div",o0[2]),b(M3)("div",o0[3]),b(M3)("div",o0[4]),b(M3)("div",o0[5]),b(M3)("div",o0[6])]),b(M3)("div",{id:"calendar-body"}),b(M3)("div",{id:"event-slider-indicator",class:"flex width-100 justify-content-spacearound"},[b(M3)("div",{class:"flex justify-content-spacearound"})]),b(M3)("div",{id:"event-slider",class:"flex "},[b(M3)("div",{id:"slider-inner",class:"flex width-100 justify-content-spacearound"})])])},onbeforeremove:function(){o1.selected_day=document.activeElement.getAttribute("data-date")},oncreate:function(){setTimeout(function(){document.activeElement.hasAttribute("data-date")&&(o1.selected_day=document.activeElement.getAttribute("data-date")),MY("","","");var M=new Date(o1.selected_day);ph=M.getMonth(),pR=M.getFullYear(),pk(ph,pR),document.querySelectorAll("div#calendar-body div.item").forEach(function(M){if(M.getAttribute("data-date")==o1.selected_day){M.focus(),pX(o1.selected_day);return}}),!1==o1.startup&&(pX(o1.selected_day),pT(),o1.startup=!0)},200)}},"/page_events":{view:function(){return b(M3)("div",{class:"flex",id:"events-wrapper",oninit:function(){document.querySelector(".loading-spinner").style.display="block",oQ(),o1.shortCut=!1},onremove:function(){o1.selected_day=document.activeElement.getAttribute("data-date"),o1.selected_day_id=document.activeElement.getAttribute("data-id")},oncreate:function(){document.querySelector(".loading-spinner").style.display="none",pL(),MY("","","")}},b(M3)("input",{type:"search",class:"width-98 item",id:"search",tabIndex:0,onfocus:function(){window.scroll({top:20,left:0,behavior:"smooth"})},oninput:function(){pE(document.activeElement.value)}}),b(M3)("div",{id:"filter-menu",class:"flex justify-content-spacearound",oncreate:function(M){M.dom.style.display="none"},onfocus:function(){window.scroll({top:20,left:0,behavior:"smooth"})}},[b(M3)("button",{class:"item",tabindex:0,"data-action":"filter-last-modified",oncreate:function(M){M.dom.style.display="none"}},"last edited"),b(M3)("button",{class:"item",tabindex:0,"data-action":"filter-desc",oncreate:function(M){M.dom.style.display="none"}},"the latest"),b(M3)("button",{class:"item",tabindex:0,"data-action":"filter-asc",oncreate:function(M){M.dom.style.display="none"}},"the oldest"),b(M3)("button",{class:"item category-filter-button",tabindex:0,"data-action":"filter-category",oncreate:function(M){M.dom.style.display="none",void 0!==o2.eventsfilter&&(document.querySelector(".category-filter-button").style.display="flex")}},"show only category: "+o2.eventsfilter)]),[oP.map(function(M,e){var z,o="";o=M.allDay?"all day":b(Mw)(1e3*M.dateStartUnix).format("HH:mm");var p="sunday"==o2.firstday?o0[b(Mw)(1e3*M.dateStartUnix).day()]:o0[b(Mw)(1e3*M.dateStartUnix).day()-1];void 0==p&&(p=""),z=null==M.dateStartUnix||null==M.dateEndUnix||b(Mw)(1e3*M.dateStartUnix).format(o2.dateformat)==b(Mw)(1e3*M.dateEndUnix).format(o2.dateformat)||M.allDay?b(Mw)(1e3*M.dateStartUnix).format(o2.dateformat)+" | "+p:b(Mw)(1e3*M.dateStartUnix).format(o2.dateformat)+" - "+b(Mw)(1e3*M.dateEndUnix).format(o2.dateformat);var c="";M.RRULE&&M.RRULE.freq&&(c=M.RRULE.freq.toLowerCase());var t=M.isSubscription?"subscription":"",n=M.allDay?"allDay":"";return b(M3)("article",{class:"item events "+t+" "+n,tabindex:0,"data-id":M.UID,"data-date":b(Mw)(1e3*M.dateStartUnix).format("YYYY-MM-DD"),"data-category":(M.CATEGORIES||"").toUpperCase(),"data-summary":(M.SUMMARY||"").toUpperCase(),"data-calendar-name":M.calendar_name||""},[b(M3)("div",{class:"icons-bar"},[b(M3)("div",{class:"date"},z),b(M3)("div",{class:"time"},o),b(M3)("div",{class:"rrule-freq"},c),b(M3)("h2",{class:"summary"},M.SUMMARY),b(M3)("div",{class:"location"},M.LOCATION),b(M3)("div",{class:"description"},M.DESCRIPTION)])])})])}},"/page_options":{view:function(){return b(M3)("div",{id:"options",oninit:function(){oQ(),o1.shortCut=!1},oncreate:function(){o1.notKaiOS||oE(),MY("","","")}},[b(M3)("h2",{class:"item",tabIndex:0},"Key assignment"),b(M3)("ul",{id:"keys",class:"item width-100",tabindex:"1",oncreate:function(M){var b=M.dom;MY("","",""),document.querySelectorAll(".select-box").forEach(function(M){M.addEventListener("keypress",function(){setTimeout(function(){M.parentElement.focus()},200)})}),b.focus()}},[b(M3)("li",{class:"flex justify-content-spacebetween"},[b(M3)("kbd","1 & 3"),b(M3)("div","Month")]),b(M3)("li",{class:"flex justify-content-spacebetween"},[b(M3)("kbd","2"),b(M3)("div","Event slider")]),b(M3)("li",{class:"width-100 flex justify-content-spacebetween"},[b(M3)("kbd","5"),b(M3)("div","Edit event")]),b(M3)("li",{class:"width-100 flex justify-content-spacebetween"},[b(M3)("kbd","Enter"),b(M3)("div","Events/Month")]),b(M3)("li",{class:"width-100 flex justify-content-spacebetween"},[b(M3)("kbd","0"),b(M3)("div","Events filtered by category")]),b(M3)("li",{class:"width-100 flex justify-content-spacebetween"},[b(M3)("kbd","#"),b(M3)("div","Moon")]),b(M3)("li",{class:"width-100 flex justify-content-spacebetween"},[b(M3)("kbd","*"),b(M3)("div","Today")]),b(M3)("li",{class:"width-100 flex justify-content-spacebetween"},[b(M3)("kbd","SoftLeft longpress"),b(M3)("div",{},"create event from template")]),b(M3)("li",{class:"width-100 flex justify-content-spacebetween"},[b(M3)("span",{class:"keys-day-event"}),b(M3)("span","day with event")]),b(M3)("li",{class:"width-100 flex justify-content-spacebetween"},[b(M3)("span",{class:"keys-day-multi-event"}),b(M3)("span","day with several events")]),b(M3)("li",{class:"width-100 flex justify-content-spacebetween"},[b(M3)("span",{class:"keys-day-rrule-event"}),b(M3)("span","day with reccurence")])]),b(M3)("h2",{class:"item",tabindex:"2"},"Settings"),b(M3)("div",{class:"text-center"},"Timezone: "+o2.timezone),b(M3)("div",{class:"item input-parent",id:"event-date-format-box",tabindex:"3"},[b(M3)("label",{for:"event-date-format"},"dateformat"),b(M3)("select",{id:"event-date-format",class:"select-box",onchange:function(){pY()},oncreate:function(){o9(),setTimeout(function(){pS(),""==o2.dateformat?document.querySelector("#event-date-format").value="YYYY-MM-DD":document.querySelector("#event-date-format").value=o2.dateformat},1e3)}},[b(M3)("option",{value:"YYYY-MM-DD"},"YYYY-MM-DD"),b(M3)("option",{value:"DD.MM.YYYY"},"DD.MM.YYYY")])]),b(M3)("div",{class:"item input-parent",id:"background-sync-box",tabindex:"3"},[b(M3)("label",{for:"background-syn-box"},"Background sync ?"),b(M3)("select",{id:"background-sync",class:"select-box",onchange:function(){pY()},oncreate:function(){"b2g"in navigator&&(document.getElementById("background-sync-box").style.display="none"),o9(),setTimeout(function(){pS(),"No"==o2.background_sync?document.querySelector("#background-sync").value="No":document.querySelector("#background-sync").value="Yes"},1e3)}},[b(M3)("option",{value:"Yes"},"Yes"),b(M3)("option",{value:"No"},"No")]),b(M3)("div",{class:"last-sync-info"},"last sync: "+oF)]),b(M3)("div",{class:"item input-parent",id:"firs-day-of-the-week-box",tabindex:"4"},[b(M3)("label",{for:"first-day-of-the-week"},"first day of the week"),b(M3)("select",{id:"first-day-of-the-week",class:"select-box",onchange:function(){pY()},oncreate:function(){setTimeout(function(){pS(),""==o2.firstday||void 0==o2.firstday?document.querySelector("#first-day-of-the-week").value="sunday":document.querySelector("#first-day-of-the-week").value=o2.firstday},1e3)}},[b(M3)("option",{value:"sunday"},"Sunday"),b(M3)("option",{value:"monday"},"Monday")])]),b(M3)("div",{class:"item input-parent",id:"event-duration-wrapper",tabindex:"5"},[b(M3)("label",{for:"default-duration-time"},"default Duration"),b(M3)("select",{id:"default-duration-time",class:"select-box",onchange:function(){pY()},oncreate:function(){o9(),setTimeout(function(){pS(),document.querySelector("#default-duration-time").value=o2.default_duration},1e3)}},[b(M3)("option",{value:"30"},"30 minutes"),b(M3)("option",{value:"60"},"60 minutes"),b(M3)("option",{value:"120"},"120 minutes"),b(M3)("option",{value:"240"},"240 minutes")])]),b(M3)("div",{class:"item input-parent",id:"event-notification-time-wrapper",tabindex:"5"},[b(M3)("label",{for:"default-notification"},"default Notification"),b(M3)("select",{id:"default-notification-time",class:"select-box",onchange:function(){pY()},oncreate:function(){o9(),setTimeout(function(){pS(),""==o2.default_notification?document.querySelector("#default-notification-time").value="none":document.querySelector("#default-notification-time").value=o2.default_notification},1e3)}},[b(M3)("option",{value:"none"},"none"),b(M3)("option",{value:"5"},"5 minutes"),b(M3)("option",{value:"10"},"10 minutes"),b(M3)("option",{value:"30"},"30 minutes"),b(M3)("option",{value:"1440"},"1 Day")])]),b(M3)("button",{class:"item",tabindex:"6",oncreate:function(){pU=[],MV("ics",pj)},onclick:function(){b(M3).route.set("/page_list_files")}},"Import events"),b(M3)("button",{class:"item",tabindex:"7",onclick:function(){setTimeout(function(){pp(!0,!1)},1e3),Mj("the big loading has begun",2e3)}},"Reload all events"),b(M3)("h2","Subscriptions"),b(M3)("button",{class:"item",tabindex:"8",onclick:function(){b(M3).route.set("/page_subscriptions")}},"add subscription"),b(M3)("div",{id:"subscription-text"},"Your subscriptions"),null!=oY?oY.map(function(M,e){return b(M3)("button",{class:"item subscriptions-item","data-id":M.id,"data-action":"delete-subscription",tabindex:e+8,onfocus:function(){MY("","","")},onblur:function(){MY("","","")}},M.name)}):b(M3)("div",{class:"text-center"},"No subscriptions available"),b(M3)("h2","Category view"),b(M3)("div",{class:"item input-parent",id:"events-category-filter-wrapper",tabindex:""},[b(M3)("label",{for:"events-category-filter"},"Select the category"),b(M3)("select",{id:"events-category-filter",class:"select-box",onchange:function(){pY()},oncreate:function(){setTimeout(function(){pS(),document.querySelector("#events-category-filter").value=o2.eventsfilter},1e3)}},oP.length>0?[b(M3)("option",{value:"-"},"-")].concat(Mm(oP.map(function(M){return M.CATEGORIES}).filter(function(M,b,e){return""!==M&&e.indexOf(M)===b}).map(function(M){return b(M3)("option",{value:M},M)}))):[b(M3)("option",{value:"-"},"No categories available")])]),b(M3)("h2","Calendars"),null!=Mp?Mp.map(function(M){return b(M3)("button",{class:"item","data-calendar-name":M.name,oncreate:function(b){var e=b.dom;!1==M.view&&e.classList.add("active"),"local"==M.name&&(e.style.display="none")},onclick:function(){Mp.forEach(function(M){M.name==document.activeElement.getAttribute("data-calendar-name")&&(M.view=!M.view)}),document.activeElement.classList.toggle("active"),b(Mv).setItem("calendarNames",Mp).then(function(){o5(),Mj("will be applied the next time the app is started",2e3)})}},M.name)}):"",,b(M3)("h2","Accounts"),b(M3)("button",{class:"item google-button caldav-button",onclick:function(){b(M3).route.set("/page_accounts")}},[b(M3)("div",{class:"flex align-item-center justify-content-spacebetween "},[b(M3)("img",{src:"assets/image/caldav.png"}),b(M3)("span","CalDAV Account")])]),b(M3)("button",{class:"item google-button",onclick:function(){o$=setInterval(function(){"true"==localStorage.getItem("oauth_callback")&&(b(M3).route.set("/page_calendar"),clearInterval(o$),setTimeout(function(){ox=[],b(Mv).getItem("accounts").then(function(M){if(null==M)return ox=[],!1;ox=M,pp(!1,!1)}).catch(function(M){console.log(M)})},5e3))},1e3),window.open("https://accounts.google.com/o/oauth2/v2/auth?client_id=762086220505-f0kij4nt279nqn21ukokm06j0jge2ngl.apps.googleusercontent.com&response_type=code&state=state_parameter_passthrough_value&scope=https://www.googleapis.com/auth/calendar%20https://www.googleapis.com/auth/calendar.calendarlist&redirect_uri=https://greg.strukturart.com/index.html&access_type=offline&prompt=consent")}},[b(M3)("div",{class:"flex justify-content-spacebetween align-item-center "},[b(M3)("img",{src:"assets/image/google_button.png"}),b(M3)("span","Sign in with Google")])]),null!=ox?b(M3)("div",{id:"subscription-text"},"Your accounts"):"",null!=ox?ox.map(function(M){return b(M3)("button",{class:"item subscriptions-item","data-id":M.id,"data-account-type":M.type,"data-action":"edit-delete-account",onblur:function(){MY("","","")},onfocus:function(){"oauth"==M.type?MY("","",""):MY("","","")}},M.name)}):"",b(M3)("h2",{class:"ads-title"},"Ads"),b(M3)("div",{id:"KaiOsAds-Wrapper",class:"flex justify-content-spacearound",oninit:function(){o2.ads||document.querySelector("h2.ads-title").remove()},oncreate:function(){},onfocus:function(){MY("","open ads","")},onblur:function(){MY("","open ads","")}})])}},"/page_add_event":{view:function(){return b(M3)("div",{id:"add-edit-event",tabindex:"0",oninit:function(){oQ(),o1.shortCut=!1}},[b(M3)("div",{class:"item input-parent",tabindex:0,oncreate:function(M){var b=M.dom;setTimeout(function(){b.focus(),MY("","","")},500)}},[b(M3)("label",{for:"event-title"},"Title"),b(M3)("input",{placeholder:"",type:"text",id:"event-title",oncreate:function(){o9(),pZ()},onfocus:function(){px="event-title",MY("","","")},onblur:function(){px="event-title",MY("","","")}})]),b(M3)("div",{class:"item input-parent",tabindex:"1"},[b(M3)("label",{for:"event-location"},"Location"),b(M3)("input",{placeholder:"",type:"text",id:"event-location",oninput:function(M){Mk(M.target.value,"LOCATION")}})]),b(M3)("div",{id:"search-result"}),b(M3)("div",{class:"item input-parent",tabindex:"2",onfocus:function(){Mk("close")}},[b(M3)("label",{for:"event-date"},"Start Date"),b(M3)("input",{placeholder:o2.dateformat,type:"date",id:"event-date",class:"select-box",oncreate:function(M){M.dom.value=o1.selected_day}})]),b(M3)("div",{class:"item input-parent",tabindex:"3"},[b(M3)("label",{for:"event-date-end"},"End Date"),b(M3)("input",{placeholder:o2.dateformat,type:"date",id:"event-date-end",class:"select-box",oncreate:function(M){M.dom.min=o1.selected_day}})]),b(M3)("div",{class:"item input-parent flex justify-content-center",tabindex:"4"},[b(M3)("label",{for:"event-all-day"},"All Day"),b(M3)("input",{type:"checkbox",id:"event-all-day",class:"check-box",onfocus:function(M){!1==M.target.checked?(setTimeout(function(){document.querySelector(".check-box").parentElement.focus()},300),document.querySelectorAll(".time").forEach(function(M){document.querySelector("#event-time-start").value="01:00",document.querySelector("#event-time-end").value="01:00",M.style.display="none",M.classList.remove("item"),cM()})):(setTimeout(function(){document.querySelector(".check-box").parentElement.focus()},300),document.querySelectorAll(".time").forEach(function(M){M.style.display="block",M.classList.add("item"),cM()}))}}),b(M3)("div",{class:"ckb-wrapper"},[b(M3)("div",{class:"ckb-icon"}),b(M3)("div",{class:"toogle-button"})])]),b(M3)("div",{class:"item input-parent time",tabindex:"4"},[b(M3)("label",{for:"event-time-start"},"Start Time"),b(M3)("input",{placeholder:"hh:mm",type:"time",id:"event-time-start",class:"select-box",oncreate:function(M){M.dom.value=b(Mw)().format("HH:mm")}})]),b(M3)("div",{class:"item input-parent time",tabindex:"5"},[b(M3)("label",{for:"event-time-end"},"End Time"),b(M3)("input",{placeholder:"hh:mm",type:"time",id:"event-time-end",class:"select-box",onblur:function(M){var e=document.querySelector("#event-date").value,z=""!=document.querySelector("#event-date-end").value?document.querySelector("#event-date-end").value:document.querySelector("#event-date").value,o=b(Mw)(e+" "+document.querySelector("#event-time-start").value);!1==b(Mw)(z+" "+M.target.value).isAfter(o)&&Mj("something is wrong with the time",2e3)},oncreate:function(M){var e=M.dom;console.log(o2.default_duration),e.value=b(Mw)().add(o2.default_duration,"minutes").format("HH:mm")}})]),b(M3)("div",{class:"item input-parent",tabindex:"6"},[b(M3)("label",{for:"event-description"},"Description"),b(M3)("input",{placeholder:"",type:"text",id:"event-description"})]),b(M3)("div",{class:"item input-parent",tabindex:"6"},[b(M3)("label",{for:"event-category"},"Category"),b(M3)("input",{placeholder:"",type:"text",id:"event-category"})]),b(M3)("div",{class:"item input-parent",id:"event-notification-time-wrapper",tabindex:"7"},[b(M3)("label",{for:"notification"},"Notification"),b(M3)("select",{id:"event-notification-time",class:"select-box",oncreate:function(){setTimeout(function(){document.querySelector("#event-notification-time").value=o2.default_notification},2e3)}},[b(M3)("option",{value:"none"},"none"),b(M3)("option",{value:"5"},"5 minutes"),b(M3)("option",{value:"10"},"10 minutes"),b(M3)("option",{value:"30"},"30 minutes"),b(M3)("option",{value:"60"},"60 minutes"),b(M3)("option",{value:"1440"},"1 Day")])]),b(M3)("div",{class:"item input-parent",id:"event-recur-wrapper",tabindex:"8",oncreate:function(){setTimeout(function(){document.querySelector("#event-recur").value="none"},1e3)}},[b(M3)("label",{for:"event-recur"},"Recur"),b(M3)("select",{id:"event-recur",class:"select-box"},[b(M3)("option",{value:"none"},"none"),b(M3)("option",{value:"DAILY"},"Daily"),b(M3)("option",{value:"WEEKLY"},"Weekly"),b(M3)("option",{value:"BIWEEKLY"},"Biweekly"),b(M3)("option",{value:"MONTHLY"},"Monthly"),b(M3)("option",{value:"YEARLY"},"Yearly")])]),b(M3)("div",{class:"item input-parent",id:"event-calendar-wrapper",tabindex:"9"},[b(M3)("label",{for:"event-calendar"},"Calendars"),b(M3)("select",{id:"event-calendar",class:"select-box"},[Mp.map(function(M){return b(M3)("option",{value:M.id,"data-calendar-data":M.data},M.name)})])]),b(M3)("button",{tabindex:"10",id:"save-event",class:"item save-button",oncreate:function(){pS(),cM()},onclick:function(){var M=document.getElementById("event-calendar");p8(M.options[M.selectedIndex].value,M.options[M.selectedIndex].text)}},"save")])},oncreate:function(){MY("","","")}},"/page_edit_event":{view:function(){var M;return b(M3)("div",{id:"add-edit-event",oninit:function(){},omcreate:function(){oQ(),o1.shortCut=!1}},[b(M3)("div",{class:"item input-parent",tabindex:0,oncreate:function(M){var b=M.dom;setTimeout(function(){b.focus(),MY("","","")},500)}},[b(M3)("label",{for:"event-title"},"Title"),b(M3)("input",{placeholder:"",type:"text",id:"event-title",value:Mc.SUMMARY})]),b(M3)("div",{class:"item input-parent",tabindex:"1"},[b(M3)("label",{for:"event-location"},"Location"),b(M3)("input",{placeholder:"",type:"text",id:"event-location",value:Mc.LOCATION})]),b(M3)("div",{class:"item input-parent",tabindex:"2"},[b(M3)("label",{for:"event-date"},"Start Date"),b(M3)("input",{placeholder:o2.dateformat,type:"date",id:"event-date",class:"select-box",oncreate:function(M){M.dom.value=Mc.dateStart}})]),b(M3)("div",{class:"item input-parent",tabindex:"3"},[b(M3)("label",{for:"event-date-end"},"End Date"),b(M3)("input",{placeholder:o2.dateformat,type:"date",id:"event-date-end",class:"select-box",oncreate:function(M){M.dom.value=Mc.dateEnd}})]),b(M3)("div",{class:"item input-parent",tabindex:"4"},[b(M3)("label",{for:"event-all-day"},"All Day"),b(M3)("input",{type:"checkbox",id:"event-all-day",class:"check-box",oncreate:function(){!0==Mc.allDay&&(document.querySelector("#event-all-day").checked=!0,document.querySelectorAll(".time").forEach(function(M){M.style.display="none",M.classList.remove("item"),cM()}))},onfocus:function(M){!1==M.target.checked?(setTimeout(function(){M.focus()},300),document.querySelectorAll(".time").forEach(function(M){M.style.display="none",M.classList.remove("item"),document.querySelector("#event-time-start").value="01:00",document.querySelector("#event-time-end").value="01:00",cM()})):(setTimeout(function(){M.focus()},300),document.querySelectorAll(".time").forEach(function(M){M.style.display="block",M.classList.add("item"),cM()}))}}),b(M3)("div",{class:"ckb-wrapper"},[b(M3)("div",{class:"ckb-icon"}),b(M3)("div",{class:"toogle-button"})])]),b(M3)("div",{class:"item input-parent time",tabindex:"4"},[b(M3)("label",{for:"event-time-start"},"Start Time"),b(M3)("input",{placeholder:"HH:mm",type:"time",id:"event-time-start",class:"select-box",value:8==Mc.time_start.length?Mc.time_start.slice(0,-3):Mc.time_start})]),b(M3)("div",{class:"item input-parent time",tabindex:"5"},[b(M3)("label",{for:"event-time-end"},"End Time"),b(M3)("input",{placeholder:"hh:mm",type:"time",id:"event-time-end",class:"select-box",value:8==Mc.time_end.length?Mc.time_end.slice(0,-3):Mc.time_end})]),b(M3)("div",{class:"item input-parent",tabindex:"6"},[b(M3)("label",{for:"event-description"},"Description"),b(M3)("input",{placeholder:"",type:"text",id:"event-description",value:Mc.DESCRIPTION})]),b(M3)("div",{class:"item input-parent",tabindex:"6"},[b(M3)("label",{for:"event-category"},"Category"),b(M3)("input",{placeholder:"",type:"text",id:"event-category",value:Mc.CATEGORIES})]),b(M3)("div",{class:"item input-parent",id:"event-notification-time-wrapper",tabindex:"7"},[b(M3)("label",{for:"notification"},"Notification"),b(M3)("select",{id:"event-notification-time",class:"select-box"},[b(M3)("option",{value:"none"},"none"),b(M3)("option",{value:"5"},"5 minutes"),b(M3)("option",{value:"10"},"10 minutes"),b(M3)("option",{value:"30"},"30 minutes"),b(M3)("option",{value:"60"},"60 minutes"),b(M3)("option",{value:"1440"},"1 Day")])]),b(M3)("div",{class:"item input-parent",id:"event-calendar-wrapper",tabindex:"9"},[b(M3)("label",{for:"event-calendar"},"Calendars"),b(M3)("select",{id:"event-calendar",class:"select-box",onchange:function(){o1.event_calendar_changed=!0}},[Mp.map(function(M){var e="";return Mc.calendar_name==M.name&&(e="selected"),b(M3)("option",{value:M.id,selected:e,"data-calendar-data":M.data},M.name)})])]),b(M3)("div",{class:"item input-parent",id:"event-recur-wrapper",tabindex:"8",oncreate:function(){document.querySelector("#event-notification-time").value=Mc.alarm}},[b(M3)("label",{for:"event-recur"},"Recur"),b(M3)("select",{id:"event-recur",value:null!==(M=Mc.RRULE.freq)&&void 0!==M?M:"none",class:"select-box"},[b(M3)("option",{value:"none"},"none"),b(M3)("option",{value:"DAILY"},"Daily"),b(M3)("option",{value:"WEEKLY"},"Weekly"),b(M3)("option",{value:"BIWEEKLY"},"Biweekly"),b(M3)("option",{value:"MONTHLY"},"Monthly"),b(M3)("option",{value:"YEARLY"},"Yearly")])]),b(M3)("button",{tabindex:"9",id:"delete-event",class:"item",onclick:function(){p9(Mc.etag,Mc.url,Mc.id,Mc.UID)}},"delete"),b(M3)("button",{tabindex:"10",id:"save-event",class:"item save-button",oncreate:function(){pS()},onclick:function(){if(o1.event_calendar_changed||p7(Mc.etag,Mc.url,Mc.id,Mc.UID,Mc.calendar_name),o1.event_calendar_changed){var M=document.getElementById("event-calendar");p9(Mc.etag,Mc.url,Mc.id,Mc.UID),p8(M.options[M.selectedIndex].value,M.options[M.selectedIndex].text)}}},"update"),b(M3)("button",{tabindex:"11",id:"save-event-as-template",class:"item save-template-button",oncreate:function(){pS()},onclick:function(){pf(document.getElementById("event-title").value,document.getElementById("event-description").value,document.getElementById("event-location").value,document.getElementById("event-category").value)}},"save as template")])}},"/page_subscriptions":{view:function(){return b(M3)("div",{id:"subscription-form"},[b(M3)("div",{class:"item input-parent",tabindex:"0",oninit:function(){MY("","",""),oQ(),o1.shortCut=!1},oncreate:function(M){M.dom.focus()}},[b(M3)("label",{for:"description"},"subscription name"),b(M3)("input",{placeholder:"Name",type:"text",id:"cal-subs-name"})]),b(M3)("div",{class:"item input-parent",tabindex:"1",onblur:function(){MY("","","")}},[b(M3)("label",{for:"description"},"subscription url"),b(M3)("input",{placeholder:"URL",type:"text",id:"cal-subs-url","data-scan-action":"true",onfocus:function(){MY("","","")},oncreate:function(){setTimeout(function(){document.getElementById("cal-subs-url").value=pP},1e3)},onblur:function(){MY("","","")}})]),b(M3)("button",{class:"item save-button",tabindex:"2",onclick:function(){pV()}},"save")])}},"/page_accounts":{view:function(){return b(M3)("div",{id:"account-form"},[b(M3)("div",{class:"item input-parent",tabindex:"0",oninit:function(){oQ()},oncreate:function(M){M.dom.focus()}},[b(M3)("label",{for:"description"},"account name"),b(M3)("input",{placeholder:"Name",type:"text",id:"account-name"})]),b(M3)("div",{class:"item input-parent",tabindex:"1",onblur:function(){MY("","","")}},[b(M3)("label",{for:"description"},"server"),b(M3)("input",{placeholder:"URL",type:"text",id:"account-url","data-scan-action":"true",onfocus:function(){MY("","","")},onblur:function(){MY("","","")}})]),b(M3)("div",{class:"item input-parent",tabindex:"2",onblur:function(){MY("","","")}},[b(M3)("label",{for:"description"},"username"),b(M3)("input",{placeholder:"username",type:"url",id:"account-username","data-scan-action":"true",onfocus:function(){MY("","","")},onblur:function(){MY("","","")}})]),b(M3)("div",{class:"item input-parent",tabindex:"3",onblur:function(){MY("","","")}},[b(M3)("label",{for:"description"},"password"),b(M3)("input",{placeholder:"password",type:"password",id:"account-password","data-scan-action":"true",onfocus:function(){MY("","","")},onblur:function(){MY("","","")}})]),b(M3)("button",{class:"item save-button",tabindex:"4",onclick:function(){pG()}},"save")])}},"/page_edit_account":{view:function(){return b(M3)("div",{id:"account-form"},[b(M3)("div",{class:"item input-parent",tabindex:"0",oninit:function(){},oncreate:function(M){M.dom.focus(),oQ(),o1.shortCut=!1}},[b(M3)("label",{for:"description"},"account name"),b(M3)("input",{placeholder:"Name",type:"text",id:"account-name",value:Mt.name})]),b(M3)("div",{class:"item input-parent",tabindex:"1",onblur:function(){MY("","","")}},[b(M3)("label",{for:"description"},"server"),b(M3)("input",{placeholder:"URL",type:"text",id:"account-url","data-scan-action":"true",value:Mt.server_url,onfocus:function(){MY("","","")},onblur:function(){MY("","","")}})]),b(M3)("div",{class:"item input-parent",tabindex:"2",onblur:function(){MY("","","")}},[b(M3)("label",{for:"description"},"username"),b(M3)("input",{placeholder:"username",type:"url",id:"account-username",value:Mt.user,"data-scan-action":"true",onfocus:function(){MY("","","")},onblur:function(){MY("","","")}})]),b(M3)("div",{class:"item input-parent",tabindex:"3",onblur:function(){MY("","","")}},[b(M3)("label",{for:"description"},"password"),b(M3)("input",{placeholder:"password",type:"password",id:"account-password","data-scan-action":"true",value:Mt.password,onfocus:function(){MY("","","")},onblur:function(){MY("","","")}})]),b(M3)("button",{class:"item save-button",tabindex:"4",onclick:function(){pG(!0,o1.edit_account_id)}},"update")])}},"/page_event_templates":{view:function(){return b(M3)("div",{id:"options",oninit:function(){oQ()},oncreate:function(){MY("","","")}},[b(M3)("h2",{class:"text-center"},"Templates"),oI.map(function(M,e){return b(M3)("button",{class:"item",onclick:function(){Mn=M.id,b(M3).route.set("/page_add_event")},oncreate:function(M){M.dom},tabIndex:e,"data-id":M.id},M.title)})])}},"/page_list_files":{view:function(){return b(M3)("div",{id:"options",oninit:function(){oQ()}},[b(M3)("h2",{class:"text-center",id:"file-head"},"files"),pU.map(function(M,e){var z=M.split("/");return z=z[z.length-1],b(M3)("button",{class:"item",oncreate:function(M){var b=M.dom;0==e&&b.focus()},tabIndex:e,onclick:function(){!function(M,b){try{var e=navigator.getDeviceStorage("sdcard"),z=e.get(M);z.onsuccess=function(){var M=this.result,e=new FileReader;e.onerror=function(M){helper.toaster("can't read file",3e3),e.abort()},e.onloadend=function(M){b(e.result)},e.readAsText(M)},z.onerror=function(){alert("Unable to get the file: "+this.error)}}catch(M){console.log(M)}if("b2g"in navigator)try{var e=navigator.b2g.getDeviceStorage("sdcard"),z=e.get(M).then(function(M){var e=new FileReader;e.onerror=function(M){console.log("filereader error: "+M),e.abort()},e.onloadend=function(M){b(e.result)},e.readAsText(M)})}catch(M){alert(M)}}(M,pF)}},z)})])}},"/page_events_filtered":{view:function(){var M=b(M3).route.param("query"),e=0;return b(M3)("div",{class:"flex",id:"events-wrapper",onremove:function(){o1.selected_day=document.activeElement.getAttribute("data-date"),o1.selected_day_id=document.activeElement.getAttribute("data-id")},oninit:function(){oQ(),o1.shortCut=!1,Mj("Category: "+M,8e3)},oncreate:function(){document.querySelectorAll(".item")[0].focus(),MY("","","")}},[oP.map(function(z){if(z.CATEGORIES&&z.CATEGORIES.toLowerCase()===M.toLowerCase()){e++;var o,p="";p=z.allDay?"all day":b(Mw)(1e3*z.dateStartUnix).format("HH:mm"),o=null==z.dateStartUnix||null==z.dateEndUnix||b(Mw)(1e3*z.dateStartUnix).format(o2.dateformat)==b(Mw)(1e3*z.dateStartUnix).format(o2.dateformat)||z.allDay?b(Mw)(1e3*z.dateStartUnix).format(o2.dateformat):b(Mw)(1e3*z.dateStartUnix).format(o2.dateformat)+" - "+b(Mw)(1e3*z.dateStartUnix).format(o2.dateformat);var c=z.isSubscription?"subscription":"",t=z.allDay?"allDay":"";return b(M3)("article",{class:"item events "+c+" "+t,tabindex:e,"data-id":z.UID,"data-date":b(Mw)(1e3*z.dateStartUnix).format("YYYY-MM-DD"),"data-category":(z.CATEGORIES||"").toUpperCase(),"data-summary":(z.SUMMARY||"").toUpperCase()},[b(M3)("div",{class:"icons-bar"},[b(M3)("div",{class:"date"},o),b(M3)("div",{class:"time"},p),b(M3)("h2",{class:"summary"},z.SUMMARY),b(M3)("div",{class:"location"},z.LOCATION),b(M3)("div",{class:"description"},z.DESCRIPTION)])])}})])}}}),b(M3).route.prefix="#");var pY=function(){o2.default_notification=document.getElementById("default-notification-time").value,o2.default_duration=document.getElementById("default-duration-time").value,o2.dateformat=document.getElementById("event-date-format").value,o2.firstday=document.getElementById("first-day-of-the-week").value,o2.eventsfilter=document.getElementById("events-category-filter").value,o2.background_sync=document.getElementById("background-sync").value,"Yes"==o2.background_sync?MQ():MK(),b(Mv).setItem("settings",o2).then(function(){o9()}).catch(function(M){console.log(M)})},pH=function(M){document.activeElement.value=M},pV=function(){var M;null==oY&&(oY=[]),MD(document.getElementById("cal-subs-url").value)&&""!=document.getElementById("cal-subs-name").value?(M=MT(32),oY.push({url:document.getElementById("cal-subs-url").value,name:document.getElementById("cal-subs-name").value,id:M}),document.querySelector("input#cal-subs-name").value="",document.querySelector("input#cal-subs-url").value="",b(Mv).setItem("subscriptions",oY).then(function(M){b(M3).route.set("/page_options")}),b(Mv).setItem(M,"").then(function(M){Mj("subscription added",4e3),pq()}).catch(function(M){console.log(M)})):Mj("Please enter a name and a valid url",2e3)},pG=function(M,e){MD(document.getElementById("account-url").value)&&""!=document.getElementById("account-name").value&&""!=document.getElementById("account-username").value&&""!=document.getElementById("account-password").value?(M?(ox=ox.filter(function(M){return M.id!==e})).push({server_url:document.getElementById("account-url").value,user:document.getElementById("account-username").value,password:document.getElementById("account-password").value,name:document.getElementById("account-name").value,id:e,type:"basic"}):(null==ox&&(ox=[]),ox.push({server_url:document.getElementById("account-url").value,user:document.getElementById("account-username").value,password:document.getElementById("account-password").value,name:document.getElementById("account-name").value,id:MT(32),type:"basic"})),b(Mv).setItem("accounts",ox).then(function(M){o8(),pp(!0,!1),b(M3).route.set("/page_options")}).catch(function(M){console.log(M)})):Mx("Please enter a name and a valid url",2e3)},pK=function(){var M=oY.filter(function(M){return M.id!=document.activeElement.getAttribute("data-id")});b(Mv).removeItem(document.activeElement.getAttribute("data-id")).then(function(){Mx("subscription removed",4e3)}).catch(function(M){console.log(M)}),b(Mv).setItem("subscriptions",M).then(function(M){Mj("subscription deleted",2e3)}).catch(function(M){Mx(M,2e3)}),document.activeElement.remove()},pQ=function(){var M=ox.filter(function(M){return M.id!=document.activeElement.getAttribute("data-id")});b(Mv).setItem("accounts",M).then(function(M){Mj("account deleted",2e3),document.activeElement.remove(),MY("","","")}).catch(function(M){Mx(M,2e3)}),b(Mv).removeItem(document.activeElement.getAttribute("data-id")).then(function(){}).catch(function(M){console.log(M)})};function pJ(){"hidden"===document.visibilityState?o1.visible=!1:setTimeout(function(){o1.visible=!0},1e3)}b(Mv).getItem("subscriptions").then(function(M){oY=M,pq()}).catch(function(M){}),pJ();var p$=function(M){oI=oI.filter(function(b){return b.id!=M}),b(Mv).setItem("event_templates",oI).then(function(M){Mj("template deleted",2e3),b(M3).route.set("/page_calendar")}).catch(function(M){console.log(M)})},pZ=function(){oI.forEach(function(M){M.id==Mn&&(document.getElementById("event-title").value=M.title,document.getElementById("event-description").value=M.description,document.getElementById("event-location").value=M.location,document.getElementById("event-category").value=M.category,Mn="")})},p0=function(M){if(pw(),cM(),"SELECT"==document.activeElement.nodeName||"date"==document.activeElement.type||"time"==document.activeElement.type)return!1;var e=document.activeElement.tabIndex+M,z=0,o=document.activeElement.parentNode.parentNode;if(z=o.querySelectorAll('.item:not([style*="display: none"]'),("/page_calendar"==b(M3).route.get()||"/page_options"==b(M3).route.get()||"/page_events"==b(M3).route.get()||"/page_event_templates"==b(M3).route.get()||"/page_list_files"==b(M3).route.get()||b(M3).route.get().startsWith("/page_events"))&&(z=document.activeElement.parentNode.parentNode.querySelectorAll('.item:not([style*="display: none"]'),o1.shortCut=!1),"/page_calendar"==b(M3).route.get()&&(o1.shortCut=!1,MY("","","")),("/page_subscriptions"==b(M3).route.get()||"/page_accounts"==b(M3).route.get()||"/page_edit_account"==b(M3).route.get())&&(z=o.querySelectorAll('.item:not([style*="display: none"]'),z=o.querySelectorAll(".item")),"/page_add_event"==b(M3).route.get()||"/page_edit_event"==b(M3).route.get()){if(z=o.querySelectorAll('.item:not([style*="display: none"]'),document.activeElement.parentNode.classList.contains("input-parent"))return document.activeElement.parentNode.focus(),!0;document.getElementById("add-edit-event").firstElementChild.focus()}var p=0;e<=z.length&&(p=z[e]).focus(),e==z.length&&(p=z[0]).focus();for(var c=document.activeElement.getBoundingClientRect(),t=c.top-document.body.getBoundingClientRect().top+c.height/2,n=document.activeElement.parentNode;n&&!(n.scrollHeight>n.clientHeight)&&!(n.scrollWidth>n.clientWidth);)n=n.parentNode;if(n?n.scrollBy({left:0,top:t-window.innerHeight/2,behavior:"smooth"}):document.body.scrollBy({left:0,top:t-window.innerHeight/2,behavior:"smooth"}),"/page_calendar"==b(M3).route.get()||"/page_events"==b(M3).route.get()||b(M3).route.get().startsWith("/page_events"))try{o1.selected_day=p.getAttribute("data-date"),o1.selected_day_id=p.getAttribute("data-id"),pX(o1.selected_day)}catch(M){}},p1=function(M,b,e,z){if("mozAlarms"in navigator){var o=navigator.mozAlarms.add(M,"honorTimezone",{note:b,event_id:e,type:z});o.onsuccess=function(){console.log("alarm set")},o.onerror=function(){console.log("An error occurred: "+this.error.name)}}if("b2g"in navigator)try{navigator.b2g.alarmManager.add({date:M,data:{note:b,type:z},ignoreTimezone:!1}).then(function(M){return console.log("add id: "+M)},function(M){return console.log("add err: "+M)})}catch(M){console.log(M)}},p2=function(M){if(navigator.mozAlarms){var b=navigator.mozAlarms.getAll();b.onsuccess=function(){this.result.forEach(function(b){if(b.data.event_id==M){var e=navigator.mozAlarms.remove(b.id);e.onsuccess=function(){console.log("removed")},e.onerror=function(){console.log("An error occurred: "+this.error.name)}}})},b.onerror=function(){console.log("An error occurred:",this.error.name)}}if("b2g"in navigator)try{navigator.b2g.alarmManager.getAll().onsuccess=function(){this.result.forEach(function(b){if(b.data.event_id==M){var e=navigator.b2g.alarmManager.remove(b.id);e.onsuccess=function(){console.log("removed")},e.onerror=function(){console.log("An error occurred: "+this.error.name)}}})}}catch(M){console.log(M)}},p3=function(M,e,z){var o=b(Mw)(M).format("YYYYMMDDTHHmmss");return o=e?";VALUE=DATE:"+b(Mw)(M).format("YYYYMMDD"):":"+o,z&&(o=b(Mw)(M).format("YYYYMMDDTHHmmss")),o},p4=["SU","MO","TU","WE","TH","FR","SA"],p5=function(M,b,e){if("none"===M)return"";var z=p4[new Date(e).getDay()];return"WEEKLY"===M?"FREQ=".concat(M,";INTERVAL=1;BYDAY=").concat(z,";UNTIL=").concat(p3(b,!1,!0)):"FREQ=".concat(M,";UNTIL=").concat(p3(b,!1,!0))},p6=[],p8=function(M,e){var z,o,p=!0,c=!1;!0===document.getElementById("event-all-day").checked&&(c=!0),""===document.getElementById("event-title").value&&(Mx("Title can't be empty",2e3),p=!1),"none"!=document.getElementById("event-recur").value&&""==document.getElementById("event-date-end").value&&(Mx("An end date is required for a recurrence",2e3),p=!1);var t=document.getElementById("event-time-start"),n=t.value?"".concat(t.value,":00"):"00:00:00",O=document.getElementById("event-time-end"),r=O.value?"".concat(O.value,":00"):"00:00:00",a=new Date("01/01/2000 "+n),i=new Date("01/01/2000 "+r),A=document.getElementById("event-date").value+" "+n;""==document.getElementById("event-date-end").value&&(document.getElementById("event-date-end").value=document.getElementById("event-date").value);var d=document.getElementById("event-date-end").value+" "+r;c&&(d=b(Mw)(document.getElementById("event-date-end").value+" "+r).add(1,"day").format("YYYY-MM-DD hh:mm:ss"));var s=document.getElementById("event-date").value+" "+r,q=document.getElementById("event-notification-time").value;if("none"!==q&&((z=new Date(A)).setMinutes(z.getMinutes()-q),q=p3(z.toISOString())),""!=n&&""!=r){var a=new Date(document.getElementById("event-date").value+" "+n),i=new Date(document.getElementById("event-date-end").value+" "+r);i","",""));break;case"#":document.querySelectorAll("div#calendar div#calendar-body div div [class^='moon-phase-']").forEach(function(M){M.classList.toggle("active")});break;case"SoftRight":case"Alt":case"m":if(cz("page_events_filtered"))return b(M3).route.set("/page_events");if(ce("page_calendar")&&o1.shortCut){var e="",z=document.querySelectorAll("#event-slider article");return z.forEach(function(M,b){"block"==M.style.display&&(e=M),z.length-1==b&&(void 0==(Mc=oP.filter(function(M){return!0!=M.isSubscription&&M.UID==e.getAttribute("data-uid")})[0])?Mj("subscriptions events cannot be edited",4e3):p9(Mc.etag,Mc.url,Mc.id,Mc.UID))})}if(ce("page_calendar")&&!o1.shortCut)return b(M3).route.set("/page_options");if(cz("page_events"))return document.querySelectorAll("#filter-menu button").forEach(function(M){M.style.display="block"}),document.querySelector("#filter-menu").style.display="flex",document.querySelector("#filter-menu").firstChild.focus(),document.querySelector("#search").focus();cz("page_add_event")&&M_(pI),"edit-delete-account"==document.activeElement.getAttribute("data-action")&&"oauth"!=document.activeElement.getAttribute("data-account-type")&&(o1.edit_account_id=document.activeElement.getAttribute("data-id"),Mt=ox.filter(function(M){return M.id==o1.edit_account_id})[0],b(M3).route.set("/page_edit_account"));break;case"SoftLeft":case"Control":if(ce("page_event_templates")&&p$(document.activeElement.getAttribute("data-id")),cz("page_events")){if(document.activeElement.classList.contains("subscription"))return Mj("subscriptions events cannot be edited",4e3);return pl(),document.activeElement.classList.contains("events")&&b(M3).route.set("/page_edit_event")}if(ce("page_subscriptions")||ce("page_accounts"))return"true"==document.activeElement.getAttribute("data-scan-action")&&M2(pH);if(ce("page_options")&&("delete-subscription"==document.activeElement.getAttribute("data-action")&&pK(),"edit-delete-account"==document.activeElement.getAttribute("data-action")&&pQ()),ce("page_calendar")&&o1.shortCut){var o="",p=document.querySelectorAll("#event-slider article");return p.forEach(function(M,e){"block"==M.style.display&&(o=M),p.length-1==e&&(void 0==(Mc=oP.filter(function(M){return!M.isSubscription&&M.UID==o.getAttribute("data-uid")})[0])?Mj("subscriptions events cannot be edited",4e3):b(M3).route.set("/page_edit_event"))})}if(ce("page_calendar"))return b(M3).route.set("/page_add_event");break;case"Enter":if(!o1.visible)return;if(document.activeElement.classList.contains("input-parent"))return document.activeElement.children[1].focus(),document.activeElement.classList.contains("check-box")&&(!0==document.activeElement.checked?document.activeElement.checked=!1:document.activeElement.checked=!0);if(document.activeElement.classList.contains("search-item"))return Mk("click");if("export-event"==document.activeElement.id)return oP.forEach(function(M){M.UID==o1.selected_day_id&&p6.push(M.data)}),M$(p6[0].UID+".ics",p6,function(M){Mj(M,3e3)}),Mj("event exported",5e3);if(oP.length>0||null==oP){if(cz("page_calendar")&&(document.querySelector(".loading-spinner").style.display="block"),cz("page_events")){if("BUTTON"!==document.activeElement.tagName&&b(M3).route.set("/page_calendar"),"BUTTON"===document.activeElement.tagName){var c=document.activeElement.getAttribute("data-action");document.querySelectorAll("#events-wrapper article").forEach(function(M){M.style.display="block"}),"filter-category"==c&&p_(o2.eventsfilter),"filter-last-modified"==c&&MC(oP,"lastmod","date","asc").then(function(){document.querySelector("#search").focus(),cM()}),"filter-asc"==c&&MC(oP,"dateStartUnix","date","asc").then(function(){document.querySelector("#search").focus(),cM()}),"filter-desc"==c&&MC(oP,"dateStartUnix","date","desc").then(function(){document.querySelector("#search").focus(),cM()}),document.querySelector("#filter-menu").style.display="none",document.querySelectorAll("#filter-menu button").forEach(function(M){M.style.display="none"})}"INPUT"===document.activeElement.tagName&&setTimeout(pT,1e3)}else(ce("page_calendar")||ce("page_events"))&&b(M3).route.set(ce("page_calendar")?"/page_events":"/page_calendar")}else ce("page_calendar")&&Mj("There are no calendar entries to display",3e3);break;case"Backspace":ce("page_add_event")&&"INPUT"!=document.activeElement.tagName&&b(M3).route.set("/page_calendar"),ce("page_events_filtered")&&b(M3).route.set("/page_calendar"),ce("page_edit_event")&&"INPUT"!=document.activeElement.tagName&&b(M3).route.set("/page_calendar"),ce("page_options")&&b(M3).route.set("/page_calendar"),ce("page_event_templates")&&b(M3).route.set("/page_calendar"),(ce("page_subscriptions")||ce("page_accounts")||ce("page_edit_account")||ce("page_list_files"))&&(b(M3).route.set("/page_options"),"block"==document.getElementById("qr-screen").style&&(document.getElementById("qr-screen").style="none"),M1(cb));break;case"0":if(ce("page_calendar")||ce("page_events")){if(o2.eventsfilter||Mj("no category selected, you can do that in the settings",4e3),"INPUT"==document.activeElement.tagName)return;b(M3).route.set("/page_events_filtered",{query:o2.eventsfilter})}}}(M)}),document.addEventListener("visibilitychange",pJ,!1),o1.debug&&(window.onerror=function(M,b,e){return alert("Error message: "+M+"\nURL: "+b+"\nLine Number: "+e),!0});var cp=(j=Ml(function(M){var e,z,o,p;return(0,MB.__generator)(this,function(c){switch(c.label){case 0:var t,n;t=Ml(function(M){var b,e,z,o,p,c;return(0,MB.__generator)(this,function(t){switch(t.label){case 0:(b=new Headers).append("Content-Type","application/x-www-form-urlencoded"),(e=new URLSearchParams).append("code",M),e.append("grant_type","authorization_code"),e.append("redirect_uri","https://greg.strukturart.com/index.html"),e.append("client_id","762086220505-f0kij4nt279nqn21ukokm06j0jge2ngl.apps.googleusercontent.com"),e.append("client_secret","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"),z={method:"POST",headers:b,body:e,redirect:"follow"},t.label=1;case 1:return t.trys.push([1,6,,7]),[4,fetch("https://oauth2.googleapis.com/token",z)];case 2:if((o=t.sent()).ok)return[3,4];return[4,o.text()];case 3:throw p=t.sent(),Error("Token exchange failed: ".concat(o.statusText,". Details: ").concat(p));case 4:return[4,o.json()];case 5:return[2,t.sent()];case 6:throw console.error("Error fetching the token:",c=t.sent()),c;case 7:return[2]}})}),e=function(M){return t.apply(this,arguments)},n=Ml(function(M,e){var z,o;return(0,MB.__generator)(this,function(p){switch(p.label){case 0:return p.trys.push([0,3,,4]),[4,b(Mv).getItem("accounts")];case 1:return(z=p.sent()||[]).push({server_url:"https://apidata.googleusercontent.com/caldav/v2/",tokens:M,authorizationCode:e,name:"Google",id:MT(32),type:"oauth"}),[4,b(Mv).setItem("accounts",z)];case 2:return p.sent(),setTimeout(function(){oG(),localStorage.setItem("oauth_callback","true")},3e3),[3,4];case 3:return o=p.sent(),alert("Error saving account: "+o.message),[3,4];case 4:return[2]}})}),z=function(M,b){return n.apply(this,arguments)},c.label=1;case 1:return c.trys.push([1,4,,5]),[4,e(M)];case 2:return o=c.sent(),[4,z(o,M)];case 3:return c.sent(),[3,5];case 4:return p=c.sent(),alert("OAuth process failed: "+p.message),[3,5];case 5:return[2]}})}),function(M){return j.apply(this,arguments)}),cc=!1,ct=!1;oD.addEventListener("message",function(M){if(M.data.oauth_success){var e=M.data.oauth_success.data;e&&cp(e)}if("parse"==M.data.action){Ma=Date.now(),ct=!0;try{document.getElementById("icon-waiting").style.visibility="visible"}catch(M){}!1!==M.data.content.parsed_data&&(0===o4.length||-1===o4.indexOf(M.data.content.parsed_data.calendar_name))&&(oP.push(M.data.content.parsed_data),M.data.content.callback&&oG(),M.data.content.raw_data&&(o7.data.push({uid:M.data.content.uid,data:M.data.content.raw_data}),b(Mv).setItem("local_account",o7).then(function(){oG()}).catch(function(){}))),!1==cc&&cn()}if("error"==M.data.action)try{document.getElementById("icon-waiting").style.visibility="hidden"}catch(M){}});var cn=function(){Mr=setInterval(function(){if(cc=!0,!ct)return!1;if(Date.now()-Ma>=400){try{document.getElementById("icon-waiting").style.visibility="hidden"}catch(M){}ct=!1,cc=!1,pM(pR,ph),MC(oP,"dateStartUnix","number"),clearInterval(Mr)}},100)};try{navigator.mozSetMessageHandler("activity",function(M){var b=M.source;"view"==b.name&&(pP=b.data.url,Mj("please open the subscriptions page and store the values",15e3),MH())})}catch(M){} \ No newline at end of file diff --git a/docs/index.2ef9694f.js b/docs/index.2ef9694f.js index 3217f734..1fc23f28 100644 --- a/docs/index.2ef9694f.js +++ b/docs/index.2ef9694f.js @@ -3,4 +3,4 @@ * * @author Jerry Bendy (https://github.com/jerrybendy) * @licence MIT - */function(M){var b,e,z=function(){try{if(M.URLSearchParams&&"bar"===new M.URLSearchParams("foo=bar").get("foo"))return M.URLSearchParams}catch(M){}return null}(),o=z&&"a=1"===new z({a:1}).toString(),p=z&&"+"===new z("s=%2B").get("s"),c=z&&"size"in z.prototype,t="__URLSearchParams__",n=!z||((b=new z).append("s"," &"),"s=+%26"===b.toString()),O=A.prototype,r=!!(M.Symbol&&M.Symbol.iterator);if(!z||!o||!p||!n||!c){O.append=function(M,b){l(this[t],M,b)},O.delete=function(M){delete this[t][M]},O.get=function(M){var b=this[t];return this.has(M)?b[M][0]:null},O.getAll=function(M){var b=this[t];return this.has(M)?b[M].slice(0):[]},O.has=function(M){return W(this[t],M)},O.set=function(M,b){this[t][M]=[""+b]},O.toString=function(){var M,b,e,z,o=this[t],p=[];for(b in o)for(M=0,e=d(b),z=o[b];M *");document.querySelector("#KaiOsAds-Wrapper").style.margin="0px 0px 30px 0",M.forEach(function(M){M.addEventListener("focus",function(M){MY("","open ads","")})})}catch(M){console.log(M)}}),M.call("display",{navClass:"item",display:"block"})}})},document.head.appendChild(M)},o_={},ML=Ms("lqBc9");o_=function(M){var b={};function e(z){if(b[z])return b[z].exports;var o=b[z]={i:z,l:!1,exports:{}};return M[z].call(o.exports,o,o.exports,e),o.l=!0,o.exports}return e.m=M,e.c=b,e.d=function(M,b,z){e.o(M,b)||Object.defineProperty(M,b,{enumerable:!0,get:z})},e.r=function(M){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(M,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(M,"__esModule",{value:!0})},e.t=function(M,b){if(1&b&&(M=e(M)),8&b||4&b&&"object"==typeof M&&M&&M.__esModule)return M;var z=Object.create(null);if(e.r(z),Object.defineProperty(z,"default",{enumerable:!0,value:M}),2&b&&"string"!=typeof M)for(var o in M)e.d(z,o,(function(b){return M[b]}).bind(null,o));return z},e.n=function(M){var b=M&&M.__esModule?function(){return M.default}:function(){return M};return e.d(b,"a",b),b},e.o=function(M,b){return Object.prototype.hasOwnProperty.call(M,b)},e.p="",e(e.s=0)}([function(M,b,e){function z(M){return(z="function"==typeof Symbol&&"symbol"==(0,ML._)(Symbol.iterator)?function(M){return void 0===M?"undefined":(0,ML._)(M)}:function(M){return M&&"function"==typeof Symbol&&M.constructor===Symbol&&M!==Symbol.prototype?"symbol":void 0===M?"undefined":(0,ML._)(M)})(M)}function o(M){var b;switch(z(M)){case"string":return/Z$/.test(M)?0:(b=/([+-])(\d{2}):?(\d{2})/.exec(M))&&(+b[3]+60*b[2])*("+"===b[1]?1:-1);case"number":return Number.isNaN(M)?null:16>Math.abs(M)?60*M:M;default:return null}}e.r(b);var p=function(M,b,e){var z=String(M);return!z||z.length>=b?M:"".concat(Array(b+1-z.length).join(e)).concat(M)},c=function(M){var b=Math.abs(M);return"".concat(M<=0?"+":"-").concat(p(Math.floor(b/60),2,"0"),":").concat(p(b%60,2,"0"))};function t(M,b){for(var e=0;e1&&void 0!==arguments[1]?arguments[1]:n))}var a=function(){var M,b;function e(){var M=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new Date,b=arguments.length>1&&void 0!==arguments[1]?arguments[1]:M.getTimezoneOffset();(function(M,b){if(!(M instanceof b))throw TypeError("Cannot call a class as a function")})(this,e),this.$d=new Date(M.getTime()-r(b)),this.$timezoneOffset=b}return M=[{key:"getTimezoneOffset",value:function(){return this.$timezoneOffset}},{key:"setTimezoneOffset",value:function(){var M=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.$timezoneOffset;this.$d.setTime(this.$d.getTime()+r(this.$timezoneOffset,M)),this.$timezoneOffset=M}}],t(e.prototype,M),b&&t(e,b),e}();["toDateString","toLocaleString","toLocaleDateString","toLocaleTimeString","setDate","setFullYear","setHours","setMilliseconds","setMinutes","setMonth","setSeconds","setTime","setYear","getDate","getDay","getFullYear","getHours","getMilliseconds","getMinutes","getMonth","getSeconds","getYear"].forEach(function(M){a.prototype[M]=function(){return O[M].apply(this.$d,arguments)}}),["toISOString","toUTCString","toGMTString","toJSON","getUTCDate","getUTCDay","getUTCFullYear","getUTCHours","getUTCMilliseconds","getUTCMinutes","getUTCMonth","getUTCSeconds","valueOf","getTime"].forEach(function(M){a.prototype[M]=function(){return O[M].apply(new Date(this.$d.getTime()+r(this.$timezoneOffset)),arguments)}}),["setUTCDate","setUTCFullYear","setUTCHours","setUTCMilliseconds","setUTCMinutes","setUTCMonth","setUTCSeconds"].forEach(function(M){a.prototype[M]=function(){var b=new Date(this.$d.getTime()+r(this.$timezoneOffset));O[M].apply(b,arguments),b.setTime(b.getTime()-r(this.$timezoneOffset)),this.$d=b}}),["toString","toTimeString"].forEach(function(M){a.prototype[M]=function(){return O[M].apply(this.$d,arguments).replace(/GMT(.*)$/,"GMT".concat(c(this.$timezoneOffset)))}});var i=!1,A=function(M,b){["clone","add","subtract","startOf"].forEach(function(e){M[e]=function(){var M=this.utcOffset();return b[e].apply(this,arguments).utcOffset(M)}}),M.utc=function(){return this.utcOffset(0)},M.local=function(){return this.utcOffset(-n)},M.utcOffset=function(M){if(void 0===M){var b=this.$d.getTimezoneOffset();return 0===b?0:-b}return null!==o(M)&&(this.$d.setTimezoneOffset(-o(M)),this.init()),this},M.toDate=function(){return new Date(this.$d.getTime())},M.isLocal=function(){return this.$d.getTimezoneOffset()===n},M.isUTC=function(){return 0===this.$d.getTimezoneOffset()},M.$set=function(){for(var M,e=this.$d.getTimezoneOffset(),z=arguments.length,o=Array(z),p=0;p0&&void 0!==arguments[0]?arguments[0]:{},b=arguments.length>1?arguments[1]:void 0,e=arguments.length>2?arguments[2]:void 0;i=!!M.parseToLocal;var z=b.prototype,p=function(){};p.prototype=z;var c=new p;A(c,z),c.constructor=b.constructor,b.prototype=c,e.utc=function(M){var b=this(M);return"string"==typeof M&&null===o(M)&&(b.$d.$timezoneOffset=0),b.utc()}}}]),b(Mw).extend(b(o_));var oS={};(oS=Ms("iYrAK")).tz.load(Ms("kZ0MA"));var oD=new BroadcastChannel("sw-messages");b(Mv).setDriver(b(Mv).INDEXEDDB);var oP=[],ox=[],oI=[],oU=!1,oj=60,oF=localStorage.getItem("last_sync")||"",oY=[];b(Mv).getItem("subscriptions").then(function(M){console.log(M)});var oH=(E=Ml(function(){var M,e,z,o,p;return(0,MB.__generator)(this,function(c){switch(c.label){case 0:var t,n;M=function(){return new URLSearchParams(window.location.search).get("code")},t=Ml(function(M){var b,e,z,o,p;return(0,MB.__generator)(this,function(c){switch(c.label){case 0:(b=new Headers).append("Content-Type","application/x-www-form-urlencoded"),(e=new URLSearchParams).append("code",M),e.append("grant_type","authorization_code"),e.append("redirect_uri","https://greg.strukturart.com/index.html"),e.append("client_id","762086220505-f0kij4nt279nqn21ukokm06j0jge2ngl.apps.googleusercontent.com"),e.append("client_secret","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"),z={method:"POST",headers:b,body:e,redirect:"follow"},c.label=1;case 1:return c.trys.push([1,4,,5]),[4,fetch("https://oauth2.googleapis.com/token",z)];case 2:if(!(o=c.sent()).ok)throw Error("Token exchange failed: ".concat(o.statusText));return[4,o.json()];case 3:return[2,c.sent()];case 4:throw console.error("Error fetching the token:",p=c.sent()),p;case 5:return[2]}})}),e=function(M){return t.apply(this,arguments)},n=Ml(function(M,e){var z,o;return(0,MB.__generator)(this,function(p){switch(p.label){case 0:return p.trys.push([0,3,,4]),[4,b(Mv).getItem("accounts")];case 1:return(z=p.sent()||[]).push({server_url:"https://apidata.googleusercontent.com/caldav/v2/",tokens:M,authorizationCode:e,name:"Google",id:MT(32),type:"oauth"}),[4,b(Mv).setItem("accounts",z)];case 2:return p.sent(),setTimeout(function(){window.close()},3e3),[3,4];case 3:return o=p.sent(),alert("Error saving account: "+o.message),[3,4];case 4:return[2]}})}),z=function(M,b){return n.apply(this,arguments)},c.label=1;case 1:if(c.trys.push([1,4,,5]),!(o=M()))return[2,!1];return[4,e(o)];case 2:return p=c.sent(),[4,z(p,o)];case 3:case 4:return c.sent(),[3,5];case 5:return[2]}})}),function(){return E.apply(this,arguments)});"b2g"in navigator||"navigator.mozApps"in navigator?function(){if(!window.location.href.includes("code="))return!1;var M=new URLSearchParams(window.location.search).get("code");if(!M)return!1;setTimeout(function(){try{var b=new MozActivity({name:"greg-oauth",data:M});b.onsuccess=function(){console.log("Activity successfuly handled")},b.onerror=function(){console.log("The activity encouter en error: "+this.error),alert(this.error)}}catch(M){}if("b2g"in navigator)try{new WebActivity("greg-oauth",{name:"greg-oauth",type:"string",data:M}).start().then(function(M){window.close(),console.log("Results passed back from activity handler:"),console.log(M)},function(M){alert(M)})}catch(M){}},4e3)}():oH();var oV=function(){document.querySelector("#intro").classList.add("intro-animation"),document.querySelector("#version").classList.add("intro-version-animation"),document.querySelector("#intro img").classList.add("intro-img-anmation")},oG=function(){setTimeout(function(){document.querySelector(".success-checkmark").style.display="block"},2e3),setTimeout(function(){document.querySelector(".success-checkmark").style.display="none"},4e3)},oK=[],oQ=function(){oK.push(b(M3).route.get())},oJ=function(){setTimeout(function(){b(M3).route.set(oK[oK.length-2])},1e3)};MH();var o$="",oZ=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],o0=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],o1={selected_day:b(Mw)().format("YYYY-MM-DD"),selected_day_id:"",visible:!1,update_event_id:"",event_calendar_changed:!1,startup:!1,sortEvents:"startDate",shortCut:!1,background_sync_running:!1,version:localStorage.getItem("version")||"time is relative",notKaiOS:!0,debug:!1},o2={default_notification:"none",ads:!0,timezone:oS.tz.guess(),dateformat:"YYYY-MM-DD",firstday:"sunday",background_sync:"No",default_duration:30};("b2g"in navigator||"navigator.mozApps"in navigator)&&(o1.notKaiOS=!1),o1.notKaiOS||["http://127.0.0.1/api/v1/shared/core.js","http://127.0.0.1/api/v1/shared/session.js","http://127.0.0.1/api/v1/apps/service.js","http://127.0.0.1/api/v1/audiovolumemanager/service.js","./assets/js/kaiads.v5.min.js"].forEach(function(M){var b=document.createElement("script");b.type="text/javascript",b.src=M,document.head.appendChild(b)}),function(){try{if("No"==localStorage.getItem("background_sync"))return!1;var M=navigator.mozAlarms.getAll();M.onsuccess=function(){this.result.forEach(function(M){"keep alive"==M.data.note&&MQ()})},M.onerror=function(){console.log("An error occurred:",this.error.name)}}catch(M){}}();var o3={};if(o3=Ms("4TeC4").getBundleURL("llXtB")+"sw.js","b2g"in navigator)try{navigator.serviceWorker.register(o3).then(function(M){M.waiting&&setTimeout(function(){window.location.reload(!0)},1e3),M.systemMessageManager.subscribe("alarm").then(function(M){console.log('Successfully subscribe system messages of name "alarm".')},function(M){console.log("Fail to subscribe system message, error: "+M)}),M.systemMessageManager.subscribe("activity").then(function(M){},function(M){})})}catch(M){console.log(M)}else if("serviceWorker"in navigator&&navigator.serviceWorker.controller)console.log("Service worker found");else try{console.log("Try to register service worker"),navigator.serviceWorker.register(o3).then(function(M){M.waiting&&setTimeout(function(){window.location.reload(!0)},1e3)})}catch(M){console.error("Error during service worker registration:",M)}var o4=[];function o5(){return o6.apply(this,arguments)}function o6(){return(o6=Ml(function(){return(0,MB.__generator)(this,function(M){switch(M.label){case 0:return M.trys.push([0,2,,3]),[4,b(Mv).keys()];case 1:return -1==M.sent().indexOf("calendarNames")?Mp=[{name:"local",id:"local-id",data:[],type:"local",view:!0}]:b(Mv).getItem("calendarNames").then(function(M){(Mp=M).forEach(function(M){!1==M.view&&o4.push(M.name)})}),[3,3];case 2:return M.sent(),[3,3];case 3:return[2]}})})).apply(this,arguments)}var o8=function(){b(Mv).getItem("accounts").then(function(M){oV(),ox=M,o5(),null!=ox&&pr().then(function(){pO(pu)})}).catch(function(){console.log("no accounts")})};o8();var o7={data:[],calendar_name:"local",calendar_id:"local-id"};b(Mv).getItem("local_account").then(function(M){null!=M?(o7.data=M.data,o7.data.forEach(function(M){try{navigator.serviceWorker.controller.postMessage({type:"parse",t:M,e:"local-id",callback:!1,store:!1})}catch(M){console.log("send to sw")}})):b(Mv).setItem("local_account",o7).then(function(){console.log("Local account created:",o7)}).catch(function(M){console.error("Error creating local account:",M)})}).catch(function(M){console.error("Error loading local account:",M)});var o9=function(){b(Mv).getItem("settings").then(function(M){null!=M&&(o2=M,localStorage.setItem("background_sync",o2.background_sync),o0="sunday"==o2.firstday||void 0==o2.firstday?["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]:["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],void 0==o2.dateformat&&(o2.dateformat="YYYY-MM-DD"),document.querySelectorAll(".calendar-head div").forEach(function(M,b){M.innerText=o0[b]}))}).catch(function(M){})};o9();var pM=function(){try{document.querySelectorAll("div.calendar-cell").forEach(function(M){var b=M.getAttribute("data-date");!0==pB(b).event?(M.classList.add("event"),!0==pB(b).multidayevent&&M.classList.add("multievent")):M.classList.contains("event")&&M.classList.remove("event"),!0==pv(b).rrule&&(M.classList.add("rrule"),pv(b).count>1&&M.classList.add("multievent"))})}catch(M){console.log(M)}},pb={},pe={};function pz(M){return po.apply(this,arguments)}function po(){return(po=Ml(function(M){return(0,MB.__generator)(this,function(b){try{return pb[M.id]||("oauth"===M.type&&(pb[M.id]=new ok({serverUrl:M.server_url,credentials:{tokenUrl:"https://oauth2.googleapis.com/token",refreshToken:M.tokens.refresh_token,clientId:"762086220505-f0kij4nt279nqn21ukokm06j0jge2ngl.apps.googleusercontent.com",clientSecret:"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",authorizationCode:M.authorizationCode,redirectUrl:"https://greg.strukturart.com/index.html"},authMethod:"Oauth",defaultAccountType:"caldav"})),"basic"===M.type&&(pb[M.id]=new ok({serverUrl:M.server_url,credentials:{username:M.user,password:M.password},authMethod:"Basic",defaultAccountType:"caldav"}))),[2,pb[M.id]]}catch(M){throw console.error("Error occurred while creating DAVClient instance:",M),M}return[2]})})).apply(this,arguments)}function pp(){return pc.apply(this,arguments)}function pc(){return(pc=Ml(function(){var M,e,z,o,p,c,t,n,O,r,a,i,A,d,s,q,u,l,f,W,h,R,m,L,B,v,g=arguments;return(0,MB.__generator)(this,function(N){switch(N.label){case 0:if(M=g.length>0&&void 0!==g[0]&&g[0],e=g.length>1&&void 0!==g[1]&&g[1],!navigator.onLine)return[2,!1];if(oU=!0,e)try{oP=oP.filter(function(M){return M.id==M.account_to_update})}catch(M){console.log(M)}else try{oP=oP.filter(function(M){return!M.isCaldav})}catch(M){console.log(M)}z=!0,o=!1,p=void 0,N.label=1;case 1:N.trys.push([1,30,31,32]),c=ox[Symbol.iterator](),N.label=2;case 2:if(z=(t=c.next()).done)return[3,29];if(n=t.value,!1!=e&&e!==n)return[3,28];return[4,pz(n)];case 3:O=N.sent(),N.label=4;case 4:if(N.trys.push([4,27,,28]),pe[n.id])return[3,9];N.label=5;case 5:return N.trys.push([5,7,,8]),[4,O.login()];case 6:return N.sent(),pe[n.id]=!0,console.log("login successfull"),[3,8];case 7:return console.log("cant login"+N.sent()),pe[n.id]=!1,[3,28];case 8:return[3,10];case 9:console.log("login"),N.label=10;case 10:r=void 0,N.label=11;case 11:return N.trys.push([11,13,,14]),[4,O.fetchCalendars()];case 12:return console.log(r=N.sent()),[3,14];case 13:return console.log(N.sent()),[3,28];case 14:"/page_calendar"===b(M3).route.get()&&(document.getElementById("icon-loading").style.visibility="visible"),a=[],i=!0,A=!1,d=void 0,N.label=15;case 15:N.trys.push([15,24,25,26]),s=r[Symbol.iterator](),N.label=16;case 16:if(i=(q=s.next()).done)return[3,23];return u=q.value,[4,O.fetchCalendarObjects({calendar:u})];case 17:l=N.sent(),f={displayName:u.displayName,syncToken:u.syncToken,ctag:u.ctag,url:u.url,objects:l},a.push(f),N.label=18;case 18:return N.trys.push([18,20,,21]),[4,b(Mv).setItem(n.id,a)];case 19:return N.sent(),console.log("Data cached"),[3,21];case 20:return console.log(N.sent()),oU=!1,[3,21];case 21:W=!0,h=!1,R=void 0;try{for(m=l[Symbol.iterator]();!(W=(L=m.next()).done);W=!0)B=L.value,"serviceWorker"in navigator&&navigator.serviceWorker.controller&&navigator.serviceWorker.controller.postMessage({type:"parse",t:B,e:n.id,callback:!1,store:!1})}catch(M){h=!0,R=M}finally{try{W||null==m.return||m.return()}finally{if(h)throw R}}N.label=22;case 22:return i=!0,[3,16];case 23:return[3,26];case 24:return v=N.sent(),A=!0,d=v,[3,26];case 25:try{i||null==s.return||s.return()}finally{if(A)throw d}return[7];case 26:try{document.getElementById("icon-loading").style.visibility="hidden",document.getElementById("icon-waiting").style.visibility="hidden"}catch(M){console.log(M)}return M&&Mj("all event reloaded",2e3),oU=!1,[3,28];case 27:N.sent(),oU=!1;try{document.getElementById("icon-loading").style.visibility="hidden",document.getElementById("icon-waiting").style.visibility="hidden"}catch(M){console.log(M)}return[3,28];case 28:return z=!0,[3,2];case 29:return[3,32];case 30:return v=N.sent(),o=!0,p=v,[3,32];case 31:try{z||null==c.return||c.return()}finally{if(o)throw p}return[7];case 32:return[2]}})})).apply(this,arguments)}var pt=(_=Ml(function(){var M,e,z,o,p,c,t,n,O;return(0,MB.__generator)(this,function(r){switch(r.label){case 0:oU=!0,e=!0,z=!1,o=void 0,r.label=1;case 1:r.trys.push([1,6,7,8]),p=function(){var e,z,o,p,c,n;return(0,MB.__generator)(this,function(O){switch(O.label){case 0:return[4,pz(e=t.value)];case 1:z=O.sent(),O.label=2;case 2:return O.trys.push([2,8,,9]),[4,z.fetchCalendars()];case 3:o=O.sent(),p=[],c=0,O.label=4;case 4:if(!(c0)return M(t),[3,18];return[3,17];case 16:return q.sent(),navigator.onLine||MS("greg","device offline"),[3,17];case 17:return i++,[3,13];case 18:return[3,20];case 19:return q.sent(),navigator.onLine||MS("greg","device offline"),[3,20];case 20:return e=!0,[3,2];case 21:return[3,24];case 22:return s=q.sent(),z=!0,o=s,[3,24];case 23:try{e||null==p.return||p.return()}finally{if(z)throw o}return[7];case 24:if(JSON.stringify(pn)!=JSON.stringify(Mp)){try{pn.forEach(function(M){var b;Array.isArray(Mp)?b=Mp.find(function(b){return b.name===M.name}):console.error("calendar_names is not an array or is undefined"),b&&(M.view=b.view)})}catch(M){console.log(M)}b(Mv).setItem("calendarNames",pn).then(function(){o5()})}return[2]}})}),function(M){return S.apply(this,arguments)}),pr=(D=Ml(function(){var M,e,z,o,p,c,t,n,O,r,a,i,A,d,s,q,u,l,f,W;return(0,MB.__generator)(this,function(h){switch(h.label){case 0:if(!ox)return[2,!1];M=!0,e=!1,z=void 0,h.label=1;case 1:h.trys.push([1,8,9,10]),o=ox[Symbol.iterator](),h.label=2;case 2:if(M=(p=o.next()).done)return[3,7];c=p.value,h.label=3;case 3:return h.trys.push([3,5,,6]),[4,b(Mv).getItem(c.id)];case 4:if(null===(t=h.sent()))try{pp(!1,c.id)}catch(M){console.log(M)}n=!0,O=!1,r=void 0,a=!0,i=!1,A=void 0;try{for(d=t[Symbol.iterator]();!(a=(s=d.next()).done);a=!0){q=s.value;try{for(u=q.objects[Symbol.iterator]();!(n=(l=u.next()).done);n=!0)if(f=l.value,"serviceWorker"in navigator&&navigator.serviceWorker.controller)try{navigator.serviceWorker.controller.postMessage({type:"parse",t:f,e:c.id,callback:!1,store:!1})}catch(M){console.log("send to sw")}else console.log("no sw")}catch(M){O=!0,r=M}finally{try{n||null==u.return||u.return()}finally{if(O)throw r}}}}catch(M){i=!0,A=M}finally{try{a||null==d.return||d.return()}finally{if(i)throw A}}return[3,6];case 5:return console.log(h.sent()),[3,6];case 6:return M=!0,[3,2];case 7:return[3,10];case 8:return W=h.sent(),e=!0,z=W,[3,10];case 9:try{M||null==o.return||o.return()}finally{if(e)throw z}return[7];case 10:return[2]}})}),function(){return D.apply(this,arguments)}),pa=(P=Ml(function(M,b,e,z,o){var p,c,t,n,O;return(0,MB.__generator)(this,function(r){switch(r.label){case 0:if(!navigator.onLine)return[2,!1];if(document.querySelector(".loading-spinner").style.display="block",!(p=ox.find(function(M){return M.id===b})))return[3,14];return[4,pz(p)];case 1:c=r.sent(),r.label=2;case 2:if(r.trys.push([2,13,,14]),pe[p.id])return[3,4];return[4,c.login()];case 3:r.sent(),pe[p.id]=!0,r.label=4;case 4:return[4,c.fetchCalendars()];case 5:if(!(t=r.sent().find(function(M){return M.displayName===e})))return[3,12];return[4,c.createCalendarObject({calendar:t,filename:o+".ics",iCalString:M,headers:c.authHeaders})];case 6:if(!(n=r.sent()).ok)return[3,11];r.label=7;case 7:return r.trys.push([7,9,,10]),[4,c.propfind({url:n.url,props:Mf({},"".concat(J.DAV,":getetag"),{}),depth:"0",headers:c.authHeaders})];case 8:return O=MR.apply(void 0,[r.sent(),1])[0],z.etag=O.props.getetag,z.url=n.url,z.isCaldav=!0,z.id=b,z.calendar_name=e,document.querySelector(".loading-spinner").style.display="none",pt().then(function(M){}),[2,z];case 9:return console.log(r.sent()),[3,10];case 10:return[3,12];case 11:document.querySelector(".loading-spinner").style.display="none",Mj("There was a problem saving, please try again later.",5e3),r.label=12;case 12:return[3,14];case 13:return console.log(r.sent()),[3,14];case 14:return[2]}})}),function(M,b,e,z,o){return P.apply(this,arguments)}),pi=(x=Ml(function(M,b,e,z){var o,p,c,t;return(0,MB.__generator)(this,function(n){switch(n.label){case 0:if(console.log(oP),!navigator.onLine)return[2,!1];if(document.querySelector(".loading-spinner").style.display="block",console.log("hey"+(o=ox.find(function(M){return M.id===e}))),void 0==o)return document.querySelector(".loading-spinner").style.display="none",Mj("There was a problem deleting, please try again later.",5e3),[2,!1];if(!o)return[3,7];return[4,pz(o)];case 1:p=n.sent(),n.label=2;case 2:if(n.trys.push([2,6,,7]),pe[o.id])return[3,4];return[4,p.login()];case 3:n.sent(),pe[o.id]=!0,n.label=4;case 4:return[4,p.deleteCalendarObject({calendarObject:{url:b,etag:M},headers:p.authHeaders})];case 5:if(!n.sent().ok)return oJ(),Mj("There was a problem deleting, please try again later.",5e3),[2,"error"];if(-1!==(c=oP.findIndex(function(M){return M.UID===z}))){if(oP.splice(c,1),pt(),p2(z),pC(),pM(pR,ph),document.querySelector(".loading-spinner").style.display="none",!1==o1.shortCut)return oJ(),[2,"success"];return oG(),[2,"success"]}return[3,7];case 6:return t=n.sent(),oJ(),Mj("There was a problem deleting, please try again later.",5e3),[2,t];case 7:return[2]}})}),function(M,b,e,z){return x.apply(this,arguments)}),pA=(I=Ml(function(M,b,e,z){var o,p,c,t,n;return(0,MB.__generator)(this,function(O){switch(O.label){case 0:if(!navigator.onLine)return[2,!1];if(document.querySelector(".loading-spinner").style.display="block",void 0==(o=ox.find(function(M){return M.id===z})))return document.querySelector(".loading-spinner").style.display="none",Mj("There was a problem saving, please try again later.",5e3),[2,!1];if(!o)return[3,13];return[4,pz(o)];case 1:p=O.sent(),O.label=2;case 2:if(O.trys.push([2,12,,13]),pe[o.id])return[3,4];return[4,p.login()];case 3:O.sent(),pe[o.id]=!0,O.label=4;case 4:return[4,p.updateCalendarObject({calendarObject:{url:b,data:e,etag:M},headers:p.authHeaders})];case 5:if(!(c=O.sent()).ok)return[3,10];document.querySelector(".loading-spinner").style.display="none",O.label=6;case 6:return O.trys.push([6,8,,9]),[4,p.propfind({url:c.url,props:Mf({},"".concat(J.DAV,":getetag"),{}),depth:"0",headers:p.authHeaders})];case 7:return t=MR.apply(void 0,[O.sent(),1])[0],(n={}).etag=t.props.getetag,n.url=c.url,pt(),[2,n];case 8:return console.log(O.sent()),document.querySelector(".loading-spinner").style.display="none",[3,9];case 9:return[3,11];case 10:document.querySelector(".loading-spinner").style.display="none",Mj("There was a problem saving, please try again later.",5e3),O.label=11;case 11:return[3,13];case 12:return O.sent(),document.querySelector(".loading-spinner").style.display="none",Mj("There was a problem saving, please try again later.",5e3),[3,13];case 13:return[2]}})}),function(M,b,e,z){return I.apply(this,arguments)}),pd=function(M,b){var e=new XMLHttpRequest({mozSystem:!0});e.open("GET",M+"?time="+new Date().getTime(),!0),e.timeout=2e3,e.onload=function(){e.status>=200&&e.status<300?b(e.responseText,M):b(Error("Request failed with status "+e.status))},e.onerror=function(){b(Error("XMLHttpRequest error"),null)},e.ontimeout=function(){b(Error("XMLHttpRequest timed out"),null)},e.send()},ps=function(M,b){try{navigator.serviceWorker.controller.postMessage({type:"parse",t:{uid:"",data:M,url:b,etag:""},e:"subscription",callback:!1,store:!1})}catch(M){console.log(M)}},pq=(U=Ml(function(){var M,b,e,z,o,p;return(0,MB.__generator)(this,function(c){M=!0,b=!1,e=void 0;try{for(z=oY[Symbol.iterator]();!(M=(o=z.next()).done);M=!0)p=o.value,pd(p.url,ps)}catch(M){b=!0,e=M}finally{try{M||null==z.return||z.return()}finally{if(b)throw e}}return[2]})}),function(){return U.apply(this,arguments)}),pu=function(M){pp(!1,M).then(function(){})},pl=function(){o1.selected_day_id=document.activeElement.getAttribute("data-id"),Mc=oP.filter(function(M){return M.UID==o1.selected_day_id})[0]};b(Mv).getItem("event_templates").then(function(M){if(null==M)return oI=[],!1;oI=M}).catch(function(M){console.log(M)});var pf=function(M,e,z,o){var p={id:MT(32),title:M,description:e,location:z,category:o};oI.push(p),b(Mv).setItem("event_templates",oI).then(function(M){Mj("template saved",2e3),oJ()}).catch(function(M){console.log(M)})},pW=new Date,ph=pW.getMonth(),pR=pW.getFullYear(),pm=pW.getDate(),pL=function(M){var e=M?b(Mw)().unix():b(Mw)(o1.selected_day).unix();if(0===oP.length)return document.getElementById("events-wrapper").innerHTML="You haven't made any calendar entries yet.",!1;var z=0,o=function(){setTimeout(function(){document.querySelectorAll('div#events-wrapper article[data-id="'+z+'"]')[0].focus();var M=document.activeElement.getBoundingClientRect(),b=M.top-document.body.getBoundingClientRect().top+M.height/2;document.activeElement.parentNode.scrollBy({left:0,top:b-window.innerHeight/2,behavior:"smooth"})},1e3)};try{var p=oP.findIndex(function(M){return M.dateStartUnix===e});z=oP[p-1].UID,o()}catch(M){!function(){try{var M=oP.findIndex(function(M){return M.dateStartUnix=o&&!b.RRULE.freq});if(b.event=e.length>0,b.event_data=e,e.length>1){for(var z=e.sort(function(M,b){return new Date(M.dateStart).getTime()-new Date(b.dateStart).getTime()}),o=1;o=new Date(z[o].dateStart).getTime()){b.multidayevent=!0,b.event_data=e;break}}return b},pv=function(M){var b={date:"",event:!1,subscription:!1,multidayevent:!1,rrule:"none",event_data:""},e=!0,z=!1,o=void 0;try{for(var p,c=oP[Symbol.iterator]();!(e=(p=c.next()).done);e=!0){var t=p.value;if("object"==typeof t){b.event=!1,b.multidayevent=!1,b.rrule=!1,b.date=M,b.event_data="";var n=new Date(t.dateStart).getTime(),O=new Date(t.dateEnd).getTime(),r=new Date(M).getTime(),a=t.RRULE.freq;if(void 0!==t.RRULE&&null!==t.RRULE&&(void 0==t.RRULE.until&&void 0==t.RRULE.count&&(O=new Date("3000-01-01").getTime()),n===r||nr))switch(b.event_data=t,a){case"MONTHLY":if(new Date(t.dateStart).getDate()===new Date(M).getDate())return b.event=!0,b.rrule=!0,b;break;case"WEEKLY":if(new Date(t.dateStart).getDay()===new Date(M).getDay())return b.rrule=!0,b.event=!0,b;break;case"BIWEEKLY":if(Math.floor((r-n)/864e5)%14==0)return b.rrule=!0,b.event=!0,b;break;case"YEARLY":var i=new Date(t.dateStart),A=new Date(M);if(i.getDate()===A.getDate()&&i.getMonth()===A.getMonth())return b.rrule=!0,b.event=!0,b}}}}catch(M){z=!0,o=M}finally{try{e||null==c.return||c.return()}finally{if(z)throw o}}return b},pg=[],pN=0,py=function(){++pN>document.querySelectorAll("div#event-slider article").length-1&&(pN=0);var M=document.querySelectorAll("div#event-slider-indicator div div");document.querySelectorAll("div#event-slider article").forEach(function(M){M.style.display="none"}),document.querySelectorAll("div#event-slider article")[pN].style.display="block",M.forEach(function(M){M.classList.remove("active")}),M[pN].classList.add("active")},pX=function(M){pg=[];var e=document.querySelector("div#event-slider-indicator div");e.innerHTML="",document.querySelector("div#event-slider").innerHTML="";for(var z=0;z=c)&&pg.push(oP[z]);else if(null!=oP[z].RRULE&&void 0==oP[z].RRULE.until&&void 0==oP[z].RRULE.count&&(p=new Date("3000-01-01").getTime()),o===c||p===c||oc){if("YEARLY"==t){var n=new Date(oP[z].dateStart),O=new Date(M);n.getDate()+"-"+n.getMonth()==O.getDate()+"-"+O.getMonth()&&pg.push(oP[z])}"WEEKLY"==t&&new Date(oP[z].dateStart).getDay()==new Date(M).getDay()&&pg.push(oP[z]),"BIWEEKLY"==t&&Math.floor((c-o)/864e5)%14==0&&pg.push(oP[z]),"MONTHLY"==t&&new Date(oP[z].dateStart).getDate()==new Date(M).getDate()&&pg.push(oP[z]),"DAILY"==t&&(o===c||p===c||oc)&&pg.push(oP[z])}}if(pg.length>=0&&(pg.forEach(function(M){e.insertAdjacentHTML("beforeend","
");var z="";M.allDay||(z=b(Mw).unix(M.dateStartUnix).format("HH:mm")),document.querySelector("div#event-slider").insertAdjacentHTML("beforeend","
"+M.SUMMARY+"
"+z+"
")}),pg.length>0))try{document.querySelectorAll("div#event-slider article")[0].style.display="block"}catch(M){console.log(M)}document.querySelectorAll("div.indicator").length<=1||void 0==document.querySelectorAll("div.indicator").length?document.getElementById("event-slider-indicator").style.opacity=0:(document.getElementById("event-slider-indicator").style.opacity=1,document.querySelector("div#event-slider article").style.display="block",document.querySelectorAll("div#event-slider .indicator")[0].style.classList.add("active"))},pT=function(){ph=pW.getMonth(),pR=pW.getFullYear(),pk(ph,pR),setTimeout(function(){o1.selected_day=b(Mw)().format("YYYY-MM-DD"),pX(o1.selected_day)},1e3)},pw=function(){if("/page_calendar"!=b(M3).route.get())return!1;setTimeout(function(){document.querySelectorAll("div#calendar div.calendar-head div").forEach(function(M){M.classList.remove("active")}),document.querySelectorAll("span.weeknumber").forEach(function(M){M.classList.remove("active")});var M=new Date(document.activeElement.getAttribute("data-date")).getDay();document.activeElement.closest("div.row").querySelector("span.weeknumber").classList.add("active"),"monday"==o2.firstday&&-1==(M-=1)&&(M=6),document.querySelectorAll("div#calendar div.calendar-head div")[M].classList.add("active")},200)};Date.prototype.getWeek=function(){var M=new Date(this.getTime());M.setHours(0,0,0,0),M.setDate(M.getDate()+3-(M.getDay()+6)%7);var b=new Date(M.getFullYear(),0,4);return 1+Math.round(((M.getTime()-b.getTime())/864e5-3+(b.getDay()+6)%7)/7)};var pk=function(M,b){document.getElementById("monthAndYear").textContent=oZ[M]+" "+b;var e=new Date(b,M).getDay();"monday"==o2.firstday&&(0==e?e=6:e-=1);var z=32-new Date(b,M,32).getDate(),o=document.getElementById("calendar-body");o.innerHTML="";for(var p=1,c=0;c<6;c++)!function(c){var t=document.createElement("div");t.classList.add("flex"),t.classList.add("row"),t.setAttribute("data-weeknumber",c),t.classList.add("width-100");for(var n=0;n<7;n++)if(0===c&&nz)break;else{var a=document.createElement("div"),i=document.createElement("span"),A=document.createElement("div"),d=document.createTextNode(p);a.appendChild(d),a.appendChild(i),a.setAttribute("tabindex",p-1),a.classList.add("calendar-cell");var s=b+"-"+"0".concat(M+1).slice(-2)+"-"+"0".concat(p).slice(-2);A.classList.add("moon-phase-"+function(M,b,e){var z,o,p,c=p=o=z=0;return b<3&&(M--,b+=12),++b,z=parseInt(o=((c=365.25*M)+(p=30.6*b)+e-694039.09)/29.5305882),o-=z,(z=Math.round(8*o))>=8&&(z=0),z}(b,M,p)),a.appendChild(A),a.setAttribute("data-date",s),a.classList.add("item"),t.appendChild(a),p++}var q=document.createElement("span");q.classList.add("weeknumber");var u=document.createTextNode("monday"==o2.firstday?new Date(b,M,p-1).getWeek():new Date(b,M,p).getWeek());q.appendChild(u),t.appendChild(q),o.appendChild(t)}(c);document.querySelectorAll(".item")[0].focus(),o1.selected_day=document.activeElement.getAttribute("data-date"),pW.getMonth()==M&&pW.getFullYear()==b&&(document.querySelectorAll(".item")[pm-1].focus(),document.querySelectorAll(".item")[pm-1].classList.add("today")),pw(),pM(pR,ph)},pC=function(){document.querySelectorAll("div#add-edit-event input").forEach(function(M){M.value=""})},pE=function(M){var b=M.toUpperCase();if(b.length<1)return!1;document.querySelectorAll("#events-wrapper article").forEach(function(M){M.getAttribute("data-summary").indexOf(b)>=0||M.getAttribute("data-category").indexOf(b)>=0?M.style.display="block":M.style.display="none"}),cM()},p_=function(M){var b=M.toUpperCase();document.querySelectorAll("#events-wrapper article").forEach(function(M){M.getAttribute("data-category").indexOf(b)>=0?M.style.display="block":M.style.display="none"}),cM(),document.getElementById("search").focus()},pS=function(){if(null==document.querySelectorAll(".select-box"))return!1;document.querySelectorAll(".select-box").forEach(function(M){M.addEventListener("blur",function(b){setTimeout(function(){M.parentElement.focus()},200)})})},pD=document.getElementById("app"),pP="",px=null,pI=function(M){document.getElementById(px).value=M},pU=[],pj=function(M){pU.push(M)},pF=function(M){try{"serviceWorker"in navigator&&navigator.serviceWorker.controller&&(collectionOfData={data:M,etag:"",url:""},navigator.serviceWorker.controller.postMessage({type:"parse",t:collectionOfData,e:"local-id",callback:!0,store:!0}))}catch(M){alert("event could not be imported because the file content is invalid"+M)}};!1==o1.background_sync_running&&(b(M3).route(pD,"/page_calendar",{"/page_calendar":{view:function(){return b(M3)("div",{class:"width-100 height-100",id:"calendar",oninit:function(){oQ(),o9(),pC(),MJ(),document.querySelector("#version").textContent=localStorage.getItem("version")}},[b(M3)("div",{class:"flex justify-content-spacebetween",id:""},[b(M3)("h3",{class:"card-header",id:"monthAndYear"},""),b(M3)("img",{id:"icon-loading",src:"./assets/image/E252.svg",alt:"loading"}),b(M3)("img",{id:"icon-waiting",src:"./assets/image/waiting.png",alt:"loading"}),b(M3)("div",{id:"time",oncreate:function(){document.getElementById("time").innerText=b(Mw)().format("HH:mm")}},o1.version)]),b(M3)("div",{class:"calendar-head flex width-100"},[b(M3)("div",o0[0]),b(M3)("div",o0[1]),b(M3)("div",o0[2]),b(M3)("div",o0[3]),b(M3)("div",o0[4]),b(M3)("div",o0[5]),b(M3)("div",o0[6])]),b(M3)("div",{id:"calendar-body"}),b(M3)("div",{id:"event-slider-indicator",class:"flex width-100 justify-content-spacearound"},[b(M3)("div",{class:"flex justify-content-spacearound"})]),b(M3)("div",{id:"event-slider",class:"flex "},[b(M3)("div",{id:"slider-inner",class:"flex width-100 justify-content-spacearound"})])])},onbeforeremove:function(){o1.selected_day=document.activeElement.getAttribute("data-date")},oncreate:function(){setTimeout(function(){document.activeElement.hasAttribute("data-date")&&(o1.selected_day=document.activeElement.getAttribute("data-date")),MY("","","");var M=new Date(o1.selected_day);ph=M.getMonth(),pR=M.getFullYear(),pk(ph,pR),document.querySelectorAll("div#calendar-body div.item").forEach(function(M){if(M.getAttribute("data-date")==o1.selected_day){M.focus(),pX(o1.selected_day);return}}),!1==o1.startup&&(pX(o1.selected_day),pT(),o1.startup=!0)},200)}},"/page_events":{view:function(){return b(M3)("div",{class:"flex",id:"events-wrapper",oninit:function(){document.querySelector(".loading-spinner").style.display="block",oQ(),o1.shortCut=!1},onremove:function(){o1.selected_day=document.activeElement.getAttribute("data-date"),o1.selected_day_id=document.activeElement.getAttribute("data-id")},oncreate:function(){document.querySelector(".loading-spinner").style.display="none",pL(),MY("","","")}},b(M3)("input",{type:"search",class:"width-98 item",id:"search",tabIndex:0,onfocus:function(){window.scroll({top:20,left:0,behavior:"smooth"})},oninput:function(){pE(document.activeElement.value)}}),b(M3)("div",{id:"filter-menu",class:"flex justify-content-spacearound",oncreate:function(M){M.dom.style.display="none"},onfocus:function(){window.scroll({top:20,left:0,behavior:"smooth"})}},[b(M3)("button",{class:"item",tabindex:0,"data-action":"filter-last-modified",oncreate:function(M){M.dom.style.display="none"}},"last edited"),b(M3)("button",{class:"item",tabindex:0,"data-action":"filter-desc",oncreate:function(M){M.dom.style.display="none"}},"the latest"),b(M3)("button",{class:"item",tabindex:0,"data-action":"filter-asc",oncreate:function(M){M.dom.style.display="none"}},"the oldest"),b(M3)("button",{class:"item category-filter-button",tabindex:0,"data-action":"filter-category",oncreate:function(M){M.dom.style.display="none",void 0!==o2.eventsfilter&&(document.querySelector(".category-filter-button").style.display="flex")}},"show only category: "+o2.eventsfilter)]),[oP.map(function(M,e){var z,o="";o=M.allDay?"all day":b(Mw)(1e3*M.dateStartUnix).format("HH:mm");var p="sunday"==o2.firstday?o0[b(Mw)(1e3*M.dateStartUnix).day()]:o0[b(Mw)(1e3*M.dateStartUnix).day()-1];void 0==p&&(p=""),z=null==M.dateStartUnix||null==M.dateEndUnix||b(Mw)(1e3*M.dateStartUnix).format(o2.dateformat)==b(Mw)(1e3*M.dateEndUnix).format(o2.dateformat)||M.allDay?b(Mw)(1e3*M.dateStartUnix).format(o2.dateformat)+" | "+p:b(Mw)(1e3*M.dateStartUnix).format(o2.dateformat)+" - "+b(Mw)(1e3*M.dateEndUnix).format(o2.dateformat);var c="";M.RRULE&&M.RRULE.freq&&(c=M.RRULE.freq.toLowerCase());var t=M.isSubscription?"subscription":"",n=M.allDay?"allDay":"";return b(M3)("article",{class:"item events "+t+" "+n,tabindex:0,"data-id":M.UID,"data-date":b(Mw)(1e3*M.dateStartUnix).format("YYYY-MM-DD"),"data-category":(M.CATEGORIES||"").toUpperCase(),"data-summary":(M.SUMMARY||"").toUpperCase(),"data-calendar-name":M.calendar_name||""},[b(M3)("div",{class:"icons-bar"},[b(M3)("div",{class:"date"},z),b(M3)("div",{class:"time"},o),b(M3)("div",{class:"rrule-freq"},c),b(M3)("h2",{class:"summary"},M.SUMMARY),b(M3)("div",{class:"location"},M.LOCATION),b(M3)("div",{class:"description"},M.DESCRIPTION)])])})])}},"/page_options":{view:function(){return b(M3)("div",{id:"options",oninit:function(){oQ(),o1.shortCut=!1},oncreate:function(){o1.notKaiOS||oE(),MY("","","")}},[b(M3)("h2",{class:"item",tabIndex:0},"Key assignment"),b(M3)("ul",{id:"keys",class:"item width-100",tabindex:"1",oncreate:function(M){var b=M.dom;MY("","",""),document.querySelectorAll(".select-box").forEach(function(M){M.addEventListener("keypress",function(){setTimeout(function(){M.parentElement.focus()},200)})}),b.focus()}},[b(M3)("li",{class:"flex justify-content-spacebetween"},[b(M3)("kbd","1 & 3"),b(M3)("div","Month")]),b(M3)("li",{class:"flex justify-content-spacebetween"},[b(M3)("kbd","2"),b(M3)("div","Event slider")]),b(M3)("li",{class:"width-100 flex justify-content-spacebetween"},[b(M3)("kbd","5"),b(M3)("div","Edit event")]),b(M3)("li",{class:"width-100 flex justify-content-spacebetween"},[b(M3)("kbd","Enter"),b(M3)("div","Events/Month")]),b(M3)("li",{class:"width-100 flex justify-content-spacebetween"},[b(M3)("kbd","0"),b(M3)("div","Events filtered by category")]),b(M3)("li",{class:"width-100 flex justify-content-spacebetween"},[b(M3)("kbd","#"),b(M3)("div","Moon")]),b(M3)("li",{class:"width-100 flex justify-content-spacebetween"},[b(M3)("kbd","*"),b(M3)("div","Today")]),b(M3)("li",{class:"width-100 flex justify-content-spacebetween"},[b(M3)("kbd","SoftLeft longpress"),b(M3)("div",{},"create event from template")]),b(M3)("li",{class:"width-100 flex justify-content-spacebetween"},[b(M3)("span",{class:"keys-day-event"}),b(M3)("span","day with event")]),b(M3)("li",{class:"width-100 flex justify-content-spacebetween"},[b(M3)("span",{class:"keys-day-multi-event"}),b(M3)("span","day with several events")]),b(M3)("li",{class:"width-100 flex justify-content-spacebetween"},[b(M3)("span",{class:"keys-day-rrule-event"}),b(M3)("span","day with reccurence")])]),b(M3)("h2",{class:"item",tabindex:"2"},"Settings"),b(M3)("div",{class:"text-center"},"Timezone: "+o2.timezone),b(M3)("div",{class:"item input-parent",id:"event-date-format-box",tabindex:"3"},[b(M3)("label",{for:"event-date-format"},"dateformat"),b(M3)("select",{id:"event-date-format",class:"select-box",onchange:function(){pY()},oncreate:function(){o9(),setTimeout(function(){pS(),""==o2.dateformat?document.querySelector("#event-date-format").value="YYYY-MM-DD":document.querySelector("#event-date-format").value=o2.dateformat},1e3)}},[b(M3)("option",{value:"YYYY-MM-DD"},"YYYY-MM-DD"),b(M3)("option",{value:"DD.MM.YYYY"},"DD.MM.YYYY")])]),b(M3)("div",{class:"item input-parent",id:"background-sync-box",tabindex:"3"},[b(M3)("label",{for:"background-syn-box"},"Background sync ?"),b(M3)("select",{id:"background-sync",class:"select-box",onchange:function(){pY()},oncreate:function(){"b2g"in navigator&&(document.getElementById("background-sync-box").style.display="none"),o9(),setTimeout(function(){pS(),"No"==o2.background_sync?document.querySelector("#background-sync").value="No":document.querySelector("#background-sync").value="Yes"},1e3)}},[b(M3)("option",{value:"Yes"},"Yes"),b(M3)("option",{value:"No"},"No")]),b(M3)("div",{class:"last-sync-info"},"last sync: "+oF)]),b(M3)("div",{class:"item input-parent",id:"firs-day-of-the-week-box",tabindex:"4"},[b(M3)("label",{for:"first-day-of-the-week"},"first day of the week"),b(M3)("select",{id:"first-day-of-the-week",class:"select-box",onchange:function(){pY()},oncreate:function(){setTimeout(function(){pS(),""==o2.firstday||void 0==o2.firstday?document.querySelector("#first-day-of-the-week").value="sunday":document.querySelector("#first-day-of-the-week").value=o2.firstday},1e3)}},[b(M3)("option",{value:"sunday"},"Sunday"),b(M3)("option",{value:"monday"},"Monday")])]),b(M3)("div",{class:"item input-parent",id:"event-duration-wrapper",tabindex:"5"},[b(M3)("label",{for:"default-duration-time"},"default Duration"),b(M3)("select",{id:"default-duration-time",class:"select-box",onchange:function(){pY()},oncreate:function(){o9(),setTimeout(function(){pS(),document.querySelector("#default-duration-time").value=o2.default_duration},1e3)}},[b(M3)("option",{value:"30"},"30 minutes"),b(M3)("option",{value:"60"},"60 minutes"),b(M3)("option",{value:"120"},"120 minutes"),b(M3)("option",{value:"240"},"240 minutes")])]),b(M3)("div",{class:"item input-parent",id:"event-notification-time-wrapper",tabindex:"5"},[b(M3)("label",{for:"default-notification"},"default Notification"),b(M3)("select",{id:"default-notification-time",class:"select-box",onchange:function(){pY()},oncreate:function(){o9(),setTimeout(function(){pS(),""==o2.default_notification?document.querySelector("#default-notification-time").value="none":document.querySelector("#default-notification-time").value=o2.default_notification},1e3)}},[b(M3)("option",{value:"none"},"none"),b(M3)("option",{value:"5"},"5 minutes"),b(M3)("option",{value:"10"},"10 minutes"),b(M3)("option",{value:"30"},"30 minutes"),b(M3)("option",{value:"1440"},"1 Day")])]),b(M3)("button",{class:"item",tabindex:"6",oncreate:function(){pU=[],MV("ics",pj)},onclick:function(){b(M3).route.set("/page_list_files")}},"Import events"),b(M3)("button",{class:"item",tabindex:"7",onclick:function(){setTimeout(function(){pp(!0,!1)},1e3),Mj("the big loading has begun",2e3)}},"Reload all events"),b(M3)("h2","Subscriptions"),b(M3)("button",{class:"item",tabindex:"8",onclick:function(){b(M3).route.set("/page_subscriptions")}},"add subscription"),b(M3)("div",{id:"subscription-text"},"Your subscriptions"),null!=oY?oY.map(function(M,e){return b(M3)("button",{class:"item subscriptions-item","data-id":M.id,"data-action":"delete-subscription",tabindex:e+8,onfocus:function(){MY("","","")},onblur:function(){MY("","","")}},M.name)}):b(M3)("div",{class:"text-center"},"No subscriptions available"),b(M3)("h2","Category view"),b(M3)("div",{class:"item input-parent",id:"events-category-filter-wrapper",tabindex:""},[b(M3)("label",{for:"events-category-filter"},"Select the category"),b(M3)("select",{id:"events-category-filter",class:"select-box",onchange:function(){pY()},oncreate:function(){setTimeout(function(){pS(),document.querySelector("#events-category-filter").value=o2.eventsfilter},1e3)}},oP.length>0?[b(M3)("option",{value:"-"},"-")].concat(Mm(oP.map(function(M){return M.CATEGORIES}).filter(function(M,b,e){return""!==M&&e.indexOf(M)===b}).map(function(M){return b(M3)("option",{value:M},M)}))):[b(M3)("option",{value:"-"},"No categories available")])]),b(M3)("h2","Calendars"),null!=Mp?Mp.map(function(M){return b(M3)("button",{class:"item","data-calendar-name":M.name,oncreate:function(b){var e=b.dom;!1==M.view&&e.classList.add("active"),"local"==M.name&&(e.style.display="none")},onclick:function(){Mp.forEach(function(M){M.name==document.activeElement.getAttribute("data-calendar-name")&&(M.view=!M.view)}),document.activeElement.classList.toggle("active"),b(Mv).setItem("calendarNames",Mp).then(function(){o5(),Mj("will be applied the next time the app is started",2e3)})}},M.name)}):"",,b(M3)("h2","Accounts"),b(M3)("button",{class:"item google-button caldav-button",onclick:function(){b(M3).route.set("/page_accounts")}},[b(M3)("div",{class:"flex align-item-center justify-content-spacebetween "},[b(M3)("img",{src:"assets/image/caldav.png"}),b(M3)("span","CalDAV Account")])]),b(M3)("button",{class:"item google-button",onclick:function(){o$=setInterval(function(){"true"==localStorage.getItem("oauth_callback")&&(b(M3).route.set("/page_calendar"),clearInterval(o$),setTimeout(function(){ox=[],b(Mv).getItem("accounts").then(function(M){if(null==M)return ox=[],!1;ox=M,pp(!1,!1)}).catch(function(M){console.log(M)})},5e3))},1e3),window.open("https://accounts.google.com/o/oauth2/v2/auth?client_id=762086220505-f0kij4nt279nqn21ukokm06j0jge2ngl.apps.googleusercontent.com&response_type=code&state=state_parameter_passthrough_value&scope=https://www.googleapis.com/auth/calendar&redirect_uri=https://greg.strukturart.com/index.html&access_type=offline&prompt=consent")}},[b(M3)("div",{class:"flex justify-content-spacebetween align-item-center "},[b(M3)("img",{src:"assets/image/google_button.png"}),b(M3)("span","Sign in with Google")])]),null!=ox?b(M3)("div",{id:"subscription-text"},"Your accounts"):"",null!=ox?ox.map(function(M){return b(M3)("button",{class:"item subscriptions-item","data-id":M.id,"data-account-type":M.type,"data-action":"edit-delete-account",onblur:function(){MY("","","")},onfocus:function(){"oauth"==M.type?MY("","",""):MY("","","")}},M.name)}):"",b(M3)("h2",{class:"ads-title"},"Ads"),b(M3)("div",{id:"KaiOsAds-Wrapper",class:"flex justify-content-spacearound",oninit:function(){o2.ads||document.querySelector("h2.ads-title").remove()},oncreate:function(){},onfocus:function(){MY("","open ads","")},onblur:function(){MY("","open ads","")}})])}},"/page_add_event":{view:function(){return b(M3)("div",{id:"add-edit-event",tabindex:"0",oninit:function(){oQ(),o1.shortCut=!1}},[b(M3)("div",{class:"item input-parent",tabindex:0,oncreate:function(M){var b=M.dom;setTimeout(function(){b.focus(),MY("","","")},500)}},[b(M3)("label",{for:"event-title"},"Title"),b(M3)("input",{placeholder:"",type:"text",id:"event-title",oncreate:function(){o9(),pZ()},onfocus:function(){px="event-title",MY("","","")},onblur:function(){px="event-title",MY("","","")}})]),b(M3)("div",{class:"item input-parent",tabindex:"1"},[b(M3)("label",{for:"event-location"},"Location"),b(M3)("input",{placeholder:"",type:"text",id:"event-location",oninput:function(M){Mk(M.target.value,"LOCATION")}})]),b(M3)("div",{id:"search-result"}),b(M3)("div",{class:"item input-parent",tabindex:"2",onfocus:function(){Mk("close")}},[b(M3)("label",{for:"event-date"},"Start Date"),b(M3)("input",{placeholder:o2.dateformat,type:"date",id:"event-date",class:"select-box",oncreate:function(M){M.dom.value=o1.selected_day}})]),b(M3)("div",{class:"item input-parent",tabindex:"3"},[b(M3)("label",{for:"event-date-end"},"End Date"),b(M3)("input",{placeholder:o2.dateformat,type:"date",id:"event-date-end",class:"select-box",oncreate:function(M){M.dom.min=o1.selected_day}})]),b(M3)("div",{class:"item input-parent flex justify-content-center",tabindex:"4"},[b(M3)("label",{for:"event-all-day"},"All Day"),b(M3)("input",{type:"checkbox",id:"event-all-day",class:"check-box",onfocus:function(M){!1==M.target.checked?(setTimeout(function(){document.querySelector(".check-box").parentElement.focus()},300),document.querySelectorAll(".time").forEach(function(M){document.querySelector("#event-time-start").value="01:00",document.querySelector("#event-time-end").value="01:00",M.style.display="none",M.classList.remove("item"),cM()})):(setTimeout(function(){document.querySelector(".check-box").parentElement.focus()},300),document.querySelectorAll(".time").forEach(function(M){M.style.display="block",M.classList.add("item"),cM()}))}}),b(M3)("div",{class:"ckb-wrapper"},[b(M3)("div",{class:"ckb-icon"}),b(M3)("div",{class:"toogle-button"})])]),b(M3)("div",{class:"item input-parent time",tabindex:"4"},[b(M3)("label",{for:"event-time-start"},"Start Time"),b(M3)("input",{placeholder:"hh:mm",type:"time",id:"event-time-start",class:"select-box",oncreate:function(M){M.dom.value=b(Mw)().format("HH:mm")}})]),b(M3)("div",{class:"item input-parent time",tabindex:"5"},[b(M3)("label",{for:"event-time-end"},"End Time"),b(M3)("input",{placeholder:"hh:mm",type:"time",id:"event-time-end",class:"select-box",onblur:function(M){var e=document.querySelector("#event-date").value,z=""!=document.querySelector("#event-date-end").value?document.querySelector("#event-date-end").value:document.querySelector("#event-date").value,o=b(Mw)(e+" "+document.querySelector("#event-time-start").value);!1==b(Mw)(z+" "+M.target.value).isAfter(o)&&Mj("something is wrong with the time",2e3)},oncreate:function(M){var e=M.dom;console.log(o2.default_duration),e.value=b(Mw)().add(o2.default_duration,"minutes").format("HH:mm")}})]),b(M3)("div",{class:"item input-parent",tabindex:"6"},[b(M3)("label",{for:"event-description"},"Description"),b(M3)("input",{placeholder:"",type:"text",id:"event-description"})]),b(M3)("div",{class:"item input-parent",tabindex:"6"},[b(M3)("label",{for:"event-category"},"Category"),b(M3)("input",{placeholder:"",type:"text",id:"event-category"})]),b(M3)("div",{class:"item input-parent",id:"event-notification-time-wrapper",tabindex:"7"},[b(M3)("label",{for:"notification"},"Notification"),b(M3)("select",{id:"event-notification-time",class:"select-box",oncreate:function(){setTimeout(function(){document.querySelector("#event-notification-time").value=o2.default_notification},2e3)}},[b(M3)("option",{value:"none"},"none"),b(M3)("option",{value:"5"},"5 minutes"),b(M3)("option",{value:"10"},"10 minutes"),b(M3)("option",{value:"30"},"30 minutes"),b(M3)("option",{value:"60"},"60 minutes"),b(M3)("option",{value:"1440"},"1 Day")])]),b(M3)("div",{class:"item input-parent",id:"event-recur-wrapper",tabindex:"8",oncreate:function(){setTimeout(function(){document.querySelector("#event-recur").value="none"},1e3)}},[b(M3)("label",{for:"event-recur"},"Recur"),b(M3)("select",{id:"event-recur",class:"select-box"},[b(M3)("option",{value:"none"},"none"),b(M3)("option",{value:"DAILY"},"Daily"),b(M3)("option",{value:"WEEKLY"},"Weekly"),b(M3)("option",{value:"BIWEEKLY"},"Biweekly"),b(M3)("option",{value:"MONTHLY"},"Monthly"),b(M3)("option",{value:"YEARLY"},"Yearly")])]),b(M3)("div",{class:"item input-parent",id:"event-calendar-wrapper",tabindex:"9"},[b(M3)("label",{for:"event-calendar"},"Calendars"),b(M3)("select",{id:"event-calendar",class:"select-box"},[Mp.map(function(M){return b(M3)("option",{value:M.id,"data-calendar-data":M.data},M.name)})])]),b(M3)("button",{tabindex:"10",id:"save-event",class:"item save-button",oncreate:function(){pS(),cM()},onclick:function(){var M=document.getElementById("event-calendar");p8(M.options[M.selectedIndex].value,M.options[M.selectedIndex].text)}},"save")])},oncreate:function(){MY("","","")}},"/page_edit_event":{view:function(){var M;return b(M3)("div",{id:"add-edit-event",oninit:function(){},omcreate:function(){oQ(),o1.shortCut=!1}},[b(M3)("div",{class:"item input-parent",tabindex:0,oncreate:function(M){var b=M.dom;setTimeout(function(){b.focus(),MY("","","")},500)}},[b(M3)("label",{for:"event-title"},"Title"),b(M3)("input",{placeholder:"",type:"text",id:"event-title",value:Mc.SUMMARY})]),b(M3)("div",{class:"item input-parent",tabindex:"1"},[b(M3)("label",{for:"event-location"},"Location"),b(M3)("input",{placeholder:"",type:"text",id:"event-location",value:Mc.LOCATION})]),b(M3)("div",{class:"item input-parent",tabindex:"2"},[b(M3)("label",{for:"event-date"},"Start Date"),b(M3)("input",{placeholder:o2.dateformat,type:"date",id:"event-date",class:"select-box",oncreate:function(M){M.dom.value=Mc.dateStart}})]),b(M3)("div",{class:"item input-parent",tabindex:"3"},[b(M3)("label",{for:"event-date-end"},"End Date"),b(M3)("input",{placeholder:o2.dateformat,type:"date",id:"event-date-end",class:"select-box",oncreate:function(M){M.dom.value=Mc.dateEnd}})]),b(M3)("div",{class:"item input-parent",tabindex:"4"},[b(M3)("label",{for:"event-all-day"},"All Day"),b(M3)("input",{type:"checkbox",id:"event-all-day",class:"check-box",oncreate:function(){!0==Mc.allDay&&(document.querySelector("#event-all-day").checked=!0,document.querySelectorAll(".time").forEach(function(M){M.style.display="none",M.classList.remove("item"),cM()}))},onfocus:function(M){!1==M.target.checked?(setTimeout(function(){M.focus()},300),document.querySelectorAll(".time").forEach(function(M){M.style.display="none",M.classList.remove("item"),document.querySelector("#event-time-start").value="01:00",document.querySelector("#event-time-end").value="01:00",cM()})):(setTimeout(function(){M.focus()},300),document.querySelectorAll(".time").forEach(function(M){M.style.display="block",M.classList.add("item"),cM()}))}}),b(M3)("div",{class:"ckb-wrapper"},[b(M3)("div",{class:"ckb-icon"}),b(M3)("div",{class:"toogle-button"})])]),b(M3)("div",{class:"item input-parent time",tabindex:"4"},[b(M3)("label",{for:"event-time-start"},"Start Time"),b(M3)("input",{placeholder:"HH:mm",type:"time",id:"event-time-start",class:"select-box",value:8==Mc.time_start.length?Mc.time_start.slice(0,-3):Mc.time_start})]),b(M3)("div",{class:"item input-parent time",tabindex:"5"},[b(M3)("label",{for:"event-time-end"},"End Time"),b(M3)("input",{placeholder:"hh:mm",type:"time",id:"event-time-end",class:"select-box",value:8==Mc.time_end.length?Mc.time_end.slice(0,-3):Mc.time_end})]),b(M3)("div",{class:"item input-parent",tabindex:"6"},[b(M3)("label",{for:"event-description"},"Description"),b(M3)("input",{placeholder:"",type:"text",id:"event-description",value:Mc.DESCRIPTION})]),b(M3)("div",{class:"item input-parent",tabindex:"6"},[b(M3)("label",{for:"event-category"},"Category"),b(M3)("input",{placeholder:"",type:"text",id:"event-category",value:Mc.CATEGORIES})]),b(M3)("div",{class:"item input-parent",id:"event-notification-time-wrapper",tabindex:"7"},[b(M3)("label",{for:"notification"},"Notification"),b(M3)("select",{id:"event-notification-time",class:"select-box"},[b(M3)("option",{value:"none"},"none"),b(M3)("option",{value:"5"},"5 minutes"),b(M3)("option",{value:"10"},"10 minutes"),b(M3)("option",{value:"30"},"30 minutes"),b(M3)("option",{value:"60"},"60 minutes"),b(M3)("option",{value:"1440"},"1 Day")])]),b(M3)("div",{class:"item input-parent",id:"event-calendar-wrapper",tabindex:"9"},[b(M3)("label",{for:"event-calendar"},"Calendars"),b(M3)("select",{id:"event-calendar",class:"select-box",onchange:function(){o1.event_calendar_changed=!0}},[Mp.map(function(M){var e="";return Mc.calendar_name==M.name&&(e="selected"),b(M3)("option",{value:M.id,selected:e,"data-calendar-data":M.data},M.name)})])]),b(M3)("div",{class:"item input-parent",id:"event-recur-wrapper",tabindex:"8",oncreate:function(){document.querySelector("#event-notification-time").value=Mc.alarm}},[b(M3)("label",{for:"event-recur"},"Recur"),b(M3)("select",{id:"event-recur",value:null!==(M=Mc.RRULE.freq)&&void 0!==M?M:"none",class:"select-box"},[b(M3)("option",{value:"none"},"none"),b(M3)("option",{value:"DAILY"},"Daily"),b(M3)("option",{value:"WEEKLY"},"Weekly"),b(M3)("option",{value:"BIWEEKLY"},"Biweekly"),b(M3)("option",{value:"MONTHLY"},"Monthly"),b(M3)("option",{value:"YEARLY"},"Yearly")])]),b(M3)("button",{tabindex:"9",id:"delete-event",class:"item",onclick:function(){p9(Mc.etag,Mc.url,Mc.id,Mc.UID)}},"delete"),b(M3)("button",{tabindex:"10",id:"save-event",class:"item save-button",oncreate:function(){pS()},onclick:function(){if(o1.event_calendar_changed||p7(Mc.etag,Mc.url,Mc.id,Mc.UID,Mc.calendar_name),o1.event_calendar_changed){var M=document.getElementById("event-calendar");p9(Mc.etag,Mc.url,Mc.id,Mc.UID),p8(M.options[M.selectedIndex].value,M.options[M.selectedIndex].text)}}},"update"),b(M3)("button",{tabindex:"11",id:"save-event-as-template",class:"item save-template-button",oncreate:function(){pS()},onclick:function(){pf(document.getElementById("event-title").value,document.getElementById("event-description").value,document.getElementById("event-location").value,document.getElementById("event-category").value)}},"save as template")])}},"/page_subscriptions":{view:function(){return b(M3)("div",{id:"subscription-form"},[b(M3)("div",{class:"item input-parent",tabindex:"0",oninit:function(){MY("","",""),oQ(),o1.shortCut=!1},oncreate:function(M){M.dom.focus()}},[b(M3)("label",{for:"description"},"subscription name"),b(M3)("input",{placeholder:"Name",type:"text",id:"cal-subs-name"})]),b(M3)("div",{class:"item input-parent",tabindex:"1",onblur:function(){MY("","","")}},[b(M3)("label",{for:"description"},"subscription url"),b(M3)("input",{placeholder:"URL",type:"text",id:"cal-subs-url","data-scan-action":"true",onfocus:function(){MY("","","")},oncreate:function(){setTimeout(function(){document.getElementById("cal-subs-url").value=pP},1e3)},onblur:function(){MY("","","")}})]),b(M3)("button",{class:"item save-button",tabindex:"2",onclick:function(){pV()}},"save")])}},"/page_accounts":{view:function(){return b(M3)("div",{id:"account-form"},[b(M3)("div",{class:"item input-parent",tabindex:"0",oninit:function(){oQ()},oncreate:function(M){M.dom.focus()}},[b(M3)("label",{for:"description"},"account name"),b(M3)("input",{placeholder:"Name",type:"text",id:"account-name"})]),b(M3)("div",{class:"item input-parent",tabindex:"1",onblur:function(){MY("","","")}},[b(M3)("label",{for:"description"},"server"),b(M3)("input",{placeholder:"URL",type:"text",id:"account-url","data-scan-action":"true",onfocus:function(){MY("","","")},onblur:function(){MY("","","")}})]),b(M3)("div",{class:"item input-parent",tabindex:"2",onblur:function(){MY("","","")}},[b(M3)("label",{for:"description"},"username"),b(M3)("input",{placeholder:"username",type:"url",id:"account-username","data-scan-action":"true",onfocus:function(){MY("","","")},onblur:function(){MY("","","")}})]),b(M3)("div",{class:"item input-parent",tabindex:"3",onblur:function(){MY("","","")}},[b(M3)("label",{for:"description"},"password"),b(M3)("input",{placeholder:"password",type:"password",id:"account-password","data-scan-action":"true",onfocus:function(){MY("","","")},onblur:function(){MY("","","")}})]),b(M3)("button",{class:"item save-button",tabindex:"4",onclick:function(){pG()}},"save")])}},"/page_edit_account":{view:function(){return b(M3)("div",{id:"account-form"},[b(M3)("div",{class:"item input-parent",tabindex:"0",oninit:function(){},oncreate:function(M){M.dom.focus(),oQ(),o1.shortCut=!1}},[b(M3)("label",{for:"description"},"account name"),b(M3)("input",{placeholder:"Name",type:"text",id:"account-name",value:Mt.name})]),b(M3)("div",{class:"item input-parent",tabindex:"1",onblur:function(){MY("","","")}},[b(M3)("label",{for:"description"},"server"),b(M3)("input",{placeholder:"URL",type:"text",id:"account-url","data-scan-action":"true",value:Mt.server_url,onfocus:function(){MY("","","")},onblur:function(){MY("","","")}})]),b(M3)("div",{class:"item input-parent",tabindex:"2",onblur:function(){MY("","","")}},[b(M3)("label",{for:"description"},"username"),b(M3)("input",{placeholder:"username",type:"url",id:"account-username",value:Mt.user,"data-scan-action":"true",onfocus:function(){MY("","","")},onblur:function(){MY("","","")}})]),b(M3)("div",{class:"item input-parent",tabindex:"3",onblur:function(){MY("","","")}},[b(M3)("label",{for:"description"},"password"),b(M3)("input",{placeholder:"password",type:"password",id:"account-password","data-scan-action":"true",value:Mt.password,onfocus:function(){MY("","","")},onblur:function(){MY("","","")}})]),b(M3)("button",{class:"item save-button",tabindex:"4",onclick:function(){pG(!0,o1.edit_account_id)}},"update")])}},"/page_event_templates":{view:function(){return b(M3)("div",{id:"options",oninit:function(){oQ()},oncreate:function(){MY("","","")}},[b(M3)("h2",{class:"text-center"},"Templates"),oI.map(function(M,e){return b(M3)("button",{class:"item",onclick:function(){Mn=M.id,b(M3).route.set("/page_add_event")},oncreate:function(M){M.dom},tabIndex:e,"data-id":M.id},M.title)})])}},"/page_list_files":{view:function(){return b(M3)("div",{id:"options",oninit:function(){oQ()}},[b(M3)("h2",{class:"text-center",id:"file-head"},"files"),pU.map(function(M,e){var z=M.split("/");return z=z[z.length-1],b(M3)("button",{class:"item",oncreate:function(M){var b=M.dom;0==e&&b.focus()},tabIndex:e,onclick:function(){!function(M,b){try{var e=navigator.getDeviceStorage("sdcard"),z=e.get(M);z.onsuccess=function(){var M=this.result,e=new FileReader;e.onerror=function(M){helper.toaster("can't read file",3e3),e.abort()},e.onloadend=function(M){b(e.result)},e.readAsText(M)},z.onerror=function(){alert("Unable to get the file: "+this.error)}}catch(M){console.log(M)}if("b2g"in navigator)try{var e=navigator.b2g.getDeviceStorage("sdcard"),z=e.get(M).then(function(M){var e=new FileReader;e.onerror=function(M){console.log("filereader error: "+M),e.abort()},e.onloadend=function(M){b(e.result)},e.readAsText(M)})}catch(M){alert(M)}}(M,pF)}},z)})])}},"/page_events_filtered":{view:function(){var M=b(M3).route.param("query"),e=0;return b(M3)("div",{class:"flex",id:"events-wrapper",onremove:function(){o1.selected_day=document.activeElement.getAttribute("data-date"),o1.selected_day_id=document.activeElement.getAttribute("data-id")},oninit:function(){oQ(),o1.shortCut=!1,Mj("Category: "+M,8e3)},oncreate:function(){document.querySelectorAll(".item")[0].focus(),MY("","","")}},[oP.map(function(z){if(z.CATEGORIES&&z.CATEGORIES.toLowerCase()===M.toLowerCase()){e++;var o,p="";p=z.allDay?"all day":b(Mw)(1e3*z.dateStartUnix).format("HH:mm"),o=null==z.dateStartUnix||null==z.dateEndUnix||b(Mw)(1e3*z.dateStartUnix).format(o2.dateformat)==b(Mw)(1e3*z.dateStartUnix).format(o2.dateformat)||z.allDay?b(Mw)(1e3*z.dateStartUnix).format(o2.dateformat):b(Mw)(1e3*z.dateStartUnix).format(o2.dateformat)+" - "+b(Mw)(1e3*z.dateStartUnix).format(o2.dateformat);var c=z.isSubscription?"subscription":"",t=z.allDay?"allDay":"";return b(M3)("article",{class:"item events "+c+" "+t,tabindex:e,"data-id":z.UID,"data-date":b(Mw)(1e3*z.dateStartUnix).format("YYYY-MM-DD"),"data-category":(z.CATEGORIES||"").toUpperCase(),"data-summary":(z.SUMMARY||"").toUpperCase()},[b(M3)("div",{class:"icons-bar"},[b(M3)("div",{class:"date"},o),b(M3)("div",{class:"time"},p),b(M3)("h2",{class:"summary"},z.SUMMARY),b(M3)("div",{class:"location"},z.LOCATION),b(M3)("div",{class:"description"},z.DESCRIPTION)])])}})])}}}),b(M3).route.prefix="#");var pY=function(){o2.default_notification=document.getElementById("default-notification-time").value,o2.default_duration=document.getElementById("default-duration-time").value,o2.dateformat=document.getElementById("event-date-format").value,o2.firstday=document.getElementById("first-day-of-the-week").value,o2.eventsfilter=document.getElementById("events-category-filter").value,o2.background_sync=document.getElementById("background-sync").value,"Yes"==o2.background_sync?MQ():MK(),b(Mv).setItem("settings",o2).then(function(){o9()}).catch(function(M){console.log(M)})},pH=function(M){document.activeElement.value=M},pV=function(){var M;null==oY&&(oY=[]),MD(document.getElementById("cal-subs-url").value)&&""!=document.getElementById("cal-subs-name").value?(M=MT(32),oY.push({url:document.getElementById("cal-subs-url").value,name:document.getElementById("cal-subs-name").value,id:M}),document.querySelector("input#cal-subs-name").value="",document.querySelector("input#cal-subs-url").value="",b(Mv).setItem("subscriptions",oY).then(function(M){b(M3).route.set("/page_options")}),b(Mv).setItem(M,"").then(function(M){Mj("subscription added",4e3),pq()}).catch(function(M){console.log(M)})):Mj("Please enter a name and a valid url",2e3)},pG=function(M,e){MD(document.getElementById("account-url").value)&&""!=document.getElementById("account-name").value&&""!=document.getElementById("account-username").value&&""!=document.getElementById("account-password").value?(M?(ox=ox.filter(function(M){return M.id!==e})).push({server_url:document.getElementById("account-url").value,user:document.getElementById("account-username").value,password:document.getElementById("account-password").value,name:document.getElementById("account-name").value,id:e,type:"basic"}):(null==ox&&(ox=[]),ox.push({server_url:document.getElementById("account-url").value,user:document.getElementById("account-username").value,password:document.getElementById("account-password").value,name:document.getElementById("account-name").value,id:MT(32),type:"basic"})),b(Mv).setItem("accounts",ox).then(function(M){o8(),pp(!0,!1),b(M3).route.set("/page_options")}).catch(function(M){console.log(M)})):Mx("Please enter a name and a valid url",2e3)},pK=function(){var M=oY.filter(function(M){return M.id!=document.activeElement.getAttribute("data-id")});b(Mv).removeItem(document.activeElement.getAttribute("data-id")).then(function(){Mx("subscription removed",4e3)}).catch(function(M){console.log(M)}),b(Mv).setItem("subscriptions",M).then(function(M){Mj("subscription deleted",2e3)}).catch(function(M){Mx(M,2e3)}),document.activeElement.remove()},pQ=function(){var M=ox.filter(function(M){return M.id!=document.activeElement.getAttribute("data-id")});b(Mv).setItem("accounts",M).then(function(M){Mj("account deleted",2e3),document.activeElement.remove(),MY("","","")}).catch(function(M){Mx(M,2e3)}),b(Mv).removeItem(document.activeElement.getAttribute("data-id")).then(function(){}).catch(function(M){console.log(M)})};function pJ(){"hidden"===document.visibilityState?o1.visible=!1:setTimeout(function(){o1.visible=!0},1e3)}b(Mv).getItem("subscriptions").then(function(M){oY=M,pq()}).catch(function(M){}),pJ();var p$=function(M){oI=oI.filter(function(b){return b.id!=M}),b(Mv).setItem("event_templates",oI).then(function(M){Mj("template deleted",2e3),b(M3).route.set("/page_calendar")}).catch(function(M){console.log(M)})},pZ=function(){oI.forEach(function(M){M.id==Mn&&(document.getElementById("event-title").value=M.title,document.getElementById("event-description").value=M.description,document.getElementById("event-location").value=M.location,document.getElementById("event-category").value=M.category,Mn="")})},p0=function(M){if(pw(),cM(),"SELECT"==document.activeElement.nodeName||"date"==document.activeElement.type||"time"==document.activeElement.type)return!1;var e=document.activeElement.tabIndex+M,z=0,o=document.activeElement.parentNode.parentNode;if(z=o.querySelectorAll('.item:not([style*="display: none"]'),("/page_calendar"==b(M3).route.get()||"/page_options"==b(M3).route.get()||"/page_events"==b(M3).route.get()||"/page_event_templates"==b(M3).route.get()||"/page_list_files"==b(M3).route.get()||b(M3).route.get().startsWith("/page_events"))&&(z=document.activeElement.parentNode.parentNode.querySelectorAll('.item:not([style*="display: none"]'),o1.shortCut=!1),"/page_calendar"==b(M3).route.get()&&(o1.shortCut=!1,MY("","","")),("/page_subscriptions"==b(M3).route.get()||"/page_accounts"==b(M3).route.get()||"/page_edit_account"==b(M3).route.get())&&(z=o.querySelectorAll('.item:not([style*="display: none"]'),z=o.querySelectorAll(".item")),"/page_add_event"==b(M3).route.get()||"/page_edit_event"==b(M3).route.get()){if(z=o.querySelectorAll('.item:not([style*="display: none"]'),document.activeElement.parentNode.classList.contains("input-parent"))return document.activeElement.parentNode.focus(),!0;document.getElementById("add-edit-event").firstElementChild.focus()}var p=0;e<=z.length&&(p=z[e]).focus(),e==z.length&&(p=z[0]).focus();for(var c=document.activeElement.getBoundingClientRect(),t=c.top-document.body.getBoundingClientRect().top+c.height/2,n=document.activeElement.parentNode;n&&!(n.scrollHeight>n.clientHeight)&&!(n.scrollWidth>n.clientWidth);)n=n.parentNode;if(n?n.scrollBy({left:0,top:t-window.innerHeight/2,behavior:"smooth"}):document.body.scrollBy({left:0,top:t-window.innerHeight/2,behavior:"smooth"}),"/page_calendar"==b(M3).route.get()||"/page_events"==b(M3).route.get()||b(M3).route.get().startsWith("/page_events"))try{o1.selected_day=p.getAttribute("data-date"),o1.selected_day_id=p.getAttribute("data-id"),pX(o1.selected_day)}catch(M){}},p1=function(M,b,e,z){if("mozAlarms"in navigator){var o=navigator.mozAlarms.add(M,"honorTimezone",{note:b,event_id:e,type:z});o.onsuccess=function(){console.log("alarm set")},o.onerror=function(){console.log("An error occurred: "+this.error.name)}}if("b2g"in navigator)try{navigator.b2g.alarmManager.add({date:M,data:{note:b,type:z},ignoreTimezone:!1}).then(function(M){return console.log("add id: "+M)},function(M){return console.log("add err: "+M)})}catch(M){console.log(M)}},p2=function(M){if(navigator.mozAlarms){var b=navigator.mozAlarms.getAll();b.onsuccess=function(){this.result.forEach(function(b){if(b.data.event_id==M){var e=navigator.mozAlarms.remove(b.id);e.onsuccess=function(){console.log("removed")},e.onerror=function(){console.log("An error occurred: "+this.error.name)}}})},b.onerror=function(){console.log("An error occurred:",this.error.name)}}if("b2g"in navigator)try{navigator.b2g.alarmManager.getAll().onsuccess=function(){this.result.forEach(function(b){if(b.data.event_id==M){var e=navigator.b2g.alarmManager.remove(b.id);e.onsuccess=function(){console.log("removed")},e.onerror=function(){console.log("An error occurred: "+this.error.name)}}})}}catch(M){console.log(M)}},p3=function(M,e,z){var o=b(Mw)(M).format("YYYYMMDDTHHmmss");return o=e?";VALUE=DATE:"+b(Mw)(M).format("YYYYMMDD"):":"+o,z&&(o=b(Mw)(M).format("YYYYMMDDTHHmmss")),o},p4=["SU","MO","TU","WE","TH","FR","SA"],p5=function(M,b,e){if("none"===M)return"";var z=p4[new Date(e).getDay()];return"WEEKLY"===M?"FREQ=".concat(M,";INTERVAL=1;BYDAY=").concat(z,";UNTIL=").concat(p3(b,!1,!0)):"FREQ=".concat(M,";UNTIL=").concat(p3(b,!1,!0))},p6=[],p8=function(M,e){var z,o,p=!0,c=!1;!0===document.getElementById("event-all-day").checked&&(c=!0),""===document.getElementById("event-title").value&&(Mx("Title can't be empty",2e3),p=!1),"none"!=document.getElementById("event-recur").value&&""==document.getElementById("event-date-end").value&&(Mx("An end date is required for a recurrence",2e3),p=!1);var t=document.getElementById("event-time-start"),n=t.value?"".concat(t.value,":00"):"00:00:00",O=document.getElementById("event-time-end"),r=O.value?"".concat(O.value,":00"):"00:00:00",a=new Date("01/01/2000 "+n),i=new Date("01/01/2000 "+r),A=document.getElementById("event-date").value+" "+n;""==document.getElementById("event-date-end").value&&(document.getElementById("event-date-end").value=document.getElementById("event-date").value);var d=document.getElementById("event-date-end").value+" "+r;c&&(d=b(Mw)(document.getElementById("event-date-end").value+" "+r).add(1,"day").format("YYYY-MM-DD hh:mm:ss"));var s=document.getElementById("event-date").value+" "+r,q=document.getElementById("event-notification-time").value;if("none"!==q&&((z=new Date(A)).setMinutes(z.getMinutes()-q),q=p3(z.toISOString())),""!=n&&""!=r){var a=new Date(document.getElementById("event-date").value+" "+n),i=new Date(document.getElementById("event-date-end").value+" "+r);i","",""));break;case"#":document.querySelectorAll("div#calendar div#calendar-body div div [class^='moon-phase-']").forEach(function(M){M.classList.toggle("active")});break;case"SoftRight":case"Alt":case"m":if(cz("page_events_filtered"))return b(M3).route.set("/page_events");if(ce("page_calendar")&&o1.shortCut){var e="",z=document.querySelectorAll("#event-slider article");return z.forEach(function(M,b){"block"==M.style.display&&(e=M),z.length-1==b&&(void 0==(Mc=oP.filter(function(M){return!0!=M.isSubscription&&M.UID==e.getAttribute("data-uid")})[0])?Mj("subscriptions events cannot be edited",4e3):p9(Mc.etag,Mc.url,Mc.id,Mc.UID))})}if(ce("page_calendar")&&!o1.shortCut)return b(M3).route.set("/page_options");if(cz("page_events"))return document.querySelectorAll("#filter-menu button").forEach(function(M){M.style.display="block"}),document.querySelector("#filter-menu").style.display="flex",document.querySelector("#filter-menu").firstChild.focus(),document.querySelector("#search").focus();cz("page_add_event")&&M_(pI),"edit-delete-account"==document.activeElement.getAttribute("data-action")&&"oauth"!=document.activeElement.getAttribute("data-account-type")&&(o1.edit_account_id=document.activeElement.getAttribute("data-id"),Mt=ox.filter(function(M){return M.id==o1.edit_account_id})[0],b(M3).route.set("/page_edit_account"));break;case"SoftLeft":case"Control":if(ce("page_event_templates")&&p$(document.activeElement.getAttribute("data-id")),cz("page_events")){if(document.activeElement.classList.contains("subscription"))return Mj("subscriptions events cannot be edited",4e3);return pl(),document.activeElement.classList.contains("events")&&b(M3).route.set("/page_edit_event")}if(ce("page_subscriptions")||ce("page_accounts"))return"true"==document.activeElement.getAttribute("data-scan-action")&&M2(pH);if(ce("page_options")&&("delete-subscription"==document.activeElement.getAttribute("data-action")&&pK(),"edit-delete-account"==document.activeElement.getAttribute("data-action")&&pQ()),ce("page_calendar")&&o1.shortCut){var o="",p=document.querySelectorAll("#event-slider article");return p.forEach(function(M,e){"block"==M.style.display&&(o=M),p.length-1==e&&(void 0==(Mc=oP.filter(function(M){return!M.isSubscription&&M.UID==o.getAttribute("data-uid")})[0])?Mj("subscriptions events cannot be edited",4e3):b(M3).route.set("/page_edit_event"))})}if(ce("page_calendar"))return b(M3).route.set("/page_add_event");break;case"Enter":if(!o1.visible)return;if(document.activeElement.classList.contains("input-parent"))return document.activeElement.children[1].focus(),document.activeElement.classList.contains("check-box")&&(!0==document.activeElement.checked?document.activeElement.checked=!1:document.activeElement.checked=!0);if(document.activeElement.classList.contains("search-item"))return Mk("click");if("export-event"==document.activeElement.id)return oP.forEach(function(M){M.UID==o1.selected_day_id&&p6.push(M.data)}),M$(p6[0].UID+".ics",p6,function(M){Mj(M,3e3)}),Mj("event exported",5e3);if(oP.length>0||null==oP){if(cz("page_calendar")&&(document.querySelector(".loading-spinner").style.display="block"),cz("page_events")){if("BUTTON"!==document.activeElement.tagName&&b(M3).route.set("/page_calendar"),"BUTTON"===document.activeElement.tagName){var c=document.activeElement.getAttribute("data-action");document.querySelectorAll("#events-wrapper article").forEach(function(M){M.style.display="block"}),"filter-category"==c&&p_(o2.eventsfilter),"filter-last-modified"==c&&MC(oP,"lastmod","date","asc").then(function(){document.querySelector("#search").focus(),cM()}),"filter-asc"==c&&MC(oP,"dateStartUnix","date","asc").then(function(){document.querySelector("#search").focus(),cM()}),"filter-desc"==c&&MC(oP,"dateStartUnix","date","desc").then(function(){document.querySelector("#search").focus(),cM()}),document.querySelector("#filter-menu").style.display="none",document.querySelectorAll("#filter-menu button").forEach(function(M){M.style.display="none"})}"INPUT"===document.activeElement.tagName&&setTimeout(pT,1e3)}else(ce("page_calendar")||ce("page_events"))&&b(M3).route.set(ce("page_calendar")?"/page_events":"/page_calendar")}else ce("page_calendar")&&Mj("There are no calendar entries to display",3e3);break;case"Backspace":ce("page_add_event")&&"INPUT"!=document.activeElement.tagName&&b(M3).route.set("/page_calendar"),ce("page_events_filtered")&&b(M3).route.set("/page_calendar"),ce("page_edit_event")&&"INPUT"!=document.activeElement.tagName&&b(M3).route.set("/page_calendar"),ce("page_options")&&b(M3).route.set("/page_calendar"),ce("page_event_templates")&&b(M3).route.set("/page_calendar"),(ce("page_subscriptions")||ce("page_accounts")||ce("page_edit_account")||ce("page_list_files"))&&(b(M3).route.set("/page_options"),"block"==document.getElementById("qr-screen").style&&(document.getElementById("qr-screen").style="none"),M1(cb));break;case"0":if(ce("page_calendar")||ce("page_events")){if(o2.eventsfilter||Mj("no category selected, you can do that in the settings",4e3),"INPUT"==document.activeElement.tagName)return;b(M3).route.set("/page_events_filtered",{query:o2.eventsfilter})}}}(M)}),document.addEventListener("visibilitychange",pJ,!1),o1.debug&&(window.onerror=function(M,b,e){return alert("Error message: "+M+"\nURL: "+b+"\nLine Number: "+e),!0});var cp=(j=Ml(function(M){var e,z,o,p;return(0,MB.__generator)(this,function(c){switch(c.label){case 0:var t,n;t=Ml(function(M){var b,e,z,o,p,c;return(0,MB.__generator)(this,function(t){switch(t.label){case 0:(b=new Headers).append("Content-Type","application/x-www-form-urlencoded"),(e=new URLSearchParams).append("code",M),e.append("grant_type","authorization_code"),e.append("redirect_uri","https://greg.strukturart.com/index.html"),e.append("client_id","762086220505-f0kij4nt279nqn21ukokm06j0jge2ngl.apps.googleusercontent.com"),e.append("client_secret","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"),z={method:"POST",headers:b,body:e,redirect:"follow"},t.label=1;case 1:return t.trys.push([1,6,,7]),[4,fetch("https://oauth2.googleapis.com/token",z)];case 2:if((o=t.sent()).ok)return[3,4];return[4,o.text()];case 3:throw p=t.sent(),Error("Token exchange failed: ".concat(o.statusText,". Details: ").concat(p));case 4:return[4,o.json()];case 5:return[2,t.sent()];case 6:throw console.error("Error fetching the token:",c=t.sent()),c;case 7:return[2]}})}),e=function(M){return t.apply(this,arguments)},n=Ml(function(M,e){var z,o;return(0,MB.__generator)(this,function(p){switch(p.label){case 0:return p.trys.push([0,3,,4]),[4,b(Mv).getItem("accounts")];case 1:return(z=p.sent()||[]).push({server_url:"https://apidata.googleusercontent.com/caldav/v2/",tokens:M,authorizationCode:e,name:"Google",id:MT(32),type:"oauth"}),[4,b(Mv).setItem("accounts",z)];case 2:return p.sent(),setTimeout(function(){oG(),localStorage.setItem("oauth_callback","true")},3e3),[3,4];case 3:return o=p.sent(),alert("Error saving account: "+o.message),[3,4];case 4:return[2]}})}),z=function(M,b){return n.apply(this,arguments)},c.label=1;case 1:return c.trys.push([1,4,,5]),[4,e(M)];case 2:return o=c.sent(),[4,z(o,M)];case 3:return c.sent(),[3,5];case 4:return p=c.sent(),alert("OAuth process failed: "+p.message),[3,5];case 5:return[2]}})}),function(M){return j.apply(this,arguments)}),cc=!1,ct=!1;oD.addEventListener("message",function(M){if(M.data.oauth_success){var e=M.data.oauth_success.data;e&&cp(e)}if("parse"==M.data.action){Ma=Date.now(),ct=!0;try{document.getElementById("icon-waiting").style.visibility="visible"}catch(M){}!1!==M.data.content.parsed_data&&(0===o4.length||-1===o4.indexOf(M.data.content.parsed_data.calendar_name))&&(oP.push(M.data.content.parsed_data),M.data.content.callback&&oG(),M.data.content.raw_data&&(o7.data.push({uid:M.data.content.uid,data:M.data.content.raw_data}),b(Mv).setItem("local_account",o7).then(function(){oG()}).catch(function(){}))),!1==cc&&cn()}if("error"==M.data.action)try{document.getElementById("icon-waiting").style.visibility="hidden"}catch(M){}});var cn=function(){Mr=setInterval(function(){if(cc=!0,!ct)return!1;if(Date.now()-Ma>=400){try{document.getElementById("icon-waiting").style.visibility="hidden"}catch(M){}ct=!1,cc=!1,pM(pR,ph),MC(oP,"dateStartUnix","number"),clearInterval(Mr)}},100)};try{navigator.mozSetMessageHandler("activity",function(M){var b=M.source;"view"==b.name&&(pP=b.data.url,Mj("please open the subscriptions page and store the values",15e3),MH())})}catch(M){}}(); \ No newline at end of file + */function(M){var b,e,z=function(){try{if(M.URLSearchParams&&"bar"===new M.URLSearchParams("foo=bar").get("foo"))return M.URLSearchParams}catch(M){}return null}(),o=z&&"a=1"===new z({a:1}).toString(),p=z&&"+"===new z("s=%2B").get("s"),c=z&&"size"in z.prototype,t="__URLSearchParams__",n=!z||((b=new z).append("s"," &"),"s=+%26"===b.toString()),O=A.prototype,r=!!(M.Symbol&&M.Symbol.iterator);if(!z||!o||!p||!n||!c){O.append=function(M,b){l(this[t],M,b)},O.delete=function(M){delete this[t][M]},O.get=function(M){var b=this[t];return this.has(M)?b[M][0]:null},O.getAll=function(M){var b=this[t];return this.has(M)?b[M].slice(0):[]},O.has=function(M){return W(this[t],M)},O.set=function(M,b){this[t][M]=[""+b]},O.toString=function(){var M,b,e,z,o=this[t],p=[];for(b in o)for(M=0,e=d(b),z=o[b];M *");document.querySelector("#KaiOsAds-Wrapper").style.margin="0px 0px 30px 0",M.forEach(function(M){M.addEventListener("focus",function(M){MY("","open ads","")})})}catch(M){console.log(M)}}),M.call("display",{navClass:"item",display:"block"})}})},document.head.appendChild(M)},o_={},ML=Ms("lqBc9");o_=function(M){var b={};function e(z){if(b[z])return b[z].exports;var o=b[z]={i:z,l:!1,exports:{}};return M[z].call(o.exports,o,o.exports,e),o.l=!0,o.exports}return e.m=M,e.c=b,e.d=function(M,b,z){e.o(M,b)||Object.defineProperty(M,b,{enumerable:!0,get:z})},e.r=function(M){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(M,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(M,"__esModule",{value:!0})},e.t=function(M,b){if(1&b&&(M=e(M)),8&b||4&b&&"object"==typeof M&&M&&M.__esModule)return M;var z=Object.create(null);if(e.r(z),Object.defineProperty(z,"default",{enumerable:!0,value:M}),2&b&&"string"!=typeof M)for(var o in M)e.d(z,o,(function(b){return M[b]}).bind(null,o));return z},e.n=function(M){var b=M&&M.__esModule?function(){return M.default}:function(){return M};return e.d(b,"a",b),b},e.o=function(M,b){return Object.prototype.hasOwnProperty.call(M,b)},e.p="",e(e.s=0)}([function(M,b,e){function z(M){return(z="function"==typeof Symbol&&"symbol"==(0,ML._)(Symbol.iterator)?function(M){return void 0===M?"undefined":(0,ML._)(M)}:function(M){return M&&"function"==typeof Symbol&&M.constructor===Symbol&&M!==Symbol.prototype?"symbol":void 0===M?"undefined":(0,ML._)(M)})(M)}function o(M){var b;switch(z(M)){case"string":return/Z$/.test(M)?0:(b=/([+-])(\d{2}):?(\d{2})/.exec(M))&&(+b[3]+60*b[2])*("+"===b[1]?1:-1);case"number":return Number.isNaN(M)?null:16>Math.abs(M)?60*M:M;default:return null}}e.r(b);var p=function(M,b,e){var z=String(M);return!z||z.length>=b?M:"".concat(Array(b+1-z.length).join(e)).concat(M)},c=function(M){var b=Math.abs(M);return"".concat(M<=0?"+":"-").concat(p(Math.floor(b/60),2,"0"),":").concat(p(b%60,2,"0"))};function t(M,b){for(var e=0;e1&&void 0!==arguments[1]?arguments[1]:n))}var a=function(){var M,b;function e(){var M=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new Date,b=arguments.length>1&&void 0!==arguments[1]?arguments[1]:M.getTimezoneOffset();(function(M,b){if(!(M instanceof b))throw TypeError("Cannot call a class as a function")})(this,e),this.$d=new Date(M.getTime()-r(b)),this.$timezoneOffset=b}return M=[{key:"getTimezoneOffset",value:function(){return this.$timezoneOffset}},{key:"setTimezoneOffset",value:function(){var M=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.$timezoneOffset;this.$d.setTime(this.$d.getTime()+r(this.$timezoneOffset,M)),this.$timezoneOffset=M}}],t(e.prototype,M),b&&t(e,b),e}();["toDateString","toLocaleString","toLocaleDateString","toLocaleTimeString","setDate","setFullYear","setHours","setMilliseconds","setMinutes","setMonth","setSeconds","setTime","setYear","getDate","getDay","getFullYear","getHours","getMilliseconds","getMinutes","getMonth","getSeconds","getYear"].forEach(function(M){a.prototype[M]=function(){return O[M].apply(this.$d,arguments)}}),["toISOString","toUTCString","toGMTString","toJSON","getUTCDate","getUTCDay","getUTCFullYear","getUTCHours","getUTCMilliseconds","getUTCMinutes","getUTCMonth","getUTCSeconds","valueOf","getTime"].forEach(function(M){a.prototype[M]=function(){return O[M].apply(new Date(this.$d.getTime()+r(this.$timezoneOffset)),arguments)}}),["setUTCDate","setUTCFullYear","setUTCHours","setUTCMilliseconds","setUTCMinutes","setUTCMonth","setUTCSeconds"].forEach(function(M){a.prototype[M]=function(){var b=new Date(this.$d.getTime()+r(this.$timezoneOffset));O[M].apply(b,arguments),b.setTime(b.getTime()-r(this.$timezoneOffset)),this.$d=b}}),["toString","toTimeString"].forEach(function(M){a.prototype[M]=function(){return O[M].apply(this.$d,arguments).replace(/GMT(.*)$/,"GMT".concat(c(this.$timezoneOffset)))}});var i=!1,A=function(M,b){["clone","add","subtract","startOf"].forEach(function(e){M[e]=function(){var M=this.utcOffset();return b[e].apply(this,arguments).utcOffset(M)}}),M.utc=function(){return this.utcOffset(0)},M.local=function(){return this.utcOffset(-n)},M.utcOffset=function(M){if(void 0===M){var b=this.$d.getTimezoneOffset();return 0===b?0:-b}return null!==o(M)&&(this.$d.setTimezoneOffset(-o(M)),this.init()),this},M.toDate=function(){return new Date(this.$d.getTime())},M.isLocal=function(){return this.$d.getTimezoneOffset()===n},M.isUTC=function(){return 0===this.$d.getTimezoneOffset()},M.$set=function(){for(var M,e=this.$d.getTimezoneOffset(),z=arguments.length,o=Array(z),p=0;p0&&void 0!==arguments[0]?arguments[0]:{},b=arguments.length>1?arguments[1]:void 0,e=arguments.length>2?arguments[2]:void 0;i=!!M.parseToLocal;var z=b.prototype,p=function(){};p.prototype=z;var c=new p;A(c,z),c.constructor=b.constructor,b.prototype=c,e.utc=function(M){var b=this(M);return"string"==typeof M&&null===o(M)&&(b.$d.$timezoneOffset=0),b.utc()}}}]),b(Mw).extend(b(o_));var oS={};(oS=Ms("iYrAK")).tz.load(Ms("kZ0MA"));var oD=new BroadcastChannel("sw-messages");b(Mv).setDriver(b(Mv).INDEXEDDB);var oP=[],ox=[],oI=[],oU=!1,oj=60,oF=localStorage.getItem("last_sync")||"",oY=[];b(Mv).getItem("subscriptions").then(function(M){console.log(M)});var oH=(E=Ml(function(){var M,e,z,o,p;return(0,MB.__generator)(this,function(c){switch(c.label){case 0:var t,n;M=function(){return new URLSearchParams(window.location.search).get("code")},t=Ml(function(M){var b,e,z,o,p;return(0,MB.__generator)(this,function(c){switch(c.label){case 0:(b=new Headers).append("Content-Type","application/x-www-form-urlencoded"),(e=new URLSearchParams).append("code",M),e.append("grant_type","authorization_code"),e.append("redirect_uri","https://greg.strukturart.com/index.html"),e.append("client_id","762086220505-f0kij4nt279nqn21ukokm06j0jge2ngl.apps.googleusercontent.com"),e.append("client_secret","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"),z={method:"POST",headers:b,body:e,redirect:"follow"},c.label=1;case 1:return c.trys.push([1,4,,5]),[4,fetch("https://oauth2.googleapis.com/token",z)];case 2:if(!(o=c.sent()).ok)throw Error("Token exchange failed: ".concat(o.statusText));return[4,o.json()];case 3:return[2,c.sent()];case 4:throw console.error("Error fetching the token:",p=c.sent()),p;case 5:return[2]}})}),e=function(M){return t.apply(this,arguments)},n=Ml(function(M,e){var z,o;return(0,MB.__generator)(this,function(p){switch(p.label){case 0:return p.trys.push([0,3,,4]),[4,b(Mv).getItem("accounts")];case 1:return(z=p.sent()||[]).push({server_url:"https://apidata.googleusercontent.com/caldav/v2/",tokens:M,authorizationCode:e,name:"Google",id:MT(32),type:"oauth"}),[4,b(Mv).setItem("accounts",z)];case 2:return p.sent(),setTimeout(function(){window.close()},3e3),[3,4];case 3:return o=p.sent(),alert("Error saving account: "+o.message),[3,4];case 4:return[2]}})}),z=function(M,b){return n.apply(this,arguments)},c.label=1;case 1:if(c.trys.push([1,4,,5]),!(o=M()))return[2,!1];return[4,e(o)];case 2:return p=c.sent(),[4,z(p,o)];case 3:case 4:return c.sent(),[3,5];case 5:return[2]}})}),function(){return E.apply(this,arguments)});"b2g"in navigator||"navigator.mozApps"in navigator?function(){if(!window.location.href.includes("code="))return!1;var M=new URLSearchParams(window.location.search).get("code");if(!M)return!1;setTimeout(function(){try{var b=new MozActivity({name:"greg-oauth",data:M});b.onsuccess=function(){console.log("Activity successfuly handled")},b.onerror=function(){console.log("The activity encouter en error: "+this.error),alert(this.error)}}catch(M){}if("b2g"in navigator)try{new WebActivity("greg-oauth",{name:"greg-oauth",type:"string",data:M}).start().then(function(M){window.close(),console.log("Results passed back from activity handler:"),console.log(M)},function(M){alert(M)})}catch(M){}},4e3)}():oH();var oV=function(){document.querySelector("#intro").classList.add("intro-animation"),document.querySelector("#version").classList.add("intro-version-animation"),document.querySelector("#intro img").classList.add("intro-img-anmation")},oG=function(){setTimeout(function(){document.querySelector(".success-checkmark").style.display="block"},2e3),setTimeout(function(){document.querySelector(".success-checkmark").style.display="none"},4e3)},oK=[],oQ=function(){oK.push(b(M3).route.get())},oJ=function(){setTimeout(function(){b(M3).route.set(oK[oK.length-2])},1e3)};MH();var o$="",oZ=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],o0=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],o1={selected_day:b(Mw)().format("YYYY-MM-DD"),selected_day_id:"",visible:!1,update_event_id:"",event_calendar_changed:!1,startup:!1,sortEvents:"startDate",shortCut:!1,background_sync_running:!1,version:localStorage.getItem("version")||"time is relative",notKaiOS:!0,debug:!1},o2={default_notification:"none",ads:!0,timezone:oS.tz.guess(),dateformat:"YYYY-MM-DD",firstday:"sunday",background_sync:"No",default_duration:30};("b2g"in navigator||"navigator.mozApps"in navigator)&&(o1.notKaiOS=!1),o1.notKaiOS||["http://127.0.0.1/api/v1/shared/core.js","http://127.0.0.1/api/v1/shared/session.js","http://127.0.0.1/api/v1/apps/service.js","http://127.0.0.1/api/v1/audiovolumemanager/service.js","./assets/js/kaiads.v5.min.js"].forEach(function(M){var b=document.createElement("script");b.type="text/javascript",b.src=M,document.head.appendChild(b)}),function(){try{if("No"==localStorage.getItem("background_sync"))return!1;var M=navigator.mozAlarms.getAll();M.onsuccess=function(){this.result.forEach(function(M){"keep alive"==M.data.note&&MQ()})},M.onerror=function(){console.log("An error occurred:",this.error.name)}}catch(M){}}();var o3={};if(o3=Ms("4TeC4").getBundleURL("llXtB")+"sw.js","b2g"in navigator)try{navigator.serviceWorker.register(o3).then(function(M){M.waiting&&setTimeout(function(){window.location.reload(!0)},1e3),M.systemMessageManager.subscribe("alarm").then(function(M){console.log('Successfully subscribe system messages of name "alarm".')},function(M){console.log("Fail to subscribe system message, error: "+M)}),M.systemMessageManager.subscribe("activity").then(function(M){},function(M){})})}catch(M){console.log(M)}else if("serviceWorker"in navigator&&navigator.serviceWorker.controller)console.log("Service worker found");else try{console.log("Try to register service worker"),navigator.serviceWorker.register(o3).then(function(M){M.waiting&&setTimeout(function(){window.location.reload(!0)},1e3)})}catch(M){console.error("Error during service worker registration:",M)}var o4=[];function o5(){return o6.apply(this,arguments)}function o6(){return(o6=Ml(function(){return(0,MB.__generator)(this,function(M){switch(M.label){case 0:return M.trys.push([0,2,,3]),[4,b(Mv).keys()];case 1:return -1==M.sent().indexOf("calendarNames")?Mp=[{name:"local",id:"local-id",data:[],type:"local",view:!0}]:b(Mv).getItem("calendarNames").then(function(M){(Mp=M).forEach(function(M){!1==M.view&&o4.push(M.name)})}),[3,3];case 2:return M.sent(),[3,3];case 3:return[2]}})})).apply(this,arguments)}var o8=function(){b(Mv).getItem("accounts").then(function(M){oV(),ox=M,o5(),null!=ox&&pr().then(function(){pO(pu)})}).catch(function(){console.log("no accounts")})};o8();var o7={data:[],calendar_name:"local",calendar_id:"local-id"};b(Mv).getItem("local_account").then(function(M){null!=M?(o7.data=M.data,o7.data.forEach(function(M){try{navigator.serviceWorker.controller.postMessage({type:"parse",t:M,e:"local-id",callback:!1,store:!1})}catch(M){console.log("send to sw")}})):b(Mv).setItem("local_account",o7).then(function(){console.log("Local account created:",o7)}).catch(function(M){console.error("Error creating local account:",M)})}).catch(function(M){console.error("Error loading local account:",M)});var o9=function(){b(Mv).getItem("settings").then(function(M){null!=M&&(o2=M,localStorage.setItem("background_sync",o2.background_sync),o0="sunday"==o2.firstday||void 0==o2.firstday?["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]:["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],void 0==o2.dateformat&&(o2.dateformat="YYYY-MM-DD"),document.querySelectorAll(".calendar-head div").forEach(function(M,b){M.innerText=o0[b]}))}).catch(function(M){})};o9();var pM=function(){try{document.querySelectorAll("div.calendar-cell").forEach(function(M){var b=M.getAttribute("data-date");!0==pB(b).event?(M.classList.add("event"),!0==pB(b).multidayevent&&M.classList.add("multievent")):M.classList.contains("event")&&M.classList.remove("event"),!0==pv(b).rrule&&(M.classList.add("rrule"),pv(b).count>1&&M.classList.add("multievent"))})}catch(M){console.log(M)}},pb={},pe={};function pz(M){return po.apply(this,arguments)}function po(){return(po=Ml(function(M){return(0,MB.__generator)(this,function(b){try{return pb[M.id]||("oauth"===M.type&&(pb[M.id]=new ok({serverUrl:M.server_url,credentials:{tokenUrl:"https://oauth2.googleapis.com/token",refreshToken:M.tokens.refresh_token,clientId:"762086220505-f0kij4nt279nqn21ukokm06j0jge2ngl.apps.googleusercontent.com",clientSecret:"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",authorizationCode:M.authorizationCode,redirectUrl:"https://greg.strukturart.com/index.html"},authMethod:"Oauth",defaultAccountType:"caldav"})),"basic"===M.type&&(pb[M.id]=new ok({serverUrl:M.server_url,credentials:{username:M.user,password:M.password},authMethod:"Basic",defaultAccountType:"caldav"}))),[2,pb[M.id]]}catch(M){throw console.error("Error occurred while creating DAVClient instance:",M),M}return[2]})})).apply(this,arguments)}function pp(){return pc.apply(this,arguments)}function pc(){return(pc=Ml(function(){var M,e,z,o,p,c,t,n,O,r,a,i,A,d,s,q,u,l,f,W,h,R,m,L,B,v,g=arguments;return(0,MB.__generator)(this,function(N){switch(N.label){case 0:if(M=g.length>0&&void 0!==g[0]&&g[0],e=g.length>1&&void 0!==g[1]&&g[1],!navigator.onLine)return[2,!1];if(oU=!0,e)try{oP=oP.filter(function(M){return M.id==M.account_to_update})}catch(M){console.log(M)}else try{oP=oP.filter(function(M){return!M.isCaldav})}catch(M){console.log(M)}z=!0,o=!1,p=void 0,N.label=1;case 1:N.trys.push([1,30,31,32]),c=ox[Symbol.iterator](),N.label=2;case 2:if(z=(t=c.next()).done)return[3,29];if(n=t.value,!1!=e&&e!==n)return[3,28];return[4,pz(n)];case 3:O=N.sent(),N.label=4;case 4:if(N.trys.push([4,27,,28]),pe[n.id])return[3,9];N.label=5;case 5:return N.trys.push([5,7,,8]),[4,O.login()];case 6:return N.sent(),pe[n.id]=!0,console.log("login successfull"),[3,8];case 7:return console.log("cant login"+N.sent()),pe[n.id]=!1,[3,28];case 8:return[3,10];case 9:console.log("login"),N.label=10;case 10:r=void 0,N.label=11;case 11:return N.trys.push([11,13,,14]),[4,O.fetchCalendars()];case 12:return console.log(r=N.sent()),[3,14];case 13:return console.log(N.sent()),[3,28];case 14:"/page_calendar"===b(M3).route.get()&&(document.getElementById("icon-loading").style.visibility="visible"),a=[],i=!0,A=!1,d=void 0,N.label=15;case 15:N.trys.push([15,24,25,26]),s=r[Symbol.iterator](),N.label=16;case 16:if(i=(q=s.next()).done)return[3,23];return u=q.value,[4,O.fetchCalendarObjects({calendar:u})];case 17:l=N.sent(),f={displayName:u.displayName,syncToken:u.syncToken,ctag:u.ctag,url:u.url,objects:l},a.push(f),N.label=18;case 18:return N.trys.push([18,20,,21]),[4,b(Mv).setItem(n.id,a)];case 19:return N.sent(),console.log("Data cached"),[3,21];case 20:return console.log(N.sent()),oU=!1,[3,21];case 21:W=!0,h=!1,R=void 0;try{for(m=l[Symbol.iterator]();!(W=(L=m.next()).done);W=!0)B=L.value,"serviceWorker"in navigator&&navigator.serviceWorker.controller&&navigator.serviceWorker.controller.postMessage({type:"parse",t:B,e:n.id,callback:!1,store:!1})}catch(M){h=!0,R=M}finally{try{W||null==m.return||m.return()}finally{if(h)throw R}}N.label=22;case 22:return i=!0,[3,16];case 23:return[3,26];case 24:return v=N.sent(),A=!0,d=v,[3,26];case 25:try{i||null==s.return||s.return()}finally{if(A)throw d}return[7];case 26:try{document.getElementById("icon-loading").style.visibility="hidden",document.getElementById("icon-waiting").style.visibility="hidden"}catch(M){console.log(M)}return M&&Mj("all event reloaded",2e3),oU=!1,[3,28];case 27:N.sent(),oU=!1;try{document.getElementById("icon-loading").style.visibility="hidden",document.getElementById("icon-waiting").style.visibility="hidden"}catch(M){console.log(M)}return[3,28];case 28:return z=!0,[3,2];case 29:return[3,32];case 30:return v=N.sent(),o=!0,p=v,[3,32];case 31:try{z||null==c.return||c.return()}finally{if(o)throw p}return[7];case 32:return[2]}})})).apply(this,arguments)}var pt=(_=Ml(function(){var M,e,z,o,p,c,t,n,O;return(0,MB.__generator)(this,function(r){switch(r.label){case 0:oU=!0,e=!0,z=!1,o=void 0,r.label=1;case 1:r.trys.push([1,6,7,8]),p=function(){var e,z,o,p,c,n;return(0,MB.__generator)(this,function(O){switch(O.label){case 0:return[4,pz(e=t.value)];case 1:z=O.sent(),O.label=2;case 2:return O.trys.push([2,8,,9]),[4,z.fetchCalendars()];case 3:o=O.sent(),p=[],c=0,O.label=4;case 4:if(!(c0)return M(t),[3,18];return[3,17];case 16:return q.sent(),navigator.onLine||MS("greg","device offline"),[3,17];case 17:return i++,[3,13];case 18:return[3,20];case 19:return q.sent(),navigator.onLine||MS("greg","device offline"),[3,20];case 20:return e=!0,[3,2];case 21:return[3,24];case 22:return s=q.sent(),z=!0,o=s,[3,24];case 23:try{e||null==p.return||p.return()}finally{if(z)throw o}return[7];case 24:if(JSON.stringify(pn)!=JSON.stringify(Mp)){try{pn.forEach(function(M){var b;Array.isArray(Mp)?b=Mp.find(function(b){return b.name===M.name}):console.error("calendar_names is not an array or is undefined"),b&&(M.view=b.view)})}catch(M){console.log(M)}b(Mv).setItem("calendarNames",pn).then(function(){o5()})}return[2]}})}),function(M){return S.apply(this,arguments)}),pr=(D=Ml(function(){var M,e,z,o,p,c,t,n,O,r,a,i,A,d,s,q,u,l,f,W;return(0,MB.__generator)(this,function(h){switch(h.label){case 0:if(!ox)return[2,!1];M=!0,e=!1,z=void 0,h.label=1;case 1:h.trys.push([1,8,9,10]),o=ox[Symbol.iterator](),h.label=2;case 2:if(M=(p=o.next()).done)return[3,7];c=p.value,h.label=3;case 3:return h.trys.push([3,5,,6]),[4,b(Mv).getItem(c.id)];case 4:if(null===(t=h.sent()))try{pp(!1,c.id)}catch(M){console.log(M)}n=!0,O=!1,r=void 0,a=!0,i=!1,A=void 0;try{for(d=t[Symbol.iterator]();!(a=(s=d.next()).done);a=!0){q=s.value;try{for(u=q.objects[Symbol.iterator]();!(n=(l=u.next()).done);n=!0)if(f=l.value,"serviceWorker"in navigator&&navigator.serviceWorker.controller)try{navigator.serviceWorker.controller.postMessage({type:"parse",t:f,e:c.id,callback:!1,store:!1})}catch(M){console.log("send to sw")}else console.log("no sw")}catch(M){O=!0,r=M}finally{try{n||null==u.return||u.return()}finally{if(O)throw r}}}}catch(M){i=!0,A=M}finally{try{a||null==d.return||d.return()}finally{if(i)throw A}}return[3,6];case 5:return console.log(h.sent()),[3,6];case 6:return M=!0,[3,2];case 7:return[3,10];case 8:return W=h.sent(),e=!0,z=W,[3,10];case 9:try{M||null==o.return||o.return()}finally{if(e)throw z}return[7];case 10:return[2]}})}),function(){return D.apply(this,arguments)}),pa=(P=Ml(function(M,b,e,z,o){var p,c,t,n,O;return(0,MB.__generator)(this,function(r){switch(r.label){case 0:if(!navigator.onLine)return[2,!1];if(document.querySelector(".loading-spinner").style.display="block",!(p=ox.find(function(M){return M.id===b})))return[3,14];return[4,pz(p)];case 1:c=r.sent(),r.label=2;case 2:if(r.trys.push([2,13,,14]),pe[p.id])return[3,4];return[4,c.login()];case 3:r.sent(),pe[p.id]=!0,r.label=4;case 4:return[4,c.fetchCalendars()];case 5:if(!(t=r.sent().find(function(M){return M.displayName===e})))return[3,12];return[4,c.createCalendarObject({calendar:t,filename:o+".ics",iCalString:M,headers:c.authHeaders})];case 6:if(!(n=r.sent()).ok)return[3,11];r.label=7;case 7:return r.trys.push([7,9,,10]),[4,c.propfind({url:n.url,props:Mf({},"".concat(J.DAV,":getetag"),{}),depth:"0",headers:c.authHeaders})];case 8:return O=MR.apply(void 0,[r.sent(),1])[0],z.etag=O.props.getetag,z.url=n.url,z.isCaldav=!0,z.id=b,z.calendar_name=e,document.querySelector(".loading-spinner").style.display="none",pt().then(function(M){}),[2,z];case 9:return console.log(r.sent()),[3,10];case 10:return[3,12];case 11:document.querySelector(".loading-spinner").style.display="none",Mj("There was a problem saving, please try again later.",5e3),r.label=12;case 12:return[3,14];case 13:return console.log(r.sent()),[3,14];case 14:return[2]}})}),function(M,b,e,z,o){return P.apply(this,arguments)}),pi=(x=Ml(function(M,b,e,z){var o,p,c,t;return(0,MB.__generator)(this,function(n){switch(n.label){case 0:if(console.log(oP),!navigator.onLine)return[2,!1];if(document.querySelector(".loading-spinner").style.display="block",console.log("hey"+(o=ox.find(function(M){return M.id===e}))),void 0==o)return document.querySelector(".loading-spinner").style.display="none",Mj("There was a problem deleting, please try again later.",5e3),[2,!1];if(!o)return[3,7];return[4,pz(o)];case 1:p=n.sent(),n.label=2;case 2:if(n.trys.push([2,6,,7]),pe[o.id])return[3,4];return[4,p.login()];case 3:n.sent(),pe[o.id]=!0,n.label=4;case 4:return[4,p.deleteCalendarObject({calendarObject:{url:b,etag:M},headers:p.authHeaders})];case 5:if(!n.sent().ok)return oJ(),Mj("There was a problem deleting, please try again later.",5e3),[2,"error"];if(-1!==(c=oP.findIndex(function(M){return M.UID===z}))){if(oP.splice(c,1),pt(),p2(z),pC(),pM(pR,ph),document.querySelector(".loading-spinner").style.display="none",!1==o1.shortCut)return oJ(),[2,"success"];return oG(),[2,"success"]}return[3,7];case 6:return t=n.sent(),oJ(),Mj("There was a problem deleting, please try again later.",5e3),[2,t];case 7:return[2]}})}),function(M,b,e,z){return x.apply(this,arguments)}),pA=(I=Ml(function(M,b,e,z){var o,p,c,t,n;return(0,MB.__generator)(this,function(O){switch(O.label){case 0:if(!navigator.onLine)return[2,!1];if(document.querySelector(".loading-spinner").style.display="block",void 0==(o=ox.find(function(M){return M.id===z})))return document.querySelector(".loading-spinner").style.display="none",Mj("There was a problem saving, please try again later.",5e3),[2,!1];if(!o)return[3,13];return[4,pz(o)];case 1:p=O.sent(),O.label=2;case 2:if(O.trys.push([2,12,,13]),pe[o.id])return[3,4];return[4,p.login()];case 3:O.sent(),pe[o.id]=!0,O.label=4;case 4:return[4,p.updateCalendarObject({calendarObject:{url:b,data:e,etag:M},headers:p.authHeaders})];case 5:if(!(c=O.sent()).ok)return[3,10];document.querySelector(".loading-spinner").style.display="none",O.label=6;case 6:return O.trys.push([6,8,,9]),[4,p.propfind({url:c.url,props:Mf({},"".concat(J.DAV,":getetag"),{}),depth:"0",headers:p.authHeaders})];case 7:return t=MR.apply(void 0,[O.sent(),1])[0],(n={}).etag=t.props.getetag,n.url=c.url,pt(),[2,n];case 8:return console.log(O.sent()),document.querySelector(".loading-spinner").style.display="none",[3,9];case 9:return[3,11];case 10:document.querySelector(".loading-spinner").style.display="none",Mj("There was a problem saving, please try again later.",5e3),O.label=11;case 11:return[3,13];case 12:return O.sent(),document.querySelector(".loading-spinner").style.display="none",Mj("There was a problem saving, please try again later.",5e3),[3,13];case 13:return[2]}})}),function(M,b,e,z){return I.apply(this,arguments)}),pd=function(M,b){var e=new XMLHttpRequest({mozSystem:!0});e.open("GET",M+"?time="+new Date().getTime(),!0),e.timeout=2e3,e.onload=function(){e.status>=200&&e.status<300?b(e.responseText,M):b(Error("Request failed with status "+e.status))},e.onerror=function(){b(Error("XMLHttpRequest error"),null)},e.ontimeout=function(){b(Error("XMLHttpRequest timed out"),null)},e.send()},ps=function(M,b){try{navigator.serviceWorker.controller.postMessage({type:"parse",t:{uid:"",data:M,url:b,etag:""},e:"subscription",callback:!1,store:!1})}catch(M){console.log(M)}},pq=(U=Ml(function(){var M,b,e,z,o,p;return(0,MB.__generator)(this,function(c){M=!0,b=!1,e=void 0;try{for(z=oY[Symbol.iterator]();!(M=(o=z.next()).done);M=!0)p=o.value,pd(p.url,ps)}catch(M){b=!0,e=M}finally{try{M||null==z.return||z.return()}finally{if(b)throw e}}return[2]})}),function(){return U.apply(this,arguments)}),pu=function(M){pp(!1,M).then(function(){})},pl=function(){o1.selected_day_id=document.activeElement.getAttribute("data-id"),Mc=oP.filter(function(M){return M.UID==o1.selected_day_id})[0]};b(Mv).getItem("event_templates").then(function(M){if(null==M)return oI=[],!1;oI=M}).catch(function(M){console.log(M)});var pf=function(M,e,z,o){var p={id:MT(32),title:M,description:e,location:z,category:o};oI.push(p),b(Mv).setItem("event_templates",oI).then(function(M){Mj("template saved",2e3),oJ()}).catch(function(M){console.log(M)})},pW=new Date,ph=pW.getMonth(),pR=pW.getFullYear(),pm=pW.getDate(),pL=function(M){var e=M?b(Mw)().unix():b(Mw)(o1.selected_day).unix();if(0===oP.length)return document.getElementById("events-wrapper").innerHTML="You haven't made any calendar entries yet.",!1;var z=0,o=function(){setTimeout(function(){document.querySelectorAll('div#events-wrapper article[data-id="'+z+'"]')[0].focus();var M=document.activeElement.getBoundingClientRect(),b=M.top-document.body.getBoundingClientRect().top+M.height/2;document.activeElement.parentNode.scrollBy({left:0,top:b-window.innerHeight/2,behavior:"smooth"})},1e3)};try{var p=oP.findIndex(function(M){return M.dateStartUnix===e});z=oP[p-1].UID,o()}catch(M){!function(){try{var M=oP.findIndex(function(M){return M.dateStartUnix=o&&!b.RRULE.freq});if(b.event=e.length>0,b.event_data=e,e.length>1){for(var z=e.sort(function(M,b){return new Date(M.dateStart).getTime()-new Date(b.dateStart).getTime()}),o=1;o=new Date(z[o].dateStart).getTime()){b.multidayevent=!0,b.event_data=e;break}}return b},pv=function(M){var b={date:"",event:!1,subscription:!1,multidayevent:!1,rrule:"none",event_data:""},e=!0,z=!1,o=void 0;try{for(var p,c=oP[Symbol.iterator]();!(e=(p=c.next()).done);e=!0){var t=p.value;if("object"==typeof t){b.event=!1,b.multidayevent=!1,b.rrule=!1,b.date=M,b.event_data="";var n=new Date(t.dateStart).getTime(),O=new Date(t.dateEnd).getTime(),r=new Date(M).getTime(),a=t.RRULE.freq;if(void 0!==t.RRULE&&null!==t.RRULE&&(void 0==t.RRULE.until&&void 0==t.RRULE.count&&(O=new Date("3000-01-01").getTime()),n===r||nr))switch(b.event_data=t,a){case"MONTHLY":if(new Date(t.dateStart).getDate()===new Date(M).getDate())return b.event=!0,b.rrule=!0,b;break;case"WEEKLY":if(new Date(t.dateStart).getDay()===new Date(M).getDay())return b.rrule=!0,b.event=!0,b;break;case"BIWEEKLY":if(Math.floor((r-n)/864e5)%14==0)return b.rrule=!0,b.event=!0,b;break;case"YEARLY":var i=new Date(t.dateStart),A=new Date(M);if(i.getDate()===A.getDate()&&i.getMonth()===A.getMonth())return b.rrule=!0,b.event=!0,b}}}}catch(M){z=!0,o=M}finally{try{e||null==c.return||c.return()}finally{if(z)throw o}}return b},pg=[],pN=0,py=function(){++pN>document.querySelectorAll("div#event-slider article").length-1&&(pN=0);var M=document.querySelectorAll("div#event-slider-indicator div div");document.querySelectorAll("div#event-slider article").forEach(function(M){M.style.display="none"}),document.querySelectorAll("div#event-slider article")[pN].style.display="block",M.forEach(function(M){M.classList.remove("active")}),M[pN].classList.add("active")},pX=function(M){pg=[];var e=document.querySelector("div#event-slider-indicator div");e.innerHTML="",document.querySelector("div#event-slider").innerHTML="";for(var z=0;z=c)&&pg.push(oP[z]);else if(null!=oP[z].RRULE&&void 0==oP[z].RRULE.until&&void 0==oP[z].RRULE.count&&(p=new Date("3000-01-01").getTime()),o===c||p===c||oc){if("YEARLY"==t){var n=new Date(oP[z].dateStart),O=new Date(M);n.getDate()+"-"+n.getMonth()==O.getDate()+"-"+O.getMonth()&&pg.push(oP[z])}"WEEKLY"==t&&new Date(oP[z].dateStart).getDay()==new Date(M).getDay()&&pg.push(oP[z]),"BIWEEKLY"==t&&Math.floor((c-o)/864e5)%14==0&&pg.push(oP[z]),"MONTHLY"==t&&new Date(oP[z].dateStart).getDate()==new Date(M).getDate()&&pg.push(oP[z]),"DAILY"==t&&(o===c||p===c||oc)&&pg.push(oP[z])}}if(pg.length>=0&&(pg.forEach(function(M){e.insertAdjacentHTML("beforeend","
");var z="";M.allDay||(z=b(Mw).unix(M.dateStartUnix).format("HH:mm")),document.querySelector("div#event-slider").insertAdjacentHTML("beforeend","
"+M.SUMMARY+"
"+z+"
")}),pg.length>0))try{document.querySelectorAll("div#event-slider article")[0].style.display="block"}catch(M){console.log(M)}document.querySelectorAll("div.indicator").length<=1||void 0==document.querySelectorAll("div.indicator").length?document.getElementById("event-slider-indicator").style.opacity=0:(document.getElementById("event-slider-indicator").style.opacity=1,document.querySelector("div#event-slider article").style.display="block",document.querySelectorAll("div#event-slider .indicator")[0].style.classList.add("active"))},pT=function(){ph=pW.getMonth(),pR=pW.getFullYear(),pk(ph,pR),setTimeout(function(){o1.selected_day=b(Mw)().format("YYYY-MM-DD"),pX(o1.selected_day)},1e3)},pw=function(){if("/page_calendar"!=b(M3).route.get())return!1;setTimeout(function(){document.querySelectorAll("div#calendar div.calendar-head div").forEach(function(M){M.classList.remove("active")}),document.querySelectorAll("span.weeknumber").forEach(function(M){M.classList.remove("active")});var M=new Date(document.activeElement.getAttribute("data-date")).getDay();document.activeElement.closest("div.row").querySelector("span.weeknumber").classList.add("active"),"monday"==o2.firstday&&-1==(M-=1)&&(M=6),document.querySelectorAll("div#calendar div.calendar-head div")[M].classList.add("active")},200)};Date.prototype.getWeek=function(){var M=new Date(this.getTime());M.setHours(0,0,0,0),M.setDate(M.getDate()+3-(M.getDay()+6)%7);var b=new Date(M.getFullYear(),0,4);return 1+Math.round(((M.getTime()-b.getTime())/864e5-3+(b.getDay()+6)%7)/7)};var pk=function(M,b){document.getElementById("monthAndYear").textContent=oZ[M]+" "+b;var e=new Date(b,M).getDay();"monday"==o2.firstday&&(0==e?e=6:e-=1);var z=32-new Date(b,M,32).getDate(),o=document.getElementById("calendar-body");o.innerHTML="";for(var p=1,c=0;c<6;c++)!function(c){var t=document.createElement("div");t.classList.add("flex"),t.classList.add("row"),t.setAttribute("data-weeknumber",c),t.classList.add("width-100");for(var n=0;n<7;n++)if(0===c&&nz)break;else{var a=document.createElement("div"),i=document.createElement("span"),A=document.createElement("div"),d=document.createTextNode(p);a.appendChild(d),a.appendChild(i),a.setAttribute("tabindex",p-1),a.classList.add("calendar-cell");var s=b+"-"+"0".concat(M+1).slice(-2)+"-"+"0".concat(p).slice(-2);A.classList.add("moon-phase-"+function(M,b,e){var z,o,p,c=p=o=z=0;return b<3&&(M--,b+=12),++b,z=parseInt(o=((c=365.25*M)+(p=30.6*b)+e-694039.09)/29.5305882),o-=z,(z=Math.round(8*o))>=8&&(z=0),z}(b,M,p)),a.appendChild(A),a.setAttribute("data-date",s),a.classList.add("item"),t.appendChild(a),p++}var q=document.createElement("span");q.classList.add("weeknumber");var u=document.createTextNode("monday"==o2.firstday?new Date(b,M,p-1).getWeek():new Date(b,M,p).getWeek());q.appendChild(u),t.appendChild(q),o.appendChild(t)}(c);document.querySelectorAll(".item")[0].focus(),o1.selected_day=document.activeElement.getAttribute("data-date"),pW.getMonth()==M&&pW.getFullYear()==b&&(document.querySelectorAll(".item")[pm-1].focus(),document.querySelectorAll(".item")[pm-1].classList.add("today")),pw(),pM(pR,ph)},pC=function(){document.querySelectorAll("div#add-edit-event input").forEach(function(M){M.value=""})},pE=function(M){var b=M.toUpperCase();if(b.length<1)return!1;document.querySelectorAll("#events-wrapper article").forEach(function(M){M.getAttribute("data-summary").indexOf(b)>=0||M.getAttribute("data-category").indexOf(b)>=0?M.style.display="block":M.style.display="none"}),cM()},p_=function(M){var b=M.toUpperCase();document.querySelectorAll("#events-wrapper article").forEach(function(M){M.getAttribute("data-category").indexOf(b)>=0?M.style.display="block":M.style.display="none"}),cM(),document.getElementById("search").focus()},pS=function(){if(null==document.querySelectorAll(".select-box"))return!1;document.querySelectorAll(".select-box").forEach(function(M){M.addEventListener("blur",function(b){setTimeout(function(){M.parentElement.focus()},200)})})},pD=document.getElementById("app"),pP="",px=null,pI=function(M){document.getElementById(px).value=M},pU=[],pj=function(M){pU.push(M)},pF=function(M){try{"serviceWorker"in navigator&&navigator.serviceWorker.controller&&(collectionOfData={data:M,etag:"",url:""},navigator.serviceWorker.controller.postMessage({type:"parse",t:collectionOfData,e:"local-id",callback:!0,store:!0}))}catch(M){alert("event could not be imported because the file content is invalid"+M)}};!1==o1.background_sync_running&&(b(M3).route(pD,"/page_calendar",{"/page_calendar":{view:function(){return b(M3)("div",{class:"width-100 height-100",id:"calendar",oninit:function(){oQ(),o9(),pC(),MJ(),document.querySelector("#version").textContent=localStorage.getItem("version")}},[b(M3)("div",{class:"flex justify-content-spacebetween",id:""},[b(M3)("h3",{class:"card-header",id:"monthAndYear"},""),b(M3)("img",{id:"icon-loading",src:"./assets/image/E252.svg",alt:"loading"}),b(M3)("img",{id:"icon-waiting",src:"./assets/image/waiting.png",alt:"loading"}),b(M3)("div",{id:"time",oncreate:function(){document.getElementById("time").innerText=b(Mw)().format("HH:mm")}},o1.version)]),b(M3)("div",{class:"calendar-head flex width-100"},[b(M3)("div",o0[0]),b(M3)("div",o0[1]),b(M3)("div",o0[2]),b(M3)("div",o0[3]),b(M3)("div",o0[4]),b(M3)("div",o0[5]),b(M3)("div",o0[6])]),b(M3)("div",{id:"calendar-body"}),b(M3)("div",{id:"event-slider-indicator",class:"flex width-100 justify-content-spacearound"},[b(M3)("div",{class:"flex justify-content-spacearound"})]),b(M3)("div",{id:"event-slider",class:"flex "},[b(M3)("div",{id:"slider-inner",class:"flex width-100 justify-content-spacearound"})])])},onbeforeremove:function(){o1.selected_day=document.activeElement.getAttribute("data-date")},oncreate:function(){setTimeout(function(){document.activeElement.hasAttribute("data-date")&&(o1.selected_day=document.activeElement.getAttribute("data-date")),MY("","","");var M=new Date(o1.selected_day);ph=M.getMonth(),pR=M.getFullYear(),pk(ph,pR),document.querySelectorAll("div#calendar-body div.item").forEach(function(M){if(M.getAttribute("data-date")==o1.selected_day){M.focus(),pX(o1.selected_day);return}}),!1==o1.startup&&(pX(o1.selected_day),pT(),o1.startup=!0)},200)}},"/page_events":{view:function(){return b(M3)("div",{class:"flex",id:"events-wrapper",oninit:function(){document.querySelector(".loading-spinner").style.display="block",oQ(),o1.shortCut=!1},onremove:function(){o1.selected_day=document.activeElement.getAttribute("data-date"),o1.selected_day_id=document.activeElement.getAttribute("data-id")},oncreate:function(){document.querySelector(".loading-spinner").style.display="none",pL(),MY("","","")}},b(M3)("input",{type:"search",class:"width-98 item",id:"search",tabIndex:0,onfocus:function(){window.scroll({top:20,left:0,behavior:"smooth"})},oninput:function(){pE(document.activeElement.value)}}),b(M3)("div",{id:"filter-menu",class:"flex justify-content-spacearound",oncreate:function(M){M.dom.style.display="none"},onfocus:function(){window.scroll({top:20,left:0,behavior:"smooth"})}},[b(M3)("button",{class:"item",tabindex:0,"data-action":"filter-last-modified",oncreate:function(M){M.dom.style.display="none"}},"last edited"),b(M3)("button",{class:"item",tabindex:0,"data-action":"filter-desc",oncreate:function(M){M.dom.style.display="none"}},"the latest"),b(M3)("button",{class:"item",tabindex:0,"data-action":"filter-asc",oncreate:function(M){M.dom.style.display="none"}},"the oldest"),b(M3)("button",{class:"item category-filter-button",tabindex:0,"data-action":"filter-category",oncreate:function(M){M.dom.style.display="none",void 0!==o2.eventsfilter&&(document.querySelector(".category-filter-button").style.display="flex")}},"show only category: "+o2.eventsfilter)]),[oP.map(function(M,e){var z,o="";o=M.allDay?"all day":b(Mw)(1e3*M.dateStartUnix).format("HH:mm");var p="sunday"==o2.firstday?o0[b(Mw)(1e3*M.dateStartUnix).day()]:o0[b(Mw)(1e3*M.dateStartUnix).day()-1];void 0==p&&(p=""),z=null==M.dateStartUnix||null==M.dateEndUnix||b(Mw)(1e3*M.dateStartUnix).format(o2.dateformat)==b(Mw)(1e3*M.dateEndUnix).format(o2.dateformat)||M.allDay?b(Mw)(1e3*M.dateStartUnix).format(o2.dateformat)+" | "+p:b(Mw)(1e3*M.dateStartUnix).format(o2.dateformat)+" - "+b(Mw)(1e3*M.dateEndUnix).format(o2.dateformat);var c="";M.RRULE&&M.RRULE.freq&&(c=M.RRULE.freq.toLowerCase());var t=M.isSubscription?"subscription":"",n=M.allDay?"allDay":"";return b(M3)("article",{class:"item events "+t+" "+n,tabindex:0,"data-id":M.UID,"data-date":b(Mw)(1e3*M.dateStartUnix).format("YYYY-MM-DD"),"data-category":(M.CATEGORIES||"").toUpperCase(),"data-summary":(M.SUMMARY||"").toUpperCase(),"data-calendar-name":M.calendar_name||""},[b(M3)("div",{class:"icons-bar"},[b(M3)("div",{class:"date"},z),b(M3)("div",{class:"time"},o),b(M3)("div",{class:"rrule-freq"},c),b(M3)("h2",{class:"summary"},M.SUMMARY),b(M3)("div",{class:"location"},M.LOCATION),b(M3)("div",{class:"description"},M.DESCRIPTION)])])})])}},"/page_options":{view:function(){return b(M3)("div",{id:"options",oninit:function(){oQ(),o1.shortCut=!1},oncreate:function(){o1.notKaiOS||oE(),MY("","","")}},[b(M3)("h2",{class:"item",tabIndex:0},"Key assignment"),b(M3)("ul",{id:"keys",class:"item width-100",tabindex:"1",oncreate:function(M){var b=M.dom;MY("","",""),document.querySelectorAll(".select-box").forEach(function(M){M.addEventListener("keypress",function(){setTimeout(function(){M.parentElement.focus()},200)})}),b.focus()}},[b(M3)("li",{class:"flex justify-content-spacebetween"},[b(M3)("kbd","1 & 3"),b(M3)("div","Month")]),b(M3)("li",{class:"flex justify-content-spacebetween"},[b(M3)("kbd","2"),b(M3)("div","Event slider")]),b(M3)("li",{class:"width-100 flex justify-content-spacebetween"},[b(M3)("kbd","5"),b(M3)("div","Edit event")]),b(M3)("li",{class:"width-100 flex justify-content-spacebetween"},[b(M3)("kbd","Enter"),b(M3)("div","Events/Month")]),b(M3)("li",{class:"width-100 flex justify-content-spacebetween"},[b(M3)("kbd","0"),b(M3)("div","Events filtered by category")]),b(M3)("li",{class:"width-100 flex justify-content-spacebetween"},[b(M3)("kbd","#"),b(M3)("div","Moon")]),b(M3)("li",{class:"width-100 flex justify-content-spacebetween"},[b(M3)("kbd","*"),b(M3)("div","Today")]),b(M3)("li",{class:"width-100 flex justify-content-spacebetween"},[b(M3)("kbd","SoftLeft longpress"),b(M3)("div",{},"create event from template")]),b(M3)("li",{class:"width-100 flex justify-content-spacebetween"},[b(M3)("span",{class:"keys-day-event"}),b(M3)("span","day with event")]),b(M3)("li",{class:"width-100 flex justify-content-spacebetween"},[b(M3)("span",{class:"keys-day-multi-event"}),b(M3)("span","day with several events")]),b(M3)("li",{class:"width-100 flex justify-content-spacebetween"},[b(M3)("span",{class:"keys-day-rrule-event"}),b(M3)("span","day with reccurence")])]),b(M3)("h2",{class:"item",tabindex:"2"},"Settings"),b(M3)("div",{class:"text-center"},"Timezone: "+o2.timezone),b(M3)("div",{class:"item input-parent",id:"event-date-format-box",tabindex:"3"},[b(M3)("label",{for:"event-date-format"},"dateformat"),b(M3)("select",{id:"event-date-format",class:"select-box",onchange:function(){pY()},oncreate:function(){o9(),setTimeout(function(){pS(),""==o2.dateformat?document.querySelector("#event-date-format").value="YYYY-MM-DD":document.querySelector("#event-date-format").value=o2.dateformat},1e3)}},[b(M3)("option",{value:"YYYY-MM-DD"},"YYYY-MM-DD"),b(M3)("option",{value:"DD.MM.YYYY"},"DD.MM.YYYY")])]),b(M3)("div",{class:"item input-parent",id:"background-sync-box",tabindex:"3"},[b(M3)("label",{for:"background-syn-box"},"Background sync ?"),b(M3)("select",{id:"background-sync",class:"select-box",onchange:function(){pY()},oncreate:function(){"b2g"in navigator&&(document.getElementById("background-sync-box").style.display="none"),o9(),setTimeout(function(){pS(),"No"==o2.background_sync?document.querySelector("#background-sync").value="No":document.querySelector("#background-sync").value="Yes"},1e3)}},[b(M3)("option",{value:"Yes"},"Yes"),b(M3)("option",{value:"No"},"No")]),b(M3)("div",{class:"last-sync-info"},"last sync: "+oF)]),b(M3)("div",{class:"item input-parent",id:"firs-day-of-the-week-box",tabindex:"4"},[b(M3)("label",{for:"first-day-of-the-week"},"first day of the week"),b(M3)("select",{id:"first-day-of-the-week",class:"select-box",onchange:function(){pY()},oncreate:function(){setTimeout(function(){pS(),""==o2.firstday||void 0==o2.firstday?document.querySelector("#first-day-of-the-week").value="sunday":document.querySelector("#first-day-of-the-week").value=o2.firstday},1e3)}},[b(M3)("option",{value:"sunday"},"Sunday"),b(M3)("option",{value:"monday"},"Monday")])]),b(M3)("div",{class:"item input-parent",id:"event-duration-wrapper",tabindex:"5"},[b(M3)("label",{for:"default-duration-time"},"default Duration"),b(M3)("select",{id:"default-duration-time",class:"select-box",onchange:function(){pY()},oncreate:function(){o9(),setTimeout(function(){pS(),document.querySelector("#default-duration-time").value=o2.default_duration},1e3)}},[b(M3)("option",{value:"30"},"30 minutes"),b(M3)("option",{value:"60"},"60 minutes"),b(M3)("option",{value:"120"},"120 minutes"),b(M3)("option",{value:"240"},"240 minutes")])]),b(M3)("div",{class:"item input-parent",id:"event-notification-time-wrapper",tabindex:"5"},[b(M3)("label",{for:"default-notification"},"default Notification"),b(M3)("select",{id:"default-notification-time",class:"select-box",onchange:function(){pY()},oncreate:function(){o9(),setTimeout(function(){pS(),""==o2.default_notification?document.querySelector("#default-notification-time").value="none":document.querySelector("#default-notification-time").value=o2.default_notification},1e3)}},[b(M3)("option",{value:"none"},"none"),b(M3)("option",{value:"5"},"5 minutes"),b(M3)("option",{value:"10"},"10 minutes"),b(M3)("option",{value:"30"},"30 minutes"),b(M3)("option",{value:"1440"},"1 Day")])]),b(M3)("button",{class:"item",tabindex:"6",oncreate:function(){pU=[],MV("ics",pj)},onclick:function(){b(M3).route.set("/page_list_files")}},"Import events"),b(M3)("button",{class:"item",tabindex:"7",onclick:function(){setTimeout(function(){pp(!0,!1)},1e3),Mj("the big loading has begun",2e3)}},"Reload all events"),b(M3)("h2","Subscriptions"),b(M3)("button",{class:"item",tabindex:"8",onclick:function(){b(M3).route.set("/page_subscriptions")}},"add subscription"),b(M3)("div",{id:"subscription-text"},"Your subscriptions"),null!=oY?oY.map(function(M,e){return b(M3)("button",{class:"item subscriptions-item","data-id":M.id,"data-action":"delete-subscription",tabindex:e+8,onfocus:function(){MY("","","")},onblur:function(){MY("","","")}},M.name)}):b(M3)("div",{class:"text-center"},"No subscriptions available"),b(M3)("h2","Category view"),b(M3)("div",{class:"item input-parent",id:"events-category-filter-wrapper",tabindex:""},[b(M3)("label",{for:"events-category-filter"},"Select the category"),b(M3)("select",{id:"events-category-filter",class:"select-box",onchange:function(){pY()},oncreate:function(){setTimeout(function(){pS(),document.querySelector("#events-category-filter").value=o2.eventsfilter},1e3)}},oP.length>0?[b(M3)("option",{value:"-"},"-")].concat(Mm(oP.map(function(M){return M.CATEGORIES}).filter(function(M,b,e){return""!==M&&e.indexOf(M)===b}).map(function(M){return b(M3)("option",{value:M},M)}))):[b(M3)("option",{value:"-"},"No categories available")])]),b(M3)("h2","Calendars"),null!=Mp?Mp.map(function(M){return b(M3)("button",{class:"item","data-calendar-name":M.name,oncreate:function(b){var e=b.dom;!1==M.view&&e.classList.add("active"),"local"==M.name&&(e.style.display="none")},onclick:function(){Mp.forEach(function(M){M.name==document.activeElement.getAttribute("data-calendar-name")&&(M.view=!M.view)}),document.activeElement.classList.toggle("active"),b(Mv).setItem("calendarNames",Mp).then(function(){o5(),Mj("will be applied the next time the app is started",2e3)})}},M.name)}):"",,b(M3)("h2","Accounts"),b(M3)("button",{class:"item google-button caldav-button",onclick:function(){b(M3).route.set("/page_accounts")}},[b(M3)("div",{class:"flex align-item-center justify-content-spacebetween "},[b(M3)("img",{src:"assets/image/caldav.png"}),b(M3)("span","CalDAV Account")])]),b(M3)("button",{class:"item google-button",onclick:function(){o$=setInterval(function(){"true"==localStorage.getItem("oauth_callback")&&(b(M3).route.set("/page_calendar"),clearInterval(o$),setTimeout(function(){ox=[],b(Mv).getItem("accounts").then(function(M){if(null==M)return ox=[],!1;ox=M,pp(!1,!1)}).catch(function(M){console.log(M)})},5e3))},1e3),window.open("https://accounts.google.com/o/oauth2/v2/auth?client_id=762086220505-f0kij4nt279nqn21ukokm06j0jge2ngl.apps.googleusercontent.com&response_type=code&state=state_parameter_passthrough_value&scope=https://www.googleapis.com/auth/calendar%20https://www.googleapis.com/auth/calendar.calendarlist&redirect_uri=https://greg.strukturart.com/index.html&access_type=offline&prompt=consent")}},[b(M3)("div",{class:"flex justify-content-spacebetween align-item-center "},[b(M3)("img",{src:"assets/image/google_button.png"}),b(M3)("span","Sign in with Google")])]),null!=ox?b(M3)("div",{id:"subscription-text"},"Your accounts"):"",null!=ox?ox.map(function(M){return b(M3)("button",{class:"item subscriptions-item","data-id":M.id,"data-account-type":M.type,"data-action":"edit-delete-account",onblur:function(){MY("","","")},onfocus:function(){"oauth"==M.type?MY("","",""):MY("","","")}},M.name)}):"",b(M3)("h2",{class:"ads-title"},"Ads"),b(M3)("div",{id:"KaiOsAds-Wrapper",class:"flex justify-content-spacearound",oninit:function(){o2.ads||document.querySelector("h2.ads-title").remove()},oncreate:function(){},onfocus:function(){MY("","open ads","")},onblur:function(){MY("","open ads","")}})])}},"/page_add_event":{view:function(){return b(M3)("div",{id:"add-edit-event",tabindex:"0",oninit:function(){oQ(),o1.shortCut=!1}},[b(M3)("div",{class:"item input-parent",tabindex:0,oncreate:function(M){var b=M.dom;setTimeout(function(){b.focus(),MY("","","")},500)}},[b(M3)("label",{for:"event-title"},"Title"),b(M3)("input",{placeholder:"",type:"text",id:"event-title",oncreate:function(){o9(),pZ()},onfocus:function(){px="event-title",MY("","","")},onblur:function(){px="event-title",MY("","","")}})]),b(M3)("div",{class:"item input-parent",tabindex:"1"},[b(M3)("label",{for:"event-location"},"Location"),b(M3)("input",{placeholder:"",type:"text",id:"event-location",oninput:function(M){Mk(M.target.value,"LOCATION")}})]),b(M3)("div",{id:"search-result"}),b(M3)("div",{class:"item input-parent",tabindex:"2",onfocus:function(){Mk("close")}},[b(M3)("label",{for:"event-date"},"Start Date"),b(M3)("input",{placeholder:o2.dateformat,type:"date",id:"event-date",class:"select-box",oncreate:function(M){M.dom.value=o1.selected_day}})]),b(M3)("div",{class:"item input-parent",tabindex:"3"},[b(M3)("label",{for:"event-date-end"},"End Date"),b(M3)("input",{placeholder:o2.dateformat,type:"date",id:"event-date-end",class:"select-box",oncreate:function(M){M.dom.min=o1.selected_day}})]),b(M3)("div",{class:"item input-parent flex justify-content-center",tabindex:"4"},[b(M3)("label",{for:"event-all-day"},"All Day"),b(M3)("input",{type:"checkbox",id:"event-all-day",class:"check-box",onfocus:function(M){!1==M.target.checked?(setTimeout(function(){document.querySelector(".check-box").parentElement.focus()},300),document.querySelectorAll(".time").forEach(function(M){document.querySelector("#event-time-start").value="01:00",document.querySelector("#event-time-end").value="01:00",M.style.display="none",M.classList.remove("item"),cM()})):(setTimeout(function(){document.querySelector(".check-box").parentElement.focus()},300),document.querySelectorAll(".time").forEach(function(M){M.style.display="block",M.classList.add("item"),cM()}))}}),b(M3)("div",{class:"ckb-wrapper"},[b(M3)("div",{class:"ckb-icon"}),b(M3)("div",{class:"toogle-button"})])]),b(M3)("div",{class:"item input-parent time",tabindex:"4"},[b(M3)("label",{for:"event-time-start"},"Start Time"),b(M3)("input",{placeholder:"hh:mm",type:"time",id:"event-time-start",class:"select-box",oncreate:function(M){M.dom.value=b(Mw)().format("HH:mm")}})]),b(M3)("div",{class:"item input-parent time",tabindex:"5"},[b(M3)("label",{for:"event-time-end"},"End Time"),b(M3)("input",{placeholder:"hh:mm",type:"time",id:"event-time-end",class:"select-box",onblur:function(M){var e=document.querySelector("#event-date").value,z=""!=document.querySelector("#event-date-end").value?document.querySelector("#event-date-end").value:document.querySelector("#event-date").value,o=b(Mw)(e+" "+document.querySelector("#event-time-start").value);!1==b(Mw)(z+" "+M.target.value).isAfter(o)&&Mj("something is wrong with the time",2e3)},oncreate:function(M){var e=M.dom;console.log(o2.default_duration),e.value=b(Mw)().add(o2.default_duration,"minutes").format("HH:mm")}})]),b(M3)("div",{class:"item input-parent",tabindex:"6"},[b(M3)("label",{for:"event-description"},"Description"),b(M3)("input",{placeholder:"",type:"text",id:"event-description"})]),b(M3)("div",{class:"item input-parent",tabindex:"6"},[b(M3)("label",{for:"event-category"},"Category"),b(M3)("input",{placeholder:"",type:"text",id:"event-category"})]),b(M3)("div",{class:"item input-parent",id:"event-notification-time-wrapper",tabindex:"7"},[b(M3)("label",{for:"notification"},"Notification"),b(M3)("select",{id:"event-notification-time",class:"select-box",oncreate:function(){setTimeout(function(){document.querySelector("#event-notification-time").value=o2.default_notification},2e3)}},[b(M3)("option",{value:"none"},"none"),b(M3)("option",{value:"5"},"5 minutes"),b(M3)("option",{value:"10"},"10 minutes"),b(M3)("option",{value:"30"},"30 minutes"),b(M3)("option",{value:"60"},"60 minutes"),b(M3)("option",{value:"1440"},"1 Day")])]),b(M3)("div",{class:"item input-parent",id:"event-recur-wrapper",tabindex:"8",oncreate:function(){setTimeout(function(){document.querySelector("#event-recur").value="none"},1e3)}},[b(M3)("label",{for:"event-recur"},"Recur"),b(M3)("select",{id:"event-recur",class:"select-box"},[b(M3)("option",{value:"none"},"none"),b(M3)("option",{value:"DAILY"},"Daily"),b(M3)("option",{value:"WEEKLY"},"Weekly"),b(M3)("option",{value:"BIWEEKLY"},"Biweekly"),b(M3)("option",{value:"MONTHLY"},"Monthly"),b(M3)("option",{value:"YEARLY"},"Yearly")])]),b(M3)("div",{class:"item input-parent",id:"event-calendar-wrapper",tabindex:"9"},[b(M3)("label",{for:"event-calendar"},"Calendars"),b(M3)("select",{id:"event-calendar",class:"select-box"},[Mp.map(function(M){return b(M3)("option",{value:M.id,"data-calendar-data":M.data},M.name)})])]),b(M3)("button",{tabindex:"10",id:"save-event",class:"item save-button",oncreate:function(){pS(),cM()},onclick:function(){var M=document.getElementById("event-calendar");p8(M.options[M.selectedIndex].value,M.options[M.selectedIndex].text)}},"save")])},oncreate:function(){MY("","","")}},"/page_edit_event":{view:function(){var M;return b(M3)("div",{id:"add-edit-event",oninit:function(){},omcreate:function(){oQ(),o1.shortCut=!1}},[b(M3)("div",{class:"item input-parent",tabindex:0,oncreate:function(M){var b=M.dom;setTimeout(function(){b.focus(),MY("","","")},500)}},[b(M3)("label",{for:"event-title"},"Title"),b(M3)("input",{placeholder:"",type:"text",id:"event-title",value:Mc.SUMMARY})]),b(M3)("div",{class:"item input-parent",tabindex:"1"},[b(M3)("label",{for:"event-location"},"Location"),b(M3)("input",{placeholder:"",type:"text",id:"event-location",value:Mc.LOCATION})]),b(M3)("div",{class:"item input-parent",tabindex:"2"},[b(M3)("label",{for:"event-date"},"Start Date"),b(M3)("input",{placeholder:o2.dateformat,type:"date",id:"event-date",class:"select-box",oncreate:function(M){M.dom.value=Mc.dateStart}})]),b(M3)("div",{class:"item input-parent",tabindex:"3"},[b(M3)("label",{for:"event-date-end"},"End Date"),b(M3)("input",{placeholder:o2.dateformat,type:"date",id:"event-date-end",class:"select-box",oncreate:function(M){M.dom.value=Mc.dateEnd}})]),b(M3)("div",{class:"item input-parent",tabindex:"4"},[b(M3)("label",{for:"event-all-day"},"All Day"),b(M3)("input",{type:"checkbox",id:"event-all-day",class:"check-box",oncreate:function(){!0==Mc.allDay&&(document.querySelector("#event-all-day").checked=!0,document.querySelectorAll(".time").forEach(function(M){M.style.display="none",M.classList.remove("item"),cM()}))},onfocus:function(M){!1==M.target.checked?(setTimeout(function(){M.focus()},300),document.querySelectorAll(".time").forEach(function(M){M.style.display="none",M.classList.remove("item"),document.querySelector("#event-time-start").value="01:00",document.querySelector("#event-time-end").value="01:00",cM()})):(setTimeout(function(){M.focus()},300),document.querySelectorAll(".time").forEach(function(M){M.style.display="block",M.classList.add("item"),cM()}))}}),b(M3)("div",{class:"ckb-wrapper"},[b(M3)("div",{class:"ckb-icon"}),b(M3)("div",{class:"toogle-button"})])]),b(M3)("div",{class:"item input-parent time",tabindex:"4"},[b(M3)("label",{for:"event-time-start"},"Start Time"),b(M3)("input",{placeholder:"HH:mm",type:"time",id:"event-time-start",class:"select-box",value:8==Mc.time_start.length?Mc.time_start.slice(0,-3):Mc.time_start})]),b(M3)("div",{class:"item input-parent time",tabindex:"5"},[b(M3)("label",{for:"event-time-end"},"End Time"),b(M3)("input",{placeholder:"hh:mm",type:"time",id:"event-time-end",class:"select-box",value:8==Mc.time_end.length?Mc.time_end.slice(0,-3):Mc.time_end})]),b(M3)("div",{class:"item input-parent",tabindex:"6"},[b(M3)("label",{for:"event-description"},"Description"),b(M3)("input",{placeholder:"",type:"text",id:"event-description",value:Mc.DESCRIPTION})]),b(M3)("div",{class:"item input-parent",tabindex:"6"},[b(M3)("label",{for:"event-category"},"Category"),b(M3)("input",{placeholder:"",type:"text",id:"event-category",value:Mc.CATEGORIES})]),b(M3)("div",{class:"item input-parent",id:"event-notification-time-wrapper",tabindex:"7"},[b(M3)("label",{for:"notification"},"Notification"),b(M3)("select",{id:"event-notification-time",class:"select-box"},[b(M3)("option",{value:"none"},"none"),b(M3)("option",{value:"5"},"5 minutes"),b(M3)("option",{value:"10"},"10 minutes"),b(M3)("option",{value:"30"},"30 minutes"),b(M3)("option",{value:"60"},"60 minutes"),b(M3)("option",{value:"1440"},"1 Day")])]),b(M3)("div",{class:"item input-parent",id:"event-calendar-wrapper",tabindex:"9"},[b(M3)("label",{for:"event-calendar"},"Calendars"),b(M3)("select",{id:"event-calendar",class:"select-box",onchange:function(){o1.event_calendar_changed=!0}},[Mp.map(function(M){var e="";return Mc.calendar_name==M.name&&(e="selected"),b(M3)("option",{value:M.id,selected:e,"data-calendar-data":M.data},M.name)})])]),b(M3)("div",{class:"item input-parent",id:"event-recur-wrapper",tabindex:"8",oncreate:function(){document.querySelector("#event-notification-time").value=Mc.alarm}},[b(M3)("label",{for:"event-recur"},"Recur"),b(M3)("select",{id:"event-recur",value:null!==(M=Mc.RRULE.freq)&&void 0!==M?M:"none",class:"select-box"},[b(M3)("option",{value:"none"},"none"),b(M3)("option",{value:"DAILY"},"Daily"),b(M3)("option",{value:"WEEKLY"},"Weekly"),b(M3)("option",{value:"BIWEEKLY"},"Biweekly"),b(M3)("option",{value:"MONTHLY"},"Monthly"),b(M3)("option",{value:"YEARLY"},"Yearly")])]),b(M3)("button",{tabindex:"9",id:"delete-event",class:"item",onclick:function(){p9(Mc.etag,Mc.url,Mc.id,Mc.UID)}},"delete"),b(M3)("button",{tabindex:"10",id:"save-event",class:"item save-button",oncreate:function(){pS()},onclick:function(){if(o1.event_calendar_changed||p7(Mc.etag,Mc.url,Mc.id,Mc.UID,Mc.calendar_name),o1.event_calendar_changed){var M=document.getElementById("event-calendar");p9(Mc.etag,Mc.url,Mc.id,Mc.UID),p8(M.options[M.selectedIndex].value,M.options[M.selectedIndex].text)}}},"update"),b(M3)("button",{tabindex:"11",id:"save-event-as-template",class:"item save-template-button",oncreate:function(){pS()},onclick:function(){pf(document.getElementById("event-title").value,document.getElementById("event-description").value,document.getElementById("event-location").value,document.getElementById("event-category").value)}},"save as template")])}},"/page_subscriptions":{view:function(){return b(M3)("div",{id:"subscription-form"},[b(M3)("div",{class:"item input-parent",tabindex:"0",oninit:function(){MY("","",""),oQ(),o1.shortCut=!1},oncreate:function(M){M.dom.focus()}},[b(M3)("label",{for:"description"},"subscription name"),b(M3)("input",{placeholder:"Name",type:"text",id:"cal-subs-name"})]),b(M3)("div",{class:"item input-parent",tabindex:"1",onblur:function(){MY("","","")}},[b(M3)("label",{for:"description"},"subscription url"),b(M3)("input",{placeholder:"URL",type:"text",id:"cal-subs-url","data-scan-action":"true",onfocus:function(){MY("","","")},oncreate:function(){setTimeout(function(){document.getElementById("cal-subs-url").value=pP},1e3)},onblur:function(){MY("","","")}})]),b(M3)("button",{class:"item save-button",tabindex:"2",onclick:function(){pV()}},"save")])}},"/page_accounts":{view:function(){return b(M3)("div",{id:"account-form"},[b(M3)("div",{class:"item input-parent",tabindex:"0",oninit:function(){oQ()},oncreate:function(M){M.dom.focus()}},[b(M3)("label",{for:"description"},"account name"),b(M3)("input",{placeholder:"Name",type:"text",id:"account-name"})]),b(M3)("div",{class:"item input-parent",tabindex:"1",onblur:function(){MY("","","")}},[b(M3)("label",{for:"description"},"server"),b(M3)("input",{placeholder:"URL",type:"text",id:"account-url","data-scan-action":"true",onfocus:function(){MY("","","")},onblur:function(){MY("","","")}})]),b(M3)("div",{class:"item input-parent",tabindex:"2",onblur:function(){MY("","","")}},[b(M3)("label",{for:"description"},"username"),b(M3)("input",{placeholder:"username",type:"url",id:"account-username","data-scan-action":"true",onfocus:function(){MY("","","")},onblur:function(){MY("","","")}})]),b(M3)("div",{class:"item input-parent",tabindex:"3",onblur:function(){MY("","","")}},[b(M3)("label",{for:"description"},"password"),b(M3)("input",{placeholder:"password",type:"password",id:"account-password","data-scan-action":"true",onfocus:function(){MY("","","")},onblur:function(){MY("","","")}})]),b(M3)("button",{class:"item save-button",tabindex:"4",onclick:function(){pG()}},"save")])}},"/page_edit_account":{view:function(){return b(M3)("div",{id:"account-form"},[b(M3)("div",{class:"item input-parent",tabindex:"0",oninit:function(){},oncreate:function(M){M.dom.focus(),oQ(),o1.shortCut=!1}},[b(M3)("label",{for:"description"},"account name"),b(M3)("input",{placeholder:"Name",type:"text",id:"account-name",value:Mt.name})]),b(M3)("div",{class:"item input-parent",tabindex:"1",onblur:function(){MY("","","")}},[b(M3)("label",{for:"description"},"server"),b(M3)("input",{placeholder:"URL",type:"text",id:"account-url","data-scan-action":"true",value:Mt.server_url,onfocus:function(){MY("","","")},onblur:function(){MY("","","")}})]),b(M3)("div",{class:"item input-parent",tabindex:"2",onblur:function(){MY("","","")}},[b(M3)("label",{for:"description"},"username"),b(M3)("input",{placeholder:"username",type:"url",id:"account-username",value:Mt.user,"data-scan-action":"true",onfocus:function(){MY("","","")},onblur:function(){MY("","","")}})]),b(M3)("div",{class:"item input-parent",tabindex:"3",onblur:function(){MY("","","")}},[b(M3)("label",{for:"description"},"password"),b(M3)("input",{placeholder:"password",type:"password",id:"account-password","data-scan-action":"true",value:Mt.password,onfocus:function(){MY("","","")},onblur:function(){MY("","","")}})]),b(M3)("button",{class:"item save-button",tabindex:"4",onclick:function(){pG(!0,o1.edit_account_id)}},"update")])}},"/page_event_templates":{view:function(){return b(M3)("div",{id:"options",oninit:function(){oQ()},oncreate:function(){MY("","","")}},[b(M3)("h2",{class:"text-center"},"Templates"),oI.map(function(M,e){return b(M3)("button",{class:"item",onclick:function(){Mn=M.id,b(M3).route.set("/page_add_event")},oncreate:function(M){M.dom},tabIndex:e,"data-id":M.id},M.title)})])}},"/page_list_files":{view:function(){return b(M3)("div",{id:"options",oninit:function(){oQ()}},[b(M3)("h2",{class:"text-center",id:"file-head"},"files"),pU.map(function(M,e){var z=M.split("/");return z=z[z.length-1],b(M3)("button",{class:"item",oncreate:function(M){var b=M.dom;0==e&&b.focus()},tabIndex:e,onclick:function(){!function(M,b){try{var e=navigator.getDeviceStorage("sdcard"),z=e.get(M);z.onsuccess=function(){var M=this.result,e=new FileReader;e.onerror=function(M){helper.toaster("can't read file",3e3),e.abort()},e.onloadend=function(M){b(e.result)},e.readAsText(M)},z.onerror=function(){alert("Unable to get the file: "+this.error)}}catch(M){console.log(M)}if("b2g"in navigator)try{var e=navigator.b2g.getDeviceStorage("sdcard"),z=e.get(M).then(function(M){var e=new FileReader;e.onerror=function(M){console.log("filereader error: "+M),e.abort()},e.onloadend=function(M){b(e.result)},e.readAsText(M)})}catch(M){alert(M)}}(M,pF)}},z)})])}},"/page_events_filtered":{view:function(){var M=b(M3).route.param("query"),e=0;return b(M3)("div",{class:"flex",id:"events-wrapper",onremove:function(){o1.selected_day=document.activeElement.getAttribute("data-date"),o1.selected_day_id=document.activeElement.getAttribute("data-id")},oninit:function(){oQ(),o1.shortCut=!1,Mj("Category: "+M,8e3)},oncreate:function(){document.querySelectorAll(".item")[0].focus(),MY("","","")}},[oP.map(function(z){if(z.CATEGORIES&&z.CATEGORIES.toLowerCase()===M.toLowerCase()){e++;var o,p="";p=z.allDay?"all day":b(Mw)(1e3*z.dateStartUnix).format("HH:mm"),o=null==z.dateStartUnix||null==z.dateEndUnix||b(Mw)(1e3*z.dateStartUnix).format(o2.dateformat)==b(Mw)(1e3*z.dateStartUnix).format(o2.dateformat)||z.allDay?b(Mw)(1e3*z.dateStartUnix).format(o2.dateformat):b(Mw)(1e3*z.dateStartUnix).format(o2.dateformat)+" - "+b(Mw)(1e3*z.dateStartUnix).format(o2.dateformat);var c=z.isSubscription?"subscription":"",t=z.allDay?"allDay":"";return b(M3)("article",{class:"item events "+c+" "+t,tabindex:e,"data-id":z.UID,"data-date":b(Mw)(1e3*z.dateStartUnix).format("YYYY-MM-DD"),"data-category":(z.CATEGORIES||"").toUpperCase(),"data-summary":(z.SUMMARY||"").toUpperCase()},[b(M3)("div",{class:"icons-bar"},[b(M3)("div",{class:"date"},o),b(M3)("div",{class:"time"},p),b(M3)("h2",{class:"summary"},z.SUMMARY),b(M3)("div",{class:"location"},z.LOCATION),b(M3)("div",{class:"description"},z.DESCRIPTION)])])}})])}}}),b(M3).route.prefix="#");var pY=function(){o2.default_notification=document.getElementById("default-notification-time").value,o2.default_duration=document.getElementById("default-duration-time").value,o2.dateformat=document.getElementById("event-date-format").value,o2.firstday=document.getElementById("first-day-of-the-week").value,o2.eventsfilter=document.getElementById("events-category-filter").value,o2.background_sync=document.getElementById("background-sync").value,"Yes"==o2.background_sync?MQ():MK(),b(Mv).setItem("settings",o2).then(function(){o9()}).catch(function(M){console.log(M)})},pH=function(M){document.activeElement.value=M},pV=function(){var M;null==oY&&(oY=[]),MD(document.getElementById("cal-subs-url").value)&&""!=document.getElementById("cal-subs-name").value?(M=MT(32),oY.push({url:document.getElementById("cal-subs-url").value,name:document.getElementById("cal-subs-name").value,id:M}),document.querySelector("input#cal-subs-name").value="",document.querySelector("input#cal-subs-url").value="",b(Mv).setItem("subscriptions",oY).then(function(M){b(M3).route.set("/page_options")}),b(Mv).setItem(M,"").then(function(M){Mj("subscription added",4e3),pq()}).catch(function(M){console.log(M)})):Mj("Please enter a name and a valid url",2e3)},pG=function(M,e){MD(document.getElementById("account-url").value)&&""!=document.getElementById("account-name").value&&""!=document.getElementById("account-username").value&&""!=document.getElementById("account-password").value?(M?(ox=ox.filter(function(M){return M.id!==e})).push({server_url:document.getElementById("account-url").value,user:document.getElementById("account-username").value,password:document.getElementById("account-password").value,name:document.getElementById("account-name").value,id:e,type:"basic"}):(null==ox&&(ox=[]),ox.push({server_url:document.getElementById("account-url").value,user:document.getElementById("account-username").value,password:document.getElementById("account-password").value,name:document.getElementById("account-name").value,id:MT(32),type:"basic"})),b(Mv).setItem("accounts",ox).then(function(M){o8(),pp(!0,!1),b(M3).route.set("/page_options")}).catch(function(M){console.log(M)})):Mx("Please enter a name and a valid url",2e3)},pK=function(){var M=oY.filter(function(M){return M.id!=document.activeElement.getAttribute("data-id")});b(Mv).removeItem(document.activeElement.getAttribute("data-id")).then(function(){Mx("subscription removed",4e3)}).catch(function(M){console.log(M)}),b(Mv).setItem("subscriptions",M).then(function(M){Mj("subscription deleted",2e3)}).catch(function(M){Mx(M,2e3)}),document.activeElement.remove()},pQ=function(){var M=ox.filter(function(M){return M.id!=document.activeElement.getAttribute("data-id")});b(Mv).setItem("accounts",M).then(function(M){Mj("account deleted",2e3),document.activeElement.remove(),MY("","","")}).catch(function(M){Mx(M,2e3)}),b(Mv).removeItem(document.activeElement.getAttribute("data-id")).then(function(){}).catch(function(M){console.log(M)})};function pJ(){"hidden"===document.visibilityState?o1.visible=!1:setTimeout(function(){o1.visible=!0},1e3)}b(Mv).getItem("subscriptions").then(function(M){oY=M,pq()}).catch(function(M){}),pJ();var p$=function(M){oI=oI.filter(function(b){return b.id!=M}),b(Mv).setItem("event_templates",oI).then(function(M){Mj("template deleted",2e3),b(M3).route.set("/page_calendar")}).catch(function(M){console.log(M)})},pZ=function(){oI.forEach(function(M){M.id==Mn&&(document.getElementById("event-title").value=M.title,document.getElementById("event-description").value=M.description,document.getElementById("event-location").value=M.location,document.getElementById("event-category").value=M.category,Mn="")})},p0=function(M){if(pw(),cM(),"SELECT"==document.activeElement.nodeName||"date"==document.activeElement.type||"time"==document.activeElement.type)return!1;var e=document.activeElement.tabIndex+M,z=0,o=document.activeElement.parentNode.parentNode;if(z=o.querySelectorAll('.item:not([style*="display: none"]'),("/page_calendar"==b(M3).route.get()||"/page_options"==b(M3).route.get()||"/page_events"==b(M3).route.get()||"/page_event_templates"==b(M3).route.get()||"/page_list_files"==b(M3).route.get()||b(M3).route.get().startsWith("/page_events"))&&(z=document.activeElement.parentNode.parentNode.querySelectorAll('.item:not([style*="display: none"]'),o1.shortCut=!1),"/page_calendar"==b(M3).route.get()&&(o1.shortCut=!1,MY("","","")),("/page_subscriptions"==b(M3).route.get()||"/page_accounts"==b(M3).route.get()||"/page_edit_account"==b(M3).route.get())&&(z=o.querySelectorAll('.item:not([style*="display: none"]'),z=o.querySelectorAll(".item")),"/page_add_event"==b(M3).route.get()||"/page_edit_event"==b(M3).route.get()){if(z=o.querySelectorAll('.item:not([style*="display: none"]'),document.activeElement.parentNode.classList.contains("input-parent"))return document.activeElement.parentNode.focus(),!0;document.getElementById("add-edit-event").firstElementChild.focus()}var p=0;e<=z.length&&(p=z[e]).focus(),e==z.length&&(p=z[0]).focus();for(var c=document.activeElement.getBoundingClientRect(),t=c.top-document.body.getBoundingClientRect().top+c.height/2,n=document.activeElement.parentNode;n&&!(n.scrollHeight>n.clientHeight)&&!(n.scrollWidth>n.clientWidth);)n=n.parentNode;if(n?n.scrollBy({left:0,top:t-window.innerHeight/2,behavior:"smooth"}):document.body.scrollBy({left:0,top:t-window.innerHeight/2,behavior:"smooth"}),"/page_calendar"==b(M3).route.get()||"/page_events"==b(M3).route.get()||b(M3).route.get().startsWith("/page_events"))try{o1.selected_day=p.getAttribute("data-date"),o1.selected_day_id=p.getAttribute("data-id"),pX(o1.selected_day)}catch(M){}},p1=function(M,b,e,z){if("mozAlarms"in navigator){var o=navigator.mozAlarms.add(M,"honorTimezone",{note:b,event_id:e,type:z});o.onsuccess=function(){console.log("alarm set")},o.onerror=function(){console.log("An error occurred: "+this.error.name)}}if("b2g"in navigator)try{navigator.b2g.alarmManager.add({date:M,data:{note:b,type:z},ignoreTimezone:!1}).then(function(M){return console.log("add id: "+M)},function(M){return console.log("add err: "+M)})}catch(M){console.log(M)}},p2=function(M){if(navigator.mozAlarms){var b=navigator.mozAlarms.getAll();b.onsuccess=function(){this.result.forEach(function(b){if(b.data.event_id==M){var e=navigator.mozAlarms.remove(b.id);e.onsuccess=function(){console.log("removed")},e.onerror=function(){console.log("An error occurred: "+this.error.name)}}})},b.onerror=function(){console.log("An error occurred:",this.error.name)}}if("b2g"in navigator)try{navigator.b2g.alarmManager.getAll().onsuccess=function(){this.result.forEach(function(b){if(b.data.event_id==M){var e=navigator.b2g.alarmManager.remove(b.id);e.onsuccess=function(){console.log("removed")},e.onerror=function(){console.log("An error occurred: "+this.error.name)}}})}}catch(M){console.log(M)}},p3=function(M,e,z){var o=b(Mw)(M).format("YYYYMMDDTHHmmss");return o=e?";VALUE=DATE:"+b(Mw)(M).format("YYYYMMDD"):":"+o,z&&(o=b(Mw)(M).format("YYYYMMDDTHHmmss")),o},p4=["SU","MO","TU","WE","TH","FR","SA"],p5=function(M,b,e){if("none"===M)return"";var z=p4[new Date(e).getDay()];return"WEEKLY"===M?"FREQ=".concat(M,";INTERVAL=1;BYDAY=").concat(z,";UNTIL=").concat(p3(b,!1,!0)):"FREQ=".concat(M,";UNTIL=").concat(p3(b,!1,!0))},p6=[],p8=function(M,e){var z,o,p=!0,c=!1;!0===document.getElementById("event-all-day").checked&&(c=!0),""===document.getElementById("event-title").value&&(Mx("Title can't be empty",2e3),p=!1),"none"!=document.getElementById("event-recur").value&&""==document.getElementById("event-date-end").value&&(Mx("An end date is required for a recurrence",2e3),p=!1);var t=document.getElementById("event-time-start"),n=t.value?"".concat(t.value,":00"):"00:00:00",O=document.getElementById("event-time-end"),r=O.value?"".concat(O.value,":00"):"00:00:00",a=new Date("01/01/2000 "+n),i=new Date("01/01/2000 "+r),A=document.getElementById("event-date").value+" "+n;""==document.getElementById("event-date-end").value&&(document.getElementById("event-date-end").value=document.getElementById("event-date").value);var d=document.getElementById("event-date-end").value+" "+r;c&&(d=b(Mw)(document.getElementById("event-date-end").value+" "+r).add(1,"day").format("YYYY-MM-DD hh:mm:ss"));var s=document.getElementById("event-date").value+" "+r,q=document.getElementById("event-notification-time").value;if("none"!==q&&((z=new Date(A)).setMinutes(z.getMinutes()-q),q=p3(z.toISOString())),""!=n&&""!=r){var a=new Date(document.getElementById("event-date").value+" "+n),i=new Date(document.getElementById("event-date-end").value+" "+r);i","",""));break;case"#":document.querySelectorAll("div#calendar div#calendar-body div div [class^='moon-phase-']").forEach(function(M){M.classList.toggle("active")});break;case"SoftRight":case"Alt":case"m":if(cz("page_events_filtered"))return b(M3).route.set("/page_events");if(ce("page_calendar")&&o1.shortCut){var e="",z=document.querySelectorAll("#event-slider article");return z.forEach(function(M,b){"block"==M.style.display&&(e=M),z.length-1==b&&(void 0==(Mc=oP.filter(function(M){return!0!=M.isSubscription&&M.UID==e.getAttribute("data-uid")})[0])?Mj("subscriptions events cannot be edited",4e3):p9(Mc.etag,Mc.url,Mc.id,Mc.UID))})}if(ce("page_calendar")&&!o1.shortCut)return b(M3).route.set("/page_options");if(cz("page_events"))return document.querySelectorAll("#filter-menu button").forEach(function(M){M.style.display="block"}),document.querySelector("#filter-menu").style.display="flex",document.querySelector("#filter-menu").firstChild.focus(),document.querySelector("#search").focus();cz("page_add_event")&&M_(pI),"edit-delete-account"==document.activeElement.getAttribute("data-action")&&"oauth"!=document.activeElement.getAttribute("data-account-type")&&(o1.edit_account_id=document.activeElement.getAttribute("data-id"),Mt=ox.filter(function(M){return M.id==o1.edit_account_id})[0],b(M3).route.set("/page_edit_account"));break;case"SoftLeft":case"Control":if(ce("page_event_templates")&&p$(document.activeElement.getAttribute("data-id")),cz("page_events")){if(document.activeElement.classList.contains("subscription"))return Mj("subscriptions events cannot be edited",4e3);return pl(),document.activeElement.classList.contains("events")&&b(M3).route.set("/page_edit_event")}if(ce("page_subscriptions")||ce("page_accounts"))return"true"==document.activeElement.getAttribute("data-scan-action")&&M2(pH);if(ce("page_options")&&("delete-subscription"==document.activeElement.getAttribute("data-action")&&pK(),"edit-delete-account"==document.activeElement.getAttribute("data-action")&&pQ()),ce("page_calendar")&&o1.shortCut){var o="",p=document.querySelectorAll("#event-slider article");return p.forEach(function(M,e){"block"==M.style.display&&(o=M),p.length-1==e&&(void 0==(Mc=oP.filter(function(M){return!M.isSubscription&&M.UID==o.getAttribute("data-uid")})[0])?Mj("subscriptions events cannot be edited",4e3):b(M3).route.set("/page_edit_event"))})}if(ce("page_calendar"))return b(M3).route.set("/page_add_event");break;case"Enter":if(!o1.visible)return;if(document.activeElement.classList.contains("input-parent"))return document.activeElement.children[1].focus(),document.activeElement.classList.contains("check-box")&&(!0==document.activeElement.checked?document.activeElement.checked=!1:document.activeElement.checked=!0);if(document.activeElement.classList.contains("search-item"))return Mk("click");if("export-event"==document.activeElement.id)return oP.forEach(function(M){M.UID==o1.selected_day_id&&p6.push(M.data)}),M$(p6[0].UID+".ics",p6,function(M){Mj(M,3e3)}),Mj("event exported",5e3);if(oP.length>0||null==oP){if(cz("page_calendar")&&(document.querySelector(".loading-spinner").style.display="block"),cz("page_events")){if("BUTTON"!==document.activeElement.tagName&&b(M3).route.set("/page_calendar"),"BUTTON"===document.activeElement.tagName){var c=document.activeElement.getAttribute("data-action");document.querySelectorAll("#events-wrapper article").forEach(function(M){M.style.display="block"}),"filter-category"==c&&p_(o2.eventsfilter),"filter-last-modified"==c&&MC(oP,"lastmod","date","asc").then(function(){document.querySelector("#search").focus(),cM()}),"filter-asc"==c&&MC(oP,"dateStartUnix","date","asc").then(function(){document.querySelector("#search").focus(),cM()}),"filter-desc"==c&&MC(oP,"dateStartUnix","date","desc").then(function(){document.querySelector("#search").focus(),cM()}),document.querySelector("#filter-menu").style.display="none",document.querySelectorAll("#filter-menu button").forEach(function(M){M.style.display="none"})}"INPUT"===document.activeElement.tagName&&setTimeout(pT,1e3)}else(ce("page_calendar")||ce("page_events"))&&b(M3).route.set(ce("page_calendar")?"/page_events":"/page_calendar")}else ce("page_calendar")&&Mj("There are no calendar entries to display",3e3);break;case"Backspace":ce("page_add_event")&&"INPUT"!=document.activeElement.tagName&&b(M3).route.set("/page_calendar"),ce("page_events_filtered")&&b(M3).route.set("/page_calendar"),ce("page_edit_event")&&"INPUT"!=document.activeElement.tagName&&b(M3).route.set("/page_calendar"),ce("page_options")&&b(M3).route.set("/page_calendar"),ce("page_event_templates")&&b(M3).route.set("/page_calendar"),(ce("page_subscriptions")||ce("page_accounts")||ce("page_edit_account")||ce("page_list_files"))&&(b(M3).route.set("/page_options"),"block"==document.getElementById("qr-screen").style&&(document.getElementById("qr-screen").style="none"),M1(cb));break;case"0":if(ce("page_calendar")||ce("page_events")){if(o2.eventsfilter||Mj("no category selected, you can do that in the settings",4e3),"INPUT"==document.activeElement.tagName)return;b(M3).route.set("/page_events_filtered",{query:o2.eventsfilter})}}}(M)}),document.addEventListener("visibilitychange",pJ,!1),o1.debug&&(window.onerror=function(M,b,e){return alert("Error message: "+M+"\nURL: "+b+"\nLine Number: "+e),!0});var cp=(j=Ml(function(M){var e,z,o,p;return(0,MB.__generator)(this,function(c){switch(c.label){case 0:var t,n;t=Ml(function(M){var b,e,z,o,p,c;return(0,MB.__generator)(this,function(t){switch(t.label){case 0:(b=new Headers).append("Content-Type","application/x-www-form-urlencoded"),(e=new URLSearchParams).append("code",M),e.append("grant_type","authorization_code"),e.append("redirect_uri","https://greg.strukturart.com/index.html"),e.append("client_id","762086220505-f0kij4nt279nqn21ukokm06j0jge2ngl.apps.googleusercontent.com"),e.append("client_secret","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"),z={method:"POST",headers:b,body:e,redirect:"follow"},t.label=1;case 1:return t.trys.push([1,6,,7]),[4,fetch("https://oauth2.googleapis.com/token",z)];case 2:if((o=t.sent()).ok)return[3,4];return[4,o.text()];case 3:throw p=t.sent(),Error("Token exchange failed: ".concat(o.statusText,". Details: ").concat(p));case 4:return[4,o.json()];case 5:return[2,t.sent()];case 6:throw console.error("Error fetching the token:",c=t.sent()),c;case 7:return[2]}})}),e=function(M){return t.apply(this,arguments)},n=Ml(function(M,e){var z,o;return(0,MB.__generator)(this,function(p){switch(p.label){case 0:return p.trys.push([0,3,,4]),[4,b(Mv).getItem("accounts")];case 1:return(z=p.sent()||[]).push({server_url:"https://apidata.googleusercontent.com/caldav/v2/",tokens:M,authorizationCode:e,name:"Google",id:MT(32),type:"oauth"}),[4,b(Mv).setItem("accounts",z)];case 2:return p.sent(),setTimeout(function(){oG(),localStorage.setItem("oauth_callback","true")},3e3),[3,4];case 3:return o=p.sent(),alert("Error saving account: "+o.message),[3,4];case 4:return[2]}})}),z=function(M,b){return n.apply(this,arguments)},c.label=1;case 1:return c.trys.push([1,4,,5]),[4,e(M)];case 2:return o=c.sent(),[4,z(o,M)];case 3:return c.sent(),[3,5];case 4:return p=c.sent(),alert("OAuth process failed: "+p.message),[3,5];case 5:return[2]}})}),function(M){return j.apply(this,arguments)}),cc=!1,ct=!1;oD.addEventListener("message",function(M){if(M.data.oauth_success){var e=M.data.oauth_success.data;e&&cp(e)}if("parse"==M.data.action){Ma=Date.now(),ct=!0;try{document.getElementById("icon-waiting").style.visibility="visible"}catch(M){}!1!==M.data.content.parsed_data&&(0===o4.length||-1===o4.indexOf(M.data.content.parsed_data.calendar_name))&&(oP.push(M.data.content.parsed_data),M.data.content.callback&&oG(),M.data.content.raw_data&&(o7.data.push({uid:M.data.content.uid,data:M.data.content.raw_data}),b(Mv).setItem("local_account",o7).then(function(){oG()}).catch(function(){}))),!1==cc&&cn()}if("error"==M.data.action)try{document.getElementById("icon-waiting").style.visibility="hidden"}catch(M){}});var cn=function(){Mr=setInterval(function(){if(cc=!0,!ct)return!1;if(Date.now()-Ma>=400){try{document.getElementById("icon-waiting").style.visibility="hidden"}catch(M){}ct=!1,cc=!1,pM(pR,ph),MC(oP,"dateStartUnix","number"),clearInterval(Mr)}},100)};try{navigator.mozSetMessageHandler("activity",function(M){var b=M.source;"view"==b.name&&(pP=b.data.url,Mj("please open the subscriptions page and store the values",15e3),MH())})}catch(M){}}(); \ No newline at end of file diff --git a/docs/manifest.webmanifest b/docs/manifest.webmanifest index 2ce37b9c..84722bf7 100644 --- a/docs/manifest.webmanifest +++ b/docs/manifest.webmanifest @@ -24,7 +24,7 @@ ], "b2g_features": { - "version": "3.0.678", + "version": "3.0.679", "id": "greg", "subtitle": "easy to use calendar", "core": true,