m?-1:0}).map(function(p){return Ag(p)}).join("|"),")$"))},r._closeAutocomplete=function(){var d=r.state.currentTrigger;r.escListenerDestroy(),r.setState({data:null,dataLoading:!1,currentTrigger:null},function(){d&&r._onItemHighlightedHandler(null)})},r._cleanUpProps=function(){var d=k8({},r.props),p=["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 m in d)p.includes(m)&&delete d[m];return d},r._changeHandler=function(d){var p=r.props,m=p.trigger,g=p.onChange,v=p.minChar,D=p.onCaretPositionChange,S=p.movePopupAsYouType,T=r.state,E=T.top,O=T.left,k=d;k||(k=new M8("change",{bubbles:!0}),r.textareaRef.dispatchEvent(k));var j=k.target||r.textareaRef,F=j.selectionEnd,B=j.value;if(r.lastValueBubbledEvent=B,g&&k&&(k.persist&&k.persist(),g(new Proxy(k,{get:function(Z,G,te){return G==="target"?j:Reflect.get(Z,G,te)}}))),D){var R=r.getCaretPosition();D(R)}r.setState({value:B});var z=function(){var Z=E8(j,F),G=Z.top,te=Z.left;r.setState({top:G-r.textareaRef.scrollTop||0,left:te})},H=function(Z){r.lastTrigger=F-Z,r._closeAutocomplete(),z()};if(F<=r.lastTrigger){var Y=B.slice(0,F),U=r.tokenRegExp.exec(Y);H(U?U[0].length:0)}var J=B.slice(r.lastTrigger,F),Q=r.tokenRegExp.exec(J),le=Q&&Q[0],pe=Q&&Q[1]||null,ie=pe?pe.length-1:0,se=r.tokenRegExpEnding.exec(J);if(se?H(se[0].length):r._isAutocompleteOpen()||r._closeAutocomplete(),(!le||le.length<=v+ie)&&(r.state.currentTrigger&&!m[r.state.currentTrigger].allowWhitespace||!r.state.currentTrigger)){r._closeAutocomplete();return}if(pe&&m[pe].afterWhitespace&&!/\s/.test(B[F-le.length-1])&&B[F-le.length-1]!==void 0){r._closeAutocomplete();return}if(r.state.currentTrigger&&m[r.state.currentTrigger].allowWhitespace){if(Q=new RegExp("".concat(Ag(r.state.currentTrigger),".*$")).exec(B.slice(0,F)),le=Q&&Q[0],!le){r._closeAutocomplete();return}pe=Object.keys(m).find(function(we){return we.slice(0,ie+1)===le.slice(0,ie+1)})||null}var fe=le.slice(1);if(pe){(S||E===null&&O===null||r.state.currentTrigger!==pe)&&z(),r.escListenerInit();var oe=r._getTextToReplace(pe);r.setState({selectionEnd:F,currentTrigger:pe,textToReplace:oe,actualToken:fe},function(){try{r._getValuesFromProvider()}catch(we){jD(we.message)}})}},r._selectHandler=function(d){var p=r.props,m=p.onCaretPositionChange,g=p.onSelect;if(m){var v=r.getCaretPosition();m(v)}g&&(d.persist(),g(d))},r._shouldStayOpen=function(d){var p=d.relatedTarget;return p===null&&(p=document.activeElement),!!(r.dropdownRef&&p instanceof Node&&r.dropdownRef.contains(p))},r._onClick=function(d){var p=r.props.onClick;p&&(d.persist(),p(d)),!r._shouldStayOpen(d)&&r._closeAutocomplete()},r._onBlur=function(d){var p=r.props.onBlur;p&&(d.persist(),p(d)),!r._shouldStayOpen(d)&&r._closeAutocomplete()},r._onScrollHandler=function(){r._closeAutocomplete()},r._onItemHighlightedHandler=function(d){var p=r.props.onItemHighlighted,m=r.state.currentTrigger;if(p)if(typeof p=="function")p({currentTrigger:m,item:d});else throw new Error("`onItemHighlighted` has to be a function")},r._dropdownScroll=function(d){var p=r.props.scrollToItem;if(p){if(p===!0){_8(r.dropdownRef,d);return}if(typeof p!="function"||p.length!==2)throw new Error("`scrollToItem` has to be boolean (true for default implementation) or function with two parameters: container, item.");p(r.dropdownRef,d)}},r._isAutocompleteOpen=function(){var d=r.state,p=d.dataLoading,m=d.currentTrigger,g=r._getSuggestions();return!!((p||g)&&m)},r._textareaRef=function(d){r.props.innerRef&&r.props.innerRef(d),r.textareaRef=d},r.lastTrigger=0,r.escListener=null;var a=r.props,o=a.loadingComponent,s=a.trigger,c=a.value;if(c&&(r.state.value=c),r._createRegExp(),!o)throw new Error("RTA: loadingComponent is not defined");if(!s)throw new Error("RTA: trigger is not defined");return r}return _y(t,[{key:"componentDidMount",value:function(){Eu.startListen(this.textareaRef),this.textareaRef&&this.textareaRef.addEventListener("focus",this._handleCaretChange),this.textareaRef&&this.textareaRef.addEventListener("click",this._handleCaretChange),this.textareaRef&&this.textareaRef.addEventListener("keydown",this._handleCaretChange)}},{key:"componentDidUpdate",value:function(r){var a=r.trigger,o=r.value,s=this.props,c=s.trigger,d=s.value;Object.keys(c).join("")!==Object.keys(a).join("")&&this._createRegExp(),o!==d&&this.lastValueBubbledEvent!==d&&(this.lastTrigger=0,this._changeHandler())}},{key:"componentWillUnmount",value:function(){this.escListenerDestroy(),Eu.stopListen(this.textareaRef),this.textareaRef&&this.textareaRef.removeEventListener("focus",this._handleCaretChange),this.textareaRef&&this.textareaRef.removeEventListener("click",this._handleCaretChange),this.textareaRef&&this.textareaRef.removeEventListener("keydown",this._handleCaretChange)}},{key:"render",value:function(){var r=this,a=this.props,o=a.loadingComponent,s=a.style,c=a.className,d=a.listStyle,p=a.itemStyle,m=a.boundariesElement,g=a.movePopupAsYouType,v=a.listClassName,D=a.itemClassName,S=a.dropdownClassName,T=a.dropdownStyle,E=a.containerStyle,O=a.containerClassName,k=a.loaderStyle,j=a.loaderClassName,F=a.textAreaComponent,B=a.renderToBody,R=this.state,z=R.left,H=R.top,Y=R.dataLoading,U=R.component,J=R.value,Q=R.textToReplace,le=this._isAutocompleteOpen(),pe=this._getSuggestions(),ie={},se;return F.component?(se=F.component,ie[F.ref]=this._textareaRef):(se=F,ie.ref=this._textareaRef),$.createElement("div",{className:"rta ".concat(Y===!0?"rta--loading":""," ").concat(O||""),style:E},$.createElement(se,Object.assign({},this._cleanUpProps(),{className:"rta__textarea ".concat(c||""),onChange:this._changeHandler,onSelect:this._selectHandler,onScroll:this._onScrollHandler,onClick:this._onClick,onBlur:this._onBlur,value:J,style:s},ie)),le&&$.createElement(Y8,{innerRef:function(oe){r.dropdownRef=oe},top:H,left:z,style:T,className:S,movePopupAsYouType:g,boundariesElement:m,textareaRef:this.textareaRef,renderToBody:B},pe&&U&&Q&&$.createElement(B8,{values:pe,component:U,style:d,className:v,itemClassName:D,itemStyle:p,getTextToReplace:Q,onItemHighlighted:this._onItemHighlightedHandler,onSelect:this._onSelect,dropdownScroll:this._dropdownScroll}),Y&&$.createElement("div",{className:"rta__loader ".concat(pe!==null?"rta__loader--suggestion-data":"rta__loader--empty-suggestion-data"," ").concat(j||""),style:k},$.createElement(o,{data:pe}))))}}],[{key:"getDerivedStateFromProps",value:function(r){var a=r.value;return a==null?null:{value:a}}}]),t}($.Component);WT.defaultProps={movePopupAsYouType:!1,value:null,minChar:1,boundariesElement:"body",scrollToItem:!0,textAreaComponent:"textarea",renderToBody:!1};const z8=()=>{const{app:e}=Xe.getState(),t=e.metadataCache.getTags();return[...Object.keys(t)].map(n=>n.split("#").pop())},U8=e=>{let t=[];const n=Xe.getState().settings;if(n&&(n!=null&&n.UseVaultTags))t=z8();else{const{tags:o}=Te.getState();t=o}const r=e.toLowerCase(),a=[];return t.forEach(o=>{o&&o.toLowerCase().contains(r)&&a.push({name:o,char:o})}),a},V8=e=>{const{app:t}=Xe.getState(),n=t.vault.getAllLoadedFiles(),r=[];let a;return n.forEach(o=>{e==="["?a="":e.contains("[")&&(a=e.slice(1));const s=a.toLowerCase();o instanceof C.TFile&&["md","png","jpg","canvas","jpeg","gif"].contains(o.extension)&&o.path.toLowerCase().contains(s)&&r.push({name:o.basename,char:o.name,file:o})}),r};var P0=A,Z8=function(e){return typeof e=="function"},W8=function(e){var t=P0.useState(e),n=t[0],r=t[1],a=P0.useRef(n),o=P0.useCallback(function(s){a.current=Z8(s)?s(a.current):s,r(a.current)},[]);return[n,o,a]},$8=W8;const Kr=er($8);function qh(e,t){const n=Object.keys(t).map(r=>G8(e,r,t[r]));return n.length===1?n[0]:function(){n.forEach(r=>r())}}function G8(e,t,n){const r=e[t],a=e.hasOwnProperty(t);let o=n(r);return r&&Object.setPrototypeOf(o,r),Object.setPrototypeOf(s,o),e[t]=s,c;function s(...d){return o===r&&e[t]===s&&c(),o.apply(this,d)}function c(){e[t]===s&&(a?e[t]=r:delete e[t]),o!==r&&(o=r,Object.setPrototypeOf(s,r||Function))}}function q8(e){return e.containerEl.matches(".memos-list-view")}const J8=e=>{const{dailyNotesState:{app:t,plugin:n,editor:r,view:a,dailyNotes:o}}=A.useContext(mt),[s,c]=A.useState(null),[d,p]=A.useState(!1),[m,g]=A.useState(""),[v,D]=A.useState(null),S=A.useRef(C.debounce((z,H)=>{Q8(z,H)},100));A.useEffect(()=>{var z;if(!v){if(!o){const H=(z=t||window.app)==null?void 0:z.vault.getMarkdownFiles();D(H[0]);return}for(const H in o)if(o[H]instanceof C.TFile){D(o[H]);break}}},[o]),A.useEffect(()=>{if(!(!e||!r)&&!d)return k(e),()=>{p(!1),s==null||s.destroy()}},[r,e]),A.useEffect(()=>{if(!s||!t)return;const z=K8(t);g(z),(s==null?void 0:s.editor).replaceSelection(z)},[s,t]),A.useEffect(()=>{!s||!t||S.current(m,t)},[m,t]);const T=()=>{s&&s.toggleSource()},E=C.debounce((z,H)=>O(z,H),500,!0),O=(z,H)=>{z&&g(H)},k=z=>{if(!a){new C.Notice(N("Please open thino first"));return}if(r&&a){a.register(qh(r.constructor.prototype,{onUpdate:Y=>function(...U){if(Y.call(this,U),this.owner.getViewType()==="thino_view"||this.owner instanceof wl){const J=this.get();E(this.owner,J)}},getMode:()=>function(){return"source"}})),a.register(qh(C.Workspace.prototype,{getActiveViewOfType:Y=>function(U){const J=Y.call(this,U);if(!J&&(U==null?void 0:U.VIEW_TYPE)==="markdown"){const Q=this.activeLeaf;if(Q.view instanceof wl)return Q.view}return J},setActiveLeaf:Y=>function(U,J){if(q8(U)&&(Y.call(this,U,J),U.activeTime=17e11),Y.call(this,U,J),U.view instanceof wl){const Q=Qe.getState().instanceList.get(U.id);if(!Q)return;self.app.workspace.activeEditor=Q.owner,U.view.editor=Q.editor}},getActiveFile:Y=>function(){var J;const U=Y.call(this);return((J=this.activeLeaf)==null?void 0:J.view)instanceof wl&&v||U}}));const H=new r.constructor(a.app,z,a);H.owner.editor=H.editor,H.set&&H.set("",!0),H.owner.onMarkdownScroll=()=>{},t.workspace.trigger("thino-editor-created",z,H.editor),p(!0),c(H),Qe.setInstance(`${a.leaf.id}`,H)}};return{instance:s,value:m,set:z=>{try{s&&((s==null?void 0:s.editor).replaceSelection(z),g(z))}catch(H){console.error(H)}},get:()=>s?s.get():"",append:(z,H)=>{if(!s||H&&H!==s.owner.leaf.id)return;const U=(s.get()||"")+z;(s==null?void 0:s.editor).replaceSelection(z),g(U)},clear:()=>{s&&(s.clear(),g(""))},toggleSource:T}};function $T(e){return`thinoEditorContentCache:${e}`}function K8(e){try{const t=$T(e==null?void 0:e.appId);return Kn.get([t])[t]||""}catch(t){return console.error(t),""}}function Q8(e,t){try{const n=$T(t==null?void 0:t.appId);Kn.set({[n]:e})}catch(n){console.error(n)}}function X8(e,t){return{line:e.line,ch:e.ch+t}}const LD=({entity:{name:e,char:t,file:n}})=>w.jsx("div",{children:`${t}`}),e9=({data:e})=>w.jsx("div",{children:"Loading"});let wi;const t9=A.forwardRef((e,t)=>{var Ie;const{globalState:{useTinyUndoHistoryCache:n,globalEditorShown:r,memoListView:a},dailyNotesState:{settings:o,app:s}}=A.useContext(mt),{SaveMemoButtonLabel:c,SaveMemoButtonIcon:d}=o,{className:p,inputerType:m,initialContent:g,placeholder:v,showConfirmBtn:D,showCancelBtn:S,onConfirmBtnClick:T,onCancelBtnClick:E,onContentChange:O}=e,k=A.useRef(null),j=A.useRef(null),F=A.useRef(null),B=I8(),{instance:R,value:z,set:H,get:Y,append:U,clear:J,toggleSource:Q}=J8(j.current),[,le,pe]=Kr(0),[ie,se]=Kr(!1);A.useEffect(()=>{var De,ke;if(o&&o.FocusOnEditor)switch(m){case"minimal":case"memos":(De=k.current)==null||De.focus();break;case"obsidian":R&&((ke=R.editor)==null||ke.focus())}},[o,R]),A.useEffect(()=>{if(!s)return;const De=s.workspace.getLeavesOfType(_r);let ke,Ye;De.length>0?(Ye=De[0].view.containerEl,ke=Ye.offsetHeight):(Ye=document,ke=window.outerHeight),le(ke)},[s]),A.useEffect(()=>{!k.current||m==="obsidian"||g&&(k.current.value=g,B())},[]),A.useEffect(()=>{var De;if(m!=="obsidian")if(n){if(!k.current)return;const{tinyUndoActionsCache:ke,tinyUndoIndexCache:Ye}=Kn.get(["tinyUndoActionsCache","tinyUndoIndexCache"]);return F.current=new S8(k.current,{interval:5e3,initialActions:ke,initialIndex:Ye}),F.current.subscribe((Re,rt)=>{Kn.set({tinyUndoActionsCache:Re,tinyUndoIndexCache:rt})}),()=>{var Re;(Re=F.current)==null||Re.destroy()}}else(De=F.current)==null||De.destroy(),F.current=null,Kn.remove(["tinyUndoActionsCache","tinyUndoIndexCache"])},[n]),A.useEffect(()=>{k.current&&(k.current.style.height="auto",k.current.style.height=(k.current.scrollHeight??0)+"px")},[(Ie=k.current)==null?void 0:Ie.value]),A.useImperativeHandle(t,()=>({element:k.current,blur:()=>{var De,ke;switch(m){case"minimal":case"memos":(De=k.current)==null||De.blur();break;case"obsidian":R&&((ke=R.editor)==null||ke.blur())}},focus:De=>{var ke,Ye,Re,rt,Ht;switch(m){case"minimal":case"memos":(ke=k.current)==null||ke.focus();break;case"obsidian":if(R){if(De&&De!==((rt=(Re=(Ye=R==null?void 0:R.owner)==null?void 0:Ye.view)==null?void 0:Re.leaf)==null?void 0:rt.id))return;(Ht=R.editor)==null||Ht.focus()}}},insertTag:De=>{var ke,Ye,Re;switch(m){case"minimal":case"memos":{if(!k.current)return;const rt=k.current.value;k.current.value=rt.slice(0,k.current.selectionStart)+"# "+rt.slice(k.current.selectionStart),O(k.current.value),B();break}case"obsidian":if(De&&De!==((Re=(Ye=(ke=R==null?void 0:R.owner)==null?void 0:ke.view)==null?void 0:Ye.leaf)==null?void 0:Re.id))return;if(R){const rt=R.editor,Ht=rt.getCursor("from");rt.replaceRange("#",Ht),rt.setSelection(X8(Ht,1))}break}},insertText:(De,ke)=>{switch(m){case"minimal":case"memos":{if(!k.current)return;const Ye=k.current.value;k.current.value=Ye.slice(0,k.current.selectionStart)+De+Ye.slice(k.current.selectionStart),O(k.current.value),B()}break;case"obsidian":R&&U(De,ke);break}},setContent:De=>{switch(m){case"minimal":case"memos":k.current&&(k.current.value=De,O(k.current.value),B());break;case"obsidian":R&&H(De);break}},getContent:()=>{switch(m){case"minimal":case"memos":return k.current?k.current.value:"";case"obsidian":return Y()}},toggleSource:()=>{switch(m){case"minimal":case"memos":break;case"obsidian":Q();break}},clear:()=>{switch(m){case"minimal":case"memos":k.current&&(k.current.value="",O(k.current.value),B());break;case"obsidian":J();break}}}),[R,m]);const fe=De=>{if(!k.current)return;const{fileManager:ke}=Ee.getState().dailyNotesState.app;if(De.currentTrigger==="#"){const Ye=k.current.value;let Re;wi!=null?Re=wi.length:Re=0;let rt=k.current.selectionStart;for(let Ht=0;Ht{var De;O(((De=k.current)==null?void 0:De.value)||""),B()},[]),we=()=>{var De;switch(m){case"minimal":case"memos":if(!k.current)return;k.current.value=G(),T(k.current.value),k.current.value="",B(),(De=F.current)==null||De.resetState();break;case"obsidian":T(Y()),J(),B();break}},Z=A.useCallback(()=>{switch(m){case"minimal":case"memos":k.current&&(k.current.value="",O(k.current.value),B());break;case"obsidian":J();break}E()},[m,R,k]),G=()=>Kn.get(["thinoEditorContentCache"]).thinoEditorContentCache||"",te=()=>{if(k.current)return k.current.value=G(),k.current.value},ge=De=>{switch(De){case"memos":return w.jsx(WT,{className:`common-editor-inputer scroll ${ie?" editing":""}`,loadingComponent:e9,placeholder:v,movePopupAsYouType:!0,value:te(),innerRef:ke=>{k.current=ke},onFocus:()=>{se(!0)},onBlur:()=>{se(!1)},onInput:oe,style:{maxHeight:`${pe.current>400?pe.current-400:100}px`},dropdownStyle:{minWidth:180,maxHeight:250,overflowY:"auto"},minChar:0,onItemSelected:fe,scrollToItem:!0,trigger:{"#":{dataProvider:ke=>(wi=ke,U8(ke).map(({name:Ye,char:Re})=>({name:Ye,char:Re}))),component:LD,afterWhitespace:!0,output:ke=>ke.char},"[[":{dataProvider:ke=>(wi=ke,V8(ke).slice(0,10).map(({name:Ye,char:Re,file:rt})=>({name:Ye,char:Re,file:rt}))),component:LD,afterWhitespace:!0,output:ke=>ke.char}}});case"minimal":return w.jsx("textarea",{style:{minHeight:48},className:"common-editor-inputer scroll",rows:1,placeholder:v,ref:k,onInput:oe});case"obsidian":return w.jsx("div",{className:"common-editor-inputer common-editor-mod-cm6",ref:j});default:return w.jsx("div",{className:"common-editor-inputer common-editor-mod-cm6",ref:j})}};return w.jsxs("div",{className:"common-editor-wrapper "+p,children:[ge(m),w.jsxs("div",{className:"common-tools-wrapper",children:[w.jsx("div",{className:"common-tools-container",children:w.jsx(so,{when:e.tools!==void 0,children:e.tools})}),w.jsxs("div",{className:"btns-container",children:[w.jsx(so,{when:S,children:w.jsx("button",{className:"action-btn cancel-btn",onClick:()=>{o&&o.DefaultEditorLocation==="Top"&&!r&&Z()},onPointerDown:()=>{(o&&o.DefaultEditorLocation==="Bottom"||r)&&Z()},children:He.getState().pathname==="/"&&a==="chat"&&((o==null?void 0:o.chatViewStyle)==="fluent"||(o==null?void 0:o.chatViewStyle)==="inline")?"":N("CANCEL EDIT")})}),w.jsx(so,{when:D,children:w.jsxs("button",{title:"Ctrl/Cmd + Enter to save thino",className:"action-btn confirm-btn",onClick:()=>{o&&o.DefaultEditorLocation==="Top"&&!r&&we()},onPointerDown:()=>{(o&&o.DefaultEditorLocation==="Bottom"||r)&&we()},children:[a==="chat"&&((o==null?void 0:o.chatViewStyle)==="fluent"||(o==null?void 0:o.chatViewStyle)==="inline")?"":c,w.jsx("span",{className:"icon-text",children:a==="chat"&&((o==null?void 0:o.chatViewStyle)==="fluent"||(o==null?void 0:o.chatViewStyle)==="inline")?null:d})]})})]})]})]})}),n9=typeof window<"u"?A.useLayoutEffect:A.useEffect;function r9(e,t,n,r){const a=A.useRef(t);n9(()=>{a.current=t},[t]),A.useEffect(()=>{const o=(n==null?void 0:n.current)||window;if(!(o&&o.addEventListener))return;const s=c=>{a.current(c)};return o.addEventListener(e,s,r),()=>{o.removeEventListener(e,s,r)}},[e,n,r])}function Pp(e,t,n="mousedown"){r9(n,r=>{const a=r.target;if(!a||!a.isConnected||a.closest(".suggestion-container")||a.closest(".menu"))return;(Array.isArray(e)?e.every(s=>s.current&&!s.current.contains(a)):e.current&&!e.current.contains(a))&&t(r)})}const GT=e=>{const{year:t,handleYearChange:n}=e,[r,a]=A.useState([]),[o,s]=A.useState(t),c=A.useRef(null),d=A.useRef(null),[p,m]=$.useState(!1),g=$.useRef(null);Pp(g,()=>{m(!1)}),A.useEffect(()=>{c.current&&C.setIcon(c.current,"chevron-left"),d.current&&C.setIcon(d.current,"chevron-right")},[c,d,p]),A.useEffect(()=>{D(o)},[t]);const D=S=>{const T=parseInt(S),E=T-T%10,O=[];for(let k=0;k<10;k++)O.push(`${E+k}`);a(O)};return w.jsxs(w.Fragment,{children:[w.jsxs("span",{className:"btn year-btn",onClick:()=>{m(!p)},children:[w.jsx("span",{children:t}),w.jsx("span",{children:N("year")})]}),p&&w.jsxs("div",{ref:g,className:"year-picker-wrapper",children:[w.jsxs("div",{className:"year-picker-header",children:[w.jsxs("div",{className:"year-picker-header-title",children:[o," "+(N("year")||"")]}),w.jsxs("div",{className:"year-picker-header-btns",children:[w.jsx("span",{className:"btn",ref:c,onClick:()=>{const S=parseInt(o)-10;s(S.toString()),D(S.toString())}}),w.jsx("span",{className:"btn",ref:d,onClick:()=>{const S=parseInt(o)+10;s(S.toString()),D(S.toString())}})]})]}),w.jsx("div",{className:"year-picker-body",children:w.jsx("div",{className:"year-picker-body-list",children:r.map(S=>w.jsx("div",{className:`year-picker-body-item ${S===o?"selected":""}`,onClick:()=>{s(S),n(S),m(!1)},children:S},S))})})]})]})},qT=e=>{const{month:t,handleMonthChange:n}=e,[r,a]=A.useState([]),[o,s]=A.useState((parseInt(t)+1).toString()),[c,d]=$.useState(!1),p=$.useRef(null);Pp(p,()=>{d(!1)}),A.useEffect(()=>{g()},[t]);const g=()=>{const v=[];for(let D=1;D<=12;D++)v.push(`${D}`);a(v)};return w.jsxs(w.Fragment,{children:[w.jsxs("span",{className:"btn month-btn",onClick:()=>{d(!c)},children:[w.jsxs("span",{children:[N("monthsShort")[parseInt(t)]||parseInt(t)+1," "]}),w.jsx("span",{children:N("month")||""})]}),c&&w.jsxs("div",{ref:p,className:"month-picker-wrapper",children:[w.jsxs("div",{className:"month-picker-header",children:[w.jsxs("div",{className:"month-picker-header-title",children:[o," "+(N("month")||"")]}),w.jsx("div",{className:"month-picker-header-btns"})]}),w.jsx("div",{className:"month-picker-body",children:w.jsx("div",{className:"month-picker-body-list",children:r.map(v=>w.jsx("div",{className:`month-picker-body-item ${v===o?"selected":""}`,onClick:()=>{s(v),n(v),d(!1)},children:v},v))})})]})]})},zy=e=>{const{className:t,datestamp:n,handleDateStampChange:r}=e,[a,o]=A.useState(Ph(n)),[s,c]=A.useState(n);A.useEffect(()=>{o(Ph(n))},[n]);const d=new Date(a),p=d.getDay(),m=[];for(let S=0;S{r(T,S.nativeEvent),c(T)},D=S=>{const T=d.getFullYear(),E=d.getMonth()+1;let O=0;E===1&&S===-1?O=new Date(`${T-1}/12/1`).getTime():E===12&&S===1?O=new Date(`${T+1}/1/1`).getTime():O=new Date(`${T}/${E+S}/1`).getTime(),o(Ph(O))};return w.jsxs("div",{className:`date-picker-wrapper ${t}`,children:[w.jsxs("div",{className:"date-picker-header",children:[w.jsx("span",{ref:S=>{S&&C.setIcon(S,"chevron-left")},className:"btn btn-text",onClick:()=>D(-1)}),w.jsxs("span",{className:"normal-text",children:[w.jsx(GT,{year:d.getFullYear().toString(),handleYearChange:S=>{o(Ph(new Date(`${S}/${d.getMonth()+1}/1`).getTime()))}}),w.jsx(qT,{month:d.getMonth().toString(),handleMonthChange:S=>{o(Ph(new Date(`${d.getFullYear()}/${parseInt(S)}/1`).getTime()))}})]}),w.jsx("span",{ref:S=>{S&&C.setIcon(S,"chevron-right")},className:"btn btn-text",onClick:()=>D(1)})]}),w.jsxs("div",{className:"date-picker-day-container",children:[w.jsx("div",{className:"date-picker-day-header",children:N("weekDaysShort").map(S=>w.jsx("span",{className:"day-item",children:S},S))}),w.jsx("div",{className:"date-picker-day-content",children:m.map(S=>S.date===0?w.jsx("span",{className:"day-item null",children:""},S.datestamp):w.jsx("span",{className:`day-item ${S.datestamp===n?"current":""} ${S.datestamp===s?"selected":""}`,onClick:T=>v(T,S.datestamp),children:w.jsx("span",{className:"day-item-text",children:S.date})},S.datestamp))})]})]})};function a9(e){const t=new Date(e),n=new Date(`${t.getFullYear()}/${t.getMonth()+1}/1`);return((n.getMonth()===11?new Date(`${n.getFullYear()+1}/1/1`):new Date(`${n.getFullYear()}/${n.getMonth()+2}/1`)).getTime()-n.getTime())/Mi}function Ph(e){const t=new Date(e);return new Date(`${t.getFullYear()}/${t.getMonth()+1}/1`).getTime()}var RD=function(t){return t.reduce(function(n,r){var a=r[0],o=r[1];return n[a]=o,n},{})},BD=typeof window<"u"&&window.document&&window.document.createElement?A.useLayoutEffect:A.useEffect,wa="top",uo="bottom",co="right",ba="left",C1="auto",jp=[wa,uo,co,ba],kd="start",rp="end",o9="clippingParents",JT="viewport",jh="popper",i9="reference",_D=jp.reduce(function(e,t){return e.concat([t+"-"+kd,t+"-"+rp])},[]),x1=[].concat(jp,[C1]).reduce(function(e,t){return e.concat([t,t+"-"+kd,t+"-"+rp])},[]),s9="beforeRead",l9="read",u9="afterRead",c9="beforeMain",d9="main",f9="afterMain",h9="beforeWrite",p9="write",m9="afterWrite",g9=[s9,l9,u9,c9,d9,f9,h9,p9,m9];function Ai(e){return e?(e.nodeName||"").toLowerCase():null}function za(e){if(e==null)return window;if(e.toString()!=="[object Window]"){var t=e.ownerDocument;return t&&t.defaultView||window}return e}function Au(e){var t=za(e).Element;return e instanceof t||e instanceof Element}function lo(e){var t=za(e).HTMLElement;return e instanceof t||e instanceof HTMLElement}function M1(e){if(typeof ShadowRoot>"u")return!1;var t=za(e).ShadowRoot;return e instanceof t||e instanceof ShadowRoot}function y9(e){var t=e.state;Object.keys(t.elements).forEach(function(n){var r=t.styles[n]||{},a=t.attributes[n]||{},o=t.elements[n];!lo(o)||!Ai(o)||(Object.assign(o.style,r),Object.keys(a).forEach(function(s){var c=a[s];c===!1?o.removeAttribute(s):o.setAttribute(s,c===!0?"":c)}))})}function v9(e){var t=e.state,n={popper:{position:t.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};return Object.assign(t.elements.popper.style,n.popper),t.styles=n,t.elements.arrow&&Object.assign(t.elements.arrow.style,n.arrow),function(){Object.keys(t.elements).forEach(function(r){var a=t.elements[r],o=t.attributes[r]||{},s=Object.keys(t.styles.hasOwnProperty(r)?t.styles[r]:n[r]),c=s.reduce(function(d,p){return d[p]="",d},{});!lo(a)||!Ai(a)||(Object.assign(a.style,c),Object.keys(o).forEach(function(d){a.removeAttribute(d)}))})}}const w9={name:"applyStyles",enabled:!0,phase:"write",fn:y9,effect:v9,requires:["computeStyles"]};function Ni(e){return e.split("-")[0]}var Mu=Math.max,hy=Math.min,Ad=Math.round;function kw(){var e=navigator.userAgentData;return e!=null&&e.brands&&Array.isArray(e.brands)?e.brands.map(function(t){return t.brand+"/"+t.version}).join(" "):navigator.userAgent}function KT(){return!/^((?!chrome|android).)*safari/i.test(kw())}function Fd(e,t,n){t===void 0&&(t=!1),n===void 0&&(n=!1);var r=e.getBoundingClientRect(),a=1,o=1;t&&lo(e)&&(a=e.offsetWidth>0&&Ad(r.width)/e.offsetWidth||1,o=e.offsetHeight>0&&Ad(r.height)/e.offsetHeight||1);var s=Au(e)?za(e):window,c=s.visualViewport,d=!KT()&&n,p=(r.left+(d&&c?c.offsetLeft:0))/a,m=(r.top+(d&&c?c.offsetTop:0))/o,g=r.width/a,v=r.height/o;return{width:g,height:v,top:m,right:p+g,bottom:m+v,left:p,x:p,y:m}}function N1(e){var t=Fd(e),n=e.offsetWidth,r=e.offsetHeight;return Math.abs(t.width-n)<=1&&(n=t.width),Math.abs(t.height-r)<=1&&(r=t.height),{x:e.offsetLeft,y:e.offsetTop,width:n,height:r}}function QT(e,t){var n=t.getRootNode&&t.getRootNode();if(e.contains(t))return!0;if(n&&M1(n)){var r=t;do{if(r&&e.isSameNode(r))return!0;r=r.parentNode||r.host}while(r)}return!1}function ms(e){return za(e).getComputedStyle(e)}function b9(e){return["table","td","th"].indexOf(Ai(e))>=0}function Tl(e){return((Au(e)?e.ownerDocument:e.document)||window.document).documentElement}function Uy(e){return Ai(e)==="html"?e:e.assignedSlot||e.parentNode||(M1(e)?e.host:null)||Tl(e)}function HD(e){return!lo(e)||ms(e).position==="fixed"?null:e.offsetParent}function D9(e){var t=/firefox/i.test(kw()),n=/Trident/i.test(kw());if(n&&lo(e)){var r=ms(e);if(r.position==="fixed")return null}var a=Uy(e);for(M1(a)&&(a=a.host);lo(a)&&["html","body"].indexOf(Ai(a))<0;){var o=ms(a);if(o.transform!=="none"||o.perspective!=="none"||o.contain==="paint"||["transform","perspective"].indexOf(o.willChange)!==-1||t&&o.willChange==="filter"||t&&o.filter&&o.filter!=="none")return a;a=a.parentNode}return null}function Lp(e){for(var t=za(e),n=HD(e);n&&b9(n)&&ms(n).position==="static";)n=HD(n);return n&&(Ai(n)==="html"||Ai(n)==="body"&&ms(n).position==="static")?t:n||D9(e)||t}function k1(e){return["top","bottom"].indexOf(e)>=0?"x":"y"}function Jh(e,t,n){return Mu(e,hy(t,n))}function S9(e,t,n){var r=Jh(e,t,n);return r>n?n:r}function XT(){return{top:0,right:0,bottom:0,left:0}}function eE(e){return Object.assign({},XT(),e)}function tE(e,t){return t.reduce(function(n,r){return n[r]=e,n},{})}var I9=function(t,n){return t=typeof t=="function"?t(Object.assign({},n.rects,{placement:n.placement})):t,eE(typeof t!="number"?t:tE(t,jp))};function T9(e){var t,n=e.state,r=e.name,a=e.options,o=n.elements.arrow,s=n.modifiersData.popperOffsets,c=Ni(n.placement),d=k1(c),p=[ba,co].indexOf(c)>=0,m=p?"height":"width";if(!(!o||!s)){var g=I9(a.padding,n),v=N1(o),D=d==="y"?wa:ba,S=d==="y"?uo:co,T=n.rects.reference[m]+n.rects.reference[d]-s[d]-n.rects.popper[m],E=s[d]-n.rects.reference[d],O=Lp(o),k=O?d==="y"?O.clientHeight||0:O.clientWidth||0:0,j=T/2-E/2,F=g[D],B=k-v[m]-g[S],R=k/2-v[m]/2+j,z=Jh(F,R,B),H=d;n.modifiersData[r]=(t={},t[H]=z,t.centerOffset=z-R,t)}}function E9(e){var t=e.state,n=e.options,r=n.element,a=r===void 0?"[data-popper-arrow]":r;a!=null&&(typeof a=="string"&&(a=t.elements.popper.querySelector(a),!a)||QT(t.elements.popper,a)&&(t.elements.arrow=a))}const nE={name:"arrow",enabled:!0,phase:"main",fn:T9,effect:E9,requires:["popperOffsets"],requiresIfExists:["preventOverflow"]};function Od(e){return e.split("-")[1]}var C9={top:"auto",right:"auto",bottom:"auto",left:"auto"};function x9(e,t){var n=e.x,r=e.y,a=t.devicePixelRatio||1;return{x:Ad(n*a)/a||0,y:Ad(r*a)/a||0}}function YD(e){var t,n=e.popper,r=e.popperRect,a=e.placement,o=e.variation,s=e.offsets,c=e.position,d=e.gpuAcceleration,p=e.adaptive,m=e.roundOffsets,g=e.isFixed,v=s.x,D=v===void 0?0:v,S=s.y,T=S===void 0?0:S,E=typeof m=="function"?m({x:D,y:T}):{x:D,y:T};D=E.x,T=E.y;var O=s.hasOwnProperty("x"),k=s.hasOwnProperty("y"),j=ba,F=wa,B=window;if(p){var R=Lp(n),z="clientHeight",H="clientWidth";if(R===za(n)&&(R=Tl(n),ms(R).position!=="static"&&c==="absolute"&&(z="scrollHeight",H="scrollWidth")),a===wa||(a===ba||a===co)&&o===rp){F=uo;var Y=g&&R===B&&B.visualViewport?B.visualViewport.height:R[z];T-=Y-r.height,T*=d?1:-1}if(a===ba||(a===wa||a===uo)&&o===rp){j=co;var U=g&&R===B&&B.visualViewport?B.visualViewport.width:R[H];D-=U-r.width,D*=d?1:-1}}var J=Object.assign({position:c},p&&C9),Q=m===!0?x9({x:D,y:T},za(n)):{x:D,y:T};if(D=Q.x,T=Q.y,d){var le;return Object.assign({},J,(le={},le[F]=k?"0":"",le[j]=O?"0":"",le.transform=(B.devicePixelRatio||1)<=1?"translate("+D+"px, "+T+"px)":"translate3d("+D+"px, "+T+"px, 0)",le))}return Object.assign({},J,(t={},t[F]=k?T+"px":"",t[j]=O?D+"px":"",t.transform="",t))}function M9(e){var t=e.state,n=e.options,r=n.gpuAcceleration,a=r===void 0?!0:r,o=n.adaptive,s=o===void 0?!0:o,c=n.roundOffsets,d=c===void 0?!0:c,p={placement:Ni(t.placement),variation:Od(t.placement),popper:t.elements.popper,popperRect:t.rects.popper,gpuAcceleration:a,isFixed:t.options.strategy==="fixed"};t.modifiersData.popperOffsets!=null&&(t.styles.popper=Object.assign({},t.styles.popper,YD(Object.assign({},p,{offsets:t.modifiersData.popperOffsets,position:t.options.strategy,adaptive:s,roundOffsets:d})))),t.modifiersData.arrow!=null&&(t.styles.arrow=Object.assign({},t.styles.arrow,YD(Object.assign({},p,{offsets:t.modifiersData.arrow,position:"absolute",adaptive:!1,roundOffsets:d})))),t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-placement":t.placement})}const rE={name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:M9,data:{}};var Fg={passive:!0};function N9(e){var t=e.state,n=e.instance,r=e.options,a=r.scroll,o=a===void 0?!0:a,s=r.resize,c=s===void 0?!0:s,d=za(t.elements.popper),p=[].concat(t.scrollParents.reference,t.scrollParents.popper);return o&&p.forEach(function(m){m.addEventListener("scroll",n.update,Fg)}),c&&d.addEventListener("resize",n.update,Fg),function(){o&&p.forEach(function(m){m.removeEventListener("scroll",n.update,Fg)}),c&&d.removeEventListener("resize",n.update,Fg)}}const aE={name:"eventListeners",enabled:!0,phase:"write",fn:function(){},effect:N9,data:{}};var k9={left:"right",right:"left",bottom:"top",top:"bottom"};function Kg(e){return e.replace(/left|right|bottom|top/g,function(t){return k9[t]})}var A9={start:"end",end:"start"};function zD(e){return e.replace(/start|end/g,function(t){return A9[t]})}function A1(e){var t=za(e),n=t.pageXOffset,r=t.pageYOffset;return{scrollLeft:n,scrollTop:r}}function F1(e){return Fd(Tl(e)).left+A1(e).scrollLeft}function F9(e,t){var n=za(e),r=Tl(e),a=n.visualViewport,o=r.clientWidth,s=r.clientHeight,c=0,d=0;if(a){o=a.width,s=a.height;var p=KT();(p||!p&&t==="fixed")&&(c=a.offsetLeft,d=a.offsetTop)}return{width:o,height:s,x:c+F1(e),y:d}}function O9(e){var t,n=Tl(e),r=A1(e),a=(t=e.ownerDocument)==null?void 0:t.body,o=Mu(n.scrollWidth,n.clientWidth,a?a.scrollWidth:0,a?a.clientWidth:0),s=Mu(n.scrollHeight,n.clientHeight,a?a.scrollHeight:0,a?a.clientHeight:0),c=-r.scrollLeft+F1(e),d=-r.scrollTop;return ms(a||n).direction==="rtl"&&(c+=Mu(n.clientWidth,a?a.clientWidth:0)-o),{width:o,height:s,x:c,y:d}}function O1(e){var t=ms(e),n=t.overflow,r=t.overflowX,a=t.overflowY;return/auto|scroll|overlay|hidden/.test(n+a+r)}function oE(e){return["html","body","#document"].indexOf(Ai(e))>=0?e.ownerDocument.body:lo(e)&&O1(e)?e:oE(Uy(e))}function Kh(e,t){var n;t===void 0&&(t=[]);var r=oE(e),a=r===((n=e.ownerDocument)==null?void 0:n.body),o=za(r),s=a?[o].concat(o.visualViewport||[],O1(r)?r:[]):r,c=t.concat(s);return a?c:c.concat(Kh(Uy(s)))}function Aw(e){return Object.assign({},e,{left:e.x,top:e.y,right:e.x+e.width,bottom:e.y+e.height})}function P9(e,t){var n=Fd(e,!1,t==="fixed");return n.top=n.top+e.clientTop,n.left=n.left+e.clientLeft,n.bottom=n.top+e.clientHeight,n.right=n.left+e.clientWidth,n.width=e.clientWidth,n.height=e.clientHeight,n.x=n.left,n.y=n.top,n}function UD(e,t,n){return t===JT?Aw(F9(e,n)):Au(t)?P9(t,n):Aw(O9(Tl(e)))}function j9(e){var t=Kh(Uy(e)),n=["absolute","fixed"].indexOf(ms(e).position)>=0,r=n&&lo(e)?Lp(e):e;return Au(r)?t.filter(function(a){return Au(a)&&QT(a,r)&&Ai(a)!=="body"}):[]}function L9(e,t,n,r){var a=t==="clippingParents"?j9(e):[].concat(t),o=[].concat(a,[n]),s=o[0],c=o.reduce(function(d,p){var m=UD(e,p,r);return d.top=Mu(m.top,d.top),d.right=hy(m.right,d.right),d.bottom=hy(m.bottom,d.bottom),d.left=Mu(m.left,d.left),d},UD(e,s,r));return c.width=c.right-c.left,c.height=c.bottom-c.top,c.x=c.left,c.y=c.top,c}function iE(e){var t=e.reference,n=e.element,r=e.placement,a=r?Ni(r):null,o=r?Od(r):null,s=t.x+t.width/2-n.width/2,c=t.y+t.height/2-n.height/2,d;switch(a){case wa:d={x:s,y:t.y-n.height};break;case uo:d={x:s,y:t.y+t.height};break;case co:d={x:t.x+t.width,y:c};break;case ba:d={x:t.x-n.width,y:c};break;default:d={x:t.x,y:t.y}}var p=a?k1(a):null;if(p!=null){var m=p==="y"?"height":"width";switch(o){case kd:d[p]=d[p]-(t[m]/2-n[m]/2);break;case rp:d[p]=d[p]+(t[m]/2-n[m]/2);break}}return d}function ap(e,t){t===void 0&&(t={});var n=t,r=n.placement,a=r===void 0?e.placement:r,o=n.strategy,s=o===void 0?e.strategy:o,c=n.boundary,d=c===void 0?o9:c,p=n.rootBoundary,m=p===void 0?JT:p,g=n.elementContext,v=g===void 0?jh:g,D=n.altBoundary,S=D===void 0?!1:D,T=n.padding,E=T===void 0?0:T,O=eE(typeof E!="number"?E:tE(E,jp)),k=v===jh?i9:jh,j=e.rects.popper,F=e.elements[S?k:v],B=L9(Au(F)?F:F.contextElement||Tl(e.elements.popper),d,m,s),R=Fd(e.elements.reference),z=iE({reference:R,element:j,strategy:"absolute",placement:a}),H=Aw(Object.assign({},j,z)),Y=v===jh?H:R,U={top:B.top-Y.top+O.top,bottom:Y.bottom-B.bottom+O.bottom,left:B.left-Y.left+O.left,right:Y.right-B.right+O.right},J=e.modifiersData.offset;if(v===jh&&J){var Q=J[a];Object.keys(U).forEach(function(le){var pe=[co,uo].indexOf(le)>=0?1:-1,ie=[wa,uo].indexOf(le)>=0?"y":"x";U[le]+=Q[ie]*pe})}return U}function R9(e,t){t===void 0&&(t={});var n=t,r=n.placement,a=n.boundary,o=n.rootBoundary,s=n.padding,c=n.flipVariations,d=n.allowedAutoPlacements,p=d===void 0?x1:d,m=Od(r),g=m?c?_D:_D.filter(function(S){return Od(S)===m}):jp,v=g.filter(function(S){return p.indexOf(S)>=0});v.length===0&&(v=g);var D=v.reduce(function(S,T){return S[T]=ap(e,{placement:T,boundary:a,rootBoundary:o,padding:s})[Ni(T)],S},{});return Object.keys(D).sort(function(S,T){return D[S]-D[T]})}function B9(e){if(Ni(e)===C1)return[];var t=Kg(e);return[zD(e),t,zD(t)]}function _9(e){var t=e.state,n=e.options,r=e.name;if(!t.modifiersData[r]._skip){for(var a=n.mainAxis,o=a===void 0?!0:a,s=n.altAxis,c=s===void 0?!0:s,d=n.fallbackPlacements,p=n.padding,m=n.boundary,g=n.rootBoundary,v=n.altBoundary,D=n.flipVariations,S=D===void 0?!0:D,T=n.allowedAutoPlacements,E=t.options.placement,O=Ni(E),k=O===E,j=d||(k||!S?[Kg(E)]:B9(E)),F=[E].concat(j).reduce(function(Ie,De){return Ie.concat(Ni(De)===C1?R9(t,{placement:De,boundary:m,rootBoundary:g,padding:p,flipVariations:S,allowedAutoPlacements:T}):De)},[]),B=t.rects.reference,R=t.rects.popper,z=new Map,H=!0,Y=F[0],U=0;U=0,ie=pe?"width":"height",se=ap(t,{placement:J,boundary:m,rootBoundary:g,altBoundary:v,padding:p}),fe=pe?le?co:ba:le?uo:wa;B[ie]>R[ie]&&(fe=Kg(fe));var oe=Kg(fe),we=[];if(o&&we.push(se[Q]<=0),c&&we.push(se[fe]<=0,se[oe]<=0),we.every(function(Ie){return Ie})){Y=J,H=!1;break}z.set(J,we)}if(H)for(var Z=S?3:1,G=function(De){var ke=F.find(function(Ye){var Re=z.get(Ye);if(Re)return Re.slice(0,De).every(function(rt){return rt})});if(ke)return Y=ke,"break"},te=Z;te>0;te--){var ge=G(te);if(ge==="break")break}t.placement!==Y&&(t.modifiersData[r]._skip=!0,t.placement=Y,t.reset=!0)}}const sE={name:"flip",enabled:!0,phase:"main",fn:_9,requiresIfExists:["offset"],data:{_skip:!1}};function VD(e,t,n){return n===void 0&&(n={x:0,y:0}),{top:e.top-t.height-n.y,right:e.right-t.width+n.x,bottom:e.bottom-t.height+n.y,left:e.left-t.width-n.x}}function ZD(e){return[wa,co,uo,ba].some(function(t){return e[t]>=0})}function H9(e){var t=e.state,n=e.name,r=t.rects.reference,a=t.rects.popper,o=t.modifiersData.preventOverflow,s=ap(t,{elementContext:"reference"}),c=ap(t,{altBoundary:!0}),d=VD(s,r),p=VD(c,a,o),m=ZD(d),g=ZD(p);t.modifiersData[n]={referenceClippingOffsets:d,popperEscapeOffsets:p,isReferenceHidden:m,hasPopperEscaped:g},t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-reference-hidden":m,"data-popper-escaped":g})}const lE={name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:H9};function Y9(e,t,n){var r=Ni(e),a=[ba,wa].indexOf(r)>=0?-1:1,o=typeof n=="function"?n(Object.assign({},t,{placement:e})):n,s=o[0],c=o[1];return s=s||0,c=(c||0)*a,[ba,co].indexOf(r)>=0?{x:c,y:s}:{x:s,y:c}}function z9(e){var t=e.state,n=e.options,r=e.name,a=n.offset,o=a===void 0?[0,0]:a,s=x1.reduce(function(m,g){return m[g]=Y9(g,t.rects,o),m},{}),c=s[t.placement],d=c.x,p=c.y;t.modifiersData.popperOffsets!=null&&(t.modifiersData.popperOffsets.x+=d,t.modifiersData.popperOffsets.y+=p),t.modifiersData[r]=s}const uE={name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:z9};function U9(e){var t=e.state,n=e.name;t.modifiersData[n]=iE({reference:t.rects.reference,element:t.rects.popper,strategy:"absolute",placement:t.placement})}const cE={name:"popperOffsets",enabled:!0,phase:"read",fn:U9,data:{}};function V9(e){return e==="x"?"y":"x"}function Z9(e){var t=e.state,n=e.options,r=e.name,a=n.mainAxis,o=a===void 0?!0:a,s=n.altAxis,c=s===void 0?!1:s,d=n.boundary,p=n.rootBoundary,m=n.altBoundary,g=n.padding,v=n.tether,D=v===void 0?!0:v,S=n.tetherOffset,T=S===void 0?0:S,E=ap(t,{boundary:d,rootBoundary:p,padding:g,altBoundary:m}),O=Ni(t.placement),k=Od(t.placement),j=!k,F=k1(O),B=V9(F),R=t.modifiersData.popperOffsets,z=t.rects.reference,H=t.rects.popper,Y=typeof T=="function"?T(Object.assign({},t.rects,{placement:t.placement})):T,U=typeof Y=="number"?{mainAxis:Y,altAxis:Y}:Object.assign({mainAxis:0,altAxis:0},Y),J=t.modifiersData.offset?t.modifiersData.offset[t.placement]:null,Q={x:0,y:0};if(R){if(o){var le,pe=F==="y"?wa:ba,ie=F==="y"?uo:co,se=F==="y"?"height":"width",fe=R[F],oe=fe+E[pe],we=fe-E[ie],Z=D?-H[se]/2:0,G=k===kd?z[se]:H[se],te=k===kd?-H[se]:-z[se],ge=t.elements.arrow,Ie=D&&ge?N1(ge):{width:0,height:0},De=t.modifiersData["arrow#persistent"]?t.modifiersData["arrow#persistent"].padding:XT(),ke=De[pe],Ye=De[ie],Re=Jh(0,z[se],Ie[se]),rt=j?z[se]/2-Z-Re-ke-U.mainAxis:G-Re-ke-U.mainAxis,Ht=j?-z[se]/2+Z+Re+Ye+U.mainAxis:te+Re+Ye+U.mainAxis,Se=t.elements.arrow&&Lp(t.elements.arrow),Ze=Se?F==="y"?Se.clientTop||0:Se.clientLeft||0:0,Ke=(le=J==null?void 0:J[F])!=null?le:0,Je=fe+rt-Ke-Ze,lt=fe+Ht-Ke,ft=Jh(D?hy(oe,Je):oe,fe,D?Mu(we,lt):we);R[F]=ft,Q[F]=ft-fe}if(c){var Dt,Ct=F==="x"?wa:ba,un=F==="x"?uo:co,Ft=R[B],Ot=B==="y"?"height":"width",an=Ft+E[Ct],wn=Ft-E[un],Tn=[wa,ba].indexOf(O)!==-1,vr=(Dt=J==null?void 0:J[B])!=null?Dt:0,Ia=Tn?an:Ft-z[Ot]-H[Ot]-vr+U.altAxis,tr=Tn?Ft+z[Ot]+H[Ot]-vr-U.altAxis:wn,Nr=D&&Tn?S9(Ia,Ft,tr):Jh(D?Ia:an,Ft,D?tr:wn);R[B]=Nr,Q[B]=Nr-Ft}t.modifiersData[r]=Q}}const dE={name:"preventOverflow",enabled:!0,phase:"main",fn:Z9,requiresIfExists:["offset"]};function W9(e){return{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}}function $9(e){return e===za(e)||!lo(e)?A1(e):W9(e)}function G9(e){var t=e.getBoundingClientRect(),n=Ad(t.width)/e.offsetWidth||1,r=Ad(t.height)/e.offsetHeight||1;return n!==1||r!==1}function q9(e,t,n){n===void 0&&(n=!1);var r=lo(t),a=lo(t)&&G9(t),o=Tl(t),s=Fd(e,a,n),c={scrollLeft:0,scrollTop:0},d={x:0,y:0};return(r||!r&&!n)&&((Ai(t)!=="body"||O1(o))&&(c=$9(t)),lo(t)?(d=Fd(t,!0),d.x+=t.clientLeft,d.y+=t.clientTop):o&&(d.x=F1(o))),{x:s.left+c.scrollLeft-d.x,y:s.top+c.scrollTop-d.y,width:s.width,height:s.height}}function J9(e){var t=new Map,n=new Set,r=[];e.forEach(function(o){t.set(o.name,o)});function a(o){n.add(o.name);var s=[].concat(o.requires||[],o.requiresIfExists||[]);s.forEach(function(c){if(!n.has(c)){var d=t.get(c);d&&a(d)}}),r.push(o)}return e.forEach(function(o){n.has(o.name)||a(o)}),r}function K9(e){var t=J9(e);return g9.reduce(function(n,r){return n.concat(t.filter(function(a){return a.phase===r}))},[])}function Q9(e){var t;return function(){return t||(t=new Promise(function(n){Promise.resolve().then(function(){t=void 0,n(e())})})),t}}function X9(e){var t=e.reduce(function(n,r){var a=n[r.name];return n[r.name]=a?Object.assign({},a,r,{options:Object.assign({},a.options,r.options),data:Object.assign({},a.data,r.data)}):r,n},{});return Object.keys(t).map(function(n){return t[n]})}var WD={placement:"bottom",modifiers:[],strategy:"absolute"};function $D(){for(var e=arguments.length,t=new Array(e),n=0;n({placement:e,modifiers:[{name:"flip",options:{allowedAutoPlacements:t,rootBoundary:"document"}},{name:"preventOverflow",options:{rootBoundary:"document"}}]}),f5=e=>{const n=A.useRef(null),[r,a]=A.useState(null),[o,s]=A.useState(0);let c,d;const p=()=>{if(C.Platform.isMobile){c="right-end",d=["bottom"];return}const g=window.innerWidth-o>280*1.2,v=window.innerWidth-o<280,D=window.innerWidth>280*1.5;if(e.DefaultEditorLocation!=="Bottom"){g?(c="right-end",d=["left-end"]):v&&D?(c="left-end",d=["right-end"]):(c="bottom",d=["bottom"]);return}g?(c="top-end",d=["top-start"]):v&&o>280?(c="top-start",d=["top-end"]):(c="top",d=["top"])};A.useEffect(()=>{e&&p()},[o,e==null?void 0:e.DefaultEditorLocation]);const m=Vy(n.current,r,d5(c,d));return{setPosX:s,popperRef:n,setPopperElement:a,popper:m}},h5=()=>{const e=new Set,t=He.getState().query.filter,n=He.getState().query.tag,r=Et.getQueryById(t||"");if(r&&r.querystring){const a=JSON.parse(r.querystring);if(Array.isArray(a))for(const o of a)o.type==="TAG"&&o.value&&o.value.operator==="CONTAIN"&&e.add(o.value.value)}return n&&e.add(n),Array.from(e)},p5=e=>{const{offsetLeft:t,offsetTop:n,offsetHeight:r,offsetWidth:a,selectionEnd:o}=e,s=document.createElement("div"),c=window.getComputedStyle(e);for(const T of c)s.style.setProperty(T,c.getPropertyValue(T));s.style.position="fixed",s.style.visibility="hidden",s.style.whiteSpace="pre-wrap";const p=e.tagName==="INPUT"?e.value.replace(/ /g,"."):e.value;s.textContent=p.substring(0,o||0),e.tagName==="TEXTAREA"&&(s.style.height="auto");const m=document.createElement("span");m.textContent=p.substring(o||0)||".",s.appendChild(m),document.body.appendChild(s);const{offsetLeft:g,offsetTop:v,offsetHeight:D,offsetWidth:S}=m;return document.body.removeChild(s),{x:t+g,y:n+v,h:r+D,w:a+S}},Nu=({className:e,editorType:t,destroy:n})=>{const{globalState:r,dailyNotesState:{app:a,settings:o,view:s,verifyState:c}}=A.useContext(mt),[d,p]=ki(!0),m=A.useRef(d),[g,v]=Kr(!0),D=A.useRef(null),S=A.useRef(null),T=A.useRef(r),[E,O]=Kr(!1),[k,j]=Kr(!1),{setPosX:F,popperRef:B,setPopperElement:R,popper:z}=f5(o),[H]=Kr(parseInt(C.moment().format("x"))),Y=A.useRef(null),[U,J]=Kr((o==null?void 0:o.EnabledLocationList.length)===1?o==null?void 0:o.EnabledLocationList[0].value:(o==null?void 0:o.MemoSaveLocation)||"DAILY"),Q=A.useRef(o.MemoSaveLocation||"DAILY");A.useEffect(()=>{m.current=d},[d]),A.useEffect(()=>{!S.current||!a||!s||(s.registerEvent(a.workspace.on("focus-on-textarea",Se=>{var Ze;(Ze=S.current)==null||Ze.focus(Se==null?void 0:Se.id)})),s.registerEvent(a.workspace.on("blur-on-memos",()=>{var Se;(Se=S.current)==null||Se.blur()})),s.registerEvent(a.workspace.on("send-to-thino",async(Se,Ze)=>{var Ke,Je;if(typeof Se=="string")(Ke=S.current)==null||Ke.insertText(Se+`
`,Ze.id);else{const lt=Se.toPNG(),ft=new Blob([lt],{type:"image/png"}),Dt=new File([ft],"image.png",{type:"image/png",lastModified:Date.now()});if(!Dt)return;const Ct=await oe(Dt);Ct&&((Je=S.current)==null||Je.insertText(Ct+`
`,Ze.id))}})))},[S,s,a]),A.useEffect(()=>{o&&p(o.DefaultPrefix==="List")},[o==null?void 0:o.DefaultPrefix]),A.useEffect(()=>{if(o){if(o.EnabledLocationList.length===1){J(o.EnabledLocationList[0].value);return}J(o.MemoSaveLocation||"DAILY")}},[o==null?void 0:o.MemoSaveLocation,o==null?void 0:o.EnabledLocationList]),A.useEffect(()=>{var Ke;if(!o||!Y.current)return;const Se=(Ke=tp.find(Je=>Je.title===U))==null?void 0:Ke.icon;C.setIcon(Y.current,Se),C.requireApiVersion("1.4.4")&&C.setTooltip(Y.current,N("Thino Save To: ")+U),Q.current=U;const Ze=r.manifest;if(Ze){const Je=a==null?void 0:a.plugins.getPlugin(Ze.id);if(Je){if(Je.settings.MemoSaveLocation===U)return;Je.settings.MemoSaveLocation=U,Je.saveSettings()}}},[U,g]),A.useEffect(()=>{S.current&&o.MemoSaveLocation&&J(o.MemoSaveLocation)},[Y,o]),A.useEffect(()=>{if(!S.current||!o||C.Platform.isDesktop||r.globalEditorShown)return;const Se=o.UseButtonToShowEditor&&o.DefaultEditorLocation==="Bottom";if(C.Platform.isDesktop){v(!0);return}if(t&&t==="inline"){v(!0);return}if(v(C.Platform.isMobile&&!Se),!Se||r.memoListView==="chat")return;const Ze=document.body.find(".memolist-wrapper");Ze&&(Ze.onscroll=()=>{if(r.globalEditorShown)return;if(!r.memoListView&&Qe.getState().memoListView==="chat"){Ze.onscroll=null;return}const Ke=S.current.getContent();C.Platform.isMobile&&Se&&!Ke&&v(!1)})},[r.globalEditorShown,t,S]);const le=()=>{j(!1)};A.useEffect(()=>{var Se,Ze,Ke,Je,lt,ft,Dt,Ct,un;if(a&&(r.markMemoId||(Se=r.editMemoId)!=null&&Se.trim()&&r.editMemoId!==T.current.editMemoId)){const Ft=a.workspace.getLeavesOfType("thino_view");Ft.length>0&&a.workspace.revealLeaf(Ft[0])}if(r.markMemoId){const Ft=`${N("MARK")}: [@THINO](${r.markMemoId})`;(Ze=S.current)==null||Ze.insertText(Ft),(Ke=S.current)==null||Ke.focus(),Qe.setMarkMemoId("");return}if((Je=r.editMemoId)!=null&&Je.trim()&&r.editMemoId!==T.current.editMemoId){const Ft=Te.getMemoById(r.editMemoId);if(Ft)switch(p(Ft.thinoType==="JOURNAL"),o.EditorType){case"memos":(lt=S.current)==null||lt.setContent(Ft.content.replace(/ \^\S{6}$/,"")||""),(ft=S.current)==null||ft.focus();break;case"obsidian":(Dt=S.current)==null||Dt.clear(),(Ct=S.current)==null||Ct.setContent(Ft.content.replace(/ \^\S{6}$/,"")||""),(un=S.current)==null||un.focus();break}}T.current=r},[r.markMemoId,r.editMemoId]),A.useEffect(()=>{var Se,Ze,Ke;!S.current||E||o.EditorType==="memos"&&((Se=S.current)==null||Se.element.addEventListener("paste",pe),(Ze=S.current)==null||Ze.element.addEventListener("drop",ie),(Ke=S.current)==null||Ke.element.addEventListener("click",se),O(!0))},[S.current]);const pe=async Se=>{var Ze;if(Se.clipboardData&&Se.clipboardData.files.length>0){Se.preventDefault();const Ke=Se.clipboardData.files;for(const Je of Ke){const lt=await oe(Je);lt&&((Ze=S.current)==null||Ze.insertText(lt))}}},ie=async Se=>{var Ze;if(Se.dataTransfer&&Se.dataTransfer.files.length>0){Se.preventDefault();const Ke=Se.dataTransfer.files;for(const Je of Ke){const lt=await oe(Je);lt&&((Ze=S.current)==null||Ze.insertText(lt))}}},se=()=>{var Se;G(((Se=S.current)==null?void 0:Se.element.value)||"")},fe=async(Se,Ze)=>{var lt,ft,Dt;const Ke=Se.ctrlKey||Se.metaKey,Je=Se.altKey;if(Se.key==="Escape"&&r.globalEditorShown&&(Qe.setGlobalEditorShown(!1),Se.preventDefault()),Ke&&Se.key==="Enter"){Se.preventDefault(),Se.stopPropagation(),Ze?(await we((ft=S.current)==null?void 0:ft.getContent()),(Dt=S.current)==null||Dt.clear()):await we((lt=S.current)==null?void 0:lt.element.value);return}if(Je)for(let Ct=0;Ct{var Ct;Ze||G(((Ct=S.current)==null?void 0:Ct.element.value)||"")})},oe=A.useCallback(async Se=>{const{type:Ze}=Se;if(Ze.startsWith("image"))try{return`${await S1.upload(Se)}`}catch(Ke){new C.Notice(Ke)}},[]),we=async Se=>{if(!Se||Se.trim()===""){new C.Notice(N("Content cannot be empty"));return}const Ze=Xe.getState().settings,Ke=Ze==null?void 0:Ze.addTagAutomatically,Je=Ze==null?void 0:Ze.addTagWithNewline,lt=Ze==null?void 0:Ze.addTagPosition,Dt=(h5()||[]).filter(Ot=>!Se.includes(`#${Ot}`)),Ct=async(Ot,an)=>{an=an.replaceAll(" "," "),Og("");try{if(!Ot){let Tn;switch(Q.current){case"CANVAS":Tn=await Te.createMemoCanvas({text:an,isList:m.current});break;case"MULTI":Tn=await Te.createMemoMultiFile({content:an,isList:m.current});break;case"DAILY":Tn=await Te.createMemoDaily(an,m.current);break;case"FILE":Tn=await Te.createMemoSingleFile({content:an,isList:m.current});break}if(!Tn)return;Te.pushMemo(Tn),(!Ke||Dt.length===0)&&He.clearQuery();const vr=a||Xe.getState().app,Ia=vr==null?void 0:vr.loadLocalStorage("tokenForSync");Tn&&Ia&&o.startSync&&setTimeout(async()=>{try{const tr=await RT({content:an,thinoType:Q.current==="DAILY"?"DAILY":"FILE"});await Te.updateMemoById(Tn.id,tr,!0)}catch(tr){console.error(tr)}},200);return}const wn=Te.getMemoById(Ot);if(wn&&(wn.content!==an||wn.thinoType!==(m.current?"JOURNAL":"TASK-TODO"))){const Tn=await Te.updateMemo(wn.id,an,m.current?"JOURNAL":"TASK-TODO");Tn.updatedAt=Ue.getDateTimeString(Date.now()),Te.editMemo(Tn)}Qe.setEditMemoId("")}catch(wn){new C.Notice(wn.message)}},{editMemoId:un}=Qe.getState(),Ft=Dt&&Dt.length>0&&Ke?lt==="Beginning"?`${Dt.map(Ot=>`#${Ot}`).join(" ")} ${Je?`
`:""}${Se}`:`${Se} ${Je?`
`:""}${Dt.map(Ot=>`#${Ot}`).join(" ")}`:Se;await Ct(un,Ft),n&&n(),Og("")},Z=A.useCallback(()=>{var Se;Qe.setEditMemoId(""),(Se=S.current)==null||Se.setContent(""),Og("")},[]),G=A.useCallback(Se=>{if(Og(Se??""),!S.current)return;const Ze=S.current.getContent(),Ke=S.current.element.selectionStart,Je=Ze.slice(0,Ke),lt=Ze.slice(Ke);(Je.endsWith("@")||Je.endsWith("📆"))&<.startsWith(" ")||(Je.endsWith("@")||Je.endsWith("📆"))&<===""?(Ye(),j(!0)):j(!1),setTimeout(()=>{var ft;(ft=S.current)==null||ft.focus()})},[o.EditorType]),te=Se=>{if(!S.current||!o)return;Se&&(le(),p(!1));const Ze=S.current.getContent(),Ke=S.current.element.selectionStart,Je=Ze.slice(0,Ke),lt=Ze.slice(Ke),ft=C.moment(Se);if(Je.endsWith("@"))switch(o.InsertDateFormat){case"Dataview":S.current.element.value=Ze.slice(0,S.current.element.selectionStart-1)+"[due::"+ft.format("YYYY-MM-DD")+"]"+lt,S.current.element.setSelectionRange(Ke+17,Ke+17),S.current.focus(),G(S.current.element.value);break;case"Tasks":S.current.element.value=Ze.slice(0,S.current.element.selectionStart-1)+"📆"+ft.format("YYYY-MM-DD")+lt,S.current.element.setSelectionRange(Ke+11,Ke+11),S.current.focus(),G(S.current.element.value)}else{S.current.element.value=Je+ft.format("YYYY-MM-DD")+lt,S.current.element.setSelectionRange(Ke+10,Ke+10),S.current.focus(),G(S.current.element.value);return}},ge=()=>{S.current&&p()},Ie=async()=>{var Ke;const Se=!C.Platform.isDesktop&&await((Ke=window.Capacitor)==null?void 0:Ke.Plugins.Device.getId()),Ze=C.Platform.isDesktop?await vn():Se.identifier||Se.uuid;return!c||(c==null?void 0:c.appId)!==Ze?(qt(),!1):!0},De=async Se=>{if(!await Ie())return;const Ze=new C.Menu;o.EnabledLocationList.forEach(ft=>{Ze.addItem(Dt=>{var Ct;Dt.setTitle(N(ft.value)).setIcon(((Ct=tp.find(un=>un.title===ft.value))==null?void 0:Ct.icon)??"file").setChecked(U===ft.value).onClick(()=>{J(ft.value)})})});let Ke=Se.target,Je=null;for(;!Ke.hasClass("location-wrapper")&&(Je=Ke.parentElement,Je);)Ke=Je;const lt=Ke.getBoundingClientRect();setTimeout(()=>{Ze.showAtPosition({x:lt.x,y:lt.bottom,width:lt.width,left:!1,overlap:!0})},200)},ke=A.useCallback(()=>{var Se,Ze;if(!(!S.current&&o.EditorType==="memos"))switch(o.EditorType){case"obsidian":(Se=S.current)==null||Se.focus(),(Ze=S.current)==null||Ze.insertTag();break;case"memos":{const Ke=S.current.getContent(),Je=S.current.element.selectionStart,lt=Ke.slice(0,Je),ft=Ke.slice(Je);let Dt=lt+"# "+ft,Ct=lt.length+1;lt.endsWith("#")&&ft.startsWith(" ")&&(Dt=lt.slice(0,lt.length-1)+ft.slice(1),Ct=lt.length-1),S.current.element.value=Dt,S.current.element.setSelectionRange(Ct,Ct),S.current.focus();const un=new Event("input",{bubbles:!0,cancelable:!0});S.current.element.dispatchEvent(un),G(S.current.element.value)}}},[a]),Ye=A.useCallback(()=>{if(!S.current||!B.current||!o||!a)return;const Ke=a.workspace.getLeavesOfType(_r)[0].view.containerEl,Je=280,lt=Ke.clientWidth,{x:ft,y:Dt}=p5(S.current.element);let Ct,un;C.Platform.isMobile?(window.innerWidth-ft>Je?Ct=(ft+Je+16>lt,ft+18):window.innerWidth-ftlt,ft+34):Ct=S.current.element.clientWidth/2,o.DefaultEditorLocation==="Bottom"&&window.innerWidth>875?un=Dt+4:o.DefaultEditorLocation==="Bottom"&&window.innerWidth<=875?un=Dt+19:o.DefaultEditorLocation==="Top"&&window.innerWidth<=875&&(un=Dt+36)):(Ct=(ft+Je+16>lt,ft+18),un=Dt+34),F(ft),B.current.style.left=`${Ct}px`,B.current.style.top=`${un}px`},[o,a]),Re=A.useCallback(()=>{const Se=document.createElement("input");document.body.appendChild(Se),Se.type="file",Se.multiple=!1,Se.accept="image/png, image/gif, image/jpeg",Se.onchange=async()=>{var Je;if(!Se.files||Se.files.length===0)return;const Ze=Se.files[0],Ke=await oe(Ze);Ke&&((Je=S.current)==null||Je.insertText(Ke)),document.body.removeChild(Se)},Se.click()},[]),rt=!!r.editMemoId,Ht=A.useMemo(()=>({className:"memo-editor",inputerType:o.EditorType||"obsidian",initialContent:m5(),placeholder:N("What do you think now..."),showConfirmBtn:!0,showCancelBtn:rt,showTools:!0,onConfirmBtnClick:we,onCancelBtnClick:Z,onContentChange:G}),[rt,o.EditorType]);return w.jsxs(w.Fragment,{children:[!r.globalEditorShown&&t==="block"&&w.jsx("div",{ref:Se=>{D.current=Se,Se&&C.setIcon&&C.setIcon(Se,"plus-circle")},className:`memo-show-editor-button ${g?"hidden":""}`,onClick:()=>{var Se;(Se=D.current.firstElementChild)==null||Se.toggleClass("rotate-hidden",!0),setTimeout(()=>{v(!0),D.current.firstElementChild.toggleClass("rotate-hidden",!1)},500),setTimeout(()=>{var Ze;(Ze=S.current)==null||Ze.focus()},600)}}),w.jsxs("div",{className:`memo-editor-wrapper ${e||""} ${rt?"edit-ing":""} ${r.globalEditorShown?"fullscreen-editor":""} ${g?"":"hidden"}`,onKeyDownCapture:Se=>fe(Se,!0),children:[w.jsx("span",{className:`tip-text ${rt?"":"hidden"}`,children:"Modifying..."}),w.jsx(t9,{ref:S,...Ht,tools:w.jsxs(w.Fragment,{children:[w.jsx("span",{ref:Se=>{Se&&C.setIcon(Se,"hash")},className:"btn action-btn add-tag",onClick:()=>{o&&o.DefaultEditorLocation==="Top"&&!r.globalEditorShown&&ke()},onPointerDown:()=>{(o&&o.DefaultEditorLocation==="Bottom"||r.globalEditorShown)&&ke()}}),w.jsx("span",{ref:Se=>{Se&&C.setIcon(Se,"paperclip")},className:"btn action-btn file-upload",onClick:()=>{o&&o.DefaultEditorLocation==="Top"&&!r.globalEditorShown&&Re()},onPointerDown:()=>{(o&&o.DefaultEditorLocation==="Bottom"||r.globalEditorShown)&&Re()}}),w.jsx("span",{ref:Se=>{Se&&C.setIcon(Se,d?"layout-list":"check-square")},className:Xn("btn action-btn list-or-task",d?"list":"task"),onClick:()=>{o&&o.DefaultEditorLocation==="Top"&&!r.globalEditorShown&&ge()},onPointerDown:()=>{(o&&o.DefaultEditorLocation==="Bottom"||r.globalEditorShown)&&ge()}}),w.jsx("div",{ref:Se=>{Se&&(C.setIcon&&C.setIcon(Se,r.globalEditorShown?"shrink":"expand"),C.setTooltip&&C.setTooltip(Se,r.globalEditorShown?N("Exit fullscreen mode"):N("Enter fullscreen mode")))},className:"action-btn show-editor pro",onPointerDown:async()=>{await Ie()&&(v(!0),Qe.setGlobalEditorShown(!r.globalEditorShown))}}),w.jsx("div",{className:"action-btn split-line pro"}),w.jsx("div",{className:"action-btn location-wrapper pro",onClick:async Se=>{o&&o.DefaultEditorLocation==="Top"&&!r.globalEditorShown&&await De(Se)},onPointerDown:async Se=>{(o&&o.DefaultEditorLocation==="Bottom"||r.globalEditorShown)&&await De(Se)},children:w.jsx("div",{ref:Y,className:"action-btn file-location-btn"})})]})}),w.jsx("div",{ref:B,className:"date-picker",children:k&&w.jsx("div",{tabIndex:-1,style:z.styles.popper,...z.attributes.popper,ref:R,role:"dialog",children:w.jsx(zy,{className:`editor-date-picker ${k?"":"hidden"}`,datestamp:H,handleDateStampChange:te})})})]})]})};function m5(){return Kn.get(["thinoEditorContentCache"]).thinoEditorContentCache??""}function Og(e){Kn.set({thinoEditorContentCache:e})}const g5=e=>{const t=[];return e.map(n=>{t.length==0?t.push({date:C.moment(n.createdAt,"YYYY/MM/DD HH:mm:ss").format("YYYY-MM-DD"),have:[n]}):t.some(a=>{if(a.date==C.moment(n.createdAt,"YYYY/MM/DD HH:mm:ss").format("YYYY-MM-DD"))return a.have.push(n),!0})||t.push({date:C.moment(n.createdAt,"YYYY/MM/DD HH:mm:ss").format("YYYY-MM-DD"),have:[n]})}),t},y5=e=>Te.getState().commentMemos.filter(t=>t.linkId===e.hasId).sort((t,n)=>Ue.getTimeStampByDate(t.createdAt)-Ue.getTimeStampByDate(n.createdAt)).map(t=>({...t,createdAtStr:Ue.getDateTimeString(t.createdAt),dateStr:Ue.getDateString(t.createdAt)})),v5=e=>{const t=Xe.getState().settings,n=DN(),r=t!=null&&t.ShowDate?" ":"",a="YYYY/MM/DD HH:mm:ss",o=/comment:(.*)$/g,s=/^\d{14}/g,c=(g,v,D)=>{const S=C.moment(g.createdAt,a).format("HH:mm");return D?D.replace(/{TIME}/g,S).replace(/{CONTENT}/g,v):`${S} ${v}`},d=g=>{const v=g.match(/TASK-(.*)?/g);return v?v[1]:""},p=g=>g==="TASK-TODO"?"- [ ] ":g==="TASK-DONE"?"- [x] ":g.match(/TASK-(.*)?/g)?`- [${d(g)}] `:"- ",m=g=>g.reduce((v,D)=>{const S=D.sourceType!=="MULTI"?`${D.content}`:`[[${D.path}]]`,T=t!=null&&t.ShowTime?c(D,S,t==null?void 0:t.DefaultMemoComposition):S,E=`${p(D.thinoType)}${T}`;let O="";return t.CommentOnMemos&&D.hasId!==void 0&&D.hasId!==""&&(O=y5(D).reduce((j,F)=>{const B=p(F.thinoType),R=F.content.replace(o,"").replace(s,""),z=t!=null&&t.ShowDate?`${B}[[${C.moment(F.createdAt).format(n)}]] ${C.moment(F.createdAt).format("HH:mm")} ${R}`:`${B}${R}`;return j+r+" "+z+`
`},"")),v+r+E.replace(/ \^\S{6}/g,"")+`
`+O},"");return e.reduce((g,v)=>{const D=t!=null&&t.ShowDate?`- [[${C.moment(v.date,"YYYY-MM-DD").format(n)}]]
`:"",S=m(v.have),T=t!=null&&t.ShowDate&&(t!=null&&t.AddBlankLineWhenDate)&&!(t!=null&&t.CommentOnMemos)?`
`:"";return g+D+S+T},"").replace(/ /g,`
`)},w5=[{label:N("Today"),value:C.moment().format("YYYY-MM-DD")},{label:N("Yesterday"),value:C.moment().subtract(1,"days").format("YYYY-MM-DD")},{label:N("Last 7 days"),value:C.moment().subtract(7,"days").format("YYYY-MM-DD")},{label:N("Last 30 days"),value:C.moment().subtract(30,"days").format("YYYY-MM-DD")},{label:N("Last 90 days"),value:C.moment().subtract(90,"days").format("YYYY-MM-DD")},{label:N("Last 180 days"),value:C.moment().subtract(180,"days").format("YYYY-MM-DD")},{label:N("Last 365 days"),value:C.moment().subtract(365,"days").format("YYYY-MM-DD")}],pE=e=>{const{handleValueChange:t,setShownStatus:n}=e;return w.jsxs(w.Fragment,{children:[e.type==="icon"&&w.jsx("div",{className:"quick-date-btn-group",children:w5.map((r,a)=>w.jsx("div",{className:"btn action-btn quick-date-btn",onClick:()=>{t(r.value),n&&n(!1)},children:r.label},a))}),w.jsx(zy,{className:"calendar-date-picker",datestamp:(e==null?void 0:e.defaultValue)||C.moment().startOf("day").valueOf(),handleDateStampChange:(r,a)=>{t(e.type==="icon"?C.moment(r).format("YYYY-MM-DD"):r.toString()),n&&n(!1)}})]})},py=e=>{const{handleValueChange:t}=e,[n,r]=$.useState(!1),a=$.useRef(null),o=$.useRef(null),s=Vy(o.current,a.current,{placement:"bottom-start"});return Pp(a,()=>{r(!1)}),w.jsxs(w.Fragment,{children:[w.jsx("span",{ref:d=>{o.current=d,d&&e.type==="icon"&&C.setIcon(d,"calendar")},className:`btn calendar-btn ${e.type==="icon"?"icon-btn":"text-btn"}`,onClick:()=>{!C.Platform.isMobile&&r(!n),!C.Platform.isMobile&&(s!=null&&s.update)&&(s==null||s.update()),C.Platform.isMobile&&new mE(Xe.getState().app,e.type,t).open()},children:e.type==="text"&&e.defaultValue?e.defaultText?e.defaultText:C.moment(e.defaultValue,"x").subtract(e.startOrEnd==="end"?1:0,"days").format("YYYY/MM/DD"):""}),w.jsx("div",{className:`menu-btns-popup ${n?"":"hidden"}`,ref:a,style:s.styles.popper,children:w.jsx(pE,{type:e.defaultText?"icon":e.type,handleValueChange:t,setShownStatus:r})})]})};class mE extends C.Modal{constructor(n,r,a){super(n);me(this,"root");me(this,"type");me(this,"handleValueChange");this.type=r,this.handleValueChange=a}onOpen(){const{contentEl:n}=this;this.root=Ap(n),this.root.render(w.jsx(pE,{type:this.type,handleValueChange:this.handleValueChange.bind(this),setShownStatus:r=>{!r&&this.close()}}))}onClose(){var n;(n=this.root)==null||n.unmount()}}const b5=(e,t)=>(e%t+t)%t;class D5{constructor(t,n,r){me(this,"owner");me(this,"values");me(this,"suggestions");me(this,"selectedItem");me(this,"containerEl");this.owner=t,this.containerEl=n,n.on("click",".suggestion-item",this.onSuggestionClick.bind(this)),n.on("mousemove",".suggestion-item",this.onSuggestionMouseover.bind(this)),r.register([],"ArrowUp",a=>{if(!a.isComposing)return this.setSelectedItem(this.selectedItem-1,!0),!1}),r.register([],"ArrowDown",a=>{if(!a.isComposing)return this.setSelectedItem(this.selectedItem+1,!0),!1}),r.register([],"Enter",a=>{if(!a.isComposing)return this.useSelectedItem(a),!1})}onSuggestionClick(t,n){t.preventDefault();const r=this.suggestions.indexOf(n);this.setSelectedItem(r,!1),this.useSelectedItem(t)}onSuggestionMouseover(t,n){const r=this.suggestions.indexOf(n);this.setSelectedItem(r,!1)}setSuggestions(t){this.containerEl.empty();const n=[];t.forEach(r=>{const a=this.containerEl.createDiv("suggestion-item");this.owner.renderSuggestion(r,a),n.push(a)}),this.values=t,this.suggestions=n,this.setSelectedItem(0,!1)}useSelectedItem(t){const n=this.values[this.selectedItem];n&&this.owner.selectSuggestion(n,t)}setSelectedItem(t,n){const r=b5(t,this.suggestions.length),a=this.suggestions[this.selectedItem],o=this.suggestions[r];a==null||a.removeClass("is-selected"),o==null||o.addClass("is-selected"),this.selectedItem=r,n&&o.scrollIntoView(!1)}}class gE{constructor(t,n){me(this,"inputEl");me(this,"popper");me(this,"scope");me(this,"suggestEl");me(this,"suggest");me(this,"cb");this.inputEl=t,this.scope=new C.Scope,this.cb=n,this.suggestEl=createDiv("suggestion-container");const r=this.suggestEl.createDiv("suggestion");this.suggest=new D5(this,r,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.onInputChanged.bind(this)),this.inputEl.addEventListener("blur",this.close.bind(this)),this.suggestEl.on("mousedown",".suggestion-container",a=>{a.preventDefault()})}clearInput(){this.inputEl.value="",this.inputEl.trigger("blur"),this.inputEl.trigger("focus"),this.inputEl.trigger("input"),this.onInputChanged()}onInputChanged(){const t=this.inputEl.value,n=this.getSuggestions(t);if(!n){this.close();return}n.length>0?(this.suggest.setSuggestions(n),this.open(app.dom.appContainerEl,this.inputEl)):this.close()}open(t,n){app.keymap.pushScope(this.scope),t.appendChild(this.suggestEl),this.popper=hE(n,this.suggestEl,{placement:"bottom-start",modifiers:[{name:"sameWidth",enabled:!0,fn:({state:r,instance:a})=>{const o=`${r.rects.reference.width}px`;r.styles.popper.width!==o&&(r.styles.popper.width=o,a.update())},phase:"beforeWrite",requires:["computeStyles"]}]})}close(){app.keymap.popScope(this.scope),this.suggest.setSuggestions([]),this.popper&&this.popper.destroy(),this.suggestEl.detach()}destroy(){this.inputEl.removeEventListener("input",this.onInputChanged.bind(this)),this.inputEl.removeEventListener("focus",this.onInputChanged.bind(this)),this.inputEl.removeEventListener("blur",this.close.bind(this)),this.close()}updateCb(t){this.cb=t}}const S5=e=>{const t=e.metadataCache.getTags();return[...Object.keys(t)].map(n=>n.split("#").pop())};let yE=class extends gE{fuzzySearchItemsOptimized(t,n){const r=C.prepareFuzzySearch(t);return n.map(a=>{const o=r(a);return o?{item:a,match:o,score:o.score}:null}).sort((a,o)=>(o==null?void 0:o.score)-(a==null?void 0:a.score)).filter(Boolean)}getSuggestions(t){const{settings:n,app:r}=Xe.getState(),a=t.toLocaleLowerCase(),o=n.UseVaultTags?S5(r):Te.getState().tags;return this.fuzzySearchItemsOptimized(a,o).map(s=>s.item)}renderSuggestion(t,n){n.toggleClass("thino-image-suggest-item",!0),n.createSpan({cls:"suggestion-name",text:t})}selectSuggestion(t){this.inputEl.value=t,this.inputEl.dispatchEvent(new Event("change")),this.cb&&this.cb(t),this.close()}};const I5=e=>{const t=new Set;return e.forEach(n=>{const r=new RegExp(Fn).exec(n.content),a=new RegExp($n).exec(n.content);if(r)for(let o=1;o{const[r,a]=$.useState([]),[o,s]=$.useState([]),[c,d]=$.useState([]),p=$.useRef(null),m=$.useRef(null),g=$.useRef(null),v=$.useRef("End"),D=$.useRef(!1),S=$.useRef(null);A.useEffect(()=>{t&&t.length&&a(I5(t))},[t]),A.useEffect(()=>{!g.current||!m.current||(new C.Setting(m.current).setName(N("Add tag position")).addDropdown(k=>{k.addOption("End",N("End")),k.addOption("Beginning",N("Beginning")),k.setValue("End").onChange(async j=>{v.current=j})}),new C.Setting(g.current).setName(N("Add tag with new line")).addToggle(k=>{k.setValue(!1).onChange(async j=>{D.current=j})}))},[]);const T=k=>{if(!k)return;const j=new Set(o);j.add(k),s(Array.from(j)),p.current.clearInput()};A.useEffect(()=>{if(S.current){if(p.current){p.current.updateCb(T);return}p.current=new yE(S.current,T)}},[S.current,o]);const E=()=>{n(),O({remove:c,add:o,targetThinos:t})},O=async({remove:k,add:j,targetThinos:F})=>{const B=D.current||!1,R=[];for(const z of F){let H=z.content;for(const Y of k)H=H.replace(new RegExp(`#${Y}`,"g"),"");if(H=H.trim(),j.length>0&&(H=v.current==="Beginning"?`${j.map(Y=>`#${Y}`).join(" ")} ${B?`
`:""}${H}`:`${H} ${B?`
`:""}${j.map(Y=>`#${Y}`).join(" ")}`),z&&z.content!==H){const Y=await Te.updateMemo(z.id,H==null?void 0:H.trim());R.push(Y)}}R.length>0&&Te.editMemoBulk(R),R.length>0&&He.clearQuery()};return w.jsxs("div",{className:"thino-tag-operation",children:[w.jsx("div",{className:"tag-operation-title",children:N("Tag Bulk Edit")}),w.jsxs("div",{className:"tag-operation-content",children:[w.jsxs("div",{className:"tag-operation-content-title exist-tags",children:[w.jsx("div",{className:"name",children:N("Exist Tags")}),w.jsx("div",{className:"desc",children:N("Click to remove exist tag")})]}),w.jsx("div",{className:"tag-operation-content-tags exist-tags",children:r.map(k=>w.jsx("div",{className:Xn("tag-operation-content-tag",c.includes(k)&&"tag-operation-content-tag-removed"),onClick:()=>{c.includes(k)||d([...c,k]),c.includes(k)&&d(c.filter(j=>j!==k)),o.includes(k)&&s(o.filter(j=>j!==k))},children:k},k))}),w.jsxs("div",{className:"tag-operation-content-title selected-tags",children:[w.jsx("div",{className:"name",children:N("Selected Tags")}),w.jsx("div",{className:"desc",children:N("Click to remove selected tag")})]}),w.jsx("div",{className:"tag-operation-content-tags selected-tags",children:o.map(k=>w.jsx("div",{className:"tag-operation-content-tag",onClick:()=>{s(o.filter(j=>j!==k))},children:k},k))}),w.jsx("div",{className:"tag-operation-content-inputer",children:w.jsx("input",{placeholder:N("Input to select exist tag"),ref:S,onKeyDown:k=>{k.key==="Enter"&&T(S.current.value)}})}),w.jsxs("div",{className:"tag-operation-settings",children:[w.jsx("div",{ref:m}),w.jsx("div",{ref:g})]}),w.jsxs("div",{className:"tag-operation-content-btn-group",children:[w.jsx("button",{className:"cancel-btn",onClick:n,children:N("Cancel")}),w.jsx("button",{className:"save-btn",onClick:E,children:N("Save")})]})]})]})},Fw=new Map,xd=async(e,t=!0)=>{const{vault:n,metadataCache:r}=Xe.getState().app;if(t&&Fw.has(e))return Promise.resolve(Fw.get(e));if(e.contains("data:image"))return e;let a;const o=await n.adapter.exists(e);let s="";try{if(!o&&!/(http|https)/g.test(e)&&!e.includes("data:image")){const c=r.getFirstLinkpathDest(e,"");if(!c){new C.Notice(N("File not exist"));return}s=c.path}else s=e}catch(c){console.error(c)}if(s){if(/(http|https)/g.test(s))try{const c=await C.requestUrl(e),d=new Uint8Array(c.arrayBuffer);a=new Blob([d],{type:"image/png"})}catch{}else if(s){const c=await n.adapter.readBinary(s),d=new Uint8Array(c);a=new Blob([d],{type:"image/png"})}return a?await E5(a,e):""}},E5=(e,t)=>new Promise(n=>{const r=new FileReader;r.onloadend=()=>{const a=r.result;Fw.set(t,a),n(a)},r.readAsDataURL(e)}),Uh=async e=>{if(!e.style.backgroundImage.includes("url(")&&!e.style.backgroundImage.includes("http"))return;const t=e.style.backgroundImage.includes("url(")?e.style.backgroundImage.slice(5,-2):e.style.backgroundImage;return await xd(t)},C5=async e=>{const t=document.createElement(e.tagName);t.innerHTML=e.innerHTML;const n=async(r,a)=>{if(!r||!a)return;const o=window.getComputedStyle(r);if(r.tagName==="IMG")try{let s="";const c=r.getAttribute("src");c!=null&&c.startsWith("http")&&!c.startsWith("http://localhost")?s=await xd(r==null?void 0:r.getAttribute("src")):s=await xd(r.getAttribute("path")||C.normalizePath(r==null?void 0:r.parentElement.getAttribute("src"))),a.src=s}catch(s){console.error(s)}else if(r.hasClass("property-image")||r.hasClass("moments-view-background"))try{const s=r.style.backgroundImage.includes("url(")?r.style.backgroundImage.slice(5,-2):r.style.backgroundImage,c=await xd(s);a.style.backgroundImage=`url(${c})`}catch(s){console.error(s)}for(const s of o)a.style.setProperty(s,o.getPropertyValue(s),o.getPropertyPriority(s));for(let s=0;s{const t=e.ownerDocument.styleSheets,n=[];for(const a of t)for(const o of a.cssRules)o.constructor.name==="CSSFontFaceRule"&&n.push(o.style);return document.createElement("style")},vE=e=>{const{width:t,height:n}=window.getComputedStyle(e);return{width:parseInt(t.replace("px","")),height:parseInt(n.replace("px",""))}},M5=e=>{const t=new XMLSerializer().serializeToString(e);return`data:image/svg+xml;charset=utf-8,${encodeURIComponent(t)}`},N5=(e,t,n)=>{const r="http://www.w3.org/2000/svg",a=document.createElementNS(r,"svg");a.setAttribute("width",`${e}`),a.setAttribute("height",`${t}`),a.setAttribute("viewBox",`0 0 ${e} ${t}`);const o=document.createElementNS(r,"foreignObject");return o.setAttribute("width","100%"),o.setAttribute("height","100%"),o.setAttribute("x","0"),o.setAttribute("y","0"),o.setAttribute("externalResourcesRequired","true"),o.appendChild(n),a.appendChild(o),a},k5=async(e,t)=>{const{width:n,height:r}=vE(e),a=await C5(e);t!=null&&t.backgroundColor&&(a.style.backgroundColor=t.backgroundColor);const o=N5(n,r,a);return o.prepend(await x5(e)),M5(o)},A5=async(e,t)=>{const n=await k5(e,t),r=new Image;r.src=n;const a=(t==null?void 0:t.pixelRatio)||1,{width:o,height:s}=vE(e),c=document.createElement("canvas"),d=c.getContext("2d");return d?(c.width=o*a,c.height=s*a,c.style.width=`${o}`,c.style.height=`${s}`,(t!=null&&t.backgroundColor||document.body.className.contains("theme-dark"))&&(d.fillStyle=t.backgroundColor||"#1f1f1f",d.fillRect(0,0,c.width,c.height)),new Promise(p=>{r.onload=()=>{d.drawImage(r,0,0,c.width,c.height),p(c)}})):Promise.reject("Canvas error")},Zy=async(e,t)=>(await A5(e,t)).toDataURL(),GD=async e=>{e.startsWith("http")&&(e=await xd(e));const t=e.split("base64,")[1],n=Oy(t,"image/png");await wE(n),new C.Notice(N("Send to clipboard successfully"))},F5=async(e,t)=>{const n=await e.vault.adapter.exists(t);let r="";if(n)r=t;else{const c=e.metadataCache.getFirstLinkpathDest(t,"");if(!c){new C.Notice(N("File not exist"));return}r=c.path}const a=await e.vault.adapter.readBinary(r),o=new Uint8Array(a),s=new Blob([o],{type:"image/png"});await wE(s)},wE=async e=>{const t=new ClipboardItem({"image/png":e});await window.navigator.clipboard.write([t])},qD=1.1,JD=300,KD=20,O5=({destroy:e,imgUrl:t,filepath:n,otherIMGEls:r,currentIndex:a})=>{const o=A.useRef(null),[s,c]=A.useState(-1),d=Ee.getState().dailyNotesState.app,[p,m]=A.useState(a),[g,v]=A.useState(t),D={close:A.useRef(null),previous:A.useRef(null),next:A.useRef(null),decrease:A.useRef(null),increase:A.useRef(null),zoom:A.useRef(null),copy:A.useRef(null)};A.useEffect(()=>{!n&&!t||(C.setIcon(D.close.current,"x"),D.previous.current&&C.setIcon(D.previous.current,"arrow-left"),D.next.current&&C.setIcon(D.next.current,"arrow-right"),C.setIcon(D.decrease.current,"zoom-out"),C.setIcon(D.increase.current,"zoom-in"),C.setIcon(D.zoom.current,"circle"),C.setIcon(D.copy.current,"clipboard"))},[D]),A.useEffect(()=>{Ue.getImageSize(g).then(({width:R})=>{c(R!==0?40:0)})},[g]);const S=()=>{let R=p-1;R<0&&(R=r.length-1),m(R),v(r[R].src)},T=()=>{let R=p+1;R>=r.length&&(R=0),m(R),v(r[R].src)},E=()=>{e()},O=()=>{s>30&&c(s-10)},k=()=>{c(s+10)},j=R=>{R.target!==o.current&&R.target===o.current.parentElement&&E()},F=R=>{if(R.ctrlKey){R.preventDefault();const z=o.current,H=R.nativeEvent.offsetX,Y=R.nativeEvent.offsetY,U=H/z.clientWidth,J=Y/z.clientHeight;let Q;R.deltaY>0?Q=s/qD:Q=s*qD,Q>JD?Q=JD:Q{if(g&&!n)await GD(t);else if(n){const z=r[p].parentElement.getAttribute("src");if(!z){await GD(g);return}await F5(d,z)}};return w.jsxs(w.Fragment,{children:[w.jsx("button",{ref:D.close,className:"btn close-btn",onClick:E}),w.jsxs("div",{className:"img-container internal-embed image-embed is-loaded",onClick:j,onWheel:F,children:[w.jsx("img",{className:s<=0?"hidden":"",ref:o,height:s+"%",src:g}),w.jsx("span",{className:"loading-text "+(s===-1?"":"hidden"),children:N("Image is loading...")}),w.jsx("span",{className:"loading-text "+(s===0?"":"hidden"),children:N("😟 Cannot load image, image link maybe broken")})]}),w.jsxs("div",{className:"action-btns-container",children:[r&&(r==null?void 0:r.length)>1&&w.jsxs(w.Fragment,{children:[w.jsx("button",{ref:D.previous,className:"btn",onClick:S}),w.jsx("button",{ref:D.next,className:"btn",onClick:T})]}),w.jsx("button",{ref:D.decrease,className:"btn",onClick:O}),w.jsx("button",{ref:D.increase,className:"btn",onClick:k}),w.jsx("button",{ref:D.zoom,className:"btn",onClick:()=>c(80)}),w.jsx("button",{ref:D.copy,className:"btn",onClick:B})]})]})};function Wy({imgUrl:e,filepath:t,otherIMGEls:n,currentIndex:r}){By({className:"preview-image-dialog"},O5,{...{imgUrl:e,otherIMGEls:n,currentIndex:r},filepath:t})}const yd=async()=>{var r;const{verifyState:e}=Xe.getState(),t=!C.Platform.isDesktop&&await((r=window.Capacitor)==null?void 0:r.Plugins.Device.getId()),n=C.Platform.isDesktop?await vn():t.identifier||t.uuid;return e&&(e==null?void 0:e.appId)===n},P5=async(e,t)=>{if(!(t!=="chat"&&t!=="moments")){if(t==="moments"){const n=e.querySelectorAll(".thino-moment-icon"),r=e.find(".moments-view-user-icon"),a=e.find(".moments-view-background");for(const o of n){const s=await Uh(o);o.style.backgroundImage=`url(${s})`}if(r){const o=await Uh(r);r.style.backgroundImage=`url(${o})`}if(a){const o=await Uh(a);a.style.backgroundImage=`url(${o})`}}else if(t==="chat"){const n=e.querySelectorAll(".icon-img");for(const r of n){const a=await Uh(r);r.style.backgroundImage=`url(${a})`}}}};class vd extends C.Modal{constructor(t,n,r){super(t),this.title=n,this.cb=r}onOpen(){super.onOpen(),this.containerEl.toggleClass("thino-bulk-action-dialog",!0),this.titleEl.setText(this.title+N("Confirm?")),this.contentEl.createEl("button",{text:N("Confirm?").replace(/\?|?/,"")}).onclick=()=>{this.cb("confirm"),this.close()},this.contentEl.createEl("button",{text:N("Cancel")}).onclick=()=>{this.cb("cancel"),this.close()}}onClose(){super.onClose()}}class j5 extends C.Modal{constructor(n,r){super(n);me(this,"root");this.thinos=r}onOpen(){super.onOpen(),this.containerEl.toggleClass(["thino-bulk-action-dialog","tag-actions"],!0),this.root=Lo.createRoot(this.contentEl),this.root.render(w.jsx(Bo,{store:Ee,context:mt,children:w.jsx(T5,{app:this.app,closeDialog:this.close.bind(this),thinos:this.thinos})}))}onClose(){var n;super.onClose(),(n=this.root)==null||n.unmount()}}const Rp=({thinosCount:e,thinos:t})=>{const{globalState:{memoListView:n},locationState:{query:r,pathname:a},dailyNotesState:{settings:o,app:s}}=A.useContext(mt),{tag:c,duration:d,type:p,text:m,filter:g}=r,v=Et.getQueryById(g),D=!!(c||d&&d.from{S&&C.setIcon(S.current,"more-horizontal")},[S]);const T=async()=>{if(!((t==null?void 0:t.length)>0))return;const H=g5(t),Y=v5(H);await Ue.copyTextToClipboard(Y),new C.Notice(N("Copied to clipboard Successfully"))},E=async()=>{if(!((t==null?void 0:t.length)>0))return;if(!await yd()){qt();return}const H=[...t],Y=o.DeleteThinoDirectly;try{for(const U of H)if(Y)await Te.deleteMemoById(U.id);else{const J=await Te.hideMemoById(U.id);J&&Te.editMemo(J)}He.clearQuery()}catch(U){console.error("error",U),new C.Notice(U.message)}},O=async()=>{if(!((t==null?void 0:t.length)>0))return;if(!await yd()){qt();return}const H=[...t];try{for(const Y of H)await Te.deleteMemoById(Y.id);He.clearQuery(),new C.Notice(N("DELETE SUCCEED"))}catch(Y){console.error("error",Y),new C.Notice(Y.message)}},k=async()=>{if(!((t==null?void 0:t.length)>0))return;if(!await yd()){qt();return}const H=[...t];try{const Y=await Te.unarchiveThinoBulk(H);for(const U of Y)U&&Te.editMemo(U);new C.Notice(N("RESTORE SUCCEED")),He.clearQuery()}catch(Y){console.error("error",Y),new C.Notice(Y.message)}},j=async()=>{if(!((t==null?void 0:t.length)>0))return;if(!await yd()){qt();return}const H=[...t],Y=Xe.getState().settings.startSync;try{for(const U of H){const J=await Te.restoreMemoById(U.id),Q=Xe.getState().app,le=Q==null?void 0:Q.loadLocalStorage("tokenForSync");J&&J.webId&&le&&Y&&await BT(J.webId),J&&Te.editMemo(J)}He.clearQuery(),new C.Notice(N("RESTORE SUCCEED"))}catch(U){new C.Notice(U.message)}},F=async()=>{if(!((t==null?void 0:t.length)>0))return;if(!await yd()){qt();return}const H=[...t];try{const Y=await Te.archiveThinoBulk(H);for(const U of Y)U&&Te.editMemo(U);He.clearQuery()}catch(Y){console.error("error",Y),new C.Notice(Y.message)}},B=async()=>{if((t==null?void 0:t.length)>0){if(!await yd()){qt();return}new j5(s,t).open()}},R=async H=>{setTimeout(async()=>{if(new C.Notice(N("Image is generating...")),!H){new C.Notice(N("No content to generate."));return}await P5(H,n);let Y;document.body.hasClass("theme-dark")?Y="#232323":Y="#eaeaea",Zy(H,{backgroundColor:Y,pixelRatio:window.devicePixelRatio*2}).then(U=>{if(o!=null&&o.AutoSaveWhenOnMobile&&C.Platform.isMobile){const J=U.split("base64,")[1];Oy(J,"image/png").arrayBuffer().then(async le=>{let pe;const ie="png",se=bs();for(const fe in se)if(se[fe]instanceof C.TFile){pe=se[fe];break}pe!==void 0&&await s.vault.createBinary(await vault.getAvailablePathForAttachments(`Pasted Image ${C.moment().format("YYYYMMDDHHmmss")}`,ie,pe),le)})}Wy({imgUrl:U}),new C.Notice(N("Image generated successfully.")),H.hasClass("share-image")?H.toggleClass("share-image",!1):H.closest(".share-image").toggleClass("share-image",!1)}).catch(U=>{console.error(U)})},0)},z=H=>{const Y=new C.Menu;switch(Y.addItem(U=>{U.setTitle(N("Copy filtered thinos")).setIcon("copy").onClick(async()=>{await T()})}),Y.addItem(U=>{U.setTitle(N("Share filtered thinos as image")).setIcon("image").onClick(async()=>{const J=document.querySelector(".memolist-container");J.toggleClass("share-image",!0);try{if(n==="calendar"){if(J.find(".rbc-agenda-table")){const Q=J.find(".rbc-agenda-table");await R(Q)}}else if(n==="table"){if(J.find(".thino-table")){const Q=J.find(".thino-table");await R(Q)}}else await R(J)}catch(Q){console.error(Q),new C.Notice(N("Failed to generate image.")),J.toggleClass("share-image",!1)}})}),Y.addSeparator(),a){case"/":Y.addItem(U=>{U.setTitle(N("Bulk tag operation")).setIcon("hash").onClick(async()=>{await B()})}).addItem(U=>{U.setTitle(N("Bulk archive")).setIcon("archive").onClick(async()=>{new vd(s,N("ARCHIVE"),async J=>{J==="confirm"&&await F()}).open()})}).addItem(U=>{U.setTitle(N("Bulk delete")).setIcon("trash").onClick(async()=>{new vd(s,N("DELETE"),async J=>{J==="confirm"&&await E()}).open()})});break;case"/archive":Y.addItem(U=>{U.setTitle(N("Bulk restore")).setIcon("archive").onClick(async()=>{new vd(s,N("RESTORE"),async J=>{J==="confirm"&&await k()}).open()})}).addItem(U=>{U.setTitle(N("Bulk delete")).setIcon("trash").onClick(async()=>{new vd(s,N("DELETE"),async J=>{J==="confirm"&&await E()}).open()})});break;case"/recycle":Y.addItem(U=>{U.setTitle(N("Bulk restore")).setIcon("archive-restore").onClick(async()=>{new vd(s,N("RESTORE"),async J=>{J==="confirm"&&await j()}).open()})}).addItem(U=>{U.setTitle(N("Bulk delete")).setIcon("trash").onClick(async()=>{new vd(s,N("DELETE"),async J=>{J==="confirm"&&await O()}).open()})});break}Y.showAtMouseEvent(H.nativeEvent)};return w.jsxs("div",{className:`filter-query-container ${D?"":"hidden"}`,children:[w.jsxs("div",{className:"filter-query",children:[w.jsx("span",{className:"tip-text",children:N("FILTER")}),w.jsxs("div",{"data-filter-type":"query",className:"filter-item-container "+(v?"":"hidden"),onClick:()=>{He.setMemoFilter("")},children:[w.jsx("span",{className:"icon-text",children:"🔖"})," ",v==null?void 0:v.title]}),w.jsxs("div",{"data-filter-type":"tag",className:"filter-item-container "+(c?"":"hidden"),onClick:()=>{He.setTagQuery("")},children:[w.jsx("span",{className:"icon-text",children:"🏷️"})," ",c]}),w.jsxs("div",{"data-filter-type":"type",className:"filter-item-container "+(p?"":"hidden"),onClick:()=>{He.setMemoTypeQuery("")},children:[w.jsx("span",{className:"icon-text",children:"📦"})," ",c8(p)]}),d&&d.from{const Y=C.moment(d.to,"x"),U=C.moment(H,"x"),J=U.isAfter(Y)||U.isSame(Y);He.setFromAndToQuery(J?Y.startOf("day").valueOf():C.moment(H,"x").startOf("day").valueOf(),d.to)}}),w.jsx("span",{children:N("to")}),w.jsx(py,{type:"text",startOrEnd:"end",defaultValue:C.moment(d.to,"x").add(1,"days").valueOf(),handleValueChange:H=>{const Y=C.moment(d.from,"x"),U=C.moment(H,"x"),J=U.isBefore(Y)||U.isSame(Y),Q=C.moment(H,"x").endOf("day").valueOf();He.setFromAndToQuery(d.from,J?Y.endOf("day").valueOf():Q)}})]}),w.jsx("div",{ref:H=>H&&C.setIcon(H,"x"),className:"btn close-btn",onClick:()=>{He.setFromAndToQuery(0,0)}})]}),w.jsxs("div",{className:"filter-item-container "+(m?"":"hidden"),onClick:()=>{He.setTextQuery("")},children:[w.jsx("span",{className:"icon-text",children:"🔍"})," ",m]})]}),w.jsxs("div",{className:"thino-filter-items",children:[e&&w.jsx("div",{className:"thinos-count",children:`${e?`${e} Thinos `:""}`}),w.jsx("div",{ref:S,className:"btn memo-action-menu",onClick:z})]})]})},L5=e=>{const{dailyNotesState:{app:t,view:n}}=A.useContext(mt),{memo:r,handleMemoContentClick:a,handleMemoDoubleClick:o}=e,s=$.useRef(null),[c,d]=$.useState("");return A.useEffect(()=>{if(!s.current||s.current.hasChildNodes()&&r.content===c||!n||!t)return;d(r.content),s.current.hasChildNodes()&&s.current.empty(),(async()=>{var g,v;await C.MarkdownRenderer.render(t,r.content+`
`,s.current,r.path,n),(g=s.current)==null||g.toggleClass(["markdown-rendered"],!0);const m=(v=s.current)==null?void 0:v.querySelectorAll(".internal-link");m==null||m.forEach(D=>{const S=D,T=S.getAttribute("data-href");if(!T)return;t.metadataCache.getFirstLinkpathDest(T,r.path)||D.classList.add("is-unresolved"),S.addEventListener("mouseover",O=>{O.stopPropagation(),t.workspace.trigger("hover-link",{event:O,source:"thino",hoverParent:n.containerEl,targetEl:S,linktext:T,sourcePath:S.href})})})})()},[r.content,n,t]),w.jsx("div",{ref:s,className:"memo-content-text",onClick:p=>a(p,r),onDoubleClick:o,onContextMenu:p=>{p.preventDefault()}})},bE=A.memo(L5),R5=e=>{const[t,n]=A.useState({...e.memo,createdAtStr:Ue.getDateTimeString(e.memo.createdAt)}),[r,a]=A.useState([]),[o,s]=A.useState([]);A.useEffect(()=>{(async()=>{try{const g=[],v=[...t.content.matchAll(Il)];for(const S of v)if(S&&S.length===3){const T=S[2],E=Te.getMemoById(T);E&&g.push({...E,createdAtStr:Ue.getDateTimeString(E.createdAt),dateStr:Ue.getDateString(E.createdAt)})}a([...g]);const D=await Te.getLinkedMemos(t.id);s(D.sort((S,T)=>Ue.getTimeStampByDate(T.createdAt)-Ue.getTimeStampByDate(S.createdAt)).map(S=>({...S,createdAtStr:Ue.getDateTimeString(S.createdAt),dateStr:Ue.getDateString(S.createdAt)})))}catch(g){console.error(g)}})()},[t.id]);const c=A.useCallback(async m=>{var v;const g=m.target;if(g.className==="memo-link-text"){const D=(v=g.dataset)==null?void 0:v.value,S=Te.getMemoById(D??"");if(S){const T={...S,createdAtStr:Ue.getDateTimeString(S.createdAt)};a([]),s([]),n(T)}else new C.Notice(N("Thino not found")),g.classList.remove("memo-link-text")}},[]),d=A.useCallback(m=>{a([]),s([]),n({...m,createdAtStr:Ue.getDateTimeString(m.createdAt)})},[t.id]),p=A.useCallback(()=>{e.destroy(),Qe.setEditMemoId(t.id)},[t.id]);return w.jsxs(w.Fragment,{children:[w.jsxs("div",{className:"memo-card-container",children:[w.jsxs("div",{className:"header-container",children:[w.jsx("span",{className:"time-text",children:t.createdAtStr}),w.jsxs("div",{className:"btns-container",children:[w.jsx("button",{ref:m=>{m&&C.setIcon(m,"edit")},className:"btn edit-btn",onClick:p}),w.jsx("button",{ref:m=>{m&&C.setIcon(m,"x")},className:"btn close-btn",onClick:e.destroy})]})]}),w.jsx("div",{className:"memo-container",children:w.jsx("div",{className:"memo-content-text",children:w.jsx(bE,{memo:t,handleMemoContentClick:c,handleMemoDoubleClick:()=>{}})})}),w.jsx("div",{className:"layer-container"})]}),r.length>0?w.jsxs("div",{className:"linked-memos-wrapper",children:[w.jsxs("span",{className:"normal-text",children:[N("LINKED")," ",r.length," THINO"," "]}),r.map(m=>{const g=Vb(pw(m.content)).replaceAll(`
`," ");return w.jsxs("div",{className:"linked-memo-container",onClick:()=>d(m),children:[w.jsxs("span",{className:"time-text",children:[m.dateStr," "]}),g]},m.id)})]}):null,o.length>0?w.jsxs("div",{className:"linked-memos-wrapper",children:[w.jsxs("span",{className:"normal-text",children:[o.length," THINO ",N("LINK TO THE")," THINO"]}),o.map(m=>{const g=Vb(pw(m.content)).replaceAll(`
`," ");return w.jsxs("div",{className:"linked-memo-container",onClick:()=>d(m),children:[w.jsxs("span",{className:"time-text",children:[m.dateStr," "]}),g]},m.id)})]}):null]})};function $d(e){By({className:"memo-card-dialog"},R5,{memo:e})}const B5=' ',_5=' ',QD=(e,t)=>{const n=window.atob(e),r=new ArrayBuffer(n.length),a=new Uint8Array(r);for(let o=0;o{const{vault:t}=Xe.getState().app,n=await t.adapter.readBinary(e),r=new Uint8Array(n),a=new Blob([r],{type:"image/png"});return new Promise(o=>{const s=new FileReader;s.onloadend=()=>{const c=s.result;o(c)},s.readAsDataURL(a)})},Y5=async e=>{const t=e.find(".thino-user-icon");if(t){const n=await Uh(t);t.style.backgroundImage=`url(${n})`}},z5=async()=>{const{app:e,settings:t}=Xe.getState();let n,r;const a=document.body.hasClass("theme-light"),o=a?t==null?void 0:t.DefaultLightBackgroundImage:t==null?void 0:t.DefaultDarkBackgroundImage,s=await e.vault.adapter.exists(t==null?void 0:t.DefaultLightBackgroundImage)&&/\.(png|svg|jpg|jpeg)/g.test(t==null?void 0:t.DefaultLightBackgroundImage),c=o==null?void 0:o.startsWith("http");s||c?(r=o,n=c?await xd(o):await H5(r)):n="data:image/svg+xml;base64,"+btoa(a?B5:_5);const d=document.querySelector(".dialog-wrapper .memo-background .property-image");d.style.backgroundImage="url('"+n+"')",document.body.className.contains("theme-dark")&&(d.style.backgroundColor="#1f1f1f")},U5=e=>{const{memo:t,destroy:n}=e,{memos:r}=Ee.getState().memoState,{view:a,app:o,settings:s}=Ee.getState().dailyNotesState,c={...t,createdAtStr:Ue.getDateTimeString(t.createdAt)},[d,p]=A.useState(!1),[m,g]=A.useState(c.content),[v,D]=A.useState(!1),S=A.useRef(null),T=A.useRef(null),E=A.useRef(null),[O,k]=A.useState(""),j=A.useRef(null),F=A.useRef(null);let B,R;r.length&&(B=r.length>0?r[r.length-1]:null,B?R=r?Math.ceil((Date.now()-Ue.getTimeStampByDate(B==null?void 0:B.createdAt))/1e3/3600/24)+1:0:R=0),s==null||s.ShareFooterEnd.replace("{UserName}",s==null?void 0:s.UserName);const z=s==null?void 0:s.ShareFooterStart.replace("{ThinoNum}",r.length.toString()).replace("{UsedDay}",R.toString());A.useEffect(()=>{!S.current||!T.current||(C.setIcon(S.current,"copy"),C.setIcon(T.current,"x"))},[S,T]),A.useEffect(()=>{E.current&&C.setIcon(E.current,"file-down")},[E]),A.useEffect(()=>{C.setIcon(S.current,v?"loader":"copy"),S.current.disabled=v,S.current.toggleClass("copying",v)},[v]),A.useEffect(()=>{if(!F.current||!a||d)return;g(t.content),F.current.hasChildNodes()&&F.current.empty();async function Q(){var le;(le=F.current)==null||le.toggleClass(["markdown-rendered"],!0),await C.MarkdownRenderer.render(o,t.content+`
`,F.current,t.path,a)}Q(),setTimeout(async()=>{if(await z5(),await Y5(j.current),!j.current)return;let le;document.body.hasClass("theme-dark")?le="#727171":le="#eaeaea",Zy(j.current,{backgroundColor:le,pixelRatio:window.devicePixelRatio*2}).then(pe=>{k(pe),p(!0)}).catch(()=>{})},MI)},[j,F,c]);const H=()=>{n()},Y=A.useCallback(Q=>{D(Q)},[v]),U=async()=>{const{vault:Q}=Ee.getState().dailyNotesState.app,le=j.current.querySelector(".memo-shortcut-img");if(!le)return;const pe=le==null?void 0:le.getAttribute("src").split("base64,")[1],ie=QD(pe,"image/png");let se;ie.arrayBuffer().then(async fe=>{const oe="png",we=bs();for(const Z in we)if(we[Z]instanceof C.TFile){se=we[Z];break}if(se!==void 0){const Z=await Q.getAvailablePathForAttachments(`Pasted Image ${C.moment().format("YYYYMMDDHHmmss")}`,oe,se);await Q.createBinary(Z,fe),new C.Notice(N("Save image successfully"))}})},J=async()=>{Y(!0);const Q=j.current.querySelector(".memo-shortcut-img");if(!Q)return;const le=Q==null?void 0:Q.getAttribute("src").split("base64,")[1],pe=QD(le,"image/png");if(!pe){new C.Notice("Copy to clipboard failed");return}const ie=new ClipboardItem({"image/png":pe});window.navigator.clipboard.write([ie]).then(()=>{setTimeout(()=>{Y(!1)},500)}),new C.Notice("Copy to clipboard successfully")};return w.jsxs(w.Fragment,{children:[w.jsxs("div",{className:"dialog-header-container",children:[w.jsxs("p",{className:"title-text",children:[w.jsx("span",{className:"icon-text",children:"🥰"}),N("Share Memo Image")]}),w.jsxs("div",{className:"btn-group",children:[C.Platform.isMobile&&w.jsx("button",{ref:E,className:"btn download-btn",onClick:U}),w.jsx("button",{ref:S,className:"btn copy-btn",onClick:J}),w.jsx("button",{ref:T,className:"btn close-btn",onClick:H})]})]}),w.jsxs("div",{className:"dialog-content-container",children:[w.jsx("div",{className:`tip-words-container ${O?"finish":"loading"}`,children:w.jsx("p",{className:"tip-text",children:N(O?"↗Click the button to save":"Image is generating...")})}),w.jsxs("div",{className:"memo-container",ref:j,children:[w.jsx(so,{when:O!=="",children:w.jsx("img",{className:"memo-shortcut-img",onClick:J,src:O})}),w.jsxs("div",{className:"memo-background",children:[w.jsx("div",{className:"property-image",style:{backgroundSize:"cover",backgroundRepeat:"no-repeat",backgroundPosition:"center"}}),w.jsx("span",{className:"background-container"}),w.jsxs("div",{className:"thino-user-header",children:[w.jsx("div",{className:"thino-user-icon",ref:Q=>{if(s!=null&&s.MomentsIcon){Q==null||Q.empty();return}s!=null&&s.MomentsIcon||Q&&C.setIcon(Q,"Memos")},style:{backgroundImage:`url(${s==null?void 0:s.MomentsIcon})`}}),w.jsxs("div",{className:"thino-user-info",children:[w.jsx("div",{className:"thino-user-name",children:s==null?void 0:s.UserName}),(s==null?void 0:s.MomentsQuote)&&w.jsx("div",{className:"thino-user-quote",children:s==null?void 0:s.MomentsQuote})]})]}),w.jsx("div",{ref:F,className:"memo-content-text"}),w.jsx("div",{className:"thino-time-footer",children:c.createdAt}),w.jsxs("div",{className:"watermark-container",children:[w.jsxs("span",{className:"normal-text footer-start",children:[w.jsx("div",{className:"property-social-icons"}),w.jsx("span",{className:"name-text",children:z})]}),w.jsx("span",{className:"normal-text footer-end",children:w.jsx("span",{className:"name-text",children:"THINO"})})]})]})]})]})]})};function V5(e){By({className:"share-memo-image-dialog"},U5,{memo:e})}const Z5=A.forwardRef((e,t)=>{const{memo:n,handlePinMemoClick:r,handleFixMemoClick:a,handleSourceMemoClick:o,handleShowMemoStoryDialog:s,handleCopyMemoClick:c,handleEditMemoClick:d,handleGenMemoImageBtnClick:p,handleMarkMemoClick:m,handleArchiveMemo:g,handleDeleteMemoClick:v}=e,D=A.useRef(null),S=Ee.getState().dailyNotesState.settings,[T,E]=ki(!1),O=A.useRef(null),k={pinRef:A.useRef(null),fixRef:A.useRef(null),typeRef:A.useRef(null),moreRef:A.useRef(null)},j={copy:A.useRef(null),read:A.useRef(null),mark:A.useRef(null),share:A.useRef(null),edit:A.useRef(null),source:A.useRef(null),archive:A.useRef(null),delete:A.useRef(null)};return A.useEffect(()=>{O.current&&(C.setIcon(j.copy.current,"copy"),C.setIcon(j.read.current,"book-open"),C.setIcon(j.mark.current,"bookmark"),C.setIcon(j.share.current,"share-2"),C.setIcon(j.edit.current,"pencil"),C.setIcon(j.source.current,"home"),C.setIcon(j.archive.current,"archive"),C.setIcon(j.delete.current,"trash"))},[O]),A.useEffect(()=>{if(!k.typeRef)return;const F=tp.find(B=>B.title===n.sourceType);C.setIcon(k.typeRef.current,F.icon),C.requireApiVersion("1.4.4")&&C.setTooltip(k.typeRef.current,n.path),k.fixRef&&(C.setIcon(k.fixRef.current,"shield-alert"),C.requireApiVersion("1.4.4")&&C.setTooltip(k.fixRef.current,"Update Thino property"))},[k.typeRef]),A.useEffect(()=>{k.pinRef&&(n.pinned?(C.setIcon(k.pinRef.current,"pin-off"),C.requireApiVersion("1.4.4")&&C.setTooltip(k.pinRef.current,N("UNPIN"))):(C.setIcon(k.pinRef.current,"pin"),C.requireApiVersion("1.4.4")&&C.setTooltip(k.pinRef.current,N("PIN"))))},[k.pinRef,n.pinned]),A.useImperativeHandle(t,()=>({toggleConfirm:F=>E(F),confirmStatus:T})),w.jsx("div",{ref:O,className:"memo-top-right-wrapper",children:w.jsxs("div",{className:"btns-container",children:[w.jsx("span",{ref:k.fixRef,className:`btn ${n.sourceType!=="MULTI"||n.id!==""?"hidden":""} fix-memo-btn`,onClick:()=>a(n)}),w.jsx("span",{ref:k.typeRef,className:`btn ${n.sourceType==="DAILY"?"hidden":""} source-type-btn`,onClick:()=>o(n)}),w.jsx("span",{ref:k.pinRef,className:`btn ${e.memo.pinned?"pinned-btn":"unpinned-btn"} pro`,onClick:r}),w.jsx("span",{ref:F=>{k.moreRef.current=F,F&&C.setIcon(F,"more-horizontal")},className:"btn more-action-btn"}),w.jsx("div",{ref:D,className:"more-action-btns-wrapper",children:w.jsxs("div",{className:"more-action-btns-container",children:[w.jsxs("div",{className:"more-action-btn-group more-action-menu-item",children:[w.jsx("span",{ref:j.copy,className:"more-action-item-icon",onClick:c}),w.jsx("span",{ref:j.edit,className:"more-action-item-icon",onClick:d}),w.jsx("span",{ref:j.share,className:"more-action-item-icon",onClick:p})]}),w.jsx("hr",{className:"menu-hr"}),w.jsxs("div",{className:"more-action-menu-item",onClick:s,children:[w.jsx("span",{ref:j.read,className:"more-action-item-icon"}),w.jsx("span",{className:"btn",children:N("READ")})]}),w.jsxs("div",{className:"more-action-menu-item",children:[w.jsx("span",{ref:j.mark,className:"more-action-item-icon"}),w.jsx("span",{className:"btn",onClick:m,children:N("MARK")})]}),w.jsxs("div",{className:"more-action-menu-item",children:[w.jsx("span",{ref:j.source,className:"more-action-item-icon"}),w.jsx("span",{className:"btn",onClick:()=>o(n),children:N("SOURCE")})]}),w.jsx("hr",{className:"menu-hr"}),w.jsxs("div",{className:"more-action-menu-item archive-menu-item",children:[w.jsx("span",{ref:j.archive,className:"more-action-item-icon"}),w.jsx("span",{className:"btn delete-btn",onClick:()=>g(n),children:N("ARCHIVE").toUpperCase()})]}),w.jsxs("div",{className:"more-action-menu-item delete-menu-item",children:[w.jsx("span",{ref:j.delete,className:"more-action-item-icon"}),w.jsx("span",{className:`btn delete-btn ${T?"final-confirm":""}`,onClick:async F=>{F.stopPropagation(),F.preventDefault(),await v(F)},children:T?N("CONFIRM!"):S.DeleteThinoDirectly?N("DELETE"):N("Recycle bin").toUpperCase()})]}),w.jsx("hr",{className:"menu-hr"}),w.jsx("div",{className:"text-count-item more-action-menu-item",children:w.jsx("span",{className:"btn text-count-btn",children:Ue.getWordCount(n.content.replace(/```[^\S\r\n]*[a-z]*\n.*?\n```/g,""))+` ${N("words")}`})})]})})]})})}),W5=e=>{const{memo:t,handleMemoTypeToggle:n,handleShowMemoStoryDialog:r,settings:a}=e;return w.jsxs("div",{className:"memo-top-left-wrapper",children:[e.children,w.jsx("span",{title:t.createdAt,className:"time-text",onClick:r,children:t.createdAt}),w.jsx("div",{className:`btn memo-type-img ${a!=null&&a.ShowTaskLabel?"":"hidden"}`,onClick:n,children:t.thinoType!=="JOURNAL"&&w.jsx("input",{className:"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)})})]})},$5=async(e,t,n)=>{const r=n.getAttribute("href"),a=n.className;if(a.contains("tag"))G5(n.innerText.slice(1));else if(a.contains("internal-link")){const o=n.getAttribute("data-href"),s=Te.getMemoById(o??"");s?$d(s):await e.workspace.openLinkText(o,o,!C.Platform.isMobile&&t.navigation!==!0)}else r&&window.open(r,"_blank")},G5=e=>{const t=He.getState().query.tag;He.setTagQuery(t.contains(",")?t.split(",").includes(e)?t.split(",").filter(n=>n!==e).join(","):t+","+e:t===e?"":e)},q5=(e,t)=>{const n=t==null?void 0:t.getAttribute("src"),r=t==null?void 0:t.parentElement.getAttribute("src"),a=[...(e==null?void 0:e.querySelectorAll("img"))||[]],o=a.indexOf(t);Wy({imgUrl:n,filepath:n.startsWith("app")?r:void 0,otherIMGEls:a,currentIndex:o})},J5=e=>{var r;const t=(r=e.dataset)==null?void 0:r.value,n=Te.getMemoById(t??"");n?$d(n):(new C.Notice("Thino Not Found"),e.classList.remove("memo-link-text"))},K5=async(e,t,n)=>{var o;const r=((o=n.parentElement.dataset)==null?void 0:o.task)==="x"?"DONE":"TODO",a=[...(t==null?void 0:t.querySelectorAll("li.task-list-item"))||[]];for(const s of a)if(s===n||s===n.closest("li.task-list-item")){const c=a.indexOf(s),d=e.content.split(/\n/),p=[];for(let S=0;S{const{globalState:{editMemoId:t},dailyNotesState:{app:n,view:r,settings:a,verifyState:o},locationState:{pathname:s}}=A.useContext(mt),{memo:c,type:d="inline"}=e,p=A.useRef(null),m=A.useRef(null),[g,v]=A.useState(!1);A.useEffect(()=>{g&&setTimeout(()=>{Qe.setEditMemoId(c.id)},100)},[g]),A.useEffect(()=>{(s==="/review"||s==="/daily")&&t!==c.id&&g&&v(!1)},[t]);const D=()=>{$d(c)},S=()=>{if(a!=null&&a.UseButtonToShowEditor&&(a==null?void 0:a.DefaultEditorLocation)==="Bottom"){const ie=document.querySelector("div[data-type='thino_view'] .view-content .memo-show-editor-button:not(.hidden)");ie&&ie.trigger("click")}Qe.setMarkMemoId(c.id)},T=async()=>{var fe;const ie=!C.Platform.isDesktop&&await((fe=window.Capacitor)==null?void 0:fe.Plugins.Device.getId()),se=C.Platform.isDesktop?await vn():ie.identifier||ie.uuid;if(!o||(o==null?void 0:o.appId)!==se){qt();return}c.pinned?await Te.unpinMemoById(c.id):await Te.pinMemoById(c.id)},E=()=>{if(a!=null&&a.UseButtonToShowEditor&&(a==null?void 0:a.DefaultEditorLocation)==="Bottom"&&C.Platform.isMobile){const ie=document.querySelector("div[data-type='thino_view'] .view-content .memo-show-editor-button:not(.hidden)");ie&&ie.trigger("click")}(s==="/review"||s==="/daily")&&v(!0),s!=="/review"&&s!=="/daily"&&Qe.setEditMemoId(c.id)},O=async ie=>{ie.sourceType==="MULTI"&&ie.id.trim()===""&&await Te.updateMemoProperty(ie)},k=async ie=>{await Te.openThinoByID(ie.id)},j=async ie=>{try{const se=await Te.archiveMemo(ie);se&&Te.editMemo(se)}catch(se){console.error(se),new C.Notice(se.message)}},F=async(ie,se)=>{if(!se&&m.current&&!m.current.confirmStatus){m.current&&m.current.toggleConfirm();return}try{if(a.DeleteThinoDirectly)await Te.deleteMemoById(c.id);else{const fe=await Te.hideMemoById(c.id);fe&&Te.editMemo(fe)}}catch(fe){new C.Notice(fe.message)}Qe.getState().editMemoId===c.id&&Qe.setEditMemoId("")},B=()=>{if(m.current&&!m.current.confirmStatus){m.current&&m.current.toggleConfirm(!1);return}},R=()=>{V5(c)},z=async()=>{const ie=await Te.updateMemo(c.id,c.content,c.thinoType==="TASK-TODO"?"TASK-DONE":"TASK-TODO");ie&&Te.editMemo(ie)},H=async ie=>{ie.stopPropagation(),navigator.clipboard.writeText(c.content).then(()=>{new C.Notice(N("COPY SUCCEED"))}).catch(()=>{new C.Notice(N("COPY FAILED"))})},Y=ie=>{ie&&ie.target.tagName!=="INPUT"&&E()},U=async(ie,se)=>{ie.preventDefault(),ie.stopPropagation();const fe=ie.target;if(ie.ctrlKey||ie.metaKey){await k(se);return}if(fe.tagName==="A"){await $5(n,r,fe);return}if(fe.tagName==="IMG"){q5(p.current,fe);return}if(fe.tagName==="A"&&fe.getAttribute("href")){const oe=fe.getAttribute("href");window.open(oe,"_blank");return}if(fe.className==="memo-link-text"){J5(fe);return}if(fe.tagName==="INPUT"&&fe.hasClass("task-list-item-checkbox")){await K5(se,p.current,fe);return}},J=ie=>{const se=new C.Menu;se.dom.toggleClass("memo-context-menu",!0);const fe=window.getSelection();(fe==null?void 0:fe.toString().length)>0&&se.addItem(oe=>{oe.setIcon("copy").setTitle(N("Copy selected text")).onClick(()=>{navigator.clipboard.writeText(fe.toString()).then(()=>{new C.Notice(N("COPY SUCCEED"))}).catch(()=>{new C.Notice(N("COPY FAILED"))})})}).addSeparator(),se.addItem(oe=>{oe.setIcon("copy").setTitle(N("Copy thino").toLocaleUpperCase()).onClick(async we=>{await H(we),se.close()})}).addItem(oe=>{oe.setIcon("book-open").setTitle(N("READ")).onClick(D)}).addItem(oe=>{oe.setIcon(c.pinned?"pin-off":"pin").setTitle(c.pinned?N("UNPIN"):N("PIN")).onClick(T)}).addItem(oe=>{oe.setIcon("bookmark").setTitle(N("MARK")).onClick(S)}).addItem(oe=>{oe.setIcon("share-2").setTitle(N("SHARE")).onClick(R)}).addItem(oe=>{oe.setIcon("pencil").setTitle(N("EDIT")).onClick(E)}).addItem(oe=>{oe.setIcon("home").setTitle(N("SOURCE")).onClick(()=>k(c))}).addSeparator().addItem(oe=>{oe.setIcon("archive").setTitle(N("ARCHIVE").toLocaleUpperCase()).onClick(()=>j(c))}).addItem(oe=>{oe.setIcon("trash").setTitle(N("DELETE")).onClick(async we=>{await F(we,!0)})}),se.showAtMouseEvent(ie.nativeEvent)},Q=A.useMemo(()=>({memo:c,handlePinMemoClick:T,handleFixMemoClick:O,handleSourceMemoClick:k,handleArchiveMemo:j,handleDeleteMemoClick:F,handleGenMemoImageBtnClick:R,handleMarkMemoClick:S,handleEditMemoClick:E,handleCopyMemoClick:H,handleShowMemoStoryDialog:D}),[c]),le=A.useMemo(()=>({memo:c,handleMemoTypeToggle:z,handleShowMemoStoryDialog:D,settings:a}),[c,a]),pe=A.useMemo(()=>w.jsxs("div",{ref:p,className:`memo-wrapper ${c.pinned?"pinned":""}`,"data-source-type":c.sourceType,"data-thino-type":c.thinoType,"data-thino-id":c.id,onMouseLeave:B,onMouseOver:ie=>{ie.shiftKey&&(ie.stopPropagation(),n.workspace.trigger("hover-link",{event:ie,source:"thino",hoverParent:r.containerEl,targetEl:p.current,linktext:c.path,sourcePath:c.path,state:{scroll:c.sourceType==="DAILY"?parseInt(c.id.slice(14)):0}}))},onContextMenu:J,children:[g&&w.jsx(Nu,{editorType:"inline"}),!g&&w.jsxs(w.Fragment,{children:[d==="inline"&&w.jsxs("div",{className:"memo-top-wrapper",draggable:!0,onDragStart:ie=>{ie.target.classList.add("dragging"),ie.dataTransfer.setDragImage(p.current,0,0),ie.dataTransfer.setData("text/plain",c.content)},onDragEnd:ie=>{ie.target.classList.remove("dragging")},children:[w.jsx(W5,{...le}),w.jsx(Z5,{ref:m,...Q})]}),w.jsx(bE,{memo:c,handleMemoContentClick:U,handleMemoDoubleClick:Y})]})]}),[c,g]);return w.jsx(w.Fragment,{children:pe})},Sa=A.memo(Q5);function X5(e,t){if(e==null)return{};var n=eF(e,t),r,a;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(a=0;a=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function eF(e,t){if(e==null)return{};var n={},r=Object.keys(e),a,o;for(o=0;o=0)&&(n[a]=e[a]);return n}function my(){return my=Object.assign||function(e){for(var t=1;t{this.reCalculateColumnCount()})}reCalculateColumnCount(){const t=window&&window.innerWidth||1/0;let n=this.props.breakpointCols;typeof n!="object"&&(n={default:parseInt(n)||j0});let r=1/0,a=n.default||j0;for(let o in n){const s=parseInt(o);s>0&&t<=s&&s"u"&&(s="my-masonry-grid_column"));const c=Lh(Lh(Lh({},t),n),{},{style:Lh(Lh({},n.style),{},{width:o}),className:s});return a.map((d,p)=>$.createElement("div",my({},c,{key:p}),d))}logDeprecated(t){console.error("[Masonry]",t)}render(){const t=this.props,{children:n,breakpointCols:r,columnClassName:a,columnAttrs:o,column:s,className:c}=t,d=X5(t,["children","breakpointCols","columnClassName","columnAttrs","column","className"]);let p=c;return typeof c!="string"&&(this.logDeprecated('The property "className" requires a string'),typeof c>"u"&&(p="my-masonry-grid")),$.createElement("div",my({},d,{className:p}),this.renderColumns())}}gy.defaultProps=nF;const Ow=e=>{const t=Ee.getState().dailyNotesState.settings,{thinos:n,dayMark:r,dayMarkRange:a="day",thinoWrapper:o}=e,[s,c]=$.useState(!(t!=null&&t.hidePinnedGroup&&r==="PINNED")),d=$.useRef(null);A.useEffect(()=>{d&&C.setTooltip&&C.setTooltip(d.current,N("Click to expand or fold, Cmd+Click to show all thinos of the day"))},[d]);const p=g=>{if(C.Keymap.isModifier(g.nativeEvent,"Mod")){const v={day:"YYYY-MM-DD",week:"YYYY-[W]WW",month:"YYYY-MM",quarter:"YYYY-[Q]Q",year:"YYYY"},D=C.moment(r,v[a]);He.setFromAndToQuery(D.startOf(a).valueOf(),D.endOf(a).valueOf());return}c(!s)},m=A.useMemo(()=>w.jsx(w.Fragment,{children:e.type==="list"?w.jsxs(w.Fragment,{children:[w.jsx("div",{ref:d,className:`day-mark ${s?"":"folded"} PINNED`,onClick:p,children:w.jsxs("span",{className:"day-mark-text",children:[s?"▼ ":"▶ ",r==="PINNED"?r+" 📌":r]})},r),s&&n.map((g,v)=>o?o({thino:g}):w.jsx(Sa,{memo:g},`${g.id}-${C.moment(g.updatedAt,"YYYY/MM/DD HH:mm:ss").format("x")}-${v}`))]}):w.jsxs(w.Fragment,{children:[w.jsx("div",{ref:d,className:`day-mark ${s?"":"folded"}`,onClick:p,children:w.jsxs("span",{className:"day-mark-text",children:[s?"▼ ":"▶ ",r==="PINNED"?r+" 📌":r]})},r),w.jsx(gy,{breakpointCols:e.type==="waterfall"?3:1,className:`${e.type}-view masonry-memolist`,columnClassName:"masonry-memolist-grid_column",children:s&&n.map((g,v)=>o?o({thino:g}):w.jsx(Sa,{memo:g},`${g.id}-${C.moment(g.updatedAt,"YYYY/MM/DD HH:mm:ss").format("x")}-${v}`))})]})}),[n,s]);return w.jsx(w.Fragment,{children:m})};function gs(e){"@babel/helpers - typeof";return gs=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},gs(e)}function rF(e,t){if(gs(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(gs(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function DE(e){var t=rF(e,"string");return gs(t)=="symbol"?t:String(t)}function Iu(e,t,n){return t=DE(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function eS(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),n.push.apply(n,r)}return n}function rn(e){for(var t=1;t=0)&&(n[a]=e[a]);return n}function Fi(e,t){if(e==null)return{};var n=$y(e,t),r,a;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(a=0;a=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function gr(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function tS(e,t){for(var n=0;ne.length)&&(t=e.length);for(var n=0,r=new Array(t);n1?z-1:0),Y=1;Yt}),_p=qd(function(e,t){return e>=t}),L1=qd(function(e,t){return e=t&&a.getHours()-n.getHours()a?0:a+t),n=n>a?a:n,n<0&&(n+=a),a=t>n?0:n-t>>>0,t>>>=0;for(var o=Array(a);++r-1&&e%1==0&&e<=rO}var B1=aO,oO=R1,iO=B1;function sO(e){return e!=null&&iO(e.length)&&!oO(e)}var Yp=sO,lO=9007199254740991,uO=/^(?:0|[1-9]\d*)$/;function cO(e,t){var n=typeof e;return t=t??lO,!!t&&(n=="number"||n!="symbol"&&uO.test(e))&&e>-1&&e%1==0&&e{t.current=e},[e]),t}function mS(e){const t=f7(e);return A.useCallback(function(...n){return t.current&&t.current(...n)},[t])}function gS(){return A.useState(null)}function h7(){const e=A.useRef(!0),t=A.useRef(()=>e.current);return A.useEffect(()=>(e.current=!0,()=>{e.current=!1}),[]),t.current}function p7(e){const t=h7();return[e[0],A.useCallback(n=>{if(t())return e[1](n)},[t,e[1]])]}var m7=fE({defaultModifiers:[lE,cE,rE,aE,uE,sE,dE,nE]}),yS=function(t){return{position:t,top:"0",left:"0",opacity:"0",pointerEvents:"none"}},g7={name:"applyStyles",enabled:!1},y7={name:"ariaDescribedBy",enabled:!0,phase:"afterWrite",effect:function(t){var n=t.state;return function(){var r=n.elements,a=r.reference,o=r.popper;if("removeAttribute"in a){var s=(a.getAttribute("aria-describedby")||"").split(",").filter(function(c){return c.trim()!==o.id});s.length?a.setAttribute("aria-describedby",s.join(",")):a.removeAttribute("aria-describedby")}}},fn:function(t){var n,r=t.state,a=r.elements,o=a.popper,s=a.reference,c=(n=o.getAttribute("role"))==null?void 0:n.toLowerCase();if(o.id&&c==="tooltip"&&"setAttribute"in s){var d=s.getAttribute("aria-describedby");if(d&&d.split(",").indexOf(o.id)!==-1)return;s.setAttribute("aria-describedby",d?d+","+o.id:o.id)}}},v7=[];function w7(e,t,n){var r=n===void 0?{}:n,a=r.enabled,o=a===void 0?!0:a,s=r.placement,c=s===void 0?"bottom":s,d=r.strategy,p=d===void 0?"absolute":d,m=r.modifiers,g=m===void 0?v7:m,v=$y(r,["enabled","placement","strategy","modifiers"]),D=A.useRef(),S=A.useCallback(function(){var F;(F=D.current)==null||F.update()},[]),T=A.useCallback(function(){var F;(F=D.current)==null||F.forceUpdate()},[]),E=p7(A.useState({placement:c,update:S,forceUpdate:T,attributes:{},styles:{popper:yS(p),arrow:{}}})),O=E[0],k=E[1],j=A.useMemo(function(){return{name:"updateStateModifier",enabled:!0,phase:"write",requires:["computeStyles"],fn:function(B){var R=B.state,z={},H={};Object.keys(R.elements).forEach(function(Y){z[Y]=R.styles[Y],H[Y]=R.attributes[Y]}),k({state:R,styles:z,attributes:H,update:S,forceUpdate:T,placement:R.placement})}}},[S,T,k]);return A.useEffect(function(){!D.current||!o||D.current.setOptions({placement:c,strategy:p,modifiers:[].concat(g,[j,g7])})},[p,c,j,o]),A.useEffect(function(){if(!(!o||e==null||t==null))return D.current=m7(e,t,An({},v,{placement:c,strategy:p,modifiers:[].concat(g,[y7,j])})),function(){D.current!=null&&(D.current.destroy(),D.current=void 0,k(function(F){return An({},F,{attributes:{},styles:{popper:yS(p)}})}))}},[o,e,t]),O}function b7(e,t,n,r){var a=r&&typeof r!="boolean"?r.capture:r;e.removeEventListener(t,n,a),n.__once&&e.removeEventListener(t,n.__once,a)}function Vh(e,t,n,r){return d7(e,t,n,r),function(){b7(e,t,n,r)}}function D7(e){return e&&"setState"in e?T1.findDOMNode(e):e??null}const S7=function(e){return Up(D7(e))};var I7=27,vS=function(){};function T7(e){return e.button===0}function E7(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}var wS=function(t){return t&&("current"in t?t.current:t)};function C7(e,t,n){var r=n===void 0?{}:n,a=r.disabled,o=r.clickTrigger,s=o===void 0?"click":o,c=A.useRef(!1),d=t||vS,p=A.useCallback(function(v){var D,S=wS(e);c5(!!S,"RootClose captured a close event but does not have a ref to compare it to. useRootClose(), should be passed a ref that resolves to a DOM node"),c.current=!S||E7(v)||!T7(v)||!!pp(S,(D=v.composedPath==null?void 0:v.composedPath()[0])!=null?D:v.target)},[e]),m=mS(function(v){c.current||d(v)}),g=mS(function(v){v.keyCode===I7&&d(v)});A.useEffect(function(){if(!(a||e==null)){var v=window.event,D=S7(wS(e)),S=Vh(D,s,p,!0),T=Vh(D,s,function(k){if(k===v){v=void 0;return}m(k)}),E=Vh(D,"keyup",function(k){if(k===v){v=void 0;return}g(k)}),O=[];return"ontouchstart"in D.documentElement&&(O=[].slice.call(D.body.children).map(function(k){return Vh(k,"mousemove",vS)})),function(){S(),T(),E(),O.forEach(function(k){return k()})}}},[e,a,s,p,m,g])}function x7(e){var t={};return Array.isArray(e)?(e==null||e.forEach(function(n){t[n.name]=n}),t):e||t}function M7(e){return e===void 0&&(e={}),Array.isArray(e)?e:Object.keys(e).map(function(t){return e[t].name=t,e[t]})}function N7(e){var t,n,r,a,o=e.enabled,s=e.enableEvents,c=e.placement,d=e.flip,p=e.offset,m=e.fixed,g=e.containerPadding,v=e.arrowElement,D=e.popperConfig,S=D===void 0?{}:D,T=x7(S.modifiers);return An({},S,{placement:c,enabled:o,strategy:m?"fixed":S.strategy,modifiers:M7(An({},T,{eventListeners:{enabled:s},preventOverflow:An({},T.preventOverflow,{options:g?An({padding:g},(t=T.preventOverflow)==null?void 0:t.options):(n=T.preventOverflow)==null?void 0:n.options}),offset:{options:An({offset:p},(r=T.offset)==null?void 0:r.options)},arrow:An({},T.arrow,{enabled:!!v,options:An({},(a=T.arrow)==null?void 0:a.options,{element:v})}),flip:An({enabled:!!d},T.flip)}))})}function k7(e,t){return e.classList?!!t&&e.classList.contains(t):(" "+(e.className.baseVal||e.className)+" ").indexOf(" "+t+" ")!==-1}function A7(e,t){e.classList?e.classList.add(t):k7(e,t)||(typeof e.className=="string"?e.className=e.className+" "+t:e.setAttribute("class",(e.className&&e.className.baseVal||"")+" "+t))}function bS(e,t){return e.replace(new RegExp("(^|\\s)"+t+"(?:\\s|$)","g"),"$1").replace(/\s+/g," ").replace(/^\s*|\s*$/g,"")}function F7(e,t){e.classList?e.classList.remove(t):typeof e.className=="string"?e.className=bS(e.className,t):e.setAttribute("class",bS(e.className&&e.className.baseVal||"",t))}var jg;function JE(e){if((!jg&&jg!==0||e)&&Y1){var t=document.createElement("div");t.style.position="absolute",t.style.top="-9999px",t.style.width="50px",t.style.height="50px",t.style.overflow="scroll",document.body.appendChild(t),jg=t.offsetWidth-t.clientWidth,document.body.removeChild(t)}return jg}var H0=function(t){var n;return typeof document>"u"?null:t==null?Up().body:(typeof t=="function"&&(t=t()),t&&"current"in t&&(t=t.current),(n=t)!=null&&n.nodeType&&t||null)};function DS(e,t){var n=A.useState(function(){return H0(e)}),r=n[0],a=n[1];if(!r){var o=H0(e);o&&a(o)}return A.useEffect(function(){t&&r&&t(r)},[t,r]),A.useEffect(function(){var s=H0(e);s!==r&&a(s)},[e,r]),r}const SS=e=>!e||typeof e=="function"?e:t=>{e.current=t};function O7(e,t){const n=SS(e),r=SS(t);return a=>{n&&n(a),r&&r(a)}}function P7(e,t){return A.useMemo(()=>O7(e,t),[e,t])}var z1=$.forwardRef(function(e,t){var n=e.flip,r=e.offset,a=e.placement,o=e.containerPadding,s=o===void 0?5:o,c=e.popperConfig,d=c===void 0?{}:c,p=e.transition,m=gS(),g=m[0],v=m[1],D=gS(),S=D[0],T=D[1],E=P7(v,t),O=DS(e.container),k=DS(e.target),j=A.useState(!e.show),F=j[0],B=j[1],R=w7(k,g,N7({placement:a,enableEvents:!!e.show,containerPadding:s||5,flip:n,offset:r,arrowElement:S,popperConfig:d})),z=R.styles,H=R.attributes,Y=$y(R,["styles","attributes"]);e.show?F&&B(!1):!e.transition&&!F&&B(!0);var U=function(){B(!0),e.onExited&&e.onExited.apply(e,arguments)},J=e.show||p&&!F;if(C7(g,e.onHide,{disabled:!e.rootClose||e.rootCloseDisabled,clickTrigger:e.rootCloseEvent}),!J)return null;var Q=e.children(An({},Y,{show:!!e.show,props:An({},H.popper,{style:z.popper,ref:E}),arrowProps:An({},H.arrow,{style:z.arrow,ref:T})}));if(p){var le=e.onExit,pe=e.onExiting,ie=e.onEnter,se=e.onEntering,fe=e.onEntered;Q=$.createElement(p,{in:e.show,appear:!0,onExit:le,onExiting:pe,onExited:U,onEnter:ie,onEntering:se,onEntered:fe},Q)}return O?T1.createPortal(Q,O):null});z1.displayName="Overlay";z1.propTypes={show:Ae.bool,placement:Ae.oneOf(x1),target:Ae.any,container:Ae.any,flip:Ae.bool,children:Ae.func.isRequired,containerPadding:Ae.number,popperConfig:Ae.object,rootClose:Ae.bool,rootCloseEvent:Ae.oneOf(["click","mousedown"]),rootCloseDisabled:Ae.bool,onHide:function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),a=1;a-1}var J7=q7,K7=Jy;function Q7(e,t){var n=this.__data__,r=K7(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this}var X7=Q7,eP=R7,tP=V7,nP=$7,rP=J7,aP=X7;function Qd(e){var t=-1,n=e==null?0:e.length;for(this.clear();++tc))return!1;var p=o.get(e),m=o.get(t);if(p&&m)return p==t&&m==e;var g=-1,v=!0,D=n&gL?new fL:void 0;for(o.set(e,t),o.set(t,e);++g0&&n(c)?t>1?pC(c,t-1,n,r,a):MY(a,c):r||(a[a.length]=c)}return a}var mC=pC;function kY(e){return function(t,n,r){for(var a=-1,o=Object(t),s=r(t),c=s.length;c--;){var d=s[e?c:++a];if(n(o[d],d,o)===!1)break}return t}}var AY=kY,FY=AY,OY=FY(),PY=OY,jY=PY,LY=Vp;function RY(e,t){return e&&jY(e,t,LY)}var nb=RY,BY=Yp;function _Y(e,t){return function(n,r){if(n==null)return n;if(!BY(n))return e(n,r);for(var a=n.length,o=t?a:-1,s=Object(n);(t?o--:++ot||o&&s&&d&&!c&&!p||r&&s&&d||!n&&d||!a)return 1;if(!r&&!o&&!p&&e=c)return d;var p=n[r];return d*(p=="desc"?-1:1)}}return e.index-t.index}var tz=ez,W0=tb,nz=av,rz=iv,az=GY,oz=JY,iz=tv,sz=tz,lz=ov,uz=fo;function cz(e,t,n){t.length?t=W0(t,function(o){return uz(o)?function(s){return nz(s,o.length===1?o[0]:o)}:o}):t=[lz];var r=-1;t=W0(t,iz(rz));var a=az(e,function(o,s,c){var d=W0(t,function(p){return p(o)});return{criteria:d,index:++r,value:o}});return oz(a,function(o,s){return sz(o,s,n)})}var dz=cz;function fz(e,t,n){switch(n.length){case 0:return e.call(t);case 1:return e.call(t,n[0]);case 2:return e.call(t,n[0],n[1]);case 3:return e.call(t,n[0],n[1],n[2])}return e.apply(t,n)}var hz=fz,pz=hz,XS=Math.max;function mz(e,t,n){return t=XS(t===void 0?e.length-1:t,0),function(){for(var r=arguments,a=-1,o=XS(r.length-t,0),s=Array(o);++a0){if(++t>=Tz)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}var Mz=xz,Nz=Iz,kz=Mz,Az=kz(Nz),vC=Az,Fz=ov,Oz=gC,Pz=vC;function jz(e,t){return Pz(Oz(e,t,Fz),e+"")}var wC=jz,Lz=mC,Rz=dz,Bz=wC,t2=qy,_z=Bz(function(e,t){if(e==null)return[];var n=t.length;return n>1&&t2(e,t[0],t[1])?t=[]:n>2&&t2(t[0],t[1],t[2])&&(t=[t[0]]),Rz(e,Lz(t,1),[])}),Hz=_z;const Yz=er(Hz);function Vw(e,t){var n=H1(e);return n?n.innerWidth:t?e.clientWidth:ku(e).width}function bC(e){return TE(e)||_E(e)||P1(e)||EE()}function zz(e,t){for(var n=-1,r=e==null?0:e.length;++n1),o}),OW(e,LW(e),n),r&&(n=kW(n,RW|BW|_W,PW));for(var a=t.length;a--;)AW(n,t[a]);return n}),YW=HW;const zW=er(YW);var UW=wC,VW=Hp,ZW=qy,WW=sv,kC=Object.prototype,$W=kC.hasOwnProperty,GW=UW(function(e,t){e=Object(e);var n=-1,r=t.length,a=r>2?t[2]:void 0;for(a&&ZW(t[0],t[1],a)&&(r=1);++n0&&(c=c[0]),d=(c=c.filter(function(m){return m}))[0];for(var p=1;p2?r-2:0),o=2;o2&&arguments[2]!==void 0?arguments[2]:"day",r=e,a=[];Gd(r,t,n);)a.push(r),r=Ro(r,1,n);return a}function C$(e,t){return t==null&&e==null?null:(t==null&&(t=new Date),e==null&&(e=new Date),e=Mr(e,"day"),e=hp(e,hp(t)),e=jd(e,jd(t)),e=fp(e,fp(t)),dp(e,dp(t)))}function p2(e){return hp(e)===0&&jd(e)===0&&fp(e)===0&&dp(e)===0}function x$(e,t,n,r){return n==="day"&&(n="date"),Math.abs(oS[n](e,void 0,r)-oS[n](t,void 0,r))}function ob(e,t,n){return!n||n==="milliseconds"?Math.abs(+e-+t):Math.round(Math.abs(+Mr(e,n)/h2[n]-+Mr(t,n)/h2[n]))}var M$=Ae.oneOfType([Ae.string,Ae.func]);function N$(e,t,n,r,a){var o=typeof r=="function"?r(n,a,e):t.call(e,n,r,a);return op(o==null||typeof o=="string","`localizer format(..)` must return a string, null, or undefined"),o}function k$(e,t,n){return new Date(e.getFullYear(),e.getMonth(),e.getDate(),0,t+n,0,0)}function ib(e,t){return e.getTimezoneOffset()-t.getTimezoneOffset()}function A$(e,t){return ob(e,t,"minutes")+ib(e,t)}function F$(e){var t=Mr(e,"day");return ob(t,e,"minutes")+ib(t,e)}function O$(e,t){return L1(e,t,"day")}function P$(e,t,n){var r=Bp(e,t,"minutes");return r?_p(t,n,"minutes"):Gy(t,n,"minutes")}function Zw(e,t){return x$(e,t,"day")}function j$(e){var t=e.evtA,n=t.start,r=t.end,a=t.allDay,o=e.evtB,s=o.start,c=o.end,d=o.allDay,p=+Mr(n,"day")-+Mr(s,"day"),m=Zw(n,r),g=Zw(s,c);return p||g-m||!!d-!!a||+n-+s||+r-+c}function L$(e){var t=e.event,n=t.start,r=t.end,a=e.range,o=a.start,s=a.end,c=Mr(n,"day"),d=Gd(c,s,"day"),p=j1(c,r,"minutes"),m=p?Gy(r,o,"minutes"):_p(r,o,"minutes");return d&&m}function R$(e,t){return Bp(e,t,"day")}function B$(e,t){return p2(e)&&p2(t)}var _$=yr(function e(t){var n=this;gr(this,e),op(typeof t.format=="function","date localizer `format(..)` must be a function"),op(typeof t.firstOfWeek=="function","date localizer `firstOfWeek(..)` must be a function"),this.propType=t.propType||M$,this.formats=t.formats,this.format=function(){for(var r=arguments.length,a=new Array(r),o=0;o1,pe=E.eventProp(s,J,U,c),ie=$.createElement("div",{className:"rbc-event-content",title:Y||void 0},j?$.createElement(j,{event:s,continuesPrior:D,continuesAfter:S,title:H,isAllDay:Q,localizer:v,slotStart:B,slotEnd:R}):H);return $.createElement(F,Object.assign({},this.props,{type:"date"}),$.createElement("div",Object.assign({},z,{style:rn(rn({},pe.style),a),className:Qn("rbc-event",o,pe.className,{"rbc-selected":c,"rbc-event-allday":le,"rbc-event-continues-prior":D,"rbc-event-continues-after":S}),onClick:function(fe){return p&&p(s,fe)},onDoubleClick:function(fe){return m&&m(s,fe)},onKeyDown:function(fe){return g&&g(s,fe)}}),typeof O=="function"?O(ie):ie))}}]),t}($.Component);function uv(e,t){return!e||t==null?!1:l_(e,t)}function PC(e,t){var n=e.right-e.left,r=n/t;return r}function jC(e,t,n,r){var a=PC(e,r);return n?r-1-Math.floor((t-e.left)/a):Math.floor((t-e.left)/a)}function Z$(e,t){var n=t.x,r=t.y;return r>=e.top&&r<=e.bottom&&n>=e.left&&n<=e.right}function W$(e,t,n,r,a){var o=-1,s=-1,c=r-1,d=PC(t,r),p=jC(t,n.x,a,r),m=t.topn.y,g=t.tope.y,v=e.y>t.bottom,D=t.top>e.y,S=n.topt.bottom;return S&&(o=0,s=c),m&&(D?(o=0,s=p):v&&(o=p,s=c)),g&&(o=s=a?c-Math.floor((e.x-t.left)/d):Math.floor((e.x-t.left)/d),m?pk?s-O-z:s+z+p,Y=B>j?c+R-E+d:c+R;return{topOffset:H,leftOffset:Y}}function G$(e){var t=e.containerRef,n=e.accessors,r=e.getters,a=e.selected,o=e.components,s=e.localizer,c=e.position,d=e.show,p=e.events,m=e.slotStart,g=e.slotEnd,v=e.onSelect,D=e.onDoubleClick,S=e.onKeyPress,T=e.handleDragStart,E=e.popperRef,O=e.target,k=e.offset;U$({ref:E,callback:d}),A.useLayoutEffect(function(){var B=$$({target:O,offset:k,container:t.current,box:E.current}),R=B.topOffset,z=B.leftOffset;E.current.style.top="".concat(R,"px"),E.current.style.left="".concat(z,"px")},[k.x,k.y,O]);var j=c.width,F={minWidth:j+j/2};return $.createElement("div",{style:F,className:"rbc-overlay",ref:E},$.createElement("div",{className:"rbc-overlay-header"},s.format(m,"dayHeaderFormat")),p.map(function(B,R){return $.createElement(OC,{key:R,type:"popup",localizer:s,event:B,getters:r,onSelect:v,accessors:n,components:o,onDoubleClick:D,onKeyPress:S,continuesPrior:s.lt(n.end(B),m,"day"),continuesAfter:s.gte(n.start(B),g,"day"),slotStart:m,slotEnd:g,selected:uv(B,a),draggable:!0,onDragStart:function(){return T(B)},onDragEnd:function(){return d()}})}))}var LC=$.forwardRef(function(e,t){return $.createElement(G$,Object.assign({},e,{popperRef:t}))});LC.propTypes={accessors:Ae.object.isRequired,getters:Ae.object.isRequired,selected:Ae.object,components:Ae.object.isRequired,localizer:Ae.object.isRequired,position:Ae.object.isRequired,show:Ae.func.isRequired,events:Ae.array.isRequired,slotStart:Ae.instanceOf(Date).isRequired,slotEnd:Ae.instanceOf(Date),onSelect:Ae.func,onDoubleClick:Ae.func,onKeyPress:Ae.func,handleDragStart:Ae.func,style:Ae.object,offset:Ae.shape({x:Ae.number,y:Ae.number})};function q$(e){var t=e.containerRef,n=e.popupOffset,r=n===void 0?5:n,a=e.overlay,o=e.accessors,s=e.localizer,c=e.components,d=e.getters,p=e.selected,m=e.handleSelectEvent,g=e.handleDoubleClickEvent,v=e.handleKeyPressEvent,D=e.handleDragStart,S=e.onHide,T=e.overlayDisplay,E=A.useRef(null);if(!a.position)return null;var O=r;isNaN(r)||(O={x:r,y:r});var k=a.position,j=a.events,F=a.date,B=a.end;return $.createElement(j7,{rootClose:!0,flip:!0,show:!0,placement:"bottom",onHide:S,target:a.target},function(R){var z=R.props;return $.createElement(LC,Object.assign({},z,{containerRef:t,ref:E,target:a.target,offset:O,accessors:o,getters:d,selected:p,components:c,localizer:s,position:k,show:T,events:j,slotStart:F,slotEnd:B,onSelect:m,onDoubleClick:g,onKeyPress:v,handleDragStart:D}))})}var sb=$.forwardRef(function(e,t){return $.createElement(q$,Object.assign({},e,{containerRef:t}))});sb.propTypes={popupOffset:Ae.oneOfType([Ae.number,Ae.shape({x:Ae.number,y:Ae.number})]),overlay:Ae.shape({position:Ae.object,events:Ae.array,date:Ae.instanceOf(Date),end:Ae.instanceOf(Date)}),accessors:Ae.object.isRequired,localizer:Ae.object.isRequired,components:Ae.object.isRequired,getters:Ae.object.isRequired,selected:Ae.object,handleSelectEvent:Ae.func,handleDoubleClickEvent:Ae.func,handleKeyPressEvent:Ae.func,handleDragStart:Ae.func,onHide:Ae.func,overlayDisplay:Ae.func};function Lr(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:document;return Vh(n,e,t,{passive:!1})}function J$(e,t,n){return!e||pp(e,document.elementFromPoint(t,n))}function K$(e,t){var n=t.clientX,r=t.clientY,a=document.elementFromPoint(n,r);return lC(a,".rbc-event",e)}function Q$(e,t){var n=t.clientX,r=t.clientY,a=document.elementFromPoint(n,r);return lC(a,".rbc-show-more",e)}function Cy(e,t){return!!K$(e,t)}function X$(e,t){return!!Q$(e,t)}function wd(e){var t=e;return e.touches&&e.touches.length&&(t=e.touches[0]),{clientX:t.clientX,clientY:t.clientY,pageX:t.pageX,pageY:t.pageY}}var m2=5,eG=250,RC=function(){function e(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=n.global,a=r===void 0?!1:r,o=n.longPressThreshold,s=o===void 0?250:o,c=n.validContainers,d=c===void 0?[]:c;gr(this,e),this.isDetached=!1,this.container=t,this.globalMouse=!t||a,this.longPressThreshold=s,this.validContainers=d,this._listeners=Object.create(null),this._handleInitialEvent=this._handleInitialEvent.bind(this),this._handleMoveEvent=this._handleMoveEvent.bind(this),this._handleTerminatingEvent=this._handleTerminatingEvent.bind(this),this._keyListener=this._keyListener.bind(this),this._dropFromOutsideListener=this._dropFromOutsideListener.bind(this),this._dragOverFromOutsideListener=this._dragOverFromOutsideListener.bind(this),this._removeTouchMoveWindowListener=Lr("touchmove",function(){},window),this._removeKeyDownListener=Lr("keydown",this._keyListener),this._removeKeyUpListener=Lr("keyup",this._keyListener),this._removeDropFromOutsideListener=Lr("drop",this._dropFromOutsideListener),this._removeDragOverFromOutsideListener=Lr("dragover",this._dragOverFromOutsideListener),this._addInitialEventListener()}return yr(e,[{key:"on",value:function(n,r){var a=this._listeners[n]||(this._listeners[n]=[]);return a.push(r),{remove:function(){var s=a.indexOf(r);s!==-1&&a.splice(s,1)}}}},{key:"emit",value:function(n){for(var r=arguments.length,a=new Array(r>1?r-1:0),o=1;o0&&arguments[0]!==void 0?arguments[0]:0;return gs(e)!=="object"&&(e={top:e,left:e,right:e,bottom:e}),e}function g2(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,r=Ru(e),a=r.top,o=r.left,s=r.right,c=s===void 0?o:s,d=r.bottom,p=d===void 0?a:d,m=Ru(t),g=m.top,v=m.left,D=m.right,S=D===void 0?v:D,T=m.bottom,E=T===void 0?g:T;return!(p-nE||c-nS)}function Ru(e){if(!e.getBoundingClientRect)return e;var t=e.getBoundingClientRect(),n=t.left+y2("left"),r=t.top+y2("top");return{top:r,left:n,right:(e.offsetWidth||0)+n,bottom:(e.offsetHeight||0)+r}}function y2(e){if(e==="left")return window.pageXOffset||document.body.scrollLeft||0;if(e==="top")return window.pageYOffset||document.body.scrollTop||0}var nG=function(e){ta(t,e);function t(n,r){var a;return gr(this,t),a=ea(this,t,[n,r]),a.state={selecting:!1},a.containerRef=A.createRef(),a}return yr(t,[{key:"componentDidMount",value:function(){this.props.selectable&&this._selectable()}},{key:"componentWillUnmount",value:function(){this._teardownSelectable()}},{key:"componentDidUpdate",value:function(r){!r.selectable&&this.props.selectable&&this._selectable(),r.selectable&&!this.props.selectable&&this._teardownSelectable()}},{key:"render",value:function(){var r=this.props,a=r.range,o=r.getNow,s=r.getters,c=r.date,d=r.components.dateCellWrapper,p=r.localizer,m=this.state,g=m.selecting,v=m.startIdx,D=m.endIdx,S=o();return $.createElement("div",{className:"rbc-row-bg",ref:this.containerRef},a.map(function(T,E){var O=g&&E>=v&&E<=D,k=s.dayProp(T),j=k.className,F=k.style;return $.createElement(d,{key:E,value:T,range:a},$.createElement("div",{style:F,className:Qn("rbc-day-bg",j,O&&"rbc-selected-cell",p.isSameDate(T,S)&&"rbc-today",c&&p.neq(c,T,"month")&&"rbc-off-range-bg")}))}))}},{key:"_selectable",value:function(){var r=this,a=this.containerRef.current,o=this._selector=new RC(this.props.container,{longPressThreshold:this.props.longPressThreshold}),s=function(d,p){if(!Cy(a,d)&&!X$(a,d)){var m=Ru(a),g=r.props,v=g.range,D=g.rtl;if(Z$(m,d)){var S=jC(m,d.x,D,v.length);r._selectSlot({startIdx:S,endIdx:S,action:p,box:d})}}r._initial={},r.setState({selecting:!1})};o.on("selecting",function(c){var d=r.props,p=d.range,m=d.rtl,g=-1,v=-1;if(r.state.selecting||(yn(r.props.onSelectStart,[c]),r._initial={x:c.x,y:c.y}),o.isSelected(a)){var D=Ru(a),S=W$(r._initial,D,c,p.length,m);g=S.startIdx,v=S.endIdx}r.setState({selecting:!0,startIdx:g,endIdx:v})}),o.on("beforeSelect",function(c){if(r.props.selectable==="ignoreEvents")return!Cy(r.containerRef.current,c)}),o.on("click",function(c){return s(c,"click")}),o.on("doubleClick",function(c){return s(c,"doubleClick")}),o.on("select",function(c){r._selectSlot(rn(rn({},r.state),{},{action:"select",bounds:c})),r._initial={},r.setState({selecting:!1}),yn(r.props.onSelectEnd,[r.state])})}},{key:"_teardownSelectable",value:function(){this._selector&&(this._selector.teardown(),this._selector=null)}},{key:"_selectSlot",value:function(r){var a=r.endIdx,o=r.startIdx,s=r.action,c=r.bounds,d=r.box;a!==-1&&o!==-1&&this.props.onSelectSlot&&this.props.onSelectSlot({start:o,end:a,action:s,bounds:c,box:d,resourceId:this.props.resourceId})}}]),t}($.Component),xi={propTypes:{slotMetrics:Ae.object.isRequired,selected:Ae.object,isAllDay:Ae.bool,accessors:Ae.object.isRequired,localizer:Ae.object.isRequired,components:Ae.object.isRequired,getters:Ae.object.isRequired,onSelect:Ae.func,onDoubleClick:Ae.func,onKeyPress:Ae.func},defaultProps:{segments:[],selected:{}},renderEvent:function(t,n){var r=t.selected;t.isAllDay;var a=t.accessors,o=t.getters,s=t.onSelect,c=t.onDoubleClick,d=t.onKeyPress,p=t.localizer,m=t.slotMetrics,g=t.components,v=t.resizable,D=m.continuesPrior(n),S=m.continuesAfter(n);return $.createElement(OC,{event:n,getters:o,localizer:p,accessors:a,components:g,onSelect:s,onDoubleClick:c,onKeyPress:d,continuesPrior:D,continuesAfter:S,slotStart:m.first,slotEnd:m.last,selected:uv(n,r),resizable:v})},renderSpan:function(t,n,r){var a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:" ",o=Math.abs(n)/t*100+"%";return $.createElement("div",{key:r,className:"rbc-row-segment",style:{WebkitFlexBasis:o,flexBasis:o,maxWidth:o}},a)}},BC=function(e){ta(t,e);function t(){return gr(this,t),ea(this,t,arguments)}return yr(t,[{key:"render",value:function(){var r=this,a=this.props,o=a.segments,s=a.slotMetrics.slots,c=a.className,d=1;return $.createElement("div",{className:Qn(c,"rbc-row")},o.reduce(function(p,m,g){var v=m.event,D=m.left,S=m.right,T=m.span,E="_lvl_"+g,O=D-d,k=xi.renderEvent(r.props,v);return O&&p.push(xi.renderSpan(s,O,"".concat(E,"_gap"))),p.push(xi.renderSpan(s,T,E,k)),d=S+1,p},[]))}}]),t}($.Component);BC.defaultProps=rn({},xi.defaultProps);function _C(e){var t=e.dateRange,n=e.unit,r=n===void 0?"day":n,a=e.localizer;return{first:t[0],last:a.add(t[t.length-1],1,r)}}function rG(e,t,n,r){var a=_C({dateRange:t,localizer:r}),o=a.first,s=a.last,c=r.diff(o,s,"day"),d=r.max(r.startOf(n.start(e),"day"),o),p=r.min(r.ceil(n.end(e),"day"),s),m=uY(t,function(v){return r.isSameDate(v,d)}),g=r.diff(d,p,"day");return g=Math.min(g,c),g=Math.max(g-r.segmentOffset,1),{event:e,span:g,left:m+1,right:Math.max(m+g,1)}}function HC(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1/0,n,r,a,o=[],s=[];for(n=0;n=t?s.push(a):(o[r]||(o[r]=[])).push(a)}for(n=0;n=e.left})}function oG(e,t,n){var r=ey(e),a=[],o=[];r.forEach(function(d){var p=t.start(d),m=t.end(d);n.daySpan(p,m)>1?a.push(d):o.push(d)});var s=a.sort(function(d,p){return Ww(d,p,t,n)}),c=o.sort(function(d,p){return Ww(d,p,t,n)});return[].concat(ey(s),ey(c))}function Ww(e,t,n,r){var a={start:n.start(e),end:n.end(e),allDay:n.allDay(e)},o={start:n.start(t),end:n.end(t),allDay:n.allDay(t)};return r.sortEvents({evtA:a,evtB:o})}var YC=function(t,n){return t.left<=n&&t.right>=n},v2=function(t,n){return t.filter(function(r){return YC(r,n)}).map(function(r){return r.event})},zC=function(e){ta(t,e);function t(){return gr(this,t),ea(this,t,arguments)}return yr(t,[{key:"render",value:function(){for(var r=this.props,a=r.segments,o=r.slotMetrics.slots,s=HC(a).levels[0],c=1,d=1,p=[];c<=o;){var m="_lvl_"+c,g=s.filter(function(k){return YC(k,c)})[0]||{},v=g.event,D=g.left,S=g.right,T=g.span;if(!v){c++;continue}var E=Math.max(0,D-d);if(this.canRenderSlotEvent(D,T)){var O=xi.renderEvent(this.props,v);E&&p.push(xi.renderSpan(o,E,m+"_gap")),p.push(xi.renderSpan(o,T,m,O)),d=c=S+1}else E&&p.push(xi.renderSpan(o,E,m+"_gap")),p.push(xi.renderSpan(o,1,m,this.renderShowMore(a,c))),d=c+=1}return $.createElement("div",{className:"rbc-row"},p)}},{key:"canRenderSlotEvent",value:function(r,a){var o=this.props.segments;return DY(r,r+a).every(function(s){var c=v2(o,s).length;return c===1})}},{key:"renderShowMore",value:function(r,a){var o=this,s=this.props,c=s.localizer,d=s.slotMetrics,p=d.getEventsForSlot(a),m=v2(r,a),g=m.length;return g?$.createElement("button",{type:"button",key:"sm_"+a,className:Qn("rbc-button-link","rbc-show-more"),onClick:function(D){return o.showMore(a,D)}},c.messages.showMore(g,m,p)):!1}},{key:"showMore",value:function(r,a){a.preventDefault(),a.stopPropagation(),this.props.onShowMore(r,a.target)}}]),t}($.Component);zC.defaultProps=rn({},xi.defaultProps);var iG=function(t){var n=t.children;return $.createElement("div",{className:"rbc-row-content-scroll-container"},n)},sG=function(t,n){return t.left<=n&&t.right>=n},lG=function(t,n){return t[0].range===n[0].range&&t[0].events===n[0].events};function UC(){return hC(function(e){for(var t=e.range,n=e.events,r=e.maxRows,a=e.minRows,o=e.accessors,s=e.localizer,c=_C({dateRange:t,localizer:s}),d=c.first,p=c.last,m=n.map(function(T){return rG(T,t,o,s)}),g=HC(m,Math.max(r-1,1)),v=g.levels,D=g.extra,S=D.length>0?a-1:a;v.length1&&arguments[1]!==void 0?arguments[1]:0;if(o.lt(F,t,"minutes"))return v[0];if(o.gt(F,n,"minutes"))return v[v.length-1];var R=o.diff(t,F,"minutes");return v[(R-R%r)/r+B]},startsBeforeDay:function(F){return o.lt(F,t,"day")},startsAfterDay:function(F){return o.gt(F,n,"day")},startsBefore:function(F){return o.lt(o.merge(t,F),t,"minutes")},startsAfter:function(F){return o.gt(o.merge(n,F),n,"minutes")},getRange:function(F,B,R,z){R||(F=o.min(n,o.max(t,F))),z||(B=o.min(n,o.max(t,B)));var H=k(F),Y=k(B),U=Y>r*m&&!o.eq(n,B)?(H-r)/(r*m)*100:H/(r*m)*100;return{top:U,height:Y/(r*m)*100-U,start:k(F),startDate:F,end:k(B),endDate:B}},getCurrentTimePosition:function(F){var B=k(F),R=B/(r*m)*100;return R}}}var fG=function(){function e(t,n){var r=n.accessors,a=n.slotMetrics;gr(this,e);var o=a.getRange(r.start(t),r.end(t)),s=o.start,c=o.startDate,d=o.end,p=o.endDate,m=o.top,g=o.height;this.start=s,this.end=d,this.startMs=+c,this.endMs=+p,this.top=m,this.height=g,this.data=t}return yr(e,[{key:"_width",get:function(){if(this.rows){var n=this.rows.reduce(function(a,o){return Math.max(a,o.leaves.length+1)},0)+1;return 100/n}if(this.leaves){var r=100-this.container._width;return r/(this.leaves.length+1)}return this.row._width}},{key:"width",get:function(){var n=this._width,r=Math.min(100,this._width*1.7);if(this.rows)return r;if(this.leaves)return this.leaves.length>0?r:n;var a=this.row.leaves,o=a.indexOf(this);return o===a.length-1?n:r}},{key:"xOffset",get:function(){if(this.rows)return 0;if(this.leaves)return this.container._width;var n=this.row,r=n.leaves,a=n.xOffset,o=n._width,s=r.indexOf(this)+1;return a+s*o}}]),e}();function hG(e,t,n){return Math.abs(t.start-e.start)e.start&&t.start0;){var r=t.shift();n.push(r);for(var a=0;ao.startMs)){if(a>0){var s=t.splice(a,1)[0];n.push(s)}break}}}return n}function ZC(e){for(var t=e.events,n=e.minimumStartDifference,r=e.slotMetrics,a=e.accessors,o=t.map(function(m){return new fG(m,{slotMetrics:r,accessors:a})}),s=pG(o),c=[],d=function(){var g=s[p],v=c.find(function(T){return T.end>g.start||Math.abs(g.start-T.start)=0;S--)hG(v.rows[S],g,n)&&(D=v.rows[S]);D?(D.leaves.push(g),g.row=D):(g.leaves=[],v.rows.push(g))},p=0;p-1)){t=t>e.friends[r].idx?t:e.friends[r].idx,n.push(e.friends[r]);var a=WC(e.friends[r],t,n);t=t>a?t:a}return t}function mG(e){var t=e.events,n=e.minimumStartDifference,r=e.slotMetrics,a=e.accessors,o=ZC({events:t,minimumStartDifference:n,slotMetrics:r,accessors:a});o.sort(function(ie,se){return ie=ie.style,se=se.style,ie.top!==se.top?ie.top>se.top?1:-1:ie.height!==se.height?ie.top+ie.height=p&&S<=m||S>p&&S<=m||D>=p&&Dle?J:le}J<=U.idx&&(U.size=100-U.idx*U.size);var pe=U.idx===0?0:3;U.style.width="calc(".concat(U.size,"% - ").concat(pe,"px)"),U.style.height="calc(".concat(U.style.height,"% - 2px)"),U.style.xOffset="calc(".concat(U.style.left,"% + ").concat(pe,"px)")}return o}var b2={overlap:ZC,"no-overlap":mG};function gG(e){return!!(e&&e.constructor&&e.call&&e.apply)}function yG(e){e.events,e.minimumStartDifference,e.slotMetrics,e.accessors;var t=e.dayLayoutAlgorithm,n=t;return t in b2&&(n=b2[t]),gG(n)?n.apply(this,arguments):[]}var $C=function(e){ta(t,e);function t(){return gr(this,t),ea(this,t,arguments)}return yr(t,[{key:"render",value:function(){var r=this.props,a=r.renderSlot,o=r.resource,s=r.group,c=r.getters,d=r.components,p=d===void 0?{}:d,m=p.timeSlotWrapper,g=m===void 0?ds:m,v=c?c.slotGroupProp(s):{};return $.createElement("div",Object.assign({className:"rbc-timeslot-group"},v),s.map(function(D,S){var T=c?c.slotProp(D,o):{};return $.createElement(g,{key:S,value:D,resource:o},$.createElement("div",Object.assign({},T,{className:Qn("rbc-time-slot",T.className)}),a&&a(D,S)))}))}}]),t}(A.Component);function Rg(e){return typeof e=="string"?e:e+"%"}function vG(e){var t=e.style,n=e.className,r=e.event,a=e.accessors,o=e.rtl,s=e.selected,c=e.label,d=e.continuesPrior,p=e.continuesAfter,m=e.getters,g=e.onClick,v=e.onDoubleClick,D=e.isBackgroundEvent,S=e.onKeyPress,T=e.components,E=T.event,O=T.eventWrapper,k=a.title(r),j=a.tooltip(r),F=a.end(r),B=a.start(r),R=m.eventProp(r,B,F,s),z=[$.createElement("div",{key:"1",className:"rbc-event-label"},c),$.createElement("div",{key:"2",className:"rbc-event-content"},E?$.createElement(E,{event:r,title:k}):k)],H=t.height,Y=t.top,U=t.width,J=t.xOffset,Q=rn(rn({},R.style),{},Iu({top:Rg(Y),height:Rg(H),width:Rg(U)},o?"right":"left",Rg(J)));return $.createElement(O,Object.assign({type:"time"},e),$.createElement("div",{role:"button",tabIndex:0,onClick:g,onDoubleClick:v,style:Q,onKeyDown:S,title:j?(typeof c=="string"?c+": ":"")+j:void 0,className:Qn(D?"rbc-background-event":"rbc-event",n,R.className,{"rbc-selected":s,"rbc-event-continues-earlier":d,"rbc-event-continues-later":p})},z))}var wG=function(t){var n=t.children,r=t.className,a=t.style,o=t.innerRef;return $.createElement("div",{className:r,style:a,ref:o},n)},bG=$.forwardRef(function(e,t){return $.createElement(wG,Object.assign({},e,{innerRef:t}))}),DG=["dayProp"],SG=["eventContainerWrapper"],GC=function(e){ta(t,e);function t(){var n;gr(this,t);for(var r=arguments.length,a=new Array(r),o=0;o0&&arguments[0]!==void 0?arguments[0]:!1;!this.intervalTriggered&&!a&&this.positionTimeIndicator(),this._timeIndicatorTimeout=window.setTimeout(function(){r.intervalTriggered=!0,r.positionTimeIndicator(),r.setTimeIndicatorPositionUpdateInterval()},6e4)}},{key:"clearTimeIndicatorInterval",value:function(){this.intervalTriggered=!1,window.clearTimeout(this._timeIndicatorTimeout)}},{key:"positionTimeIndicator",value:function(){var r=this.props,a=r.min,o=r.max,s=r.getNow,c=s();if(c>=a&&c<=o){var d=this.slotMetrics.getCurrentTimePosition(c);this.intervalTriggered=!0,this.setState({timeIndicatorPosition:d})}else this.clearTimeIndicatorInterval()}},{key:"render",value:function(){var r=this.props,a=r.date,o=r.max,s=r.rtl,c=r.isNow,d=r.resource,p=r.accessors,m=r.localizer,g=r.getters,v=g.dayProp,D=Fi(g,DG),S=r.components,T=S.eventContainerWrapper,E=Fi(S,SG),O=this.slotMetrics,k=this.state,j=k.selecting,F=k.top,B=k.height,R=k.startDate,z=k.endDate,H={start:R,end:z},Y=v(o),U=Y.className,J=Y.style,Q=E.dayColumnWrapper||bG;return $.createElement(Q,{ref:this.containerRef,date:a,style:J,className:Qn(U,"rbc-day-slot","rbc-time-column",c&&"rbc-now",c&&"rbc-today",j&&"rbc-slot-selecting"),slotMetrics:O},O.groups.map(function(le,pe){return $.createElement($C,{key:pe,group:le,resource:d,getters:D,components:E})}),$.createElement(T,{localizer:m,resource:d,accessors:p,getters:D,components:E,slotMetrics:O},$.createElement("div",{className:Qn("rbc-events-container",s&&"rtl")},this.renderEvents({events:this.props.backgroundEvents,isBackgroundEvent:!0}),this.renderEvents({events:this.props.events}))),j&&$.createElement("div",{className:"rbc-slot-selection",style:{top:F,height:B}},$.createElement("span",null,m.format(H,"selectRangeFormat"))),c&&this.intervalTriggered&&$.createElement("div",{className:"rbc-current-time-indicator",style:{top:"".concat(this.state.timeIndicatorPosition,"%")}}))}}]),t}($.Component);GC.defaultProps={dragThroughEvents:!0,timeslots:2};function IG(e){var t=e.min,n=e.max,r=e.localizer;return r.getTimezoneOffset(t)!==r.getTimezoneOffset(n)?{start:r.add(t,-1,"day"),end:r.add(n,-1,"day")}:{start:t,end:n}}var TG=function(t){var n=t.min,r=t.max,a=t.timeslots,o=t.step,s=t.localizer,c=t.getNow,d=t.resource,p=t.components,m=t.getters,g=t.gutterRef,v=p.timeGutterWrapper,D=A.useMemo(function(){return IG({min:n,max:r,localizer:s})},[n==null?void 0:n.toISOString(),r==null?void 0:r.toISOString(),s]),S=D.start,T=D.end,E=A.useState(lb({min:S,max:T,timeslots:a,step:o,localizer:s})),O=fs(E,2),k=O[0],j=O[1];A.useEffect(function(){k&&j(k.update({min:S,max:T,timeslots:a,step:o,localizer:s}))},[S==null?void 0:S.toISOString(),T==null?void 0:T.toISOString(),a,o]);var F=A.useCallback(function(B,R){if(R)return null;var z=k.dateIsInGroup(c(),R);return $.createElement("span",{className:Qn("rbc-label",z&&"rbc-now")},s.format(B,"timeGutterFormat"))},[k,s,c]);return $.createElement(v,{slotMetrics:k},$.createElement("div",{className:"rbc-time-gutter rbc-time-column",ref:g},k.groups.map(function(B,R){return $.createElement($C,{key:R,group:B,resource:d,components:p,renderSlot:F,getters:m})})))},EG=$.forwardRef(function(e,t){return $.createElement(TG,Object.assign({gutterRef:t},e))}),CG=function(t){var n=t.label;return $.createElement($.Fragment,null,n)},xG=function(e){ta(t,e);function t(){var n;gr(this,t);for(var r=arguments.length,a=new Array(r),o=0;oa.clientHeight;r.state.isOverflowing!==o&&(r._updatingOverflow=!0,r.setState({isOverflowing:o},function(){r._updatingOverflow=!1}))}}},r.memoizedResources=hC(function(a,o){return MG(a,o)}),r.state={gutterWidth:void 0,isOverflowing:null},r.scrollRef=$.createRef(),r.contentRef=$.createRef(),r.containerRef=$.createRef(),r._scrollRatio=null,r.gutterRef=A.createRef(),r}return yr(t,[{key:"getSnapshotBeforeUpdate",value:function(){return this.checkOverflow(),null}},{key:"componentDidMount",value:function(){this.props.width==null&&this.measureGutter(),this.calculateScroll(),this.applyScroll(),window.addEventListener("resize",this.handleResize)}},{key:"componentWillUnmount",value:function(){window.removeEventListener("resize",this.handleResize),pS(this.rafHandle),this.measureGutterAnimationFrameRequest&&window.cancelAnimationFrame(this.measureGutterAnimationFrameRequest)}},{key:"componentDidUpdate",value:function(){this.applyScroll()}},{key:"renderEvents",value:function(r,a,o,s){var c=this,d=this.props,p=d.min,m=d.max,g=d.components,v=d.accessors,D=d.localizer,S=d.dayLayoutAlgorithm,T=this.memoizedResources(this.props.resources,v),E=T.groupEvents(a),O=T.groupEvents(o);return T.map(function(k,j){var F=fs(k,2),B=F[0],R=F[1];return r.map(function(z,H){var Y=(E.get(B)||[]).filter(function(J){return D.inRange(z,v.start(J),v.end(J),"day")}),U=(O.get(B)||[]).filter(function(J){return D.inRange(z,v.start(J),v.end(J),"day")});return $.createElement(GC,Object.assign({},c.props,{localizer:D,min:D.merge(z,p),max:D.merge(z,m),resource:R&&B,components:g,isNow:D.isSameDate(z,s),key:j+"-"+H,date:z,events:Y,backgroundEvents:U,dayLayoutAlgorithm:S}))})})}},{key:"render",value:function(){var r,a=this.props,o=a.events,s=a.backgroundEvents,c=a.range,d=a.width,p=a.rtl,m=a.selected,g=a.getNow,v=a.resources,D=a.components,S=a.accessors,T=a.getters,E=a.localizer,O=a.min,k=a.max,j=a.showMultiDayTimes,F=a.longPressThreshold,B=a.resizable;d=d||this.state.gutterWidth;var R=c[0],z=c[c.length-1];this.slots=c.length;var H=[],Y=[],U=[];return o.forEach(function(J){if(mp(J,R,z,S,E)){var Q=S.start(J),le=S.end(J);S.allDay(J)||E.startAndEndAreDateOnly(Q,le)||!j&&!E.isSameDate(Q,le)?H.push(J):Y.push(J)}}),s.forEach(function(J){mp(J,R,z,S,E)&&U.push(J)}),H.sort(function(J,Q){return Ww(J,Q,S,E)}),$.createElement("div",{className:Qn("rbc-time-view",v&&"rbc-time-view-resources"),ref:this.containerRef},$.createElement(xG,{range:c,events:H,width:d,rtl:p,getNow:g,localizer:E,selected:m,allDayMaxRows:this.props.showAllEvents?1/0:(r=this.props.allDayMaxRows)!==null&&r!==void 0?r:1/0,resources:this.memoizedResources(v,S),selectable:this.props.selectable,accessors:S,getters:T,components:D,scrollRef:this.scrollRef,isOverflowing:this.state.isOverflowing,longPressThreshold:F,onSelectSlot:this.handleSelectAllDaySlot,onSelectEvent:this.handleSelectEvent,onShowMore:this.handleShowMore,onDoubleClickEvent:this.props.onDoubleClickEvent,onKeyPressEvent:this.props.onKeyPressEvent,onDrillDown:this.props.onDrillDown,getDrilldownView:this.props.getDrilldownView,resizable:B}),this.props.popup&&this.renderOverlay(),$.createElement("div",{ref:this.contentRef,className:"rbc-time-content",onScroll:this.handleScroll},$.createElement(EG,{date:R,ref:this.gutterRef,localizer:E,min:E.merge(R,O),max:E.merge(R,k),step:this.props.step,getNow:this.props.getNow,timeslots:this.props.timeslots,components:D,className:"rbc-time-gutter",getters:T}),this.renderEvents(c,Y,U,g())))}},{key:"renderOverlay",value:function(){var r,a,o=this,s=(r=(a=this.state)===null||a===void 0?void 0:a.overlay)!==null&&r!==void 0?r:{},c=this.props,d=c.accessors,p=c.localizer,m=c.components,g=c.getters,v=c.selected,D=c.popupOffset,S=c.handleDragStart,T=function(){return o.setState({overlay:null})};return $.createElement(sb,{overlay:s,accessors:d,localizer:p,components:m,getters:g,selected:v,popupOffset:D,ref:this.containerRef,handleKeyPressEvent:this.handleKeyPressEvent,handleSelectEvent:this.handleSelectEvent,handleDoubleClickEvent:this.handleDoubleClickEvent,handleDragStart:S,show:!!s.position,overlayDisplay:this.overlayDisplay,onHide:T})}},{key:"clearSelection",value:function(){clearTimeout(this._selectTimer),this._pendingSelection=[]}},{key:"measureGutter",value:function(){var r=this;this.measureGutterAnimationFrameRequest&&window.cancelAnimationFrame(this.measureGutterAnimationFrameRequest),this.measureGutterAnimationFrameRequest=window.requestAnimationFrame(function(){var a,o=(a=r.gutterRef)!==null&&a!==void 0&&a.current?Vw(r.gutterRef.current):void 0;o&&r.state.gutterWidth!==o&&r.setState({gutterWidth:o})})}},{key:"applyScroll",value:function(){if(this._scrollRatio!=null&&this.props.enableAutoScroll===!0){var r=this.contentRef.current;r.scrollTop=r.scrollHeight*this._scrollRatio,this._scrollRatio=null}}},{key:"calculateScroll",value:function(){var r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.props,a=r.min,o=r.max,s=r.scrollToTime,c=r.localizer,d=c.diff(c.merge(s,a),s,"milliseconds"),p=c.diff(a,o,"milliseconds");this._scrollRatio=d/p}}]),t}(A.Component);rf.defaultProps={step:30,timeslots:2};var NG=["date","localizer","min","max","scrollToTime","enableAutoScroll"],dv=function(e){ta(t,e);function t(){return gr(this,t),ea(this,t,arguments)}return yr(t,[{key:"render",value:function(){var r=this.props,a=r.date,o=r.localizer,s=r.min,c=s===void 0?o.startOf(new Date,"day"):s,d=r.max,p=d===void 0?o.endOf(new Date,"day"):d,m=r.scrollToTime,g=m===void 0?o.startOf(new Date,"day"):m,v=r.enableAutoScroll,D=v===void 0?!0:v,S=Fi(r,NG),T=t.range(a,{localizer:o});return $.createElement(rf,Object.assign({},S,{range:T,eventOffset:10,localizer:o,min:c,max:p,scrollToTime:g,enableAutoScroll:D}))}}]),t}($.Component);dv.range=function(e,t){var n=t.localizer;return[n.startOf(e,"day")]};dv.navigate=function(e,t,n){var r=n.localizer;switch(t){case Da.PREVIOUS:return r.add(e,-1,"day");case Da.NEXT:return r.add(e,1,"day");default:return e}};dv.title=function(e,t){var n=t.localizer;return n.format(e,"dayHeaderFormat")};var kG=["date","localizer","min","max","scrollToTime","enableAutoScroll"],bl=function(e){ta(t,e);function t(){return gr(this,t),ea(this,t,arguments)}return yr(t,[{key:"render",value:function(){var r=this.props,a=r.date,o=r.localizer,s=r.min,c=s===void 0?o.startOf(new Date,"day"):s,d=r.max,p=d===void 0?o.endOf(new Date,"day"):d,m=r.scrollToTime,g=m===void 0?o.startOf(new Date,"day"):m,v=r.enableAutoScroll,D=v===void 0?!0:v,S=Fi(r,kG),T=t.range(a,this.props);return $.createElement(rf,Object.assign({},S,{range:T,eventOffset:15,localizer:o,min:c,max:p,scrollToTime:g,enableAutoScroll:D}))}}]),t}($.Component);bl.defaultProps=rf.defaultProps;bl.navigate=function(e,t,n){var r=n.localizer;switch(t){case Da.PREVIOUS:return r.add(e,-1,"week");case Da.NEXT:return r.add(e,1,"week");default:return e}};bl.range=function(e,t){var n=t.localizer,r=n.startOfWeek(),a=n.startOf(e,"week",r),o=n.endOf(e,"week",r);return n.range(a,o)};bl.title=function(e,t){var n=t.localizer,r=bl.range(e,{localizer:n}),a=bC(r),o=a[0],s=a.slice(1);return n.format({start:o,end:s.pop()},"dayRangeHeaderFormat")};var AG=["date","localizer","min","max","scrollToTime","enableAutoScroll"];function ub(e,t){return bl.range(e,t).filter(function(n){return[6,0].indexOf(n.getDay())===-1})}var $p=function(e){ta(t,e);function t(){return gr(this,t),ea(this,t,arguments)}return yr(t,[{key:"render",value:function(){var r=this.props,a=r.date,o=r.localizer,s=r.min,c=s===void 0?o.startOf(new Date,"day"):s,d=r.max,p=d===void 0?o.endOf(new Date,"day"):d,m=r.scrollToTime,g=m===void 0?o.startOf(new Date,"day"):m,v=r.enableAutoScroll,D=v===void 0?!0:v,S=Fi(r,AG),T=ub(a,this.props);return $.createElement(rf,Object.assign({},S,{range:T,eventOffset:15,localizer:o,min:c,max:p,scrollToTime:g,enableAutoScroll:D}))}}]),t}($.Component);$p.defaultProps=rf.defaultProps;$p.range=ub;$p.navigate=bl.navigate;$p.title=function(e,t){var n=t.localizer,r=ub(e,{localizer:n}),a=bC(r),o=a[0],s=a.slice(1);return n.format({start:o,end:s.pop()},"dayRangeHeaderFormat")};function Dl(e){var t=e.accessors,n=e.components,r=e.date,a=e.events,o=e.getters,s=e.length,c=e.localizer,d=e.onDoubleClickEvent,p=e.onSelectEvent,m=e.selected,g=A.useRef(null),v=A.useRef(null),D=A.useRef(null),S=A.useRef(null),T=A.useRef(null);A.useEffect(function(){k()});var E=function(z,H,Y){var U=n.event,J=n.date;return H=H.filter(function(Q){return mp(Q,c.startOf(z,"day"),c.endOf(z,"day"),t,c)}),H.map(function(Q,le){var pe=t.title(Q),ie=t.end(Q),se=t.start(Q),fe=o.eventProp(Q,se,ie,uv(Q,m)),oe=le===0&&c.format(z,"agendaDateFormat"),we=le===0?$.createElement("td",{rowSpan:H.length,className:"rbc-agenda-date-cell"},J?$.createElement(J,{day:z,label:oe}):oe):!1;return $.createElement("tr",{key:Y+"_"+le,className:fe.className,style:fe.style},we,$.createElement("td",{className:"rbc-agenda-time-cell"},O(z,Q)),$.createElement("td",{className:"rbc-agenda-event-cell",onClick:function(G){return p&&p(Q,G)},onDoubleClick:function(G){return d&&d(Q,G)}},U?$.createElement(U,{event:Q,title:pe}):pe))},[])},O=function(z,H){var Y="",U=n.time,J=c.messages.allDay,Q=t.end(H),le=t.start(H);return t.allDay(H)||(c.eq(le,Q)?J=c.format(le,"agendaTimeFormat"):c.isSameDate(le,Q)?J=c.format({start:le,end:Q},"agendaTimeRangeFormat"):c.isSameDate(z,le)?J=c.format(le,"agendaTimeFormat"):c.isSameDate(z,Q)&&(J=c.format(Q,"agendaTimeFormat"))),c.gt(z,le,"day")&&(Y="rbc-continues-prior"),c.lt(z,Q,"day")&&(Y+=" rbc-continues-after"),$.createElement("span",{className:Y.trim()},U?$.createElement(U,{event:H,day:z,label:J}):J)},k=function(){if(T.current){var z=g.current,H=T.current.firstChild;if(H){var Y=S.current.scrollHeight>S.current.clientHeight,U=[],J=U;U=[Vw(H.children[0]),Vw(H.children[1])],(J[0]!==U[0]||J[1]!==U[1])&&(v.current.style.width=U[0]+"px",D.current.style.width=U[1]+"px"),Y?(A7(z,"rbc-header-overflowing"),z.style.marginRight=JE()+"px"):F7(z,"rbc-header-overflowing")}}},j=c.messages,F=c.add(r,s,"day"),B=c.range(r,F,"day");return a=a.filter(function(R){return mp(R,c.startOf(r,"day"),c.endOf(F,"day"),t,c)}),a.sort(function(R,z){return+t.start(R)-+t.start(z)}),$.createElement("div",{className:"rbc-agenda-view"},a.length!==0?$.createElement($.Fragment,null,$.createElement("table",{ref:g,className:"rbc-agenda-table"},$.createElement("thead",null,$.createElement("tr",null,$.createElement("th",{className:"rbc-header",ref:v},j.date),$.createElement("th",{className:"rbc-header",ref:D},j.time),$.createElement("th",{className:"rbc-header"},j.event)))),$.createElement("div",{className:"rbc-agenda-content",ref:S},$.createElement("table",{className:"rbc-agenda-table"},$.createElement("tbody",{ref:T},B.map(function(R,z){return E(R,a,z)}))))):$.createElement("span",{className:"rbc-agenda-empty"},j.noEventsInRange))}Dl.defaultProps={length:30};Dl.range=function(e,t){var n=t.length,r=n===void 0?Dl.defaultProps.length:n,a=t.localizer,o=a.add(e,r,"day");return{start:e,end:o}};Dl.navigate=function(e,t,n){var r=n.length,a=r===void 0?Dl.defaultProps.length:r,o=n.localizer;switch(t){case Da.PREVIOUS:return o.add(e,-a,"day");case Da.NEXT:return o.add(e,a,"day");default:return e}};Dl.title=function(e,t){var n=t.length,r=n===void 0?Dl.defaultProps.length:n,a=t.localizer,o=a.add(e,r,"day");return a.format({start:e,end:o},"agendaHeaderFormat")};var ny=Iu(Iu(Iu(Iu(Iu({},Qr.MONTH,cv),Qr.WEEK,bl),Qr.WORK_WEEK,$p),Qr.DAY,dv),Qr.AGENDA,Dl),FG=["action","date","today"];function OG(e,t){var n=t.action,r=t.date,a=t.today,o=Fi(t,FG);switch(e=typeof e=="string"?ny[e]:e,n){case Da.TODAY:r=a||new Date;break;case Da.DATE:break;default:op(e&&typeof e.navigate=="function","Calendar View components must implement a static `.navigate(date, action)` method.s"),r=e.navigate(r,n,o)}return r}var PG=function(e){ta(t,e);function t(){var n;gr(this,t);for(var r=arguments.length,a=new Array(r),o=0;o1)return o.map(function(c){return $.createElement("button",{type:"button",key:c,className:Qn({"rbc-active":s===c}),onClick:a.view.bind(null,c)},r[c])})}}]),t}($.Component);function jG(e,t){var n=null;return typeof t=="function"?n=t(e):typeof t=="string"&&gs(e)==="object"&&e!=null&&t in e&&(n=e[t]),n}var fl=function(t){return function(n){return jG(n,t)}},LG=["view","date","getNow","onNavigate"],RG=["view","toolbar","events","backgroundEvents","style","className","elementProps","date","getNow","length","showMultiDayTimes","onShowMore","doShowMoreDrillDown","components","formats","messages","culture"];function qC(e){if(Array.isArray(e))return e;for(var t=[],n=0,r=Object.entries(e);n0&&arguments[0]!==void 0?arguments[0]:null,te=arguments.length>1?arguments[1]:void 0,ge=hl(te);return ge?e(G).startOf(ge).toDate():e(G).toDate()}function c(){var G=arguments.length>0&&arguments[0]!==void 0?arguments[0]:null,te=arguments.length>1?arguments[1]:void 0,ge=hl(te);return ge?e(G).endOf(ge).toDate():e(G).toDate()}function d(G,te,ge){var Ie=o(G,te,ge),De=fs(Ie,3),ke=De[0],Ye=De[1],Re=De[2];return ke.isSame(Ye,Re)}function p(G,te,ge){return!d(G,te,ge)}function m(G,te,ge){var Ie=o(G,te,ge),De=fs(Ie,3),ke=De[0],Ye=De[1],Re=De[2];return ke.isAfter(Ye,Re)}function g(G,te,ge){var Ie=o(G,te,ge),De=fs(Ie,3),ke=De[0],Ye=De[1],Re=De[2];return ke.isBefore(Ye,Re)}function v(G,te,ge){var Ie=o(G,te,ge),De=fs(Ie,3),ke=De[0],Ye=De[1],Re=De[2];return ke.isSameOrBefore(Ye,Re)}function D(G,te,ge){var Ie=o(G,te,ge),De=fs(Ie,3),ke=De[0],Ye=De[1],Re=De[2];return ke.isSameOrBefore(Ye,Re)}function S(G,te,ge){var Ie=arguments.length>3&&arguments[3]!==void 0?arguments[3]:"day",De=hl(Ie),ke=e(G),Ye=e(te),Re=e(ge);return ke.isBetween(Ye,Re,De,"[]")}function T(G,te){var ge=e(G),Ie=e(te),De=e.min(ge,Ie);return De.toDate()}function E(G,te){var ge=e(G),Ie=e(te),De=e.max(ge,Ie);return De.toDate()}function O(G,te){if(!G&&!te)return null;var ge=e(te).format("HH:mm:ss"),Ie=e(G).startOf("day").format("MM/DD/YYYY");return e("".concat(Ie," ").concat(ge),"MM/DD/YYYY HH:mm:ss").toDate()}function k(G,te,ge){var Ie=hl(ge);return e(G).add(te,Ie).toDate()}function j(G,te){for(var ge=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"day",Ie=hl(ge),De=e(G).toDate(),ke=[];D(De,te);)ke.push(De),De=k(De,1,Ie);return ke}function F(G,te){var ge=hl(te),Ie=s(G,ge);return d(Ie,G)?Ie:k(Ie,1,ge)}function B(G,te){var ge=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"day",Ie=hl(ge),De=e(G),ke=e(te);return ke.diff(De,Ie)}function R(G){var te=e(G);return te.minutes()}function z(G){var te=G?e.localeData(G):e.localeData();return te?te.firstDayOfWeek():0}function H(G){return e(G).startOf("month").startOf("week").toDate()}function Y(G){return e(G).endOf("month").endOf("week").toDate()}function U(G){for(var te=H(G),ge=Y(G),Ie=[];D(te,ge);)Ie.push(te),te=k(te,1,"d");return Ie}function J(G,te,ge){return e(G).startOf("day").minute(te+ge).toDate()}function Q(G,te){return B(G,te,"minutes")}function le(G){var te=e(G).startOf("day"),ge=e(G);return ge.diff(te,"minutes")+a(G)}function pe(G,te){var ge=e(G),Ie=e(te);return ge.isBefore(Ie,"day")}function ie(G,te,ge){var Ie=e(te),De=e(ge);return Ie.isSameOrAfter(De,"minutes")}function se(G,te){var ge=e(G),Ie=e(te),De=e.duration(Ie.diff(ge));return De.days()}function fe(G){var te=G.evtA,ge=te.start,Ie=te.end,De=te.allDay,ke=G.evtB,Ye=ke.start,Re=ke.end,rt=ke.allDay,Ht=+s(ge,"day")-+s(Ye,"day"),Se=se(ge,Ie),Ze=se(Ye,Re);return Ht||Ze-Se||!!rt-!!De||+ge-+Ye||+Ie-+Re}function oe(G){var te=G.event,ge=te.start,Ie=te.end,De=G.range,ke=De.start,Ye=De.end,Re=e(ge).startOf("day"),rt=e(Ie),Ht=e(ke),Se=e(Ye),Ze=Re.isSameOrBefore(Se,"day"),Ke=!Re.isSame(rt,"minutes"),Je=Ke?rt.isAfter(Ht,"minutes"):rt.isSameOrAfter(Ht,"minutes");return Ze&&Je}function we(G,te){var ge=e(G),Ie=e(te);return ge.isSame(Ie,"day")}function Z(){var G=new Date,te=/-/.test(G.toString())?"-":"",ge=G.getTimezoneOffset(),Ie=Number("".concat(te).concat(Math.abs(ge))),De=e().utcOffset();return De>Ie?1:0}return new _$({formats:VG,firstOfWeek:z,firstVisibleDay:H,lastVisibleDay:Y,visibleDays:U,format:function(te,ge,Ie){return t(e(te),Ie).format(ge)},lt:g,lte:D,gt:m,gte:v,eq:d,neq:p,merge:O,inRange:S,startOf:s,endOf:c,range:j,add:k,diff:B,ceil:F,min:T,max:E,minutes:R,getSlotDate:J,getTimezoneOffset:n,getDstOffset:r,getTotalMin:Q,getMinutesFromMidnight:le,continuesPrior:pe,continuesAfter:ie,sortEvents:fe,inEventRange:oe,isSameDate:we,daySpan:se,browserTZOffset:Z})}function D2(e,t,n,r,a){const o={start:r.start(e),end:r.end(e)},s={start:t,end:n};return a.inEventRange({event:o,range:s})}function WG(e,t){return!e||t==null?!1:FI.isEqual(e,t)}const Td={PREVIOUS:"PREV",NEXT:"NEXT",TODAY:"TODAY",DATE:"DATE"};function ys({accessors:e,components:t,date:n,events:r,getters:a,length:o,localizer:s,onDoubleClickEvent:c,onSelectEvent:d,selected:p}){A.useRef(null);const m=A.useRef(null),g=A.useRef(null),v=A.useRef(null),D=A.useRef(null),[S,T]=A.useState(!1),[E,O]=A.useState(!1),k=(U,J,Q)=>{const{event:le,date:pe}=t;return J=J.filter(ie=>D2(ie,s.startOf(U,"day"),s.endOf(U,"day"),e,s)),J.map((ie,se)=>{const fe=e.title(ie),oe=e.end(ie),we=e.start(ie),Z=a.eventProp(ie,we,oe,WG(ie,p)),G=se===0&&s.format(U,"agendaDateFormat"),te=se===0?w.jsx("td",{rowSpan:J.length,className:"rbc-agenda-date-cell",children:pe?w.jsx(pe,{day:U,label:G}):G}):!1;return w.jsxs("tr",{className:Z.className,style:Z.style,children:[te,w.jsx("td",{className:"rbc-agenda-time-cell",children:j(U,ie)}),w.jsx("td",{className:"rbc-agenda-event-cell",onClick:ge=>d&&d(ie,ge),onDoubleClick:ge=>c&&c(ie,ge),children:le?w.jsx(le,{event:ie,title:fe}):fe})]},Q+"_"+se)},[])},j=(U,J)=>{const Q=t.time;let le="",pe=s.messages.allDay;const ie=e.end(J),se=e.start(J);return e.allDay(J)||(s.eq(se,ie)?pe=s.format(se,"agendaTimeFormat"):s.isSameDate(se,ie)?pe=s.format({start:se,end:ie},"agendaTimeRangeFormat"):s.isSameDate(U,se)?pe=s.format(se,"agendaTimeFormat"):s.isSameDate(U,ie)&&(pe=s.format(ie,"agendaTimeFormat"))),s.gt(U,se,"day")&&(le="rbc-continues-prior"),s.lt(U,ie,"day")&&(le+=" rbc-continues-after"),w.jsx("span",{className:le.trim(),children:Q?w.jsx(Q,{event:J,day:U,label:pe}):pe})},{messages:F}=s,B=s.add(n,-o/2,"day"),R=s.add(n,o/2,"day"),z=s.range(B,R,"day");S&&z.reverse(),r=r.filter(U=>D2(U,s.startOf(B,"day"),s.endOf(R,"day"),e,s)),r.sort((U,J)=>+e.start(U)-+e.start(J)),E&&r.reverse();const H=A.useCallback(()=>setTimeout(()=>{D.current&&Zy(D.current,{backgroundColor:"#ffffff",pixelRatio:window.devicePixelRatio*2}).then(U=>{new C.Notice(N("Image is generating..."));const J=Xe.getState().settings.AutoSaveWhenOnMobile,Q=Xe.getState().app.vault;if(J&&C.Platform.isMobile){const le=U.split("base64,")[1];Oy(le,"image/png").arrayBuffer().then(async ie=>{let se;const fe="png",oe=bs();for(const we in oe)if(oe[we]instanceof C.TFile){se=oe[we];break}se!==void 0&&await Q.createBinary(await Q.getAvailablePathForAttachments(`Pasted Image ${C.moment().format("YYYYMMDDHHmmss")}`,fe,se),ie)})}Wy({imgUrl:U})}).catch(U=>{console.error(U)})},0),[D.current,z]),Y=A.useCallback(U=>{const J=new C.Menu;J.addItem(Q=>{Q.setIcon("share-2").setTitle(N("Share")).onClick(()=>{H()})}),J.showAtMouseEvent(U.nativeEvent)},[D.current,z,H]);return w.jsx("div",{className:"rbc-agenda-view",children:r.length!==0?w.jsx($.Fragment,{children:w.jsxs("table",{ref:D,className:"rbc-agenda-table",children:[w.jsx("thead",{onContextMenu:Y,children:w.jsxs("tr",{children:[w.jsx("th",{className:"rbc-header",ref:m,onClick:()=>{T(!S)},children:F.date+(S?" 🔼":" 🔽")}),w.jsx("th",{className:"rbc-header",ref:g,onClick:()=>{O(!E)},children:F.time+(E?" 🔼":" 🔽")}),w.jsx("th",{className:"rbc-header",children:F.event})]})}),w.jsx("tbody",{ref:v,children:z.map((U,J)=>k(U,r,J))})]})}):w.jsx("span",{className:"rbc-agenda-empty",children:F.noEventsInRange})})}ys.propTypes={accessors:Ae.object.isRequired,components:Ae.object.isRequired,date:Ae.instanceOf(Date),events:Ae.array,getters:Ae.object.isRequired,length:Ae.number.isRequired,localizer:Ae.object.isRequired,onSelectEvent:Ae.func,onDoubleClickEvent:Ae.func,selected:Ae.object};ys.defaultProps={length:30};ys.range=(e,{length:t=ys.defaultProps.length,localizer:n})=>{const r=n.add(e,-t/2,"day"),a=n.add(e,t/2,"day");return{customStart:r,customEnd:a}};ys.navigate=(e,t,{length:n=ys.defaultProps.length,localizer:r})=>{switch(t){case Td.PREVIOUS:return r.add(e,-n,"day");case Td.NEXT:return r.add(e,n,"day");default:return e}};ys.title=(e,{length:t=ys.defaultProps.length,localizer:n})=>{const r=n.add(e,-t/2,"day"),a=n.add(e,t/2,"day");return n.format({start:r,end:a},"agendaHeaderFormat")};function $G(e,t){e.hoverEl.toggleClass("thino-hover-popover",!0);const n=Ap(e.hoverEl);return n.render(w.jsx(Bo,{store:Ee,context:mt,children:w.jsx(Sa,{memo:t})})),n}function GG({event:e}){const t=e.resource,n=t.content.split(`
`)[0].slice(0,20),r=$.useRef(null),a=$.useRef(null),o=$.useRef(null);A.useEffect(()=>{if(a.current)return C.setIcon(a.current,"calendar"),()=>{r.current&&(r.current=null)}},[r]);const s=A.useCallback(d=>{o.current&&(o.current.unmount(),o.current=null),o.current=d},[]),c=A.useCallback(d=>{if(!r.current||!C.Keymap.isModifier(d.nativeEvent,"Mod"))return;const p=new C.HoverPopover(Xe.getState().view,r.current,100),m=$G(p,t);s(m)},[r.current]);return w.jsxs("span",{className:"rbc-event-renderer","data-source-type":t.sourceType,"data-thino-type":t.thinoType,"data-thino-id":t.id,ref:r,"aria-label":t.path,onMouseOver:c,children:[w.jsx(qG,{event:e}),w.jsx("strong",{children:n})]})}const qG=({event:e})=>{const t=$.useRef(null),n=e.resource;A.useEffect(()=>{t.current&&C.setIcon(t.current,n.thinoType==="JOURNAL"?"calendar":n.thinoType==="TASK-TODO"?"square":"check-square")},[n==null?void 0:n.thinoType,t]);const r=A.useCallback(async a=>{a.stopPropagation(),a.preventDefault(),await(async()=>{const s=await Te.updateMemo(n.id,n.content,n.thinoType==="TASK-TODO"?"TASK-DONE":"TASK-TODO");s&&Te.editMemo(s)})()},[n==null?void 0:n.thinoType,n==null?void 0:n.id,n==null?void 0:n.content]);return w.jsx(w.Fragment,{children:w.jsxs("span",{className:"rbc-event-icon-group",children:[w.jsx("span",{className:"rbc-event-icon",ref:t,onClick:r}),w.jsx("span",{className:Xn("rbc-event-time","hidden"),children:w.jsx("span",{className:"rbc-event-time-text",children:C.moment(e.start).format("HH:mm")})})]})})};function KC({views:e,view:t,messages:n,onView:r}){return e.map(a=>w.jsx("button",{type:"button",className:Xn({"rbc-active":t===a}),onClick:()=>r(a),children:n[a]},a))}KC.propTypes={messages:Ae.object,onView:Ae.func,view:Ae.string,views:Ae.array};function QC({date:e,label:t,localizer:{messages:n},onNavigate:r,onView:a,view:o,views:s}){const c={previous:A.useRef(null),today:A.useRef(null),next:A.useRef(null)};A.useEffect(()=>{c&&(C.setIcon(c.previous.current,"chevron-left"),C.setIcon(c.today.current,"dot"),C.setIcon(c.next.current,"chevron-right"))},[c]);const d=A.useMemo(()=>w.jsxs(w.Fragment,{children:[w.jsx("button",{ref:c.previous,type:"button",onClick:()=>r(Td.PREVIOUS),"aria-label":n.previous,children:"<"}),w.jsx("button",{ref:c.today,type:"button",onClick:()=>r(Td.TODAY),"aria-label":n.today,children:"•"}),w.jsx("button",{ref:c.next,type:"button",onClick:()=>r(Td.NEXT),"aria-label":n.next,children:">"})]}),[n]);return w.jsxs("div",{className:"rbc-toolbar",children:[w.jsx("span",{className:Xn("rbc-btn-group","thino-view-custom-toolbar"),children:d}),w.jsx("span",{className:"rbc-toolbar-label",children:w.jsx(py,{type:"text",handleValueChange:p=>{r(Td.DATE,C.moment(p,"YYYY-MM-DD").format("YYYY-MM-DDTHH:mm:ssZ"))},defaultText:t+(o==="week"?C.moment(e.valueOf(),"x").format(" [W]WW"):""),defaultValue:C.moment(e.valueOf(),"x").valueOf()})}),w.jsx("span",{className:"rbc-btn-group",children:w.jsx(KC,{view:o,views:s,messages:n,onView:a})})]})}QC.propTypes={date:Ae.instanceOf(Date),label:Ae.string,localizer:Ae.object,messages:Ae.object,onNavigate:Ae.func,onView:Ae.func,view:Ae.string,views:Ae.array};function JG({event:e,children:t,showPopup:n,callRender:r,...a}){const o=A.useRef(null),s=A.useRef(null),c=A.useCallback(d=>{if(!d.isTrusted){r();return}s.current=d.nativeEvent.target,s.current&&(s.current.hasClass("rbc-event")||(s.current=s.current.closest(".rbc-event")),o.current!==null?(window.clearTimeout(o.current),o.current=null):o.current=window.setTimeout(()=>{n(e,s.current),o.current=null},250))},[e,n]);return w.jsx(w.Fragment,{children:w.jsx("div",{className:"rbc-event-wrapper","aria-describedby":"thino",onClick:c,children:t})})}const KG=ZG(C.moment),QG=({event:e})=>{const t=e.resource;return w.jsx(w.Fragment,{children:w.jsx(Sa,{memo:t})})},XG=e=>{var Q;const{thinos:t}=e,[n,r]=$.useState([]),[a,o]=$.useState((app==null?void 0:app.loadLocalStorage("thino-calendar-view"))||"month"),[s,c]=$.useState(null),d=$.useRef(null),p=$.useRef(null),[m,g]=$.useState(!1),v=A.useRef(null),[D,S]=A.useState(new Date);A.useEffect(()=>()=>{d.current&&(d.current=null),p.current&&(p.current=null),v.current&&(v.current=null)},[]),A.useEffect(()=>{const le=t.map(pe=>{const ie=C.moment(pe.createdAt,"YYYY/MM/DD HH:mm:ss"),se=ie.clone().add(1,"minute");return{title:pe.content,start:new Date(ie.format("YYYY-MM-DDTHH:mm:ss")),end:new Date(se.format("YYYY-MM-DDTHH:mm:ss")),resource:pe}});r(le)},[t]),A.useEffect(()=>{app==null||app.saveLocalStorage("thino-calendar-view",a)},[a]),A.useEffect(()=>{m&&c(t.find(le=>le.id===s.id))},[t]),A.useEffect(()=>{s&&v.current.update()},[s]),v.current=Vy(d.current,p.current,{placement:"bottom-start",modifiers:[{name:"offset",options:{offset:[0,4]}}]});const T=A.useCallback(()=>{v.current.update(),v.current.update()},[]),E=A.useCallback((le,pe)=>{c(null),F(),v.current.state.elements.reference=pe,c(le.resource),B()},[]),O=A.useCallback(()=>{F(),c(null)},[]),k=A.useCallback((le,pe,ie)=>{var se;if(j(le),pe==="week"||pe==="day"){const fe=d.current.find(".rbc-event-wrapper");if(d.current.closest(".memolist-wrapper"),fe){(se=fe.children[0])==null||se.click();return}else{setTimeout(()=>{var we,Z;const oe=d.current.find(".rbc-event-wrapper");(Z=(we=oe==null?void 0:oe.children)==null?void 0:we[0])==null||Z.click()},0);return}}},[]),j=A.useCallback(le=>{S(le)},[S]);Pp(p,O);const F=A.useCallback(()=>{g(!1)},[g]),B=A.useCallback(()=>{v.current.update(),g(!0)},[g]),R=A.useCallback(le=>{const pe=le.resource;Qe.setEditMemoId(pe.id)},[]),z=A.useCallback(le=>{o(le)},[o]),{components:H,views:Y,messages:U}=A.useMemo(()=>({components:{toolbar:QC,eventWrapper:le=>w.jsx(JG,{...le,callRender:T,showPopup:E}),agenda:{event:QG},event:GG},views:{month:!0,agenda:ys,week:!0,day:!0},messages:{month:N("Month"),day:N("Day"),next:N("Next"),previous:N("Previous"),today:N("Today"),agenda:N("Agenda"),week:N("Week"),yesterday:N("Yesterday"),tomorrow:N("Tomorrow"),noEventsInRange:N("No thinos in range"),date:N("date"),time:N("time"),event:N("event")}}),[]),J=A.useMemo(()=>({timeGutterFormat:(le,pe,ie)=>ie.format(le,"HH:mm",pe),agendaTimeRangeFormat:({start:le,end:pe},ie,se)=>se.format(le,"HH:mm",ie)+" — "+se.format(pe,"HH:mm",ie),agendaHeaderFormat:({start:le,end:pe},ie,se)=>se.format(le,"YYYY-MM-DD")+" — "+se.format(pe,"YYYY-MM-DD")}),[]);return w.jsxs("div",{ref:d,className:"calendar-view",children:[w.jsx(_G,{date:D,messages:U,components:H,localizer:KG,events:n,views:Y,onView:z,onDoubleClickEvent:R,onNavigate:k,formats:J,defaultView:a,tooltipAccessor:null,startAccessor:"start",endAccessor:"end"}),w.jsx("div",{ref:p,style:(Q=v.current)==null?void 0:Q.styles.popper,className:Xn("thino-popup-container",m?"":"hidden"),children:s&&w.jsx(Sa,{memo:s})})]})};function vl(e,t){return typeof e=="function"?e(t):e}function Ua(e,t){return n=>{t.setState(r=>({...r,[e]:vl(n,r[e])}))}}function My(e){return e instanceof Function}function eq(e){return Array.isArray(e)&&e.every(t=>typeof t=="number")}function tq(e,t){const n=[],r=a=>{a.forEach(o=>{n.push(o);const s=t(o);s!=null&&s.length&&r(s)})};return r(e),n}function ht(e,t,n){let r=[],a;return o=>{let s;n.key&&n.debug&&(s=Date.now());const c=e(o);if(!(c.length!==r.length||c.some((m,g)=>r[g]!==m)))return a;r=c;let p;if(n.key&&n.debug&&(p=Date.now()),a=t(...c),n==null||n.onChange==null||n.onChange(a),n.key&&n.debug&&n!=null&&n.debug()){const m=Math.round((Date.now()-s)*100)/100,v=Math.round((Date.now()-p)*100)/100/16,D=(S,T)=>{for(S=String(S);S.length{var a;return(a=e==null?void 0:e.debugAll)!=null?a:e[t]},key:!1,onChange:r}}function nq(e,t,n,r){var a,o;const c={...e._getDefaultColumnDef(),...t},d=c.accessorKey;let p=(a=(o=c.id)!=null?o:d?d.replace(".","_"):void 0)!=null?a:typeof c.header=="string"?c.header:void 0,m;if(c.accessorFn?m=c.accessorFn:d&&(d.includes(".")?m=v=>{let D=v;for(const T of d.split(".")){var S;D=(S=D)==null?void 0:S[T]}return D}:m=v=>v[c.accessorKey]),!p)throw new Error;let g={id:`${String(p)}`,accessorFn:m,parent:r,depth:n,columnDef:c,columns:[],getFlatColumns:ht(()=>[!0],()=>{var v;return[g,...(v=g.columns)==null?void 0:v.flatMap(D=>D.getFlatColumns())]},pt(e.options,"debugColumns")),getLeafColumns:ht(()=>[e._getOrderColumnsFn()],v=>{var D;if((D=g.columns)!=null&&D.length){let S=g.columns.flatMap(T=>T.getLeafColumns());return v(S)}return[g]},pt(e.options,"debugColumns"))};for(const v of e._features)v.createColumn==null||v.createColumn(g,e);return g}const Rr="debugHeaders";function S2(e,t,n){var r;let o={id:(r=n.id)!=null?r:t.id,column:t,index:n.index,isPlaceholder:!!n.isPlaceholder,placeholderId:n.placeholderId,depth:n.depth,subHeaders:[],colSpan:0,rowSpan:0,headerGroup:null,getLeafHeaders:()=>{const s=[],c=d=>{d.subHeaders&&d.subHeaders.length&&d.subHeaders.map(c),s.push(d)};return c(o),s},getContext:()=>({table:e,header:o,column:t})};return e._features.forEach(s=>{s.createHeader==null||s.createHeader(o,e)}),o}const rq={createTable:e=>{e.getHeaderGroups=ht(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.left,e.getState().columnPinning.right],(t,n,r,a)=>{var o,s;const c=(o=r==null?void 0:r.map(g=>n.find(v=>v.id===g)).filter(Boolean))!=null?o:[],d=(s=a==null?void 0:a.map(g=>n.find(v=>v.id===g)).filter(Boolean))!=null?s:[],p=n.filter(g=>!(r!=null&&r.includes(g.id))&&!(a!=null&&a.includes(g.id)));return Bg(t,[...c,...p,...d],e)},pt(e.options,Rr)),e.getCenterHeaderGroups=ht(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.left,e.getState().columnPinning.right],(t,n,r,a)=>(n=n.filter(o=>!(r!=null&&r.includes(o.id))&&!(a!=null&&a.includes(o.id))),Bg(t,n,e,"center")),pt(e.options,Rr)),e.getLeftHeaderGroups=ht(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.left],(t,n,r)=>{var a;const o=(a=r==null?void 0:r.map(s=>n.find(c=>c.id===s)).filter(Boolean))!=null?a:[];return Bg(t,o,e,"left")},pt(e.options,Rr)),e.getRightHeaderGroups=ht(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.right],(t,n,r)=>{var a;const o=(a=r==null?void 0:r.map(s=>n.find(c=>c.id===s)).filter(Boolean))!=null?a:[];return Bg(t,o,e,"right")},pt(e.options,Rr)),e.getFooterGroups=ht(()=>[e.getHeaderGroups()],t=>[...t].reverse(),pt(e.options,Rr)),e.getLeftFooterGroups=ht(()=>[e.getLeftHeaderGroups()],t=>[...t].reverse(),pt(e.options,Rr)),e.getCenterFooterGroups=ht(()=>[e.getCenterHeaderGroups()],t=>[...t].reverse(),pt(e.options,Rr)),e.getRightFooterGroups=ht(()=>[e.getRightHeaderGroups()],t=>[...t].reverse(),pt(e.options,Rr)),e.getFlatHeaders=ht(()=>[e.getHeaderGroups()],t=>t.map(n=>n.headers).flat(),pt(e.options,Rr)),e.getLeftFlatHeaders=ht(()=>[e.getLeftHeaderGroups()],t=>t.map(n=>n.headers).flat(),pt(e.options,Rr)),e.getCenterFlatHeaders=ht(()=>[e.getCenterHeaderGroups()],t=>t.map(n=>n.headers).flat(),pt(e.options,Rr)),e.getRightFlatHeaders=ht(()=>[e.getRightHeaderGroups()],t=>t.map(n=>n.headers).flat(),pt(e.options,Rr)),e.getCenterLeafHeaders=ht(()=>[e.getCenterFlatHeaders()],t=>t.filter(n=>{var r;return!((r=n.subHeaders)!=null&&r.length)}),pt(e.options,Rr)),e.getLeftLeafHeaders=ht(()=>[e.getLeftFlatHeaders()],t=>t.filter(n=>{var r;return!((r=n.subHeaders)!=null&&r.length)}),pt(e.options,Rr)),e.getRightLeafHeaders=ht(()=>[e.getRightFlatHeaders()],t=>t.filter(n=>{var r;return!((r=n.subHeaders)!=null&&r.length)}),pt(e.options,Rr)),e.getLeafHeaders=ht(()=>[e.getLeftHeaderGroups(),e.getCenterHeaderGroups(),e.getRightHeaderGroups()],(t,n,r)=>{var a,o,s,c,d,p;return[...(a=(o=t[0])==null?void 0:o.headers)!=null?a:[],...(s=(c=n[0])==null?void 0:c.headers)!=null?s:[],...(d=(p=r[0])==null?void 0:p.headers)!=null?d:[]].map(m=>m.getLeafHeaders()).flat()},pt(e.options,Rr))}};function Bg(e,t,n,r){var a,o;let s=0;const c=function(v,D){D===void 0&&(D=1),s=Math.max(s,D),v.filter(S=>S.getIsVisible()).forEach(S=>{var T;(T=S.columns)!=null&&T.length&&c(S.columns,D+1)},0)};c(e);let d=[];const p=(v,D)=>{const S={depth:D,id:[r,`${D}`].filter(Boolean).join("_"),headers:[]},T=[];v.forEach(E=>{const O=[...T].reverse()[0],k=E.column.depth===S.depth;let j,F=!1;if(k&&E.column.parent?j=E.column.parent:(j=E.column,F=!0),O&&(O==null?void 0:O.column)===j)O.subHeaders.push(E);else{const B=S2(n,j,{id:[r,D,j.id,E==null?void 0:E.id].filter(Boolean).join("_"),isPlaceholder:F,placeholderId:F?`${T.filter(R=>R.column===j).length}`:void 0,depth:D,index:T.length});B.subHeaders.push(E),T.push(B)}S.headers.push(E),E.headerGroup=S}),d.push(S),D>0&&p(T,D-1)},m=t.map((v,D)=>S2(n,v,{depth:s,index:D}));p(m,s-1),d.reverse();const g=v=>v.filter(S=>S.column.getIsVisible()).map(S=>{let T=0,E=0,O=[0];S.subHeaders&&S.subHeaders.length?(O=[],g(S.subHeaders).forEach(j=>{let{colSpan:F,rowSpan:B}=j;T+=F,O.push(B)})):T=1;const k=Math.min(...O);return E+=k,S.colSpan=T,S.rowSpan=E,{colSpan:T,rowSpan:E}});return g((a=(o=d[0])==null?void 0:o.headers)!=null?a:[]),d}const _g={size:150,minSize:20,maxSize:Number.MAX_SAFE_INTEGER},q0=()=>({startOffset:null,startSize:null,deltaOffset:null,deltaPercentage:null,isResizingColumn:!1,columnSizingStart:[]}),aq={getDefaultColumnDef:()=>_g,getInitialState:e=>({columnSizing:{},columnSizingInfo:q0(),...e}),getDefaultOptions:e=>({columnResizeMode:"onEnd",columnResizeDirection:"ltr",onColumnSizingChange:Ua("columnSizing",e),onColumnSizingInfoChange:Ua("columnSizingInfo",e)}),createColumn:(e,t)=>{e.getSize=()=>{var n,r,a;const o=t.getState().columnSizing[e.id];return Math.min(Math.max((n=e.columnDef.minSize)!=null?n:_g.minSize,(r=o??e.columnDef.size)!=null?r:_g.size),(a=e.columnDef.maxSize)!=null?a:_g.maxSize)},e.getStart=ht(n=>[n,Qh(t,n),t.getState().columnSizing],(n,r)=>r.slice(0,e.getIndex(n)).reduce((a,o)=>a+o.getSize(),0),pt(t.options,"debugColumns")),e.getAfter=ht(n=>[n,Qh(t,n),t.getState().columnSizing],(n,r)=>r.slice(e.getIndex(n)+1).reduce((a,o)=>a+o.getSize(),0),pt(t.options,"debugColumns")),e.resetSize=()=>{t.setColumnSizing(n=>{let{[e.id]:r,...a}=n;return a})},e.getCanResize=()=>{var n,r;return((n=e.columnDef.enableResizing)!=null?n:!0)&&((r=t.options.enableColumnResizing)!=null?r:!0)},e.getIsResizing=()=>t.getState().columnSizingInfo.isResizingColumn===e.id},createHeader:(e,t)=>{e.getSize=()=>{let n=0;const r=a=>{if(a.subHeaders.length)a.subHeaders.forEach(r);else{var o;n+=(o=a.column.getSize())!=null?o:0}};return r(e),n},e.getStart=()=>{if(e.index>0){const n=e.headerGroup.headers[e.index-1];return n.getStart()+n.getSize()}return 0},e.getResizeHandler=n=>{const r=t.getColumn(e.column.id),a=r==null?void 0:r.getCanResize();return o=>{if(!r||!a||(o.persist==null||o.persist(),J0(o)&&o.touches&&o.touches.length>1))return;const s=e.getSize(),c=e?e.getLeafHeaders().map(O=>[O.column.id,O.column.getSize()]):[[r.id,r.getSize()]],d=J0(o)?Math.round(o.touches[0].clientX):o.clientX,p={},m=(O,k)=>{typeof k=="number"&&(t.setColumnSizingInfo(j=>{var F,B;const R=t.options.columnResizeDirection==="rtl"?-1:1,z=(k-((F=j==null?void 0:j.startOffset)!=null?F:0))*R,H=Math.max(z/((B=j==null?void 0:j.startSize)!=null?B:0),-.999999);return j.columnSizingStart.forEach(Y=>{let[U,J]=Y;p[U]=Math.round(Math.max(J+J*H,0)*100)/100}),{...j,deltaOffset:z,deltaPercentage:H}}),(t.options.columnResizeMode==="onChange"||O==="end")&&t.setColumnSizing(j=>({...j,...p})))},g=O=>m("move",O),v=O=>{m("end",O),t.setColumnSizingInfo(k=>({...k,isResizingColumn:!1,startOffset:null,startSize:null,deltaOffset:null,deltaPercentage:null,columnSizingStart:[]}))},D=n||typeof document<"u"?document:null,S={moveHandler:O=>g(O.clientX),upHandler:O=>{D==null||D.removeEventListener("mousemove",S.moveHandler),D==null||D.removeEventListener("mouseup",S.upHandler),v(O.clientX)}},T={moveHandler:O=>(O.cancelable&&(O.preventDefault(),O.stopPropagation()),g(O.touches[0].clientX),!1),upHandler:O=>{var k;D==null||D.removeEventListener("touchmove",T.moveHandler),D==null||D.removeEventListener("touchend",T.upHandler),O.cancelable&&(O.preventDefault(),O.stopPropagation()),v((k=O.touches[0])==null?void 0:k.clientX)}},E=oq()?{passive:!1}:!1;J0(o)?(D==null||D.addEventListener("touchmove",T.moveHandler,E),D==null||D.addEventListener("touchend",T.upHandler,E)):(D==null||D.addEventListener("mousemove",S.moveHandler,E),D==null||D.addEventListener("mouseup",S.upHandler,E)),t.setColumnSizingInfo(O=>({...O,startOffset:d,startSize:s,deltaOffset:0,deltaPercentage:0,columnSizingStart:c,isResizingColumn:r.id}))}}},createTable:e=>{e.setColumnSizing=t=>e.options.onColumnSizingChange==null?void 0:e.options.onColumnSizingChange(t),e.setColumnSizingInfo=t=>e.options.onColumnSizingInfoChange==null?void 0:e.options.onColumnSizingInfoChange(t),e.resetColumnSizing=t=>{var n;e.setColumnSizing(t?{}:(n=e.initialState.columnSizing)!=null?n:{})},e.resetHeaderSizeInfo=t=>{var n;e.setColumnSizingInfo(t?q0():(n=e.initialState.columnSizingInfo)!=null?n:q0())},e.getTotalSize=()=>{var t,n;return(t=(n=e.getHeaderGroups()[0])==null?void 0:n.headers.reduce((r,a)=>r+a.getSize(),0))!=null?t:0},e.getLeftTotalSize=()=>{var t,n;return(t=(n=e.getLeftHeaderGroups()[0])==null?void 0:n.headers.reduce((r,a)=>r+a.getSize(),0))!=null?t:0},e.getCenterTotalSize=()=>{var t,n;return(t=(n=e.getCenterHeaderGroups()[0])==null?void 0:n.headers.reduce((r,a)=>r+a.getSize(),0))!=null?t:0},e.getRightTotalSize=()=>{var t,n;return(t=(n=e.getRightHeaderGroups()[0])==null?void 0:n.headers.reduce((r,a)=>r+a.getSize(),0))!=null?t:0}}};let Hg=null;function oq(){if(typeof Hg=="boolean")return Hg;let e=!1;try{const t={get passive(){return e=!0,!1}},n=()=>{};window.addEventListener("test",n,t),window.removeEventListener("test",n)}catch{e=!1}return Hg=e,Hg}function J0(e){return e.type==="touchstart"}const iq={getInitialState:e=>({expanded:{},...e}),getDefaultOptions:e=>({onExpandedChange:Ua("expanded",e),paginateExpandedRows:!0}),createTable:e=>{let t=!1,n=!1;e._autoResetExpanded=()=>{var r,a;if(!t){e._queue(()=>{t=!0});return}if((r=(a=e.options.autoResetAll)!=null?a:e.options.autoResetExpanded)!=null?r:!e.options.manualExpanding){if(n)return;n=!0,e._queue(()=>{e.resetExpanded(),n=!1})}},e.setExpanded=r=>e.options.onExpandedChange==null?void 0:e.options.onExpandedChange(r),e.toggleAllRowsExpanded=r=>{r??!e.getIsAllRowsExpanded()?e.setExpanded(!0):e.setExpanded({})},e.resetExpanded=r=>{var a,o;e.setExpanded(r?{}:(a=(o=e.initialState)==null?void 0:o.expanded)!=null?a:{})},e.getCanSomeRowsExpand=()=>e.getPrePaginationRowModel().flatRows.some(r=>r.getCanExpand()),e.getToggleAllRowsExpandedHandler=()=>r=>{r.persist==null||r.persist(),e.toggleAllRowsExpanded()},e.getIsSomeRowsExpanded=()=>{const r=e.getState().expanded;return r===!0||Object.values(r).some(Boolean)},e.getIsAllRowsExpanded=()=>{const r=e.getState().expanded;return typeof r=="boolean"?r===!0:!(!Object.keys(r).length||e.getRowModel().flatRows.some(a=>!a.getIsExpanded()))},e.getExpandedDepth=()=>{let r=0;return(e.getState().expanded===!0?Object.keys(e.getRowModel().rowsById):Object.keys(e.getState().expanded)).forEach(o=>{const s=o.split(".");r=Math.max(r,s.length)}),r},e.getPreExpandedRowModel=()=>e.getSortedRowModel(),e.getExpandedRowModel=()=>(!e._getExpandedRowModel&&e.options.getExpandedRowModel&&(e._getExpandedRowModel=e.options.getExpandedRowModel(e)),e.options.manualExpanding||!e._getExpandedRowModel?e.getPreExpandedRowModel():e._getExpandedRowModel())},createRow:(e,t)=>{e.toggleExpanded=n=>{t.setExpanded(r=>{var a;const o=r===!0?!0:!!(r!=null&&r[e.id]);let s={};if(r===!0?Object.keys(t.getRowModel().rowsById).forEach(c=>{s[c]=!0}):s=r,n=(a=n)!=null?a:!o,!o&&n)return{...s,[e.id]:!0};if(o&&!n){const{[e.id]:c,...d}=s;return d}return r})},e.getIsExpanded=()=>{var n;const r=t.getState().expanded;return!!((n=t.options.getIsRowExpanded==null?void 0:t.options.getIsRowExpanded(e))!=null?n:r===!0||r!=null&&r[e.id])},e.getCanExpand=()=>{var n,r,a;return(n=t.options.getRowCanExpand==null?void 0:t.options.getRowCanExpand(e))!=null?n:((r=t.options.enableExpanding)!=null?r:!0)&&!!((a=e.subRows)!=null&&a.length)},e.getIsAllParentsExpanded=()=>{let n=!0,r=e;for(;n&&r.parentId;)r=t.getRow(r.parentId,!0),n=r.getIsExpanded();return n},e.getToggleExpandedHandler=()=>{const n=e.getCanExpand();return()=>{n&&e.toggleExpanded()}}}},XC=(e,t,n)=>{var r;const a=n.toLowerCase();return!!(!((r=e.getValue(t))==null||(r=r.toString())==null||(r=r.toLowerCase())==null)&&r.includes(a))};XC.autoRemove=e=>Po(e);const ex=(e,t,n)=>{var r;return!!(!((r=e.getValue(t))==null||(r=r.toString())==null)&&r.includes(n))};ex.autoRemove=e=>Po(e);const tx=(e,t,n)=>{var r;return((r=e.getValue(t))==null||(r=r.toString())==null?void 0:r.toLowerCase())===(n==null?void 0:n.toLowerCase())};tx.autoRemove=e=>Po(e);const nx=(e,t,n)=>{var r;return(r=e.getValue(t))==null?void 0:r.includes(n)};nx.autoRemove=e=>Po(e)||!(e!=null&&e.length);const rx=(e,t,n)=>!n.some(r=>{var a;return!((a=e.getValue(t))!=null&&a.includes(r))});rx.autoRemove=e=>Po(e)||!(e!=null&&e.length);const ax=(e,t,n)=>n.some(r=>{var a;return(a=e.getValue(t))==null?void 0:a.includes(r)});ax.autoRemove=e=>Po(e)||!(e!=null&&e.length);const ox=(e,t,n)=>e.getValue(t)===n;ox.autoRemove=e=>Po(e);const ix=(e,t,n)=>e.getValue(t)==n;ix.autoRemove=e=>Po(e);const cb=(e,t,n)=>{let[r,a]=n;const o=e.getValue(t);return o>=r&&o<=a};cb.resolveFilterValue=e=>{let[t,n]=e,r=typeof t!="number"?parseFloat(t):t,a=typeof n!="number"?parseFloat(n):n,o=t===null||Number.isNaN(r)?-1/0:r,s=n===null||Number.isNaN(a)?1/0:a;if(o>s){const c=o;o=s,s=c}return[o,s]};cb.autoRemove=e=>Po(e)||Po(e[0])&&Po(e[1]);const ls={includesString:XC,includesStringSensitive:ex,equalsString:tx,arrIncludes:nx,arrIncludesAll:rx,arrIncludesSome:ax,equals:ox,weakEquals:ix,inNumberRange:cb};function Po(e){return e==null||e===""}const sq={getDefaultColumnDef:()=>({filterFn:"auto"}),getInitialState:e=>({columnFilters:[],globalFilter:void 0,...e}),getDefaultOptions:e=>({onColumnFiltersChange:Ua("columnFilters",e),onGlobalFilterChange:Ua("globalFilter",e),filterFromLeafRows:!1,maxLeafRowFilterDepth:100,globalFilterFn:"auto",getColumnCanGlobalFilter:t=>{var n;const r=(n=e.getCoreRowModel().flatRows[0])==null||(n=n._getAllCellsByColumnId()[t.id])==null?void 0:n.getValue();return typeof r=="string"||typeof r=="number"}}),createColumn:(e,t)=>{e.getAutoFilterFn=()=>{const n=t.getCoreRowModel().flatRows[0],r=n==null?void 0:n.getValue(e.id);return typeof r=="string"?ls.includesString:typeof r=="number"?ls.inNumberRange:typeof r=="boolean"||r!==null&&typeof r=="object"?ls.equals:Array.isArray(r)?ls.arrIncludes:ls.weakEquals},e.getFilterFn=()=>{var n,r;return My(e.columnDef.filterFn)?e.columnDef.filterFn:e.columnDef.filterFn==="auto"?e.getAutoFilterFn():(n=(r=t.options.filterFns)==null?void 0:r[e.columnDef.filterFn])!=null?n:ls[e.columnDef.filterFn]},e.getCanFilter=()=>{var n,r,a;return((n=e.columnDef.enableColumnFilter)!=null?n:!0)&&((r=t.options.enableColumnFilters)!=null?r:!0)&&((a=t.options.enableFilters)!=null?a:!0)&&!!e.accessorFn},e.getCanGlobalFilter=()=>{var n,r,a,o;return((n=e.columnDef.enableGlobalFilter)!=null?n:!0)&&((r=t.options.enableGlobalFilter)!=null?r:!0)&&((a=t.options.enableFilters)!=null?a:!0)&&((o=t.options.getColumnCanGlobalFilter==null?void 0:t.options.getColumnCanGlobalFilter(e))!=null?o:!0)&&!!e.accessorFn},e.getIsFiltered=()=>e.getFilterIndex()>-1,e.getFilterValue=()=>{var n;return(n=t.getState().columnFilters)==null||(n=n.find(r=>r.id===e.id))==null?void 0:n.value},e.getFilterIndex=()=>{var n,r;return(n=(r=t.getState().columnFilters)==null?void 0:r.findIndex(a=>a.id===e.id))!=null?n:-1},e.setFilterValue=n=>{t.setColumnFilters(r=>{const a=e.getFilterFn(),o=r==null?void 0:r.find(m=>m.id===e.id),s=vl(n,o?o.value:void 0);if(I2(a,s,e)){var c;return(c=r==null?void 0:r.filter(m=>m.id!==e.id))!=null?c:[]}const d={id:e.id,value:s};if(o){var p;return(p=r==null?void 0:r.map(m=>m.id===e.id?d:m))!=null?p:[]}return r!=null&&r.length?[...r,d]:[d]})},e._getFacetedRowModel=t.options.getFacetedRowModel&&t.options.getFacetedRowModel(t,e.id),e.getFacetedRowModel=()=>e._getFacetedRowModel?e._getFacetedRowModel():t.getPreFilteredRowModel(),e._getFacetedUniqueValues=t.options.getFacetedUniqueValues&&t.options.getFacetedUniqueValues(t,e.id),e.getFacetedUniqueValues=()=>e._getFacetedUniqueValues?e._getFacetedUniqueValues():new Map,e._getFacetedMinMaxValues=t.options.getFacetedMinMaxValues&&t.options.getFacetedMinMaxValues(t,e.id),e.getFacetedMinMaxValues=()=>{if(e._getFacetedMinMaxValues)return e._getFacetedMinMaxValues()}},createRow:(e,t)=>{e.columnFilters={},e.columnFiltersMeta={}},createTable:e=>{e.getGlobalAutoFilterFn=()=>ls.includesString,e.getGlobalFilterFn=()=>{var t,n;const{globalFilterFn:r}=e.options;return My(r)?r:r==="auto"?e.getGlobalAutoFilterFn():(t=(n=e.options.filterFns)==null?void 0:n[r])!=null?t:ls[r]},e.setColumnFilters=t=>{const n=e.getAllLeafColumns(),r=a=>{var o;return(o=vl(t,a))==null?void 0:o.filter(s=>{const c=n.find(d=>d.id===s.id);if(c){const d=c.getFilterFn();if(I2(d,s.value,c))return!1}return!0})};e.options.onColumnFiltersChange==null||e.options.onColumnFiltersChange(r)},e.setGlobalFilter=t=>{e.options.onGlobalFilterChange==null||e.options.onGlobalFilterChange(t)},e.resetGlobalFilter=t=>{e.setGlobalFilter(t?void 0:e.initialState.globalFilter)},e.resetColumnFilters=t=>{var n,r;e.setColumnFilters(t?[]:(n=(r=e.initialState)==null?void 0:r.columnFilters)!=null?n:[])},e.getPreFilteredRowModel=()=>e.getCoreRowModel(),e.getFilteredRowModel=()=>(!e._getFilteredRowModel&&e.options.getFilteredRowModel&&(e._getFilteredRowModel=e.options.getFilteredRowModel(e)),e.options.manualFiltering||!e._getFilteredRowModel?e.getPreFilteredRowModel():e._getFilteredRowModel()),e._getGlobalFacetedRowModel=e.options.getFacetedRowModel&&e.options.getFacetedRowModel(e,"__global__"),e.getGlobalFacetedRowModel=()=>e.options.manualFiltering||!e._getGlobalFacetedRowModel?e.getPreFilteredRowModel():e._getGlobalFacetedRowModel(),e._getGlobalFacetedUniqueValues=e.options.getFacetedUniqueValues&&e.options.getFacetedUniqueValues(e,"__global__"),e.getGlobalFacetedUniqueValues=()=>e._getGlobalFacetedUniqueValues?e._getGlobalFacetedUniqueValues():new Map,e._getGlobalFacetedMinMaxValues=e.options.getFacetedMinMaxValues&&e.options.getFacetedMinMaxValues(e,"__global__"),e.getGlobalFacetedMinMaxValues=()=>{if(e._getGlobalFacetedMinMaxValues)return e._getGlobalFacetedMinMaxValues()}}};function I2(e,t,n){return(e&&e.autoRemove?e.autoRemove(t,n):!1)||typeof t>"u"||typeof t=="string"&&!t}const lq=(e,t,n)=>n.reduce((r,a)=>{const o=a.getValue(e);return r+(typeof o=="number"?o:0)},0),uq=(e,t,n)=>{let r;return n.forEach(a=>{const o=a.getValue(e);o!=null&&(r>o||r===void 0&&o>=o)&&(r=o)}),r},cq=(e,t,n)=>{let r;return n.forEach(a=>{const o=a.getValue(e);o!=null&&(r=o)&&(r=o)}),r},dq=(e,t,n)=>{let r,a;return n.forEach(o=>{const s=o.getValue(e);s!=null&&(r===void 0?s>=s&&(r=a=s):(r>s&&(r=s),a{let n=0,r=0;if(t.forEach(a=>{let o=a.getValue(e);o!=null&&(o=+o)>=o&&(++n,r+=o)}),n)return r/n},hq=(e,t)=>{if(!t.length)return;const n=t.map(o=>o.getValue(e));if(!eq(n))return;if(n.length===1)return n[0];const r=Math.floor(n.length/2),a=n.sort((o,s)=>o-s);return n.length%2!==0?a[r]:(a[r-1]+a[r])/2},pq=(e,t)=>Array.from(new Set(t.map(n=>n.getValue(e))).values()),mq=(e,t)=>new Set(t.map(n=>n.getValue(e))).size,gq=(e,t)=>t.length,K0={sum:lq,min:uq,max:cq,extent:dq,mean:fq,median:hq,unique:pq,uniqueCount:mq,count:gq},yq={getDefaultColumnDef:()=>({aggregatedCell:e=>{var t,n;return(t=(n=e.getValue())==null||n.toString==null?void 0:n.toString())!=null?t:null},aggregationFn:"auto"}),getInitialState:e=>({grouping:[],...e}),getDefaultOptions:e=>({onGroupingChange:Ua("grouping",e),groupedColumnMode:"reorder"}),createColumn:(e,t)=>{e.toggleGrouping=()=>{t.setGrouping(n=>n!=null&&n.includes(e.id)?n.filter(r=>r!==e.id):[...n??[],e.id])},e.getCanGroup=()=>{var n,r,a,o;return(n=(r=(a=(o=e.columnDef.enableGrouping)!=null?o:!0)!=null?a:t.options.enableGrouping)!=null?r:!0)!=null?n:!!e.accessorFn},e.getIsGrouped=()=>{var n;return(n=t.getState().grouping)==null?void 0:n.includes(e.id)},e.getGroupedIndex=()=>{var n;return(n=t.getState().grouping)==null?void 0:n.indexOf(e.id)},e.getToggleGroupingHandler=()=>{const n=e.getCanGroup();return()=>{n&&e.toggleGrouping()}},e.getAutoAggregationFn=()=>{const n=t.getCoreRowModel().flatRows[0],r=n==null?void 0:n.getValue(e.id);if(typeof r=="number")return K0.sum;if(Object.prototype.toString.call(r)==="[object Date]")return K0.extent},e.getAggregationFn=()=>{var n,r;if(!e)throw new Error;return My(e.columnDef.aggregationFn)?e.columnDef.aggregationFn:e.columnDef.aggregationFn==="auto"?e.getAutoAggregationFn():(n=(r=t.options.aggregationFns)==null?void 0:r[e.columnDef.aggregationFn])!=null?n:K0[e.columnDef.aggregationFn]}},createTable:e=>{e.setGrouping=t=>e.options.onGroupingChange==null?void 0:e.options.onGroupingChange(t),e.resetGrouping=t=>{var n,r;e.setGrouping(t?[]:(n=(r=e.initialState)==null?void 0:r.grouping)!=null?n:[])},e.getPreGroupedRowModel=()=>e.getFilteredRowModel(),e.getGroupedRowModel=()=>(!e._getGroupedRowModel&&e.options.getGroupedRowModel&&(e._getGroupedRowModel=e.options.getGroupedRowModel(e)),e.options.manualGrouping||!e._getGroupedRowModel?e.getPreGroupedRowModel():e._getGroupedRowModel())},createRow:(e,t)=>{e.getIsGrouped=()=>!!e.groupingColumnId,e.getGroupingValue=n=>{if(e._groupingValuesCache.hasOwnProperty(n))return e._groupingValuesCache[n];const r=t.getColumn(n);return r!=null&&r.columnDef.getGroupingValue?(e._groupingValuesCache[n]=r.columnDef.getGroupingValue(e.original),e._groupingValuesCache[n]):e.getValue(n)},e._groupingValuesCache={}},createCell:(e,t,n,r)=>{e.getIsGrouped=()=>t.getIsGrouped()&&t.id===n.groupingColumnId,e.getIsPlaceholder=()=>!e.getIsGrouped()&&t.getIsGrouped(),e.getIsAggregated=()=>{var a;return!e.getIsGrouped()&&!e.getIsPlaceholder()&&!!((a=n.subRows)!=null&&a.length)}}};function vq(e,t,n){if(!(t!=null&&t.length)||!n)return e;const r=e.filter(o=>!t.includes(o.id));return n==="remove"?r:[...t.map(o=>e.find(s=>s.id===o)).filter(Boolean),...r]}const wq={getInitialState:e=>({columnOrder:[],...e}),getDefaultOptions:e=>({onColumnOrderChange:Ua("columnOrder",e)}),createColumn:(e,t)=>{e.getIndex=ht(n=>[Qh(t,n)],n=>n.findIndex(r=>r.id===e.id),pt(t.options,"debugColumns")),e.getIsFirstColumn=n=>{var r;return((r=Qh(t,n)[0])==null?void 0:r.id)===e.id},e.getIsLastColumn=n=>{var r;const a=Qh(t,n);return((r=a[a.length-1])==null?void 0:r.id)===e.id}},createTable:e=>{e.setColumnOrder=t=>e.options.onColumnOrderChange==null?void 0:e.options.onColumnOrderChange(t),e.resetColumnOrder=t=>{var n;e.setColumnOrder(t?[]:(n=e.initialState.columnOrder)!=null?n:[])},e._getOrderColumnsFn=ht(()=>[e.getState().columnOrder,e.getState().grouping,e.options.groupedColumnMode],(t,n,r)=>a=>{let o=[];if(!(t!=null&&t.length))o=a;else{const s=[...t],c=[...a];for(;c.length&&s.length;){const d=s.shift(),p=c.findIndex(m=>m.id===d);p>-1&&o.push(c.splice(p,1)[0])}o=[...o,...c]}return vq(o,n,r)},pt(e.options,"debugTable"))}},$w=0,Gw=10,Q0=()=>({pageIndex:$w,pageSize:Gw}),bq={getInitialState:e=>({...e,pagination:{...Q0(),...e==null?void 0:e.pagination}}),getDefaultOptions:e=>({onPaginationChange:Ua("pagination",e)}),createTable:e=>{let t=!1,n=!1;e._autoResetPageIndex=()=>{var r,a;if(!t){e._queue(()=>{t=!0});return}if((r=(a=e.options.autoResetAll)!=null?a:e.options.autoResetPageIndex)!=null?r:!e.options.manualPagination){if(n)return;n=!0,e._queue(()=>{e.resetPageIndex(),n=!1})}},e.setPagination=r=>{const a=o=>vl(r,o);return e.options.onPaginationChange==null?void 0:e.options.onPaginationChange(a)},e.resetPagination=r=>{var a;e.setPagination(r?Q0():(a=e.initialState.pagination)!=null?a:Q0())},e.setPageIndex=r=>{e.setPagination(a=>{let o=vl(r,a.pageIndex);const s=typeof e.options.pageCount>"u"||e.options.pageCount===-1?Number.MAX_SAFE_INTEGER:e.options.pageCount-1;return o=Math.max(0,Math.min(o,s)),{...a,pageIndex:o}})},e.resetPageIndex=r=>{var a,o;e.setPageIndex(r?$w:(a=(o=e.initialState)==null||(o=o.pagination)==null?void 0:o.pageIndex)!=null?a:$w)},e.resetPageSize=r=>{var a,o;e.setPageSize(r?Gw:(a=(o=e.initialState)==null||(o=o.pagination)==null?void 0:o.pageSize)!=null?a:Gw)},e.setPageSize=r=>{e.setPagination(a=>{const o=Math.max(1,vl(r,a.pageSize)),s=a.pageSize*a.pageIndex,c=Math.floor(s/o);return{...a,pageIndex:c,pageSize:o}})},e.setPageCount=r=>e.setPagination(a=>{var o;let s=vl(r,(o=e.options.pageCount)!=null?o:-1);return typeof s=="number"&&(s=Math.max(-1,s)),{...a,pageCount:s}}),e.getPageOptions=ht(()=>[e.getPageCount()],r=>{let a=[];return r&&r>0&&(a=[...new Array(r)].fill(null).map((o,s)=>s)),a},pt(e.options,"debugTable")),e.getCanPreviousPage=()=>e.getState().pagination.pageIndex>0,e.getCanNextPage=()=>{const{pageIndex:r}=e.getState().pagination,a=e.getPageCount();return a===-1?!0:a===0?!1:re.setPageIndex(r=>r-1),e.nextPage=()=>e.setPageIndex(r=>r+1),e.firstPage=()=>e.setPageIndex(0),e.lastPage=()=>e.setPageIndex(e.getPageCount()-1),e.getPrePaginationRowModel=()=>e.getExpandedRowModel(),e.getPaginationRowModel=()=>(!e._getPaginationRowModel&&e.options.getPaginationRowModel&&(e._getPaginationRowModel=e.options.getPaginationRowModel(e)),e.options.manualPagination||!e._getPaginationRowModel?e.getPrePaginationRowModel():e._getPaginationRowModel()),e.getPageCount=()=>{var r;return(r=e.options.pageCount)!=null?r:Math.ceil(e.getRowCount()/e.getState().pagination.pageSize)},e.getRowCount=()=>{var r;return(r=e.options.rowCount)!=null?r:e.getPrePaginationRowModel().rows.length}}},X0=()=>({left:[],right:[]}),ew=()=>({top:[],bottom:[]}),Dq={getInitialState:e=>({columnPinning:X0(),rowPinning:ew(),...e}),getDefaultOptions:e=>({onColumnPinningChange:Ua("columnPinning",e),onRowPinningChange:Ua("rowPinning",e)}),createColumn:(e,t)=>{e.pin=n=>{const r=e.getLeafColumns().map(a=>a.id).filter(Boolean);t.setColumnPinning(a=>{var o,s;if(n==="right"){var c,d;return{left:((c=a==null?void 0:a.left)!=null?c:[]).filter(g=>!(r!=null&&r.includes(g))),right:[...((d=a==null?void 0:a.right)!=null?d:[]).filter(g=>!(r!=null&&r.includes(g))),...r]}}if(n==="left"){var p,m;return{left:[...((p=a==null?void 0:a.left)!=null?p:[]).filter(g=>!(r!=null&&r.includes(g))),...r],right:((m=a==null?void 0:a.right)!=null?m:[]).filter(g=>!(r!=null&&r.includes(g)))}}return{left:((o=a==null?void 0:a.left)!=null?o:[]).filter(g=>!(r!=null&&r.includes(g))),right:((s=a==null?void 0:a.right)!=null?s:[]).filter(g=>!(r!=null&&r.includes(g)))}})},e.getCanPin=()=>e.getLeafColumns().some(r=>{var a,o,s;return((a=r.columnDef.enablePinning)!=null?a:!0)&&((o=(s=t.options.enableColumnPinning)!=null?s:t.options.enablePinning)!=null?o:!0)}),e.getIsPinned=()=>{const n=e.getLeafColumns().map(c=>c.id),{left:r,right:a}=t.getState().columnPinning,o=n.some(c=>r==null?void 0:r.includes(c)),s=n.some(c=>a==null?void 0:a.includes(c));return o?"left":s?"right":!1},e.getPinnedIndex=()=>{var n,r;const a=e.getIsPinned();return a?(n=(r=t.getState().columnPinning)==null||(r=r[a])==null?void 0:r.indexOf(e.id))!=null?n:-1:0}},createRow:(e,t)=>{e.pin=(n,r,a)=>{const o=r?e.getLeafRows().map(d=>{let{id:p}=d;return p}):[],s=a?e.getParentRows().map(d=>{let{id:p}=d;return p}):[],c=new Set([...s,e.id,...o]);t.setRowPinning(d=>{var p,m;if(n==="bottom"){var g,v;return{top:((g=d==null?void 0:d.top)!=null?g:[]).filter(T=>!(c!=null&&c.has(T))),bottom:[...((v=d==null?void 0:d.bottom)!=null?v:[]).filter(T=>!(c!=null&&c.has(T))),...Array.from(c)]}}if(n==="top"){var D,S;return{top:[...((D=d==null?void 0:d.top)!=null?D:[]).filter(T=>!(c!=null&&c.has(T))),...Array.from(c)],bottom:((S=d==null?void 0:d.bottom)!=null?S:[]).filter(T=>!(c!=null&&c.has(T)))}}return{top:((p=d==null?void 0:d.top)!=null?p:[]).filter(T=>!(c!=null&&c.has(T))),bottom:((m=d==null?void 0:d.bottom)!=null?m:[]).filter(T=>!(c!=null&&c.has(T)))}})},e.getCanPin=()=>{var n;const{enableRowPinning:r,enablePinning:a}=t.options;return typeof r=="function"?r(e):(n=r??a)!=null?n:!0},e.getIsPinned=()=>{const n=[e.id],{top:r,bottom:a}=t.getState().rowPinning,o=n.some(c=>r==null?void 0:r.includes(c)),s=n.some(c=>a==null?void 0:a.includes(c));return o?"top":s?"bottom":!1},e.getPinnedIndex=()=>{var n,r;const a=e.getIsPinned();if(!a)return-1;const o=(n=t._getPinnedRows(a))==null?void 0:n.map(s=>{let{id:c}=s;return c});return(r=o==null?void 0:o.indexOf(e.id))!=null?r:-1},e.getCenterVisibleCells=ht(()=>[e._getAllVisibleCells(),t.getState().columnPinning.left,t.getState().columnPinning.right],(n,r,a)=>{const o=[...r??[],...a??[]];return n.filter(s=>!o.includes(s.column.id))},pt(t.options,"debugRows")),e.getLeftVisibleCells=ht(()=>[e._getAllVisibleCells(),t.getState().columnPinning.left],(n,r)=>(r??[]).map(o=>n.find(s=>s.column.id===o)).filter(Boolean).map(o=>({...o,position:"left"})),pt(t.options,"debugRows")),e.getRightVisibleCells=ht(()=>[e._getAllVisibleCells(),t.getState().columnPinning.right],(n,r)=>(r??[]).map(o=>n.find(s=>s.column.id===o)).filter(Boolean).map(o=>({...o,position:"right"})),pt(t.options,"debugRows"))},createTable:e=>{e.setColumnPinning=t=>e.options.onColumnPinningChange==null?void 0:e.options.onColumnPinningChange(t),e.resetColumnPinning=t=>{var n,r;return e.setColumnPinning(t?X0():(n=(r=e.initialState)==null?void 0:r.columnPinning)!=null?n:X0())},e.getIsSomeColumnsPinned=t=>{var n;const r=e.getState().columnPinning;if(!t){var a,o;return!!((a=r.left)!=null&&a.length||(o=r.right)!=null&&o.length)}return!!((n=r[t])!=null&&n.length)},e.getLeftLeafColumns=ht(()=>[e.getAllLeafColumns(),e.getState().columnPinning.left],(t,n)=>(n??[]).map(r=>t.find(a=>a.id===r)).filter(Boolean),pt(e.options,"debugColumns")),e.getRightLeafColumns=ht(()=>[e.getAllLeafColumns(),e.getState().columnPinning.right],(t,n)=>(n??[]).map(r=>t.find(a=>a.id===r)).filter(Boolean),pt(e.options,"debugColumns")),e.getCenterLeafColumns=ht(()=>[e.getAllLeafColumns(),e.getState().columnPinning.left,e.getState().columnPinning.right],(t,n,r)=>{const a=[...n??[],...r??[]];return t.filter(o=>!a.includes(o.id))},pt(e.options,"debugColumns")),e.setRowPinning=t=>e.options.onRowPinningChange==null?void 0:e.options.onRowPinningChange(t),e.resetRowPinning=t=>{var n,r;return e.setRowPinning(t?ew():(n=(r=e.initialState)==null?void 0:r.rowPinning)!=null?n:ew())},e.getIsSomeRowsPinned=t=>{var n;const r=e.getState().rowPinning;if(!t){var a,o;return!!((a=r.top)!=null&&a.length||(o=r.bottom)!=null&&o.length)}return!!((n=r[t])!=null&&n.length)},e._getPinnedRows=ht(t=>[e.getRowModel().rows,e.getState().rowPinning[t],t],(t,n,r)=>{var a;return((a=e.options.keepPinnedRows)==null||a?(n??[]).map(s=>{const c=e.getRow(s,!0);return c.getIsAllParentsExpanded()?c:null}):(n??[]).map(s=>t.find(c=>c.id===s))).filter(Boolean).map(s=>({...s,position:r}))},pt(e.options,"debugRows")),e.getTopRows=()=>e._getPinnedRows("top"),e.getBottomRows=()=>e._getPinnedRows("bottom"),e.getCenterRows=ht(()=>[e.getRowModel().rows,e.getState().rowPinning.top,e.getState().rowPinning.bottom],(t,n,r)=>{const a=new Set([...n??[],...r??[]]);return t.filter(o=>!a.has(o.id))},pt(e.options,"debugRows"))}},Sq={getInitialState:e=>({rowSelection:{},...e}),getDefaultOptions:e=>({onRowSelectionChange:Ua("rowSelection",e),enableRowSelection:!0,enableMultiRowSelection:!0,enableSubRowSelection:!0}),createTable:e=>{e.setRowSelection=t=>e.options.onRowSelectionChange==null?void 0:e.options.onRowSelectionChange(t),e.resetRowSelection=t=>{var n;return e.setRowSelection(t?{}:(n=e.initialState.rowSelection)!=null?n:{})},e.toggleAllRowsSelected=t=>{e.setRowSelection(n=>{t=typeof t<"u"?t:!e.getIsAllRowsSelected();const r={...n},a=e.getPreGroupedRowModel().flatRows;return t?a.forEach(o=>{o.getCanSelect()&&(r[o.id]=!0)}):a.forEach(o=>{delete r[o.id]}),r})},e.toggleAllPageRowsSelected=t=>e.setRowSelection(n=>{const r=typeof t<"u"?t:!e.getIsAllPageRowsSelected(),a={...n};return e.getRowModel().rows.forEach(o=>{qw(a,o.id,r,!0,e)}),a}),e.getPreSelectedRowModel=()=>e.getCoreRowModel(),e.getSelectedRowModel=ht(()=>[e.getState().rowSelection,e.getCoreRowModel()],(t,n)=>Object.keys(t).length?tw(e,n):{rows:[],flatRows:[],rowsById:{}},pt(e.options,"debugTable")),e.getFilteredSelectedRowModel=ht(()=>[e.getState().rowSelection,e.getFilteredRowModel()],(t,n)=>Object.keys(t).length?tw(e,n):{rows:[],flatRows:[],rowsById:{}},pt(e.options,"debugTable")),e.getGroupedSelectedRowModel=ht(()=>[e.getState().rowSelection,e.getSortedRowModel()],(t,n)=>Object.keys(t).length?tw(e,n):{rows:[],flatRows:[],rowsById:{}},pt(e.options,"debugTable")),e.getIsAllRowsSelected=()=>{const t=e.getFilteredRowModel().flatRows,{rowSelection:n}=e.getState();let r=!!(t.length&&Object.keys(n).length);return r&&t.some(a=>a.getCanSelect()&&!n[a.id])&&(r=!1),r},e.getIsAllPageRowsSelected=()=>{const t=e.getPaginationRowModel().flatRows.filter(a=>a.getCanSelect()),{rowSelection:n}=e.getState();let r=!!t.length;return r&&t.some(a=>!n[a.id])&&(r=!1),r},e.getIsSomeRowsSelected=()=>{var t;const n=Object.keys((t=e.getState().rowSelection)!=null?t:{}).length;return n>0&&n{const t=e.getPaginationRowModel().flatRows;return e.getIsAllPageRowsSelected()?!1:t.filter(n=>n.getCanSelect()).some(n=>n.getIsSelected()||n.getIsSomeSelected())},e.getToggleAllRowsSelectedHandler=()=>t=>{e.toggleAllRowsSelected(t.target.checked)},e.getToggleAllPageRowsSelectedHandler=()=>t=>{e.toggleAllPageRowsSelected(t.target.checked)}},createRow:(e,t)=>{e.toggleSelected=(n,r)=>{const a=e.getIsSelected();t.setRowSelection(o=>{var s;if(n=typeof n<"u"?n:!a,e.getCanSelect()&&a===n)return o;const c={...o};return qw(c,e.id,n,(s=r==null?void 0:r.selectChildren)!=null?s:!0,t),c})},e.getIsSelected=()=>{const{rowSelection:n}=t.getState();return db(e,n)},e.getIsSomeSelected=()=>{const{rowSelection:n}=t.getState();return Jw(e,n)==="some"},e.getIsAllSubRowsSelected=()=>{const{rowSelection:n}=t.getState();return Jw(e,n)==="all"},e.getCanSelect=()=>{var n;return typeof t.options.enableRowSelection=="function"?t.options.enableRowSelection(e):(n=t.options.enableRowSelection)!=null?n:!0},e.getCanSelectSubRows=()=>{var n;return typeof t.options.enableSubRowSelection=="function"?t.options.enableSubRowSelection(e):(n=t.options.enableSubRowSelection)!=null?n:!0},e.getCanMultiSelect=()=>{var n;return typeof t.options.enableMultiRowSelection=="function"?t.options.enableMultiRowSelection(e):(n=t.options.enableMultiRowSelection)!=null?n:!0},e.getToggleSelectedHandler=()=>{const n=e.getCanSelect();return r=>{var a;n&&e.toggleSelected((a=r.target)==null?void 0:a.checked)}}}},qw=(e,t,n,r,a)=>{var o;const s=a.getRow(t,!0);n?(s.getCanMultiSelect()||Object.keys(e).forEach(c=>delete e[c]),s.getCanSelect()&&(e[t]=!0)):delete e[t],r&&(o=s.subRows)!=null&&o.length&&s.getCanSelectSubRows()&&s.subRows.forEach(c=>qw(e,c.id,n,r,a))};function tw(e,t){const n=e.getState().rowSelection,r=[],a={},o=function(s,c){return s.map(d=>{var p;const m=db(d,n);if(m&&(r.push(d),a[d.id]=d),(p=d.subRows)!=null&&p.length&&(d={...d,subRows:o(d.subRows)}),m)return d}).filter(Boolean)};return{rows:o(t.rows),flatRows:r,rowsById:a}}function db(e,t){var n;return(n=t[e.id])!=null?n:!1}function Jw(e,t,n){var r;if(!((r=e.subRows)!=null&&r.length))return!1;let a=!0,o=!1;return e.subRows.forEach(s=>{if(!(o&&!a)&&(s.getCanSelect()&&(db(s,t)?o=!0:a=!1),s.subRows&&s.subRows.length)){const c=Jw(s,t);c==="all"?o=!0:(c==="some"&&(o=!0),a=!1)}}),a?"all":o?"some":!1}const Kw=/([0-9]+)/gm,Iq=(e,t,n)=>sx(Sl(e.getValue(n)).toLowerCase(),Sl(t.getValue(n)).toLowerCase()),Tq=(e,t,n)=>sx(Sl(e.getValue(n)),Sl(t.getValue(n))),Eq=(e,t,n)=>fb(Sl(e.getValue(n)).toLowerCase(),Sl(t.getValue(n)).toLowerCase()),Cq=(e,t,n)=>fb(Sl(e.getValue(n)),Sl(t.getValue(n))),xq=(e,t,n)=>{const r=e.getValue(n),a=t.getValue(n);return r>a?1:rfb(e.getValue(n),t.getValue(n));function fb(e,t){return e===t?0:e>t?1:-1}function Sl(e){return typeof e=="number"?isNaN(e)||e===1/0||e===-1/0?"":String(e):typeof e=="string"?e:""}function sx(e,t){const n=e.split(Kw).filter(Boolean),r=t.split(Kw).filter(Boolean);for(;n.length&&r.length;){const a=n.shift(),o=r.shift(),s=parseInt(a,10),c=parseInt(o,10),d=[s,c].sort();if(isNaN(d[0])){if(a>o)return 1;if(o>a)return-1;continue}if(isNaN(d[1]))return isNaN(s)?-1:1;if(s>c)return 1;if(c>s)return-1}return n.length-r.length}const Id={alphanumeric:Iq,alphanumericCaseSensitive:Tq,text:Eq,textCaseSensitive:Cq,datetime:xq,basic:Mq},Nq={getInitialState:e=>({sorting:[],...e}),getDefaultColumnDef:()=>({sortingFn:"auto",sortUndefined:1}),getDefaultOptions:e=>({onSortingChange:Ua("sorting",e),isMultiSortEvent:t=>t.shiftKey}),createColumn:(e,t)=>{e.getAutoSortingFn=()=>{const n=t.getFilteredRowModel().flatRows.slice(10);let r=!1;for(const a of n){const o=a==null?void 0:a.getValue(e.id);if(Object.prototype.toString.call(o)==="[object Date]")return Id.datetime;if(typeof o=="string"&&(r=!0,o.split(Kw).length>1))return Id.alphanumeric}return r?Id.text:Id.basic},e.getAutoSortDir=()=>{const n=t.getFilteredRowModel().flatRows[0];return typeof(n==null?void 0:n.getValue(e.id))=="string"?"asc":"desc"},e.getSortingFn=()=>{var n,r;if(!e)throw new Error;return My(e.columnDef.sortingFn)?e.columnDef.sortingFn:e.columnDef.sortingFn==="auto"?e.getAutoSortingFn():(n=(r=t.options.sortingFns)==null?void 0:r[e.columnDef.sortingFn])!=null?n:Id[e.columnDef.sortingFn]},e.toggleSorting=(n,r)=>{const a=e.getNextSortingOrder(),o=typeof n<"u"&&n!==null;t.setSorting(s=>{const c=s==null?void 0:s.find(D=>D.id===e.id),d=s==null?void 0:s.findIndex(D=>D.id===e.id);let p=[],m,g=o?n:a==="desc";if(s!=null&&s.length&&e.getCanMultiSort()&&r?c?m="toggle":m="add":s!=null&&s.length&&d!==s.length-1?m="replace":c?m="toggle":m="replace",m==="toggle"&&(o||a||(m="remove")),m==="add"){var v;p=[...s,{id:e.id,desc:g}],p.splice(0,p.length-((v=t.options.maxMultiSortColCount)!=null?v:Number.MAX_SAFE_INTEGER))}else m==="toggle"?p=s.map(D=>D.id===e.id?{...D,desc:g}:D):m==="remove"?p=s.filter(D=>D.id!==e.id):p=[{id:e.id,desc:g}];return p})},e.getFirstSortDir=()=>{var n,r;return((n=(r=e.columnDef.sortDescFirst)!=null?r:t.options.sortDescFirst)!=null?n:e.getAutoSortDir()==="desc")?"desc":"asc"},e.getNextSortingOrder=n=>{var r,a;const o=e.getFirstSortDir(),s=e.getIsSorted();return s?s!==o&&((r=t.options.enableSortingRemoval)==null||r)&&(!(n&&(a=t.options.enableMultiRemove)!=null)||a)?!1:s==="desc"?"asc":"desc":o},e.getCanSort=()=>{var n,r;return((n=e.columnDef.enableSorting)!=null?n:!0)&&((r=t.options.enableSorting)!=null?r:!0)&&!!e.accessorFn},e.getCanMultiSort=()=>{var n,r;return(n=(r=e.columnDef.enableMultiSort)!=null?r:t.options.enableMultiSort)!=null?n:!!e.accessorFn},e.getIsSorted=()=>{var n;const r=(n=t.getState().sorting)==null?void 0:n.find(a=>a.id===e.id);return r?r.desc?"desc":"asc":!1},e.getSortIndex=()=>{var n,r;return(n=(r=t.getState().sorting)==null?void 0:r.findIndex(a=>a.id===e.id))!=null?n:-1},e.clearSorting=()=>{t.setSorting(n=>n!=null&&n.length?n.filter(r=>r.id!==e.id):[])},e.getToggleSortingHandler=()=>{const n=e.getCanSort();return r=>{n&&(r.persist==null||r.persist(),e.toggleSorting==null||e.toggleSorting(void 0,e.getCanMultiSort()?t.options.isMultiSortEvent==null?void 0:t.options.isMultiSortEvent(r):!1))}}},createTable:e=>{e.setSorting=t=>e.options.onSortingChange==null?void 0:e.options.onSortingChange(t),e.resetSorting=t=>{var n,r;e.setSorting(t?[]:(n=(r=e.initialState)==null?void 0:r.sorting)!=null?n:[])},e.getPreSortedRowModel=()=>e.getGroupedRowModel(),e.getSortedRowModel=()=>(!e._getSortedRowModel&&e.options.getSortedRowModel&&(e._getSortedRowModel=e.options.getSortedRowModel(e)),e.options.manualSorting||!e._getSortedRowModel?e.getPreSortedRowModel():e._getSortedRowModel())}},kq={getInitialState:e=>({columnVisibility:{},...e}),getDefaultOptions:e=>({onColumnVisibilityChange:Ua("columnVisibility",e)}),createColumn:(e,t)=>{e.toggleVisibility=n=>{e.getCanHide()&&t.setColumnVisibility(r=>({...r,[e.id]:n??!e.getIsVisible()}))},e.getIsVisible=()=>{var n,r;const a=e.columns;return(n=a.length?a.some(o=>o.getIsVisible()):(r=t.getState().columnVisibility)==null?void 0:r[e.id])!=null?n:!0},e.getCanHide=()=>{var n,r;return((n=e.columnDef.enableHiding)!=null?n:!0)&&((r=t.options.enableHiding)!=null?r:!0)},e.getToggleVisibilityHandler=()=>n=>{e.toggleVisibility==null||e.toggleVisibility(n.target.checked)}},createRow:(e,t)=>{e._getAllVisibleCells=ht(()=>[e.getAllCells(),t.getState().columnVisibility],n=>n.filter(r=>r.column.getIsVisible()),pt(t.options,"debugRows")),e.getVisibleCells=ht(()=>[e.getLeftVisibleCells(),e.getCenterVisibleCells(),e.getRightVisibleCells()],(n,r,a)=>[...n,...r,...a],pt(t.options,"debugRows"))},createTable:e=>{const t=(n,r)=>ht(()=>[r(),r().filter(a=>a.getIsVisible()).map(a=>a.id).join("_")],a=>a.filter(o=>o.getIsVisible==null?void 0:o.getIsVisible()),pt(e.options,"debugColumns"));e.getVisibleFlatColumns=t("getVisibleFlatColumns",()=>e.getAllFlatColumns()),e.getVisibleLeafColumns=t("getVisibleLeafColumns",()=>e.getAllLeafColumns()),e.getLeftVisibleLeafColumns=t("getLeftVisibleLeafColumns",()=>e.getLeftLeafColumns()),e.getRightVisibleLeafColumns=t("getRightVisibleLeafColumns",()=>e.getRightLeafColumns()),e.getCenterVisibleLeafColumns=t("getCenterVisibleLeafColumns",()=>e.getCenterLeafColumns()),e.setColumnVisibility=n=>e.options.onColumnVisibilityChange==null?void 0:e.options.onColumnVisibilityChange(n),e.resetColumnVisibility=n=>{var r;e.setColumnVisibility(n?{}:(r=e.initialState.columnVisibility)!=null?r:{})},e.toggleAllColumnsVisible=n=>{var r;n=(r=n)!=null?r:!e.getIsAllColumnsVisible(),e.setColumnVisibility(e.getAllLeafColumns().reduce((a,o)=>({...a,[o.id]:n||!(o.getCanHide!=null&&o.getCanHide())}),{}))},e.getIsAllColumnsVisible=()=>!e.getAllLeafColumns().some(n=>!(n.getIsVisible!=null&&n.getIsVisible())),e.getIsSomeColumnsVisible=()=>e.getAllLeafColumns().some(n=>n.getIsVisible==null?void 0:n.getIsVisible()),e.getToggleAllColumnsVisibilityHandler=()=>n=>{var r;e.toggleAllColumnsVisible((r=n.target)==null?void 0:r.checked)}}};function Qh(e,t){return t?t==="center"?e.getCenterVisibleLeafColumns():t==="left"?e.getLeftVisibleLeafColumns():e.getRightVisibleLeafColumns():e.getVisibleLeafColumns()}const T2=[rq,kq,wq,Dq,sq,Nq,yq,iq,bq,Sq,aq];function Aq(e){var t;e.debugAll||e.debugTable;let n={_features:T2};const r=n._features.reduce((m,g)=>Object.assign(m,g.getDefaultOptions==null?void 0:g.getDefaultOptions(n)),{}),a=m=>n.options.mergeOptions?n.options.mergeOptions(r,m):{...r,...m};let s={...{},...(t=e.initialState)!=null?t:{}};n._features.forEach(m=>{var g;s=(g=m.getInitialState==null?void 0:m.getInitialState(s))!=null?g:s});const c=[];let d=!1;const p={_features:T2,options:{...r,...e},initialState:s,_queue:m=>{c.push(m),d||(d=!0,Promise.resolve().then(()=>{for(;c.length;)c.shift()();d=!1}).catch(g=>setTimeout(()=>{throw g})))},reset:()=>{n.setState(n.initialState)},setOptions:m=>{const g=vl(m,n.options);n.options=a(g)},getState:()=>n.options.state,setState:m=>{n.options.onStateChange==null||n.options.onStateChange(m)},_getRowId:(m,g,v)=>{var D;return(D=n.options.getRowId==null?void 0:n.options.getRowId(m,g,v))!=null?D:`${v?[v.id,g].join("."):g}`},getCoreRowModel:()=>(n._getCoreRowModel||(n._getCoreRowModel=n.options.getCoreRowModel(n)),n._getCoreRowModel()),getRowModel:()=>n.getPaginationRowModel(),getRow:(m,g)=>{let v=(g?n.getPrePaginationRowModel():n.getRowModel()).rowsById[m];if(!v&&(v=n.getCoreRowModel().rowsById[m],!v))throw new Error;return v},_getDefaultColumnDef:ht(()=>[n.options.defaultColumn],m=>{var g;return m=(g=m)!=null?g:{},{header:v=>{const D=v.header.column.columnDef;return D.accessorKey?D.accessorKey:D.accessorFn?D.id:null},cell:v=>{var D,S;return(D=(S=v.renderValue())==null||S.toString==null?void 0:S.toString())!=null?D:null},...n._features.reduce((v,D)=>Object.assign(v,D.getDefaultColumnDef==null?void 0:D.getDefaultColumnDef()),{}),...m}},pt(e,"debugColumns")),_getColumnDefs:()=>n.options.columns,getAllColumns:ht(()=>[n._getColumnDefs()],m=>{const g=function(v,D,S){return S===void 0&&(S=0),v.map(T=>{const E=nq(n,T,S,D),O=T;return E.columns=O.columns?g(O.columns,E,S+1):[],E})};return g(m)},pt(e,"debugColumns")),getAllFlatColumns:ht(()=>[n.getAllColumns()],m=>m.flatMap(g=>g.getFlatColumns()),pt(e,"debugColumns")),_getAllFlatColumnsById:ht(()=>[n.getAllFlatColumns()],m=>m.reduce((g,v)=>(g[v.id]=v,g),{}),pt(e,"debugColumns")),getAllLeafColumns:ht(()=>[n.getAllColumns(),n._getOrderColumnsFn()],(m,g)=>{let v=m.flatMap(D=>D.getLeafColumns());return g(v)},pt(e,"debugColumns")),getColumn:m=>n._getAllFlatColumnsById()[m]};Object.assign(n,p);for(let m=0;m{var s;return(s=o.getValue())!=null?s:e.options.renderFallbackValue},o={id:`${t.id}_${n.id}`,row:t,column:n,getValue:()=>t.getValue(r),renderValue:a,getContext:ht(()=>[e,n,t,o],(s,c,d,p)=>({table:s,column:c,row:d,cell:p,getValue:p.getValue,renderValue:p.renderValue}),pt(e.options,"debugCells"))};return e._features.forEach(s=>{s.createCell==null||s.createCell(o,n,t,e)},{}),o}const hb=(e,t,n,r,a,o,s)=>{let c={id:t,index:r,original:n,depth:a,parentId:s,_valuesCache:{},_uniqueValuesCache:{},getValue:d=>{if(c._valuesCache.hasOwnProperty(d))return c._valuesCache[d];const p=e.getColumn(d);if(p!=null&&p.accessorFn)return c._valuesCache[d]=p.accessorFn(c.original,r),c._valuesCache[d]},getUniqueValues:d=>{if(c._uniqueValuesCache.hasOwnProperty(d))return c._uniqueValuesCache[d];const p=e.getColumn(d);if(p!=null&&p.accessorFn)return p.columnDef.getUniqueValues?(c._uniqueValuesCache[d]=p.columnDef.getUniqueValues(c.original,r),c._uniqueValuesCache[d]):(c._uniqueValuesCache[d]=[c.getValue(d)],c._uniqueValuesCache[d])},renderValue:d=>{var p;return(p=c.getValue(d))!=null?p:e.options.renderFallbackValue},subRows:o??[],getLeafRows:()=>tq(c.subRows,d=>d.subRows),getParentRow:()=>c.parentId?e.getRow(c.parentId,!0):void 0,getParentRows:()=>{let d=[],p=c;for(;;){const m=p.getParentRow();if(!m)break;d.push(m),p=m}return d.reverse()},getAllCells:ht(()=>[e.getAllLeafColumns()],d=>d.map(p=>Fq(e,c,p,p.id)),pt(e.options,"debugRows")),_getAllCellsByColumnId:ht(()=>[c.getAllCells()],d=>d.reduce((p,m)=>(p[m.column.id]=m,p),{}),pt(e.options,"debugRows"))};for(let d=0;dht(()=>[e.options.data],t=>{const n={rows:[],flatRows:[],rowsById:{}},r=function(a,o,s){o===void 0&&(o=0);const c=[];for(let p=0;pe._autoResetPageIndex()))}function lx(e,t,n){return n.options.filterFromLeafRows?Pq(e,t,n):jq(e,t,n)}function Pq(e,t,n){var r;const a=[],o={},s=(r=n.options.maxLeafRowFilterDepth)!=null?r:100,c=function(d,p){p===void 0&&(p=0);const m=[];for(let v=0;vht(()=>[e.getPreFilteredRowModel(),e.getState().columnFilters,e.getState().globalFilter],(t,n,r)=>{if(!t.rows.length||!(n!=null&&n.length)&&!r){for(let v=0;v{var D;const S=e.getColumn(v.id);if(!S)return;const T=S.getFilterFn();T&&a.push({id:v.id,filterFn:T,resolvedValue:(D=T.resolveFilterValue==null?void 0:T.resolveFilterValue(v.value))!=null?D:v.value})});const s=n.map(v=>v.id),c=e.getGlobalFilterFn(),d=e.getAllLeafColumns().filter(v=>v.getCanGlobalFilter());r&&c&&d.length&&(s.push("__global__"),d.forEach(v=>{var D;o.push({id:v.id,filterFn:c,resolvedValue:(D=c.resolveFilterValue==null?void 0:c.resolveFilterValue(r))!=null?D:r})}));let p,m;for(let v=0;v{D.columnFiltersMeta[T]=E})}if(o.length){for(let S=0;S{D.columnFiltersMeta[T]=E})){D.columnFilters.__global__=!0;break}}D.columnFilters.__global__!==!0&&(D.columnFilters.__global__=!1)}}const g=v=>{for(let D=0;De._autoResetPageIndex()))}function Rq(){return(e,t)=>ht(()=>[e.getPreFilteredRowModel(),e.getState().columnFilters,e.getState().globalFilter,e.getFilteredRowModel()],(n,r,a)=>{if(!n.rows.length||!(r!=null&&r.length)&&!a)return n;const o=[...r.map(c=>c.id).filter(c=>c!==t),a?"__global__":void 0].filter(Boolean),s=c=>{for(let d=0;dht(()=>{var n;return[(n=e.getColumn(t))==null?void 0:n.getFacetedRowModel()]},n=>{if(!n)return new Map;let r=new Map;for(let o=0;oht(()=>{var n;return[(n=e.getColumn(t))==null?void 0:n.getFacetedRowModel()]},n=>{var r;if(!n)return;const a=(r=n.flatRows[0])==null?void 0:r.getUniqueValues(t);if(typeof a>"u")return;let o=[a,a];for(let s=0;so[1]&&(o[1]=p)}}return o},pt(e.options,"debugTable"))}function Hq(){return e=>ht(()=>[e.getState().sorting,e.getPreSortedRowModel()],(t,n)=>{if(!n.rows.length||!(t!=null&&t.length))return n;const r=e.getState().sorting,a=[],o=r.filter(d=>{var p;return(p=e.getColumn(d.id))==null?void 0:p.getCanSort()}),s={};o.forEach(d=>{const p=e.getColumn(d.id);p&&(s[d.id]={sortUndefined:p.columnDef.sortUndefined,invertSorting:p.columnDef.invertSorting,sortingFn:p.getSortingFn()})});const c=d=>{const p=d.map(m=>({...m}));return p.sort((m,g)=>{for(let D=0;D{var g;a.push(m),(g=m.subRows)!=null&&g.length&&(m.subRows=c(m.subRows))}),p};return{rows:c(n.rows),flatRows:a,rowsById:n.rowsById}},pt(e.options,"debugTable","getSortedRowModel",()=>e._autoResetPageIndex()))}function Yq(e){const t=[],n=r=>{var a;t.push(r),(a=r.subRows)!=null&&a.length&&r.getIsExpanded()&&r.subRows.forEach(n)};return e.rows.forEach(n),{rows:t,flatRows:e.flatRows,rowsById:e.rowsById}}function zq(e){return t=>ht(()=>[t.getState().pagination,t.getPrePaginationRowModel(),t.options.paginateExpandedRows?void 0:t.getState().expanded],(n,r)=>{if(!r.rows.length)return r;const{pageSize:a,pageIndex:o}=n;let{rows:s,flatRows:c,rowsById:d}=r;const p=a*o,m=p+a;s=s.slice(p,m);let g;t.options.paginateExpandedRows?g={rows:s,flatRows:c,rowsById:d}:g=Yq({rows:s,flatRows:c,rowsById:d}),g.flatRows=[];const v=D=>{g.flatRows.push(D),D.subRows.length&&D.subRows.forEach(v)};return g.rows.forEach(v),g},pt(t.options,"debugTable"))}function E2(e,t){return e?Uq(e)?A.createElement(e,t):e:null}function Uq(e){return Vq(e)||typeof e=="function"||Zq(e)}function Vq(e){return typeof e=="function"&&(()=>{const t=Object.getPrototypeOf(e);return t.prototype&&t.prototype.isReactComponent})()}function Zq(e){return typeof e=="object"&&typeof e.$$typeof=="symbol"&&["react.memo","react.forward_ref"].includes(e.$$typeof.description)}function Wq(e){const t={state:{},onStateChange:()=>{},renderFallbackValue:null,...e},[n]=A.useState(()=>({current:Aq(t)})),[r,a]=A.useState(()=>n.current.initialState);return n.current.setOptions(o=>({...o,...e,state:{...r,...e.state},onStateChange:s=>{a(s),e.onStateChange==null||e.onStateChange(s)}})),n.current}const ux={À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",Ấ:"A",Ắ:"A",Ẳ:"A",Ẵ:"A",Ặ:"A",Æ:"AE",Ầ:"A",Ằ:"A",Ȃ:"A",Ç:"C",Ḉ:"C",È:"E",É:"E",Ê:"E",Ë:"E",Ế:"E",Ḗ:"E",Ề:"E",Ḕ:"E",Ḝ:"E",Ȇ:"E",Ì:"I",Í:"I",Î:"I",Ï:"I",Ḯ:"I",Ȋ:"I",Ð:"D",Ñ:"N",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",Ố:"O",Ṍ:"O",Ṓ:"O",Ȏ:"O",Ù:"U",Ú:"U",Û:"U",Ü:"U",Ý:"Y",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",ấ:"a",ắ:"a",ẳ:"a",ẵ:"a",ặ:"a",æ:"ae",ầ:"a",ằ:"a",ȃ:"a",ç:"c",ḉ:"c",è:"e",é:"e",ê:"e",ë:"e",ế:"e",ḗ:"e",ề:"e",ḕ:"e",ḝ:"e",ȇ:"e",ì:"i",í:"i",î:"i",ï:"i",ḯ:"i",ȋ:"i",ð:"d",ñ:"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",Q̌:"Q",q̌:"q",Ř̩:"R",ř̩:"r",Ṧ:"S",ṧ:"s",V̌:"V",v̌:"v",W̌:"W",w̌:"w",X̌:"X",x̌:"x",Y̌:"Y",y̌:"y",A̧:"A",a̧:"a",B̧:"B",b̧:"b",Ḑ:"D",ḑ:"d",Ȩ:"E",ȩ:"e",Ɛ̧:"E",ɛ̧:"e",Ḩ:"H",ḩ:"h",I̧:"I",i̧:"i",Ɨ̧:"I",ɨ̧:"i",M̧:"M",m̧:"m",O̧:"O",o̧:"o",Q̧:"Q",q̧:"q",U̧:"U",u̧:"u",X̧:"X",x̧:"x",Z̧:"Z",z̧:"z"},$q=Object.keys(ux).join("|"),Gq=new RegExp($q,"g");function qq(e){return e.replace(Gq,t=>ux[t])}const va={CASE_SENSITIVE_EQUAL:7,EQUAL:6,STARTS_WITH:5,WORD_STARTS_WITH:4,CONTAINS:3,ACRONYM:2,MATCHES:1,NO_MATCH:0};function Jq(e,t,n){var r;if(n=n||{},n.threshold=(r=n.threshold)!=null?r:va.MATCHES,!n.accessors){const s=C2(e,t,n);return{rankedValue:e,rank:s,accessorIndex:-1,accessorThreshold:n.threshold,passed:s>=n.threshold}}const a=tJ(e,n.accessors),o={rankedValue:e,rank:va.NO_MATCH,accessorIndex:-1,accessorThreshold:n.threshold,passed:!1};for(let s=0;s=va.MATCHES?d=p:d>m&&(d=m),d=Math.min(d,m),d>=g&&d>o.rank&&(o.rank=d,o.passed=!0,o.accessorIndex=s,o.accessorThreshold=g,o.rankedValue=c.itemValue)}return o}function C2(e,t,n){return e=x2(e,n),t=x2(t,n),t.length>e.length?va.NO_MATCH:e===t?va.CASE_SENSITIVE_EQUAL:(e=e.toLowerCase(),t=t.toLowerCase(),e===t?va.EQUAL:e.startsWith(t)?va.STARTS_WITH:e.includes(` ${t}`)?va.WORD_STARTS_WITH:e.includes(t)?va.CONTAINS:t.length===1?va.NO_MATCH:Kq(e).includes(t)?va.ACRONYM:Qq(e,t))}function Kq(e){let t="";return e.split(" ").forEach(r=>{r.split("-").forEach(o=>{t+=o.substr(0,1)})}),t}function Qq(e,t){let n=0,r=0;function a(d,p,m){for(let g=m,v=p.length;g-1))return va.NO_MATCH}const c=r-s;return o(c)}function Xq(e,t){return e.rank===t.rank?0:e.rank>t.rank?-1:1}function x2(e,t){let{keepDiacritics:n}=t;return e=`${e}`,n||(e=qq(e)),e}function eJ(e,t){let n=t;typeof t=="object"&&(n=t.accessor);const r=n(e);return r==null?[]:Array.isArray(r)?r:[String(r)]}function tJ(e,t){const n=[];for(let r=0,a=t.length;r{const t=A.useRef(null);A.useEffect(()=>(t.current&&C.setIcon(t.current,"pin"),()=>{t.current&&(t.current=null)}),[t]);const n=A.useCallback(async()=>{e.pinned?await Te.unpinMemoById(e.id):await Te.pinMemoById(e.id)},[e]);return w.jsx("span",{ref:t,className:Xn("pinned-status",e.pinned?"pinned":"not-pinned"),onClick:n})},aJ=({thino:e})=>{const t=A.useRef(null);A.useEffect(()=>(t.current&&C.setIcon(t.current,e.thinoType==="JOURNAL"?"calendar":"check-square"),()=>{t.current&&(t.current=null)}),[t,e==null?void 0:e.thinoType]);const n=A.useCallback(async()=>{if(e.thinoType==="JOURNAL")return;const r=await Te.updateMemo(e.id,e.content,e.thinoType==="TASK-TODO"?"TASK-DONE":"TASK-TODO");r&&Te.editMemo(r)},[e]);return w.jsx(w.Fragment,{children:e.thinoType!=="JOURNAL"?w.jsx("input",{className:Xn("thino-type-status","task-list-item-checkbox"),type:"checkbox",checked:e.thinoType!=="TASK-TODO","data-task":e.thinoType==="TASK-TODO"?"":e.thinoType==="TASK-DONE"?"x":e.thinoType.slice(5),onClick:n}):w.jsx("span",{ref:t,className:"thino-type-status"})})},oJ=({id:e,path:t})=>{const n=A.useRef(null);A.useEffect(()=>(n.current&&C.setIcon(n.current,"link"),()=>{n.current&&(n.current=null)}),[]);const r=A.useCallback(()=>{!e||!t||Te.openThinoByID(e)},[e,t]);return w.jsxs("span",{className:"source-thino",onClick:r,children:[w.jsx("span",{children:t}),w.jsx("span",{ref:n,className:"source-thino-icon"})]})},iJ=({id:e,sourceType:t})=>{const n=A.useRef(null);A.useEffect(()=>{var a;return n.current&&C.setIcon(n.current,((a=tp.find(o=>o.title===t))==null?void 0:a.icon)||"list"),()=>{n.current&&(n.current=null)}},[]);const r=A.useCallback(async()=>{e&&await Te.openThinoByID(e)},[e]);return w.jsx("span",{ref:n,className:"source-type-icon",onClick:r})},N2=(e,t,n,r)=>{const a=Jq(e.getValue(t),n);return r({itemRank:a}),a.passed},k2=(e,t,n)=>{var a,o;let r=0;return e.columnFiltersMeta[n]&&(r=Xq((a=e.columnFiltersMeta[n])==null?void 0:a.itemRank,(o=t.columnFiltersMeta[n])==null?void 0:o.itemRank)),r===0?Id.alphanumeric(e,t,n):r};function sJ({thinos:e}){var m;$.useReducer(()=>({}),{})[1];const[t,n]=$.useState([]),[r,a]=$.useState(""),o=$.useMemo(()=>[{header:N("Basic Info"),footer:g=>g.column.id,columns:[{accessorKey:"createdAt",header:()=>w.jsx("span",{className:"create-at-header-cell",children:N("Created At")}),cell:g=>g.getValue(),footer:g=>g.column.id,enableColumnFilter:!1},{accessorFn:g=>g.content,id:"content",header:()=>w.jsx("span",{className:"thino-header-cell",children:N("Thino")}),cell:g=>w.jsx(Sa,{memo:g.row.original,type:"table"}),footer:g=>g.column.id,filterFn:"fuzzy",sortingFn:k2},{accessorFn:g=>g.thinoType,id:"thinoType",cell:g=>w.jsx(aJ,{thino:g.row.original}),header:()=>w.jsx("span",{children:N("Thino Type")}),footer:g=>g.column.id},{accessorFn:g=>g.sourceType,id:"sourceType",cell:g=>w.jsx(iJ,{id:g.row.original.id,sourceType:g.getValue()}),header:()=>w.jsx("span",{children:N("Source Type")}),footer:g=>g.column.id}]},{header:N("Additional Info"),footer:g=>g.column.id,columns:[{accessorKey:"pinned",header:()=>w.jsx("span",{children:N("Pinned Status")}),cell:g=>w.jsx(rJ,{thino:g.row.original}),footer:g=>g.column.id,filterFn:"fuzzy",sortingFn:k2},{accessorKey:"rowStatus",header:()=>w.jsx("span",{children:N("Row status")}),cell:g=>w.jsx("span",{children:g.getValue()==="NORMAL"?"":g.getValue()}),footer:g=>g.column.id},{accessorKey:"path",header:()=>N("Path"),cell:g=>w.jsx(oJ,{id:g.row.original.id,path:g.getValue()}),footer:g=>g.column.id}]}],[]),[s,c]=$.useState(()=>e),d=()=>c(g=>e);A.useEffect(()=>{d()},[e]);const p=Wq({data:s,columns:o,filterFns:{fuzzy:N2},initialState:{pagination:{pageSize:20}},state:{columnFilters:t,globalFilter:r},onColumnFiltersChange:n,onGlobalFilterChange:a,globalFilterFn:N2,getCoreRowModel:Oq(),getFilteredRowModel:Lq(),getSortedRowModel:Hq(),getPaginationRowModel:zq(),getFacetedRowModel:Rq(),getFacetedUniqueValues:Bq(),getFacetedMinMaxValues:_q(),debugTable:!1,debugHeaders:!1,debugColumns:!1});return $.useEffect(()=>{var g,v;((g=p.getState().columnFilters[0])==null?void 0:g.id)==="createdAt"&&((v=p.getState().sorting[0])==null?void 0:v.id)!=="createdAt"&&p.setSorting([{id:"createdAt",desc:!1}])},[(m=p.getState().columnFilters[0])==null?void 0:m.id]),w.jsxs("div",{className:"table-view",children:[w.jsx("div",{children:w.jsx(ry,{value:r||"",onChange:g=>a(String(g)),className:"table-search-bar",placeholder:N("Search all columns...")})}),w.jsxs("table",{className:"thino-table",children:[w.jsx("thead",{children:p.getHeaderGroups().map(g=>w.jsx("tr",{children:g.headers.map(v=>w.jsx("th",{colSpan:v.colSpan,children:v.isPlaceholder?null:w.jsxs(w.Fragment,{children:[w.jsxs("div",{className:Xn(v.column.getCanSort()?"filter-header":"","table-header",v.column.id==="content"?"content-header":""),onClick:v.column.getToggleSortingHandler(),children:[E2(v.column.columnDef.header,v.getContext()),{asc:" 🔼",desc:" 🔽"}[v.column.getIsSorted()]??null]}),v.column.getCanFilter()?w.jsx(uJ,{column:v.column,table:p}):null]})},v.id))},g.id))}),w.jsx("tbody",{children:p.getRowModel().rows.map(g=>w.jsx("tr",{className:Xn(g.getValue("pinned")?"pinned":""),children:g.getVisibleCells().map(v=>w.jsx("td",{children:E2(v.column.columnDef.cell,v.getContext())},v.id))},g.id))})]}),w.jsxs("div",{className:"table-nav-bar",children:[w.jsx("button",{className:"prev-start-btn",onClick:()=>p.setPageIndex(0),disabled:!p.getCanPreviousPage(),children:"<<"}),w.jsx("button",{className:"prev-btn",onClick:()=>p.previousPage(),disabled:!p.getCanPreviousPage(),children:"<"}),w.jsx("button",{className:"next-btn",onClick:()=>p.nextPage(),disabled:!p.getCanNextPage(),children:">"}),w.jsx("button",{className:"next-end-btn",onClick:()=>p.setPageIndex(p.getPageCount()-1),disabled:!p.getCanNextPage(),children:">>"}),w.jsxs("span",{className:"table-page-info",children:[w.jsx("div",{children:N("Page")}),w.jsxs("strong",{children:[p.getState().pagination.pageIndex+1," of ",p.getPageCount()]})]}),w.jsxs("span",{className:"table-page-jump",children:["| ",N("Go to page"),":",w.jsx("input",{type:"number",defaultValue:p.getState().pagination.pageIndex+1,onChange:g=>{const v=g.target.value?Number(g.target.value)-1:0;p.setPageIndex(v)},className:"jump-inputer"})]}),w.jsx("select",{value:p.getState().pagination.pageSize,onChange:g=>{p.setPageSize(Number(g.target.value))},children:[10,20,30,40,50].map(g=>w.jsxs("option",{value:g,children:[N("Show")," ",g," ",N("rows")]},g))})]})]})}const lJ=e=>e==="sourceType"?["ALL"]:["ALL","ALL-TASK"];function uJ({column:e,table:t}){var o,s,c,d,p,m,g,v,D;const n=(o=t.getPreFilteredRowModel().flatRows[0])==null?void 0:o.getValue(e.id),r=e.getFilterValue(),a=$.useMemo(()=>typeof n=="number"?[]:Array.from(e.getFacetedUniqueValues().keys()).sort(),[e.getFacetedUniqueValues()]);return typeof n=="number"?w.jsx("div",{children:w.jsxs("div",{className:"filter-input-group",children:[w.jsx(ry,{type:"number",min:Number(((s=e.getFacetedMinMaxValues())==null?void 0:s[0])??""),max:Number(((c=e.getFacetedMinMaxValues())==null?void 0:c[1])??""),value:(r==null?void 0:r[0])??"",onChange:S=>e.setFilterValue(T=>[S,T==null?void 0:T[1]]),placeholder:`Min ${(d=e.getFacetedMinMaxValues())!=null&&d[0]?`(${(p=e.getFacetedMinMaxValues())==null?void 0:p[0]})`:""}`,className:"filter-input-short"}),w.jsx(ry,{type:"number",min:Number(((m=e.getFacetedMinMaxValues())==null?void 0:m[0])??""),max:Number(((g=e.getFacetedMinMaxValues())==null?void 0:g[1])??""),value:(r==null?void 0:r[1])??"",onChange:S=>e.setFilterValue(T=>[T==null?void 0:T[0],S]),placeholder:`Max ${(v=e.getFacetedMinMaxValues())!=null&&v[1]?`(${(D=e.getFacetedMinMaxValues())==null?void 0:D[1]})`:""}`,className:"filter-input-short"})]})}):w.jsx(w.Fragment,{children:a.length>1?w.jsxs(w.Fragment,{children:[e.id!=="path"&&e.id!=="content"&&e.id!=="thinoType"&&e.id!=="sourceType"&&w.jsx("datalist",{id:e.id+"list",children:a.slice(0,5e3).map(S=>w.jsx("option",{value:S},S))}),e.id==="thinoType"||e.id==="sourceType"?w.jsx("select",{id:e.id,onChange:S=>e.setFilterValue(S.target.value==="ALL"?"":S.target.value==="ALL-TASK"?"TASK":S.target.value),children:[...lJ(e.id),...a].map(S=>w.jsx("option",{value:S,children:N(S)||S},S))}):"",e.id!=="thinoType"&&e.id!=="sourceType"?w.jsx(ry,{type:"text",value:r??"",onChange:S=>e.setFilterValue(S),placeholder:`Search... (${e.getFacetedUniqueValues().size})`,className:"filter-input-long",list:e.id+"list"}):""]}):""})}function ry({value:e,onChange:t,debounce:n=500,...r}){const[a,o]=$.useState(e);return $.useEffect(()=>{o(e)},[e]),$.useEffect(()=>{const s=setTimeout(()=>{t(a)},n);return()=>clearTimeout(s)},[a]),w.jsx("input",{...r,value:a,onChange:s=>o(s.target.value)})}const cJ=e=>{const{locationState:{query:t},globalState:{memoListView:n,manifest:r},dailyNotesState:{app:a,settings:o}}=A.useContext(mt),{thinos:s}=e,[c,d]=$.useState(yp(s,"day")),p=$.useRef(null),m=A.useRef([]),g=A.useRef(0);A.useEffect(()=>{d(yp(s,"day"))},[s]),A.useEffect(()=>{var k,j;const S=s.filter(F=>F.pinned),T=s.filter(F=>!F.pinned),E=m.current.filter(F=>F.pinned)[0],O=m.current.filter(F=>!F.pinned)[0];if(E&&E.id!==((k=S[0])==null?void 0:k.id)||O&&O.id!==((j=T[0])==null?void 0:j.id)){const F=p.current.closest(".memolist-wrapper");F.scrollTop=F.scrollHeight}else{const F=p.current.closest(".memolist-wrapper");F.scrollTop=F.scrollHeight-g.current,m.current=s}},[s]),A.useEffect(()=>{if(!p.current)return;const S=p.current.closest(".memolist-wrapper");S.scrollTop=S.scrollHeight},[t]),A.useEffect(()=>{if(n==="chat"&&p.current){const S=p.current.closest(".memolist-wrapper");S.scrollTop=S.scrollHeight,g.current=S.scrollHeight-S.scrollTop,m.current=s,S.onscrollend=()=>{g.current=S.scrollHeight-S.scrollTop}}},[p.current]);const v=A.useCallback(()=>{a.setting.open(),a.setting.openTabById(r.id||"obsidian-memos")},[a]),D=A.useMemo(()=>w.jsx(w.Fragment,{children:Object.keys(c).map((S,T)=>w.jsx(w.Fragment,{children:w.jsx(dJ,{thinos:c[S],dayMark:S,handleOpenSettings:v},S+T)}))}),[c]);return w.jsx("div",{ref:p,className:Xn("chat-view",`${o==null?void 0:o.chatViewStyle}-style`),children:D})},dJ=({thinos:e,dayMark:t,handleOpenSettings:n})=>{const{dailyNotesState:{settings:r}}=A.useContext(mt),[a,o]=$.useState(!0),s=$.useRef(null),c=m=>{if(C.Keymap.isModifier(m.nativeEvent,"Mod")){const g=C.moment(t,"YYYY-MM-DD");He.setFromAndToQuery(g.startOf("day").valueOf(),g.endOf("day").valueOf());return}o(!a),s.current.scrollIntoView(!0)},d=m=>{$d(m)},p=A.useMemo(()=>e.map((m,g)=>w.jsxs("div",{className:"thino-bubble right",children:[w.jsx(fJ,{icon:r==null?void 0:r.MomentsIcon,handleOpenSettings:n}),w.jsx("div",{className:"wrap",children:w.jsx(hJ,{thino:m,handleClickTimeStamp:d},`${m.id}-${C.moment(m.createdAt,"YYYY/MM/DD HH:mm:ss").format("x")}-${g}`)})]},m.id+g)),[e,r==null?void 0:r.MomentsIcon]);return w.jsxs(w.Fragment,{children:[a&&p,w.jsx("div",{className:`thino-chat-day-mark day-mark ${a?"":"folded"}`,onClick:c,children:w.jsx("div",{className:"day-mark-bubble",children:(t==="PINNED"?t+" 📌":t)+(a?"":"...")})})]})},fJ=({icon:e,handleOpenSettings:t})=>w.jsx("div",{ref:n=>{if(e){n==null||n.empty();return}e||n&&C.setIcon(n,"Memos")},className:"icon-img",style:{backgroundImage:`url(${e})`}}),hJ=({thino:e,handleClickTimeStamp:t})=>{const n=A.useCallback(async()=>{if(e.thinoType==="JOURNAL")return;const o=await Te.updateMemo(e.id,e.content,e.thinoType==="TASK-TODO"?"TASK-DONE":"TASK-TODO");o&&Te.editMemo(o)},[e]),r=A.useMemo(()=>w.jsxs("div",{className:"content",children:[w.jsx("div",{className:"time-stamp","data-date":C.moment(e.createdAt,"YYYY/MM/DD HH:mm:ss").format("YYYY-MM-DD"),"data-time":C.moment(e.createdAt,"YYYY/MM/DD HH:mm:ss").format("HH:mm:ss"),onClick:()=>{t(e)},children:C.moment(e.createdAt,"YYYY/MM/DD HH:mm:ss").format("HH:mm:ss")}),w.jsx(Sa,{memo:e})]}),[e.content]),a=A.useMemo(()=>w.jsxs("div",{className:"content task",children:[w.jsx("div",{className:"task-inputer",children:w.jsx("input",{className:Xn("thino-type-status","task-list-item-checkbox"),type:"checkbox",checked:e.thinoType!=="TASK-TODO","data-task":e.thinoType==="TASK-TODO"?"":e.thinoType==="TASK-DONE"?"x":e.thinoType.slice(5),onClick:n})}),w.jsx("div",{className:"time-stamp","data-date":C.moment(e.createdAt,"YYYY/MM/DD HH:mm:ss").format("YYYY-MM-DD"),"data-time":C.moment(e.createdAt,"YYYY/MM/DD HH:mm:ss").format("HH:mm:ss"),onClick:()=>{t(e)},children:C.moment(e.createdAt,"YYYY/MM/DD HH:mm:ss").format("HH:mm:ss")}),w.jsx(Sa,{memo:e})]}),[e.content,e.thinoType]);return e.thinoType==="JOURNAL"?r:a};class Ve extends C.Setting{constructor(n,r){super(n);me(this,"settingTab");me(this,"name","");me(this,"desc","");this.settingTab=r}setName(n){return super.setName(n),this.name=n,this}setDesc(n){return super.setDesc(n),this.desc=n,this}setTab(n){const r=typeof this.name=="string"?this.name:this.name.textContent||"",a=typeof this.desc=="string"?this.desc:this.desc.textContent||"";return this.settingTab.addSettingToMasterSettingsList(n,this.settingEl,r,a),this}}class pJ extends C.Modal{constructor(n,r,a,o,s){super(n);me(this,"plugin");me(this,"settingTab");me(this,"target",5);me(this,"cb");this.app=n,this.settingTab=r,this.plugin=a,this.target=o,this.cb=s}onOpen(){var c;const{contentEl:n}=this;(c=n.parentElement)==null||c.classList.add("memo-save-location-modal"),n.createEl("h3",{text:N("Thino Daily Target")});const r=n.createDiv("modal-setting");new Ve(r,this.settingTab).setName(N("Target Thino Count")).addSlider(d=>{d.setDynamicTooltip().setValue(this.target).setLimits(1,30,1).onChange(async p=>{this.target=p})});const a=n.createDiv("button-group"),o=a.createEl("button",{text:N("Cancel")}),s=a.createEl("button",{text:N("Save")});s.onclick=async()=>{this.plugin.settings.MemoDailyTarget=this.target,this.settingTab.applySettingsUpdate(),this.cb(this.target),this.close()},o.onclick=async()=>{this.close()}}onClose(){const{contentEl:n}=this;n.empty()}}const mJ=({allStat:e,todayTimeStamp:t,calendarType:n,handleCalendarTypeChange:r})=>{const{dailyNotesState:{app:a,settings:o},globalState:{manifest:s}}=A.useContext(mt),[c,d]=A.useState(),[p,m]=A.useState(5),[g,v]=A.useState(0),[D,S]=A.useState(0),[T,E]=A.useState(o.HeatmapColorScheme||"default"),O=A.useRef(null),k=A.useRef(null);A.useEffect(()=>{o.HeatmapColorScheme&&E(o.HeatmapColorScheme)},[o.HeatmapColorScheme]),A.useEffect(()=>{let F,B=5;s&&a&&(F=a==null?void 0:a.plugins.getPlugin(s.id),B=F==null?void 0:F.settings.MemoDailyTarget,d(F)),m(B)},[s,a]),A.useEffect(()=>{const F=e.find(z=>z.timestamp===t),B=F?F.count:0;S(B);const R=Math.min(100,B/p*100);v(R)},[e,p]),A.useEffect(()=>{C.requireApiVersion("1.4.4")&&(C.setTooltip(k.current,g.toFixed(2)+"%"),C.setTooltip(O.current,N("Set daily target")+` (${D}/${p})`))},[g,D]),A.useEffect(()=>{O.current&&(O.current.hasChildNodes()||C.setIcon(O.current,"crosshair"),C.requireApiVersion("1.4.4")&&C.setTooltip(k.current,g+"%"))},[O,p]);const j=A.useCallback(()=>{if(!c)return;new pJ(a,c==null?void 0:c.settingTab,c,p,B=>{m(B)}).open()},[c,p]);return w.jsx(w.Fragment,{children:w.jsxs("div",{className:`usage-daily-progress-wrapper heatmap-${T}`,children:[w.jsx("div",{ref:k,className:"daily-progress-bar",children:w.jsx("div",{className:"daily-progress-bar-inner",style:{width:`${g}%`}})}),w.jsx("div",{ref:O,className:"daily-progress-target",onClick:j}),w.jsx("div",{ref:F=>{F&&C.setIcon(F,n==="basic"?"layout-grid":"calendar"),F&&C.setTooltip&&C.setTooltip(F,N("Switch calendar type"))},className:"switch-calendar-type-btn",onClick:()=>r&&r(n==="basic"?"heatmap":"basic")})]})})},gJ=e=>{const{className:t,view:n,datestamp:r,handleDateStampChange:a,handleDateItemClick:o,handleMonthChange:s,dailyStat:c}=e,d=C.moment().startOf("day").valueOf(),[p,m]=A.useState(Bh(r)),[g,v]=A.useState(null);A.useEffect(()=>{m(Bh(r))},[r]);const D=new Date(p),S=D.getDay(),T=[];for(let k=0;k{const j=D.getFullYear(),F=D.getMonth()+1;let B=0;F===1&&k===-1?B=new Date(`${j-1}/12/1`).getTime():F===12&&k===1?B=new Date(`${j+1}/1/1`).getTime():B=new Date(`${j}/${F+k}/1`).getTime(),m(Bh(B)),s&&s(B)};return w.jsxs("div",{className:`heatmap-date-picker-wrapper ${t}`,children:[w.jsxs("div",{className:"date-picker-header",children:[w.jsx("span",{ref:k=>{k&&C.setIcon(k,"chevron-left")},className:"btn btn-text",onClick:()=>O(-1)}),w.jsxs("span",{className:"normal-text",children:[w.jsx(GT,{year:D.getFullYear().toString(),handleYearChange:k=>{m(Bh(new Date(`${k}/${D.getMonth()+1}/1`).getTime()))}}),w.jsx(qT,{month:D.getMonth().toString(),handleMonthChange:k=>{m(Bh(new Date(`${D.getFullYear()}/${parseInt(k)}/1`).getTime()))}})]}),w.jsx("span",{ref:k=>{k&&C.setIcon(k,"chevron-right")},className:"btn btn-text",onClick:()=>O(1)})]}),w.jsxs("div",{className:"date-picker-day-container",children:[w.jsx("div",{className:"date-picker-day-header",children:N("weekDaysShort").map(k=>w.jsx("span",{className:"day-item",children:k},k))}),w.jsx("div",{className:"date-picker-day-content",children:T.map(k=>{if(k.date===0)return w.jsx("span",{className:"day-item null",children:""},k.datestamp);const j=c.find(R=>R.timestamp===k.datestamp)||{count:0,timestamp:k.datestamp,list:0},F=j.count-j.list,B=j.list;return w.jsxs("span",{className:`day-item ${k.datestamp===d?"current":""} ${k.datestamp===g?"selected":""} ${nw(j.count)}`,onClick:R=>{a(r,R.nativeEvent),v(k.datestamp===g?null:k.datestamp),o&&o(R,j)},onMouseOver:R=>{if(!j||!j.count)return;const z=new C.HoverPopover(n,R.currentTarget,100);cx(z,{d:k,list:B,task:F})},children:[w.jsx("span",{className:"day-item-text",children:k.date}),w.jsx(w.Fragment,{children:j&&j.count!==0&&w.jsxs("span",{className:"day-item-dots",children:[F>0&&w.jsx("div",{className:`day-item-dot thino-task-dot ${nw(F)}`}),B>0&&w.jsx("div",{className:`day-item-dot thino-list-dot ${nw(B)}`})]})})]},k.datestamp)})})]})]})};function cx(e,{d:t,list:n,task:r}){e.hoverEl.toggleClass("thino-hover-popover",!0);const a=e.hoverEl.createDiv({cls:"thino-hover-popover-content"});a.createDiv({cls:"thino-date-item",text:`${C.moment(t.datestamp).format("YYYY-MM-DD")}`});const o=a.createDiv({cls:"thino-task-item"});o.createSpan({cls:"thino-task-item-title-text",text:`${N("Task")}: `}),o.createSpan({cls:"thino-task-item-title-count",text:`${r}`});const s=a.createDiv({cls:"thino-list-item"});s.createSpan({cls:"thino-list-item-title-text",text:`${N("List")}: `}),s.createSpan({cls:"thino-list-item-title-count",text:`${n}`})}function yJ(e){const t=new Date(e),n=new Date(`${t.getFullYear()}/${t.getMonth()+1}/1`);return((n.getMonth()===11?new Date(`${n.getFullYear()+1}/1/1`):new Date(`${n.getFullYear()}/${n.getMonth()+2}/1`)).getTime()-n.getTime())/Mi}function Bh(e){const t=new Date(e);return new Date(`${t.getFullYear()}/${t.getMonth()+1}/1`).getTime()}function nw(e){return e<=0?"":e<=1?"stat-day-L1-bg":e<=2?"stat-day-L2-bg":e<=4?"stat-day-L3-bg":"stat-day-L4-bg"}const A2={width:12,height:7},F2=(e,t)=>{const n=[];for(let r=0;r<=e;r++)n.push({timestamp:parseInt(C.moment(t).add(r,"days").format("x")),count:0,list:0});return n},gp=({initThinos:e,basicType:t})=>{const n=parseInt(C.moment().endOf("day").format("x")),r=new Date(n).getDay()||7,a=parseInt(C.moment().startOf("day").format("x")),o=new Array(7-(r===7?1:r)).fill(0),s=(A2.width-1)*A2.height+r,c=parseInt(C.moment().startOf("day").subtract(s,"days").format("x")),d=C.moment().startOf("day").subtract(s,"days"),{memoState:{memos:p},dailyNotesState:{view:m,app:g,settings:v,verifyState:D}}=A.useContext(mt),[S,T]=Kr(t||wJ(g||window.app)||"heatmap"),[E,O]=Kr(C.moment().startOf("day").valueOf()),[k,j]=Kr(v.HeatmapColorScheme||"default"),[F,B]=Kr(F2(s,c)),[R,z]=Kr(null),[H,Y,U]=Kr(""),J=A.useRef(null);A.useEffect(()=>{const se=F2(s,c),fe=(e||p).filter(oe=>!oe.deletedAt&&oe.rowStatus!=="ARCHIVED");for(const oe of fe){const Z=C.moment(oe.createdAt.replaceAll("/","-"),"YYYY-MM-DD HH:mm:ss").startOf("day").diff(d,"days");Z>=0&&Z{v.HeatmapColorScheme&&j(v.HeatmapColorScheme)},[v.HeatmapColorScheme]);const Q=A.useCallback((se,fe)=>{if(!fe||!fe.count)return;const oe=fe.count-fe.list,we=fe.list,Z={date:fe.timestamp,datestamp:fe.timestamp},G=new C.HoverPopover(m,se.currentTarget,100);cx(G,{d:Z,list:we,task:oe})},[]),le=()=>{T(S==="heatmap"?"basic":"heatmap"),vJ(g,S==="heatmap"?"basic":"heatmap"),O(C.moment().startOf("day").valueOf())},pe=A.useCallback(async(se,fe)=>{if(fe.count===0)return;const oe=He.getState().query.duration,we=oe==null?void 0:oe.from,Z=oe==null?void 0:oe.to,G=C.moment(we).diff(Z,"day")==0;if(we===fe.timestamp&&G)He.setFromAndToQuery(0,0),z(null),Y(null);else if(we!==fe.timestamp&&we>0&&se.shiftKey){const te=C.moment(fe.timestamp).endOf("day").diff(Z,"day");we===0&&se.shiftKey?Y("from"):te<0&&G&&Y("to"),C.moment(we).isBefore(fe.timestamp)?U.current==="to"?te<0?He.setFromAndToQuery(fe.timestamp,Z):(He.setFromAndToQuery(parseInt(C.moment(Z).startOf("day").format("x")),parseInt(C.moment(fe.timestamp).endOf("day").format("x"))),Y("from")):U.current==="from"&&(te<0,He.setFromAndToQuery(we,parseInt(C.moment(fe.timestamp).endOf("day").format("x")))):U.current==="to"?He.setFromAndToQuery(fe.timestamp,Z):U.current==="from"&&(He.setFromAndToQuery(fe.timestamp,parseInt(C.moment(we).endOf("day").format("x"))),Y("to"))}else if(we===0&&se.shiftKey)He.setFromAndToQuery(fe.timestamp,parseInt(C.moment().endOf("day").format("x")));else if(fe.count>0&&(se.ctrlKey||se.metaKey)){const{app:te,dailyNotes:ge}=Xe.getState(),Ie=Fy(C.moment(fe.timestamp),ge);if(!C.Platform.isMobile)await te.workspace.getLeaf(!0).openFile(Ie);else{let De=te.workspace.activeLeaf;De===null&&(De=te.workspace.getLeaf(!0)),De.openFile(Ie)}}else fe.count>0&&!se.shiftKey&&!se.ctrlKey&&!se.metaKey&&(["/","/recycle"].includes(He.getState().pathname)||He.setPathname("/"),He.setFromAndToQuery(fe.timestamp,Ue.getTimeStampByDate(C.moment(fe.timestamp+Mi).subtract(1,"days").endOf("day").format("YYYY-MM-DD HH:mm:ss"))),z(fe))},[]),ie=A.useMemo(()=>w.jsx(gJ,{className:`heatmap-${k}`,view:m,datestamp:E,dailyStat:F,handleMonthChange:se=>{O(se)},handleDateStampChange:se=>{},handleDateItemClick:(se,fe)=>pe(se,fe)}),[JSON.stringify(F),m,E,k]);return w.jsxs(w.Fragment,{children:[S==="basic"&&ie,S==="heatmap"&&w.jsxs("div",{className:`usage-heat-map-wrapper heatmap-${k}`,ref:J,children:[w.jsxs("div",{className:"day-tip-text-container",children:[w.jsx("span",{className:"tip-text",children:N("weekDaysShort")[0]}),w.jsx("span",{className:"tip-text"}),w.jsx("span",{className:"tip-text",children:N("weekDaysShort")[2]}),w.jsx("span",{className:"tip-text"}),w.jsx("span",{className:"tip-text",children:N("weekDaysShort")[4]}),w.jsx("span",{className:"tip-text"}),w.jsx("span",{className:"tip-text",children:N("weekDaysShort")[6]})]}),w.jsxs("div",{className:"usage-heat-map",children:[F.map((se,fe)=>{const oe=se.count,we=oe<=0?"":oe<=1?"stat-day-L1-bg":oe<=2?"stat-day-L2-bg":oe<=4?"stat-day-L3-bg":"stat-day-L4-bg";return w.jsx("span",{className:`stat-container ${we} ${R===se?"current":""} ${a===se.timestamp?"today":""}`,onMouseOver:Z=>Q(Z,se),onClick:Z=>pe(Z,se)},fe)}),o.map((se,fe)=>w.jsx("span",{className:"stat-container null"},fe))]})]}),!t&&D&&w.jsx(mJ,{allStat:F,todayTimeStamp:a,calendarType:S,handleCalendarTypeChange:le})]})};function vJ(e,t){try{e==null||e.saveLocalStorage("calendarType",t)}catch(n){console.error(n)}}function wJ(e){try{return(e==null?void 0:e.loadLocalStorage("calendarType"))||"heatmap"}catch(t){return console.error(t),"heatmap"}}const dx=({type:e,timestamp:t})=>{const{memoState:{memos:n}}=A.useContext(mt),[r,a]=A.useState([]),o=$.useRef(null);return A.useEffect(()=>{if(e==="daily"){if(t){const c=n.filter(d=>C.moment(d.createdAt,"YYYY/MM/DD HH:mm:ss").isSame(C.moment(t,"YYYY/MM/DD HH:mm:ss"),"day"));a(c);return}const s=n.filter(c=>C.moment(c.createdAt,"YYYY/MM/DD HH:mm:ss").isSame(C.moment(),"day"));a(s)}else if(e==="latest"){const s=n.filter(p=>!p.deletedAt&&p.rowStatus!=="ARCHIVED"),c=s.filter(p=>p.pinned),d=s.filter(p=>!p.pinned).slice(0,5);a([...c,...d])}},[n]),A.useEffect(()=>{o.current&&(o.current.scrollTop=0)},[n]),r.length>0?w.jsx("div",{ref:o,className:"thino-list-container",children:r.map(s=>w.jsx(Sa,{memo:s}))}):w.jsx("div",{className:"tip-text-container",children:w.jsx("span",{className:"tip-text",children:N("Here is No Memos.")})})},bJ=(e,t)=>{Lo.createRoot(e).render(w.jsx($.StrictMode,{children:w.jsx(Bo,{store:Ee,context:mt,children:w.jsx(DJ,{plugin:t})})}))},DJ=({plugin:e})=>w.jsxs(w.Fragment,{children:[w.jsx("div",{className:"thino-error-code-block",children:N("Please open thino first")}),w.jsx("button",{className:"thino-open-view",onClick:()=>e.openMemos("center"),children:N("Open thino in center window")})]}),SJ=(e,t)=>{Lo.createRoot(e).render(w.jsx($.StrictMode,{children:w.jsx(Bo,{store:Ee,context:mt,children:w.jsx(IJ,{yaml:t})})}))},IJ=({yaml:e})=>{const t=Object.keys(e).filter(a=>e[a]),n=e.daily?e.daily:"",r=a=>{switch(a){case"editor":return O2;case"heatmap":return EJ;case"calendar":return CJ;case"daily":return MJ;case"list":return NJ;case"status":return xJ;default:return O2}};return w.jsx(w.Fragment,{children:t.map(a=>w.jsx("div",{"data-embed-type":a,className:Xn("thino-embed-container",a==="editor"?"thino-editor-modal":""),children:a==="daily"?r(a)(n):r(a)()}))})};function O2(){return w.jsx(Nu,{editorType:"inline"})}function TJ(e,t){try{const n=Lo.createRoot(e);return n.render(w.jsx($.StrictMode,{children:w.jsx(Bo,{store:Ee,context:mt,children:w.jsx(Nu,{editorType:"inline",destroy:t})})})),n}catch(n){console.error(n)}}function EJ(){return w.jsx(gp,{basicType:"heatmap"})}function CJ(){return w.jsx(gp,{basicType:"basic"})}function xJ(){return w.jsx(E1,{statusType:"banner"})}function MJ(e){return w.jsx(dx,{type:"daily",timestamp:e})}function NJ(){return w.jsx(dx,{type:"latest"})}class fx extends C.Modal{constructor(n){super(n);me(this,"root")}onOpen(){const{contentEl:n,modalEl:r}=this;try{this.root=TJ(n,this.close.bind(this)),r.toggleClass("thino-editor-modal",!0),setTimeout(()=>{var a;(a=n.querySelector("textarea"))==null||a.focus(),this.app.workspace.trigger("focus-on-textarea")},10)}catch(a){console.error(a)}}onClose(){this.root.unmount(),this.containerEl&&this.containerEl.empty()}}const kJ=({userIcon:e})=>w.jsx("div",{className:"moments-view-user-icon",ref:t=>{if(e){t==null||t.empty();return}e||t&&C.setIcon(t,"Memos")},style:{backgroundImage:`url(${e})`}}),P2="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZlcnNpb249IjEuMSIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHhtbG5zOnN2Z2pzPSJodHRwOi8vc3ZnanMuZGV2L3N2Z2pzIiB3aWR0aD0iMTQ0MCIgaGVpZ2h0PSI1NjAiIHByZXNlcnZlQXNwZWN0UmF0aW89Im5vbmUiIHZpZXdCb3g9IjAgMCAxNDQwIDU2MCI+PGcgbWFzaz0idXJsKCZxdW90OyNTdmdqc01hc2sxMDgwJnF1b3Q7KSIgZmlsbD0ibm9uZSI+PHJlY3Qgd2lkdGg9IjE0NDAiIGhlaWdodD0iNTYwIiB4PSIwIiB5PSIwIiBmaWxsPSIjMGUyYTQ3Ij48L3JlY3Q+PHVzZSB4bGluazpocmVmPSIjU3ZnanNTeW1ib2wxMDg3IiB4PSIwIiB5PSIwIj48L3V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ZWY9IiNTdmdqc1BhdGgxMDgzIiB4PSI2OTAiIHk9IjM5MCIgc3Ryb2tlPSJyZ2JhKDE2LCA1MCwgODMsIDEpIj48L3VzZT48dXNlIHhsaW5rOmhyZWY9IiNTdmdqc1BhdGgxMDg1IiB4PSI2OTAiIHk9IjQ1MCIgc3Ryb2tlPSJyZ2JhKDE2LCA1MCwgODMsIDEpIj48L3VzZT48dXNlIHhsaW5rOmhyZWY9IiNTdmdqc1BhdGgxMDgxIiB4PSI2OTAiIHk9IjUxMCIgc3Ryb2tlPSJyZ2JhKDIwOCwgMjE3LCAyMDksIDEpIj48L3VzZT48dXNlIHhsaW5rOmhyZWY9IiNTdmdqc1BhdGgxMDg2IiB4PSI2OTAiIHk9IjU3MCIgc3Ryb2tlPSJyZ2JhKDE2LCA1MCwgODMsIDEpIj48L3VzZT48L3N5bWJvbD48L3N2Zz4=",AJ=e=>{const{globalState:{memoListView:t,markMemoId:n,manifest:r,editMemoId:a},dailyNotesState:{app:o,settings:s}}=A.useContext(mt),{thinos:c}=e,d=$.useRef(null),p=$.useRef(null),[m,g]=$.useState(!1),[v,D]=A.useState({}),[S,T]=A.useState((o==null?void 0:o.loadLocalStorage("dayMarkRange"))||"day");A.useEffect(()=>{s!=null&&s.showDayMark&&D(yp(c,(o==null?void 0:o.loadLocalStorage("dayMarkRange"))||"day"))},[c]),A.useEffect(()=>{d.current.closest(".workspace-window")&&g(!0)},[d.current]),A.useEffect(()=>{n&&g(!0)},[n]),A.useEffect(()=>{a?(g(!0),setTimeout(()=>{o.workspace.trigger("focus-on-textarea")},200)):g(!1)},[a]),A.useEffect(()=>{p.current&&(!m&&C.setIcon(p.current,"camera"),m&&C.setIcon(p.current,"camera-off"))},[p.current,m]);const E=A.useCallback(()=>{o.setting.open(),o.setting.openTabById(r.id||"obsidian-memos")},[o]);return w.jsxs("div",{ref:d,className:Xn("moments-view",m?"show-editor":""),children:[w.jsxs("div",{className:"moments-view-background-wrapper",children:[w.jsx(FJ,{}),w.jsx("div",{ref:p,className:"moments-show-editor-btn",onClick:()=>{(m||a)&&g(!m),!m&&!a&&new fx(o).open()}}),w.jsxs("div",{className:"moments-view-background-overlay",children:[w.jsxs("div",{className:"moments-view-user-info",children:[w.jsx("div",{className:"moments-view-user-name",children:s==null?void 0:s.UserName}),w.jsx(kJ,{userIcon:s==null?void 0:s.MomentsIcon})]}),w.jsx("div",{className:"moments-view-user-idea",children:s.MomentsQuote||" "})]})]}),s!=null&&s.showDayMark?v&&Object.keys(v).length>0&&Object.keys(v).map((O,k)=>w.jsx(Ow,{type:"list",thinos:v[O],dayMark:O,dayMarkRange:S,thinoWrapper:j=>w.jsx(j2,{thino:j.thino,handleOpenSettings:E},j.thino.createdAt+k)},O)):c.map((O,k)=>w.jsx(j2,{thino:O,handleOpenSettings:E},O.createdAt+k))]})},FJ=()=>{const{dailyNotesState:{view:e,settings:t}}=A.useContext(mt),[n,r]=A.useState((t==null?void 0:t.MomentsBackgroundImage)||rw);return A.useEffect(()=>{if(!(t!=null&&t.MomentsBackgroundImage)){r(document.body.hasClass("theme-dark")?P2:rw);return}r(t==null?void 0:t.MomentsBackgroundImage)},[t==null?void 0:t.MomentsBackgroundImage]),A.useEffect(()=>{e&&e.registerEvent(e.app.workspace.on("css-change",()=>{r(document.body.hasClass("theme-dark")&&!(t!=null&&t.MomentsBackgroundImage)?P2:!document.body.hasClass("theme-dark")&&!(t!=null&&t.MomentsBackgroundImage)?rw:t==null?void 0:t.MomentsBackgroundImage)}))},[e]),w.jsx("div",{className:"moments-view-background",style:{backgroundImage:`url(${n})`}})},OJ=e=>{const{icon:t}=e,n=A.useCallback(()=>{app.setting.open(),app.setting.openTabById(manifest.id||"obsidian-memos")},[]);return w.jsx("div",{className:"thino-moment-icon",ref:r=>{if(t){r==null||r.empty();return}t||r&&C.setIcon(r,"Memos")},style:{backgroundImage:`url(${t})`},onClick:n})},j2=e=>{const{dailyNotesState:{settings:t}}=A.useContext(mt),n=A.useRef(null),r=A.useRef(null),{thino:a}=e;return A.useEffect(()=>{n.current&&C.setIcon(n.current,"more-horizontal")},[n.current]),w.jsxs("div",{className:"thino-moment-wrapper",children:[w.jsx(OJ,{icon:t==null?void 0:t.MomentsIcon}),w.jsxs("div",{ref:r,className:"thino-moment-container",children:[w.jsx("div",{className:"thino-moment-user-name",children:t==null?void 0:t.UserName}),w.jsx("div",{className:"thino-moment-user-content",children:w.jsx(Sa,{memo:a})})]})]})};function PJ(e){const t=e.filter(r=>r.pinned),n=e.filter(r=>!r.pinned);return[...t,...n]}function yp(e,t){const n={},r={day:"YYYY-MM-DD ddd",week:"YYYY-[W]WW",month:"YYYY-MM",quarter:"YYYY-[Q]1",year:"YYYY"};for(const a of e){const o=C.moment(a.createdAt,"YYYY/MM/DD HH:mm:ss").format(r[t]);if(a.pinned){n.PINNED||(n.PINNED=[]),n.PINNED.push(a);continue}n[o]||(n[o]=[]),n[o].push(a)}return n}function Yg(e){const{tag:t,duration:n,type:r,text:a,filter:o}=e,s=Et.getQueryById(o);return!(!!(t||n&&n.from{const r=e.filter(g=>g.rowStatus!=="ARCHIVED"&&!(g.deletedAt!==""&&g.deletedAt)),{tag:a,duration:o,type:s,text:c,filter:d}=t,p=Et.getQueryById(d);return!!(a||o&&o.from{let v=!0;if(g.thinoType!==void 0&&n&&g.thinoType==="TASK-DONE"&&(v=!1),g.content.contains("comment:")&&(v=!1),p){const D=JSON.parse(p.querystring);Array.isArray(D)&&(v=Wd(g,D))}if(a){const D=new Set;for(const S of Array.from(g.content.match(Fn)||[])){const E=S.replace(Fn,"$1").trim().split("/");let O="";for(const k of E)O+=k,D.add(O),O+="/"}for(const S of Array.from(g.content.match($n)||[])){const E=S.replace($n,"$1").trim().split("/");let O="";for(const k of E)O+=k,D.add(O),O+="/"}for(const S of Array.from(g.content.match(mr)||[])){const E=S.replace(mr,"$2").trim().split("/");let O="";for(const k of E)O+=k,D.add(O),O+="/"}D.has(a)||(v=!1)}return o&&o.fromo.to)&&(v=!1),s&&(s==="NOT_TAGGED"&&(g.content.match(Fn)!==null||g.content.match(mr)!==null||g.content.match($n)!==null)||s==="LINKED"&&g.content.match(Bu)===null||s==="IMAGED"&&g.content.match(_u)===null||s==="CONNECTED"&&g.content.match(Il)===null)&&(v=!1),c&&!g.content.toLowerCase().includes(c.toLowerCase())&&(v=!1),v}):r.filter(g=>!g.content.contains("comment:"))},LJ=({updateThinos:e})=>{var G;const{locationState:{query:t},memoState:{memos:n},globalState:{memoListView:r},dailyNotesState:{app:a,settings:o,verifyState:s,plugin:c}}=A.useContext(mt),[d,p]=A.useState(!1),[m,g]=A.useState(!1),[v,D,S]=Kr([]),[T,E]=A.useState([]),[O,k]=A.useState({}),[j,F]=A.useState((G=window.app||a)==null?void 0:G.loadLocalStorage("thinoListView")),[B,R]=A.useState((a==null?void 0:a.loadLocalStorage("showDayMark"))||!1),[z,H]=A.useState((a==null?void 0:a.loadLocalStorage("dayMarkRange"))||"day"),[Y,U,J]=Kr([]),Q=A.useRef(0),le=A.useRef(!1),pe=A.useRef(null),ie=A.useRef(null),se=A.useRef(null),fe=A.useRef(null),oe=A.useRef(!1);A.useEffect(()=>{F(r),a&&a.saveLocalStorage("thinoListView",r),D(Y.slice(0,v.length>20?Math.min(v.length,40):40))},[r]),A.useEffect(()=>()=>{ie.current&&(ie.current=null),se.current&&(se.current=null),fe.current&&(fe.current=null)},[]),A.useLayoutEffect(()=>{if((n.length!==0||!a)&&oe.current===!0)return;const te=RJ(a);!te||te.length===0||(U(te),E(te),R((a==null?void 0:a.loadLocalStorage("showDayMark"))||!1),a!=null&&a.loadLocalStorage("showDayMark")&&k(yp(te,(a==null?void 0:a.loadLocalStorage("dayMarkRange"))||"day")))},[a]),A.useEffect(()=>{if(n.length===0&&!Te.initialized)return;p(!1);const te=PJ(n),ge=jJ({tempMemos:te,query:t,HideDoneTasks:(o==null?void 0:o.HideDoneTasks)||!1});return oe.current=!0,e&&e(ge),U(ge),()=>{oe.current=!1}},[n,t,o==null?void 0:o.HideDoneTasks]),A.useEffect(()=>{D(Y.slice(0,v.length>20?Math.min(v.length,40):40))},[Y]),A.useEffect(()=>{var te;v.length<40&&((te=se.current)==null||te.click())},[Y]),A.useEffect(()=>{(Yg(t)&&v.length0||!Yg(t)&&v.length===Y.length&&Y.length>0)&&g(!0),BJ(v||[],a),E(v),a==null||a.saveLocalStorage("showDayMark",o==null?void 0:o.showDayMark),a==null||a.saveLocalStorage("dayMarkRange",o==null?void 0:o.dayMarkRange),R((o==null?void 0:o.showDayMark)||!1),H((o==null?void 0:o.dayMarkRange)||"day"),o!=null&&o.showDayMark&&k(yp(v,o==null?void 0:o.dayMarkRange))},[v,o==null?void 0:o.showDayMark,o==null?void 0:o.dayMarkRange]),A.useEffect(()=>{if(!ie.current)return;const te=async()=>{le.current||(Q.current++,await we(),Q.current>=1&&(le.current=!0,setTimeout(()=>{Q.current=0,le.current=!1},3e3)))};v.length<40&&te();const ge=new IntersectionObserver(([Ie])=>{if(Ie.isIntersecting){if(m)return;te()}else Q.current=0,le.current=!1});return ie!=null&&ie.current&&ge.observe(ie.current),()=>{ie!=null&&ie.current&&ge.unobserve(ie.current)}},[d,m,ie.current]),A.useEffect(()=>{var te;(te=fe.current)==null||te.scrollTo({top:0})},[t]);const we=async()=>{try{if(J.current.length>S.current.length){p(!0);const te=Math.min(S.current.length+40,J.current.length)-S.current.length,ge=J.current.slice(S.current.length,S.current.length+te);D(Ie=>[...Ie,...ge]),p(!1),g(ge.length<40)}}catch(te){console.error(te),new C.Notice(te.response.data.message)}},Z=A.useMemo(()=>w.jsx("div",{ref:ie,className:Xn("status-text-container",j==="calendar"||j==="table"?"hidden":""),children:w.jsx("p",{className:"status-text",children:d?N("Fetching data..."):m?Y.length===0?N("Noooop!"):N("All Data is Loaded 🎉"):w.jsx(w.Fragment,{children:w.jsx("span",{ref:se,className:"cursor-pointer hover:text-green-600",onClick:we,children:N("fetch more")})})})}),[j,we,Y,d,m,ie]);return w.jsxs("div",{className:`memolist-wrapper ${m?"completed":""}`,ref:fe,children:[j==="chat"&&Z,w.jsxs("div",{ref:pe,className:"memolist-container",children:[j==="chat"&&w.jsx(cJ,{thinos:T}),j==="calendar"&&w.jsx(XG,{thinos:Y}),j==="table"&&w.jsx(sJ,{thinos:Y}),j==="moments"&&w.jsx(AJ,{thinos:T}),j==="list"&&w.jsx(gy,{breakpointCols:1,className:`${j}-view masonry-memolist`,columnClassName:"masonry-memolist-grid_column",children:B?w.jsx(w.Fragment,{children:Object.keys(O).map(te=>w.jsx(Ow,{type:"list",thinos:O[te],dayMark:te,dayMarkRange:z},te))}):T.map((te,ge)=>w.jsx(Sa,{memo:te},`${te.id}-${C.moment(te.updatedAt,"YYYY/MM/DD HH:mm:ss").format("x")}-${ge}`))}),j==="waterfall"&&w.jsx(w.Fragment,{children:B&&Object.keys(O).length>0?Object.keys(O).map(te=>w.jsx(Ow,{type:"waterfall",thinos:O[te],dayMark:te,dayMarkRange:z},te)):w.jsx(gy,{breakpointCols:3,className:`${j}-view masonry-memolist`,columnClassName:"masonry-memolist-grid_column",children:T.map((te,ge)=>w.jsx(Sa,{memo:te},`${te.id}-${C.moment(te.updatedAt,"YYYY/MM/DD HH:mm:ss").format("x")}-${ge}`))})})]}),j!=="chat"&&Z]})};function hx(e){return`memosListCache:${e}`}function RJ(e){var t;try{const n=hx(e==null?void 0:e.appId),r=Kn.get([n])[n];return r?((t=JSON.parse(r))==null?void 0:t.memos)||[]:[]}catch(n){return console.error(n),[]}}function BJ(e,t){try{if(!e)return;const n=e==null?void 0:e.slice(0,100),r=hx(t==null?void 0:t.appId);Kn.set({[r]:JSON.stringify({memos:n})})}catch(n){console.error(n)}}const Tu=async e=>{const{app:t,settings:n}=Xe.getState();if(!n.startSync||!(t!=null&&t.loadLocalStorage("tokenForSync")))return;const r=await W6(e);if(!r||r.length===0)return;r.sort((s,c)=>C.moment(s.createdAt,"YYYY/MM/DD HH:mm:ss").isAfter(C.moment(c.createdAt,"YYYY/MM/DD HH:mm:ss"))?1:-1);const a=r.filter(s=>!s.deleted),o=r.filter(s=>s.deleted);for(let s=0;s{if(!t||!r||!n||!(t==null?void 0:t.loadLocalStorage("tokenForSync"))||!e.startSync)return;s.current=window.setInterval(async()=>{const v=Qw(t);await Tu(v)},3e4),n.registerInterval(s.current);const g=Qw(t);return Tu(g),()=>{s.current&&window.clearInterval(s.current)}},[n,t,r,e.startSync]);const p=[w.jsx(Rp,{thinosCount:c.length,thinos:c},"filter"),w.jsx(LJ,{updateThinos:m=>{d(m)}},"list")];return w.jsx(w.Fragment,{children:a==="chat"?w.jsx(w.Fragment,{children:[w.jsx(ay,{syncThino:Tu},"header"),...p.reverse(),w.jsx(Nu,{className:"mod-editor-bottom",editorType:"inline"},"editor")]}):w.jsx(w.Fragment,{children:o?[w.jsx(ay,{syncThino:Tu},"header"),...p,w.jsx(Nu,{className:"mod-editor-bottom",editorType:"block"},"editor")]:[w.jsx(ay,{syncThino:Tu},"header"),w.jsx(Nu,{editorType:"block"},"editor"),...p]})})}function HJ(e){try{e!=null&&e.saveLocalStorage&&(e==null||e.saveLocalStorage("thinoLastUpdated",C.moment("2000-01-01 00:01:00","YYYY-MM-DD HH:mm:ss").format("x")))}catch(t){console.error(t)}}function Qw(e){try{const t=(e==null?void 0:e.loadLocalStorage)&&(e==null?void 0:e.loadLocalStorage("thinoLastUpdated"));return t||C.moment("2000-01-01 00:01:00","YYYY-MM-DD HH:mm:ss").format("x")}catch(t){return console.error(t),C.moment().format("x")}}function YJ(e){try{e!=null&&e.saveLocalStorage&&(e==null||e.saveLocalStorage("thinoLastUpdated",C.moment().format("x")))}catch(t){console.error(t)}}function af(e=!0){const[t,n]=A.useState({isLoading:e,isFailed:!1,isSucceed:!1,isPending:!1});return{...t,setLoading:()=>{n({...t,isLoading:!0,isFailed:!1,isPending:!1,isSucceed:!1})},setFinish:()=>{n({...t,isLoading:!1,isFailed:!1,isPending:!1,isSucceed:!0})},setError:()=>{n({...t,isLoading:!1,isFailed:!0,isPending:!1,isSucceed:!1})},setPending:()=>{n({...t,isLoading:!1,isFailed:!1,isPending:!0,isSucceed:!1})}}}const zJ={text:N("SELECT"),value:""},UJ=e=>{const{className:t,dataSource:n,handleValueChanged:r,value:a}=e,[o,s]=ki(!1),c=A.useRef(null);let d=zJ;for(const g of n)if(g.value===a){d=g;break}A.useEffect(()=>{if(o){const g=v=>{var D;(D=c.current)!=null&&D.contains(v.target)||s(!1)};window.addEventListener("click",g,{capture:!0,once:!0})}},[o]);const p=g=>{r&&r(g.value),s(!1)},m=g=>{g.stopPropagation(),s()};return w.jsxs("div",{className:`selector-wrapper ${t||""}`,ref:c,children:[w.jsxs("div",{className:`current-value-container ${o?"active":""}`,onClick:m,children:[w.jsx("span",{className:"value-text",children:d.text}),w.jsx("span",{ref:g=>{g&&C.setIcon(g,"chevron-right")},className:"btn arrow-text"})]}),w.jsx("div",{className:`items-wrapper ${o?"":"hidden"}`,children:n.map(g=>w.jsx("div",{className:`item-container ${g.value===a?"selected":""}`,onClick:()=>{p(g)},children:g.text},g.value))})]})},bd=A.memo(UJ),pb=e=>{const{destroy:t,queryId:n,type:r="dialog"}=e,[a,o]=A.useState(""),[s,c]=A.useState(r!=="dialog"?[kD()]:[]),d=af(!1),[p,m]=A.useState(!1),[g,v]=ki(!1),D=Te.getState().memos.filter(R=>!(R.deletedAt!==""&&R.deletedAt)).filter(R=>Wd(R,s)).length;A.useEffect(()=>{S()},[n]);const S=()=>{const R=Et.getQueryById(n??"");if(R){o(R.title);const z=JSON.parse(R.querystring);return Array.isArray(z)&&c(z),R}},T=R=>{const z=R.target.value;o(z)},E=async()=>{if(!a)return new C.Notice(N("TITLE CANNOT BE NULL!")),null;if(s.length===0)return new C.Notice(N("FILTER CANNOT BE NULL!")),null;if(s.length===1&&s[s.length-1].value.value==="")return new C.Notice(N("Please finish the last filter setting first")),null;let R;try{n&&!n.startsWith("Filter [Temp] ")?(R=await Et.updateQuery(n,a,JSON.stringify(s)),Et.editQuery(R),await Et.getMyAllQueries()):(R=await Et.createQuery(a,JSON.stringify(s)),Et.pushQuery(R),await Et.getMyAllQueries())}catch(z){new C.Notice(z.message)}return R},O=async()=>{switch(r){case"modal":case"inline":if(s.length===0){new C.Notice(N("FILTER CANNOT BE NULL!"));return}if(s.length===1&&s[s.length-1].value.value===""){new C.Notice(N("Please finish the last filter setting first"));return}try{const R=Et.getQueryById(n??"");if(R&&JSON.stringify(s)===R.querystring){He.setMemoFilter(R.id),t();return}const z=Et.createTempQuery(`Filter [Temp] ${Math.random().toString(36).substring(7)}`,JSON.stringify(s));Et.pushQuery(z),He.setMemoFilter(z.id)}catch(R){new C.Notice(R.message)}t();break;case"dialog":try{if(!await E())return}catch(R){console.error(R),new C.Notice(R.message)}t();break}},k=()=>{if(s.length===0){new C.Notice(N("FILTER CANNOT BE NULL!"));return}if(p){He.setMemoFilter(""),m(!1);return}const R=Et.getQueryById(n??"");if(R&&JSON.stringify(s)===R.querystring){He.setMemoFilter(R.id);return}const z=Et.createTempQuery(`Filter [Temp] ${Math.random().toString(36).substring(7)}`,JSON.stringify(s));Et.pushQuery(z),He.setMemoFilter(z.id),e.setPreview&&e.setPreview(z.id),m(!0)},j=()=>{if(s.length>0&&s[s.length-1].value.value===""){new C.Notice(N("Please finish the last filter setting first"));return}c([...s,kD()])},F=A.useCallback((R,z)=>{c(H=>{const Y=[...H];return Y[R]=z,Y})},[]),B=A.useCallback(R=>{c(z=>z.filter((Y,U)=>U!==R))},[]);return w.jsxs(w.Fragment,{children:[r==="dialog"&&w.jsxs("div",{className:"dialog-header-container",children:[w.jsxs("span",{className:"title-text",children:[w.jsx("span",{className:"icon-text",children:"🔖"}),N(n?"EDIT QUERY":"CREATE QUERY")]}),w.jsx("button",{ref:R=>{R&&C.setIcon(R,"x")},className:"btn close-btn",onClick:t})]}),w.jsxs("div",{className:"dialog-content-container",children:[(r==="dialog"||g)&&w.jsxs("div",{className:"form-item-container input-form-container",children:[w.jsx("span",{className:"normal-text",children:N("TITLE")}),w.jsx("input",{className:"title-input",type:"text",value:a,onChange:T})]}),w.jsxs("div",{className:"form-item-container filter-form-container",children:[w.jsx("span",{className:"normal-text",children:N("FILTER")}),w.jsxs("div",{className:"filters-wrapper",children:[s.map((R,z)=>w.jsx(ZJ,{index:z,filter:R,handleFilterChange:F,handleFilterRemove:B},z)),w.jsx("div",{className:"create-filter-btn",onClick:j,children:N("ADD FILTER TERMS")})]})]})]}),w.jsx("div",{className:"dialog-footer-container",children:w.jsxs("div",{className:"btns-container",children:[(r==="inline"||r==="modal")&&w.jsx("button",{className:`btn ${g?"mod-cta":"save-btn"}`,onClick:async()=>{if(!g)v();else{const R=await E();v(!1),t(),R&&He.setMemoFilter(R.id)}},children:N(g?"Set and save":"Save")}),w.jsxs("div",{className:"btns-group-container",children:[w.jsxs("span",{className:`tip-text ${s.length===0&&"hidden"}`,children:[N("MATCH")," Thino ",w.jsx("strong",{children:D})," ",N("TIMES")]}),w.jsx(w.Fragment,{children:r==="inline"&&w.jsx("button",{className:"btn mod-cta",onClick:k,children:N("Preview")})}),w.jsx("button",{className:`btn save-btn ${d.isLoading?"requesting":""}`,onClick:O,children:N(r==="inline"||r==="modal"?"Filter":n?"EDIT":"Save")})]})]})})]})},VJ=e=>{const{index:t,filter:n,handleFilterChange:r,handleFilterRemove:a}=e,{type:o}=n,s=A.useRef(null),c=A.useRef(null),d=A.useRef(n),p=A.useRef(o);A.useEffect(()=>{d.current=e.filter},[n]),A.useEffect(()=>{if(s.current)return o==="TAG"&&!c.current&&(p.current=o,c.current=new yE(s.current,D)),()=>{c.current&&(c.current.destroy(),c.current=null)}},[s,o]);const m=A.useCallback(E=>{["AND","OR"].includes(E)&&r(t,{...n,relation:E})},[n]),g=A.useCallback(async E=>{var O;if(n.type!==E){const{verifyState:k}=Xe.getState(),j=!C.Platform.isDesktop&&await((O=window.Capacitor)==null?void 0:O.Plugins.Device.getId()),F=C.Platform.isDesktop?await vn():j.identifier||j.uuid,B=k&&(k==null?void 0:k.appId)===F;if(E==="SOURCE"&&!B){qt();return}const R=Object.values(pl[E].operators);r(t,{...n,type:E,value:{operator:R[0].value,value:""}})}},[n]),v=A.useCallback(E=>{r(t,{...n,value:{...n.value,operator:E}})},[n]),D=A.useCallback(E=>{r(t,{...d.current,value:{...d.current.value,value:E}})},[n]),S=()=>{a(t)},T={TYPE:w.jsx(bd,{className:"value-selector",dataSource:pl.TYPE.values,value:n.value.value,handleValueChanged:D}),LIST:w.jsx(bd,{className:"value-selector",dataSource:pl.LIST.values,value:n.value.value,handleValueChanged:D}),SOURCE:w.jsx(bd,{className:"value-selector",dataSource:pl.SOURCE.values,value:n.value.value,handleValueChanged:D}),TAG:w.jsx("input",{type:"text",id:Math.random().toString(36).substring(7),className:"value-inputer",ref:s,value:n.value.value,onChange:E=>{D(E.target.value)}}),TEXT:w.jsx("input",{type:"text",className:"value-inputer",value:n.value.value,onChange:E=>{D(E.target.value)}}),DATE:w.jsxs("div",{className:"date-inputer",children:[w.jsx(py,{type:"icon",handleValueChange:D}),w.jsx("input",{type:"text",className:"value-inputer",value:n.value.value,onChange:E=>{D(E.target.value)}})]})};return w.jsxs("div",{className:"memo-filter-input-wrapper",children:[t>0&&w.jsx(bd,{className:"relation-selector",dataSource:u8,value:n.relation,handleValueChanged:m}),w.jsx(bd,{className:"type-selector",dataSource:Object.values(pl),value:n.type,handleValueChanged:g}),w.jsxs(w.Fragment,{children:[Object.keys(pl).includes(o)&&w.jsx(bd,{className:"operator-selector",dataSource:Object.values(pl[o].operators),value:n.value.operator,handleValueChanged:v}),T[o]]}),w.jsx("div",{ref:E=>{E&&C.setIcon(E,"x")},className:"btn remove-btn",onClick:S})]})},ZJ=A.memo(VJ);function Xw(e){By({className:"create-query-dialog"},pb,{queryId:e})}const mb=e=>{var D,S;const{dailyNotesState:{app:t,verifyState:n},locationState:{query:r}}=A.useContext(mt),a=$.useRef(null),[o,s]=$.useState(!1),c=$.useRef(null),[d,p]=$.useState(""),m=Vy(a.current,c.current,{placement:"bottom-start",modifiers:[{name:"offset",options:{offset:[0,10]}}]});A.useEffect(()=>{o&&m.update&&(m==null||m.update())},[o]),A.useEffect(()=>{a&&C.setIcon(a.current,"filter")},[a]);const g=async()=>{var O;const T=!C.Platform.isDesktop&&await((O=window.Capacitor)==null?void 0:O.Plugins.Device.getId()),E=C.Platform.isDesktop?await vn():T.identifier||T.uuid;return!n||(n==null?void 0:n.appId)!==E?(qt(),!1):!0};return Pp(c,()=>{s(!1),d&&He.getState().query.filter===d&&He.setMemoFilter("")}),w.jsxs(w.Fragment,{children:[w.jsx("div",{className:"thino-inline-filter-wrapper pro",ref:a,onClick:async()=>{await g()&&(C.Platform.isDesktop?(s(!o),await(m==null?void 0:m.update())):new WJ(Xe.getState().app,r.filter,E=>{p(E)}).open())}}),w.jsx("div",{ref:c,className:`thino-inline-filter-container ${o?"":"hidden"}`,style:m.styles.popper,children:o&&w.jsx(pb,{type:"inline",queryId:(D=r.filter)!=null&&D.startsWith("Filter [Temp] ")&&!((S=r.filter)!=null&&S.includes("Filter [Temp]"))?"":r.filter,destroy:()=>{s(!1)},setPreview:T=>{p(T)}})})]})};class WJ extends C.Modal{constructor(n,r,a){super(n);me(this,"root");me(this,"setPreview");this.filter=r,this.setPreview=a}onOpen(){var r,a;const{contentEl:n}=this;this.root=Ap(n),this.root.render(w.jsx(Bo,{store:Ee,context:mt,children:w.jsx("div",{className:"thino-inline-filter-container",children:w.jsx(pb,{type:"modal",queryId:(r=this.filter)!=null&&r.startsWith("Filter [Temp] ")&&!((a=this.filter)!=null&&a.includes("Filter [Temp]"))?"":this.filter,destroy:()=>{this.close()},setPreview:o=>{this.setPreview(o)}})})}))}onClose(){var n;(n=this.root)==null||n.unmount()}}const px=()=>{const{dailyNotesState:{app:e},globalState:{isMobileView:t,showSiderbarInMobileView:n}}=A.useContext(mt),[r]=A.useState($.createRef());A.useEffect(()=>{if(!r.current)return;const o=r.current;C.setIcon(o,"refresh-cw")},[r.current]);const a=A.useCallback(async()=>{if(!(t&&n)){if(Tu){const o=Qw(e);await Tu(o)}await Te.fetchAllMemos()}},[]);return w.jsx("span",{className:"refresh-icon",ref:r,onClick:()=>{a(),r&&r.current.firstElementChild.toggleClass("rotate-hidden",!0),setTimeout(()=>{r&&r.current.firstElementChild.toggleClass("rotate-hidden",!1)},1e3)}})},ay=()=>{const{locationState:{query:{filter:e}},globalState:{isMobileView:t},queryState:{queries:n}}=A.useContext(mt),[r,a]=A.useState("THINO");A.useEffect(()=>{const s=Et.getQueryById(e);a(s?s.title:"THINO")},[e,n]);const o=A.useCallback(s=>{s.stopPropagation(),Qe.setShowSiderbarInMobileView(!0)},[]);return w.jsxs("div",{className:"section-header-container memos-header-container",children:[w.jsxs("div",{className:"title-text",children:[w.jsx(so,{when:t,children:w.jsx("button",{ref:s=>{s&&C.setIcon(s,"menu")},className:"btn action-btn clickable-icon",onClick:o})}),w.jsx("span",{className:"normal-text",children:r}),w.jsx(px,{})]}),w.jsxs("div",{className:"memos-header-search-section",children:[w.jsx(D8,{}),w.jsx(b8,{}),w.jsx(mb,{}),w.jsx(Fp,{})]})]})},$J=()=>{const{dailyNotesState:{settings:e,app:t,verifyState:n},globalState:{manifest:r,showSiderbarInMobileView:a,isMobileView:o}}=A.useContext(mt),[s,c]=A.useState("Memos"),[d,p]=A.useState(!1);A.useEffect(()=>{e&&c(e.UserName)},[e]);const m=A.useCallback(()=>{He.pushHistory("/"),He.clearQuery()},[]),g=()=>{const v=document.querySelector(".memos-sidebar-wrapper"),D=document.querySelector(".menu-btns-popup");D.style.top=70-v.scrollTop+"px",p(!0)};return w.jsxs("div",{className:"user-banner-container",children:[w.jsxs("div",{className:"userinfo-header-container",children:[w.jsxs("div",{className:"userinfo-container",onClick:()=>{t.setting.open(),t.setting.openTabById(r.id||"obsidian-memos")},children:[w.jsx("div",{ref:v=>{if(e!=null&&e.MomentsIcon){v==null||v.empty();return}e!=null&&e.MomentsIcon||v&&C.setIcon(v,"Memos")},className:"thino-user-icon",style:{backgroundImage:`url(${e==null?void 0:e.MomentsIcon})`}}),w.jsxs("div",{className:"thino-user-info",children:[w.jsxs("span",{className:"username-container",children:[w.jsx("span",{"aria-label":s==="MEMO 😉"?"THINO 😉":s||"THINO",className:"username-text",onClick:m,children:s==="MEMO 😉"?"THINO 😉":s||"THINO"}),w.jsx("span",{className:`user-pro-badge ${n?"activated":""}`,onClick:()=>{t.setting.open(),t.setting.openTabById(r.id||"obsidian-memos")},children:"PRO"})]}),(e==null?void 0:e.MomentsQuote)&&w.jsx("span",{className:"thino-user-quote",children:e==null?void 0:e.MomentsQuote})]})]}),w.jsxs("span",{className:"btn-group",children:[(e==null?void 0:e.DefaultThemeForThino)==="modern"&&!o&&w.jsx(px,{}),w.jsx("span",{ref:v=>{v&&v.hasChildNodes()||v&&C.setIcon(v,"more-horizontal")},className:"btn action-btn menu-popup-btn",onClick:g}),a&&w.jsx("span",{ref:v=>{v&&v.hasChildNodes()||v&&C.setIcon(v,"x")},className:"btn action-btn",onClick:()=>{Qe.setShowSiderbarInMobileView(!1)}})]}),w.jsx(a8,{shownStatus:d,setShownStatus:p})]}),w.jsx(E1,{statusType:"banner"})]})},L2=()=>{const{queryState:{queries:e},dailyNotesState:{app:t},locationState:{query:{filter:n}}}=A.useContext(mt),r=af(),[a,o]=A.useState([]);return A.useEffect(()=>{const s=e.filter(c=>{var d,p;return!((d=c.id)!=null&&d.toString().startsWith("Filter [Temp]"))&&!((p=c.id)!=null&&p.toString().includes("Filter [Temp]"))}).sort((c,d)=>{if(d.pinnedAt&&!c.pinnedAt)return 1;if(c.pinnedAt&&!d.pinnedAt)return-1;const p=Ue.getTimeStampByDate(c.pinnedAt||c.createdAt);return Ue.getTimeStampByDate(d.pinnedAt||d.createdAt)-p});o(s)},[e]),A.useEffect(()=>{Et.getMyAllQueries().catch(()=>{}).finally(()=>{r.setFinish()})},[t]),w.jsxs("div",{className:"queries-wrapper",children:[w.jsxs("span",{className:"title-text",children:[w.jsx("span",{className:"normal-text",children:N("QUERY")}),w.jsx("span",{ref:s=>{s&&C.setIcon(s,"plus")},className:"btn create-query-btn",onClick:()=>Xw()})]}),w.jsx(so,{when:r.isSucceed&&a.length===0,children:w.jsx("div",{className:"create-query-btn-container",children:w.jsx("span",{className:"btn",onClick:()=>Xw(),children:N("CREATE FILTER")})})}),w.jsx("div",{className:"queries-container",children:a.map(s=>w.jsx(GJ,{query:s,isActive:s.id===n},`${s.id}-${C.moment(s.createdAt,"YYYY/MM/DD HH:mm:ss").format("x")}`))})]})},GJ=e=>{const{query:t,isActive:n}=e,[r,a]=ki(!1),[o,s]=ki(!1),c=()=>{He.setMemoFilter(n?"":t.id)},d=T=>{T.stopPropagation(),a()},p=()=>{a(!1)},m=async T=>{if(T.stopPropagation(),o)try{await Et.deleteQuery(t.id)}catch(E){new C.Notice(E.message)}else s()},g=T=>{T.stopPropagation(),Xw(t.id)},v=async T=>{T.stopPropagation();try{t.pinnedAt?await Et.unpinQuery(t.id):await Et.pinQuery(t.id),Et.editQuery({...t,pinnedAt:t.pinnedAt?"":Ue.getDateTimeString(Date.now())})}catch(E){console.error(E)}},D=()=>{s(!1)},S=A.useMemo(()=>w.jsxs("div",{className:"action-btns-container",children:[w.jsxs("span",{className:"btn",onClick:v,children:[w.jsx("span",{ref:T=>{T&&C.setIcon(T,t.pinnedAt?"pin-off":"pin")},className:"icon-text"}),w.jsx("span",{className:"normal-text",children:t.pinnedAt?N("UNPIN"):N("PIN")})]}),w.jsxs("span",{className:"btn",onClick:g,children:[w.jsx("span",{ref:T=>{T&&!T.hasChildNodes()&&C.setIcon(T,"edit")},className:"icon-text"}),w.jsx("span",{className:"normal-text",children:N("EDIT")})]}),w.jsxs("span",{className:`btn delete-btn ${o?"final-confirm":""}`,onClick:m,onMouseLeave:D,children:[w.jsx("span",{ref:T=>{T&&!T.hasChildNodes()&&C.setIcon(T,"trash-2")},className:"icon-text"}),w.jsx("span",{className:"normal-text",children:N(o?"CONFIRM!":"DELETE")})]})]}),[t.pinnedAt,o]);return w.jsx(w.Fragment,{children:w.jsxs("div",{className:`query-item-container ${n?"active":""}`,onClick:c,children:[w.jsxs("div",{className:"query-text-container",children:[w.jsx("span",{ref:T=>{T&&!T.hasChildNodes()&&C.setIcon(T,"filter")},className:"icon-text"}),w.jsxs("span",{className:"query-text",children:[t.title,t.pinnedAt&&" 📌"]})]}),w.jsxs("div",{className:"btns-container",children:[w.jsx("span",{ref:T=>{T&&!T.hasChildNodes()&&C.setIcon(T,"more-horizontal")},className:"btn action-btn toggle-btn",onClick:d}),w.jsx("div",{className:`action-btns-wrapper ${r?"":"hidden"}`,onMouseLeave:p,children:S})]})]})})},R2=()=>{var v,D;const{locationState:{query:{tag:e,filter:t}},dailyNotesState:{app:n},memoState:{tags:r,tagsNum:a,memos:o}}=A.useContext(mt),s=t&&((v=t==null?void 0:t.toString())==null?void 0:v.startsWith("Filter [Temp] "))&&Et.getQueryById(t),[c,d]=A.useState([]),[p,m]=A.useState(((D=n||app)==null?void 0:D.loadLocalStorage("thino-tag-sort-order"))||"alphabetical");A.useEffect(()=>{var T;const S=(T=n||app)==null?void 0:T.loadLocalStorage("thino-temp-tags");d(S||[])},[]),A.useEffect(()=>{Te.updateTagsState()},[o]),A.useEffect(()=>{const S=Array.from(r).sort(),T={subTags:[]};for(const E of S){const O=E.split("/");let k=T,j="";for(let F=0;Fz.text===j);if(R||(R={key:B,text:j,count:a[j]||0,subTags:[],parent:k},k.subTags.push(R)),F===O.length-1){let z=R.parent;for(;z;)z.count||(z.count=0),z.count+=a[j]||0,z=z.parent}k=R}}d(T.subTags)},[r]),A.useEffect(()=>{var S;Te.initialized&&((S=n||app)==null||S.saveLocalStorage("thino-temp-tags",c))},[c]);const g=S=>{S.stopPropagation();const T=new C.Menu;for(const E of["alphabetical","alphabeticalReverse","byCount","byCountReverse"])T.addItem(O=>{O.setTitle(N(E)).onClick(()=>{m(E),n==null||n.saveLocalStorage("thino-tag-sort-order",E)}).setChecked(p===E)}),E==="alphabeticalReverse"&&T.addSeparator();T.showAtMouseEvent(S.nativeEvent)};return w.jsxs("div",{className:"tags-wrapper",children:[w.jsxs("div",{className:"tags-header title-text",children:[w.jsx("span",{className:"normal-text",children:N("Frequently Used Tags")}),w.jsx("span",{ref:S=>{S&&C.setIcon(S,"arrow-down-narrow-wide")},className:"tags-sort-btn",onClick:g})]}),w.jsxs("div",{className:"tags-container",children:[c.sort(qJ(p)).map((S,T)=>w.jsx(mx,{tag:S,tagQuery:e,filterQuery:s},S.text+"-"+T)),w.jsx(so,{when:c.length<5&&Te.initialized,children:w.jsxs("span",{className:"tag-tip-container",children:[N("Input")," ",w.jsxs("span",{className:"code-text",children:[N("#Tag")," "]}),N("to create tag"),"..."]})})]})]})},mx=e=>{const{tag:t,tagQuery:n,filterQuery:r}=e,a=n===t.text||r&&JSON.parse(r.querystring).find(m=>m.type==="TAG"&&m.value.value===t.text),o=t.subTags.length>0,[s,c]=ki(!1),d=async m=>{var g;if(m.ctrlKey||m.metaKey){const{verifyState:v}=Xe.getState(),D=!C.Platform.isDesktop&&await((g=window.Capacitor)==null?void 0:g.Plugins.Device.getId()),S=C.Platform.isDesktop?await vn():D.identifier||D.uuid;if(!(v&&(v==null?void 0:v.appId)===S)){qt();return}const E=He.getState().query.filter;if(E&&(E!=null&&E.startsWith("Filter [Temp] "))){const k=Et.getQueryById(E).querystring,j=JSON.parse(k);let F;if(j.some(B=>B.type==="TAG"&&B.value.value===t.text)){if(F=j.filter(R=>R.value.value!==t.text),F.length===0){He.setMemoFilter("");return}const B=Et.createTempQuery(`Filter [Temp] ${Math.random().toString(36).substring(7)}`,JSON.stringify([{...F[0],relation:"AND"},...F.slice(1)]));Et.pushQuery(B),He.setMemoFilter(B.id)}else{F=[...j,{type:"TAG",value:{value:t.text,operator:"CONTAIN"},relation:"OR"}];const B=Et.createTempQuery(`Filter [Temp] ${Math.random().toString(36).substring(7)}`,JSON.stringify(F));Et.pushQuery(B),He.setMemoFilter(B.id)}}else if(n){He.setTagQuery("");const O=Et.createTempQuery(`Filter [Temp] ${Math.random().toString(36).substring(7)}`,JSON.stringify([{type:"TAG",value:{value:n,operator:"CONTAIN"},relation:"AND"},{type:"TAG",value:{value:t.text,operator:"CONTAIN"},relation:"OR"}]));Et.pushQuery(O),He.setMemoFilter(O.id)}else if(!n){const O=Et.createTempQuery(`Filter [Temp] ${Math.random().toString(36).substring(7)}`,JSON.stringify([{type:"TAG",value:{value:t.text,operator:"CONTAIN"},relation:"AND"}]));Et.pushQuery(O),He.setMemoFilter(O.id)}Ue.copyTextToClipboard(`#${t.text} `),["/","/recycle","/archive","/daily"].includes(He.getState().pathname)||He.setPathname("/");return}if(a){if(He.setTagQuery(""),r){const D=JSON.parse(r.querystring).filter(T=>T.value.value!==t.text);if(D.length===0){He.setMemoFilter("");return}const S=Et.createTempQuery(`Filter [Temp] ${Math.random().toString(36).substring(7)}`,JSON.stringify([{...D[0],relation:"AND"},...D.slice(1)]));Et.pushQuery(S),He.setMemoFilter(S.id)}}else await Ue.copyTextToClipboard(`#${t.text} `),["/","/recycle","/archive","/daily"].includes(He.getState().pathname)||He.setPathname("/"),He.setTagQuery(t.text)},p=m=>{m.stopPropagation(),c()};return w.jsxs(w.Fragment,{children:[w.jsxs("div",{className:`tag-item-container ${a?"active":""}`,onClick:d,children:[w.jsxs("div",{className:"tag-text-container",children:[w.jsx("span",{ref:m=>{m&&C.setIcon(m,"hash")},className:"btn tag-btn"}),w.jsx("span",{className:"tag-text",children:t.key})]}),w.jsxs("div",{className:"btns-container",children:[w.jsx("span",{className:"tag-count",children:t.count}),o?w.jsx("span",{ref:m=>{m&&C.setIcon(m,"chevron-right")},className:`btn action-btn toggle-btn ${s?"shown":""}`,onClick:p}):null]})]}),o?w.jsx("div",{className:`subtags-container ${s?"":"hidden"}`,children:t.subTags.map((m,g)=>w.jsx(mx,{tag:m,tagQuery:n},m.text+"-"+g))}):null]})},B2=new Intl.Collator(void 0,{usage:"sort",sensitivity:"base",numeric:!0}).compare,aw={alphabetical:(e,t)=>B2(e.text,t.text),alphabeticalReverse:(e,t)=>-B2(e.text,t.text),byCount:(e,t)=>t.count-e.count,byCountReverse:(e,t)=>e.count-t.count},qJ=(e="byCount")=>aw.hasOwnProperty(e)?aw[e]:aw.alphabetical,_2=()=>{const{dailyNotesState:{app:e,settings:t,verifyState:n}}=A.useContext(mt),r=[{name:N("Random Review"),path:"/review",iconID:"star"},{name:N("ARCHIVE"),path:"/archive",iconID:"archive"},{name:N("Recycle bin"),path:"/recycle",iconID:"recycle"}],a=A.useRef([]);return A.useEffect(()=>{a.current.forEach((o,s)=>{o&&C.setIcon(o,r[s].iconID)})},[t,a]),w.jsx(w.Fragment,{children:w.jsx("div",{className:"path-entry-wrapper",children:r.map((o,s)=>w.jsx(w.Fragment,{children:w.jsxs("div",{className:`path-entry-container ${He.getState().pathname===o.path?"active":""} ${t.DeleteThinoDirectly&&o.path==="/recycle"?"hidden":""} ${o.path==="/review"&&"pro"}`,onClick:async()=>{var p;const c=!C.Platform.isDesktop&&await((p=window.Capacitor)==null?void 0:p.Plugins.Device.getId()),d=C.Platform.isDesktop?await vn():c.identifier||c.uuid;if(!n&&(n==null?void 0:n.appId)!==d&&o.path==="/review"){qt();return}if(He.setPathname(o.path),o.path==="/review"&&He.getState().pathname==="/review"){e.workspace.trigger("refresh-review-memos");return}He.clearQuery()},children:[w.jsx("span",{ref:c=>a.current[s]=c,className:"path-entry-icon"}),w.jsx("span",{className:"path-entry-text",children:o.name})]},s)}))})})},H2=e=>{const{dailyNotesState:{settings:t},locationState:n,globalState:{isMobileView:r,showSiderbarInMobileView:a}}=A.useContext(mt),o=A.useRef(null),s=A.useMemo(()=>c=>{var p,m,g;const d=Qe.getState().showSiderbarInMobileView;if(!d){window.removeEventListener("click",s,{capture:!0});return}(p=o.current)!=null&&p.contains(c.target)||(g=(m=o.current)==null?void 0:m.parentNode)!=null&&g.contains(c.target)&&(d&&c.stopPropagation(),Qe.setShowSiderbarInMobileView(!1),window.removeEventListener("click",s,{capture:!0}))},[]);return A.useEffect(()=>{Qe.setShowSiderbarInMobileView(!1)},[n]),A.useEffect(()=>{a?document.body.classList.add(Zb):document.body.classList.remove(Zb)},[a]),A.useEffect(()=>{r&&a&&window.addEventListener("click",s,{capture:!0})},[r,a]),w.jsxs("aside",{className:Xn("memos-sidebar-wrapper",e.className),ref:o,children:[e.children,w.jsx($J,{}),(t==null?void 0:t.DefaultThemeForThino)==="modern"&&!r?(e==null?void 0:e.sidebarPosition)==="right"?w.jsx(gp,{}):null:w.jsx(gp,{}),(t==null?void 0:t.DefaultThemeForThino)==="modern"&&!r?(e==null?void 0:e.sidebarPosition)==="left"?w.jsxs(w.Fragment,{children:[w.jsx(_2,{}),w.jsx(L2,{}),w.jsx(E1,{statusType:"sidebar"})]}):null:w.jsxs(w.Fragment,{children:[w.jsx(_2,{}),w.jsx(L2,{})]}),(t==null?void 0:t.DefaultThemeForThino)==="modern"&&!r?(e==null?void 0:e.sidebarPosition)==="right"?w.jsx(w.Fragment,{children:w.jsx(R2,{})}):null:w.jsx(w.Fragment,{children:w.jsx(R2,{})})]})},JJ=()=>{const{dailyNotesState:{settings:e}}=A.useContext(mt),[t,n]=$.useState(""),r=a=>{n(a.target.value)};return w.jsx("div",{className:"locked-screen-wrapper",children:w.jsxs("div",{className:"locked-screen-content",children:[w.jsx("div",{className:"locked-screen-header",children:w.jsx("div",{className:"locked-screen-header-title",children:N("Locked")})}),w.jsx("div",{className:"locked-screen-body",children:w.jsxs("div",{className:"locked-screen-body-content",children:[w.jsxs("div",{className:"locked-screen-body-content-text",children:[w.jsx("div",{className:"locked-screen-body-content-text-title",children:N("Thino is locked")}),w.jsx("div",{className:"locked-screen-body-content-text-desc",children:N("Please unlock Thino by input password")})]}),w.jsxs("div",{className:"locked-screen-body-content-inputer",children:[w.jsx("input",{onKeyDown:a=>{a.key==="Enter"&&((e==null?void 0:e.password)===t?Qe.setLocked(!1):new C.Notice(N("Password is incorrect")))},onChange:r,value:t,type:"password",className:"locked-screen-body-content-input"}),w.jsx("button",{className:"locked-screen-body-content-btn",onClick:()=>{(e==null?void 0:e.password)===t?Qe.setLocked(!1):new C.Notice(N("Password is incorrect"))},children:N("Unlock")})]})]})})]})})};function KJ(){const{dailyNotesState:{settings:e,verifyState:t},locationState:{pathname:n},globalState:{isMobileView:r,memoListView:a,globalEditorShown:o,locked:s}}=A.useContext(mt),c=A.useRef(null);return A.useEffect(()=>{if(!e.needVerify){Qe.setLocked(!1);return}Qe.setLocked(!0)},[e==null?void 0:e.needVerify]),A.useEffect(()=>{if(!c.current)return;(async()=>{var g;const p=!C.Platform.isDesktop&&await((g=window.Capacitor)==null?void 0:g.Plugins.Device.getId()),m=C.Platform.isDesktop?await vn():p.identifier||p.uuid;!t||(t==null?void 0:t.appId)!==m?c.current.toggleClass("hide-pro",!0):c.current.toggleClass("hide-pro",!1)})()},[t,c.current]),w.jsxs(w.Fragment,{children:[s&&w.jsx(JJ,{}),!s&&o&&w.jsx(Nu,{editorType:"block"}),!s&&!o&&w.jsx("section",{ref:c,id:"page-wrapper","data-path":n,className:Xn(`memos-${n==="/"?a:"list"}-view`,(e==null?void 0:e.DefaultThemeForThino)==="modern"?"modern":"classic"),children:w.jsxs(w.Fragment,{children:[w.jsx(H2,{sidebarPosition:"left",className:"left-sidebar"}),w.jsx("main",{className:"content-wrapper",children:hK(n)}),(e==null?void 0:e.DefaultThemeForThino)==="modern"&&!r?w.jsx(H2,{sidebarPosition:"right",className:"right-sidebar"}):null]})})]})}const QJ={"*":w.jsx(KJ,{})},XJ=e=>{const{memo:t,handleDeletedMemoAction:n}=e,{dailyNotesState:r}=A.useContext(mt),a={...t,createdAtStr:Ue.getDateTimeString(t.createdAt),deletedAtStr:Ue.getDateTimeString(t.deletedAt||t.createdAt)},o=$.useRef(null),s=$.useRef(null),[c,d]=$.useState(""),[p,m]=ki(!1),g={restore:A.useRef(null),delete:A.useRef(null),source:A.useRef(null)};A.useEffect(()=>{s&&(C.setIcon(g.restore.current,"archive-restore"),C.setIcon(g.delete.current,"trash"),C.setIcon(g.source.current,"home"))},[s]),A.useEffect(()=>{if(!o.current||!s.current||o.current.hasChildNodes()&&t.content===c||!r.view)return;const E=r.view;d(t.content),o.current.hasChildNodes()&&o.current.empty();async function O(){var j;await C.MarkdownRenderer.render(r.app,t.content+`
`,o.current,t.path,E);const k=(j=o.current)==null?void 0:j.querySelectorAll(".internal-link");k==null||k.forEach(F=>{const B=F,R=B.getAttribute("data-href");if(!R)return;r.app.metadataCache.getFirstLinkpathDest(R,t.path)||F.classList.add("is-unresolved"),B.addEventListener("mouseover",H=>{H.stopPropagation(),r.app.workspace.trigger("hover-link",{event:H,source:"thino",hoverParent:E.containerEl,targetEl:B,linktext:R,sourcePath:B.href})})})}O()},[t.content,s]);const v=async()=>{if(p)try{await Te.deleteMemoById(a.id),n(a.id)}catch(E){new C.Notice(E.message)}else m()},D=async()=>{switch(a.sourceType){case"DAILY":await w1(a.id,a.path);break;case"CANVAS":await D1(a.id,a.path);break;case"MULTI":await v1(a.path);break;case"FILE":await b1(a.id,a.path);break}},S=async()=>{try{const E=await Te.restoreMemoById(a.id),O=r.app,k=O==null?void 0:O.loadLocalStorage("tokenForSync");E&&E.webId&&k&&r.settings.startSync&&await BT(E.webId),E&&Te.editMemo(E),n(a.id),new C.Notice(N("RESTORE SUCCEED"))}catch(E){new C.Notice(E.message)}},T=()=>{p&&m(!1)};return w.jsxs("div",{ref:s,className:`memo-wrapper ${"memos-"+a.id}`,onMouseLeave:T,children:[w.jsxs("div",{className:"memo-top-wrapper",children:[w.jsxs("span",{className:"time-text",children:[N("DELETE AT")," ",a.deletedAtStr]}),w.jsxs("div",{className:"btns-container",children:[w.jsx("span",{ref:E=>{E&&C.setIcon(E,"more-horizontal")},className:"btn more-action-btn"}),w.jsx("div",{className:"more-action-btns-wrapper",children:w.jsxs("div",{className:"more-action-btns-container",children:[w.jsxs("div",{className:"more-action-menu-item",children:[w.jsx("span",{ref:g.restore,className:"more-action-item-icon"}),w.jsx("span",{className:"btn restore-btn",onClick:S,children:N("RESTORE")})]}),w.jsxs("div",{className:"more-action-menu-item",children:[w.jsx("span",{ref:g.source,className:"more-action-item-icon"}),w.jsx("span",{className:"btn",onClick:D,children:N("SOURCE")})]}),w.jsxs("div",{className:"more-action-menu-item delete-menu-item",children:[w.jsx("span",{ref:g.delete,className:"more-action-item-icon"}),w.jsx("span",{className:`btn delete-btn ${p?"final-confirm":""}`,onClick:v,children:N(p?"CONFIRM!":"DELETE")})]})]})})]})]}),w.jsx("div",{ref:o,className:"memo-content-text",onContextMenu:E=>{E.preventDefault(),E.stopPropagation()}})]})},eK=({memos:e,query:t,HideDoneTasks:n})=>{const{tag:r,duration:a,type:o,text:s,filter:c}=t,d=Et.getQueryById(c);return!!(r||a&&a.from{let g=!0;if(m.thinoType!==void 0&&n&&m.thinoType==="TASK-DONE"&&(g=!1),m.content.contains("comment:")&&(g=!1),d){const v=JSON.parse(d.querystring);Array.isArray(v)&&(g=Wd(m,v))}if(r){const v=new Set;for(const D of Array.from(m.content.match(Fn)||[])){const T=D.replace(Fn,"$1").trim().split("/");let E="";for(const O of T)E+=O,v.add(E),E+="/"}for(const D of Array.from(m.content.match($n)||[])){const T=D.replace($n,"$1").trim().split("/");let E="";for(const O of T)E+=O,v.add(E),E+="/"}for(const D of Array.from(m.content.match(mr)||[])){const T=D.replace(mr,"$2").trim().split("/");let E="";for(const O of T)E+=O,v.add(E),E+="/"}v.has(r)||(g=!1)}return a&&a.froma.to)&&(g=!1),o&&(o==="NOT_TAGGED"&&(m.content.match(Fn)!==null||m.content.match(mr)!==null||m.content.match($n)!==null)||o==="LINKED"&&m.content.match(Bu)===null||o==="IMAGED"&&m.content.match(_u)===null||o==="CONNECTED"&&m.content.match(Il)===null)&&(g=!1),s&&!m.content.toLowerCase().includes(s.toLowerCase())&&(g=!1),g}):e.filter(m=>!m.content.contains("comment:"))},tK=()=>{const{locationState:{query:e},globalState:{isMobileView:t},memoState:{memos:n}}=A.useContext(mt),r=af(),[a,o]=A.useState([]),s=$.useRef(null);A.useEffect(()=>{const p=eK({memos:n.filter(m=>m.deletedAt!==""&&m.deletedAt),query:e,HideDoneTasks:!1});o(p),r.setFinish()},[n,s.current,e]);const c=A.useCallback(p=>{o(m=>m.filter(g=>g.id!==p))},[]),d=A.useCallback(()=>{Qe.setShowSiderbarInMobileView(!0)},[]);return w.jsxs("div",{className:"memo-trash-wrapper",ref:s,children:[w.jsxs("div",{className:"section-header-container",children:[w.jsxs("div",{className:"title-text",children:[w.jsx(so,{when:t,children:w.jsx("button",{ref:p=>{p&&C.setIcon(p,"menu")},className:"btn action-btn clickable-icon",onClick:d})}),w.jsxs("span",{className:"go-home-btn",onClick:()=>{He.clearQuery(),He.setPathname("/")},children:["🏠 ",N("Return To Home Page")]})]}),w.jsx(Fp,{})]}),w.jsx(Rp,{thinosCount:a.length,thinos:a}),r.isLoading?w.jsx("div",{className:"tip-text-container",children:w.jsx("span",{className:"tip-text",children:N("Fetching data...")})}):a.length===0?w.jsx("div",{className:"tip-text-container",children:w.jsx("span",{className:"tip-text",children:N("Here is No Memos.")})}):w.jsx("div",{className:"deleted-memos-container",children:a.map(p=>w.jsx(XJ,{memo:p,handleDeletedMemoAction:c},`${p.id}-${p.updatedAt}`))})]})},zg="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20height='24px'%20viewBox='0%200%2024%2024'%20width='24px'%20fill='currentColor'%3e%3cpath%20d='M0%200h24v24H0V0z'%20fill='none'/%3e%3cpath%20d='M19%203H5c-1.1%200-2%20.9-2%202v14c0%201.1.9%202%202%202h14c1.1%200%202-.9%202-2V5c0-1.1-.9-2-2-2zm0%2016H5V5h14v14zM17.99%209l-1.41-1.42-6.59%206.59-2.58-2.57-1.42%201.41%204%203.99z'/%3e%3c/svg%3e",Ug="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='24'%20height='24'%20fill='currentColor'%20viewBox='0%200%2024%2024'%3e%3cpath%20fill='none'%20d='M0%200h24v24H0V0z'/%3e%3cpath%20d='M19%205v14H5V5h14m0-2H5c-1.1%200-2%20.9-2%202v14c0%201.1.9%202%202%202h14c1.1%200%202-.9%202-2V5c0-1.1-.9-2-2-2z'/%3e%3c/svg%3e",nK=()=>{const{globalState:e}=A.useContext(mt),{useTinyUndoHistoryCache:t,shouldHideImageUrl:n,shouldSplitMemoWord:r,shouldUseMarkdownParser:a}=e,o=`👋 你好呀~欢迎使用memos!
* ✨ **开源项目**;
* 😋 精美且细节的视觉样式;
* 📑 体验优良的交互逻辑;`,s=()=>{Qe.setAppSetting({useTinyUndoHistoryCache:!t})},c=()=>{Qe.setAppSetting({shouldSplitMemoWord:!r})},d=()=>{Qe.setAppSetting({shouldHideImageUrl:!n})},p=()=>{Qe.setAppSetting({shouldUseMarkdownParser:!a})},m=async()=>{const g=Te.getState().memos.map(S=>({...S})),v=JSON.stringify(g),D=document.createElement("a");D.setAttribute("href","data:text/plain;charset=utf-8,"+encodeURIComponent(v)),D.setAttribute("download","data.json"),D.style.display="none",document.body.appendChild(D),D.click(),document.body.removeChild(D)};return w.jsxs(w.Fragment,{children:[w.jsxs("div",{className:"section-container preferences-section-container",children:[w.jsx("p",{className:"title-text",children:"Memo 显示相关"}),w.jsx("div",{className:"demo-content-container memo-content-text",dangerouslySetInnerHTML:{__html:pw(o)}}),w.jsxs("label",{className:"form-label checkbox-form-label",onClick:c,children:[w.jsx("span",{className:"normal-text",children:"中英文内容自动间隔"}),w.jsx("img",{className:"icon-img",src:r?zg:Ug})]}),w.jsxs("label",{className:"form-label checkbox-form-label",onClick:p,children:[w.jsx("span",{className:"normal-text",children:"部分 markdown 格式解析"}),w.jsx("img",{className:"icon-img",src:a?zg:Ug})]}),w.jsxs("label",{className:"form-label checkbox-form-label",onClick:d,children:[w.jsx("span",{className:"normal-text",children:"隐藏图片链接地址"}),w.jsx("img",{className:"icon-img",src:n?zg:Ug})]})]}),w.jsxs("div",{className:"section-container preferences-section-container",children:[w.jsx("p",{className:"title-text",children:"编辑器"}),w.jsxs("label",{className:"form-label checkbox-form-label",onClick:s,children:[w.jsxs("span",{className:"normal-text",children:["启用"," ",w.jsx("a",{target:"_blank",href:"https://github.com/boojack/tiny-undo",onClick:g=>g.stopPropagation(),rel:"noreferrer",children:"tiny-undo"})]}),w.jsx("img",{className:"icon-img",src:t?zg:Ug})]})]}),w.jsxs("div",{className:"section-container hidden",children:[w.jsx("p",{className:"title-text",children:"其他"}),w.jsx("div",{className:"btn-container",children:w.jsx("button",{className:"btn export-btn",onClick:m,children:"导出数据(JSON)"})})]})]})},rK=()=>{const{globalState:{isMobileView:e}}=A.useContext(mt);A.useEffect(()=>{Te.fetchAllMemos()},[]);const t=A.useCallback(()=>{Qe.setShowSiderbarInMobileView(!0)},[]);return w.jsxs("div",{className:"preference-wrapper",children:[w.jsx("div",{className:"section-header-container",children:w.jsxs("div",{className:"title-text",children:[w.jsx(so,{when:e,children:w.jsx("button",{className:"action-btn",onClick:t})}),w.jsx("span",{className:"normal-text",children:"账号与设置"})]})}),w.jsx("div",{className:"sections-wrapper",children:w.jsx(nK,{})})]})},aK=e=>{const{dailyNotesState:{app:t,settings:n,view:r}}=A.useContext(mt),{memo:a,handleUnarchivedMemoAction:o}=e,s=$.useRef(null),c=$.useRef(null),[d,p]=$.useState(""),m={...a,createdAtStr:Ue.getDateTimeString(a.createdAt),deletedAtStr:Ue.getDateTimeString(a.deletedAt||a.createdAt)},[g,v]=ki(!1),D={restore:A.useRef(null),delete:A.useRef(null),source:A.useRef(null)};A.useEffect(()=>{c&&(C.setIcon(D.restore.current,"archive-restore"),C.setIcon(D.delete.current,"trash"),C.setIcon(D.source.current,"home"))},[c]),A.useEffect(()=>{if(!s.current||!c.current||s.current.hasChildNodes()&&a.content===d||!r)return;p(a.content),s.current.hasChildNodes()&&s.current.empty();async function k(){var F,B;(F=s.current)==null||F.toggleClass(["markdown-rendered"],!0),await C.MarkdownRenderer.render(t,a.content+`
`,s.current,a.path,r);const j=(B=s.current)==null?void 0:B.querySelectorAll(".internal-link");j==null||j.forEach(R=>{const z=R,H=z.getAttribute("data-href");if(!H)return;t.metadataCache.getFirstLinkpathDest(H,a.path)||R.classList.add("is-unresolved"),z.addEventListener("mouseover",U=>{U.stopPropagation(),t.workspace.trigger("hover-link",{event:U,source:"thino",hoverParent:r.containerEl,targetEl:z,linktext:H,sourcePath:z.href})})})}k()},[a.content,c]);const S=async()=>{switch(m.sourceType){case"DAILY":await w1(m.id,m.path);break;case"CANVAS":await D1(m.id,m.path);break;case"MULTI":await v1(m.path);break;case"FILE":await b1(m.id,m.path);break}},T=async()=>{if(g)try{if(n.DeleteThinoDirectly)await Te.deleteMemoById(m.id);else{const k=await Te.hideMemoById(m.id);k&&Te.editMemo(k)}}catch(k){new C.Notice(k.message)}else v()},E=async()=>{try{const k=await Te.unarchiveMemo(m);k&&Te.editMemo(k),o(m.id),new C.Notice(N("RESTORE SUCCEED"))}catch(k){new C.Notice(k.message)}},O=()=>{g&&v(!1)};return w.jsxs("div",{ref:c,className:`memo-wrapper ${"memos-"+m.id}`,onMouseLeave:O,children:[w.jsxs("div",{className:"memo-top-wrapper",children:[w.jsxs("span",{className:"time-text",children:[N("ARCHIVED AT")," ",m.updatedAt]}),w.jsxs("div",{className:"btns-container",children:[w.jsx("span",{ref:k=>{k&&C.setIcon(k,"more-horizontal")},className:"btn more-action-btn"}),w.jsx("div",{className:"more-action-btns-wrapper",children:w.jsxs("div",{className:"more-action-btns-container",children:[w.jsxs("div",{className:"more-action-menu-item",children:[w.jsx("span",{ref:D.restore,className:"more-action-item-icon"}),w.jsx("span",{className:"btn restore-btn",onClick:E,children:N("RESTORE")})]}),w.jsxs("div",{className:"more-action-menu-item",children:[w.jsx("span",{ref:D.source,className:"more-action-item-icon"}),w.jsx("span",{className:"btn",onClick:S,children:N("SOURCE")})]}),w.jsxs("div",{className:"more-action-menu-item delete-menu-item",children:[w.jsx("span",{ref:D.delete,className:"more-action-item-icon"}),w.jsx("span",{className:`btn delete-btn ${g?"final-confirm":""}`,onClick:T,children:N(g?"CONFIRM!":"DELETE")})]})]})})]})]}),w.jsx("div",{ref:s,className:"memo-content-text"})]})},oK=({memos:e,query:t,HideDoneTasks:n})=>{const{tag:r,duration:a,type:o,text:s,filter:c}=t,d=Et.getQueryById(c);return!!(r||a&&a.from{let g=!0;if(m.thinoType!==void 0&&n&&m.thinoType==="TASK-DONE"&&(g=!1),m.content.contains("comment:")&&(g=!1),d){const v=JSON.parse(d.querystring);Array.isArray(v)&&(g=Wd(m,v))}if(r){const v=new Set;for(const D of Array.from(m.content.match(Fn)||[])){const T=D.replace(Fn,"$1").trim().split("/");let E="";for(const O of T)E+=O,v.add(E),E+="/"}for(const D of Array.from(m.content.match($n)||[])){const T=D.replace($n,"$1").trim().split("/");let E="";for(const O of T)E+=O,v.add(E),E+="/"}for(const D of Array.from(m.content.match(mr)||[])){const T=D.replace(mr,"$2").trim().split("/");let E="";for(const O of T)E+=O,v.add(E),E+="/"}v.has(r)||(g=!1)}return a&&a.froma.to)&&(g=!1),o&&(o==="NOT_TAGGED"&&(m.content.match(Fn)!==null||m.content.match(mr)!==null||m.content.match($n)!==null)||o==="LINKED"&&m.content.match(Bu)===null||o==="IMAGED"&&m.content.match(_u)===null||o==="CONNECTED"&&m.content.match(Il)===null)&&(g=!1),s&&!m.content.toLowerCase().includes(s.toLowerCase())&&(g=!1),g}):e.filter(m=>!m.content.contains("comment:"))},iK=()=>{const{locationState:{query:e},globalState:{isMobileView:t},memoState:{memos:n}}=A.useContext(mt),r=af(),[a,o]=A.useState([]),s=$.useRef(null);A.useEffect(()=>{const m=oK({memos:n.filter(g=>g.rowStatus==="ARCHIVED"&&g.deletedAt===""),query:e,HideDoneTasks:!1});o(m),r.setFinish()},[n,s.current,e]);const c=A.useCallback(m=>{o(g=>g.filter(v=>v.id!==m))},[]),d=A.useCallback(m=>{o(g=>g.filter(v=>v.id!==m))},[]),p=A.useCallback(()=>{Qe.setShowSiderbarInMobileView(!0)},[]);return w.jsxs("div",{className:"memo-trash-wrapper",ref:s,children:[w.jsxs("div",{className:"section-header-container",children:[w.jsxs("div",{className:"title-text",children:[w.jsx(so,{when:t,children:w.jsx("button",{ref:m=>{m&&C.setIcon(m,"menu")},className:"btn action-btn clickable-icon",onClick:p})}),w.jsxs("span",{className:"go-home-btn",onClick:()=>{He.clearQuery(),He.setPathname("/")},children:["🏠 ",N("Return To Home Page")]})]}),w.jsx(Fp,{})]}),w.jsx(Rp,{thinosCount:a.length,thinos:a}),r.isLoading?w.jsx("div",{className:"tip-text-container",children:w.jsx("p",{className:"tip-text",children:N("Fetching data...")})}):a.length===0?w.jsx("div",{className:"tip-text-container",children:w.jsx("p",{className:"tip-text",children:N("Here is No Memos.")})}):w.jsx("div",{className:"deleted-memos-container",children:a.map(m=>w.jsx(aK,{memo:m,handleUnarchivedMemoAction:d,handleDeletedMemoAction:c},`${m.id}-${m.updatedAt}`))})]})},sK=()=>{const{dailyNotesState:{app:e},locationState:{query:t},globalState:{isMobileView:n,changedByMemos:r},memoState:{memos:a}}=A.useContext(mt),o=af(),[s,c]=A.useState([]),[d,p]=A.useState([]),m=$.useRef(null),g=$.useRef(null),[v,D]=A.useState(!1),[S,T]=A.useState([]),E=$.useRef([]),O=A.useCallback(({memos:F,query:B,HideDoneTasks:R})=>{const{tag:z,duration:H,type:Y,text:U,filter:J}=B,Q=Et.getQueryById(J);return!!(z||H&&H.from{let ie=!0;if(pe.thinoType!==void 0&&R&&pe.thinoType==="TASK-DONE"&&(ie=!1),pe.content.contains("comment:")&&(ie=!1),Q){const se=JSON.parse(Q.querystring);Array.isArray(se)&&(ie=Wd(pe,se))}if(z){const se=new Set;for(const fe of Array.from(pe.content.match(Fn)||[])){const we=fe.replace(Fn,"$1").trim().split("/");let Z="";for(const G of we)Z+=G,se.add(Z),Z+="/"}for(const fe of Array.from(pe.content.match($n)||[])){const we=fe.replace($n,"$1").trim().split("/");let Z="";for(const G of we)Z+=G,se.add(Z),Z+="/"}for(const fe of Array.from(pe.content.match(mr)||[])){const we=fe.replace(mr,"$2").trim().split("/");let Z="";for(const G of we)Z+=G,se.add(Z),Z+="/"}se.has(z)||(ie=!1)}return H&&H.fromH.to)&&(ie=!1),Y&&(Y==="NOT_TAGGED"&&(pe.content.match(Fn)!==null||pe.content.match($n)!==null)||Y==="LINKED"&&pe.content.match(Bu)===null||Y==="IMAGED"&&pe.content.match(_u)===null||Y==="CONNECTED"&&pe.content.match(Il)===null)&&(ie=!1),U&&!pe.content.toLowerCase().includes(U.toLowerCase())&&(ie=!1),ie}):F},[]);A.useEffect(()=>{g.current&&(C.setIcon(g.current,"refresh-cw"),e.workspace.on("refresh-review-memos",j))},[g]),A.useEffect(()=>{if(!v)return;if(t){const R=[...O({memos:a,query:t,HideDoneTasks:!1})].sort(()=>Math.random()-Math.random()).slice(0,10);c(R),D(!1);return}const F=[...S].sort(()=>Math.random()-Math.random()).slice(0,10);c(F),D(!1)},[v]),A.useEffect(()=>{if(!(S.length>0))return;const F=[...S].sort(()=>Math.random()-Math.random()).slice(0,10);c(F),D(!1)},[S]),A.useEffect(()=>{m.current&&(T(O({memos:a,query:t,HideDoneTasks:!1}).filter(F=>F.rowStatus!=="ARCHIVED"&&!(F.deletedAt!==""&&F.deletedAt))),o.setFinish(),He.clearQuery())},[a,m.current]),A.useEffect(()=>{if(r&&E.current.length>0){const F=S.filter(R=>E.current.includes(R.id)),B=E.current.map(R=>F.find(z=>z.id===R)).filter(R=>R!==void 0);p(B);return}E.current=s.map(F=>F.id),p(s)},[s]),A.useEffect(()=>{if(s.length===0)return;const F=O({memos:s,query:t,HideDoneTasks:!1});p(F)},[t]);const k=A.useCallback(()=>{Qe.setShowSiderbarInMobileView(!0)},[]),j=()=>{D(!0)};return w.jsxs("div",{className:"memo-review-wrapper",ref:m,children:[w.jsx("div",{className:"section-header-container",children:w.jsxs("div",{className:"title-wrapper",children:[w.jsxs("div",{className:"title-btns-left-wrapper",children:[w.jsx(so,{when:n,children:w.jsx("button",{ref:F=>{F&&C.setIcon(F,"menu")},className:"btn action-btn clickable-icon",onClick:k})}),w.jsx("span",{ref:g,onClick:j,className:"refresh-icon"})]}),w.jsx("div",{className:"title-btns-right-wrapper",children:w.jsxs("span",{className:"go-home-btn",onClick:()=>{He.setPathname("/")},children:["🏠 ",N("Return To Home Page")]})})]})}),w.jsx(Rp,{}),o.isLoading?w.jsx("div",{className:"tip-text-container",children:w.jsx("span",{className:"tip-text",children:N("Fetching data...")})}):a.length===0?w.jsx("div",{className:"tip-text-container",children:w.jsx("span",{className:"tip-text",children:N("Here is No Memos.")})}):w.jsx("div",{className:"review-memos-container",children:d.map(F=>w.jsx(Sa,{memo:F},`${F==null?void 0:F.id}-${F.createdAt}`))})]})},gx=({memos:e,query:t,HideDoneTasks:n})=>{const{tag:r,duration:a,type:o,text:s,filter:c}=t,d=Et.getQueryById(c);return!!(r||a&&a.from{let g=!0;if(m.thinoType!==void 0&&n&&m.thinoType==="TASK-DONE"&&(g=!1),m.content.contains("comment:")&&(g=!1),d){const v=JSON.parse(d.querystring);Array.isArray(v)&&(g=Wd(m,v))}if(r){const v=new Set;for(const D of Array.from(m.content.match(Fn)||[])){const T=D.replace(Fn,"$1").trim().split("/");let E="";for(const O of T)E+=O,v.add(E),E+="/"}for(const D of Array.from(m.content.match($n)||[])){const T=D.replace($n,"$1").trim().split("/");let E="";for(const O of T)E+=O,v.add(E),E+="/"}for(const D of Array.from(m.content.match(mr)||[])){const T=D.replace(mr,"$2").trim().split("/");let E="";for(const O of T)E+=O,v.add(E),E+="/"}v.has(r)||(g=!1)}return a&&a.froma.to)&&(g=!1),o&&(o==="NOT_TAGGED"&&(m.content.match(Fn)!==null||m.content.match(mr)!==null||m.content.match($n)!==null)||o==="LINKED"&&m.content.match(Bu)===null||o==="IMAGED"&&m.content.match(_u)===null||o==="CONNECTED"&&m.content.match(Il)===null)&&(g=!1),s&&!m.content.toLowerCase().includes(s.toLowerCase())&&(g=!1),g}):e.filter(m=>!m.content.contains("comment:"))},lK=A.forwardRef((e,t)=>{const{currentDate:n,setCurrentDateStamp:r}=e,[a,o]=A.useState(!1),s=Ue.getDateStampByDate(Ue.getDateString(n)),c=A.useRef(null);A.useEffect(()=>{c.current&&(!a&&C.setIcon(c.current,"more-horizontal"),a&&C.setIcon(c.current,"x"))},[c.current,a]);const d=p=>{r(p)};return A.useImperativeHandle(t,()=>({closeDatePicker:()=>{o(!1)}})),w.jsxs(w.Fragment,{children:[w.jsxs("div",{className:"date-card-container",children:[w.jsxs("div",{className:"date-container-details",children:[w.jsxs("div",{className:"details-text",children:[C.moment(s,"x").format("dddd")+" ",w.jsx("div",{className:"date-text",children:C.moment(s,"x").format("MMM")+" "+C.moment(s,"x").format("DD")})]}),w.jsx("div",{className:"details-logo-text",children:N("Daily Memos")})]}),w.jsxs("div",{className:"date-container-info",children:[w.jsxs("div",{className:"date-container-info-text",children:["Week ",w.jsx("div",{className:"week-text",children:C.moment(s,"x").format("ww")}),"of ",w.jsx("div",{className:"year-text",children:C.moment(s,"x").format("YYYY")})]}),w.jsx("div",{ref:c,onClick:()=>o(!a)})]})]}),w.jsx(zy,{className:`date-picker ${a?"":"hidden"}`,datestamp:s,handleDateStampChange:d})]})}),uK=({thino:e})=>{const t=A.useCallback(()=>{$d(e)},[]);return w.jsxs("div",{className:"daily-thino-wrapper",children:[w.jsx("div",{className:"time-wrapper",onClick:t,children:w.jsx("span",{className:"normal-text",children:C.moment(e.createdAt,"YYYY/MM/DD HH:mm:ss").format("HH:mm")})}),w.jsx("div",{className:"daily-thino-container",children:w.jsx(Sa,{memo:e})})]})},cK=()=>{const{locationState:{query:e},globalState:{isMobileView:t},memoState:{memos:n},dailyNotesState:{settings:r,app:a}}=A.useContext(mt),o=af(),[s,c]=A.useState([]),[d,p]=A.useState(Ue.getDateStampByDate(Ue.getDateString(C.moment().format("YYYY-MM-DD HH:mm:ss")))),m=A.useRef(),g=A.useRef(null),v=$.useRef(null),D=A.useRef(null),[S,T]=A.useState(!1);A.useEffect(()=>{e.duration&&e.duration.from&&e.duration.to&&p(e.duration.from)},[e.duration]),A.useEffect(()=>{D.current&&(C.setIcon&&D&&!S&&C.setIcon(D.current,"share"),C.setIcon&&D&&S&&C.setIcon(D.current,"chrome"))},[D.current,S]),A.useEffect(()=>{const j=gx({memos:n,query:e,HideDoneTasks:!1}).filter(F=>Ue.getTimeStampByDate(F.createdAt)>=d&&Ue.getTimeStampByDate(F.createdAt)F.deletedAt==="").sort((F,B)=>Ue.getTimeStampByDate(F.createdAt)-Ue.getTimeStampByDate(B.createdAt));c(j),o.setFinish()},[n,d,v.current,e]);const E=A.useCallback(()=>{Qe.setShowSiderbarInMobileView(!0)},[]),O=async()=>{var k;m.current&&((k=m==null?void 0:m.current)==null||k.closeDatePicker()),T(!0),setTimeout(()=>{if(!g.current){T(!1);return}let j;document.body.hasClass("theme-dark")?j="#232323":j="#eaeaea",Zy(g.current,{backgroundColor:j,pixelRatio:window.devicePixelRatio*2}).then(F=>{if(r!=null&&r.AutoSaveWhenOnMobile&&C.Platform.isMobile){const B=F.split("base64,")[1];Oy(B,"image/png").arrayBuffer().then(async z=>{let H;const Y="png",U=bs();for(const J in U)if(U[J]instanceof C.TFile){H=U[J];break}H!==void 0&&await a.vault.createBinary(await vault.getAvailablePathForAttachments(`Pasted Image ${C.moment().format("YYYYMMDDHHmmss")}`,Y,H),z)})}Wy({imgUrl:F}),T(!1)}).catch(()=>{T(!1)})},0)};return w.jsxs("div",{className:"daily-thinos-list-wrapper",ref:v,children:[w.jsxs("div",{className:"section-header-container",children:[w.jsxs("div",{className:"title-text",children:[w.jsx(so,{when:t,children:w.jsx("button",{ref:k=>{k&&C.setIcon(k,"menu")},className:"btn action-btn clickable-icon",onClick:E})}),w.jsxs("span",{className:"go-home-btn",onClick:()=>{He.clearQuery(),He.setPathname("/")},children:["🏠 ",N("Return To Home Page")]})]}),w.jsxs("div",{className:"header-right-section",children:[w.jsxs("div",{className:"btns-container",children:[w.jsx("span",{ref:k=>{C.setIcon&&k&&C.setIcon(k,"chevron-left")},className:"btn btn-text",onClick:()=>p(k=>k-Mi)}),w.jsx("span",{ref:k=>{C.setIcon&&k&&C.setIcon(k,"chevron-right")},className:"btn btn-text",onClick:()=>p(k=>k+Mi)}),w.jsx("span",{ref:D,className:Xn("btn btn-text share-btn",S?"generating":""),onClick:O})]}),w.jsx(mb,{}),w.jsx(Fp,{})]})]}),w.jsx(Rp,{thinosCount:s.length,thinos:s}),w.jsx("div",{className:"daily-thinos-view-wrapper",children:w.jsxs("div",{ref:g,className:"daily-thinos-view-container",children:[w.jsx(lK,{ref:m,currentDate:new Date(d),setCurrentDateStamp:p}),o.isLoading?w.jsx("div",{className:"tip-text-container",children:w.jsx("p",{className:"tip-text",children:N("Fetching data...")})}):s.length===0?w.jsx("div",{className:"tip-container",children:w.jsx("p",{className:"tip-text",children:N("Noooop!")})}):w.jsx("div",{className:"daily-thinos-list-container",children:s.map(k=>w.jsx(uK,{thino:k},`${k.id}-${k.updatedAt}`))})]})})]})},dK={"/recycle":w.jsx(tK,{}),"/setting":w.jsx(rK,{}),"/archive":w.jsx(iK,{}),"/review":w.jsx(sK,{}),"/daily":w.jsx(cK,{}),"*":w.jsx(_J,{})},yx=e=>t=>{for(const n of Object.keys(e))if(n===t)return e[n];return e["*"]},fK=yx(QJ),hK=yx(dK);function pK({app:e}){const{locationState:{pathname:t},dailyNotesState:{settings:n}}=A.useContext(mt);return A.useEffect(()=>{Te.fetchAllMemos()},[]),!a1()&&!e.plugins.getPlugin("periodic-notes")&&(n!=null&&n.EnabledLocationList.find(r=>r.value==="DAILY"))&&new C.Notice(N("Check if you opened Daily Notes Plugin Or Periodic Notes Plugin")),w.jsx(Bo,{store:Ee,context:mt,children:fK(t)})}function mK(e){const t=e.view.canvas;if(!t||!e.view.file.path.endsWith(".thino.canvas")||t.thinoBtn)return;const n=t.wrapperEl.createDiv({cls:"thino-canvas-menu-btn"}),r=Ap(n);r.render(w.jsx($.StrictMode,{children:w.jsx(Bo,{store:Ee,context:mt,children:w.jsx(gK,{leaf:e})})})),t.thinoBtn=r,Xe.getState().view.appendRoot({root:r,canvas:t})}function gK({leaf:e}){const{memoState:{memos:t},locationState:{query:n}}=A.useContext(mt),r=$.useRef(null),a=$.useRef(null),[o,s]=$.useState(!1),[c,d]=$.useState([]),[p,m]=$.useState([]),{tag:g,duration:v,type:D,text:S,filter:T}=n,E=Et.getQueryById(T),O=!!(g||v&&v.from{a.current&&C.setIcon(a.current,"eraser")},[a.current]),A.useEffect(()=>{r.current&&C.setIcon(r.current,"Memos")},[r.current]),A.useEffect(()=>{const k=e.view.file.path;d(t.filter(j=>j.sourceType==="CANVAS"&&j.path===k))},[t]),A.useEffect(()=>{if(c.length===0||!n)return;const k=gx({memos:c,query:n,HideDoneTasks:!1});m(k)},[n,c]),A.useEffect(()=>{if(!n)return;const k=new Set(p.map(F=>F.id)),j=Array.from(e.view.canvas.nodes.values());j.forEach(F=>{F.nodeEl.toggleVisibility(!0),e.view.canvas.getEdgesForNode(F).forEach(B=>{var R,z,H;(R=B.lineGroupEl)==null||R.toggleClass("hidden",!1),(z=B.lineStartGroupEl)==null||z.toggleClass("hidden",!1),(H=B.lineEndGroupEl)==null||H.toggleClass("hidden",!1)})}),j.filter(F=>!k.has(F.id)).forEach(F=>{F.nodeEl.toggleVisibility(!1),e.view.canvas.getEdgesForNode(F).forEach(B=>{var R,z,H;(R=B.lineGroupEl)==null||R.toggleClass("hidden",!0),(z=B.lineStartGroupEl)==null||z.toggleClass("hidden",!0),(H=B.lineEndGroupEl)==null||H.toggleClass("hidden",!0)})})},[p]),w.jsxs(w.Fragment,{children:[w.jsx("div",{ref:r,className:"btn-container",onClick:()=>s(!o)}),o&&w.jsxs("div",{className:"thino-canvas-menu",children:[w.jsxs("div",{className:"thino-canvas-filter-group",children:[w.jsx(mb,{}),w.jsx(Fp,{}),O&&w.jsx("div",{ref:a,className:"clear-query",onClick:()=>{He.clearQuery()}})]}),w.jsx(gp,{initThinos:p})]})]})}const _r="thino_view";class yK extends C.EditorSuggest{constructor(n,r){super(n);me(this,"root");me(this,"editor");me(this,"cursor");me(this,"plugin");this.plugin=r,this.suggestEl.toggleClass("thino-date-selector",!0)}checkInMemosView(n){var o;const r=n.containerEl;if(!r)return!1;const a=(o=r.parentElement)==null?void 0:o.parentElement;return(a==null?void 0:a.classList.contains("common-editor-inputer"))||!1}onTrigger(n,r){const o=r.getLine(n.line)[n.ch-1];return this.checkInMemosView(r)&&o==="@"?(this.cursor=n,this.editor=r,C.Platform.isMobile?(new mE(this.app,"text",s=>{this.selectSuggestion(parseInt(s),new MouseEvent("click"))}).open(),null):{start:{line:n.line,ch:n.ch-1},end:n,query:""}):null}getSuggestions(){return[parseInt(C.moment().startOf("day").format("x"))]}renderSuggestion(n,r){r.empty(),this.root=Lo.createRoot(r),this.root.render(w.jsx($.StrictMode,{children:w.jsx(zy,{className:"editor-date-picker",datestamp:n,handleDateStampChange:this.selectSuggestion.bind(this)})}))}selectSuggestion(n,r){var c,d,p;if(r instanceof KeyboardEvent||r instanceof PointerEvent&&!r.target.closest(".day-item"))return;const a=(c=this.app.workspace.getLeavesOfType("thino_view")[0])==null?void 0:c.view;(d=a==null?void 0:a.contentEl.find(".action-btn.list-or-task.list"))==null||d.click();let o="",s="";switch(this.plugin.settings.InsertDateFormat){case"Dataview":o="[due::",s="]";break;case"Tasks":o="📆";break}this.editor.replaceRange(o+C.moment(n).format("YYYY-MM-DD")+s,{line:this.cursor.line,ch:this.cursor.ch-1},this.cursor),(p=this.root)==null||p.unmount(),this.close()}}class vK extends C.EditorSuggest{constructor(n,r){super(n);me(this,"root");me(this,"editor");me(this,"cursor");me(this,"plugin");me(this,"memos",[]);this.plugin=r,this.memos=Te.getState().memos.filter(a=>!a.deletedAt&&a.rowStatus!=="ARCHIVED")}checkInMemosView(n){var o;const r=n.containerEl;if(!r)return!1;const a=(o=r.parentElement)==null?void 0:o.parentElement;return(a==null?void 0:a.classList.contains("common-editor-inputer"))||!1}fuzzySearchItemsOptimized(n,r){const a=C.prepareFuzzySearch(n);return r.map(o=>{const s=a(o.content);return s?{item:o,match:s}:null}).filter(Boolean)}onTrigger(n,r){if(!this.checkInMemosView(r))return null;const o=r.getLine(n.line).slice(0,n.ch);if(o.lastIndexOf("~")===-1)return null;const s=o.slice(o.lastIndexOf("~")+1,n.ch);if(o[o.lastIndexOf("~")-1]!==" "&&o.lastIndexOf("~")!==0)return null;const c=s.trim();return this.memos=Te.getState().memos.filter(d=>!d.deletedAt&&d.rowStatus!=="ARCHIVED"),{start:{line:n.line,ch:n.ch-c.length},end:n,query:c}}getSuggestions(n){return n.query?this.fuzzySearchItemsOptimized(n.query,this.memos).sort((a,o)=>o.match.score-a.match.score).map(a=>a.item).map(a=>({time:a.createdAt,id:a.id,content:a.content})):this.memos.map(a=>({time:a.createdAt,id:a.id,content:a.content}))}renderSuggestion(n,r){r.toggleClass("thino-suggestion",!0),r.createEl("div",{cls:"thino-suggestion-time",text:n.time}),r.createEl("div",{cls:"thino-suggestion-container"}).createEl("div",{cls:"thino-suggestion-content",text:n.content})}selectSuggestion(n){const r=n.id;this.context.editor.replaceRange("MARK: [@THINO]("+r+")",{line:this.context.end.line,ch:this.context.start.ch-1},this.context.end)}}class wK{constructor(){me(this,"path","/fake-file-that-generated-for-thino.png");me(this,"basename","fake-file-that-generated-for-thino");me(this,"extension","png");me(this,"deleted",!1);me(this,"name","fake-file-that-generated-for-thino.png");me(this,"parent",null);me(this,"stat");me(this,"vault",null)}static[Symbol.hasInstance](t){return t instanceof C.TFile}setPath(t){}getNewPathAfterRename(t){}getShortName(){}cache(t){}updateCacheLimit(){}}class wl extends C.ItemView{constructor(n,r){super(n);me(this,"scope",new C.Scope(this.app.scope));me(this,"root");me(this,"mobileHeaderRoot");me(this,"plugin");me(this,"hoverPopover");me(this,"memosComponent");me(this,"rootList",[]);me(this,"editor",null);me(this,"navigation",!1);me(this,"file",this.app.vault.getMarkdownFiles()[0]||new wK);me(this,"handleUpdateInstance",n=>{this.editor=n.editor});this.plugin=r,this.registerScope()}getDisplayText(){return"Thino"}getIcon(){return"Memos"}getViewType(){return _r}getMode(){return"source"}canToggleBacklinks(){return!1}registerScope(){const{scope:n}=this;n.register(["Mod"],"Enter",()=>{}),n.register([],"i",r=>{const a=r.target;a.tagName==="INPUT"||a.tagName==="TEXTAREA"||a.hasClass("cm-line")||a.hasClass("cm-content")||(r.preventDefault(),this.plugin.app.workspace.trigger("focus-on-textarea"))}),n.register(["Mod"],"f",r=>{const a=r.target;a.tagName==="INPUT"||a.tagName==="TEXTAREA"||a.hasClass("cm-line")||a.hasClass("cm-content")||(r.preventDefault(),this.plugin.app.workspace.trigger("focus-on-searchBar"))}),n.register([],"o",r=>{const a=r.target;a.tagName==="INPUT"||a.tagName==="TEXTAREA"||a.hasClass("cm-line")||a.hasClass("cm-content")||(r.preventDefault(),this.plugin.app.workspace.trigger("focus-on-searchBar"))}),n.register([],"Escape",()=>{setTimeout(()=>{this.plugin.app.workspace.trigger("blur-on-memos")},20)})}async onFileDeleted(n){var d,p,m;const r=Wh(n,"day"),a=n.path.contains(".thino")&&n.path.contains(".canvas"),o=n.path.contains(".thino")&&n.path.contains(".md"),s=((d=this.plugin.settings)==null?void 0:d.MemoOtherSaveLocation.MemoDefaultMultiFilePath)||"Thino",c=(m=((p=n.parent)==null?void 0:p.path)||n.path)==null?void 0:m.contains(s==null?void 0:s.trim());(r||a&&this.plugin.settings.EnabledLocationList.find(g=>g.value==="CANVAS"))&&(await Te.removeMemosInFile(n),Te.updateTagsState()),c&&this.plugin.settings.EnabledLocationList.find(g=>g.value==="MULTI")&&(await Te.removeMemosInFile(n,s),Te.updateTagsState()),o&&this.plugin.settings.EnabledLocationList.find(g=>g.value==="FILE")&&(await Te.removeMemosInFile(n),Te.updateTagsState())}async onFileModified(n){var d;if(Qe.getState().changedByMemos){Qe.setChangedByMemos(!1);return}const r=Wh(n,"day"),a=n.path.contains(".thino")&&n.path.contains(".canvas"),o=n.path.contains(".thino")&&n.path.contains(".md"),s=((d=this.plugin.settings)==null?void 0:d.MemoOtherSaveLocation.MemoDefaultMultiFilePath)||"Thino",c=n.parent.path.contains(s==null?void 0:s.trim());if(r||a&&this.plugin.settings.EnabledLocationList.find(p=>p.value==="CANVAS")){await Te.updateMemosInFile(n),Te.updateTagsState();return}c&&this.plugin.settings.EnabledLocationList.find(p=>p.value==="MULTI")&&(await Te.updateMemosInFile(n,s),Te.updateTagsState()),o&&this.plugin.settings.EnabledLocationList.find(p=>p.value==="FILE")&&(await Te.updateMemosInFile(n),Te.updateTagsState())}async onFileCreated(n){var r;if(this.app.workspace.layoutReady&&this.memosComponent){const a=Wh(n,"day"),o=n.path.contains(".thino")&&n.path.contains(".canvas"),s=n.path.contains(".thino")&&n.path.contains(".md"),c=((r=this.plugin.settings)==null?void 0:r.MemoOtherSaveLocation.MemoDefaultMultiFilePath)||"Thino",d=n.parent.path.contains(c==null?void 0:c.trim());if(a){await Xe.updateDailyNotes(n,!1),await Te.updateMemosInFile(n),Te.updateTagsState();return}if(o&&this.plugin.settings.EnabledLocationList.find(p=>p.value==="CANVAS")){await Te.updateMemosInFile(n),Te.updateTagsState();return}d&&this.plugin.settings.EnabledLocationList.find(p=>p.value==="MULTI")&&(await Te.updateMemosInFile(n,c),Te.updateTagsState()),s&&this.plugin.settings.EnabledLocationList.find(p=>p.value==="FILE")&&(await Te.updateMemosInFile(n),Te.updateTagsState())}}async onResize(){var r;super.onResize();const n=this.leaf;if(n&&n.height!==0){if(n.view.containerEl.toggleClass("tiny-view",n.width<600),n.view.containerEl.toggleClass("waterfall-small-group",n.width<1300),n.width>950){n.view.containerEl.classList.toggle("mobile-view",!1),Qe.setIsMobileView(n.width<=950);return}if((r=this.plugin.settings)!=null&&r.ShowLeftSideBar&&!C.Platform.isMobile)return;n.view.containerEl.classList.toggle("mobile-view",!0),Qe.setIsMobileView(n.width<=950)}}appendToHeader(){const n=this.leaf.view.titleContainerEl;n&&(this.mobileHeaderRoot=Lo.createRoot(n),this.mobileHeaderRoot.render(w.jsx($.StrictMode,{children:w.jsx(Bo,{store:Ee,context:mt,children:w.jsx(ay,{})})})))}appendRoot({root:n,canvas:r}){this.rootList.push({root:n,canvas:r})}async onOpen(){this.navigation=this.plugin.settings.navigation,await this.onResize(),this.onFileCreated=this.onFileCreated.bind(this),this.onFileDeleted=this.onFileDeleted.bind(this),this.onFileModified=this.onFileModified.bind(this),C.Platform.isTablet&&document.body.toggleClass("is-tablet",!0),C.Platform.isMobile&&!C.Platform.isTablet&&this.appendToHeader(),this.registerEvent(this.app.vault.on("create",this.onFileCreated)),this.registerEvent(this.app.vault.on("delete",this.onFileDeleted)),this.registerEvent(this.app.vault.on("modify",C.debounce(this.onFileModified,2e3,!0))),this.registerEvent(this.app.workspace.on("active-leaf-change",n=>{n.view.getViewType()==="canvas"&&mK(n)}));try{this.root=Lo.createRoot(this.contentEl),Xe.setView(this),this.root.render(w.jsx($.StrictMode,{children:w.jsx(pK,{app:this.plugin.app})}))}catch(n){console.error(n)}}onunload(){var n;super.onunload(),this.root.unmount(),(n=this.mobileHeaderRoot)==null||n.unmount(),this.rootList.forEach(r=>{var a,o,s;(a=r==null?void 0:r.root)==null||a.unmount(),(o=r==null?void 0:r.canvas)!=null&&o.thinoBtn&&(r.canvas.thinoBtn=void 0),(s=r==null?void 0:r.canvas)!=null&&s.wrapperEl.find(".thino-canvas-menu-btn")&&r.canvas.wrapperEl.find(".thino-canvas-menu-btn").detach()})}}const Y2={Memos:' '};function bK(){Object.keys(Y2).forEach(e=>{C.addIcon(e,Y2[e])})}class z2 extends gE{fuzzySearchItemsOptimized(t,n){const r=C.prepareFuzzySearch(t);return n.map(a=>{const o=r(a.path);return o?{item:a,match:o,score:o.score}:null}).sort((a,o)=>(o==null?void 0:o.score)-(a==null?void 0:a.score)).filter(Boolean)}getSuggestions(t){const r=app.vault.getFiles().filter(o=>["png","jpg","jpeg","gif"].includes(o.extension)),a=t.toLowerCase();return this.fuzzySearchItemsOptimized(a,r).map(o=>o.item)}renderSuggestion(t,n){var o;const r=t.basename,a=((o=t.parent)==null?void 0:o.path)||"";n.toggleClass("thino-image-suggest-item",!0),n.createSpan({cls:"suggestion-name",text:r}),n.createSpan({cls:"suggestion-path",text:a})}selectSuggestion(t){this.inputEl.value=t.path,this.inputEl.trigger("input"),this.close()}}const gb=typeof Buffer=="function";typeof TextDecoder=="function"&&new TextDecoder;const U2=typeof TextEncoder=="function"?new TextEncoder:void 0,DK="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",Zh=Array.prototype.slice.call(DK);(e=>{let t={};return e.forEach((n,r)=>t[n]=r),t})(Zh);const bi=String.fromCharCode.bind(String);typeof Uint8Array.from=="function"&&Uint8Array.from.bind(Uint8Array);const SK=e=>e.replace(/=/g,"").replace(/[+\/]/g,t=>t=="+"?"-":"_"),IK=e=>{let t,n,r,a,o="";const s=e.length%3;for(let c=0;c255||(r=e.charCodeAt(c++))>255||(a=e.charCodeAt(c++))>255)throw new TypeError("invalid character found");t=n<<16|r<<8|a,o+=Zh[t>>18&63]+Zh[t>>12&63]+Zh[t>>6&63]+Zh[t&63]}return s?o.slice(0,s-3)+"===".substring(s):o},vx=typeof btoa=="function"?e=>btoa(e):gb?e=>Buffer.from(e,"binary").toString("base64"):IK,TK=gb?e=>Buffer.from(e).toString("base64"):e=>{let n=[];for(let r=0,a=e.length;r{if(e.length<2){var t=e.charCodeAt(0);return t<128?e:t<2048?bi(192|t>>>6)+bi(128|t&63):bi(224|t>>>12&15)+bi(128|t>>>6&63)+bi(128|t&63)}else{var t=65536+(e.charCodeAt(0)-55296)*1024+(e.charCodeAt(1)-56320);return bi(240|t>>>18&7)+bi(128|t>>>12&63)+bi(128|t>>>6&63)+bi(128|t&63)}},CK=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,xK=e=>e.replace(CK,EK),V2=gb?e=>Buffer.from(e,"utf8").toString("base64"):U2?e=>TK(U2.encode(e)):e=>vx(xK(e)),MK=(e,t=!1)=>t?SK(V2(e)):V2(e),ow=C.Platform.isDesktop&&require("os"),wx=async()=>{var r,a;let e="";if(C.Platform.isDesktop)e=await vn();else{const o=await((r=window.Capacitor)==null?void 0:r.Plugins.Device.getId());e=o.identifier||o.uuid}let t;if(ow)t=JSON.stringify({hostname:ow.hostname(),platform:ow.platform(),machineid:e});else{const o=await((a=window.Capacitor)==null?void 0:a.Plugins.Device.getInfo()),s=o==null?void 0:o.model,c=o==null?void 0:o.platform;t=JSON.stringify({hostname:s||("mobile"+C.Platform.isMobile?Math.random().toString(36).substring(7):""),platform:c||"mobile",machineid:e})}return MK(t)},NK=async()=>{var t;let e="";if(C.Platform.isDesktop)e=await vn();else{const n=await((t=window.Capacitor)==null?void 0:t.Plugins.Device.getId());e=n.identifier||n.uuid}return e},kK={General:"chef-hat",Thino:"Memos",Interface:"brush",Share:"share-2",Advanced:"cog"},bx=[{value:"DAILY",target:"ProcessEntriesBelow",insert:"InsertAfter"},{value:"CANVAS",target:"MemoDefaultCanvasPath"},{value:"MULTI",target:"MemoDefaultMultiFilePath"},{value:"FILE",target:"MemoDefaultSingleFilePath"}],cs={FirstLoaded:!1,StartDate:"Sunday",InsertAfter:"",UserName:"THINO 😉",ProcessEntriesBelow:"",Language:"en",SaveMemoButtonLabel:"NOTE",SaveMemoButtonIcon:"✍️",ShareFooterStart:"{ThinoNum} Thino {UsedDay} Day",ShareFooterEnd:"✍️ by {UserName}",DefaultPrefix:"List",DefaultTimePrefix:"HH:mm",UseDailyOrPeriodic:"Daily",InsertDateFormat:"Tasks",DefaultEditorLocation:"Top",UseButtonToShowEditor:!1,FocusOnEditor:!0,OpenDailyMemosWithMemos:!0,HideDoneTasks:!1,ShowTaskLabel:!1,MobileAndDesktop:"All",OpenMemosAutomatically:!1,ShowTime:!0,ShowDate:!0,AddBlankLineWhenDate:!1,AutoSaveWhenOnMobile:!1,DeleteFileName:"delete",QueryFileName:"query",UseVaultTags:!1,SetCustomBackgroundImage:!1,SetCustomMemoFooter:!1,DefaultLightBackgroundImage:"",DefaultDarkBackgroundImage:"",DefaultMemoComposition:"{TIME} {CONTENT}",CommentOnMemos:!1,CommentsInOriginalNotes:!1,FetchMemosMark:"#memo",FetchMemosFromNote:!1,ShowCommentOnMemos:!1,ShowLeftSideBar:!1,MemoListView:"list",MemoSaveLocation:"DAILY",MemoOtherSaveLocation:{MemoDefaultCanvasPath:"basic.thino.canvas",MemoDefaultMultiFilePath:"Thino",MemoDefaultSingleFilePath:"basic.thino.md"},MemoDailyTarget:5,HeatmapColorScheme:"default",EnabledHttpApi:!1,HttpApiIpType:"localhost",HttpApiPort:"43999",AutoDownloadImage:!1,EditorType:"obsidian",EnabledLocationList:bx,DeleteThinoDirectly:!1,CaptureKey:{EnableCaptureKey:!1,OpenThinoGlobally:"CommandOrControl+Shift+T",ShowNearMouse:!1},startSync:!1,tokenForVerify:{},saveThinoType:"FILE",showDayMark:!1,dayMarkRange:"day",navigation:!1,password:"",needVerify:!1,addTagAutomatically:!1,addTagPosition:"End",addTagWithNewline:!1,chatViewStyle:"default",MomentsBackgroundImage:"https://images.pexels.com/photos/531767/pexels-photo-531767.jpeg",MomentsIcon:"https://images.pexels.com/photos/256514/pexels-photo-256514.jpeg",MomentsQuote:"Share your thino with the world",DefaultThemeForThino:"modern",LastUpdatedVersion:"0.0.0",ShareToThinoWithText:!1,ShareToThinoWithTextAppend:"",ShareToThinoWithTextPrepend:"",ShareToThinoWithTextNewline:"none",hidePinnedGroup:!1,DifferentInsertTarget:!1,InsertAfterForTask:"",ProcessContentTarget:"custom",InsertType:"custom"};function AK({plugin:e}){const{dailyNotesState:{verifyState:t}}=A.useContext(mt),[n,r]=A.useState(!1),[a,o]=A.useState(!1),[s,c]=A.useState(""),[d,p]=A.useState("");A.useEffect(()=>{NK().then(v=>{p(v)})},[]);const m=async()=>{var T;const v=s,D=!C.Platform.isDesktop&&await((T=window.Capacitor)==null?void 0:T.Plugins.Device.getId()),S=C.Platform.isDesktop?await vn():D.identifier||D.uuid;v&&(e.settingTab.updateSettings("tokenForVerify",{...e.settings.tokenForVerify,[S]:v}),e.verify().then(E=>{E&&(r(!0),Qe.setRefresh(!0),setTimeout(()=>{e.settingTab.display()},200),e.registerToolbarCheck()),new C.Notice(N(E?"Verify successfully":"Failed to verify"))}).catch(E=>{new C.Notice(N("Failed to verify"))}))},g=async v=>{c(v)};return w.jsx("div",{className:"thino-verify-component",children:t?w.jsxs("div",{className:"thino-verify-content verified",children:[w.jsx("div",{className:"thino-verified-text",children:N("You have verified your account. Congrats!")}),w.jsx("div",{className:"thino-description-link",children:w.jsxs("p",{children:[N("If you have any questions, please contact us."),w.jsx("span",{className:"thino-url",onClick:()=>{const v=localStorage.getItem("language");v&&(v==="zh"||v==="zh-TW")?window.open("https://pkmer.cn"):window.open("https://thino.pkmer.net/en/")},children:"@ PKMer"})]})})]}):w.jsxs("div",{className:"thino-verify-content",children:[w.jsxs("div",{className:"thino-description-link",children:[N("You can buy a license from")+"->",w.jsxs("span",{className:"thino-url",onClick:()=>{const v=localStorage.getItem("language");v&&(v==="zh"||v==="zh-TW")?window.open("https://pkmer.cn/products/thino"):window.open("https://thino.pkmer.net/en/#price")},children:[" ","PKMer"]})]}),w.jsx("textarea",{className:"thino-verify-textarea",value:s,onChange:v=>g(v.target.value),placeholder:N("Input activation code here")}),w.jsxs("div",{className:"thino-button-container",children:[w.jsxs("div",{className:"thino-button-group",children:[w.jsx("button",{onClick:async()=>{try{const v=await wx();await navigator.clipboard.writeText(v),o(!0)}catch(v){console.error(v),new C.Notice("Failed to copy id");return}new C.Notice(N("Copied to clipboard Successfully"))},children:N("Copy Thino id")}),w.jsx("button",{onClick:()=>{if(!a){new C.Notice(N("Please copy Thino id first"));return}const v=localStorage.getItem("language");v&&(v==="zh"||v==="zh-TW")?window.open("https://pkmer.cn/products/UserProfile/#tab-21&getCode"):window.open("https://pkmer.net/en/userprofile/#tab-21&getCode"),r(!0)},children:N("Get activation code")}),s&&w.jsx(w.Fragment,{children:w.jsx("button",{onClick:async()=>{await m()},children:N("Verify")})})]}),n?w.jsx("p",{children:N("After you verify your account, please refresh this page.")}):""]}),w.jsxs("div",{className:"thino-description-link",children:[N("If you have any questions, please contact us."),w.jsx("span",{className:"thino-url",onClick:()=>{const v=localStorage.getItem("language");v&&(v==="zh"||v==="zh-TW")?window.open("https://pkmer.cn"):window.open("https://thino.pkmer.net/en/")},children:"@ PKMer"})]})]})})}class FK extends C.PluginSettingTab{constructor(n,r){super(n,r);me(this,"plugin");me(this,"applyDebounceTimer",0);me(this,"tabContent",new Map);me(this,"selectedTab","General");me(this,"search");me(this,"searchSettingInfo",new Map);me(this,"searchZeroState");me(this,"navigateEl");me(this,"passwordMatched",!1);me(this,"root");me(this,"debounceApplySettingsUpdate",C.debounce(async()=>{await this.plugin.saveSettings()},100,!0));me(this,"debounceDisplay",C.debounce(async()=>{await this.display()},300,!0));this.plugin=r}updateSettings(n,r){this.plugin.settings={...this.plugin.settings,[n]:r},this.applySettingsUpdate()}applySettingsUpdate(){this.debounceApplySettingsUpdate(),Te.updateTagsState()}async hide(){var n;(n=this.root)==null||n.unmount(),this.passwordMatched=!1}async display(){var n;await this.plugin.loadSettings(),this.root&&((n=this.root)==null||n.unmount()),this.containerEl.empty(),this.containerEl.toggleClass("memos-settings",!0),C.Platform.isMobile&&this.containerEl.toggleClass("memos-mobile",!0),this.generateSettingsTitle(),this.addTabHeader()}generateSettingsTitle(){const n=this.containerEl.createDiv("memos-setting-title");n.createEl("h2",{text:"Thino"}),this.generateSearchBar(n)}addTabHeader(){const n=this.containerEl.createEl("nav",{cls:"memos-setting-header"});this.navigateEl=n.createDiv("memos-setting-tab-group");const r=this.containerEl.createDiv("memos-setting-content");this.updateOldData(),this.createTabAndContent("General",this.navigateEl,r,(a,o)=>this.generateGeneralSettings(o,a)),this.createTabAndContent("Thino",this.navigateEl,r,(a,o)=>this.generateMemosSettings(o,a)),this.createTabAndContent("Interface",this.navigateEl,r,(a,o)=>this.generateThemeSettings(o,a)),this.createTabAndContent("Share",this.navigateEl,r,(a,o)=>this.generateShareSettings(o,a)),this.createTabAndContent("Advanced",this.navigateEl,r,(a,o)=>this.generateAdvancedSettings(o,a)),this.createSearchZeroState(r)}updateOldData(){this.plugin.settings.UserName.startsWith("MEMO ")&&(this.plugin.settings.UserName="THINO 😉"),this.plugin.settings.ShareFooterStart.contains("{Memo")&&(this.plugin.settings.ShareFooterStart=this.plugin.settings.ShareFooterStart.replace("{MemosNum}","{ThinoNum}").replace("memos","thino")),this.applySettingsUpdate()}generateSearchBar(n){const r=new C.Setting(n);r.settingEl.style.border="none",r.addSearch(a=>{this.search=a}),this.search.setPlaceholder(N("Search all settings")),this.search.inputEl.oninput=()=>{for(const a of this.tabContent){const o=a[1];o.navButton.removeClass("memos-navigation-item-selected"),o.content.show(),o.heading.show();const s=this.search.getValue();this.selectedTab==""&&s.trim()!=""&&this.searchSettings(s.toLowerCase()),this.selectedTab=""}this.navigateEl.addClass("memos-setting-searching")},this.search.inputEl.onblur=()=>{this.navigateEl.removeClass("memos-setting-searching")},this.search.onChange(a=>{var o;if(a===""){this.triggerTabChange((o=this.tabContent.get("General"))==null?void 0:o.navButton,"General");return}this.searchSettings(a.toLowerCase())})}triggerTabChange(n,r){if(this.selectedTab==r)return;n.toggleClass("memos-navigation-item-selected",!0);const a=this.tabContent.get(r);if((a==null?void 0:a.content).show(),this.selectedTab!=""){const o=this.tabContent.get(this.selectedTab);o==null||o.navButton.removeClass("memos-navigation-item-selected"),(o==null?void 0:o.content).hide()}else{this.searchZeroState.hide();for(const o of this.searchSettingInfo)for(const s of o[1])s.containerEl.show();for(const o of this.tabContent){const s=o[1];s.heading.hide(),r!==o[0]&&s.content.hide()}}this.selectedTab=r}createTabAndContent(n,r,a,o){const s=this.selectedTab===n,c=r.createDiv("memos-navigation-item");c.toggleClass("memos-desktop",!0),C.setIcon(c.createEl("div",{cls:"memos-navigation-item-icon"}),kK[n]),c.createSpan({text:N(n)}),c.onclick=()=>{this.triggerTabChange(c,n)};const d=a.createDiv("memos-tab-settings"),p=d.createEl("h2",{cls:"memos-setting-heading",text:n+" Settings"});p.hide(),d.id=n.toLowerCase().replace(" ","-"),s?c.addClass("memos-navigation-item-selected"):d.hide(),o&&o(d,n),this.tabContent.set(n,{content:d,heading:p,navButton:c})}searchSettings(n){var o;const r=new Set,a=(s,c)=>{s.show(),r.has(c)||r.add(c)};for(const s of this.searchSettingInfo){const c=s[0],d=s[1];for(const p of d)if(n.trim()===""||(o=p.alias)!=null&&o.includes(n)||p.description.includes(n)||p.name.includes(n))a(p.containerEl,c);else if(p.options&&p.options.length>0)for(const m of p.options){if(m.description.toLowerCase().includes(n)||m.name.toLowerCase().includes(n)){a(p.containerEl,c);break}else if(m.options){for(const g of m.options)if(g.description.toLowerCase().includes(n)||g.value.toLowerCase().includes(n)){a(p.containerEl,c);break}}p.containerEl.hide()}else p.containerEl.hide()}for(const s of this.tabContent)r.has(s[0])?s[1].heading.show():s[1].heading.hide();r.size===0?this.searchZeroState.show():this.searchZeroState.hide()}addSettingToMasterSettingsList(n,r,a="",o="",s=[],c=""){var p;const d={containerEl:r,name:a.toLowerCase(),description:o.toLowerCase(),options:s,alias:c};this.searchSettingInfo.has(n)?(p=this.searchSettingInfo.get(n))==null||p.push(d):this.searchSettingInfo.set(n,[d])}createSearchZeroState(n){this.searchZeroState=n.createDiv(),this.searchZeroState.hide(),this.searchZeroState.createEl(C.Platform.isMobile?"h3":"h2",{text:"No settings match search"}).style.textAlign="center"}generateGeneralSettings(n,r){this.customHeading(n,r)}async generateThemeSettings(n,r){var d;const a=Xe.getState().verifyState,o=!C.Platform.isDesktop&&await((d=window.Capacitor)==null?void 0:d.Plugins.Device.getId()),s=C.Platform.isDesktop?await vn():o.identifier||o.uuid,c=a&&(a==null?void 0:a.appId)===s;await this.customNameAndTheme(n,r,c)}async generateMemosSettings(n,r){var d;const a=Xe.getState().verifyState,o=!C.Platform.isDesktop&&await((d=window.Capacitor)==null?void 0:d.Plugins.Device.getId()),s=C.Platform.isDesktop?await vn():o.identifier||o.uuid,c=a&&(a==null?void 0:a.appId)===s;this.setPasswordSettings(n,r),this.addMemoSettings(n,r),this.customFileNameSettings(n,r,c),this.addThinoProSettings(n,r,c)}async generateShareSettings(n,r){var d;const a=Xe.getState().verifyState,o=!C.Platform.isDesktop&&await((d=window.Capacitor)==null?void 0:d.Plugins.Device.getId()),s=C.Platform.isDesktop?await vn():o.identifier||o.uuid,c=a&&(a==null?void 0:a.appId)===s;new Ve(r,this).setHeading().setTab(n).setName(N("Copy filtered results")),this.copyMemosSettings(n,r),new Ve(r,this).setHeading().setTab(n).setName(N("Share image")),this.shareMemosSettings(n,r),C.Platform.isMobile&&this.shareToThinosSettings(n,r,c)}async generateAdvancedSettings(n,r){var d;this.saveDataSettings(n,r),this.fetchDataSettings(n,r),this.navigationSettings(n,r);const a=Xe.getState().verifyState,o=!C.Platform.isDesktop&&await((d=window.Capacitor)==null?void 0:d.Plugins.Device.getId()),s=C.Platform.isDesktop?await vn():o.identifier||o.uuid,c=a&&(a==null?void 0:a.appId)===s;this.setGlobalSettings(n,r,c)}async customNameAndTheme(n,r,a){new Ve(r,this).setName(N("Theme for Thino")).setDesc(N("Set the theme for Thino")).setTab(n).addDropdown(async s=>{s.addOption("modern","Modern"),s.addOption("classic","Classic"),s.setValue(this.plugin.settings.DefaultThemeForThino).onChange(async c=>{this.plugin.settings.DefaultThemeForThino=c,this.applySettingsUpdate()})}),new Ve(r,this).setTab(n).setHeading().setName(N("Interface Details"));let o;new Ve(r,this).setName(N("Heatmap Color Scheme")).setDesc(N("Set different color scheme for heatmap.")).setTab(n).addDropdown(async s=>{o=s,o.addOption("default",N("Default")),o.addOption("gray",N("Gray")),o.addOption("grass",N("Grass")),o.addOption("flame",N("Flame")),o.addOption("olive",N("Olive")),o.addOption("ice",N("Ice")),o.addOption("magenta",N("Magenta")),o.setValue(this.plugin.settings.HeatmapColorScheme).onChange(async c=>{this.plugin.settings.HeatmapColorScheme=c,this.applySettingsUpdate()})}),new Ve(r,this).setName(N("Show Tasks Label")).setDesc(N("Show tasks label near the time text. False by default")).setTab(n).addToggle(s=>s.setValue(this.plugin.settings.ShowTaskLabel).onChange(async c=>{this.plugin.settings.ShowTaskLabel=c,this.applySettingsUpdate()})),new Ve(r,this).setName(N("Save Memo button label")).setDesc(N("The text shown on the save Memo button in the UI. 'NOTEIT' by default.")).setTab(n).addText(s=>s.setPlaceholder(cs.SaveMemoButtonLabel).setValue(this.plugin.settings.SaveMemoButtonLabel).onChange(async c=>{this.plugin.settings.SaveMemoButtonLabel=c,this.applySettingsUpdate()})),C.Platform.isDesktop&&new Ve(r,this).setName(N("Always Show Leaf Sidebar on PC")).setDesc(N("Show left sidebar on PC even when the leaf width is less than 875px. False by default.")).setTab(n).addToggle(s=>s.setValue(this.plugin.settings.ShowLeftSideBar).onChange(async c=>{this.plugin.settings.ShowLeftSideBar=c,this.applySettingsUpdate()})),await this.getEditorLocation(r,n),new Ve(r,this).setHeading().setTab(n).setName("💎 "+N("Pro features")),this.addThinoDailyMarkSettings(n,r,a),new Ve(r,this).setName(N("Chat view style")).setDesc(N("Set the style of chat view")).setTab(n).addDropdown(async s=>{o=s,o.addOption("default","Default"),o.addOption("fluent","Fluent"),o.addOption("inline","Inline"),o.setValue(this.plugin.settings.chatViewStyle).onChange(async c=>{if(!a){qt();return}this.plugin.settings.chatViewStyle=c,this.applySettingsUpdate()})}),this.addThinoMomentsSettings(n,r,a)}addThinoDailyMarkSettings(n,r,a){let o;new Ve(r,this).setName(N("Show day mark in thino list")).setDesc(N("Show day mark on the top of daily range thino. False by default.")).setTab(n).addToggle(s=>s.setValue(this.plugin.settings.showDayMark).onChange(async c=>{if(!a){qt();return}this.plugin.settings.showDayMark=c,this.applySettingsUpdate(),this.debounceDisplay()})),this.plugin.settings.showDayMark&&(new Ve(r,this).setName(N("Day mark range")).setDesc(N("Set the range of day mark. Day by default.")).setTab(n).addDropdown(async s=>{o=s,o.addOption("day","day"),o.addOption("week","week"),o.addOption("month","month"),o.addOption("quarter","quarter"),o.addOption("year","year"),o.setValue(this.plugin.settings.dayMarkRange).onChange(async c=>{this.plugin.settings.dayMarkRange=c,this.applySettingsUpdate()})}),new Ve(r,this).setName(N("Hide pinned group")).setDesc(N("Hide pinned group in thino list. False by default.")).setTab(n).addToggle(s=>s.setValue(this.plugin.settings.hidePinnedGroup).onChange(async c=>{if(!a){qt();return}this.plugin.settings.hidePinnedGroup=c,this.applySettingsUpdate()})))}addThinoMomentsSettings(n,r,a){new Ve(r,this).setTab(n).setName(N("Background image for moments view")).setDesc(N("Set the background image for moments view")).addText(o=>o.setPlaceholder("URL").setValue(this.plugin.settings.MomentsBackgroundImage).onChange(async s=>{a&&(this.plugin.settings.MomentsBackgroundImage=s,this.applySettingsUpdate())}))}async getEditorLocation(n,r){let a;C.Platform.isMobile&&(new Ve(n,this).setName(N("Default editor position on mobile")).setDesc(N("Set the default editor position on Mobile, 'Top' by default.")).setTab(r).addDropdown(async o=>{a=o,a.addOption("Top",N("Top")),a.addOption("Bottom",N("Bottom")),a.setValue(this.plugin.settings.DefaultEditorLocation).onChange(async s=>{this.plugin.settings.DefaultEditorLocation=s,this.applySettingsUpdate(),setTimeout(()=>{this.display()},200)})}),this.plugin.settings.DefaultEditorLocation!=="Top"&&new Ve(n,this).setName(N("Use button to show editor on mobile")).setDesc(N("Set a float button to call editor on mobile. Only when editor located at the bottom works.")).setTab(r).addToggle(o=>o.setValue(this.plugin.settings.UseButtonToShowEditor).onChange(async s=>{this.plugin.settings.UseButtonToShowEditor=s,this.applySettingsUpdate()})))}customHeading(n,r){new Ve(r,this).setHeading().setName(N("User info")).setTab(n),new Ve(r,this).setName(N("User name")).setDesc(N("Set your user name here. 'Memos 😏' By default")).setTab(n).addText(v=>v.setPlaceholder(cs.UserName).setValue(this.plugin.settings.UserName).onChange(async D=>{this.plugin.settings.UserName=D,this.applySettingsUpdate()})),new Ve(r,this).setTab(n).setName(N("User icon")).setDesc(N("Set user icon for thino")).addText(v=>v.setPlaceholder("URL").setValue(this.plugin.settings.MomentsIcon).onChange(async D=>{this.plugin.settings.MomentsIcon=D,this.applySettingsUpdate()})),new Ve(r,this).setTab(n).setName(N("User quote")).setDesc(N("Set user quote for thino")).addText(v=>v.setPlaceholder("Input anything here").setValue(this.plugin.settings.MomentsQuote).onChange(async D=>{this.plugin.settings.MomentsQuote=D,this.applySettingsUpdate()}));let a=!1;const o=document.createDocumentFragment();o.createEl("span",{text:N("Connect to PKMer Sync, you can check it in ")});const s=localStorage.getItem("language");let c;s&&s==="zh"?c="https://pkmer.cn/products/UserProfile/#tab-21&activateSync":c="https://thino.pkmer.net/en/",o.createEl("a",{text:N("PKMer Sync"),attr:{href:c}}),new Ve(r,this).setHeading().setName(N("Pro verification status")).setTab(n);const d=document.createDocumentFragment(),p=d.createEl("div",{cls:"thino-activation"}),m=new Ve(r,this).setName(N("Activate Pro Version")).setDesc(d).setTab(n);m.settingEl.toggleClass("thino-activation-setting",!0),m.nameEl.toggleClass("thino-activation-title",!0),this.root=Lo.createRoot(p),this.root.render(w.jsx(Bo,{store:Ee,context:mt,children:w.jsx(AK,{plugin:this.plugin})}));let g=!1;new Ve(r,this).setName(N("Deactivate")).setTab(n).addButton(v=>{v.setWarning().setButtonText(N("Remove")).onClick(async()=>{var T;if(!g){v.setButtonText(N("Confirm?")),g=!0;return}g=!1;const D=!C.Platform.isDesktop&&await((T=window.Capacitor)==null?void 0:T.Plugins.Device.getId()),S=C.Platform.isDesktop?await vn():D.identifier||D.uuid;this.plugin.settings.tokenForVerify[S]&&(delete this.plugin.settings.tokenForVerify[S],await this.plugin.saveSettings(),new C.Notice(N("Remove successfully"))),await this.plugin.verify(),Qe.setRefresh(!0),setTimeout(()=>{this.display()},20)})}),(s==="zh"||s==="zh-TW")&&new Ve(r,this).setHeading().setName(N("Sync service")).setTab(n),(s==="zh"||s==="zh-TW")&&new Ve(r,this).setName(N("Sync Thino via PKMer")).setDesc(o).setTab(n).addButton(v=>{var S;const D=(S=this.plugin.app)==null?void 0:S.loadLocalStorage("tokenForSync");v.setButtonText(N(D?"Unlink":"Link")).onClick(async()=>{var T;if(!D){const E=localStorage.getItem("language");E&&(E==="zh"||E==="zh-TW")?window.open("https://pkmer.cn/products/UserProfile/#tab-21&activateSync"):window.open("https://thino.pkmer.net/en/");return}if(!a){v.setButtonText(N("Confirm?")),a=!0;return}a=!1,D&&((T=this.plugin.app)==null||T.saveLocalStorage("tokenForSync",""),new C.Notice(N("Remove successfully"))),Qe.setRefresh(!0),setTimeout(()=>{this.display()},20)})}),(s==="zh"||s==="zh-TW")&&this.showSyncStatus(r,n)}showSyncStatus(n,r){var o;(o=this.plugin.app)!=null&&o.loadLocalStorage("tokenForSync")&&(new Ve(n,this).setName(N("Save thino type when sync local")).setDesc(N("Set the default save thino type when sync local, FILE by default.")).setTab(r).addDropdown(async s=>{s.addOption("DAILY",N("DAILY")),s.addOption("FILE",N("FILE")),s.setValue(this.plugin.settings.saveThinoType).onChange(async c=>{this.plugin.settings.saveThinoType=c,this.applySettingsUpdate()})}),new Ve(n,this).setName(N("Sync Status")).setDesc(N("Start or stop sync")).setTab(r).addButton(s=>{s.setButtonText(this.plugin.settings.startSync?N("Stop"):N("Start")).onClick(async()=>{this.plugin.settings.startSync=!this.plugin.settings.startSync,await this.plugin.saveSettings(),Qe.setRefresh(!0),new C.Notice(this.plugin.settings.startSync?N("Start sync successfully"):N("Stop sync successfully")),setTimeout(()=>{this.display()},200)})}))}addMemoSettings(n,r){new Ve(r,this).setName(N("Open Memos when obsidian opens")).setDesc(N("When enable this, Memos will open when Obsidian opens. False by default.")).setTab(n).addDropdown(o=>{o.addOption("Desktop","Desktop"),o.addOption("Mobile","Mobile"),o.addOption("All","All"),o.setValue(this.plugin.settings.MobileAndDesktop).onChange(async s=>{this.plugin.settings.MobileAndDesktop=s,this.applySettingsUpdate()})}).addToggle(o=>o.setValue(this.plugin.settings.OpenMemosAutomatically).onChange(async s=>{this.plugin.settings.OpenMemosAutomatically=s,this.applySettingsUpdate()})),new Ve(r,this).setHeading().setTab(n).setName(N("Editor")),new Ve(r,this).setName(N("Use Tags In Vault")).setDesc(N("Use tags in vault rather than only in Memos. False by default.")).setTab(n).addToggle(o=>o.setValue(this.plugin.settings.UseVaultTags).onChange(async s=>{this.plugin.settings.UseVaultTags=s,this.applySettingsUpdate()}));let a;new Ve(r,this).setName(N("Default insert date format")).setDesc(N("Set the default date format when insert date by @, 'Tasks' by default.")).setTab(n).addDropdown(async o=>{a=o,a.addOption("Tasks","Tasks"),a.addOption("Dataview","Dataview"),a.setValue(this.plugin.settings.InsertDateFormat).onChange(async s=>{this.plugin.settings.InsertDateFormat=s,this.applySettingsUpdate()})}),new Ve(r,this).setHeading().setTab(n).setName(N("Daily notes")),new Ve(r,this).setName(N("Default prefix when save thino in daily notes")).setDesc(N("Set the default prefix when create memo, 'List' by default.")).setTab(n).addDropdown(async o=>{a=o,a.addOption("List",N("List")),a.addOption("Task",N("Task")),a.setValue(this.plugin.settings.DefaultPrefix).onChange(async s=>{this.plugin.settings.DefaultPrefix=s,this.applySettingsUpdate()})}),this.plugin.settings.EnabledLocationList.some(o=>o.value==="DAILY")&&new Ve(r,this).setName(N("Default time prefix for thino in daily notes")).setDesc(N("Set default time prefix for thino in daily notes.")).setTab(n).addDropdown(async o=>{a=o,a.addOption("HH:mm","HH:mm"),a.addOption("HH:mm:ss","HH:mm:ss"),a.setValue(this.plugin.settings.DefaultTimePrefix).onChange(async s=>{this.plugin.settings.DefaultTimePrefix=s,this.applySettingsUpdate()})})}addThinoProSettings(n,r,a){new Ve(r,this).setHeading().setTab(n).setName("💎 "+N("Pro features")),new Ve(r,this).setName(N("Default save type")).setDesc(N('Set the default save type for thino. "DAILY" by default')).setTab(n).addDropdown(async o=>{for(const s of this.plugin.settings.EnabledLocationList)o.addOption(s.value,N(s.value));o.setValue(this.plugin.settings.MemoSaveLocation||this.plugin.settings.EnabledLocationList[0].value).onChange(async s=>{if(!a){qt();return}this.plugin.settings.MemoSaveLocation=s,this.applySettingsUpdate()})}),new Ve(r,this).setName(N("Add tag automatically")).setDesc(N("Add tag to the end or beginning of the thino content when creating a thino and filtering tags")).setTab(n).addToggle(o=>o.setValue(this.plugin.settings.addTagAutomatically).onChange(async s=>{if(!a){qt();return}this.plugin.settings.addTagAutomatically=s,this.applySettingsUpdate(),this.debounceDisplay()})),this.plugin.settings.addTagAutomatically&&(new Ve(r,this).setName(N("Add tag position")).setDesc(N("Set the position of the tag when adding tag automatically")).setTab(n).addDropdown(async o=>{o.addOption("End",N("End")),o.addOption("Beginning",N("Beginning")),o.setValue(this.plugin.settings.addTagPosition).onChange(async s=>{this.plugin.settings.addTagPosition=s,this.applySettingsUpdate()})}),new Ve(r,this).setName(N("Add tag with new line")).setDesc(N("Add tag with new line when adding tag automatically")).setTab(n).addToggle(o=>o.setValue(this.plugin.settings.addTagWithNewline).onChange(async s=>{this.plugin.settings.addTagWithNewline=s,this.applySettingsUpdate()})))}memosCommentSettings(n,r){new Ve(r,this).setName(N("Allow Comments On Memos")).setDesc(N("You can comment on memos. False by default")).setTab(n).addToggle(a=>a.setValue(this.plugin.settings.CommentOnMemos).onChange(async o=>{this.plugin.settings.CommentOnMemos=o,this.applySettingsUpdate(),this.display()})),this.plugin.settings.CommentOnMemos&&(new Ve(r,this).setName(N("Always Show Memo Comments")).setDesc(N("Always show memo comments on memos. False by default")).setTab(n).addToggle(a=>a.setValue(this.plugin.settings.ShowCommentOnMemos).onChange(async o=>{this.plugin.settings.ShowCommentOnMemos=o,this.applySettingsUpdate()})),new Ve(r,this).setName(N("Comments In Original DailyNotes/Notes")).setDesc(N("You should install Dataview Plugin ver 0.5.9 or later to use this feature.")).setTab(n).addToggle(a=>a.setValue(this.plugin.settings.CommentsInOriginalNotes).onChange(async o=>{this.plugin.settings.CommentsInOriginalNotes=o,this.applySettingsUpdate()})))}shareToThinosSettings(n,r,a){new Ve(r,this).setHeading().setTab(n).setName("💎 "+N("Pro features")),new Ve(r,this).setTab(n).setName(N("Append/prepend text when share to Thino")).addToggle(o=>{o.setValue(this.plugin.settings.ShareToThinoWithText).onChange(async s=>{if(!a){qt();return}this.plugin.settings.ShareToThinoWithText=s,this.applySettingsUpdate(),this.debounceDisplay()})}),this.plugin.settings.ShareToThinoWithText&&(new Ve(r,this).setTab(n).setName(N("Append text when share to Thino")).addText(o=>{o.setPlaceholder(N("Input anything here")).setValue(this.plugin.settings.ShareToThinoWithTextAppend).onChange(async s=>{this.plugin.settings.ShareToThinoWithTextAppend=s,this.applySettingsUpdate()})}),new Ve(r,this).setTab(n).setName(N("Prepend text when share to Thino")).addText(o=>{o.setPlaceholder(N("Input anything here")).setValue(this.plugin.settings.ShareToThinoWithTextPrepend).onChange(async s=>{this.plugin.settings.ShareToThinoWithTextPrepend=s,this.applySettingsUpdate()})}),new Ve(r,this).setTab(n).setName(N("Add newline when append/prepend text")).addDropdown(async o=>{o.addOption("prepend",N("Prepend")),o.addOption("append",N("Append")),o.addOption("both",N("Both")),o.addOption("none",N("None")),o.setValue(this.plugin.settings.ShareToThinoWithTextNewline).onChange(async s=>{this.plugin.settings.ShareToThinoWithTextNewline=s,this.applySettingsUpdate()})}))}copyMemosSettings(n,r){new Ve(r,this).setName(N("Show Time When Copy Results")).setDesc(N("Show time when you copy results, like 12:00. Copy time by default.")).setTab(n).addToggle(a=>a.setValue(this.plugin.settings.ShowTime).onChange(async o=>{this.plugin.settings.ShowTime=o,this.applySettingsUpdate()})),new Ve(r,this).setName(N("Show Date When Copy Results")).setDesc(N("Show date when you copy results, like [[2022-01-01]]. Copy date by default.")).setTab(n).addToggle(a=>a.setValue(this.plugin.settings.ShowDate).onChange(async o=>{this.plugin.settings.ShowDate=o,this.applySettingsUpdate(),this.debounceDisplay()})),this.plugin.settings.ShowDate&&new Ve(r,this).setName(N("Add Blank Line Between Different Date")).setDesc(N("Add blank line when copy result with date. No blank line by default.")).setTab(n).addToggle(a=>a.setValue(this.plugin.settings.AddBlankLineWhenDate).onChange(async o=>{this.plugin.settings.AddBlankLineWhenDate=o,this.applySettingsUpdate()}))}shareMemosSettings(n,r){this.customMemoFooter(n,r),new Ve(r,this).setName(N("Custom Background Image")).setDesc(N("Set custom background image.")).setTab(n).addToggle(a=>a.setValue(this.plugin.settings.SetCustomBackgroundImage).onChange(async o=>{this.plugin.settings.SetCustomBackgroundImage=o,this.applySettingsUpdate(),setTimeout(()=>{this.display()},100)})),this.plugin.settings.SetCustomBackgroundImage&&(new Ve(r,this).setName(N("Background Image in Light Theme")).setDesc(N('Set background image in light theme. Set something like "Daily/one.png"')).setTab(n).addText(a=>{new z2(a.inputEl),a.setPlaceholder(cs.DefaultLightBackgroundImage).setValue(this.plugin.settings.DefaultLightBackgroundImage).onChange(async o=>{this.plugin.settings.DefaultLightBackgroundImage=o,this.applySettingsUpdate()})}),new Ve(r,this).setName(N("Background Image in Dark Theme")).setDesc(N('Set background image in dark theme. Set something like "Daily/one.png"')).setTab(n).addText(a=>{new z2(a.inputEl),a.setPlaceholder(cs.DefaultDarkBackgroundImage).setValue(this.plugin.settings.DefaultDarkBackgroundImage).onChange(async o=>{this.plugin.settings.DefaultDarkBackgroundImage=o,this.applySettingsUpdate()})}))}customMemoFooter(n,r){new Ve(r,this).setName(N("Custom Memo Footer")).setDesc(N("Set custom memo footer.")).setTab(n).addToggle(a=>a.setValue(this.plugin.settings.SetCustomMemoFooter).onChange(async o=>{this.plugin.settings.SetCustomMemoFooter=o,this.applySettingsUpdate(),setTimeout(()=>{this.display()},100)})),this.plugin.settings.SetCustomMemoFooter&&(new Ve(r,this).setName(N("Share Memos Image Footer Start")).setDesc(N("Set anything you want here, use {ThinoNum} to display Number of thino, {UsedDay} for days. '{ThinoNum} Thino {UsedDay} Days' By default")).setTab(n).addText(a=>a.setPlaceholder(cs.ShareFooterStart).setValue(this.plugin.settings.ShareFooterStart).onChange(async o=>{this.plugin.settings.ShareFooterStart=o,this.applySettingsUpdate()})),new Ve(r,this).setName(N("Share Memos Image Footer End")).setDesc(N("Set anything you want here, use {UserName} as your username. '✍️ By {UserName}' By default")).setTab(n).addText(a=>a.setPlaceholder(cs.ShareFooterEnd).setValue(this.plugin.settings.ShareFooterEnd).onChange(async o=>{this.plugin.settings.ShareFooterEnd=o,this.applySettingsUpdate()})))}saveDataSettings(n,r){let a;new Ve(r,this).setName(N("Default Editor Mode")).setDesc(N("Live-Preview Mode OR Source Mode.")).setTab(n).addDropdown(async o=>{a=o,a.addOption("obsidian",N("Live-preview")),a.addOption("memos",N("Source")),a.setValue(this.plugin.settings.EditorType).onChange(async s=>{this.plugin.settings.EditorType=s,this.applySettingsUpdate()})}),new Ve(r,this).setName(N("Delete Thino Directly")).setDesc(N("When delete thino directly, it will not be moved to trash. False by default.")).setTab(n).addToggle(o=>{o.setValue(this.plugin.settings.DeleteThinoDirectly).onChange(async s=>{this.plugin.settings.DeleteThinoDirectly=s,this.applySettingsUpdate()})})}async initHttpServer(n,r){var d;const a=Xe.getState().verifyState,o=!C.Platform.isDesktop&&await((d=window.Capacitor)==null?void 0:d.Plugins.Device.getId()),s=C.Platform.isDesktop?await vn():o.identifier||o.uuid,c=a&&(a==null?void 0:a.appId)===s;new Ve(n,this).setName(N("Enable Local Http Server")).setTab(r).setDisabled(!c).addToggle(p=>p.setValue(this.plugin.settings.EnabledHttpApi).onChange(async m=>{if(!c){qt();return}this.plugin.settings.EnabledHttpApi=m,this.applySettingsUpdate(),setTimeout(()=>{this.plugin.settings.EnabledHttpApi?this.plugin.initServer():this.plugin.stopServer(),this.display()},100)})),this.plugin.settings.EnabledHttpApi&&(new Ve(n,this).setName(N("Memos Http Server Port")).setDesc(N("Set memos http server port to listen. '43999' by default")).setTab(r).addText(p=>p.setPlaceholder(cs.HttpApiPort).setValue(this.plugin.settings.HttpApiPort).onChange(async m=>{if(!c){qt();return}this.plugin.settings.HttpApiPort=m,this.applySettingsUpdate(),setTimeout(()=>{this.plugin.stopServer(),this.plugin.initServer()},1e3)})),new Ve(n,this).setName(N("Auto Download Image")).setDesc(N("Auto download image when save to thino. 'false' by default")).setTab(r).setDisabled(!c).addToggle(p=>{p.setValue(this.plugin.settings.AutoDownloadImage).onChange(async m=>{if(!c){qt();return}this.plugin.settings.AutoDownloadImage=m,this.applySettingsUpdate(),setTimeout(()=>{this.plugin.stopServer(),this.plugin.initServer()},1e3)})}),new Ve(n,this).setName(N("Thino Http IP Type")).setDesc(N("Set Thino http server ip to listen. 'localhost' by default")).setTab(r).addDropdown(p=>{p.addOption("localhost","localhost"),p.addOption("127.0.0.1","127.0.0.1"),p.setValue(this.plugin.settings.HttpApiIpType).onChange(async m=>{if(!a||(a==null?void 0:a.appId)!==s){qt();return}this.plugin.settings.HttpApiIpType=m,this.applySettingsUpdate(),setTimeout(()=>{this.plugin.stopServer(),this.plugin.initServer()},1e3)})}))}fetchDataSettings(n,r){let a;new Ve(r,this).setName(N("Use which plugin's default configuration")).setDesc(N("Memos use the plugin's default configuration to fetch memos from daily, 'Daily' by default.")).setTab(n).addDropdown(async o=>{a=o,a.addOption("Daily",N("Daily")),a.addOption("Periodic","Periodic"),a.setValue(this.plugin.settings.UseDailyOrPeriodic).onChange(async s=>{this.plugin.settings.UseDailyOrPeriodic=s,this.applySettingsUpdate()})})}navigationSettings(n,r){new Ve(r,this).setName(N("Open link directly in Thino view")).setTab(n).addToggle(a=>a.setValue(this.plugin.settings.navigation).onChange(async o=>{this.plugin.settings.navigation=o,this.applySettingsUpdate()}))}setPasswordSettings(n,r){new Ve(r,this).setName(N("Need password to unlock Thino")).setTab(n).addToggle(a=>{this.plugin.settings.needVerify&&this.plugin.settings.password&&!this.passwordMatched&&(a.toggleEl.onclick=o=>{this.passwordMatched||(o.preventDefault(),new Z2(this.app,this,this.plugin,s=>{a.setDisabled(!s),this.passwordMatched=s,this.debounceDisplay()}).open(),new C.Notice(N("Please input your password to change password settings")))}),a.setDisabled(this.plugin.settings.needVerify&&this.plugin.settings.password&&!this.passwordMatched).setValue(this.plugin.settings.needVerify).onChange(async o=>{this.plugin.settings.needVerify=o,o&&(this.passwordMatched=!1),this.applySettingsUpdate(),this.debounceDisplay()})}),this.plugin.settings.needVerify&&new Ve(r,this).setName(N("Password to lock Thino")).setTab(n).addText(a=>{this.plugin.settings.needVerify&&this.plugin.settings.password&&!this.passwordMatched&&(a.inputEl.onclick=o=>{this.passwordMatched||(o.preventDefault(),new Z2(this.app,this,this.plugin,s=>{a.inputEl.readOnly=!s,this.passwordMatched=s,this.debounceDisplay()}).open(),new C.Notice(N("Please input your password to change password settings")))}),a.inputEl.readOnly=this.plugin.settings.password&&this.plugin.settings.needVerify&&!this.passwordMatched,a.inputEl.oncopy=()=>!1,a.inputEl.type="password",a.setValue(this.plugin.settings.password).onChange(async o=>{this.plugin.settings.password=o,this.applySettingsUpdate()})})}setGlobalSettings(n,r,a){new Ve(r,this).setHeading().setTab(n).setName("💎 "+N("Pro features")),this.initHttpServer(r,n),new Ve(r,this).setName(N("Enable opening thino globally")).setDesc(N("Enable opening thino globally. False by default.")).setTab(n).addToggle(o=>o.setValue(this.plugin.settings.CaptureKey.EnableCaptureKey).onChange(async s=>{if(!a){qt();return}this.plugin.settings.CaptureKey.EnableCaptureKey=s,this.applySettingsUpdate(),setTimeout(()=>{this.display()},100)})),this.plugin.settings.CaptureKey.EnableCaptureKey&&(new Ve(r,this).setName(N("Key for opening thino globally")).setDesc(N("Set key for opening thino globally. CTRL + SHIFT + T by default.")).setTab(n).addText(o=>o.setPlaceholder(cs.CaptureKey.OpenThinoGlobally).setValue(this.plugin.settings.CaptureKey.OpenThinoGlobally).onChange(async s=>{if(!a){qt();return}this.plugin.settings.CaptureKey.OpenThinoGlobally=s,this.applySettingsUpdate()})),new Ve(r,this).setName(N("Show thino near mouse")).setTab(n).addToggle(o=>o.setValue(this.plugin.settings.CaptureKey.ShowNearMouse).onChange(async s=>{if(!a){qt();return}this.plugin.settings.CaptureKey.ShowNearMouse=s,this.applySettingsUpdate()})))}checkInList(n){return this.plugin.settings.EnabledLocationList.find(r=>r.value===n)!==void 0}customFileNameSettings(n,r,a){var d;const o=document.createDocumentFragment(),s=o.createEl("div",{cls:"memo-save-location-desc"});for(const p of bx){const m=s.createEl("div",{cls:`memo-save-location-desc-item ${p.value}`}),g=m.createEl("span",{cls:"memo-save-location-desc-item-icon"});C.setIcon(g,((d=tp.find(E=>E.title===p.value))==null?void 0:d.icon)||""),m.createEl("span",{cls:"memo-save-location-desc-item-desc",text:`${N(p.value)}`});const v=m.createEl("span",{cls:"memo-save-location-desc-item-toggle"}),D=m.createEl("span",{cls:"memo-save-location-desc-item-setting"});p.value!=="DAILY"&&m.createEl("span",{cls:["memo-save-location-desc-item-pro","user-pro-badge"],text:"PRO"}),new C.ToggleComponent(v).setValue(this.checkInList(p.value)).onChange(async E=>{if(!a){qt();return}E?(await Te.updateTypeMemos(p.value),this.plugin.settings.EnabledLocationList=[...this.plugin.settings.EnabledLocationList,p]):(await Te.removeTypeMemos(p.value),this.plugin.settings.EnabledLocationList=this.plugin.settings.EnabledLocationList.filter(O=>O.value!==p.value)),this.plugin.settings.EnabledLocationList.length===1&&(this.plugin.settings.MemoSaveLocation=p.value),this.applySettingsUpdate(),setTimeout(()=>{this.display()},500)}).setDisabled(this.plugin.settings.EnabledLocationList.length===1&&this.checkInList(p.value)),new C.ExtraButtonComponent(D).setIcon("settings").onClick(()=>{new OK(this.app,this,this.plugin,p,a).open()})}const c=new Ve(r,this).setName(N("Save type for Thino")).setDesc(o).setTab(n);c.settingEl.toggleClass("memo-save-location-setting",!0),c.nameEl.toggleClass("memo-save-location-title",!0)}}class OK extends C.Modal{constructor(n,r,a,o,s){super(n);me(this,"plugin");me(this,"settingTab");me(this,"LocationList");me(this,"target","");me(this,"insertTarget","");me(this,"verified");me(this,"updateValue",C.debounce(n=>{this.LocationList.value!=="DAILY"&&this.LocationList.value!=="MULTI"?this.target=n.trim()===""?"basic":n.trim():this.target=n.trim()===""&&this.LocationList.value==="MULTI"?"Memos":n.trim()},400,!0));me(this,"debounceDisplay",C.debounce(()=>this.display(),400,!0));this.verified=s,this.app=n,this.settingTab=r,this.plugin=a,this.LocationList=o,this.target=o.target!=="ProcessEntriesBelow"?a.settings.MemoOtherSaveLocation[o.target]:a.settings[o.target],this.insertTarget=a.settings.InsertAfter}onOpen(){this.display()}async display(){var d;const{contentEl:n}=this;this.contentEl.empty(),(d=n.parentElement)==null||d.classList.add("memo-save-location-modal"),this.titleEl.toggleClass("modal-title",!0),this.titleEl.setText(N("Save type for Thino")+` [${N(this.LocationList.value)}]`),(this.LocationList.value==="FILE"||this.LocationList.value==="CANVAS")&&n.createDiv("modal-desc",p=>{p.setText(N('You can set folder name with file name like "folder/file"'))}),this.LocationList.value==="MULTI"&&n.createDiv("modal-desc",p=>{p.setText(N('You can set folder name like "folder1/folder2/folder3" to create sub-folder'))}),this.LocationList.value==="DAILY"&&n.createDiv("modal-desc",p=>{p.setText(N('You can set target heading like "# Heading" to control data location'))});const r=n.createDiv("modal-setting"),a=this.LocationList.value==="DAILY"?N("Process Memos below"):this.LocationList.value==="MULTI"?N("Set the folder name"):N("Set the filename");if(this.LocationList.value==="DAILY"&&(new Ve(r,this.settingTab).setName(N("Set thino insert place")).setDesc(N("Set where to insert thino content")).addDropdown(async p=>{p.addOption("end",N("End of the diary")),p.addOption("custom",N("Custom location")),p.setValue(this.plugin.settings.InsertType).onChange(async m=>{this.plugin.settings.InsertType=m,this.settingTab.applySettingsUpdate(),this.debounceDisplay()})}),this.plugin.settings.InsertType==="custom"&&await this.addDailySettings(r),new Ve(r,this.settingTab).setName(N("Set process target")).setDesc(N("You can set whole diary or only part of it")).addDropdown(async p=>{p.addOption("custom",N("Custom")),p.addOption("whole",N("Whole diary")),p.setValue(this.plugin.settings.ProcessContentTarget).onChange(async m=>{this.plugin.settings.ProcessContentTarget=m,this.settingTab.applySettingsUpdate(),this.debounceDisplay()})})),this.LocationList.value!=="DAILY"||this.plugin.settings.ProcessContentTarget!=="whole"){const p=new Ve(r,this.settingTab).setName(a).addText(m=>m.setPlaceholder(this.LocationList.value==="DAILY"?N("# Heading"):N("Set the filename for current location file")).setValue(this.LocationList.value!=="DAILY"&&this.LocationList.value!=="MULTI"?this.target.replace(/\.thino\.(canvas|md)/g,""):this.target).onChange(async g=>{const v=this.LocationList.value==="CANVAS"?".thino.canvas":this.LocationList.value==="FILE"?".thino.md":"";this.updateValue(g.replace(/\.thino\.(canvas|md)/g,"")+v)}));this.LocationList.value==="DAILY"&&p.setDesc(N("If left blank, the Thino interface will display all thino record contents; if a title is provided, the Thino interface will only display the contents under that title, and contents written elsewhere will not be shown.")),this.LocationList.value!=="DAILY"&&this.LocationList.value!=="MULTI"&&p.controlEl.createEl("span",{text:`${this.LocationList.value==="FILE"?".thino.md":".thino.canvas"}`})}const o=n.createDiv("button-group"),s=o.createEl("button",{text:N("Cancel")}),c=o.createEl("button",{text:N("Save")});c.onclick=async()=>{if(!this.verified&&this.LocationList.value!=="DAILY"){this.close(),qt();return}this.LocationList.target!=="ProcessEntriesBelow"?this.plugin.settings.MemoOtherSaveLocation[this.LocationList.target]=this.target:this.plugin.settings[this.LocationList.target]=this.target,this.LocationList.value==="MULTI"&&Ue.checkDailyInMulti(this.plugin.settings),this.LocationList.target==="ProcessEntriesBelow"&&(this.plugin.settings.InsertAfter=this.insertTarget),this.settingTab.applySettingsUpdate(),setTimeout(()=>{Te.updateTypeMemos(this.LocationList.value)},1e3),this.close()},s.onclick=async()=>{this.close()}}async addDailySettings(n){var d,p,m,g;const r=Xe.getState().verifyState,a=!C.Platform.isDesktop&&await((d=window.Capacitor)==null?void 0:d.Plugins.Device.getId()),o=C.Platform.isDesktop?await vn():a.identifier||a.uuid,s=r&&(r==null?void 0:r.appId)===o,c=((p=this.plugin.settings)!=null&&p.DifferentInsertTarget?`[${N("List")}] `:"")+N("Insert after heading");new Ve(n,this.settingTab).setName(c).setDesc(N("If left blank, the recorded thino content will be inserted at the end of the diary; if a title is provided, all recorded thino content will be uniformly categorized under that title.")).addText(v=>v.setPlaceholder(N("# Heading")).setValue(this.insertTarget).onChange(async D=>{this.insertTarget=D})),(m=this.plugin.settings)!=null&&m.DifferentInsertTarget&&new Ve(n,this.settingTab).setName(((g=this.plugin.settings)!=null&&g.DifferentInsertTarget?`[${N("Task")}] `:"")+N("Insert after heading")).setDesc(N("Set the heading for the task type of thino, by default the recorded thino content will be inserted at the end of the diary; if a title is provided, all recorded thino content will be uniformly categorized under that title.")).addText(v=>{v.setPlaceholder(N("# Heading")).setValue(this.plugin.settings.InsertAfterForTask).onChange(async D=>{this.plugin.settings.InsertAfterForTask=D,this.settingTab.applySettingsUpdate()})}),new Ve(n,this.settingTab).setName(N("Different insert target for different type")).setDesc(N("Toggle this to set different insert target for different type of thino, like task or list type of thino")).addToggle(v=>v.setValue(this.plugin.settings.DifferentInsertTarget).onChange(async D=>{if(!s){qt();return}this.plugin.settings.DifferentInsertTarget=D,this.settingTab.applySettingsUpdate(),this.debounceDisplay()}))}onClose(){const{contentEl:n}=this;n.empty()}}class Z2 extends C.Modal{constructor(n,r,a,o){super(n);me(this,"plugin");me(this,"settingTab");this.cb=o,this.app=n,this.settingTab=r,this.plugin=a}onOpen(){var d;const{contentEl:n}=this;(d=n.parentElement)==null||d.classList.add("memo-save-location-modal"),this.titleEl.toggleClass("modal-title",!0),this.titleEl.setText(N("Password for Thino")),n.createDiv("modal-desc",p=>{p.setText(N("Please input your password to change password settings"))});const r=n.createDiv("modal-setting"),a=new Ve(r,this.settingTab).setName(N("Password")).addText(p=>{p.setPlaceholder(N("Please input your password")).inputEl.type="password"}),o=n.createDiv("button-group"),s=o.createEl("button",{text:N("Cancel")}),c=o.createEl("button",{cls:"thino-password-confirm-btn",text:N("Confirm?").replace(/(\?|?)/g,"")});c.onclick=async()=>{var p;a.controlEl.querySelector("input").value===this.plugin.settings.password?((p=this.cb)==null||p.call(this,!0),this.close()):new C.Notice(N("Password is incorrect"))},s.onclick=async()=>{this.close()}}onClose(){const{contentEl:n}=this;n.empty()}}function fv(e){return e.split("-")[0]}function Dx(e){return e.split("-")[1]}function yb(e){return["top","bottom"].includes(fv(e))?"x":"y"}function Sx(e){return e==="y"?"height":"width"}function W2(e){let{reference:t,floating:n,placement:r}=e;const a=t.x+t.width/2-n.width/2,o=t.y+t.height/2-n.height/2;let s;switch(fv(r)){case"top":s={x:a,y:t.y-n.height};break;case"bottom":s={x:a,y:t.y+t.height};break;case"right":s={x:t.x+t.width,y:o};break;case"left":s={x:t.x-n.width,y:o};break;default:s={x:t.x,y:t.y}}const c=yb(r),d=Sx(c);switch(Dx(r)){case"start":s[c]=s[c]-(t[d]/2-n[d]/2);break;case"end":s[c]=s[c]+(t[d]/2-n[d]/2);break}return s}const PK=async(e,t,n)=>{const{placement:r="bottom",strategy:a="absolute",middleware:o=[],platform:s}=n;let c=await s.getElementRects({reference:e,floating:t,strategy:a}),{x:d,y:p}=W2({...c,placement:r}),m=r,g={};for(let v=0;vRK[t])}function BK(e,t){const n=Dx(e)==="start",r=yb(e),a=Sx(r);let o=r==="x"?n?"right":"left":n?"bottom":"top";return t.reference[a]>t.floating[a]&&(o=Ny(o)),{main:o,cross:Ny(o)}}const _K={start:"end",end:"start"};function $2(e){return e.replace(/start|end/g,t=>_K[t])}function HK(e){const t=Ny(e);return[$2(e),t,$2(t)]}const YK=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:a,middlewareData:o,rects:s,initialPlacement:c}=t;if((n=o.flip)!=null&&n.skip)return{};const{mainAxis:d=!0,crossAxis:p=!0,fallbackPlacements:m,fallbackStrategy:g="bestFit",flipAlignment:v=!0,...D}=e,S=fv(a),E=m||(S===c||!v?[Ny(c)]:HK(c)),O=[c,...E],k=await t1(t,D),j=[];let F=((r=o.flip)==null?void 0:r.overflows)||[];if(d&&j.push(k[S]),p){const{main:H,cross:Y}=BK(a,s);j.push(k[H],k[Y])}if(F=[...F,{placement:a,overflows:j}],!j.every(H=>H<=0)){var B,R;const H=((B=(R=o.flip)==null?void 0:R.index)!=null?B:0)+1,Y=O[H];if(Y)return{data:{index:H,overflows:F},reset:{placement:Y}};let U="bottom";switch(g){case"bestFit":{var z;const J=(z=F.slice().sort((Q,le)=>Q.overflows.filter(pe=>pe>0).reduce((pe,ie)=>pe+ie,0)-le.overflows.filter(pe=>pe>0).reduce((pe,ie)=>pe+ie,0))[0])==null?void 0:z.placement;J&&(U=J);break}case"initialPlacement":U=c;break}return{data:{skip:!0},reset:{placement:U}}}return{}}}};function zK(e){let{placement:t,rects:n,value:r}=e;const a=fv(t),o=["left","top"].includes(a)?-1:1,s=typeof r=="function"?r({...n,placement:t}):r,{mainAxis:c,crossAxis:d}=typeof s=="number"?{mainAxis:s,crossAxis:0}:{mainAxis:0,crossAxis:0,...s};return yb(a)==="x"?{x:d,y:c*o}:{x:c*o,y:d}}const UK=function(e){return e===void 0&&(e=0),{name:"offset",options:e,fn(t){const{x:n,y:r,placement:a,rects:o}=t,s=zK({placement:a,rects:o,value:e});return{x:n+s.x,y:r+s.y,data:s}}}};function vb(e){return(e==null?void 0:e.toString())==="[object Window]"}function xl(e){if(e==null)return window;if(!vb(e)){const t=e.ownerDocument;return t&&t.defaultView||window}return e}function hv(e){return xl(e).getComputedStyle(e)}function vs(e){return vb(e)?"":e?(e.nodeName||"").toLowerCase():""}function ws(e){return e instanceof xl(e).HTMLElement}function ky(e){return e instanceof xl(e).Element}function VK(e){return e instanceof xl(e).Node}function Ix(e){const t=xl(e).ShadowRoot;return e instanceof t||e instanceof ShadowRoot}function pv(e){const{overflow:t,overflowX:n,overflowY:r}=hv(e);return/auto|scroll|overlay|hidden/.test(t+r+n)}function ZK(e){return["table","td","th"].includes(vs(e))}function Tx(e){const t=navigator.userAgent.toLowerCase().includes("firefox"),n=hv(e);return n.transform!=="none"||n.perspective!=="none"||n.contain==="paint"||["transform","perspective"].includes(n.willChange)||t&&n.willChange==="filter"||t&&(n.filter?n.filter!=="none":!1)}const G2=Math.min,Xh=Math.max,Ay=Math.round;function Ld(e,t){t===void 0&&(t=!1);const n=e.getBoundingClientRect();let r=1,a=1;return t&&ws(e)&&(r=e.offsetWidth>0&&Ay(n.width)/e.offsetWidth||1,a=e.offsetHeight>0&&Ay(n.height)/e.offsetHeight||1),{width:n.width/r,height:n.height/a,top:n.top/a,right:n.right/r,bottom:n.bottom/a,left:n.left/r,x:n.left/r,y:n.top/a}}function Ml(e){return((VK(e)?e.ownerDocument:e.document)||window.document).documentElement}function mv(e){return vb(e)?{scrollLeft:e.pageXOffset,scrollTop:e.pageYOffset}:{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}}function Ex(e){return Ld(Ml(e)).left+mv(e).scrollLeft}function WK(e){const t=Ld(e);return Ay(t.width)!==e.offsetWidth||Ay(t.height)!==e.offsetHeight}function $K(e,t,n){const r=ws(t),a=Ml(t),o=Ld(e,r&&WK(t));let s={scrollLeft:0,scrollTop:0};const c={x:0,y:0};if(r||!r&&n!=="fixed")if((vs(t)!=="body"||pv(a))&&(s=mv(t)),ws(t)){const d=Ld(t,!0);c.x=d.x+t.clientLeft,c.y=d.y+t.clientTop}else a&&(c.x=Ex(a));return{x:o.left+s.scrollLeft-c.x,y:o.top+s.scrollTop-c.y,width:o.width,height:o.height}}function gv(e){return vs(e)==="html"?e:e.assignedSlot||e.parentNode||(Ix(e)?e.host:null)||Ml(e)}function q2(e){return!ws(e)||getComputedStyle(e).position==="fixed"?null:e.offsetParent}function GK(e){let t=gv(e);for(;ws(t)&&!["html","body"].includes(vs(t));){if(Tx(t))return t;t=t.parentNode}return null}function n1(e){const t=xl(e);let n=q2(e);for(;n&&ZK(n)&&getComputedStyle(n).position==="static";)n=q2(n);return n&&(vs(n)==="html"||vs(n)==="body"&&getComputedStyle(n).position==="static"&&!Tx(n))?t:n||GK(e)||t}function J2(e){return{width:e.offsetWidth,height:e.offsetHeight}}function qK(e){let{rect:t,offsetParent:n,strategy:r}=e;const a=ws(n),o=Ml(n);if(n===o)return t;let s={scrollLeft:0,scrollTop:0};const c={x:0,y:0};if((a||!a&&r!=="fixed")&&((vs(n)!=="body"||pv(o))&&(s=mv(n)),ws(n))){const d=Ld(n,!0);c.x=d.x+n.clientLeft,c.y=d.y+n.clientTop}return{...t,x:t.x-s.scrollLeft+c.x,y:t.y-s.scrollTop+c.y}}function JK(e){const t=xl(e),n=Ml(e),r=t.visualViewport;let a=n.clientWidth,o=n.clientHeight,s=0,c=0;return r&&(a=r.width,o=r.height,Math.abs(t.innerWidth/r.scale-r.width)<.01&&(s=r.offsetLeft,c=r.offsetTop)),{width:a,height:o,x:s,y:c}}function KK(e){var t;const n=Ml(e),r=mv(e),a=(t=e.ownerDocument)==null?void 0:t.body,o=Xh(n.scrollWidth,n.clientWidth,a?a.scrollWidth:0,a?a.clientWidth:0),s=Xh(n.scrollHeight,n.clientHeight,a?a.scrollHeight:0,a?a.clientHeight:0);let c=-r.scrollLeft+Ex(e);const d=-r.scrollTop;return hv(a||n).direction==="rtl"&&(c+=Xh(n.clientWidth,a?a.clientWidth:0)-o),{width:o,height:s,x:c,y:d}}function Cx(e){return["html","body","#document"].includes(vs(e))?e.ownerDocument.body:ws(e)&&pv(e)?e:Cx(gv(e))}function xx(e,t){var n;t===void 0&&(t=[]);const r=Cx(e),a=r===((n=e.ownerDocument)==null?void 0:n.body),o=xl(r),s=a?[o].concat(o.visualViewport||[],pv(r)?r:[]):r,c=t.concat(s);return a?c:c.concat(xx(gv(s)))}function QK(e,t){const n=t.getRootNode==null?void 0:t.getRootNode();if(e.contains(t))return!0;if(n&&Ix(n)){let r=t;do{if(r&&e===r)return!0;r=r.parentNode||r.host}while(r)}return!1}function XK(e){const t=Ld(e),n=t.top+e.clientTop,r=t.left+e.clientLeft;return{top:n,left:r,x:r,y:n,right:r+e.clientWidth,bottom:n+e.clientHeight,width:e.clientWidth,height:e.clientHeight}}function K2(e,t){return t==="viewport"?e1(JK(e)):ky(t)?XK(t):e1(KK(Ml(e)))}function eQ(e){const t=xx(gv(e)),r=["absolute","fixed"].includes(hv(e).position)&&ws(e)?n1(e):e;return ky(r)?t.filter(a=>ky(a)&&QK(a,r)&&vs(a)!=="body"):[]}function tQ(e){let{element:t,boundary:n,rootBoundary:r}=e;const o=[...n==="clippingParents"?eQ(t):[].concat(n),r],s=o[0],c=o.reduce((d,p)=>{const m=K2(t,p);return d.top=Xh(m.top,d.top),d.right=G2(m.right,d.right),d.bottom=G2(m.bottom,d.bottom),d.left=Xh(m.left,d.left),d},K2(t,s));return c.width=c.right-c.left,c.height=c.bottom-c.top,c.x=c.left,c.y=c.top,c}const nQ={getElementRects:e=>{let{reference:t,floating:n,strategy:r}=e;return{reference:$K(t,n1(n),r),floating:{...J2(n),x:0,y:0}}},convertOffsetParentRelativeRectToViewportRelativeRect:e=>qK(e),getOffsetParent:e=>{let{element:t}=e;return n1(t)},isElement:e=>ky(e),getDocumentElement:e=>{let{element:t}=e;return Ml(t)},getClippingClientRect:e=>tQ(e),getDimensions:e=>{let{element:t}=e;return J2(t)},getClientRects:e=>{let{element:t}=e;return t.getClientRects()}},rQ=(e,t,n)=>PK(e,t,{platform:nQ,...n});var aQ=function e(t,n){if(t===n)return!0;if(t&&n&&typeof t=="object"&&typeof n=="object"){if(t.constructor!==n.constructor)return!1;var r,a,o;if(Array.isArray(t)){if(r=t.length,r!=n.length)return!1;for(a=r;a--!==0;)if(!e(t[a],n[a]))return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if(o=Object.keys(t),r=o.length,r!==Object.keys(n).length)return!1;for(a=r;a--!==0;)if(!Object.prototype.hasOwnProperty.call(n,o[a]))return!1;for(a=r;a--!==0;){var s=o[a];if(!e(t[s],n[s]))return!1}return!0}return t!==t&&n!==n};const oQ=er(aQ),iw=ep.Facet.define({combine:e=>{var t,n;return{defaultPlacement:((t=e.find(r=>r.defaultPlacement))==null?void 0:t.defaultPlacement)||"top",padding:((n=e.find(r=>r.padding))==null?void 0:n.padding)||8}}}),Mx=e=>e.split("-")[0],iQ=e=>e==="x"?"y":"x",sQ=e=>["top","bottom"].includes(Mx(e))?"x":"y",_h=(e,t,n)=>Math.max(e,Math.min(t,n)),lQ=(e,t)=>Object.fromEntries(Object.entries(e).map(([n,r],a)=>[n,t(r,n,a)])),uQ=e=>e===void 0?e:typeof e=="number"?-e:lQ(e,t=>t!==void 0?-t:t),cQ=(e={})=>({name:"shift",fn:async t=>{const{x:n,y:r,placement:a}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:c=({x:E,y:O})=>({x:E,y:O}),editorMenu:d,...p}=e,m={x:n,y:r},g=await t1(t,p),v=sQ(Mx(a)),D=iQ(v);let S=m[v],T=m[D];if(o){const E=v==="y"?"top":"left",O=v==="y"?"bottom":"right",k=S+g[E],j=S-g[O];if(d){const F=await t1(t,{...p,boundary:d.dom,padding:uQ(p.padding)});if((D==="y"?["top","bottom"]:["left","right"]).every(R=>F[R]<=0)){const R=t.rects.floating.width,z=S+F[E]-R,H=S-F[O]+R,Y=Math.abs(g[E]-F[E]),U=Math.abs(g[O]-F[O]);Y>=R||U({width:0,height:0,top:t,left:e,bottom:t,right:e,x:e,y:t}),hQ=(e,t)=>{if(!e)return null;const n=Math.min(e.left,(t==null?void 0:t.left)??e.left),r=Math.max(e.right,(t==null?void 0:t.right)??e.right),a=Math.max(e.bottom,(t==null?void 0:t.bottom)??e.bottom)-Math.min(e.top,(t==null?void 0:t.top)??e.top),o=Math.min(e.top,(t==null?void 0:t.top)??e.top),s=o+a,c={left:n,right:r,top:o,bottom:s,width:0,height:a,x:o,y:n};return t&&(c.width=Math.abs(r-n)),c},pQ=fQ();class mQ{constructor(t){me(this,"containerEl");me(this,"virtualEl");me(this,"toolbar",null);me(this,"isThinoView");me(this,"tooltipInfo");me(this,"inView",!0);me(this,"defaultPlacement");me(this,"editorMenu");me(this,"cachedRefRect",null);me(this,"readFromDOM",()=>{if(this.tooltipInfo){const{start:t}=this.tooltipInfo;let{end:n}=this.tooltipInfo;n&&t===n&&(n=void 0);const r=this.view.coordsAtPos(t);let a=n?this.view.coordsAtPos(n):null;if(r&&a&&r.top!==a.top){const s=this.view.contentDOM.getBoundingClientRect();a={left:s.right,right:s.right,top:r.top,bottom:r.bottom}}const o=hQ(r,a);o&&(this.cachedRefRect=o,this.computePosition(o))}});this.view=t,this.containerEl=this.view.dom.parentElement,this.defaultPlacement=this.view.state.facet(iw).defaultPlacement,this.tooltipInfo=t.state.facet(r1),this.virtualEl={rect:pQ,getBoundingClientRect(){return this.rect}},this.maybeMeasure(),this.editorMenu={currMenu:null,evtRef:t.state.field(C.editorInfoField)},this.isThinoView=this.checkThinoView()}get workspace(){return this.view.state.field(C.editorInfoField).app.workspace}checkThinoView(){return this.view.state.field(C.editorInfoField)&&this.view.state.field(C.editorInfoField)instanceof wl}shouldRemoveToolbar(t){const n=t??this.tooltipInfo;return!(n!=null&&n.end||this.editorMenu.currMenu)}onEditorMenuOpen(t){this.editorMenu.currMenu||(this.editorMenu.currMenu=t,this.cachedRefRect?this.computePosition(this.cachedRefRect):this.maybeMeasure(),!C.Platform.isMacOS&&this.tooltipInfo&&(this.createToolbar(),this.maybeMeasure()))}onEditorMenuClose(t){this.editorMenu.currMenu===t&&(this.editorMenu.currMenu=null),!C.Platform.isMacOS&&this.toolbar&&this.shouldRemoveToolbar()&&this.removeToolbar()}createToolbar(t){const n=t??this.tooltipInfo;if(!n)return;this.removeToolbar();const r=n.create(this.containerEl),a=this.view.state.field(C.editorInfoField);if(!a||!(a!=null&&a.editor))return;const o=a.editor.offsetToPos(n.start),s=n.end?a.editor.offsetToPos(n.end):o;this.workspace.trigger(dQ,r,{from:o,to:s},a.editor,a),this.toolbar=r}removeToolbar(){this.toolbar&&(this.toolbar.hide(),this.toolbar=null)}update(t){if(!this.isThinoView)return;const n=t.state.facet(r1),r=n!==this.tooltipInfo&&!oQ(n,this.tooltipInfo);r&&(this.tooltipInfo=n,this.shouldRemoveToolbar()?this.removeToolbar():n&&!this.toolbar&&this.createToolbar(n));const a=r||t.geometryChanged,o=t.state.facet(iw);o.defaultPlacement!=this.defaultPlacement&&(o.defaultPlacement=this.defaultPlacement),a&&this.maybeMeasure()}destroy(){this.editorMenu.currMenu=null,this.removeToolbar(),this.toolbar=null,this.view.state.field(C.editorInfoField).app.workspace.offref(this.editorMenu.evtRef)}async computePosition(t){if(!this.toolbar)return;this.virtualEl.rect=t;const{padding:n}=this.view.state.facet(iw),{x:r,y:a}=await rQ(this.virtualEl,this.toolbar.dom,{placement:this.defaultPlacement,middleware:[UK({mainAxis:5}),YK({padding:n,boundary:this.view.scrollDOM}),cQ({padding:n,boundary:this.view.scrollDOM,editorMenu:this.editorMenu.currMenu})]});Object.assign(this.toolbar.dom.style,{top:"0",left:"0",transform:`translate(${Math.round(r)}px,${Math.round(a)}px)`})}maybeMeasure(){this.view.inView&&this.toolbar&&this.view.requestMeasure({read:this.readFromDOM}),this.inView!=this.view.inView&&(this.inView=this.view.inView,this.inView||this.removeToolbar())}}const gQ=Ci.ViewPlugin.fromClass(mQ,{eventHandlers:{scroll(){this.maybeMeasure()}}}),r1=ep.Facet.define({enables:[gQ],combine:e=>e.filter(t=>t!=null).first()??null}),yQ=e=>{const t=SQ(e);t&&window.navigator.clipboard.writeText(t==null?void 0:t.getSelection())},vQ=e=>{e.commands.executeCommandById("editor:toggle-bold",e)},wQ=e=>{e.commands.executeCommandById("editor:toggle-strikethrough",e)},bQ=e=>{e.commands.executeCommandById("editor:toggle-highlight",e)},DQ=e=>{e.commands.executeCommandById("editor:toggle-italics",e)},SQ=e=>{const{editor:t}=e.field(C.editorInfoField);return t},Q2=(e,t)=>{const n=e.selection.ranges[0];if(!n)return null;const{anchor:r,head:a,empty:o}=n,[s,c]=[r,a].sort();return{start:s,end:o?void 0:c,create:p=>new CQ(p).addSmallButton(g=>g.setClass("clickable-icon").setIcon("copy").onClick(()=>yQ(e))).addSmallButton(g=>g.setClass("clickable-icon").setIcon("bold").onClick(()=>vQ(t))).addSmallButton(g=>g.setClass("clickable-icon").setIcon("italic").onClick(()=>DQ(t))).addSmallButton(g=>g.setClass("clickable-icon").setIcon("strikethrough").onClick(()=>wQ(t))).addSmallButton(g=>g.setClass("clickable-icon").setIcon("highlighter").onClick(()=>bQ(t)))}},IQ=e=>ep.StateField.define({create:t=>Q2(t,e),update:(t,n)=>!n.docChanged&&!n.selection?t:Q2(n.state,e),provide:t=>r1.from(t)}),TQ=e=>[IQ(e)];class EQ extends C.BaseComponent{constructor(n){super();me(this,"button");me(this,"disabled",!1);me(this,"dropdownOptions",[]);me(this,"menu");me(this,"menuOpened",!1);this.button=new C.ButtonComponent(n)}setDisabled(n){return this.button.setDisabled(n),this.disabled=n,this}setIcon(n){return this.button.setIcon(n),this}setClass(n){return this.button.setClass(n),this}setDropdownText(n){var d;const r=this.button.buttonEl.createDiv("mini-toolbar-text"),a=this.button.buttonEl.createDiv("mini-toolbar-icon-with-text");C.setIcon(a,"chevron-down");const o=(d=n.doc.lineAt(n.selection.ranges[0].from))==null?void 0:d.from,s=b0.syntaxTree(n).resolveInner(o+1),c=s.type.prop(b0.tokenClassNodeProp);return r.setText(this.detectFormat(c,s)||"Text"),this}setDropdownIcon(){const n=this.button.buttonEl.createDiv("mini-toolbar-highlight-icon"),r=this.button.buttonEl.createDiv("mini-toolbar-icon-with-icon");return C.setIcon(n,"highlighter"),C.setIcon(r,"chevron-down"),this}detectFormat(n,r){var a;if(!n)return"Text";if(n.includes("strong"))return"Bold";if(n.includes("em"))return"Italic";if(n.includes("strikethrough"))return"Strike";if(n.contains("hmd-codeblock"))return"CodeBlock";if(n.contains("hmd-inline-code"))return"Code";if(n.contains("formatting-header")){const o=n.match(/header-\d{1,}/);if(o)return"Heading "+o[0].slice(-1)}if(n.contains("formatting-list")||n.contains("hmd-list-indent")){if(r!=null&&r.parent){const o=(a=r.parent)==null?void 0:a.type.prop(b0.lineClassNodeProp);if(o!=null&&o.contains("HyperMD-task-line"))return"To-do list"}if(n.contains("formatting-list-ol"))return"Numbered list";if(n.contains("formatting-list-ul"))return"Bulleted list"}}setTooltip(n){return this.button.setTooltip(n),this}setOptionsList(n){return this.dropdownOptions=n,this}onClick(n){return this.dropdownOptions.length>0?(this.button.onClick(r=>this.showEditMenu(r)),this):(this.button.onClick(n),this)}showEditMenu(n){var s,c;if(this.menuOpened=!this.menuOpened,!this.menuOpened)return;this.menu=new C.Menu,this.menu.onHide(()=>{this.menuOpened=!1});const r=n.currentTarget,a=(s=n.currentTarget)==null?void 0:s.getBoundingClientRect(),o={x:a.left-6,y:a.bottom+6};for(let d=0;d<((c=this.dropdownOptions)==null?void 0:c.length);d++)this.menu.addItem(p=>{p.setIcon("zap").setTitle(this.dropdownOptions[d]).onClick(()=>{})});this.menu.setParentElement(r).showAtPosition(o)}then(n){return n(this),this}}class CQ extends C.Component{constructor(n){super();me(this,"dom");me(this,"smallBtnContainer");me(this,"unloading",!1);this.dom=n==null?void 0:n.createDiv({cls:"cm-mini-toolbar"},r=>r.style.position="absolute"),this.smallBtnContainer=this.dom}addSmallButton(n){return n(new EQ(this.smallBtnContainer)),this}hide(){return this.unload(),this.unloading?this:(this.unloading=!0,this.dom.detach(),this.unloading=!1,this)}}const xQ=Ci.Decoration.line({attributes:{"data-ph":N("What do you think now...")},class:"thino-editor-placeholder"}),MQ=ep.StateField.define({create(){return Ci.Decoration.none},update(e,t){const n=t.state.field(C.editorInfoField);if(!(n!=null&&n.view)&&!((n==null?void 0:n.view)instanceof wl))return e;const r=new ep.RangeSetBuilder,a=t.state.doc.toString(),o=t.state.doc.lineAt(0);return(a==null?void 0:a.length)==0&&r.add(o.from,o.from,xQ),r.finish()},provide:e=>Ci.EditorView.decorations.from(e)});function Nx(e){return`userId:${e}`}function NQ(e,t){return`expiryDate:${t}:${e}`}function kQ(e){try{const t=Nx(e==null?void 0:e.appId);return Kn.get([t])[t]||""}catch(t){return console.error(t),""}}function AQ(e,t){try{const n=Nx(t==null?void 0:t.appId);return Kn.set({[n]:e}),{userId:e,key:n}}catch(n){console.error(n)}}function FQ(e,t){try{const n=NQ(kQ(t),t==null?void 0:t.appId);Kn.set({[n]:e})}catch(n){console.error(n)}}const OQ=Ue.grabImageFromUrl,PQ=require("http"),jQ=require("url");function LQ(e){const t=e.indexOf(";base64,"),n=e.substring(5,t),r=e.substr(t+8),a=atob(r),o=new ArrayBuffer(a.length),s=new Uint8Array(o);for(let d=0;d{const{type:t}=e;if(t.startsWith("image"))try{return`${await S1.upload(e)}`}catch(n){new C.Notice(n)}};function RQ(e){const t=PQ.createServer(async function(n,r){r.setHeader("Access-Control-Allow-Origin","*"),r.setHeader("Access-Control-Allow-Methods","GET, HEAD, POST, OPTIONS, PUT, PATCH, DELETE"),r.setHeader("Access-Control-Allow-Headers","Access-Control-Allow-Headers, Origin, Authorization,Accept,x-client-id, X-Requested-With, Content-Type, Access-Control-Request-Method, Access-Control-Request-Headers, hypothesis-client-version"),r.setHeader("Access-Control-Allow-Credentials","true");try{if(n.url){const a=jQ.parse(n.url,!0);if(a.pathname==="/create"&&n.method==="POST"){let o="";n.on("data",s=>{o+=s}),n.on("end",async()=>{const s=JSON.parse(o),{text:c,isList:d,type:p,imageList:m}=s;let g=c;if(!g){r.statusCode=200,r.setHeader("Content-Type","application/json"),r.end(JSON.stringify({status:"success",thino:null,link:null}));return}new RegExp(/(<([^>]+)>)/g).test(c)&&(g=C.htmlToMarkdown(c));let D=[];const S=[];if(e.AutoDownloadImage){const E=g.match(_u)||[];if(E.length>0){for(const O of E)try{const k=await OQ(O);if(k.size===0)continue;const j=new File([k],"image.png",{type:"image/png"}),F=await X2(j);S.push({oldUrl:O,newUrl:F})}catch(k){console.error(k)}S.forEach(O=>{g=g.replace(O.oldUrl,O.newUrl)}),m&&m.length>0&&(D=await Promise.all(m.map(async O=>{const k=LQ(O);return new File([k],"image.png",{type:"image/png"})})));for(const O of D){const k=await X2(O);g+=`
${k}`}}}const T=await Te.createThino({content:g,isList:d,type:p});T&&(Te.pushMemo(T),He.clearQuery()),r.statusCode=200,r.setHeader("Content-Type","application/json"),r.end(JSON.stringify({status:"success",thino:T,link:`obsidian://thino?openId=${T.id}`}))})}else if(a.pathname==="/search"&&n.method==="GET"){const o=a.query,{keyword:s}=o,c=Te.getThinoViaKeyword(s);r.statusCode=200,r.setHeader("Content-Type","application/json");const d=JSON.stringify({status:"success",thinos:c});r.end(d)}else r.statusCode=404,r.end()}}catch(a){console.error(a),r.statusCode=500,r.end({status:"error",message:a.message})}});return{listen(n,r){try{t.listen({port:parseInt(r),host:n})}catch(a){console.error(a),new C.Notice(N("Thino - Failed to start HTTP server, please check the port is available."))}new C.Notice(`${N("Thino - Started HTTP server on port")} ${r}`)},close(){t.close(),new C.Notice(N("Thino - Terminated HTTP server"))}}}const{clipboard:gn}=C.Platform.isDesktop?require("electron"):"";class BQ{constructor(){me(this,"eventListeners");this.eventListeners={}}on(t,n){this.eventListeners[t]=this.eventListeners[t]||[],this.eventListeners[t].push(n)}once(t,n){n.$emitOnce=!0,this.on(t,n)}removeListener(t,n){if(this.eventListeners[t]){const r=this.eventListeners[t].findIndex(a=>a===n);r>=0&&this.eventListeners[t].splice(r,1)}}removeAllListeners(t){this.eventListeners[t]&&(this.eventListeners[t].length=0)}emit(t,...n){this.eventListeners[t]&&this.eventListeners[t].forEach(r=>{r.call(this,...n),r.$emitOnce&&this.removeListener(t,r)})}}const Dd=new BQ;let Hh=null,eI=gn==null?void 0:gn.readText(),tI=gn==null?void 0:gn.readImage();gn&&(gn.on=(e,t)=>(Dd.on(e,t),gn),gn.once=(e,t)=>(Dd.once(e,t),gn),gn.off=(e,t)=>(t?Dd.removeListener(e,t):Dd.removeAllListeners(e),gn),gn.startWatching=()=>(Hh||(Hh=setInterval(()=>{_Q(eI,eI=gn==null?void 0:gn.readText())&&Dd.emit("text-changed"),HQ(tI,tI=gn==null?void 0:gn.readImage())&&Dd.emit("image-changed")},500)),gn),gn.stopWatching=()=>(Hh&&clearInterval(Hh),Hh=null,gn));function _Q(e,t){return t&&e!==t}function HQ(e,t){return!t.isEmpty()&&e.toDataURL()!==t.toDataURL()}var sI;const sw=(sI=require("electron"))==null?void 0:sI.remote;var lI,uI;const nI=(uI=(lI=require("electron"))==null?void 0:lI.remote)==null?void 0:uI.screen;class YQ{constructor(t,n){me(this,"isRegisted");me(this,"leaf");me(this,"clipboard");me(this,"isScreenTop",!1);me(this,"currentSplitWindow");me(this,"intervalNum");me(this,"allowsCopy",!1);me(this,"plugin");me(this,"actionEl",null);this.app=t,this.plugin=n,this.isRegisted=!1,this.leaf=null,this.clipboard=gn}async onload(){C.Platform.isDesktop&&(this.initGlobalCopyEvents(),await this.registerAllShortcuts(),this.registerEvents())}registerEvents(){this.plugin.registerEvent(this.app.workspace.on("quit",()=>{sw.globalShortcut.unregister(this.plugin.settings.CaptureKey.OpenThinoGlobally)}))}initGlobalCopyEvents(){this.plugin.addCommand({id:"init-global-copy-events",name:N("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",()=>{var t;this.allowsCopy=!1,this.clipboard.stopWatching(),(t=this.actionEl)==null||t.remove()}))}})}onunload(){this.isRegisted&&(sw.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(){var n;return this.leaf?this.app.workspace.getLeavesOfType("thino_view").length>0&&!!this.app.workspace.getLeafById(this.leaf.id)?!0:((n=this.leaf)==null||n.detach(),this.currentSplitWindow.close(),this.currentSplitWindow=null,this.leaf=null,this.isScreenTop=!1,!1):!1}async registerAllShortcuts(){sw.globalShortcut.register(this.plugin.settings.CaptureKey.OpenThinoGlobally,()=>{this.getCurrentLeaf()?this.showThinoView():this.openThinoView()}),this.isRegisted=!0}showThinoView(){var r,a,o,s;const t=nI.getCursorScreenPoint(),n=(s=(o=(a=(r=this.leaf)==null?void 0:r.parent)==null?void 0:a.parent)==null?void 0:o.win)==null?void 0:s.electronWindow;if(n){if(n.setAlwaysOnTop(!this.isScreenTop,"screen"),this.leaf.setPinned(!this.isScreenTop),this.leaf.view.containerEl.toggleClass("thino-float-window",!0),n.isMinimized()&&n.restore(),n.focus(),this.plugin.settings.CaptureKey.ShowNearMouse){const{width:c,height:d}=n.getBounds();n.setBounds({x:t.x,y:t.y,width:c,height:d})}if(this.app.workspace.trigger("focus-on-textarea"),this.isScreenTop){this.isScreenTop=!1,setTimeout(()=>{n.setAlwaysOnTop(!1,"screen")},200);return}this.isScreenTop=!0}}openThinoView(){var o,s,c,d,p;this.leaf=this.app.workspace.openPopoutLeaf({size:{width:400,height:400}});const t=this.leaf;this.leaf.view.containerEl.toggleClass("thino-float-window",!0),this.leaf.setViewState({type:"thino_view"}),setTimeout(()=>{t.view.containerEl.classList.toggle("mobile-view",!0)},0),this.currentSplitWindow=(s=(o=this.leaf)==null?void 0:o.parent)==null?void 0:s.parent;const n=(p=(d=(c=this.leaf)==null?void 0:c.parent)==null?void 0:d.parent)==null?void 0:p.win.electronWindow;if(!n)return;n.setAlwaysOnTop(!this.isScreenTop,"screen"),this.leaf.setPinned(!this.isScreenTop),this.isScreenTop=!0;const r=this.app,a=m=>{var D,S,T;const g=nI.getCursorScreenPoint(),v=(T=(S=(D=t==null?void 0:t.parent)==null?void 0:D.parent)==null?void 0:S.win)==null?void 0:T.electronWindow;if(v){if(v.isMinimized()&&v.restore(),!this.isScreenTop&&this.plugin.settings.CaptureKey.ShowNearMouse){const{width:E,height:O}=v.getBounds();v.setBounds({x:g.x,y:g.y-200,width:E,height:O})}v.setAlwaysOnTop(!0,"screen"),r.workspace.trigger("focus-on-textarea"),r.workspace.trigger("send-to-thino",m,t)}};this.clipboard.on("text-changed",()=>{const m=this.clipboard.readText();a(m)}).on("image-changed",()=>{const m=this.clipboard.readImage();a(m)})}}class rI extends C.EditorSuggest{constructor(n,r){super(n);me(this,"root");me(this,"editor");me(this,"cursor");me(this,"plugin");me(this,"tags");me(this,"type","customTag");me(this,"HASHTAG_REGEX",/(^|\s)#[^\u2000-\u206F\u2E00-\u2E7F'!"#$%&()*+,.:;<=>?@^`{|}~\[\]\\\s]*$/g);this.plugin=r}checkSettings(){return this.plugin.settings.UseVaultTags}checkInMemosView(n){var o;const r=n.containerEl;if(!r)return!1;const a=(o=r.parentElement)==null?void 0:o.parentElement;return(a==null?void 0:a.classList.contains("common-editor-inputer"))||!1}fuzzySearchItemsOptimized(n,r){const a=C.prepareFuzzySearch(n);return r.map(s=>{const c=a(s);return c?{item:s,match:c}:null}).filter(Boolean)}onTrigger(n,r){if(!this.checkInMemosView(r)||this.checkSettings())return null;this.tags=Te.getState().tags,this.cursor=n,this.editor=r;const a=n.line,o=r.getLine(a),s=o.substr(0,n.ch);if(s.match(this.HASHTAG_REGEX)&&o.substr(n.ch,1)!=="#"){const c=s.lastIndexOf("#"),d=s.substr(c+1);return{start:{line:a,ch:c},end:{line:a,ch:n.ch},query:d}}return null}getSuggestions(n){return this.fuzzySearchItemsOptimized(n.query,this.tags).map(r=>r.item).sort((r,a)=>r.localeCompare(a))||[]}renderSuggestion(n,r){r.setText(n)}selectSuggestion(n){if(this.context){const r=this.context.editor,a=this.context.start,o=this.context.end;r.transaction({changes:[{from:a,to:o,text:"#"+n+" "}]}),setTimeout(function(){return r.focus()})}this.close()}}const wb=crypto,kx=e=>e instanceof CryptoKey,Vg=new TextEncoder,bb=new TextDecoder;function zQ(...e){const t=e.reduce((a,{length:o})=>a+o,0),n=new Uint8Array(t);let r=0;for(const a of e)n.set(a,r),r+=a.length;return n}const UQ=e=>{const t=atob(e),n=new Uint8Array(t.length);for(let r=0;r{let t=e;t instanceof Uint8Array&&(t=bb.decode(t)),t=t.replace(/-/g,"+").replace(/_/g,"/").replace(/\s/g,"");try{return UQ(t)}catch{throw new TypeError("The input to be decoded is not correctly encoded.")}};class yv extends Error{static get code(){return"ERR_JOSE_GENERIC"}constructor(t){var n;super(t),this.code="ERR_JOSE_GENERIC",this.name=this.constructor.name,(n=Error.captureStackTrace)==null||n.call(Error,this,this.constructor)}}class VQ extends yv{constructor(){super(...arguments),this.code="ERR_JOSE_ALG_NOT_ALLOWED"}static get code(){return"ERR_JOSE_ALG_NOT_ALLOWED"}}class vv extends yv{constructor(){super(...arguments),this.code="ERR_JOSE_NOT_SUPPORTED"}static get code(){return"ERR_JOSE_NOT_SUPPORTED"}}class xr extends yv{constructor(){super(...arguments),this.code="ERR_JWS_INVALID"}static get code(){return"ERR_JWS_INVALID"}}class ZQ extends yv{constructor(){super(...arguments),this.code="ERR_JWS_SIGNATURE_VERIFICATION_FAILED",this.message="signature verification failed"}static get code(){return"ERR_JWS_SIGNATURE_VERIFICATION_FAILED"}}function us(e,t="algorithm.name"){return new TypeError(`CryptoKey does not support this operation, its ${t} must be ${e}`)}function Zg(e,t){return e.name===t}function uw(e){return parseInt(e.name.slice(4),10)}function WQ(e){switch(e){case"ES256":return"P-256";case"ES384":return"P-384";case"ES512":return"P-521";default:throw new Error("unreachable")}}function $Q(e,t){if(t.length&&!t.some(n=>e.usages.includes(n))){let n="CryptoKey does not support this operation, its usages must include ";if(t.length>2){const r=t.pop();n+=`one of ${t.join(", ")}, or ${r}.`}else t.length===2?n+=`one of ${t[0]} or ${t[1]}.`:n+=`${t[0]}.`;throw new TypeError(n)}}function GQ(e,t,...n){switch(t){case"HS256":case"HS384":case"HS512":{if(!Zg(e.algorithm,"HMAC"))throw us("HMAC");const r=parseInt(t.slice(2),10);if(uw(e.algorithm.hash)!==r)throw us(`SHA-${r}`,"algorithm.hash");break}case"RS256":case"RS384":case"RS512":{if(!Zg(e.algorithm,"RSASSA-PKCS1-v1_5"))throw us("RSASSA-PKCS1-v1_5");const r=parseInt(t.slice(2),10);if(uw(e.algorithm.hash)!==r)throw us(`SHA-${r}`,"algorithm.hash");break}case"PS256":case"PS384":case"PS512":{if(!Zg(e.algorithm,"RSA-PSS"))throw us("RSA-PSS");const r=parseInt(t.slice(2),10);if(uw(e.algorithm.hash)!==r)throw us(`SHA-${r}`,"algorithm.hash");break}case"EdDSA":if(e.algorithm.name!=="Ed25519"&&e.algorithm.name!=="Ed448")throw us("Ed25519 or Ed448");break;case"ES256":case"ES384":case"ES512":{if(!Zg(e.algorithm,"ECDSA"))throw us("ECDSA");const r=WQ(t);if(e.algorithm.namedCurve!==r)throw us(r,"algorithm.namedCurve");break}default:throw new TypeError("CryptoKey does not support this operation")}$Q(e,n)}function Ax(e,t,...n){var r;if(n.length>2){const a=n.pop();e+=`one of type ${n.join(", ")}, or ${a}.`}else n.length===2?e+=`one of type ${n[0]} or ${n[1]}.`:e+=`of type ${n[0]}.`;return t==null?e+=` Received ${t}`:typeof t=="function"&&t.name?e+=` Received function ${t.name}`:typeof t=="object"&&t!=null&&(r=t.constructor)!=null&&r.name&&(e+=` Received an instance of ${t.constructor.name}`),e}const aI=(e,...t)=>Ax("Key must be ",e,...t);function Fx(e,t,...n){return Ax(`Key for the ${e} algorithm must be `,t,...n)}const Ox=e=>kx(e),Ei=["CryptoKey"],qQ=(...e)=>{const t=e.filter(Boolean);if(t.length===0||t.length===1)return!0;let n;for(const r of t){const a=Object.keys(r);if(!n||n.size===0){n=new Set(a);continue}for(const o of a){if(n.has(o))return!1;n.add(o)}}return!0};function JQ(e){return typeof e=="object"&&e!==null}function oI(e){if(!JQ(e)||Object.prototype.toString.call(e)!=="[object Object]")return!1;if(Object.getPrototypeOf(e)===null)return!0;let t=e;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}const KQ=(e,t)=>{if(e.startsWith("RS")||e.startsWith("PS")){const{modulusLength:n}=t.algorithm;if(typeof n!="number"||n<2048)throw new TypeError(`${e} requires key modulusLength to be 2048 bits or larger`)}},ml=(e,t,n=0)=>{n===0&&(t.unshift(t.length),t.unshift(6));const r=e.indexOf(t[0],n);if(r===-1)return!1;const a=e.subarray(r,r+t.length);return a.length!==t.length?!1:a.every((o,s)=>o===t[s])||ml(e,t,r+1)},iI=e=>{switch(!0){case ml(e,[42,134,72,206,61,3,1,7]):return"P-256";case ml(e,[43,129,4,0,34]):return"P-384";case ml(e,[43,129,4,0,35]):return"P-521";case ml(e,[43,101,110]):return"X25519";case ml(e,[43,101,111]):return"X448";case ml(e,[43,101,112]):return"Ed25519";case ml(e,[43,101,113]):return"Ed448";default:throw new vv("Invalid or unsupported EC Key Curve or OKP Key Sub Type")}},QQ=async(e,t,n,r,a)=>{let o,s;const c=new Uint8Array(atob(n.replace(e,"")).split("").map(p=>p.charCodeAt(0))),d=t==="spki";switch(r){case"PS256":case"PS384":case"PS512":o={name:"RSA-PSS",hash:`SHA-${r.slice(-3)}`},s=d?["verify"]:["sign"];break;case"RS256":case"RS384":case"RS512":o={name:"RSASSA-PKCS1-v1_5",hash:`SHA-${r.slice(-3)}`},s=d?["verify"]:["sign"];break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":o={name:"RSA-OAEP",hash:`SHA-${parseInt(r.slice(-3),10)||1}`},s=d?["encrypt","wrapKey"]:["decrypt","unwrapKey"];break;case"ES256":o={name:"ECDSA",namedCurve:"P-256"},s=d?["verify"]:["sign"];break;case"ES384":o={name:"ECDSA",namedCurve:"P-384"},s=d?["verify"]:["sign"];break;case"ES512":o={name:"ECDSA",namedCurve:"P-521"},s=d?["verify"]:["sign"];break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":{const p=iI(c);o=p.startsWith("P-")?{name:"ECDH",namedCurve:p}:{name:p},s=d?[]:["deriveBits"];break}case"EdDSA":o={name:iI(c)},s=d?["verify"]:["sign"];break;default:throw new vv('Invalid or unsupported "alg" (Algorithm) value')}return wb.subtle.importKey(t,c,o,(a==null?void 0:a.extractable)??!1,s)},XQ=(e,t,n)=>QQ(/(?:-----(?:BEGIN|END) PUBLIC KEY-----|\s)/g,"spki",e,t,n);async function eX(e,t,n){if(typeof e!="string"||e.indexOf("-----BEGIN PUBLIC KEY-----")!==0)throw new TypeError('"spki" must be SPKI formatted string');return XQ(e,t,n)}const tX=(e,t)=>{if(!(t instanceof Uint8Array)){if(!Ox(t))throw new TypeError(Fx(e,t,...Ei,"Uint8Array"));if(t.type!=="secret")throw new TypeError(`${Ei.join(" or ")} instances for symmetric algorithms must be of type "secret"`)}},nX=(e,t,n)=>{if(!Ox(t))throw new TypeError(Fx(e,t,...Ei));if(t.type==="secret")throw new TypeError(`${Ei.join(" or ")} instances for asymmetric algorithms must not be of type "secret"`);if(n==="sign"&&t.type==="public")throw new TypeError(`${Ei.join(" or ")} instances for asymmetric algorithm signing must be of type "private"`);if(n==="decrypt"&&t.type==="public")throw new TypeError(`${Ei.join(" or ")} instances for asymmetric algorithm decryption must be of type "private"`);if(t.algorithm&&n==="verify"&&t.type==="private")throw new TypeError(`${Ei.join(" or ")} instances for asymmetric algorithm verifying must be of type "public"`);if(t.algorithm&&n==="encrypt"&&t.type==="private")throw new TypeError(`${Ei.join(" or ")} instances for asymmetric algorithm encryption must be of type "public"`)},rX=(e,t,n)=>{e.startsWith("HS")||e==="dir"||e.startsWith("PBES2")||/^A\d{3}(?:GCM)?KW$/.test(e)?tX(e,t):nX(e,t,n)};function aX(e,t,n,r,a){if(a.crit!==void 0&&r.crit===void 0)throw new e('"crit" (Critical) Header Parameter MUST be integrity protected');if(!r||r.crit===void 0)return new Set;if(!Array.isArray(r.crit)||r.crit.length===0||r.crit.some(s=>typeof s!="string"||s.length===0))throw new e('"crit" (Critical) Header Parameter MUST be an array of non-empty strings when present');let o;n!==void 0?o=new Map([...Object.entries(n),...t.entries()]):o=t;for(const s of r.crit){if(!o.has(s))throw new vv(`Extension Header Parameter "${s}" is not recognized`);if(a[s]===void 0)throw new e(`Extension Header Parameter "${s}" is missing`);if(o.get(s)&&r[s]===void 0)throw new e(`Extension Header Parameter "${s}" MUST be integrity protected`)}return new Set(r.crit)}const oX=(e,t)=>{if(t!==void 0&&(!Array.isArray(t)||t.some(n=>typeof n!="string")))throw new TypeError(`"${e}" option must be an array of strings`);if(t)return new Set(t)};function iX(e,t){const n=`SHA-${e.slice(-3)}`;switch(e){case"HS256":case"HS384":case"HS512":return{hash:n,name:"HMAC"};case"PS256":case"PS384":case"PS512":return{hash:n,name:"RSA-PSS",saltLength:e.slice(-3)>>3};case"RS256":case"RS384":case"RS512":return{hash:n,name:"RSASSA-PKCS1-v1_5"};case"ES256":case"ES384":case"ES512":return{hash:n,name:"ECDSA",namedCurve:t.namedCurve};case"EdDSA":return{name:t.name};default:throw new vv(`alg ${e} is not supported either by JOSE or your javascript runtime`)}}function sX(e,t,n){if(kx(t))return GQ(t,e,n),t;if(t instanceof Uint8Array){if(!e.startsWith("HS"))throw new TypeError(aI(t,...Ei));return wb.subtle.importKey("raw",t,{hash:`SHA-${e.slice(-3)}`,name:"HMAC"},!1,[n])}throw new TypeError(aI(t,...Ei,"Uint8Array"))}const lX=async(e,t,n,r)=>{const a=await sX(e,t,"verify");KQ(e,a);const o=iX(e,a.algorithm);try{return await wb.subtle.verify(o,a,n,r)}catch{return!1}};async function uX(e,t,n){if(!oI(e))throw new xr("Flattened JWS must be an object");if(e.protected===void 0&&e.header===void 0)throw new xr('Flattened JWS must have either of the "protected" or "header" members');if(e.protected!==void 0&&typeof e.protected!="string")throw new xr("JWS Protected Header incorrect type");if(e.payload===void 0)throw new xr("JWS Payload missing");if(typeof e.signature!="string")throw new xr("JWS Signature missing or incorrect type");if(e.header!==void 0&&!oI(e.header))throw new xr("JWS Unprotected Header incorrect type");let r={};if(e.protected)try{const T=lw(e.protected);r=JSON.parse(bb.decode(T))}catch{throw new xr("JWS Protected Header is invalid")}if(!qQ(r,e.header))throw new xr("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");const a={...r,...e.header},o=aX(xr,new Map([["b64",!0]]),n==null?void 0:n.crit,r,a);let s=!0;if(o.has("b64")&&(s=r.b64,typeof s!="boolean"))throw new xr('The "b64" (base64url-encode payload) Header Parameter must be a boolean');const{alg:c}=a;if(typeof c!="string"||!c)throw new xr('JWS "alg" (Algorithm) Header Parameter missing or invalid');const d=n&&oX("algorithms",n.algorithms);if(d&&!d.has(c))throw new VQ('"alg" (Algorithm) Header Parameter value not allowed');if(s){if(typeof e.payload!="string")throw new xr("JWS Payload must be a string")}else if(typeof e.payload!="string"&&!(e.payload instanceof Uint8Array))throw new xr("JWS Payload must be a string or an Uint8Array instance");let p=!1;typeof t=="function"&&(t=await t(r,e),p=!0),rX(c,t,"verify");const m=zQ(Vg.encode(e.protected??""),Vg.encode("."),typeof e.payload=="string"?Vg.encode(e.payload):e.payload);let g;try{g=lw(e.signature)}catch{throw new xr("Failed to base64url decode the signature")}if(!await lX(c,t,g,m))throw new ZQ;let D;if(s)try{D=lw(e.payload)}catch{throw new xr("Failed to base64url decode the payload")}else typeof e.payload=="string"?D=Vg.encode(e.payload):D=e.payload;const S={payload:D};return e.protected!==void 0&&(S.protectedHeader=r),e.header!==void 0&&(S.unprotectedHeader=e.header),p?{...S,key:t}:S}async function cX(e,t,n){if(e instanceof Uint8Array&&(e=bb.decode(e)),typeof e!="string")throw new xr("Compact JWS must be a string or Uint8Array");const{0:r,1:a,2:o,length:s}=e.split(".");if(s!==3)throw new xr("Invalid Compact JWS");const c=await uX({payload:a,protected:r,signature:o},t,n),d={payload:c.payload,protectedHeader:c.protectedHeader};return typeof t=="function"?{...d,key:c.key}:d}const dX={webId:"globe-2",pinned:"pin",archived:"archive",visibility:"eye",deleted:"trash"};class fX extends Ci.WidgetType{constructor(n,r,a,o,s){super();me(this,"error",!1);this.view=n,this.plugin=r,this.target=a,this.type=o,this.to=s}eq(n){return this.target===n.target}toDOM(){const n=createSpan();return n.toggleClass("thino-inline-widget",!0),C.setIcon(n,dX[this.type]||"help-circle"),C.setTooltip&&C.setTooltip(n,this.target),n}}function hX(e){class t{constructor(a){me(this,"view");me(this,"match",new Ci.MatchDecorator({regexp:/\[(webId|pinned|archived|visibility|deleted)::([^\]]+)\]/g,decorate:(a,o,s,c,d)=>{this.shouldRender(d,o,s)&&a(o,s,Ci.Decoration.replace({widget:new fX(d,e,c[0],c[1],s)}))}}));me(this,"decorations",Ci.Decoration.none);this.view=a,this.updateDecorations(a)}update(a){this.updateDecorations(a.view,a)}destroy(){this.decorations=Ci.Decoration.none}updateDecorations(a,o){!o||this.decorations.size===0?this.decorations=this.match.createDeco(a):this.decorations=this.match.updateDeco(o,this.decorations)}isLivePreview(a){return a.field(C.editorLivePreviewField)}shouldRender(a,o,s){return!a.state.selection.ranges.some(d=>d.from<=o?d.to>=o:d.from<=s)&&this.isLivePreview(a.state)}}const n={decorations:r=>r.decorations.update({filter:(a,o,s)=>{const c=s.spec.widget;return c&&c.error?!1:a===o||!r.view.state.selection.ranges.filter(d=>{const p=d.from,m=d.to;return p<=a?m>=a:p<=o}).length}})};return Ci.ViewPlugin.fromClass(t,n)}const pX=e=>e.ctrlKey!==void 0||e.metaKey!==void 0||e.shiftKey!==void 0||e.altKey!==void 0,Wg=()=>{new C.Notice(N("Open Memos Successfully"))},$g=[{id:"open-thino-in-left-sidebar",shortName:N("Left sidebar"),name:N("Open thino in left sidebar"),icon:"arrow-left",location:"left",cb:Wg,modKeys:"shift"},{id:"open-thino-in-right-sidebar",shortName:N("Right sidebar"),name:N("Open thino in right sidebar"),icon:"arrow-right",location:"right",cb:Wg,modKeys:["ctrl","meta"]},{id:"open-thino-in-float",shortName:N("Float window"),name:N("Open thino in float window"),icon:"layout",location:"float",cb:Wg,modKeys:"alt"},{id:"open-thino-in-center",shortName:N("Center window"),name:N("Open thino in center window"),icon:"tv-2",location:"center",cb:Wg,modKeys:void 0}];class mX extends C.Plugin{constructor(){super(...arguments);me(this,"settings");me(this,"settingTab");me(this,"triggerBySelf",!1);me(this,"updatedID","");me(this,"debounceTimer",0);me(this,"apiHttpServer",null);me(this,"captureService",null);me(this,"loaded",!1)}async onload(){await this.loadSettings(),bK(),this.registerRibbon(),await this.verify(),this.checkVersionAndShowChangeLog(),this.settingTab=new FK(this.app,this),this.addSettingTab(this.settingTab),this.initEditor(),this.initURIHandler(),this.registerMobileEvent(),this.registerCommands(),this.registerCanvasNodeMemos(),this.registerHoverEvent(),this.registerLinkOpen(),this.registerCodeBlocks(),this.registerEditorSuggest(new yK(this.app,this)),this.registerEditorExtension([MQ]),this.app.workspace.onLayoutReady(this.onLayoutReady.bind(this)),this.registerView(_r,n=>new wl(n,this))}async loadSettings(){this.settings=Object.assign({},cs,await this.loadData()),Xe.setSettings(this.settings)}async saveSettings(){await this.saveData(this.settings),Xe.setSettings(this.settings)}onunload(){var r;this.app.workspace.detachLeavesOfType(_r),Te.clearMemos(),Ee.dispatch({type:"CLEAR_MEMOS",payload:null}),Ee.dispatch({type:"CLEAR_FILES",payload:null}),Ee.dispatch({type:"CLEAR_VIEW",payload:null});const n=document.body.find(".dialog-wrapper");n&&((r=n.parentElement)==null||r.detach()),this.apiHttpServer&&(this.apiHttpServer.close(),this.apiHttpServer=null),this.captureService&&this.captureService.onunload(),new C.Notice(N("Close Memos Successfully"))}initEditor(){const n=()=>{const r=this.app.embedRegistry;if(!r)return!1;const a=r.embedByExtension.md,o=createEl("div"),s=a({app:this.app,containerEl:o},null,null);if(s.editable=!0,s.set(""),s.showEditor(),!s.editMode)return!1;const c=Object.getPrototypeOf(Object.getPrototypeOf(s.editMode));return Xe.setEditor(c),o.detach(),!0};this.app.workspace.onLayoutReady(()=>{n()||this.app.workspace.onLayoutReady(()=>{setTimeout(()=>{n()},100)})}),this.register(qh(C.MetadataCache.prototype,{getFileCache:r=>function(a){return!(a!=null&&a.path)&&!a?null:r.call(this,a)}}))}initApp(){Xe.setApp(this.app)}initURIHandler(){this.registerObsidianProtocolHandler("thino",async n=>{var s,c,d;if(!n)return;if(n.userid)try{const p=n.userid;AQ(p,this.app),FQ(C.moment().add(30,"days").valueOf(),this.app),Qe.setRefresh(!0)}catch(p){console.error(p),new C.Notice(N("Failed to verify"))}if(n.token)try{const p=n.token;(s=this.app)==null||s.saveLocalStorage("tokenForSync",p),setTimeout(()=>{this.app.setting.open(),this.app.setting.openTabById(this.manifest.id||"obsidian-memos"),this.settingTab.display()},200),new C.Notice(N("Saved sync token successfully"))}catch(p){console.error(p),new C.Notice(N("Failed to save"))}if(n.copyToken){this.app.setting.open(),this.app.setting.openTabById(this.manifest.id??"obsidian-memos");const p=await wx();await navigator.clipboard.writeText(p),new C.Notice(N("Copied app id successfully"))}const r=(c=Xe.getState())==null?void 0:c.verifyState,a=!C.Platform.isDesktop&&await((d=window.Capacitor)==null?void 0:d.Plugins.Device.getId()),o=C.Platform.isDesktop?await vn():a.identifier||a.uuid;if(!(!r||(r==null?void 0:r.appId)!==o)){if(n.content){const p=n.type,m=decodeURI(n.content)!==n.content?decodeURI(n.content):n.content,g=n.task,v=await Te.createThino({content:m,type:p,isList:!!g});if(!v)return;Te.pushMemo(v),He.clearQuery()}n.openId&&await Te.openThinoByID(n.openId)}})}initGlobalManifest(){Qe.setPluginManifest(this.manifest)}stopServer(){this.apiHttpServer&&(this.apiHttpServer.close(),this.apiHttpServer=null)}async initServer(){var o,s;if(C.Platform.isMobile||!this.settings.EnabledHttpApi)return;const n=(o=Xe.getState())==null?void 0:o.verifyState,r=!C.Platform.isDesktop&&await((s=window.Capacitor)==null?void 0:s.Plugins.Device.getId()),a=C.Platform.isDesktop?await vn():r.identifier||r.uuid;!n||(n==null?void 0:n.appId)!==a||(this.apiHttpServer=RQ(this.settings),this.initServerPort())}initServerPort(){this.apiHttpServer&&this.settings.EnabledHttpApi&&this.apiHttpServer.listen(this.settings.HttpApiIpType,this.settings.HttpApiPort)}async initCaptureService(){var o,s;if(C.Platform.isMobile||!this.settings.CaptureKey.EnableCaptureKey)return;const n=(o=Xe.getState())==null?void 0:o.verifyState,r=!C.Platform.isDesktop&&await((s=window.Capacitor)==null?void 0:s.Plugins.Device.getId()),a=C.Platform.isDesktop?await vn():r.identifier||r.uuid;!n||(n==null?void 0:n.appId)!==a||(this.captureService=new YQ(this.app,this),await this.captureService.onload())}registerMobileEvent(){C.Platform.isMobile&&(this.registerEvent(this.app.workspace.on("receive-text-menu",(n,r)=>{n.addItem(a=>{a.setSection("options").setIcon("popup-open").setTitle(N("Insert as Memo")).onClick(async()=>{let o=r;if(this.settings.ShareToThinoWithText){const c=this.settings.ShareToThinoWithTextPrepend+(this.settings.ShareToThinoWithTextNewline==="prepend"||this.settings.ShareToThinoWithTextNewline==="both"?`
`:" "),d=(this.settings.ShareToThinoWithTextNewline==="append"||this.settings.ShareToThinoWithTextNewline==="both"?`
`:" ")+this.settings.ShareToThinoWithTextAppend;o=c+o+d}const s=await Te.createThino({content:o,type:this.settings.MemoSaveLocation||"DAILY",isList:!0});Te.pushMemo(s)})})})),this.registerEvent(this.app.workspace.on("receive-files-menu",(n,r)=>{n.addItem(a=>{a.setIcon("popup-open").setTitle(N("Insert file as memo content")).onClick(async()=>{let s=r.map(d=>this.app.fileManager.generateMarkdownLink(d,d.path)).join(`
`);if(this.settings.ShareToThinoWithText){const d=this.settings.ShareToThinoWithTextPrepend+(this.settings.ShareToThinoWithTextNewline==="prepend"||this.settings.ShareToThinoWithTextNewline==="both"?`
`:" "),p=(this.settings.ShareToThinoWithTextNewline==="append"||this.settings.ShareToThinoWithTextNewline==="both"?`
`:" ")+this.settings.ShareToThinoWithTextAppend;s=d+s+p}const c=await Te.createThino({content:s,type:this.settings.MemoSaveLocation||"DAILY",isList:!0});Te.pushMemo(c)})})})))}registerCommands(){$g.forEach(n=>{this.addCommand({id:n.id,name:n.name,callback:()=>this.openMemos(n.location,n.cb),hotkeys:[]})}),this.addCommand({id:"show-thino-editor",name:N("Show thino editor"),checkCallback:n=>{if(Te.initialized&&Xe.initialized){if(!n){if(!Xe.getState().view){new C.Notice(N("Please open thino first"));return}new fx(this.app).open()}return!0}}}),this.addCommand({id:"lock-thino",name:N("Lock thino"),checkCallback:n=>{if(this.app.workspace.getActiveViewOfType(wl)&&this.settings.needVerify)return n||Qe.setLocked(!0),!0}}),this.addCommand({id:"copy-debug-info",name:N("Copy debug info"),callback:()=>{try{const n=this.app.internalPlugins.plugins["daily-notes"];let r;r={settings:{...this.settings,tokenForVerify:"***"},manifest:this.manifest,platform:C.Platform.resourcePathPrefix},n&&(r={...r,dailyNotePluginInfo:{options:n.instance.options}}),navigator.clipboard.writeText(`\`\`\`json
${JSON.stringify(r,null,2)}
\`\`\``),new C.Notice(N("Debug info copied to clipboard"))}catch(n){console.error(n)}}}),this.addCommand({id:"insert-editor",name:N("Insert editor"),checkCallback:n=>{const r=this.app.workspace.getActiveViewOfType(C.MarkdownView);if(r&&r.getViewType()==="markdown")return n||r.editor.replaceSelection("\n```thino\n{\n editor: false\n}\n```\n"),!0}}),this.addCommand({id:"toggle-minimal-thino",name:N("Toggle minimal mode"),callback:()=>{const n=document.body.hasClass("minimal-thino");document.body.toggleClass("minimal-thino",!n)}}),this.addCommand({id:"focus-on-thino-editor",name:N("Focus on thino editor"),callback:()=>this.focusOnEditor(),hotkeys:[]}),this.addCommand({id:"reinit-thino-sync",name:N("ReSync web thinos to local"),callback:()=>{HJ(this.app)}}),this.addCommand({id:"init-thino-sync",name:N("Sync local thinos to web"),callback:async()=>{var r;if(!((r=this.app)==null?void 0:r.loadLocalStorage("tokenForSync"))){new C.Notice(N("Please input token first"));return}if(!this.settings.startSync){new C.Notice(N("Please enable sync first"));return}try{await Te.initSync()}catch(a){console.error(a),new C.Notice(N("Init Failed"))}}}),this.addCommand({id:"show-daily-thino",name:N("Show daily thino"),callback:()=>this.openDailyMemo(),hotkeys:[]}),this.addCommand({id:"focus-on-search-bar",name:N("Focus on search bar"),callback:()=>this.searchIt(),hotkeys:[]}),this.addCommand({id:"show-thino-in-popover",name:N("Show-thino in popover(Hover editor)"),callback:()=>this.showInPopover(),hotkeys:[]})}async onLayoutReady(){this.initApp(),await this.initServer(),this.initGlobalManifest(),await this.initMemos(),this.autoOpenMemos(),this.registerThinoWidget(),await this.registerToolbarCheck(),await this.initCaptureService(),Xe.setPlugin(this);const n=this.app.workspace.editorSuggest.suggests.findIndex(r=>r.type==="customTag");n!==-1?(this.app.workspace.editorSuggest.suggests.splice(n,1),this.app.workspace.editorSuggest.suggests.unshift(new rI(this.app,this))):this.app.workspace.editorSuggest.suggests.unshift(new rI(this.app,this))}async initMemos(){try{await this.initDailyNotes()}catch(n){console.error(n)}Xe.getState(),Te.getState(),await Te.fetchAllMemos()}async initDailyNotes(){this.settings.EnabledLocationList.find(n=>n.value==="DAILY")&&await Xe.fechLocalDailyNotes()}registerCanvasNodeMemos(){if(!C.requireApiVersion("1.2.0")||!this.settings.EnabledLocationList.find(o=>o.value==="CANVAS"))return;const n=o=>{clearTimeout(this.debounceTimer),this.debounceTimer=window.setTimeout(()=>{setTimeout(async()=>{const s=o.canvas.getData(),c=s.nodes.find(d=>d.id===o.id);if(c&&(r(c),o.canvas.setData(s),Te.getMemoById(o.id))){const p=await Te.updateMemo(o.id,c.text,c.thinoType);Te.editMemo(p)}o.canvas.requestSave(!0)},0)},800)},r=o=>{o.createdAt||(o.createdAt=C.moment().format("YYYY-MM-DD HH:mm:ss")),o.updatedAt=C.moment().format("YYYY-MM-DD HH:mm:ss"),o.deletedAt=o.deletedAt?o.deletedAt:"",o.pinned=o.pinned?o.pinned:!1,o.visibility=o.visibility?o.visibility:"PUBLIC",o.rowStatus=o.rowStatus?o.rowStatus:"NORMAL",o.thinoType=o.thinoType?o.thinoType:"JOURNAL",o.hasId=o.hasId?o.hasId:"",o.linkId=o.linkId?o.linkId:"",o.resourceList=[]},a=()=>{var v,D;const o=(v=this.app.workspace.getLeavesOfType("canvas").first())==null?void 0:v.view;if(!o||!(o==null?void 0:o.canvas))return!1;const c=((D=this.app.workspace.getLeavesOfType("canvas").first())==null?void 0:D.view).canvas.nodes.values(),p=Array.from(c).filter(S=>S.text!==void 0);if(!p||p.length===0)return!1;const m=p[0].child;if(!m)return!1;const g=qh(m.constructor.prototype,{save:S=>function(...T){S.call(this,...T),this.node.isEditing&&n(this.node)}});return this.register(g),!0};this.app.workspace.onLayoutReady(()=>{if(!a()){const o=this.app.workspace.on("layout-change",()=>{a()&&this.app.workspace.offref(o)});this.registerEvent(o)}})}registerLinkOpen(){qh(C.Workspace.prototype,{openLinkText:n=>async function(r,a,o,s,...c){const d=Te.getState().memos;if(d.find(p=>p.id===r||p.id===a)){const p=d.find(m=>m.id===r||m.id===a);$d(p);return}n.call(this,r,a,o,s,...c)}})}registerHoverEvent(){this.registerHoverLinkSource("thino",{defaultMod:!0,display:"Thino"})}registerCodeBlocks(){this.registerMarkdownCodeBlockProcessor("thino",async(n,r)=>{var a;if(n){if(!((a=this.app.workspace.getLeavesOfType("thino_view"))!=null&&a.length)){r.toggleClass(["thino-editor-codeblock","view-error"],!0),bJ(r,this);return}if(n){const o=C.parseYaml(n);SJ(r,o)}}})}registerRibbon(){this.addRibbonIcon("Memos",N("ribbonIconTitle"),async n=>{if(n.button===2){n.preventDefault();const r=new C.Menu;$g.forEach(a=>{r.addItem(o=>{o.setTitle(a.shortName).setIcon(a.icon).onClick(async()=>{await this.openMemos(a.location,a.cb)})})}),r.showAtMouseEvent(n);return}for(let r=0;r<$g.length;r++){const a=$g[r];if(!a.modKeys){await this.openMemos(a.location,a.cb);break}if(!pX(n))continue;const o=s=>n[`${s}Key`];if(typeof a.modKeys=="string"&&o(a.modKeys)||Array.isArray(a.modKeys)&&a.modKeys.some(o)){await this.openMemos(a.location,a.cb);break}}})}registerThinoWidget(){this.registerEditorExtension([hX(this)])}async registerToolbarCheck(){var o,s;if(this.loaded)return;const n=(o=Xe.getState())==null?void 0:o.verifyState,r=!C.Platform.isDesktop&&await((s=window.Capacitor)==null?void 0:s.Plugins.Device.getId()),a=C.Platform.isDesktop?await vn():r.identifier||r.uuid;!n||(n==null?void 0:n.appId)!==a||(this.registerEditorExtension([TQ(this.app)]),this.registerEditorSuggest(new vK(this.app,this)),this.loaded=!0)}async verify(){var a;let n="";if(C.Platform.isDesktop)n=await vn();else{const o=await((a=window.Capacitor.Plugins.Device)==null?void 0:a.getId());if(!o)return;n=o.identifier||o.uuid}async function r(o){if(!o)return Xe.setVerifyState(null),!1;const d=await eX(`-----BEGIN PUBLIC KEY-----
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:p}=await cX(o,d),m=JSON.parse(new TextDecoder().decode(p));return!m||m.iss!=="pkmer"||m.type!=="thino"||m.appId!==n?!1:(Xe.setVerifyState(m),!0)}catch(p){console.error(p)}}return await r(this.settings.tokenForVerify[n])}async checkVersionAndShowChangeLog(){const n=this.manifest.version,r=this.settings.LastUpdatedVersion;n!==r&&(this.settings.LastUpdatedVersion=n,await this.saveSettings(),this.showChangeLog())}showChangeLog(){new Db(this.app,this.manifest.version).open()}autoOpenMemos(){this.app.workspace.getLeavesOfType(_r).length>0||this.settings.MobileAndDesktop==="Mobile"&&C.Platform.isDesktop||this.settings.MobileAndDesktop==="Desktop"&&C.Platform.isMobile||this.settings.OpenMemosAutomatically&&this.openMemos()}async openDailyMemo(){if(this.app.workspace.getLeavesOfType(_r).length>0){He.setPathname("/daily");return}await this.openMemos(),He.setPathname("/daily")}async openMemos(n="center",r){const a=this.app.workspace;if(a.getLeavesOfType(_r).length>0){const c=a.getLeavesOfType(_r)[0];a.setActiveLeaf(c),a.revealLeaf(c);return}a.detachLeavesOfType(_r);let o;switch(n){case"left":o=a.getLeftLeaf(!1);break;case"right":o=a.getRightLeaf(!1);break;case"float":o=a.getLeaf("window");break;default:o=a.getLeaf(!0);break}o&&(await o.setViewState({type:_r}),a.revealLeaf(o));const s=o.view.containerEl.querySelector("textarea");s&&s.focus(),r==null||r()}async searchIt(){const n=this.app.workspace,r=n.getLeavesOfType(_r);if(!(r.length>0)){await this.openMemos(),this.app.workspace.trigger("focus-on-searchbar");return}const a=r[0];n.revealLeaf(a),this.app.workspace.trigger("focus-on-searchbar")}async focusOnEditor(){if(!(this.app.workspace.getLeavesOfType(_r).length>0)){await this.openMemos();return}this.app.workspace.trigger("focus-on-textarea")}changeStatus(){const n=this.app.workspace,r=n.getLeavesOfType(_r);if(!(r.length>0)){new C.Notice(N("Please Open Memos First"));return}const a=r[0];n.setActiveLeaf(a),a.view.containerEl.querySelector(".list-or-task").click()}async showInPopover(){var o,s,c;const n=this.app.workspace;if(n.detachLeavesOfType(_r),!this.app.plugins.getPlugin("obsidian-hover-editor")){new C.Notice(N("Please install obsidian-hover-editor plugin first"));return}const a=await((o=this.app.plugins.getPlugin("obsidian-hover-editor"))==null?void 0:o.spawnPopover());a&&(await a.setViewState({type:_r}),n.revealLeaf(a),a.view.containerEl.classList.add("mobile-view"),(s=this.settings)!=null&&s.FocusOnEditor&&a.view.containerEl.querySelector("textarea")!==void 0&&((c=a.view.containerEl.querySelector("textarea"))==null||c.focus()))}}class Db extends C.Modal{constructor(n,r){super(n);me(this,"component");this.version=r}async onOpen(){const{contentEl:n}=this;this.containerEl.toggleClass("thino-changelog-modal",!0),n.createEl("h2",{text:N("Thino update info")+` version ${this.version}`});try{n.createEl("h3",{text:N("Latest version")});const r=n.createDiv("current-change-log");n.createEl("hr"),n.createEl("h3",{text:N("Previous version")});const a=n.createDiv("prev-change-log"),s=await C.requestUrl("https://raw.githubusercontent.com/Quorafind/Obsidian-Thino/main/CHANGELOG.md");this.component=new C.Component;const[c,d]=this.getLatestVersionContent(s.text);await C.MarkdownRenderer.render(this.app,c,r,"",this.component),await C.MarkdownRenderer.render(this.app,d,a,"",this.component)}catch(r){console.error(r),n.createEl("p",{text:N("Failed to load changelog")}),n.createEl("a",{text:N("View online"),attr:{href:"https://raw.githubusercontent.com/Quorafind/Obsidian-Thino/main/CHANGELOG.md",target:"_blank"}})}}getLatestVersionContent(n){const r=/^# .+/gm,a=[...n.matchAll(r)];if(a.length===0)return[n,""];const o=a[0].index||0;let s=n.length;a.length>1&&(s=a[1].index||n.length);const c=n.substring(o,s).trim(),d=n.substring(s).trim();return[c,d]}onClose(){var r;const{contentEl:n}=this;n.empty(),(r=this.component)==null||r.unload()}}exports.ChangeLogModal=Db;exports.default=mX;