From b279e876f0669fc2ada35d20ac7c266329ce419e Mon Sep 17 00:00:00 2001 From: teomrd Date: Sat, 2 Nov 2024 12:36:56 +0000 Subject: [PATCH] deploy: f0ea0e0800a3c70587b430e35ec3be4c9ccb53e4 --- index.js | 4 ++-- service-worker.js | 2 +- version | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index ecf0c99..4381eb3 100644 --- a/index.js +++ b/index.js @@ -132,7 +132,7 @@ var Zr=Object.create;var ze=Object.defineProperty;var Xr=Object.getOwnPropertyDe

& Ctrl+P: to format a JSON doc

`,100),localStorage.setItem("miropad.user",new Date().toLocaleDateString())},jt=uo;var co={set:function(o,r){return localStorage.setItem(o,r),this},update:function(o,r){let e=JSON.parse(this.get(o));return localStorage.setItem(o,JSON.stringify({...e,...r})),this},remove:function(o){return localStorage.removeItem(o),this},get:function(o){return ue(o)?o.reduce((r,e)=>({...r,[e]:this.get(e)}),{}):localStorage.getItem(o)},parse:function(o){let r=this.get(o);return JSON.parse(r)},getDictionary:function(){let o=localStorage.getItem("__dictionary__");return o?JSON.parse(o):[]},removeFromDictionary:function(o){let e=this.getDictionary().filter(a=>a!==o);localStorage.setItem("__dictionary__",JSON.stringify(e))},saveToDictionary:async function(o){if(o.length)try{let r=o.toLowerCase().replace(/[^a-zA-Zά-ώΑ-Ω]/g," "),e=await this.getDictionary(),a=[...r.split(" ").filter(h=>h.length>3),...e],s=[...new Set(a)];localStorage.setItem("__dictionary__",JSON.stringify(s))}catch(r){M.error(`\u{1F631} Something went wrong while trying to save to local storage ${r}`)}else M.warning("\u{1F615} Nothing to save!");return this}},S=co;var te={github:{client_id:"70c1955dfe4914c52c10",request_state:"miro-pad"},auth_service:"https://vercel-api-phi.vercel.app/api/auth",mail_service:{api:"https://vercel-api-phi.vercel.app/api/mail",signature:`Theo Mironidis
Software Engineer
- https://teomrd.github.io`},file_service:{api:"https://vercel-api-phi.vercel.app/api/upload"}};var Me=(o,r=S.get("authToken"))=>fetch(`https://api.github.com/gists/${o}`,{headers:{Authorization:`token ${r}`}}).then(e=>{if(!e.ok)throw Error(e.statusText);return e.json()}),Nt=(o=S.get("authToken"))=>fetch("https://api.github.com/gists",{headers:{Authorization:`token ${o}`}}).then(r=>{if(!r.ok)throw Error(r.statusText);return r.json()}),Bt=async(o,r=S.get("gistId"),e=S.get("authToken"))=>{let a=await fetch(`https://api.github.com/gists/${r}`,{method:"PATCH",headers:{Authorization:`token ${e}`,Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify({files:{[o]:null},description:"MiroPad Gist",public:!1})});if(!a.ok)throw new Error(a.statusText);let s=await a.json();return M.info(`${o} deleted on Gist!`),s},It=(o=ee(),r=S.get("gistId"),e=S.get("authToken"))=>{if(r&&e){let a=o.reduce((s,{id:h,text:g,deleted:y})=>({...s,[h]:y?null:{content:g}}),{});return fetch(`https://api.github.com/gists/${r}`,{method:"PATCH",headers:{Authorization:`token ${e}`,Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify({files:a,description:"MiroPad Gist",public:!1})}).then(s=>{if(!s.ok)throw new Error(s.statusText);return s.json()}).then(s=>(o.map(({id:h,deleted:g})=>{g&&localStorage.removeItem(h)}),s))}},Ot=async(o=S.get("authToken"))=>{let e=ee().reduce((h,g)=>({...h,[g.id]:{content:g.text}}),{}),a=await fetch("https://api.github.com/gists",{method:"POST",headers:{Authorization:`token ${o}`,Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify({files:e,description:"MiroPad Gist",public:!1})});if(!a.ok)throw Error(a.statusText);return await a.json()},Ft=(o,r)=>fetch(`${te.auth_service}?state=${r}&code=${o}`,{headers:{Accept:"application/json","Content-Type":"application/json"}}).then(e=>{if(!e.ok)throw Error(e.statusText);return e.json()}).then(e=>e),$t=async({note:o,token:r=S.get("authToken")})=>{let e=await fetch("https://api.github.com/gists",{method:"POST",headers:{Authorization:`token ${r}`,Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify({files:{[o.id]:{content:o.text}},description:"MiroPad Gist",public:!0})});if(!e.ok)throw Error(e.statusText);return await e.json()};var Cd=new Uint8Array(0);function Gt(o,r){if(o===r)return!0;if(o.byteLength!==r.byteLength)return!1;for(let e=0;e=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),a=0;a>>0,d=new Uint8Array(t);q!==Z;){for(var n=L[q],i=0,l=t-1;(n!==0||i>>0,d[l]=n%y>>>0,n=n/y>>>0;if(n!==0)throw new Error("Non-zero carry");X=i,q++}for(var f=t-X;f!==t&&d[f]===0;)f++;for(var c=x.repeat(O);f>>0,t=new Uint8Array(Z);L[O];){var d=e[L.charCodeAt(O)];if(d===255)return;for(var n=0,i=Z-1;(d!==0||n>>0,t[i]=d%256>>>0,d=d/256>>>0;if(d!==0)throw new Error("Non-zero carry");q=n,O++}if(L[O]!==" "){for(var l=Z-q;l!==Z&&t[l]===0;)l++;for(var f=new Uint8Array(X+(Z-l)),c=X;l!==Z;)f[c++]=t[l++];return f}}}function H(L){var O=V(L);if(O)return O;throw new Error(`Non-${r} character`)}return{encode:F,decodeUnsafe:V,decode:H}}var fo=lo,ho=fo,Vt=ho;var Ke=class{constructor(r,e,a){B(this,"name");B(this,"prefix");B(this,"baseEncode");this.name=r,this.prefix=e,this.baseEncode=a}encode(r){if(r instanceof Uint8Array)return`${this.prefix}${this.baseEncode(r)}`;throw Error("Unknown type, must be binary type")}},Ye=class{constructor(r,e,a){B(this,"name");B(this,"prefix");B(this,"baseDecode");B(this,"prefixCodePoint");this.name=r,this.prefix=e;let s=e.codePointAt(0);if(s===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=s,this.baseDecode=a}decode(r){if(typeof r=="string"){if(r.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(r)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(r.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(r){return Ht(this,r)}},Ze=class{constructor(r){B(this,"decoders");this.decoders=r}or(r){return Ht(this,r)}decode(r){let e=r[0],a=this.decoders[e];if(a!=null)return a.decode(r);throw RangeError(`Unable to decode multibase string ${JSON.stringify(r)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function Ht(o,r){return new Ze({...o.decoders??{[o.prefix]:o},...r.decoders??{[r.prefix]:r}})}var Xe=class{constructor(r,e,a,s){B(this,"name");B(this,"prefix");B(this,"baseEncode");B(this,"baseDecode");B(this,"encoder");B(this,"decoder");this.name=r,this.prefix=e,this.baseEncode=a,this.baseDecode=s,this.encoder=new Ke(r,e,a),this.decoder=new Ye(r,e,s)}encode(r){return this.encoder.encode(r)}decode(r){return this.decoder.decode(r)}};function Ut({name:o,prefix:r,encode:e,decode:a}){return new Xe(o,r,e,a)}function fe({name:o,prefix:r,alphabet:e}){let{encode:a,decode:s}=Vt(e,o);return Ut({prefix:r,name:o,encode:a,decode:h=>le(s(h))})}function po(o,r,e,a){let s={};for(let E=0;E=8&&(y-=8,g[P++]=255&x>>y)}if(y>=e||255&x<<8-y)throw new SyntaxError("Unexpected end of data");return g}function mo(o,r,e){let a=r[r.length-1]==="=",s=(1<e;)g-=e,h+=r[s&y>>g];if(g!==0&&(h+=r[s&y<=yo;)r[e++]=o&255|Rt,o/=128;for(;o&wo;)r[e++]=o&255|Rt,o>>>=7;return r[e]=o|0,qt.bytes=e-a+1,r}var vo=Qe,ko=128,Wt=127;function Qe(o,a){var e=0,a=a||0,s=0,h=a,g,y=o.length;do{if(h>=y)throw Qe.bytes=0,new RangeError("Could not decode varint");g=o[h++],e+=s<28?(g&Wt)<=ko);return Qe.bytes=h-a,e}var _o=Math.pow(2,7),xo=Math.pow(2,14),Co=Math.pow(2,21),So=Math.pow(2,28),zo=Math.pow(2,35),Mo=Math.pow(2,42),To=Math.pow(2,49),Po=Math.pow(2,56),Eo=Math.pow(2,63),Ao=function(o){return o<_o?1:o{let[F,V]=ve(r.subarray(e));return e+=V,F},s=a(),h=_e;if(s===18?(s=0,e=0):h=a(),s!==0&&s!==1)throw new RangeError(`Invalid CID version ${s}`);let g=e,y=a(),x=a(),P=e+x,E=P-g;return{version:s,codec:h,multihashCode:y,digestSize:x,multihashSize:E,size:P}}static parse(r,e){let[a,s]=jo(r,e),h=o.decode(s);if(h.version===0&&r[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return et(h).set(a,r),h}};function jo(o,r){switch(o[0]){case"Q":{let e=r??oe;return[oe.prefix,e.decode(`${oe.prefix}${o}`)]}case oe.prefix:{let e=r??oe;return[oe.prefix,e.decode(o)]}case we.prefix:{let e=r??we;return[we.prefix,e.decode(o)]}case Te.prefix:{let e=r??Te;return[Te.prefix,e.decode(o)]}default:{if(r==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[o[0],r.decode(o)]}}}function No(o,r,e){let{prefix:a}=e;if(a!==oe.prefix)throw Error(`Cannot string encode V0 in ${e.name} encoding`);let s=r.get(a);if(s==null){let h=e.encode(o).slice(1);return r.set(a,h),h}else return s}function Bo(o,r,e){let{prefix:a}=e,s=r.get(a);if(s==null){let h=e.encode(o);return r.set(a,h),h}else return s}var _e=112,Io=18;function er(o,r,e){let a=pe(o),s=a+pe(r),h=new Uint8Array(s+e.byteLength);return he(o,h,0),he(r,h,a),h.set(e,s),h}var Oo=Symbol.for("@ipld/js-cid/CID");var Fo=new TextEncoder,na=new TextDecoder;var rr=512;function or(o){return Fo.encode(JSON.stringify(o))}function rt({name:o,code:r,encode:e}){return new tt(o,r,e)}var tt=class{constructor(r,e,a){B(this,"name");B(this,"code");B(this,"encode");this.name=r,this.code=e,this.encode=a}digest(r){if(r instanceof Uint8Array){let e=this.encode(r);return e instanceof Uint8Array?ke(this.code,e):e.then(a=>ke(this.code,a))}else throw Error("Unknown type, must be binary type")}};function nr(o){return async r=>new Uint8Array(await crypto.subtle.digest(o,r))}var dr=rt({name:"sha2-256",code:18,encode:nr("SHA-256")}),sa=rt({name:"sha2-512",code:19,encode:nr("SHA-512")});var Go=async o=>{let r=or(o),e=await dr.digest(r);return Pe.create(1,rr,e).toString()},Ee=Go;var Vo=o=>{try{JSON.parse(o)}catch{return!1}return!0},Ae=Vo;var ar=()=>document.title.split("|")[0],ot=o=>{let r=ar();document.title=r.trim()+" | "+o.trim(),m(".title h3").html(o.trim())},De=()=>{let o=ar();document.title=o,m("title").innerHTML("\u270D\uFE0F MiroPad v3.1.4"),m(".title h3").innerHTML('\u270D\uFE0F MiroPad v3.1.4')};var A={baseUrl:`${globalThis.location.origin}${globalThis.location.pathname}`,get:function(){return globalThis.location.href},getPageId:function(o=globalThis.location.href){return new URL(o).hash.slice(1).split("?")[0]||null},getSearchParams:function(o=globalThis.location.href){let a=new URL(o).href.split("?")[1]||"";return new URLSearchParams(a)},getParamsObject:function(o=globalThis.location.href){let r=this.getSearchParams(o),e={};for(let a of r.keys())e={...e,[a]:this.getSearchParam(a,o)};return e},getSearchParam(o,r=globalThis.location.href){return this.getSearchParams(r).get(o)},deleteParam:function(o){let r=this.getSearchParams();Array.isArray(o)?o.forEach(s=>{r.delete(s)}):r.delete(o);let{pathname:e}=globalThis.location,a=this.getPageId();return globalThis.location.assign(`${a?`#${a}`:e}${r.toString()?`?${r.toString()}`:""}`)},set:function(o=this.getPageId(),r=this.getParamsObject()){let e={...this.getParamsObject(),...r},a=new URLSearchParams(e);return globalThis.location.assign(`#${o}?${a.toString()}`)}};var se=(o=!0)=>{o?(m("#save").removeClass("unsaved"),m("#logo").removeClass("unsaved")):(m("#save").addClass("unsaved"),m("#logo").addClass("unsaved"))};var ir=o=>{let r=encodeURIComponent(o);if(r.length===0)throw new Error("You need to start with a valid title for your note!");return r},Le=o=>{let r=ur(o),e=G(r);if(e){let{dateCreated:a}=e;return a}throw new Error(`Note "${o}" cannot found!`)},Ho=o=>{let r=G(o);r&&localStorage.setItem(o,JSON.stringify({title:r.title,deleted:!0,revisions:r.revisions}))},G=(o=A.getPageId(),r)=>{let e;try{if(e=JSON.parse(S.get(o)),!e.revisions)throw new Error("This is not a note!")}catch{return null}let a=e?Object.values(e.revisions).reduce((h,g)=>g.dateCreated>h.dateCreated?g:h,{dateCreated:0}):{},s=r?e.revisions[r]:a;return o?{...e,id:o,...s||{},numberOfRevisions:e&&e.revisions?Object.keys(e.revisions).length:void 0,title:e.title}:null},sr=o=>{let r=G();r&&(S.update(r.id,{disableSync:o}),M.info(`"${r.title}" cloud sync ${o?"disabled \u{1F636}":"enabled \u26A1\uFE0F"}`))},je=(o=A.getPageId())=>{if(o){let r=A.getSearchParam("v")||void 0,e=G(void 0,r);e&&(m("#revisions").html(`${e.numberOfRevisions} revision${e.numberOfRevisions>1?"s":""}`),ot(e.title),m(".terminal").setValue(e.text)),e||M.error("404 Note not found \u{1F937}\u200D\u2642\uFE0F")}},Ne=()=>{location.hash="",De(),m("#revisions").html(""),m(".terminal").setValue("").focus(),se()},ge=(o="")=>o.split(` + https://teomrd.github.io`},file_service:{api:"https://vercel-api-phi.vercel.app/api/upload"}};var Me=(o,r=S.get("authToken"))=>fetch(`https://api.github.com/gists/${o}`,{headers:{Authorization:`token ${r}`}}).then(e=>{if(!e.ok)throw Error(e.statusText);return e.json()}),Nt=(o=S.get("authToken"))=>fetch("https://api.github.com/gists",{headers:{Authorization:`token ${o}`}}).then(r=>{if(!r.ok)throw Error(r.statusText);return r.json()}),Bt=async(o,r=S.get("gistId"),e=S.get("authToken"))=>{let a=await fetch(`https://api.github.com/gists/${r}`,{method:"PATCH",headers:{Authorization:`token ${e}`,Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify({files:{[o]:null},description:"MiroPad Gist",public:!1})});if(!a.ok)throw new Error(a.statusText);let s=await a.json();return M.info(`${o} deleted on Gist!`),s},It=(o=ee(),r=S.get("gistId"),e=S.get("authToken"))=>{if(r&&e){let a=o.reduce((s,{id:h,text:g,deleted:y})=>({...s,[h]:y?null:{content:g}}),{});return fetch(`https://api.github.com/gists/${r}`,{method:"PATCH",headers:{Authorization:`token ${e}`,Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify({files:a,description:"MiroPad Gist",public:!1})}).then(s=>{if(!s.ok)throw new Error(s.statusText);return s.json()}).then(s=>(o.map(({id:h,deleted:g})=>{g&&localStorage.removeItem(h)}),s))}},Ot=async(o=S.get("authToken"))=>{let e=ee().reduce((h,g)=>({...h,[g.id]:{content:g.text}}),{}),a=await fetch("https://api.github.com/gists",{method:"POST",headers:{Authorization:`token ${o}`,Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify({files:e,description:"MiroPad Gist",public:!1})});if(!a.ok)throw Error(a.statusText);return await a.json()},Ft=(o,r)=>fetch(`${te.auth_service}?state=${r}&code=${o}`,{headers:{Accept:"application/json","Content-Type":"application/json"}}).then(e=>{if(!e.ok)throw Error(e.statusText);return e.json()}).then(e=>e),$t=async({note:o,token:r=S.get("authToken")})=>{let e=await fetch("https://api.github.com/gists",{method:"POST",headers:{Authorization:`token ${r}`,Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify({files:{[o.id]:{content:o.text}},description:"MiroPad Gist",public:!0})});if(!e.ok)throw Error(e.statusText);return await e.json()};var Cd=new Uint8Array(0);function Gt(o,r){if(o===r)return!0;if(o.byteLength!==r.byteLength)return!1;for(let e=0;e=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),a=0;a>>0,d=new Uint8Array(t);q!==Z;){for(var n=L[q],i=0,l=t-1;(n!==0||i>>0,d[l]=n%y>>>0,n=n/y>>>0;if(n!==0)throw new Error("Non-zero carry");X=i,q++}for(var f=t-X;f!==t&&d[f]===0;)f++;for(var c=x.repeat(O);f>>0,t=new Uint8Array(Z);L[O];){var d=e[L.charCodeAt(O)];if(d===255)return;for(var n=0,i=Z-1;(d!==0||n>>0,t[i]=d%256>>>0,d=d/256>>>0;if(d!==0)throw new Error("Non-zero carry");q=n,O++}if(L[O]!==" "){for(var l=Z-q;l!==Z&&t[l]===0;)l++;for(var f=new Uint8Array(X+(Z-l)),c=X;l!==Z;)f[c++]=t[l++];return f}}}function H(L){var O=V(L);if(O)return O;throw new Error(`Non-${r} character`)}return{encode:F,decodeUnsafe:V,decode:H}}var fo=lo,ho=fo,Vt=ho;var Ke=class{constructor(r,e,a){B(this,"name");B(this,"prefix");B(this,"baseEncode");this.name=r,this.prefix=e,this.baseEncode=a}encode(r){if(r instanceof Uint8Array)return`${this.prefix}${this.baseEncode(r)}`;throw Error("Unknown type, must be binary type")}},Ye=class{constructor(r,e,a){B(this,"name");B(this,"prefix");B(this,"baseDecode");B(this,"prefixCodePoint");this.name=r,this.prefix=e;let s=e.codePointAt(0);if(s===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=s,this.baseDecode=a}decode(r){if(typeof r=="string"){if(r.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(r)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(r.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(r){return Ht(this,r)}},Ze=class{constructor(r){B(this,"decoders");this.decoders=r}or(r){return Ht(this,r)}decode(r){let e=r[0],a=this.decoders[e];if(a!=null)return a.decode(r);throw RangeError(`Unable to decode multibase string ${JSON.stringify(r)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function Ht(o,r){return new Ze({...o.decoders??{[o.prefix]:o},...r.decoders??{[r.prefix]:r}})}var Xe=class{constructor(r,e,a,s){B(this,"name");B(this,"prefix");B(this,"baseEncode");B(this,"baseDecode");B(this,"encoder");B(this,"decoder");this.name=r,this.prefix=e,this.baseEncode=a,this.baseDecode=s,this.encoder=new Ke(r,e,a),this.decoder=new Ye(r,e,s)}encode(r){return this.encoder.encode(r)}decode(r){return this.decoder.decode(r)}};function Ut({name:o,prefix:r,encode:e,decode:a}){return new Xe(o,r,e,a)}function fe({name:o,prefix:r,alphabet:e}){let{encode:a,decode:s}=Vt(e,o);return Ut({prefix:r,name:o,encode:a,decode:h=>le(s(h))})}function po(o,r,e,a){let s={};for(let E=0;E=8&&(y-=8,g[P++]=255&x>>y)}if(y>=e||255&x<<8-y)throw new SyntaxError("Unexpected end of data");return g}function mo(o,r,e){let a=r[r.length-1]==="=",s=(1<e;)g-=e,h+=r[s&y>>g];if(g!==0&&(h+=r[s&y<=yo;)r[e++]=o&255|Rt,o/=128;for(;o&wo;)r[e++]=o&255|Rt,o>>>=7;return r[e]=o|0,qt.bytes=e-a+1,r}var vo=Qe,ko=128,Wt=127;function Qe(o,a){var e=0,a=a||0,s=0,h=a,g,y=o.length;do{if(h>=y)throw Qe.bytes=0,new RangeError("Could not decode varint");g=o[h++],e+=s<28?(g&Wt)<=ko);return Qe.bytes=h-a,e}var _o=Math.pow(2,7),xo=Math.pow(2,14),Co=Math.pow(2,21),So=Math.pow(2,28),zo=Math.pow(2,35),Mo=Math.pow(2,42),To=Math.pow(2,49),Po=Math.pow(2,56),Eo=Math.pow(2,63),Ao=function(o){return o<_o?1:o{let[F,V]=ve(r.subarray(e));return e+=V,F},s=a(),h=_e;if(s===18?(s=0,e=0):h=a(),s!==0&&s!==1)throw new RangeError(`Invalid CID version ${s}`);let g=e,y=a(),x=a(),P=e+x,E=P-g;return{version:s,codec:h,multihashCode:y,digestSize:x,multihashSize:E,size:P}}static parse(r,e){let[a,s]=jo(r,e),h=o.decode(s);if(h.version===0&&r[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return et(h).set(a,r),h}};function jo(o,r){switch(o[0]){case"Q":{let e=r??oe;return[oe.prefix,e.decode(`${oe.prefix}${o}`)]}case oe.prefix:{let e=r??oe;return[oe.prefix,e.decode(o)]}case we.prefix:{let e=r??we;return[we.prefix,e.decode(o)]}case Te.prefix:{let e=r??Te;return[Te.prefix,e.decode(o)]}default:{if(r==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[o[0],r.decode(o)]}}}function No(o,r,e){let{prefix:a}=e;if(a!==oe.prefix)throw Error(`Cannot string encode V0 in ${e.name} encoding`);let s=r.get(a);if(s==null){let h=e.encode(o).slice(1);return r.set(a,h),h}else return s}function Bo(o,r,e){let{prefix:a}=e,s=r.get(a);if(s==null){let h=e.encode(o);return r.set(a,h),h}else return s}var _e=112,Io=18;function er(o,r,e){let a=pe(o),s=a+pe(r),h=new Uint8Array(s+e.byteLength);return he(o,h,0),he(r,h,a),h.set(e,s),h}var Oo=Symbol.for("@ipld/js-cid/CID");var Fo=new TextEncoder,na=new TextDecoder;var rr=512;function or(o){return Fo.encode(JSON.stringify(o))}function rt({name:o,code:r,encode:e}){return new tt(o,r,e)}var tt=class{constructor(r,e,a){B(this,"name");B(this,"code");B(this,"encode");this.name=r,this.code=e,this.encode=a}digest(r){if(r instanceof Uint8Array){let e=this.encode(r);return e instanceof Uint8Array?ke(this.code,e):e.then(a=>ke(this.code,a))}else throw Error("Unknown type, must be binary type")}};function nr(o){return async r=>new Uint8Array(await crypto.subtle.digest(o,r))}var dr=rt({name:"sha2-256",code:18,encode:nr("SHA-256")}),sa=rt({name:"sha2-512",code:19,encode:nr("SHA-512")});var Go=async o=>{let r=or(o),e=await dr.digest(r);return Pe.create(1,rr,e).toString()},Ee=Go;var Vo=o=>{try{JSON.parse(o)}catch{return!1}return!0},Ae=Vo;var ar=()=>document.title.split("|")[0],ot=o=>{let r=ar();document.title=r.trim()+" | "+o.trim(),m(".title h3").html(o.trim())},De=()=>{let o=ar();document.title=o,m("title").innerHTML("\u270D\uFE0F MiroPad v3.1.5"),m(".title h3").innerHTML('\u270D\uFE0F MiroPad v3.1.5')};var A={baseUrl:`${globalThis.location.origin}${globalThis.location.pathname}`,get:function(){return globalThis.location.href},getPageId:function(o=globalThis.location.href){return new URL(o).hash.slice(1).split("?")[0]||null},getSearchParams:function(o=globalThis.location.href){let a=new URL(o).href.split("?")[1]||"";return new URLSearchParams(a)},getParamsObject:function(o=globalThis.location.href){let r=this.getSearchParams(o),e={};for(let a of r.keys())e={...e,[a]:this.getSearchParam(a,o)};return e},getSearchParam(o,r=globalThis.location.href){return this.getSearchParams(r).get(o)},deleteParam:function(o){let r=this.getSearchParams();Array.isArray(o)?o.forEach(s=>{r.delete(s)}):r.delete(o);let{pathname:e}=globalThis.location,a=this.getPageId();return globalThis.location.assign(`${a?`#${a}`:e}${r.toString()?`?${r.toString()}`:""}`)},set:function(o=this.getPageId(),r=this.getParamsObject()){let e={...this.getParamsObject(),...r},a=new URLSearchParams(e);return globalThis.location.assign(`#${o}?${a.toString()}`)}};var se=(o=!0)=>{o?(m("#save").removeClass("unsaved"),m("#logo").removeClass("unsaved")):(m("#save").addClass("unsaved"),m("#logo").addClass("unsaved"))};var ir=o=>{let r=encodeURIComponent(o);if(r.length===0)throw new Error("You need to start with a valid title for your note!");return r},Le=o=>{let r=ur(o),e=G(r);if(e){let{dateCreated:a}=e;return a}throw new Error(`Note "${o}" cannot found!`)},Ho=o=>{let r=G(o);r&&localStorage.setItem(o,JSON.stringify({title:r.title,deleted:!0,revisions:r.revisions}))},G=(o=A.getPageId(),r)=>{let e;try{if(e=JSON.parse(S.get(o)),!e.revisions)throw new Error("This is not a note!")}catch{return null}let a=e?Object.values(e.revisions).reduce((h,g)=>g.dateCreated>h.dateCreated?g:h,{dateCreated:0}):{},s=r?e.revisions[r]:a;return o?{...e,id:o,...s||{},numberOfRevisions:e&&e.revisions?Object.keys(e.revisions).length:void 0,title:e.title}:null},sr=o=>{let r=G();r&&(S.update(r.id,{disableSync:o}),M.info(`"${r.title}" cloud sync ${o?"disabled \u{1F636}":"enabled \u26A1\uFE0F"}`))},je=(o=A.getPageId())=>{if(o){let r=A.getSearchParam("v")||void 0,e=G(void 0,r);e&&(m("#revisions").html(`${e.numberOfRevisions} revision${e.numberOfRevisions>1?"s":""}`),ot(e.title),m(".terminal").setValue(e.text)),e||M.error("404 Note not found \u{1F937}\u200D\u2642\uFE0F")}},Ne=()=>{location.hash="",De(),m("#revisions").html(""),m(".terminal").setValue("").focus(),se()},ge=(o="")=>o.split(` `)[0].trim().replace("#","").trim(),ur=o=>{let r=ge(o);return ir(r)},cr=async o=>{if(o.length){let r=ur(o),e=ge(o),a=G(r);if(a===null)return Be(o);let{text:s}=a,h=await Ee(o),g=await Ee(s);if(h===g)return;let y=S.get(r),x=JSON.parse(y);S.set(r,JSON.stringify({...x,title:e,revisions:{...x&&x.revisions||{},[h]:{dateCreated:Date.now(),text:o}}}))}},Be=async(o=m(".terminal").getValue())=>{if(await S.saveToDictionary(o),o.length){let r=await Ee(o);try{let e=o.split(` `)[0].trim().replace("#","").trim();ot(e);let a=ir(e),s=S.get(a),h=JSON.parse(s);S.set(a,JSON.stringify({...h,title:e,lines:o.split(` `),revisions:{...h&&h.revisions||{},[r]:{dateCreated:Date.now(),text:o}}})),A.set(a,{v:r}),S.set("lastLocalUpdate",new Date),M.success("\u{1F44C} Note saved!"),se()}catch(e){M.error(`\u{1F631} Something went wrong while trying to save to local storage ${e}`)}}else M.warning("\u{1F615} Nothing to save!")},ee=({includeDeleted:o=!1}={})=>Object.entries(localStorage).filter(([,r])=>typeof r=="string").filter(([r,e])=>!r.startsWith("__")&&Ae(e)).map(([r,e])=>[r,JSON.parse(e)]).filter(([,r])=>!!r.title).reduce((r,[e])=>[...r,G(e)],[]).filter(({deleted:r})=>o?!0:!r),lr=(o=null)=>o?ee().map(({id:e})=>G(e)).filter(e=>e!==null).filter(({text:e})=>e.toLowerCase().includes(o.toLowerCase()))[0]:void 0,Ie=()=>{if(confirm("Are you sure you want do that?")){let r=G();Ne(),r&&r.id&&(Bt(r.id),Ho(r.id))}j.hide()};var fr=()=>!!S.get("authToken");var de=({title:o,secondary:r,onclick:e,onSecondaryClick:a,icon:s},h=!1)=>{let g=document.createElement("LI");if(g.className=h?"selected":"",s){let P=s.cloneNode(!0);g.appendChild(P)}let y=ce(o)?o:document.createTextNode(o);y.onclick=e,g.appendChild(y);let x=document.createElement("span");if(r){x.className="secondary";let P=ce(r)?r:document.createTextNode(r);P.onclick=a,x.appendChild(P)}return g.appendChild(x),g};var hr=(o,r)=>{let e=o.toLowerCase().split(r),a=0;return e.reduce((s,h,g)=>[...s,...g===0?[h]:[r,h]],[]).filter(s=>s!=="").map(s=>{a=a+s.length;let h=a-s.length,g=h+s.length;return o.slice(h,g)})};var pr=o=>{let r=document.createElement("mark");return r.appendChild(document.createTextNode(o)),r},ne=({content:o="",highlight:r=""})=>{let e=document.createElement("div"),a=o.split(" "),s=r.toLowerCase().split(" ");return r.trim()===""?(e.appendChild(document.createTextNode(o)),e):(a.map(h=>{let g=s.map(y=>h.toLocaleLowerCase().includes(y)?y:void 0).filter(y=>y!==void 0);return{word:h,matches:g}}).forEach(({word:h,matches:g})=>{if(g.length>0){let y=g[0];if(h===y)e.appendChild(pr(` ${h}`));else{let P=hr(h,y).map(E=>E.toLowerCase()===y?pr(E):document.createTextNode(E));e.appendChild(document.createTextNode(" ")),P.forEach(E=>{e.appendChild(E)})}}else e.appendChild(document.createTextNode(` ${h} `))}),e)};var mr=()=>(M.info("You need to be authenticated!"),j.hide(),globalThis.location.replace(`https://github.com/login/oauth/authorize?client_id=${te.github.client_id}&scope=gist&state=${te.github.request_state}`)),gr=async o=>{M.info("Downloading my Gists!");let r=await Nt(o);j.setState({mode:j.getModes().gists}),M.info("Select Gist to sync with");let e=r.sort((s,h)=>new Date(h.updated_at).getTime()-new Date(s.updated_at).getTime()).map(({description:s,updated_at:h,id:g})=>({title:ne({content:`${s}(${g})`}),secondary:h,onclick:async()=>{await S.set("gistId",g),M.success(`${s}(${g}) selected for synchronization!`),xe(),j.hide()}})),a=de([{title:"Create a new Gist",onclick:async()=>{M.info("Syncing your MiroPads to a new Gist");try{let{id:s}=await Ot();S.set("gistId",s),M.success("MiroPads synced to a new Gist \u{1F389}")}catch(s){M.error(s.message)}j.hide()}},...e]);m("#commands").html(""),m("#commands").append(a)},xe=async(o=S.get("gistId"))=>{if(S.get("authToken")&&o){m("#logo").addClass("loading");let{files:e}=await Me(o);Object.values(e).forEach(({content:a})=>{cr(a)}),S.set("lastSync",new Date),M.success("\u2B07 MiroPad synced \u2705"),m("#logo").removeClass("loading")}},br=async()=>{let o=A.getSearchParam("code"),r=A.getSearchParam("state");if(o&&r){m("#logo").addClass("loading"),M.info("\u{1F510} Authenticating...");try{let{token:e}=await Ft(o,r);S.set("authToken",e),M.info("\u26F3 You have been authenticated!"),A.deleteParam(["code","state"])}catch(e){M.error(e.message)}m("#logo").removeClass("loading")}};var Uo=async(o="no-titled")=>{let r={suggestedName:`${o}`,types:[{description:"MiroPad text notes",accept:{"text/plain":[".miropad"]}}]};return await globalThis.showSaveFilePicker(r)},Ro=async(o,r)=>{let e=await o.createWritable();await e.write(r),await e.close()},wr=async(o,r)=>{try{let e=await Uo(r);await Ro(e,o)}catch{M.error("An error occurred trying to save the file.");return}},yr=(()=>{let o=document.createElement("a");return document.body.appendChild(o),o.setAttribute("style","display: none"),(r,e=`MiroPad-${new Date().toISOString()}.json`)=>{let a=JSON.stringify(r),s=new Blob([a],{type:"octet/stream"}),h=globalThis.URL.createObjectURL(s);o.href=h,o.download=e,o.click(),globalThis.URL.revokeObjectURL(h)}})();var _r=Lt(kr()),xr=new _r.default.Converter({tasklists:!0,underline:!0,emoji:!0,simplifiedAutoLink:!0,tables:!0,openLinksInNewWindow:!0});xr.setFlavor("github");var Fe=o=>xr.makeHtml(o);var nt=o=>{if(o.status.toString().slice(0,1)==="2")return o;throw new Error(o)},Wo=(o="")=>` @@ -169,7 +169,7 @@ var Zr=Object.create;var ze=Object.defineProperty;var Xr=Object.getOwnPropertyDe - `,qo=async(o,r,e="MiroPad note")=>{if(!o){M.error("\u{1F47B} No message to send, type something and try again! \u{1F913}");return}try{await fetch(`${te.mail_service.api}`,{method:"POST",headers:{"x-secret-token":S.get("MIROPAD_SECRET_TOKEN"),accept:"application/json","content-type":"application/json"},body:JSON.stringify({to:r,subject:e,html:Wo(o)})}).then(nt).then(a=>a.json()),M.success("Email sent \u{1F680}")}catch{M.error("Error not went through \u{1F4A5}! Check your credentials and try again!")}},Jo=()=>{let o=S.get("mail");if(o){let a=globalThis.prompt(`Mail ${o} again? (y)es/(no)`,"yeap");if(a===null)return a;if(a.slice(0,1).toLowerCase()==="y")return o}let r=globalThis.prompt("Where do you wanna send the mail to?"),e=globalThis.prompt("Do you wanna save that to your preferences for later on? (y)es/(no)","yeap");return e&&e.slice(0,1).toLowerCase()==="y"&&S.set("mail",r),r},Cr=o=>{let r=Jo();if(r===null){M.info("Sending mail cancelled \u{1F636}");return}M.info("Sending mail... \u{1F680}");let e=ge(o),a=Fe(o);qo(a,r,e)};var ae=async(o,r="\u{1F4CB} Copied to clipboard")=>{try{await navigator.clipboard.writeText(o),M.success(r)}catch(e){M.error(e.message)}};var $e=(o,r,e)=>{let a=ue(o)?o:[o],s=document.createElement("button");return s.setAttribute("type","button"),e&&s.setAttribute("id",e),a.forEach(h=>{typeof h=="string"?s.appendChild(document.createTextNode(h)):s.appendChild(h)}),s.onclick=h=>r(h),s};var Ko={view:m(".preview"),init:function(){return this.update(),m(".terminal").listen("input",()=>this.update()),!!A.getSearchParam("md")?this.view.show():this.view.hide(),this},autoLink:function(){let o=S.parse("__auto-links__"),r=Object.keys(o).map(s=>`${s}\\w+`).join("|"),e=new RegExp(`(${r})`,"g"),a=this.view.el.innerHTML.replace(e,s=>{let h=Object.keys(o).find(y=>s.startsWith(y)),g=o[h];return g.startsWith("http")?`${s}`:`${s}`});this.view.innerHTML(a)},update:function(){let md=m(".terminal").getValue();this.view.innerHTML(Fe(md)),this.autoLink();let{elements}=m("pre");Array.prototype.slice.call(elements).forEach(o=>{let r=$e("\u{1F4CB} Copy",async e=>{e.stopPropagation();let a=e.srcElement.previousSibling.innerHTML;await ae(a,"\u{1F4CB} Code copied to clipboard")});o.appendChild(r)}),m("code").listenAll("click",({innerHTML})=>{let result=eval(innerHTML);m(".console").show().innerHTML(result)}),m(".console").listen("click",async o=>{o.srcElement.classList.add("hidden");let r=o.srcElement.innerHTML;await ae(r,"\u{1F4CB} Code copied to clipboard")})},show:function(o=!0){this.view.show(),A.set(void 0,{md:o})},hide:function(){this.view.hide(),A.deleteParam("md")},toggle:function(o="true"){return A.getSearchParam("md")===o?this.hide():this.show(o),this}},ie=Ko;var Yo=o=>{let r=document.querySelector(o);if(Ae(r.value)){let e=JSON.stringify(JSON.parse(r.value),null,2);r.value=e,M.success("\u{1F44D} JSON value prettified")}else M.error("\u{1F627} Value is not in valid JSON format")},Sr=Yo;var zr=(o=1e3)=>new Promise(r=>{setTimeout(r,o)});var I=(o,r,e)=>{let a=document.createElement("IMG");return e&&a.classList.add(e),r&&a.setAttribute("alt",r),a.setAttribute("src",o),a};var dt={};$(dt,{default:()=>Xo});var Xo="./list-LK7OCHR7.svg";var be={};$(be,{default:()=>en});var en="./trash-RDL437QG.svg";var at={};$(at,{default:()=>rn});var rn="./checkmark-circle-JQ7ADSUI.svg";var it={};$(it,{default:()=>nn});var nn="./cloud-sync-F3RLGHML.svg";var st={};$(st,{default:()=>an});var an="./lighter-UBEI67LL.svg";var ut={};$(ut,{default:()=>un});var un="./enter-down-6TVO6OFR.svg";var ct={};$(ct,{default:()=>ln});var ln="./download-FVXMIYZ4.svg";var lt={};$(lt,{default:()=>hn});var hn="./envelope-Z2VRVSLR.svg";var ft={};$(ft,{default:()=>mn});var mn="./bug-36UGMUXT.svg";var ht={};$(ht,{default:()=>bn});var bn="./picture-3TDOSVS3.svg";var pt={};$(pt,{default:()=>yn});var yn="./printer-B7RMPYZC.svg";var mt={};$(mt,{default:()=>kn});var kn="./page-break-BLVP5QBQ.svg";var gt={};$(gt,{default:()=>xn});var xn="./frame-expand-CX6CNP53.svg";var bt={};$(bt,{default:()=>Sn});var Sn="./arrow-right-circle-2Q6EHM2H.svg";var wt={};$(wt,{default:()=>Mn});var Mn="./magic-wand-JQJ6EKRO.svg";var yt={};$(yt,{default:()=>Pn});var Pn="./rocket-AIY2RJJS.svg";var vt={};$(vt,{default:()=>An});var An="./spell-check-V6QYTGNT.svg";var kt={};$(kt,{default:()=>Ln});var Ln="./pencil-X3ZMY3QU.svg";var Ge={};$(Ge,{default:()=>Nn});var Nn="./exit-up-GH6BPN2X.svg";var _t={};$(_t,{default:()=>In});var In="./leaf-CGBE7XAJ.svg";var Mr=async()=>{try{let o=G(),r=A.get();await navigator.share({title:o?o.title:"\u270D\uFE0F MiroPad",text:o?o.text:"Temporary note keeping app for the browser",url:r})}catch(o){M.info(`${o.message}`)}};var On=()=>{let o=S.get("gistId");return S.get("authToken")?o?"Sync: Notes with my GitHub Gist":"Sync: Pick your Gist to sync with":"Sync: Authorize your GitHub account for synchronisation"},Fn={title:"Share note",icon:I(Ge,"share note"),sortTitle:"Share",call:Mr},$n={title:"Share public link",key:null,icon:I(Ge,"share public link"),sortTitle:"Share public link",call:async()=>{j.hide(),await Be(m(".terminal").getValue());let o=G();if(o){let e=(await $t({note:o})).history[0].url,a=await fetch(e).then(E=>E.json()),{files:s}=a,h=Object.values(s),[g]=h,{raw_url:y}=g,x=`${A.baseUrl}?raw=${y}`;ae(x,"MiroPad public link copied to clipboard \u{1F4CB}!")}}},xt=()=>[{title:"New note",icon:I(kt,"new note"),sortTitle:"New",key:"n",call:Ne},{title:"Save",key:"s",icon:I(at,"save"),sortTitle:"Save",call:async()=>{j.hide(),await Be(m(".terminal").getValue());let o=G();o&&!o.disableSync&&It([o]),se()}},...navigator.share?[Fn]:[],{title:"Toggle MarkDown Viewer",icon:I(mt,"toggle markdown viewer","rotate90"),sortTitle:"Split",key:"m",call:()=>{ie.toggle(),j.hide()}},{title:"Full MarkDown view",icon:I(gt,"full view"),sortTitle:"Full view",key:"shift m",call:()=>{ie.toggle("full"),j.hide()}},...fr()?[$n]:[],{title:"Zen mode",icon:I(_t,"zen mode"),sortTitle:"Zen mode",key:"shift z",call:()=>{!!A.getSearchParam("zen")?A.deleteParam("zen"):A.set(void 0,{zen:!0}),j.hide()}},{title:"List saved notes",icon:I(dt,"list notes"),sortTitle:"Notes",key:"p",call:()=>j.toggle(j.getModes().notes)},{title:"Delete note",key:"shift d",icon:I(be,"delete note"),sortTitle:"Delete",call:Ie},{title:On(),icon:I(it,"sync with github"),key:null,call:async()=>{let o=S.get("authToken");if(!o)return mr();if(!S.get("gistId"))return await gr(o);j.hide(),await xe()}},{title:"Sync: Reset Gist settings",icon:I(st,"reset github settings"),key:null,call:()=>{localStorage.removeItem("authToken"),localStorage.removeItem("gistId"),localStorage.removeItem("lastLocalUpdate"),localStorage.removeItem("lastSync"),M.info("Gist setting have been reset!"),j.hide()}},{title:"Toggle sidebar",experimental:!0,key:"shift l",call:()=>{m("aside").toggle()}},{title:"Save to File System...",experimental:!0,icon:I(ut,"save file"),key:"shift s",call:()=>{let o=G();if(o){let{text:r,title:e}=o;wr(r,e),j.hide()}}},{title:"Email note to...",experimental:!0,icon:I(lt,"email"),key:"e",call:()=>{let o=m(".terminal").getValue();Cr(o),j.hide()}},{title:"Toggle experimental features",experimental:!1,icon:I(ft,"lab"),key:null,call:()=>{let o=!!S.get("__experimental__");o?S.remove("__experimental__"):S.set("__experimental__",!0),M.showNotification(`Experimental features turned ${o?"off":"on"}`),j.hide()}},{title:"Toggle Autocompletion",experimental:!1,icon:I(bt,"autocompletion"),key:null,call:()=>{let o=!!S.get("__autocomplete__");o?S.remove("__autocomplete__"):S.set("__autocomplete__",!0),M.showNotification(`Autocomplete feature turned ${o?"off":"on"}`),j.hide(),m(".terminal").focus()}},{title:"Add a cover picture",experimental:!0,icon:I(ht,"cover picture"),key:null,call:async()=>{let o=prompt("Paste the image URL in here...");j.hide(),await zr(200),ae(`

`,"\u{1F44C}Copied! Paste the code on the MiroPad editor"),m(".terminal").focus(),M.info("Paste the cover picture wherever you prefer on the MirPad editor")}},{title:"Print MarkDown output",experimental:!0,icon:I(pt,"print"),key:null,call:()=>{m(".preview").show(),ie.init(),globalThis.print(),j.hide()}},{key:"j",title:"Prettify JSON document",icon:I(wt,"prettify json"),call:()=>{Sr(".terminal"),j.hide()}},{title:"Toggle command palette",icon:I(yt,"toggle command palette"),key:["shift p","k"],call:()=>j.toggle(j.getModes().commands)},{title:"Find and Replace...",experimental:!0,icon:I(vt,"find and replace"),key:"shift f",call:()=>{let o=m(".terminal").getValue().slice(m(".terminal").el.selectionStart,m(".terminal").el.selectionEnd),r=prompt("What do you wanna find?",o);if(!r)return M.info("Value not found");let e=m(".terminal").getValue().indexOf(r);m(".terminal").el.setSelectionRange(e,e+r.length);let a=prompt(`Replace ${r} with...`);a&&m(".terminal").el.setRangeText(a)}},{title:"Download all notes!",icon:I(ct,"Download all notes on your local file system"),call:()=>{let o=ee({includeDeleted:!0});yr(o),j.hide()}},{title:"Permanently delete ALL notes \u2757",icon:I(be,"delete note"),call:()=>{confirm("Are you sure you want do delete ALL your notes?")&&(ee({includeDeleted:!0}).forEach(e=>{S.remove(e.id)}),Ne()),j.hide()}}];var Gn={events:[],on(o,r){return Array.isArray(o)?(o.forEach(e=>{let a=e.key||e,s=e.call||r;this.on(a,s)}),this):(o&&typeof o=="string"&&r&&typeof r=="function"&&(this.events=[...this.events,{key:o.includes("shift")?o.replace("shift","").trim():o,shift:o.includes("shift"),fn(){r()}}]),this)},listen(){return document.addEventListener("keydown",o=>{this.handleEvent(o)}),this},handleEvent(o){this.events.map(r=>(r.key===o.key&&(o.ctrlKey===!0||o.metaKey===!0)&&o.shiftKey===r.shift&&(o.preventDefault(),r.fn()),!0))}},Tr=Gn;var Pr=(o,r)=>{let e=document.createElement("a");return e.href=r,e.appendChild(ce(o)?o:document.createTextNode(o)),e};var Ct=(o,r=new Date)=>{let e=new Date(o).getFullYear(),a=new Date(r).getFullYear();return e===a},Dr=(o,r=new Date)=>{let e=new Date(o).getMonth(),a=new Date(r).getMonth();return e===a},Vn=(o,r=new Date)=>{let e=new Date(o).getDate(),a=new Date(r).getDate();return e===a},Er=(o,r=new Date)=>Ct(o,r)&&Dr(o,r)&&Vn(o,r),Hn=["January","February","March","April","May","June","July","August","September","October","November","December"],Un=Hn.map(o=>o.slice(0,3)),Ar=(o=new Date)=>{let r=new Date(o),e=new Date().getDate()-1;return Dr(r)&&Ct(r)&&r.getDate()===e},Ce=o=>{let r=new Date(o),e=Ar(o)?"":Un[r.getMonth()],a=Ct(r)?"":r.getFullYear(),s=Ar(r)?"Yesterday":r.getDate();return`${Er(r)?"":`${s} ${e} ${a}`} ${Er(r)?r.toLocaleTimeString():""}`};var Lr=o=>o.reduce((e,a)=>{if(e.length===0)return[a];let s=Math.max(...e);return[...e,...a>=s?[a]:[]]},[]).length===o.length;var St=(o,r)=>{let e=o.split(" ").map(h=>h.toLowerCase()),s=r.split(" ").map(h=>h.toLowerCase()).map(h=>e.map((x,P)=>x.includes(h)?P:-1).reduce((x,P)=>P>-1?P:x,-1));return s.includes(-1)?!1:Lr(s)};var jr=async()=>{if(!S.get("__notification-permission__")){let o=await globalThis.Notification.requestPermission();S.set("__notification-permission__",o)}},Nr=()=>{"serviceWorker"in navigator&&navigator.serviceWorker.register(`${globalThis.location.pathname}service-worker.js?v=v3.1.4`)};var Br=o=>Array.isArray(o)?o.map(r=>Br(r)).join(", "):o?`\u2318+${o.toUpperCase()}`:"",Rn=(()=>{let o;(y=>(y.off="off",y.notes="notes",y.revisions="revisions",y.commands="commands",y.gists="gists"))(o||(o={}));let r={input:"",mode:"off",options:{selected:0,length:0}};return{getState:function(){return r},getModes:function(){return o},setState:function(e){return r={...r,...e},r},show:function(e="commands"){switch(m("#commander").show(),m("#commander input").focus(),e){case"commands":this.generateCommands(),m("#commander input").setValue("> "),this.setState({mode:"commands"});break;case"notes":this.generateNotes(),m("#commander input").setValue(""),this.setState({mode:"notes"});break;case"revisions":this.generateRevisions(),m("#commander input").setValue(""),this.setState({mode:"revisions"});break;default:break}return this},hide:function(){return m("#commander").hide(),r.mode="off",this},toggle:function(e){return jr(),r.mode==="off"||r.mode!==e?this.show(e):this.hide(),this},commands:function(){return xt()},selectOption:function(e="down"){let a=r.options.selected,s=r.options.length-1,x=e==="down"?a===s?0:a+1:a===0?s:a-1;r.options={...r.options,selected:x}},initCommander:function(){return xt().slice(0,5).map(e=>{m(".mobile-dock").append($e([e.icon,document.createTextNode(e.sortTitle)],e.call,e.title.toLowerCase().replace(/\s/g,"-")))}),m("#commander button").listen("click",()=>{this.hide()}),m("#commander input").listen("keydown",e=>{e.keyCode===40&&(r.mode==="revisions"&&m("#commands li.selected").click(),this.selectOption("down")),e.keyCode===38&&(r.mode==="revisions"&&m("#commands li.selected").click(),this.selectOption("up"))}).listen("keyup",e=>{e.keyCode===13&&(r.mode==="commands"?m("#commands li.selected div").click():m("#commands li.selected a").click()),e.keyCode===27&&m(".terminal").focus();let a=e.target;r.input!==a.value&&(r.options.selected=0),r.input=a.value,this.generateOptions(a.value)}),this},init:function(){return this.initCommander(),Tr.listen().on(this.commands()),m(".menu").listen("click",()=>this.toggle()),m("#revisions").listen("click",()=>this.generateRevisions()),this},generateRevisions:function(){this.show(),r.mode="revisions";let e=G();if(e){let{revisions:a}=e,s=r.options.selected,h=Object.keys(a).sort((g,y)=>{let{dateCreated:x}=a[g],{dateCreated:P}=a[y];return P-x}).map((g,y)=>({title:ne({content:`...${g.slice(-10)}`}),secondary:`${Ce(a[g].dateCreated)}`,onclick:()=>{A.set(void 0,{v:g}),r.options.selected=y,this.generateRevisions()}})).map((g,y)=>de(g,y===s));m("#commands").html(h),r.options={...r.options,length:h.length}}return this},generateOptions:function(e){switch(r.mode){case"commands":case"notes":e.slice(0,1)===">"?(r.mode="commands",this.generateCommands(e.slice(1).trim()),m("#commander input").placeholder("Search for commands...")):(r.mode="notes",this.generateNotes(e));return;case"revisions":return this.generateRevisions();case"off":break;default:break}},generateNotes:function(e=""){let a=r.options.selected,s=ee().filter(({title:h})=>St(h,e)).filter(({id:h,deleted:g})=>!g&&h!==A.getPageId()).sort((h,g)=>{let y=Le(h.title);return Le(g.title)-y}).map(({id:h,title:g},y)=>{let x=Le(g),P=`${globalThis.location.origin}${globalThis.location.pathname}#${h}`,E=Pr(ne({content:g,highlight:e}),P);return de({title:E,secondary:Ce(x),onclick:()=>{this.hide(),m(".terminal").focus()}},y===a)});return m("#commands").html(s),m("#commander input").placeholder(`Search from ${s.length} saved notes...`),r.options={...r.options,length:s.length},this},generateCommands:function(e=""){let a=r.options.selected,s=this.commands().filter(({title:h})=>St(h,e)).filter(({experimental:h=!1})=>S.get("__experimental__")?!0:!h).map(({title:h,key:g,call:y,icon:x},P)=>de({title:ne({content:h,highlight:e}),icon:x,secondary:Br(g),onclick:y},P===a));return m("#commands").html(s),r.options={...r.options,length:s.length},this}}})(),j=Rn;var Ir="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";var Or=(o=21)=>{let r="",e=crypto.getRandomValues(new Uint8Array(o));for(;o--;)r+=Ir[e[o]&63];return r};var $r=Lt(Fr());var Wn=o=>{let r=o.replace(/[\r\n\t]+/g,"").toLowerCase();return Se.getMatchingWords(r)},zt=(o,r)=>{let e="",a=r-1;do{let s=o[a]||"";a=s.trim()===""?-1:a-1,e=s.trim()!==""?`${s}${e}`:e}while(a>=0);return e},Mt=o=>{let r=(0,$r.default)(o,o.selectionEnd),{top:e,left:a}=r,s=m(".terminal").el.scrollHeight,h=m("main").el;h.style.height=`${s}px`,m(".suggestion").el.style.top=`${e}px`,m(".suggestion").el.style.left=`${a}px`},Tt=(o,r)=>o[r]===void 0||o[r].trim()==="",Gr=o=>{let r=o.target.selectionEnd,e=D.el.getValue(),a=e[r-1];if(o.inputType==="deleteContentBackward"||a===" ")return D.setState({prediction:null,currentWord:null}),m(".suggestion").hide();let s=zt(e,r);if(o.inputType==="insertText"&&Tt(e,r)&&!s.startsWith("#")){Mt(o.target);let g=Wn(s),[y]=g,x=y||"";D.setState({prediction:x,currentWord:s,matches:g.slice(0,10),options:{selected:0,length:g.length}});let P=D.getState();P.currentWord&&P.prediction&&P.currentWord.length>1?(D.renderInlineSuggestion(),D.renderOptions()):m(".suggestion").hide()}};var Vr=(o,r)=>o.split(` + `,qo=async(o,r,e="MiroPad note")=>{if(!o){M.error("\u{1F47B} No message to send, type something and try again! \u{1F913}");return}try{await fetch(`${te.mail_service.api}`,{method:"POST",headers:{"x-secret-token":S.get("MIROPAD_SECRET_TOKEN"),accept:"application/json","content-type":"application/json"},body:JSON.stringify({to:r,subject:e,html:Wo(o)})}).then(nt).then(a=>a.json()),M.success("Email sent \u{1F680}")}catch{M.error("Error not went through \u{1F4A5}! Check your credentials and try again!")}},Jo=()=>{let o=S.get("mail");if(o){let a=globalThis.prompt(`Mail ${o} again? (y)es/(no)`,"yeap");if(a===null)return a;if(a.slice(0,1).toLowerCase()==="y")return o}let r=globalThis.prompt("Where do you wanna send the mail to?"),e=globalThis.prompt("Do you wanna save that to your preferences for later on? (y)es/(no)","yeap");return e&&e.slice(0,1).toLowerCase()==="y"&&S.set("mail",r),r},Cr=o=>{let r=Jo();if(r===null){M.info("Sending mail cancelled \u{1F636}");return}M.info("Sending mail... \u{1F680}");let e=ge(o),a=Fe(o);qo(a,r,e)};var ae=async(o,r="\u{1F4CB} Copied to clipboard")=>{try{await navigator.clipboard.writeText(o),M.success(r)}catch(e){M.error(e.message)}};var $e=(o,r,e)=>{let a=ue(o)?o:[o],s=document.createElement("button");return s.setAttribute("type","button"),e&&s.setAttribute("id",e),a.forEach(h=>{typeof h=="string"?s.appendChild(document.createTextNode(h)):s.appendChild(h)}),s.onclick=h=>r(h),s};var Ko={view:m(".preview"),init:function(){return this.update(),m(".terminal").listen("input",()=>this.update()),!!A.getSearchParam("md")?this.view.show():this.view.hide(),this},autoLink:function(){let o=S.parse("__auto-links__"),r=Object.keys(o).map(s=>`${s}\\w+`).join("|"),e=new RegExp(`(${r})`,"g"),a=this.view.el.innerHTML.replace(e,s=>{let h=Object.keys(o).find(y=>s.startsWith(y)),g=o[h];return g.startsWith("http")?`${s}`:`${s}`});this.view.innerHTML(a)},update:function(){let md=m(".terminal").getValue();this.view.innerHTML(Fe(md)),this.autoLink();let{elements}=m("pre");Array.prototype.slice.call(elements).forEach(o=>{let r=$e("\u{1F4CB} Copy",async e=>{e.stopPropagation();let a=e.srcElement.previousSibling.innerHTML;await ae(a,"\u{1F4CB} Code copied to clipboard")});o.appendChild(r)}),m("code").listenAll("click",({innerHTML})=>{let result=eval(innerHTML);m(".console").show().innerHTML(result)}),m(".console").listen("click",async o=>{o.srcElement.classList.add("hidden");let r=o.srcElement.innerHTML;await ae(r,"\u{1F4CB} Code copied to clipboard")})},show:function(o=!0){this.view.show(),A.set(void 0,{md:o})},hide:function(){this.view.hide(),A.deleteParam("md")},toggle:function(o="true"){return A.getSearchParam("md")===o?this.hide():this.show(o),this}},ie=Ko;var Yo=o=>{let r=document.querySelector(o);if(Ae(r.value)){let e=JSON.stringify(JSON.parse(r.value),null,2);r.value=e,M.success("\u{1F44D} JSON value prettified")}else M.error("\u{1F627} Value is not in valid JSON format")},Sr=Yo;var zr=(o=1e3)=>new Promise(r=>{setTimeout(r,o)});var I=(o,r,e)=>{let a=document.createElement("IMG");return e&&a.classList.add(e),r&&a.setAttribute("alt",r),a.setAttribute("src",o),a};var dt={};$(dt,{default:()=>Xo});var Xo="./list-LK7OCHR7.svg";var be={};$(be,{default:()=>en});var en="./trash-RDL437QG.svg";var at={};$(at,{default:()=>rn});var rn="./checkmark-circle-JQ7ADSUI.svg";var it={};$(it,{default:()=>nn});var nn="./cloud-sync-F3RLGHML.svg";var st={};$(st,{default:()=>an});var an="./lighter-UBEI67LL.svg";var ut={};$(ut,{default:()=>un});var un="./enter-down-6TVO6OFR.svg";var ct={};$(ct,{default:()=>ln});var ln="./download-FVXMIYZ4.svg";var lt={};$(lt,{default:()=>hn});var hn="./envelope-Z2VRVSLR.svg";var ft={};$(ft,{default:()=>mn});var mn="./bug-36UGMUXT.svg";var ht={};$(ht,{default:()=>bn});var bn="./picture-3TDOSVS3.svg";var pt={};$(pt,{default:()=>yn});var yn="./printer-B7RMPYZC.svg";var mt={};$(mt,{default:()=>kn});var kn="./page-break-BLVP5QBQ.svg";var gt={};$(gt,{default:()=>xn});var xn="./frame-expand-CX6CNP53.svg";var bt={};$(bt,{default:()=>Sn});var Sn="./arrow-right-circle-2Q6EHM2H.svg";var wt={};$(wt,{default:()=>Mn});var Mn="./magic-wand-JQJ6EKRO.svg";var yt={};$(yt,{default:()=>Pn});var Pn="./rocket-AIY2RJJS.svg";var vt={};$(vt,{default:()=>An});var An="./spell-check-V6QYTGNT.svg";var kt={};$(kt,{default:()=>Ln});var Ln="./pencil-X3ZMY3QU.svg";var Ge={};$(Ge,{default:()=>Nn});var Nn="./exit-up-GH6BPN2X.svg";var _t={};$(_t,{default:()=>In});var In="./leaf-CGBE7XAJ.svg";var Mr=async()=>{try{let o=G(),r=A.get();await navigator.share({title:o?o.title:"\u270D\uFE0F MiroPad",text:o?o.text:"Temporary note keeping app for the browser",url:r})}catch(o){M.info(`${o.message}`)}};var On=()=>{let o=S.get("gistId");return S.get("authToken")?o?"Sync: Notes with my GitHub Gist":"Sync: Pick your Gist to sync with":"Sync: Authorize your GitHub account for synchronisation"},Fn={title:"Share note",icon:I(Ge,"share note"),sortTitle:"Share",call:Mr},$n={title:"Share public link",key:null,icon:I(Ge,"share public link"),sortTitle:"Share public link",call:async()=>{j.hide(),await Be(m(".terminal").getValue());let o=G();if(o){let e=(await $t({note:o})).history[0].url,a=await fetch(e).then(E=>E.json()),{files:s}=a,h=Object.values(s),[g]=h,{raw_url:y}=g,x=`${A.baseUrl}?raw=${y}`;ae(x,"MiroPad public link copied to clipboard \u{1F4CB}!")}}},xt=()=>[{title:"New note",icon:I(kt,"new note"),sortTitle:"New",key:"n",call:Ne},{title:"Save",key:"s",icon:I(at,"save"),sortTitle:"Save",call:async()=>{j.hide(),await Be(m(".terminal").getValue());let o=G();o&&!o.disableSync&&It([o]),se()}},...navigator.share?[Fn]:[],{title:"Toggle MarkDown Viewer",icon:I(mt,"toggle markdown viewer","rotate90"),sortTitle:"Split",key:"m",call:()=>{ie.toggle(),j.hide()}},{title:"Full MarkDown view",icon:I(gt,"full view"),sortTitle:"Full view",key:"shift m",call:()=>{ie.toggle("full"),j.hide()}},...fr()?[$n]:[],{title:"Zen mode",icon:I(_t,"zen mode"),sortTitle:"Zen mode",key:"shift z",call:()=>{!!A.getSearchParam("zen")?A.deleteParam("zen"):A.set(void 0,{zen:!0}),j.hide()}},{title:"List saved notes",icon:I(dt,"list notes"),sortTitle:"Notes",key:"p",call:()=>j.toggle(j.getModes().notes)},{title:"Delete note",key:"shift d",icon:I(be,"delete note"),sortTitle:"Delete",call:Ie},{title:On(),icon:I(it,"sync with github"),key:null,call:async()=>{let o=S.get("authToken");if(!o)return mr();if(!S.get("gistId"))return await gr(o);j.hide(),await xe()}},{title:"Sync: Reset Gist settings",icon:I(st,"reset github settings"),key:null,call:()=>{localStorage.removeItem("authToken"),localStorage.removeItem("gistId"),localStorage.removeItem("lastLocalUpdate"),localStorage.removeItem("lastSync"),M.info("Gist setting have been reset!"),j.hide()}},{title:"Toggle sidebar",experimental:!0,key:"shift l",call:()=>{m("aside").toggle()}},{title:"Save to File System...",experimental:!0,icon:I(ut,"save file"),key:"shift s",call:()=>{let o=G();if(o){let{text:r,title:e}=o;wr(r,e),j.hide()}}},{title:"Email note to...",experimental:!0,icon:I(lt,"email"),key:"e",call:()=>{let o=m(".terminal").getValue();Cr(o),j.hide()}},{title:"Toggle experimental features",experimental:!1,icon:I(ft,"lab"),key:null,call:()=>{let o=!!S.get("__experimental__");o?S.remove("__experimental__"):S.set("__experimental__",!0),M.showNotification(`Experimental features turned ${o?"off":"on"}`),j.hide()}},{title:"Toggle Autocompletion",experimental:!1,icon:I(bt,"autocompletion"),key:null,call:()=>{let o=!!S.get("__autocomplete__");o?S.remove("__autocomplete__"):S.set("__autocomplete__",!0),M.showNotification(`Autocomplete feature turned ${o?"off":"on"}`),j.hide(),m(".terminal").focus()}},{title:"Add a cover picture",experimental:!0,icon:I(ht,"cover picture"),key:null,call:async()=>{let o=prompt("Paste the image URL in here...");j.hide(),await zr(200),ae(`
`,"\u{1F44C}Copied! Paste the code on the MiroPad editor"),m(".terminal").focus(),M.info("Paste the cover picture wherever you prefer on the MirPad editor")}},{title:"Print MarkDown output",experimental:!0,icon:I(pt,"print"),key:null,call:()=>{m(".preview").show(),ie.init(),globalThis.print(),j.hide()}},{key:"j",title:"Prettify JSON document",icon:I(wt,"prettify json"),call:()=>{Sr(".terminal"),j.hide()}},{title:"Toggle command palette",icon:I(yt,"toggle command palette"),key:["shift p","k"],call:()=>j.toggle(j.getModes().commands)},{title:"Find and Replace...",experimental:!0,icon:I(vt,"find and replace"),key:"shift f",call:()=>{let o=m(".terminal").getValue().slice(m(".terminal").el.selectionStart,m(".terminal").el.selectionEnd),r=prompt("What do you wanna find?",o);if(!r)return M.info("Value not found");let e=m(".terminal").getValue().indexOf(r);m(".terminal").el.setSelectionRange(e,e+r.length);let a=prompt(`Replace ${r} with...`);a&&m(".terminal").el.setRangeText(a)}},{title:"Download all notes!",icon:I(ct,"Download all notes on your local file system"),call:()=>{let o=ee({includeDeleted:!0});yr(o),j.hide()}},{title:"Permanently delete ALL notes \u2757",icon:I(be,"delete note"),call:()=>{confirm("Are you sure you want do delete ALL your notes?")&&(ee({includeDeleted:!0}).forEach(e=>{S.remove(e.id)}),Ne()),j.hide()}}];var Gn={events:[],on(o,r){return Array.isArray(o)?(o.forEach(e=>{let a=e.key||e,s=e.call||r;this.on(a,s)}),this):(o&&typeof o=="string"&&r&&typeof r=="function"&&(this.events=[...this.events,{key:o.includes("shift")?o.replace("shift","").trim():o,shift:o.includes("shift"),fn(){r()}}]),this)},listen(){return document.addEventListener("keydown",o=>{this.handleEvent(o)}),this},handleEvent(o){this.events.map(r=>(r.key===o.key&&(o.ctrlKey===!0||o.metaKey===!0)&&o.shiftKey===r.shift&&(o.preventDefault(),r.fn()),!0))}},Tr=Gn;var Pr=(o,r)=>{let e=document.createElement("a");return e.href=r,e.appendChild(ce(o)?o:document.createTextNode(o)),e};var Ct=(o,r=new Date)=>{let e=new Date(o).getFullYear(),a=new Date(r).getFullYear();return e===a},Dr=(o,r=new Date)=>{let e=new Date(o).getMonth(),a=new Date(r).getMonth();return e===a},Vn=(o,r=new Date)=>{let e=new Date(o).getDate(),a=new Date(r).getDate();return e===a},Er=(o,r=new Date)=>Ct(o,r)&&Dr(o,r)&&Vn(o,r),Hn=["January","February","March","April","May","June","July","August","September","October","November","December"],Un=Hn.map(o=>o.slice(0,3)),Ar=(o=new Date)=>{let r=new Date(o),e=new Date().getDate()-1;return Dr(r)&&Ct(r)&&r.getDate()===e},Ce=o=>{let r=new Date(o),e=Ar(o)?"":Un[r.getMonth()],a=Ct(r)?"":r.getFullYear(),s=Ar(r)?"Yesterday":r.getDate();return`${Er(r)?"":`${s} ${e} ${a}`} ${Er(r)?r.toLocaleTimeString():""}`};var Lr=o=>o.reduce((e,a)=>{if(e.length===0)return[a];let s=Math.max(...e);return[...e,...a>=s?[a]:[]]},[]).length===o.length;var St=(o,r)=>{let e=o.split(" ").map(h=>h.toLowerCase()),s=r.split(" ").map(h=>h.toLowerCase()).map(h=>e.map((x,P)=>x.includes(h)?P:-1).reduce((x,P)=>P>-1?P:x,-1));return s.includes(-1)?!1:Lr(s)};var jr=async()=>{if(!S.get("__notification-permission__")){let o=await globalThis.Notification.requestPermission();S.set("__notification-permission__",o)}},Nr=()=>{"serviceWorker"in navigator&&navigator.serviceWorker.register(`${globalThis.location.pathname}service-worker.js?v=v3.1.5`)};var Br=o=>Array.isArray(o)?o.map(r=>Br(r)).join(", "):o?`\u2318+${o.toUpperCase()}`:"",Rn=(()=>{let o;(y=>(y.off="off",y.notes="notes",y.revisions="revisions",y.commands="commands",y.gists="gists"))(o||(o={}));let r={input:"",mode:"off",options:{selected:0,length:0}};return{getState:function(){return r},getModes:function(){return o},setState:function(e){return r={...r,...e},r},show:function(e="commands"){switch(m("#commander").show(),m("#commander input").focus(),e){case"commands":this.generateCommands(),m("#commander input").setValue("> "),this.setState({mode:"commands"});break;case"notes":this.generateNotes(),m("#commander input").setValue(""),this.setState({mode:"notes"});break;case"revisions":this.generateRevisions(),m("#commander input").setValue(""),this.setState({mode:"revisions"});break;default:break}return this},hide:function(){return m("#commander").hide(),r.mode="off",this},toggle:function(e){return jr(),r.mode==="off"||r.mode!==e?this.show(e):this.hide(),this},commands:function(){return xt()},selectOption:function(e="down"){let a=r.options.selected,s=r.options.length-1,x=e==="down"?a===s?0:a+1:a===0?s:a-1;r.options={...r.options,selected:x}},initCommander:function(){return xt().slice(0,5).map(e=>{m(".mobile-dock").append($e([e.icon,document.createTextNode(e.sortTitle)],e.call,e.title.toLowerCase().replace(/\s/g,"-")))}),m("#commander button").listen("click",()=>{this.hide()}),m("#commander input").listen("keydown",e=>{e.keyCode===40&&(r.mode==="revisions"&&m("#commands li.selected").click(),this.selectOption("down")),e.keyCode===38&&(r.mode==="revisions"&&m("#commands li.selected").click(),this.selectOption("up"))}).listen("keyup",e=>{e.keyCode===13&&(r.mode==="commands"?m("#commands li.selected div").click():m("#commands li.selected a").click()),e.keyCode===27&&m(".terminal").focus();let a=e.target;r.input!==a.value&&(r.options.selected=0),r.input=a.value,this.generateOptions(a.value)}),this},init:function(){return this.initCommander(),Tr.listen().on(this.commands()),m(".menu").listen("click",()=>this.toggle()),m("#revisions").listen("click",()=>this.generateRevisions()),this},generateRevisions:function(){this.show(),r.mode="revisions";let e=G();if(e){let{revisions:a}=e,s=r.options.selected,h=Object.keys(a).sort((g,y)=>{let{dateCreated:x}=a[g],{dateCreated:P}=a[y];return P-x}).map((g,y)=>({title:ne({content:`...${g.slice(-10)}`}),secondary:`${Ce(a[g].dateCreated)}`,onclick:()=>{A.set(void 0,{v:g}),r.options.selected=y,this.generateRevisions()}})).map((g,y)=>de(g,y===s));m("#commands").html(h),r.options={...r.options,length:h.length}}return this},generateOptions:function(e){switch(r.mode){case"commands":case"notes":e.slice(0,1)===">"?(r.mode="commands",this.generateCommands(e.slice(1).trim()),m("#commander input").placeholder("Search for commands...")):(r.mode="notes",this.generateNotes(e));return;case"revisions":return this.generateRevisions();case"off":break;default:break}},generateNotes:function(e=""){let a=r.options.selected,s=ee().filter(({title:h})=>St(h,e)).filter(({id:h,deleted:g})=>!g&&h!==A.getPageId()).sort((h,g)=>{let y=Le(h.title);return Le(g.title)-y}).map(({id:h,title:g},y)=>{let x=Le(g),P=`${globalThis.location.origin}${globalThis.location.pathname}#${h}`,E=Pr(ne({content:g,highlight:e}),P);return de({title:E,secondary:Ce(x),onclick:()=>{this.hide(),m(".terminal").focus()}},y===a)});return m("#commands").html(s),m("#commander input").placeholder(`Search from ${s.length} saved notes...`),r.options={...r.options,length:s.length},this},generateCommands:function(e=""){let a=r.options.selected,s=this.commands().filter(({title:h})=>St(h,e)).filter(({experimental:h=!1})=>S.get("__experimental__")?!0:!h).map(({title:h,key:g,call:y,icon:x},P)=>de({title:ne({content:h,highlight:e}),icon:x,secondary:Br(g),onclick:y},P===a));return m("#commands").html(s),r.options={...r.options,length:s.length},this}}})(),j=Rn;var Ir="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";var Or=(o=21)=>{let r="",e=crypto.getRandomValues(new Uint8Array(o));for(;o--;)r+=Ir[e[o]&63];return r};var $r=Lt(Fr());var Wn=o=>{let r=o.replace(/[\r\n\t]+/g,"").toLowerCase();return Se.getMatchingWords(r)},zt=(o,r)=>{let e="",a=r-1;do{let s=o[a]||"";a=s.trim()===""?-1:a-1,e=s.trim()!==""?`${s}${e}`:e}while(a>=0);return e},Mt=o=>{let r=(0,$r.default)(o,o.selectionEnd),{top:e,left:a}=r,s=m(".terminal").el.scrollHeight,h=m("main").el;h.style.height=`${s}px`,m(".suggestion").el.style.top=`${e}px`,m(".suggestion").el.style.left=`${a}px`},Tt=(o,r)=>o[r]===void 0||o[r].trim()==="",Gr=o=>{let r=o.target.selectionEnd,e=D.el.getValue(),a=e[r-1];if(o.inputType==="deleteContentBackward"||a===" ")return D.setState({prediction:null,currentWord:null}),m(".suggestion").hide();let s=zt(e,r);if(o.inputType==="insertText"&&Tt(e,r)&&!s.startsWith("#")){Mt(o.target);let g=Wn(s),[y]=g,x=y||"";D.setState({prediction:x,currentWord:s,matches:g.slice(0,10),options:{selected:0,length:g.length}});let P=D.getState();P.currentWord&&P.prediction&&P.currentWord.length>1?(D.renderInlineSuggestion(),D.renderOptions()):m(".suggestion").hide()}};var Vr=(o,r)=>o.split(` `).reduce((s,h)=>{let{isFound:g}=s;if(g)return s;let y=`${s.text}${h} `,x=y.length;return r>=x?{text:y,isFound:!1}:{text:h,isFound:!0}},{text:"",isFound:!1}).text;var Hr=o=>{let r=Vr(o.target.value,o.target.selectionEnd),e={"* [":` * [] `,"* ":` diff --git a/service-worker.js b/service-worker.js index 8319bb2..21cce9e 100644 --- a/service-worker.js +++ b/service-worker.js @@ -3,7 +3,7 @@ importScripts( ); const { precacheAndRoute } = workbox.precaching; -precacheAndRoute([{"revision":"b9816a8779946abd6884c8d0835aab1a","url":"arrow-right-circle-2Q6EHM2H.svg"},{"revision":"6b352c8234986802e30f57b4a173db65","url":"bug-36UGMUXT.svg"},{"revision":"715ea2f9ed9c32e912d10f1f8cfd1333","url":"checkmark-circle-JQ7ADSUI.svg"},{"revision":"642881591601125261f78f3ad5a52c32","url":"cloud-sync-F3RLGHML.svg"},{"revision":"f8fc1cc37e1226392cc0cc4c6068cf66","url":"download-FVXMIYZ4.svg"},{"revision":"08cc87504b693a32d717aaaf13e414a0","url":"enter-down-6TVO6OFR.svg"},{"revision":"a69f752fafc2a5f161dbc1c851d4f17b","url":"envelope-Z2VRVSLR.svg"},{"revision":"7665092453f7b45c2782db5f16e6ce5c","url":"exit-up-GH6BPN2X.svg"},{"revision":"7cdfed241e2edb7e7ed37eaaf9bae94a","url":"favicon.ico"},{"revision":"fd02fe115943662aa6a6581ab31ce38d","url":"frame-expand-CX6CNP53.svg"},{"revision":"59b2a5f4e0884d7c2d4e2324e3727ecc","url":"images/icons/icon-128x128.png"},{"revision":"77b08750ba54d3a8f21f331d04530637","url":"images/icons/icon-144x144.png"},{"revision":"84cb614c066d965f784c2ed810dc31e1","url":"images/icons/icon-152x152.png"},{"revision":"2f95a518fbfc169e32fd5fb7a5b063fd","url":"images/icons/icon-192x192.png"},{"revision":"87029203db3903aab4be829b030b3514","url":"images/icons/icon-384x384.png"},{"revision":"ad2869f40002d4f268f6b60a0c115136","url":"images/icons/icon-512x512.png"},{"revision":"e70a2704695d7026ab6fe403f4604867","url":"images/icons/icon-72x72.png"},{"revision":"0bfc17b6ea552774646836236d7e5954","url":"images/icons/icon-96x96.png"},{"revision":"79e59607337b1e6a34e0935965ad4d21","url":"images/icons/maskable_icon.png"},{"revision":"ce9a2fd61cb2f8c25e2a20ffceb432d1","url":"index.html"},{"revision":"c26806f06c0b3a9e3e57c2ee5a76ba5d","url":"index.js"},{"revision":"3ce2509712df0cd63aa28b3bedf3ffe6","url":"leaf-CGBE7XAJ.svg"},{"revision":"4e1ab5abca803d8371db0bac365fdf93","url":"lighter-UBEI67LL.svg"},{"revision":"2694687077344bc31a1968ce3329660b","url":"list-LK7OCHR7.svg"},{"revision":"b399e36fdd1b4597c9c5036c6a4869f8","url":"magic-wand-JQJ6EKRO.svg"},{"revision":"5b3ba4abf0df4fc44cd679b1ce903ac6","url":"manifest.json"},{"revision":"126653c706df1e5655be880ddc02e164","url":"page-break-BLVP5QBQ.svg"},{"revision":"d26a9edb2928bbeba1749f454aab95d3","url":"pencil-X3ZMY3QU.svg"},{"revision":"1c74f8e5f212764756b46b728d31a97f","url":"picture-3TDOSVS3.svg"},{"revision":"299ddb01bcee73f853049f4ca36e9dc8","url":"printer-B7RMPYZC.svg"},{"revision":"1eccb57fd8613bb74b8394400b7b1b1f","url":"rocket-AIY2RJJS.svg"},{"revision":"41be43627587fa71a315c9a1d2565283","url":"spell-check-V6QYTGNT.svg"},{"revision":"abef7b4a2eb95c594f45063c3fe372eb","url":"trash-RDL437QG.svg"}]); +precacheAndRoute([{"revision":"b9816a8779946abd6884c8d0835aab1a","url":"arrow-right-circle-2Q6EHM2H.svg"},{"revision":"6b352c8234986802e30f57b4a173db65","url":"bug-36UGMUXT.svg"},{"revision":"715ea2f9ed9c32e912d10f1f8cfd1333","url":"checkmark-circle-JQ7ADSUI.svg"},{"revision":"642881591601125261f78f3ad5a52c32","url":"cloud-sync-F3RLGHML.svg"},{"revision":"f8fc1cc37e1226392cc0cc4c6068cf66","url":"download-FVXMIYZ4.svg"},{"revision":"08cc87504b693a32d717aaaf13e414a0","url":"enter-down-6TVO6OFR.svg"},{"revision":"a69f752fafc2a5f161dbc1c851d4f17b","url":"envelope-Z2VRVSLR.svg"},{"revision":"7665092453f7b45c2782db5f16e6ce5c","url":"exit-up-GH6BPN2X.svg"},{"revision":"7cdfed241e2edb7e7ed37eaaf9bae94a","url":"favicon.ico"},{"revision":"fd02fe115943662aa6a6581ab31ce38d","url":"frame-expand-CX6CNP53.svg"},{"revision":"59b2a5f4e0884d7c2d4e2324e3727ecc","url":"images/icons/icon-128x128.png"},{"revision":"77b08750ba54d3a8f21f331d04530637","url":"images/icons/icon-144x144.png"},{"revision":"84cb614c066d965f784c2ed810dc31e1","url":"images/icons/icon-152x152.png"},{"revision":"2f95a518fbfc169e32fd5fb7a5b063fd","url":"images/icons/icon-192x192.png"},{"revision":"87029203db3903aab4be829b030b3514","url":"images/icons/icon-384x384.png"},{"revision":"ad2869f40002d4f268f6b60a0c115136","url":"images/icons/icon-512x512.png"},{"revision":"e70a2704695d7026ab6fe403f4604867","url":"images/icons/icon-72x72.png"},{"revision":"0bfc17b6ea552774646836236d7e5954","url":"images/icons/icon-96x96.png"},{"revision":"79e59607337b1e6a34e0935965ad4d21","url":"images/icons/maskable_icon.png"},{"revision":"ce9a2fd61cb2f8c25e2a20ffceb432d1","url":"index.html"},{"revision":"085d901ea2f90b0ec31004f8d2229ead","url":"index.js"},{"revision":"3ce2509712df0cd63aa28b3bedf3ffe6","url":"leaf-CGBE7XAJ.svg"},{"revision":"4e1ab5abca803d8371db0bac365fdf93","url":"lighter-UBEI67LL.svg"},{"revision":"2694687077344bc31a1968ce3329660b","url":"list-LK7OCHR7.svg"},{"revision":"b399e36fdd1b4597c9c5036c6a4869f8","url":"magic-wand-JQJ6EKRO.svg"},{"revision":"5b3ba4abf0df4fc44cd679b1ce903ac6","url":"manifest.json"},{"revision":"126653c706df1e5655be880ddc02e164","url":"page-break-BLVP5QBQ.svg"},{"revision":"d26a9edb2928bbeba1749f454aab95d3","url":"pencil-X3ZMY3QU.svg"},{"revision":"1c74f8e5f212764756b46b728d31a97f","url":"picture-3TDOSVS3.svg"},{"revision":"299ddb01bcee73f853049f4ca36e9dc8","url":"printer-B7RMPYZC.svg"},{"revision":"1eccb57fd8613bb74b8394400b7b1b1f","url":"rocket-AIY2RJJS.svg"},{"revision":"41be43627587fa71a315c9a1d2565283","url":"spell-check-V6QYTGNT.svg"},{"revision":"abef7b4a2eb95c594f45063c3fe372eb","url":"trash-RDL437QG.svg"}]); const checkForNewerVersion = (currentVersion) => { const intervalChecker = setInterval(async () => { diff --git a/version b/version index 6eef43b..ed530b3 100644 --- a/version +++ b/version @@ -1 +1 @@ -v3.1.4 +v3.1.5