247 lines
1.6 MiB
JavaScript
247 lines
1.6 MiB
JavaScript
|
|
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const k=require("obsidian"),cg=require("@codemirror/language"),bu=require("@codemirror/state"),ir=require("@codemirror/view");function gP(t,e){for(var n=0;n<e.length;n++){const i=e[n];if(typeof i!="string"&&!Array.isArray(i)){for(const o in i)if(o!=="default"&&!(o in t)){const r=Object.getOwnPropertyDescriptor(i,o);r&&Object.defineProperty(t,o,r.get?r:{enumerable:!0,get:()=>i[o]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}var ru=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function bn(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var ug={exports:{}},qc={},dg={exports:{}},xt={},oI;function yP(){if(oI)return xt;oI=1;var t=Symbol.for("react.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),r=Symbol.for("react.provider"),a=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),c=Symbol.for("react.suspense"),d=Symbol.for("react.memo"),h=Symbol.for("react.lazy"),m=Symbol.iterator;function g(Y){return Y===null||typeof Y!="object"?null:(Y=m&&Y[m]||Y["@@iterator"],typeof Y=="function"?Y:null)}var y={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},T=Object.assign,w={};function S(Y,K,ce){this.props=Y,this.context=K,this.refs=w,this.updater=ce||y}S.prototype.isReactComponent={},S.prototype.setState=function(Y,K){if(typeof Y!="object"&&typeof Y!="function"&&Y!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,Y,K,"setState")},S.prototype.forceUpdate=function(Y){this.updater.enqueueForceUpdate(this,Y,"forceUpdate")};function I(){}I.prototype=S.prototype;function E(Y,K,ce){this.props=Y,this.context=K,this.refs=w,this.updater=ce||y}var L=E.prototype=new I;L.constructor=E,T(L,S.prototype),L.isPureReactComponent=!0;var C=Array.isArray,R=Object.prototype.hasOwnProperty,M={current:null},O={key:!0,ref:!0,__self:!0,__source:!0};function F(Y,K,ce){var ue,te={},ae=null,Ee=null;if(K!=null)for(ue in K.ref!==void 0&&(Ee=K.ref),K.key!==void 0&&(ae=""+K.key),K)R.call(K,ue)&&!O.hasOwnProperty(ue)&&(te[ue]=K[ue]);var xe=arguments.length-2;if(xe===1)te.children=ce;else if(1<xe){for(var Fe=Array(xe),Ge=0;Ge<xe;Ge++)Fe[Ge]=arguments[Ge+2];te.children=Fe}if(Y&&Y.defaultProps)for(ue in xe=Y.defaultProps,xe)te[ue]===void 0&&(te[ue]=xe[ue]);return{$$typeof:t,type:Y,key:ae,ref:Ee,props:te,_owner:M.current}}function j(Y,K){return{$$typeof:t,type:Y.type,key:K,ref:Y.ref,props:Y.props,_owner:Y._owner}}function z(Y){return typeof Y=="object"&&Y!==null&&Y.$$typeof===t}function _(Y){var K={"=":"=0",":":"=2"};return"$"+Y.replace(/[=:]/g,function(ce){return K[ce]})}var V=/\/+/g;function G(Y,K){return typeof Y=="object"&&Y!==null&&Y.key!=null?_(""+Y.key):K.toString(36)}function Z(Y,K,ce,ue,te){var ae=typeof Y;(ae==="undefined"||ae==="boolean")&&(Y=null);var Ee=!1;if(Y===null)Ee=!0;else switch(ae){case"string":case"number":Ee=!0;break;case"object":switch(Y.$$typeof){case t:case e:Ee=!0}}if(Ee)return Ee=Y,te=te(Ee),Y=ue===""?"."+G(Ee,0):ue,C(te)?(ce="",Y!=null&&(ce=Y.replace(V,"$&/")+"/"),Z(te,K,ce,"",function(Ge){return Ge})):te!=null&&(z(te)&&(te=j(te,ce+(!te.key||Ee&&Ee.key===te.key?"":(""+te.key).replace(V,"$&/")+"/")+Y)),K.push(te)),1;if(Ee=0,ue=ue===""?".":ue+":",C(Y))for(var xe=0;xe<Y.length;xe++){ae=Y[xe];var Fe=ue+G(ae,xe);Ee+=Z(ae,K,ce,Fe,te)}else if(Fe=g(Y),typeof Fe=="function")for(Y=Fe.call(Y),xe=0;!(ae=Y.next()).done;)ae=ae.value,Fe=ue+G(ae,xe++),Ee+=Z(ae,K,ce,Fe,te);else if(ae==="object")throw K=String(Y),Error("Objects are not valid as a React child (found: "+(K==="[object Object]"?"object with keys {"+Object.keys(Y).join(", ")+"}":K)+"). If you meant to render a collection of children, use an array instead.");return
|
|||
|
|
`),o=i.findIndex(a=>a.includes("api.setState"));if(o<0)return;const r=((e=i[o+1])==null?void 0:e.trim())||"";return(n=/.+ (.+) .+/.exec(r))==null?void 0:n[1]},MP=(t,e={})=>(n,i,o)=>{const{enabled:r,anonymousActionType:a,store:l,...c}=e;let d;try{d=(r??(uI?"production":void 0)!=="production")&&window.__REDUX_DEVTOOLS_EXTENSION__}catch{}if(!d)return t(n,i,o);const{connection:h,...m}=xP(l,d,c);let g=!0;o.setState=(w,S,I)=>{const E=n(w,S);if(!g)return E;const L=I===void 0?{type:a||DP(new Error().stack)||"anonymous"}:typeof I=="string"?{type:I}:I;return l===void 0?(h?.send(L,i()),E):(h?.send({...L,type:`${l}/${L.type}`},{...fh(c.name),[l]:o.getState()}),E)},o.devtools={cleanup:()=>{h&&typeof h.unsubscribe=="function"&&h.unsubscribe(),CP(c.name,l)}};const y=(...w)=>{const S=g;g=!1,n(...w),g=S},T=t(o.setState,i,o);if(m.type==="untracked"?h?.init(T):(m.stores[m.store]=o,h?.init(Object.fromEntries(Object.entries(m.stores).map(([w,S])=>[w,w===m.store?T:S.getState()])))),o.dispatchFromDevtools&&typeof o.dispatch=="function"){let w=!1;const S=o.dispatch;o.dispatch=(...I)=>{(uI?"production":void 0)!=="production"&&I[0].type==="__setState"&&!w&&(console.warn('[zustand devtools middleware] "__setState" action type is reserved to set state from the devtools. Avoid using it.'),w=!0),S(...I)}}return h.subscribe(w=>{var S;switch(w.type){case"ACTION":if(typeof w.payload!="string"){console.error("[zustand devtools middleware] Unsupported action format");return}return hg(w.payload,I=>{if(I.type==="__setState"){if(l===void 0){y(I.state);return}Object.keys(I.state).length!==1&&console.error(`
|
|||
|
|
[zustand devtools middleware] Unsupported __setState action format.
|
|||
|
|
When using 'store' option in devtools(), the 'state' should have only one key, which is a value of 'store' that was passed in devtools(),
|
|||
|
|
and value of this only key should be a state object. Example: { "type": "__setState", "state": { "abc123Store": { "foo": "bar" } } }
|
|||
|
|
`);const E=I.state[l];if(E==null)return;JSON.stringify(o.getState())!==JSON.stringify(E)&&y(E);return}o.dispatchFromDevtools&&typeof o.dispatch=="function"&&o.dispatch(I)});case"DISPATCH":switch(w.payload.type){case"RESET":return y(T),l===void 0?h?.init(o.getState()):h?.init(fh(c.name));case"COMMIT":if(l===void 0){h?.init(o.getState());return}return h?.init(fh(c.name));case"ROLLBACK":return hg(w.state,I=>{if(l===void 0){y(I),h?.init(o.getState());return}y(I[l]),h?.init(fh(c.name))});case"JUMP_TO_STATE":case"JUMP_TO_ACTION":return hg(w.state,I=>{if(l===void 0){y(I);return}JSON.stringify(o.getState())!==JSON.stringify(I[l])&&y(I[l])});case"IMPORT_STATE":{const{nextLiftedState:I}=w.payload,E=(S=I.computedStates.slice(-1)[0])==null?void 0:S.state;if(!E)return;y(l===void 0?E:E[l]),h?.send(null,I);return}case"PAUSE_RECORDING":return g=!g}return}}),T},Zr=MP,hg=(t,e)=>{let n;try{n=JSON.parse(t)}catch(i){console.error("[zustand devtools middleware] Could not parse the received json",i)}n!==void 0&&e(n)},AP=t=>(e,n,i)=>{const o=i.subscribe;return i.subscribe=(a,l,c)=>{let d=a;if(l){const h=c?.equalityFn||Object.is;let m=a(i.getState());d=g=>{const y=a(g);if(!h(m,y)){const T=m;l(m=y,T)}},c?.fireImmediately&&l(m,m)}return o(d)},t(e,n,i)},Uu=AP;function NP(t,e){let n;try{n=t()}catch{return}return{getItem:o=>{var r;const a=c=>c===null?null:JSON.parse(c,void 0),l=(r=n.getItem(o))!=null?r:null;return l instanceof Promise?l.then(a):a(l)},setItem:(o,r)=>n.setItem(o,JSON.stringify(r,void 0)),removeItem:o=>n.removeItem(o)}}const jb=t=>e=>{try{const n=t(e);return n instanceof Promise?n:{then(i){return jb(i)(n)},catch(i){return this}}}catch(n){return{then(i){return this},catch(i){return jb(i)(n)}}}},PP=(t,e)=>(n,i,o)=>{let r={storage:NP(()=>localStorage),partialize:w=>w,version:0,merge:(w,S)=>({...S,...w}),...e},a=!1;const l=new Set,c=new Set;let d=r.storage;if(!d)return t((...w)=>{console.warn(`[zustand persist middleware] Unable to update item '${r.name}', the given storage is currently unavailable.`),n(...w)},i,o);const h=()=>{const w=r.partialize({...i()});return d.setItem(r.name,{state:w,version:r.version})},m=o.setState;o.setState=(w,S)=>(m(w,S),h());const g=t((...w)=>(n(...w),h()),i,o);o.getInitialState=()=>g;let y;const T=()=>{var w,S;if(!d)return;a=!1,l.forEach(E=>{var L;return E((L=i())!=null?L:g)});const I=((S=r.onRehydrateStorage)==null?void 0:S.call(r,(w=i())!=null?w:g))||void 0;return jb(d.getItem.bind(d))(r.name).then(E=>{if(E)if(typeof E.version=="number"&&E.version!==r.version){if(r.migrate){const L=r.migrate(E.state,E.version);return L instanceof Promise?L.then(C=>[!0,C]):[!0,L]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,E.state];return[!1,void 0]}).then(E=>{var L;const[C,R]=E;if(y=r.merge(R,(L=i())!=null?L:g),n(y,!0),C)return h()}).then(()=>{I?.(y,void 0),y=i(),a=!0,c.forEach(E=>E(y))}).catch(E=>{I?.(void 0,E)})};return o.persist={setOptions:w=>{r={...r,...w},w.storage&&(d=w.storage)},clearStorage:()=>{d?.removeItem(r.name)},getOptions:()=>r,rehydrate:()=>T(),hasHydrated:()=>a,onHydrate:w=>(l.add(w),()=>{l.delete(w)}),onFinishHydration:w=>(c.add(w),()=>{c.delete(w)})},r.skipHydration||T(),y||g},js=PP;var KM=Symbol.for("immer-nothing"),dI=Symbol.for("immer-draftable"),Hi=Symbol.for("immer-state");function ko(t,...e){throw new Error(`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`)}var Fl=Object.getPrototypeOf;function jl(t){return!!t&&!!t[Hi]}function xs(t){return t?JM(t)||Array.isArray(t)||!!t[dI]||!!t.constructor?.[dI]||_u(t)||Gf(t):!1}var LP=Object.prototype.constructor.toString();function JM(t){if(!t||typeof t!="object")return!1;const e=Fl(t);if(e===null)return!0;const n=Object.hasOwnProperty.call(e,"constructor")&&e.constructor;return n===Object?!0:typeof n=="function"&&Function.toString.call(n)===LP}function rf(t,e){qf(t)===0?Reflect.ownKeys(t).forEach(n=>{e(n,t[n],t)}):t.forEach((n,i)=>e(i,n,t))}function qf(t){const e=t[Hi];return e?e.type_:Array.isArray(t)?1:_u(t)?2:Gf(t)?3:0}function Hb(t,e){return
|
|||
|
|
`);r.length===0&&await t.vault.adapter.write(Ss(t),JSON.stringify({queries:[]},null,2));const a=[];for(let l=0;l<r.length;l++){const c=l,d="Memos";let h="未命名";const m=r[l];let g=k.moment().format("YYYY/MM/DD HH:mm:ss"),y="[]";const T=m.match(/^\d{14,16}/);T&&(g=k.moment(T[0].slice(0,14),"YYYYMMDDHHmmss").format("YYYY/MM/DD HH:mm:ss"));const w=m.match(/\[\{(.+)\}\]/);w&&(y=w[0]);const S=m.match(/\s(.+)\s\[\{/);S&&(h=S[0].slice(1,-3)),a.push({id:c,pinnedAt:"",createdAt:g,updatedAt:g,title:h,querystring:y,userId:d})}await t.vault.adapter.write(Ss(t),JSON.stringify({queries:a},null,2))}},GL=async()=>{const{app:t}=rt.getState().dailyNotesState;return await rA(t,Ss(t))||await aA(t),await tc(t)||[]},$L=(t,e)=>({createdAt:k.moment().format("YYYY/MM/DD HH:mm:ss"),id:t,pinnedAt:"",querystring:e,title:v("Temp Filter"),updatedAt:k.moment().format("YYYY/MM/DD HH:mm:ss"),userId:"Thino"}),ZL=async(t,e)=>{const n=await tc(rt.getState().dailyNotesState.app)||[],i={createdAt:k.moment().format("YYYY/MM/DD HH:mm:ss"),id:k.moment().format("YYYYMMDDHHmmss")+n.length,pinnedAt:"",querystring:e,title:t,updatedAt:k.moment().format("YYYY/MM/DD HH:mm:ss"),userId:"Thino"};return n.push(i),await qu(rt.getState().dailyNotesState.app,n),i};function uf(t,e){if(t===e)return!0;if(t==null||e==null)return t===e;if(typeof t!=typeof e)return!1;if(typeof t!="object")return t===e;if(Array.isArray(t)!==Array.isArray(e))return!1;if(Array.isArray(t)){if(t.length!==e.length)return!1;for(let o=0;o<t.length;o++)if(!uf(t[o],e[o]))return!1;return!0}if(t.constructor!==e.constructor)return!1;if(t instanceof Date)return t.getTime()===e.getTime();if(t instanceof RegExp)return t.toString()===e.toString();const n=Object.keys(t),i=Object.keys(e);if(n.length!==i.length)return!1;for(const o of n)if(!i.includes(o)||!uf(t[o],e[o]))return!1;return!0}function KL(t){return t==null?!0:typeof t=="string"||Array.isArray(t)?t.length===0:t instanceof Map||t instanceof Set?t.size===0:typeof t=="object"?Object.keys(t).length===0:!1}function gh(t){const e=t.match(/^#+/);return e?e[0].length:0}function SI(t,e){const n=t.split(`
|
|||
|
|
`);let i="",o=[],r=!1,a=1;for(let l=0;l<n.length;l++){const c=n[l];if(c.startsWith("#")&&/^#{1,6}\s/g.test(c)){if(r&&gh(c)<=gh(e))break;i=c,i===e?(r=!0,a=l+1):r&&gh(c)>gh(e)?o.push(c):(r=!1,o=[])}else r&&o.push(c)}return e?KL(o)?{content:"",startLine:-1}:{content:o.join(`
|
|||
|
|
`),startLine:a}:{content:t,startLine:0}}function P0(t){const e={};for(const n of t)n.parent&&n.parent>0&&(e[n.position.start.line]=n.parent);return e}function JL(t,e,n){const i={},o=(g,y)=>{for(;g[y]!==void 0&&g[y]!==y;)y=g[y];return y},r=Ve.getState().app,a=n.split(`
|
|||
|
|
`),l=e+a.length-1,c=r.metadataCache.getFileCache(t)?.listItems,d={};if(!c)return[];const h=g=>{const y=/^(-|\*|\d\.)\s/,T=/(\[.\]\s)?/,w=/(\d{1,2}:\d{2}(:\d{2})?)(-\d{1,2}:\d{2}(:\d{2})?)?\s?/;return new RegExp(y.source+T.source+w.source).test(g)};return c.forEach(g=>{const y=g.position.start.line,T=g.position.end.line;if(y>=e&&T<=l){const w=y-e,S=T-e,I=a.slice(w,S+1),E=I.join(`
|
|||
|
|
`);if(g.parent&&g.parent>0&&(i[g.position.start.line]=g.parent),g.parent&&d[g.parent]){if(y-g.parent===1){const C=a[w]?.match(/^(\s*)/);C&&(d[g.parent].indent=C[0])}const L=new RegExp("^"+d[g.parent].indent);d[g.parent].content+=`
|
|||
|
|
`+E.split(`
|
|||
|
|
`).map(C=>C?.replace(L,"")).join(`
|
|||
|
|
`)}else if(g.parent&&d[o(i,g.parent)]){const L=new RegExp("^"+d[o(i,g.parent)].indent);d[o(i,g.parent)].content+=`
|
|||
|
|
`+E.split(`
|
|||
|
|
`).map(C=>C?.replace(L,"")).join(`
|
|||
|
|
`)}else if(h(E)||new RegExp(HL).test(E)){d[y]||(d[y]={content:"",blockId:"",indent:""});const L=I.length>1&&I[1]?.match(/^(\s*)/);L&&(d[y].indent=L[0]),d[y].content=E.split(`
|
|||
|
|
`).map(C=>C?.replace(d[y].indent,"")).join(`
|
|||
|
|
`),d[y].blockId=g.id}}}),Object.keys(d).map(g=>{const y=parseInt(g);return{line:d[y].content,blockId:d[y].blockId||"",index:y}})}async function QL(t,e){let n=e.vault.getAbstractFileByPath(t);return n||(new k.Notice(v("File not found for the given thino path, is creating a new file")),n=await e.vault.create(t,'{"nodes": [], "edges": []}'),We.setChangedByMemos(!0)),n}async function XL(t,e){let n;try{n=await e.vault.read(t)}catch(o){console.error(o),n=await e.vault.cachedRead(t)}const i=e.metadataCache.getFileCache(t)?.frontmatterPosition;return i?n.slice(i.end.offset+1):n}function eO(t){const e=t.split(/\r?\n/),n=[];let i=!1,o=[],r="";for(let a=0;a<e.length;a++){const l=e[a];l.startsWith("> [!thino]")?(i&&(n.push({metadata:r,content:o.join(`
|
|||
|
|
`).trim()}),o=[]),i=!0,r=l.replace("> [!thino]","").trim()):i&&l.startsWith(">")?o.push(l.replace(/^> /,"")):i&&!l.startsWith(">")&&(i=!1,n.push({metadata:r,content:o.join(`
|
|||
|
|
`).trim()}),o=[],r="")}return i&&n.push({metadata:r,content:o.join(`
|
|||
|
|
`).trim()}),n}async function tO(t,e={}){const{maxRetries:n=3,retryDelay:i=200,useExponentialBackoff:o=!0,forceReread:r=!1}=e;return sA(t,0,n,i,o,r)}async function sA(t,e,n,i,o,r){try{const{vault:a,metadataCache:l}=rt.getState().dailyNotesState.app;if(r)await a.read(t);else try{await a.cachedRead(t)}catch{await a.read(t)}l.getFileCache(t),await new Promise(h=>setTimeout(h,150));const d=l.getFileCache(t)?.listItems||[];return!0}catch(a){if(console.warn(`Failed to refresh file cache for ${t.path} (attempt ${e+1}):`,a),e<n){const l=o?i*Math.pow(2,e):i;return await new Promise(c=>setTimeout(c,l)),sA(t,e+1,n,i,o,r)}return!1}}async function nO(t,e,n,i){const o=n.replace(/\s?\[pinned::[^\]]+\]/g,"").replace(/\s?\[visibility::[^\]]+\]/g,"").replace(/\s?\[archived::[^\]]+\]/g,"").replace(/\s?\[deleted::[^\]]+\]/g,"").replace(/\s?\[webId::[^\]]+\]/g,"").replace(/\s\^([0-9a-zA-Z-]+)($|\s|\n)/g,"").trim(),r=lA(o);let a=null,l=0;for(const c of t){if(!c.position)continue;const m=e.slice(c.position.start.line,c.position.end.line+1).join(`
|
|||
|
|
`).replace(/^- \d{2}:\d{2}\s*/,"").replace(/^- \[.\]\s*\d{2}:\d{2}\s*/,"").replace(/^- \[.\]\s*/,"").replace(/^- /,"").replace(/\s?\[pinned::[^\]]+\]/g,"").replace(/\s?\[visibility::[^\]]+\]/g,"").replace(/\s?\[archived::[^\]]+\]/g,"").replace(/\s?\[deleted::[^\]]+\]/g,"").replace(/\s?\[webId::[^\]]+\]/g,"").replace(/\s\^([0-9a-zA-Z-]+)($|\s|\n)/g,"").trim(),g=iO(o,m,r);if(g===1)return c;g>l&&g>.8&&(a=c,l=g)}return a&&l>.8?a:(console.warn(`⚠️ Could not find memo by content for memo ${i.slice(-6)} (best score: ${l.toFixed(2)})`),null)}function lA(t){const e=t.split(/\s+/).filter(r=>r.length>3),n=[...new Set(e)].slice(0,5).join(" "),i=t.substring(0,30),o=t.length>30?t.substring(t.length-30):"";return`${i}|${o}|${n}`}function iO(t,e,n){if(t===e)return 1;const i=lA(e);if(n===i)return .95;const o=Math.min(t.length,e.length)/Math.max(t.length,e.length);if(o<.5)return 0;const r=new Set(t.toLowerCase().split(/\s+/)),a=new Set(e.toLowerCase().split(/\s+/)),l=new Set([...r].filter(m=>a.has(m))),c=new Set([...r,...a]),d=l.size/c.size,h=t.length>20&&e.includes(t.substring(0,Math.min(50,t.length)))?.3:0;return Math.max(d,h)*o}function oO(t,e){const n=/%%(.*?)%%/,i=t.match(n);if(!i)return t;const o=i[1].trim(),r={};o.split(" ").forEach(l=>{const[c,d]=l.slice(1,-1).split("::");r[c]=d});for(const l of Object.keys(e))if(l!=="id"&&l!=="content"){if(l==="rowStatus"&&e.rowStatus==="ARCHIVED"){r.archived="true";continue}else if(l==="rowStatus"&&e.rowStatus==="NORMAL"){delete r.archived;continue}if(l==="deleted"&&e.deleted){const c=k.moment().format("YYYYMMDDHHmmss");r.deleted=c}else typeof e[l]=="boolean"?e[l]?r[l]="true":delete r[l]:e[l]&&(typeof e[l]=="string"||typeof e[l]=="boolean")&&(r[l]=e[l])}const a=Object.entries(r).map(([l,c])=>`[${l}::${c}]`).join(" ");return t.replace(n,`%% ${a} %%`)}async function To(t,e){if(!t.sourceType||t.sourceType!=="MULTI")return t;const{vault:n,fileManager:i}=rt.getState().dailyNotesState.app,o=n.getAbstractFileByPath(t.path);if(!o)return t;const r=k.moment();if(await i.processFrontMatter(o,a=>{(e.pinned!==void 0||e.thinoType||e.rowStatus||e.visibility||e.deleted)&&We.setChangedByMemos(!0),e.id&&(a.id=e.id),e.thinoType&&(a.thinoType=e.thinoType),e.rowStatus&&(a.rowStatus=e.rowStatus),e.visibility&&(a.visibility=e.visibility),e.webId&&(a.webId=e.webId),e.pinned!==void 0&&(a.pinned=e.pinned),e.deleted!==void 0&&(a.deletedAt=e.deleted?r.format("YYYY/MM/DD HH:mm:ss"):""),a.createdAt||(a.createdAt=r.format("YYYY/MM/DD HH:mm:ss")),a.updatedAt=r.format("YYYY/MM/DD HH:mm:ss")}),e.content){const a=await n.read(o);let l=a;const c=e.content.replace(/\$/g,"$$$$");l=a.replace(t.content,c),await n.modify(o,l)}return We.setChangedByMemos(!0),{...t,id:e.id||t.id,thinoType:e.thinoType||t.thinoType,createdAt:t.createdAt||r.format("YYYY/MM/DD HH:mm:ss"),updatedAt:k.moment().format("YYYY/MM/DD HH:mm:ss"),content:e.content||t.content,rowStatus:e.rowStatus||t.rowStatus,visibility:e.visibility||t.visibility,pinned:e.pinned!==void 0?e.pinned:t.pinned,webId:e.webId||t.webId,deletedAt:e.deleted?r.format("YYYY/MM/DD HH:mm:ss"):e.deleted===!1?"":t.deletedAt?t.deletedAt:""}}async function er(t,e){if(!t.sourceType||t.sourceType!=="FILE")return t;const{vault:n}=rt.getState().dailyNotesState.app,i=n.getAbstractFileByPath(t.path);if(!i)return t;const o=k.moment();let r="";try{r=await n.read(i)}catch(I){console.error(I),r=await n.cachedRead(i)}const a=r.split(/\r?\n/),l=a.findIndex(I=>I.includes("id::"+t.id)||I.includes("Id::"+t.id)||t.webId&&I.includes(t.webId)),c=a[l];if(!c)return t;const d=oO(c,e);if(!c)return t;const h=d+`
|
|||
|
|
`,m=a.findIndex((I,E)=>E>l&&I.trim()==="");let g="";m===-1&&(g=a.slice(l+1).join(`
|
|||
|
|
`)),m!==-1&&(g=a.slice(l+1,m).join(`
|
|||
|
|
`));let y=g;e?.content&&(y=e.content.split(/\r?\n/).map(C=>"> "+C).join(`
|
|||
|
|
`));const w=(h+y).split(/\r?\n/);a.splice(l,m!==-1?m-l:a.length-l,...w);const S=a.join(`
|
|||
|
|
`);return await n.modify(i,S),We.setChangedByMemos(!0),{...t,id:e.id||t.id,thinoType:e.thinoType||t.thinoType,createdAt:t.createdAt||o.format("YYYY/MM/DD HH:mm:ss"),updatedAt:k.moment().format("YYYY/MM/DD HH:mm:ss"),content:e.content||t.content,rowStatus:e.rowStatus||t.rowStatus,visibility:e.visibility||t.visibility,pinned:e.pinned!==void 0?e.pinned:t.pinned,webId:e.webId||t.webId,deletedAt:e.deleted?o.format("YYYY/MM/DD HH:mm:ss"):e.deleted===!1?"":t.deletedAt?t.deletedAt:""}}async function tr(t,e){if(!t.sourceType||t.sourceType!=="CANVAS")return t;const{vault:n}=rt.getState().dailyNotesState.app,i=n.getAbstractFileByPath(t.path);if(!i)return t;const o=await n.read(i),r=JSON.parse(o),a=r.nodes.find(d=>d.id===t.id);if(!a)return t;e.content&&(a.text=e.content),e.thinoType&&(a.thinoType=e.thinoType),e.rowStatus&&(a.rowStatus=e.rowStatus),e.visibility&&(a.visibility=e.visibility),e.pinned!==void 0&&(a.pinned=e.pinned),e.webId&&(a.webId=e.webId);const l=k.moment();e.deleted!==void 0&&(a.deletedAt=e.deleted?l.format("YYYY/MM/DD HH:mm:ss"):""),a.updatedAt=l.format("YYYY/MM/DD HH:mm:ss");const c=JSON.stringify(r,null,2);return await n.modify(i,c),We.setChangedByMemos(!0),{...t,thinoType:e.thinoType||t.thinoType,createdAt:t.createdAt,updatedAt:k.moment().format("YYYY/MM/DD HH:mm:ss"),content:e.content??t.content,rowStatus:e.rowStatus??t.rowStatus,visibility:e.visibility??t.visibility,pinned:e.pinned??t.pinned,webId:e.webId??t.webId,deletedAt:e.deleted?l.format("YYYY/MM/DD HH:mm:ss"):e.deleted===!1?"":t.deletedAt?t.deletedAt:""}}function rO(t,e,n){const i=[];if(!e.find(d=>d.position.start.line===t))return i;const a=(n[t]||"").match(/^(\s*)/),l=a?a[1].length:0,c=d=>/^(\s*)- (\[.\] )?\d{2}:\d{2}/.test(d);for(const d of e){const h=d.position.start.line;if(h<=t)continue;const m=n[h]||"",g=m.match(/^(\s*)/),y=g?g[1].length:0;if(y>l){let T=!0;for(const w of e){const S=w.position.start.line;if(S>t&&S<h){const E=(n[S]||"").match(/^(\s*)/);if((E?E[1].length:0)<=l){T=!1;break}}}T&&i.push(h)}else if(y===l){if(c(m))break}else break}return i}async function ji(t,e){cA()||new k.Notice(v("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:i}=rt.getState().dailyNotesState.app,o=rt.getState().dailyNotesState.app,{settings:r}=rt.getState().dailyNotesState,a=t.id.toString().slice(0,14),l=k.moment(t.createdAt,"YYYY/MM/DD HH:mm:ss").isSame(k.moment(a,"YYYYMMDDHHmmss"))?k.moment(t.createdAt,"YYYY/MM/DD HH:mm:ss"):k.moment(a,"YYYYMMDDHHmmss"),c=k.moment(t.createdAt,"YYYY/MM/DD HH:mm:ss").isSame(l,"day"),d=t.path,h=n.getAbstractFileByPath(d)||n.getAbstractFileByPath(t.path);if(!h)return new k.Notice(v("Please check your daily note plugin OR periodic notes plugin settings")),t;const g=(await n.read(h)).split(`
|
|||
|
|
`);let y=i.getFileCache(h),T=y?.listItems||[];if(T.length===0&&(await tO(h)&&(y=i.getFileCache(h),T=y?.listItems||[],T.length>0),T.length===0)){console.warn(`⚠️ No list items found for memo ${t.id.slice(-6)} even after cache refresh. This might be a newly created memo.`);const pe={...t,content:e.content||t.content,thinoType:e.thinoType||t.thinoType,updatedAt:k.moment().format("YYYY/MM/DD HH:mm:ss"),pinned:e.pinned!==void 0?e.pinned:t.pinned,rowStatus:e.rowStatus||t.rowStatus,visibility:e.visibility||t.visibility,webId:e.webId||t.webId,deletedAt:e.deleted?k.moment().format("YYYY/MM/DD HH:mm:ss"):e.deleted===!1?"":t.deletedAt||""};return console.warn(`Returning updated memo without file modification for memo ${t.id.slice(-6)}`),pe}const w=parseInt(t.id.slice(14));let S=w;P0(T);let I=T.find(ie=>ie.position.start.line===w);if(!I&&t.content&&(I=await nO(T,g,t.content,t.id)),!I&&t.hasId&&(I=T.find(ie=>ie.position?g.slice(ie.position.start.line,ie.position.end.line+1).join(`
|
|||
|
|
`).includes(`^${t.hasId}`):!1)),!I){console.warn(`⚠️ List item not found after all search strategies for memo ${t.id.slice(-6)}. Original line: ${w}. This might indicate a line number mismatch.`);const ie={...t,content:e.content||t.content,thinoType:e.thinoType||t.thinoType,updatedAt:k.moment().format("YYYY/MM/DD HH:mm:ss"),pinned:e.pinned!==void 0?e.pinned:t.pinned,rowStatus:e.rowStatus||t.rowStatus,visibility:e.visibility||t.visibility,webId:e.webId||t.webId,deletedAt:e.deleted?k.moment().format("YYYY/MM/DD HH:mm:ss"):e.deleted===!1?"":t.deletedAt||""};return console.warn(`Returning updated memo without file modification for memo ${t.id.slice(-6)}`),ie}const E=I.position.start.line,L=t.content.split(`
|
|||
|
|
`).length;S=E+L,S>=g.length&&(S=g.length-1);const C=T.find(ie=>{const pe=ie.position.start.line;if(pe<=E)return!1;const Y=g[pe]||"";return/^(\s*)- (\[.\] )?\d{2}:\d{2}/.test(Y)});C&&S>=C.position.start.line&&(console.warn(`⚠️ Limiting endLine to prevent including next memo. Original: ${S}, Limited: ${C.position.start.line-1}`),S=C.position.start.line-1);const R=g.slice(E,S+1),M=R.join(`
|
|||
|
|
`);let O=M;const F=o.vault.getConfig("useTab")===void 0||app.vault.getConfig("useTab")===!0,j=F?1:o.vault.getConfig("tabSize"),z=(F?" ":" ").repeat(j),_=M.match(/\s\^([0-9a-zA-Z-]+)($|\s|\n)/),V=e.hasId!==void 0?e.hasId:_?_[1]:t.hasId||null,G=R[0]||"",Z=Us(G);let ee;Z.fullTimeMatch?ee=Z.fullTimeMatch:ee=c?k.moment(t.createdAt,"YYYY/MM/DD HH:mm:ss").format("HH:mm"):(parseInt(t.id.toString().slice(10,12))+24).toString()+":"+t.id.toString().slice(12,14);let $=ee;!Z.fullTimeMatch&&r.DefaultTimePrefix!=="HH:mm"&&($=k.moment(t.createdAt,"YYYY/MM/DD HH:mm:ss").format(r.DefaultTimePrefix));const re={pinned:M.includes("[pinned::true]"),deleted:M.match(/\[deleted::([^\]]+)\]/)?.[1]||"",archived:M.includes("[archived::true]"),webId:M.match(/\[webId::([^\]]+)\]/)?.[1]||"",visibility:M.match(/\[visibility::"([^"]+)"\]/)?.[1]||""};if(M.match(/^(- \[.\] |- |(\*|\d{1,2}\.) )/)?.[0],e.content){const ie=e.thinoType?e.thinoType==="TASK-TODO"?"- [ ] ":e.thinoType==="TASK-DONE"?"- [x] ":e.thinoType.startsWith("TASK")?`- [${e.thinoType.slice(5)}] `:"- ":t.thinoType==="TASK-TODO"?"- [ ] ":t.thinoType==="TASK-DONE"?"- [x] ":t.thinoType.startsWith("TASK")?`- [${t.thinoType.slice(5)}] `:"- ",pe=[];if((e.pinned!==void 0?e.pinned:re.pinned)&&pe.push("[pinned::true]"),e.deleted||e.deleted!==!1&&re.deleted){const ue=e.deleted?k.moment().format("YYYYMMDDHHmmss"):re.deleted;pe.push(`[deleted::${ue}]`)}(e.rowStatus==="ARCHIVED"||e.rowStatus!=="NORMAL"&&re.archived)&&pe.push("[archived::true]"),(e.webId!==void 0?e.webId:re.webId)&&pe.push(`[webId::${e.webId!==void 0?e.webId:re.webId}]`),(e.visibility||re.visibility)&&pe.push(`[visibility::"${e.visibility||re.visibility}"]`);const Y=V?`^${V}`:"",K=e.content.trim().split(`
|
|||
|
|
`).length>1;/^((-|\*|\d\.|>)\s|```)/g.test(e.content);const ce=e.content.trim().split(`
|
|||
|
|
`);if(/(^(-|\*|\d\.|>)\s)/g.test(ce[ce.length-1]),K){const ue=ce.map(ae=>z+ae);let te=!1;for(let ae=ue.length-1;ae>=0;ae--)if(!/(^(-|\*|\d\.|>)\s)/g.test(ue[ae].trim())){ue[ae]=ue[ae]+(V?` ${Y}`:""),te=!0;break}!te&&V&&(ue[ue.length-1]+=` ${Y}`),O=`${ie}${$}
|
|||
|
|
${ue.join(`
|
|||
|
|
`)} ${pe.join(" ")}`.trim()}else O=`${ie}${$} ${e.content.trim()} ${pe.join(" ")}`.trim()+(Y?` ${Y}`:"")}else{if(e.thinoType){const ie=e.thinoType==="TASK-TODO"?"- [ ] ":e.thinoType==="TASK-DONE"?"- [x] ":e.thinoType.startsWith("TASK")?`- [${e.thinoType.slice(5)}] `:"- ";O=O.replace(/^((- \[.\] )|((-|\*) ))/,ie)}if(e.rowStatus&&(e.rowStatus==="ARCHIVED"?O.includes("[archived::")?O=O.replace(/\[archived::(true|false)\]/,"[archived::true]"):O+=(O.endsWith(" ")?"":" ")+"[archived::true]":e.rowStatus==="NORMAL"&&(O=O.replace(/\s?\[archived::(true|false)\]/,""))),e.visibility){const ie=`[visibility::"${e.visibility}"]`;O.includes("[visibility::")?O=O.replace(/\[visibility::"(PUBLIC|PROTECTED)"\]/,ie):O+=(O.endsWith(" ")?"":" ")+ie}if(e.pinned!==void 0&&(e.pinned?O.includes("[pinned::")?O=O.replace(/\[pinned::(true|false)\]/,"[pinned::true]"):O+=(O.endsWith(" ")?"":" ")+"[pinned::true]":O=O.replace(/\s?\[pinned::(true|false)\]/,"")),e.webId!==void 0&&(O.includes("[webId::")?e.webId===""?O=O.replace(/\s?\[webId::([^\]]+)\]/,""):O=O.replace(/\[webId::([^\]]+)\]/,`[webId::${e.webId}]`):e.webId!==""&&(O+=(O.endsWith(" ")?"":" ")+`[webId::${e.webId}]`)),e.deleted!==void 0){const ie=k.moment();if(e.deleted){const pe=`[deleted::${ie.format("YYYYMMDDHHmmss")}]`;O.includes("[deleted::")?O=O.replace(/\[deleted::([^\]]+)\]/,pe):O+=(O.endsWith(" ")?"":" ")+pe}else O=O.replace(/\s?\[deleted::([^\]]+)\]/,"")}if(e.hasId!==void 0||V){const ie=e.hasId!==void 0?e.hasId:V;O=O.replace(/\s\^([0-9a-zA-Z-]+)($|\s|\n)/g,""),ie&&(O=O.trimEnd(),O+=` ^${ie}`)}}if(O!==M){const ie=S-E+1,pe=O.trim().split(`
|
|||
|
|
`);ie>10&&pe.length<ie/2&&console.warn(`⚠️ Safety check: Replacing ${ie} lines with ${pe.length} lines for memo ${t.id.slice(-6)}. This might indicate content mixing.`);const Y=(M.match(/^- \d{2}:\d{2}/gm)||[]).length;if(Y>1){console.warn(`⚠️ Safety check: Original content contains ${Y} memo-like structures. Limiting replacement to single memo.`);const ue=M.match(/^- \d{2}:\d{2}.*$/m);if(ue){const te=M.indexOf(ue[0]),ae=M.substring(te+ue[0].length).match(/^- \d{2}:\d{2}/m);if(ae){const Ee=E+M.substring(0,te+ue[0].length+M.substring(te+ue[0].length).indexOf(ae[0])).split(`
|
|||
|
|
`).length-1;S=Math.min(S,Ee-1)}}}const K=S-E+1;g.splice(E,K,O.trim()),await n.modify(h,g.join(`
|
|||
|
|
`)),We.setChangedByMemos(!0);const ce=k.moment();return{...t,thinoType:e.thinoType||t.thinoType,createdAt:t.createdAt,updatedAt:k.moment().format("YYYY/MM/DD HH:mm:ss"),content:e.content??t.content,rowStatus:e.rowStatus??t.rowStatus,visibility:e.visibility??t.visibility,pinned:e.pinned??t.pinned,webId:e.webId??t.webId,hasId:e.hasId??t.hasId,deletedAt:e.deleted?ce.format("YYYY/MM/DD HH:mm:ss"):e.deleted===!1?"":t.deletedAt?t.deletedAt:""}}return t}async function aO(t,e,n){const{vault:i,metadataCache:o}=rt.getState().dailyNotesState.app||window.app,r=i.getFileByPath(t);if(!r)return;const a=o.getFileCache(r)?.listItems||[];P0(a);const l=[],c=i.getConfig("useTab")===void 0||app.vault.getConfig("useTab")===!0,d=c?1:i.getConfig("tabSize"),h=(c?" ":" ").repeat(d),m=k.moment(),y=(await i.read(r)).split(`
|
|||
|
|
`);return e.map(w=>{const S=parseInt(w.id.slice(14));let I=a.find(O=>O.position.start.line===S);if(!I&&w.content&&(I=a.find(O=>{if(!O.position)return!1;const z=y.slice(O.position.start.line,O.position.end.line+1).join(`
|
|||
|
|
`).replace(/^- \d{2}:\d{2}\s*/,"").replace(/^- \[.\]\s*\d{2}:\d{2}\s*/,"").replace(/^- \[.\]\s*/,"").replace(/^- /,"").trim(),_=w.content.trim();return z.includes(_.substring(0,50))})),!I)return console.warn(`⚠️ Bulk update: Could not find memo ${w.id.slice(-6)} at line ${S}`),null;const E=I.position.start.line,C=rO(E,a,y).map(O=>{const F=a.find(j=>j.position.start.line===O);return F?F.position.end.line:-1});let R=Math.max(...C,I.position.end.line);const M=a.find(O=>O.position.start.line>E&&(!O.parent||O.parent<=0));return M&&R>=M.position.start.line&&(console.warn(`⚠️ Bulk update: Limiting endLine to prevent including next block. Original: ${R}, Limited: ${M.position.start.line-1}`),R=M.position.start.line-1),{id:w.id,start:E,end:R}}).filter(Boolean).forEach(w=>{const I=y.slice(w.start,w.end+1).join(`
|
|||
|
|
`),E=I.split(`
|
|||
|
|
`),L=E.length-1,R=E[L].trim();let M=I;const O=/\[(pinned|archived|deleted|webId|visibility)::[^\]]*\]\s*$/.test(R),F=(j,z)=>j.split(`
|
|||
|
|
`).length>1&&(/```/g.test(R)||!O)?j+`
|
|||
|
|
`+h+z:j+(j.endsWith(" ")?"":" ")+z;if(n==="delete"){const j="[deleted::"+m.format("YYYYMMDDHHmmss")+"]";M=M.replace(/\[deleted::([^\]]+)\]/,""),M=F(M,j)}if(n==="restoreFromDelete"&&(M=M.replace(/ ?\[deleted::([^\]]+)\]/,"")),n==="archive"){const j="[archived::true]";M.includes("[archived::")?M=M.replace(/\[archived::(true|false)\]/,j):M=F(M,j)}n==="restoreFromArchive"&&(M=M.replace(/ ?\[archived::(true|false)\]/,"")),n==="deleteForever"?y.splice(w.start,w.end-w.start+1):y.splice(w.start,w.end-w.start+1,M),l.push({...e.find(j=>j.id===w.id),deletedAt:n==="delete"?m.format("YYYY/MM/DD HH:mm:ss"):"",rowStatus:n==="archive"?"ARCHIVED":"NORMAL"})}),await i.modify(r,y.join(`
|
|||
|
|
`)),We.setChangedByMemos(!0),l}const sO=t=>{switch(t?.sourceType){case"CANVAS":return tr(t,{id:t.id,pinned:!0});case"DAILY":return ji(t,{id:t.id,pinned:!0});case"MULTI":return To(t,{id:t.id,pinned:!0});case"FILE":return er(t,{id:t.id,pinned:!0})}},lO=t=>{switch(t?.sourceType){case"CANVAS":return tr(t,{id:t.id,pinned:!1});case"DAILY":return ji(t,{id:t.id,pinned:!1});case"MULTI":return To(t,{id:t.id,pinned:!1});case"FILE":return er(t,{id:t.id,pinned:!1})}},cO=t=>{let e;switch(t){case" ":e="TASK-TODO";break;case"x":case"X":e="TASK-DONE";break;default:e="TASK-"+t;break}return e};async function uO(t,e){if(!e)return 0;const{vault:n}=rt.getState().dailyNotesState.app,i=t?.DefaultMemoComposition,o=t?.ProcessEntriesBelow&&t?.ProcessContentTarget!=="whole"?t?.ProcessEntriesBelow:"",r=t?.ProcessContentTarget!=="whole"?t?.DifferentInsertTarget?t?.InsertAfterForTask?t?.InsertAfterForTask:"":o:"";let a;try{a=await n.read(e)}catch(T){console.error(T),a=await n.cachedRead(e)}let l;i!=""&&/{TIME}/g.test(i)&&/{CONTENT}/g.test(i)?l="(-|\\*) (\\[(.{1})\\]\\s)?"+i.replace(/{TIME}/g,"((\\<time\\>)?\\d{1,2}:\\d{2}(\\:\\d{2})?)?").replace(/ {CONTENT}/g,""):l="(-|\\*) (\\[(.{1})\\]\\s)?((\\<time\\>)?\\d{1,2}\\:\\d{2}(\\:\\d{2})?)?";const c=new RegExp(l,"g"),d=(a.match(c)||[]).length,h=new RegExp(o.replace(/([.?*+^$[\]\\(){}|-])/g,"\\$1"),"g"),m=new RegExp(r.replace(/([.?*+^$[\]\\(){}|-])/g,"\\$1"),"g"),g=(a.match(h)||[]).length,y=(a.match(m)||[]).length;return a=null,g||y?d:0}function TI(t,e,n,i,o){const r=rt.getState().dailyNotesState.app||window.app,a=Lt.getDateFromFile(o,"day")||k.moment(o.stat.ctime),l=JL(o,n,e),c=r?.metadataCache.getFileCache(o),d={frontmatter:c?.frontmatter||{},tags:c?.frontmatter?.tags||[]};for(const h of l){dO(a,h,t);const{rawText:m,memoType:g}=hO(h),{content:y,pinned:T,archived:w,deleted:S,deletedAtStr:I,webId:E,visibility:L}=fO(m,h),C=Xf(y);i.push({id:a.format("YYYYMMDDHHmmss")+`${h.index}`,content:y.trim(),createdAt:a.format("YYYY/MM/DD HH:mm:ss"),updatedAt:a.format("YYYY/MM/DD HH:mm:ss"),thinoType:g,hasId:h.blockId?h.blockId:"",linkId:C,path:o.path,deletedAt:S?k.moment(I,"YYYYMMDDHHmmss").format("YYYY/MM/DD HH:mm:SS"):"",rowStatus:w?"ARCHIVED":"NORMAL",visibility:L,pinned:T,creatorName:"Thino",resourceList:[],sourceType:"DAILY",webId:E,fileInfo:d})}}function dO(t,e,n){const i=Us(e.line);if(i.startHour&&i.startMin)t.hours(parseInt(i.startHour)),t.minutes(parseInt(i.startMin)),i.startSec?t.seconds(parseInt(i.startSec)):t.seconds(0);else{const o=pO(n.DefaultMemoComposition,e.line),r=mO(n.DefaultMemoComposition,e.line),a=gO(e.line);t.hours(parseInt(o)),t.minutes(parseInt(r)),a?t.seconds(parseInt(a)):t.seconds(0)}}function hO(t){let e=vO(t.line),n;if(/^\s*[-*]\s(\[(.)\])\s/g.test(t.line)){const i=yO(t.line);e=wO(t.line),n=cO(i)}else n="JOURNAL";return{rawText:e,memoType:n}}function fO(t,e){if(!t)return{content:"",pinned:!1,archived:!1,deleted:!1,deletedAtStr:"",webId:"",visibility:"PRIVATE"};let n=t.trim().replaceAll(/<br>/g,`
|
|||
|
|
`);const i=new RegExp(/\[(pinned|PINNED)::true\]/,"g").test(t),o=new RegExp(/\[(archived|ARCHIVED)::true\]/,"g").test(t),r=new RegExp(/\[(deleted|DELETED)::([^\]]*)\]/,"g").test(t),a=new RegExp(/\[(deleted|DELETED)::([^\]]*)\]/,"g").exec(t)?.[2],l=new RegExp(/\[(webId|WEBID)::([^\]]*)\]/,"g").exec(t)?.[2],c=new RegExp(/\[(visibility|VISIBILITY)::("PROTECT"|"PUBLIC")\]/,"g").test(t)?"PUBLIC":"PRIVATE";return n=n.replace(/\s?\[pinned::[^\]]+\]/g,"").replace(/\s?\[visibility::[^\]]+\]/g,"").replace(/\s?\[archived::[^\]]+\]/g,"").replace(/\s?\[deleted::[^\]]+\]/g,"").replace(/\s?\[webId::[^\]]+\]/g,""),e.blockId&&(n=n.replace("^"+e.blockId,"")),{content:n,pinned:i,archived:o,deleted:r,deletedAtStr:a,webId:l,visibility:c}}function Xf(t){const e=[],n=/(?:\[\[([^\]|]+)#\^([a-zA-Z0-9-]+)(?:\|[^\]]+)?\]\])|(?:\[.+?\]\(([^)]+)#\^([a-zA-Z0-9-]+)\))/g;let i;for(;(i=n.exec(t))!==null;)i[1]&&i[2]?e.push(`${i[1]}#^${i[2]}`):i[3]&&i[4]&&e.push(`${i[3]}#^${i[4]}`);return e}function Us(t){const e=/((\d{1,2}):(\d{2})(:(\d{2}))?)-(\d{1,2}):(\d{2})(:(\d{2}))?/,n=/(\d{1,2}):(\d{2})(:(\d{2}))?/,i=t.match(e);if(i)return{startHour:i[2],startMin:i[3],startSec:i[5],endHour:i[6],endMin:i[7],endSec:i[9],fullTimeMatch:i[0]};const o=t.match(n);return o?{startHour:o[1],startMin:o[2],startSec:o[4],fullTimeMatch:o[0]}:{startHour:"",startMin:"",fullTimeMatch:""}}const pO=(t,e)=>{const n=Us(e);if(n.startHour)return n.startHour;let i;return t!=""&&/{TIME}/g.test(t)&&/{CONTENT}/g.test(t)?i="^\\s*(\\-|\\*|(\\d{1,}\\.))\\s(\\[(.{1})\\]\\s?)?"+t.replace(/{TIME}/g,"(\\<time\\>)?(\\d{1,2})\\:(\\d{2})(\\:\\d{2})?").replace(/{CONTENT}/g,"(.*)"):i="^\\s*(\\-|\\*|(\\d{1,}\\.))\\s(\\[(.{1})\\]\\s?)?(\\<time\\>)?(\\d{1,2})\\:(\\d{2})(.*)",new RegExp(i,"").exec(e)?.[6]},mO=(t,e)=>{const n=Us(e);if(n.startMin)return n.startMin;let i;return t!=""&&/{TIME}/g.test(t)&&/{CONTENT}/g.test(t)?i="^\\s*(\\-|\\*|(\\d{1,}\\.))\\s(\\[(.{1})\\]\\s?)?"+t.replace(/{TIME}/g,"(\\<time\\>)?(\\d{1,2})\\:(\\d{2})(\\:\\d{2})?").replace(/{CONTENT}/g,"(.*)"):i="^\\s*(\\-|\\*|(\\d{1,}\\.))\\s(\\[(.{1})\\]\\s?)?(\\<time\\>)?(\\d{1,2})\\:(\\d{2})(.*)",new RegExp(i,"").exec(e)?.[7]},gO=t=>{const e=Us(t);if(e.startSec)return e.startSec;const n="^\\s*(\\-|\\*|(\\d{1,}\\.))\\s(\\[(.{1})\\]\\s?)?(\\d{1,2})\\:(\\d{2})\\:(\\d{2})(.*)";return new RegExp(n,"").exec(t)?.[7]},yO=t=>/^\s*[\-\*]\s(\[(.{1})\])\s(.*)/.exec(t)?.[2],cA=()=>Lt.appHasDailyNotesPluginLoaded()?!0:(new k.Notice(v("Check if you opened Daily Notes Plugin Or Periodic Notes Plugin")),!1);function vO(t){const e=Us(t);return e.fullTimeMatch?t.replace(new RegExp(`^(-|\\*|\\d\\.) (${e.fullTimeMatch})\\s(.*)`),"$3"):t.replace(/^(-|\*|\d\.) (\d{1,2}:\d{2}(:\d{2})?)\s(.*)/g,"$4")}function wO(t){return bO(t)}const bO=t=>{const e=Us(t);if(e.fullTimeMatch)return new RegExp(`^(-|\\*|\\d\\.)\\s+\\[.\\]\\s(${e.fullTimeMatch})\\s([\\w\\W]*)`).exec(t)?.[3];const n="^(-|\\*|\\d\\.)\\s+\\[.\\]\\s(\\d{1,2}:\\d{2}(:\\d{2})?)\\s([\\w\\W]*)";return new RegExp(n,"").exec(t)?.[4]};async function uA(t,e=!1){const n=rt.getState().dailyNotesState.app,i=n.vault.getFileByPath(t.path);if(i&&t.hasId)return e?"!"+n.fileManager.generateMarkdownLink(i,"","#^"+t.hasId,t.id):t.hasId?n.fileManager.generateMarkdownLink(i,"","#^"+t.hasId,t.id):`[@THINO](${t.id})`;const o=Ne.randomId(6);return await ji(t,{id:t.id,hasId:o}),i?e?"!"+n.fileManager.generateMarkdownLink(i,"","#^"+o,t.id):n.fileManager.generateMarkdownLink(i,"","#^"+o,t.id):`[@THINO](${t.id})`}const II=()=>typeof performance<"u"?performance.now():Date.now();function gg(){const t=window;return t.__THINO_PERF__||(t.__THINO_PERF__={records:{}}),t.__THINO_PERF__}const Ji={start(t){try{const e=gg();e.records[t]={label:t,start:II()}}catch{}},end(t,e){try{const i=gg().records[t];if(!i)return;i.end=II(),i.duration=i.end-i.start}catch{}},mark(t){this.start(t),this.end(t)},getAll(){try{return{...gg().records}}catch{return{}}}};async function dA(t,e){if(!t)return e;const n=rt.getState().dailyNotesState.app||window.app;if(!await n.vault.adapter.exists(t.path))return e;const o=rt.getState().dailyNotesState.settings,r=await XL(t
|
|||
|
|
`);){const i=n.indexOf(`
|
|||
|
|
`);e.push(n.slice(0,i)),n=n.slice(i+1)}return e.push(n),e}async function jO({content:t,isList:e,name:n}){const i=rt.getState().dailyNotesState.settings,o=k.moment(),r=Ne.randomId(16),a=i?.MemoOtherSaveLocation.MemoDefaultMultiFilePath||"Thino",l=n||`${o.format("YYYYMMDD")}-${r}`,c=`${a}/${l}.md`,d={id:r,content:t,deletedAt:"",path:c,createdAt:o.format("YYYY/MM/DD HH:mm:ss"),updatedAt:o.format("YYYY/MM/DD HH:mm:ss"),thinoType:e?"JOURNAL":"TASK-TODO",hasId:"",linkId:[],pinned:!1,visibility:"PUBLIC",rowStatus:"NORMAL",creatorName:"Thino",resourceList:[],sourceType:"MULTI",fileInfo:{tags:[],frontmatter:{}}},h=Ve.getState().app||window.app,{vault:m,fileManager:g}=h,y=m.getAbstractFileByPath(a);(!y||!(y instanceof k.TFolder))&&(new k.Notice(v("Folder not found for the given thino path, is creating a new folder")),await m.createFolder(a)),We.setChangedByMemos(!0);let T;const w=h.vault.getFileByPath(c);w?T=await m.create(`${a}/${o.format("YYYYMMDD")}-${r}.md`,t):T=await m.create(c,t),await g.processFrontMatter(T,E=>{E.id=r,E.createdAt=o.format("YYYY/MM/DD HH:mm:ss"),E.updatedAt=o.format("YYYY/MM/DD HH:mm:ss"),E.thinoType=e?"JOURNAL":"TASK-TODO"}),(!n||w)&&i?.SetFileNameAfterCreate&&h.fileManager.promptForFileRename(T);const S=h.metadataCache.getFileCache(T),I={tags:S?.frontmatter?.tags||[],frontmatter:S?.frontmatter||{}};return{...d,fileInfo:I}}async function HO({content:t,isList:e}){const n=rt.getState().dailyNotesState.settings,i=k.moment(),o=Ne.randomId(16),r=n?.MemoOtherSaveLocation.MemoDefaultSingleFilePath||"basic.thino.md",a={id:o,content:t,deletedAt:"",path:r,createdAt:i.format("YYYY/MM/DD HH:mm:ss"),updatedAt:i.format("YYYY/MM/DD HH:mm:ss"),thinoType:e?"JOURNAL":"TASK-TODO",hasId:"",linkId:[],pinned:!1,visibility:"PUBLIC",rowStatus:"NORMAL",creatorName:"Thino",resourceList:[],sourceType:"FILE",fileInfo:{tags:[],frontmatter:{}}},l=Ve.getState().app,{vault:c}=l;let d=c.getAbstractFileByPath(r);(!d||!(d instanceof k.TFile))&&(new k.Notice(v("File not found for the given thino path, is creating a new file")),d=await c.create(r,""));const h=l.metadataCache.getFileCache(d),m={tags:h?.frontmatter?.tags||[],frontmatter:h?.frontmatter||{}};let g="";try{g=await c.read(d)||await c.cachedRead(d)}catch(L){console.error(L),new k.Notice(v("Failed to read current daily note, check if it exists."))}const y=g.indexOf(`# ${i.format("YYYY-MM-DD")}`);let T=g.indexOf(`
|
|||
|
|
#`,y+1);T===-1&&(T=g.length);const w=`> [!thino] ${i.format("YYYY/MM/DD HH:mm:ss")} %% [id::${o}] [thinoType::${e?"JOURNAL":"TASK-TODO"}] %%`,S=t.replace(/\n/g,`
|
|||
|
|
> `),I=`
|
|||
|
|
${w}
|
|||
|
|
> ${S}
|
|||
|
|
`;let E;if(y===-1){const L=`# ${i.format("YYYY-MM-DD")}`;E=`${g.substring(0,T)}
|
|||
|
|
${L}${I}
|
|||
|
|
${g.substring(T)}`}else E=`${g.substring(0,T)}${I}${g.substring(T)}`;return setTimeout(async()=>{We.setChangedByMemos(!0),await c.modify(d,E)},200),{...a,fileInfo:m}}async function EI(t){const e=rt.getState().dailyNotesState.settings,n=k.moment(t.createdAt,"YYYY/MM/DD HH:mm:ss"),i=t.id,o=e?.MemoOtherSaveLocation.MemoDefaultSingleFilePath||"basic.thino.md",r={id:i,content:t.content,deletedAt:t.deletedAt||"",path:o,createdAt:n.format("YYYY/MM/DD HH:mm:ss"),updatedAt:n.format("YYYY/MM/DD HH:mm:ss"),thinoType:t.thinoType||"JOURNAL",hasId:"",linkId:[],pinned:t.pinned,visibility:"PUBLIC",rowStatus:t.rowStatus||"NORMAL",creatorName:"Thino",resourceList:[],sourceType:"FILE",webId:t.id,fileInfo:t?.fileInfo},a=Ve.getState().app,{vault:l}=a;let c=l.getAbstractFileByPath(o);(!c||!(c instanceof k.TFile))&&(new k.Notice(v("File not found for the given thino path, is creating a new file")),c=await l.create(o,""));let d="";try{d=await l.read(c)||await l.cachedRead(c)}catch(E){console.error(E),new k.Notice(v("Failed to read current daily note, check if it exists."))}const h=a.metadataCache.getFileCache(c),m={tags:h?.frontmatter?.tags||[],frontmatter:h?.frontmatter||{}},g=d.indexOf(`# ${n.format("YYYY-MM-DD")}`);let y=d.indexOf(`
|
|||
|
|
#`,g+1);y===-1&&(y=d.length);const T=`> [!thino] ${n.format("YYYY/MM/DD HH:mm:ss")} %% [id::${i}] [thinoType::JOURNAL]${t.rowStatus==="ARCHIVED"?" [archived::true]":""}${t.pinned===!0?" [pinned::true]":""}${t.deletedAt?` [deleted::${t.deletedAt}]`:""}${t.id?` [webId::${t.id}]`:""} %%`,w=t.content.replace(/\n/g,`
|
|||
|
|
> `),S=`
|
|||
|
|
${T}
|
|||
|
|
> ${w}
|
|||
|
|
`;let I;if(g===-1){const E=`# ${n.format("YYYY-MM-DD")}`;I=`${d.substring(0,y)}
|
|||
|
|
${E}${S}
|
|||
|
|
${d.substring(y)}`}else I=`${d.substring(0,y)}${S}${d.substring(y)}`;return We.setChangedByMemos(!0),await l.modify(c,I),{...r,fileInfo:m}}async function BO({content:t,isList:e}){const i=rt.getState().dailyNotesState.settings?.MemoOtherSaveLocation.MemoDefaultCanvasPath||"basic.thino.canvas",o=k.moment(),r=Ne.randomId(16),a={id:r,content:t,deletedAt:"",path:i,createdAt:o.format("YYYY/MM/DD HH:mm:ss"),updatedAt:o.format("YYYY/MM/DD HH:mm:ss"),thinoType:e?"JOURNAL":"TASK-TODO",hasId:"",linkId:[],pinned:!1,visibility:"PUBLIC",rowStatus:"NORMAL",creatorName:"Thino",resourceList:[],sourceType:"CANVAS",fileInfo:{tags:[],frontmatter:{}}},l=Ve.getState().app,{vault:c}=l,d=await QL(i,l);if(!d||!(d instanceof k.TFile)){new k.Notice(v("File not found for the given thino path, is creating a new file"));return}const h=await c.read(d),m=JSON.parse(h);if(m.nodes.find(S=>S.id===a.id))return;let y;m.nodes.length>0&&(y=[...m.nodes].reduce((S,I)=>{if(!S.createdAt)return I;const E=k.moment(S.createdAt,"YYYY/MM/DD HH:mm:ss"),L=k.moment(I.createdAt,"YYYY/MM/DD HH:mm:ss");return E.isAfter(L)?S:I}));const T=y?{x:y.x,y:y.y+100,width:y.width,height:y.height}:{x:0,y:0,width:200,height:100};m.nodes.push({...T,type:"text",id:r,text:t,deletedAt:"",createdAt:o.format("YYYY/MM/DD HH:mm:ss"),updatedAt:o.format("YYYY/MM/DD HH:mm:ss"),thinoType:e?"JOURNAL":"TASK-TODO",hasId:"",linkId:[],pinned:!1,visibility:"PUBLIC",rowStatus:"NORMAL",creatorName:"Thino",resourceList:[]}),We.setChangedByMemos(!0);const w=JSON.stringify(m,null,2);return await c.modify(d,w),a}async function vg(t,e,n,i){const{vault:o}=rt.getState().dailyNotesState.app||window.app,r=rt.getState().dailyNotesState.app||window.app,a=rt.getState().dailyNotesState.settings,l=r.vault.getConfig("useTab")===void 0||window.app.vault.getConfig("useTab")===!0,c=l?1:r.vault.getConfig("tabSize"),d=(l?" ":" ").repeat(c),h=t.split(`
|
|||
|
|
`).join(`
|
|||
|
|
`+d),m=n||k.moment(),{DifferentInsertTarget:g,InsertAfterForTask:y,InsertType:T}=a,w=m.format(a.DefaultTimePrefix||"HH:mm");let S="",I="";a.UseMemoFixedStrings&&(S=df(a.MemoFixedPrefix||"",m),I=df(a.MemoFixedSuffix||"",m));const E=T==="end"?"":e?a.InsertAfter:g&&y||a.InsertAfter,L=r?.loadLocalStorage("tokenForSync");let C="";try{!i&&t&&L&&a.startSync&&(C=(await L0({content:t,thinoType:"DAILY",thinoStatus:e?"JOURNAL":"TASK-TODO"})).id)}catch(pe){console.error(pe)}const R=S?S+(S.endsWith(" ")?"":" ")+h:h,M=I?R+(R.endsWith(" ")?"":" ")+I:R,O=e?"- ":"- [ ] ",F=a?.DefaultMemoComposition?`${O}${a?.DefaultMemoComposition?.replace(/{TIME}/g,w).replace(/{CONTENT}/g,(M.split(`
|
|||
|
|
`).length>1||/^((-|\*|\d\.|>)\s|```)/g.test(M)?`
|
|||
|
|
`+d:"")+M)}${M.split(`
|
|||
|
|
`).length>1&&/((-|\*|\d\.|>)\s|```)/g.test(M.split(`
|
|||
|
|
`)[M.split(`
|
|||
|
|
`).length-1])&&C?`
|
|||
|
|
`+d:" "}${C?`[webId::${C}]`:""}`:`${O}${w} ${M.split(`
|
|||
|
|
`).length>1||/^((-|\*|\d\.|>)\s|```)/g.test(M)?`
|
|||
|
|
`+d:""}${M}${M.split(`
|
|||
|
|
`).length>1&&/((-|\*|\d\.|>)\s|```)/g.test(M.split(`
|
|||
|
|
`)[M.split(`
|
|||
|
|
`).length-1])&&C?`
|
|||
|
|
`+d:" "}${C?`[webId::${C}]`:""}`,j=Lt.getAllDailyNotes(),z=Lt.getDailyNote(m,j),_="fake"+Ne.randomId(16);let V=!1;const G=r.plugins.getPlugin("templater-obsidian");let Z;if(z?Z=z:(G?.templater&&G?.settings.trigger_on_file_creation&&(he.setWaitingForTemplater({origin:t,date:m,isList:e,id:_,type:C?"web":"local"}),V=!0),Z=await Ne.createDailyNoteCheck(m)),!Z){new k.Notice(v("Failed to create daily note, check if it exists."));return}if(z||await Ve.fechLocalDailyNotes(),G&&G?.templater&&G?.settings.trigger_on_file_creation&&V)return We.setChangedByMemos(!0),{id:_,content:M,deletedAt:"",createdAt:m.format("YYYY/MM/DD HH:mm:ss"),updatedAt:m.format("YYYY/MM/DD HH:mm:ss"),thinoType:e?"JOURNAL":"TASK-TODO",path:Z.path,hasId:"",linkId:[],webId:C,pinned:!1,visibility:"PUBLIC",rowStatus:"NORMAL",creatorName:"Thino",resourceList:[],sourceType:"DAILY",fileInfo:{tags:[],frontmatter:{}}};let ee="";try{ee=await o.read(Z)||await o.cachedRead(Z)}catch(pe){console.error(pe),new k.Notice(v("Failed to read current daily note, check if it exists."))}const $=r.metadataCache.getFileCache(Z),re={tags:$?.frontmatter?.tags||[],frontmatter:$?.frontmatter||{}},ne=await pA(E,F,ee);await o.modify(Z,ne.content);const ie=ne.posNum===-1?mA(ne.content).length-(F.split(`
|
|||
|
|
`).length-1)-1:ne.posNum+1;return We.setChangedByMemos(!0),{id:m.format("YYYYMMDDHHmm")+"00"+ie,content:M,deletedAt:"",createdAt:m.format("YYYY/MM/DD HH:mm:ss"),updatedAt:m.format("YYYY/MM/DD HH:mm:ss"),thinoType:e?"JOURNAL":"TASK-TODO",path:Z.path,hasId:"",linkId:[],webId:C,pinned:!1,visibility:"PUBLIC",rowStatus:"NORMAL",creatorName:"Thino",resourceList:[],sourceType:"DAILY",fileInfo:re}}async function xI(t){const{vault:e}=rt.getState().dailyNotesState.app||window.app,n=rt.getState().dailyNotesState.app||window.app,{DefaultMemoComposition:i,InsertAfter:o,DefaultTimePrefix:r,DifferentInsertTarget:a,InsertAfterForTask:l,InsertType:c,UseMemoFixedStrings:d,MemoFixedPrefix:h,MemoFixedSuffix:m}=rt.getState().dailyNotesState.settings;let g=(t.pinned?" [pinned::true]":"")+(t.rowStatus==="ARCHIVED"?" [archived::true]":"")+(t.visibility==="PRIVATE"?' [visibility::"PRIVATE"]':"");if(t.id){const K=" [webId::"+t.id+"]";g+=K}const y=k.moment();if(t.deletedAt){const K=" [deleted::"+y.format("YYYYMMDDHHmmss")+"]";g+=K}const T=n.vault.getConfig("useTab")===void 0||n.vault.getConfig("useTab")===!0,w=T?1:n.vault.getConfig("tabSize"),S=(T?" ":" ").repeat(w),I=t.content.split(`
|
|||
|
|
`).join(`
|
|||
|
|
`+S),E=k.moment(t.createdAt,"YYYY/MM/DD HH:mm:ss");let L="",C="";d&&(L=df(h||"",E),C=df(m||"",E));const R=L?L+(L.endsWith(" ")?"":" ")+I:I,M=C?R+(R.endsWith(" ")?"":" ")+C:R,O=E.format(r||"HH:mm"),F=!t.thinoType||t.thinoType==="JOURNAL"?"- ":t.thinoType==="TASK-TODO"?"- [ ] ":"- [x] ",j=i?`${F}${i?.replace(/{TIME}/g,O).replace(/{CONTENT}/g,(M.split(`
|
|||
|
|
`).length>1||/^((-|\*|\d\.|>)\s|```)/g.test(M)?`
|
|||
|
|
`+S:"")+M)}${M.split(`
|
|||
|
|
`).length>1&&/```/g.test(M.split(`
|
|||
|
|
`)[M.split(`
|
|||
|
|
`).length-1])&&g.trim()?`
|
|||
|
|
`+S:" "}${g}`:`${F}${O} ${M.split(`
|
|||
|
|
`).length>1||/^((-|\*|\d\.|>)\s|```)/g.test(M)?`
|
|||
|
|
`+S:""}${M}${M.split(`
|
|||
|
|
`).length>1&&/```/g.test(M.split(`
|
|||
|
|
`)[M.split(`
|
|||
|
|
`).length-1])&&g.trim()?`
|
|||
|
|
`+S:" "}${g}`,z=Lt.getAllDailyNotes(),_=Lt.getDailyNote(E,z),V="fake"+Ne.randomId(16);let G=!1;const Z=n.plugins.getPlugin("templater-obsidian");let ee;if(_?ee=_:(Z?.templater&&Z?.settings.trigger_on_file_creation&&(he.setWaitingForTemplater({origin:t.content,date:E,isList:t.thinoType&&t.thinoType==="JOURNAL",id:V,type:"local"}),G=!0),ee=await Ne.createDailyNoteCheck(E)),!ee){new k.Notice(v("Failed to create daily note, check if it exists.")),new k.Notice(v("Your content has been copied to clipboard, and inserted into the editor. Please try it again")),await navigator.clipboard.writeText(t.content);const K=n.workspace.getLeavesOfType("thino_view").first();n.workspace.trigger("send-to-thino",t.content,K);return}if(_||await Ve.fechLocalDailyNotes(),Z&&Z?.templater&&Z?.settings.trigger_on_file_creation&&G)return We.setChangedByMemos(!0),{id:V,content:t.content,deletedAt:t.deletedAt??"",createdAt:E.format("YYYY/MM/DD HH:mm:ss"),updatedAt:E.format("YYYY/MM/DD HH:mm:ss"),thinoType:t.thinoType||"JOURNAL",path:ee.path,hasId:"",linkId:[],pinned:t.pinned??!1,visibility:"PUBLIC",rowStatus:t.rowStatus??"NORMAL",webId:t.webId||t.id,creatorName:"Thino",resourceList:[],sourceType:"DAILY",fileInfo:t?.fileInfo||{tags:[],frontmatter:{}}};const $=n.metadataCache.getFileCache(ee),re={tags:$?.frontmatter?.tags||[],frontmatter:$?.frontmatter||{}};let ne="";try{ne=await e.read(ee)||await e.cachedRead(ee)}catch(K){console.error(K),new k.Notice(v("Failed to read current daily note, check if it exists."))}const ie=c==="end"?"":t.thinoType&&a&&l||o,pe=await pA(ie,j,ne);await e.modify(ee,pe.content);const Y=pe.posNum===-1?mA(pe.content).length-1:pe.posNum+1;return We.setChangedByMemos(!0),{id:E.format("YYYYMMDDHHmm")+"00"+Y,content:t.content,deletedAt:t.deletedAt??"",createdAt:E.format("YYYY/MM/DD HH:mm:ss"),updatedAt:E.format("YYYY/MM/DD HH:mm:ss"),thinoType:t.thinoType||"JOURNAL",path:ee.path,hasId:"",linkId:[],pinned:t.pinned??!1,visibility:"PUBLIC",rowStatus:t.rowStatus??"NORMAL",webId:t.id,creatorName:"Thino",resourceList:[],sourceType:"DAILY",fileInfo:re}}async function pA(t,e,n){const i=new RegExp(`(s*?)${await RO(t)}(s*?)`),o=FO(n),r=o.findIndex(d=>i.test(d)),a=t?.trim()===""?!0:r===-1,l=o.slice(r+1).findIndex(d=>/(^#+ |---|^\^[a-zA-Z0-9-]{2,}$)/.test(d)),c=l!==-1;if(c){let d;for(let h=l+r;h>r;h--)if(!/^[\s\n ]*$/.test(o[h])){d=h;break}return d||(d=r),await CI(e,n,a?-1:d,c)}else return await CI(e,n,o.length-1,c)}async function CI(t,e,n,i){if(n<-1)throw new Error("Invalid position");if(n===-1)return{content:`${e}
|
|||
|
|
${t}`,posNum:-1};const o=e.split(`
|
|||
|
|
`),r=o.slice(0,n+1).join(`
|
|||
|
|
`),a=o.slice(n+1).join(`
|
|||
|
|
`),l=a.trim().length>0;return{content:`${r}${!l&&!i||!r.endsWith(`
|
|||
|
|
`)?`
|
|||
|
|
`:""}${t}${(l||i?`
|
|||
|
|
`:"")+a}`,posNum:n}}const mA=t=>t.split(/\r?\n/);async function zO(t){const e=rt.getState().dailyNotesState.app,n=e.vault.getAbstractFileByPath(t.path);if(!(n instanceof k.TFile)){new k.Notice(v("File not found for the given thino path"));return}await e.vault.delete(n)}async function UO(t){const e=rt.getState().dailyNotesState.app,n=e.vault.getAbstractFileByPath(t.path);if(!(n instanceof k.TFile)){new k.Notice(v("File not found for the given thino path"));return}const o=(await e.vault.read(n)).split(`
|
|||
|
|
`),r=o.findIndex(c=>c.includes(t.id));if(r===-1){new k.Notice(v("Thino not found"));return}const a=o.findIndex((c,d)=>d>r&&c.trim()==="");a===-1?o.splice(r,o.length-r):o.splice(r,a-r);const l=o.join(`
|
|||
|
|
`);if(!l){new k.Notice(v("Thino not found"));return}We.setChangedByMemos(!0),await e.vault.modify(n,l)}async function _O(t){const e=rt.getState().dailyNotesState.app,n=e.metadataCache.getFirstLinkpathDest("",t.path);if(!n){new k.Notice(v("File not found for the given thino path"));return}const i=await e.vault.read(n),o=JSON.parse(i),r=o.nodes,a=r.findIndex(h=>h.id===t.id);if(a===-1){new k.Notice(v("Thino not found"));return}r.splice(a,1);const l=o.edges;l.filter(h=>h.fromNode===t.id||h.toNode===t.id).forEach(h=>{const m=l.findIndex(g=>g.id===h.id);m!==-1&&l.splice(m,1)}),We.setChangedByMemos(!0);const d=JSON.stringify(o,null,2);await e.vault.modify(n,d)}async function YO(t){cA()||new k.Notice(v("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:e,metadataCache:n}=rt.getState().dailyNotesState.app,i=t.path,o=e.getAbstractFileByPath(i);if(!o){new k.Notice(v("Please check your daily note plugin OR periodic notes plugin settings"));return}const r=await e.read(o),a=r.split(`
|
|||
|
|
`),c=n.getFileCache(o)?.listItems||[],d=parseInt(t.id.slice(14));let h=d;function m(w,S){const I=[];for(const E in S)S[E]===w&&I.push(parseInt(E),...m(parseInt(E),S));return I}const g=P0(c),y=c.find(w=>w.position.start.line===d),T=m(d,g);if(T.length>0){const w=T.map(S=>{const I=c.find(E=>E.position.start.line===S);return I?I.position.end.line:-1});h=Math.max(...w,y.position.end.line)}else h=y.position.end.line;if(!r){new k.Notice(v("Thino not found"));return}We.setChangedByMemos(!0),a.splice(d,h-d+1),await e.modify(o,a.join(`
|
|||
|
|
`))}async function VO(){const{vault:t,metadataCache:e}=rt.getState().dailyNotesState.app,n=rt.getState().dailyNotesState.settings,o=Jf()+"/"+n.DeleteFileName+".md",r=[],a=e.getFirstLinkpathDest("",o);if(a instanceof k.TFile){let l=await t.read(a),c=WO(l);if(c.length===0)return r;for(let d=0;d<c.length;d++){const h=c[d];if(/- /.test(h)){const g=qO(h).slice(0,13),y=k.moment(g,"YYYYMMDDHHmmss"),T=$O(c[d]),w=k.moment(T.slice(0,13),"YYYYMMDDHHmmss"),S=GO(c[d]);r.push({id:T,content:S,user_id:1,createdAt:y.format("YYYY/MM/DD HH:mm:SS"),updatedAt:y.format("YYYY/MM/DD HH:mm:SS"),deletedAt:w})}else continue}c=null,l=null}return r}const WO=t=>t.split(/\r?\n/),qO=t=>/^- (\d{14})(\d+)\s(.+)\s(deletedAt: )(.+)$/.exec(t)?.[1],GO=t=>/^- (\d+)\s(.+)\s(deletedAt: )(.+)$/.exec(t)?.[2],$O=t=>/^- (\d+)\s(.+)\s(deletedAt: )(.+)$/.exec(t)?.[4];async function ZO(t){const e=await tc(rt.getState().dailyNotesState.app)||[],n=e.findIndex(i=>i.id===t);e.splice(n,1),await qu(rt.getState().dailyNotesState.app,e)}const KO=async t=>{const{app:e}=rt.getState().dailyNotesState,n=await tc(e)||[],i=n.find(o=>o.id===t);if(i){const o=k.moment().format("YYYY/MM/DD HH:mm:ss");return i.pinnedAt=o,await qu(e,n),o}else{new k.Notice(v("Query not found"));return}},JO=async t=>{const{app:e}=rt.getState().dailyNotesState,n=await tc(e)||[],i=n.find(o=>o.id===t);if(i){i.pinnedAt="",await qu(e,n);return}else{new k.Notice(v("Query not found"));return}};var $b;(t=>{async function e(w){return await kI(w)}t.getMyMemos=e;async function n(w){return await kI([w])}t.updateSpecificTypeMemo=n;function i(){return VO()}t.getMyDeletedMemos=i;function o(w){const S=he.getMemoById(w);if(S)switch(S?.sourceType){case"DAILY":return ji(S,{id:S.id,deleted:!1});case"CANVAS":return tr(S,{id:S.id,deleted:!1});case"MULTI":return To(S,{id:S.id,deleted:!1});case"FILE":return er(S,{id:S.id,deleted:!1})}}t.restoreMemo=o;function r(w){return UO(w)}t.deleteMemoInSingleFile=r;function a(w){return zO(w)}t.deleteMemoInMultiFiles=a;function l(w){return YO(w)}t.deleteMemoInDailyNote=l;function c(w){return _O(w)}t.deleteMemoInCanvas=c;function d(){return GL()}t.getMyQueries=d;async function h(w,S){return await ZL(w,S)}t.createQuery=h;function m(w,S,I){return EO(w,S,I)}t.updateQuery=m;function g(w){return ZO(w)}t.deleteQueryById=g;function y(w){return KO(w)}t.pinQuery=y;function T(w){return JO(w)}t.unpinQuery=T})($b||($b={}));const ii=$b;function QO(t,e,n){const i=e.workspace.getLeavesOfType("markdown");for(const o of i)if(o.view?.file?.path===t){e.workspace.revealLeaf(o);try{return o.view.setEphemeralState({line:n}),!0}catch(a){return console.error(a),!1}}return!1}const R0=async t=>{const e=Ve.getState().app,n=e.workspace.getLeavesOfType("markdown");for(const r of n)if(r.view?.file?.path===t){e.workspace.revealLeaf(r);return}const i=e.metadataCache.getFirstLinkpathDest("",t);if(!i){new k.Notice(v("File not found for the given thino path"));return}await e.workspace.getLeaf(!0).openFile(i)},F0=async(t,e)=>{const{app:n}=Ve.getState(),i=parseInt(t.slice(14));if(QO(e,n,i))return;const o=n.metadataCache.getFirstLinkpathDest("",e);if(!k.Platform.isMobile)await n.workspace.getLeaf(!0).openFile(o,{eState:{line:i}});else{let r=n.workspace.activeLeaf;r===null&&(r=n.workspace.getLeaf(!0)),await r.openFile(o,{eState:{line:i}})}},j0=async(t,e)=>{const n=Ve.getState().app,i=n.metadataCache.getFirstLinkpathDest("",e);if(!i){new k.Notice(v("File not found for the given thino path"));return}let o="";try{o=await n.vault.read(i)}catch(d){console.error(d),o=await n.vault.cachedRead(i)}const a=o.split(/\r?\n/).findIndex(d=>d.contains(t)),l=n.workspace.getLeavesOfType("markdown");for(const d of l)if(d.view?.file?.path===i.path){n.workspace.revealLeaf(d);try{d.view.editor?.setCursor({line:a,ch:1});return}catch(m){console.error(m)}}const c=n.workspace.getLeaf(!0);await c.openFile(i,{eState:{line:a}});try{c.view.editor?.setCursor({line:a,ch:1})}catch(d){console.error(d)}},H0=async(t,e)=>{const n=Ve.getState().app,i=(l,c)=>{const d=Array.from(l.nodes.values())?.find(h=>h.id===c);return d?(l.selectOnly(d),l.zoomToSelection(),!0):!1},
|
|||
|
|
`+Y+s}var ce=!1;function ue(s,u){if(!s||ce)return"";ce=!0;var f=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(u)if(u=function(){throw Error()},Object.defineProperty(u.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(u,[])}catch(ke){var b=ke}Reflect.construct(s,[],u)}else{try{u.call()}catch(ke){b=ke}s.call(u.prototype)}else{try{throw Error()}catch(ke){b=ke}s()}}catch(ke){if(ke&&b&&typeof ke.stack=="string"){for(var D=ke.stack.split(`
|
|||
|
|
`),P=b.stack.split(`
|
|||
|
|
`),U=D.length-1,oe=P.length-1;1<=U&&0<=oe&&D[U]!==P[oe];)oe--;for(;1<=U&&0<=oe;U--,oe--)if(D[U]!==P[oe]){if(U!==1||oe!==1)do if(U--,oe--,0>oe||D[U]!==P[oe]){var le=`
|
|||
|
|
`+D[U].replace(" at new "," at ");return s.displayName&&le.includes("<anonymous>")&&(le=le.replace("<anonymous>",s.displayName)),le}while(1<=U&&0<=oe);break}}}finally{ce=!1,Error.prepareStackTrace=f}return(s=s?s.displayName||s.name:"")?K(s):""}function te(s){switch(s.tag){case 5:return K(s.type);case 16:return K("Lazy");case 13:return K("Suspense");case 19:return K("SuspenseList");case 0:case 2:case 15:return s=ue(s.type,!1),s;case 11:return s=ue(s.type.render,!1),s;case 1:return s=ue(s.type,!0),s;default:return""}}function ae(s){if(s==null)return null;if(typeof s=="function")return s.displayName||s.name||null;if(typeof s=="string")return s;switch(s){case O:return"Fragment";case M:return"Portal";case j:return"Profiler";case F:return"StrictMode";case G:return"Suspense";case Z:return"SuspenseList"}if(typeof s=="object")switch(s.$$typeof){case _:return(s.displayName||"Context")+".Consumer";case z:return(s._context.displayName||"Context")+".Provider";case V:var u=s.render;return s=s.displayName,s||(s=u.displayName||u.name||"",s=s!==""?"ForwardRef("+s+")":"ForwardRef"),s;case ee:return u=s.displayName||null,u!==null?u:ae(s.type)||"Memo";case $:u=s._payload,s=s._init;try{return ae(s(u))}catch{}}return null}function Ee(s){var u=s.type;switch(s.tag){case 24:return"Cache";case 9:return(u.displayName||"Context")+".Consumer";case 10:return(u._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return s=u.render,s=s.displayName||s.name||"",u.displayName||(s!==""?"ForwardRef("+s+")":"ForwardRef");case 7:return"Fragment";case 5:return u;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return ae(u);case 8:return u===F?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof u=="function")return u.displayName||u.name||null;if(typeof u=="string")return u}return null}function xe(s){switch(typeof s){case"boolean":case"number":case"string":case"undefined":return s;case"object":return s;default:return""}}function Fe(s){var u=s.type;return(s=s.nodeName)&&s.toLowerCase()==="input"&&(u==="checkbox"||u==="radio")}function Ge(s){var u=Fe(s)?"checked":"value",f=Object.getOwnPropertyDescriptor(s.constructor.prototype,u),b=""+s[u];if(!s.hasOwnProperty(u)&&typeof f<"u"&&typeof f.get=="function"&&typeof f.set=="function"){var D=f.get,P=f.set;return Object.defineProperty(s,u,{configurable:!0,get:function(){return D.call(this)},set:function(U){b=""+U,P.call(this,U)}}),Object.defineProperty(s,u,{enumerable:f.enumerable}),{getValue:function(){return b},setValue:function(U){b=""+U},stopTracking:function(){s._valueTracker=null,delete s[u]}}}}function at(s){s._valueTracker||(s._valueTracker=Ge(s))}function Dt(s){if(!s)return!1;var u=s._valueTracker;if(!u)return!0;var f=u.getValue(),b="";return s&&(b=Fe(s)?s.checked?"true":"false":s.value),s=b,s!==f?(u.setValue(s),!0):!1}function Me(s){if(s=s||(typeof document<"u"?document:void 0),typeof s>"u")return null;try{return s.activeElement||s.body}catch{return s.body}}function ye(s,u){var f=u.checked;return pe({},u,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:f??s._wrapperState.initialChecked})}function Ae(s,u){var f=u.defaultValue==null?"":u.defaultValue,b=u.checked!=null?u.checked:u.defaultChecked;f=xe(u.value!=null?u.value:f),s._wrapperState={initialChecked:b,initialValue:f,controlled:u.type==="checkbox"||u.type==="radio"?u.checked!=null:u.value!=null}}function de(s,u){u=u.checked,u!=null&&L(s,"checked",u,!1)}function se(s,u){de(s,u);var f=xe(u.value),b=u.type;if(f!=null)b==="number"?(f===0&&s.value===""||s.value!=f)&&(s.value=""+f):s.value!==""+f&&(s.value=""+f);else if(b==="submit"||b==="reset"){s.removeAttribute("value");return}u.hasOwnProperty("value")?Oe(s,u.type,f):u.hasOwnProperty("defaultValue")&&Oe(s,u.type,xe(u.defaultValue)),u.checked==null&&u.defaultChecked!=null&&(s.defaultChecked=!!u.defaultChecked)}function Pe(s,u,f){if(u.hasOwnProperty("value")||u.hasO
|
|||
|
|
`).replace(M4,"")}function xd(s,u,f){if(u=IT(u),IT(s)!==u&&f)throw Error(n(425))}function Cd(){}var em=null,tm=null;function nm(s,u){return s==="textarea"||s==="noscript"||typeof u.children=="string"||typeof u.children=="number"||typeof u.dangerouslySetInnerHTML=="object"&&u.dangerouslySetInnerHTML!==null&&u.dangerouslySetInnerHTML.__html!=null}var im=typeof setTimeout=="function"?setTimeout:void 0,A4=typeof clearTimeout=="function"?clearTimeout:void 0,kT=typeof Promise=="function"?Promise:void 0,N4=typeof queueMicrotask=="function"?queueMicrotask:typeof kT<"u"?function(s){return kT.resolve(null).then(s).catch(P4)}:im;function P4(s){setTimeout(function(){throw s})}function om(s,u){var f=u,b=0;do{var D=f.nextSibling;if(s.removeChild(f),D&&D.nodeType===8)if(f=D.data,f==="/$"){if(b===0){s.removeChild(D),_o(u);return}b--}else f!=="$"&&f!=="$?"&&f!=="$!"||b++;f=D}while(f);_o(u)}function la(s){for(;s!=null;s=s.nextSibling){var u=s.nodeType;if(u===1||u===3)break;if(u===8){if(u=s.data,u==="$"||u==="$!"||u==="$?")break;if(u==="/$")return null}}return s}function ET(s){s=s.previousSibling;for(var u=0;s;){if(s.nodeType===8){var f=s.data;if(f==="$"||f==="$!"||f==="$?"){if(u===0)return s;u--}else f==="/$"&&u++}s=s.previousSibling}return null}var sl=Math.random().toString(36).slice(2),Wo="__reactFiber$"+sl,Ac="__reactProps$"+sl,Mr="__reactContainer$"+sl,rm="__reactEvents$"+sl,L4="__reactListeners$"+sl,O4="__reactHandles$"+sl;function Xa(s){var u=s[Wo];if(u)return u;for(var f=s.parentNode;f;){if(u=f[Mr]||f[Wo]){if(f=u.alternate,u.child!==null||f!==null&&f.child!==null)for(s=ET(s);s!==null;){if(f=s[Wo])return f;s=ET(s)}return u}s=f,f=s.parentNode}return null}function Nc(s){return s=s[Wo]||s[Mr],!s||s.tag!==5&&s.tag!==6&&s.tag!==13&&s.tag!==3?null:s}function ll(s){if(s.tag===5||s.tag===6)return s.stateNode;throw Error(n(33))}function Dd(s){return s[Ac]||null}var am=[],cl=-1;function ca(s){return{current:s}}function tn(s){0>cl||(s.current=am[cl],am[cl]=null,cl--)}function Qt(s,u){cl++,am[cl]=s.current,s.current=u}var ua={},Yn=ca(ua),fi=ca(!1),es=ua;function ul(s,u){var f=s.type.contextTypes;if(!f)return ua;var b=s.stateNode;if(b&&b.__reactInternalMemoizedUnmaskedChildContext===u)return b.__reactInternalMemoizedMaskedChildContext;var D={},P;for(P in f)D[P]=u[P];return b&&(s=s.stateNode,s.__reactInternalMemoizedUnmaskedChildContext=u,s.__reactInternalMemoizedMaskedChildContext=D),D}function pi(s){return s=s.childContextTypes,s!=null}function Md(){tn(fi),tn(Yn)}function xT(s,u,f){if(Yn.current!==ua)throw Error(n(168));Qt(Yn,u),Qt(fi,f)}function CT(s,u,f){var b=s.stateNode;if(u=u.childContextTypes,typeof b.getChildContext!="function")return f;b=b.getChildContext();for(var D in b)if(!(D in u))throw Error(n(108,Ee(s)||"Unknown",D));return pe({},f,b)}function Ad(s){return s=(s=s.stateNode)&&s.__reactInternalMemoizedMergedChildContext||ua,es=Yn.current,Qt(Yn,s),Qt(fi,fi.current),!0}function DT(s,u,f){var b=s.stateNode;if(!b)throw Error(n(169));f?(s=CT(s,u,es),b.__reactInternalMemoizedMergedChildContext=s,tn(fi),tn(Yn),Qt(Yn,s)):tn(fi),Qt(fi,f)}var Ar=null,Nd=!1,sm=!1;function MT(s){Ar===null?Ar=[s]:Ar.push(s)}function R4(s){Nd=!0,MT(s)}function da(){if(!sm&&Ar!==null){sm=!0;var s=0,u=qe;try{var f=Ar;for(qe=1;s<f.length;s++){var b=f[s];do b=b(!0);while(b!==null)}Ar=null,Nd=!1}catch(D){throw Ar!==null&&(Ar=Ar.slice(s+1)),Tr(ta,da),D}finally{qe=u,sm=!1}}return null}var dl=[],hl=0,Pd=null,Ld=0,Wi=[],qi=0,ts=null,Nr=1,Pr="";function ns(s,u){dl[hl++]=Ld,dl[hl++]=Pd,Pd=s,Ld=u}function AT(s,u,f){Wi[qi++]=Nr,Wi[qi++]=Pr,Wi[qi++]=ts,ts=s;var b=Nr;s=Pr;var D=32-Sn(b)-1;b&=~(1<<D),f+=1;var P=32-Sn(u)+D;if(30<P){var U=D-D%5;P=(b&(1<<U)-1).toString(32),b>>=U,D-=U,Nr=1<<32-Sn(u)+D|f<<D|b,Pr=P+s}else Nr=1<<P|f<<D|b,Pr=s}function lm(s){s.return!==null&&(ns(s,1),AT(s,1,0))}function cm(s){for(;s===Pd;)Pd=dl[--hl],dl[hl]=null,Ld=dl[--hl],dl[hl]=null;for(;s===ts;)ts=Wi[--qi],Wi[qi]=null,Pr=Wi[--qi],Wi[qi]=null,Nr=Wi[--qi],Wi[qi]=null}var Pi=null,Li=null,rn=!1,yo=null;function NT(s,u){var f=Ki(5,null,null,0);f.elementType="DELETED",f.stateNode=u,f.return=s,u=s.deletio
|
|||
|
|
Error generating stack: `+P.message+`
|
|||
|
|
`+P.stack}return{value:s,source:u,stack:D,digest:null}}function Lm(s,u,f){return{value:s,source:null,stack:f??null,digest:u??null}}function Om(s,u){try{console.error(u.value)}catch(f){setTimeout(function(){throw f})}}var V4=typeof WeakMap=="function"?WeakMap:Map;function f1(s,u,f){f=Or(-1,f),f.tag=3,f.payload={element:null};var b=u.value;return f.callback=function(){Xd||(Xd=!0,Zm=b),Om(s,u)},f}function p1(s,u,f){f=Or(-1,f),f.tag=3;var b=s.type.getDerivedStateFromError;if(typeof b=="function"){var D=u.value;f.payload=function(){return b(D)},f.callback=function(){Om(s,u)}}var P=s.stateNode;return P!==null&&typeof P.componentDidCatch=="function"&&(f.callback=function(){Om(s,u),typeof b!="function"&&(ma===null?ma=new Set([this]):ma.add(this));var U=u.stack;this.componentDidCatch(u.value,{componentStack:U!==null?U:""})}),f}function m1(s,u,f){var b=s.pingCache;if(b===null){b=s.pingCache=new V4;var D=new Set;b.set(u,D)}else D=b.get(u),D===void 0&&(D=new Set,b.set(u,D));D.has(f)||(D.add(f),s=oP.bind(null,s,u,f),u.then(s,s))}function g1(s){do{var u;if((u=s.tag===13)&&(u=s.memoizedState,u=u!==null?u.dehydrated!==null:!0),u)return s;s=s.return}while(s!==null);return null}function y1(s,u,f,b,D){return(s.mode&1)===0?(s===u?s.flags|=65536:(s.flags|=128,f.flags|=131072,f.flags&=-52805,f.tag===1&&(f.alternate===null?f.tag=17:(u=Or(-1,1),u.tag=2,fa(f,u,1))),f.lanes|=1),s):(s.flags|=65536,s.lanes=D,s)}var W4=C.ReactCurrentOwner,mi=!1;function ti(s,u,f,b){u.child=s===null?jT(u,null,f,b):pl(u,s.child,f,b)}function v1(s,u,f,b,D){f=f.render;var P=u.ref;return gl(u,D),b=Em(s,u,f,b,P,D),f=xm(),s!==null&&!mi?(u.updateQueue=s.updateQueue,u.flags&=-2053,s.lanes&=~D,Rr(s,u,D)):(rn&&f&&lm(u),u.flags|=1,ti(s,u,b,D),u.child)}function w1(s,u,f,b,D){if(s===null){var P=f.type;return typeof P=="function"&&!ng(P)&&P.defaultProps===void 0&&f.compare===null&&f.defaultProps===void 0?(u.tag=15,u.type=P,b1(s,u,P,b,D)):(s=rh(f.type,null,b,u,u.mode,D),s.ref=u.ref,s.return=u,u.child=s)}if(P=s.child,(s.lanes&D)===0){var U=P.memoizedProps;if(f=f.compare,f=f!==null?f:Ec,f(U,b)&&s.ref===u.ref)return Rr(s,u,D)}return u.flags|=1,s=wa(P,b),s.ref=u.ref,s.return=u,u.child=s}function b1(s,u,f,b,D){if(s!==null){var P=s.memoizedProps;if(Ec(P,b)&&s.ref===u.ref)if(mi=!1,u.pendingProps=b=P,(s.lanes&D)!==0)(s.flags&131072)!==0&&(mi=!0);else return u.lanes=s.lanes,Rr(s,u,D)}return Rm(s,u,f,b,D)}function S1(s,u,f){var b=u.pendingProps,D=b.children,P=s!==null?s.memoizedState:null;if(b.mode==="hidden")if((u.mode&1)===0)u.memoizedState={baseLanes:0,cachePool:null,transitions:null},Qt(bl,Oi),Oi|=f;else{if((f&1073741824)===0)return s=P!==null?P.baseLanes|f:f,u.lanes=u.childLanes=1073741824,u.memoizedState={baseLanes:s,cachePool:null,transitions:null},u.updateQueue=null,Qt(bl,Oi),Oi|=s,null;u.memoizedState={baseLanes:0,cachePool:null,transitions:null},b=P!==null?P.baseLanes:f,Qt(bl,Oi),Oi|=b}else P!==null?(b=P.baseLanes|f,u.memoizedState=null):b=f,Qt(bl,Oi),Oi|=b;return ti(s,u,D,f),u.child}function T1(s,u){var f=u.ref;(s===null&&f!==null||s!==null&&s.ref!==f)&&(u.flags|=512,u.flags|=2097152)}function Rm(s,u,f,b,D){var P=pi(f)?es:Yn.current;return P=ul(u,P),gl(u,D),f=Em(s,u,f,b,P,D),b=xm(),s!==null&&!mi?(u.updateQueue=s.updateQueue,u.flags&=-2053,s.lanes&=~D,Rr(s,u,D)):(rn&&b&&lm(u),u.flags|=1,ti(s,u,f,D),u.child)}function I1(s,u,f,b,D){if(pi(f)){var P=!0;Ad(u)}else P=!1;if(gl(u,D),u.stateNode===null)$d(s,u),d1(u,f,b),Pm(u,f,b,D),b=!0;else if(s===null){var U=u.stateNode,oe=u.memoizedProps;U.props=oe;var le=U.context,ke=f.contextType;typeof ke=="object"&&ke!==null?ke=Gi(ke):(ke=pi(f)?es:Yn.current,ke=ul(u,ke));var je=f.getDerivedStateFromProps,He=typeof je=="function"||typeof U.getSnapshotBeforeUpdate=="function";He||typeof U.UNSAFE_componentWillReceiveProps!="function"&&typeof U.componentWillReceiveProps!="function"||(oe!==b||le!==ke)&&h1(u,U,b,ke),ha=!1;var Re=u.memoizedState;U.state=Re,Bd(u,b,U,D),le=u.memoizedState,oe!==b||Re!==le||fi.current||ha?(typeof je=="function"&&(Nm(u,f,je,b),le=u.memoizedState),(oe=ha||u1(u,f,oe,b,Re,le,ke))?(He||typeof U.UNSAFE_componentWillMount!="function"
|
|||
|
|
`)[0].replace(/\=|\s+|\"/gi,"").toLowerCase();case"win32":return t.toString().split("REG_SZ")[1].replace(/\r+|\n+|\s+/gi,"").toLowerCase();case"linux":return t.toString().replace(/\r+|\n+|\s+/gi,"").toLowerCase();case"freebsd":return t.toString().replace(/\r+|\n+|\s+/gi,"").toLowerCase();default:throw new Error(`Unsupported platform: ${process.platform}`)}}function Jt(t=!1){return new Promise((e,n)=>{T5(E5[process.platform],{},(i,o)=>{if(i)return n(new Error(`Error while obtaining machine id: ${i.stack}`));const r=D5(o.toString());return e(t?r:C5(r))})})}const qI={list:"align-left",waterfall:"layout-grid",calendar:"calendar",minimal:"list",table:"table",chat:"message-square",moments:"chrome",flow:"workflow"},M5=({className:t})=>{const{app:e,view:n,verifyState:i,settings:o}=Ke(),{manifest:r,isMobileView:a}=Tt(),l=x.useRef(null),c=x.useRef(null),[d,h]=x.useState(()=>(window.app||e)?.loadLocalStorage("thinoListView")||"list"),[m,g]=x.useState(null),y=x.useCallback(()=>{if(!n?.leaf||n.leaf.height===0||!m?.settings)return;const I=m.settings.MemoListView;if(m.settings.SupportSelectOtherView||I==="chat"||I==="moments"||I==="flow")return;const E=n.leaf.width>950?I:"list";h(E),We.setMemoListView(E)},[n,m]);x.useEffect(()=>{if(!r||!e)return;const I=e.plugins.getPlugin(r.id);if(I){g(I);const E=I.settings?.MemoListView||"list";h(E),We.setMemoListView(E)}},[r,e]),x.useEffect(()=>{if(!(!e||!n||!m?.settings))return y(),c.current||(c.current=e.workspace.on("resize",y),n.registerEvent(c.current)),()=>{c.current&&(e.workspace.offref(c.current),c.current=null)}},[e,n,m,y]),x.useEffect(()=>{if(!l.current||!d)return;const I=qI[d]||"list";k.setIcon(l.current,I),We.setMemoListView(d),k.requireApiVersion("1.4.4")&&k.setTooltip(l.current,v("Switch view"))},[d]);const T=x.useMemo(()=>{const I=[{view:"list",title:v("List")},{view:"chat",title:v("Chat")},{view:"moments",title:v("Moments")}];return(!a||o?.SupportSelectOtherView)&&I.push({view:"waterfall",title:v("Waterfall")},{view:"calendar",title:v("Calendar")},{view:"table",title:v("Table")}),I},[a,o?.SupportSelectOtherView]),w=x.useCallback(async I=>{try{const E=!k.Platform.isDesktop&&await window.Capacitor?.Plugins.Device.getId(),L=k.Platform.isDesktop?await Jt():E?.identifier||E?.uuid;if(!i||i.appId!==L){wt();return}const C=async M=>{d!==M&&(We.setMemoListView(M),m&&(m.settings={...m.settings,MemoListView:M},await m.saveSettings()),h(M))},R=new k.Menu;T.forEach(({view:M,title:O})=>{R.addItem(F=>{F.setChecked(d===M).setIcon(qI[M]).setTitle(O).onClick(()=>C(M))})}),R.showAtMouseEvent(I.nativeEvent)}catch(E){console.error("Error handling view switcher click:",E)}},[i,d,m,T]),S=x.useMemo(()=>`memos-view-switcher-wrapper ${t||""} pro`.trim(),[t]);return p.jsx("div",{className:S,ref:l,onClick:w})},A5=()=>{const t=x.useRef(null);return x.useEffect(()=>{t&&(k.setIcon(t.current,"calendar-check"),k.setTooltip&&k.setTooltip(t.current,v("Daily Memos")))},[t]),p.jsx("div",{className:"memos-review-entry-wrapper",ref:t,onClick:()=>{Le.setPathname("/daily")}})},Ig=()=>({type:"initialText",value:"",timestamp:Date.now(),selectionStart:0,selectionEnd:0}),GI={initialValue:"",interval:300};class N5{constructor(e,n=GI){this.listeners=[],this.runUndo=()=>{const i=this.actions[this.currentIndex].selectionStart;this.currentIndex>0&&this.currentIndex--,this.element.value=this.actions[this.currentIndex].value,this.element.setSelectionRange(i,i),this.dispatchChange()},this.runRedo=()=>{this.currentIndex<this.actions.length-1&&this.currentIndex++;const i=this.actions[this.currentIndex].selectionEnd;this.element.value=this.actions[this.currentIndex].value,this.element.setSelectionRange(i,i),this.dispatchChange()},this.getActions=()=>this.actions,this.setState=(i,o)=>{this.actions=[...i],this.currentIndex=o<this.actions.length?o:this.actions.length-1,this.dispatchChange()},this.resetState=()=>{this.actions=[Ig()],this.currentIndex=0,this.dispatchChange()},this.destroy=()=>{this.rmEventListeners()},this.subscribe=i=>{this.listeners.push(i)},this.handleElementKeydown=i=>{const o=i;o.key==="z"&&!o.shiftKey&&(o.metaKey||o.ctrl
|
|||
|
|
|
|||
|
|
Check the documentation or create issue if you think it's bug. https://github.com/webscopeio/react-textarea-autocomplete/issues`))},K5=[".","^","$","*","+","-","?","(",")","[","]","{","}","\\","|"],wh=function(e){return W5(e).map(function(n){return K5.includes(n)?"\\".concat(n):n}).join("")},J5=(function(t){ip(e,t);function e(){return Ku(this,e),np(this,zl(e).apply(this,arguments))}return tp(e,[{key:"componentDidMount",value:function(){var i=this.props.boundariesElement;if(typeof i=="string"){var o=document.querySelector(i);if(!o)throw new Error("RTA: Invalid prop boundariesElement: it has to be string or HTMLElement.");this.containerElem=o}else if(i instanceof HTMLElement)this.containerElem=i;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 i,o,r=this.props.top||0,a=this.props.left||0,l=[],c=[],d=0,h=0,m=this.containerElem.getBoundingClientRect(),g=this.ref.getBoundingClientRect(),y=this.props.textareaRef.getBoundingClientRect(),T=window.getComputedStyle(this.ref),w=parseInt(T.getPropertyValue("margin-top"),10),S=parseInt(T.getPropertyValue("margin-bottom"),10),I=parseInt(T.getPropertyValue("margin-left"),10),E=parseInt(T.getPropertyValue("margin-right"),10),L=w+S+y.top+r+g.height,C=I+E+y.left+a+g.width;C>m.right&&y.left+a>g.width?(h=a-g.width,l.push(Sa.X.LEFT),c.push(Sa.X.RIGHT)):(h=a,l.push(Sa.X.RIGHT),c.push(Sa.X.LEFT)),L>m.bottom&&y.top+r>g.height?(d=r-g.height,l.push(Sa.Y.TOP),c.push(Sa.Y.BOTTOM)):(d=r,l.push(Sa.Y.BOTTOM),c.push(Sa.Y.TOP)),this.props.renderToBody&&(d+=y.top,h+=y.left),this.ref.style.top="".concat(d,"px"),this.ref.style.left="".concat(h,"px"),(i=this.ref.classList).remove.apply(i,c),(o=this.ref.classList).add.apply(o,l)}},{key:"render",value:function(){var i=this,o=this.props,r=o.style,a=o.className,l=o.innerRef,c=o.children,d=o.renderToBody,h=document.body,m=J.createElement("div",{ref:function(y){i.ref=y,l(y)},className:"rta__autocomplete ".concat(a||""),style:r},c);return d&&h!==null?G0.createPortal(m,h):m}}]),e})(J.Component),FA=(function(t){ip(e,t);function e(n){var i;Ku(this,e),i=np(this,zl(e).call(this,n)),i.state={top:null,left:null,currentTrigger:null,actualToken:"",data:null,value:"",dataLoading:!1,selectionEnd:0,component:null,textToReplace:null},i.escListenerInit=function(){i.escListener||(i.escListener=ws.add(Fi.ESC,i._closeAutocomplete))},i.escListenerDestroy=function(){i.escListener&&(ws.remove(i.escListener),i.escListener=null)},i.getSelectionPosition=function(){return i.textareaRef?{selectionStart:i.textareaRef.selectionStart,selectionEnd:i.textareaRef.selectionEnd}:null},i.getSelectedText=function(){if(!i.textareaRef)return null;var c=i.textareaRef,d=c.selectionStart,h=c.selectionEnd;return d===h?null:i.state.value.substr(d,h-d)},i.setCaretPosition=function(){var c=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;i.textareaRef&&(i.textareaRef.focus(),i.textareaRef.setSelectionRange(c,c))},i.getCaretPosition=function(){if(!i.textareaRef)return 0;var c=i.textareaRef.selectionEnd;return c},i._handleCaretChange=function(c){var d=function(){var g=i.getCaretPosition()-1;i.lastTrigger=i.lastTrigger?g:0};if(c.type==="keydown"){var h=c.keyCode||c.which;switch(h){case Fi.UP:case Fi.DOWN:i._isAutocompleteOpen()||d();break;case Fi.LEFT:case Fi.RIGHT:d();break}return}d()},i._onSelect=function(c){var d=i.state,h=d.selectionEnd,m=d.currentTrigger,g=d.value,y=i.props.onItemSelected;if(m){var T=i._getTextToReplace(m);if(!T){i._closeAutocomplete();return}var w=T(c);if(!w){i._closeAutocomplete();return}y&&y({currentTrigger:m,item:c});var S=function(z,_,V){switch(z){case"start":return V;case"next":case"end":return V+_.length;default:if(!Number.isInteger(z))throw new Error('RTA: caretPosition should be "start", "next", "end" or number.');return z}},I=g.slice(0,h),E=wh(m),L=I.length-I.lastIndexOf(m),C=I.search(new RegExp("(?!".concat(E,")$"
|
|||
|
|
Got "`.concat(String(g),'". Check the implementation for trigger "').concat(c,`"
|
|||
|
|
|
|||
|
|
See https://github.com/webscopeio/react-textarea-autocomplete#trigger-type for more information.
|
|||
|
|
`));if(g===null)return null;if(typeof g=="string")return{text:g,caretPosition:JI};if(!g.text&&typeof g.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(!g.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 g}if(typeof m!="string")throw new Error(`Output item should be string
|
|||
|
|
`);return{text:"".concat(c).concat(m).concat(c),caretPosition:JI}}},i._getCurrentTriggerSettings=function(){var c=i.state.currentTrigger;return c?i.props.trigger[c]:null},i._getValuesFromProvider=function(){var c=i.state,d=c.currentTrigger,h=c.actualToken,m=i._getCurrentTriggerSettings();if(!(!d||!m)){var g=m.dataProvider,y=m.component;if(typeof g!="function")throw new Error("Trigger provider has to be a function!");i.setState({dataLoading:!0});var T=g(h);T instanceof Promise||(T=Promise.resolve(T)),T.then(function(w){if(!Array.isArray(w))throw new Error("Trigger provider has to provide an array!");if(typeof y!="function")throw new Error("Component should be defined!");if(d===i.state.currentTrigger){if(!w.length){i._closeAutocomplete();return}i.setState({dataLoading:!1,data:w,component:y})}}).catch(function(w){return QI(w.message)})}},i._getSuggestions=function(){var c=i.state,d=c.currentTrigger,h=c.data;return!d||!h||h&&!h.length?null:h},i._createRegExp=function(){var c=i.props.trigger;i.tokenRegExp=new RegExp("(".concat(Object.keys(c).sort(function(d,h){return d<h?1:d>h?-1:0}).map(function(d){return wh(d)}).join("|"),")((?:(?!\\1)[^\\s])*$)")),i.tokenRegExpEnding=new RegExp("(".concat(Object.keys(c).sort(function(d,h){return d<h?1:d>h?-1:0}).map(function(d){return wh(d)}).join("|"),")$"))},i._closeAutocomplete=function(){var c=i.state.currentTrigger;i.escListenerDestroy(),i.setState({data:null,dataLoading:!1,currentTrigger:null},function(){c&&i._onItemHighlightedHandler(null)})},i._cleanUpProps=function(){var c=z5({},i.props),d=["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)d.includes(h)&&delete c[h];return c},i._changeHandler=function(c){var d=i.props,h=d.trigger,m=d.onChange,g=d.minChar,y=d.onCaretPositionChange,T=d.movePopupAsYouType,w=i.state,S=w.top,I=w.left,E=c;E||(E=new H5("change",{bubbles:!0}),i.textareaRef.dispatchEvent(E));var L=E.target||i.textareaRef,C=L.selectionEnd,R=L.value;if(i.lastValueBubbledEvent=R,m&&E&&(E.persist&&E.persist(),m(new Proxy(E,{get:function(pe,Y,K){return Y==="target"?L:Reflect.get(pe,Y,K)}}))),y){var M=i.getCaretPosition();y(M)}i.setState({value:R});var O=function(){var pe=R5(L,C),Y=pe.top,K=pe.left;i.setState({top:Y-i.textareaRef.scrollTop||0,left:K})},F=function(pe){i.lastTrigger=C-pe,i._closeAutocomplete(),O()};if(C<=i.lastTrigger){var j=R.slice(0,C),z=i.tokenRegExp.exec(j);F(z?z[0].length:0)}var _=R.slice(i.lastTrigger,C),V=i.tokenRegExp.exec(_),G=V&&V[0],Z=V&&V[1]||null,ee=Z?Z.length-1:0,$=i.tokenRegExpEnding.exec(_);if($?F($[0].length):i._isAutocompleteOpen()||i._closeAutocomplete(),(!G||G.length<=g+ee)&&(i.state.currentTrigger&&!h[i.state.currentTrigger].allowWhitespace||!i.state.currentTrigger)){i._closeAutocomplete();return}if(Z&&h[Z].afterWhitespace&&!/\s/.test(R[C-G.length-1])&&R[C-G.length-1]!==void 0){i._closeAutocomplete();return}if(i.state.currentTrigger&&h[i.state.currentTrigger].allowWhitespace){if(V=new RegExp("".concat(wh(i.state.currentTrigger),".*$")).exec(R.slice(0,C)),G=V&&V[0],!G){i._closeAutocomplete();return}Z=Object.keys(h).find(function(ie){return ie.slice(0,ee+1)===G.slice(0,ee+1)})||null}var re=G.slice(1);if(Z){(T||S===null&&I===null||i.state.currentTrigger!==Z)&&O(),i.escListenerInit();var ne=i._getTextToReplace(Z);i.setState({selectionEnd:C,currentTrigger:Z,textToReplace:ne,actualToken:re},function(){try{i._getValuesFromProvider()}catch(ie){QI(ie.message)}})}},i._selectHandler=function(c){var d=i.props,h=d.onCaretPositionChange,m=d.onSelect;if(h){var g=i.getCaretPosition();h(g)}m&&(c.persist(),m(c))},i._shouldStayOpen=function(c){var d=c.relatedTarget;return d===null&&(d=document.activeElement),!!(i.dropdownRef&&d instanceof Node&&i.dropdownRef.contains(d))},
|
|||
|
|
`,Ae.id);else{const de=ye.toPNG(),se=new Blob([de],{type:"image/png"}),Pe=new File([se],"image.png",{type:"image/png",lastModified:Date.now()});if(!Pe)return;const Oe=await ie(Pe);Oe&&w.current?.insertText(Oe+`
|
|||
|
|
`,Ae.id)}})))},[w,l,r]),x.useEffect(()=>{a&&h(a.DefaultPrefix==="List")},[a?.DefaultPrefix]),x.useEffect(()=>{if(a){if(a.EnabledLocationList.length===1){V(a.EnabledLocationList[0].value);return}V(a.MemoSaveLocation||"DAILY")}},[a?.MemoSaveLocation,a?.EnabledLocationList]),x.useEffect(()=>{if(!a||!z.current)return;const ye=Hl.find(de=>de.title===_)?.icon;k.setIcon(z.current,ye),k.requireApiVersion("1.4.4")&&k.setTooltip(z.current,v("Thino Save To: ")+_),G.current=_;const Ae=o.manifest;if(Ae){const de=r?.plugins.getPlugin(Ae.id);if(de){if(de.settings.MemoSaveLocation===_)return;de.settings.MemoSaveLocation=_,de.saveSettings()}}},[_,g]),x.useEffect(()=>{w.current&&a&&a.MemoSaveLocation&&V(a.MemoSaveLocation)},[z,a]),x.useEffect(()=>{if(!w.current||!a||k.Platform.isDesktop||o.globalEditorShown)return;const ye=a.UseButtonToShowEditor&&a.DefaultEditorLocation==="Bottom";if(k.Platform.isDesktop){y(!0);return}if(e&&e==="inline"){y(!0);return}if(y(k.Platform.isMobile&&!ye),!ye||o.memoListView==="chat")return;const Ae=document.body.find(".memolist-scrollview");Ae&&(Ae.onscroll=()=>{if(o.globalEditorShown)return;if(!o.memoListView&&We.getState().memoListView==="chat"){Ae.onscroll=null;return}const de=w.current.getContent();k.Platform.isMobile&&ye&&!de&&y(!1)})},[o.globalEditorShown,e,w]);const Z=()=>{C(!1)};x.useEffect(()=>{if(r&&(o.markMemoId||o.editMemoId?.trim()&&o.editMemoId!==S.current.editMemoId)){const ye=r.workspace.getLeavesOfType("thino_view");ye.length>0&&r.workspace.revealLeaf(ye[0])}if(o.markMemoId){const ye=he.getMemoById(o.markMemoId);if(ye&&ye.sourceType==="DAILY")uA(ye).then(Ae=>{const de=`${v("MARK")}: ${Ae}`;w.current?.insertText(de),w.current?.focus(),We.setMarkMemoId("")});else{const Ae=`${v("MARK")}: [@THINO](${o.markMemoId})`;w.current?.insertText(Ae),w.current?.focus(),We.setMarkMemoId("")}return}if(o.editMemoId?.trim()&&o.editMemoId!==S.current.editMemoId){const ye=he.getMemoById(o.editMemoId);if(ye)switch(h(ye.thinoType==="JOURNAL"),a.EditorType){case"memos":w.current?.setContent(ye.content.replace(/ \^\S{6}$/,"")||""),w.current?.focus();break;case"obsidian":w.current?.clear(!1),w.current?.setContent(ye.content.replace(/ \^\S{6}$/,"")||""),w.current?.focus();break}}S.current=o},[o.markMemoId,o.editMemoId]),x.useEffect(()=>{!w.current||I||a.EditorType==="memos"&&(w.current?.element.addEventListener("paste",ee),w.current?.element.addEventListener("drop",$),w.current?.element.addEventListener("click",re),E(!0))},[w.current]);const ee=async ye=>{if(ye.clipboardData&&ye.clipboardData.files.length>0){ye.preventDefault();const Ae=ye.clipboardData.files;for(const de of Ae){const se=await ie(de);se&&w.current?.insertText(se)}}},$=async ye=>{if(ye.dataTransfer&&ye.dataTransfer.files.length>0){ye.preventDefault();const Ae=ye.dataTransfer.files;for(const de of Ae){const se=await ie(de);se&&w.current?.insertText(se)}}},re=()=>{ce(w.current?.element.value||"")},ne=async(ye,Ae)=>{const de=ye.ctrlKey||ye.metaKey,se=ye.altKey;if(ye.key==="Escape"&&o.globalEditorShown&&(We.setGlobalEditorShown(!1),ye.preventDefault()),de&&ye.key==="Enter"){ye.preventDefault(),ye.stopPropagation(),await Y(w.current?.getContent()),w.current?.clear(!0);return}if(se)for(let Pe=0;Pe<a.EnabledLocationList.length;Pe++)ye.key===(Pe+1).toString()&&V(a.EnabledLocationList[Pe].value);setTimeout(()=>{})},ie=x.useCallback(async ye=>{const{type:Ae}=ye;if(Ae.startsWith("image"))try{return`${await Y0.upload(ye)}`}catch(de){new k.Notice(de)}},[]),pe=x.useCallback(async ye=>{if(a.enableWordCount){const Ae=!k.Platform.isDesktop&&await window.Capacitor?.Plugins.Device.getId(),de=k.Platform.isDesktop?await Jt():Ae.identifier||Ae.uuid;if(!(c&&c?.appId===de))return wt(),!1;if(a.maxWordCount===0)return!0;const Pe=ye.replace(/```[^\S\r\n]*[a-z]*\n.*?\n```/g,""),Oe=Ne.getWordCount(Pe),Be=a.maxWordCount||1e3;return!(Oe>Be&&Be>0)}return!0},[a.enableWordCount,a.maxWordCount]),Y=async ye=>{if(!ye||ye.trim()===""){new k.Notice(v("Content cannot be empty"));return}const Ae=Ve.getState().settings,de=Ae?.addTagAutomatically,se=Ae?.addTagWithNewline,Pe=Ae?.addTagPosition,Be
|
|||
|
|
`:""}${ye}`:`${ye} ${se?`
|
|||
|
|
`:""}${Be.map(It=>`#${It}`).join(" ")}`:ye;await $e(it,ot),Sh("")},K=x.useCallback(()=>{We.setEditMemoId(""),w.current?.setContent(""),Sh("")},[]),ce=x.useCallback(ye=>{if(Sh(ye??""),!w.current)return;const Ae=w.current.getContent(),de=w.current.element.selectionStart,se=Ae.slice(0,de),Pe=Ae.slice(de);(se.endsWith("@")||se.endsWith("📆"))&&Pe.startsWith(" ")||(se.endsWith("@")||se.endsWith("📆"))&&Pe===""?(Ge(),C(!0)):C(!1),setTimeout(()=>{w.current?.focus()})},[a.EditorType]),ue=ye=>{if(!w.current||!a)return;ye&&(Z(),h(!1));const Ae=w.current.getContent(),de=w.current.element.selectionStart,se=Ae.slice(0,de),Pe=Ae.slice(de),Oe=k.moment(ye);if(se.endsWith("@"))switch(a.InsertDateFormat){case"Dataview":w.current.element.value=Ae.slice(0,w.current.element.selectionStart-1)+"[due:: "+Oe.format("YYYY-MM-DD")+"]"+Pe,w.current.element.setSelectionRange(de+17,de+17),w.current.focus(),ce(w.current.element.value);break;case"Tasks":w.current.element.value=Ae.slice(0,w.current.element.selectionStart-1)+"📅 "+Oe.format("YYYY-MM-DD")+Pe,w.current.element.setSelectionRange(de+11,de+11),w.current.focus(),ce(w.current.element.value)}else{w.current.element.value=se+Oe.format("YYYY-MM-DD")+Pe,w.current.element.setSelectionRange(de+10,de+10),w.current.focus(),ce(w.current.element.value);return}},te=()=>{w.current&&h()},ae=async()=>{const ye=!k.Platform.isDesktop&&await window.Capacitor?.Plugins.Device.getId(),Ae=k.Platform.isDesktop?await Jt():ye.identifier||ye.uuid;return!c||c?.appId!==Ae?(wt(),!1):!0},Ee=async ye=>{if(!await ae())return;const Ae=new k.Menu;a.EnabledLocationList.forEach(Oe=>{Ae.addItem(Be=>{Be.setTitle(v(Oe.value)).setIcon(Hl.find($e=>$e.title===Oe.value)?.icon??"file").setChecked(_===Oe.value).onClick(()=>{V(Oe.value)})})});let de=ye.target,se=null;for(;!de.hasClass("location-wrapper")&&(se=de.parentElement,se);)de=se;const Pe=de.getBoundingClientRect();setTimeout(()=>{Ae.showAtPosition({x:Pe.x,y:Pe.bottom,width:Pe.width,left:!1,overlap:!0})},200)},xe=x.useCallback(async ye=>{const Ae=await jA(r,i?"modal":"view"),de=new k.Menu;if(de.dom.addClass("history-menu"),Ae.length===0){de.addItem(se=>{se.setTitle(v("No history")),se.setIcon("file-clock"),se.setDisabled(!0)}),de.showAtMouseEvent(ye.nativeEvent);return}Ae.forEach(se=>{de.addItem(Pe=>{Pe.titleEl.addClass("history-item"),Pe.titleEl.createEl("span",{text:`${se.content.length} chars`}),Pe.titleEl.createEl("span",{text:k.moment(se.timestamp).format("YYYY-MM-DD HH:mm:ss")}),Pe.onClick(()=>{w.current?.updateContent(se.content)}),Pe.dom.onmouseover=Oe=>{const Be=new k.HoverPopover(l,Pe.dom,1e3);Be.hoverEl.createEl("div",{text:"History content:",cls:"history-popover-title"}),Be.hoverEl.createEl("div",{cls:"history-popover-content"},$e=>{k.MarkdownRenderer.render(r,se.content,$e,"",l)}),Be.hoverEl.addClass("history-popover"),Be.load(),l.addChild(Be),setTimeout(()=>{Be.unload()},1e3)}})}),de.showAtMouseEvent(ye.nativeEvent)},[r]),Fe=x.useCallback(()=>{if(!(!w.current&&a.EditorType==="memos"))switch(a.EditorType){case"obsidian":w.current?.focus(),w.current?.insertTag();break;case"memos":{const ye=w.current.getContent(),Ae=w.current.element.selectionStart,de=ye.slice(0,Ae),se=ye.slice(Ae);let Pe=de+"# "+se,Oe=de.length+1;de.endsWith("#")&&se.startsWith(" ")&&(Pe=de.slice(0,de.length-1)+se.slice(1),Oe=de.length-1),w.current.element.value=Pe,w.current.element.setSelectionRange(Oe,Oe),w.current.focus();const Be=new Event("input",{bubbles:!0,cancelable:!0});w.current.element.dispatchEvent(Be),ce(w.current.element.value)}}},[r]),Ge=x.useCallback(()=>{if(!w.current||!M.current||!a||!r)return;const de=r.workspace.getLeavesOfType(Zn)[0].view.containerEl,se=280,Pe=de.clientWidth,{x:Oe,y:Be}=kj(w.current.element);let $e,it;k.Platform.isMobile?(window.innerWidth-Oe>se?$e=(Oe+se+16>Pe,Oe+18):window.innerWidth-Oe<se?$e=(Oe+se+16>Pe,Oe+34):$e=w.current.element.clientWidth/2,a.DefaultEditorLocation==="Bottom"&&window.innerWidth>875?it=Be+4:a.DefaultEditorLocation==="Bottom"&&window.innerWidth<=875?it=Be+19:a.DefaultEditorLocation==="Top"&&window.innerWidth<=875&&(it=Be+36)):($e=(Oe+se+1
|
|||
|
|
`},"")),g+i+S.replace(/ \^\S{6}/g,"")+`
|
|||
|
|
`+I},"");return t.reduce((m,g)=>{const y=e?.ShowDate?`- [[${k.moment(g.date,"YYYY-MM-DD").format(n)}]]
|
|||
|
|
`:"",T=h(g.have),w=e?.ShowDate&&e?.AddBlankLineWhenDate&&!e?.CommentOnMemos?`
|
|||
|
|
`:"";return m+y+T+w},"").replace(/<br>/g,`
|
|||
|
|
`)},Mj=[{label:v("Today"),value:k.moment().format("YYYY-MM-DD")},{label:v("Yesterday"),value:k.moment().subtract(1,"days").format("YYYY-MM-DD")},{label:v("Last 7 days"),value:k.moment().subtract(7,"days").format("YYYY-MM-DD")},{label:v("Last 30 days"),value:k.moment().subtract(30,"days").format("YYYY-MM-DD")},{label:v("Last 90 days"),value:k.moment().subtract(90,"days").format("YYYY-MM-DD")},{label:v("Last 180 days"),value:k.moment().subtract(180,"days").format("YYYY-MM-DD")},{label:v("Last 365 days"),value:k.moment().subtract(365,"days").format("YYYY-MM-DD")}],rN=t=>{const{handleValueChange:e,setShownStatus:n}=t;return p.jsxs(p.Fragment,{children:[t.type==="icon"&&p.jsx("div",{className:"quick-date-btn-group",children:Mj.map((i,o)=>p.jsx("div",{className:"btn action-btn quick-date-btn",onClick:()=>{e(i.value),n&&n(!1)},children:i.label},o))}),p.jsx(op,{className:"calendar-date-picker",datestamp:t?.defaultValue||k.moment().startOf("day").valueOf(),handleDateStampChange:(i,o)=>{e(t.type==="icon"?k.moment(i).format("YYYY-MM-DD"):i.toString()),n&&n(!1)}})]})},kf=t=>{const{handleValueChange:e}=t,[n,i]=J.useState(!1),o=J.useRef(null),r=J.useRef(null),a=ap(r.current,o.current,{placement:"bottom-start"});return Ju(o,()=>{i(!1)}),p.jsxs(p.Fragment,{children:[p.jsx("span",{ref:c=>{r.current=c,c&&t.type==="icon"&&k.setIcon(c,"calendar")},className:`btn calendar-btn ${t.type==="icon"?"icon-btn":"text-btn"}`,onClick:()=>{!k.Platform.isMobile&&i(!n),!k.Platform.isMobile&&a?.update&&a?.update(),k.Platform.isMobile&&new aN(Ve.getState().app,t.type,e).open()},children:t.type==="text"&&t.defaultValue?t.defaultText?t.defaultText:k.moment(t.defaultValue,"x").subtract(t.startOrEnd==="end"?1:0,"days").format("YYYY/MM/DD"):""}),p.jsx("div",{className:`menu-btns-popup ${n?"":"thino-hidden"}`,ref:o,style:a.styles.popper,children:p.jsx(rN,{type:t.defaultText?"icon":t.type,handleValueChange:e,setShownStatus:i})})]})};class aN extends k.Modal{root;type;handleValueChange;constructor(e,n,i){super(e),this.type=n,this.handleValueChange=i}onOpen(){const{contentEl:e}=this;this.root=$u.createRoot(e),this.root.render(p.jsx(rN,{type:this.type,handleValueChange:this.handleValueChange.bind(this),setShownStatus:n=>{!n&&this.close()}}))}onClose(){this.root?.unmount()}}const Aj=(t,e)=>(t%e+e)%e;class Nj{owner;values;suggestions;selectedItem;containerEl;constructor(e,n,i){this.owner=e,this.containerEl=n,n.on("click",".suggestion-item",this.onSuggestionClick.bind(this)),n.on("mousemove",".suggestion-item",this.onSuggestionMouseover.bind(this)),i.register([],"ArrowUp",o=>{if(!o.isComposing)return this.setSelectedItem(this.selectedItem-1,!0),!1}),i.register([],"ArrowDown",o=>{if(!o.isComposing)return this.setSelectedItem(this.selectedItem+1,!0),!1}),i.register([],"Enter",o=>{if(!o.isComposing)return this.useSelectedItem(o),!1})}onSuggestionClick(e,n){e.preventDefault();const i=this.suggestions.indexOf(n);this.setSelectedItem(i,!1),this.useSelectedItem(e)}onSuggestionMouseover(e,n){const i=this.suggestions.indexOf(n);this.setSelectedItem(i,!1)}setSuggestions(e){this.containerEl.empty();const n=[];e.forEach(i=>{const o=this.containerEl.createDiv("suggestion-item");this.owner.renderSuggestion(i,o),n.push(o)}),this.values=e,this.suggestions=n,this.setSelectedItem(0,!1)}useSelectedItem(e){const n=this.values[this.selectedItem];n&&this.owner.selectSuggestion(n,e)}setSelectedItem(e,n){const i=Aj(e,this.suggestions.length),o=this.suggestions[this.selectedItem],r=this.suggestions[i];o?.removeClass("is-selected"),r?.addClass("is-selected"),this.selectedItem=i,n&&r.scrollIntoView(!1)}}class sN{inputEl;popper;scope;suggestEl;suggest;cb;constructor(e,n){this.inputEl=e,this.scope=new k.Scope,this.cb=n,this.suggestEl=createDiv("suggestion-container");const i=this.suggestEl.createDiv("suggestion");this.suggest=new Nj(this,i,this.scope),this.scope.register([],"Escape",this.close.bind(this)),this.inputEl.addEventListener("input",this.onInputChanged.bind(this)),this.inputEl.addEventListener("focus",this.onInputChanged.bind(this)),this.inputEl.addEventListener("click",this.onInpu
|
|||
|
|
`:""}${F}`:`${F} ${R?`
|
|||
|
|
`:""}${L.map(j=>`#${j}`).join(" ")}`),O&&O.content!==F){const j=await he.updateMemo(O.id,F?.trim());M.push(j)}}M.length>0&&he.editMemoBulk(M),M.length>0&&Le.clearQuery()};return p.jsxs("div",{className:"thino-tag-operation",children:[p.jsx("div",{className:"tag-operation-title",children:v("Tag Bulk Edit")}),p.jsxs("div",{className:"tag-operation-content",children:[i.length>0&&p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"tag-operation-content-title exist-tags",children:[p.jsx("div",{className:"name",children:v("Exist Tags")}),p.jsx("div",{className:"desc",children:v("Click to remove exist tag")})]}),p.jsx("div",{className:"tag-operation-content-tags exist-tags",children:i.map(E=>p.jsx("div",{className:Ct("tag-operation-content-tag",l.includes(E)&&"tag-operation-content-tag-removed"),onClick:()=>{l.includes(E)||c([...l,E]),l.includes(E)&&c(l.filter(L=>L!==E)),r.includes(E)&&a(r.filter(L=>L!==E))},children:E},E))})]}),p.jsxs("div",{className:"tag-operation-content-title selected-tags",children:[p.jsx("div",{className:"name",children:v("Selected Tags")}),p.jsx("div",{className:"desc",children:v("Click to remove selected tag")})]}),p.jsx("div",{className:"tag-operation-content-tags selected-tags",children:r.map(E=>p.jsx("div",{className:"tag-operation-content-tag",onClick:()=>{a(r.filter(L=>L!==E))},children:E},E))}),p.jsx("div",{className:"tag-operation-content-inputer",children:p.jsx("input",{placeholder:v("Input to select exist tag"),ref:T,onKeyDown:E=>{E.key==="Enter"&&w(T.current.value)}})}),p.jsxs("div",{className:"tag-operation-settings",children:[p.jsx("div",{ref:h}),p.jsx("div",{ref:m})]}),p.jsxs("div",{className:"tag-operation-content-btn-group",children:[p.jsx("button",{className:"cancel-btn",onClick:n,children:v("Cancel")}),p.jsx("button",{className:"save-btn",onClick:S,children:v("Save")})]})]})]})},Xb=new Map,io=async(t,e=!0)=>{const{vault:n,metadataCache:i}=Ve.getState().app;if(e&&Xb.has(t))return Promise.resolve(Xb.get(t));if(t.contains("data:image"))return t;let o;const r=await n.adapter.exists(k.normalizePath(t));let a="";try{if(!r&&!/(http|https)/g.test(t)&&!t.includes("data:image")){let l;if(t.startsWith("app://")){const c=k.normalizePath(decodeURIComponent(t).replace(k.Platform.resourcePathPrefix,"").replace(/\?(.*)$/,"").replace(k.normalizePath(app?.vault.adapter.basePath),""));a=k.normalizePath(decodeURIComponent(c))}else{if(l=i.getFirstLinkpathDest(t,""),!l){new k.Notice(v("File not exist"));return}a=l.path}}else a=t}catch(l){console.error(l)}if(a){if(/(http|https)/g.test(a))if(a.startsWith("http://localhost")){let l=a;l=l.replace("http://localhost/_capacitor_file_",""),l=decodeURIComponent(l).replace(/\?(.*)$/,"").replace(app?.vault.adapter.basePath,""),l=k.normalizePath(decodeURIComponent(l));const c=await n.adapter.readBinary(l),d=new Uint8Array(c);o=new Blob([d],{type:"image/png"})}else try{const l=await k.requestUrl(t),c=new Uint8Array(l.arrayBuffer);o=new Blob([c],{type:"image/png"})}catch{}else if(a){const l=await n.adapter.readBinary(a),c=new Uint8Array(l);o=new Blob([c],{type:"image/png"})}return o?await jj(o,t):""}},jj=(t,e)=>new Promise(n=>{const i=new FileReader;i.onloadend=()=>{const o=i.result;Xb.set(e,o),n(o)},i.readAsDataURL(t)}),au=async t=>{if(!t.style.backgroundImage.includes("url(")&&!t.style.backgroundImage.includes("http"))return;let e=t.style.backgroundImage.includes("url(")?t.style.backgroundImage.slice(5,-2):t.style.backgroundImage;return e?(e.startsWith("http://localhost")&&(e=e.replace("http://localhost/_capacitor_file_",""),e=decodeURIComponent(e).replace(/\?(.*)$/,"").replace(app?.vault.adapter.basePath,""),e=k.normalizePath(decodeURIComponent(e))),await io(e)):void 0},Hj=async t=>t.getAttribute("src")?t?.src?.startsWith("http://localhost")?await io(t.getAttribute("path")||k.normalizePath(t?.parentElement.getAttribute("src"))):await io(t.getAttribute("src")):void 0,pt=$j(),Ef=Zj(),lN=Kj(),cN=Jj(),hs={copyDefaultStyles:!0,imagePlaceholder:void 0,cacheBust:!1,useCredentials:!1,httpTimeout:3e4,styleCaching:"strict",corsImg:void 0},At={toSvg:uN,toPng:Uj,toJpeg:_j,toBl
|
|||
|
|
`)})}function e(){return Promise.resolve(pt.asArray(document.styleSheets)).then(i).then(n).then(function(r){return r.map(o)});function n(r){return r.filter(function(a){return a.type===CSSRule.FONT_FACE_RULE}).filter(function(a){return Ef.shouldProcess(a.style.getPropertyValue("src"))})}function i(r){const a=[];return r.forEach(function(l){if(Object.prototype.hasOwnProperty.call(Object.getPrototypeOf(l),"cssRules"))try{pt.asArray(l.cssRules||[]).forEach(a.push.bind(a))}catch(c){console.error(`domtoimage: Error while reading CSS rules from ${l.href}`,c.toString())}}),a}function o(r){return{resolve:function(){const l=(r.parentStyleSheet||{}).href;return Ef.inlineAll(r.cssText,l)},src:function(){return r.style.getPropertyValue("src")}}}}}function Jj(){return{inlineAll:e,impl:{newImage:t}};function t(n){return{inline:i};function i(o){return pt.isDataUrl(n.src)?Promise.resolve():Promise.resolve(n.src).then(o||pt.getAndEncode).then(function(r){return new Promise(function(a){n.onload=a,n.onerror=a,n.src=r})})}}function e(n){if(!pt.isElement(n))return Promise.resolve(n);return i(n).then(function(){return pt.isHTMLImageElement(n)?t(n).inline():Promise.all(pt.asArray(n.childNodes).map(function(o){return e(o)}))});function i(o){const a=["background","background-image"].map(function(l){const c=o.style.getPropertyValue(l),d=o.style.getPropertyPriority(l);return c?Ef.inlineAll(c).then(function(h){o.style.setProperty(l,h,d)}):Promise.resolve()});return Promise.all(a).then(function(){return o})}}}function Qj(t,e,n,i){const o=["background-clip"].indexOf(e)>=0;i?(t.setProperty(e,n,i),o&&t.setProperty(`-webkit-${e}`,n,i)):(t.setProperty(e,n),o&&t.setProperty(`-webkit-${e}`,n))}function Xj(t,e,n,i,o){const r=At.impl.options.copyDefaultStyles?t6(t,e):{},a=o.style;pt.asArray(n).forEach(function(l){const c=n.getPropertyValue(l),d=r[l],h=i?i.getPropertyValue(l):void 0;if(c!==d||i&&c!==h){const m=n.getPropertyPriority(l);Qj(a,l,c,m)}})}let Th=null,_h={};const e6=["ADDRESS","ARTICLE","ASIDE","BLOCKQUOTE","DETAILS","DIALOG","DD","DIV","DL","DT","FIELDSET","FIGCAPTION","FIGURE","FOOTER","FORM","H1","H2","H3","H4","H5","H6","HEADER","HGROUP","HR","LI","MAIN","NAV","OL","P","PRE","SECTION","SVG","TABLE","UL","math","svg","BODY","HEAD","HTML"];function t6(t,e){const n=l(e),i=c(n);if(_h[i])return _h[i];const o=n6(),r=d(o.document,n),a=h(o,r);return m(r),_h[i]=a,a;function l(g){const y=[];do{if(g.nodeType===iS){const T=g.tagName;if(y.push(T),e6.includes(T))break}g=g.parentNode}while(g);return y}function c(g){return t.styleCaching==="relaxed"?g.filter((y,T,w)=>T===0||T===w.length-1).join(">"):g.join(">")}function d(g,y){let T=g.body;do{const w=y.pop(),S=g.createElement(w);T.appendChild(S),T=S}while(y.length>0);return T.textContent="",T}function h(g,y){const T={},w=g.getComputedStyle(y);return pt.asArray(w).forEach(function(S){T[S]=S==="width"||S==="height"?"auto":w.getPropertyValue(S)}),T}function m(g){do{const y=g.parentElement;y!==null&&y.removeChild(g),g=y}while(g&&g.tagName!=="BODY")}}function n6(){if(Ri)return Ri.contentWindow;const t=document.characterSet||"UTF-8",e=document.doctype,n=e?`<!DOCTYPE ${i(e.name)} ${i(e.publicId)} ${i(e.systemId)}`.trim()+">":"";return Ri=document.createElement("iframe"),Ri.id="domtoimage-sandbox-"+pt.uid(),Ri.className="domtoimage-thino",Ri.style.visibility="hidden",Ri.style.position="fixed",document.body.appendChild(Ri),o(Ri,n,t,"domtoimage-sandbox");function i(r){if(r){const a=document.createElement("div");return a.innerText=r,a.innerHTML}else return""}function o(r,a,l,c){try{return r.contentWindow.document.write(`${a}<html><head><meta charset='${l}'><title>${c}</title></head><body></body></html>`),r.contentWindow}catch{}const d=document.createElement("meta");d.setAttribute("charset",l);try{const h=document.implementation.createHTMLDocument(c);h.head.appendChild(d);const m=a+h.documentElement.outerHTML;return r.setAttribute("srcdoc",m),r.contentWindow}catch{}return r.contentDocument.head.appendChild(d),r.contentDocument.title=c,r.contentWindow}}function i6(){Ri&&(document.body.removeChild(Ri),Ri=null),Th&&clearTi
|
|||
|
|
|
|||
|
|
Before: <div {...getCollapseProps({style: {padding: 10}})}>{children}</div>
|
|||
|
|
|
|||
|
|
After: <div {...getCollapseProps()}>
|
|||
|
|
<div style={{padding: 10}}>
|
|||
|
|
{children}
|
|||
|
|
</div>
|
|||
|
|
</div>`)},x.useEffect(()=>{e(t)},[t])}var S6=typeof window>"u"?x.useEffect:x.useLayoutEffect;function T6({duration:t,easing:e="cubic-bezier(0.4, 0, 0.2, 1)",onTransitionStateChange:n=()=>{},isExpanded:i,defaultExpanded:o=!1,hasDisabledAnimation:r,id:a,...l}={}){const c=fN(n),d=g6(a?`${a}`:void 0),[h,m]=l6(i,o),g=x.useRef(h),[y,T]=x.useState(!1),w=u6(),S=r??w,I=x.useRef(),E=x.useRef(),L=x.useRef(null),[C,R]=x.useState(null);b6(L);const M=`${l.collapsedHeight||0}px`;function O(F){if(!L.current)return;const j=L.current;for(const z in F){const _=F[z];_?j.style[z]=_:j.style.removeProperty(z)}}return S6(()=>{if(!L.current||h===g.current)return;g.current=h;function j(V){return S?0:t??v6(V)}const z=V=>`height ${j(V)}ms ${e}`,_=V=>{function G(){h?(O({height:"",overflow:"",transition:"",display:""}),c("expandEnd")):(O({transition:""}),c("collapseEnd")),T(!1)}E.current&&bk(E.current),E.current=y6(G,V)};return T(!0),h?I.current=requestAnimationFrame(()=>{c("expandStart"),O({display:"block",overflow:"hidden",height:M}),I.current=requestAnimationFrame(()=>{c("expanding");const V=Sk(L);_(j(V)),L.current&&(L.current.style.transition=z(V),L.current.style.height=`${V}px`)})}):I.current=requestAnimationFrame(()=>{c("collapseStart");const V=Sk(L);_(j(V)),O({transition:z(V),height:`${V}px`}),I.current=requestAnimationFrame(()=>{c("collapsing"),O({height:M,overflow:"hidden"})})}),()=>{I.current&&cancelAnimationFrame(I.current),E.current&&bk(E.current)}},[h,M,S,t,e,c]),{isExpanded:h,setExpanded:m,getToggleProps(F){const{disabled:j,onClick:z,refKey:_,...V}={refKey:"ref",onClick(){},disabled:!1,...F},G=C?C.tagName==="BUTTON":void 0,Z=F?.[_||"ref"],ee={id:`react-collapsed-toggle-${d}`,"aria-controls":`react-collapsed-panel-${d}`,"aria-expanded":h,onClick(ne){j||(z?.(ne),m(ie=>!ie))},[_||"ref"]:Tk(Z,R)},$={type:"button",disabled:j?!0:void 0},re={"aria-disabled":j?!0:void 0,role:"button",tabIndex:j?-1:0};return G===!1?{...ee,...re,...V}:G===!0?{...ee,...$,...V}:{...ee,...$,...re,...V}},getCollapseProps(F){const{style:j,refKey:z}={refKey:"ref",style:{},...F},_=F?.[z||"ref"];return{id:`react-collapsed-panel-${d}`,"aria-hidden":!h,"aria-labelledby":`react-collapsed-toggle-${d}`,role:"region",...F,[z||"ref"]:Tk(L,_),style:{boxSizing:"border-box",...!y&&!h?{display:M==="0px"?"none":"block",height:M,overflow:"hidden"}:{},...j}}}}}const I6=x.memo(({memoId:t,showOutgoingLinks:e=!0,showIncomingLinks:n=!0})=>{const[i,o]=x.useState([]),[r,a]=x.useState([]),[l,c]=x.useState(null),[d,h]=x.useState(!1),[m,g]=x.useState(!1),y=x.useRef(null);x.useEffect(()=>{!l&&!d&&!m&&(h(!0),(async()=>{const S=he.getMemoById(t);S&&c(S),h(!1)})())},[t,l,d,m]),x.useEffect(()=>{l&&!m&&!d&&(h(!0),(async()=>{try{if(e){const S=[],I=[...l.content.matchAll(zs)];for(const L of I)if(L&&L.length===3){const C=L[2],R=he.getMemoById(C);R&&S.push({...R,createdAtStr:Ne.getDateTimeString(R.createdAt),dateStr:Ne.getDateString(R.createdAt)})}const E=Xf(l.content);for(const L of E){const[C,R]=L.split("#^"),M=R;if(C&&M){const O=await he.getLinkedMemoByBlockId(M,C);O&&(S.some(F=>F.id===O.id)||S.push({...O,createdAtStr:Ne.getDateTimeString(O.createdAt),dateStr:Ne.getDateString(O.createdAt)}))}}o([...S])}if(n){const S=await he.getLinkedMemos(l.id);let I=[];l.hasId&&l.path&&(I=await he.getLinkedMemosByLinkId(l.hasId,l.path));const E=[...S,...I],L=Array.from(new Map(E.map(C=>[C.id,C])).values());a(L.sort((C,R)=>Ne.getTimeStampByDate(R.createdAt)-Ne.getTimeStampByDate(C.createdAt)).map(C=>({...C,createdAtStr:Ne.getDateTimeString(C.createdAt),dateStr:Ne.getDateString(C.createdAt)})))}g(!0)}catch(S){console.error("Error fetching linked memos:",S)}h(!1)})())},[l,e,n,m,d]);const T=x.useCallback(w=>{to(w)},[]);return p.jsxs("div",{className:Ct("reference-links-group",d?"loading":"loaded"),ref:y,children:[d&&p.jsx("div",{className:"links-loading",children:p.jsx("span",{className:"loading-text",children:v("Loading...")})}),m&&p.jsxs(p.Fragment,{children:[e&&i.length>0&&p.jsx("div",{className:"links-section outgoing-links",children:p.jsx("div",{className:"links-list",children:i.map(w=>{const S=lf(cf(w.
|
|||
|
|
`," ");return p.jsxs("div",{"aria-label":`${v("Linked")} ${w.content}`,className:"link-item",onClick:()=>T(w),children:[p.jsx("div",{className:"link-icon",ref:I=>I&&k.setIcon(I,"circle-dot")}),p.jsxs("div",{className:"link-date",children:[w.dateStr,":"]}),p.jsx("div",{className:"link-content",children:S})]},w.id)})})}),n&&r.length>0&&p.jsx("div",{className:"links-section incoming-links",children:p.jsx("div",{className:"links-list",children:r.map(w=>{const S=lf(cf(w.content)).replaceAll(`
|
|||
|
|
`," ");return p.jsxs("div",{"aria-label":`${v("Linked by")} ${w.content}`,className:"link-item",onClick:()=>T(w),children:[p.jsx("div",{className:"link-icon",ref:I=>I&&k.setIcon(I,"circle-dot-dashed")}),p.jsxs("div",{className:"link-date",children:[w.dateStr,":"]}),p.jsx("div",{className:"link-content",children:S})]},w.id)})})}),m&&!d&&i.length===0&&r.length===0&&null]})]})},(t,e)=>t.memoId===e.memoId&&t.showIncomingLinks===e.showIncomingLinks&&t.showOutgoingLinks===e.showOutgoingLinks),k6=t=>{const{app:e,view:n,settings:i}=Ke(),{memoListView:o}=Tt(),{getCollapseProps:r,getToggleProps:a,isExpanded:l,setExpanded:c}=T6({defaultExpanded:!0,collapsedHeight:i?.ThinoCollapsedHeight??100}),{memo:d,handleMemoContentClick:h,handleMemoDoubleClick:m}=t,g=J.useRef(null),[y,T]=J.useState(""),w=J.useRef(y),S=J.useRef(0),[I,E]=J.useState(!1),[L,C]=J.useState(!1),R=k.debounce((O,F,j)=>{for(const z of O){const{height:_}=z.contentRect,V=F?.ThinoMaxHeight||340,G=_>V;E(G),c(!G),j.disconnect()}},500);x.useEffect(()=>{if(d.content!==w.current){if(i?.OptimizeForCallout&&d.content.split("> [!").length>3&&d.content.split(`
|
|||
|
|
`).length>10&&!L){const O=g.current.createEl("button");O.setText(v("Render content")),O.onclick=async()=>{C(!0),await M()};const F=g.current.createEl("textarea");F.setText(d.content),F.disabled=!0,g.current?.toggleClass(["raw-content"],!0),c(!0),E(!1);return}M()}},[d.content]),x.useEffect(()=>{L&&S.current!==i?.ThinoMaxHeight&&(g?.current.hasChildNodes()&&C(!1),M())},[i?.ThinoMaxHeight]),x.useEffect(()=>{if(!L)return;const O=g.current;if(!O)return;if(!i?.ThinoMaxHeight){c(!0),E(!1);return}const F=new ResizeObserver(j=>{R(j,i,F)});return F.observe(O),()=>F.disconnect()},[L]);const M=async()=>{g.current&&n&&e&&d.content!==w.current&&(g.current.empty(),await k.MarkdownRenderer.render(e,d.content,g.current,d.path,n),g.current?.querySelectorAll(".internal-link")?.forEach(F=>{const j=F,z=j.getAttribute("data-href");if(!z)return;e.metadataCache.getFirstLinkpathDest(z,d.path)||F.classList.add("is-unresolved"),j.addEventListener("mouseover",V=>{V.stopPropagation(),e.workspace.trigger("hover-link",{event:V,source:"thino",hoverParent:n.containerEl,targetEl:j,linktext:z,sourcePath:j.href})})})),w.current=d.content,g.current?.toggleClass(["markdown-rendered"],!0),g.current?.toggleClass(["raw-content"],!1),C&&C(!0),S.current=i?.ThinoMaxHeight||340};return p.jsxs(p.Fragment,{children:[I&&o==="moments"&&p.jsxs(p.Fragment,{children:[p.jsx("button",{className:"thino-collapse-button",...a({style:{display:"block",marginTop:2}}),children:v(l?"Collapse":"Expand")}),!l&&i?.ThinoCollapsedHeight!==0&&p.jsx("div",{className:"thino-collapse-shadowOverlay",onDoubleClick:m})]}),p.jsx("div",{...r({style:{margin:0}}),ref:g,className:"memo-content-text",onClick:O=>h(O,d),onDoubleClick:m,onContextMenu:O=>{O.preventDefault()}}),o==="list"&&i?.enableReferenceLinksGroup&&p.jsx(I6,{memoId:d.id}),I&&o!=="moments"&&p.jsxs(p.Fragment,{children:[!l&&i?.ThinoCollapsedHeight!==0&&p.jsx("div",{className:"thino-collapse-shadowOverlay",onDoubleClick:m}),p.jsx("button",{className:"thino-collapse-button",...a({style:{display:"block",marginTop:2}}),children:v(l?"Collapse":"Expand")})]})]})},pN=x.memo(k6,(t,e)=>t.memo.content===e.memo.content),E6=t=>{const[e,n]=x.useState({...t.memo,createdAtStr:Ne.getDateTimeString(t.memo.createdAt)}),[i,o]=x.useState([]),[r,a]=x.useState([]);x.useEffect(()=>{(async()=>{try{const m=[],g=[...e.content.matchAll(zs)];for(const E of g)if(E&&E.length===3){const L=E[2],C=he.getMemoById(L);C&&m.push({...C,createdAtStr:Ne.getDateTimeString(C.createdAt),dateStr:Ne.getDateString(C.createdAt)})}const y=Xf(e.content);for(const E of y){const[L,C]=E.split("#^"),R=C;if(L&&R){const M=await he.getLinkedMemoByBlockId(R,L);M&&(m.some(O=>O.id===M.id)||m.push({...M,createdAtStr:Ne.getDateTimeString(M.createdAt),dateStr:Ne.getDateString(M.createdAt)}))}}o([...m]);const T=await he.getLinkedMemos(e.id);let w=[];e.hasId&&e.path&&(w=await he.getLinkedMemosByLinkId(e.hasId,e.path));const S=[...T,...w],I=Array.from(new Map(S.map(E=>[E.id,E])).values());a(I.sort((E,L)=>Ne.getTimeStampByDate(L.createdAt)-Ne.getTimeStampByDate(E.createdAt)).map(E=>({...E,createdAtStr:Ne.getDateTimeString(E.createdAt),dateStr:Ne.getDateString(E.createdAt)})))}catch(m){console.error("Error fetching linked memos:",m)}})()},[e.id,e.hasId,e.path]);const l=x.useCallback(async h=>{const m=h.target;if(m.className==="memo-link-text"){const g=m.dataset?.value,y=he.getMemoById(g??"");if(y){const T={...y,createdAtStr:Ne.getDateTimeString(y.createdAt)};o([]),a([]),n(T)}else new k.Notice(v("Thino not found")),m.classList.remove("memo-link-text")}},[]),c=x.useCallback(h=>{o([]),a([]),n({...h,createdAtStr:Ne.getDateTimeString(h.createdAt)})},[e.id]),d=x.useCallback(()=>{t.destroy(),We.setEditMemoId(e.id)},[e.id]);return p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"memo-card-container",children:[p.jsxs("div",{className:"header-container",children:[p.jsx("span",{className:"time-text",children:e.createdAtStr}),p.jsxs("div",{className:"btns-container",children:[p.jsx("button",{ref:h=>{h&&k.setIcon(h,"edit")},className:"btn edit-btn",onClick:d}),p.jsx("button",{ref:h=>{h&&k.setIcon(h,"x")},cla
|
|||
|
|
`," ");return p.jsxs("div",{className:"linked-memo-container",onClick:()=>c(h),children:[p.jsxs("span",{className:"time-text",children:[h.dateStr," "]}),m]},h.id)})]}):null,r.length>0?p.jsxs("div",{className:"linked-memos-wrapper",children:[p.jsxs("span",{className:"normal-text",children:[r.length," THINO ",v("LINK TO THE")," THINO"]}),r.map(h=>{const m=lf(cf(h.content)).replaceAll(`
|
|||
|
|
`," ");return p.jsxs("div",{className:"linked-memo-container",onClick:()=>c(h),children:[p.jsxs("span",{className:"time-text",children:[h.dateStr," "]}),m]},h.id)})]}):null]})};function to(t){ep({className:"memo-card-dialog"},E6,{memo:t})}function x6({mouseEnterDelayMS:t=0,mouseLeaveDelayMS:e=0}={}){const[n,i]=x.useState(!1);let o,r;return[n,{onMouseEnter:()=>{clearTimeout(r),o=window.setTimeout(()=>i(!0),t)},onMouseLeave:()=>{clearTimeout(o),r=window.setTimeout(()=>i(!1),e)}}]}const C6=t=>{const{memo:e,memoListView:n,handlePinMemoClick:i,handleFixMemoClick:o,handleSourceMemoClick:r,handleShowMemoStoryDialog:a,handleCopyMemoClick:l,handleEditMemoClick:c,handleGenMemoImageBtnClick:d,handleMarkMemoClick:h,handleArchiveMemo:m,handleDeleteMemoClick:g,handleSplitMemoClick:y,handleCopyEmbedLink:T,handleReferenceLinksGroupClick:w}=t,S=Le.getState().query.tag,I=rt.getState().dailyNotesState.settings,E=I.EnabledLocationList.find(G=>G.value==="MULTI"),[L,C]=rc(!1),R=x.useRef(null),M={pinRef:x.useRef(null),fixRef:x.useRef(null),typeRef:x.useRef(null),referenceLinksGroupRef:x.useRef(null),moreRef:x.useRef(null)},[O,F]=x6({mouseEnterDelayMS:500}),j=x.useRef();x.useEffect(()=>{if(!M.typeRef)return;const G=Hl.find(Z=>Z.title===e.sourceType);k.setIcon(M.typeRef.current,G.icon),k.requireApiVersion("1.4.4")&&k.setTooltip(M.typeRef.current,e.path),M.fixRef&&(k.setIcon(M.fixRef.current,"shield-alert"),k.requireApiVersion("1.4.4")&&k.setTooltip(M.fixRef.current,"Update Thino property")),M.referenceLinksGroupRef&&I?.enableReferenceLinksGroup&&(k.setIcon(M.referenceLinksGroupRef.current,"link"),k.requireApiVersion("1.4.4")&&k.setTooltip(M.referenceLinksGroupRef.current,"Reference links group"))},[M.typeRef,M.referenceLinksGroupRef]),x.useEffect(()=>{M.pinRef&&(e.pinned?(k.setIcon(M.pinRef.current,"pin-off"),k.requireApiVersion("1.4.4")&&k.setTooltip(M.pinRef.current,v("UNPIN"))):(k.setIcon(M.pinRef.current,"pin"),k.requireApiVersion("1.4.4")&&k.setTooltip(M.pinRef.current,v("PIN"))))},[M.pinRef,e.pinned]);const z=k.debounce(()=>{if(O&&M.moreRef.current){if(j.current&&j.current._loaded||j.current?.useNativeMenu||document.body.find(".more-action-btns-wrapper"))return;const G=_(),Z=M.moreRef.current.getBoundingClientRect();G.showAtPosition({x:Z.left,y:Z.bottom})}},200);x.useEffect(()=>{z()},[O]);const _=()=>{const G=new k.Menu;return G.dom.toggleClass(["more-action-btns-wrapper"],!0),G.useNativeMenu?(G.setNoIcon(),G.addItem(Z=>{Z.setTitle(v("COPY")).onClick(l)}),G.addItem(Z=>{Z.setTitle(v("EDIT")).onClick(c)}),G.addItem(Z=>{Z.setTitle(v("SHARE")).onClick(d)})):G.addItem(Z=>{const ee=Z.dom;Z.dom.empty(),Z.dom.toggleClass(["more-action-btn-group","more-action-menu-item"],!0);const $=ee.createEl("span");new k.ExtraButtonComponent($).setIcon("copy"),$.toggleClass(["menu-item-icon","more-action-item-icon"],!0),$.onclick=ie=>{ie.stopPropagation(),ie.preventDefault(),l(),G.close()};const re=ee.createEl("span");re.toggleClass(["menu-item-icon","more-action-item-icon"],!0),re.onclick=ie=>{ie.stopPropagation(),ie.preventDefault(),c(),G.close()},new k.ExtraButtonComponent(re).setIcon("pencil");const ne=ee.createEl("span");ne.toggleClass(["menu-item-icon","more-action-item-icon"],!0),ne.onclick=ie=>{ie.stopPropagation(),ie.preventDefault(),d(),G.close()},new k.ExtraButtonComponent(ne).setIcon("share-2")}),G.addSeparator(),e.sourceType==="DAILY"&&(G.addItem(Z=>{Z.setIcon("copy").setTitle(v("Copy embed link")).onClick(()=>{T(!0)})}),G.addItem(Z=>{Z.setIcon("copy").setTitle(v("Copy link")).onClick(()=>{T(!1)})}),G.addSeparator()),G.addItem(Z=>{Z.setIcon("book-open").setTitle(v("READ")).onClick(()=>a(new MouseEvent("click")))}),G.addItem(Z=>{Z.setIcon("bookmark").setTitle(v("MARK")).onClick(h)}),/(^|\n)#{1,6}\s/g.exec(e.content)?.length>1&&E&&G.addItem(Z=>{Z.setIcon("separator-horizontal").setTitle(v("SPLIT")).onClick(y)}),G.addItem(Z=>{Z.setIcon("home").setTitle(v("SOURCE")).onClick(()=>r(e))}),G.addSeparator(),G.addItem(Z=>{Z.setWarning(!0).setIcon("archive").setTitle(v("ARCHIVE").toUpperCase()).onClick(()=>m(e))}),G.addItem(Z=>{Z.setWarning(!0).setIcon("tras
|
|||
|
|
`),o=new Array(n).join("#")+" ",r=new Array(n+1).join("#")+" ",a=[];let l=[];return i.forEach((c,d)=>{c.startsWith(r)?(l.length>0&&(a.push(l),l=[]),l.push(c)):l.length>0&&!c.startsWith(o)?l.push(c):l.length>0&&(a.push(l),l=[]),d===i.length-1&&l.length>0&&a.push(l)}),a}onChooseSuggestion(e,n){this.selectSuggestion(e,n)}renderSuggestion(e,n){n.setText(e.title)}getSuggestions(){return[{id:"splitByHeading1",title:v("Split by Heading 1")},{id:"splitByHeading2",title:v("Split by Heading 2")},{id:"splitByHeading3",title:v("Split by Heading 3")}]}async selectSuggestion(e,n){let i=[];if(e.id==="splitByHeading1"?i=this.contentSplitByHeading(this.thino.content,1):e.id==="splitByHeading2"?i=this.contentSplitByHeading(this.thino.content,2):e.id==="splitByHeading3"&&(i=this.contentSplitByHeading(this.thino.content,3)),i.length===0){new k.Notice("No headings found"),this.close();return}const o=this.ensureUniqueFileNames(i);for(const l of i){const c=i.indexOf(l),d=await he.createThino({content:l.join(`
|
|||
|
|
`),name:o[c],type:"MULTI",isList:!0});he.pushMemo(d)}let r=this.thino.content;i.forEach((l,c)=>{r=r.replace(l.join(`
|
|||
|
|
`),`[[${o[c]}]]`)});const a=await he.updateMemo(this.thino.id,r);a&&he.editMemo(a),this.close()}}const A6=async(t,e,n)=>{const i=n.getAttribute("href"),o=n.className;if(o.contains("tag"))N6(n.innerText.slice(1));else if(o.contains("internal-link")){const r=n.getAttribute("data-href"),a=he.getMemoById(r??"");a?to(a):await t.workspace.openLinkText(r,r,!k.Platform.isMobile&&e.navigation!==!0)}else i&&window.open(i,"_blank")},N6=t=>{const e=Le.getState().query.tag;Le.setTagQuery(e.contains(",")?e.split(",").includes(t)?e.split(",").filter(n=>n!==t).join(","):e+","+t:e===t?"":t)},P6=(t,e)=>{const n=e?.getAttribute("src"),i=e?.parentElement.getAttribute("src"),o=[...t?.querySelectorAll("img")||[]],r=o.indexOf(e);Wl({imgUrl:n,filepath:n.startsWith("app")?i:void 0,otherIMGEls:o,currentIndex:r})},L6=t=>{const e=t.dataset?.value,n=he.getMemoById(e??"");n?to(n):(new k.Notice("Thino Not Found"),t.classList.remove("memo-link-text"))},O6=async(t,e,n,i)=>{const o=t?.AppendDateWhenTaskDone?" ✅ "+k.moment().format("YYYY-MM-DD"):"",r=i.parentElement.dataset?.task==="x"?"DONE":"TODO",a=[...n?.querySelectorAll("li.task-list-item")||[]];for(const l of a)if(l===i||l===i.closest("li.task-list-item")){const c=a.indexOf(l),d=e.content.split(/\n/),h=[];for(let S=0;S<d.length;S++)/^\s*(-|\*|\d+\.)\s\[.\]\s/.test(d[S])&&h.push(S);const m=h[c],g=d[m],y=g.match(/^\s*(-|\*|\d+\.)\s\[.\]\s/)[0];let T=g.replace(/^\s*(-|\*|\d+\.)\s\[.\]\s/,y.replace(/\[.\]/,r==="TODO"?"[x]":"[ ]"))+(r==="TODO"?o:"");t.AppendDateWhenTaskDone&&r!=="TODO"&&(T=T.replace(/ ✅ \d{4}-\d{2}-\d{2}/g,"")),d[m]=T;const w=d.join(`
|
|||
|
|
`).trim();if(e&&e.content!==w){const S=await he.updateMemo(e.id,w);he.editMemo(S)}}},R6=t=>{const{editMemoId:e,memoListView:n}=Tt(),{app:i,view:o,settings:r,verifyState:a}=Ke(),{pathname:l}=yt(),{memo:c,type:d="inline"}=t,h=x.useRef(null),m=x.useRef(null),[g,y]=x.useState(!1),T=x.useRef(null),[w,S]=x.useState(!1);x.useEffect(()=>{g&&setTimeout(()=>{We.setEditMemoId(c.id)},100)},[g]),x.useEffect(()=>{(l==="/review"||l==="/daily")&&e!==c.id&&g&&y(!1)},[e]),x.useEffect(()=>{T.current&&!w&&h.current&&(i.dragManager.handleDrag(T.current,K=>{i.dragManager.updateSource([h.current],"is-dragging");const ce=he.getMemoById(c.id);if(K.dataTransfer.setData("text/plain",c.content),K.dataTransfer.setData("text/uri-list",c.content),K.dataTransfer.setData("Text",c.content),r?.DraggingBehavior==="block-link")if(ce?.sourceType==="DAILY"){const ue=i.vault.getFileByPath(ce.path);let te=ce.hasId;return ce.hasId||(te=Ne.randomId(6),ji(ce,{id:ce.id,hasId:te})),{type:"link",icon:"lucide-link",title:ue.basename,linktext:`${ce.path}#^${te}`,sourcePath:ce.path,file:ue,memo:ce,blockId:te,source:"thino-plugin"}}else return null;else if(r?.DraggingBehavior==="text")return null}),S(!0))},[T.current,h.current,r?.DraggingBehavior]);const I=K=>{if(K.ctrlKey||K.metaKey){const ce=k.moment(c.createdAt,"YYYY/MM/DD HH:mm:ss");Le.setFromAndToQuery(ce.startOf("day").valueOf(),ce.endOf("day").valueOf());return}to(c)},E=()=>{if(r?.UseButtonToShowEditor&&r?.DefaultEditorLocation==="Bottom"){const K=document.querySelector("div[data-type='thino_view'] .view-content .memo-show-editor-button:not(.thino-hidden)");K&&K.trigger("click")}We.setMarkMemoId(c.id)},L=async()=>{const K=!k.Platform.isDesktop&&await window.Capacitor?.Plugins.Device.getId(),ce=k.Platform.isDesktop?await Jt():K.identifier||K.uuid;if(!a||a?.appId!==ce){wt();return}c.pinned?await he.unpinMemoById(c.id):await he.pinMemoById(c.id)},C=()=>{if(r?.UseButtonToShowEditor&&r?.DefaultEditorLocation==="Bottom"&&k.Platform.isMobile){const K=document.querySelector("div[data-type='thino_view'] .view-content .memo-show-editor-button:not(.thino-hidden)");K&&K.trigger("click")}(l==="/review"||l==="/daily")&&y(!0),l!=="/review"&&l!=="/daily"&&We.setEditMemoId(c.id)},R=async K=>{K.sourceType==="MULTI"&&K.id.trim()===""&&await he.updateMemoProperty(K)},M=async K=>{await he.openThinoByID(K.id)},O=async K=>{try{const ce=await he.archiveMemo(K);ce&&he.editMemo(ce)}catch(ce){console.error(ce),new k.Notice(ce.message)}},F=async()=>{try{if(r.DeleteThinoDirectly)await he.deleteMemoById(c.id);else{const K=await he.hideMemoById(c.id);K&&he.editMemo(K)}}catch(K){new k.Notice(K.message)}We.getState().editMemoId===c.id&&We.setEditMemoId("")},j=()=>{if(m.current&&!m.current.confirmStatus){m.current&&m.current.toggleConfirm(!1);return}},z=()=>{ys(c)},_=async()=>{const K=await he.updateMemo(c.id,c.content,c.thinoType==="TASK-TODO"?"TASK-DONE":"TASK-TODO");K&&he.editMemo(K)},V=async()=>{navigator.clipboard.writeText(c.content).then(()=>{new k.Notice(v("COPY SUCCEED"))}).catch(()=>{new k.Notice(v("COPY FAILED"))})},G=async()=>{new M6(i,c).open()},Z=K=>{if(!K||K.target.tagName==="INPUT")return;switch(r?.doubleClickBehavior||"edit-thino"){case"open-thino":to(c);break;case"edit-thino":C();break;case"go-to-source":M(c);break;case"do-nothing":break;default:C();break}},ee=async(K,ce)=>{K.preventDefault(),K.stopPropagation();const ue=K.target;if(K.ctrlKey||K.metaKey){await M(ce);return}if(ue.tagName==="A"){await A6(i,o,ue);return}if(ue.tagName==="IMG"){P6(h.current,ue);return}if(ue.tagName==="A"&&ue.getAttribute("href")){const te=ue.getAttribute("href");window.open(te,"_blank");return}if(ue.className==="memo-link-text"){L6(ue);return}if(ue.tagName==="INPUT"&&ue.hasClass("task-list-item-checkbox")){await O6(r,ce,h.current,ue);return}},$=async K=>{const ce=await uA(c,K);navigator.clipboard.writeText(ce),new k.Notice(v("COPY SUCCEED"))},re=K=>{const ce=new k.Menu;ce.dom.toggleClass("memo-context-menu",!0);const ue=window.getSelection();ue?.toString().length>0&&ce.addItem(te=>{te.setIcon("copy").setTitle(v("Copy selected text")).onClick(()=>{nav
|
|||
|
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function eo(t,e){return CN(t)||w8(t,e)||aS(t,e)||DN()}function MN(t){var e,n,i="";if(typeof t=="string"||typeof t=="number")i+=t;else if(typeof t=="object")if(Array.isArray(t))for(e=0;e<t.length;e++)t[e]&&(n=MN(t[e]))&&(i&&(i+=" "),i+=n);else for(e in t)t[e]&&(i&&(i+=" "),i+=e);return i}function fn(){for(var t,e,n=0,i="";n<arguments.length;)(t=arguments[n++])&&(e=MN(t))&&(i&&(i+=" "),i+=e);return i}function hn(){return hn=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)({}).hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},hn.apply(null,arguments)}var Pg,Rk;function b8(){if(Rk)return Pg;Rk=1;var t=function(e,n,i,o,r,a,l,c){if(!e){var d;if(n===void 0)d=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var h=[i,o,r,a,l,c],m=0;d=new Error(n.replace(/%s/g,function(){return h[m++]})),d.name="Invariant Violation"}throw d.framesToPop=1,d}};return Pg=t,Pg}var S8=b8();const Mu=bn(S8);var T8=function(){};function I8(t,e){var n={};return Object.keys(t).forEach(function(i){n[Yh(i)]=T8}),n}function Fk(t,e){return t[e]!==void 0}function Yh(t){return"default"+t.charAt(0).toUpperCase()+t.substr(1)}function k8(t){return!!t&&(typeof t!="function"||t.prototype&&t.prototype.isReactComponent)}function E8(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,Df(t,e)}function AN(){var t=this.constructor.getDerivedStateFromProps(this.props,this.state);t!=null&&this.setState(t)}function NN(t){function e(n){var i=this.constructor.getDerivedStateFromProps(t,n);return i??null}this.setState(e.bind(this))}function PN(t,e){try{var n=this.props,i=this.state;this.props=t,this.state=e,this.__reactInternalSnapshotFlag=!0,this.__reactInternalSnapshot=this.getSnapshotBeforeUpdate(n,i)}finally{this.props=n,this.state=i}}AN.__suppressDeprecationWarning=!0;NN.__suppressDeprecationWarning=!0;PN.__suppressDeprecationWarning=!0;function x8(t){var e=t.prototype;if(!e||!e.isReactComponent)throw new Error("Can only polyfill class components");if(typeof t.getDerivedStateFromProps!="function"&&typeof e.getSnapshotBeforeUpdate!="function")return t;var n=null,i=null,o=null;if(typeof e.componentWillMount=="function"?n="componentWillMount":typeof e.UNSAFE_componentWillMount=="function"&&(n="UNSAFE_componentWillMount"),typeof e.componentWillReceiveProps=="function"?i="componentWillReceiveProps":typeof e.UNSAFE_componentWillReceiveProps=="function"&&(i="UNSAFE_componentWillReceiveProps"),typeof e.componentWillUpdate=="function"?o="componentWillUpdate":typeof e.UNSAFE_componentWillUpdate=="function"&&(o="UNSAFE_componentWillUpdate"),n!==null||i!==null||o!==null){var r=t.displayName||t.name,a=typeof t.getDerivedStateFromProps=="function"?"getDerivedStateFromProps()":"getSnapshotBeforeUpdate()";throw Error(`Unsafe legacy lifecycles will not be called for components using new component APIs.
|
|||
|
|
|
|||
|
|
`+r+" uses "+a+" but also contains the following legacy lifecycles:"+(n!==null?`
|
|||
|
|
`+n:"")+(i!==null?`
|
|||
|
|
`+i:"")+(o!==null?`
|
|||
|
|
`+o:"")+`
|
|||
|
|
|
|||
|
|
The above lifecycles should be removed. Learn more about this warning here:
|
|||
|
|
https://fb.me/react-async-component-lifecycle-hooks`)}if(typeof t.getDerivedStateFromProps=="function"&&(e.componentWillMount=AN,e.componentWillReceiveProps=NN),typeof e.getSnapshotBeforeUpdate=="function"){if(typeof e.componentDidUpdate!="function")throw new Error("Cannot polyfill getSnapshotBeforeUpdate() for components that do not define componentDidUpdate() on the prototype");e.componentWillUpdate=PN;var l=e.componentDidUpdate;e.componentDidUpdate=function(d,h,m){var g=this.__reactInternalSnapshotFlag?this.__reactInternalSnapshot:m;l.call(this,d,h,g)}}return t}var C8="/Users/jquense/src/uncontrollable/src/uncontrollable.js";function LN(t,e,n){n===void 0&&(n=[]);var i=t.displayName||t.name||"Component",o=k8(t),r=Object.keys(e),a=r.map(Yh);o||!n.length||Mu(!1);var l=(function(d){E8(h,d);function h(){for(var g,y=arguments.length,T=new Array(y),w=0;w<y;w++)T[w]=arguments[w];g=d.call.apply(d,[this].concat(T))||this,g.handlers=Object.create(null),r.forEach(function(I){var E=e[I],L=function(R){if(g.props[E]){var M;g._notifying=!0;for(var O=arguments.length,F=new Array(O>1?O-1:0),j=1;j<O;j++)F[j-1]=arguments[j];(M=g.props)[E].apply(M,[R].concat(F)),g._notifying=!1}g.unmounted||g.setState(function(z){var _,V=z.values;return{values:hn(Object.create(null),V,(_={},_[I]=R,_))}})};g.handlers[E]=L}),n.length&&(g.attachRef=function(I){g.inner=I});var S=Object.create(null);return r.forEach(function(I){S[I]=g.props[Yh(I)]}),g.state={values:S,prevProps:{}},g}var m=h.prototype;return m.shouldComponentUpdate=function(){return!this._notifying},h.getDerivedStateFromProps=function(y,T){var w=T.values,S=T.prevProps,I={values:hn(Object.create(null),w),prevProps:{}};return r.forEach(function(E){I.prevProps[E]=y[E],!Fk(y,E)&&Fk(S,E)&&(I.values[E]=y[Yh(E)])}),I},m.componentWillUnmount=function(){this.unmounted=!0},m.render=function(){var y=this,T=this.props,w=T.innerRef,S=lp(T,["innerRef"]);a.forEach(function(E){delete S[E]});var I={};return r.forEach(function(E){var L=y.props[E];I[E]=L!==void 0?L:y.state.values[E]}),J.createElement(t,hn({},S,I,this.handlers,{ref:w||this.attachRef}))},h})(J.Component);x8(l),l.displayName="Uncontrolled("+i+")",l.propTypes=hn({innerRef:function(){}},I8(e)),n.forEach(function(d){l.prototype[d]=function(){var m;return(m=this.inner)[d].apply(m,arguments)}});var c=l;return J.forwardRef&&(c=J.forwardRef(function(d,h){return J.createElement(l,hn({},d,{innerRef:h,__source:{fileName:C8,lineNumber:128},__self:this}))}),c.propTypes=l.propTypes),c.ControlledComponent=t,c.deferControlTo=function(d,h,m){return h===void 0&&(h={}),LN(d,hn({},e,h),m)},c}var Lg={exports:{}},Og,jk;function D8(){if(jk)return Og;jk=1;var t="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return Og=t,Og}var Rg,Hk;function M8(){if(Hk)return Rg;Hk=1;var t=D8();function e(){}function n(){}return n.resetWarningCache=e,Rg=function(){function i(a,l,c,d,h,m){if(m!==t){var g=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw g.name="Invariant Violation",g}}i.isRequired=i;function o(){return i}var r={array:i,bigint:i,bool:i,func:i,number:i,object:i,string:i,symbol:i,any:i,arrayOf:o,element:i,elementType:i,instanceOf:o,node:i,objectOf:o,oneOf:o,oneOfType:o,shape:o,exact:o,checkPropTypes:n,resetWarningCache:e};return r.PropTypes=r,r},Rg}var Bk;function A8(){return Bk||(Bk=1,Lg.exports=M8()()),Lg.exports}var N8=A8();const be=bn(N8);var Mf="milliseconds",Au="seconds",Nu="minutes",Pu="hours",Ms="day",ql="week",Lu="month",As="year",Ns="decade",Ps="century",ON={milliseconds:1,seconds:1e3,minutes:60*1e3,hours:3600*1e3,day:1440*60*1e3,week:10080*60*1e3},P8={month:1,year:12,decade:120,century:1200};function L8(t){return[31,O8(t),31,30,31,30,31,31,30,31,30,31]}function O8(t){return t%4===0&&t%100!==0||t%400===0?29:28}function Mo(t,e,n){switch(t=new Date(t),n){case Mf:case Au:case Nu:case Pu:case Ms:case ql:return R8(t,e*ON[n]);case Lu:case As:case Ns:case Ps:return F8(t,e*P8[n])}throw new TypeError('Invalid units: "'+n+'"')}functi
|
|||
|
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Vh(t){return U8(t)||UN(t)||aS(t)||_8()}var Fg,Uk;function _N(){if(Uk)return Fg;Uk=1;function t(e,n,i){var o=-1,r=e.length;n<0&&(n=-n>r?0:r+n),i=i>r?r:i,i<0&&(i+=r),r=n>i?0:i-n>>>0,n>>>=0;for(var a=Array(r);++o<r;)a[o]=e[o+n];return a}return Fg=t,Fg}var jg,_k;function od(){if(_k)return jg;_k=1;function t(e,n){return e===n||e!==e&&n!==n}return jg=t,jg}var Hg,Yk;function YN(){if(Yk)return Hg;Yk=1;var t=typeof ru=="object"&&ru&&ru.Object===Object&&ru;return Hg=t,Hg}var Bg,Vk;function mr(){if(Vk)return Bg;Vk=1;var t=YN(),e=typeof self=="object"&&self&&self.Object===Object&&self,n=t||e||Function("return this")();return Bg=n,Bg}var zg,Wk;function lc(){if(Wk)return zg;Wk=1;var t=mr(),e=t.Symbol;return zg=e,zg}var Ug,qk;function Y8(){if(qk)return Ug;qk=1;var t=lc(),e=Object.prototype,n=e.hasOwnProperty,i=e.toString,o=t?t.toStringTag:void 0;function r(a){var l=n.call(a,o),c=a[o];try{a[o]=void 0;var d=!0}catch{}var h=i.call(a);return d&&(l?a[o]=c:delete a[o]),h}return Ug=r,Ug}var _g,Gk;function V8(){if(Gk)return _g;Gk=1;var t=Object.prototype,e=t.toString;function n(i){return e.call(i)}return _g=n,_g}var Yg,$k;function cc(){if($k)return Yg;$k=1;var t=lc(),e=Y8(),n=V8(),i="[object Null]",o="[object Undefined]",r=t?t.toStringTag:void 0;function a(l){return l==null?l===void 0?o:i:r&&r in Object(l)?e(l):n(l)}return Yg=a,Yg}var Vg,Zk;function Kr(){if(Zk)return Vg;Zk=1;function t(e){var n=typeof e;return e!=null&&(n=="object"||n=="function")}return Vg=t,Vg}var Wg,Kk;function cS(){if(Kk)return Wg;Kk=1;var t=cc(),e=Kr(),n="[object AsyncFunction]",i="[object Function]",o="[object GeneratorFunction]",r="[object Proxy]";function a(l){if(!e(l))return!1;var c=t(l);return c==i||c==o||c==n||c==r}return Wg=a,Wg}var qg,Jk;function uS(){if(Jk)return qg;Jk=1;var t=9007199254740991;function e(n){return typeof n=="number"&&n>-1&&n%1==0&&n<=t}return qg=e,qg}var Gg,Qk;function rd(){if(Qk)return Gg;Qk=1;var t=cS(),e=uS();function n(i){return i!=null&&e(i.length)&&!t(i)}return Gg=n,Gg}var $g,Xk;function dS(){if(Xk)return $g;Xk=1;var t=9007199254740991,e=/^(?:0|[1-9]\d*)$/;function n(i,o){var r=typeof i;return o=o??t,!!o&&(r=="number"||r!="symbol"&&e.test(i))&&i>-1&&i%1==0&&i<o}return $g=n,$g}var Zg,eE;function up(){if(eE)return Zg;eE=1;var t=od(),e=rd(),n=dS(),i=Kr();function o(r,a,l){if(!i(l))return!1;var c=typeof a;return(c=="number"?e(l)&&n(a,l.length):c=="string"&&a in l)?t(l[a],r):!1}return Zg=o,Zg}var Kg,tE;function W8(){if(tE)return Kg;tE=1;var t=/\s/;function e(n){for(var i=n.length;i--&&t.test(n.charAt(i)););return i}return Kg=e,Kg}var Jg,nE;function q8(){if(nE)return Jg;nE=1;var t=W8(),e=/^\s+/;function n(i){return i&&i.slice(0,t(i)+1).replace(e,"")}return Jg=n,Jg}var Qg,iE;function Pa(){if(iE)return Qg;iE=1;function t(e){return e!=null&&typeof e=="object"}return Qg=t,Qg}var Xg,oE;function ad(){if(oE)return Xg;oE=1;var t=cc(),e=Pa(),n="[object Symbol]";function i(o){return typeof o=="symbol"||e(o)&&t(o)==n}return Xg=i,Xg}var ey,rE;function G8(){if(rE)return ey;rE=1;var t=q8(),e=Kr(),n=ad(),i=NaN,o=/^[-+]0x[0-9a-f]+$/i,r=/^0b[01]+$/i,a=/^0o[0-7]+$/i,l=parseInt;function c(d){if(typeof d=="number")return d;if(n(d))return i;if(e(d)){var h=typeof d.valueOf=="function"?d.valueOf():d;d=e(h)?h+"":h}if(typeof d!="string")return d===0?d:+d;d=t(d);var m=r.test(d);return m||a.test(d)?l(d.slice(2),m?2:8):o.test(d)?i:+d}return ey=c,ey}var ty,aE;function VN(){if(aE)return ty;aE=1;var t=G8(),e=1/0,n=17976931348623157e292;function i(o){if(!o)return o===0?o:0;if(o=t(o),o===e||o===-e){var r=o<0?-1:1;return r*n}return o===o?o:0}return ty=i,ty}var ny,sE;function WN(){if(sE)return ny;sE=1;var t=VN();function e(n){var i=t(n),o=i%1;return i===i?o?i-o:i:0}return ny=e,ny}var iy,lE;function $8(){if(lE)return iy;lE=1;var t=_N(),e=up(),n=WN(),i=Math.ceil,o=Math.max;function r(a,l,c){(c?e(a,l,c):l===void 0)?l=1:l=o(n(l),0);var d=a==null?0:a.length;if(!d||l<1)return[];for(var h=0,m=0,g=Array(i(d/l));h<d;)g[m++]=t(a,h,h+=l);return g}return iy=r,iy}var Z8=$8();const K8=bn(Z8);function
|
|||
|
|
`)[0].slice(0,20),i=J.useRef(null),o=J.useRef(null),r=J.useRef(null);x.useEffect(()=>{if(o.current)return k.setIcon(o.current,"calendar"),()=>{i.current&&(i.current=null)}},[i]);const a=x.useCallback(c=>{r.current&&(r.current.unmount(),r.current=null),r.current=c},[]),l=x.useCallback(c=>{if(!i.current||!k.Keymap.isModifier(c.nativeEvent,"Mod"))return;const d=new k.HoverPopover(Ve.getState().view,i.current,100),h=$U(d,e);a(h)},[i.current]);return p.jsxs("span",{className:"rbc-event-renderer","data-source-type":e.sourceType,"data-thino-type":e.thinoType,"data-thino-id":e.id,ref:i,"aria-label":e.path,onMouseOver:l,children:[p.jsx(KU,{event:t}),p.jsx("span",{children:n})]})}const KU=({event:t})=>{const e=J.useRef(null),n=t.resource;x.useEffect(()=>{e.current&&k.setIcon(e.current,n.thinoType==="JOURNAL"?"calendar":n.thinoType==="TASK-TODO"?"square":"check-square")},[n?.thinoType,e]);const i=x.useCallback(async o=>{o.stopPropagation(),o.preventDefault(),await(async()=>{const a=await he.updateMemo(n.id,n.content,n.thinoType==="TASK-TODO"?"TASK-DONE":"TASK-TODO");a&&he.editMemo(a)})()},[n?.thinoType,n?.id,n?.content]);return p.jsx(p.Fragment,{children:p.jsxs("span",{className:"rbc-event-icon-group",children:[p.jsx("span",{className:"rbc-event-icon",ref:e,onClick:i}),p.jsx("span",{className:Ct("rbc-event-time","thino-hidden"),children:p.jsx("span",{className:"rbc-event-time-text",children:k.moment(t.start).format("HH:mm")})})]})})};function H2({views:t,view:e,messages:n,onView:i}){return t.map(o=>p.jsx("button",{type:"button",className:Ct({"rbc-active":e===o}),onClick:()=>i(o),children:n[o]},o))}H2.propTypes={messages:be.object,onView:be.func,view:be.string,views:be.array};function B2({date:t,label:e,localizer:{messages:n},onNavigate:i,onView:o,view:r,views:a}){const l={previous:x.useRef(null),today:x.useRef(null),next:x.useRef(null)};x.useEffect(()=>{l&&(k.setIcon(l.previous.current,"chevron-left"),k.setIcon(l.today.current,"dot"),k.setIcon(l.next.current,"chevron-right"))},[l]);const c=x.useMemo(()=>p.jsxs(p.Fragment,{children:[p.jsx("button",{ref:l.previous,type:"button",onClick:()=>i(Pl.PREVIOUS),"aria-label":n.previous,children:"<"}),p.jsx("button",{ref:l.today,type:"button",onClick:()=>i(Pl.TODAY),"aria-label":n.today,children:"•"}),p.jsx("button",{ref:l.next,type:"button",onClick:()=>i(Pl.NEXT),"aria-label":n.next,children:">"})]}),[n]);return p.jsxs("div",{className:"rbc-toolbar",children:[p.jsx("span",{className:Ct("rbc-btn-group","thino-view-custom-toolbar"),children:c}),p.jsx("span",{className:"rbc-toolbar-label",children:p.jsx(kf,{type:"text",handleValueChange:d=>{i(Pl.DATE,k.moment(d,"YYYY-MM-DD").format("YYYY-MM-DDTHH:mm:ssZ"))},defaultText:e+(r==="week"?k.moment(t.valueOf(),"x").format(" [W]WW"):""),defaultValue:k.moment(t.valueOf(),"x").valueOf()})}),p.jsx("span",{className:"rbc-btn-group",children:p.jsx(H2,{view:r,views:a,messages:n,onView:o})})]})}B2.propTypes={date:be.instanceOf(Date),label:be.string,localizer:be.object,messages:be.object,onNavigate:be.func,onView:be.func,view:be.string,views:be.array};function JU({event:t,children:e,showPopup:n,callRender:i,...o}){const r=x.useRef(null),a=x.useRef(null),l=x.useCallback(c=>{if(!c.isTrusted){i();return}a.current=c.nativeEvent.target,a.current&&(a.current.hasClass("rbc-event")||(a.current=a.current.closest(".rbc-event")),r.current!==null?(window.clearTimeout(r.current),r.current=null):r.current=window.setTimeout(()=>{n(t,a.current),r.current=null},250))},[t,n]);return p.jsx(p.Fragment,{children:p.jsx("div",{className:"rbc-event-wrapper","aria-describedby":"thino",onClick:l,children:e})})}const QU=qU(k.moment),XU=({event:t})=>{const e=t.resource;return p.jsx(p.Fragment,{children:p.jsx(_i,{memo:e})})},e_=t=>{const{thinos:e}=t,[n,i]=J.useState([]),[o,r]=J.useState(app?.loadLocalStorage("thino-calendar-view")||"month"),[a,l]=J.useState(null),c=J.useRef(null),d=J.useRef(null),[h,m]=J.useState(!1),g=x.useRef(null),[y,T]=x.useState(new Date);x.useEffect(()=>()=>{c.current&&(c.current=null),d.current&&(d.current=null),g.current&&(g.current=null)},[]),x.useEffect(()=>{
|
|||
|
|
`,hY="\uFEFF",J2=t=>Object.assign({},uY,t);let fY=class extends Error{constructor(e){super(e),this.name="CsvGenerationError"}},pY=class extends Error{constructor(e){super(e),this.name="EmptyHeadersError"}},mY=class extends Error{constructor(e){super(e),this.name="UnsupportedDataFormatError"}};var gY=function(t,e){return e=='"'&&t.indexOf('"')>-1?t.replace(/"/g,'""'):t},yY=t=>KD(typeof t=="object"?t.key:t),vY=t=>JD(typeof t=="object"?t.displayLabel:t),wY=(t,...e)=>e.reduce((n,i)=>i(n),t),bY=t=>e=>t.useBom?Ap(Ui(e)+hY):e,SY=t=>e=>t.showTitle?US(Ap(Ui(e)+t.title))($l("")):e,US=t=>e=>Ap(Ui(t)+Ui(e)+dY),Q2=t=>(e,n)=>TY(t)($l(Ui(e)+Ui(n))),TY=t=>e=>dc(Ui(e)+t.fieldSeparator),IY=(t,e)=>n=>{if(!t.showColumnHeaders)return n;if(e.length<1)throw new pY("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 i=$l("");for(let o=0;o<e.length;o++){const r=vY(e[o]);i=Q2(t)(i,X2(t,Ui(r)))}return i=$l(Ui(i).slice(0,-1)),US(n)(i)},kY=(t,e,n)=>i=>{let o=i;for(var r=0;r<n.length;r++){let a=$l("");for(let l=0;l<e.length;l++){const c=yY(e[l]),d=n[r][Ui(c)];a=Q2(t)(a,X2(t,d))}a=$l(Ui(a).slice(0,-1)),o=US(o)(a)}return o},EY=Ui,xY=t=>+t===t&&(!isFinite(t)||!!(t%1)),CY=(t,e)=>{if(xY(e)){if(t.decimalSeparator==="locale")return yu(e.toLocaleString());if(t.decimalSeparator)return yu(e.toString().replace(".",t.decimalSeparator))}return yu(e.toString())},ef=(t,e)=>{let n=e;return(t.quoteStrings||t.fieldSeparator&&e.indexOf(t.fieldSeparator)>-1||t.quoteCharacter&&e.indexOf(t.quoteCharacter)>-1||e.indexOf(`
|
|||
|
|
`)>-1||e.indexOf("\r")>-1)&&(n=t.quoteCharacter+gY(e,t.quoteCharacter)+t.quoteCharacter),yu(n)},DY=(t,e)=>{const n=e?"true":"false";return yu(t.boolDisplay[n])},MY=(t,e)=>typeof e>"u"&&t.replaceUndefinedWith!==void 0?ef(t,t.replaceUndefinedWith+""):e===null?ef(t,"null"):ef(t,""),X2=(t,e)=>{if(typeof e=="number")return CY(t,e);if(typeof e=="string")return ef(t,e);if(typeof e=="boolean"&&t.boolDisplay)return DY(t,e);if(e===null||typeof e>"u")return MY(t,e);throw new mY(`
|
|||
|
|
typeof ${typeof e} isn't supported. Only number, string, boolean, null and undefined are supported.
|
|||
|
|
Please convert the data in your object to one of those before generating the CSV.
|
|||
|
|
`)},AY=t=>e=>{const n=J2(t),i=n.useKeysAsHeaders?Object.keys(e[0]):n.columnHeaders;let o=wY(Ap(""),bY(n),SY(n),IY(n,i),kY(n,i,e));if(Ui(o).length<1)throw new fY("Output is empty. Is your data formatted correctly?");return o};const NY=({thino:t})=>{const e=x.useRef(null);x.useEffect(()=>(e.current&&k.setIcon(e.current,"pin"),()=>{e.current&&(e.current=null)}),[e]);const n=x.useCallback(async()=>{t.pinned?await he.unpinMemoById(t.id):await he.pinMemoById(t.id)},[t]);return p.jsx("span",{ref:e,className:Ct("pinned-status",t.pinned?"pinned":"not-pinned"),onClick:n})},PY=({thino:t})=>{const e=x.useRef(null);x.useEffect(()=>(e.current&&k.setIcon(e.current,t.thinoType==="JOURNAL"?"calendar":"check-square"),()=>{e.current&&(e.current=null)}),[e,t?.thinoType]);const n=x.useCallback(async()=>{if(t.thinoType==="JOURNAL")return;const i=await he.updateMemo(t.id,t.content,t.thinoType==="TASK-TODO"?"TASK-DONE":"TASK-TODO");i&&he.editMemo(i)},[t]);return p.jsx(p.Fragment,{children:t.thinoType!=="JOURNAL"?p.jsx("input",{className:Ct("thino-type-status","task-list-item-checkbox"),type:"checkbox",checked:t.thinoType!=="TASK-TODO","data-task":t.thinoType==="TASK-TODO"?"":t.thinoType==="TASK-DONE"?"x":t.thinoType?.slice(5),onClick:n}):p.jsx("span",{ref:e,className:"thino-type-status"})})},LY=({id:t,path:e})=>{const n=x.useRef(null);x.useEffect(()=>(n.current&&k.setIcon(n.current,"link"),()=>{n.current&&(n.current=null)}),[]);const i=x.useCallback(()=>{!t||!e||he.openThinoByID(t)},[t,e]);return p.jsxs("span",{className:"source-thino",onClick:i,children:[p.jsx("span",{children:e}),p.jsx("span",{ref:n,className:"source-thino-icon"})]})},OY=({id:t,sourceType:e})=>{const n=x.useRef(null);x.useEffect(()=>(n.current&&k.setIcon(n.current,Hl.find(o=>o.title===e)?.icon||"list"),()=>{n.current&&(n.current=null)}),[]);const i=x.useCallback(async()=>{t&&await he.openThinoByID(t)},[t]);return p.jsx("span",{ref:n,className:"source-type-icon",onClick:i})},QD=(t,e,n,i)=>{const o=iY(t.getValue(e),n);return i({itemRank:o}),o.passed},XD=(t,e,n)=>{let i=0;return t.columnFiltersMeta[n]&&(i=aY(t.columnFiltersMeta[n]?.itemRank,e.columnFiltersMeta[n]?.itemRank)),i===0?Al.alphanumeric(t,e,n):i},RY=J2({fieldSeparator:",",decimalSeparator:".",useKeysAsHeaders:!0}),FY=t=>t+`
|
|||
|
|
`;function jY({thinos:t,isFiltering:e}){J.useReducer(()=>({}),{})[1];const[n,i]=J.useState([]),[o,r]=J.useState(""),a=J.useMemo(()=>[{header:v("Basic Info"),footer:y=>y.column.id,columns:[{accessorKey:"createdAt",header:()=>p.jsx("span",{className:"create-at-header-cell",children:v("Created At")}),cell:y=>y.getValue(),footer:y=>y.column.id,enableColumnFilter:!1},{accessorFn:y=>y.content,id:"content",header:()=>p.jsx("span",{className:"thino-header-cell",children:v("Thino")}),cell:y=>p.jsx(_i,{memo:y.row.original,type:"table"}),footer:y=>y.column.id,filterFn:"fuzzy",sortingFn:XD},{accessorFn:y=>y.thinoType,id:"thinoType",cell:y=>p.jsx(PY,{thino:y.row.original}),header:()=>p.jsx("span",{children:v("Thino Type")}),footer:y=>y.column.id},{accessorFn:y=>y.sourceType,id:"sourceType",cell:y=>p.jsx(OY,{id:y.row.original.id,sourceType:y.getValue()}),header:()=>p.jsx("span",{children:v("Source Type")}),footer:y=>y.column.id}]},{header:v("Additional Info"),footer:y=>y.column.id,columns:[{accessorKey:"pinned",header:()=>p.jsx("span",{children:v("Pinned Status")}),cell:y=>p.jsx(NY,{thino:y.row.original}),footer:y=>y.column.id,filterFn:"fuzzy",sortingFn:XD},{accessorKey:"rowStatus",header:()=>p.jsx("span",{children:v("Row status")}),cell:y=>p.jsx("span",{children:y.getValue()==="NORMAL"?"":y.getValue()}),footer:y=>y.column.id},{accessorKey:"path",header:()=>v("Path"),cell:y=>p.jsx(LY,{id:y.row.original.id,path:y.getValue()}),footer:y=>y.column.id}]}],[]),[l,c]=J.useState(()=>t),d=()=>c(y=>t);x.useEffect(()=>{d()},[t]);const h=X_({data:l,columns:a,filterFns:{fuzzy:QD},initialState:{pagination:{pageSize:20}},state:{columnFilters:n,globalFilter:o},onColumnFiltersChange:i,onGlobalFilterChange:r,globalFilterFn:QD,getCoreRowModel:z_(),getFilteredRowModel:G_(),getSortedRowModel:Z_(),getPaginationRowModel:$_(),getFacetedRowModel:W_(),getFacetedUniqueValues:q_(),getFacetedMinMaxValues:__(),debugTable:!1,debugHeaders:!1,debugColumns:!1});J.useEffect(()=>{h.getState().columnFilters[0]?.id==="createdAt"&&h.getState().sorting[0]?.id!=="createdAt"&&h.setSorting([{id:"createdAt",desc:!1}])},[h.getState().columnFilters[0]?.id]);async function m(y,T){const w=v("Created At"),S=v("Updated At"),I=v("Content"),E=v("Path"),L=y.map(F=>({[w]:F.createdAt,[S]:F.updatedAt,[I]:F.content,Thino:`=hyperlink("obsidian://thino?openId=${F.id}","${F.id}")`,[E]:`=hyperlink("obsidian://open?path=${k.normalizePath(F.path)},"${F.path}")`})),C=AY(RY)(L),R=Ve.getState().app||window.app,M=FY(EY(C));return{file:await R.vault.create(`${T}-${Ne.randomId(6)}.csv`,M),app:R}}async function g(y){const{file:T,app:w}=await m(y.map(E=>E.original),"thino-export"),S=document.createDocumentFragment(),I=S.createEl("div",{cls:"export-file-btn-group"});S.createEl("div",{cls:"open-file-button"}),new k.Setting(I).setName(v("Exported CSV file")).addButton(E=>{E.setButtonText(v("Open File")).onClick(()=>{const L=k.normalizePath(T.path);w.openWithDefaultApp(L)})}),new k.Notice(S)}return p.jsxs("div",{className:"table-view",children:[p.jsxs("div",{children:[p.jsx(tf,{value:o||"",onChange:y=>r(String(y)),className:"table-search-bar",placeholder:v("Search all columns...")}),k.Platform.isDesktop&&(o||n.length>0||e)&&p.jsx("button",{className:"mod-cta",disabled:h.getPrePaginationRowModel().rows.length===0,onClick:()=>g(h.getPrePaginationRowModel().rows),children:v("Export to CSV")})]}),p.jsxs("table",{className:"thino-table",children:[p.jsx("thead",{children:h.getHeaderGroups().map(y=>p.jsx("tr",{children:y.headers.map(T=>p.jsx("th",{colSpan:T.colSpan,children:T.isPlaceholder?null:p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:Ct(T.column.getCanSort()?"filter-header":"","table-header",T.column.id==="content"?"content-header":""),onClick:T.column.getToggleSortingHandler(),children:[qD(T.column.columnDef.header,T.getContext()),{asc:" 🔼",desc:" 🔽"}[T.column.getIsSorted()]??null]}),T.column.getCanFilter()?p.jsx(BY,{column:T.column,table:h}):null]})},T.id))},y.id))}),p.jsx("tbody",{children:h.getRowModel().rows.map(y=>p.jsx("tr",{className:Ct(y.getValue("pinned")?"pinned":""),children:y.getVis
|
|||
|
|
`,R.current,l.path,a)}j()},[C,R,t,a,l,r]),x.useEffect(()=>{S&&(I(!1),L(""),setTimeout(async()=>{await M()},Vb))},[e,m,g,y,T,w]),x.useEffect(()=>{S||setTimeout(async()=>{await M()},Vb)},[]);const{memos:O}=rt.getState().memoState,F=uV(O);return p.jsxs("div",{className:Ct("memo-container",e),ref:C,style:{fontFamily:m!=="default"?m:void 0},children:[p.jsx(cr,{when:E!=="",children:p.jsx("img",{className:"memo-shortcut-img",onClick:h,src:E})}),p.jsxs("div",{className:"memo-background",children:[p.jsx("div",{className:"property-image",style:{backgroundSize:"cover",backgroundRepeat:"no-repeat",backgroundPosition:"center"}}),p.jsx("span",{className:"background-container"}),p.jsxs("div",{className:"thino-user-header",children:[p.jsx("div",{className:"thino-user-icon",ref:j=>{if(c?.MomentsIcon){j?.empty();return}c?.MomentsIcon||j&&k.setIcon(j,"Memos")},style:{backgroundImage:`url("${n}")`}}),p.jsxs("div",{className:"thino-user-info",children:[p.jsx("div",{className:"thino-user-name",children:c?.UserName}),c?.MomentsQuote&&p.jsx("div",{className:"thino-user-quote",children:c?.MomentsQuote})]})]}),p.jsx("div",{ref:R,className:"memo-content-text",style:{minHeight:c.MinHeightForShare||"200px",fontSize:`${w}px`}}),p.jsx("div",{className:"thino-time-footer",children:t.createdAt}),p.jsxs("div",{className:"watermark-container",children:[p.jsx("span",{className:"normal-text footer-start",children:y==="heatmap"?p.jsx("div",{className:"footer-heatmap",children:p.jsx(dV,{data:F})}):p.jsxs(p.Fragment,{children:[p.jsx("div",{className:"property-social-icons"}),p.jsx("span",{className:"name-text",children:i})]})}),p.jsx("span",{className:"normal-text footer-end",children:p.jsx("span",{className:"name-text",children:T||"THINO"})})]})]})]})},fV=t=>{const{memo:e,destroy:n}=t,{memos:i}=rt.getState().memoState,{view:o,app:r,settings:a,verifyState:l}=rt.getState().dailyNotesState,c={...e,createdAtStr:Ne.getDateTimeString(e.createdAt)},[d,h]=x.useState(!1),m=x.useRef(null),g=x.useRef(null),y=x.useRef(null),[T,w]=x.useState(t.style||(r||window.app).loadLocalStorage("memoShareDialogStyle")||"clean"),[S,I]=x.useState(""),[E,L]=x.useState((r||window.app).loadLocalStorage("memoShareDialogFont")||"default"),[C,R]=x.useState((r||window.app).loadLocalStorage("memoShareDialogBackground")||"default"),M=x.useRef(null),[O,F]=x.useState((r||window.app).loadLocalStorage("memoShareDialogLeftContent")||"default"),[j,z]=x.useState((r||window.app).loadLocalStorage("memoShareDialogRightContent")||""),[_,V]=x.useState(parseInt((r||window.app).loadLocalStorage("memoShareDialogFontSize")||"14")),[G,Z]=J.useState(a?.MomentsIcon),ee=[{value:"default",label:v("Default font")},{value:"serif",label:"Serif"},{value:"sans-serif",label:"Sans Serif"},{value:"monospace",label:"Monospace"},{value:"Georgia",label:"Georgia"},{value:"Times New Roman",label:"Times New Roman"},{value:"Arial",label:"Arial"},{value:"Helvetica",label:"Helvetica"},{value:"Courier New",label:"Courier New"}],$=[{value:"default",label:v("Default background")},{value:"custom",label:v("Select local image")},{value:"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNDAwIiBoZWlnaHQ9IjQwMCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZGVmcz48bGluZWFyR3JhZGllbnQgaWQ9ImEiIHgxPSIwJSIgeTE9IjAlIiB4Mj0iMTAwJSIgeTI9IjEwMCUiPjxzdG9wIG9mZnNldD0iMCUiIHN0b3AtY29sb3I9IiNmZmNkYjIiLz48c3RvcCBvZmZzZXQ9IjEwMCUiIHN0b3AtY29sb3I9IiNmZmI3YjciLz48L2xpbmVhckdyYWRpZW50PjwvZGVmcz48cmVjdCB3aWR0aD0iNDAwIiBoZWlnaHQ9IjQwMCIgZmlsbD0idXJsKCNhKSIvPjwvc3ZnPg==",label:v("Orange gradient")},{value:"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNDAwIiBoZWlnaHQ9IjQwMCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZGVmcz48bGluZWFyR3JhZGllbnQgaWQ9ImIiIHgxPSIwJSIgeTE9IjAlIiB4Mj0iMTAwJSIgeTI9IjEwMCUiPjxzdG9wIG9mZnNldD0iMCUiIHN0b3AtY29sb3I9IiNhZGJlZmYiLz48c3RvcCBvZmZzZXQ9IjEwMCUiIHN0b3AtY29sb3I9IiNhM2E4ZjUiLz48L2xpbmVhckdyYWRpZW50PjwvZGVmcz48cmVjdCB3aWR0aD0iNDAwIiBoZWlnaHQ9IjQwMCIgZmlsbD0idXJsKCNiKSIvPjwvc3ZnPg==",label:v("Blue gradient")},{value:"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNDAwIiBoZWlnaHQ9IjQwMCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZGV
|
|||
|
|
`,a.current,o.path,i),a.current?.querySelectorAll(".internal-link")?.forEach(E=>{const L=E,C=L.getAttribute("data-href");if(!C)return;e.metadataCache.getFirstLinkpathDest(C,o.path)||E.classList.add("is-unresolved"),L.addEventListener("mouseover",M=>{M.stopPropagation(),e.workspace.trigger("hover-link",{event:M,source:"thino",hoverParent:i.containerEl,targetEl:L,linktext:C,sourcePath:L.href})})})}S()},[o.content,l]);const g=async()=>{switch(h.sourceType){case"DAILY":await F0(h.id,h.path);break;case"CANVAS":await H0(h.id,h.path);break;case"MULTI":await R0(h.path);break;case"FILE":await j0(h.id,h.path);break}},y=async()=>{try{if(n.DeleteThinoDirectly)await he.deleteMemoById(h.id);else{const S=await he.hideMemoById(h.id);S&&he.editMemo(S)}}catch(S){new k.Notice(S.message)}},T=async()=>{try{const S=await he.unarchiveMemo(h);S&&he.editMemo(S),r(h.id),new k.Notice(v("RESTORE SUCCEED"))}catch(S){new k.Notice(S.message)}},w=S=>{S.stopPropagation();const I=new k.Menu;I.addItem(E=>{E.setTitle(v("RESTORE")).setIcon("archive-restore").onClick(T)}),I.addItem(E=>{E.setTitle(v("SOURCE")).setIcon("home").onClick(g)}),I.addItem(E=>{E.setTitle(v("DELETE")).setIcon("trash").setWarning(!0).onClick(()=>{const L=new k.Menu;L.addItem(C=>{C.setTitle(v("CONFIRM!")).setIcon("trash").setWarning(!0).onClick(y)}),L.addItem(C=>{C.setTitle(v("Cancel")).setIcon("x").onClick(()=>{})}),L.showAtMouseEvent(S.nativeEvent)})}),I.showAtMouseEvent(S.nativeEvent)};return p.jsxs("div",{ref:l,className:`memo-wrapper ${"memos-"+h.id}`,children:[p.jsxs("div",{className:"memo-top-wrapper",children:[p.jsxs("span",{className:"time-text",children:[v("ARCHIVED AT")," ",h.updatedAt]}),p.jsx("div",{className:"btns-container",children:p.jsx("span",{ref:m,className:"btn more-action-btn",onClick:w})})]}),p.jsx("div",{ref:a,className:"memo-content-text"})]})},_r=({title:t,showSidebar:e=!1,onShowSidebarClick:n,showHomeButton:i=!0,children:o,rightContent:r})=>{const a=x.useCallback(()=>{n?n():We.setShowSiderbarInMobileView(!0)},[n]),l=x.useCallback(()=>{Le.clearQuery(),Le.setPathname("/")},[]);return p.jsxs("div",{className:"section-header-container",children:[p.jsx("div",{className:"title-wrapper",children:p.jsx("div",{className:"title-btns-left-wrapper",children:p.jsxs("div",{className:"title-text",children:[e&&p.jsx(cr,{when:!0,children:p.jsx("button",{ref:c=>{c&&k.setIcon(c,"menu")},className:"btn action-btn clickable-icon",onClick:a})}),t&&p.jsx("span",{className:"normal-text",children:t}),i&&p.jsxs("button",{className:"go-home-btn",onClick:l,children:["🏠 ",v("Return To Home Page")]}),o]})})}),r&&p.jsx("div",{className:"title-btns-right-wrapper",children:r})]})},zr=t=>{const e=new Map;for(const n of t){const i=n.path;e.has(i)||e.set(i,[]),e.get(i)?.push(n)}return Array.from(e).map(([n,i])=>({path:n,thinos:i}))},mV=()=>{const{query:t}=yt(),{isMobileView:e}=Tt(),{memos:n}=nt(),{plugin:i}=Ke(),o=Jr(),[r,a]=x.useState([]),l=J.useRef(null),c=J.useRef(null);x.useEffect(()=>{c.current&&k.setIcon(c.current,"more-horizontal")},[c]),x.useEffect(()=>{xa({memos:n,query:t,filterOptions:{filterDoneTasks:!1,onlyFilterType:"archived"},plugin:i}).then(T=>{a(T)}),o.setFinish()},[n,l.current,t]);const d=x.useCallback(T=>{a(w=>w.filter(S=>S.id!==T))},[]),h=x.useCallback(T=>{a(w=>w.filter(S=>S.id!==T))},[]);x.useCallback(()=>{We.setShowSiderbarInMobileView(!0)},[]);const m=async()=>{if(!(r?.length>0))return;if(!await nr()){wt();return}const T=[...r];try{const w=T.filter(L=>L.sourceType==="DAILY"),S=T.filter(L=>L.sourceType!=="DAILY"),I=await he.unarchiveThinoBulk(S);for(const L of I)L&&he.editMemo(L);const E=zr(w);for(const{path:L,thinos:C}of E)await he.dealWithDailyThinoBulk(L,C,"restoreFromArchive");new k.Notice(v("RESTORE SUCCEED")),Le.clearQuery()}catch(w){console.error("error",w),new k.Notice(w.message)}},g=async()=>{if(!(r?.length>0))return;if(!await nr()){wt();return}const T=[...r],w=Ve.getState().settings.DeleteThinoDirectly;try{const S=T.filter(L=>L.sourceType==="DAILY"),I=T.filter(L=>L.sourceType!=="DAILY");for(const L of I)if(w)await he.deleteMemoById(L.id);else{const C=await h
|
|||
|
|
${Z.content.split(`
|
|||
|
|
`).map($=>$.trim()?`> ${$}
|
|||
|
|
`:`>
|
|||
|
|
`)}
|
|||
|
|
|
|||
|
|
`+(ee===e.length-1?`
|
|||
|
|
|
|||
|
|
`:`
|
|||
|
|
|
|||
|
|
------
|
|||
|
|
|
|||
|
|
`)});const G={createdAt:k.moment().format("YYYY/MM/DD HH:mm:ss"),updatedAt:k.moment().format("YYYY/MM/DD HH:mm:ss"),content:V.replace(/(^|\n),>/g,`
|
|||
|
|
>`),id:"temp-"+Math.random().toString(36).substr(2,9),thinoType:"JOURNAL",sourceType:"DAILY",rowStatus:"NORMAL",visibility:"PRIVATE",pinned:!1,creatorName:"thino",deletedAt:"",path:"",resourceList:[]};ys(G,"clean")})}),z.addSeparator(),o){case"/":z.addItem(_=>{_.setTitle(v("Bulk tag operation")).setIcon("hash").onClick(async()=>{await M()})}).addItem(_=>{_.setTitle(v("Bulk archive")).setIcon("archive").onClick(async()=>{new Io(a,v("ARCHIVE"),async V=>{V==="confirm"&&await R()}).open()})}).addItem(_=>{_.setTitle(v("Bulk delete")).setIcon("trash").onClick(async()=>{new Io(a,v("DELETE"),async V=>{V==="confirm"&&await I()}).open()})});break;case"/archive":z.addItem(_=>{_.setTitle(v("Bulk restore")).setIcon("archive").onClick(async()=>{new Io(a,v("RESTORE"),async V=>{V==="confirm"&&await L()}).open()})}).addItem(_=>{_.setTitle(v("Bulk delete")).setIcon("trash").onClick(async()=>{new Io(a,v("DELETE"),async V=>{V==="confirm"&&await I()}).open()})});break;case"/recycle":z.addItem(_=>{_.setTitle(v("Bulk restore")).setIcon("archive-restore").onClick(async()=>{new Io(a,v("RESTORE"),async V=>{V==="confirm"&&await C()}).open()})}).addItem(_=>{_.setTitle(v("Bulk delete")).setIcon("trash").onClick(async()=>{new Io(a,v("DELETE"),async V=>{V==="confirm"&&await E()}).open()})});break}z.showAtMouseEvent(j.nativeEvent)};return p.jsxs("div",{className:`filter-query-container ${T?"":"thino-hidden"}`,children:[p.jsxs("div",{className:"filter-query",children:[p.jsx("span",{className:"tip-text",children:v("FILTER")}),p.jsxs("div",{"data-filter-type":"query",className:"filter-item-container "+(y?"":"thino-hidden"),onClick:()=>{Le.setMemoFilter("")},children:[p.jsx("span",{className:"icon-text",children:"🔖"})," ",y?.title]}),p.jsxs("div",{"data-filter-type":"tag",className:"filter-item-container "+(l?"":"thino-hidden"),onClick:()=>{Le.setTagQuery("")},children:[p.jsx("span",{className:"icon-text",children:"🏷️"})," ",l]}),p.jsxs("div",{"data-filter-type":"type",className:"filter-item-container "+(d?"":"thino-hidden"),onClick:()=>{Le.setMemoTypeQuery("")},children:[p.jsx("span",{className:"icon-text",children:"📦"})," ",w5(d)]}),c&&c.from<c.to&&p.jsxs("div",{"data-filter-type":"date",className:"filter-item-container",children:[p.jsxs("div",{className:"day-picker-component-group",children:[p.jsx("span",{className:"icon-text",children:"🗓️"})," ",p.jsx(kf,{type:"text",startOrEnd:"start",defaultValue:k.moment(c.from,"x").valueOf(),handleValueChange:j=>{const z=k.moment(c.to,"x"),_=k.moment(j,"x"),V=_.isAfter(z)||_.isSame(z);Le.setFromAndToQuery(V?z.startOf("day").valueOf():k.moment(j,"x").startOf("day").valueOf(),c.to)}}),p.jsx("span",{children:v("to")}),p.jsx(kf,{type:"text",startOrEnd:"end",defaultValue:k.moment(c.to,"x").add(1,"days").valueOf(),handleValueChange:j=>{const z=k.moment(c.from,"x"),_=k.moment(j,"x"),V=_.isBefore(z)||_.isSame(z),G=k.moment(j,"x").endOf("day").valueOf();Le.setFromAndToQuery(c.from,V?z.endOf("day").valueOf():G)}})]}),p.jsx("div",{ref:j=>j&&k.setIcon(j,"x"),className:"btn close-btn",onClick:()=>{Le.setFromAndToQuery(0,0)}})]}),p.jsxs("div",{className:"filter-item-container "+(h?"":"thino-hidden"),onClick:()=>{Le.setTextQuery("")},children:[p.jsx("span",{className:"icon-text",children:"🔍"})," ",h]}),p.jsxs("div",{className:"filter-item-container "+(g?"":"thino-hidden"),onClick:()=>{Le.setPathQuery("")},children:[p.jsx("span",{className:"icon-text",children:"📦"})," ",p.jsx("span",{className:"path-text",children:g})]})]}),p.jsxs("div",{className:"thino-filter-items",children:[t&&p.jsx("div",{className:"thinos-count",children:`${t?`${t} Thinos `:""}`}),p.jsx("div",{ref:w,className:"btn memo-action-menu",onClick:F})]})]})},vs=async t=>{const{app:e,settings:n}=Ve.getState();if(!n.startSync||!e?.loadLocalStorage("tokenForSync"))return;const i=await PO(t);if(!i||i.length===0)return;i.sort((a,l)=>k.moment(a.createdAt,"YYYY/MM/DD HH:mm:ss").isAfter(k.moment(l.createdAt,"YYYY/MM/DD HH:mm:ss"))?1:-1);const o=i.filter(a=>!a.deleted),r=i.filter(a=>a.deleted);for(let a=0;a<o.length;a++){const l=o[a],c=await he.createO
|
|||
|
|
`&&A.push(`
|
|||
|
|
`),ge!==null&&A.push(T(""+ge)),null;case"input":A.push(V("input")),qe=vt=Ye=ge=null;for(Ce in q)if(n.call(q,Ce)&&(ht=q[Ce],ht!=null))switch(Ce){case"children":case"dangerouslySetInnerHTML":throw Error(e(399,"input"));case"defaultChecked":qe=ht;break;case"defaultValue":Ye=ht;break;case"checked":vt=ht;break;case"value":ge=ht;break;default:M(A,X,Ce,ht)}return vt!==null?M(A,X,"checked",vt):qe!==null&&M(A,X,"checked",qe),ge!==null?M(A,X,"value",ge):Ye!==null&&M(A,X,"value",Ye),A.push("/>"),null;case"menuitem":A.push(V("menuitem"));for(var ai in q)if(n.call(q,ai)&&(ge=q[ai],ge!=null))switch(ai){case"children":case"dangerouslySetInnerHTML":throw Error(e(400));default:M(A,X,ai,ge)}return A.push(">"),null;case"title":A.push(V("title")),ge=null;for(Vt in q)if(n.call(q,Vt)&&(Ce=q[Vt],Ce!=null))switch(Vt){case"children":ge=Ce;break;case"dangerouslySetInnerHTML":throw Error(e(434));default:M(A,X,Vt,Ce)}return A.push(">"),ge;case"listing":case"pre":A.push(V(B)),Ce=ge=null;for(qe in q)if(n.call(q,qe)&&(Ye=q[qe],Ye!=null))switch(qe){case"children":ge=Ye;break;case"dangerouslySetInnerHTML":Ce=Ye;break;default:M(A,X,qe,Ye)}if(A.push(">"),Ce!=null){if(ge!=null)throw Error(e(60));if(typeof Ce!="object"||!("__html"in Ce))throw Error(e(61));q=Ce.__html,q!=null&&(typeof q=="string"&&0<q.length&&q[0]===`
|
|||
|
|
`?A.push(`
|
|||
|
|
`,q):A.push(""+q))}return typeof ge=="string"&&ge[0]===`
|
|||
|
|
`&&A.push(`
|
|||
|
|
`),ge;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":A.push(V(B));for(var si in q)if(n.call(q,si)&&(ge=q[si],ge!=null))switch(si){case"children":case"dangerouslySetInnerHTML":throw Error(e(399,B));default:M(A,X,si,ge)}return A.push("/>"),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 j(A,q,B,X);case"html":return Se.insertionMode===0&&A.push("<!DOCTYPE html>"),j(A,q,B,X);default:if(B.indexOf("-")===-1&&typeof q.is!="string")return j(A,q,B,X);A.push(V(B)),Ce=ge=null;for(ht in q)if(n.call(q,ht)&&(Ye=q[ht],Ye!=null))switch(ht){case"children":ge=Ye;break;case"dangerouslySetInnerHTML":Ce=Ye;break;case"style":R(A,X,Ye);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":break;default:a(ht)&&typeof Ye!="function"&&typeof Ye!="symbol"&&A.push(" ",ht,'="',T(Ye),'"')}return A.push(">"),O(A,Ce,ge),ge}}function Z(A,B,q){if(A.push('<!--$?--><template id="'),q===null)throw Error(e(395));return A.push(q),A.push('"></template>')}function ee(A,B,q,X){switch(q.insertionMode){case 0:case 1:return A.push('<div hidden id="'),A.push(B.segmentPrefix),B=X.toString(16),A.push(B),A.push('">');case 2:return A.push('<svg aria-hidden="true" style="display:none" id="'),A.push(B.segmentPrefix),B=X.toString(16),A.push(B),A.push('">');case 3:return A.push('<math aria-hidden="true" style="display:none" id="'),A.push(B.segmentPrefix),B=X.toString(16),A.push(B),A.push('">');case 4:return A.push('<table hidden id="'),A.push(B.segmentPrefix),B=X.toString(16),A.push(B),A.push('">');case 5:return A.push('<table hidden><tbody id="'),A.push(B.segmentPrefix),B=X.toString(16),A.push(B),A.push('">');case 6:return A.push('<table hidden><tr id="'),A.push(B.segmentPrefix),B=X.toString(16),A.push(B),A.push('">');case 7:return A.push('<table hidden><colgroup id="'),A.push(B.segmentPrefix),B=X.toString(16),A.push(B),A.push('">');default:throw Error(e(397))}}function $(A,B){switch(B.insertionMode){case 0:case 1:return A.push("</div>");case 2:return A.push("</svg>");case 3:return A.push("</math>");case 4:return A.push("</table>");case 5:return A.push("</tbody></table>");case 6:return A.push("</tr></table>");case 7:return A.push("</colgroup></table>");default:throw Error(e(397))}}var re=/[<\u2028\u2029]/g;function ne(A){return JSON.stringify(A).replace(re,function(B){switch(B){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 longer in sync. This is a bug in React")}})}function ie(A,B){return B=B===void 0?"":B,{bootstrapChunks:[],startInlineScript:"<script>",placeholderPrefix:B+"P:",segmentPrefix:B+"S:",boundaryPrefix:B+"B:",idPrefix:B,nextSuspenseID:0,sentCompleteSegmentFunction:!1,sentCompleteBoundaryFunction:!1,sentClientRenderFunction:!1,generateStaticMarkup:A}}function pe(A,B,q,X){return q.generateStaticMarkup?(A.push(T(B)),!1):(B===""?A=X:(X&&A.push("<!-- -->"),A.push(T(B)),A=!0),A)}var Y=Object.assign,K=Symbol.for("react.element"),ce=Symbol.for("react.portal"),ue=Symbol.for("react.fragment"),te=Symbol.for("react.strict_mode"),ae=Symbol.for("react.profiler"),Ee=Symbol.for("react.provider"),xe=Symbol.for("react.context"),Fe=Symbol.for("react.forward_ref"),Ge=Symbol.for("react.suspense"),at=Symbol.for("react.suspense_list"),Dt=Symbol.for("react.memo"),Me=Symbol.for("react.lazy"),ye=Symbol.for("react.scope"),Ae=Symbol.for("react.debug_trace_mode"),de=Symbol.for("react.legacy_hidden"),se=Symbol.for("react.default_value"),Pe=Symbol.iterator;function Oe(A){if(A==null)return null;if(typeof A=="function")return A.displayName||A.name||null;if(typeof A=="string")return A;switch(A){case ue:return"Fragment";case ce:return"Portal";case ae:return"Profiler";case te:return"StrictMode";case Ge:return"Suspense";case at:return"Suspe
|
|||
|
|
`),$e=/^[a-zA-Z][a-zA-Z:_\.\-\d]*$/,it=new Map;function ot(N){var H=it.get(N);if(H===void 0){if(!$e.test(N))throw Error(e(65,N));H=d("<"+N),it.set(N,H)}return H}var It=d("<!DOCTYPE html>");function ft(N,H,W,Q,Ie){switch(H){case"select":N.push(ot("select"));var we=null,De=null;for(mt in W)if(m.call(W,mt)){var Ue=W[mt];if(Ue!=null)switch(mt){case"children":we=Ue;break;case"dangerouslySetInnerHTML":De=Ue;break;case"defaultValue":case"value":break;default:Me(N,Q,mt,Ue)}}return N.push(ye),de(N,De,we),we;case"option":De=Ie.selectedValue,N.push(ot("option"));var dt=Ue=null,St=null,mt=null;for(we in W)if(m.call(W,we)){var Zt=W[we];if(Zt!=null)switch(we){case"children":Ue=Zt;break;case"selected":St=Zt;break;case"dangerouslySetInnerHTML":mt=Zt;break;case"value":dt=Zt;default:Me(N,Q,we,Zt)}}if(De!=null)if(W=dt!==null?""+dt:se(Ue),z(De)){for(Q=0;Q<De.length;Q++)if(""+De[Q]===W){N.push(Pe);break}}else""+De===W&&N.push(Pe);else St&&N.push(Pe);return N.push(ye),de(N,mt,Ue),Ue;case"textarea":N.push(ot("textarea")),mt=De=we=null;for(Ue in W)if(m.call(W,Ue)&&(dt=W[Ue],dt!=null))switch(Ue){case"children":mt=dt;break;case"value":we=dt;break;case"defaultValue":De=dt;break;case"dangerouslySetInnerHTML":throw Error(e(91));default:Me(N,Q,Ue,dt)}if(we===null&&De!==null&&(we=De),N.push(ye),mt!=null){if(we!=null)throw Error(e(92));if(z(mt)&&1<mt.length)throw Error(e(93));we=""+mt}return typeof we=="string"&&we[0]===`
|
|||
|
|
`&&N.push(Be),we!==null&&N.push(c(O(""+we))),null;case"input":N.push(ot("input")),dt=mt=Ue=we=null;for(De in W)if(m.call(W,De)&&(St=W[De],St!=null))switch(De){case"children":case"dangerouslySetInnerHTML":throw Error(e(399,"input"));case"defaultChecked":dt=St;break;case"defaultValue":Ue=St;break;case"checked":mt=St;break;case"value":we=St;break;default:Me(N,Q,De,St)}return mt!==null?Me(N,Q,"checked",mt):dt!==null&&Me(N,Q,"checked",dt),we!==null?Me(N,Q,"value",we):Ue!==null&&Me(N,Q,"value",Ue),N.push(Ae),null;case"menuitem":N.push(ot("menuitem"));for(var _n in W)if(m.call(W,_n)&&(we=W[_n],we!=null))switch(_n){case"children":case"dangerouslySetInnerHTML":throw Error(e(400));default:Me(N,Q,_n,we)}return N.push(ye),null;case"title":N.push(ot("title")),we=null;for(Zt in W)if(m.call(W,Zt)&&(De=W[Zt],De!=null))switch(Zt){case"children":we=De;break;case"dangerouslySetInnerHTML":throw Error(e(434));default:Me(N,Q,Zt,De)}return N.push(ye),we;case"listing":case"pre":N.push(ot(H)),De=we=null;for(dt in W)if(m.call(W,dt)&&(Ue=W[dt],Ue!=null))switch(dt){case"children":we=Ue;break;case"dangerouslySetInnerHTML":De=Ue;break;default:Me(N,Q,dt,Ue)}if(N.push(ye),De!=null){if(we!=null)throw Error(e(60));if(typeof De!="object"||!("__html"in De))throw Error(e(61));W=De.__html,W!=null&&(typeof W=="string"&&0<W.length&&W[0]===`
|
|||
|
|
`?N.push(Be,c(W)):N.push(c(""+W)))}return typeof we=="string"&&we[0]===`
|
|||
|
|
`&&N.push(Be),we;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":N.push(ot(H));for(var di in W)if(m.call(W,di)&&(we=W[di],we!=null))switch(di){case"children":case"dangerouslySetInnerHTML":throw Error(e(399,H));default:Me(N,Q,di,we)}return N.push(Ae),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 Oe(N,W,H,Q);case"html":return Ie.insertionMode===0&&N.push(It),Oe(N,W,H,Q);default:if(H.indexOf("-")===-1&&typeof W.is!="string")return Oe(N,W,H,Q);N.push(ot(H)),De=we=null;for(St in W)if(m.call(W,St)&&(Ue=W[St],Ue!=null))switch(St){case"children":we=Ue;break;case"dangerouslySetInnerHTML":De=Ue;break;case"style":xe(N,Q,Ue);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":break;default:w(St)&&typeof Ue!="function"&&typeof Ue!="symbol"&&N.push(Fe,c(St),Ge,c(O(Ue)),at)}return N.push(ye),de(N,De,we),we}}var Bt=d("</"),kt=d(">"),Ot=d('<template id="'),sn=d('"></template>'),Gt=d("<!--$-->"),Xt=d('<!--$?--><template id="'),Yt=d('"></template>'),Mt=d("<!--$!-->"),Cn=d("<!--/$-->"),gr=d("<template"),Ra=d('"'),Fa=d(' data-dgst="');d(' data-msg="'),d(' data-stck="');var ja=d("></template>");function Bn(N,H,W){if(o(N,Xt),W===null)throw Error(e(395));return o(N,W),r(N,Yt)}var yr=d('<div hidden id="'),xi=d('">'),Nt=d("</div>"),Ao=d('<svg aria-hidden="true" style="display:none" id="'),vr=d('">'),No=d("</svg>"),Ci=d('<math aria-hidden="true" style="display:none" id="'),wr=d('">'),Di=d("</math>"),Ha=d('<table hidden id="'),lo=d('">'),br=d("</table>"),Po=d('<table hidden><tbody id="'),Ys=d('">'),Lo=d("</tbody></table>"),Qr=d('<table hidden><tr id="'),Xr=d('">'),Oo=d("</tr></table>"),Vs=d('<table hidden><colgroup id="'),ea=d('">'),Ba=d("</colgroup></table>");function co(N,H,W,Q){switch(W.insertionMode){case 0:case 1:return o(N,yr),o(N,H.segmentPrefix),o(N,c(Q.toString(16))),r(N,xi);case 2:return o(N,Ao),o(N,H.segmentPrefix),o(N,c(Q.toString(16))),r(N,vr);case 3:return o(N,Ci),o(N,H.segmentPrefix),o(N,c(Q.toString(16))),r(N,wr);case 4:return o(N,Ha),o(N,H.segmentPrefix),o(N,c(Q.toString(16))),r(N,lo);case 5:return o(N,Po),o(N,H.segmentPrefix),o(N,c(Q.toString(16))),r(N,Ys);case 6:return o(N,Qr),o(N,H.segmentPrefix),o(N,c(Q.toString(16))),r(N,Xr);case 7:return o(N,Vs),o(N,H.segmentPrefix),o(N,c(Q.toString(16))),r(N,ea);default:throw Error(e(397))}}function Ro(N,H){switch(H.insertionMode){case 0:case 1:return r(N,Nt);case 2:return r(N,No);case 3:return r(N,Di);case 4:return r(N,br);case 5:return r(N,Lo);case 6:return r(N,Oo);case 7:return r(N,Ba);default:throw Error(e(397))}}var Ws=d('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("'),za=d('$RS("'),Sr=d('","'),Fo=d('")<\/script>'),Tr=d('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("'),Ua=d('$RC("'),qs=d('","'),Gs=d('")<\/script>'),$t=d('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("'),Ln=d('$RX("'),ta=d('"'),na=d(")<\/script>"),jo=d(","),$s=/[<\u2028\u2029]/g;function uo(N){return JSON.stringify(N).replace($s,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 longer in sy
|
|||
|
|
`,r.current,e.path,T),r.current?.querySelectorAll(".internal-link")?.forEach(I=>{const E=I,L=E.getAttribute("data-href");if(!L)return;i.app.metadataCache.getFirstLinkpathDest(L,e.path)||I.classList.add("is-unresolved"),E.addEventListener("mouseover",R=>{R.stopPropagation(),i.app.workspace.trigger("hover-link",{event:R,source:"thino",hoverParent:T.containerEl,targetEl:E,linktext:L,sourcePath:E.href})})})}w()},[e.content,a]);const h=async()=>{try{await he.deleteMemoById(o.id),n(o.id)}catch(T){new k.Notice(T.message)}},m=async()=>{switch(o.sourceType){case"DAILY":await F0(o.id,o.path);break;case"CANVAS":await H0(o.id,o.path);break;case"MULTI":await R0(o.path);break;case"FILE":await j0(o.id,o.path);break}},g=async()=>{try{const T=await he.restoreMemoById(o.id),S=i.app?.loadLocalStorage("tokenForSync");T&&T.webId&&S&&i.settings.startSync&&await ku(T.webId),T&&he.editMemo(T),n(o.id),new k.Notice(v("RESTORE SUCCEED"))}catch(T){new k.Notice(T.message)}},y=T=>{T.stopPropagation();const w=new k.Menu;w.addItem(S=>{S.setTitle(v("RESTORE")).setIcon("archive-restore").onClick(g)}),w.addItem(S=>{S.setTitle(v("SOURCE")).setIcon("home").onClick(m)}),w.addItem(S=>{S.setTitle(v("DELETE")).setIcon("trash").setWarning(!0).onClick(()=>{const I=new k.Menu;I.addItem(E=>{E.setTitle(v("CONFIRM!")).setIcon("trash").setWarning(!0).onClick(h)}),I.addItem(E=>{E.setTitle(v("Cancel")).setIcon("x").onClick(()=>{})}),I.showAtMouseEvent(T.nativeEvent)})}),w.showAtMouseEvent(T.nativeEvent)};return p.jsxs("div",{ref:a,className:`memo-wrapper ${"memos-"+o.id}`,children:[p.jsxs("div",{className:"memo-top-wrapper",children:[p.jsxs("span",{className:"time-text",children:[v("DELETE AT")," ",o.deletedAtStr]}),p.jsx("div",{className:"btns-container",children:p.jsx("span",{ref:d,className:"btn more-action-btn",onClick:y})})]}),p.jsx("div",{ref:r,className:"memo-content-text",onContextMenu:T=>{T.preventDefault(),T.stopPropagation()}})]})},ZS=({isLoading:t,isEmpty:e,emptyMessage:n=v("Here is No Memos.")})=>t?p.jsx("div",{className:"tip-text-container",children:p.jsx("span",{className:"tip-text",children:v("Fetching data...")})}):e?p.jsx("div",{className:"tip-text-container",children:p.jsx("span",{className:"tip-text",children:n})}):null,sW=()=>{const{query:t}=yt(),{isMobileView:e}=Tt(),{memos:n}=nt(),{app:i,plugin:o}=Ke(),r=Jr(),[a,l]=x.useState([]),c=J.useRef(null),d=J.useRef(null);x.useEffect(()=>{d.current&&k.setIcon(d.current,"more-horizontal")},[d]),x.useEffect(()=>{xa({memos:n,query:t,filterOptions:{filterDoneTasks:!1,onlyFilterType:"deleted"},plugin:o}).then(w=>{l(w)}),r.setFinish()},[n,c.current,t]);const h=x.useCallback(w=>{l(S=>S.filter(I=>I.id!==w))},[]),m=async()=>{if(!(a?.length>0))return;if(!await nr()){wt();return}const w=[...a],S=Ve.getState().settings.startSync,I=i?.loadLocalStorage("tokenForSync");try{const E=w.filter(R=>R.sourceType==="DAILY"),L=w.filter(R=>R.sourceType!=="DAILY");for(const R of L){const M=await he.restoreMemoById(R.id);M&&M.webId&&I&&S&&await ku(M.webId),M&&he.editMemo(M)}const C=zr(E);for(const{path:R,thinos:M}of C){const O=await he.dealWithDailyThinoBulk(R,M,"restoreFromDelete");for(const F of O)F&&F.webId&&I&&S&&await ku(F.webId)}Le.clearQuery(),new k.Notice(v("RESTORE SUCCEED"))}catch(E){new k.Notice(E.message)}},g=async()=>{if(!(a?.length>0))return;if(!await nr()){wt();return}const w=[...a],S=Ve.getState().settings,I=i?.loadLocalStorage("tokenForSync");try{const E=w.filter(R=>R.sourceType==="DAILY"),L=w.filter(R=>R.sourceType!=="DAILY");for(const R of L)await he.deleteMemoById(R.id);const C=zr(E);for(const{path:R,thinos:M}of C){const O=await he.dealWithDailyThinoBulk(R,M,"deleteForever");if(!(!I||!S.startSync))for(const F of O)F&&F.webId&&await O0(F.webId)}Le.clearQuery(),new k.Notice(v("DELETE SUCCEED"))}catch(E){console.error("error",E),new k.Notice(E.message)}},y=w=>{const S=new k.Menu;S.addItem(I=>{I.setTitle(v("Bulk restore")).setIcon("archive-restore").onClick(async()=>{new Io(i,v("RESTORE"),async E=>{E==="confirm"&&await m()}).open()})}).addItem(I=>{I.setTitle(v("Bulk delete")).setIcon("trash").onClick(async()=>{new
|
|||
|
|
-H "Authorization: ${this.authHeader}" \\
|
|||
|
|
-H "Content-Type: application/json" \\
|
|||
|
|
-d '{"text": "Hello from API", "type": "DAILY"}'`;const d=e.createDiv("expiry-info"),h=this.expiryHours>=24?`⏰ This token will expire in ${Math.floor(this.expiryHours/24)} day(s).`:`⏰ This token will expire in ${this.expiryHours} hour(s).`;d.createEl("p",{text:h,cls:"expiry-warning"});const m=e.createDiv("button-group"),g=m.createEl("button",{text:"Copy Token"});g.onclick=async()=>{await navigator.clipboard.writeText(this.token),new k.Notice("Token copied to clipboard")};const y=m.createEl("button",{text:"Copy Auth Header"});y.onclick=async()=>{await navigator.clipboard.writeText(this.authHeader),new k.Notice("Authorization header copied to clipboard")};const T=m.createEl("button",{text:"Close"});T.onclick=()=>this.close()}onClose(){const{contentEl:e}=this;e.empty()}}class LM extends k.Modal{constructor(e,n,i,o){super(e),this.cb=o,this.app=e,this.settingTab=n,this.plugin=i}plugin;settingTab;onOpen(){const{contentEl:e}=this;e.parentElement?.classList.add("memo-save-location-modal"),this.titleEl.toggleClass("modal-title",!0),this.titleEl.setText(v("Password for Thino")),e.createDiv("modal-desc",l=>{l.setText(v("Please input your password to change password settings"))});const n=e.createDiv("modal-setting"),i=new me(n,this.settingTab).setName(v("Password")).addText(l=>{l.setPlaceholder(v("Please input your password")).inputEl.type="password"}),o=e.createDiv("button-group"),r=o.createEl("button",{text:v("Cancel")}),a=o.createEl("button",{cls:"thino-password-confirm-btn",text:v("Confirm?").replace(/(\?|?)/g,"")});a.onclick=async()=>{i.controlEl.querySelector("input").value===this.plugin.settings.password?(this.cb?.(!0),this.close()):new k.Notice(v("Password is incorrect"))},r.onclick=async()=>{this.close()}}onClose(){const{contentEl:e}=this;e.empty()}}class qq extends k.Modal{plugin;constructor(e,n){super(e),this.plugin=n}onOpen(){const{contentEl:e}=this;e.parentElement?.classList.add("api-documentation-modal"),this.titleEl.setText("Thino API Documentation");const n=e.createDiv("api-doc-container"),i=n.createDiv("api-section");i.createEl("h2",{text:"Overview"}),i.createEl("p",{text:"The Thino HTTP API allows you to interact with your thinos programmatically. All endpoints require authentication using a Bearer token."});const o=i.createDiv("server-info");o.createEl("strong",{text:"Server Address: "}),o.createSpan({text:`http://${this.plugin.settings.HttpApiIpType}:${this.plugin.settings.HttpApiPort}`});const r=n.createDiv("api-section");r.createEl("h2",{text:"Authentication"}),r.createEl("p",{text:'All API requests require a Bearer token in the Authorization header. Generate a token using the "Generate Token" button above.'});const a=r.createDiv("code-example");a.createEl("h4",{text:"Authorization Header Format:"}),a.createEl("pre").createEl("code",{text:"Authorization: Bearer <your-token-here>"});const c=n.createDiv("api-section");c.createEl("h2",{text:"API Endpoints"}),this.createEndpointSection(c,{title:"Create Thino",method:"POST",endpoint:"/create",description:"Create a new thino with text content and optional images",parameters:[{name:"text",type:"string",required:!0,description:"The content of the thino"},{name:"isList",type:"boolean",required:!1,description:"Whether to format as list item (default: false)"},{name:"type",type:"string",required:!1,description:"Save location type (DAILY, CANVAS, MULTI, FILE)"},{name:"imageList",type:"array",required:!1,description:"Array of base64 encoded images"},{name:"sourceLink",type:"string",required:!1,description:"Source URL to append to the thino"}],examples:{curl:this.generateCurlExample("POST","/create",{text:"This is my new thino",isList:!1,type:"DAILY"}),python:this.generatePythonExample("POST","/create",{text:"This is my new thino",isList:!1,type:"DAILY"}),nodejs:this.generateNodeExample("POST","/create",{text:"This is my new thino",isList:!1,type:"DAILY"})}}),this.createEndpointSection(c,{title:"Search Thinos",method:"GET",endpoint:"/search",description:"Search for thinos containing specific keywords",parameters:[{name:"keyword",type:"string",required:!0,description
|
|||
|
|
-H "Authorization: Bearer <your-token>"`;return i&&e!=="GET"&&(r+=` \\
|
|||
|
|
-H "Content-Type: application/json" \\
|
|||
|
|
-d '${JSON.stringify(i,null,2)}'`),r}generatePythonExample(e,n,i){let r=`import requests
|
|||
|
|
import json
|
|||
|
|
|
|||
|
|
url = "${`http://${this.plugin.settings.HttpApiIpType}:${this.plugin.settings.HttpApiPort}`}${n}"
|
|||
|
|
headers = {
|
|||
|
|
"Authorization": "Bearer <your-token>"`;return i&&e!=="GET"&&(r+=`,
|
|||
|
|
"Content-Type": "application/json"`),r+=`
|
|||
|
|
}`,i&&e!=="GET"?r+=`
|
|||
|
|
|
|||
|
|
data = ${JSON.stringify(i,null,4)}
|
|||
|
|
|
|||
|
|
response = requests.${e.toLowerCase()}(url, headers=headers, json=data)`:r+=`
|
|||
|
|
|
|||
|
|
response = requests.${e.toLowerCase()}(url, headers=headers)`,r+=`
|
|||
|
|
print(response.json())`,r}generateNodeExample(e,n,i){let r=`const fetch = require('node-fetch');
|
|||
|
|
|
|||
|
|
const url = '${`http://${this.plugin.settings.HttpApiIpType}:${this.plugin.settings.HttpApiPort}`}${n}';
|
|||
|
|
const options = {
|
|||
|
|
method: '${e}',
|
|||
|
|
headers: {
|
|||
|
|
'Authorization': 'Bearer <your-token>'`;return i&&e!=="GET"&&(r+=`,
|
|||
|
|
'Content-Type': 'application/json'`),r+=`
|
|||
|
|
}`,i&&e!=="GET"&&(r+=`,
|
|||
|
|
body: JSON.stringify(${JSON.stringify(i,null,8)})`),r+=`
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
fetch(url, options)
|
|||
|
|
.then(response => response.json())
|
|||
|
|
.then(data => console.log(data))
|
|||
|
|
.catch(error => console.error('Error:', error));`,r}onClose(){const{contentEl:e}=this;e.empty()}}function Rp(t){return t.split("-")[0]}function $3(t){return t.split("-")[1]}function JS(t){return["top","bottom"].includes(Rp(t))?"x":"y"}function Z3(t){return t==="y"?"height":"width"}function OM(t){let{reference:e,floating:n,placement:i}=t;const o=e.x+e.width/2-n.width/2,r=e.y+e.height/2-n.height/2;let a;switch(Rp(i)){case"top":a={x:o,y:e.y-n.height};break;case"bottom":a={x:o,y:e.y+e.height};break;case"right":a={x:e.x+e.width,y:r};break;case"left":a={x:e.x-n.width,y:r};break;default:a={x:e.x,y:e.y}}const l=JS(i),c=Z3(l);switch($3(i)){case"start":a[l]=a[l]-(e[c]/2-n[c]/2);break;case"end":a[l]=a[l]+(e[c]/2-n[c]/2);break}return a}const Gq=async(t,e,n)=>{const{placement:i="bottom",strategy:o="absolute",middleware:r=[],platform:a}=n;let l=await a.getElementRects({reference:t,floating:e,strategy:o}),{x:c,y:d}=OM({...l,placement:i}),h=i,m={};for(let g=0;g<r.length;g++){const{name:y,fn:T}=r[g],{x:w,y:S,data:I,reset:E}=await T({x:c,y:d,initialPlacement:i,placement:h,strategy:o,middlewareData:m,rects:l,platform:a,elements:{reference:t,floating:e}});if(c=w??c,d=S??d,m={...m,[y]:I??{}},E){typeof E=="object"&&(E.placement&&(h=E.placement),E.rects&&(l=E.rects===!0?await a.getElementRects({reference:t,floating:e,strategy:o}):E.rects),{x:c,y:d}=OM({...l,placement:h})),g=-1;continue}}return{x:c,y:d,placement:h,strategy:o,middlewareData:m}};function $q(t){return{top:0,right:0,bottom:0,left:0,...t}}function Zq(t){return typeof t!="number"?$q(t):{top:t,right:t,bottom:t,left:t}}function k0(t){return{...t,top:t.y,left:t.x,right:t.x+t.width,bottom:t.y+t.height}}async function E0(t,e){e===void 0&&(e={});const{x:n,y:i,platform:o,rects:r,elements:a,strategy:l}=t,{boundary:c="clippingParents",rootBoundary:d="viewport",elementContext:h="floating",altBoundary:m=!1,padding:g=0}=e,y=Zq(g),w=a[m?h==="floating"?"reference":"floating":h],S=await o.getClippingClientRect({element:await o.isElement(w)?w:w.contextElement||await o.getDocumentElement({element:a.floating}),boundary:c,rootBoundary:d}),I=k0(await o.convertOffsetParentRelativeRectToViewportRelativeRect({rect:h==="floating"?{...r.floating,x:n,y:i}:r.reference,offsetParent:await o.getOffsetParent({element:a.floating}),strategy:l}));return{top:S.top-I.top+y.top,bottom:I.bottom-S.bottom+y.bottom,left:S.left-I.left+y.left,right:I.right-S.right+y.right}}const Kq={left:"right",right:"left",bottom:"top",top:"bottom"};function zf(t){return t.replace(/left|right|bottom|top/g,e=>Kq[e])}function Jq(t,e){const n=$3(t)==="start",i=JS(t),o=Z3(i);let r=i==="x"?n?"right":"left":n?"bottom":"top";return e.reference[o]>e.floating[o]&&(r=zf(r)),{main:r,cross:zf(r)}}const Qq={start:"end",end:"start"};function RM(t){return t.replace(/start|end/g,e=>Qq[e])}function Xq(t){const e=zf(t);return[RM(t),e,RM(e)]}const eG=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var n,i;const{placement:o,middlewareData:r,rects:a,initialPlacement:l}=e;if((n=r.flip)!=null&&n.skip)return{};const{mainAxis:c=!0,crossAxis:d=!0,fallbackPlacements:h,fallbackStrategy:m="bestFit",flipAlignment:g=!0,...y}=t,T=Rp(o),S=h||(T===l||!g?[zf(l)]:Xq(l)),I=[l,...S],E=await E0(e,y),L=[];let C=((i=r.flip)==null?void 0:i.overflows)||[];if(c&&L.push(E[T]),d){const{main:F,cross:j}=Jq(o,a);L.push(E[F],E[j])}if(C=[...C,{placement:o,overflows:L}],!L.every(F=>F<=0)){var R,M;const F=((R=(M=r.flip)==null?void 0:M.index)!=null?R:0)+1,j=I[F];if(j)return{data:{index:F,overflows:C},reset:{placement:j}};let z="bottom";switch(m){case"bestFit":{var O;const _=(O=C.slice().sort((V,G)=>V.overflows.filter(Z=>Z>0).reduce((Z,ee)=>Z+ee,0)-G.overflows.filter(Z=>Z>0).reduce((Z,ee)=>Z+ee,0))[0])==null?void 0:O.placement;_&&(z=_);break}case"initialPlacement":z=l;break}return{data:{skip:!0},reset:{placement:z}}}return{}}}};function tG(t){let{placement:e,rects:n,value:i}=t;const o=Rp(e),r=["left","top"].includes(o)?-1:1,a=typeof i=="function"?i({...n,placement:e}):i,{mainAxis:l,crossAxis:c}=typeof a=="number"?{mainAxis:a,crossAxis:0}:{mainAxis:0,crossAxis:0,...
|
|||
|
|
\r
|
|||
|
|
`)})}async handleRequest(e,n){if(!e.url){this.sendErrorResponse(n,400,"Invalid request");return}const i=$G.parse(e.url,!0),o=i.pathname;if(e.method==="OPTIONS"){n.statusCode=200,n.setHeader("Content-Length","0"),n.end();return}const a=e.headers.authorization;if(!a){this.sendErrorResponse(n,401,"Missing authorization header");return}const l=this.tokenManager.extractTokenFromHeader(a);if(!l){this.sendErrorResponse(n,401,"Invalid authorization format");return}if(!await this.tokenManager.validateToken(l)){this.sendErrorResponse(n,401,"Invalid or expired token");return}if(!await this.tokenManager.isUserVerified()){this.sendErrorResponse(n,403,"Pro license required");return}const h=e.socket.remoteAddress||"unknown";if(!this.checkRateLimit(h)){this.sendErrorResponse(n,429,"Too many requests");return}try{switch(o){case"/create":await this.handleCreateRequest(e,n);break;case"/search":await this.handleSearchRequest(e,n,i.query);break;case"/list":await this.handleListRequest(e,n,i.query);break;case"/info":await this.handleInfoRequest(e,n,i.query);break;default:this.sendErrorResponse(n,404,"Not found");break}}catch(m){console.error("Route handling error:",m),this.sendErrorResponse(n,500,"Internal server error")}}async handleCreateRequest(e,n){if(e.method!=="POST"){this.sendErrorResponse(n,405,"Method not allowed");return}let i="",o=0;const r=10*1024*1024;e.on("data",a=>{if(o+=a.length,o>r){this.sendErrorResponse(n,413,"Request too large");return}i+=a.toString()}),e.on("end",async()=>{try{const a=this.validateAndSanitizeInput(JSON.parse(i)),l=await this.processCreateRequest(a);n.statusCode=200,n.setHeader("Content-Type","application/json"),n.end(JSON.stringify(l))}catch(a){console.error("Create request error:",a),this.sendErrorResponse(n,400,"Invalid request data")}}),e.on("error",a=>{console.error("Request stream error:",a),this.sendErrorResponse(n,400,"Request error")})}async handleSearchRequest(e,n,i){if(e.method!=="GET"){this.sendErrorResponse(n,405,"Method not allowed");return}const o=this.sanitizeInput(i.keyword);if(!o){this.sendErrorResponse(n,400,"Invalid keyword");return}try{const r=he.getThinoViaKeyword(o);n.statusCode=200,n.setHeader("Content-Type","application/json"),n.end(JSON.stringify({status:"success",thinos:r}))}catch(r){console.error("Search error:",r),this.sendErrorResponse(n,500,"Search failed")}}async handleListRequest(e,n,i){if(e.method!=="GET"){this.sendErrorResponse(n,405,"Method not allowed");return}const o=i.count,r=Math.min(Math.max(parseInt(o)||10,1),100);try{const a=he.getState().memos.slice(0,r);n.statusCode=200,n.setHeader("Content-Type","application/json"),n.end(JSON.stringify({status:"success",thinos:a}))}catch(a){console.error("List error:",a),this.sendErrorResponse(n,500,"List failed")}}async handleInfoRequest(e,n,i){if(e.method!=="GET"){this.sendErrorResponse(n,405,"Method not allowed");return}if(!i.getSettings){this.sendErrorResponse(n,400,"Missing getSettings parameter");return}try{const o=Ve.getState().settings;n.statusCode=200,n.setHeader("Content-Type","application/json"),n.end(JSON.stringify({status:"success",infoSettings:o}))}catch(o){console.error("Info error:",o),this.sendErrorResponse(n,500,"Info retrieval failed")}}validateAndSanitizeInput(e){if(!e||typeof e!="object")throw new Error("Invalid request data");return{text:this.sanitizeInput(e.text||""),isList:!!e.isList,type:this.sanitizeInput(e.type||""),imageList:Array.isArray(e.imageList)?e.imageList.slice(0,10):[],sourceLink:this.sanitizeInput(e.sourceLink||"")}}sanitizeInput(e){return typeof e!="string"?"":e.replace(/[<>]/g,"").replace(/javascript:/gi,"").replace(/data:/gi,"").substring(0,1e4)}async processCreateRequest(e){const{text:n,isList:i,type:o,imageList:r,sourceLink:a}=e;if(!n)return{status:"success",thino:null,link:null};let l=n;if(/<[a-zA-Z][^>]*>/g.test(n)&&(l=k.htmlToMarkdown(n)),a)try{const m=decodeURIComponent(a);l=`${l} [source](<${m}>)`}catch(m){console.warn("Failed to decode source link:",m)}this.settings.AutoDownloadImage&&r.length>0&&(l=await this.processImages(l,r)),this.plugin.settings?.AppendOrPrependTextViaServe
|
|||
|
|
`+r.join(`
|
|||
|
|
`))}catch(i){console.error("Error processing images:",i)}return e}base64ImageToBlob(e){const n=e.indexOf(";base64,");if(n===-1)throw new Error("Invalid base64 image format");const i=e.substring(5,n),o=e.substr(n+8);if(!/^[A-Za-z0-9+/]*={0,2}$/.test(o))throw new Error("Invalid base64 characters");const r=atob(o),a=new ArrayBuffer(r.length),l=new Uint8Array(a);for(let c=0;c<r.length;c++)l[c]=r.charCodeAt(c);return new Blob([a],{type:i})}async handleUploadFile(e){const{type:n}=e;if(!n.startsWith("image"))return null;try{return`${await Y0.upload(e)}`}catch(i){return console.error("Upload error:",i),new k.Notice(i),null}}formatText(e){const n=this.settings;return`${n?.PrependViaServer||""}${n?.WithNewLineViaServer==="prepend"||n?.WithNewLineViaServer==="both"?`
|
|||
|
|
`:""}${e}${n?.WithNewLineViaServer==="append"||n?.WithNewLineViaServer==="both"?`
|
|||
|
|
`:""}${n?.AppendViaServer||""}`}sendErrorResponse(e,n,i){e.statusCode=n,e.setHeader("Content-Type","application/json"),e.setHeader("Access-Control-Allow-Origin","*"),e.setHeader("Access-Control-Allow-Methods","GET, HEAD, POST, OPTIONS, PUT, PATCH, DELETE"),e.setHeader("Access-Control-Allow-Headers","Origin, X-Requested-With, Content-Type, Accept, Authorization, Cache-Control, Pragma"),e.end(JSON.stringify({status:"error",message:i}))}rateLimitMap=new Map;checkRateLimit(e){const n=Date.now(),i=6e4,o=100,r=this.rateLimitMap.get(e);return!r||n>r.resetTime?(this.rateLimitMap.set(e,{count:1,resetTime:n+i}),!0):r.count>=o?!1:(r.count++,!0)}async listen(e,n){try{await this.initializeWorker(),this.server.listen({port:parseInt(n),host:e},()=>{this.isServerRunning=!0,new k.Notice(`${v("Thino - Started HTTP server on port")} ${n}`)})}catch(i){throw console.error("Failed to start server:",i),new k.Notice(v("Thino - Failed to start HTTP server, please check the port is available.")),i}}close(){this.server&&this.isServerRunning&&this.server.close(()=>{this.isServerRunning=!1,new k.Notice(v("Thino - Terminated HTTP server"))}),this.worker&&(this.worker.terminate(),this.worker=null)}isRunning(){return this.isServerRunning}}function KG(t,e){const n=new ZG(t,e);return{listen(i,o){n.listen(i,o)},close(){n.close()}}}const{clipboard:Kn}=k.Platform.isDesktop?require("electron"):"";class JG{eventListeners;constructor(){this.eventListeners={}}on(e,n){this.eventListeners[e]=this.eventListeners[e]||[],this.eventListeners[e].push(n)}once(e,n){n.$emitOnce=!0,this.on(e,n)}removeListener(e,n){if(this.eventListeners[e]){const i=this.eventListeners[e].findIndex(o=>o===n);i>=0&&this.eventListeners[e].splice(i,1)}}removeAllListeners(e){this.eventListeners[e]&&(this.eventListeners[e].length=0)}emit(e,...n){this.eventListeners[e]&&this.eventListeners[e].forEach(i=>{i.call(this,...n),i.$emitOnce&&this.removeListener(e,i)})}}const xl=new JG;let iu=null,_M=Kn?.readText(),YM=Kn?.readImage();Kn&&(Kn.on=(t,e)=>(xl.on(t,e),Kn),Kn.once=(t,e)=>(xl.once(t,e),Kn),Kn.off=(t,e)=>(e?xl.removeListener(t,e):xl.removeAllListeners(t),Kn),Kn.startWatching=()=>(iu||(iu=setInterval(()=>{QG(_M,_M=Kn?.readText())&&xl.emit("text-changed"),XG(YM,YM=Kn?.readImage())&&xl.emit("image-changed")},500)),Kn),Kn.stopWatching=()=>(iu&&clearInterval(iu),iu=null,Kn));function QG(t,e){return e&&t!==e}function XG(t,e){return!e.isEmpty()&&t.toDataURL()!==e.toDataURL()}const Rb=require("electron")?.remote,VM=require("electron")?.remote?.screen;class e${constructor(e,n){this.app=e,this.plugin=n,this.isRegisted=!1,this.leaf=null,this.clipboard=Kn}isRegisted;leaf;clipboard;isScreenTop=!1;currentSplitWindow;intervalNum;allowsCopy=!1;plugin;actionEl=null;async onload(){k.Platform.isDesktop&&(this.initGlobalCopyEvents(),await this.registerAllShortcuts(),this.registerEvents())}registerEvents(){this.plugin.registerEvent(this.app.workspace.on("quit",()=>{Rb.globalShortcut.unregister(this.plugin.settings.CaptureKey.OpenThinoGlobally)}))}initGlobalCopyEvents(){this.plugin.addCommand({id:"init-global-copy-events",name:v("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",()=>{this.allowsCopy=!1,this.clipboard.stopWatching(),this.actionEl?.remove()}))}})}onunload(){this.isRegisted&&(Rb.globalShortcut.unregister(this.plugin.settings.CaptureKey.OpenThinoGlobally),this.clipboard.off("text-changed"),this.clipboard.off("image-changed"),this.clipboard.stopWatching(),this.leaf&&this.leaf.detach())}getCurrentLeaf(){return this.leaf?this.app.workspace.getLeavesOfType("thino_view").length>0&&!!this.app.workspace.getLeafById(this.leaf.id)?!0:(this.leaf?.detach(),this.currentSplitWindow.close(),this.currentSplitWindow=null,this.leaf=null,this.isScreenTop=!1,!1):!1}async registerAllShortcuts(){Rb?.globalShortcut?.register(this.plugin.settings.CaptureKey.OpenThinoGlobally,()=>{this.getCurrentLeaf()?this.showThinoVi
|
|||
|
|
`:" ";switch(e[c==="prepend"?"SharePrependType":"ShareAppendType"]){case"none":d();break;case"preset":e.ShareToThinoWithText&&(c==="prepend"?r=e.ShareToThinoWithTextPrepend+m:a=m+e.ShareToThinoWithTextAppend),d();break;case"input":{const g="Thino "+v(c==="prepend"?"Prepend text":"Append text");new h4(t,g,y=>{c==="prepend"?r=y.trim()+(y.trim()?m:""):a=(y.trim()?m:"")+y,d()}).open();break}case"selectTags":new Oj(t,g=>{const y=g.length>0?g.map(T=>"#"+T).join(" "):"";c==="prepend"?r=y.trim()+(y.trim()?m:""):a=(y.trim()?m:"")+y.trim(),d()}).open();break;default:h(new Error("Invalid configuration type."))}});Promise.all([l("append"),l("prepend")]).then(()=>n(r,a)).then(()=>i()).catch(o)})}const Y$=t=>{const e=t.embedRegistry;if(!e)return!1;const n=e.embedByExtension.md,i=n({app:t,containerEl:createDiv()},null,null);return i.editable=!0,i.set(""),i.showEditor(),Object.getPrototypeOf(Object.getPrototypeOf(i.editMode)).constructor};async function eT(t){try{const e=t.app.internalPlugins.plugins["daily-notes"];let n;n={settings:{...t.settings,tokenForVerify:"***"},plugins:Object.keys(t.app.plugins.plugins),manifest:t.manifest,platform:k.Platform.resourcePathPrefix},e&&(n={...n,dailyNotePluginInfo:{options:e.instance.options}}),await navigator.clipboard.writeText(`\`\`\`json
|
|||
|
|
${JSON.stringify(n,null,2)}
|
|||
|
|
\`\`\``),new k.Notice(v("Debug info copied to clipboard"))}catch(e){console.error(e)}}class V$ extends k.Plugin{settings;settingTab;thinoWorkerManager;triggerBySelf=!1;updatedID="";debounceTimer=0;apiHttpServer=null;captureService=null;loaded=!1;MarkdownEditor;async onload(){this.MarkdownEditor=Y$(this.app),Ve.setPlugin(this),await this.loadSettings(),gq(),this.registerRibbon(),await this.verify();try{this.settings.ShowUpdateMessage&&await this.checkVersionAndShowChangeLog()}catch(e){console.error(e)}this.settingTab=new Yq(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(),k.Platform.isMobile&&this.registerMobileNavbar(),this.updateLayoutSettings(),this.registerEditorContextMenu(),this.registerEditorSuggest(new mq(this.app,this)),this.registerEditorExtension([_G]),this.app.workspace.onLayoutReady(this.onLayoutReady.bind(this)),this.registerView(Zn,e=>new Rl(e,this)),this.registerView(Sf,e=>new f5(e,this.manifest.version)),this.thinoWorkerManager=new MA(this.app,this),this.addChild(this.thinoWorkerManager)}async loadSettings(){this.settings=Object.assign({},gn,await this.loadData()),Ve.setSettings(this.settings),this.settings.MemoListView&&We.setMemoListView(this.settings.MemoListView)}async saveSettings(){await this.saveData(this.settings),Ve.setSettings(this.settings)}onunload(){this.app.workspace.detachLeavesOfType(Zn),Ke.getState().clearFiles(),Ke.getState().clearView();const e=document.body.find(".dialog-wrapper");if(e&&e.parentElement?.detach(),this.apiHttpServer&&(this.apiHttpServer.close(),this.apiHttpServer=null),this.captureService&&this.captureService.onunload(),k.Platform.isMobile){const n=this.app.mobileNavbar;n&&n.showThinoBtnEl&&this.settings?.NavbarButton&&(n.showThinoBtnEl.detach(),n.showThinoBtnEl=null)}new k.Notice(v("Close Memos Successfully"))}initEditor(){this.register(du(k.MetadataCache.prototype,{getFileCache:n=>function(i){return!i?.path&&!i?null:n.call(this,i)}})),(n=>{const i=n.app.embedRegistry.embedByExtension.md({app:n.app,containerEl:document.createElement("div")},null,"");i.editable=!0,i.showEditor();const o=Object.getPrototypeOf(Object.getPrototypeOf(i.editMode)),r=du(o.constructor.prototype,{triggerClickableToken:a=>async function(...l){if(l[0].type==="internal-link"){if(this.editorEl.closest(".memo-editor-wrapper")){const c=he.getMemoById(l[0].text??"");if(c){to(c);return}return a.apply(this,l)}return a.apply(this,l)}return a.apply(this,l)}});this.register(r),i.unload()})(this)}initApp(){Ve.setApp(this.app)}initURIHandler(){this.registerObsidianProtocolHandler("thino",async e=>{if(!e)return;if(e.openSettings&&(this.app.setting.open(),this.app.setting.openTabById(this.manifest.id||"obsidian-memos")),e.userid)try{const r=e.userid;WG(r,this.app),qG(k.moment().add(30,"days").valueOf(),this.app),We.setRefresh(!0)}catch(r){console.error(r),new k.Notice(v("Failed to verify"))}if(e.token)try{const r=e.token;this.app?.saveLocalStorage("tokenForSync",r),setTimeout(()=>{this.app.setting.open(),this.app.setting.openTabById(this.manifest.id||"obsidian-memos"),this.settingTab.display()},200),new k.Notice(v("Saved sync token successfully"))}catch(r){console.error(r),new k.Notice(v("Failed to save"))}if(e.copyToken){this.app.setting.open(),this.app.setting.openTabById(this.manifest.id??"obsidian-memos");const r=await G3();await navigator.clipboard.writeText(r),new k.Notice(v("Copied app id successfully"))}const n=Ve.getState()?.verifyState,i=!k.Platform.isDesktop&&await window.Capacitor?.Plugins.Device?.getId(),o=k.Platform.isDesktop?await Jt():i?.identifier||i?.uuid;if(!(!n||n?.appId!==o)){if(e.content){const r=e.type,a=decodeURI(e.content)!==e.content?decodeURI(e.content):e.content,l=e.task,c=await he.createThino({content:a,type:r,isList:!!l});if(!c)return;he.pushMemo(c),Le.clearQuery()}e.openId&&await he.openThinoByID(e.openId)}})}initGlobalManifest(){We.setPluginManifest(this.manifest)}sto
|
|||
|
|
`);try{await ZM(this.app,this.settings,async(a,l)=>{r=a+r+l;const c=await he.createThino({content:r,type:this.settings.MemoSaveLocation||"DAILY",isList:!0});he.pushMemo(c)})}catch(a){console.error("Configuration failed:",a);return}})})})))}registerCommands(){jh.forEach(e=>{this.addCommand({id:e.id,name:e.name,callback:()=>this.openMemos(e.location,e.cb),hotkeys:[]})}),["Modern","Clean","Minimal","Gradient"].forEach(e=>{this.addCommand({id:`share-thino-via-${e.toLowerCase()}`,name:v("Share thino")+` [${v(e)}]`,editorCallback:(n,i)=>{const o=n.getSelection();if(o.length===0)return;const r={id:`temp-${Date.now()}`,content:o,createdAt:k.moment().format("YYYY-MM-DD HH:mm:ss"),updatedAt:k.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:i.file.path,fileInfo:{tags:[],frontmatter:{}}};ys(r,e.toLowerCase(),i)}})}),this.addCommand({id:"focus-mode",name:"Focus mode",callback:()=>{const e=document.body.hasClass("thino-focus");document.body.toggleClass("thino-focus",!e)}}),this.addCommand({id:"hide-side-bar",name:v("Toggle sidebar visibility"),callback:()=>{const e=We.getState().isMobileView,n=document.body.hasClass("thino-hide-side-bar");document.body.toggleClass("thino-hide-side-bar",e?!1:!n)}}),this.addCommand({id:"hide-tags",name:v("Toggle tags visibility"),callback:()=>{const e=document.body.hasClass("thino-hide-tags");document.body.toggleClass("thino-hide-tags",!e)}}),this.addCommand({id:"hide-query-list",name:v("Toggle query list visibility"),callback:()=>{const e=document.body.hasClass("thino-hide-query-list");document.body.toggleClass("thino-hide-query-list",!e)}}),this.addCommand({id:"insert-task",name:v("Insert task"),checkCallback:e=>{const n=this.app.plugins.getPlugin("obsidian-tasks-plugin"),i=this.app.workspace.getLeavesOfType("thino_view").first();if(n&&i)return e||this.app.plugins.plugins["obsidian-tasks-plugin"].apiV1.createTaskLineModal().then(r=>{const a=this.app.workspace.activeEditor;a&&a.editor?.insertText(r)}),!0}}),this.addCommand({id:"show-thino-editor",name:v("Show thino editor"),checkCallback:e=>{if(he.initialized&&Ve.initialized){if(!e){if(!Ve.getState().view){new k.Notice(v("Please open thino first"));return}new Nk(this.app).open()}return!0}}}),this.addCommand({id:"lock-thino",name:v("Lock thino"),checkCallback:e=>{if(this.app.workspace.getActiveViewOfType(Rl)&&this.settings.needVerify)return e||We.setLocked(!0),!0}}),this.addCommand({id:"copy-debug-info",name:v("Copy debug info"),callback:async()=>{await eT(this)}}),this.addCommand({id:"insert-editor",name:v("Insert editor"),checkCallback:e=>{const n=this.app.workspace.getActiveViewOfType(k.MarkdownView);if(n&&n?.getViewType()==="markdown")return e||n.editor.replaceSelection("\n```thino\n{\n editor: false\n}\n```\n"),!0}}),this.addCommand({id:"toggle-minimal-thino",name:v("Toggle minimal mode"),callback:()=>{const e=document.body.hasClass("minimal-thino");document.body.toggleClass("minimal-thino",!e)}}),this.addCommand({id:"focus-on-thino-editor",name:v("Focus on thino editor"),callback:()=>this.focusOnEditor(),hotkeys:[]}),this.addCommand({id:"reinit-thino-sync",name:v("ReSync web thinos to local"),callback:()=>{bV(this.app)}}),this.addCommand({id:"init-thino-sync",name:v("Sync local thinos to web"),callback:async()=>{if(!this.app?.loadLocalStorage("tokenForSync")){new k.Notice(v("Please input token first"));return}if(!this.settings.startSync){new k.Notice(v("Please enable sync first"));return}try{await he.initSync()}catch(n){console.error(n),new k.Notice(v("Init Failed"))}}}),this.addCommand({id:"show-daily-thino",name:v("Show daily thino"),callback:()=>this.openDailyMemo(),hotkeys:[]}),this.addCommand({id:"focus-on-search-bar",name:v("Focus on search bar"),callback:()=>this.searchIt(),hotkeys:[]}),this.addCommand({id:"show-thino-in-popover",name:v("Show-thino in popover(Hover editor)"),callback:()=>this.showInPopover(),hotkeys:[]})}async onLayoutReady(){await this.stopEnableList(),await this.initServ
|
|||
|
|
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAr+i4MLzI40gGFHl7gdRH
|
|||
|
|
UL1mH0NcWEs1/IBYDDbc9ALbvUGwDaUcVIKke+b+F4T7qISexyGd5qV0s1vNYeCk
|
|||
|
|
iCTq4w3+CFDurIFYAgQYTcV6K5pL8Bpb79FEclsTnAcKgiuzKBxPZ1djKxbgnmFj
|
|||
|
|
+PE+EcmX+JJK9hG1O8X+YFJoPJWl225eCoysONickiI7Ndwu9YLR8pIUb1VMyJSy
|
|||
|
|
cMR87z466Nc5Hx2QhwyuiiQYL3Ru4WkNF3AVWgqeOlhBDybFFwDaV7OOMTiYtH46
|
|||
|
|
3iKx6azEVS8W/gYfrW+hKp2VziPPw3oxouP/wCes/4qRlXkwyjSwtfLtpE4Rsa4+
|
|||
|
|
swIDAQAB
|
|||
|
|
-----END PUBLIC KEY-----`,"RS256");try{const{payload:l}=await H$(i,a),c=JSON.parse(new TextDecoder().decode(l));return!c||c.iss!=="pkmer"||c.type!=="thino"||c.appId!==e?!1:(Ve.setVerifyState(c),!0)}catch(l){console.error(l)}}return await n(this.settings.tokenForVerify[e])}async checkVersionAndShowChangeLog(){const e=this.manifest.version,n=this.settings.LastUpdatedVersion;e!==n&&(this.settings={...this.settings,LastUpdatedVersion:e},await this.saveSettings(),this.showChangeLog())}async showChangeLog(){await V0(this.app)}autoOpenMemos(){this.app.workspace.getLeavesOfType(Zn).length>0||this.settings.MobileAndDesktop==="Mobile"&&k.Platform.isDesktop||this.settings.MobileAndDesktop==="Desktop"&&k.Platform.isMobile||this.settings.OpenMemosAutomatically&&this.openMemos()}async openDailyMemo(){if(this.app.workspace.getLeavesOfType(Zn).length>0){Le.setPathname("/daily");return}await this.openMemos(),Le.setPathname("/daily")}async openMemos(e="center",n){const i=this.app.workspace;if(i.getLeavesOfType(Zn).length>0){const a=i.getLeavesOfType(Zn)[0];return i.setActiveLeaf(a),i.revealLeaf(a),a}i.detachLeavesOfType(Zn);let o;switch(e){case"left":o=i.getLeftLeaf(!1);break;case"right":o=i.getRightLeaf(!1);break;case"float":o=i.getLeaf("window");break;default:o=i.getLeaf(!0);break}if(o)return await o.setViewState({type:Zn}),i.revealLeaf(o),o;const r=o.view.containerEl.querySelector("textarea");return r?(r.focus(),o):(n?.(),o)}async searchIt(){const e=this.app.workspace,n=e.getLeavesOfType(Zn);if(!(n.length>0)){const o=await this.openMemos();setTimeout(()=>{o.view.containerEl.find(".search-bar-inputer .text-input").focus(),this.app.workspace.trigger("focus-on-searchbar")},300);return}const i=n[0];e.revealLeaf(i),setTimeout(()=>{i.view.containerEl.find(".search-bar-inputer .text-input").focus(),this.app.workspace.trigger("focus-on-searchbar")},300)}async focusOnEditor(){if(!(this.app.workspace.getLeavesOfType(Zn).length>0)){await this.openMemos();return}this.app.workspace.trigger("focus-on-textarea")}changeStatus(){const e=this.app.workspace,n=e.getLeavesOfType(Zn);if(!(n.length>0)){new k.Notice(v("Please Open Memos First"));return}const i=n[0];e.setActiveLeaf(i),i.view.containerEl.querySelector(".list-or-task").click()}async showInPopover(){const e=this.app.workspace;if(e.detachLeavesOfType(Zn),!this.app.plugins.getPlugin("obsidian-hover-editor")){new k.Notice(v("Please install obsidian-hover-editor plugin first"));return}const i=await this.app.plugins.getPlugin("obsidian-hover-editor")?.spawnPopover();i&&(await i.setViewState({type:Zn}),e.revealLeaf(i),i.view.containerEl.classList.add("mobile-view"),this.settings?.FocusOnEditor&&i.view.containerEl.querySelector("textarea")!==void 0&&i.view.containerEl.querySelector("textarea")?.focus())}}class h4 extends k.Modal{constructor(e,n,i){super(e),this.title=n,this.callback=i}inputEl;callback;onOpen(){const{contentEl:e}=this;this.setTitle(this.title),this.containerEl.toggleClass(["thino-input-dialog","thino-bulk-action-dialog","tag-actions"],!0),this.inputEl=e.createEl("input",{attr:{type:"text"}}),this.inputEl.focus(),new k.Setting(e).addButton(n=>{n.setButtonText(v("OK")).onClick(()=>{this.close()})})}onClose(){this.contentEl.empty(),this.callback(this.inputEl.value)}}exports.InputModal=h4;exports.default=V$;exports.getCurrentDebugInfo=eT;
|
|||
|
|
|
|||
|
|
/* nosourcemap */
|