@augmentd-labs/canvas-web 2.26.27 → 2.26.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/CalendarApplet-CXG7O1QW.js +1 -0
- package/dist/assets/{DocumentBodyEditor-8DNmOBS0.js → DocumentBodyEditor-DRFQgBNB.js} +1 -1
- package/dist/assets/{DocumentIcon-x299QNu_.js → DocumentIcon-ByDAILhm.js} +1 -1
- package/dist/assets/{EditorOverlay-Cv1MaTok.js → EditorOverlay-DpQKmxkR.js} +1 -1
- package/dist/assets/{FileForm-CqJpRbXv.js → FileForm-B6eFRKG-.js} +1 -1
- package/dist/assets/{FiltersApplet-C-WD5XT9.js → FiltersApplet-C6-D-MEW.js} +1 -1
- package/dist/assets/{HomeFab-CzKEIYDk.js → HomeFab-DZbi60PC.js} +2 -2
- package/dist/assets/{IdentityFields-Bti7ojF3.js → IdentityFields-CEDxU-Hd.js} +1 -1
- package/dist/assets/{LensApplet-BCJXNx84.js → LensApplet-B9OaePzA.js} +1 -1
- package/dist/assets/LinkToCard-VXpoeMDH.js +1 -0
- package/dist/assets/{MarkdownEditor-CNY-VmKb.js → MarkdownEditor-Dnyez7VT.js} +2 -2
- package/dist/assets/{MessageComposerDialog-gbD0Gu_b.js → MessageComposerDialog-BKGlI7jO.js} +1 -1
- package/dist/assets/{NextShell-UX4Efo0u.js → NextShell-BvKyH2Oj.js} +1 -1
- package/dist/assets/{NotesApplet-CvPyt7xB.js → NotesApplet-BM7ksdXl.js} +1 -1
- package/dist/assets/ObjectPropertiesCard-CFZ_LqzX.js +8 -0
- package/dist/assets/{PathPickerField-fZazwxCN.js → PathPickerField-B58yeJGw.js} +1 -1
- package/dist/assets/PickDocumentsCard-B72XNYh3.js +1 -0
- package/dist/assets/{SketchApplet-DDIg411i.js → SketchApplet-BHee4eKG.js} +1 -1
- package/dist/assets/{SketchEditor-CKPPuZt3.js → SketchEditor-Knj-HA0P.js} +1 -1
- package/dist/assets/{TerminalApplet-wGJG1PPc.js → TerminalApplet-Djk4l1Jm.js} +1 -1
- package/dist/assets/{TextDocumentEditor-CRre32cj.js → TextDocumentEditor-rgHsbLCL.js} +1 -1
- package/dist/assets/{TodosApplet-CleBd4uU.js → TodosApplet-DZVcRHmh.js} +1 -1
- package/dist/assets/{TodosWidget-CxiqmDuJ.js → TodosWidget-CX4lgk-9.js} +1 -1
- package/dist/assets/{UploadProgressList-DRJzjy6A.js → UploadProgressList-CHQ-Kn-e.js} +1 -1
- package/dist/assets/{_agentId_-BXYnpAWp.js → _agentId_-CweMTe-q.js} +0 -0
- package/dist/assets/_contextId_-HAAoVKBa.js +1 -0
- package/dist/assets/_workspaceName_-D79RwRsV.js +1 -0
- package/dist/assets/{about-DrgIxiPQ.js → about-dr4T4ju8.js} +1 -1
- package/dist/assets/{add-CPkuZwMW.js → add-fha_SoND.js} +1 -1
- package/dist/assets/agents-CZgEe18J.js +1 -0
- package/dist/assets/{agents-DlLq0q2s.js → agents-DEJU4O1Z.js} +1 -1
- package/dist/assets/{alert-dialog-izlVMXfa.js → alert-dialog-CShuAcnP.js} +1 -1
- package/dist/assets/{api-tokens-DDH7LMJ7.js → api-tokens-CmHhwd58.js} +1 -1
- package/dist/assets/{appearance-DRBtL9nd.js → appearance-SqhMHD_S.js} +1 -1
- package/dist/assets/{applet-target-C_gBgU-Z.js → applet-target-Bl9Je1N-.js} +1 -1
- package/dist/assets/apps-stCO1N5r.js +1 -0
- package/dist/assets/{auth-HZNJB4wv.js → auth-_bmIEN02.js} +1 -1
- package/dist/assets/backend-sync-progress-DyvV8N9D.js +7 -0
- package/dist/assets/{button-SgR3GVvV.js → button-Bum-POPT.js} +1 -1
- package/dist/assets/content-app-view-CotdPc2q.js +1 -0
- package/dist/assets/{context-DQoZFMDQ.js → context-BGgz0Y_q.js} +1 -1
- package/dist/assets/{contexts-CvMtPd1N2.js → contexts-CwGdjtXy2.js} +1 -1
- package/dist/assets/{contexts-Ef3fHwv6.js → contexts-Dtl9oERX.js} +1 -1
- package/dist/assets/{date-time-picker-DebNUTx3.js → date-time-picker-Bzu8H_Oa.js} +1 -1
- package/dist/assets/{devices-C3gLuNDv.js → devices-CmVlYbam.js} +1 -1
- package/dist/assets/{document-DOp6AbOi.js → document-Ds_P5v-f.js} +1 -1
- package/dist/assets/document-list-Cq4rdquK.js +2 -0
- package/dist/assets/{embedding-B5JiUA9X.js → embedding-2EjzoVFT.js} +1 -1
- package/dist/assets/{embedding-B7cWrpy0.js → embedding-BqI3l5RB.js} +1 -1
- package/dist/assets/{form-panel-C34lByEH.js → form-panel-DZj3WZ3z.js} +1 -1
- package/dist/assets/{home-C6aXJsmf.js → home-w5SlrNH7.js} +1 -1
- package/dist/assets/index-DGCnvWMM.js +16 -0
- package/dist/assets/index-XDD8pFI_.css +2 -0
- package/dist/assets/{inferd-config-editor--MDmN_7w.js → inferd-config-editor-CyDCQJRs.js} +1 -1
- package/dist/assets/{key-bindings-BDktmxOD.js → key-bindings-5HbdLjsz.js} +1 -1
- package/dist/assets/{label-Dn4gCMcc.js → label-DJc8-3CQ.js} +1 -1
- package/dist/assets/{lazy-editor-BSRnneOo.js → lazy-editor-Bdm5JEXv.js} +2 -2
- package/dist/assets/{logs-Czn2sPeP.js → logs-DUeiDqCX.js} +1 -1
- package/dist/assets/{offline-COOUcZsG.js → offline-yfQ63Zr7.js} +1 -1
- package/dist/assets/{page-header-DkOHw0g-.js → page-header-BoCaZiqu.js} +1 -1
- package/dist/assets/{public-share-g_wBd6BW.js → public-share-D2S8DEsv.js} +1 -1
- package/dist/assets/{query-debug-CrPsUwT-.js → query-debug-B3pFyO8g.js} +1 -1
- package/dist/assets/registry-BRI7e6jw.js +2 -0
- package/dist/assets/{remotes-CdEU1Y5l.js → remotes-BjjlqN_M.js} +1 -1
- package/dist/assets/{roles-BpVWTMmp.js → roles-BHJYWaBs.js} +1 -1
- package/dist/assets/{roles-Bo9GZdOk.js → roles-CuqCEPC7.js} +1 -1
- package/dist/assets/{settings-TQmRYAGg.js → settings-Btb3SUu6.js} +1 -1
- package/dist/assets/{settings-DJyvE-wf.js → settings-D55sWdd2.js} +1 -1
- package/dist/assets/{settings-Be_a2PGC.js → settings-UMBkdMdX.js} +1 -1
- package/dist/assets/settings-y5FovQxO.js +16 -0
- package/dist/assets/{share-target-BDbVdgTo.js → share-target-5HoF3Y5a.js} +1 -1
- package/dist/assets/{shared-BbAavKdN.js → shared-B24deTOM.js} +1 -1
- package/dist/assets/{shared-BQZGA3ph.js → shared-C-uHNNY8.js} +1 -1
- package/dist/assets/sketch-lazy-BOFTGGTA.js +2 -0
- package/dist/assets/{subtree-transfer-dialog-ChBI5llU.js → subtree-transfer-dialog-BN9xBB9n.js} +1 -1
- package/dist/assets/{text-documents-0P9jkIpu.js → text-documents-CFW8MWES.js} +2 -2
- package/dist/assets/ui-76Hw0NU_.js +41 -0
- package/dist/assets/{use-applet-docs-D5eXpITp.js → use-applet-docs-DBshA7yq.js} +1 -1
- package/dist/assets/use-applet-target-DmIdCxa_.js +1 -0
- package/dist/assets/use-canvas-pins-BZMaPpb7.js +3 -0
- package/dist/assets/{use-menu-BiJ8N7sS.js → use-menu-CaiLyPdw.js} +1 -1
- package/dist/assets/use-settings-back-DE0SPb7h.js +1 -0
- package/dist/assets/{use-sortable-data-BW_0sXBs.js → use-sortable-data-W2inLcb5.js} +1 -1
- package/dist/assets/{use-workspace-identity-BCrrvfeE.js → use-workspace-identity-KxY9injc.js} +1 -1
- package/dist/assets/useAddTarget-D4ra50Am.js +1 -0
- package/dist/assets/{useAgentModels-PQVPjrQu.js → useAgentModels-vTfsjAwS.js} +1 -1
- package/dist/assets/{useDocumentThumbnail-DunxmU1A.js → useDocumentThumbnail-Bs2Ju0eb.js} +1 -1
- package/dist/assets/{useEditNoteFields-BehI0vog.js → useEditNoteFields-CKYMBf8V.js} +1 -1
- package/dist/assets/{users-CKz9kOoR.js → users-DInwKAxz.js} +1 -1
- package/dist/assets/workspace-46EFyEKZ.js +1 -0
- package/dist/assets/{workspace-area-menu-C0-X-FpD.js → workspace-area-menu-COdiU0Xn.js} +1 -1
- package/dist/assets/{workspace-content-gate-9okuA7J7.js → workspace-content-gate-CGZmT2kw.js} +1 -1
- package/dist/assets/{workspace-import-form-aR-DwHf6.js → workspace-import-form-Bu1nlv8u.js} +1 -1
- package/dist/assets/workspaces-BBq3LOwy.js +1 -0
- package/dist/assets/{workspaces-Da_hUIj3.js → workspaces-p959p9BR.js} +1 -1
- package/dist/index.html +36 -36
- package/dist/sw.js +1 -1
- package/package.json +2 -2
- package/dist/assets/LinkToCard-5dg0jvSY.js +0 -1
- package/dist/assets/ObjectPropertiesCard-BIBMvx_i.js +0 -8
- package/dist/assets/PickDocumentsCard-DamtV7fN.js +0 -1
- package/dist/assets/_contextId_-BEC7o1ya.js +0 -1
- package/dist/assets/_workspaceName_-5rSLTtJT.js +0 -1
- package/dist/assets/agents-jmTwCDAu.js +0 -1
- package/dist/assets/apps-CqFFzo_Z.js +0 -1
- package/dist/assets/backend-sync-progress-pZrhQPk3.js +0 -7
- package/dist/assets/content-app-view-y5TmcjuO.js +0 -1
- package/dist/assets/document-list-DKOU9Kcc.js +0 -2
- package/dist/assets/index-B-PM5mzp.css +0 -2
- package/dist/assets/index-CyEIU2rL.js +0 -16
- package/dist/assets/registry-ZMLdscra.js +0 -2
- package/dist/assets/settings-VF2v3Ya5.js +0 -14
- package/dist/assets/sketch-lazy-C4pjV1WK.js +0 -2
- package/dist/assets/ui-Byg1cZDr.js +0 -41
- package/dist/assets/use-applet-target-gXPvZGgx.js +0 -1
- package/dist/assets/use-canvas-pins-BvN6Gw6f.js +0 -3
- package/dist/assets/use-settings-back-CQauYjQ4.js +0 -1
- package/dist/assets/useAddTarget-CqnDU0Om.js +0 -1
- package/dist/assets/workspace-CrSpR4xf.js +0 -1
- package/dist/assets/workspaces-BGbHBVHs.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{t as r}from"./button-
|
|
1
|
+
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{t as r}from"./button-Bum-POPT.js";import{t as i}from"./input-BOtCd4HP.js";import{c as a,t as o}from"./api-CA6WiiYM.js";import{t as s}from"./markdown-it-DRESbtwK.js";import{t as c}from"./lazy-editor-Bdm5JEXv.js";var l=t();function u({tabs:e,active:t,onChange:n,className:r=``,iconOnly:i=!1}){return(0,l.jsx)(`div`,{className:`flex gap-1 border-b overflow-x-auto ${r}`,children:e.map(e=>{let r=e.icon;return(0,l.jsxs)(`button`,{onClick:()=>n(e.id),title:e.label,className:`${i&&r?`px-3`:`px-4`} py-2 text-sm font-medium border-b-2 transition-colors whitespace-nowrap inline-flex items-center gap-1.5 ${t===e.id?`border-primary text-foreground`:`border-transparent text-muted-foreground hover:text-foreground`}`,children:[r&&(0,l.jsx)(r,{className:`h-3.5 w-3.5`}),(!i||!r)&&e.label]},e.id)})})}var d=e(n(),1),f=e=>`${a.workspaces}/${encodeURIComponent(e)}/messages`,p=e=>o.get(`${f(e)}/accounts`),m=(e,t)=>o.get(`${f(e)}/reply-target/${t}`),h=(e,t)=>o.post(`${f(e)}/send`,t),g=(e,t)=>o.get(`${f(e)}/whatsapp/${encodeURIComponent(t)}/connection`),_=(e,t)=>o.get(`${f(e)}/outbox/${encodeURIComponent(t)}`),v=(e,t)=>o.delete(`${f(e)}/whatsapp/${encodeURIComponent(t)}/connection`),y=(e,t)=>o.get(`${f(e)}/thread/${t}`),b=new s({html:!1});function x(e){let t=e=>{let n=[];return e.map(e=>{if(e.children)return t(e.children);switch(e.type){case`strong_open`:case`strong_close`:return`*`;case`em_open`:case`em_close`:return`_`;case`s_open`:case`s_close`:return`~`;case`code_inline`:return`\`${e.content}\``;case`fence`:case`code_block`:return`\`\`\`\n${e.content}\`\`\`\n`;case`text`:return e.content;case`softbreak`:case`hardbreak`:return`
|
|
2
2
|
`;case`paragraph_close`:case`heading_close`:return`
|
|
3
3
|
|
|
4
4
|
`;case`list_item_open`:return`- `;case`link_open`:return n.push(String(e.attrGet(`href`)||``)),``;case`link_close`:return` (${n.pop()||``})`;case`image`:return e.content;default:return``}}).join(``)};return t(b.parse(e,{})).trim()}function S(e,t,n=!1){let r=2166136261;try{for(let e of localStorage.getItem(`authToken`)||``)r=Math.imul(r^e.charCodeAt(0),16777619)}catch{}return`canvas:message-draft:${r>>>0}:${e}:${t||`new`}${n?`:fwd`:``}`}var C={reply:`Reply`,replyAll:`Reply all`,forward:`Forward`};function w({workspaceId:e,replyToDocumentId:t,mode:n=`reply`,originalSubject:a,initialAccount:o,testEmail:s=!1,onClose:u}){let f=!!t&&n===`forward`,g=s?`${S(e)}:smtp-test:${o?.address}`:S(e,t,f),v=()=>({requestId:crypto.randomUUID(),text:s?`This is a test email sent from Canvas to check the SMTP configuration.`:``,replyToDocumentId:t,...o,...s?{subject:`Canvas SMTP test`}:{},...f?{forward:!0}:t?{replyAll:n===`replyAll`,quote:!0}:{}}),[y,b]=(0,d.useState)(()=>{try{let e=localStorage.getItem(g);if(e){let r=JSON.parse(e),i=r.draft||r;if(f||!t||r.attempted)return i;let a=n===`replyAll`;return{...i,replyAll:a,...!!i.replyAll===a?{}:{to:void 0,cc:void 0}}}}catch{}return v()}),[w,T]=(0,d.useState)(null),[E,D]=(0,d.useState)([]),[O,k]=(0,d.useState)(navigator.onLine);(0,d.useEffect)(()=>{let e=()=>k(navigator.onLine);return window.addEventListener(`online`,e),window.addEventListener(`offline`,e),()=>{window.removeEventListener(`online`,e),window.removeEventListener(`offline`,e)}},[]);let A=(0,d.useRef)(!1),[j,M]=(0,d.useState)(!1),[N,P]=(0,d.useState)(!1),[F,I]=(0,d.useState)(()=>{try{return JSON.parse(localStorage.getItem(g)||`{}`).attempted===!0}catch{return!1}}),[L,R]=(0,d.useState)(``),[z,B]=(0,d.useState)(null);(0,d.useEffect)(()=>{let n=!0;return Promise.all([p(e),t?m(e,t):Promise.resolve(null)]).then(([e,r])=>{n&&(T(r),D(e.filter(e=>e.canSend&&(!r||e.driver===r.driver&&e.address===r.address))),t&&!r&&R(`This message has no supported reply account.`),r&&b(e=>{let t=e.replyAll?r.allRecipients:r.recipients;return{...e,driver:r.driver,address:r.address,...!f&&t&&!F?{to:e.to?.some(e=>e.trim())?e.to:t.to,cc:e.cc?.some(e=>e.trim())?e.cc:t.cc}:{}}}))}).catch(e=>{n&&R(e.message)}),()=>{n=!1}},[e,t,f,F]),(0,d.useEffect)(()=>{try{z?.status===`accepted`?localStorage.removeItem(g):localStorage.setItem(g,JSON.stringify({draft:y,attempted:F}))}catch{}},[g,y,F,z]);let V=E.find(e=>e.driver===y.driver&&e.address===y.address),H=V?.driver===`imap`,U=V?.driver===`whatsapp`,W=!!y.images?.length,G=!!y.text.trim(),K=e=>b(t=>({...t,...e})),q=async()=>{P(!0),R(``),I(!0);let t=H?G?y:{...y,html:void 0}:{...y,text:U?x(y.text):y.text,html:void 0,quote:void 0,forward:void 0};try{let n=F?await _(e,y.requestId).catch(n=>{if(n.statusCode===404)return h(e,t);throw n}):await h(e,t);if(B(n),n.status===`accepted`){try{localStorage.removeItem(g)}catch{}window.dispatchEvent(new CustomEvent(`workspace:documents:refresh`,{detail:{workspaceName:e}}))}}catch(e){let t=e;R(t.message),!F&&t.statusCode&&t.statusCode>=400&&t.statusCode<500&&t.statusCode!==409&&I(!1)}finally{P(!1)}},J=async e=>{if(X||A.current)return;let t=e.filter(e=>[`image/png`,`image/jpeg`,`image/webp`,`image/gif`].includes(e.type));if(t.length){if((y.images?.length||0)+t.length>(U?1:8)){R(U?`One picture per WhatsApp reply.`:`Up to 8 pictures per email.`);return}if((y.images||[]).reduce((e,t)=>e+t.base64.length*3/4,0)+t.reduce((e,t)=>e+t.size,0)>8388608){R(`Pictures must total at most 8 MB.`);return}A.current=!0,M(!0);try{let e=await Promise.all(t.map(e=>new Promise((t,n)=>{let r=new FileReader;r.onerror=()=>n(Error(`Could not read picture`)),r.onload=()=>t({name:e.name,mimeType:e.type,base64:String(r.result).split(`,`)[1]}),r.readAsDataURL(e)})));b(t=>({...t,images:[...t.images||[],...e]})),R(``)}catch(e){R(e instanceof Error?e.message:`Could not read picture`)}finally{A.current=!1,M(!1)}}},Y=y.replyAll?w?.allRecipients:w?.recipients,X=N||F||j,Z=s?`Send test email`:t?f?C.forward:C[y.replyAll?`replyAll`:`reply`]:`New message`,Q=t&&a?`${f?`Fwd`:`Re`}: ${a.replace(f?/^(fwd?|fw):\s*/i:/^re:\s*/i,``)}`:``;return(0,l.jsxs)(`section`,{onPasteCapture:e=>{if(!(H||U))return;let t=Array.from(e.clipboardData.files);t.some(e=>e.type.startsWith(`image/`))&&(e.preventDefault(),e.stopPropagation(),J(t))},className:`max-h-[70dvh] overflow-y-auto rounded-md border bg-card p-3 space-y-3`,"aria-label":t?`${Z} to message`:`New message`,children:[(0,l.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,l.jsx)(`strong`,{className:`text-sm`,children:Z}),(0,l.jsx)(r,{size:`sm`,variant:`ghost`,onClick:u,children:`Close`})]}),(0,l.jsxs)(`label`,{className:`block text-xs`,children:[`Send from`,(0,l.jsxs)(`select`,{"aria-label":`Sending account`,className:`w-full rounded border bg-background p-2`,value:V?`${V.driver}:${V.address}`:``,disabled:X||!!t||!!o,onChange:e=>{let t=E.find(t=>`${t.driver}:${t.address}`===e.target.value);t&&K({driver:t.driver,address:t.address,to:[],cc:[],bcc:[],subject:void 0,target:void 0,images:void 0,replyAll:!1})},children:[(0,l.jsx)(`option`,{value:``,children:`Select an enabled sending account`}),E.map(e=>(0,l.jsxs)(`option`,{value:`${e.driver}:${e.address}`,children:[e.driver,` · `,e.from||e.address]},`${e.driver}:${e.address}`))]})]}),s&&(0,l.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Uses the saved SMTP settings. Enter a recipient you control, then click Send. This sends a real email; provider acceptance does not guarantee inbox delivery.`}),!E.length&&(0,l.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Enable sending in the account’s workspace settings. Your draft stays on this device.`}),H?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`label`,{className:`block text-xs`,children:[`To `,t&&!f?`(leave blank to reply to the sender)`:``,(0,l.jsx)(i,{"aria-label":`To`,disabled:X,value:y.to?.join(`, `)||``,onChange:e=>K({to:[e.target.value]})})]}),t&&!f&&!y.to?.some(e=>e.trim())&&Y&&(0,l.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Reply to: `,Y.to.join(`, `),Y.cc.length?` · Cc: ${Y.cc.join(`, `)}`:``]}),[`cc`,`bcc`].map(e=>(0,l.jsxs)(`label`,{className:`block text-xs`,children:[e===`cc`?`Cc`:`Bcc`,(0,l.jsx)(i,{"aria-label":e===`cc`?`Cc`:`Bcc`,disabled:X,value:y[e]?.join(`, `)||``,onChange:t=>K({[e]:[t.target.value]})})]},e)),(0,l.jsxs)(`label`,{className:`block text-xs`,children:[`Subject`,(0,l.jsx)(i,{"aria-label":`Subject`,disabled:X,value:y.subject||``,placeholder:Q,onChange:e=>K({subject:e.target.value||void 0})})]}),t&&!f&&(0,l.jsxs)(`div`,{className:`flex flex-wrap gap-4 text-xs`,children:[(0,l.jsxs)(`label`,{className:`flex gap-2`,children:[(0,l.jsx)(`input`,{type:`checkbox`,disabled:X,checked:y.replyAll||!1,onChange:e=>{let t=e.target.checked?w?.allRecipients:w?.recipients;K({replyAll:e.target.checked,...t?{to:t.to,cc:t.cc}:{}})}}),`Reply all`]}),(0,l.jsxs)(`label`,{className:`flex gap-2`,children:[(0,l.jsx)(`input`,{type:`checkbox`,disabled:X,checked:y.quote||!1,onChange:e=>K({quote:e.target.checked})}),`Quote original message`]})]}),f&&(0,l.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`The original message and its attachments are included below your note.`}),(0,l.jsx)(c,{format:`html`,editable:!X,value:y.html||``,placeholder:f?`Add a note (optional)…`:`Write a message…`,onChange:(e,t)=>K({html:e,text:t.slice(0,32e3)})})]}):(0,l.jsxs)(l.Fragment,{children:[!t&&(0,l.jsxs)(`label`,{className:`block text-xs`,children:[`Conversation (configured channel name or ID)`,(0,l.jsx)(i,{"aria-label":`Conversation`,disabled:X,value:y.target||``,onChange:e=>K({target:e.target.value})})]}),U?(0,l.jsx)(c,{format:`markdown`,editable:!X,value:y.text,placeholder:`Write a message…`,onChange:e=>K({text:e.slice(0,32e3)})}):(0,l.jsx)(`textarea`,{"aria-label":`Message text`,className:`w-full rounded border bg-background p-2 text-sm`,rows:5,maxLength:32e3,disabled:X,value:y.text,onChange:e=>K({text:e.target.value}),placeholder:`Write a message…`})]}),(H||U)&&(0,l.jsxs)(`div`,{className:`space-y-2`,children:[(0,l.jsxs)(`label`,{className:`block text-xs`,children:[`Paste a picture into the reply, or attach one`,(0,l.jsx)(`input`,{"aria-label":`Attach pictures`,className:`block`,type:`file`,accept:`image/png,image/jpeg,image/webp,image/gif`,multiple:!U,disabled:X,onChange:e=>{J(Array.from(e.target.files||[])),e.target.value=``}})]}),y.images?.map((e,t)=>(0,l.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,l.jsx)(`img`,{className:`h-20 w-20 rounded object-contain`,src:`data:${e.mimeType};base64,${e.base64}`,alt:e.name}),(0,l.jsx)(`span`,{className:`text-xs`,children:e.name}),(0,l.jsx)(r,{size:`sm`,variant:`ghost`,disabled:X,onClick:()=>K({images:y.images?.filter((e,n)=>n!==t)}),children:`Remove picture`})]},t)),U&&(0,l.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Bold, italic, strikethrough and code are supported. Your reply becomes the picture caption.`})]}),L&&(0,l.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:L}),z&&(0,l.jsxs)(`p`,{role:`status`,className:`text-sm`,children:[z.status===`accepted`?`Accepted by the provider.`:z.message,` `,z.warnings?.join(` `),` `,z.rejected?.length?`Not accepted for: ${z.rejected.join(`, `)}`:``]}),z?.status!==`accepted`&&(0,l.jsx)(r,{size:`sm`,disabled:N||j||!F&&(!V||!G&&!W&&!(H&&f)||f&&!y.to?.some(e=>e.trim()))||!O,onClick:()=>void q(),children:N?`Sending…`:F?`Check send status`:`Send`}),(0,l.jsx)(r,{size:`sm`,variant:`ghost`,disabled:N,onClick:()=>{window.confirm(F?`This message may already have been sent. Discard this draft only after checking the conversation.`:`Discard this draft?`)&&(b({...v(),driver:y.driver,address:y.address}),I(!1),B(null),R(``))},children:`Discard draft`}),F&&z?.status!==`accepted`&&(0,l.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Do not start another send until you have checked the conversation. The same request will not be delivered twice by Canvas.`})]})}function T(e){let t=(0,d.useRef)(null),n=(0,d.useRef)(e.onClose);return(0,d.useEffect)(()=>{n.current=e.onClose}),(0,d.useEffect)(()=>{let e=t.current;if(!e)return;let n=document.activeElement;return e.showModal(),()=>{e.close(),n?.focus()}},[]),(0,l.jsx)(`dialog`,{ref:t,"aria-label":e.replyToDocumentId?`${e.mode===`forward`?`Forward`:e.mode===`replyAll`?`Reply all`:`Reply`} message`:`Send test email`,className:`m-auto w-[calc(100%-2rem)] max-w-3xl max-h-[90dvh] overflow-y-auto rounded-(--panel-radius) border bg-card p-0 text-foreground shadow-elevation-4 backdrop:bg-black/40`,onKeyDown:e=>e.stopPropagation(),onCancel:e=>{e.preventDefault(),e.stopPropagation(),n.current()},children:(0,l.jsx)(w,{...e})})}export{g as a,p as i,w as n,v as o,y as r,u as s,T as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{
|
|
1
|
+
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{Nt as r}from"./workspace-46EFyEKZ.js";var i=e(n(),1),a=t(),o=[`Inbox sweep`,`Canvas edge notes`,`Release 2.7`];function s(){let[e,t]=(0,i.useState)(`none`),[n,s]=(0,i.useState)(null);(0,i.useEffect)(()=>{e===`workspaces`&&n===null&&r().then(s).catch(()=>s([]))},[e,n]);let c=e=>t(t=>t===e?`none`:e);return(0,a.jsxs)(`div`,{className:`next-shell`,children:[(0,a.jsx)(`div`,{className:`next-wallpaper`,"aria-hidden":!0,children:(0,a.jsx)(`i`,{})}),(0,a.jsxs)(`div`,{className:`relative flex h-full flex-col items-center justify-center gap-3 select-none`,children:[(0,a.jsx)(`p`,{className:`text-2xl font-light tracking-wide text-white/80`,children:`Canvas`}),(0,a.jsx)(`p`,{className:`text-sm text-white/40`,children:`say something, or tap the orb. Swipe up for canvases (soon)`})]}),e===`tasks`&&(0,a.jsxs)(`div`,{className:`next-glass absolute bottom-24 left-6 w-64 rounded-2xl p-3`,children:[(0,a.jsx)(`p`,{className:`px-2 pb-2 text-[11px] uppercase tracking-widest text-white/40`,children:`Pinned`}),(0,a.jsx)(`div`,{className:`flex flex-col gap-1`,children:o.map(e=>(0,a.jsx)(`button`,{type:`button`,className:`rounded-xl px-3 py-2 text-left text-sm text-white/85 transition-colors hover:bg-white/10`,children:e},e))})]}),e===`workspaces`&&(0,a.jsxs)(`div`,{className:`next-glass absolute bottom-24 right-6 w-72 rounded-2xl p-3`,children:[(0,a.jsx)(`p`,{className:`px-2 pb-2 text-[11px] uppercase tracking-widest text-white/40`,children:`Workspaces`}),(0,a.jsxs)(`div`,{className:`flex max-h-80 flex-col gap-1 overflow-y-auto`,children:[n===null&&(0,a.jsx)(`p`,{className:`px-3 py-2 text-sm text-white/50`,children:`Loading…`}),n?.map(e=>(0,a.jsxs)(`button`,{type:`button`,className:`flex items-center gap-2.5 rounded-xl px-3 py-2 text-left text-sm text-white/85 transition-colors hover:bg-white/10`,children:[(0,a.jsx)(`span`,{className:`h-2.5 w-2.5 shrink-0 rounded-full`,style:{backgroundColor:e.color||`rgb(255 255 255 / 0.35)`}}),(0,a.jsx)(`span`,{className:`truncate`,children:e.label||e.name})]},e.id)),n?.length===0&&(0,a.jsx)(`p`,{className:`px-3 py-2 text-sm text-white/50`,children:`No workspaces`})]})]}),(0,a.jsxs)(`div`,{className:`absolute bottom-6 right-6 flex items-center gap-3`,children:[e!==`none`&&(0,a.jsx)(`button`,{type:`button`,onClick:()=>c(e===`tasks`?`workspaces`:`tasks`),className:`next-glass rounded-full px-4 py-2 text-xs text-white/70`,children:e===`tasks`?`workspaces`:`pinned`}),(0,a.jsx)(`button`,{type:`button`,onClick:()=>c(`tasks`),"aria-label":`Toolbox`,className:`next-orb flex h-14 w-14 items-center justify-center rounded-full`,children:(0,a.jsx)(`span`,{className:`h-3 w-3 rounded-full bg-white/85`})})]})]})}export{s as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{L as r,
|
|
1
|
+
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{L as r,Pt as i,ci as a,mi as o,pn as s,yt as c}from"./ui-76Hw0NU_.js";import{t as l}from"./utils-2pl1SbIp.js";import{Bn as u}from"./workspace-46EFyEKZ.js";import{t as d}from"./useAddTarget-D4ra50Am.js";import{t as f}from"./note-save-status-DPz4VzL6.js";import{t as p}from"./useEditNoteFields-CKYMBf8V.js";import{n as m}from"./use-applet-target-DmIdCxa_.js";import{k as h}from"./index-DGCnvWMM.js";import{n as g,r as _,t as v}from"./shared-C-uHNNY8.js";import{n as y,r as b}from"./use-applet-docs-DBshA7yq.js";var x=e(n(),1),S=t();function C({doc:e,updateWorkspace:t,registerEl:n,registerBody:r,highlighted:i,onLinkTo:a,onDelete:o}){let s=p(e,t||``,!!t),{title:c,content:u,setTitle:d,setContent:m}=s,h=()=>{s.save().catch(()=>{})};return(0,S.jsxs)(`div`,{ref:t=>n(e.id,t),className:l(`group border-t border-border/60 px-4 py-3 transition-colors`,i&&`bg-primary/5`),children:[(0,S.jsxs)(`div`,{className:`mb-1 flex items-baseline justify-between gap-2`,children:[(0,S.jsxs)(`span`,{className:`text-[10px] uppercase tracking-wide text-muted-foreground/70`,children:[y(e.createdAt),` · #`,e.id]}),(0,S.jsxs)(`div`,{className:`flex items-center gap-1 text-[10px] text-muted-foreground/70`,children:[(0,S.jsx)(f,{...s,onRetry:s.save}),(0,S.jsx)(g,{onLinkTo:a,onDelete:o})]})]}),(0,S.jsx)(`input`,{value:c,onChange:e=>d(e.target.value),onBlur:h,placeholder:`Untitled`,spellCheck:!1,className:`mb-1 w-full border-0 bg-transparent p-0 text-sm font-semibold text-foreground outline-none placeholder:text-muted-foreground/50`}),(0,S.jsx)(v,{value:u,onChange:m,onBlur:h,innerRef:t=>r(e.id,t)})]})}function w({target:e,onCreated:t,onCancel:n}){let i=h(e,void 0,`applet`),{title:a,content:o,setTitle:s,setContent:c,saving:l}=i,[u,d]=(0,x.useState)(null),p=async()=>{try{await i.save(e),i.finish(),t()}catch(e){d(e instanceof Error?e.message:`Failed to save note`)}};return(0,S.jsxs)(`div`,{className:`border-t border-border/60 bg-muted/30 px-4 py-3`,children:[(0,S.jsxs)(`div`,{className:`mb-1 flex items-baseline justify-between`,children:[(0,S.jsx)(`span`,{className:`text-[10px] uppercase tracking-wide text-muted-foreground/70`,children:`New note`}),(0,S.jsx)(`button`,{type:`button`,onClick:n,className:`text-muted-foreground hover:text-foreground`,"aria-label":`Close note`,children:(0,S.jsx)(r,{className:`h-3 w-3`})})]}),(0,S.jsx)(`input`,{value:a,onChange:e=>s(e.target.value),placeholder:`Untitled`,autoFocus:!0,spellCheck:!1,className:`mb-1 w-full border-0 bg-transparent p-0 text-sm font-semibold text-foreground outline-none placeholder:text-muted-foreground/50`}),(0,S.jsx)(v,{value:o,onChange:c,placeholder:`Write your note…`}),(0,S.jsx)(f,{...i,onRetry:i.retry}),u&&(0,S.jsx)(`p`,{className:`mt-1 text-xs text-destructive`,children:u}),(0,S.jsx)(`div`,{className:`mt-2 flex justify-end`,children:(0,S.jsx)(`button`,{type:`button`,onClick:p,disabled:!o.trim()||l,className:`rounded-md bg-primary px-2.5 py-1 text-xs text-primary-foreground disabled:opacity-50`,children:l?`Saving…`:`Done`})})]})}function T({autoAdd:e=!1}){let t=m(),{docs:n,loading:r,error:l,scope:f,reload:p,removeDoc:h}=b(t,u),[g,v]=(0,x.useState)(``),[y,T]=(0,x.useState)(0),[E,D]=(0,x.useState)(`desc`),[O,k]=(0,x.useState)(e),[A,j]=(0,x.useState)(null),M=(0,x.useRef)(new Map),N=(0,x.useRef)(new Map),P=(0,x.useCallback)((e,t)=>{t?M.current.set(e,t):M.current.delete(e)},[]),F=(0,x.useCallback)((e,t)=>{t?N.current.set(e,t):N.current.delete(e)},[]),I=(0,x.useCallback)(async e=>{let t=e.data?.title?`"${e.data.title}"`:`#${e.id}`;if(window.confirm(`Delete note ${t}?\n\nIt is removed from this path and moves to the workspace trash if nothing else links it.`))try{await h(e.id)}catch{}},[h]),L=(0,x.useMemo)(()=>{let e=[...n];return e.sort((e,t)=>{let n=new Date(e.createdAt).getTime()-new Date(t.createdAt).getTime();return E===`asc`?n:-n}),e},[n,E]),R=(0,x.useMemo)(()=>{let e=g.trim().toLowerCase();if(!e)return[];let t=[];for(let n of L){let r=String(n.data?.content??``),i=String(n.data?.title??``),a=r.toLowerCase().indexOf(e);a>=0?t.push({docId:n.id,offset:a}):i.toLowerCase().includes(e)&&t.push({docId:n.id,offset:-1})}return t},[g,L]),z=R.length?R[Math.min(y,R.length-1)]:null;(0,x.useEffect)(()=>{z&&M.current.get(z.docId)?.scrollIntoView({block:`center`,behavior:`smooth`})},[z]);let B=(0,x.useCallback)(e=>{if(!R.length)return;let t=e?(y+1)%R.length:y;e&&T(t);let n=R[t],r=N.current.get(n.docId);r&&n.offset>=0&&(r.focus(),r.setSelectionRange(n.offset,n.offset+g.trim().length)),M.current.get(n.docId)?.scrollIntoView({block:`center`,behavior:`smooth`})},[R,y,g]);return t?(0,S.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,S.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-border px-3 py-2`,children:[(0,S.jsxs)(`div`,{className:`relative flex-1`,children:[(0,S.jsx)(c,{className:`pointer-events-none absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground`}),(0,S.jsx)(`input`,{value:g,onChange:e=>{v(e.target.value),T(0)},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),B(!0))},placeholder:`Search notes…`,spellCheck:!1,className:`w-full rounded-md border border-input bg-transparent py-1 pl-7 pr-14 text-xs outline-none placeholder:text-muted-foreground focus-visible:ring-1 focus-visible:ring-ring`}),g.trim()&&(0,S.jsx)(`span`,{className:`absolute right-2 top-1/2 -translate-y-1/2 text-[10px] tabular-nums text-muted-foreground`,children:R.length?`${Math.min(y+1,R.length)}/${R.length}`:`0/0`})]}),(0,S.jsx)(`button`,{type:`button`,onClick:()=>D(e=>e===`desc`?`asc`:`desc`),className:`rounded-md border border-border p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,title:E===`desc`?`Newest first (click for oldest first)`:`Oldest first (click for newest first)`,"aria-label":`Toggle sort order`,children:E===`desc`?(0,S.jsx)(o,{className:`h-3.5 w-3.5`}):(0,S.jsx)(a,{className:`h-3.5 w-3.5`})}),(0,S.jsxs)(`button`,{type:`button`,onClick:()=>k(!0),className:`flex items-center gap-1 rounded-md bg-primary px-2 py-1.5 text-xs text-primary-foreground`,title:`Add a note`,children:[(0,S.jsx)(i,{className:`h-3.5 w-3.5`}),`Note`]})]}),(0,S.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:[O&&(0,S.jsx)(w,{target:t,onCreated:()=>{k(!1),p()},onCancel:()=>k(!1)},JSON.stringify(t)),r&&!n.length&&(0,S.jsx)(`div`,{className:`flex items-center justify-center py-10`,children:(0,S.jsx)(s,{className:`h-5 w-5 animate-spin text-muted-foreground`})}),l&&(0,S.jsx)(`p`,{className:`px-4 py-6 text-center text-sm text-destructive`,children:l}),!r&&!l&&!L.length&&!O&&(0,S.jsx)(`p`,{className:`px-4 py-10 text-center text-sm text-muted-foreground`,children:`No notes here yet - add the first one.`}),L.map(e=>(0,S.jsx)(C,{doc:e,updateWorkspace:f?.workspaceName??null,registerEl:P,registerBody:F,highlighted:z?.docId===e.id,onLinkTo:()=>j(e.id),onDelete:()=>I(e)},e.id))]}),A!==null&&(0,S.jsx)(_,{documentId:A,workspaceName:f?.workspaceName,onClose:()=>j(null)})]}):(0,S.jsx)(`div`,{className:`flex h-full items-center justify-center p-6 text-center text-sm text-muted-foreground`,children:d(t)})}export{T as NotesApplet};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/pdf-Ciz5_WNq.js","assets/preload-helper-Czpn1I53.js","assets/TextDocumentEditor-rgHsbLCL.js","assets/rolldown-runtime-C0FnF6B9.js","assets/code-editor-BOIngd5F.js","assets/ui-76Hw0NU_.js","assets/react-BHzhHVTZ.js","assets/button-Bum-POPT.js","assets/utils-BxVxyehK.js","assets/utils-2pl1SbIp.js","assets/workspace-46EFyEKZ.js","assets/input-BOtCd4HP.js","assets/api-CA6WiiYM.js","assets/alert-dialog-CShuAcnP.js","assets/text-documents-CFW8MWES.js","assets/public-share-D2S8DEsv.js","assets/blobs-WiXP9QRi.js","assets/useToastHelpers-CRrpIIdY.js","assets/use-toast-BlLDqSUO.js","assets/note-save-status-DPz4VzL6.js","assets/useEditNoteFields-CKYMBf8V.js","assets/tags-YamdPoBK.js","assets/DocumentBodyEditor-DRFQgBNB.js","assets/lazy-editor-Bdm5JEXv.js","assets/EditorOverlay-DpQKmxkR.js","assets/LocationTab-DAtqAQ3l.js","assets/map-BxCwdK0d.js","assets/map-BcsP_QXj.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{_t as r,yt as i}from"./react-BHzhHVTZ.js";import{t as a}from"./preload-helper-Czpn1I53.js";import{Bn as o,Bt as s,Dr as c,Dt as l,Et as u,Gn as d,Ht as f,J as p,Jr as m,L as h,Lt as g,Mn as _,Or as v,Pn as y,Pt as b,Qr as x,Tr as S,Un as C,Wr as w,X as T,Xr as E,Yr as D,_n as O,br as k,cn as A,ct as j,en as M,fi as ee,fr as N,jt as P,kn as te,lr as F,mr as I,mt as ne,nr as L,nt as R,on as z,or as B,pn as V,qn as re,rr as H,sn as ie,ui as ae,vr as U,yt as W,zt as oe}from"./ui-76Hw0NU_.js";import{t as G}from"./utils-2pl1SbIp.js";import{t as K}from"./button-Bum-POPT.js";import{t as se}from"./input-BOtCd4HP.js";import{t as q}from"./label-DJc8-3CQ.js";import{l as J}from"./api-CA6WiiYM.js";import{_ as ce,g as le,o as ue,t as de}from"./LinkToCard-VXpoeMDH.js";import{An as fe,Bn as pe,D as me,Gn as he,Hn as ge,J as _e,M as ve,Mn as Y,N as ye,Pn as be,Rn as xe,Un as Se,Wn as Ce,Wt as we,Y as Te,g as Ee,kt as De,l as Oe,o as ke,pn as Ae,q as je,r as Me,s as Ne,tt as Pe,vn as Fe,wn as Ie,yt as Le}from"./workspace-46EFyEKZ.js";import{r as Re,t as ze}from"./use-mobile-Db-vWu9Y.js";import{a as Be,c as Ve,i as He,n as Ue,o as We,r as Ge,s as Ke,t as qe}from"./IdentityFields-CEDxU-Hd.js";import{i as Je,r as Ye}from"./public-share-D2S8DEsv.js";import{a as Xe,i as Ze,n as Qe,o as $e,r as et,s as tt,t as nt}from"./text-documents-CFW8MWES.js";import{t as rt}from"./useDocumentThumbnail-Bs2Ju0eb.js";import{t as it}from"./markdown-view-BBBZtNSR.js";import{n as at,t as ot}from"./tags-YamdPoBK.js";import{n as st,t as ct}from"./relation-events-CKio19hE.js";import{a as lt,i as ut,r as dt,s as ft}from"./date-time-picker-Bzu8H_Oa.js";import{t as pt}from"./sanitize-DrVcFY1Q.js";import{t as mt}from"./useEscapeClose-DR_xKT_k.js";import{t as X}from"./useToastHelpers-CRrpIIdY.js";import"./layer-style-Byl5LNFR.js";import{t as ht}from"./DocumentIcon-ByDAILhm.js";import{r as gt,s as _t,t as vt}from"./MessageComposerDialog-BKGlI7jO.js";import{n as yt}from"./LinkToSidePanel-eCy3nW4R.js";import{t as bt}from"./note-save-status-DPz4VzL6.js";import{t as xt}from"./useEditNoteFields-CKYMBf8V.js";import{t as St}from"./DocumentBodyEditor-DRFQgBNB.js";import{n as Ct}from"./use-document-modal-PG8bQyIB.js";import{t as wt}from"./sketch-lazy-BOFTGGTA.js";import{r as Tt}from"./geo-CZfs0E-x.js";var Z=e(n(),1);function Et(e,t){let n=/(^|\s)(!?)@([a-z-]*)$/i.exec(e);if(!n)return null;let r=n[3].toLowerCase();return{before:e.slice(0,n.index)+n[1]+n[2],predicates:t.filter(e=>e.startsWith(r))}}var Q=t();function Dt({workspaceId:e,inputRef:t,onChange:n}){let[r,i]=(0,Z.useState)(``),[a,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)(0),l=le(e),u=Et(r,l.predicates),d=!!e&&a&&u!==null,f=u?.predicates??[],p=(0,Z.useId)(),m=Math.min(s,Math.max(0,f.length-1));(0,Z.useEffect)(()=>{d&&document.getElementById(`${p}-${m}`)?.scrollIntoView({block:`nearest`})},[p,m,d,f.length]);let h=e=>{let r=t.current;if(!r||!u)return;let a=`${u.before}@${e}: `;r.value=a,n?.(a),i(a),o(!1),r.focus()};return(0,Z.useEffect)(()=>{let e=t.current;if(!e)return;let n=()=>{i(e.value),c(0),o(!0)},r=()=>o(!1),a=e=>{!d||e.isComposing||(e.key===`Escape`?(e.preventDefault(),e.stopPropagation(),o(!1)):f.length&&[`ArrowDown`,`ArrowUp`,`Enter`,`Tab`].includes(e.key)&&(e.preventDefault(),e.stopPropagation(),e.key===`ArrowDown`?c((m+1)%f.length):e.key===`ArrowUp`?c((m+f.length-1)%f.length):h(f[m])))};return e.addEventListener(`input`,n),e.addEventListener(`focus`,n),e.addEventListener(`blur`,r),e.addEventListener(`keydown`,a),e.setAttribute(`role`,`combobox`),e.setAttribute(`aria-autocomplete`,`list`),e.setAttribute(`aria-expanded`,String(d)),d?e.setAttribute(`aria-controls`,p):e.removeAttribute(`aria-controls`),d&&f.length?e.setAttribute(`aria-activedescendant`,`${p}-${m}`):e.removeAttribute(`aria-activedescendant`),()=>{e.removeEventListener(`input`,n),e.removeEventListener(`focus`,n),e.removeEventListener(`blur`,r),e.removeEventListener(`keydown`,a);for(let t of[`role`,`aria-autocomplete`,`aria-expanded`,`aria-controls`,`aria-activedescendant`])e.removeAttribute(t)}}),d?(0,Q.jsxs)(`div`,{className:`absolute left-0 right-0 top-full z-50 mt-1 max-h-64 overflow-y-auto rounded-md border bg-popover p-1 text-popover-foreground shadow-lg`,children:[(0,Q.jsx)(`div`,{id:p,role:`listbox`,"aria-label":`Relation predicates`,children:f.map((e,t)=>(0,Q.jsxs)(`button`,{id:`${p}-${t}`,type:`button`,role:`option`,"aria-selected":t===m,className:`block w-full rounded px-3 py-2 text-left text-sm font-mono ${t===m?`bg-accent text-accent-foreground`:`hover:bg-accent`}`,onMouseDown:e=>e.preventDefault(),onClick:()=>h(e),children:[`@`,e,`:`]},e))}),!f.length&&(0,Q.jsx)(`p`,{role:`status`,className:`px-3 py-2 text-sm text-muted-foreground`,children:l.loading?`Loading relations…`:l.error?`Unable to load relation predicates.`:`No matching predicates.`})]}):null}var Ot=1,kt=8,At=320,jt=28,Mt=2.5,Nt={scale:1,x:0,y:0};function Pt({src:e,alt:t,className:n=``,onZoomChange:r}){let i=(0,Z.useRef)(null),a=(0,Z.useRef)(null),[o,s]=(0,Z.useState)(Nt),c=(0,Z.useRef)(new Map),l=(0,Z.useRef)(null),u=(0,Z.useRef)(null),d=(0,Z.useRef)(!1),f=(0,Z.useRef)(null),[p,m]=(0,Z.useState)(!1),[h,g]=(0,Z.useState)(e);h!==e&&(g(e),s(Nt)),(0,Z.useEffect)(()=>{r?.(o.scale>1.001)},[o.scale,r]);let _=(0,Z.useCallback)(e=>{let t=i.current,n=a.current;if(!t||!n)return e;let r=Math.min(kt,Math.max(Ot,e.scale)),o=Math.max(0,(n.offsetWidth*r-t.clientWidth)/2),s=Math.max(0,(n.offsetHeight*r-t.clientHeight)/2);return{scale:r,x:Math.min(o,Math.max(-o,e.x)),y:Math.min(s,Math.max(-s,e.y))}},[]),v=(0,Z.useCallback)((e,t,n)=>{let r=i.current;if(!r)return;let a=r.getBoundingClientRect(),o=t-a.left-a.width/2,c=n-a.top-a.height/2;s(t=>{let n=e/t.scale;return _({scale:e,x:o-(o-t.x)*n,y:c-(c-t.y)*n})})},[_]),y=(0,Z.useCallback)(()=>{let e=i.current,t=a.current;if(!e||!t||!t.offsetWidth||!t.offsetHeight)return Mt;let n=Math.max(e.clientWidth/t.offsetWidth,e.clientHeight/t.offsetHeight),r=Math.max(t.naturalWidth/t.offsetWidth,t.naturalHeight/t.offsetHeight)||kt;return Math.min(kt,Math.max(Mt,Math.min(Math.max(n,Mt),r)))},[]),b=(0,Z.useCallback)((e,t)=>{o.scale>1.001?s(Nt):v(y(),e,t)},[o.scale,v,y]),x=e=>{if(c.current.set(e.pointerId,{x:e.clientX,y:e.clientY}),d.current=!1,c.current.size===2){let[e,t]=[...c.current.values()];l.current={dist:Math.hypot(e.x-t.x,e.y-t.y),scale:o.scale,cx:(e.x+t.x)/2,cy:(e.y+t.y)/2}}e.currentTarget.setPointerCapture(e.pointerId)},S=e=>{let t=c.current.get(e.pointerId);if(!t)return;if(c.current.set(e.pointerId,{x:e.clientX,y:e.clientY}),c.current.size>=2&&l.current){let[e,t]=[...c.current.values()],n=Math.hypot(e.x-t.x,e.y-t.y);l.current.dist>0&&(d.current=!0,m(!0),v(l.current.scale*(n/l.current.dist),l.current.cx,l.current.cy));return}if(o.scale<=1.001)return;let n=e.clientX-t.x,r=e.clientY-t.y;(Math.abs(n)>1||Math.abs(r)>1)&&(d.current=!0,m(!0)),s(e=>_({...e,x:e.x+n,y:e.y+r}))},C=e=>{if(c.current.delete(e.pointerId),c.current.size<2&&(l.current=null),c.current.size===0&&m(!1),d.current){u.current=null;return}let t=e.timeStamp,n=u.current;if(n&&t-n.t<At&&Math.hypot(e.clientX-n.x,e.clientY-n.y)<jt){u.current=null,f.current=t,b(e.clientX,e.clientY);return}u.current={t,x:e.clientX,y:e.clientY}},w=e=>{e.preventDefault();let t=o.scale*(e.deltaY<0?1.15:1/1.15);t<=Ot?s(Nt):v(Math.min(kt,t),e.clientX,e.clientY)},T=o.scale>1.001;return(0,Q.jsx)(`div`,{ref:i,className:`relative flex h-full w-full items-center justify-center overflow-hidden`,style:{touchAction:`none`,cursor:T?`grab`:`zoom-in`},onPointerDown:x,onPointerMove:S,onPointerUp:C,onPointerCancel:e=>{c.current.delete(e.pointerId),l.current=null,u.current=null,d.current=!0,c.current.size===0&&m(!1)},onWheel:w,onDoubleClick:e=>{e.preventDefault(),e.stopPropagation(),!(f.current!==null&&e.timeStamp-f.current<At)&&b(e.clientX,e.clientY)},children:(0,Q.jsx)(`img`,{ref:a,src:e,alt:t,draggable:!1,className:n,style:{transform:`translate3d(${o.x}px, ${o.y}px, 0) scale(${o.scale})`,transformOrigin:`center center`,transition:p?`none`:`transform var(--duration-normal) ease-out`,willChange:`transform`}})})}function Ft(){return!/android|iphone|ipad|mobile/i.test(navigator.userAgent)&&navigator.pdfViewerEnabled!==!1}var It=40,Lt=1600;function Rt({blob:e,filename:t}){let n=(0,Z.useRef)(null),[r,i]=(0,Z.useState)({error:null,pages:0,truncated:!1});return(0,Z.useEffect)(()=>{let r=n.current;if(!r)return;let o=!1,s=null;return(async()=>{let n=await a(()=>import(`./pdf-Ciz5_WNq.js`),__vite__mapDeps([0,1])),c=(await a(async()=>{let{default:e}=await import(`./pdf.worker.min-C8Ts8bNu.js`);return{default:e}},[])).default;n.GlobalWorkerOptions.workerSrc=c;let l=await e.arrayBuffer();if(o)return;let u=n.getDocument({data:l});s=()=>{u.destroy()};let d=await u.promise;if(o)return;let f=Math.min(d.numPages,It),p=r.clientWidth||600,m=window.devicePixelRatio||1;for(let e=1;e<=f;e++){if(o)return;let n=await d.getPage(e),a=n.getViewport({scale:1}),s=Math.min(p*m,Lt*m)/a.width,c=n.getViewport({scale:s}),l=document.createElement(`canvas`);if(l.width=c.width,l.height=c.height,l.style.width=`100%`,l.style.height=`auto`,l.className=`rounded border bg-white`,l.setAttribute(`aria-label`,`${t}, page ${e}`),await n.render({canvas:l,viewport:c}).promise,n.cleanup(),o)return;r.appendChild(l),i({error:null,pages:e,truncated:d.numPages>It})}})().catch(e=>{o||i(t=>({...t,error:e instanceof Error?e.message:String(e)}))}),()=>{o=!0,s?.(),r.replaceChildren()}},[e,t]),(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[r.error&&(0,Q.jsxs)(`p`,{className:`text-sm text-destructive`,children:[`Could not render PDF: `,r.error]}),!r.error&&r.pages===0&&(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Rendering PDF…`}),(0,Q.jsx)(`div`,{ref:n,className:`space-y-2`}),r.truncated&&(0,Q.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Showing the first `,It,` pages. Download the file for the full document.`]})]})}function zt({blob:e,blobUrl:t,filename:n,className:r=``}){let i=(0,Z.useMemo)(()=>e&&e.type!==`application/pdf`?URL.createObjectURL(e.slice(0,e.size,`application/pdf`)):null,[e]);return(0,Z.useEffect)(()=>()=>{i&&URL.revokeObjectURL(i)},[i]),Ft()||!e?(0,Q.jsx)(`div`,{className:`min-h-[300px] ${r}`,children:(0,Q.jsx)(`iframe`,{src:i??t,className:`h-full min-h-[300px] w-full rounded border`,title:n})}):(0,Q.jsx)(`div`,{className:`max-h-viewport-pane overflow-y-auto ${r}`,children:(0,Q.jsx)(Rt,{blob:e,filename:n})})}function Bt({workspaceId:e,document:t}){let{download:n}=Ye(e),[r,i]=(0,Z.useState)(!1),a=Y(t)||`document-${t.id}`;return(0,Q.jsxs)(`button`,{type:`button`,onClick:async()=>{i(!0);try{await n(t.id,a)}finally{i(!1)}},disabled:r,className:`inline-flex items-center gap-1.5 rounded-md border px-2.5 py-1 text-xs text-muted-foreground transition-colors hover:bg-accent hover:text-foreground disabled:opacity-50`,children:[(0,Q.jsx)(U,{className:`h-3.5 w-3.5`}),r?`Preparing…`:`Download`]})}var Vt=1600;function Ht({error:e,loading:t,children:n}){return e?(0,Q.jsx)(`p`,{className:`text-sm text-destructive`,children:e}):t?(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Loading preview...`}):(0,Q.jsx)(Q.Fragment,{children:n})}function Ut({workspaceId:e,document:t,className:n=``}){let r=(0,Z.useContext)(Ve),i=ze(),a=Re(`(pointer: coarse)`),{blobUrl:o,error:s,loading:c}=rt(e,t.id,Vt,{version:t.checksumArray?.[0]??null}),{fetchBlob:l}=Ye(e),u=Y(t)||`document-${t.id}`,[d,f]=(0,Z.useState)(!1);return(0,Q.jsx)(Ht,{error:s,loading:c,children:o&&(0,Q.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col gap-2 ${n}`,children:[i||a?(0,Q.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,Q.jsx)(Pt,{src:o,alt:u,className:`max-h-full max-w-full object-contain`})}):(0,Q.jsx)(`img`,{src:o,alt:u,draggable:!1,onDoubleClick:r?e=>{e.preventDefault(),e.stopPropagation(),r()}:void 0,title:r?`Double-click to maximize or restore`:void 0,className:`min-h-0 w-full flex-1 object-contain ${r?`cursor-zoom-in`:``}`}),(0,Q.jsxs)(`button`,{type:`button`,onClick:async()=>{f(!0);try{let{blob:e}=await l(t.id),n=URL.createObjectURL(e),r=window.document.createElement(`a`);r.href=n,r.download=u,window.document.body.appendChild(r),r.click(),r.remove(),setTimeout(()=>URL.revokeObjectURL(n),3e4)}finally{f(!1)}},disabled:d,className:`inline-flex shrink-0 self-start items-center gap-1.5 rounded-md border px-2.5 py-1 text-xs text-muted-foreground transition-colors hover:bg-accent hover:text-foreground disabled:opacity-50`,children:[(0,Q.jsx)(U,{className:`h-3.5 w-3.5`}),d?`Preparing…`:`Download original`]})]})})}function Wt({workspaceId:e,document:t,className:n=``}){let{src:r,error:i,loading:a}=tt(e,t.id);return(0,Q.jsx)(Ht,{error:i,loading:a,children:r&&(0,Q.jsxs)(`div`,{className:`space-y-2 ${n}`,children:[(0,Q.jsx)(`audio`,{src:r,controls:!0,preload:`metadata`,className:`w-full`}),(0,Q.jsx)(Bt,{workspaceId:e,document:t})]})})}function Gt({workspaceId:e,document:t,className:n=``}){let{src:r,error:i,loading:a}=tt(e,t.id),[o,s]=(0,Z.useState)(!1);return(0,Q.jsx)(Ht,{error:i,loading:a,children:r&&(0,Q.jsxs)(`div`,{className:`space-y-2 ${n}`,children:[(0,Q.jsx)(`video`,{src:r,controls:!0,playsInline:!0,preload:`metadata`,onError:()=>s(!0),className:`max-h-viewport-pane w-full rounded border`}),o&&(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`This video can’t be played inline in your browser. Download it to view.`}),(0,Q.jsx)(Bt,{workspaceId:e,document:t})]})})}function Kt({workspaceId:e,document:t,className:n=``}){let{blobUrl:r,blob:i,error:a,loading:o}=$e(e,t.id,{typeHint:`application/pdf`}),s=Y(t)||`document-${t.id}`;return(0,Q.jsx)(Ht,{error:a,loading:o,children:r&&(0,Q.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col gap-2 ${n}`,children:[(0,Q.jsx)(zt,{blob:i,blobUrl:r,filename:s,className:`min-h-0 flex-1`}),(0,Q.jsx)(`div`,{children:(0,Q.jsx)(Bt,{workspaceId:e,document:t})})]})})}function qt({workspaceId:e,document:t,className:n=``}){let{text:r,error:i,loading:a}=$e(e,t.id,{mode:`text`,version:t.checksumArray?.[0]});return i?(0,Q.jsx)(`p`,{className:`text-sm text-destructive`,children:i}):a||r==null?(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Loading...`}):(0,Q.jsx)(`pre`,{className:`bg-muted p-3 rounded text-xs overflow-auto max-h-viewport-pane whitespace-pre-wrap ${n}`,children:r})}function Jt({workspaceId:e,document:t,className:n=``}){let r=t.schema===pe,{text:i,error:a,loading:o}=$e(e,t.id,{mode:`text`,enabled:!r,version:t.checksumArray?.[0]});return r?(0,Q.jsxs)(`div`,{className:`markdown-note space-y-3 ${n}`,children:[t.data?.title?(0,Q.jsx)(`h3`,{className:`text-lg font-semibold`,children:String(t.data.title)}):null,(0,Q.jsx)(`div`,{className:`markdown-document-frame rounded-md border border-input bg-transparent`,children:(0,Q.jsx)(it,{content:String(t.data?.content??``),className:`markdown-doc px-4 py-3`})})]}):a?(0,Q.jsx)(`p`,{className:`text-sm text-destructive`,children:a}):o||i==null?(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Loading...`}):(0,Q.jsx)(`div`,{className:`markdown-document-frame rounded-md border border-input bg-transparent overflow-auto max-h-viewport-pane ${n}`,children:(0,Q.jsx)(it,{content:i,className:`markdown-doc px-4 py-3`})})}function Yt({document:e,className:t=``}){let n=String(e.data?.url??e.data?.uri??``),r=he(n);return r?(0,Q.jsx)(`div`,{className:`aspect-video w-full ${t}`,children:(0,Q.jsx)(`iframe`,{src:`https://www.youtube-nocookie.com/embed/${encodeURIComponent(r)}`,title:String(e.data?.title??e.data?.label??`YouTube video`),className:`h-full w-full rounded border`,allow:`accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture`,allowFullScreen:!0})}):null}function Xt({document:e,className:t=``}){let n=String(e.data?.url??e.data?.uri??``),[r,i]=(0,Z.useState)({blobUrl:null,blob:null,failed:!1,loading:!0}),[a,o]=(0,Z.useState)(n);n!==a&&(o(n),i({blobUrl:null,blob:null,failed:!1,loading:!0})),(0,Z.useEffect)(()=>{let e=!1,t=null,r=async e=>{if(!e.ok)throw Error(`HTTP ${e.status}`);let t=await e.blob();return new Blob([t],{type:`application/pdf`})},a=()=>{let e=localStorage.getItem(`authToken`);return fetch(`${J}/proxy/pdf?url=${encodeURIComponent(n)}`,{headers:e?{Authorization:`Bearer ${e}`}:{}})};return fetch(n).then(r).catch(()=>a().then(r)).then(n=>{e||(t=URL.createObjectURL(n),i({blobUrl:t,blob:n,failed:!1,loading:!1}))}).catch(()=>{e||i({blobUrl:null,blob:null,failed:!0,loading:!1})}),()=>{e=!0,t&&URL.revokeObjectURL(t)}},[n]);let{blobUrl:s,blob:c,failed:l,loading:u}=r,d=(()=>{try{let e=decodeURIComponent(new URL(n).pathname.split(`/`).filter(Boolean).pop()??``)||`document`;return/\.pdf$/i.test(e)?e:`${e}.pdf`}catch{return`document.pdf`}})();return(0,Q.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col gap-2 ${t}`,children:[(0,Q.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-3`,children:[(0,Q.jsxs)(`a`,{href:n,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1 text-xs text-primary hover:underline`,children:[(0,Q.jsx)(I,{className:`h-3 w-3`}),` `,n]}),c&&(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>{if(!c)return;let e=URL.createObjectURL(c),t=window.document.createElement(`a`);t.href=e,t.download=d,window.document.body.appendChild(t),t.click(),t.remove(),setTimeout(()=>URL.revokeObjectURL(e),3e4)},className:`inline-flex items-center gap-1.5 rounded-md border px-2.5 py-1 text-xs text-muted-foreground transition-colors hover:bg-accent hover:text-foreground`,children:[(0,Q.jsx)(U,{className:`h-3.5 w-3.5`}),` Download`]})]}),u&&(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Loading PDF…`}),l&&(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Inline preview unavailable (direct fetch and server proxy both failed). Use the link above.`}),s&&(0,Q.jsx)(zt,{blob:c,blobUrl:s,filename:d,className:`min-h-[300px] flex-1`})]})}function Zt(e){if(!e)return!1;try{let t=new URL(e);return!!(/\.pdf$/i.test(t.pathname)||t.hostname.endsWith(`arxiv.org`)&&t.pathname.startsWith(`/pdf/`))}catch{return!1}}function Qt(e){try{return new URL(e).hostname.replace(/^www\./,``)}catch{return e}}function $t({document:e,className:t=``}){let n=e.data||{},r=String(n.url??n.uri??``),i=String(n.title??n.label??``)||Qt(r),a=typeof n.favIconUrl==`string`?n.favIconUrl:``,o=n.pinned===!0,s=typeof n.timestamp==`string`?n.timestamp:null,[c,l]=(0,Z.useState)(!1);return(0,Q.jsxs)(`div`,{className:`space-y-3 ${t}`,children:[(0,Q.jsxs)(`a`,{href:r,target:`_blank`,rel:`noopener noreferrer`,className:`group flex items-start gap-3 rounded-lg border bg-card p-3 transition-colors hover:bg-accent/40`,children:[(0,Q.jsx)(`div`,{className:`mt-0.5 flex h-9 w-9 shrink-0 items-center justify-center overflow-hidden rounded bg-muted`,children:a&&!c?(0,Q.jsx)(`img`,{src:a,alt:``,className:`h-5 w-5`,onError:()=>l(!0)}):(0,Q.jsx)(C,{className:`h-4 w-4 text-muted-foreground`})}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Q.jsx)(`span`,{className:`truncate font-medium leading-tight`,children:i}),o&&(0,Q.jsx)(g,{className:`h-3 w-3 shrink-0 fill-warning text-warning`})]}),(0,Q.jsx)(`div`,{className:`mt-0.5 truncate text-xs text-muted-foreground`,children:Qt(r)}),(0,Q.jsx)(`div`,{className:`mt-1 truncate font-mono text-[11px] text-muted-foreground/70`,children:r})]}),(0,Q.jsx)(I,{className:`mt-1 h-4 w-4 shrink-0 text-muted-foreground reveal-on-hover`})]}),s&&(0,Q.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Saved `,new Date(s).toLocaleString()]})]})}function en(e){return e.data||{}}var tn={pending:`bg-muted text-muted-foreground`,"in-progress":`bg-info/15 text-info dark:text-info`,completed:`bg-success/15 text-success dark:text-success`,cancelled:`bg-muted text-muted-foreground line-through`};function nn(e){if(!e.dueDate||e.status===`completed`||e.status===`cancelled`)return!1;let t=new Date(e.dueDate).getTime();return Number.isFinite(t)&&t<Date.now()}function rn(e){if(!e)return``;let t=new Date(e);return Number.isNaN(t.getTime())?``:t.toLocaleString(void 0,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})}async function an(e,t,n){let r=n===`completed`,i={...t.data||{},status:n,completed:r};r?i.completedAt=new Date().toISOString():delete i.completedAt,await Fe(e,{id:t.id,schema:t.schema,schemaVersion:t.schemaVersion,data:i}),window.dispatchEvent(new CustomEvent(`workspace:documents:refresh`))}function on({document:e,workspaceId:t,className:n=``}){let r=en(e),i=Je()!=null,[a,o]=(0,Z.useState)(!1),{replicating:s,label:c}=Ie(e),l=r.status===`completed`,u=r.status??`pending`,d=nn(r);return(0,Q.jsx)(`div`,{className:`space-y-3 ${n}`,children:(0,Q.jsxs)(`div`,{className:`relative flex items-start gap-3 rounded-lg border bg-card p-3 transition-opacity ${s?`opacity-60`:``}`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:async()=>{if(!(i||a)){o(!0);try{await an(t,e,l?`pending`:`completed`)}catch{}finally{o(!1)}}},disabled:i||a||s,"aria-pressed":l,title:l?`Mark not done`:`Mark done`,className:`mt-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded border transition-colors ${l?`border-success bg-success text-success-foreground`:`border-input hover:border-success`} ${i?`cursor-default opacity-70`:``}`,children:a?(0,Q.jsx)(V,{className:`h-3 w-3 animate-spin`}):l&&(0,Q.jsx)(w,{className:`h-3.5 w-3.5`})}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`div`,{className:`font-medium leading-tight ${l?`text-muted-foreground line-through`:``}`,children:r.title||`Todo ${e.id}`}),(0,Q.jsxs)(`div`,{className:`mt-1.5 flex flex-wrap items-center gap-2 text-xs`,children:[(0,Q.jsx)(`span`,{className:`rounded-full px-2 py-0.5 ${tn[u]}`,children:dt[u]}),r.dueDate&&(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 ${d?`font-medium text-destructive`:`text-muted-foreground`}`,children:[(0,Q.jsx)(m,{className:`h-3 w-3`}),rn(r.dueDate),d?` · overdue`:``]}),typeof r.priority==`number`&&(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-muted-foreground`,children:[(0,Q.jsx)(L,{className:`h-3 w-3`}),`P`,r.priority]})]}),r.description&&(0,Q.jsx)(it,{content:String(r.description),className:`mt-2 text-sm text-muted-foreground`}),s&&(0,Q.jsxs)(`div`,{className:`mt-2 inline-flex items-center gap-1.5 text-xs text-muted-foreground`,role:`status`,children:[(0,Q.jsx)(V,{className:`h-3 w-3 animate-spin`}),c]})]})]})})}function sn(e,t){let{fetchBlob:n}=Ye(e),r=Je(),i=t.checksumArray?.[0]||t.updatedAt||``,a=JSON.stringify([e,r,t.id,i]),o=typeof t.data?.body==`string`?t.data.body:null,s=typeof t.data?.bodyHtml==`string`?t.data.bodyHtml:null,c=o!==null||s!==null,[l,u]=(0,Z.useState)(null);return(0,Z.useEffect)(()=>{if(c)return;let e=new AbortController;return n(t.id,{format:`email`,version:i,signal:e.signal}).then(async({blob:t})=>{let n=JSON.parse(await t.text());if(typeof n.body!=`string`||n.bodyHtml!=null&&typeof n.bodyHtml!=`string`)throw Error(`Invalid email content response`);e.signal.aborted||u({key:a,body:n.body,bodyHtml:n.bodyHtml||null,error:null})}).catch(t=>{e.signal.aborted||u({key:a,body:``,bodyHtml:null,error:t instanceof Error?t.message:String(t)})}),()=>e.abort()},[a,c,n,t.id,i]),c?{body:o||``,bodyHtml:s,loading:!1,error:null}:l?.key===a?{...l,loading:!1}:{body:``,bodyHtml:null,loading:!0,error:null}}function cn(e){return e?typeof e==`string`?e:e.name&&e.address?`${e.name} <${e.address}>`:e.address||e.name||``:``}function $(e){return e?(Array.isArray(e)?e:[e]).map(e=>cn(e)).filter(Boolean).join(`, `):``}function ln(e){if(!Number.isFinite(e))return``;let t=Number(e);return t<1024?`${t} B`:t<1048576?`${(t/1024).toFixed(1)} KB`:`${(t/1024/1024).toFixed(1)} MB`}function un(e,t,n){let r=0;pt.addHook(`afterSanitizeAttributes`,e=>{if(e.tagName===`IMG`){let i=e.getAttribute(`src`)||``,a=i.toLowerCase();if(a.startsWith(`cid:`)){let n=i.slice(4).replace(/^<|>$/g,``),r=t.get(n)||t.get(`<${n}>`);r?e.setAttribute(`src`,r):e.removeAttribute(`src`)}else(a.startsWith(`http:`)||a.startsWith(`https:`)||a.startsWith(`//`))&&(r++,n?e.setAttribute(`src`,i.replace(/^http:/i,`https:`).replace(/^\/\//,`https://`)):e.removeAttribute(`src`))}e.tagName===`A`&&(e.setAttribute(`target`,`_blank`),e.setAttribute(`rel`,`noopener noreferrer`))});try{let t=pt.sanitize(e,{FORBID_TAGS:[`script`,`iframe`,`object`,`embed`,`form`,`base`,`link`,`meta`],FORBID_ATTR:[`srcset`]}),i=`<!doctype html><html><head>
|
|
3
|
+
<meta charset="utf-8">
|
|
4
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
5
|
+
<meta http-equiv="Content-Security-Policy" content="${`default-src 'none'; img-src data:${n?` https:`:``}; style-src 'unsafe-inline'`}">
|
|
6
|
+
<style>html{overflow:auto}body{margin:12px;font:14px/1.5 system-ui,sans-serif;color:#1a1a1a;background:#fff}@media(max-width:480px){body{margin:8px}}</style>
|
|
7
|
+
</head><body>${t}</body></html>`;return{url:URL.createObjectURL(new Blob([i],{type:`text/html;charset=utf-8`})),remoteCount:r}}finally{pt.removeHook(`afterSanitizeAttributes`)}}function dn(e){return new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(String(r.result)),r.onerror=()=>n(r.error),r.readAsDataURL(e)})}function fn(e){return(0,Q.jsx)(pn,{...e},`${e.workspaceId}:${e.document.id}`)}function pn({workspaceId:e,document:t,className:n=``}){let{fetchBlob:r,download:i}=Ye(e),a=t.data||{},o=Array.isArray(a.attachments)?a.attachments:[],{body:s,bodyHtml:l,loading:u,error:d}=sn(e,t),[f,p]=(0,Z.useState)(null),[m,h]=(0,Z.useState)(!1),[g,v]=(0,Z.useState)(!1),[b,x]=(0,Z.useState)(0),[S,C]=(0,Z.useState)(null);(0,Z.useEffect)(()=>{if(!l||m)return;let e=!1,n=[],i=o.filter(e=>e.contentId&&e.url);return Promise.all(i.slice(0,20).map(async e=>{try{let{blob:n}=await r(t.id,{url:e.url}),i=await dn(n);return[String(e.contentId).replace(/^<|>$/g,``),i]}catch{return null}})).then(t=>{if(e)return;let r=new Map(t.filter(Boolean)),{url:i,remoteCount:a}=un(l,r,g);n.push(i),p(i),x(a)}).catch(t=>{e||C(String(t instanceof Error?t.message:t))}),()=>{e=!0,n.forEach(e=>URL.revokeObjectURL(e)),p(null)}},[e,t.id,l,m,g]);let w=typeof a.date==`string`?new Date(a.date).toLocaleString():null,T=o.filter(e=>!e.isInline||!e.contentId),E=async e=>{if(e.url)try{await i(t.id,e.filename||`attachment`,{url:e.url})}catch(e){C(e instanceof Error?e.message:String(e))}};return(0,Q.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col gap-3 ${n}`,children:[(0,Q.jsx)(`div`,{className:`shrink-0 rounded-md border bg-muted/30 p-2 text-sm sm:p-3`,children:(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2 sm:gap-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1 basis-64 space-y-1`,children:[(0,Q.jsx)(`div`,{className:`truncate text-base font-semibold`,children:String(a.subject??`(no subject)`)}),(0,Q.jsxs)(`details`,{className:`sm:hidden`,children:[(0,Q.jsxs)(`summary`,{className:`cursor-pointer text-xs`,children:[(0,Q.jsx)(`span`,{className:`inline-block max-w-[85%] truncate align-bottom`,children:typeof a.from==`object`&&a.from?a.from.name||a.from.address:String(a.from||`Unknown sender`)}),(0,Q.jsx)(`span`,{className:`ml-2 text-muted-foreground`,children:`Details`})]}),(0,Q.jsxs)(`div`,{className:`mt-2 space-y-1 break-words text-xs`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:`From:`}),` `,cn(a.from)]}),$(a.to)&&(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:`To:`}),` `,$(a.to)]}),$(a.cc)&&(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:`Cc:`}),` `,$(a.cc)]}),w&&(0,Q.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:w})]})]}),(0,Q.jsxs)(`div`,{className:`hidden space-y-1 break-words sm:block`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:`From:`}),` `,cn(a.from)]}),$(a.to)&&(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:`To:`}),` `,$(a.to)]}),$(a.cc)&&(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:`Cc:`}),` `,$(a.cc)]}),w&&(0,Q.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:w})]})]}),l&&(0,Q.jsxs)(`div`,{className:`flex max-w-full flex-wrap gap-2`,children:[(0,Q.jsxs)(K,{size:`sm`,variant:`outline`,onClick:()=>h(!m),children:[m?(0,Q.jsx)(c,{className:`mr-1.5 h-3.5 w-3.5`}):(0,Q.jsx)(B,{className:`mr-1.5 h-3.5 w-3.5`}),m?`HTML`:`Plain text`]}),!m&&b>0&&(0,Q.jsxs)(K,{size:`sm`,variant:g?`secondary`:`outline`,onClick:()=>v(!g),title:`Remote images can reveal your IP/read status to the sender`,children:[g?(0,Q.jsx)(y,{className:`mr-1.5 h-3.5 w-3.5`}):(0,Q.jsx)(_,{className:`mr-1.5 h-3.5 w-3.5`}),g?`Hide remote images`:`Show remote images (${b})`]})]})]})}),(S||d)&&(0,Q.jsx)(`p`,{className:`text-sm text-destructive`,children:S||d}),u?(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Loading message…`}):d?(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:String(a.bodyPreview||`Message content could not be loaded.`)}):!m&&l?f?(0,Q.jsx)(`iframe`,{src:f,sandbox:``,title:String(a.subject??`email`),className:`min-h-[12rem] w-full flex-1 rounded border bg-white`}):(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Rendering...`}):(0,Q.jsx)(`pre`,{className:`min-h-[12rem] flex-1 overflow-auto whitespace-pre-wrap rounded bg-muted p-3 text-sm`,children:s||`(empty body)`}),T.length>0&&(0,Q.jsxs)(`div`,{className:`shrink-0 space-y-1`,children:[(0,Q.jsxs)(`div`,{className:`text-xs font-medium text-muted-foreground`,children:[`Attachments (`,T.length,`)`]}),T.map((e,t)=>(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2 rounded border px-2 py-1.5 text-sm`,children:[(0,Q.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-2`,children:[(0,Q.jsx)(B,{className:`h-4 w-4 shrink-0 text-muted-foreground`}),(0,Q.jsx)(`span`,{className:`truncate`,children:e.filename||`attachment`}),(0,Q.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground`,children:ln(e.size)})]}),e.url&&(0,Q.jsxs)(`button`,{onClick:()=>E(e),className:`inline-flex shrink-0 items-center gap-1 text-xs text-primary hover:underline`,children:[(0,Q.jsx)(U,{className:`h-3 w-3`}),` Download`]})]},e.url||t))]})]})}function mn({attachment:e,workspaceId:t,document:n}){let{download:r}=Ye(t),i=e.mimeType||e.contentType||``,a=e.name||e.filename||`Attachment`,o=i.startsWith(`audio/`)||i.startsWith(`video/`),{blobUrl:s,error:c,loading:l}=$e(t,n.id,{url:e.url,typeHint:i,enabled:!o&&!!e.url}),{src:u,error:d,loading:f}=tt(t,n.id,{url:e.url,enabled:o&&!!e.url}),[p,m]=(0,Z.useState)(!1),[h,g]=(0,Z.useState)(``),_=o?d:c;return(0,Q.jsxs)(`div`,{className:`space-y-2 rounded border p-2`,children:[_&&(0,Q.jsx)(`p`,{className:`text-xs text-destructive`,children:_}),(o?f:l)&&(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Loading attachment…`}),!o&&s&&i.startsWith(`image/`)&&(0,Q.jsx)(`img`,{src:s,alt:a,className:`max-h-96 max-w-full rounded object-contain`}),o&&u&&(i.startsWith(`video/`)?(0,Q.jsx)(`video`,{controls:!0,playsInline:!0,preload:`metadata`,src:u,onError:()=>m(!0),className:`max-h-96 w-full rounded`},u):(0,Q.jsx)(`audio`,{controls:!0,preload:`metadata`,src:u,onError:()=>m(!0),className:`w-full`},u)),p&&(0,Q.jsx)(`p`,{role:`alert`,className:`text-xs text-destructive`,children:`This media could not be played in your browser. Download it to play in another app.`}),h&&(0,Q.jsx)(`p`,{role:`alert`,className:`text-xs text-destructive`,children:h}),e.url&&(0,Q.jsxs)(`button`,{className:`text-sm text-primary underline`,onClick:()=>{r(n.id,a,{url:e.url}).catch(()=>g(`Attachment could not be downloaded.`))},children:[`Download `,a]})]})}function hn(e){let t=e.document.data,n=t.sender,r=t.channel,i=Array.isArray(t.attachments)?t.attachments:[],a=t.timestamp?new Date(String(t.timestamp)):null;return(0,Q.jsxs)(`article`,{className:`space-y-4 p-3 ${e.className||``}`,children:[(0,Q.jsxs)(`header`,{className:`space-y-1 border-b pb-3`,children:[(0,Q.jsx)(`p`,{className:`font-medium`,children:n?.name||n?.displayName||n?.username||n?.id||`Unknown sender`}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:[r?.name||r?.id,String(t.platform||``),a&&!Number.isNaN(a.getTime())?a.toLocaleString():``].filter(Boolean).join(` · `)})]}),(0,Q.jsx)(`p`,{className:`whitespace-pre-wrap break-words text-sm`,children:String(t.text||`(No text)`)}),!!t.mediaError&&(0,Q.jsx)(`p`,{className:`text-xs text-destructive`,children:String(t.mediaError)}),i.map((t,n)=>(0,Q.jsx)(mn,{...e,attachment:t},t.url||n))]})}var gn={email:A,phone:oe,sms:M,chat:M,slack:M,matrix:M,web:C,url:C},_n={person:`Person`,organization:`Organization`,service:`Service`,bot:`Bot`},vn=e=>Array.isArray(e)?e:[];function yn(e,t){return t?e===`email`?`mailto:${t}`:e===`phone`||e===`sms`?`tel:${t.replace(/[^\d+]/g,``)}`:/^https?:\/\//i.test(t)?t:null:null}function bn({title:e,count:t,children:n}){return t===0?null:(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground`,children:e}),(0,Q.jsx)(`div`,{className:`space-y-1`,children:n})]})}function xn({icon:e,primary:t,children:n,title:r}){return(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 rounded-md border bg-card px-2.5 py-1.5 text-sm`,title:r,children:[(0,Q.jsx)(e,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`}),(0,Q.jsx)(`div`,{className:`min-w-0 flex-1 truncate`,children:n}),t&&(0,Q.jsx)(R,{className:`h-3 w-3 shrink-0 fill-current text-data-5`,"aria-label":`Primary`})]})}function Sn({document:e,className:t}){let n=e.data??{},r=vn(n.identifiers),i=vn(n.channels),a=vn(n.organizations),o=vn(n.links),s=vn(n.tags),c=String(n.displayName||``).trim(),l=Ce(e.schema,xe),u=String(n.primaryEmail||``).trim(),d=n.name&&typeof n.name==`object`?n.name:{},f=[d.prefix,d.given,d.middle,d.family,d.suffix].map(e=>String(e||``).trim()).filter(Boolean).join(` `),p=i.some(e=>e.kind===`email`&&e.value===u);return(0,Q.jsxs)(`div`,{className:G(`space-y-4`,t),children:[(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`h2`,{className:`text-lg font-semibold`,children:c||`Identity ${e.id}`}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-muted-foreground`,children:[l&&(0,Q.jsx)(`span`,{className:`rounded-full bg-muted px-2 py-0.5`,children:_n[l]||l}),f&&f!==c&&(0,Q.jsx)(`span`,{children:f}),String(n.timezone||``)&&(0,Q.jsx)(`span`,{children:String(n.timezone)}),String(n.locale||``)&&(0,Q.jsx)(`span`,{children:String(n.locale)})]})]}),u&&!p&&(0,Q.jsx)(bn,{title:`Primary email`,count:1,children:(0,Q.jsx)(xn,{icon:A,primary:!0,children:(0,Q.jsx)(`a`,{href:`mailto:${u}`,className:`hover:underline`,children:u})})}),(0,Q.jsx)(bn,{title:`Channels`,count:i.length,children:i.map((e,t)=>{let n=String(e.kind||``).toLowerCase(),r=String(e.value||``),i=yn(n,r),a=gn[n]||M;return(0,Q.jsxs)(xn,{icon:a,primary:e.primary,title:e.platform||n,children:[i?(0,Q.jsx)(`a`,{href:i,className:`hover:underline`,target:i.startsWith(`http`)?`_blank`:void 0,rel:`noopener noreferrer`,children:r}):r,e.label&&(0,Q.jsx)(`span`,{className:`ml-2 text-xs text-muted-foreground`,children:e.label})]},`${n}:${r}:${t}`)})}),(0,Q.jsx)(bn,{title:`Identifiers`,count:r.length,children:r.map((e,t)=>(0,Q.jsxs)(xn,{icon:H,primary:e.primary,children:[(0,Q.jsx)(`span`,{className:`font-mono text-xs`,children:e.identifier}),(0,Q.jsx)(`span`,{className:`ml-2 text-xs text-muted-foreground`,children:[e.type,e.provider].filter(Boolean).join(` · `)})]},`${e.type}:${e.identifier}:${t}`))}),(0,Q.jsx)(bn,{title:`Organizations`,count:a.length,children:a.map((e,t)=>(0,Q.jsxs)(xn,{icon:D,children:[e.name,e.role&&(0,Q.jsx)(`span`,{className:`ml-2 text-xs text-muted-foreground`,children:e.role})]},`${e.name}:${t}`))}),(0,Q.jsx)(bn,{title:`Links`,count:o.length,children:o.map((e,t)=>(0,Q.jsxs)(xn,{icon:O,children:[(0,Q.jsx)(`span`,{className:`font-mono text-xs`,children:e.target}),e.type&&(0,Q.jsx)(`span`,{className:`ml-2 text-xs text-muted-foreground`,children:e.type})]},`${e.type}:${e.target}:${t}`))}),s.length>0&&(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:s.map(e=>(0,Q.jsx)(`span`,{className:`rounded-full bg-muted px-2 py-0.5 text-xs text-muted-foreground`,children:e},e))})]})}function Cn({document:e}){let t=String(e.metadata?.contentType||`application/octet-stream`);return(0,Q.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`No inline preview available for `,(0,Q.jsx)(`span`,{className:`font-mono`,children:t}),`. Use Download.`]})}function wn(e){let t=e.schema;if(t===`data/schema/note`)return Jt;if(t===`data/schema/drawing`)return Ut;if(t===`data/schema/task`)return on;if(t===`data/schema/message/email`)return fn;if(t===`data/schema/message`)return hn;if(t===`data/schema/identity`||t.startsWith(`data/schema/identity/`))return Sn;if(t===`data/schema/tab`||t===`data/schema/link`){let t=String(e.data?.url??e.data?.uri??``);return he(t)?Yt:Zt(t)?Xt:$t}if(t!==`data/schema/file`)return null;let n=String(e.metadata?.contentType||``);switch(Se(n,Y(e))){case`image`:return Ut;case`audio`:return Wt;case`video`:return Gt;case`pdf`:return Kt;case`markdown`:return Jt;case`text`:return qt;default:return Cn}}function Tn({onSearch:e,onDraftChange:t,inputRef:n,workspaceId:r,label:i=`Search documents`,clearOnSubmit:a=!0,showSubmitButton:o=!0}){let s=(0,Z.useRef)(null),c=n??s;return(0,Q.jsxs)(`form`,{className:`canvas-search-input`,role:`search`,onSubmit:n=>{n.preventDefault();let r=n.currentTarget.elements.namedItem(`query`),i=r.value.trim();i&&(e(i),a&&(r.value=``,t?.(``)))},children:[(0,Q.jsx)(`input`,{ref:c,name:`query`,type:`search`,"aria-label":i,placeholder:i,autoComplete:`off`,enterKeyHint:`search`,onChange:e=>t?.(e.target.value),onKeyDown:e=>{e.key===`Enter`&&e.nativeEvent.isComposing&&e.preventDefault()}}),o&&(0,Q.jsx)(`button`,{type:`submit`,className:`canvas-nav-button`,"aria-label":`Run search`,title:`Run search`,children:(0,Q.jsx)(W,{size:17})}),r&&(0,Q.jsx)(Dt,{workspaceId:r,inputRef:c,onChange:t})]})}function En({queries:e,onRemoveQuery:t,scope:n=`path`,onScopeChange:r}){return(0,Q.jsxs)(`div`,{className:`canvas-search-options`,children:[r&&(0,Q.jsxs)(`div`,{className:`canvas-search-scopes`,"aria-label":`Search scope`,children:[(0,Q.jsx)(`span`,{children:`Search in`}),(0,Q.jsx)(`button`,{type:`button`,"aria-pressed":n===`path`,onClick:()=>r(`path`),children:`This path`}),(0,Q.jsx)(`button`,{type:`button`,"aria-pressed":n===`workspace`,onClick:()=>r(`workspace`),children:`Workspace`})]}),e.length>0&&(0,Q.jsxs)(`div`,{className:`canvas-search-queries`,"aria-label":`Active searches`,children:[e.map((e,n)=>{let r=/"[^"]+/.test(e);return(0,Q.jsxs)(`span`,{className:r?`canvas-search-query canvas-search-query-exact`:`canvas-search-query`,children:[r?(0,Q.jsx)(P,{size:12,"aria-hidden":`true`}):(0,Q.jsx)(W,{size:12,"aria-hidden":`true`}),(0,Q.jsx)(`span`,{title:r?`${e} (exact phrase)`:e,children:e}),t&&(0,Q.jsx)(`button`,{type:`button`,onClick:()=>t(n),"aria-label":`Remove search: ${e}`,children:(0,Q.jsx)(h,{size:14})})]},`${e}-${n}`)}),t&&e.length>1&&(0,Q.jsx)(`button`,{type:`button`,onClick:()=>t(-1),className:`canvas-search-clear`,children:`Clear all`})]})]})}function Dn({children:e,accentColor:t}){return(0,Q.jsxs)(`div`,{className:`canvas-navigation-tabs`,children:[(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`canvas-tab-divider`,style:t?{backgroundColor:t}:void 0}),e]})}function On({workspace:e,workspaceIcon:t,tree:n,path:i,document:a,section:o,onBack:s,onBrowseWorkspaces:c,onBrowseTree:l,onNavigatePath:u,onDocument:d,onSection:f,onFilter:p,filtersActive:m,filtersOpen:g,onAdd:_,search:v,onDraftChange:y,tabs:x,accentColor:S,actions:C}){let[w,T]=(0,Z.useState)(!1),[E,D]=(0,Z.useState)(!1),O=(0,Z.useRef)(null),k=(0,Z.useRef)(null),A=(0,Z.useRef)(null),M=(0,Z.useRef)(!1),N=JSON.stringify([e,n,i,a]),[P,te]=(0,Z.useState)(N);P!==N&&(te(N),T(!1)),(0,Z.useEffect)(()=>{w?k.current?.focus():(O.current&&(O.current.scrollLeft=O.current.scrollWidth,D(O.current.scrollLeft>1)),M.current&&=(A.current?.focus(),!1))},[w,N,o]);let F=()=>{M.current=!0,T(!1),y?.(``)},I=w?F:s??l,ne=ue(i,e).slice(1),L=(e,t,n,r,i=!1)=>n?(0,Q.jsx)(`button`,{type:`button`,className:t,onClick:n,title:r,"aria-current":i?`location`:void 0,children:e}):(0,Q.jsx)(`span`,{className:`canvas-address-label ${t}`,title:r,"aria-current":i?`location`:void 0,children:e});return(0,Q.jsxs)(`header`,{className:`canvas-navigation${x?` has-tabs`:``}`,style:S?{borderTopColor:S}:void 0,children:[x&&(0,Q.jsx)(Dn,{accentColor:S,children:x}),(0,Q.jsxs)(`div`,{className:`canvas-address-row`,children:[(0,Q.jsx)(`button`,{type:`button`,className:`canvas-nav-button`,"aria-label":w?`Back to address`:`Back to previous view`,title:w?`Back to address`:`Back to previous view`,disabled:!w&&!s&&!l,onClick:I,children:(0,Q.jsx)(ee,{size:19})}),(0,Q.jsxs)(`div`,{className:`canvas-address-field`,onDoubleClick:e=>{v&&!e.target.closest(`button`)&&T(!0)},onKeyDown:e=>{e.key===`Escape`&&w&&(e.preventDefault(),e.stopPropagation(),F())},children:[w&&v?(0,Q.jsx)(Tn,{inputRef:k,workspaceId:v.localOnly?void 0:v.workspaceId,onSearch:v.onSearch,onDraftChange:y,clearOnSubmit:!v.localOnly,showSubmitButton:!1,label:v.queries.length?`Refine search…`:`Search documents…`}):(0,Q.jsxs)(Q.Fragment,{children:[L((0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(r,{icon:t||`ph:stack-fill`,className:`h-4 w-4 shrink-0`,"aria-hidden":`true`}),(0,Q.jsx)(`span`,{className:`truncate`,children:e})]}),`canvas-address-workspace`,c,`Browse workspaces`),(0,Q.jsxs)(`div`,{ref:O,className:`canvas-address-crumbs${E?` is-scrolled`:``}`,onScroll:e=>D(e.currentTarget.scrollLeft>1),role:`navigation`,"aria-label":`Canvas address`,tabIndex:0,onKeyDown:e=>{e.key===`Enter`&&e.target===e.currentTarget&&v&&T(!0)},children:[n&&L(`[${n}]`,`canvas-address-tree`,l,`Browse tree: ${n}`),L(`:/`,`canvas-address-root`,u?()=>u(`/`):void 0,`Go to tree root`),ne.map((e,t)=>(0,Q.jsxs)(`span`,{className:`canvas-address-segment`,children:[t>0&&(0,Q.jsx)(`span`,{"aria-hidden":`true`,children:`/`}),L(e.label,``,u?()=>u(e.path):void 0,e.path,!a&&t===ne.length-1)]},e.path)),a&&(0,Q.jsxs)(`span`,{className:`canvas-address-segment`,children:[(0,Q.jsx)(`span`,{"aria-hidden":`true`,children:ne.length?`/`:``}),L(a,``,d,a)]}),o&&L(`#${o}`,`canvas-address-section`,f,o,!0)]})]}),v&&(0,Q.jsxs)(`button`,{ref:A,type:`button`,className:`canvas-nav-button canvas-address-search`,onClick:()=>{w?k.current?.form?.requestSubmit():T(!0)},"aria-label":w?`Run search`:`Search this canvas`,"aria-expanded":w,title:w?`Run search`:`Search this canvas`,children:[(0,Q.jsx)(W,{size:17}),v.queries.length>0&&(0,Q.jsx)(`span`,{className:`canvas-nav-dot`})]})]}),p&&(0,Q.jsxs)(`button`,{type:`button`,className:`canvas-nav-button canvas-filter-button`,onClick:p,"aria-label":m?`Filters active`:`Filters`,"aria-expanded":!!g,"data-active":!!m,title:m?`Filters active`:`Filters`,children:[(0,Q.jsx)(j,{size:19}),m&&(0,Q.jsx)(`span`,{className:`canvas-nav-dot`})]}),_&&(0,Q.jsx)(`button`,{type:`button`,className:`canvas-nav-button canvas-add-button`,onClick:_,"aria-label":`Add here`,title:`Add here`,children:(0,Q.jsx)(b,{size:21})}),C]}),w&&v&&(0,Q.jsxs)(`div`,{className:`canvas-search-dropdown`,children:[(0,Q.jsxs)(`div`,{className:`canvas-search-heading`,children:[(0,Q.jsx)(`span`,{children:v.localOnly?`Filter documents on this page`:y?`Type to filter this page · Enter to search all results`:`Search text or an exact ID, e.g. @id:123`}),(0,Q.jsx)(`button`,{type:`button`,className:`canvas-nav-button`,onClick:F,"aria-label":`Close search`,children:(0,Q.jsx)(h,{size:16})})]}),(0,Q.jsx)(En,{...v})]}),!w&&v&&v.queries.length>0&&(0,Q.jsx)(`div`,{className:`px-3 pb-2`,children:(0,Q.jsx)(En,{queries:v.queries,onRemoveQuery:v.onRemoveQuery})})]})}function kn({workspaceId:e,document:t,className:n}){let r=wn(t);return r?(0,Q.jsx)(r,{workspaceId:e,document:t,className:n}):(0,Q.jsx)(`pre`,{className:`overflow-auto p-2 text-xs`,children:JSON.stringify(t.data,null,2)})}function An({workspaceId:e,documentId:t}){let[n,r]=(0,Z.useState)(null),[i,a]=(0,Z.useState)(``),[o,s]=(0,Z.useState)({}),[c,l]=(0,Z.useState)(null),u=(0,Z.useCallback)(async()=>{try{let n=await gt(e,t);r(n),a(``)}catch(e){a(e instanceof Error?e.message:`Could not load thread`)}},[e,t]);return(0,Z.useEffect)(()=>{let n=!0;gt(e,t).then(e=>{n&&(r(e),a(``))}).catch(e=>{n&&a(e instanceof Error?e.message:`Could not load thread`)});let i=()=>{u()};return window.addEventListener(`workspace:documents:refresh`,i),window.addEventListener(ct,i),()=>{n=!1,window.removeEventListener(`workspace:documents:refresh`,i),window.removeEventListener(ct,i)}},[e,t,u]),i?(0,Q.jsxs)(`div`,{className:`p-3`,children:[(0,Q.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:i}),(0,Q.jsx)(K,{variant:`outline`,size:`sm`,onClick:()=>void u(),children:`Retry`})]}):!n||n.documentId!==t?(0,Q.jsx)(`p`,{className:`p-3 text-sm text-muted-foreground`,children:`Loading thread…`}):(0,Q.jsxs)(`section`,{"aria-label":`Message thread`,className:`space-y-3 p-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Q.jsxs)(`h3`,{className:`text-sm font-medium`,children:[`Thread · `,n.documents.length,` message`,n.documents.length===1?``:`s`]}),(0,Q.jsx)(K,{size:`sm`,variant:`outline`,onClick:()=>void u(),children:`Refresh`})]}),n.documents.length===1&&(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No linked replies have been indexed. Other messages in this conversation are separate from this reply thread.`}),n.truncated&&(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Showing up to 200 linked messages.`}),n.documents.map(r=>{let i=fe(r),a=r.schema===`data/schema/message/email`,c=a||[`slack`,`whatsapp`].includes(String(r.data.platform)),u=r.data.timestamp||r.data.date,d=u?new Date(String(u)):null,f=(n.parents[r.id]||[]).flatMap(e=>{let t=n.documents.find(t=>Number(t.id)===e);return t?[fe(t).title]:[]}),p=o[Number(r.id)]??Number(r.id)===t;return(0,Q.jsxs)(`details`,{open:p,onToggle:e=>{let t=e.currentTarget.open;s(e=>e[Number(r.id)]===t?e:{...e,[Number(r.id)]:t})},className:`rounded-lg border bg-card`,children:[(0,Q.jsxs)(`summary`,{className:`cursor-pointer space-y-1 p-3 text-sm`,children:[(0,Q.jsx)(`span`,{className:`font-medium`,children:i.title}),(0,Q.jsxs)(`span`,{className:`block text-xs text-muted-foreground`,children:[i.subtitle,d&&!Number.isNaN(d.getTime())?` · ${d.toLocaleString()}`:``]}),f.length>0&&(0,Q.jsxs)(`span`,{className:`block text-xs text-muted-foreground`,children:[`Reply to `,f.join(`, `)]})]}),p&&c&&(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-2 px-3 pb-2`,children:(a?[`reply`,`replyAll`,`forward`]:[`reply`]).map(e=>(0,Q.jsx)(K,{variant:`outline`,size:`sm`,onClick:()=>l({document:r,mode:e}),children:e===`replyAll`?`Reply all`:e===`forward`?`Forward`:`Reply`},e))}),p&&(0,Q.jsx)(kn,{workspaceId:e,document:r})]},r.id)}),c&&(0,Q.jsx)(vt,{workspaceId:e,replyToDocumentId:Number(c.document.id),mode:c.mode,originalSubject:typeof c.document.data.subject==`string`?c.document.data.subject:void 0,onClose:()=>l(null)},`${c.document.id}:${c.mode}`)]})}function jn(e,t){return e.slice(0,3).map(e=>{let n=t.get(e.id),r=e.reason===`not-found`?`Source missing from the storage index. Resync the source backend and retry.`:e.reason===`not found`?`Document no longer exists in this workspace. Refresh the list and select it again.`:e.reason;return`${n?`${n} (ID ${e.id})`:`Document ${e.id}`}: ${r}`}).join(`
|
|
8
|
+
`)+(e.length>3?`\n…and ${e.length-3} more failed file${e.length===4?``:`s`}.`:``)}var Mn=e(i(),1),Nn=[{mode:`copy`,label:`Copy to`,icon:(0,Q.jsx)(S,{className:`h-3.5 w-3.5`})},{mode:`move`,label:`Move to`,icon:(0,Q.jsx)(ae,{className:`h-3.5 w-3.5`})},{mode:`delete`,label:`Delete from`,icon:(0,Q.jsx)(T,{className:`h-3.5 w-3.5`})}],Pn=[{value:`rename`,label:`Rename mine (file-1.ext)`},{value:`overwrite`,label:`Overwrite the existing file`},{value:`error`,label:`Skip the document`}],Fn=`h-9 w-full rounded-md border bg-background px-2 text-xs outline-none focus:ring-2 focus:ring-ring disabled:opacity-50`;function In(e){return e.driver===`cacache`?k:e.config?.remote===!0?v:o}function Ln({workspaceId:e,documentCount:t,initialMode:n=`copy`,defaultFilename:r=``,onConfirm:i,onClose:a,saving:s=!1,sizeClassName:c,deleteFrom:l,progress:u,stopping:d=!1,onStop:f}){let{showErrorToast:m}=X(),[g,_]=(0,Z.useState)(!1);mt(a,!s&&!g);let[v,y]=(0,Z.useState)(n),[b,x]=(0,Z.useState)(null),[C,w]=(0,Z.useState)(null),[E,D]=(0,Z.useState)(()=>new Set(n===`delete`&&l?[l.backend]:[])),[O,k]=(0,Z.useState)(!1),[A,j]=(0,Z.useState)(``),[M,ee]=(0,Z.useState)(r),[N,P]=(0,Z.useState)(`rename`);(0,Z.useEffect)(()=>{let t=!1;return Le(e).then(e=>{if(t)return;x(e.filter(e=>e.kind===`storage`));let n=new Set(e.filter(e=>e.kind===`storage`&&e.enabled!==!1&&e.config?.readOnly!==!0&&e.config?.supported!==!1).map(e=>e.address));D(e=>new Set([...e].filter(e=>n.has(e))))}).catch(e=>{t||w(e instanceof Error?e.message:String(e))}),()=>{t=!0}},[e]);let te=v===`move`,F=e=>e.enabled===!1?`disabled`:e.config?.readOnly===!0?`read-only`:e.config?.supported===!1?`unsupported`:null,I=(0,Z.useMemo)(()=>(b||[]).filter(e=>!F(e)).map(e=>e.address),[b,v]),ne=e=>{y(e),D(t=>{let n=(b||[]).filter(e=>e.enabled!==!1&&e.config?.readOnly!==!0&&e.config?.supported!==!1).map(e=>e.address),r=[...t].filter(e=>n.includes(e));return new Set(e===`move`?r.slice(0,1):r)})},L=e=>{D(t=>{if(te)return t.has(e)?new Set:new Set([e]);let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},R=(0,Z.useMemo)(()=>(b||[]).filter(e=>E.has(e.address)&&Ne(e)),[b,E]),z=v!==`delete`&&R.length>0,B=e=>{let t=ke(e,b||[]),n=t&&b?.find(e=>e.address===t.address);return!!n&&!F(n)&&v!==`delete`&&!s},V=async(t,n)=>{let r=ke(t,b||[]);if(!r||!B(t))throw Error(`Choose a writable file backend folder`);await Me(e,r.driver,r.address,[[r.key,n].filter(Boolean).join(`/`)])},H=e=>{_(!1);let t=Oe(e[0]||``,b||[]),n=t?(b||[]).find(e=>e.address===t.address):null;if(!t||!n){m(`Pick a folder inside a storage backend`);return}if(F(n)){m(`${n.address} is ${F(n)}`);return}if(!Ne(n)){m(`${n.address} does not keep folders — objects are stored by content`);return}j(t.key),D(e=>te?new Set([t.address]):new Set([...e,t.address]))},ie=async()=>{E.size===0||s||await i([...E],v,{keepDocument:O,folder:z?A.trim():``,filename:z&&t===1?M.trim():``,onConflict:N})},U=t,W=U===1?``:`s`,oe=v===`delete`?`Delete ${U} document${W} from…`:`${v===`move`?`Move`:`Copy`} ${U} document${W} to…`,q=v===`delete`?`Delete from`:v===`move`?`Move to`:`Copy to`,J=E.size===0?q.split(` `)[0]:`${q} ${E.size} backend${E.size===1?``:`s`}`;return(0,Q.jsxs)(`div`,{className:G(`flex flex-col overflow-hidden rounded-(--panel-radius) border bg-card shadow-elevation-4`,c||`max-h-viewport-card w-[min(420px,90vw)] max-md:h-full max-md:w-full max-md:shadow-elevation-5`),children:[(0,Q.jsxs)(`div`,{className:`flex h-12 shrink-0 items-center justify-between border-b px-4`,children:[(0,Q.jsxs)(`span`,{className:`flex items-center gap-2 text-sm font-medium`,children:[(0,Q.jsx)(o,{className:`h-4 w-4`}),oe]}),(0,Q.jsx)(`button`,{type:`button`,onClick:a,disabled:s,className:`text-muted-foreground transition-colors hover:text-foreground disabled:opacity-40`,"aria-label":`Close`,children:(0,Q.jsx)(h,{className:`h-4 w-4`})})]}),(0,Q.jsx)(`div`,{className:`flex shrink-0 items-center gap-1 border-b px-2 pt-2`,children:Nn.map(({mode:e,label:t,icon:n})=>(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>ne(e),disabled:s,className:G(`flex items-center gap-1.5 rounded-t-md border-b-2 px-3 py-2 text-xs font-medium transition-colors disabled:opacity-50`,v===e?e===`delete`?`border-destructive text-destructive`:`border-primary text-foreground`:`border-transparent text-muted-foreground hover:text-foreground`),children:[n,t]},e))}),(0,Q.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-1.5 overflow-y-auto p-3`,children:[C&&(0,Q.jsx)(`p`,{className:`px-2 py-1.5 text-xs text-destructive`,children:C}),!b&&!C&&(0,Q.jsx)(`div`,{className:`px-2 py-3 text-xs text-muted-foreground`,children:`Loading backends…`}),b?.length===0&&(0,Q.jsx)(`p`,{className:`px-2 py-1.5 text-xs text-muted-foreground`,children:`No storage backends configured.`}),b?.map(e=>{let t=In(e),n=F(e),r=E.has(e.address),i=e.config?.remote===!0;return(0,Q.jsxs)(`div`,{onClick:()=>!n&&!s&&L(e.address),className:G(`group relative flex min-h-10 items-center gap-2 rounded-md px-3 py-2 text-sm shadow-elevation-1 transition-all select-none`,`before:absolute before:left-0 before:top-0 before:bottom-0 before:w-1.5 before:transition-colors`,n?`cursor-not-allowed bg-muted/40 opacity-60 before:bg-transparent`:`cursor-pointer hover:shadow`,!n&&r?v===`delete`?`bg-destructive/[0.08] hover:bg-destructive/[0.12] before:bg-destructive`:`bg-primary/[0.08] hover:bg-primary/[0.12] before:bg-primary`:n?``:`bg-card hover:bg-primary/[0.04] before:bg-transparent`),title:e.address,children:[(0,Q.jsx)(`input`,{type:te?`radio`:`checkbox`,checked:r,disabled:!!n||s,onChange:()=>L(e.address),onClick:e=>e.stopPropagation(),className:`h-4 w-4 shrink-0 accent-primary`,"aria-label":e.address}),(0,Q.jsx)(t,{className:`h-4 w-4 shrink-0 text-muted-foreground`}),(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`span`,{className:`block truncate font-medium`,children:e.config?.label||e.address}),(0,Q.jsxs)(`span`,{className:`block truncate font-mono text-[10px] text-muted-foreground`,children:[e.driver,` · `,e.address]})]}),i&&(0,Q.jsx)(`span`,{className:`shrink-0 rounded bg-info-subtle px-1.5 py-0.5 text-[10px] uppercase text-muted-foreground`,title:`Network mount${e.config?.transport?` (${e.config.transport})`:``} — transfers cross the network`,children:e.config?.transport||`remote`}),n&&(0,Q.jsx)(`span`,{className:`shrink-0 rounded bg-muted px-1.5 py-0.5 text-[10px] uppercase text-muted-foreground`,children:n})]},`${e.driver}/${e.address}`)}),v===`delete`&&(0,Q.jsxs)(`label`,{className:`mt-3 flex cursor-pointer items-start gap-2 rounded-md border border-destructive/30 bg-destructive/5 px-3 py-2 text-xs`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,checked:O,onChange:e=>k(e.target.checked),disabled:s,className:`mt-0.5 h-3.5 w-3.5 accent-destructive`}),(0,Q.jsxs)(`span`,{children:[`Keep the index entry when its `,(0,Q.jsx)(`strong`,{children:`last`}),` copy is deleted.`,(0,Q.jsx)(`span`,{className:`block text-muted-foreground`,children:`Otherwise the document moves to workspace Trash once no locations remain.`})]})]}),z&&(0,Q.jsxs)(`div`,{className:`mt-3 space-y-2 rounded-md border px-3 py-2`,children:[(0,Q.jsxs)(`p`,{className:`text-xs font-medium`,children:[`Destination on `,R.map(e=>e.config?.label||e.address).join(`, `)]}),(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{htmlFor:`backend-transfer-folder`,className:`text-[11px] text-muted-foreground`,children:`Folder (relative to the backend root)`}),(0,Q.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,Q.jsx)(se,{id:`backend-transfer-folder`,value:A,onChange:e=>j(e.target.value),placeholder:`/`,disabled:s,className:`h-9 font-mono text-xs`}),(0,Q.jsx)(K,{type:`button`,variant:`outline`,size:`icon`,className:`h-9 w-9 shrink-0`,onClick:()=>_(!0),disabled:s,"aria-label":`Browse backend folders`,title:`Browse…`,children:(0,Q.jsx)(re,{className:`h-4 w-4`})})]})]}),t===1?(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{htmlFor:`backend-transfer-filename`,className:`text-[11px] text-muted-foreground`,children:`File name`}),(0,Q.jsx)(se,{id:`backend-transfer-filename`,value:M,onChange:e=>ee(e.target.value),placeholder:r||`keeps the document's own name`,disabled:s,className:`h-9 font-mono text-xs`})]}):(0,Q.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:`Each document keeps its own file name and extension.`}),(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{htmlFor:`backend-transfer-conflict`,className:`text-[11px] text-muted-foreground`,children:`If a different file already has that name`}),(0,Q.jsx)(`select`,{id:`backend-transfer-conflict`,className:Fn,value:N,onChange:e=>P(e.target.value),disabled:s,children:Pn.map(e=>(0,Q.jsx)(`option`,{value:e.value,children:e.label},e.value))})]})]}),v===`move`&&I.length>0&&(0,Q.jsx)(`p`,{className:`px-1 pt-2 text-[11px] text-muted-foreground`,children:`The source copy is released only once the destination write is durable.`})]}),s&&u&&(0,Q.jsxs)(`div`,{role:`status`,className:`flex items-center justify-between gap-2 border-t px-4 py-2 text-xs`,children:[(0,Q.jsxs)(`span`,{children:[d?`Stopping after current file`:`Processing`,` · `,u.completed,`/`,u.total]}),f&&(0,Q.jsx)(K,{size:`sm`,variant:`outline`,onClick:f,disabled:d,children:`Stop`})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-t px-4 py-3`,children:[(0,Q.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[E.size,` backend`,E.size===1?``:`s`,` selected`]}),(0,Q.jsx)(K,{size:`sm`,variant:v===`delete`?`destructive`:`default`,onClick:ie,disabled:E.size===0||s,children:s?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(ce,{className:`mr-1.5 h-3.5 w-3.5`}),`Working…`]}):(0,Q.jsxs)(Q.Fragment,{children:[v===`delete`?(0,Q.jsx)(T,{className:`mr-1 h-3.5 w-3.5`}):v===`move`?(0,Q.jsx)(ae,{className:`mr-1 h-3.5 w-3.5`}):(0,Q.jsx)(S,{className:`mr-1 h-3.5 w-3.5`}),J]})})]}),v===`delete`&&(0,Q.jsxs)(`div`,{className:`flex items-start gap-2 border-t bg-destructive/5 px-4 py-2 text-[11px] text-muted-foreground`,children:[(0,Q.jsx)(p,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-destructive`}),(0,Q.jsx)(`span`,{children:l&&E.has(l.backend)?`Deletes selected files in ${l.backend}/${l.folder}. Copies in other folders are kept.${E.size>1?` Other selected backends are also targeted.`:` Copies on other backends are kept.`}`:`Deletes the file data from the selected backends. Copies on other backends are untouched.`})]}),g&&(0,Q.jsx)(yt,{onClose:()=>_(!1),children:(0,Q.jsx)(de,{sizeClassName:`h-full w-[380px] max-w-[90vw] max-md:w-full`,multiple:!1,tabs:[`backends`],fixedWorkspaceName:e,title:`Pick a destination folder…`,confirmLabel:`Use folder`,backendFolderCreation:{canCreate:B,create:V},onConfirm:H,onClose:()=>_(!1)})})]})}var Rn={exif:`from the photo's EXIF`,device:`from the device at capture`,manual:`placed by hand`};function zn(e){let t=`${e.lat.toFixed(5)}, ${e.lon.toFixed(5)}`,n=e.source?Rn[e.source]:null;return[t,e.accuracy==null?null:`±${e.accuracy} m`,n].filter(Boolean).join(` · `)}function Bn({value:e,onChange:t,idPrefix:n=`edit-geo`}){let[r,i]=(0,Z.useState)(!1);return(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(q,{htmlFor:`${n}-action`,children:`Location`}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Q.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2 text-xs`,children:[(0,Q.jsx)(ie,{className:e?`h-4 w-4 shrink-0 text-info`:`h-4 w-4 shrink-0 text-muted-foreground`}),(0,Q.jsx)(`span`,{className:e?`truncate tabular-nums`:`truncate text-muted-foreground`,children:e?zn(e):`No location on this document`})]}),(0,Q.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1`,children:[(0,Q.jsxs)(`button`,{id:`${n}-action`,type:`button`,onClick:()=>i(!0),className:`inline-flex items-center gap-1.5 rounded-md border border-border px-2 py-1 text-xs text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,children:[(0,Q.jsx)(z,{className:`h-3.5 w-3.5`}),e?`Move pin`:`Set on map`]}),e&&(0,Q.jsx)(`button`,{type:`button`,onClick:()=>t(null),"aria-label":`Remove location`,title:`Remove location`,className:`rounded p-1 text-muted-foreground hover:bg-muted hover:text-foreground`,children:(0,Q.jsx)(T,{className:`h-3.5 w-3.5`})})]})]}),r&&(0,Q.jsx)(We,{initial:e,onPick:e=>t({lat:e.lat,lon:e.lon,source:`manual`}),onClose:()=>i(!1)})]})}function Vn(e){return e===`data/schema/note`||e===`data/schema/link`||e===`data/schema/tab`||e===`data/schema/task`||e===`data/schema/drawing`||e===`data/schema/identity`||e.startsWith(`data/schema/identity/`)}function Hn(e){return Vn(e.schema)||Ze(e)}function Un(e){return e===`data/schema/link`?{urlKey:`uri`,titleKey:`label`}:e===`data/schema/tab`?{urlKey:`url`,titleKey:`title`}:{urlKey:null,titleKey:`title`}}async function Wn(e,t,n){try{let r=new Set(n.map(e=>e.identityId).filter(Boolean)),i=await Te(e,t,{resolve:!1}),a=new Set(i.outgoing.filter(e=>e.p===`member-of`).map(e=>e.to));for(let n of r)a.has(n)||await Ee(e,t,`member-of`,[n]);for(let n of a)r.has(n)||await we(e,t,`member-of`,n)}catch(e){console.error(`Failed to sync organization relations`,e)}}function Gn({document:e,workspaceId:t,onClose:n}){let{showSuccessToast:r,showErrorToast:i}=X(),a=Vn(e.schema),o=e.schema===`data/schema/file`,[s,c]=(0,Z.useState)(()=>Y(e)),l=!o||!!s.trim()&&!/[\\/]/.test(s)&&!Array.from(s).some(e=>e.charCodeAt(0)<32)&&s!==`.`&&s!==`..`,u=e.schema===pe,d=Ze(e),f=et(e)??`markdown`,p=d&&Xe(e),m=e.schema===ge,h=e.schema===`data/schema/identity`||e.schema.startsWith(`data/schema/identity/`),{urlKey:g,titleKey:_}=Un(e.schema),[v,y]=(0,Z.useState)(g?String(e.data?.[g]??``):``),[b,x]=(0,Z.useState)(String(e.data?.[_]??``)),[S,C]=(0,Z.useState)(String(e.data?.content??``)),[w,T]=(0,Z.useState)(String(e.data?.description??``)),[E,D]=(0,Z.useState)(e.data?.status??`pending`),[O,k]=(0,Z.useState)(typeof e.data?.priority==`number`?e.data.priority:``),[A,j]=(0,Z.useState)(e.data?.dueDate?lt(String(e.data.dueDate)):ft()),M=He(Ge(e)),[ee,N]=(0,Z.useState)(String(e.comment??``)),P=e.metadata?.geo??null,[te,F]=(0,Z.useState)(P),I=e.features??e.metadata?.features,[ne,L]=(0,Z.useState)(ot(I).length?ot(I):e.data?.tags??[]),R=xt(e,t,u),{title:z,content:B,comment:V,tags:re,geo:H,setTitle:ie,setContent:ae,setComment:U,setTags:W,setGeo:oe}=u?R:{title:b,content:S,comment:ee,tags:ne,geo:te,setTitle:x,setContent:C,setComment:N,setTags:L,setGeo:F},G=JSON.stringify(H??null)!==JSON.stringify(P??null),J=$e(t,e.id,{mode:`text`,enabled:d&&!p,maxTextLength:Qe,version:e.checksumArray?.[0]??null}),[ce,le]=(0,Z.useState)(null),ue=`${e.id}:${e.checksumArray?.[0]??``}`;d&&J.text!=null&&ce!==ue&&(le(ue),ae(J.text));let[de,fe]=(0,Z.useState)([]),[me,he]=(0,Z.useState)(!1),{replicating:_e,mirror:ve}=Ie(e);(0,Z.useEffect)(()=>{let e=!1;return De(t).then(t=>{e||fe(t)}).catch(()=>{}),()=>{e=!0}},[t]);let ye=!g||(()=>{try{return new URL(v.trim()),!0}catch{return!1}})(),be=!me&&l&&(d?!p&&J.text!=null&&!J.loading:a?h?M.displayName.trim().length>0&&M.emailValid:m?z.trim().length>0:u?R.canSave:ye:!0),Se=async()=>{he(!0);let c=[...(I||[]).filter(e=>!e.startsWith(`tag/`)),...at(re)];try{if(u){await R.save(),n();return}if(d){let i=await nt(t,e,B,{comment:V.trim(),metadata:{features:c,...o?{filename:s.trim()}:{},...G?{geo:H}:{}}});r(`Document updated`),window.dispatchEvent(new CustomEvent(`workspace:documents:refresh`)),n(i);return}let i={id:e.id,schema:e.schema,schemaVersion:e.schemaVersion,comment:V.trim(),metadata:{features:c,...o?{filename:s.trim()}:{}}};if(h){let{type:t,...n}=e.data??{};i.schema=`${xe}/${M.values.type}`,i.data={...n,...Ue(M.values)}}else if(m)i.data={...e.data,...ut({title:z,description:w,status:E,priority:O,due:A})};else if(a){let t=re.map(e=>e.trim()).filter(Boolean),n;u?n={...z.trim()?{title:z.trim()}:{},content:B}:(n={...e.data},g&&(n[g]=v.trim()),z.trim()?n[_]=z.trim():delete n[_],n.tags=t),i.data=n}G&&(i.metadata={...i.metadata??{},geo:H}),await Fe(t,i),h&&(await Wn(t,e.id,M.values.organizations),st()),r(`Document updated`),window.dispatchEvent(new CustomEvent(`workspace:documents:refresh`)),n()}catch(e){i(e instanceof Error?e.message:`Failed to update document`)}finally{he(!1)}};return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[o&&(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(q,{htmlFor:`file-name`,children:`File name`}),(0,Q.jsx)(se,{id:`file-name`,value:s,onChange:e=>c(e.target.value)}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Changes the object’s name; storage locations stay the same.`})]}),a&&g&&(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(q,{htmlFor:`edit-url`,children:`URL`}),(0,Q.jsx)(se,{id:`edit-url`,value:v,onChange:e=>y(e.target.value),placeholder:`https://example.com`,className:`font-mono text-xs`}),v.trim()&&!ye&&(0,Q.jsx)(`p`,{className:`text-xs text-destructive`,children:`Enter a valid URL, e.g. https://example.com`})]}),a&&h&&(0,Q.jsx)(qe,{idPrefix:`edit-identity`,workspaceName:t,...M,emailValid:M.emailValid}),a&&m&&(0,Q.jsx)(Be,{idPrefix:`edit-todo`,title:z,setTitle:ie,description:w,setDescription:T,status:E,setStatus:D,priority:O,setPriority:k,due:A,setDue:j}),a&&!m&&!h&&(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(q,{htmlFor:`edit-title`,children:`Title`}),(0,Q.jsx)(se,{id:`edit-title`,value:z,onChange:e=>ie(e.target.value),placeholder:u?`Optional; defaults to today's date`:`Optional display title`})]}),(u||d)&&(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(q,{children:`Body`}),p?(0,Q.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`This file is too large to edit here (`,`>`,1e3,` kB) — download it instead.`]}):d&&J.error?(0,Q.jsx)(`p`,{className:`text-xs text-destructive`,children:J.error}):d&&J.text==null?(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Loading content…`}):(0,Q.jsx)(St,{kind:u?`markdown`:f,value:B,onChange:ae,placeholder:u?`Write your note…`:void 0})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(q,{children:`Tags`}),(0,Q.jsx)(Ke,{tags:re,onChange:W,suggestions:de})]}),(0,Q.jsx)(Bn,{value:H,onChange:oe}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(q,{htmlFor:`edit-comment`,children:`Comment`}),(0,Q.jsx)(`textarea`,{id:`edit-comment`,value:V,onChange:e=>U(e.target.value),rows:3,placeholder:`Add context you can't infer from the content, e.g. “sofa from the cozmo bar in Košice”`,className:`flex w-full rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-elevation-1 transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50`})]}),u&&(0,Q.jsx)(bt,{...R,onRetry:R.save}),(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2 pt-2`,children:[(0,Q.jsx)(K,{variant:`outline`,size:`sm`,onClick:()=>n(),disabled:me,children:u?`Close`:`Cancel`}),(0,Q.jsx)(K,{size:`sm`,onClick:Se,disabled:!be,children:me?_e?`Replicating to ${ve.label}…`:`Saving…`:`Save changes`})]})]})}var Kn=(0,Z.createContext)(null),qn={entry:null,open:()=>{},close:()=>{}};function Jn(){return(0,Z.useContext)(Kn)??qn}var Yn=`main`,Xn=(0,Z.createContext)(null);function Zn(){return(0,Z.useContext)(Xn)}var Qn=50;function $n({relation:e,workspaceId:t,direction:n,onRemove:r,removing:i}){let{open:a}=Ct(),o=Jn(),s=Zn(),c=n===`out`?e.to:e.from,l=e.document??null,u=l?fe(l).title:``,[d,f]=(0,Z.useState)(!1),{showErrorToast:p}=X(),m=async()=>{if(!(c==null||!l)){f(!0);try{let n=e.preview?await Pe(t,c):l;s?o.open(n,t):a(n,t)}catch(e){p(e instanceof Error?e.message:`Failed to open document`)}finally{f(!1)}}},h=!e.meta||e.meta.src===`doc`;return(0,Q.jsxs)(`div`,{className:`group flex items-center gap-2 rounded-md px-2 py-1.5 text-sm hover:bg-muted/60`,children:[n===`out`?(0,Q.jsx)(ae,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`}):(0,Q.jsx)(ee,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`}),l?(0,Q.jsx)(ht,{document:l,size:3.5}):null,l?(0,Q.jsx)(`button`,{type:`button`,onClick:()=>void m(),disabled:d,className:`min-w-0 flex-1 truncate text-left hover:underline`,title:u,children:u}):(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1 truncate italic text-muted-foreground`,children:[`Document `,c,` (not available)`]}),(0,Q.jsxs)(`span`,{className:`shrink-0 font-mono text-[10px] text-muted-foreground`,children:[`#`,c]}),!h&&(0,Q.jsx)(`span`,{className:`shrink-0 rounded-full bg-muted px-1.5 py-0.5 text-[10px] text-muted-foreground`,title:`Derived by ${e.meta?.src}`,children:e.meta?.src}),h&&(0,Q.jsx)(`button`,{type:`button`,onClick:r,disabled:i,className:`shrink-0 rounded p-1 text-muted-foreground opacity-0 transition-opacity hover:bg-destructive/10 hover:text-destructive group-hover:opacity-100 disabled:opacity-40`,title:`Remove relation`,"aria-label":`Remove relation`,children:(0,Q.jsx)(T,{className:`h-3.5 w-3.5`})})]})}function er({document:e,workspaceId:t}){let{showSuccessToast:n,showErrorToast:r}=X(),[i,a]=(0,Z.useState)(null),[o,s]=(0,Z.useState)(null),[c,l]=(0,Z.useState)(!1),[u,d]=(0,Z.useState)(!1),[f,p]=(0,Z.useState)(null),[m,h]=(0,Z.useState)(0),[g,_]=(0,Z.useState)(1),v=(0,Z.useRef)(0),y=(0,Z.useCallback)(()=>{v.current++},[]),x=(0,Z.useCallback)(async()=>{let n=++v.current;try{let r=await Te(t,e.id,{offset:m*Qn,limit:Qn,summary:!0});if(n!==v.current)return;let i=Math.max(0,Math.ceil(Math.max(r.outgoingCount??r.outgoing.length,r.incomingCount??r.incoming.length)/Qn)-1);if(_(i+1),m>i){h(i);return}a(r),s(null)}catch(e){if(n!==v.current)return;s(e instanceof Error?e.message:String(e))}},[t,e.id,m]),S=`${t}:${e.id}`,[C,w]=(0,Z.useState)(S);S!==C&&(w(S),a(null),s(null),h(0),_(1)),(0,Z.useEffect)(()=>{async function e(){await x()}return e(),window.addEventListener(ct,e),()=>{y(),window.removeEventListener(ct,e)}},[x,y]);let T=async(i,a)=>{let o=a===`out`?i.to:i.from;if(o==null)return;let s=`${a}:${i.p}:${o}`;p(s);try{await we(t,e.id,i.p,o,a),n(`Relation removed`),st()}catch(e){r(e instanceof Error?e.message:`Failed to remove relation`)}finally{p(null)}},E=[{dir:`out`,title:`Points at`,hint:`this document as the subject`,entries:i?.outgoing??[]},{dir:`in`,title:`Pointed at by`,hint:`this document as the object`,entries:i?.incoming??[]}],D=e=>{a(null),h(e)};return(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[(0,Q.jsx)(`h3`,{className:`font-semibold`,children:`Documents`}),(0,Q.jsxs)(K,{variant:`outline`,size:`sm`,onClick:()=>l(!0),children:[(0,Q.jsx)(b,{className:`mr-1 h-3 w-3`}),` Add relation`]})]}),o?(0,Q.jsx)(`p`,{className:`text-sm text-destructive`,children:o}):i?E.every(e=>e.entries.length===0)?(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No related documents.`}):(0,Q.jsx)(`div`,{className:`space-y-4`,children:E.filter(e=>e.entries.length>0).map(({dir:e,title:n,hint:r,entries:i})=>(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`mb-1 text-xs font-medium text-muted-foreground`,title:r,children:n}),Array.from(new Set(i.map(e=>e.p))).map(n=>(0,Q.jsxs)(`div`,{className:`mb-2`,children:[(0,Q.jsx)(`p`,{className:`px-2 font-mono text-[11px] text-muted-foreground`,children:n}),i.filter(e=>e.p===n).map(n=>{let r=e===`out`?n.to:n.from,i=`${e}:${n.p}:${r}`;return(0,Q.jsx)($n,{relation:n,workspaceId:t,direction:e,removing:f===i,onRemove:()=>void T(n,e)},i)})]},n))]},e))}):(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Loading relations…`}),(g>1||m>0)&&(0,Q.jsxs)(`div`,{className:`mt-3 flex items-center justify-between gap-2 text-xs text-muted-foreground`,children:[(0,Q.jsx)(K,{variant:`outline`,size:`sm`,disabled:m===0,onClick:()=>D(m-1),children:`Previous`}),(0,Q.jsxs)(`span`,{children:[`Page `,m+1,` of `,g]}),(0,Q.jsx)(K,{variant:`outline`,size:`sm`,disabled:!i||m+1>=g,onClick:()=>D(m+1),children:`Next`})]}),c&&(0,Q.jsx)(yt,{onClose:()=>{u||l(!1)},children:(0,Q.jsx)(de,{sizeClassName:`h-full w-[380px] max-w-[90vw] max-md:w-full`,title:`Relate to…`,tabs:[`relations`],fixedWorkspaceName:t,documentCount:1,saving:u,relationPredicates:i?.predicates,relationExcludeIds:new Set([e.id]),onClose:()=>l(!1),onConfirm:()=>{},onConfirmRelation:async({predicate:i,direction:a,targetIds:o})=>{d(!0);try{await Ee(t,e.id,i,o,a),n(`Related to ${o.length} document${o.length===1?``:`s`}`),l(!1),st()}catch(e){r(e instanceof Error?e.message:`Failed to create relation`)}finally{d(!1)}}})})]})}var tr=(0,Z.lazy)(()=>a(()=>import(`./TextDocumentEditor-rgHsbLCL.js`),__vite__mapDeps([2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,1,24]))),nr={reply:`Reply`,replyAll:`Reply all`,forward:`Forward`},rr={reply:u,replyAll:l,forward:d};function ir({document:e,workspaceId:t,initialEdit:n=!1,onChanged:r}){let i=Je()!=null,{showErrorToast:a,showSuccessToast:o}=X(),[c,l]=(0,Z.useState)(!1),u=e.data?.url||e.data?.uri,d=e.schema!==`data/schema/file`&&typeof u==`string`&&/^https?:\/\//i.test(u),[p,m]=(0,Z.useState)(!1),h=[`data/schema/message`,`data/schema/message/email`].includes(e.schema),[g,_]=(0,Z.useState)(null),v=e.schema===`data/schema/message/email`,y=!i&&(v||[`slack`,`whatsapp`].includes(String(e.data?.platform))),b=v?[`reply`,`replyAll`,`forward`]:[`reply`],x=e=>_(t=>t===e?null:e),S=!i,[C,w]=(0,Z.useState)(n&&!i),T=e.schema===be,[D,O]=(0,Z.useState)(!1),k=e.schema===`data/schema/note`||Ze(e),[A,j]=(0,Z.useState)(!1),M=`${t}:${e.id}:${n}:${i}`,[ee,N]=(0,Z.useState)(M);M!==ee&&(N(M),w(n&&!i),_(null),m(!1),O(!1),j(!1));let P=t=>{if(!S||!Hn(e)||t.defaultPrevented)return!1;let n=t.target;return n instanceof Element&&t.currentTarget.contains(n)&&!n.closest(`a, button, input, textarea, select, label, summary, audio, video, [role="button"], [role="checkbox"], [contenteditable]:not([contenteditable="false"])`)};return C&&S?(0,Q.jsx)(Gn,{document:e,workspaceId:t,onClose:e=>{w(!1),r?.(e)}}):(0,Q.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col gap-3`,children:[S&&(0,Q.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2`,children:[h&&(0,Q.jsx)(K,{size:`sm`,variant:p?`secondary`:`outline`,onClick:()=>m(!p),children:p?`Show message`:`View thread`}),y&&b.map(e=>{let t=rr[e];return(0,Q.jsxs)(K,{size:`sm`,variant:g===e?`secondary`:`outline`,onClick:()=>x(e),children:[(0,Q.jsx)(t,{className:`mr-1.5 h-3.5 w-3.5`}),nr[e]]},e)}),d&&(0,Q.jsxs)(K,{variant:`outline`,size:`sm`,disabled:c,onClick:async()=>{l(!0);try{await ye(t,e.id),window.dispatchEvent(new CustomEvent(`workspace:documents:refresh`)),r?.(),o(`File saved to workspace; the original link is preserved`)}catch(e){a(e instanceof Error?e.message:String(e))}finally{l(!1)}},children:[(0,Q.jsx)(U,{className:`mr-1 h-3 w-3`}),c?`Downloading…`:`Download to workspace`]}),e.schema===`data/schema/file`&&(0,Q.jsxs)(K,{variant:`outline`,size:`sm`,onClick:()=>ve(t,e.id,Y(e)||`document-${e.id}`).catch(e=>a(e instanceof Error?e.message:String(e))),children:[(0,Q.jsx)(U,{className:`mr-1 h-3 w-3`}),` Download`]}),T&&(0,Q.jsxs)(K,{variant:`outline`,size:`sm`,onClick:()=>O(!0),children:[(0,Q.jsx)(E,{className:`mr-1 h-3 w-3`}),` Edit sketch`]}),k&&(0,Q.jsxs)(K,{variant:`outline`,size:`sm`,onClick:()=>j(!0),children:[(0,Q.jsx)(f,{className:`mr-1 h-3 w-3`}),` Open editor`]}),(0,Q.jsxs)(K,{variant:`outline`,size:`sm`,onClick:()=>w(!0),children:[(0,Q.jsx)(s,{className:`mr-1 h-3 w-3`}),` Edit`]})]}),D&&S&&(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(`div`,{className:`fixed inset-0 z-fullscreen flex items-center justify-center bg-background surface-glass`,children:(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Loading sketch editor…`})}),children:(0,Q.jsx)(wt,{doc:e,workspaceName:t,onSaved:()=>{O(!1),r?.()},onClose:()=>O(!1),onDetails:()=>{O(!1),w(!0)}})}),A&&S&&(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(`div`,{className:`fixed inset-0 z-fullscreen flex items-center justify-center bg-background surface-glass`,children:(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Loading editor…`})}),children:(0,Q.jsx)(tr,{doc:e,workspaceName:t,onSaved:e=>{j(!1),r?.(e)},onClose:()=>j(!1),onDetails:()=>{j(!1),w(!0)}})}),(0,Q.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto`,onMouseDownCapture:e=>{e.button===0&&e.detail>1&&P(e)&&e.preventDefault()},onDoubleClickCapture:e=>{P(e)&&(e.preventDefault(),e.stopPropagation(),e.currentTarget.ownerDocument.getSelection()?.removeAllRanges(),w(!0))},children:[p&&!i?(0,Q.jsx)(An,{workspaceId:t,documentId:Number(e.id)},`${t}:${e.id}`):(0,Q.jsx)(kn,{workspaceId:t,document:e}),g&&y&&(0,Q.jsx)(vt,{workspaceId:t,replyToDocumentId:Number(e.id),mode:g,originalSubject:v&&typeof e.data?.subject==`string`?e.data.subject:void 0,onClose:()=>_(null)},`${e.id}:${g}`)]}),e.comment?.trim()&&(0,Q.jsxs)(`div`,{className:`shrink-0 rounded-md border border-border bg-muted/40 px-3 py-2`,children:[(0,Q.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground mb-0.5`,children:`Comment`}),(0,Q.jsx)(`p`,{className:`text-sm whitespace-pre-wrap`,children:e.comment})]})]})}var ar=e=>e?new Date(e).toLocaleDateString(`en-US`,{year:`numeric`,month:`long`,day:`numeric`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`}):`—`,or=e=>!Number.isFinite(e)||!e?null:e>=1?`${e}s`:`1/${Math.round(1/e)}s`;function sr({meta:e}){let{geo:t,exif:n,dimensions:r}=e;if(!t&&!n&&!r)return null;let i=(e,t)=>t==null||t===``?null:(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`span`,{className:`font-medium`,children:[e,`:`]}),(0,Q.jsx)(`span`,{className:`ml-2`,children:t})]});return(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h3`,{className:`font-semibold mb-3`,children:`Photo`}),(0,Q.jsxs)(`div`,{className:`grid gap-3 text-sm`,children:[r&&i(`Dimensions`,r.width&&r.height?`${r.width} × ${r.height}`:null),n&&i(`Camera`,[n.make,n.model].filter(Boolean).join(` `)),n&&i(`Lens`,n.lensModel),n&&i(`Aperture`,Number.isFinite(n.fNumber)?`ƒ/${n.fNumber}`:null),n&&i(`Shutter`,or(n.exposureTime)),n&&i(`ISO`,Number.isFinite(n.iso)?n.iso:null),n&&i(`Focal length`,Number.isFinite(n.focalLength)?`${n.focalLength} mm`:null),n&&i(`Captured`,ar(n.capturedAt)),t&&Number.isFinite(t.lat)&&Number.isFinite(t.lon)&&i(`Location`,(0,Q.jsxs)(`a`,{href:`https://www.openstreetmap.org/?mlat=${t.lat}&mlon=${t.lon}#map=15/${t.lat}/${t.lon}`,target:`_blank`,rel:`noopener noreferrer`,className:`text-primary underline underline-offset-2`,children:[t.lat.toFixed(5),`, `,t.lon.toFixed(5),Number.isFinite(t.alt)?` · ${Math.round(t.alt)} m`:``]}))]})]})}function cr({document:e}){let t=e.metadata;return(0,Q.jsxs)(`div`,{className:`space-y-6`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h3`,{className:`font-semibold mb-3`,children:`Basic Information`}),(0,Q.jsxs)(`div`,{className:`grid gap-3 text-sm`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`span`,{className:`font-medium`,children:`ID:`}),(0,Q.jsx)(`span`,{className:`ml-2 font-mono`,children:e.id})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`span`,{className:`font-medium`,children:`Schema:`}),(0,Q.jsx)(`span`,{className:`ml-2 font-mono`,children:e.schema})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`span`,{className:`font-medium`,children:`Schema Version:`}),(0,Q.jsx)(`span`,{className:`ml-2`,children:e.schemaVersion})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`span`,{className:`font-medium`,children:`Created:`}),(0,Q.jsx)(`span`,{className:`ml-2`,children:ar(e.createdAt)})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`span`,{className:`font-medium`,children:`Updated:`}),(0,Q.jsx)(`span`,{className:`ml-2`,children:ar(e.updatedAt)})]})]})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h3`,{className:`font-semibold mb-3`,children:`Metadata`}),(0,Q.jsxs)(`div`,{className:`grid gap-3 text-sm`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`span`,{className:`font-medium`,children:`Content Type:`}),(0,Q.jsx)(`span`,{className:`ml-2`,children:e.metadata?.contentType??`—`})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`span`,{className:`font-medium`,children:`Content Encoding:`}),(0,Q.jsx)(`span`,{className:`ml-2`,children:e.metadata?.contentEncoding??`—`})]}),Number.isFinite(e.metadata?.size)&&(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`span`,{className:`font-medium`,children:`Size:`}),(0,Q.jsxs)(`span`,{className:`ml-2`,children:[e.metadata?.size,` bytes`]})]})]})]}),(0,Q.jsx)(sr,{meta:t}),Array.isArray(e.locations)&&e.locations.length>0&&(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h3`,{className:`font-semibold mb-3`,children:`Locations`}),(0,Q.jsx)(`div`,{className:`space-y-2`,children:e.locations.map((e,t)=>{let{backend:n,key:r}=fr(e.url);return(0,Q.jsxs)(`div`,{className:`flex items-baseline gap-2 text-sm font-mono`,children:[(0,Q.jsx)(`span`,{className:`font-medium shrink-0`,children:n}),e.status&&e.status!==`available`&&(0,Q.jsx)(`span`,{className:`shrink-0 rounded border px-1 text-xs`,title:e.statusChangedAt,children:e.status===`deleted`?`Deleted`:`Not found`}),r&&(0,Q.jsx)(`span`,{className:`break-all text-muted-foreground`,children:r})]},t)})})]}),Array.isArray(e.checksumArray)&&e.checksumArray.length>0&&(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h3`,{className:`font-semibold mb-3`,children:`Checksums`}),(0,Q.jsx)(`div`,{className:`space-y-2`,children:e.checksumArray.map((e,t)=>{let[n,r]=e.split(`/`);return(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-mono`,children:[(0,Q.jsxs)(`span`,{className:`font-medium`,children:[n,`:`]}),(0,Q.jsx)(`span`,{className:`break-all text-muted-foreground`,children:r})]},t)})})]}),e.indexOptions&&(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h3`,{className:`font-semibold mb-3`,children:`Index Options`}),(0,Q.jsxs)(`div`,{className:`space-y-3 text-sm`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`span`,{className:`font-medium`,children:`FTS Search Fields:`}),(0,Q.jsx)(`div`,{className:`ml-2 mt-1`,children:(e.indexOptions.ftsSearchFields??[]).map((e,t)=>(0,Q.jsx)(`span`,{className:`mb-1 mr-2 inline-block rounded bg-muted px-2 py-1 text-xs`,children:e},t))})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`span`,{className:`font-medium`,children:`Vector Embedding Fields:`}),(0,Q.jsx)(`div`,{className:`ml-2 mt-1`,children:(e.indexOptions.vectorEmbeddingFields??[]).map((e,t)=>(0,Q.jsx)(`span`,{className:`mb-1 mr-2 inline-block rounded bg-muted px-2 py-1 text-xs`,children:e},t))})]})]})]})]})}function lr({document:e}){let{showSuccessToast:t,showErrorToast:n}=X(),r=JSON.stringify(e,null,2);return(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(`div`,{className:`flex justify-end`,children:(0,Q.jsxs)(K,{variant:`outline`,size:`sm`,onClick:async()=>{try{await navigator.clipboard.writeText(r),t(`Copied to clipboard`)}catch{n(`Copy failed`)}},children:[(0,Q.jsx)(S,{className:`mr-1 h-3 w-3`}),` Copy to clipboard`]})}),(0,Q.jsx)(`pre`,{className:`overflow-x-auto rounded-lg bg-muted p-4 text-xs`,children:r})]})}function ur({document:e,workspaceId:t}){let[n,r]=(0,Z.useState)(null),[i,a]=(0,Z.useState)(null),o=`${t}:${e.id}`,[s,c]=(0,Z.useState)(o);return o!==s&&(c(o),r(null),a(null)),(0,Z.useEffect)(()=>{let n=!1;return _e(t,e.id).then(e=>{n||r(e)}).catch(e=>{n||a(e instanceof Error?e.message:String(e))}),()=>{n=!0}},[o]),i?(0,Q.jsx)(`p`,{className:`text-sm text-destructive`,children:i}):n?(0,Q.jsxs)(`div`,{className:`space-y-6`,children:[[{title:`Context tree`,type:`context`},{title:`Directory tree`,type:`directory`}].map(({title:e,type:t})=>{let r=n.filter(e=>e.type===t),i=r.flatMap(e=>e.paths.map(t=>({tree:e.tree,path:t})));return(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h3`,{className:`mb-3 font-semibold`,children:e}),i.length===0?(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No placements.`}):(0,Q.jsx)(`div`,{className:`space-y-1`,children:i.map(({tree:e,path:t},n)=>(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-sm`,children:[(0,Q.jsx)(`span`,{className:`break-all font-mono text-xs`,children:t}),r.length>1&&(0,Q.jsxs)(`span`,{className:`shrink-0 text-xs text-muted-foreground`,children:[`(`,e,`)`]})]},`${e}:${t}:${n}`))})]},t)}),(0,Q.jsx)(er,{document:e,workspaceId:t})]}):(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Loading memberships...`})}function dr(e){return e===`stored`?k:e===`workspace-file`?o:e===`imap`?A:e===`readonly`?C:F}function fr(e){let t=e.match(/^([a-z][a-z0-9+.-]*):\/\/([^/]*)\/?(.*)$/i);return t?{backend:`${t[1]}://${t[2]}`,key:t[3]}:{backend:e,key:``}}function pr({document:e,workspaceId:t,onChanged:n}){let{showSuccessToast:r,showErrorToast:i}=X(),[a,o]=(0,Z.useState)(null),[s,c]=(0,Z.useState)(null),[l,u]=(0,Z.useState)(null),[d,f]=(0,Z.useState)(null),[p,m]=(0,Z.useState)(null),[h,g]=(0,Z.useState)(!1),_=`${t}:${e.id}`,[v,y]=(0,Z.useState)(_);_!==v&&(y(_),o(null),c(null),f(null));let b=()=>{je(t,e.id).then(o).catch(e=>c(e instanceof Error?e.message:String(e)))};(0,Z.useEffect)(()=>{let n=!1;return je(t,e.id).then(e=>{n||o(e)}).catch(e=>{n||c(e instanceof Error?e.message:String(e))}),()=>{n=!0}},[_]);let x=async(a,o)=>{u(a),f(null);try{let i=await me(t,[e.id],{urls:[a],...o===void 0?{}:{keepDocument:o}}),s=i.successful[0];if(!s)throw Error(i.failed[0]?.reason||`Destroy failed`);s.docDeleted?r(`Removed from backend; document removed from index`):s.deleted.includes(a)?r(`Removed from backend`):r(`Reference dropped (backend is read-only)`),window.dispatchEvent(new CustomEvent(`workspace:documents:refresh`)),n?.(),b()}catch(e){i(e instanceof Error?e.message:String(e))}finally{u(null)}},C=async(a,o,s)=>{g(!0);try{let i=await Ae(t,[e.id],{to:a,mode:o,keepDocument:s.keepDocument,folder:s.folder,filename:s.filename,onConflict:s.onConflict}),c=i.successful[0];if(!c)throw Error(jn(i.failed,new Map([[e.id,Y(e)||`Document ${e.id}`]]))||`Transfer failed`);let l=c.transfers?.flatMap(e=>e.state===`unchanged`?[]:[e.backend])??[],u=a.join(`, `);o===`delete`?r(`Deleted from ${u}`):l.length===0?r(`Nothing to do — already on ${u}`):r(`${o===`move`?`Moved to`:`Copied to`} ${l.join(`, `)}${c.transfers?.some(e=>e.state===`pending`)?` (pending sync)`:``}`),window.dispatchEvent(new CustomEvent(`workspace:documents:refresh`)),m(null),n?.(),b()}catch(e){i(e instanceof Error?e.message:String(e))}finally{g(!1)}},w=e=>{if((a?.length??0)<=1){f(e.url);return}window.confirm(`Remove this copy from the backend?\n\n${e.url}`)&&x(e.url)};if(s)return(0,Q.jsx)(`p`,{className:`text-sm text-destructive`,children:s});if(!a)return(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Loading locations...`});let E=a.length===0,D=Y(e);return(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2 rounded border px-3 py-2 text-sm`,children:[(0,Q.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-2`,children:[(0,Q.jsx)(k,{className:`h-4 w-4 shrink-0 text-muted-foreground`}),(0,Q.jsx)(`span`,{className:`font-mono text-xs`,children:`workspace:db`}),(0,Q.jsxs)(`span`,{className:`truncate text-xs text-muted-foreground`,children:[`index entry (id `,e.id,`)`]})]}),(0,Q.jsx)(`span`,{className:`shrink-0 rounded bg-muted px-1.5 py-0.5 text-[10px] uppercase text-muted-foreground`,children:`json`})]}),E?(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No byte locations; this object lives only in the workspace database, so there is no file data to copy or move.`}):(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsxs)(K,{variant:`outline`,size:`sm`,onClick:()=>m(`copy`),title:`Copy the file data to another storage backend (keeps the existing copies)`,children:[(0,Q.jsx)(S,{className:`mr-1 h-3.5 w-3.5`}),` Copy to…`]}),(0,Q.jsxs)(K,{variant:`outline`,size:`sm`,onClick:()=>m(`move`),title:`Move the file data to another storage backend (source released once the copy is durable)`,children:[(0,Q.jsx)(ae,{className:`mr-1 h-3.5 w-3.5`}),` Move to…`]})]}),a.map(n=>{let r=dr(n.kind),{backend:a,key:o}=fr(n.url),s=l===n.url;return(0,Q.jsxs)(`div`,{className:`space-y-2 rounded border px-3 py-2 text-sm`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Q.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-2`,children:[(0,Q.jsx)(r,{className:`h-4 w-4 shrink-0 text-muted-foreground`}),(0,Q.jsx)(`span`,{className:`shrink-0 font-mono text-xs`,children:n.backend||a}),(0,Q.jsx)(`span`,{className:`truncate font-mono text-xs text-muted-foreground`,title:n.url,children:o||n.url})]}),(0,Q.jsxs)(`span`,{className:`flex shrink-0 items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`rounded px-1.5 py-0.5 text-[10px] uppercase ${n.deletable?`bg-muted text-muted-foreground`:`bg-warning/15 text-warning`}`,children:n.deletable?n.kind:`read-only`}),(0,Q.jsx)(`button`,{onClick:()=>ve(t,e.id,D||`document-${e.id}`,{url:n.url}).catch(e=>i(e instanceof Error?e.message:String(e))),className:`text-muted-foreground hover:text-foreground`,title:`Download this copy`,children:(0,Q.jsx)(U,{className:`h-3.5 w-3.5`})}),(0,Q.jsx)(`button`,{onClick:()=>w(n),disabled:s,className:`text-muted-foreground hover:text-destructive disabled:opacity-50`,title:n.deletable?`Remove from backend`:`Drop reference (bytes stay; backend is read-only)`,children:(0,Q.jsx)(T,{className:`h-3.5 w-3.5`})})]})]}),d===n.url&&(0,Q.jsxs)(`div`,{className:`space-y-2 rounded border border-destructive/40 bg-destructive/5 p-2`,children:[(0,Q.jsxs)(`p`,{className:`text-xs`,children:[`This is the object's `,(0,Q.jsx)(`strong`,{children:`last`}),` location. Remove the bytes from the backend and…`]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Q.jsx)(K,{variant:`destructive`,size:`sm`,disabled:s,onClick:()=>void x(n.url,!1),children:`Also remove index entry`}),(0,Q.jsx)(K,{variant:`outline`,size:`sm`,disabled:s,onClick:()=>void x(n.url,!0),children:`Keep index entry (no bytes)`}),(0,Q.jsx)(K,{variant:`ghost`,size:`sm`,onClick:()=>f(null),children:`Cancel`})]})]})]},n.url)}),p&&(0,Mn.createPortal)((0,Q.jsx)(`div`,{className:`fixed inset-0 z-picker flex items-center justify-center bg-scrim p-4 max-md:p-2`,children:(0,Q.jsx)(Ln,{workspaceId:t,documentCount:1,initialMode:p,defaultFilename:D,saving:h,onConfirm:C,onClose:()=>{h||m(null)}})}),window.document.body)]})}var mr=(0,Z.lazy)(()=>a(()=>import(`./LocationTab-DAtqAQ3l.js`),__vite__mapDeps([25,3,4,26,27]))),hr=[{id:`view`,label:`View`,icon:N},{id:`location`,label:`Location`,icon:ie},{id:`metadata`,label:`Metadata`,icon:te},{id:`json`,label:`JSON`,icon:x},{id:`synapses`,label:`Synapses`,icon:ne},{id:`backends`,label:`Backends`,icon:k}];function gr({document:e,workspaceId:t,initialTab:n=`view`,initialEdit:r=!1,onChanged:i,className:a=``,compact:o=!1,navigation:s,tabActions:c,onTabChange:l}){let u=Je()!=null,d=Tt(e),f=hr.filter(e=>(e.id!==`location`||d!==null)&&(!u||![`synapses`,`backends`].includes(e.id))),[p,m]=(0,Z.useState)(n),h=`${e.id}:${n}`,[g,_]=(0,Z.useState)(h);h!==g&&(_(h),m(n));let v=f.some(e=>e.id===p)?p:`view`,y=e=>{m(e),l?.(e)},b=o&&!!c&&!s,x=(0,Q.jsx)(`div`,{className:G(b&&`document-detail-header shrink-0 border-b-[3px] bg-muted`),children:(0,Q.jsxs)(`div`,{className:G(`flex min-w-0 items-center`,b&&`mx-auto h-[calc(3rem-4px)] w-full max-w-[var(--document-reading-width,100%)] gap-1 pl-2 pr-2 sm:pl-4`),children:[(0,Q.jsx)(_t,{tabs:f,active:v,onChange:y,className:G(`min-w-0 flex-1 px-1`,b&&`h-full border-b-0 px-0 max-sm:gap-0 max-sm:[&>button]:px-2.5`),iconOnly:o}),c]})});return(0,Q.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col ${a}`,children:[s?(0,Q.jsx)(On,{...s,tabs:x,section:v,onDocument:()=>y(`view`),onSection:()=>y(`view`),onBack:v===`view`?s.onBack:()=>y(`view`)}):x,(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:(0,Q.jsxs)(`div`,{className:`mx-auto h-full w-full max-w-[var(--document-reading-width,100%)] p-4`,children:[v===`view`&&(0,Q.jsx)(ir,{document:e,workspaceId:t,initialEdit:r&&!u,onChanged:i}),v===`location`&&d&&(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Loading map…`}),children:(0,Q.jsx)(mr,{lat:d.lat,lon:d.lon})}),v===`metadata`&&(0,Q.jsx)(cr,{document:e,workspaceId:t}),v===`json`&&(0,Q.jsx)(lr,{document:e,workspaceId:t}),v===`synapses`&&!u&&(0,Q.jsx)(ur,{document:e,workspaceId:t}),v===`backends`&&!u&&(0,Q.jsx)(pr,{document:e,workspaceId:t,onChanged:i})]})})]})}export{en as _,Kn as a,Dt as b,Ln as c,Dn as d,wn as f,an as g,nn as h,Zn as i,jn as l,rn as m,Xn as n,Jn as o,tn as p,Yn as r,Bn as s,gr as t,On as u,Ut as v,Pt as y};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{
|
|
1
|
+
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{qn as r}from"./ui-76Hw0NU_.js";import{t as i}from"./utils-2pl1SbIp.js";import{t as a}from"./button-Bum-POPT.js";import{t as o}from"./input-BOtCd4HP.js";import{o as s,s as c,t as l}from"./LinkToCard-VXpoeMDH.js";import{n as u}from"./LinkToSidePanel-eCy3nW4R.js";var d=e(n(),1),f=t();function p({value:e,onChange:t,onPickTarget:n,fixedWorkspaceName:p,format:m=`url`,tabs:h=[`context`,`directory`],pickerTitle:g=`Pick a path…`,placeholder:_,id:v,disabled:y,className:b,inputClassName:x,presentation:S=`input`}){let[C,w]=(0,d.useState)(!1),T=e.match(/^(.*?):\/\//)?.[0]||``,E=T?e.slice(T.length):e;return(0,f.jsxs)(`div`,{className:i(`flex gap-2`,b),children:[S===`breadcrumbs`?(0,f.jsx)(c,{items:s(E,T.replace(`://`,``)||p||`Workspace`),onNavigate:e=>t(T?`${T}${e.replace(/^\/+/,``)}`:e),disabled:y,className:i(`rounded border px-1`,x)}):(0,f.jsx)(o,{id:v,value:e,onChange:e=>t(e.target.value),placeholder:_,disabled:y,className:i(`font-mono`,x)}),(0,f.jsx)(a,{type:`button`,variant:`outline`,size:`icon`,onClick:()=>w(!0),disabled:y,"aria-label":`Browse tree paths`,title:`Browse…`,className:`shrink-0`,children:(0,f.jsx)(r,{className:`h-4 w-4`})}),C&&(0,f.jsx)(u,{onClose:()=>w(!1),children:(0,f.jsx)(l,{sizeClassName:`h-full w-[380px] max-w-[90vw] max-md:w-full`,multiple:!1,tabs:h,fixedWorkspaceName:p,title:g,confirmLabel:`Use path`,onConfirm:(e,r)=>{w(!1);let i=e[0];if(i){if(n){n(i,r);return}t(m===`url`?`${r.workspaceName}://${i.replace(/^\/+/,``)}`:i)}},onClose:()=>w(!1)})})]})}export{p as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{yt as r}from"./react-BHzhHVTZ.js";import{g as i}from"./chunk-62JRHF6Z-vspAGgtK.js";import{L as a,Qt as o,Vr as s,an as c,cr as l,vn as u,wt as d}from"./ui-76Hw0NU_.js";import{t as f}from"./utils-2pl1SbIp.js";import{t as p}from"./button-Bum-POPT.js";import{_ as m,a as h,i as g,n as _,r as v,t as y}from"./LinkToCard-VXpoeMDH.js";import{Nt as b,Sn as x,g as S,zt as C}from"./workspace-46EFyEKZ.js";import{t as w}from"./use-mobile-Db-vWu9Y.js";import{c as T}from"./IdentityFields-CEDxU-Hd.js";import{n as E}from"./relation-events-CKio19hE.js";import{t as D}from"./useEscapeClose-DR_xKT_k.js";import{t as O}from"./useToastHelpers-CRrpIIdY.js";var k=e(n(),1);function A(e){let t=`/workspaces/${encodeURIComponent(e.workspaceName)}`,n=e.path.replace(/^\/+/,``).split(`/`).map(encodeURIComponent).join(`/`);return e.treeName===`context`?`${t}/path/${n}`:`${t}/trees/${encodeURIComponent(e.treeName)}/path/${n}`}var j=e(r(),1),M=t();function N({title:e,icon:t,onClose:n,onSave:r,navigateAfterSave:s=!1,canSave:l=!1,saving:m=!1,saveProgress:h,successMessage:g=`Saved`,lockedWorkspaceName:_,fillParent:v=!1,fullWidthContent:b=!1,relationSubjectId:x,frame:N,children:P,maximized:ee,onMaximizedChange:F}){let te=i(),[ne,re]=(0,k.useState)(`portrait`),[ie,ae]=(0,k.useState)(!1),I=ee??ie,L=e=>{ae(e),F?.(e)},[R,z]=(0,k.useState)(!1),[oe,B]=(0,k.useState)(!1),[se,V]=(0,k.useState)(!1),H=m||se;D(()=>z(!1),R&&!H),D(()=>L(!1),I&&!R);let U=(0,k.useRef)(null),W=w(),{showSuccessToast:G,showErrorToast:K}=O(),q=W&&!v&&!I,[ce,le]=(0,k.useState)(!1),J=!v&&!I&&!N&&!ce;(0,k.useEffect)(()=>{R&&U.current?.scrollIntoView({behavior:`smooth`,inline:`end`,block:`nearest`})},[R]);let ue=async(e,t)=>{if(!(!r||H)){V(!0);try{let i=await r({...t,path:e[0]}),a=e.slice(1);i.length&&a.length&&await Promise.all(a.map(e=>C(t.workspaceName,e,i,t.treeName,t.treeType))),G(g),n?.(),s&&te(A({...t,path:e[0]}),{replace:!0})}catch(e){K(e instanceof Error?e.message:`Failed to save`)}finally{V(!1)}}},Y=async e=>{if(!(!x||!_||e.targetIds.length===0)){B(!0);try{await S(_,x,e.predicate,e.targetIds,e.direction),G(`Created ${e.targetIds.length} relation${e.targetIds.length===1?``:`s`}`),E(),z(!1)}catch(e){K(e instanceof Error?e.message:`Failed to create relations`)}finally{B(!1)}}},de=I?R?{flex:`1 1 auto`,minWidth:0,height:`100%`}:{width:`100%`,height:`100%`}:v?{height:`100%`,flexShrink:0}:q?void 0:ne===`portrait`?{aspectRatio:`0.707 / 1`,height:`calc(var(--viewport-h) * 0.85)`,width:`auto`,maxWidth:`min(90vw, 100%)`,flexShrink:0}:{aspectRatio:`1 / 0.707`,width:`min(90vw, 900px)`,maxWidth:`100%`,height:`auto`,maxHeight:`calc(var(--viewport-h) * 0.85)`,flexShrink:0},X=!!(x&&_),Z=r&&R&&(0,M.jsx)(y,{onClose:()=>z(!1),onConfirm:ue,fixedWorkspaceName:_,saving:H||oe,savingContent:h,tabs:X?[`context`,`directory`,`relations`]:[`context`,`directory`],onConfirmRelation:X?Y:void 0,relationWorkspaceName:_,relationExcludeIds:X?new Set([x]):void 0,sizeClassName:N?`h-full max-h-full w-full min-w-0 rounded-none border-0 shadow-none`:v?`h-full max-h-full w-[min(380px,90vw)] max-md:h-full max-md:w-full max-md:shadow-elevation-5`:void 0}),Q=(0,M.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[!v&&(0,M.jsx)(`button`,{type:`button`,onClick:()=>re(e=>e===`portrait`?`landscape`:`portrait`),className:`rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground max-md:hidden touch-target`,"aria-label":`Toggle orientation`,title:`Toggle orientation`,children:(0,M.jsx)(d,{className:`h-4 w-4`})}),r&&(typeof P==`function`?(0,M.jsx)(`button`,{type:`button`,onClick:()=>z(!0),disabled:!l||H,className:`flex h-8 w-8 items-center justify-center rounded text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:opacity-40 touch-target`,"aria-label":H?`Saving…`:`Add relations / Link to…`,title:`Add relations / Link to…`,children:(0,M.jsx)(u,{className:`h-4 w-4`})}):(0,M.jsx)(p,{size:`sm`,variant:`outline`,onClick:()=>z(!0),disabled:!l||H,children:H?`Saving…`:`Save / Link to…`})),(0,M.jsx)(`button`,{type:`button`,onClick:()=>N&&!I?N.onToggleExpanded():L(!I),className:f(`rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,typeof P==`function`&&`flex h-8 w-8 items-center justify-center`,!I&&!N&&`max-md:hidden`),"aria-label":N&&!I?N.expanded?`Card size`:`Expand to full width`:I?`Restore`:`Maximize`,title:N&&!I?N.expanded?`Card size`:`Expand to full width`:I?`Restore`:`Maximize`,children:I||N?.expanded?(0,M.jsx)(o,{className:`h-4 w-4`}):(0,M.jsx)(c,{className:`h-4 w-4`})}),n&&(0,M.jsx)(`button`,{type:`button`,onClick:n,disabled:H,className:f(`rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:opacity-40 touch-target`,typeof P==`function`&&`flex h-8 w-8 items-center justify-center`),"aria-label":`Close`,children:(0,M.jsx)(a,{className:`h-4 w-4`})})]}),$=(0,M.jsxs)(`div`,{style:{...N&&!I?{width:`100%`,height:`100%`,minWidth:0}:de,"--document-reading-width":I&&!b?`48rem`:`100%`},onAnimationEnd:e=>{J&&e.target===e.currentTarget&&le(!0)},className:f(`flex flex-col overflow-hidden`,N&&!I?`strip-document-card`:`rounded-(--card-radius) border bg-card shadow-elevation-4 transition-[width,height]`,v&&!I&&!N&&`w-full`,q&&`fixed inset-2 z-40 shadow-elevation-5`,J&&`animate-card-in`),children:[typeof P!=`function`&&(0,M.jsxs)(`div`,{className:`flex h-12 shrink-0 items-center justify-between gap-2 border-b px-4`,children:[(0,M.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2 truncate text-sm font-medium`,children:[(0,M.jsx)(t,{className:`h-4 w-4 shrink-0`}),(0,M.jsx)(`span`,{className:`truncate`,children:e})]}),Q]}),(0,M.jsx)(T.Provider,{value:()=>L(!I),children:(0,M.jsx)(`div`,{className:f(`min-h-0 flex-1 overflow-y-auto`,I&&!b&&typeof P!=`function`&&`mx-auto w-full max-w-3xl`),children:N&&Z?Z:typeof P==`function`?P(Q):P})})]});return I?(0,j.createPortal)((0,M.jsxs)(`div`,{className:`fixed inset-0 z-picker flex items-center justify-center gap-4 bg-scrim p-4 max-md:p-2`,children:[$,Z&&(0,M.jsx)(`div`,{className:`flex max-md:absolute max-md:inset-2 max-md:z-10`,children:Z})]}),document.body):(0,M.jsxs)(M.Fragment,{children:[$,!N&&Z&&(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`div`,{className:`fixed inset-0 z-card bg-scrim animate-fade-in md:hidden`,onClick:()=>!H&&z(!1),"aria-hidden":!0}),(0,M.jsx)(`div`,{ref:U,className:`relative shrink-0 md:z-panel md:ml-2 md:pr-2 max-md:fixed max-md:bottom-2 max-md:left-2 max-md:right-2 max-md:top-2 max-md:z-card-overlay max-md:animate-fade-in`,children:Z})]})]})}function P({onClose:e,onConfirm:t,fixedWorkspaceName:n,saving:r=!1,sizeClassName:i}){let[o,c]=(0,k.useState)(n?`browse`:`workspace`),[u,d]=(0,k.useState)([]),[y,S]=(0,k.useState)(!n),[C,w]=(0,k.useState)(n??null),[T,E]=(0,k.useState)(`context`),[D,O]=(0,k.useState)(new Set),[A,j]=(0,k.useState)(n);return n!==A&&(j(n),n||S(!0)),(0,k.useEffect)(()=>{n||b().then(d).catch(()=>d([])).finally(()=>S(!1))},[n]),(0,M.jsxs)(`div`,{className:f(`flex flex-col overflow-hidden rounded-(--panel-radius) border bg-card shadow-elevation-4`,i||`h-viewport-card max-h-full w-[min(420px,90vw)] max-md:h-full max-md:w-full max-md:shadow-elevation-5`),children:[(0,M.jsxs)(`div`,{className:`flex h-12 shrink-0 items-center justify-between border-b px-4`,children:[(0,M.jsxs)(`span`,{className:`flex items-center gap-2 text-sm font-medium`,children:[(0,M.jsx)(l,{className:`h-4 w-4`}),o===`workspace`?`Add existing documents…`:`Pick documents…`]}),(0,M.jsx)(`button`,{type:`button`,onClick:e,disabled:r,className:`text-muted-foreground transition-colors hover:text-foreground disabled:opacity-40`,"aria-label":`Close`,children:(0,M.jsx)(a,{className:`h-4 w-4`})})]}),(0,M.jsx)(`div`,{className:`flex-1 overflow-hidden`,children:(0,M.jsxs)(`div`,{className:`grid h-full w-[200%] grid-cols-2 transition-transform duration-normal`,style:{transform:o===`workspace`?`translateX(0)`:`translateX(-50%)`},children:[(0,M.jsx)(`div`,{className:`flex min-w-0 flex-col overflow-y-auto p-2`,children:(0,M.jsx)(v,{workspaces:u,loading:y,onPick:e=>{w(e),O(new Set),c(`browse`)}})}),(0,M.jsxs)(`div`,{className:`flex min-w-0 flex-col overflow-hidden`,children:[(0,M.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1 border-b px-2 pt-2`,children:[!n&&(0,M.jsx)(`button`,{type:`button`,onClick:()=>c(`workspace`),className:`mr-1 rounded p-1.5 text-muted-foreground hover:bg-muted hover:text-foreground touch-target`,"aria-label":`Back to workspaces`,children:(0,M.jsx)(s,{className:`h-4 w-4 rotate-180`})}),[`context`,`directory`].map(e=>(0,M.jsxs)(`button`,{type:`button`,onClick:()=>{E(e),O(new Set)},className:f(`flex items-center gap-1.5 rounded-t-md border-b-2 px-3 py-2 text-xs font-medium transition-colors`,T===e?`border-primary text-foreground`:`border-transparent text-muted-foreground hover:text-foreground`),children:[g[e],h[e]]},e))]}),C&&(0,M.jsx)(_,{workspaceName:C,treeTab:T,onTreeTabChange:E,selectedDocIds:D,onToggleDoc:e=>{O(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},onNavigate:()=>O(new Set)})]})]})}),o===`browse`&&(0,M.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between border-t px-4 py-3`,children:[(0,M.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[D.size,` document`,D.size===1?``:`s`,` selected`]}),(0,M.jsx)(p,{size:`sm`,onClick:async()=>{!C||D.size===0||r||await t(Array.from(D),{workspaceName:C,treeName:T===`directory`?`directory`:x,treeType:T})},disabled:D.size===0||r,children:r?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(m,{className:`mr-1.5 h-3.5 w-3.5`}),`Adding…`]}):(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(l,{className:`mr-1 h-3.5 w-3.5`}),`Add`]})})]})]})}export{N as n,P as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{
|
|
1
|
+
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{Pt as r,X as i,Xr as a}from"./ui-76Hw0NU_.js";import{t as o}from"./button-Bum-POPT.js";import{Pn as s}from"./workspace-46EFyEKZ.js";import{t as c}from"./useDocumentThumbnail-Bs2Ju0eb.js";import{t as l}from"./useToastHelpers-CRrpIIdY.js";import{t as u}from"./sketch-lazy-BOFTGGTA.js";import{n as d}from"./use-applet-target-DmIdCxa_.js";import{n as f,r as p}from"./use-applet-docs-DBshA7yq.js";var m=e(n(),1),h=t();function g({doc:e,scope:t,onOpen:n,onRemove:r}){let{blobUrl:o,loading:s}=c(t.workspaceName,e.id,256,{version:e.checksumArray?.[0]??null}),l=String(e.data?.title??`Sketch`);return(0,h.jsxs)(`div`,{className:`group relative overflow-hidden rounded-(--card-radius) border bg-card shadow-elevation-2 transition-shadow hover:shadow-elevation-3`,children:[(0,h.jsxs)(`button`,{type:`button`,onClick:n,className:`block w-full text-left`,children:[(0,h.jsx)(`div`,{className:`flex aspect-[4/3] items-center justify-center overflow-hidden bg-muted/30`,children:o?(0,h.jsx)(`img`,{src:o,alt:l,className:`h-full w-full object-contain`}):(0,h.jsx)(a,{className:`h-6 w-6 text-muted-foreground ${s?`animate-pulse`:``}`})}),(0,h.jsxs)(`div`,{className:`px-2 py-1.5`,children:[(0,h.jsx)(`div`,{className:`truncate text-xs font-medium`,children:l}),(0,h.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:f(e.updatedAt||e.createdAt)})]})]}),(0,h.jsx)(`button`,{type:`button`,onClick:r,"aria-label":`Delete ${l}`,className:`absolute right-1.5 top-1.5 rounded-md bg-background/80 p-1 opacity-0 transition-opacity hover:text-destructive group-hover:opacity-100`,children:(0,h.jsx)(i,{className:`h-3.5 w-3.5`})})]})}function _({autoAdd:e}){let t=d(),{docs:n,loading:i,error:a,scope:c,reload:f,removeDoc:_}=p(t,s),[v,y]=(0,m.useState)(e?`new`:null),{showErrorToast:b}=l();return t?(0,h.jsxs)(`div`,{className:`flex flex-col gap-3 p-3`,children:[(0,h.jsxs)(o,{size:`sm`,variant:`outline`,className:`self-start`,onClick:()=>y(`new`),children:[(0,h.jsx)(r,{className:`mr-1.5 h-4 w-4`}),`New sketch`]}),a&&(0,h.jsx)(`p`,{className:`text-sm text-destructive`,children:a}),i&&!n.length&&(0,h.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Loading sketches…`}),!i&&!n.length&&!a&&(0,h.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No sketches here yet.`}),c&&n.length>0&&(0,h.jsx)(`div`,{className:`grid grid-cols-2 gap-2 sm:grid-cols-3 lg:grid-cols-4`,children:n.map(e=>(0,h.jsx)(g,{doc:e,scope:c,onOpen:()=>y(e),onRemove:()=>{confirm(`Delete "${String(e.data?.title??`Sketch`)}"?`)&&_(e.id).catch(e=>b(e instanceof Error?e.message:`Failed to delete sketch`))}},`${e.id}:${e.checksumArray?.[0]??``}`))}),v&&c&&(0,h.jsx)(m.Suspense,{fallback:(0,h.jsx)(`div`,{className:`fixed inset-0 z-fullscreen flex items-center justify-center bg-background surface-glass`,children:(0,h.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Loading sketch editor…`})}),children:(0,h.jsx)(u,{doc:v===`new`?null:v,workspaceName:c.workspaceName,target:t,onSaved:()=>{y(null),f()},onClose:()=>y(null)})}),v&&!c&&(0,h.jsx)(`div`,{className:`fixed inset-0 z-fullscreen flex items-center justify-center bg-background surface-glass`,children:(0,h.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Resolving destination…`})})]}):(0,h.jsx)(`p`,{className:`p-4 text-sm text-muted-foreground`,children:`Select a context or workspace path first.`})}export{_ as SketchApplet};
|