"use strict";varYL=Object.defineProperty;varUL=(e,t,n)=>tine?YL(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;varSe=(e,t,n)=>(UL(e,typeoft!="symbol"?t+"":t,n),n);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});constC=require("obsidian"),vS=require("@codemirror/language"),qg=require("@codemirror/state"),Wl=require("@codemirror/view");functionzL(e,t){for(varn=0;n<t.length;n++){constr=t[n];if(typeofr!="string"&&!Array.isArray(r)){for(constainr)if(a!=="default"&&!(aine)){consto=Object.getOwnPropertyDescriptor(r,a);o&&Object.defineProperty(e,a,o.get?o:{enumerable:!0,get:()=>r[a]})}}}returnObject.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}vardr=typeofglobalThis<"u"?globalThis:typeofwindow<"u"?window:typeofglobal<"u"?global:typeofself<"u"?self:{};functionqt(e){returne&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}varYN={exports:{}},pg={},UN={exports:{}},gn={},Ex;functionVL(){if(Ex)returngn;Ex=1;vare=Symbol.for("react.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),o=Symbol.for("react.provider"),i=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),c=Symbol.for("react.suspense"),f=Symbol.for("react.memo"),h=Symbol.for("react.lazy"),g=Symbol.iterator;functiony(X){returnX===null||typeofX!="object"?null:(X=g&&X[g]||X["@@iterator"],typeofX=="function"?X:null)}varw={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},S=Object.assign,D={};functionI(X,ae,De){this.props=X,this.context=ae,this.refs=D,this.updater=De||w}I.prototype.isReactComponent={},I.prototype.setState=function(X,ae){if(typeofX!="object"&&typeofX!="function"&&X!=null)throwError("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,X,ae,"setState")},I.prototype.forceUpdate=function(X){this.updater.enqueueForceUpdate(this,X,"forceUpdate")};functionM(){}M.prototype=I.prototype;functionN(X,ae,De){this.props=X,this.context=ae,this.refs=D,this.updater=De||w}var_=N.prototype=newM;_.constructor=N,S(_,I.prototype),_.isPureReactComponent=!0;vark=Array.isArray,B=Object.prototype.hasOwnProperty,L={current:null},R={key:!0,ref:!0,__self:!0,__source:!0};functionV(X,ae,De){varje,Re={},Fe=null,Be=null;if(ae!=null)for(jeinae.ref!==void0&&(Be=ae.ref),ae.key!==void0&&(Fe=""+ae.key),ae)B.call(ae,je)&&!R.hasOwnProperty(je)&&(Re[je]=ae[je]);varXe=arguments.length-2;if(Xe===1)Re.children=De;elseif(1<Xe){for(varZe=Array(Xe),st=0;st<Xe;st++)Ze[st]=arguments[st+2];Re.children=Ze}if(X&&X.defaultProps)for(jeinXe=X.defaultProps,Xe)Re[je]===void0&&(Re[je]=Xe[je]);return{$$typeof:e,type:X,key:Fe,ref:Be,props:Re,_owner:L.current}}functionY(X,ae){return{$$typeof:e,type:X.type,key:ae,ref:X.ref,props:X.props,_owner:X._owner}}functionZ(X){returntypeofX=="object"&&X!==null&&X.$$typeof===e}functionQ(X){varae={"=":"=0",":":"=2"};return"$"+X.replace(/[=:]/g,function(De){returnae[De]})}varG=/\/+/g;functionle(X,ae){returntypeofX=="object"&&X!==null&&X.key!=null?Q(""+X.key):ae.toString(36)}functionse(X,ae,De,je,Re){varFe=typeofX;(Fe==="undefined"||Fe==="boolean")&&(X=null);varBe=!1;if(X===null)Be=!0;elseswitch(Fe){case"string":case"number":Be=!0;break;case"object":switch(X.$$typeof){casee:caset:Be=!0}}if(Be)returnBe=X,Re=Re(Be),X=je===""?"."+le(Be,0):je,k(Re)?(De="",X!=null&&(De=X.replace(G,"$&/")+"/"),se(Re,ae,De,"",function(st){returnst})):Re!=null&&(Z(Re)&&(Re=Y(Re,De+(!Re.key||Be&&Be.key===Re.key?"":(""+Re.key).replace(G,"$&/")+"/")+X)),ae.push(Re)),1;if(Be=0,je=je===""?".":je+":",k(X))for(varXe=0;Xe<X.length;Xe++){Fe=X[Xe];varZe=je+le(Fe,Xe);Be+=se(Fe,ae,De,Ze,Re)}elseif(Ze=y(X),typeofZe=="function")for(X=Ze.call(X),Xe=0;!(Fe=X.next()).done;)Fe=Fe.value,Ze=je+le(Fe,Xe++),Be+=se(Fe,ae,De,Ze,Re);elseif(Fe==="object")throwae=String(X),Error("O
`),f[w].blockId=y.id}}});const h=Object.keys(f).map(y=>({line:f[y].content,blockId:f[y].blockId||"",index:parseInt(y)}));return e.path.includes("2024-04-07"),h}async function ER(e,t){let n=t.vault.getAbstractFileByPath(e);return n||(new C.Notice(E("File not found for the given thino path, is creating a new file")),n=await t.vault.create(e,'{"nodes": [], "edges": []}'),dt.setChangedByMemos(!0)),n}async function xR(e,t){var a;let n;try{n=await t.vault.read(e)}catch(o){console.error(o),n=await t.vault.cachedRead(e)}const r=(a=t.metadataCache.getFileCache(e))==null?void 0:a.frontmatterPosition;return r?n.slice(r.end.offset+1):n}function CR(e){const t=e.split(/\r?\n/),n=[];let r=!1,a=[],o="";for(let i=0;i<t.length;i++){const l=t[i];l.startsWith("> [!thino]")?(r&&(n.push({metadata:o,content:a.join(`
`);t.push(n.slice(0,r)),n=n.slice(r+1)}return t.push(n),t}async function XR({content:e,isList:t,name:n}){var N;const r=Le.getState().dailyNotesState.settings,a=C.moment(),o=ut.randomId(16),i=(r==null?void 0:r.MemoOtherSaveLocation.MemoDefaultMultiFilePath)||"Thino",l=n||`${a.format("YYYYMMDD")}-${o}`,c=`${i}/${l}.md`,f={id:o,content:e,deletedAt:"",path:c,createdAt:a.format("YYYY/MM/DD HH:mm:ss"),updatedAt:a.format("YYYY/MM/DD HH:mm:ss"),thinoType:t?"JOURNAL":"TASK-TODO",hasId:"",linkId:"",pinned:!1,visibility:"PUBLIC",rowStatus:"NORMAL",creatorName:"Thino",resourceList:[],sourceType:"MULTI",fileInfo:{tags:[],frontmatter:{}}},h=ft.getState().app||window.app,{vault:g,fileManager:y}=h,w=g.getAbstractFileByPath(i);(!w||!(w instanceof C.TFolder))&&(new C.Notice(E("Folder not found for the given thino path, is creating a new folder")),await g.createFolder(i)),dt.setChangedByMemos(!0);let S;const D=h.vault.getFileByPath(c);D?S=await g.create(`${i}/${a.format("YYYYMMDD")}-${o}.md`,e):S=await g.create(c,e),await y.processFrontMatter(S,_=>{_.id=o,_.createdAt=a.format("YYYY/MM/DD HH:mm:ss"),_.updatedAt=a.format("YYYY/MM/DD HH:mm:ss"),_.thinoType=t?"JOURNAL":"TASK-TODO"}),(!n||D)&&(r!=null&&r.SetFileNameAfterCreate)&&h.fileManager.promptForFileRename(S);const I=h.metadataCache.getFileCache(S),M={tags:((N=I==null?void 0:I.frontmatter)==null?void 0:N.tags)||[],frontmatter:(I==null?void 0:I.frontmatter)||{}};return{...f,fileInfo:M}}async function e_({content:e,isList:t}){var _;const n=Le.getState().dailyNotesState.settings,r=C.moment(),a=ut.randomId(16),o=(n==null?void 0:n.MemoOtherSaveLocation.MemoDefaultSingleFilePath)||"basic.thino.md",i={id:a,content:e,deletedAt:"",path:o,createdAt:r.format("YYYY/MM/DD HH:mm:ss"),updatedAt:r.format("YYYY/MM/DD HH:mm:ss"),thinoType:t?"JOURNAL":"TASK-TODO",hasId:"",linkId:"",pinned:!1,visibility:"PUBLIC",rowStatus:"NORMAL",creatorName:"Thino",resourceList:[],sourceType:"FILE",fileInfo:{tags:[],frontmatter:{}}},l=ft.getState().app,{vault:c}=l;let f=c.getAbstractFileByPath(o);(!f||!(f instanceof C.TFile))&&(new C.Notice(E("File not found for the given thino path, is creating a new file")),f=await c.create(o,""));const h=l.metadataCache.getFileCache(f),g={tags:((_=h==null?void 0:h.frontmatter)==null?void 0:_.tags)||[],frontmatter:(h==null?void 0:h.frontmatter)||{}};let y="";try{y=await c.read(f)||await c.cachedRead(f)}catch(k){console.error(k),new C.Notice(E("Failed to read current daily note, check if it exists."))}const w=y.indexOf(`#${r.format("YYYY-MM-DD")}`);let S=y.indexOf(`
${y.substring(S)}`}else N=`${y.substring(0,S)}${M}${y.substring(S)}`;return setTimeout(async()=>{dt.setChangedByMemos(!0),await c.modify(f,N)},200),{...i,fileInfo:g}}async function Px(e){var N;const t=Le.getState().dailyNotesState.settings,n=C.moment(e.createdAt,"YYYY/MM/DD HH:mm:ss"),r=e.id,a=(t==null?void 0:t.MemoOtherSaveLocation.MemoDefaultSingleFilePath)||"basic.thino.md",o={id:r,content:e.content,deletedAt:e.deletedAt||"",path:a,createdAt:n.format("YYYY/MM/DD HH:mm:ss"),updatedAt:n.format("YYYY/MM/DD HH:mm:ss"),thinoType:"JOURNAL",hasId:"",linkId:"",pinned:e.pinned,visibility:"PUBLIC",rowStatus:e.rowStatus||"NORMAL",creatorName:"Thino",resourceList:[],sourceType:"FILE",webId:e.id,fileInfo:e==null?void 0:e.fileInfo},i=ft.getState().app,{vault:l}=i;let c=l.getAbstractFileByPath(a);(!c||!(c instanceof C.TFile))&&(new C.Notice(E("File not found for the given thino path, is creating a new file")),c=await l.create(a,""));let f="";try{f=await l.read(c)||await l.cachedRead(c)}catch(_){console.error(_),new C.Notice(E("Failed to read current daily note, check if it exists."))}const h=i.metadataCache.getFileCache(c),g={tags:((N=h==null?void 0:h.frontmatter)==null?void 0:N.tags)||[],frontmatter:(h==null?void 0:h.frontmatter)||{}},y=f.indexOf(`#${n.format("YYYY-MM-DD")}`);let w=f.indexOf(`
${f.substring(w)}`}else M=`${f.substring(0,w)}${I}${f.substring(w)}`;return dt.setChangedByMemos(!0),await l.modify(c,M),{...o,fileInfo:g}}async function t_({content:e,isList:t}){const n=Le.getState().dailyNotesState.settings,r=(n==null?void 0:n.MemoOtherSaveLocation.MemoDefaultCanvasPath)||"basic.thino.canvas",a=C.moment(),o=ut.randomId(16),i={id:o,content:e,deletedAt:"",path:r,createdAt:a.format("YYYY/MM/DD HH:mm:ss"),updatedAt:a.format("YYYY/MM/DD HH:mm:ss"),thinoType:t?"JOURNAL":"TASK-TODO",hasId:"",linkId:"",pinned:!1,visibility:"PUBLIC",rowStatus:"NORMAL",creatorName:"Thino",resourceList:[],sourceType:"CANVAS",fileInfo:{tags:[],frontmatter:{}}},l=ft.getState().app,{vault:c}=l,f=await ER(r,l);if(!f||!(f instanceof C.TFile)){new C.Notice(E("File not found for the given thino path, is creating a new file"));return}const h=await c.read(f),g=JSON.parse(h);if(g.nodes.find(I=>I.id===i.id))return;let w;g.nodes.length>0&&(w=[...g.nodes].reduce((I,M)=>{if(!I.createdAt)return M;const N=C.moment(I.createdAt,"YYYY/MM/DD HH:mm:ss"),_=C.moment(M.createdAt,"YYYY/MM/DD HH:mm:ss");return N.isAfter(_)?I:M}));const S=w?{x:w.x,y:w.y+100,width:w.width,height:w.height}:{x:0,y:0,width:200,height:100};g.nodes.push({...S,type:"text",id:o,text:e,deletedAt:"",createdAt:a.format("YYYY/MM/DD HH:mm:ss"),updatedAt:a.format("YYYY/MM/DD HH:mm:ss"),thinoType:t?"JOURNAL":"TASK-TODO",hasId:"",linkId:"",pinned:!1,visibility:"PUBLIC",rowStatus:"NORMAL",creatorName:"Thino",resourceList:[]}),dt.setChangedByMemos(!0);const D=JSON.stringify(g,null,2);return await c.modify(f,D),i}async function bS(e,t,n,r){var $,he;const{vault:a}=Le.getState().dailyNotesState.app||window.app,o=Le.getState().dailyNotesState.app||window.app,i=Le.getState().dailyNotesState.settings,l=o.vault.getConfig("useTab")===void 0||window.app.vault.getConfig("useTab")===!0,c=l?1:o.vault.getConfig("tabSize"),f=(l?" ":" ").repeat(c),h=e.split(`
`+f:" "}${N?`[webId::${N}]`:""}`,B=qu(),L=fb(g,B),R="fake"+ut.randomId(16);letV=!1;constY=o.plugins.getPlugin("templater-obsidian");letZ;if(L?Z=L:(Y!=null&&Y.templater&&(Y!=null&&Y.settings.trigger_on_file_creation)&&(we.setWaitingForTemplater({origin:e,date:g,isList:t,id:R,type:N?"web":"local"}),V=!0),Z=awaitut.createDailyNoteCheck(g)),!Z){newC.Notice(E("Failed to create daily note, check if it exists."));return}if(L||awaitft.fechLocalDailyNotes(),Y&&(Y!=null&&Y.templater)&&(Y!=null&&Y.settings.trigger_on_file_creation)&&V)returndt.setChangedByMemos(!0),{id:R,content:e,deletedAt:"",createdAt:g.format("YYYY/MM/DD HH:mm:ss"),updatedAt:g.format("YYYY/MM/DD HH:mm:ss"),thinoType:t?"JOURNAL":"TASK-TODO",path:Z.path,hasId:"",linkId:"",webId:N,pinned:!1,visibility:"PUBLIC",rowStatus:"NORMAL",creatorName:"Thino",resourceList:[],sourceType:"DAILY",fileInfo:{tags:[],frontmatter:{}}};letQ="";try{Q=awaita.read(Z)||awaita.cachedRead(Z)}catch(ie){console.error(ie),newC.Notice(E("Failed to read current daily note, check if it exists."))}constG=o.metadataCache.getFileCache(Z),le={tags:((he=G==null?void0:G.frontmatter)==null?void0:he.tags)||[],frontmatter:(G==null?void0:G.frontmatter)||{}},se=awaitpA(I,k,Q);awaita.modify(Z,se.content);constfe=se.posNum===-1?mA(se.content).length-(k.split(`
`+w:" "}${f}`,_=qu(),k=fb(D,_),B="fake"+ut.randomId(16);letL=!1;constR=n.plugins.getPlugin("templater-obsidian");letV;if(k?V=k:(R!=null&&R.templater&&(R!=null&&R.settings.trigger_on_file_creation)&&(we.setWaitingForTemplater({origin:e.content,date:D,isList:e.thinoType&&e.thinoType==="JOURNAL",id:B,type:"local"}),L=!0),V=awaitut.createDailyNoteCheck(D)),!V){newC.Notice(E("Failed to create daily note, check if it exists.")),newC.Notice(E("Your content has been copied to clipboard, and inserted into the editor. Please try it again")),awaitnavigator.clipboard.writeText(e.content);const$=n.workspace.getLeavesOfType("thino_view").first();n.workspace.trigger("send-to-thino",e.content,$);return}if(k||awaitft.fechLocalDailyNotes(),R&&(R!=null&&R.templater)&&(R!=null&&R.settings.trigger_on_file_creation)&&L)returndt.setChangedByMemos(!0),{id:B,content:e.content,deletedAt:e.deletedAt??"",createdAt:D.format("YYYY/MM/DD HH:mm:ss"),updatedAt:D.format("YYYY/MM/DD HH:mm:ss"),thinoType:e.thinoType||"JOURNAL",path:V.path,hasId:"",linkId:"",pinned:e.pinned??!1,visibility:"PUBLIC",rowStatus:e.rowStatus??"NORMAL",webId:e.webId||e.id,creatorName:"Thino",resourceList:[],sourceType:"DAILY",fileInfo:(e==null?void0:e.fileInfo)||{tags:[],frontmatter:{}}};constY=n.metadataCache.getFileCache(V),Z={tags:((fe=Y==null?void0:Y.frontmatter)==null?void0:fe.tags)||[],frontmatter:(Y==null?void0:Y.frontmatter)||{}};letQ="";try{Q=awaitt.read(V)||awaitt.cachedRead(V)}catch($){console.error($),newC.Notice(E("Failed to read current daily note, check if it exists."))}constG=c==="end"?"":e.thinoType&&i&&l||a,le=awaitpA(G,N,Q);awaitt.modify(V,le.content);constse=le.posNum===-1?mA(le.content).length-1:le.posNum+1;returndt.setChangedByMemos(!0),{id:D.format("YYYYMMDDHHmm")+"00"+se,content:e.content,deletedAt:e.deletedAt??"",createdAt:D.format("YYYY/MM/DD HH:mm:ss"),updatedAt:D.format("YYYY/MM/DD HH:mm:ss"),thinoType:e.thinoType||"JOURNAL",path:V.path,hasId:"",linkId:"",pinned:e.pinned??!1,visibility:"PUBLIC",rowStatus:e.rowStatus??"NORMAL",webId:e.id,creatorName:"Thino",resourceList:[],sourceType:"DAILY",fileInfo:Z}}asyncfunctionpA(e,t,n){constr=newRegExp(`(s*?)${awaitKR(e)}(s*?)`),a=QR(n),o=a.findIndex(f=>r.test(f)),i=(e==null?void0:e.trim())===""?!0:o===-1;i&&console.error("unable to find insert after line in file.");constl=a.slice(o+1).findIndex(f=>/(^#+|---|^\^[a-zA-Z0-9-]{2,}$)/.test(f)),c=l!==-1;if(c){letf;for(leth=l+o;h>o;h--)if(!/^[\s\n ]*$/.test(a[h])){f=h;break}returnf||(f=o),awaitLx(t,n,i?-1:f,c)}elsereturnawaitLx(t,n,a.length-1,c)}asyncfunctionLx(e,t,n,r){if(n<-1)thrownewError("Invalid position");if(n===-1)return{content:`${t}
`:"")+i}`,posNum:n}}constmA=e=>e.split(/\r?\n/);asyncfunctionn_(e){constt=Le.getState().dailyNotesState.app,n=t.vault.getAbstractFileByPath(e.path);if(!(ninstanceofC.TFile)){newC.Notice(E("File not found for the given thino path"));return}awaitt.vault.delete(n)}asyncfunctionr_(e){constt=Le.getState().dailyNotesState.app,n=t.vault.getAbstractFileByPath(e.path);if(!(ninstanceofC.TFile)){newC.Notice(E("File not found for the given thino path"));return}consta=(awaitt.vault.read(n)).split(`
`),o=a.findIndex(c=>c.includes(e.id));if(o===-1){new C.Notice(E("Thino not found"));return}const i=a.findIndex((c,f)=>f>o&&c.trim()==="");i===-1?a.splice(o,a.length-o):a.splice(o,i-o);const l=a.join(`
`);if(!l){new C.Notice(E("Thino not found"));return}dt.setChangedByMemos(!0),await t.vault.modify(n,l)}async function a_(e){const t=Le.getState().dailyNotesState.app,n=t.metadataCache.getFirstLinkpathDest("",e.path);if(!n){new C.Notice(E("File not found for the given thino path"));return}const r=await t.vault.read(n),a=JSON.parse(r),o=a.nodes,i=o.findIndex(h=>h.id===e.id);if(i===-1){new C.Notice(E("Thino not found"));return}o.splice(i,1);const l=a.edges;l.filter(h=>h.fromNode===e.id||h.toNode===e.id).forEach(h=>{const g=l.findIndex(y=>y.id===h.id);g!==-1&&l.splice(g,1)}),dt.setChangedByMemos(!0);const f=JSON.stringify(a,null,2);await t.vault.modify(n,f)}async function o_(e){cA()||new C.Notice(E("If you are disabling the daily note plugin, it would be possible that the thino will not be deleted or patched properly. Please enable the plugin and try again."),5e3);const{vault:t,metadataCache:n}=Le.getState().dailyNotesState.app,r=e.path,a=t.getAbstractFileByPath(r);if(!a){new C.Notice(E("Please check your daily note plugin OR periodic notes plugin settings"));return}const o=await t.read(a),i=o.split(`
`),l=n.getFileCache(a),c=(l==null?void 0:l.listItems)||[],f=parseInt(e.id.slice(14));let h=f;function g(D,I){const M=[];for(const N in I)I[N]===D&&M.push(parseInt(N),...g(parseInt(N),I));return M}const y=C2(c),w=c.find(D=>D.position.start.line===f),S=g(f,y);if(S.length>0){const D=S.map(I=>{const M=c.find(N=>N.position.start.line===I);return M?M.position.end.line:-1});h=Math.max(...D,w.position.end.line)}else h=w.position.end.line;if(!o){new C.Notice(E("Thino not found"));return}dt.setChangedByMemos(!0),i.splice(f,h-f+1),await t.modify(a,i.join(`
`);return await n.modify(r,I),dt.setChangedByMemos(!0),{...e,id:t.id||e.id,thinoType:t.thinoType||e.thinoType,createdAt:e.createdAt||a.format("YYYY/MM/DD HH:mm:ss"),updatedAt:C.moment().format("YYYY/MM/DD HH:mm:ss"),content:t.content||e.content,rowStatus:t.rowStatus||e.rowStatus,visibility:t.visibility||e.visibility,pinned:t.pinned!==void 0?t.pinned:e.pinned,webId:t.webId||e.webId,deletedAt:t.deleted?a.format("YYYY/MM/DD HH:mm:ss"):t.deleted===!1?"":e.deletedAt?e.deletedAt:""}}async function Rl(e,t){if(!e.sourceType||e.sourceType!=="CANVAS")return e;const{vault:n}=Le.getState().dailyNotesState.app,r=n.getAbstractFileByPath(e.path);if(!r)return e;const a=await n.read(r),o=JSON.parse(a),i=o.nodes.find(f=>f.id===e.id);if(!i)return e;t.content&&(i.text=t.content),t.thinoType&&(i.thinoType=t.thinoType),t.rowStatus&&(i.rowStatus=t.rowStatus),t.visibility&&(i.visibility=t.visibility),t.pinned!==void 0&&(i.pinned=t.pinned),t.webId&&(i.webId=t.webId);const l=C.moment();t.deleted!==void 0&&(i.deletedAt=t.deleted?l.format("YYYY/MM/DD HH:mm:ss"):""),i.updatedAt=l.format("YYYY/MM/DD HH:mm:ss");const c=JSON.stringify(o,null,2);return await n.modify(r,c),dt.setChangedByMemos(!0),{...e,thinoType:t.thinoType||e.thinoType,createdAt:e.createdAt,updatedAt:C.moment().format("YYYY/MM/DD HH:mm:ss"),content:t.content??e.content,rowStatus:t.rowStatus??e.rowStatus,visibility:t.visibility??e.visibility,pinned:t.pinned??e.pinned,webId:t.webId??e.webId,deletedAt:t.deleted?l.format("YYYY/MM/DD HH:mm:ss"):t.deleted===!1?"":e.deletedAt?e.deletedAt:""}}async function _l(e,t){var le;cA()||new C.Notice(E("If you are disabling the daily note plugin, it would be possible that the thino will not be deleted or patched properly. Please enable the plugin and try again."));const{vault:n,metadataCache:r}=Le.getState().dailyNotesState.app,a=Le.getState().dailyNotesState.app,{settings:o}=Le.getState().dailyNotesState,i=e.id.toString().slice(0,14),l=C.moment(e.createdAt,"YYYY/MM/DD HH:mm:ss").isSame(C.moment(i,"YYYYMMDDHHmmss"))?C.moment(e.createdAt,"YYYY/MM/DD HH:mm:ss"):C.moment(i,"YYYYMMDDHHmmss"),c=C.moment(e.createdAt,"YYYY/MM/DD HH:mm:ss").isSame(l,"day"),f=e.path,h=n.getAbstractFileByPath(f)||n.getAbstractFileByPath(e.path);if(!h)return new C.Notice(E("Please check your daily note plugin OR periodic notes plugin settings")),e;const y=(await n.read(h)).split(`
`),w=r.getFileCache(h),S=(w==null?void 0:w.listItems)||[];if(S.length===0)return new C.Notice(E("Thino not found")),e;const D=parseInt(e.id.slice(14));let I=D;function M(se,fe){const $=[];for(const he in fe)fe[he]===se&&$.push(parseInt(he),...M(parseInt(he),fe));return $}const N=C2(S),_=S.find(se=>se.position.start.line===D);if(!_)return new C.Notice(E("Thino not found")),e;const k=M(D,N);if(k.length>0){const se=k.map(fe=>{const $=S.find(he=>he.position.start.line===fe);return $?$.position.end.line:-1});I=Math.max(...se,_.position.end.line)}else I=_.position.end.line;const B=y.slice(D,I+1);let L=B.join(`
`),nr=tn(jr,ha,fr).desc("newline"),Lr=tn(nr,Er);o.all=kn,o.alt=tn,o.any=Zn,o.cr=fr,o.createLanguage=function(te){var me={};for(var Ce in te)({}).hasOwnProperty.call(te,Ce)&&function(Ye){me[Ye]=Xt(function(){return te[Ye](me)})}(Ce);return me},o.crlf=jr,o.custom=function(te){return o(te(R,V))},o.digit=pt,o.digits=Mt,o.empty=dn,o.end=Lr,o.eof=Er,o.fail=Tt,o.formatError=Xe,o.index=en,o.isParser=k,o.lazy=Xt,o.letter=Jt,o.letters=sn,o.lf=ha,o.lookahead=Gt,o.makeFailure=V,o.makeSuccess=R,o.newline=nr,o.noneOf=function(te){return Vt(function(me){return te.indexOf(me)<0}).desc("none of '"+te+"'")},o.notFollowedBy=_t,o.of=St,o.oneOf=function(te){for(var me=te.split(""),Ce=0;Ce<me.length;Ce++)me[Ce]="'"+me[Ce]+"'";return Vt(function(Ye){return te.indexOf(Ye)>=0}).desc(me)},o.optWhitespace=ln,o.Parser=o,o.range=function(te,me){return Vt(function(Ce){return te<=Ce&&Ce<=me}).desc(te+"-"+me)},o.regex=ht,o.regexp=ht,o.sepBy=_e,o.sepBy1=et,o.seq=st,o.seqMap=xt,o.seqObj=function(){for(var te,me={},Ce=0,Ye=(te=arguments,Array.prototype.slice.call(te)),He=Ye.length,Qe=0;Qe<He;Qe+=1){var tt=Ye[Qe];if(!k(tt)){if(B(tt)&&tt.length===2&&typeof tt[0]=="string"&&k(tt[1])){var kt=tt[0];if(Object.prototype.hasOwnProperty.call(me,kt))throw new Error("seqObj: duplicate key "+kt);me[kt]=!0,Ce++;continue}throw new Error("seqObj arguments must be parsers or [string, parser] array pairs.")}}if(Ce===0)throw new Error("seqObj expects at least one named parser, found zero");return o(function(Yt,On){for(var yn,xr={},Jn=0;Jn<He;Jn+=1){var yr,ta;if(B(Ye[Jn])?(yr=Ye[Jn][0],ta=Ye[Jn][1]):(yr=null,ta=Ye[Jn]),!(yn=Y(ta._(Yt,On),yn)).status)return yn;yr&&(xr[yr]=yn.value),On=yn.index}return Y(R(On,xr),yn)})},o.string=nt,o.succeed=St,o.takeWhile=function(te){return fe(te),o(function(me,Ce){for(var Ye=Ce;Ye<me.length&&te(le(me,Ye));)Ye++;return R(Ye,me.slice(Ce,Ye))})},o.test=Vt,o.whitespace=vr,o["fantasy-land/empty"]=dn,o["fantasy-land/of"]=St,o.Binary={bitSeq:w,bitSeqObj:function(te){y();var me={},Ce=0,Ye=f(function(Qe){if(B(Qe)){var tt=Qe;if(tt.length!==2)throw new Error("["+tt.join(", ")+"] should be length 2, got length "+tt.length);if($(tt[0]),se(tt[1]),Object.prototype.hasOwnProperty.call(me,tt[0]))throw new Error("duplicate key in bitSeqObj: "+tt[0]);return me[tt[0]]=!0,Ce++,tt}return se(Qe),[null,Qe]},te);if(Ce<1)throw new Error("bitSeqObj expects at least one named pair, got ["+te.join(", ")+"]");var He=f(function(Qe){return Qe[0]},Ye);return w(f(function(Qe){return Qe[1]},Ye)).map(function(Qe){return c(function(tt,kt){return kt[0]!==null&&(tt[kt[0]]=kt[1]),tt},{},f(function(tt,kt){return[tt,Qe[kt]]},He))})},byte:function(te){if(y(),se(te),te>255)throw new Error("Value specified to byte constructor ("+te+"=0x"+te.toString(16)+") is larger in value than a single byte.");var me=(te>15?"0x":"0x0")+te.toString(16);return o(function(Ce,Ye){var He=le(Ce,Ye);return He===te?R(Ye+1,He):V(Ye,me)})},buffer:function(te){return S("buffer",te).map(function(me){return Buffer.from(me)})},encodedString:function(te,me){return S("string",me).map(function(Ce){return Ce.toString(te)})},uintBE:I,uint8BE:I(1),uint16BE:I(2),uint32BE:I(4),uintLE:M,uint8LE:M(1),uint16LE:M(2),uint32LE:M(4),intBE:N,int8BE:N(1),int16BE:N(2),int32BE:N(4),intLE:_,int8LE:_(1),int16LE:_(2),int32LE:_(4),floatBE:S("floatBE",4).map(function(te){return te.readFloatBE(0)}),floatLE:S("floatLE",4).map(function(te){return te.readFloatLE(0)}),doubleBE:S("doubleBE",8).map(function(te){return te.readDoubleBE(0)}),doubleLE:S("doubleLE",8).map(function(te){return te.readDoubleLE(0)})},n.exports=o}])})})(pe);var H2=()=>/(?:[#*0-9]\uFE0F?\u20E3|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26AA\u26B0\u26B1\u26BD\u26BE\u26C4\u26C8\u26CF\u26D1\u26D3\u26E9\u26F0-\u26F5\u26F7\u26F
${o}`,posNum:n}}function LH(e,t,n){var a;const r=t.workspace.getLeavesOfType("markdown");for(const o of r){const i=o.view;if(((a=i==null?void 0:i.file)==null?void 0:a.path)===e){t.workspace.revealLeaf(o);try{return o.view.setEphemeralState({line:n}),!0}catch(l){return console.error(l),!1}}}return!1}const U2=async e=>{var o;const t=ft.getState().app,n=t.workspace.getLeavesOfType("markdown");for(const i of n){const l=i.view;if(((o=l==null?void 0:l.file)==null?void 0:o.path)===e){t.workspace.revealLeaf(i);return}}const r=t.metadataCache.getFirstLinkpathDest("",e);if(!r){new C.Notice(E("File not found for the given thino path"));return}await t.workspace.getLeaf(!0).openFile(r)},z2=async(e,t)=>{const{app:n}=ft.getState(),r=parseInt(e.slice(14));if(LH(t,n,r))return;const a=n.metadataCache.getFirstLinkpathDest("",t);if(!C.Platform.isMobile)await n.workspace.getLeaf(!0).openFile(a,{eState:{line:r}});else{let o=n.workspace.activeLeaf;o===null&&(o=n.workspace.getLeaf(!0)),await o.openFile(a,{eState:{line:r}})}},V2=async(e,t)=>{var f,h,g;const n=ft.getState().app,r=n.metadataCache.getFirstLinkpathDest("",t);if(!r){new C.Notice(E("File not found for the given thino path"));return}let a="";try{a=await n.vault.read(r)}catch(y){console.error(y),a=await n.vault.cachedRead(r)}const i=a.split(/\r?\n/).findIndex(y=>y.contains(e)),l=n.workspace.getLeavesOfType("markdown");for(const y of l){const w=y.view;if(((f=w==null?void 0:w.file)==null?void 0:f.path)===r.path){n.workspace.revealLeaf(y);try{(h=y.view.editor)==null||h.setCursor({line:i,ch:1});return}catch(S){console.error(S)}}}const c=n.workspace.getLeaf(!0);await c.openFile(r,{eState:{line:i}});try{(g=c.view.editor)==null||g.setCursor({line:i,ch:1})}catch(y){console.error(y)}},W2=async(e,t)=>{var l;const n=ft.getState().app,r=(c,f)=>{var g;const h=(g=Array.from(c.nodes.values()))==null?void 0:g.find(y=>y.id===f);return h?(c.selectOnly(h),c.zoomToSelection(),!0):!1},a=n.workspace.getLeavesOfType("canvas");for(const c of a){const f=c.view;if(((l=f==null?void 0:f.file)==null?void 0:l.path)===t&&(n.workspace.revealLeaf(c),r(f.canvas,e)))return}const o=n.metadataCache.getFirstLinkpathDest("",t);if(!o){new C.Notice(E("File not found for the given thino path"));return}const i=n.workspace.getLeaf(!0);await i.openFile(o),setTimeout(()=>{var c;r((c=i.view)==null?void 0:c.canvas,e)},10)};class RH{constructor(){Se(this,"initialized",!1)}getState(){return Le.getState().memoState}async fetchAllMemos(){const t=ft.getState().settings;ut.checkDailyInMulti(t);const n=await Ko.getMyMemos(t.EnabledLocationList.map(o=>o.value)),r=[...n.memos],a=[...n.commentMemos];return Le.dispatch({type:"SET_MEMOS",payload:{memos:r}}),Le.dispatch({type:"SET_COMMENT_MEMOS",payload:{commentMemos:a}}),this.initialized||(this.initialized=!0,dt.setLoaded(!0)),r}async updateTypeMemos(t){const n=await Ko.updateSpecificTypeMemo(t),r=this.getState().memos.filter(a=>a.sourceType!==t);Le.dispatch({type:"SET_MEMOS",payload:{memos:[...r,...n.memos]}})}async removeTypeMemos(t){const n=this.getState().memos.filter(r=>r.sourceType!==t);Le.dispatch({type:"SET_MEMOS",payload:{memos:[...n]}})}async fetchDeletedMemos(){const t=await Ko.getMyDeletedMemos();return t.sort((n,r)=>ut.getTimeStampByDate(r.deletedAt)-ut.getTimeStampByDate(n.deletedAt)),t}pushMemo(t){Le.dispatch({type:"INSERT_MEMO",payload:{memo:{...t}}})}pushCommentMemo(t){Le.dispatch({type:"INSERT_COMMENT_MEMO",payload:{memo:{...t}}})}getMemoById(t){for(const n of this.getState().memos)if(n.id===t)return n;return null}getCommentMemoById(t){for(const n of this.getState().commentMemos)if(n.id===t)return n;return null}getMemoByWebId(t){for(const n of this.getState().memos)if(n.webId===t||n.id===t)return n;return null}async finishWaitingForTemplaterThinos(){const t=this.getState().preparingUpdateMemo;if(t.length!==0)for(const n of t){const r=this.getMemoById(n.id),a=n.type==="local"?await bS(n.origin,n.isList,n.date,!0):await jx(r);await this.replaceOldThinoWithNewThino(n.id,a),Le.dispatch({type:"REMOVE_PARTICULAR_PREPARE_UPDATE_THINO",payload:{id:n.id}})}}async replaceOldThinoWithNew
Checkthedocumentationorcreateissueifyouthinkit's bug. https://github.com/webscopeio/react-textarea-autocomplete/issues`))},CY=[".","^","$","*","+","-","?","(",")","[","]","{","}","\\","|"],E0=function(t){return DY(t).map(function(n){return CY.includes(n)?"\\".concat(n):n}).join("")},MY=function(e){Tb(t,e);function t(){return Rv(this,t),Db(this,wp(t).apply(this,arguments))}return Sb(t,[{key:"componentDidMount",value:function(){var r=this.props.boundariesElement;if(typeof r=="string"){var a=document.querySelector(r);if(!a)throw new Error("RTA: Invalid prop boundariesElement: it has to be string or HTMLElement.");this.containerElem=a}else if(r instanceof HTMLElement)this.containerElem=r;else throw new Error("RTA: Invalid prop boundariesElement: it has to be string or HTMLElement.");if(!this.containerElem||!this.containerElem.contains(this.ref))throw new Error("RTA: Invalid prop boundariesElement: it has to be one of the parents of the RTA.")}},{key:"componentDidUpdate",value:function(){var r,a,o=this.props.top||0,i=this.props.left||0,l=[],c=[],f=0,h=0,g=this.containerElem.getBoundingClientRect(),y=this.ref.getBoundingClientRect(),w=this.props.textareaRef.getBoundingClientRect(),S=window.getComputedStyle(this.ref),D=parseInt(S.getPropertyValue("margin-top"),10),I=parseInt(S.getPropertyValue("margin-bottom"),10),M=parseInt(S.getPropertyValue("margin-left"),10),N=parseInt(S.getPropertyValue("margin-right"),10),_=D+I+w.top+o+y.height,k=M+N+w.left+i+y.width;k>g.right&&w.left+i>y.width?(h=i-y.width,l.push(Yc.X.LEFT),c.push(Yc.X.RIGHT)):(h=i,l.push(Yc.X.RIGHT),c.push(Yc.X.LEFT)),_>g.bottom&&w.top+o>y.height?(f=o-y.height,l.push(Yc.Y.TOP),c.push(Yc.Y.BOTTOM)):(f=o,l.push(Yc.Y.BOTTOM),c.push(Yc.Y.TOP)),this.props.renderToBody&&(f+=w.top,h+=w.left),this.ref.style.top="".concat(f,"px"),this.ref.style.left="".concat(h,"px"),(r=this.ref.classList).remove.apply(r,c),(a=this.ref.classList).add.apply(a,l)}},{key:"render",value:function(){var r=this,a=this.props,o=a.style,i=a.className,l=a.innerRef,c=a.children,f=a.renderToBody,h=document.body,g=ne.createElement("div",{ref:function(w){r.ref=w,l(w)},className:"rta__autocomplete ".concat(i||""),style:o},c);return f&&h!==null?q2.createPortal(g,h):g}}]),t}(ne.Component),T6=function(e){Tb(t,e);function t(n){var r;Rv(this,t),r=Db(this,wp(t).call(this,n)),r.state={top:null,left:null,currentTrigger:null,actualToken:"",data:null,value:"",dataLoading:!1,selectionEnd:0,component:null,textToReplace:null},r.escListenerInit=function(){r.escListener||(r.escListener=uf.add(Ci.ESC,r._closeAutocomplete))},r.escListenerDestroy=function(){r.escListener&&(uf.remove(r.escListener),r.escListener=null)},r.getSelectionPosition=function(){return r.textareaRef?{selectionStart:r.textareaRef.selectionStart,selectionEnd:r.textareaRef.selectionEnd}:null},r.getSelectedText=function(){if(!r.textareaRef)return null;var c=r.textareaRef,f=c.selectionStart,h=c.selectionEnd;return f===h?null:r.state.value.substr(f,h-f)},r.setCaretPosition=function(){var c=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;r.textareaRef&&(r.textareaRef.focus(),r.textareaRef.setSelectionRange(c,c))},r.getCaretPosition=function(){if(!r.textareaRef)return 0;var c=r.textareaRef.selectionEnd;return c},r._handleCaretChange=function(c){var f=function(){var y=r.getCaretPosition()-1;r.lastTrigger=r.lastTrigger?y:0};if(c.type==="keydown"){var h=c.keyCode||c.which;switch(h){case Ci.UP:case Ci.DOWN:r._isAutocompleteOpen()||f();break;case Ci.LEFT:case Ci.RIGHT:f();break}return}f()},r._onSelect=function(c){var f=r.state,h=f.selectionEnd,g=f.currentTrigger,y=f.value,w=r.props.onItemSelected;if(g){var S=r._getTextToReplace(g);if(!S){r._closeAutocomplete();return}var D=S(c);if(!D){r._closeAutocomplete();return}w&&w({currentTrigger:g,item:c});var I=function(Z,Q,G){switch(Z){case"start":return G;case"next":case"end":return G+Q.length;default:if(!Number.isInteger(Z))throw new Error('RTA:caretPositionshouldbe"start","next","end"ornumber.');returnZ}},M=y.slice(0,h),N=E0(g),_=M.length-M.lastIndexOf(g),k=M.search(newRegExp("(?!".concat(N,")$")
`));if(y===null)return null;if(typeof y=="string")return{text:y,caretPosition:bC};if(!y.text&&typeof y.text!="string")throw new Error('Output "text" is not defined! Object should has shape {text: string, caretPosition: string | number}. Check the implementation for trigger "'.concat(c,`"
`));if(!y.caretPosition)throw new Error('Output "caretPosition" is not defined! Object should has shape {text: string, caretPosition: string | number}. Check the implementation for trigger "'.concat(c,`"
`));return y}if(typeof g!="string")throw new Error(`Outputitemshouldbestring
`);return{text:"".concat(c).concat(g).concat(c),caretPosition:bC}}},r._getCurrentTriggerSettings=function(){var c=r.state.currentTrigger;return c?r.props.trigger[c]:null},r._getValuesFromProvider=function(){var c=r.state,f=c.currentTrigger,h=c.actualToken,g=r._getCurrentTriggerSettings();if(!(!f||!g)){var y=g.dataProvider,w=g.component;if(typeof y!="function")throw new Error("Trigger provider has to be a function!");r.setState({dataLoading:!0});var S=y(h);S instanceof Promise||(S=Promise.resolve(S)),S.then(function(D){if(!Array.isArray(D))throw new Error("Trigger provider has to provide an array!");if(typeof w!="function")throw new Error("Component should be defined!");if(f===r.state.currentTrigger){if(!D.length){r._closeAutocomplete();return}r.setState({dataLoading:!1,data:D,component:w})}}).catch(function(D){return SC(D.message)})}},r._getSuggestions=function(){var c=r.state,f=c.currentTrigger,h=c.data;return!f||!h||h&&!h.length?null:h},r._createRegExp=function(){var c=r.props.trigger;r.tokenRegExp=new RegExp("(".concat(Object.keys(c).sort(function(f,h){return f<h?1:f>h?-1:0}).map(function(f){return E0(f)}).join("|"),")((?:(?!\\1)[^\\s])*$)")),r.tokenRegExpEnding=new RegExp("(".concat(Object.keys(c).sort(function(f,h){return f<h?1:f>h?-1:0}).map(function(f){return E0(f)}).join("|"),")$"))},r._closeAutocomplete=function(){var c=r.state.currentTrigger;r.escListenerDestroy(),r.setState({data:null,dataLoading:!1,currentTrigger:null},function(){c&&r._onItemHighlightedHandler(null)})},r._cleanUpProps=function(){var c=vY({},r.props),f=["loadingComponent","boundariesElement","containerStyle","minChar","scrollToItem","ref","innerRef","onChange","onCaretPositionChange","className","value","trigger","listStyle","itemStyle","containerStyle","loaderStyle","className","containerClassName","listClassName","itemClassName","loaderClassName","dropdownStyle","dropdownClassName","movePopupAsYouType","textAreaComponent","renderToBody","onItemSelected","onItemHighlighted"];for(var h in c)f.includes(h)&&delete c[h];return c},r._changeHandler=function(c){var f=r.props,h=f.trigger,g=f.onChange,y=f.minChar,w=f.onCaretPositionChange,S=f.movePopupAsYouType,D=r.state,I=D.top,M=D.left,N=c;N||(N=new mY("change",{bubbles:!0}),r.textareaRef.dispatchEvent(N));var _=N.target||r.textareaRef,k=_.selectionEnd,B=_.value;if(r.lastValueBubbledEvent=B,g&&N&&(N.persist&&N.persist(),g(new Proxy(N,{get:function(X,ae,De){return ae==="target"?_:Reflect.get(X,ae,De)}}))),w){var L=r.getCaretPosition();w(L)}r.setState({value:B});var R=function(){var X=fY(_,k),ae=X.top,De=X.left;r.setState({top:ae-r.textareaRef.scrollTop||0,left:De})},V=function(X){r.lastTrigger=k-X,r._closeAutocomplete(),R()};if(k<=r.lastTrigger){var Y=B.slice(0,k),Z=r.tokenRegExp.exec(Y);V(Z?Z[0].length:0)}var Q=B.slice(r.lastTrigger,k),G=r.tokenRegExp.exec(Q),le=G&&G[0],se=G&&G[1]||null,fe=se?se.length-1:0,$=r.tokenRegExpEnding.exec(Q);if($?V($[0].length):r._isAutocompleteOpen()||r._closeAutocomplete(),(!le||le.length<=y+fe)&&(r.state.currentTrigger&&!h[r.state.currentTrigger].allowWhitespace||!r.state.currentTrigger)){r._closeAutocomplete();return}if(se&&h[se].afterWhitespace&&!/\s/.test(B[k-le.length-1])&&B[k-le.length-1]!==void 0){r._closeAutocomplete();return}if(r.state.currentTrigger&&h[r.state.currentTrigger].allowWhitespace){if(G=new RegExp("".concat(E0(r.state.currentTrigger),".*$")).exec(B.slice(0,k)),le=G&&G[0],!le){r._closeAutocomplete();return}se=Object.keys(h).find(function(ce){return ce.slice(0,fe+1)===le.slice(0,fe+1)})||null}var he=le.slice(1);if(se){(S||I===null&&M===null||r.state.currentTrigger!==se)&&R(),r.escListenerInit();var ie=r._getTextToReplace(se);r.setState({selectionEnd:k,currentTrigger:se,textToReplace:ie,actualToken:he},function(){try{r._getValuesFromProvider()}catch(ce){SC(ce.message)}})}},r._selectHandler=function(c){var f=r.props,h=f.onCaretPositionChange,g=f.onSelect;if(h){var y=r.getCaretPosition();h(y)}g&&(c.persist(),g(c))},r._shouldStayOpen=function(c){var f=c.relatedTarget;return f===null&&(f=document.activeElement),!!(r.dropdownRef&&f instanceof Node&&r.dropd
`,Lue="\uFEFF",$8=e=>Object.assign({},Pue,e);let Rue=class extends Error{constructor(t){super(t),this.name="CsvGenerationError"}},_ue=class extends Error{constructor(t){super(t),this.name="EmptyHeadersError"}};var Qv=e=>e,Us=e=>e,qb=Qv,xp=Qv,S3=Qv,D3=Qv,Bue=function(e,t){return t=='"'&&e.indexOf('"')>-1?e.replace(/"/g,'""'):e},Hue=e=>S3(typeof e=="object"?e.key:e),Yue=e=>D3(typeof e=="object"?e.displayLabel:e),Uue=(e,...t)=>t.reduce((n,r)=>r(n),e),zue=e=>t=>e.useBom?qb(Us(t)+Lue):t,Vue=e=>t=>e.showTitle?BI(qb(Us(t)+e.title))(xp("")):t,BI=e=>t=>qb(Us(e)+Us(t)+jue),Z8=e=>(t,n)=>Wue(e)(xp(t+n)),Wue=e=>t=>Qv(Us(t)+e.fieldSeparator),$ue=(e,t)=>n=>{if(!e.showColumnHeaders)return n;if(t.length<1)throw new _ue("Option to show headers but none supplied. Make sure there are keys in your collection or that you've supplied headers through the config options.");let r=xp("");for(let a=0;a<t.length;a++){const o=Yue(t[a]);r=Z8(e)(r,q8(e,o))}return r=xp(Us(r).slice(0,-1)),BI(n)(r)},Zue=(e,t,n)=>r=>{let a=r;for(var o=0;o<n.length;o++){let i=xp("");for(let l=0;l<t.length;l++){const c=Hue(t[l]),f=typeof n[o][Us(c)]>"u"?e.replaceUndefinedWith:n[o][Us(c)];i=Z8(e)(i,q8(e,f))}i=xp(Us(i).slice(0,-1)),a=BI(a)(i)}return a},que=Us,T3=e=>+e===e&&(!isFinite(e)||!!(e%1)),q8=(e,t)=>{if(e.decimalSeparator==="locale"&&T3(t))return t.toLocaleString();if(e.decimalSeparator!=="."&&T3(t))return t.toString().replace(".",e.decimalSeparator);if(typeof t=="string"){let n=t;return(e.quoteStrings||e.fieldSeparator&&t.indexOf(e.fieldSeparator)>-1||e.quoteCharacter&&t.indexOf(e.quoteCharacter)>-1||t.indexOf(`
`)>-1||t.indexOf("\r")>-1)&&(n=e.quoteCharacter+Bue(t,e.quoteCharacter)+e.quoteCharacter),n}if(typeof t=="boolean"&&e.boolDisplay){const n=t?"true":"false";return e.boolDisplay[n]}return t},Gue=e=>t=>{const n=$8(e),r=n.useKeysAsHeaders?Object.keys(t[0]):n.columnHeaders;let a=Uue(qb(""),zue(n),Vue(n),$ue(n,r),Zue(n,r,t));if(Us(a).length<1)throw new Rue("Output is empty. Is your data formatted correctly?");return a};const Jue=({thino:e})=>{const t=P.useRef(null);P.useEffect(()=>(t.current&&C.setIcon(t.current,"pin"),()=>{t.current&&(t.current=null)}),[t]);const n=P.useCallback(async()=>{e.pinned?await we.unpinMemoById(e.id):await we.pinMemoById(e.id)},[e]);return v.jsx("span",{ref:t,className:ar("pinned-status",e.pinned?"pinned":"not-pinned"),onClick:n})},Kue=({thino:e})=>{var r;const t=P.useRef(null);P.useEffect(()=>(t.current&&C.setIcon(t.current,e.thinoType==="JOURNAL"?"calendar":"check-square"),()=>{t.current&&(t.current=null)}),[t,e==null?void 0:e.thinoType]);const n=P.useCallback(async()=>{if(e.thinoType==="JOURNAL")return;const a=await we.updateMemo(e.id,e.content,e.thinoType==="TASK-TODO"?"TASK-DONE":"TASK-TODO");a&&we.editMemo(a)},[e]);return v.jsx(v.Fragment,{children:e.thinoType!=="JOURNAL"?v.jsx("input",{className:ar("thino-type-status","task-list-item-checkbox"),type:"checkbox",checked:e.thinoType!=="TASK-TODO","data-task":e.thinoType==="TASK-TODO"?"":e.thinoType==="TASK-DONE"?"x":(r=e.thinoType)==null?void 0:r.slice(5),onClick:n}):v.jsx("span",{ref:t,className:"thino-type-status"})})},Que=({id:e,path:t})=>{const n=P.useRef(null);P.useEffect(()=>(n.current&&C.setIcon(n.current,"link"),()=>{n.current&&(n.current=null)}),[]);const r=P.useCallback(()=>{!e||!t||we.openThinoByID(e)},[e,t]);return v.jsxs("span",{className:"source-thino",onClick:r,children:[v.jsx("span",{children:t}),v.jsx("span",{ref:n,className:"source-thino-icon"})]})},Xue=({id:e,sourceType:t})=>{const n=P.useRef(null);P.useEffect(()=>{var a;return n.current&&C.setIcon(n.current,((a=Jg.find(o=>o.title===t))==null?void 0:a.icon)||"list"),()=>{n.current&&(n.current=null)}},[]);const r=P.useCallback(async()=>{e&&await we.openThinoByID(e)},[e]);return v.jsx("span",{ref:n,className:"source-type-icon",onClick:r})},I3=(e,t,n,r)=>{const a=Cue(e.getValue(t),n);return r({itemRank:a}),a.passed},E3=(e,t,n)=>{var a,o;let r=0;return e.columnFiltersMeta[n]&&(r=Nue((a=e.columnFiltersMeta[n])==null?void 0:a.itemRank,(o=t.columnFiltersMeta[n])==null?void 0:o.itemRank)),r===0?cp.alphanumeric(e,t,n):r},ece=$8({fieldSeparator:",",decimalSeparator:".",useKeysAsHeaders:!0}),tce=e=>e+`
`,L.current,t.path,a||e.view)}he(),setTimeout(async()=>{await G()},oA)},[B,L,l,M]);const G=async()=>{B.current&&(await eCe(B.current),await $E(B.current),tCe(M).then(he=>{he&&setTimeout(()=>{Cb(B.current,{pixelRatio:window.devicePixelRatio*2}).then(ie=>{k(ie),f(!0)}).catch(()=>{})},600)}))},le=()=>{n()},se=P.useCallback(he=>{w(he)},[y]),fe=async()=>{const{vault:he}=Le.getState().dailyNotesState.app,ie=B.current.querySelector(".memo-shortcut-img");if(!ie)return;const ce=ie==null?void 0:ie.getAttribute("src").split("base64,")[1],X=nN(ce,"image/png");let ae;X.arrayBuffer().then(async De=>{const je="png",Re=qu();for(const Fe in Re)if(Re[Fe]instanceof C.TFile){ae=Re[Fe];break}if(ae!==void 0){const Fe=await he.getAvailablePathForAttachments(`PastedImage${C.moment().format("YYYYMMDDHHmmss")}`,je,ae);await he.createBinary(Fe,De),new C.Notice(E("Save image successfully"))}})},$=async()=>{se(!0);const he=B.current.querySelector(".memo-shortcut-img");if(!he)return;const ie=he==null?void 0:he.getAttribute("src").split("base64,")[1],ce=nN(ie,"image/png");if(!ce){new C.Notice(E("Copy to clipboard failed"));return}const X=new ClipboardItem({"image/png":ce});window.navigator.clipboard.write([X]).then(()=>{setTimeout(()=>{se(!1)},500)}),new C.Notice(E("Copy to clipboard successfully"))};return v.jsxs(v.Fragment,{children:[v.jsxs("div",{className:ar("dialog-header-container"),children:[v.jsxs("p",{className:"title-text",children:[v.jsx("span",{className:"icon-text",children:"🥰"}),E("Share Memo Image")]}),v.jsxs("div",{className:"btn-group",children:[C.Platform.isMobile&&v.jsx("button",{ref:I,className:"btn download-btn",onClick:fe}),v.jsx("button",{ref:S,className:"btn copy-btn",onClick:$}),v.jsx("button",{ref:D,className:"btn close-btn",onClick:le})]})]}),v.jsxs("div",{className:ar("dialog-content-container",M),children:[v.jsx("div",{className:`tip-words-container${_?"finish":"loading"}`,children:v.jsx("p",{className:"tip-text",children:E(_?"↗Click the button to save":"Image is generating...")})}),v.jsxs("div",{className:"setting-item",children:[v.jsxs("div",{className:"setting-item-info",children:[v.jsx("div",{className:"setting-item-name",children:E("Default sharing style")}),v.jsx("div",{className:"setting-item-description",children:E("Set the default style for sharing thino, 'Modern' by default.")})]}),v.jsx("div",{className:"setting-item-control",children:v.jsxs("select",{className:"dropdown",defaultValue:M,onChange:async he=>{he.currentTarget.value!==M&&(f(!1),k(""),N(he.currentTarget.value),(o||window.app).saveLocalStorage("memoShareDialogStyle",he.currentTarget.value),await G())},children:[v.jsx("option",{value:"modern",children:E("Modern")}),v.jsx("option",{value:"clean",children:E("Clean")}),v.jsx("option",{value:"minimal",children:E("Minimal")}),v.jsx("option",{value:"gradient",children:E("Gradient")})]})})]}),v.jsxs("div",{className:ar("memo-container",M),ref:B,children:[v.jsx(ts,{when:_!=="",children:v.jsx("img",{className:"memo-shortcut-img",onClick:$,src:_})}),v.jsxs("div",{className:"memo-background",children:[v.jsx("div",{className:"property-image",style:{backgroundSize:"cover",backgroundRepeat:"no-repeat",backgroundPosition:"center"}}),v.jsx("span",{className:"background-container"}),v.jsxs("div",{className:"thino-user-header",children:[v.jsx("div",{className:"thino-user-icon",ref:he=>{if(i!=null&&i.MomentsIcon){he==null||he.empty();return}i!=null&&i.MomentsIcon||he&&C.setIcon(he,"Memos")},style:{backgroundImage:`url("${R}")`}}),v.jsxs("div",{className:"thino-user-info",children:[v.jsx("div",{className:"thino-user-name",children:i==null?void 0:i.UserName}),(i==null?void 0:i.MomentsQuote)&&v.jsx("div",{className:"thino-user-quote",children:i==null?void 0:i.MomentsQuote})]})]}),v.jsx("div",{ref:L,className:"memo-content-text",style:{minHeight:i.MinHeightForShare||"200px"}}),v.jsx("div",{className:"thino-time-footer",children:l.createdAt}),v.jsxs("div",{className:"watermark-container",children:[v.jsxs("span",{className:"normal-text footer-start",children:[v.jsx("div",{className:"property-social-icons"}),v.jsx("spa
`,i.current,a.path,r);const _=(B=i.current)==null?void 0:B.querySelectorAll(".internal-link");_==null||_.forEach(L=>{const R=L,V=R.getAttribute("data-href");if(!V)return;t.metadataCache.getFirstLinkpathDest(V,a.path)||L.classList.add("is-unresolved"),R.addEventListener("mouseover",Z=>{Z.stopPropagation(),t.workspace.trigger("hover-link",{event:Z,source:"thino",hoverParent:r.containerEl,targetEl:R,linktext:V,sourcePath:R.href})})})}N()},[a.content,l]);const S=async()=>{switch(h.sourceType){case"DAILY":await z2(h.id,h.path);break;case"CANVAS":await W2(h.id,h.path);break;case"MULTI":await U2(h.path);break;case"FILE":await V2(h.id,h.path);break}},D=async()=>{if(g)try{if(n.DeleteThinoDirectly)await we.deleteMemoById(h.id);else{const N=await we.hideMemoById(h.id);N&&we.editMemo(N)}}catch(N){new C.Notice(N.message)}else y()},I=async()=>{try{const N=await we.unarchiveMemo(h);N&&we.editMemo(N),o(h.id),new C.Notice(E("RESTORE SUCCEED"))}catch(N){new C.Notice(N.message)}},M=()=>{g&&y(!1)};return v.jsxs("div",{ref:l,className:`memo-wrapper${"memos-"+h.id}`,onMouseLeave:M,children:[v.jsxs("div",{className:"memo-top-wrapper",children:[v.jsxs("span",{className:"time-text",children:[E("ARCHIVED AT")," ",h.updatedAt]}),v.jsxs("div",{className:"btns-container",children:[v.jsx("span",{ref:N=>{N&&C.setIcon(N,"more-horizontal")},className:"btn more-action-btn"}),v.jsx("div",{className:"more-action-btns-wrapper",children:v.jsxs("div",{className:"more-action-btns-container",children:[v.jsxs("div",{className:"more-action-menu-item",children:[v.jsx("span",{ref:w.restore,className:"more-action-item-icon"}),v.jsx("span",{className:"btn restore-btn",onClick:I,children:E("RESTORE")})]}),v.jsxs("div",{className:"more-action-menu-item",children:[v.jsx("span",{ref:w.source,className:"more-action-item-icon"}),v.jsx("span",{className:"btn",onClick:S,children:E("SOURCE")})]}),v.jsxs("div",{className:"more-action-menu-item delete-menu-item",children:[v.jsx("span",{ref:w.delete,className:"more-action-item-icon"}),v.jsx("span",{className:`btndelete-btn${g?"final-confirm":""}`,onClick:D,children:E(g?"CONFIRM!":"DELETE")})]})]})})]})]}),v.jsx("div",{ref:i,className:"memo-content-text"})]})},Ru=e=>{var n;const t=new Map;for(const r of e){const a=r.path;t.has(a)||t.set(a,[]),(n=t.get(a))==null||n.push(r)}return Array.from(t).map(([r,a])=>({path:r,thinos:a}))},aCe=({memos:e,query:t,HideDoneTasks:n})=>{const{tag:r,duration:a,type:o,text:i,filter:l}=t,c=on.getQueryById(l);return!!(r||a&&a.from<a.to||o||i||c)||c||n?e.filter(h=>{let g=!0;if(h.thinoType!==void 0&&n&&h.thinoType==="TASK-DONE"&&(g=!1),h.content.contains("comment:")&&(g=!1),c){const y=JSON.parse(c.querystring);Array.isArray(y)&&(g=Up(h,y))}if(r){const y=new Set;for(const w of Array.from(h.content.match($r)||[])){const D=w.replace($r,"$1").trim().split("/");let I="";for(const M of D)I+=M,y.add(I),I+="/"}for(const w of Array.from(h.content.match(ua)||[])){const D=w.replace(ua,"$1").trim().split("/");let I="";for(const M of D)I+=M,y.add(I),I+="/"}for(const w of Array.from(h.content.match(Wa)||[])){const D=w.replace(Wa,"$2").trim().split("/");let I="";for(const M of D)I+=M,y.add(I),I+="/"}y.has(r)||(g=!1)}return a&&a.from<a.to&&(ut.getTimeStampByDate(h.createdAt)<a.from||ut.getTimeStampByDate(h.createdAt)>a.to)&&(g=!1),o&&(o==="NOT_TAGGED"&&(h.content.match($r)!==null||h.content.match(Wa)!==null||h.content.match(ua)!==null)||o==="LINKED"&&h.content.match(kf)===null||o==="IMAGED"&&h.content.match(Nf)===null||o==="CONNECTED"&&h.content.match(rd)===null)&&(g=!1),i&&!h.content.toLowerCase().includes(i.toLowerCase())&&(g=!1),g}):e.filter(h=>!h.content.contains("comment:"))},oCe=()=>{const{locationState:{query:e},globalState:{isMobileView:t},memoState:{memos:n}}=P.useContext(Lt),r=im(),[a,o]=P.useState([]),i=ne.useRef(null),l=ne.useRef(null);P.useEffect(()=>{l.current&&C.setIcon(l.current,"more-horizontal")},[l]),P.useEffect(()=>{const S=aCe({memos:n.filter(D=>D.rowStatus==="ARCHIVED"&&D.deletedAt===""),query:e,HideDoneTasks:!1});o(S),r.setFinish()},[n,i.current,e]);const c=P.useCallback(S=>{o(D=>D.filter(I=
`),Ie!==null&&A.push(S(""+Ie)),null;case"input":A.push(G("input")),ct=$t=it=Ie=null;for(Ue in K)if(n.call(K,Ue)&&(Ft=K[Ue],Ft!=null))switch(Ue){case"children":case"dangerouslySetInnerHTML":throw Error(t(399,"input"));case"defaultChecked":ct=Ft;break;case"defaultValue":it=Ft;break;case"checked":$t=Ft;break;case"value":Ie=Ft;break;default:L(A,oe,Ue,Ft)}return $t!==null?L(A,oe,"checked",$t):ct!==null&&L(A,oe,"checked",ct),Ie!==null?L(A,oe,"value",Ie):it!==null&&L(A,oe,"value",it),A.push("/>"),null;case"menuitem":A.push(G("menuitem"));for(var Ga in K)if(n.call(K,Ga)&&(Ie=K[Ga],Ie!=null))switch(Ga){case"children":case"dangerouslySetInnerHTML":throw Error(t(400));default:L(A,oe,Ga,Ie)}return A.push(">"),null;case"title":A.push(G("title")),Ie=null;for(Pn in K)if(n.call(K,Pn)&&(Ue=K[Pn],Ue!=null))switch(Pn){case"children":Ie=Ue;break;case"dangerouslySetInnerHTML":throw Error(t(434));default:L(A,oe,Pn,Ue)}return A.push(">"),Ie;case"listing":case"pre":A.push(G(U)),Ue=Ie=null;for(ct in K)if(n.call(K,ct)&&(it=K[ct],it!=null))switch(ct){case"children":Ie=it;break;case"dangerouslySetInnerHTML":Ue=it;break;default:L(A,oe,ct,it)}if(A.push(">"),Ue!=null){if(Ie!=null)throw Error(t(60));if(typeof Ue!="object"||!("__html"in Ue))throw Error(t(61));K=Ue.__html,K!=null&&(typeof K=="string"&&0<K.length&&K[0]===`
`&&F.push(Vt),Ee!==null&&F.push(c(R(""+Ee))),null;case"input":F.push(en("input")),It=Rt=ot=Ee=null;for(Ve in q)if(g.call(q,Ve)&&(Kt=q[Ve],Kt!=null))switch(Ve){case"children":case"dangerouslySetInnerHTML":throw Error(t(399,"input"));case"defaultChecked":It=Kt;break;case"defaultValue":ot=Kt;break;case"checked":Rt=Kt;break;case"value":Ee=Kt;break;default:et(F,re,Ve,Kt)}return Rt!==null?et(F,re,"checked",Rt):It!==null&&et(F,re,"checked",It),Ee!==null?et(F,re,"value",Ee):ot!==null&&et(F,re,"value",ot),F.push(ht),null;case"menuitem":F.push(en("menuitem"));for(var oa in q)if(g.call(q,oa)&&(Ee=q[oa],Ee!=null))switch(oa){case"children":case"dangerouslySetInnerHTML":throw Error(t(400));default:et(F,re,oa,Ee)}return F.push(nt),null;case"title":F.push(en("title")),Ee=null;for(Hn in q)if(g.call(q,Hn)&&(Ve=q[Hn],Ve!=null))switch(Hn){case"children":Ee=Ve;break;case"dangerouslySetInnerHTML":throw Error(t(434));default:et(F,re,Hn,Ve)}return F.push(nt),Ee;case"listing":case"pre":F.push(en(H)),Ve=Ee=null;for(It in q)if(g.call(q,It)&&(ot=q[It],ot!=null))switch(It){case"children":Ee=ot;break;case"dangerouslySetInnerHTML":Ve=ot;break;default:et(F,re,It,ot)}if(F.push(nt),Ve!=null){if(Ee!=null)throw Error(t(60));if(typeof Ve!="object"||!("__html"in Ve))throw Error(t(61));q=Ve.__html,q!=null&&(typeof q=="string"&&0<q.length&&q[0]===`
`&&F.push(Vt),Ee;case"area":case"base":case"br":case"col":case"embed":case"hr":case"img":case"keygen":case"link":case"meta":case"param":case"source":case"track":case"wbr":F.push(en(H));for(var Ka in q)if(g.call(q,Ka)&&(Ee=q[Ka],Ee!=null))switch(Ka){case"children":case"dangerouslySetInnerHTML":throw Error(t(399,H));default:et(F,re,Ka,Ee)}return F.push(ht),null;case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return _t(F,q,H,re);case"html":return Ae.insertionMode===0&&F.push(Zn),_t(F,q,H,re);default:if(H.indexOf("-")===-1&&typeof q.is!="string")return _t(F,q,H,re);F.push(en(H)),Ve=Ee=null;for(Kt in q)if(g.call(q,Kt)&&(ot=q[Kt],ot!=null))switch(Kt){case"children":Ee=ot;break;case"dangerouslySetInnerHTML":Ve=ot;break;case"style":Ze(F,re,ot);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":break;default:D(Kt)&&typeof ot!="function"&&typeof ot!="symbol"&&F.push(st,c(Kt),xt,c(R(ot)),tn)}return F.push(nt),St(F,Ve,Ee),Ee}}var Er=f("</"),pt=f(">"),Mt=f('<template id="'),Jt=f('"></template>'),sn=f("<!--$-->"),ln=f('<!--$?--><template id="'),vr=f('"></template>'),fr=f("<!--$!-->"),ha=f("<!--/$-->"),jr=f("<template"),nr=f('"'),Lr=f(' data-dgst="');f(' data-msg="'),f(' data-stck="');var te=f("></template>");function me(F,H,q){if(a(F,ln),q===null)throw Error(t(395));return a(F,q),o(F,vr)}var Ce=f('<div hidden id="'),Ye=f('">'),He=f("</div>"),Qe=f('<svg aria-hidden="true" style="display:none" id="'),tt=f('">'),kt=f("</svg>"),Yt=f('<math aria-hidden="true" style="display:none" id="'),On=f('">'),yn=f("</math>"),xr=f('<table hidden id="'),Jn=f('">'),yr=f("</table>"),ta=f('<table hidden><tbody id="'),Pi=f('">'),Nn=f("</tbody></table>"),Aa=f('<table hidden><tr id="'),Fa=f('">'),Zr=f("</tr></table>"),fo=f('<table hidden><colgroup id="'),Oa=f('">'),au=f("</colgroup></table>");function si(F,H,q,re){switch(q.insertionMode){case 0:case 1:return a(F,Ce),a(F,H.segmentPrefix),a(F,c(re.toString(16))),o(F,Ye);case 2:return a(F,Qe),a(F,H.segmentPrefix),a(F,c(re.toString(16))),o(F,tt);case 3:return a(F,Yt),a(F,H.segmentPrefix),a(F,c(re.toString(16))),o(F,On);case 4:return a(F,xr),a(F,H.segmentPrefix),a(F,c(re.toString(16))),o(F,Jn);case 5:return a(F,ta),a(F,H.segmentPrefix),a(F,c(re.toString(16))),o(F,Pi);case 6:return a(F,Aa),a(F,H.segmentPrefix),a(F,c(re.toString(16))),o(F,Fa);case 7:return a(F,fo),a(F,H.segmentPrefix),a(F,c(re.toString(16))),o(F,Oa);default:throw Error(t(397))}}function li(F,H){switch(H.insertionMode){case 0:case 1:return o(F,He);case 2:return o(F,kt);case 3:return o(F,yn);case 4:return o(F,yr);case 5:return o(F,Nn);case 6:return o(F,Zr);case 7:return o(F,au);default:throw Error(t(397))}}var ec=f('function $RS(a,b){a=document.getElementById(a);b=document.getElementById(b);for(a.parentNode.removeChild(a);a.firstChild;)b.parentNode.insertBefore(a.firstChild,b);b.parentNode.removeChild(b)};$RS("'),ou=f('$RS("'),us=f('","'),ji=f('")<\/script>'),cs=f('function $RC(a,b){a=document.getElementById(a);b=document.getElementById(b);b.parentNode.removeChild(b);if(a){a=a.previousSibling;var f=a.parentNode,c=a.nextSibling,e=0;do{if(c&&8===c.nodeType){var d=c.data;if("/$"===d)if(0===e)break;else e--;else"$"!==d&&"$?"!==d&&"$!"!==d||e++}d=c.nextSibling;f.removeChild(c);c=d}while(c);for(;b.firstChild;)f.insertBefore(b.firstChild,c);a.data="$";a._reactRetry&&a._reactRetry()}};$RC("'),iu=f('$RC("'),ds=f('","'),tc=f('")<\/script>'),An=f('function $RX(b,c,d,e){var a=document.getElementById(b);a&&(b=a.previousSibling,b.data="$!",a=a.dataset,c&&(a.dgst=c),d&&(a.msg=d),e&&(a.stck=e),b._reactRetry&&b._reactRetry())};$RX("'),na=f('$RX("'),qs=f('"'),Gs=f(")<\/script>"),ui=f(","),su=/[<\u2028\u2029]/g;function Fo(F){return JSON.stringify(F).replace(su,function(H){switch(H){case"<":return"\\u003c";case"\u2028":return"\\u2028";case"\u2029":return"\\u2029";default:throw Error("escapeJSStringsForInstructionScripts encountered a match it does not know how to replace. this means the match regex and the replacement characters are no
`,o.current,t.path,I);const N=(_=o.current)==null?void 0:_.querySelectorAll(".internal-link");N==null||N.forEach(k=>{const B=k,L=B.getAttribute("data-href");if(!L)return;r.app.metadataCache.getFirstLinkpathDest(L,t.path)||k.classList.add("is-unresolved"),B.addEventListener("mouseover",V=>{V.stopPropagation(),r.app.workspace.trigger("hover-link",{event:V,source:"thino",hoverParent:I.containerEl,targetEl:B,linktext:L,sourcePath:B.href})})})}M()},[t.content,i]);const y=async()=>{if(f)try{await we.deleteMemoById(a.id),n(a.id)}catch(I){new C.Notice(I.message)}else h()},w=async()=>{switch(a.sourceType){case"DAILY":await z2(a.id,a.path);break;case"CANVAS":await W2(a.id,a.path);break;case"MULTI":await U2(a.path);break;case"FILE":await V2(a.id,a.path);break}},S=async()=>{try{const I=await we.restoreMemoById(a.id),M=r.app,N=M==null?void 0:M.loadLocalStorage("tokenForSync");I&&I.webId&&N&&r.settings.startSync&&await Kg(I.webId),I&&we.editMemo(I),n(a.id),new C.Notice(E("RESTORE SUCCEED"))}catch(I){new C.Notice(I.message)}},D=()=>{f&&h(!1)};return v.jsxs("div",{ref:i,className:`memo-wrapper${"memos-"+a.id}`,onMouseLeave:D,children:[v.jsxs("div",{className:"memo-top-wrapper",children:[v.jsxs("span",{className:"time-text",children:[E("DELETE AT")," ",a.deletedAtStr]}),v.jsxs("div",{className:"btns-container",children:[v.jsx("span",{ref:I=>{I&&C.setIcon(I,"more-horizontal")},className:"btn more-action-btn"}),v.jsx("div",{className:"more-action-btns-wrapper",children:v.jsxs("div",{className:"more-action-btns-container",children:[v.jsxs("div",{className:"more-action-menu-item",children:[v.jsx("span",{ref:g.restore,className:"more-action-item-icon"}),v.jsx("span",{className:"btn restore-btn",onClick:S,children:E("RESTORE")})]}),v.jsxs("div",{className:"more-action-menu-item",children:[v.jsx("span",{ref:g.source,className:"more-action-item-icon"}),v.jsx("span",{className:"btn",onClick:w,children:E("SOURCE")})]}),v.jsxs("div",{className:"more-action-menu-item delete-menu-item",children:[v.jsx("span",{ref:g.delete,className:"more-action-item-icon"}),v.jsx("span",{className:`btndelete-btn${f?"final-confirm":""}`,onClick:y,children:E(f?"CONFIRM!":"DELETE")})]})]})})]})]}),v.jsx("div",{ref:o,className:"memo-content-text",onContextMenu:I=>{I.preventDefault(),I.stopPropagation()}})]})},_Ce=({memos:e,query:t,HideDoneTasks:n})=>{const{tag:r,duration:a,type:o,text:i,filter:l}=t,c=on.getQueryById(l);return!!(r||a&&a.from<a.to||o||i||c)||c||n?e.filter(h=>{let g=!0;if(h.thinoType!==void 0&&n&&h.thinoType==="TASK-DONE"&&(g=!1),h.content.contains("comment:")&&(g=!1),c){const y=JSON.parse(c.querystring);Array.isArray(y)&&(g=Up(h,y))}if(r){const y=new Set;for(const w of Array.from(h.content.match($r)||[])){const D=w.replace($r,"$1").trim().split("/");let I="";for(const M of D)I+=M,y.add(I),I+="/"}for(const w of Array.from(h.content.match(ua)||[])){const D=w.replace(ua,"$1").trim().split("/");let I="";for(const M of D)I+=M,y.add(I),I+="/"}for(const w of Array.from(h.content.match(Wa)||[])){const D=w.replace(Wa,"$2").trim().split("/");let I="";for(const M of D)I+=M,y.add(I),I+="/"}y.has(r)||(g=!1)}return a&&a.from<a.to&&(ut.getTimeStampByDate(h.createdAt)<a.from||ut.getTimeStampByDate(h.createdAt)>a.to)&&(g=!1),o&&(o==="NOT_TAGGED"&&(h.content.match($r)!==null||h.content.match(Wa)!==null||h.content.match(ua)!==null)||o==="LINKED"&&h.content.match(kf)===null||o==="IMAGED"&&h.content.match(Nf)===null||o==="CONNECTED"&&h.content.match(rd)===null)&&(g=!1),i&&!h.content.toLowerCase().includes(i.toLowerCase())&&(g=!1),g}):e.filter(h=>!h.content.contains("comment:"))},BCe=()=>{const{locationState:{query:e},globalState:{isMobileView:t},memoState:{memos:n}}=P.useContext(Lt),r=im(),[a,o]=P.useState([]),i=ne.useRef(null),l=ne.useRef(null);P.useEffect(()=>{l.current&&C.setIcon(l.current,"more-horizontal")},[l]),P.useEffect(()=>{const w=_Ce({memos:n.filter(S=>S.deletedAt!==""&&S.deletedAt),query:e,HideDoneTasks:!1});o(w),r.setFinish()},[n,i.current,e]);const c=P.useCallback(w=>{o(S=>S.filter(D=>D.id!==w))},[]),f=P.useCallback(()=>{dt.setShowSiderbarInMobileView(!0)}
`:""}${t==null?void0:t.AppendViaServer}`);constN=awaitwe.createThino({content:w,isList:f,type:M});N&&(we.pushMemo(N),at.clearQuery()),a.statusCode=200,a.setHeader("Content-Type","application/json"),a.end(JSON.stringify({status:"success",thino:N,link:`obsidian://thino?openId=${N.id}`}))});break}case"/search":{if(r.method!=="GET"){a.statusCode=404,a.end();break}consti=o.query,{keyword:l}=i,c=we.getThinoViaKeyword(l);a.statusCode=200,a.setHeader("Content-Type","application/json");constf=JSON.stringify({status:"success",thinos:c});a.end(f);break}case"/list":{if(r.method!=="GET"){a.statusCode=404,a.end();break}const{count:i}=o.query,l=we.getState().memos.slice(0,parseInt(i));a.statusCode=200,a.setHeader("Content-Type","application/json"),a.end(JSON.stringify({status:"success",thinos:l}));break}case"/info":{if(r.method!=="GET"){a.statusCode=404,a.end();break}const{getSettings:i}=o.query;if(!i){a.statusCode=404,a.end();break}constl=ft.getState().settings;a.statusCode=200,a.setHeader("Content-Type","application/json");constc=JSON.stringify({status:"success",infoSettings:l});a.end(c);break}default:a.statusCode=404,a.end();break}}}catch(o){console.error(o),a.statusCode=500,a.end({status:"error",message:o.message})}});return{listen(r,a){try{n.listen({port:parseInt(a),host:r})}catch(o){console.error(o),newC.Notice(E("Thino - Failed to start HTTP server, please check the port is available."))}newC.Notice(`${E("Thino - Started HTTP server on port")}${a}`)},close(){n.close(),newC.Notice(E("Thino - Terminated HTTP server"))}}}const{clipboard:mr}=C.Platform.isDesktop?require("electron"):"";classS3e{constructor(){Se(this,"eventListeners");this.eventListeners={}}on(t,n){this.eventListeners[t]=this.eventListeners[t]||[],this.eventListeners[t].push(n)}once(t,n){n.$emitOnce=!0,this.on(t,n)}removeListener(t,n){if(this.eventListeners[t]){constr=this.eventListeners[t].findIndex(a=>a===n);r>=0&&this.eventListeners[t].splice(r,1)}}removeAllListeners(t){this.eventListeners[t]&&(this.eventListeners[t].length=0)}emit(t,...n){this.eventListeners[t]&&this.eventListeners[t].forEach(r=>{r.call(this,...n),r.$emitOnce&&this.removeListener(t,r)})}}constlp=newS3e;letFg=null,NN=mr==null?void0:mr.readText(),AN=mr==null?void0:mr.readImage();mr&&(mr.on=(e,t)=>(lp.on(e,t),mr),mr.once=(e,t)=>(lp.once(e,t),mr),mr.off=(e,t)=>(t?lp.removeListener(e,t):lp.removeAllListeners(e),mr),mr.startWatching=()=>(Fg||(Fg=setInterval(()=>{D3e(NN,NN=mr==null?void0:mr.readText())&&lp.emit("text-changed"),T3e(AN,AN=mr==null?void0:mr.readImage())&&lp.emit("image-changed")},500)),mr),mr.stopWatching=()=>(Fg&&clearInterval(Fg),Fg=null,mr));functionD3e(e,t){returnt&&e!==t}functionT3e(e,t){return!t.isEmpty()&&e.toDataURL()!==t.toDataURL()}var_N;constnT=(_N=require("electron"))==null?void0:_N.remote;varBN,HN;constFN=(HN=(BN=require("electron"))==null?void0:BN.remote)==null?void0:HN.screen;classI3e{constructor(t,n){Se(this,"isRegisted");Se(this,"leaf");Se(this,"clipboard");Se(this,"isScreenTop",!1);Se(this,"currentSplitWindow");Se(this,"intervalNum");Se(this,"allowsCopy",!1);Se(this,"plugin");Se(this,"actionEl",null);this.app=t,this.plugin=n,this.isRegisted=!1,this.leaf=null,this.clipboard=mr}asynconload(){C.Platform.isDesktop&&(this.initGlobalCopyEvents(),awaitthis.registerAllShortcuts(),this.registerEvents())}registerEvents(){this.plugin.registerEvent(this.app.workspace.on("quit",()=>{nT.globalShortcut.unregister(this.plugin.settings.CaptureKey.OpenThinoGlobally)}))}initGlobalCopyEvents(){this.plugin.addCommand({id:"init-global-copy-events",name:E("Global copy"),callback:()=>{this.allowsCopy=!this.allowsCopy,!this.allowsCopy&&this.clipboard.stopWatching(),this.allowsCopy&&this.clipboard.startWatching(),this.leaf&&this.allowsCopy&&(this.actionEl=this.leaf.view.addAction("clipboard-x","Stop global copying",()=>{vart;this.allowsCopy=!1,this.clipboard.stopWatching(),(t=this.actionEl)==null||t.remove()}))}})}onunload(){this.isRegisted&&(nT.globalShortcut.unregister(this.plugin.settings.CaptureKey.OpenThinoGlobally),this.clipboard.off("text-changed"),this.cli
\`\`\``),newC.Notice(E("Debug info copied to clipboard"))}catch(t){console.error(t)}}classX3eextendsC.Plugin{constructor(){super(...arguments);Se(this,"settings");Se(this,"settingTab");Se(this,"triggerBySelf",!1);Se(this,"updatedID","");Se(this,"debounceTimer",0);Se(this,"apiHttpServer",null);Se(this,"captureService",null);Se(this,"loaded",!1);Se(this,"MarkdownEditor")}asynconload(){this.MarkdownEditor=Q3e(this.app),ft.setPlugin(this),awaitthis.loadSettings(),nMe(),this.registerRibbon(),awaitthis.verify();try{this.settings.ShowUpdateMessage&&awaitthis.checkVersionAndShowChangeLog()}catch(n){console.error(n)}this.settingTab=newmMe(this.app,this),this.addSettingTab(this.settingTab),this.initApp(),this.initEditor(),this.initURIHandler(),this.registerMobileEvent(),this.registerCommands(),this.registerCanvasNodeMemos(),this.registerHoverEvent(),this.registerLinkOpen(),this.registerCodeBlocks(),C.Platform.isMobile&&this.registerMobileNavbar(),this.updateLayoutSettings(),this.registerEditorContextMenu(),this.registerEditorSuggest(newXCe(this.app,this)),this.registerEditorExtension([d3e]),this.app.workspace.onLayoutReady(this.onLayoutReady.bind(this)),this.registerView(lo,n=>newvf(n,this))}asyncloadSettings(){this.settings=Object.assign({},Ei,awaitthis.loadData()),ft.setSettings(this.settings)}asyncsaveSettings(){awaitthis.saveData(this.settings),ft.setSettings(this.settings)}onunload(){varr,a;this.app.workspace.detachLeavesOfType(lo),we.clearMemos(),Le.dispatch({type:"CLEAR_MEMOS",payload:null}),Le.dispatch({type:"CLEAR_FILES",payload:null}),Le.dispatch({type:"CLEAR_VIEW",payload:null});constn=document.body.find(".dialog-wrapper");if(n&&((r=n.parentElement)==null||r.detach()),this.apiHttpServer&&(this.apiHttpServer.close(),this.apiHttpServer=null),this.captureService&&this.captureService.onunload(),C.Platform.isMobile){consto=this.app.mobileNavbar;o&&o.showThinoBtnEl&&((a=this.settings)!=null&&a.NavbarButton)&&(o.showThinoBtnEl.detach(),o.showThinoBtnEl=null)}newC.Notice(E("Close Memos Successfully"))}initEditor(){this.register(_g(C.MetadataCache.prototype,{getFileCache:r=>function(a){return!(a!=null&&a.path)&&!a?null:r.call(this,a)}})),(r=>{consta=r.app.embedRegistry.embedByExtension.md({app:r.app,containerEl:document.createElement("div")},null,"");a.editable=!0,a.showEditor();consto=Object.getPrototypeOf(Object.getPrototypeOf(a.editMode)),i=_g(o.constructor.prototype,{triggerClickableToken:l=>asyncfunction(...c){if(c[0].type==="internal-link"){if(this.editorEl.closest(".memo-editor-wrapper")){constf=we.getMemoById(c[0].text??"");if(f){bf(f);return}returnl.apply(this,c)}returnl.apply(this,c)}returnl.apply(this,c)}});this.register(i),a.unload()})(this)}initApp(){ft.setApp(this.app)}initURIHandler(){this.registerObsidianProtocolHandler("thino",asyncn=>{vari,l,c,f;if(!n)return;if(n.openSettings&&(this.app.setting.open(),this.app.setting.openTabById(this.manifest.id||"obsidian-memos")),n.userid)try{consth=n.userid;p3e(h,this.app),m3e(C.moment().add(30,"days").valueOf(),this.app),dt.setRefresh(!0)}catch(h){console.error(h),newC.Notice(E("Failed to verify"))}if(n.token)try{consth=n.token;(i=this.app)==null||i.saveLocalStorage("tokenForSync",h),setTimeout(()=>{this.app.setting.open(),this.app.setting.openTabById(this.manifest.id||"obsidian-memos"),this.settingTab.display()},200),newC.Notice(E("Saved sync token successfully"))}catch(h){console.error(h),newC.Notice(E("Failed to save"))}if(n.copyToken){this.app.setting.open(),this.app.setting.openTabById(this.manifest.id??"obsidian-memos");consth=awaitaP();awaitnavigator.clipboard.writeText(h),newC.Notice(E("Copied app id successfully"))}constr=(l=ft.getState())==null?void0:l.verifyState,a=!C.Platform.isDesktop&&await((f=(c=window.Capacitor)==null?void0:c.Plugins.Device)==null?void0:f.getId()),o=C.Platform.isDesktop?awaitcr():(a==null?void0:a.identifier)||(a==null?void0:a.uuid);if(!(!r||(r==null?void0:r.appId)!==o)){if(n.content){consth=n.type,g=decodeURI(n.content)!==n.content?decodeURI(n.content):n.content,y=n.task,w=awaitwe.createThino(
`);try{await RN(this.app,this.settings,async(l,c)=>{i=l+i+c;const f=await we.createThino({content:i,type:this.settings.MemoSaveLocation||"DAILY",isList:!0});we.pushMemo(f)})}catch(l){console.error("Configuration failed:",l);return}})})})))}registerCommands(){tw.forEach(n=>{this.addCommand({id:n.id,name:n.name,callback:()=>this.openMemos(n.location,n.cb),hotkeys:[]})}),["Modern","Clean","Minimal","Gradient"].forEach(n=>{this.addCommand({id:`share-thino-via-${n.toLowerCase()}`,name:E("Share thino")+`[${E(n)}]`,editorCallback:(r,a)=>{const o=r.getSelection();if(o.length===0)return;const i={id:`temp-${Date.now()}`,content:o,createdAt:C.moment().format("YYYY-MM-DD HH:mm:ss"),updatedAt:C.moment().format("YYYY-MM-DD HH:mm:ss"),deletedAt:"",pinned:!1,visibility:"PUBLIC",rowStatus:"NORMAL",thinoType:"JOURNAL",hasId:"",linkId:"",resourceList:[],creatorName:"thino",sourceType:"DAILY",path:a.file.path,fileInfo:{tags:[],frontmatter:{}}};sf(i,n.toLowerCase(),a)}})}),this.addCommand({id:"focus-mode",name:"Focus mode",callback:()=>{const n=document.body.hasClass("thino-focus");document.body.toggleClass("thino-focus",!n)}}),this.addCommand({id:"hide-side-bar",name:E("Toggle sidebar visibility"),callback:()=>{const n=dt.getState().isMobileView,r=document.body.hasClass("thino-hide-side-bar");document.body.toggleClass("thino-hide-side-bar",n?!1:!r)}}),this.addCommand({id:"hide-tags",name:E("Toggle tags visibility"),callback:()=>{const n=document.body.hasClass("thino-hide-tags");document.body.toggleClass("thino-hide-tags",!n)}}),this.addCommand({id:"hide-query-list",name:E("Toggle query list visibility"),callback:()=>{const n=document.body.hasClass("thino-hide-query-list");document.body.toggleClass("thino-hide-query-list",!n)}}),this.addCommand({id:"insert-task",name:E("Insert task"),checkCallback:n=>{const r=this.app.plugins.getPlugin("obsidian-tasks-plugin"),a=this.app.workspace.getLeavesOfType("thino_view").first();if(r&&a)return n||this.app.plugins.plugins["obsidian-tasks-plugin"].apiV1.createTaskLineModal().then(i=>{var c;const l=this.app.workspace.activeEditor;l&&((c=l.editor)==null||c.insertText(i))}),!0}}),this.addCommand({id:"show-thino-editor",name:E("Show thino editor"),checkCallback:n=>{if(we.initialized&&ft.initialized){if(!n){if(!ft.getState().view){new C.Notice(E("Please open thino first"));return}new xT(this.app).open()}return!0}}}),this.addCommand({id:"lock-thino",name:E("Lock thino"),checkCallback:n=>{if(this.app.workspace.getActiveViewOfType(vf)&&this.settings.needVerify)return n||dt.setLocked(!0),!0}}),this.addCommand({id:"copy-debug-info",name:E("Copy debug info"),callback:async()=>{await ox(this)}}),this.addCommand({id:"insert-editor",name:E("Insert editor"),checkCallback:n=>{const r=this.app.workspace.getActiveViewOfType(C.MarkdownView);if(r&&r.getViewType()==="markdown")return n||r.editor.replaceSelection("\n```thino\n{\neditor:false\n}\n```\n"),!0}}),this.addCommand({id:"toggle-minimal-thino",name:E("Toggle minimal mode"),callback:()=>{const n=document.body.hasClass("minimal-thino");document.body.toggleClass("minimal-thino",!n)}}),this.addCommand({id:"focus-on-thino-editor",name:E("Focus on thino editor"),callback:()=>this.focusOnEditor(),hotkeys:[]}),this.addCommand({id:"reinit-thino-sync",name:E("ReSync web thinos to local"),callback:()=>{uCe(this.app)}}),this.addCommand({id:"init-thino-sync",name:E("Sync local thinos to web"),callback:async()=>{var r;if(!((r=this.app)==null?void 0:r.loadLocalStorage("tokenForSync"))){new C.Notice(E("Please input token first"));return}if(!this.settings.startSync){new C.Notice(E("Please enable sync first"));return}try{await we.initSync()}catch(a){console.error(a),new C.Notice(E("Init Failed"))}}}),this.addCommand({id:"show-daily-thino",name:E("Show daily thino"),callback:()=>this.openDailyMemo(),hotkeys:[]}),this.addCommand({id:"focus-on-search-bar",name:E("Focus on search bar"),callback:()=>this.searchIt(),hotkeys:[]}),this.addCommand({id:"show-thino-in-popover",name:E("Show-thino in popover(Hover editor)"),callback:()=>this.showInPopover(),hotkeys:[]})}async onLayoutReady(){a