@augmentd-labs/canvas-web 2.26.34 → 2.26.36
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-CI650A38.js +2 -0
- package/dist/assets/{DocumentBodyEditor-DRFQgBNB.js → DocumentBodyEditor-CVO5KPCs.js} +1 -1
- package/dist/assets/{DocumentIcon-ByDAILhm.js → DocumentIcon-9i1uCMQa.js} +1 -1
- package/dist/assets/{EditorOverlay-DpQKmxkR.js → EditorOverlay-D5t3xg4w.js} +1 -1
- package/dist/assets/{FileForm-B6eFRKG-.js → FileForm-C35drQ_R.js} +1 -1
- package/dist/assets/{FiltersApplet-B3UrkkQk.js → FiltersApplet-Ia3RTHqt.js} +1 -1
- package/dist/assets/{HomeFab-D83jf0To.js → HomeFab-CXuEjvlA.js} +1 -1
- package/dist/assets/{IdentityFields-CEDxU-Hd.js → IdentityFields-DZRqtnIG.js} +1 -1
- package/dist/assets/{LensApplet-BvgmmKLC.js → LensApplet-DxqrTTvu.js} +1 -1
- package/dist/assets/{LinkToCard-VXpoeMDH.js → LinkToCard-BQ1yoFDr.js} +1 -1
- package/dist/assets/{MarkdownEditor-Dnyez7VT.js → MarkdownEditor-DbpRWbO6.js} +2 -2
- package/dist/assets/{MessageComposerDialog-BKGlI7jO.js → MessageComposerDialog-CdPp-3GR.js} +1 -1
- package/dist/assets/{NextShell-BvKyH2Oj.js → NextShell-BfQHKEKO.js} +1 -1
- package/dist/assets/{NotesApplet-BJwWkYe_.js → NotesApplet-ALnJx1R5.js} +1 -1
- package/dist/assets/{ObjectPropertiesCard-B9gkyowI.js → ObjectPropertiesCard-BTTwYnN9.js} +4 -4
- package/dist/assets/{PathPickerField-B58yeJGw.js → PathPickerField-B4yFUjgD.js} +1 -1
- package/dist/assets/{PickDocumentsCard-B72XNYh3.js → PickDocumentsCard-CFDQL70e.js} +1 -1
- package/dist/assets/{SketchApplet-BHee4eKG.js → SketchApplet-14xrogy3.js} +1 -1
- package/dist/assets/{SketchEditor-Knj-HA0P.js → SketchEditor-B2LYe_MO.js} +1 -1
- package/dist/assets/{TerminalApplet-Djk4l1Jm.js → TerminalApplet-BNeLmNFF.js} +1 -1
- package/dist/assets/{TextDocumentEditor-rgHsbLCL.js → TextDocumentEditor-CU5ersd_.js} +1 -1
- package/dist/assets/{TodosApplet-DZVcRHmh.js → TodosApplet-ASG9wXjL.js} +1 -1
- package/dist/assets/{TodosWidget-DdN3vJfS.js → TodosWidget-CYK5RbYD.js} +1 -1
- package/dist/assets/{UploadProgressList-CHQ-Kn-e.js → UploadProgressList-Ci1akl_D.js} +1 -1
- package/dist/assets/{_agentId_-Ctolhe8r.js → _agentId_-DiuSEd4O.js} +0 -0
- package/dist/assets/{_contextId_-Cj78rDep.js → _contextId_-Bovrvd2T.js} +1 -1
- package/dist/assets/{_workspaceName_-CU9Y7Zvt.js → _workspaceName_-DXYHTbna.js} +1 -1
- package/dist/assets/{about-OY_bpfUf.js → about-CIz-eZ-8.js} +1 -1
- package/dist/assets/{add-D7ysLgO3.js → add-Cf7qavr8.js} +1 -1
- package/dist/assets/{agents-DEJU4O1Z.js → agents-DxqAi3vk.js} +1 -1
- package/dist/assets/{agents-DgJX7Rbh.js → agents-t82sp0lw.js} +1 -1
- package/dist/assets/{alert-dialog-CShuAcnP.js → alert-dialog-CFeuDt0T.js} +1 -1
- package/dist/assets/{api-tokens-CmHhwd58.js → api-tokens-drrVuCYc.js} +1 -1
- package/dist/assets/{appearance-D3YShC7g.js → appearance-Ba1GYZ_J.js} +1 -1
- package/dist/assets/{applet-target-Bl9Je1N-.js → applet-target-I8w6EPj0.js} +1 -1
- package/dist/assets/{apps-CJ5g43ts.js → apps-uPsYOOCl.js} +1 -1
- package/dist/assets/{auth-_bmIEN02.js → auth-PqttD05H.js} +1 -1
- package/dist/assets/backend-sync-progress-tUU2XWtW.js +7 -0
- package/dist/assets/{button-Bum-POPT.js → button-SeUZ_Pvi.js} +1 -1
- package/dist/assets/{content-app-view-CH0wMWqu.js → content-app-view-DfmmWQ_z.js} +1 -1
- package/dist/assets/{context-BGgz0Y_q.js → context-DZ1Hn7tt.js} +1 -1
- package/dist/assets/{contexts-Dtl9oERX.js → contexts-DDJagU4j.js} +1 -1
- package/dist/assets/{contexts-CwGdjtXy2.js → contexts-Df-cWUlj2.js} +1 -1
- package/dist/assets/date-time-picker-txVhlNO0.js +1 -0
- package/dist/assets/{devices-CmVlYbam.js → devices-BwU9M8-W.js} +1 -1
- package/dist/assets/{document-CdrNjy0Z.js → document-CTvT2Qa5.js} +1 -1
- package/dist/assets/document-list-CQ1_7Sja.js +2 -0
- package/dist/assets/{embedding-2EjzoVFT.js → embedding-BvXcVfij.js} +1 -1
- package/dist/assets/{embedding-BqI3l5RB.js → embedding-D-I_ygUZ.js} +1 -1
- package/dist/assets/{form-panel-DZj3WZ3z.js → form-panel-3p-ncEVK.js} +1 -1
- package/dist/assets/{home-BYUM64nU.js → home-CsrwkvZX.js} +1 -1
- package/dist/assets/index-C51Jk0Xq.css +2 -0
- package/dist/assets/index-DRHEGJ8I.js +16 -0
- package/dist/assets/{inferd-config-editor-CyDCQJRs.js → inferd-config-editor-B8x_XPOt.js} +1 -1
- package/dist/assets/{key-bindings-BhC3zpgE.js → key-bindings-CnvBrNMZ.js} +1 -1
- package/dist/assets/{label-DJc8-3CQ.js → label-BSTdjCWU.js} +1 -1
- package/dist/assets/{lazy-editor-Bdm5JEXv.js → lazy-editor-BUFAkTGl.js} +2 -2
- package/dist/assets/{logs-DUeiDqCX.js → logs-DjG8_wJ2.js} +1 -1
- package/dist/assets/{offline-yfQ63Zr7.js → offline-sNCjxnp-.js} +1 -1
- package/dist/assets/{page-header-BoCaZiqu.js → page-header-DrDt1sQ2.js} +1 -1
- package/dist/assets/{public-share-D2S8DEsv.js → public-share-D5yz-Pmo.js} +1 -1
- package/dist/assets/{query-debug-CZacGe0M.js → query-debug-CQ0I3cXX.js} +1 -1
- package/dist/assets/registry-9MElXU-U.js +2 -0
- package/dist/assets/{remotes-BjjlqN_M.js → remotes-RPGcw6fH.js} +1 -1
- package/dist/assets/{roles-CuqCEPC7.js → roles-DoR2drD1.js} +1 -1
- package/dist/assets/{roles-BHJYWaBs.js → roles-p2cRajz-.js} +1 -1
- package/dist/assets/{settings-_xaqx07q.js → settings-B9-XHGdl.js} +1 -1
- package/dist/assets/{settings-e2lvFtNs.js → settings-CUxtVfMx.js} +1 -1
- package/dist/assets/{settings-j7fHuCH-.js → settings-Dkb35vRa.js} +1 -1
- package/dist/assets/settings-DxEF5yL8.js +16 -0
- package/dist/assets/{share-target-BNWYelcQ.js → share-target-DJICHfZZ.js} +1 -1
- package/dist/assets/{shared-C-uHNNY8.js → shared-BnpwVpxG.js} +1 -1
- package/dist/assets/{shared-td0TEahe.js → shared-DmdHUnl7.js} +1 -1
- package/dist/assets/sketch-lazy-BbNgGbR3.js +2 -0
- package/dist/assets/{subtree-transfer-dialog-BN9xBB9n.js → subtree-transfer-dialog-DQM5zfx2.js} +1 -1
- package/dist/assets/{text-documents-CFW8MWES.js → text-documents-BaXhu3ra.js} +1 -1
- package/dist/assets/ui-CDoK3F3U.js +41 -0
- package/dist/assets/{use-applet-docs-DBshA7yq.js → use-applet-docs-B2dk__vk.js} +1 -1
- package/dist/assets/{use-applet-target-DmIdCxa_.js → use-applet-target-ffIGaAqT.js} +1 -1
- package/dist/assets/{use-canvas-pins-BfT9xMi5.js → use-canvas-pins-DkWN9oEd.js} +1 -1
- package/dist/assets/{use-menu-CaiLyPdw.js → use-menu-DIP1zh7I.js} +1 -1
- package/dist/assets/use-settings-back-DGmLAD63.js +1 -0
- package/dist/assets/{use-sortable-data-W2inLcb5.js → use-sortable-data-BBKmqs79.js} +1 -1
- package/dist/assets/{use-workspace-identity-KxY9injc.js → use-workspace-identity-B8gOMGj4.js} +1 -1
- package/dist/assets/{useAddTarget-D4ra50Am.js → useAddTarget-B3b6TyZr.js} +1 -1
- package/dist/assets/{useAgentModels-C9Qu2rhq.js → useAgentModels-BjT4oN4e.js} +1 -1
- package/dist/assets/{useDocumentThumbnail-Bs2Ju0eb.js → useDocumentThumbnail-wW0lSOEy.js} +1 -1
- package/dist/assets/{useEditNoteFields-CKYMBf8V.js → useEditNoteFields-DXLTFEqL.js} +1 -1
- package/dist/assets/{users-DInwKAxz.js → users-DuVk-TEd.js} +1 -1
- package/dist/assets/{workspace-46EFyEKZ.js → workspace-BJELPCNs.js} +1 -1
- package/dist/assets/{workspace-area-menu-DEyR7-bZ.js → workspace-area-menu-BFw2yUHk.js} +1 -1
- package/dist/assets/{workspace-content-gate-CGZmT2kw.js → workspace-content-gate-NLuRPvbm.js} +1 -1
- package/dist/assets/{workspace-import-form-Bu1nlv8u.js → workspace-import-form-Bb6z42nw.js} +1 -1
- package/dist/assets/{workspaces-p959p9BR.js → workspaces-CqHYstZv.js} +1 -1
- package/dist/assets/{workspaces-BryjR7k9.js → workspaces-DpVuDD1E.js} +1 -1
- package/dist/index.html +36 -36
- package/dist/sw.js +1 -1
- package/package.json +2 -2
- package/dist/assets/CalendarApplet-CVcB6nT5.js +0 -1
- package/dist/assets/backend-sync-progress-BJsLP7o5.js +0 -7
- package/dist/assets/date-time-picker-Bzu8H_Oa.js +0 -1
- package/dist/assets/document-list-BX13fcRu.js +0 -2
- package/dist/assets/index-CJapDuPp.js +0 -16
- package/dist/assets/index-lwdPSalm.css +0 -2
- package/dist/assets/registry-C7aVPPMW.js +0 -2
- package/dist/assets/settings-HUPOeACw.js +0 -16
- package/dist/assets/sketch-lazy-BOFTGGTA.js +0 -2
- package/dist/assets/ui-76Hw0NU_.js +0 -41
- package/dist/assets/use-settings-back-DE0SPb7h.js +0 -1
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{g as r,r as i}from"./chunk-62JRHF6Z-vspAGgtK.js";import{Fr as a,Hr as o,Jr as s,L as c,Ot as l,Pt as u,Vr as d,X as f,ct as p,et as m,fr as h,jr as g,mr as _,pn as v,qr as y,vn as b}from"./ui-CDoK3F3U.js";import{t as x}from"./utils-2pl1SbIp.js";import{h as S}from"./LinkToCard-BQ1yoFDr.js";import{Hn as C,In as w,St as T,jt as E,rt as D,vn as O,w as k,wn as A}from"./workspace-BJELPCNs.js";import{o as ee,t as j}from"./useAddTarget-B3b6TyZr.js";import{a as M,o as N}from"./context-DZ1Hn7tt.js";import{n as P,o as F,s as I,t as L}from"./date-time-picker-txVhlNO0.js";import{n as te}from"./use-applet-target-ffIGaAqT.js";import{y as R}from"./index-DRHEGJ8I.js";import{r as ne,t as re}from"./shared-BnpwVpxG.js";var z=e(n(),1),ie=864e5,ae=[`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`,`Sun`];function B(e){return String(e).padStart(2,`0`)}function V(e){return`${e.getFullYear()}-${B(e.getMonth()+1)}-${B(e.getDate())}`}function H(e){let[t,n,r]=e.split(`-`).map(Number);return new Date(t,n-1,r)}function oe(e){return`${V(e)}T${B(e.getHours())}:${B(e.getMinutes())}`}function U(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate())}function W(e,t){return new Date(e.getFullYear(),e.getMonth(),e.getDate()+t,e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds())}function se(e,t){return new Date(e.getFullYear(),e.getMonth()+t,1)}function ce(e){let t=U(e);return W(t,-((t.getDay()+6)%7))}function le(e){return new Date(e.getFullYear(),e.getMonth(),1)}function G(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function K(e){let t=ce(le(e));return Array.from({length:42},(e,n)=>W(t,n))}function q(e,t){let n=[],r=t.getTime()>e.getTime()?new Date(t.getTime()-1):e;for(let t=U(e);t.getTime()<=r.getTime();t=W(t,1))n.push(t);return n}function J(e,t){let n=e.getTime()-U(t).getTime();return Math.max(0,Math.min(ie,n))/6e4}var ue=new Intl.DateTimeFormat(void 0,{month:`long`,year:`numeric`}),Y=new Intl.DateTimeFormat(void 0,{month:`short`}),de=new Intl.DateTimeFormat(void 0,{weekday:`long`,day:`numeric`,month:`long`,year:`numeric`}),X=new Intl.DateTimeFormat(void 0,{weekday:`short`,day:`numeric`,month:`short`}),fe=new Intl.DateTimeFormat(void 0,{hour:`numeric`,minute:`2-digit`});function pe(e){return ue.format(e)}function me(e){return Y.format(e)}function he(e){return de.format(e)}function ge(e){return X.format(e)}function Z(e){return fe.format(e)}function _e(e,t){return G(e,t)?he(e):e.getFullYear()===t.getFullYear()?e.getMonth()===t.getMonth()?`${e.getDate()} – ${t.getDate()} ${Y.format(e)} ${e.getFullYear()}`:`${e.getDate()} ${Y.format(e)} – ${t.getDate()} ${Y.format(t)} ${t.getFullYear()}`:`${e.getDate()} ${Y.format(e)} ${e.getFullYear()} – ${t.getDate()} ${Y.format(t)} ${t.getFullYear()}`}function ve(e){return _e(e,W(e,6))}function ye(e){return fe.format(new Date(2e3,0,1,e,0)).replace(/:00(?=\s|$)/,``)}var be={SU:0,MO:1,TU:2,WE:3,TH:4,FR:5,SA:6},xe=new Set([`FREQ`,`INTERVAL`,`COUNT`,`UNTIL`,`BYDAY`,`BYMONTHDAY`,`BYMONTH`,`WKST`]);function Se(e){let t={};for(let n of e.replace(/^RRULE:/i,``).split(`;`)){let e=n.trim();if(!e)continue;let r=e.indexOf(`=`);if(r<1)return null;t[e.slice(0,r).toUpperCase()]=e.slice(r+1).toUpperCase()}if(Object.keys(t).some(e=>!xe.has(e)))return null;let n=t.FREQ;if(n!==`DAILY`&&n!==`WEEKLY`&&n!==`MONTHLY`&&n!==`YEARLY`)return null;let r=t.INTERVAL?Number(t.INTERVAL):1;if(!Number.isInteger(r)||r<1)return null;let i=t.COUNT?Number(t.COUNT):null;if(i!==null&&(!Number.isInteger(i)||i<1))return null;let a=null;if(t.UNTIL){let e=/^(\d{4})(\d{2})(\d{2})(?:T(\d{2})(\d{2})(\d{2})(Z?))?$/.exec(t.UNTIL);if(!e)return null;let[,n,r,i,o,s,c,l]=e;if(a=o===void 0?new Date(Number(n),Number(r)-1,Number(i),23,59,59,999):l?new Date(Date.UTC(Number(n),Number(r)-1,Number(i),Number(o),Number(s),Number(c))):new Date(Number(n),Number(r)-1,Number(i),Number(o),Number(s),Number(c)),Number.isNaN(a.getTime()))return null}let o=[];if(t.BYDAY)for(let e of t.BYDAY.split(`,`)){let t=/^([+-]?\d{1,2})?(SU|MO|TU|WE|TH|FR|SA)$/.exec(e.trim());if(!t)return null;o.push({day:be[t[2]],ordinal:t[1]?Number(t[1]):null})}let s=t.BYMONTHDAY?t.BYMONTHDAY.split(`,`).map(Number):[];if(s.some(e=>!Number.isInteger(e)||e===0||e<-31||e>31))return null;let c=t.BYMONTH?t.BYMONTH.split(`,`).map(Number):[];return c.some(e=>!Number.isInteger(e)||e<1||e>12)||o.some(e=>e.ordinal!==null)&&n!==`MONTHLY`&&n!==`YEARLY`?null:{freq:n,interval:r,count:i,until:a,byDay:o,byMonthDay:s,byMonth:c}}function Ce(e,t){return new Date(e.getFullYear(),e.getMonth(),e.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds())}function we(e,t){return new Date(e,t+1,0).getDate()}function Te(e,t,n,r){let i=we(e,t),a=new Set;if(n.byMonthDay.length)for(let e of n.byMonthDay){let t=e>0?e:i+1+e;t>=1&&t<=i&&a.add(t)}if(n.byDay.length){let r=new Set;for(let{day:a,ordinal:o}of n.byDay){let n=[];for(let r=1;r<=i;r++)new Date(e,t,r).getDay()===a&&n.push(r);if(o===null)n.forEach(e=>r.add(e));else{let e=o>0?n[o-1]:n[n.length+o];e&&r.add(e)}}if(n.byMonthDay.length)for(let e of[...a])r.has(e)||a.delete(e);else r.forEach(e=>a.add(e))}return!n.byMonthDay.length&&!n.byDay.length&&r.getDate()<=i&&a.add(r.getDate()),[...a].sort((e,t)=>e-t).map(n=>Ce(new Date(e,t,n),r))}function Ee(e,t,n,r,i=0,a=5e3){let o=[],s=n.getTime()-Math.max(0,i),c=r.getTime(),l=0,u=t=>{let n=t.getTime();return e.until&&n>e.until.getTime()||(l++,n>=s&&n<c&&o.push(t),e.count!==null&&l>=e.count)?!1:l<a};if(!u(t))return o;let d=t.getTime();if(e.freq===`DAILY`){for(let n=e.interval,r=0;r<a*12;n+=e.interval,r++){let r=Ce(new Date(t.getFullYear(),t.getMonth(),t.getDate()+n),t);if(r.getTime()>=c&&e.count===null||!(e.byMonth.length&&!e.byMonth.includes(r.getMonth()+1))&&!u(r))break}return o}if(e.freq===`WEEKLY`){let n=e.byDay.length?[...new Set(e.byDay.map(e=>e.day))]:[t.getDay()],r=new Date(t.getFullYear(),t.getMonth(),t.getDate()-(t.getDay()+6)%7);for(let i=0;;i+=e.interval){let a=new Date(r.getFullYear(),r.getMonth(),r.getDate()+i*7);if(a.getTime()>=c+6048e5&&e.count===null)break;let o=!1;for(let e=0;e<7;e++){let r=new Date(a.getFullYear(),a.getMonth(),a.getDate()+e);if(!n.includes(r.getDay()))continue;let i=Ce(r,t);if(!(i.getTime()<=d)&&!u(i)){o=!0;break}}if(o)break}return o}let f=e.freq===`MONTHLY`?e.interval:12*e.interval;for(let n=0;;n+=f){let r=t.getFullYear()+Math.floor((t.getMonth()+n)/12),i=(t.getMonth()+n)%12;if(new Date(r,i,1).getTime()>=c&&e.count===null)break;if(e.freq===`YEARLY`&&e.byMonth.length&&!e.byMonth.includes(i+1)){let n=!1;for(let i of e.byMonth){for(let a of Te(r,i-1,e,t))if(!(a.getTime()<=d)&&!u(a)){n=!0;break}if(n)break}if(n)break;continue}if(e.freq===`MONTHLY`&&e.byMonth.length&&!e.byMonth.includes(i+1))continue;let a=!1;for(let n of Te(r,i,e,t))if(!(n.getTime()<=d)&&!u(n)){a=!0;break}if(a||n>4800)break}return o}function De(e){let t={DAILY:`day`,WEEKLY:`week`,MONTHLY:`month`,YEARLY:`year`}[e.freq],n=e.interval===1?`Every ${t}`:`Every ${e.interval} ${t}s`,r=[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`];return e.byDay.length?n+=` on `+e.byDay.map(({day:e,ordinal:t})=>t===null?r[e]:`${t===-1?`last`:`${t}.`} ${r[e]}`).join(`, `):e.byMonthDay.length&&(n+=` on day `+e.byMonthDay.join(`, `)),e.count!==null&&(n+=`, ${e.count} times`),e.until&&(n+=` until ${e.until.toLocaleDateString(void 0,{day:`numeric`,month:`short`,year:`numeric`})}`),n}function Oe(e){if(!e)return`none`;let t=Se(e);return!t||t.interval!==1||t.byMonthDay.length||t.byMonth.length?`custom`:t.freq===`WEEKLY`&&t.byDay.length===5&&t.byDay.every(e=>e.ordinal===null&&e.day>=1&&e.day<=5)?`weekdays`:t.byDay.length?`custom`:{DAILY:`daily`,WEEKLY:`weekly`,MONTHLY:`monthly`,YEARLY:`yearly`}[t.freq]}function ke(e,t){let n={daily:`FREQ=DAILY`,weekly:`FREQ=WEEKLY`,monthly:`FREQ=MONTHLY`,yearly:`FREQ=YEARLY`,weekdays:`FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR`}[e];if(n)return t?.until?`${n};UNTIL=${t.until.replace(/-/g,``)}`:t?.count?`${n};COUNT=${t.count}`:n}function Ae(e){let t=e?Se(e):null;if(!t)return{until:``,count:null};let n=t.until,r=e=>String(e).padStart(2,`0`);return{until:n?`${n.getFullYear()}-${r(n.getMonth()+1)}-${r(n.getDate())}`:``,count:t.count}}var je=`tasks`,Me=`data/schema/event`,Ne=`data/schema/task`;function Pe(e){if(typeof e!=`string`||!e)return null;let t=new Date(e);return Number.isNaN(t.getTime())?null:t}function Fe(e){return new Date(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate())}function Ie(e){return e.schema.startsWith(Me)}function Le(e){return e.schema===Ne}function Re(e,t,n){let r=e.data??{};if(Le(e)){let i=Pe(r.dueDate);if(!i||i<t||i>=n)return[];let a=String(r.status??`pending`);return[{key:`${e.id}@${i.getTime()}`,doc:e,kind:`task`,title:String(r.title??`Untitled`),start:i,end:i,allDay:!1,calendar:je,recurring:!1,unsupportedRule:!1,done:a===`completed`||a===`cancelled`}]}if(!Ie(e))return[];let i=Pe(r.start);if(!i)return[];let a=r.allDay===!0,o=r.end===null?null:Pe(r.end),s=a?Fe(i):i,c=a?o?Fe(o):W(s,1):o??(r.end===null?n:s),l=Math.max(0,c.getTime()-s.getTime()),u={doc:e,kind:`event`,title:String(r.title??`Untitled`),allDay:a,calendar:typeof r.calendar==`string`?r.calendar:``,done:!1},d=typeof r.recurrence==`string`?r.recurrence:``;if(!d)return c.getTime()<=t.getTime()&&!(c.getTime()===s.getTime()&&s>=t)||s>=n?[]:[{...u,key:`${e.id}@${s.getTime()}`,start:s,end:c,recurring:!1,unsupportedRule:!1}];let f=Se(d);return f?Ee(f,s,t,n,l).map(t=>({...u,key:`${e.id}@${t.getTime()}`,start:t,end:new Date(t.getTime()+l),recurring:!0,unsupportedRule:!1})):c<=t||s>=n?[]:[{...u,key:`${e.id}@${s.getTime()}`,start:s,end:c,recurring:!0,unsupportedRule:!0}]}function ze(e,t,n){return e.flatMap(e=>Re(e,t,n)).sort((e,t)=>e.start.getTime()-t.start.getTime()||t.end.getTime()-e.end.getTime()||e.title.localeCompare(t.title))}function Be(e){let t=new Map;for(let n of e)for(let e of q(n.start,n.end)){let r=`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`,i=t.get(r);i?i.push(n):t.set(r,[n])}return t}function Ve(e){return e.allDay||e.end.getTime()-e.start.getTime()>=864e5||!G(e.start,new Date(e.end.getTime()-1))&&e.end.getTime()>e.start.getTime()}function He(e,t,n=30){let r=U(e),i=t.filter(e=>!Ve(e)).map(e=>{let t=J(e.start,r),i=Math.max(n,J(e.end,r)-t);return{occurrence:e,top:t,height:Math.min(i,1440-t),column:0,columns:1}}).sort((e,t)=>e.top-t.top||t.height-e.height),a=[],o=-1,s=()=>{let e=[];for(let t of a){let n=e.findIndex(e=>e<=t.top);n<0&&(n=e.length,e.push(0)),e[n]=t.top+t.height,t.column=n}for(let t of a)t.columns=e.length;a=[]};for(let e of i)a.length&&e.top>=o&&s(),a.push(e),o=Math.max(o,e.top+e.height);return a.length&&s(),i}function Ue(e,t,n,r){if(t.kind===`task`)return{...e,dueDate:n.toISOString()};if(t.allDay)return{...e,start:`${V(n)}T00:00:00.000Z`,end:`${V(r)}T00:00:00.000Z`};let i={...e,start:n.toISOString()};return e.end===null||(r.getTime()>n.getTime()?i.end=r.toISOString():delete i.end),i}var We=[{id:`day`,label:`Day`,key:`d`},{id:`week`,label:`Week`,key:`w`},{id:`month`,label:`Month`,key:`m`},{id:`year`,label:`Year`,key:`y`},{id:`schedule`,label:`Schedule`,key:`s`}],Ge={view:`week`,hidden:[],showTasks:!0,defaultCalendar:`Personal`},Ke=`canvas:calendar:prefs`;function qe(e){return`${Ke}:${e??`global`}`}function Je(e){try{let t=JSON.parse(localStorage.getItem(qe(e))||`null`);if(!t||typeof t!=`object`)return Ge;let n=t;return{view:We.some(e=>e.id===n.view)?n.view:Ge.view,hidden:Array.isArray(n.hidden)?n.hidden.filter(e=>typeof e==`string`):[],showTasks:n.showTasks!==!1,defaultCalendar:typeof n.defaultCalendar==`string`&&n.defaultCalendar.trim()?n.defaultCalendar:Ge.defaultCalendar}}catch{return Ge}}function Ye(e,t){try{localStorage.setItem(qe(e),JSON.stringify(t))}catch{}}function Xe(e,t){let n=V(W(U(e),-1)),r=V(W(U(t),1));return{events:`t:events:${n}..${r}`,tasks:`t:tasks:${n}..${r}`}}var Ze=5e3;function Qe(e){return!!e&&!e.includes(`:`)&&![`content`,`events`,`tasks`].includes(e.toLowerCase())}function $e(e){return e?e.mode===`context`?`ctx:${e.contextId}`:`${e.workspaceName}:${e.treeName}:${e.treeType}:${e.path}`:``}function et(e,t,n,r){let[i,a]=(0,z.useState)([]),[o,s]=(0,z.useState)(!1),[c,l]=(0,z.useState)(null),[u,d]=(0,z.useState)(null),[f,p]=(0,z.useState)([]),m=t.getTime(),h=n.getTime(),g=(0,z.useCallback)(()=>{if(!e)return Promise.resolve();let t=Xe(new Date(m),new Date(h));return(e.mode===`context`?Promise.all([N(e.contextId,[w],[t.events],{limit:Ze}),r?N(e.contextId,[C],[t.tasks],{limit:Ze}):Promise.resolve([]),M(e.contextId)]).then(([e,t,n])=>{a([...e,...t]);let r=n.workspaceName||n.workspaceId;d(r?{workspaceName:r,path:n.path||`/`,treeName:n.treeId||`context`,treeType:`context`}:null)}):(()=>{let{workspaceName:n,path:i,treeName:o,treeType:s}=e,c={treeName:o,treeType:s,limit:0};return Promise.all([D(n,i,[w],{...c,filters:[t.events]}),r?D(n,i,[C],{...c,filters:[t.tasks]}):Promise.resolve({payload:[]})]).then(([e,t])=>{a([...e.payload||[],...t.payload||[]]),d({workspaceName:n,path:i,treeName:o,treeType:s})})})()).catch(e=>l(e instanceof Error?e.message:`Failed to load calendar`)).finally(()=>s(!1))},[e,m,h,r]),_=(0,z.useCallback)(async()=>{if(!e){a([]),d(null);return}s(!0),l(null),await g()},[e,g]),[v,y]=(0,z.useState)(null),b=`${$e(e)}|${m}|${h}|${r}`;v!==b&&(y(b),e?(s(!0),l(null)):(a([]),d(null))),(0,z.useEffect)(()=>{g()},[g]),(0,z.useEffect)(()=>{let e=()=>{_()};return window.addEventListener(`workspace:documents:refresh`,e),()=>window.removeEventListener(`workspace:documents:refresh`,e)},[_]);let x=u?.workspaceName??null,S=(0,z.useCallback)(()=>x?Promise.all([T(x),E(x)]).then(([e,t])=>{let n=new Set;for(let t of e)t.startsWith(`data/calendar/`)&&t.length>14&&n.add(t.slice(14));for(let e of t)Qe(e.name)&&n.add(e.name);p([...n].sort())}).catch(()=>{}):Promise.resolve(),[x]);(0,z.useEffect)(()=>{S()},[S,i.length]),(0,z.useEffect)(()=>{let e=()=>{S()};return window.addEventListener(`workspace:timelines:changed`,e),()=>window.removeEventListener(`workspace:timelines:changed`,e)},[S]);let O=(0,z.useCallback)(async e=>{if(!u)throw Error(`No workspace scope resolved`);await k(u.workspaceName,[e],u.path,[],u.treeName,u.treeType),a(t=>t.filter(t=>t.id!==e))},[u]),A=(0,z.useCallback)(e=>{a(t=>t.some(t=>t.id===e.id)?t.map(t=>t.id===e.id?e:t):[...t,e])},[]);return(0,z.useMemo)(()=>({docs:i,loading:o,error:c,scope:u,knownCalendars:f,reload:_,removeDoc:O,patchDoc:A}),[i,o,c,u,f,_,O,A])}function tt(e){return R(e?e.toLowerCase():`events`)}function nt(e){return e.kind===`task`?R(je):tt(e.calendar)}function rt(e,t=18){return`color-mix(in oklch, ${e} ${t}%, transparent)`}function it(e,t,n,r,i,a=30){let o=Math.max(0,Math.min(e.length-1,t)),s=Math.max(0,Math.min(e.length-1,r));if(o!==s){let[t,n]=o<s?[o,s]:[s,o];return{start:U(e[t]),end:W(U(e[n]),1),allDay:!0}}let c=e=>Math.floor(e/a)*a,l=c(Math.min(n,i)),u=c(Math.max(n,i))+a;l=Math.max(0,Math.min(1440-a,l)),u=Math.max(l+a,Math.min(1440,u));let d=U(e[o]);return{start:new Date(d.getTime()+l*6e4),end:new Date(d.getTime()+u*6e4),allDay:!1}}function at(e,t){let[n,r]=e.getTime()<=t.getTime()?[e,t]:[t,e];return{start:U(n),end:W(U(r),1),allDay:!0}}function ot(e,t,n,r,i,a,o=15){let s=t=>Math.max(0,Math.min(e.length-1,t)),c=s(i)-s(n),l=Math.round((a-r)/o)*o,u=t.end.getTime()-t.start.getTime(),d=W(t.start,c),f=U(d),p=Math.max(0,Math.min(1440-o,(d.getTime()-f.getTime())/6e4+l)),m=new Date(f.getTime()+p*6e4);return{start:m,end:new Date(m.getTime()+u)}}function st(e,t,n,r,i=15){let a=U(e[Math.max(0,Math.min(e.length-1,n))]),o=Math.min(1440,Math.ceil(r/i)*i),s=new Date(a.getTime()+o*6e4);return{start:t.start,end:s.getTime()<t.start.getTime()+i*6e4?new Date(t.start.getTime()+i*6e4):s}}function ct(e,t){return{start:W(e.start,t),end:W(e.end,t)}}var Q=t();function lt({month:e,selection:t,marks:n,onPick:r,onPickRange:i,onPrev:a,onNext:s,onTitle:c,onDayMenu:l,title:u,className:f}){let p=new Date,m=K(e),h=u??pe(e),[g,_]=(0,z.useState)(null),v=(0,z.useRef)(g);(0,z.useEffect)(()=>{v.current=g});let y=e=>(document.elementFromPoint(e.clientX,e.clientY)?.closest(`[data-day]`))?.dataset.day??null,b=e=>{if(!i||e.button!==0)return;let t=y(e);t&&(e.currentTarget.setPointerCapture(e.pointerId),_({from:t,to:t}))},S=e=>{if(!v.current)return;let t=y(e);t&&t!==v.current.to&&_({...v.current,to:t})},C=e=>{let t=v.current;if(!t)return;if(e.currentTarget.releasePointerCapture(e.pointerId),_(null),t.from===t.to){w(e,H(t.from));return}let n=at(H(t.from),H(t.to));i?.(n.start,n.end)},w=(e,n)=>{if(e.shiftKey&&i&&t){let e=at(t.start,n);i(e.start,e.end)}else r(n)},T=g?at(H(g.from),H(g.to)):t;return(0,Q.jsxs)(`div`,{className:x(`select-none`,f),children:[(0,Q.jsxs)(`div`,{className:`mb-1 flex items-center justify-between`,children:[a?(0,Q.jsx)(`button`,{type:`button`,onClick:a,className:`rounded p-0.5 text-muted-foreground hover:bg-muted hover:text-foreground`,"aria-label":`Previous month`,children:(0,Q.jsx)(o,{className:`h-3.5 w-3.5`})}):(0,Q.jsx)(`span`,{}),c?(0,Q.jsx)(`button`,{type:`button`,onClick:c,className:`text-xs font-semibold hover:underline`,children:h}):(0,Q.jsx)(`span`,{className:`text-xs font-semibold`,children:h}),s?(0,Q.jsx)(`button`,{type:`button`,onClick:s,className:`rounded p-0.5 text-muted-foreground hover:bg-muted hover:text-foreground`,"aria-label":`Next month`,children:(0,Q.jsx)(d,{className:`h-3.5 w-3.5`})}):(0,Q.jsx)(`span`,{})]}),(0,Q.jsx)(`div`,{className:`grid grid-cols-7 text-center text-[10px] text-muted-foreground`,children:ae.map(e=>(0,Q.jsx)(`span`,{children:e[0]},e))}),(0,Q.jsx)(`div`,{className:x(`grid grid-cols-7 gap-y-px text-center text-[11px]`,g&&`cursor-crosshair`),onPointerDown:b,onPointerMove:S,onPointerUp:C,onPointerCancel:()=>_(null),children:m.map(t=>{let r=V(t),a=t.getMonth()===e.getMonth(),o=G(t,p),s=!!T&&t>=T.start&&t<T.end,c=!!T&&s&&G(t,T.start),u=!!T&&s&&G(t,new Date(T.end.getTime()-1)),d=n?.get(r)??[],f=[...new Set(d.map(nt))].slice(0,3);return(0,Q.jsxs)(`button`,{type:`button`,"data-day":r,onClick:e=>{(e.detail===0||!i)&&w(e,t)},onContextMenu:l?e=>{e.preventDefault(),l(e,t)}:void 0,"aria-label":d.length?`${t.toDateString()}, ${d.length} ${d.length===1?`entry`:`entries`}`:t.toDateString(),title:d.length?d.slice(0,6).map(e=>e.title).join(`
|
|
2
|
+
`)+(d.length>6?`\n+${d.length-6} more`:``):void 0,className:x(`relative mx-auto flex h-6 w-full items-center justify-center transition-colors hover:bg-muted`,c&&u?`rounded-full`:c?`rounded-l-full`:u?`rounded-r-full`:s?``:`rounded-full`,!a&&`text-muted-foreground/40`,o&&!s&&`font-bold text-primary`,s&&`bg-primary text-primary-foreground hover:bg-primary`,d.length>0&&!s&&`font-semibold`),style:d.length&&!s?{background:`color-mix(in srgb, ${f[0]} 22%, transparent)`}:void 0,children:[t.getDate(),d.length>0&&!s&&(0,Q.jsx)(`span`,{className:`absolute bottom-0 left-1/2 flex -translate-x-1/2 gap-px`,children:f.map(e=>(0,Q.jsx)(`span`,{className:`h-1 w-1 rounded-full`,style:{background:e}},e))})]},r)})})]})}function ut({occurrence:e,selected:t,moving:n,showTime:r=!0,onSelect:i,className:o,...s}){let c=nt(e),u=!e.allDay&&e.kind===`event`&&e.end.getTime()>e.start.getTime();return(0,Q.jsxs)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),i(e)},title:`${e.title}${e.calendar?` · ${e.calendar}`:``}`,className:x(`flex w-full min-w-0 items-center gap-1 truncate rounded px-1 py-px text-left text-[11px] leading-4 text-foreground transition-colors hover:brightness-110`,!e.recurring&&`touch-none`,t&&`ring-1 ring-ring`,n&&`cursor-grabbing ring-2 ring-primary shadow-elevation-2`,e.done&&`line-through opacity-60`,o),style:{background:rt(c,e.allDay||e.kind===`task`?28:14),borderLeft:`3px solid ${c}`},...s,children:[e.kind===`task`&&(0,Q.jsx)(a,{className:`h-3 w-3 shrink-0`,style:{color:c}}),r&&u&&(0,Q.jsx)(`span`,{className:`shrink-0 tabular-nums text-muted-foreground`,children:Z(e.start)}),(0,Q.jsx)(`span`,{className:`truncate`,children:e.title}),e.recurring&&(0,Q.jsx)(l,{className:`ml-auto h-2.5 w-2.5 shrink-0 text-muted-foreground`})]})}function dt(e){let[t,n]=(0,z.useState)(null),r=(0,z.useRef)(e);(0,z.useEffect)(()=>{r.current=e});let i=(0,z.useRef)(null),a=(0,z.useRef)(!1);(0,z.useEffect)(()=>()=>i.current?.stop(),[]);let o=e=>(document.elementFromPoint(e.clientX,e.clientY)?.closest(`[data-day]`))?.dataset.day??null;return{moving:t,handlers:e=>e.recurring?{}:{onPointerDown:t=>{if(t.button!==0||i.current)return;let s=o(t);if(!s)return;let c=e=>{let t=i.current;if(!t)return;let r=o(e);if(!r)return;let a=Math.round((H(r).getTime()-H(t.fromKey).getTime())/ie);a!==t.delta&&(t.delta=a,n(a?{key:t.o.key,...ct(t.o,a)}:null))},l=()=>{let e=i.current;if(!e||(e.stop(),n(null),!e.delta))return;a.current=!0,setTimeout(()=>{a.current=!1},0);let t=ct(e.o,e.delta);r.current(e.o,t.start,t.end)},u=()=>{i.current?.stop(),n(null)};window.addEventListener(`pointermove`,c),window.addEventListener(`pointerup`,l),window.addEventListener(`pointercancel`,u),i.current={o:e,fromKey:s,delta:0,stop:()=>{i.current=null,window.removeEventListener(`pointermove`,c),window.removeEventListener(`pointerup`,l),window.removeEventListener(`pointercancel`,u)}}},onClickCapture:e=>{a.current&&(a.current=!1,e.stopPropagation(),e.preventDefault())}},apply:e=>t?e.map(e=>e.key===t.key?{...e,start:t.start,end:t.end}:e):e}}var $=48,ft=30,pt=15,mt=`w-12`,ht=48;function gt({days:e,occurrences:t,selectedKey:n,pending:r,onSelect:i,onCreate:a,onMove:o,onPickDay:s,onEntryMenu:c,onSlotMenu:l,compact:u}){let d=(0,z.useRef)(null),f=(0,z.useRef)(null),[p,m]=(0,z.useState)(null),h=(0,z.useRef)(p);(0,z.useEffect)(()=>{h.current=p});let g=t=>{let n=f.current;if(!n)return null;let r=n.getBoundingClientRect(),i=(r.width-ht)/e.length,a=Math.floor((t.clientX-r.left-ht)/i),o=Math.max(0,Math.min(1439,(t.clientY-r.top)/$*60));return a<0||a>=e.length?null:{day:a,min:o}},_=e=>{if(e.button!==0||e.target.closest(`button`))return;let t=g(e);t&&(e.currentTarget.setPointerCapture(e.pointerId),m({fromDay:t.day,fromMin:t.min,toDay:t.day,toMin:t.min}))},v=e=>{if(!h.current)return;let t=g(e);t&&m({...h.current,toDay:t.day,toMin:t.min})},y=t=>{let n=h.current;if(!n)return;t.currentTarget.releasePointerCapture(t.pointerId),m(null);let r=it(e,n.fromDay,n.fromMin,n.toDay,n.toMin,ft);a(r.start,r.allDay,r.end)},b=t=>{let n=g(t);n&&(t.preventDefault(),l(t,it(e,n.day,n.min,n.day,n.min,ft).start,!1))},S=p?it(e,p.fromDay,p.fromMin,p.toDay,p.toMin,ft):r,[C,w]=(0,z.useState)(null),T=(0,z.useRef)(o);(0,z.useEffect)(()=>{T.current=o});let E=(0,z.useRef)(null);(0,z.useEffect)(()=>()=>E.current?.stop(),[]);let D=(0,z.useRef)(!1),O=(t,n)=>{if(t.button!==0||n.recurring||E.current)return;let r=g(t);if(!r)return;let i=t.target.dataset.resize?`resize`:`move`,a=null,o=t=>{let o=g(t);if(!o)return;let s=i===`move`?ot(e,n,r.day,r.min,o.day,o.min,pt):st(e,n,o.day,o.min,pt);a=s.start.getTime()===n.start.getTime()&&s.end.getTime()===n.end.getTime()?null:s,w(a?{key:n.key,...a,mode:i}:null)},s=()=>{l(),w(null),a&&(D.current=!0,setTimeout(()=>{D.current=!1},0),T.current(n,a.start,a.end))},c=()=>{l(),w(null)},l=()=>{E.current=null,window.removeEventListener(`pointermove`,o),window.removeEventListener(`pointerup`,s),window.removeEventListener(`pointercancel`,c)};window.addEventListener(`pointermove`,o),window.addEventListener(`pointerup`,s),window.addEventListener(`pointercancel`,c),E.current={stop:l}},k=dt(o),A=k.apply(t),ee=(0,z.useMemo)(()=>C?A.map(e=>e.key===C.key?{...e,start:C.start,end:C.end}:e):A,[A,C]),j=(0,z.useMemo)(()=>Be(ee),[ee]),[M,N]=(0,z.useState)(()=>new Date);(0,z.useEffect)(()=>{let e=setInterval(()=>N(new Date),6e4);return()=>clearInterval(e)},[]);let P=V(e[0]);(0,z.useEffect)(()=>{let t=d.current;t&&(t.scrollTop=(e.some(e=>G(e,M))?Math.max(0,M.getHours()-1):7)*$)},[P,e.length]);let F=Array.from({length:24},(e,t)=>t),I=e.map(e=>(j.get(V(e))??[]).filter(Ve)),L=Math.max(0,...I.map(e=>e.length)),te=!!p||!!C||!!k.moving;return(0,Q.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,Q.jsxs)(`div`,{className:`flex shrink-0 border-b border-border`,children:[(0,Q.jsx)(`div`,{className:x(mt,`shrink-0`)}),e.map(e=>{let t=G(e,M);return(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>s(e),className:`flex min-w-0 flex-1 flex-col items-center border-l border-border/60 py-1 hover:bg-muted/50`,title:`Open day`,children:[(0,Q.jsx)(`span`,{className:`text-[10px] uppercase tracking-wide text-muted-foreground`,children:ae[(e.getDay()+6)%7]}),(0,Q.jsx)(`span`,{className:x(`flex h-7 w-7 items-center justify-center rounded-full text-sm font-semibold`,t&&`bg-primary text-primary-foreground`),children:e.getDate()})]},V(e))})]}),L>0&&(0,Q.jsxs)(`div`,{className:x(`flex shrink-0 border-b border-border bg-muted/20`,k.moving&&`select-none`),children:[(0,Q.jsx)(`div`,{className:x(mt,`shrink-0 py-1 pr-1 text-right text-[10px] text-muted-foreground`),children:u?``:`all day`}),e.map((e,t)=>(0,Q.jsx)(`div`,{"data-day":V(e),className:`flex min-w-0 flex-1 flex-col gap-0.5 border-l border-border/60 p-0.5`,onClick:t=>{t.target===t.currentTarget&&a(U(e),!0)},onContextMenu:t=>{t.preventDefault(),l(t,U(e),!0)},children:I[t].map(e=>(0,Q.jsx)(ut,{occurrence:e,selected:e.key===n,moving:k.moving?.key===e.key,showTime:!1,onSelect:i,onContextMenu:t=>{t.preventDefault(),t.stopPropagation(),c(t,e)},...k.handlers(e)},e.key))},V(e)))]}),(0,Q.jsx)(`div`,{ref:d,className:`min-h-0 flex-1 overflow-y-auto`,children:(0,Q.jsxs)(`div`,{ref:f,className:x(`relative flex select-none`,p&&`cursor-crosshair`,C?.mode===`move`&&`cursor-grabbing`,C?.mode===`resize`&&`cursor-ns-resize`),style:{height:1152},onPointerDown:_,onPointerMove:v,onPointerUp:y,onPointerCancel:()=>m(null),onContextMenu:b,children:[(0,Q.jsx)(`div`,{className:x(mt,`relative shrink-0`),children:F.map(e=>(0,Q.jsx)(`div`,{className:`absolute right-1 -translate-y-1/2 text-[10px] tabular-nums text-muted-foreground`,style:{top:e*$},children:e===0?``:ye(e)},e))}),e.map(e=>{let t=He(e,j.get(V(e))??[]),r=G(e,M)?(M.getHours()*60+M.getMinutes())/60*$:null;return(0,Q.jsxs)(`div`,{"data-day":V(e),className:`relative min-w-0 flex-1 cursor-cell border-l border-border/60`,role:`presentation`,children:[S&&S.end>e&&S.start<U(new Date(e.getTime()+864e5))&&(0,Q.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0.5 z-[5] rounded-md border border-primary bg-primary/15`,style:{top:J(S.start,e)/60*$,height:Math.max(8,(J(S.end,e)-J(S.start,e))/60*$)},children:(0,Q.jsx)(`span`,{className:`absolute left-1 top-0.5 text-[10px] font-medium text-primary`,children:S.allDay?`All day`:`${Z(S.start)} – ${Z(S.end)}`})}),F.map(e=>(0,Q.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 border-t border-border/50`,style:{top:e*$}},e)),t.map(e=>{let t=e.occurrence,r=nt(t),a=100/e.columns,o=e.height<45,s=C?.key===t.key,l=!t.recurring;return(0,Q.jsxs)(`button`,{type:`button`,onClick:e=>{if(e.stopPropagation(),D.current){D.current=!1;return}i(t)},onContextMenu:e=>{e.preventDefault(),e.stopPropagation(),c(e,t)},onPointerDown:e=>O(e,t),title:`${t.title} · ${Z(t.start)}${t.end>t.start?` – ${Z(t.end)}`:``}`,className:x(`absolute overflow-hidden rounded-md border-l-[3px] px-1.5 text-left text-[11px] leading-tight text-foreground shadow-elevation-1 transition-[filter] hover:brightness-110`,l&&`touch-none`,s?`z-20 ring-2 ring-primary shadow-elevation-2`:te&&`pointer-events-none`,t.key===n&&!s&&`ring-1 ring-ring`,t.done&&`line-through opacity-60`),style:{top:e.top/60*$,height:Math.max(18,e.height/60*$-2),left:`calc(${e.column*a}% + 2px)`,width:`calc(${a}% - 4px)`,background:rt(r,24),borderLeftColor:r,paddingTop:o?1:3},children:[(0,Q.jsx)(`span`,{className:x(`font-medium`,o?`inline`:`block truncate`),children:t.title}),!o&&(0,Q.jsxs)(`span`,{className:`block truncate text-[10px] text-muted-foreground`,children:[Z(t.start),t.end>t.start?` – ${Z(t.end)}`:``,t.calendar&&!u?` · ${t.calendar}`:``]}),l&&t.kind===`event`&&(0,Q.jsx)(`span`,{"data-resize":`1`,className:`absolute inset-x-0 bottom-0 h-1.5 cursor-ns-resize`})]},t.key)}),r!==null&&(0,Q.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 z-10 border-t-2 border-destructive`,style:{top:r},children:(0,Q.jsx)(`span`,{className:`absolute -left-1 -top-[5px] h-2 w-2 rounded-full bg-destructive`})})]},V(e))})]})})]})}var _t=3;function vt({month:e,occurrences:t,selectedKey:n,pending:r,onSelect:i,onCreate:a,onMove:o,onPickDay:s,onEntryMenu:c,onSlotMenu:l,narrow:u}){let d=K(e),f=dt(o),p=f.apply(t),m=(0,z.useMemo)(()=>Be(p),[p]),h=new Date,[g,_]=(0,z.useState)(null),v=(0,z.useRef)(g);(0,z.useEffect)(()=>{v.current=g});let y=e=>(document.elementFromPoint(e.clientX,e.clientY)?.closest(`[data-day]`))?.dataset.day??null,b=e=>{if(u||e.button!==0||e.target.closest(`button`))return;let t=y(e);t&&(e.currentTarget.setPointerCapture(e.pointerId),_({from:t,to:t}))},S=e=>{if(!v.current)return;let t=y(e);t&&t!==v.current.to&&_({...v.current,to:t})},C=e=>{let t=v.current;if(!t)return;e.currentTarget.releasePointerCapture(e.pointerId),_(null);let n=at(H(t.from),H(t.to));a(n.start,!0,n.end)},w=e=>{let t=y(e);t&&(e.preventDefault(),l(e,H(t),!0))},T=g?at(H(g.from),H(g.to)):r;return(0,Q.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,Q.jsx)(`div`,{className:`grid shrink-0 grid-cols-7 border-b border-border text-center text-[10px] uppercase tracking-wide text-muted-foreground`,children:ae.map(e=>(0,Q.jsx)(`span`,{className:`py-1`,children:u?e[0]:e},e))}),(0,Q.jsx)(`div`,{className:x(`grid min-h-0 flex-1 grid-cols-7 grid-rows-6 overflow-y-auto`,g&&`cursor-crosshair select-none`,f.moving&&`select-none`),onPointerDown:b,onPointerMove:S,onPointerUp:C,onPointerCancel:()=>_(null),onContextMenu:w,children:d.map(t=>{let r=V(t),a=m.get(r)??[],o=t.getMonth()===e.getMonth(),l=G(t,h),d=a.length-_t;return(0,Q.jsxs)(`div`,{role:`presentation`,"data-day":r,onClick:e=>{u&&e.target===e.currentTarget&&s(t)},className:x(`flex min-h-[3.5rem] min-w-0 flex-col gap-0.5 border-b border-r border-border/60 p-0.5`,!o&&`bg-muted/20 text-muted-foreground/60`,!u&&`cursor-cell`,T&&t>=T.start&&t<T.end&&`bg-primary/15 ring-1 ring-inset ring-primary`),children:[(0,Q.jsx)(`button`,{type:`button`,onClick:()=>s(t),className:x(`mx-auto flex h-5 w-5 items-center justify-center rounded-full text-[11px] hover:bg-muted sm:mx-0`,l&&`bg-primary font-bold text-primary-foreground hover:bg-primary`),title:`Open day`,children:t.getDate()}),u?(0,Q.jsx)(`div`,{className:`flex flex-wrap justify-center gap-0.5 px-0.5`,children:a.slice(0,4).map(e=>(0,Q.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full`,style:{background:nt(e)}},e.key))}):(0,Q.jsxs)(Q.Fragment,{children:[a.slice(0,_t).map(e=>(0,Q.jsx)(ut,{occurrence:e,selected:e.key===n,moving:f.moving?.key===e.key,onSelect:i,onContextMenu:t=>{t.preventDefault(),t.stopPropagation(),c(t,e)},...f.handlers(e)},e.key)),d>0&&(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>s(t),className:`px-1 text-left text-[10px] text-muted-foreground hover:text-foreground`,children:[`+`,d,` more`]})]})]},r)})})]})}function yt({year:e,occurrences:t,onPickDay:n,onPickRange:r,onPickMonth:i,onSlotMenu:a}){let o=(0,z.useMemo)(()=>Be(t),[t]),s=Array.from({length:12},(t,n)=>new Date(e,n,1));return(0,Q.jsx)(`div`,{className:`grid h-full min-h-0 grid-cols-[repeat(auto-fill,minmax(11rem,1fr))] gap-x-4 gap-y-5 overflow-y-auto p-3`,children:s.map(e=>(0,Q.jsx)(lt,{month:e,marks:o,title:e.toLocaleDateString(void 0,{month:`long`}),onTitle:()=>i(e),onPick:n,onPickRange:r,onDayMenu:(e,t)=>a(e,t,!0)},V(e)))})}function bt({occurrences:e,selectedKey:t,onSelect:n,onEntryMenu:r,onEarlier:i,onLater:a,onPickDay:o,loading:s}){let c=(0,z.useMemo)(()=>[...Be(e).entries()].sort(([e],[t])=>e.localeCompare(t)),[e]),l=new Date;return(0,Q.jsxs)(`div`,{className:`h-full min-h-0 overflow-y-auto`,children:[(0,Q.jsx)(`div`,{className:`flex justify-center py-2`,children:(0,Q.jsx)(`button`,{type:`button`,onClick:i,className:`rounded-md border border-border px-3 py-1 text-xs text-muted-foreground hover:bg-muted hover:text-foreground`,children:`Earlier`})}),!s&&!c.length&&(0,Q.jsx)(`p`,{className:`py-10 text-center text-sm text-muted-foreground`,children:`Nothing scheduled in this range.`}),c.map(([e,i])=>{let a=H(e),s=G(a,l);return(0,Q.jsxs)(`div`,{className:`flex border-t border-border/60 px-2 py-2`,children:[(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>o(a),className:`flex w-14 shrink-0 flex-col items-start`,title:`Open day`,children:[(0,Q.jsx)(`span`,{className:x(`flex h-8 w-8 items-center justify-center rounded-full text-lg font-semibold`,s&&`bg-primary text-primary-foreground`),children:a.getDate()}),(0,Q.jsxs)(`span`,{className:`text-[10px] uppercase tracking-wide text-muted-foreground`,children:[me(a),`, `,ae[(a.getDay()+6)%7]]})]}),(0,Q.jsx)(`div`,{className:`min-w-0 flex-1 space-y-0.5`,children:i.map(e=>{let i=nt(e),a=!Ve(e)&&e.kind===`event`;return(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>n(e),onContextMenu:t=>{t.preventDefault(),r(t,e)},className:x(`flex w-full items-center gap-2 rounded-md px-2 py-1 text-left text-sm hover:bg-muted`,e.key===t&&`bg-muted ring-1 ring-ring`,e.done&&`line-through opacity-60`),children:[(0,Q.jsx)(`span`,{className:`h-2.5 w-2.5 shrink-0 rounded-full`,style:{background:i}}),(0,Q.jsx)(`span`,{className:`w-[7.5rem] shrink-0 text-xs tabular-nums text-muted-foreground`,children:a?`${Z(e.start)}${e.end>e.start?` – ${Z(e.end)}`:``}`:e.kind===`task`?`due ${Z(e.start)}`:`All day`}),(0,Q.jsx)(`span`,{className:`truncate`,children:e.title}),e.calendar&&e.kind===`event`&&(0,Q.jsx)(`span`,{className:`ml-auto shrink-0 text-[10px] text-muted-foreground`,children:e.calendar})]},e.key)})})]},e)}),(0,Q.jsx)(`div`,{className:`flex justify-center py-2`,children:(0,Q.jsx)(`button`,{type:`button`,onClick:a,className:`rounded-md border border-border px-3 py-1 text-xs text-muted-foreground hover:bg-muted hover:text-foreground`,children:`Later`})})]})}var xt=`3.0`,St=[{id:`none`,label:`Does not repeat`},{id:`daily`,label:`Every day`},{id:`weekdays`,label:`Every weekday`},{id:`weekly`,label:`Every week`},{id:`monthly`,label:`Every month`},{id:`yearly`,label:`Every year`},{id:`custom`,label:`Custom (RRULE)…`}];function Ct(e,t){let n=e.data??{},r=n.allDay===!0,i=String(n.start??``),a=typeof n.end==`string`?n.end:``,o=typeof n.recurrence==`string`?n.recurrence:``,s=Oe(o||void 0),c=Ae(o||void 0);return{title:String(n.title??``),calendar:typeof n.calendar==`string`?n.calendar:Et(e)?``:t,allDay:r,start:r?i.slice(0,10):F(i),end:r?Dt(i.slice(0,10),a):F(a),location:String(n.location??``),description:String(n.description??``),repeat:s,until:c.until,count:c.count===null?``:String(c.count),rrule:o}}function wt(e,t){let n=e.end??new Date(e.start.getTime()+36e5);return{title:``,calendar:t,allDay:e.allDay,start:e.allDay?V(e.start):oe(e.start),end:e.allDay?V(W(n,-1)<e.start?e.start:W(n,-1)):oe(n),location:``,description:``,repeat:`none`,until:``,count:``,rrule:``}}function Tt(e){if(e.repeat===`custom`)return e.rrule.trim();let t=Number(e.count);return ke(e.repeat,{until:e.until,count:Number.isInteger(t)&&t>0?t:null})}function Et(e){let t=e.metadata;return typeof t?.source==`string`&&t.source?{source:t.source,connector:typeof t.connector==`string`?t.connector:``}:null}function Dt(e,t){if(!t)return``;let[n,r,i]=t.slice(0,10).split(`-`).map(Number),a=V(new Date(n,r-1,i-1));return a<e?e:a}function Ot(e){return`${V(W(H(e),1))}T00:00:00.000Z`}function kt(e,t){let n={...e,title:t.title.trim()},r=(e,t)=>{t===void 0||t===``||t===!1?delete n[e]:n[e]=t};return r(`calendar`,t.calendar.trim()),r(`allDay`,t.allDay),r(`location`,t.location.trim()),r(`description`,t.description.trim()),r(`recurrence`,Tt(t)),t.allDay?(n.start=`${t.start}T00:00:00.000Z`,r(`end`,t.end?Ot(t.end):void 0)):(n.start=I(t.start),r(`end`,I(t.end))),n}function At(e){return e.title.trim()?e.start?e.end&&e.end<e.start?`The end is before the start.`:e.calendar.includes(`:`)?`A calendar name cannot contain ":".`:e.repeat===`custom`&&(!e.rrule.trim()||!Se(e.rrule))?`Enter a supported RRULE (FREQ=…, INTERVAL, COUNT, UNTIL, BYDAY, BYMONTHDAY, BYMONTH).`:e.repeat!==`none`&&e.repeat!==`custom`&&e.until&&e.until<e.start.slice(0,10)?`The series ends before it starts.`:e.repeat!==`none`&&e.repeat!==`custom`&&e.count&&!(Number.isInteger(Number(e.count))&&Number(e.count)>0)?`The number of occurrences must be a whole number above zero.`:null:`Pick a start.`:`Give the event a title.`}function jt({subject:e,target:t,workspaceName:n,calendars:r,defaultCalendar:a,onClose:o,onSaved:s,onDelete:u}){let d=e.kind===`occurrence`?e.occurrence.doc:null,p=e.kind===`occurrence`&&e.occurrence.kind===`task`,[m,h]=(0,z.useState)(()=>d?Ct(d,a):wt(e.draft,a)),[g,y]=(0,z.useState)(!1),[S,C]=(0,z.useState)(null),[T,E]=(0,z.useState)(!1),D=e.kind===`draft`?`draft:${e.draft.start.getTime()}:${e.draft.end?.getTime()??``}:${e.draft.allDay}`:e.occurrence.key,[k,A]=(0,z.useState)(D);k!==D&&(A(D),h(d?Ct(d,a):wt(e.draft,a)),C(null)),(0,z.useEffect)(()=>{let e=e=>{e.key===`Escape`&&o()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[o]);let j=e=>h(t=>({...t,...e})),M=d?Et(d):null,N=typeof d?.data?.htmlLink==`string`?d.data.htmlLink:null,F=async()=>{let e=At(m);if(e){C(e);return}y(!0),C(null);try{if(d){if(!n)throw Error(`No workspace resolved for this calendar`);await O(n,{id:d.id,schema:d.schema,schemaVersion:d.schemaVersion||xt,data:kt(d.data??{},m),metadata:d.metadata})}else await ee(t,[{schema:w,schemaVersion:xt,data:kt({},m),metadata:{features:[]}}]);s(m.calendar.trim())}catch(e){C(e instanceof Error?e.message:`Failed to save the event`)}finally{y(!1)}},I=p?`Task`:d?`Event`:`New event`;return(0,Q.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-border px-3 py-2`,children:[(0,Q.jsx)(`span`,{className:`h-3 w-3 rounded-full`,style:{background:tt(p?`tasks`:m.calendar)}}),(0,Q.jsx)(`span`,{className:`text-sm font-semibold`,children:I}),d&&(0,Q.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[`#`,d.id]}),(0,Q.jsx)(`span`,{className:`flex-1`}),d&&n&&(0,Q.jsx)(i,{to:`/workspaces/${encodeURIComponent(n)}/documents/${d.id}`,className:`rounded p-1 text-muted-foreground hover:bg-muted hover:text-foreground`,title:`Open document`,"aria-label":`Open document`,children:(0,Q.jsx)(_,{className:`h-3.5 w-3.5`})}),d&&(0,Q.jsx)(`button`,{type:`button`,onClick:()=>E(!0),className:`rounded p-1 text-muted-foreground hover:bg-muted hover:text-foreground`,title:`Link to…`,"aria-label":`Link to…`,children:(0,Q.jsx)(b,{className:`h-3.5 w-3.5`})}),d&&!p&&(0,Q.jsx)(`button`,{type:`button`,onClick:()=>{u(d)},className:`rounded p-1 text-muted-foreground hover:bg-muted hover:text-destructive`,title:`Delete (moves to trash)`,"aria-label":`Delete`,children:(0,Q.jsx)(f,{className:`h-3.5 w-3.5`})}),(0,Q.jsx)(`button`,{type:`button`,onClick:o,className:`rounded p-1 text-muted-foreground hover:bg-muted hover:text-foreground`,"aria-label":`Close`,children:(0,Q.jsx)(c,{className:`h-4 w-4`})})]}),p&&d?(0,Q.jsx)(Ft,{doc:d,occurrence:e.occurrence,workspaceName:n,onSaved:()=>s(``)}):(0,Q.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-3 overflow-y-auto p-3`,children:[(0,Q.jsx)(`input`,{value:m.title,onChange:e=>j({title:e.target.value}),placeholder:`Title`,autoFocus:!d,spellCheck:!1,className:`w-full border-0 border-b border-border bg-transparent px-0 py-1 text-base font-semibold outline-none placeholder:text-muted-foreground/60 focus:border-ring`}),(0,Q.jsx)(Nt,{value:m.calendar,calendars:r,onChange:e=>j({calendar:e})}),(0,Q.jsxs)(`label`,{className:`flex items-center gap-2 text-xs`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,checked:m.allDay,onChange:e=>{let t=e.target.checked;if(t)j({allDay:t,start:m.start.slice(0,10),end:(m.end||m.start).slice(0,10)});else{let e=m.start.slice(0,10)||V(new Date),n=(m.end||e).slice(0,10);j(n>e?{allDay:t,start:`${e}T09:00`,end:`${e}T10:00`,repeat:m.repeat===`none`?`daily`:m.repeat,until:n,count:``}:{allDay:t,start:`${e}T09:00`,end:`${e}T10:00`})}},className:`h-4 w-4 accent-primary`}),`All day`]}),(0,Q.jsxs)(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-2`,children:[(0,Q.jsxs)(`label`,{className:`block text-xs`,children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:`Start`}),m.allDay?(0,Q.jsx)(`div`,{className:`mt-1`,children:(0,Q.jsx)(L,{value:m.start,onChange:e=>j({start:e,end:m.end&&m.end<e?e:m.end})})}):(0,Q.jsx)(`div`,{className:`mt-1`,children:(0,Q.jsx)(P,{value:m.start,onChange:e=>j({start:e}),clearable:!1})})]}),(0,Q.jsxs)(`label`,{className:`block text-xs`,children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:`End`}),m.allDay?(0,Q.jsx)(`div`,{className:`mt-1`,children:(0,Q.jsx)(L,{value:m.end,min:m.start,placeholder:`Same day`,onChange:e=>j({end:e})})}):(0,Q.jsx)(`div`,{className:`mt-1`,children:(0,Q.jsx)(P,{value:m.end,onChange:e=>j({end:e}),placeholder:`No end`})})]})]}),(0,Q.jsxs)(`label`,{className:`block text-xs`,children:[(0,Q.jsxs)(`span`,{className:`flex items-center gap-1 text-muted-foreground`,children:[(0,Q.jsx)(l,{className:`h-3 w-3`}),` Repeat`]}),(0,Q.jsx)(`select`,{value:m.repeat,onChange:e=>j({repeat:e.target.value,rrule:e.target.value===`custom`?m.rrule||ke(m.repeat)||`FREQ=WEEKLY`:m.rrule}),className:`mt-1 h-8 w-full rounded-md border border-input bg-transparent px-2 text-sm`,children:St.map(e=>(0,Q.jsx)(`option`,{value:e.id,children:e.label},e.id))}),m.repeat===`custom`&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`input`,{value:m.rrule,onChange:e=>j({rrule:e.target.value}),placeholder:`FREQ=WEEKLY;INTERVAL=2;BYDAY=TU,TH`,spellCheck:!1,className:`mt-1 h-8 w-full rounded-md border border-input bg-transparent px-2 font-mono text-xs`}),(0,Q.jsx)(`span`,{className:`mt-0.5 block text-[11px] text-muted-foreground`,children:Se(m.rrule)?De(Se(m.rrule)):`RFC 5545 RRULE value`})]})]}),m.repeat!==`none`&&m.repeat!==`custom`&&(0,Q.jsx)(Mt,{fields:m,patch:j}),(0,Q.jsxs)(`label`,{className:`block text-xs`,children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:`Location`}),(0,Q.jsx)(`input`,{value:m.location,onChange:e=>j({location:e.target.value}),spellCheck:!1,className:`mt-1 h-8 w-full rounded-md border border-input bg-transparent px-2 text-sm`})]}),(0,Q.jsxs)(`div`,{className:`text-xs`,children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:`Description`}),(0,Q.jsx)(`div`,{className:`mt-1 rounded-md border border-input px-2 py-1.5`,children:(0,Q.jsx)(re,{value:m.description,onChange:e=>j({description:e}),placeholder:`Notes, agenda, links…`})})]}),M&&(0,Q.jsxs)(`p`,{className:`rounded-md bg-muted/50 px-2 py-1.5 text-[11px] text-muted-foreground`,children:[`Synced from `,M.connector||M.source,`. Edits stay in Canvas unless the connector supports write-back.`,N&&(0,Q.jsxs)(Q.Fragment,{children:[` `,(0,Q.jsx)(`a`,{href:N,target:`_blank`,rel:`noopener noreferrer`,className:`underline hover:text-foreground`,children:`Open at source`})]})]}),e.kind===`occurrence`&&e.occurrence.unsupportedRule&&(0,Q.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:`This series uses RRULE parts the calendar cannot expand; only its first occurrence is shown.`}),S&&(0,Q.jsx)(`p`,{className:`text-xs text-destructive`,role:`alert`,children:S})]}),!p&&(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-2 border-t border-border px-3 py-2`,children:[(0,Q.jsx)(Pt,{doc:d}),(0,Q.jsx)(`button`,{type:`button`,onClick:o,className:`rounded-md border border-border px-3 py-1.5 text-xs hover:bg-muted`,children:`Cancel`}),(0,Q.jsxs)(`button`,{type:`button`,onClick:F,disabled:g,className:x(`flex items-center gap-1 rounded-md bg-primary px-3 py-1.5 text-xs text-primary-foreground disabled:opacity-50`),children:[g&&(0,Q.jsx)(v,{className:`h-3 w-3 animate-spin`}),d?`Save`:`Create`]})]}),T&&d&&(0,Q.jsx)(ne,{documentId:d.id,workspaceName:n??void 0,onClose:()=>E(!1)})]})}function Mt({fields:e,patch:t}){let n=e.until?`until`:e.count?`count`:`never`,r=e.start.slice(0,10),i=Tt(e),a=i?Se(i):null;return(0,Q.jsxs)(`div`,{className:`text-xs`,children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:`Ends`}),(0,Q.jsxs)(`div`,{className:`mt-1 flex items-center gap-1.5`,children:[(0,Q.jsxs)(`select`,{value:n,onChange:n=>{let i=n.target.value;t(i===`never`?{until:``,count:``}:i===`until`?{until:e.until||r,count:``}:{until:``,count:e.count||`10`})},className:`h-8 w-28 shrink-0 rounded-md border border-input bg-transparent px-2 text-sm`,children:[(0,Q.jsx)(`option`,{value:`never`,children:`Never`}),(0,Q.jsx)(`option`,{value:`until`,children:`On date`}),(0,Q.jsx)(`option`,{value:`count`,children:`After`})]}),n===`until`&&(0,Q.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,Q.jsx)(L,{value:e.until,min:r,onChange:e=>t({until:e})})}),n===`count`&&(0,Q.jsxs)(`label`,{className:`flex items-center gap-1.5`,children:[(0,Q.jsx)(`input`,{type:`number`,min:1,step:1,value:e.count,onChange:e=>t({count:e.target.value}),className:`h-8 w-20 rounded-md border border-input bg-transparent px-2 text-sm tabular-nums`}),(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:`occurrences`})]})]}),a&&(0,Q.jsx)(`span`,{className:`mt-0.5 block text-[11px] text-muted-foreground`,children:De(a)})]})}function Nt({value:e,calendars:t,onChange:n}){let r=t.some(t=>t.toLowerCase()===e.toLowerCase()),[i,a]=(0,z.useState)(!r&&!e&&t.length===0),o=r||!e?t:[e,...t];return(0,Q.jsxs)(`label`,{className:`block text-xs`,children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:`Calendar`}),i?(0,Q.jsxs)(`span`,{className:`mt-1 flex gap-1`,children:[(0,Q.jsx)(`input`,{autoFocus:!0,value:e,onChange:e=>n(e.target.value),placeholder:`New calendar name`,spellCheck:!1,className:`h-8 min-w-0 flex-1 rounded-md border border-input bg-transparent px-2 text-sm outline-none focus-visible:ring-1 focus-visible:ring-ring`}),t.length>0&&(0,Q.jsx)(`button`,{type:`button`,onClick:()=>{a(!1),n(t[0])},className:`rounded-md border border-border px-2 text-xs text-muted-foreground hover:bg-muted`,"aria-label":`Pick an existing calendar`,children:(0,Q.jsx)(c,{className:`h-3 w-3`})})]}):(0,Q.jsxs)(`select`,{value:e,onChange:e=>{e.target.value===`\0new`?(a(!0),n(``)):n(e.target.value)},className:`mt-1 h-8 w-full rounded-md border border-input bg-transparent px-2 text-sm`,children:[!e&&(0,Q.jsx)(`option`,{value:``,children:`No calendar`}),o.map(e=>(0,Q.jsx)(`option`,{value:e,children:e},e)),(0,Q.jsx)(`option`,{value:`\0new`,children:`New calendar…`})]})]})}function Pt({doc:e}){let t=A(e??{id:-1,locations:[]});return!e||!t.replicating?null:(0,Q.jsx)(`span`,{className:`mr-auto text-[10px] text-muted-foreground`,children:t.label})}function Ft({doc:e,occurrence:t,workspaceName:n,onSaved:r}){let[i,o]=(0,z.useState)(!1),s=t.done;return(0,Q.jsxs)(`div`,{className:`space-y-3 p-3 text-sm`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:async()=>{if(n){o(!0);try{let t=s?`pending`:`completed`;await O(n,{id:e.id,schema:e.schema,schemaVersion:e.schemaVersion,data:{...e.data??{},status:t,completed:t===`completed`},metadata:e.metadata}),r()}finally{o(!1)}}},disabled:i,className:`mt-0.5 text-muted-foreground hover:text-foreground`,"aria-label":s?`Mark as pending`:`Mark as completed`,children:s?(0,Q.jsx)(a,{className:`h-4 w-4 text-success`}):(0,Q.jsx)(g,{className:`h-4 w-4`})}),(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`p`,{className:x(`font-semibold`,s&&`line-through text-muted-foreground`),children:t.title}),(0,Q.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Due `,t.start.toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`})]})]})]}),typeof e.data?.description==`string`&&e.data.description&&(0,Q.jsx)(`p`,{className:`whitespace-pre-wrap text-xs text-muted-foreground`,children:e.data.description}),(0,Q.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:`Edit the task in the Todos app or on its document page.`})]})}function It({menu:e,onClose:t,onOpen:n,onOpenDocument:r,onToggleDone:i,onDelete:o,onCreate:s,onPickDay:c}){let l=e=>()=>{t(),e()};return(0,Q.jsx)(S,{x:e.x,y:e.y,onClose:t,className:`min-w-44 rounded-md border bg-popover p-1 text-xs shadow-elevation-3`,children:e.kind===`entry`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`p`,{className:`truncate px-3 py-1.5 text-[11px] text-muted-foreground`,title:e.occurrence.title,children:e.occurrence.title}),(0,Q.jsx)(Lt,{icon:(0,Q.jsx)(h,{className:`h-3.5 w-3.5`}),onClick:l(()=>n(e.occurrence)),children:`Open`}),r&&(0,Q.jsx)(Lt,{icon:(0,Q.jsx)(_,{className:`h-3.5 w-3.5`}),onClick:l(()=>r(e.occurrence)),children:`Open document`}),e.occurrence.kind===`task`&&(0,Q.jsx)(Lt,{icon:e.occurrence.done?(0,Q.jsx)(g,{className:`h-3.5 w-3.5`}):(0,Q.jsx)(a,{className:`h-3.5 w-3.5`}),onClick:l(()=>i(e.occurrence)),children:e.occurrence.done?`Mark as pending`:`Mark as completed`}),e.occurrence.kind===`event`&&(0,Q.jsx)(Lt,{icon:(0,Q.jsx)(f,{className:`h-3.5 w-3.5`}),className:`text-destructive`,onClick:l(()=>o(e.occurrence)),children:`Delete…`})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`p`,{className:`px-3 py-1.5 text-[11px] text-muted-foreground`,children:[ge(e.start),e.allDay?``:`, ${Z(e.start)}`]}),(0,Q.jsx)(Lt,{icon:(0,Q.jsx)(y,{className:`h-3.5 w-3.5`}),onClick:l(()=>s(e.start,e.allDay)),children:e.allDay?`New event`:`New event at ${Z(e.start)}`}),!e.allDay&&(0,Q.jsx)(Lt,{icon:(0,Q.jsx)(m,{className:`h-3.5 w-3.5`}),onClick:l(()=>s(e.start,!0)),children:`New all-day event`}),(0,Q.jsx)(Lt,{icon:(0,Q.jsx)(h,{className:`h-3.5 w-3.5`}),onClick:l(()=>c(e.start)),children:`Open day`})]})})}function Lt({icon:e,onClick:t,className:n,children:r}){return(0,Q.jsxs)(`button`,{type:`button`,onClick:t,className:x(`flex w-full items-center gap-2 rounded px-3 py-1.5 text-left hover:bg-accent`,n),children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:e}),r]})}var Rt=640,zt=420,Bt=30,Vt=14;function Ht(e,t,n,r){switch(e){case`day`:{let e=U(t);return{start:e,end:W(e,n)}}case`week`:{let e=ce(t);return{start:e,end:W(e,7)}}case`month`:{let e=K(t);return{start:e[0],end:W(e[41],1)}}case`year`:return{start:new Date(t.getFullYear(),0,1),end:new Date(t.getFullYear()+1,0,1)};case`schedule`:{let e=U(t);return{start:W(e,-r.before),end:W(e,r.after)}}}}function Ut(e,t,n,r){switch(e){case`day`:return W(t,n*r);case`week`:return W(t,7*r);case`month`:return se(t,r);case`year`:return new Date(t.getFullYear()+r,t.getMonth(),1);case`schedule`:return W(t,Bt*r)}}function Wt(e,t,n,r){switch(e){case`day`:return n>1?_e(t,W(t,n-1)):r?ge(t):he(t);case`week`:return ve(ce(t));case`month`:return pe(t);case`year`:return String(t.getFullYear());case`schedule`:return r?ge(t):`From ${he(t)}`}}function Gt({autoAdd:e=!1}){let t=te(),n=t?.mode===`workspace`?t.workspaceName:t?.mode===`context`?`ctx:${t.contextId}`:null,[i,a]=(0,z.useState)(()=>Je(n)),c=(0,z.useCallback)(e=>{a(t=>{let r={...t,...e};return Ye(n,r),r})},[n]),l=i.view,[f,m]=(0,z.useState)(()=>U(new Date)),[h,g]=(0,z.useState)(1),[_,y]=(0,z.useState)(null),b=r(),[S,C]=(0,z.useState)({before:0,after:Bt}),[w,T]=(0,z.useState)(()=>e?{kind:`draft`,draft:{start:Kt(),allDay:!1}}:null),[E,D]=(0,z.useState)(!1),k=(0,z.useRef)(null),[A,ee]=(0,z.useState)(1024);(0,z.useEffect)(()=>{let e=k.current;if(!e)return;let t=new ResizeObserver(e=>{for(let t of e)ee(t.contentRect.width)});return t.observe(e),()=>t.disconnect()},[]);let M=A<Rt,N=A<zt,P=(0,z.useMemo)(()=>Ht(l,f,h,S),[l,f,h,S]),{docs:F,loading:I,error:L,scope:R,knownCalendars:ne,reload:re,removeDoc:ae,patchDoc:B}=et(t,P.start,P.end,i.showTasks),V=(0,z.useMemo)(()=>{let e=new Map;for(let t of ne)e.set(t,t);for(let t of F){let n=t.data?.calendar;typeof n==`string`&&n.trim()&&e.set(n.trim().toLowerCase(),n.trim())}return i.defaultCalendar&&e.set(i.defaultCalendar.toLowerCase(),e.get(i.defaultCalendar.toLowerCase())??i.defaultCalendar),[...e.values()].sort((e,t)=>e.localeCompare(t))},[ne,F,i.defaultCalendar]),H=(0,z.useMemo)(()=>new Set(i.hidden),[i.hidden]),oe=(0,z.useMemo)(()=>F.some(e=>e.schema.startsWith(`data/schema/event`)&&!(typeof e.data?.calendar==`string`&&e.data.calendar.trim())),[F]),G=(0,z.useMemo)(()=>ze(F.filter(e=>{let t=typeof e.data?.calendar==`string`?e.data.calendar.trim().toLowerCase():``;return!H.has(t||``)}),P.start,P.end),[F,H,P]),K=w?.kind===`occurrence`?w.occurrence.key:null,q=(0,z.useCallback)((e,t)=>{m(U(e)),g(1),C({before:0,after:Bt}),t&&c({view:t})},[c]),J=(0,z.useCallback)((e,t)=>{let n=Math.round((U(t).getTime()-U(e).getTime())/ie);if(n>Vt){q(e,`month`);return}q(e,`day`),g(Math.max(1,n))},[q]),ue=(0,z.useCallback)(e=>{g(1),c({view:e})},[c]),Y=(0,z.useMemo)(()=>l===`day`||l===`week`?{start:P.start,end:P.end}:{start:f,end:W(f,1)},[l,P,f]),de=(0,z.useMemo)(()=>{if(w?.kind!==`draft`)return null;let{start:e,allDay:t,end:n}=w.draft;return{start:e,allDay:t,end:n??(t?W(U(e),1):new Date(e.getTime()+36e5))}},[w]),X=(0,z.useCallback)((e,t,n)=>T({kind:`draft`,draft:{start:e,allDay:t,end:n}}),[]),fe=(0,z.useCallback)(e=>T({kind:`occurrence`,occurrence:e}),[]),pe=(0,z.useCallback)(async(e,t,n)=>{if(!R)return;let r=e.doc,i=Ue(r.data??{},e,t,n);B({...r,data:i});try{await O(R.workspaceName,{id:r.id,schema:r.schema,schemaVersion:r.schemaVersion||`3.0`,data:i,metadata:r.metadata})}catch{B(r)}},[R,B]),me=(0,z.useCallback)(async e=>{if(!R)return;let t=e.doc,n=e.done?`pending`:`completed`,r={...t.data??{},status:n,completed:n===`completed`};B({...t,data:r});try{await O(R.workspaceName,{id:t.id,schema:t.schema,schemaVersion:t.schemaVersion,data:r,metadata:t.metadata})}catch{B(t)}},[R,B]),he=(0,z.useCallback)((e,t)=>y({x:e.clientX,y:e.clientY,kind:`entry`,occurrence:t}),[]),ge=(0,z.useCallback)((e,t,n)=>y({x:e.clientX,y:e.clientY,kind:`slot`,start:t,allDay:n}),[]),Z=(0,z.useCallback)(async e=>{let t=e.data?.title?`"${e.data.title}"`:`#${e.id}`;if(window.confirm(`Delete event ${t}?\n\nIt is removed from this path and moves to the workspace trash if nothing else links it.`))try{await ae(e.id),T(null)}catch{}},[ae]),_e=e=>{let t=e.target;if(!([`INPUT`,`TEXTAREA`,`SELECT`].includes(t.tagName)||t.isContentEditable)){if(e.key===`ArrowLeft`)ve(-1),e.preventDefault();else if(e.key===`ArrowRight`)ve(1),e.preventDefault();else if(e.key===`t`)q(new Date);else if(e.key===`n`)X(Kt(f),!1);else if(e.key===`Escape`)T(null),D(!1);else{let t=We.find(t=>t.key===e.key);t&&ue(t.id)}}},ve=e=>{let t=h;q(Ut(l,f,h,e)),g(t)};if(!t)return(0,Q.jsx)(`div`,{className:`flex h-full items-center justify-center p-6 text-center text-sm text-muted-foreground`,children:j(t)});let ye=e=>{let t=e.toLowerCase();c({hidden:H.has(t)?i.hidden.filter(e=>e!==t):[...i.hidden,t]})},be=(0,Q.jsxs)(`div`,{className:`space-y-1 text-xs`,children:[(0,Q.jsx)(`p`,{className:`px-1 text-[10px] uppercase tracking-wide text-muted-foreground`,children:`Calendars`}),V.map(e=>(0,Q.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 rounded px-1 py-0.5 hover:bg-muted`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,checked:!H.has(e.toLowerCase()),onChange:()=>ye(e),className:`h-3.5 w-3.5 accent-primary`,style:{accentColor:tt(e)}}),(0,Q.jsx)(`span`,{className:`h-2.5 w-2.5 shrink-0 rounded-sm`,style:{background:tt(e)}}),(0,Q.jsx)(`span`,{className:`truncate`,children:e})]},e)),oe&&(0,Q.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 rounded px-1 py-0.5 hover:bg-muted`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,checked:!H.has(``),onChange:()=>ye(``),className:`h-3.5 w-3.5 accent-primary`}),(0,Q.jsx)(`span`,{className:`h-2.5 w-2.5 shrink-0 rounded-sm`,style:{background:tt(``)}}),(0,Q.jsx)(`span`,{className:`truncate text-muted-foreground`,children:`Other events`})]}),(0,Q.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 rounded px-1 py-0.5 hover:bg-muted`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,checked:i.showTasks,onChange:e=>c({showTasks:e.target.checked}),className:`h-3.5 w-3.5 accent-primary`}),(0,Q.jsx)(`span`,{className:`h-2.5 w-2.5 shrink-0 rounded-sm`,style:{background:tt(je)}}),(0,Q.jsx)(`span`,{className:`truncate`,children:`Tasks (due dates)`})]})]}),xe=(()=>{switch(l){case`day`:return(0,Q.jsx)(gt,{days:Array.from({length:h},(e,t)=>W(U(f),t)),occurrences:G,selectedKey:K,pending:de,onSelect:fe,onCreate:X,onMove:pe,onPickDay:e=>q(e,`day`),onEntryMenu:he,onSlotMenu:ge,compact:N||h>3});case`week`:return(0,Q.jsx)(gt,{days:Array.from({length:7},(e,t)=>W(ce(f),t)),occurrences:G,selectedKey:K,pending:de,onSelect:fe,onCreate:X,onMove:pe,onPickDay:e=>q(e,`day`),onEntryMenu:he,onSlotMenu:ge,compact:M});case`month`:return(0,Q.jsx)(vt,{month:le(f),occurrences:G,selectedKey:K,pending:de,onSelect:fe,onCreate:X,onMove:pe,onPickDay:e=>q(e,`day`),onEntryMenu:he,onSlotMenu:ge,narrow:M});case`year`:return(0,Q.jsx)(yt,{year:f.getFullYear(),occurrences:G,onPickDay:e=>q(e,`day`),onPickRange:J,onPickMonth:e=>q(e,`month`),onSlotMenu:ge});case`schedule`:return(0,Q.jsx)(bt,{occurrences:G,selectedKey:K,onSelect:fe,onEntryMenu:he,loading:I,onEarlier:()=>C(e=>({...e,before:e.before+Bt})),onLater:()=>C(e=>({...e,after:e.after+Bt})),onPickDay:e=>q(e,`day`)})}})();return(0,Q.jsxs)(`div`,{ref:k,tabIndex:0,onKeyDown:_e,className:`relative flex h-full min-h-0 flex-col outline-none`,children:[(0,Q.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-1.5 border-b border-border px-2 py-1.5`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:()=>q(new Date),className:`rounded-md border border-border px-2 py-1 text-xs hover:bg-muted`,title:`Today (t)`,children:`Today`}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>ve(-1),className:`rounded-md p-1 text-muted-foreground hover:bg-muted hover:text-foreground`,"aria-label":`Previous`,title:`Previous (←)`,children:(0,Q.jsx)(o,{className:`h-4 w-4`})}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>ve(1),className:`rounded-md p-1 text-muted-foreground hover:bg-muted hover:text-foreground`,"aria-label":`Next`,title:`Next (→)`,children:(0,Q.jsx)(d,{className:`h-4 w-4`})}),(0,Q.jsx)(`span`,{className:`min-w-0 truncate text-sm font-semibold`,children:Wt(l,f,h,N)}),I&&(0,Q.jsx)(v,{className:`h-3.5 w-3.5 animate-spin text-muted-foreground`}),(0,Q.jsx)(`span`,{className:`flex-1`}),N?(0,Q.jsx)(`select`,{value:l,onChange:e=>ue(e.target.value),"aria-label":`View`,className:`h-7 rounded-md border border-input bg-transparent px-1.5 text-xs`,children:We.map(e=>(0,Q.jsx)(`option`,{value:e.id,children:e.label},e.id))}):(0,Q.jsx)(`div`,{className:`flex overflow-hidden rounded-md border border-border`,role:`tablist`,"aria-label":`View`,children:We.map(e=>(0,Q.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":l===e.id,onClick:()=>ue(e.id),title:`${e.label} (${e.key})`,className:x(`px-2 py-1 text-xs transition-colors`,l===e.id?`bg-foreground text-background`:`text-muted-foreground hover:bg-muted hover:text-foreground`),children:e.label},e.id))}),M&&(0,Q.jsx)(`button`,{type:`button`,onClick:()=>D(e=>!e),className:x(`rounded-md border p-1.5`,E?`border-foreground text-foreground`:`border-border text-muted-foreground hover:bg-muted hover:text-foreground`),"aria-label":`Calendars`,title:`Calendars`,children:(0,Q.jsx)(p,{className:`h-3.5 w-3.5`})}),(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>X(Kt(f),!1),className:`flex items-center gap-1 rounded-md bg-primary px-2 py-1.5 text-xs text-primary-foreground`,title:`New event (n)`,children:[(0,Q.jsx)(u,{className:`h-3.5 w-3.5`}),!N&&`Event`]})]}),L&&(0,Q.jsx)(`p`,{className:`border-b border-border px-3 py-2 text-xs text-destructive`,children:L}),(0,Q.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[!M&&(0,Q.jsxs)(`aside`,{className:`flex w-52 shrink-0 flex-col gap-4 overflow-y-auto border-r border-border p-3`,children:[(0,Q.jsx)(lt,{month:le(f),selection:Y,onPick:e=>q(e,l===`year`||l===`month`?`day`:l),onPickRange:J,onPrev:()=>m(e=>se(e,-1)),onNext:()=>m(e=>se(e,1))}),be]}),(0,Q.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[xe,M&&E&&(0,Q.jsx)(`div`,{className:`absolute right-2 top-2 z-20 w-56 rounded-md border border-border bg-popover p-2 text-popover-foreground shadow-elevation-2`,children:be})]}),w&&!M&&(0,Q.jsx)(`aside`,{className:`w-80 shrink-0 border-l border-border bg-card`,children:(0,Q.jsx)(jt,{subject:w,target:t,workspaceName:R?.workspaceName??null,calendars:V,defaultCalendar:i.defaultCalendar,onClose:()=>T(null),onSaved:e=>{e&&c({defaultCalendar:e}),T(null),re()},onDelete:Z})})]}),w&&M&&(0,Q.jsx)(`div`,{className:`absolute inset-0 z-30 flex flex-col bg-card`,children:(0,Q.jsx)(jt,{subject:w,target:t,workspaceName:R?.workspaceName??null,calendars:V,defaultCalendar:i.defaultCalendar,onClose:()=>T(null),onSaved:e=>{e&&c({defaultCalendar:e}),T(null),re()},onDelete:Z})}),_&&(0,Q.jsx)(It,{menu:_,onClose:()=>y(null),onOpen:fe,onOpenDocument:R?e=>b(`/workspaces/${encodeURIComponent(R.workspaceName)}/documents/${e.doc.id}`):null,onToggleDone:e=>{me(e)},onDelete:e=>{Z(e.doc)},onCreate:(e,t)=>X(e,t),onPickDay:e=>q(e,`day`)}),!I&&!L&&!F.length&&l!==`schedule`&&(0,Q.jsxs)(`p`,{className:`pointer-events-none absolute bottom-2 left-1/2 -translate-x-1/2 rounded-full bg-muted/80 px-3 py-1 text-[11px] text-muted-foreground`,children:[(0,Q.jsx)(s,{className:`mr-1 inline h-3 w-3`}),`Nothing here yet — click or drag a slot to add an event.`]})]})}function Kt(e){let t=new Date,n=e&&!qt(e,t)?new Date(e.getFullYear(),e.getMonth(),e.getDate(),9,0):new Date(t);return(!e||qt(e,t))&&n.setMinutes(t.getMinutes()<30?30:60,0,0),n}function qt(e,t){return e.toDateString()===t.toDateString()}export{Gt as CalendarApplet};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{l as e}from"./code-editor-BOIngd5F.js";import{t}from"./utils-2pl1SbIp.js";import{t as n}from"./lazy-editor-
|
|
1
|
+
import{l as e}from"./code-editor-BOIngd5F.js";import{t}from"./utils-2pl1SbIp.js";import{t as n}from"./lazy-editor-BUFAkTGl.js";var r=e();function i({kind:e,value:i,onChange:a,placeholder:o,rows:s=16,fill:c=!1}){return e===`markdown`?(0,r.jsx)(n,{value:i,onChange:a,placeholder:o,fill:c}):(0,r.jsx)(`textarea`,{value:i,onChange:e=>a(e.target.value),rows:c?void 0:s,placeholder:o,spellCheck:!1,className:t(`flex w-full rounded-md border border-input bg-transparent px-3 py-2 font-mono text-xs leading-relaxed shadow-elevation-1 transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`,c&&`h-full min-h-0 resize-none`)})}export{i 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{Kt as r,Mn as i,U as a,Un as o,Xt as s,ar as c,cn as l,dr as u,en as d,gt as f,ir as p,or as m,ot as h,qt as g,tt as _,ur as v}from"./ui-
|
|
1
|
+
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{Kt as r,Mn as i,U as a,Un as o,Xt as s,ar as c,cn as l,dr as u,en as d,gt as f,ir as p,or as m,ot as h,qt as g,tt as _,ur as v}from"./ui-CDoK3F3U.js";import{t as y}from"./utils-2pl1SbIp.js";var b=e(n(),1),x=[{color:`text-data-1`,chip:`bg-data-1/15`},{color:`text-data-2`,chip:`bg-data-2/15`},{color:`text-data-3`,chip:`bg-data-3/15`},{color:`text-data-4`,chip:`bg-data-4/15`},{color:`text-data-5`,chip:`bg-data-5/15`},{color:`text-data-6`,chip:`bg-data-6/15`},{color:`text-data-7`,chip:`bg-data-7/15`},{color:`text-data-8`,chip:`bg-data-8/15`},{color:`text-data-9`,chip:`bg-data-9/15`},{color:`text-data-10`,chip:`bg-data-10/15`},{color:`text-data-11`,chip:`bg-data-11/15`},{color:`text-data-12`,chip:`bg-data-12/15`}];function S(e,t){return{Icon:e,...x[t-1]}}var C={tab:S(o,7),link:S(o,7),email:S(l,3),note:S(_,3),task:S(h,5),message:S(d,6),identity:S(a,2),contact:S(a,2),device:S(s,10),application:S(r,11),dotfile:S(f,4),document:S(m,9)},w=[{test:/^image\//,spec:S(i,5)},{test:/^video\//,spec:S(p,11)},{test:/^audio\//,spec:S(g,10)},{test:/pdf$/,spec:S(m,1)},{test:/zip|tar|gzip|7z|rar|compressed/,spec:S(u,12)},{test:/json|javascript|typescript|xml|html|css|x-sh|python/,spec:S(v,6)},{test:/^text\//,spec:S(m,12)}],T=S(c,6),E=S(c,9);function D(e){let t=(e.schema||``).split(`/`).pop()||``;if(t===`file`){let t=String(e.metadata?.contentType||``).toLowerCase();return w.find(({test:e})=>e.test(t))?.spec||T}return C[t]||E}var O=t(),k={3.5:`h-3.5 w-3.5`,4:`h-4 w-4`,5:`h-5 w-5`,10:`h-10 w-10`};function A(e){let t=[],n=typeof e?.favIconUrl==`string`?e.favIconUrl:``;/^https?:\/\//i.test(n)&&t.push(n);let r=typeof e?.url==`string`?e.url:``;try{let e=new URL(r).origin;if(/^https?:/i.test(e)){let n=`${e}/favicon.ico`;t.includes(n)||t.push(n)}}catch{}return t}function j({document:e,size:t=4,chip:n=!1,className:r}){let i=D(e),a=e.schema===`data/schema/tab`?A(e.data):[],[o,s]=(0,b.useState)(0),c=a[o]??null,l=c?(0,O.jsx)(`img`,{src:c,alt:``,loading:`lazy`,onError:()=>s(e=>e+1),className:y(k[t],`rounded-xs object-contain`,!n&&`shrink-0`,!n&&r)}):(0,O.jsx)(i.Icon,{className:y(k[t],i.color,!n&&`shrink-0`,!n&&r)});return n?(0,O.jsx)(`span`,{className:y(`inline-flex shrink-0 items-center justify-center rounded-md`,t>=10?`p-3`:`p-1`,i.chip,r),children:l}):l}export{j 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{yt as r}from"./react-BHzhHVTZ.js";import{Qt as i,an as a,
|
|
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{Qt as i,an as a,kn as o,pi as s}from"./ui-CDoK3F3U.js";import{t as c}from"./utils-2pl1SbIp.js";import{t as l}from"./button-SeUZ_Pvi.js";var u=e(n(),1),d=e(r(),1),f=t();function p({title:e,onClose:t,onDetails:n,actions:r,children:p}){let[m,h]=(0,u.useState)(!0);return(0,d.createPortal)((0,f.jsx)(`div`,{className:c(`fixed inset-0 z-fullscreen flex bg-scrim`,m?`p-0`:`p-4 md:p-10`),children:(0,f.jsxs)(`div`,{className:c(`flex min-h-0 w-full flex-col overflow-hidden bg-background surface-glass`,m?``:`rounded-lg border shadow-elevation-4`),children:[(0,f.jsxs)(`div`,{className:`flex h-12 shrink-0 items-center gap-2 border-b px-3`,children:[(0,f.jsx)(l,{variant:`ghost`,size:`sm`,onClick:t,"aria-label":`Back`,title:`Back`,children:(0,f.jsx)(s,{className:`h-4 w-4`})}),e,(0,f.jsx)(`div`,{className:`flex-1`}),n&&(0,f.jsxs)(l,{variant:`ghost`,size:`sm`,onClick:n,title:`Edit details (title, tags, comment)`,children:[(0,f.jsx)(o,{className:`mr-1.5 h-4 w-4`}),` Details`]}),(0,f.jsx)(l,{variant:`ghost`,size:`sm`,onClick:()=>h(e=>!e),title:m?`Restore`:`Maximize`,"aria-label":m?`Restore`:`Maximize`,children:m?(0,f.jsx)(i,{className:`h-4 w-4`}):(0,f.jsx)(a,{className:`h-4 w-4`})}),r]}),(0,f.jsx)(`div`,{className:`min-h-0 flex-1`,children:p})]})}),window.document.body)}export{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{L as r,Pt as i,Tt as a,W as o,
|
|
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,Tt as a,W as o,di as s,pi as c}from"./ui-CDoK3F3U.js";import{t as l}from"./utils-2pl1SbIp.js";import{t as u}from"./button-SeUZ_Pvi.js";import{t as d}from"./label-BSTdjCWU.js";import{g as f,t as p}from"./LinkToCard-BQ1yoFDr.js";import{An as m,g as h,tt as g}from"./workspace-BJELPCNs.js";import{a as _,s as v,t as y}from"./useAddTarget-B3b6TyZr.js";import{n as b}from"./use-toolbox-Ck_cLGgf.js";import{n as x}from"./relation-events-CKio19hE.js";import{t as S}from"./useToastHelpers-CRrpIIdY.js";import{t as C}from"./DocumentIcon-9i1uCMQa.js";import{n as w}from"./LinkToSidePanel-eCy3nW4R.js";import{a as T,i as E,o as D,r as O,t as k}from"./UploadProgressList-Ci1akl_D.js";var A=e(n(),1),j=`references`;function M(e){return e?e.documents.map(e=>({predicate:j,direction:`out`,targetId:e.id,document:e})):[]}function N(e,t){let[n,r]=(0,A.useState)(()=>M(t)),i=e?.mode===`context`?e.contextId:null,[a,o]=(0,A.useState)(null);(0,A.useEffect)(()=>{if(!i)return;let e=!1;return _({mode:`context`,contextId:i}).then(t=>{e||o({contextId:i,workspaceName:t.workspaceName})}).catch(()=>{}),()=>{e=!0}},[i]);let s=e?.mode===`workspace`?e.workspaceName:i&&a?.contextId===i?a.workspaceName:t?.workspaceName??null,{predicates:c}=f(s);return{rows:n,predicates:c,workspaceName:s,add:(0,A.useCallback)(async(e,t,i)=>{let a=i.filter(r=>!n.some(n=>n.targetId===r&&n.predicate===e&&n.direction===t));if(a.length===0)return;let o=await Promise.all(a.map(e=>s?g(s,e).catch(()=>null):Promise.resolve(null)));r(n=>[...n,...a.map((n,r)=>({predicate:e,direction:t,targetId:n,document:o[r]??null}))])},[n,s]),update:(0,A.useCallback)((e,t)=>{r(n=>n.map((n,r)=>r===e?{...n,...t}:n))},[]),remove:(0,A.useCallback)(e=>{r(t=>t.filter((t,n)=>n!==e))},[]),write:(0,A.useCallback)(async e=>{if(n.length===0||e.length===0||!s)return 0;let t=new Map;for(let e of n){let n=`${e.direction}:${e.predicate}`,r=t.get(n)??{predicate:e.predicate,direction:e.direction,targets:[]};r.targets.push(e.targetId),t.set(n,r)}let r=0;for(let n of e)for(let e of t.values())try{await h(s,n,e.predicate,e.targets,e.direction)}catch(t){r+=1,console.error(`Failed to relate document`,n,e.predicate,t)}return r<e.length*t.size&&x(),r},[n,s]),hasRows:n.length>0}}var P=t();function F({f:e,idPrefix:t}){let[n,a]=(0,A.useState)(!1),[o,f]=(0,A.useState)(!1),h=!e.workspaceName;return(0,P.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,P.jsx)(d,{children:`Related documents`}),(0,P.jsxs)(u,{type:`button`,variant:`ghost`,size:`sm`,className:`h-7 px-2 text-xs`,disabled:h,onClick:()=>a(!0),title:h?`No workspace to relate within`:`Pick documents the new one relates to`,children:[(0,P.jsx)(i,{className:`mr-1 h-3 w-3`}),` Add`]})]}),e.rows.length===0?(0,P.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`None. Relations are written right after the document is created.`}):(0,P.jsx)(`ul`,{className:`space-y-1`,children:e.rows.map((n,i)=>{let a=n.document?m(n.document).title:`Document ${n.targetId}`,o=`${t}-relation-${i}`;return(0,P.jsxs)(`li`,{className:`flex items-center gap-1.5 rounded-md border border-input px-2 py-1.5 text-sm`,children:[(0,P.jsx)(`button`,{type:`button`,onClick:()=>e.update(i,{direction:n.direction===`out`?`in`:`out`}),className:`shrink-0 rounded p-0.5 text-muted-foreground hover:bg-accent hover:text-foreground`,title:n.direction===`out`?`The new document ${n.predicate} this one (click to flip)`:`This document ${n.predicate} the new one (click to flip)`,"aria-label":`Flip relation direction`,children:n.direction===`out`?(0,P.jsx)(s,{className:`h-3.5 w-3.5`}):(0,P.jsx)(c,{className:`h-3.5 w-3.5`})}),(0,P.jsx)(`label`,{htmlFor:o,className:`sr-only`,children:`Predicate`}),(0,P.jsx)(`select`,{id:o,value:n.predicate,onChange:t=>e.update(i,{predicate:t.target.value}),className:`w-[9.5rem] shrink-0 rounded-md border border-input bg-background px-1.5 py-1 font-mono text-[11px] focus:outline-none focus:ring-2 focus:ring-ring`,children:(e.predicates.includes(n.predicate)?e.predicates:[n.predicate,...e.predicates]).map(e=>(0,P.jsx)(`option`,{value:e,children:e},e))}),n.document?(0,P.jsx)(C,{document:n.document,size:3.5}):null,(0,P.jsx)(`span`,{className:l(`min-w-0 flex-1 truncate`,!n.document&&`italic text-muted-foreground`),title:a,children:a}),(0,P.jsx)(`button`,{type:`button`,onClick:()=>e.remove(i),className:`shrink-0 rounded p-0.5 text-muted-foreground hover:bg-destructive/10 hover:text-destructive`,title:`Remove`,"aria-label":`Remove relation`,children:(0,P.jsx)(r,{className:`h-3.5 w-3.5`})})]},`${n.direction}:${n.predicate}:${n.targetId}`)})}),n&&e.workspaceName&&(0,P.jsx)(w,{onClose:()=>{o||a(!1)},children:(0,P.jsx)(p,{sizeClassName:`h-full w-[380px] max-w-[90vw] max-md:w-full`,title:`Relate to…`,confirmLabel:`Add`,tabs:[`relations`],fixedWorkspaceName:e.workspaceName,documentCount:1,saving:o,relationPredicates:e.predicates,relationExcludeIds:new Set(e.rows.map(e=>e.targetId)),onClose:()=>a(!1),onConfirm:()=>{},onConfirmRelation:async({predicate:t,direction:n,targetIds:r})=>{f(!0);try{await e.add(t,n,r),a(!1)}finally{f(!1)}}})})]})}function I({capture:e=!1,target:t,initialFiles:n=[],onClose:r,onBusyChange:i}={}){let{closeAdd:s,state:c}=b(),d=v(),f=t===void 0?d:t,p=r??s,m=f?.mode===`workspace`&&f.treeName===`backends`,h=N(f,t===void 0?c.addRelateTo:null),{showSuccessToast:g,showErrorToast:x}=S(),C=(0,A.useRef)(null),[w,j]=(0,A.useState)(!1),M=O(n),{items:I,running:L}=M,R=(0,A.useRef)(!1),z=(0,A.useRef)(!1),[B,V]=(0,A.useState)(!1),[H,U]=(0,A.useState)(null);(0,A.useEffect)(()=>{if(f?.mode!==`context`)return;let e=!1;return _(f).then(t=>{e||U({contextId:f.contextId,workspaceName:t.workspaceName})}).catch(()=>{}),()=>{e=!0}},[f]);let W=f?.mode===`workspace`?f.workspaceName:f&&H?.contextId===f.contextId?H.workspaceName:null,G=D(W),K=e=>{e&&M.addFiles(Array.from(e))},q=e=>{e.preventDefault(),j(!1),K(e.dataTransfer.files)},J=I.filter(e=>e.status===`error`).length,Y=I.filter(e=>e.status===`done`).length,X=I.length-Y,Z=!!f&&!B&&X>0;return(0,P.jsxs)(`div`,{className:`flex flex-col gap-4 p-4`,children:[(0,P.jsxs)(`div`,{onDragOver:e=>{e.preventDefault(),j(!0)},onDragLeave:()=>j(!1),onDrop:q,onClick:()=>C.current?.click(),className:l(`flex cursor-pointer flex-col items-center justify-center gap-2 rounded-md border border-dashed px-4 py-8 text-center transition-colors`,w?`border-primary bg-primary/5`:`border-input hover:bg-muted/40`),children:[(0,P.jsx)(o,{className:`h-6 w-6 text-muted-foreground touch-target`}),(0,P.jsx)(`p`,{className:`text-sm`,children:e?`Take a photo or video`:`Drag & drop files here`}),(0,P.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e?`click to open the camera`:`or click to browse`}),(0,P.jsx)(`input`,{ref:C,type:`file`,multiple:!0,accept:e?`image/*,video/*`:void 0,capture:e?`environment`:void 0,className:`hidden`,onChange:e=>{K(e.target.files),e.target.value=``}})]}),(0,P.jsx)(k,{items:I,running:L,onRemove:M.removeItem}),!m&&(0,P.jsx)(E,{fields:G,idPrefix:`file`,multiple:I.length>1}),(0,P.jsx)(F,{f:h,idPrefix:`file`}),(0,P.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[y(f),m?`. Existing files are never overwritten.`:``]}),(0,P.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,P.jsx)(u,{variant:`outline`,size:`sm`,onClick:()=>{B?(z.current=!0,M.cancel()):p()},children:`Cancel`}),(0,P.jsx)(u,{size:`sm`,onClick:async()=>{if(!(!Z||!f||R.current)){R.current=!0,z.current=!1,V(!0),i?.(!0);try{let e=m?null:await G.geotag.capture();if(z.current)return;let t=await M.start(f,(t,n)=>T(t,n,{tags:G.tags,comment:G.comment,geo:e})),n=await h.write(t.docIds);if(t.failed===0){let e=t.resumed?` (${t.resumed} already uploaded)`:``,r=n?`; some relations failed`:``;g(`${t.done} file(s) uploaded${e}${r}`),p()}else x(`${t.failed} of ${t.total} file(s) failed — retry keeps what already made it`)}catch(e){x(e instanceof Error?e.message:`Failed to upload files`)}finally{R.current=!1,V(!1),i?.(!1)}}},disabled:!Z,children:B?`Uploading…`:J>0?(0,P.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,P.jsx)(a,{className:`h-3.5 w-3.5`}),`Retry failed (`,J,`)`]}):`Add files`})]})]})}export{F as n,N as r,I 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{t as r}from"./socket-CtH3EU9m.js";import{r as i}from"./use-toolbox-Ck_cLGgf.js";import{n as a}from"./use-applet-target-
|
|
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"./socket-CtH3EU9m.js";import{r as i}from"./use-toolbox-Ck_cLGgf.js";import{n as a}from"./use-applet-target-ffIGaAqT.js";import{C as o,M as s,v as c}from"./index-DRHEGJ8I.js";var l=e(n(),1),u=t();function d(){let e=a(),t=i()?.state,n=!!t&&(e?.mode===`context`?t.activeContextType===`context`&&t.activeContextId===e.contextId:e?.mode===`workspace`?t.activeContextType!==`context`&&t.activeWorkspaceName===e.workspaceName&&t.activeTreeName===e.treeName&&t.activeContextPath===e.path:!t.activeWorkspaceName&&!t.activeContextId),d=!n&&e?.mode===`context`?e.contextId:null;return(0,l.useEffect)(()=>{if(!d)return;let e=`context:${d}`,t=()=>r.emit(`subscribe`,{channel:e}),n=r.on(`connect`,t);return t(),()=>{n(),r.emit(`unsubscribe`,{channel:e})}},[d]),n?(0,u.jsx)(c,{}):(0,u.jsx)(s,{target:e,children:(0,u.jsx)(o,{children:(0,u.jsx)(c,{})})})}export{d as FiltersApplet};
|
|
@@ -1,3 +1,3 @@
|
|
|
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{Gr as a,L as o,Pt as s,U as c,W as l,_n as u,ar as d,hn as f,tt as p}from"./ui-
|
|
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{Gr as a,L as o,Pt as s,U as c,W as l,_n as u,ar as d,hn as f,tt as p}from"./ui-CDoK3F3U.js";import{t as m}from"./utils-2pl1SbIp.js";import{t as h}from"./input-BOtCd4HP.js";import{t as g}from"./label-BSTdjCWU.js";import{t as _}from"./LinkToCard-BQ1yoFDr.js";import{zt as v}from"./workspace-BJELPCNs.js";import{t as y}from"./use-mobile-Db-vWu9Y.js";import{a as b,i as x,s as S,t as ee}from"./IdentityFields-DZRqtnIG.js";import{n as C,r as te}from"./use-toolbox-Ck_cLGgf.js";import{l as ne}from"./date-time-picker-txVhlNO0.js";import{n as w,t as re}from"./PickDocumentsCard-CFDQL70e.js";import{t as T}from"./useToastHelpers-CRrpIIdY.js";import{r as E,t as D}from"./note-save-status-DPz4VzL6.js";import{t as O}from"./DocumentBodyEditor-CVO5KPCs.js";import{a as k,i as A,n as j,o as M,r as N,s as P,t as F}from"./UploadProgressList-Ci1akl_D.js";import{A as I,O as L,j as R,k as z}from"./index-DRHEGJ8I.js";var B=e(r(),1),V=e(n(),1),H=t();function U({onClose:e,initialData:t,draftId:n}){let r=z(void 0,void 0,`home-card:${n}`);return(0,V.useEffect)(()=>{t?.title&&r.setTitle(t.title),t?.content&&r.setContent(t.content)},[]),(0,H.jsx)(w,{title:`New Note`,icon:p,onClose:e,onSave:async e=>{let t=await r.save({mode:`workspace`,...e});return r.finish(),t},canSave:r.canSave,saving:r.saving,successMessage:`Note created`,children:(0,H.jsxs)(`div`,{className:`flex h-full flex-col gap-4 p-4`,children:[(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsx)(g,{htmlFor:`qa-note-title`,children:`Title`}),(0,H.jsx)(h,{id:`qa-note-title`,value:r.title,onChange:e=>r.setTitle(e.target.value),placeholder:`Optional; defaults to today's date`})]}),(0,H.jsxs)(`div`,{className:`flex flex-1 flex-col gap-1.5`,children:[(0,H.jsx)(g,{children:`Body`}),(0,H.jsx)(`div`,{className:`flex-1`,children:(0,H.jsx)(O,{kind:`markdown`,value:r.content,onChange:r.setContent,placeholder:`Write your note…`})})]}),(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsx)(g,{children:`Tags`}),(0,H.jsx)(S,{tags:r.tags,onChange:r.setTags})]}),(0,H.jsx)(D,{...r,onRetry:r.retry}),(0,H.jsx)(P,{geotag:r.geotag,idPrefix:`qa-note-geotag`})]})})}function W({onClose:e,initialData:t}){let n=L();return(0,V.useEffect)(()=>{t?.url&&n.setUrl(t.url),t?.title&&n.setTitle(t.title)},[]),(0,H.jsx)(w,{title:`New Link`,icon:u,onClose:e,onSave:e=>n.save({mode:`workspace`,...e}),canSave:n.canSave,saving:n.saving,successMessage:`Link created`,children:(0,H.jsxs)(`div`,{className:`flex flex-col gap-4 p-4`,children:[(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsx)(g,{htmlFor:`qa-link-url`,children:`URL`}),(0,H.jsx)(h,{id:`qa-link-url`,value:n.url,onChange:e=>n.setUrl(e.target.value),placeholder:`https://example.com`,autoFocus:!0}),n.showUrlError&&(0,H.jsx)(`p`,{className:`text-xs text-destructive`,children:`Enter a valid URL, e.g. https://example.com`})]}),(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsx)(g,{htmlFor:`qa-link-title`,children:`Title`}),(0,H.jsx)(h,{id:`qa-link-title`,value:n.title,onChange:e=>n.setTitle(e.target.value),placeholder:`Optional display title`})]}),(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsx)(g,{children:`Tags`}),(0,H.jsx)(S,{tags:n.tags,onChange:n.setTags})]}),(0,H.jsx)(P,{geotag:n.geotag,idPrefix:`qa-link-geotag`})]})})}function G({onClose:e,initialData:t}){let n=ne();return(0,V.useEffect)(()=>{t?.title&&n.setTitle(t.title),t?.content&&n.setDescription(t.content)},[]),(0,H.jsx)(w,{title:`New Todo`,icon:f,onClose:e,onSave:e=>n.save({mode:`workspace`,...e}),canSave:n.canSave,saving:n.saving,successMessage:`Todo created`,children:(0,H.jsxs)(`div`,{className:`flex h-full flex-col gap-4 p-4`,children:[(0,H.jsx)(b,{...n,idPrefix:`qa-todo`}),(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsx)(g,{children:`Tags`}),(0,H.jsx)(S,{tags:n.tags,onChange:n.setTags})]}),(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsx)(g,{htmlFor:`qa-todo-comment`,children:`Comment`}),(0,H.jsx)(`textarea`,{id:`qa-todo-comment`,value:n.comment,onChange:e=>n.setComment(e.target.value),rows:3,placeholder:`Optional context`,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`})]}),(0,H.jsx)(P,{geotag:n.geotag,idPrefix:`qa-todo-geotag`})]})})}function K({onClose:e,initialData:t}){let n=x();return(0,V.useEffect)(()=>{t?.title&&n.setDisplayName(t.title)},[]),(0,H.jsx)(w,{title:`New Identity`,icon:c,onClose:e,onSave:e=>n.save({mode:`workspace`,...e}),canSave:n.canSave,saving:n.saving,successMessage:`Identity created`,children:(0,H.jsxs)(`div`,{className:`flex h-full flex-col gap-4 p-4`,children:[(0,H.jsx)(ee,{idPrefix:`qa-identity`,...n,emailValid:n.emailValid}),(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsx)(g,{children:`Tags`}),(0,H.jsx)(S,{tags:n.tags,onChange:n.setTags})]}),(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsx)(g,{htmlFor:`qa-identity-comment`,children:`Comment`}),(0,H.jsx)(`textarea`,{id:`qa-identity-comment`,value:n.comment,onChange:e=>n.setComment(e.target.value),rows:3,placeholder:`How you know them, where they came from…`,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`})]})]})})}var q={jpg:`image/jpeg`,jpeg:`image/jpeg`,png:`image/png`,gif:`image/gif`,webp:`image/webp`,avif:`image/avif`,heic:`image/heic`,heif:`image/heif`,bmp:`image/bmp`,tif:`image/tiff`,tiff:`image/tiff`,svg:`image/svg+xml`,mp4:`video/mp4`,mov:`video/quicktime`,webm:`video/webm`,"3gp":`video/3gpp`};function J(e){return/^(image|video)\//.test(e.type)}async function Y(e){let t=await Promise.all(e.map(async e=>{let t=new Uint8Array(await e.slice(0,64).arrayBuffer()),n=(e,n)=>String.fromCharCode(...t.slice(e,e+n)),r=``;if(t[0]===255&&t[1]===216&&t[2]===255)r=`image/jpeg`;else if(n(0,8)===`PNG\r
|
|
2
2
|
|
|
3
3
|
`)r=`image/png`;else if([`GIF87a`,`GIF89a`].includes(n(0,6)))r=`image/gif`;else if(n(0,4)===`RIFF`&&n(8,4)===`WEBP`)r=`image/webp`;else if(n(0,5)===`%PDF-`)r=`application/pdf`;else if(n(0,4)===`PK`)r=`application/zip`;else if(n(4,4)===`ftyp`){let e=[n(8,4)],i=new DataView(t.buffer).getUint32(0);for(let r=16;r+4<=Math.min(t.length,i);r+=4)e.push(n(r,4));e.some(e=>[`avif`,`avis`].includes(e))?r=`image/avif`:e.some(e=>[`heic`,`heix`,`hevc`,`hevx`].includes(e))?r=`image/heic`:e.some(e=>[`mif1`,`msf1`].includes(e))?r=`image/heif`:e.includes(`qt `)?r=`video/quicktime`:e.some(e=>[`isom`,`iso2`,`mp41`,`mp42`,`avc1`,`M4V `].includes(e))&&(r=`video/mp4`)}let i=e.type.toLowerCase().split(`;`)[0].trim(),a=!i||[`application/octet-stream`,`binary/octet-stream`,`*/*`].includes(i),o=e.name.split(`.`).pop()?.toLowerCase()??``,s=r||a&&q[o]||i;return s===e.type?e:new File([e],e.name,{type:s,lastModified:e.lastModified})}));return{kind:t.length>0&&t.every(J)?`photo`:`file`,files:t}}function X({file:e}){let t=(0,V.useRef)(null),[n,r]=(0,V.useState)(!1);return(0,V.useEffect)(()=>{let n=t.current;if(!n)return;let r=URL.createObjectURL(e);return n.src=r,()=>{n.removeAttribute(`src`),URL.revokeObjectURL(r)}},[e]),(0,H.jsx)(`div`,{className:`flex min-h-24 items-center justify-center overflow-hidden rounded-md border border-input bg-muted/30`,children:n?(0,H.jsxs)(`p`,{className:`p-4 text-center text-sm text-muted-foreground`,children:[`Preview unavailable for `,e.name,`. You can still save the original.`]}):e.type.startsWith(`video/`)?(0,H.jsx)(`video`,{ref:t,controls:!0,preload:`metadata`,"aria-label":e.name,onError:()=>r(!0),className:`max-h-64 max-w-full`}):(0,H.jsx)(`img`,{ref:t,alt:e.name,onError:()=>r(!0),className:`max-h-64 max-w-full object-contain`})})}function ie({onClose:e,initialData:t}){let n=(0,V.useRef)(null),r=N(t?.files),i=r.items.map(e=>e.file),[a,o]=(0,V.useState)(!1),[s,c]=(0,V.useState)(!1),{state:u}=C(),d=M(u.activeWorkspaceName),f=e=>{e&&(s||r.addFiles(Array.from(e)))},p=e=>{e.preventDefault(),o(!1),f(e.dataTransfer.files)},h=i.length>0;return(0,H.jsx)(w,{title:`Upload File`,icon:l,onClose:e,onSave:async e=>{c(!0);try{let t={mode:`workspace`,...e},n=await d.geotag.capture(),i=await r.start(t,(e,t)=>k(e,t,{tags:d.tags,comment:d.comment,geo:n}));if(i.failed)throw Error(`${i.failed} file(s) failed or cancelled. Retry keeps completed uploads.`);return i.docIds}finally{c(!1)}},navigateAfterSave:!0,canSave:h,saving:s,saveProgress:(0,H.jsx)(j,{items:r.items,running:r.running,onCancel:r.cancel}),successMessage:`File(s) uploaded`,children:(0,H.jsxs)(`div`,{className:`flex flex-col gap-4 p-4`,children:[(0,H.jsxs)(`div`,{onDragOver:e=>{e.preventDefault(),o(!0)},onDragLeave:()=>o(!1),onDrop:p,onClick:()=>n.current?.click(),className:m(`flex cursor-pointer flex-col items-center justify-center gap-2 rounded-md border border-dashed px-4 py-8 text-center transition-colors`,a?`border-primary bg-primary/5`:`border-input hover:bg-muted/40`),children:[(0,H.jsx)(l,{className:`h-6 w-6 text-muted-foreground touch-target`}),(0,H.jsx)(`p`,{className:`text-sm`,children:`Drag & drop files here`}),(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`or click to browse`}),(0,H.jsx)(`input`,{ref:n,type:`file`,multiple:!0,disabled:s,className:`hidden`,onChange:e=>{f(e.target.files),e.target.value=``}})]}),r.items.filter(e=>J(e.file)).map(e=>(0,H.jsx)(X,{file:e.file},e.id)),(0,H.jsx)(F,{items:r.items,running:s,onRemove:r.removeItem}),(0,H.jsx)(A,{fields:d,idPrefix:`qa-file`,multiple:i.length>1})]})})}function ae({onClose:e,initialData:t}){let n=N(t?.files),r=(0,V.useRef)(null),i=n.items.length>0,[s,c]=(0,V.useState)(!1),{state:l}=C(),u=M(l.activeWorkspaceName),f=e=>{!s&&e&&n.addFiles([e])};return(0,H.jsx)(w,{title:`Photo/Video`,icon:a,onClose:e,onSave:async e=>{if(!i)return[];c(!0);try{let t=await u.geotag.capture(),r={mode:`workspace`,...e},i=await n.start(r,(e,n)=>k(e,n,{tags:u.tags,comment:u.comment,geo:t}));if(i.failed)throw Error(`Upload failed or cancelled. You can retry.`);return i.docIds}finally{c(!1)}},navigateAfterSave:!0,canSave:i,saving:s,saveProgress:(0,H.jsx)(j,{items:n.items,running:n.running,onCancel:n.cancel}),successMessage:`Upload saved`,children:(0,H.jsxs)(`div`,{className:m(`flex h-full flex-col gap-4 p-4`,!i&&`items-center justify-center`),children:[i?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{className:`flex min-h-0 w-full flex-1 flex-col gap-3 overflow-y-auto`,children:n.items.map(({id:e,file:t,status:r})=>(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsx)(X,{file:t}),(0,H.jsxs)(`div`,{className:`flex w-full items-center gap-2 rounded border border-input px-3 py-2 text-sm`,children:[(0,H.jsx)(d,{className:`h-4 w-4 shrink-0 text-muted-foreground`}),(0,H.jsx)(`span`,{className:`flex-1 truncate`,children:t.name}),(0,H.jsxs)(`span`,{className:`shrink-0 text-xs text-muted-foreground`,children:[(t.size/1024/1024).toFixed(1),` MB`]}),(0,H.jsx)(`button`,{type:`button`,disabled:s||r===`done`,onClick:()=>n.removeItem(e),"aria-label":`Remove ${t.name}`,className:`text-muted-foreground hover:text-foreground disabled:opacity-40`,children:(0,H.jsx)(o,{className:`h-3.5 w-3.5`})})]})]},e))}),(0,H.jsx)(`div`,{className:`w-full shrink-0 space-y-4`,children:(0,H.jsx)(A,{fields:u,idPrefix:`qa-photo`,multiple:n.items.length>1})})]}):(0,H.jsxs)(`button`,{type:`button`,onClick:()=>r.current?.click(),className:`flex flex-col items-center gap-2 rounded-md border border-dashed border-input px-6 py-10 text-center transition-colors hover:bg-muted/40`,children:[(0,H.jsx)(a,{className:`h-8 w-8 text-muted-foreground`}),(0,H.jsx)(`span`,{className:`text-sm`,children:`Open camera`})]}),(0,H.jsx)(`input`,{ref:r,type:`file`,accept:`image/*,video/*`,capture:`environment`,className:`hidden`,disabled:s,onChange:e=>{f(e.target.files?.[0]??null),e.target.value=``}})]})})}var Z=`shrink-0 h-viewport-card w-[min(380px,90vw)] max-md:fixed max-md:inset-2 max-md:z-40 max-md:h-auto max-md:w-auto max-md:shadow-elevation-5`;function oe({onClose:e}){let{showSuccessToast:t,showErrorToast:n}=T(),[r,i]=(0,V.useState)(null),[a,o]=(0,V.useState)(!1);return r?(0,H.jsx)(_,{sizeClassName:Z,documentCount:r.length,saving:a,onClose:e,onConfirm:async(i,a)=>{o(!0);try{await Promise.all(i.map(e=>v(a.workspaceName,e,r,a.treeName,a.treeType))),t(`${r.length} document${r.length===1?``:`s`} linked`),e()}catch(e){n(e instanceof Error?e.message:`Failed to link documents`)}finally{o(!1)}}}):(0,H.jsx)(re,{sizeClassName:Z,onConfirm:e=>{e.length&&i(e)},onClose:e})}function Q(){let e=E(`new:home-card:`);try{return Object.keys(localStorage).filter(t=>t.startsWith(e)&&t.endsWith(`:home`)).filter(e=>{let t=JSON.parse(localStorage.getItem(e)||`null`)?.value;return t&&(t.title||t.content||t.comment||t.tags?.length)}).map(t=>t.slice(e.length,-5))}catch{return[]}}var $=0;function se(){return $+=1,`card-${$}`}function ce({initialKind:e,initialData:t,onInitialCardClose:n,onCardsOpenChange:r}){let[a,c]=(0,V.useState)(!1),l=y(),u=te(),d=!!(u?.state.t1Open||u?.state.addOpen),[f,p]=(0,V.useState)(()=>e?[{id:`initial`,kind:e,initialData:t,noteDraftId:crypto.randomUUID()}]:Q().map(e=>({id:e,kind:`note`,noteDraftId:e}))),h=f.length>0,g=(0,V.useRef)(r);(0,V.useEffect)(()=>{g.current=r},[r]),(0,V.useEffect)(()=>{g.current?.(h)},[h]),d&&a&&c(!1);let _=i(),v=e=>{if(e===`sketch`){c(!1),_(R.createUrl(null));return}let t=e===`note`?Q().find(e=>!f.some(t=>t.noteDraftId===e))||crypto.randomUUID():void 0;p(n=>[...n,{id:se(),kind:e,noteDraftId:t}]),c(!1)},b=e=>{p(t=>t.filter(t=>t.id!==e)),e===`initial`&&n?.()},x=(0,H.jsxs)(`div`,{className:m(`pointer-events-none fixed right-6 z-40 flex flex-col items-end gap-2`,`bottom-fab-inset md:bottom-[calc(var(--spacing-fab-inset)+5rem)]`,f.length>0&&`max-md:hidden`,d&&`hidden`),children:[(0,H.jsx)(`div`,{className:m(`flex flex-col items-end gap-2 transition-all duration-fast`,a?`pointer-events-auto opacity-100`:`pointer-events-none translate-y-2 opacity-0`),children:(0,H.jsx)(I,{variant:`stack`,omit:[`plaintext`,`folder`,`message`],onSelect:v})}),(0,H.jsx)(`div`,{className:`pointer-events-none flex w-16 justify-center`,children:(0,H.jsx)(`button`,{type:`button`,onClick:()=>c(e=>!e),"aria-label":a?`Close quick add`:`Quick add`,className:`pointer-events-auto flex h-11 w-11 items-center justify-center rounded-full bg-primary text-primary-foreground shadow-elevation-3 transition-transform hover:scale-105`,children:a?(0,H.jsx)(o,{className:`h-5 w-5`}):(0,H.jsx)(s,{className:`h-5 w-5`})})})]});return(0,H.jsxs)(`div`,{className:`relative flex h-full w-full flex-col`,children:[f.length>0&&(0,H.jsx)(`div`,{className:`pointer-events-auto flex flex-1 items-center gap-4 overflow-x-auto p-6 md:pr-28`,children:f.map(e=>{let t=()=>b(e.id);switch(e.kind){case`note`:return(0,H.jsx)(U,{draftId:e.noteDraftId,onClose:t,initialData:e.initialData},e.id);case`link`:return(0,H.jsx)(W,{onClose:t,initialData:e.initialData},e.id);case`todo`:return(0,H.jsx)(G,{onClose:t,initialData:e.initialData},e.id);case`identity`:return(0,H.jsx)(K,{onClose:t,initialData:e.initialData},e.id);case`file`:return(0,H.jsx)(ie,{onClose:t,initialData:e.initialData},e.id);case`photo`:return(0,H.jsx)(ae,{onClose:t,initialData:e.initialData},e.id);case`existing`:return(0,H.jsx)(oe,{onClose:t},e.id);case`sketch`:return null;case`folder`:case`message`:return null}})}),l?(0,B.createPortal)(x,document.body):x]})}export{Y as n,ce 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{yt as r}from"./react-BHzhHVTZ.js";import{L as i,Pt as a,Wr as o,X as s,fn as c,nt as l,pn as u,sn as d,vn as f,xr as p,yt as m}from"./ui-76Hw0NU_.js";import{t as h}from"./utils-2pl1SbIp.js";import{t as g}from"./input-BOtCd4HP.js";import{t as _}from"./label-DJc8-3CQ.js";import{An as v,Rn as y,Wn as b,g as x,wt as S}from"./workspace-46EFyEKZ.js";import{n as C}from"./tags-YamdPoBK.js";import{o as w}from"./useAddTarget-D4ra50Am.js";import{n as T,r as E,t as D}from"./date-time-picker-Bzu8H_Oa.js";import{t as O}from"./useEscapeClose-DR_xKT_k.js";import{n as k}from"./map-BxCwdK0d.js";var A=e(n(),1),j=(0,A.createContext)(null),M=t();function N({tags:e,onChange:t,placeholder:n=`Add tag, press Enter`,suggestions:r=[]}){let[a,o]=(0,A.useState)(``),[s,c]=(0,A.useState)(!1),l=a.trim().toLowerCase(),u=(l?r.filter(t=>t.toLowerCase().includes(l)&&!e.includes(t)):s?r.filter(t=>!e.includes(t)):[]).slice(0,8),d=()=>{let n=a.trim();n&&!e.includes(n)&&t([...e,n]),o(``)};return(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 rounded-md border border-input bg-transparent px-2 py-1.5 focus-within:ring-1 focus-within:ring-ring`,children:[e.map(n=>(0,M.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded bg-muted px-1.5 py-0.5 text-xs`,children:[n,(0,M.jsx)(`button`,{type:`button`,onClick:()=>t(e.filter(e=>e!==n)),className:`text-muted-foreground hover:text-foreground`,"aria-label":`Remove ${n}`,children:(0,M.jsx)(i,{className:`h-3 w-3`})})]},n)),(0,M.jsxs)(`div`,{className:`relative flex-1 min-w-[8ch]`,children:[(0,M.jsx)(`input`,{value:a,onChange:e=>o(e.target.value),onKeyDown:n=>{n.key===`Enter`||n.key===`,`?(n.preventDefault(),d()):n.key===`Backspace`&&!a&&e.length&&t(e.slice(0,-1))},onFocus:()=>c(!0),onBlur:()=>{setTimeout(d,150),c(!1)},placeholder:e.length?``:n,className:`w-full bg-transparent text-sm outline-none placeholder:text-muted-foreground`}),u.length>0&&(0,M.jsx)(`div`,{className:`absolute left-0 top-full z-50 mt-1 max-h-48 w-56 overflow-auto rounded-md border bg-popover p-1 text-sm shadow-elevation-2`,children:u.map(n=>(0,M.jsx)(`button`,{type:`button`,onMouseDown:r=>{r.preventDefault(),e.includes(n)||t([...e,n]),o(``)},className:`block w-full rounded px-2 py-1 text-left hover:bg-accent`,children:n},n))})]})]})}var ee=e(r(),1),P=e(k(),1),F=`#8b5cf6`,I=`https://nominatim.openstreetmap.org`,te=700,L=e=>Math.round(e*1e6)/1e6;function R(){let e=`<div style="display:flex;align-items:center;justify-content:center;width:28px;height:28px;border-radius:9999px 9999px 9999px 2px;transform:rotate(-45deg);background:${F};border:2px solid #fff;box-shadow:0 1px 4px rgba(0,0,0,.45)"><div style="width:8px;height:8px;border-radius:9999px;background:#fff"></div></div>`;return P.default.divIcon({html:e,className:`canvas-map-pick`,iconSize:[28,28],iconAnchor:[14,28]})}function z({initial:e,onPick:t,onClose:n}){let r=(0,A.useRef)(null),a=(0,A.useRef)(null),s=(0,A.useRef)(null),l=(0,A.useRef)(null);(0,A.useEffect)(()=>()=>l.current?.abort(),[]);let[f,g]=(0,A.useState)(e?{lat:e.lat,lon:e.lon}:null),[_,v]=(0,A.useState)(``),[y,b]=(0,A.useState)([]),[x,S]=(0,A.useState)(!1),[C,w]=(0,A.useState)(null),[T,E]=(0,A.useState)(!1),[D,k]=(0,A.useState)(!1),[j,N]=(0,A.useState)(!1);(0,A.useEffect)(()=>{let e=requestAnimationFrame(()=>N(!0));return()=>cancelAnimationFrame(e)},[]),O(n);let F=(0,A.useCallback)((e,t,n)=>{let r=a.current;if(!r)return;let i=P.default.latLng(e,t);s.current?s.current.setLatLng(i):(s.current=P.default.marker(i,{icon:R(),draggable:!0,autoPan:!0}).addTo(r),s.current.on(`dragend`,()=>{let e=s.current.getLatLng();g({lat:L(e.lat),lon:L(e.lng)})})),g({lat:L(e),lon:L(t),...n?{label:n}:{}})},[]);(0,A.useEffect)(()=>{let t=r.current;if(!t||a.current)return;let n=P.default.map(t,{center:e?[e.lat,e.lon]:[20,0],zoom:e?13:2,worldCopyJump:!0,zoomControl:!0});P.default.tileLayer(`https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png`,{attribution:`© OpenStreetMap contributors`,maxZoom:19}).addTo(n),a.current=n,e&&F(e.lat,e.lon),n.on(`click`,e=>F(e.latlng.lat,e.latlng.lng));let i=new ResizeObserver(()=>n.invalidateSize());i.observe(t);let o=setTimeout(()=>n.invalidateSize(),260);return()=>{clearTimeout(o),i.disconnect(),n.remove(),a.current=null,s.current=null}},[]),(0,A.useEffect)(()=>{if(!f||f.label)return;let{lat:e,lon:t}=f,n=new AbortController,r=setTimeout(()=>{E(!0),fetch(`${I}/reverse?format=jsonv2&zoom=16&lat=${e}&lon=${t}`,{signal:n.signal,headers:{Accept:`application/json`}}).then(e=>e.ok?e.json():null).then(n=>{let r=n?.display_name;typeof r==`string`&&r&&g(n=>n&&n.lat===e&&n.lon===t?{...n,label:r}:n)}).catch(()=>{}).finally(()=>E(!1))},te);return()=>{clearTimeout(r),n.abort()}},[f]);let z=(0,A.useCallback)(async()=>{let e=_.trim();if(e.length<2)return;l.current?.abort();let t=new AbortController;l.current=t;let n=!1,r=window.setTimeout(()=>{n=!0,t.abort()},12e3);S(!0),b([]),w(null);try{let n=await fetch(`${I}/search?format=jsonv2&limit=6&q=${encodeURIComponent(e)}`,{signal:t.signal,headers:{Accept:`application/json`}});if(n.status===429)throw Error(`Place search is busy. Wait a moment and try again, or click the map`);if(!n.ok)throw Error(`Place search is unavailable (${n.status}). Try again, or click the map`);let r=await n.json();if(!Array.isArray(r))throw Error(`Place search returned an invalid response. Try again, or click the map`);if(t.signal.aborted||l.current!==t)return;b(r),r.length||w(`No match. Try a different spelling, or just click the map`)}catch(e){if(l.current!==t||t.signal.aborted&&!n)return;w(n?`Place search timed out. Try again, or click the map`:e instanceof TypeError?`Could not reach place search. Check your connection, or click the map`:e instanceof Error?e.message:`Search is unavailable right now. Click the map to place a pin`)}finally{window.clearTimeout(r),l.current===t&&(!t.signal.aborted||n)&&S(!1)}},[_]),B=(0,A.useCallback)(()=>{if(!navigator.geolocation){w(`This browser has no geolocation`);return}k(!0),w(null),navigator.geolocation.getCurrentPosition(e=>{k(!1),a.current?.setView([e.coords.latitude,e.coords.longitude],16),F(e.coords.latitude,e.coords.longitude)},()=>{k(!1),w(`Could not read your location. Search or click the map instead`)},{enableHighAccuracy:!0,timeout:1e4,maximumAge:6e4})},[F]),V=(0,A.useCallback)(e=>{let t=a.current,n=Number(e.lat),r=Number(e.lon);if(!t||!Number.isFinite(n)||!Number.isFinite(r))return;let i=e.boundingbox?.map(Number);i&&i.length===4&&i.every(Number.isFinite)?t.fitBounds(P.default.latLngBounds([i[0],i[2]],[i[1],i[3]]),{maxZoom:16}):t.setView([n,r],15),F(n,r,e.display_name),b([])},[F]);return(0,ee.createPortal)((0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`div`,{className:h(`fixed inset-0 z-[60] bg-scrim transition-opacity duration-normal`,j?`opacity-100`:`opacity-0`),onClick:n}),(0,M.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-label":`Pick a location on the map`,className:h(`fixed inset-y-0 right-0 z-[61] flex w-[min(560px,100vw)] flex-col overflow-hidden rounded-(--panel-radius) bg-background shadow-elevation-4 transition-transform duration-normal ease-out`,j?`translate-x-0`:`translate-x-full`),children:[(0,M.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b px-3 py-2`,children:[(0,M.jsxs)(`span`,{className:`flex items-center gap-2 text-sm font-medium`,children:[(0,M.jsx)(d,{className:`h-4 w-4 text-info`}),`Custom geotag`]}),(0,M.jsx)(`button`,{type:`button`,onClick:n,"aria-label":`Close map`,className:`rounded p-1 text-muted-foreground hover:bg-muted hover:text-foreground`,children:(0,M.jsx)(i,{className:`h-4 w-4`})})]}),(0,M.jsxs)(`div`,{className:`relative z-10 shrink-0 border-b px-3 py-2`,children:[(0,M.jsxs)(`div`,{className:`flex gap-2`,children:[(0,M.jsxs)(`div`,{className:`relative flex-1`,children:[(0,M.jsx)(m,{className:`pointer-events-none absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground`}),(0,M.jsx)(`input`,{value:_,autoFocus:!0,onChange:e=>{l.current?.abort(),l.current=null,S(!1),b([]),v(e.target.value),w(null)},"aria-label":`Search for a place or address`,onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),z())},placeholder:`Search a place, e.g. Slavkovský štít`,spellCheck:!1,className:`h-8 w-full rounded-md border border-input bg-transparent pl-7 pr-2 text-sm outline-none placeholder:text-muted-foreground focus-visible:ring-1 focus-visible:ring-ring`})]}),(0,M.jsx)(`button`,{type:`button`,onClick:B,disabled:D,title:`Use my current location`,"aria-label":`Use my current location`,className:`inline-flex h-8 w-8 items-center justify-center rounded-md border border-border text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:opacity-50`,children:D?(0,M.jsx)(u,{className:`h-3.5 w-3.5 animate-spin`}):(0,M.jsx)(c,{className:`h-3.5 w-3.5`})}),(0,M.jsxs)(`button`,{type:`button`,onClick:z,disabled:x||_.trim().length<2,className:`inline-flex h-8 items-center gap-1.5 rounded-md bg-primary px-3 text-xs text-primary-foreground disabled:opacity-50`,children:[x?(0,M.jsx)(u,{className:`h-3.5 w-3.5 animate-spin`}):(0,M.jsx)(m,{className:`h-3.5 w-3.5`}),`Search`]})]}),C&&(0,M.jsx)(`p`,{role:`status`,className:`mt-1 text-xs text-warning`,children:C}),y.length>0&&(0,M.jsx)(`div`,{className:`absolute inset-x-3 top-full z-10 mt-1 max-h-64 overflow-y-auto rounded-md border bg-popover shadow-elevation-4`,children:y.map(e=>(0,M.jsx)(`button`,{type:`button`,onClick:()=>V(e),className:`block w-full border-b border-border/60 px-3 py-2 text-left text-xs last:border-0 hover:bg-muted`,children:e.display_name},`${e.lat},${e.lon},${e.display_name}`))})]}),(0,M.jsxs)(`div`,{className:`relative isolate z-0 min-h-0 flex-1`,children:[(0,M.jsx)(`div`,{ref:r,className:`h-full w-full`}),!f&&(0,M.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 bottom-3 z-[1000] flex justify-center`,children:(0,M.jsx)(`span`,{className:`rounded-full bg-background/90 px-3 py-1 text-xs text-muted-foreground shadow-elevation-2`,children:`Click the map to drop a pin, or drag it to fine-tune`})})]}),(0,M.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-3 border-t px-3 py-2`,children:[(0,M.jsx)(`div`,{className:`min-w-0 text-xs`,children:f?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-1.5 tabular-nums text-foreground`,children:[(0,M.jsx)(p,{className:`h-3 w-3 shrink-0 text-muted-foreground`}),f.lat.toFixed(5),`, `,f.lon.toFixed(5),T&&(0,M.jsx)(u,{className:`h-3 w-3 animate-spin text-muted-foreground`})]}),f.label&&(0,M.jsx)(`div`,{className:`truncate text-muted-foreground`,children:f.label})]}):(0,M.jsx)(`span`,{className:`text-muted-foreground`,children:`No point selected`})}),(0,M.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[(0,M.jsx)(`button`,{type:`button`,onClick:n,className:`rounded-md border border-border px-3 py-1.5 text-xs text-muted-foreground hover:bg-muted hover:text-foreground`,children:`Cancel`}),(0,M.jsxs)(`button`,{type:`button`,disabled:!f,onClick:()=>{f&&(t(f),n())},className:`inline-flex items-center gap-1.5 rounded-md bg-primary px-3 py-1.5 text-xs text-primary-foreground disabled:opacity-50`,children:[(0,M.jsx)(o,{className:`h-3.5 w-3.5`}),`Use this point`]})]})]})]})]}),document.body)}var B={1:`1: Highest`,2:`2`,3:`3: High`,4:`4`,5:`5: Medium`,6:`6`,7:`7: Low`,8:`8`,9:`9: Lowest`},V=`flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-elevation-1 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`,H=`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`;function U({title:e,setTitle:t,description:n,setDescription:r,status:i,setStatus:a,priority:o,setPriority:s,due:c,setDue:l,idPrefix:u=`todo`}){return(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,M.jsx)(_,{htmlFor:`${u}-title`,children:`Title`}),(0,M.jsx)(g,{id:`${u}-title`,value:e,onChange:e=>t(e.target.value),placeholder:`What needs doing?`})]}),(0,M.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,M.jsx)(_,{htmlFor:`${u}-desc`,children:`Description`}),(0,M.jsx)(`textarea`,{id:`${u}-desc`,value:n,onChange:e=>r(e.target.value),rows:3,placeholder:`Optional details…`,className:H})]}),(0,M.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,M.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,M.jsx)(_,{htmlFor:`${u}-due`,children:`Due`}),(0,M.jsx)(D,{id:`${u}-due`,value:c,onChange:l,placeholder:`No due date`})]}),(0,M.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,M.jsx)(_,{htmlFor:`${u}-priority`,children:`Priority`}),(0,M.jsxs)(`select`,{id:`${u}-priority`,value:o===``?``:String(o),onChange:e=>s(e.target.value===``?``:Number(e.target.value)),className:V,children:[(0,M.jsx)(`option`,{value:``,children:`None`}),[1,2,3,4,5,6,7,8,9].map(e=>(0,M.jsx)(`option`,{value:e,children:B[e]},e))]})]})]}),(0,M.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,M.jsx)(_,{htmlFor:`${u}-status`,children:`Status`}),(0,M.jsx)(`select`,{id:`${u}-status`,value:i,onChange:e=>a(e.target.value),className:V,children:T.map(e=>(0,M.jsx)(`option`,{value:e,children:E[e]},e))})]})]})}var W=`3.0`,G=[`person`,`organization`,`service`,`bot`],K={person:`Person`,organization:`Organization`,service:`Service`,bot:`Bot`},q=[`email`,`phone`,`sms`,`chat`,`web`],J=[`email`,`github`,`slack`,`matrix`,`gpg`,`url`];function Y(e){let t=e.primaryEmail.trim().toLowerCase(),n=e.channels.map(e=>({...e,kind:e.kind.trim(),value:e.value.trim(),label:e.label?.trim()||void 0})).filter(e=>e.kind&&e.value);if(t&&!n.some(e=>e.kind===`email`&&e.value===t)){for(let e of n)e.kind===`email`&&(e.primary=!1);n.push({kind:`email`,value:t,label:void 0,primary:!0})}let r=e.given.trim(),i=e.family.trim();return{displayName:e.displayName.trim(),...t?{primaryEmail:t}:{},...r||i?{name:{...r?{given:r}:{},...i?{family:i}:{}}}:{},channels:n,identifiers:e.identifiers.map(e=>({...e,type:e.type.trim(),identifier:e.identifier.trim(),provider:e.provider?.trim()||void 0})).filter(e=>e.type&&e.identifier),organizations:e.organizations.map(({identityId:e,...t})=>({...t,name:t.name.trim(),role:t.role?.trim()||void 0,...e?{metadata:{identityId:e}}:{}})).filter(e=>e.name)}}function X(e){let t=e?.data??{},n=t.name&&typeof t.name==`object`?t.name:{},r=e=>Array.isArray(e)?e:[],i=b(String(e?.schema||``),y);return{displayName:String(t.displayName||``),type:G.includes(i)?i:`person`,primaryEmail:String(t.primaryEmail||``),given:String(n.given||``),family:String(n.family||``),channels:r(t.channels),identifiers:r(t.identifiers),organizations:r(t.organizations).map(e=>({name:String(e.name||``),role:e.role?String(e.role):void 0,identityId:Number(e.metadata?.identityId)||void 0}))}}async function Z(e,t,n){if(!t||!e||e.mode!==`workspace`)return;let r=n.filter(e=>e.identityId);for(let n of r)try{await x(e.workspaceName,t,`member-of`,[n.identityId])}catch(e){console.error(`Failed to link organization`,n.name,e)}}function ne(e){let[t,n]=(0,A.useState)(e?.displayName??``),[r,i]=(0,A.useState)(e?.type??`person`),[a,o]=(0,A.useState)(e?.primaryEmail??``),[s,c]=(0,A.useState)(e?.given??``),[l,u]=(0,A.useState)(e?.family??``),[d,f]=(0,A.useState)(e?.channels??[]),[p,m]=(0,A.useState)(e?.identifiers??[]),[h,g]=(0,A.useState)(e?.organizations??[]),[_,v]=(0,A.useState)([]),[b,x]=(0,A.useState)(``),[S,T]=(0,A.useState)(!1),E={displayName:t,type:r,primaryEmail:a,given:s,family:l,channels:d,identifiers:p,organizations:h},D=!a.trim()||/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(a.trim()),O=t.trim().length>0&&D&&!S;async function k(e){T(!0);try{let t=b.trim(),n={schema:`${y}/${E.type}`,schemaVersion:W,data:Y(E),...t?{comment:t}:{},metadata:{features:C(_)}},r=await w(e,[n]);return await Z(e,r[0],h),r}finally{T(!1)}}return{displayName:t,setDisplayName:n,type:r,setType:i,primaryEmail:a,setPrimaryEmail:o,given:s,setGiven:c,family:l,setFamily:u,channels:d,setChannels:f,identifiers:p,setIdentifiers:m,organizations:h,setOrganizations:g,tags:_,setTags:v,comment:b,setComment:x,values:E,saving:S,canSave:O,emailValid:D,save:k}}var Q=`h-9 shrink-0 rounded-md border border-input bg-transparent px-2 text-sm shadow-elevation-1 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`;function $({label:e,rows:t,onChange:n,blank:r,addLabel:i,children:o}){return(0,M.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,M.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,M.jsx)(_,{children:e}),(0,M.jsxs)(`button`,{type:`button`,onClick:()=>n([...t,r()]),className:`inline-flex items-center gap-1 rounded-md px-1.5 py-1 text-xs text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,children:[(0,M.jsx)(a,{className:`h-3 w-3`}),` `,i]})]}),t.length===0?(0,M.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`None yet.`}):(0,M.jsx)(`div`,{className:`space-y-1.5`,children:t.map((r,i)=>(0,M.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[o(r,e=>n(t.map((t,n)=>n===i?{...t,...e}:t))),(0,M.jsx)(`button`,{type:`button`,onClick:()=>n(t.filter((e,t)=>t!==i)),className:`shrink-0 rounded p-1.5 text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive`,"aria-label":`Remove ${e.toLowerCase()} row`,children:(0,M.jsx)(s,{className:`h-3.5 w-3.5`})})]},i))})]})}function re(e,t){let n=e[t].kind,r=e[t].primary;return e.map((e,i)=>e.kind===n?{...e,primary:!r&&i===t}:e)}function ie(e){let[t,n]=(0,A.useState)([]);return(0,A.useEffect)(()=>{if(!e)return;let t=!1;async function r(){try{let r=await S(e,`organization`);t||n(r.map(e=>({id:e.id,name:v(e).title})))}catch{t||n([])}}return r(),()=>{t=!0}},[e]),t}function ae({idPrefix:e,workspaceName:t,displayName:n,setDisplayName:r,type:i,setType:a,primaryEmail:o,setPrimaryEmail:s,given:c,setGiven:u,family:d,setFamily:p,channels:m,setChannels:v,identifiers:y,setIdentifiers:b,organizations:x,setOrganizations:S,emailValid:C=!0}){let w=ie(t);return(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,M.jsx)(_,{htmlFor:`${e}-display-name`,children:`Display name`}),(0,M.jsx)(g,{id:`${e}-display-name`,value:n,onChange:e=>r(e.target.value),placeholder:`Jane Doe, Acme Ltd, build-bot…`,autoFocus:!0})]}),(0,M.jsxs)(`div`,{className:`flex gap-2`,children:[(0,M.jsxs)(`div`,{className:`w-40 space-y-1.5`,children:[(0,M.jsx)(_,{htmlFor:`${e}-type`,children:`Type`}),(0,M.jsx)(`select`,{id:`${e}-type`,value:i,onChange:e=>a(e.target.value),className:h(Q,`w-full`),children:G.map(e=>(0,M.jsx)(`option`,{value:e,children:K[e]},e))})]}),(0,M.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1.5`,children:[(0,M.jsx)(_,{htmlFor:`${e}-email`,children:`Primary email`}),(0,M.jsx)(g,{id:`${e}-email`,type:`email`,value:o,onChange:e=>s(e.target.value),placeholder:`jane@example.com`}),!C&&(0,M.jsx)(`p`,{className:`text-xs text-destructive`,children:`Enter a valid email address.`})]})]}),i===`person`&&(0,M.jsxs)(`div`,{className:`flex gap-2`,children:[(0,M.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1.5`,children:[(0,M.jsx)(_,{htmlFor:`${e}-given`,children:`Given name`}),(0,M.jsx)(g,{id:`${e}-given`,value:c,onChange:e=>u(e.target.value),placeholder:`Jane`})]}),(0,M.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1.5`,children:[(0,M.jsx)(_,{htmlFor:`${e}-family`,children:`Family name`}),(0,M.jsx)(g,{id:`${e}-family`,value:d,onChange:e=>p(e.target.value),placeholder:`Doe`})]})]}),(0,M.jsx)($,{label:`Channels`,rows:m,onChange:v,blank:()=>({kind:`email`,value:``}),addLabel:`Add channel`,children:(e,t)=>(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(`select`,{value:e.kind,onChange:e=>t({kind:e.target.value}),className:h(Q,`w-24`),children:[q.map(e=>(0,M.jsx)(`option`,{value:e,children:e},e)),!q.includes(e.kind)&&(0,M.jsx)(`option`,{value:e.kind,children:e.kind})]}),(0,M.jsx)(g,{value:e.value,onChange:e=>t({value:e.target.value}),placeholder:e.kind===`phone`?`+421…`:`address or handle`,className:`min-w-0 flex-1`}),(0,M.jsx)(`button`,{type:`button`,onClick:()=>v(re(m,m.indexOf(e))),className:h(`shrink-0 rounded p-1.5 transition-colors hover:bg-muted`,e.primary?`text-data-5`:`text-muted-foreground`),title:e.primary?`Primary for this kind`:`Make primary for this kind`,"aria-pressed":!!e.primary,children:(0,M.jsx)(l,{className:h(`h-3.5 w-3.5`,e.primary&&`fill-current`)})})]})}),(0,M.jsx)($,{label:`Identifiers`,rows:y,onChange:b,blank:()=>({type:`github`,identifier:``}),addLabel:`Add identifier`,children:(e,t)=>(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(`select`,{value:e.type,onChange:e=>t({type:e.target.value}),className:h(Q,`w-24`),children:[J.map(e=>(0,M.jsx)(`option`,{value:e,children:e},e)),!J.includes(e.type)&&(0,M.jsx)(`option`,{value:e.type,children:e.type})]}),(0,M.jsx)(g,{value:e.identifier,onChange:e=>t({identifier:e.target.value}),placeholder:`octocat, U024BE7LH, 0xABCD…`,className:`min-w-0 flex-1 font-mono text-xs`})]})}),(0,M.jsx)($,{label:`Organizations`,rows:x,onChange:S,blank:()=>({name:``}),addLabel:`Add organization`,children:(e,t)=>(0,M.jsxs)(M.Fragment,{children:[w.length>0?(0,M.jsxs)(`select`,{value:e.identityId?String(e.identityId):``,onChange:e=>{let n=w.find(t=>String(t.id)===e.target.value);t(n?{identityId:n.id,name:n.name}:{identityId:void 0})},className:h(Q,`min-w-0 flex-1`),children:[(0,M.jsx)(`option`,{value:``,children:`Other… (type a name)`}),w.map(e=>(0,M.jsx)(`option`,{value:e.id,children:e.name},e.id))]}):null,!e.identityId&&(0,M.jsx)(g,{value:e.name,onChange:e=>t({name:e.target.value}),placeholder:`Acme Ltd`,className:`min-w-0 flex-1`}),e.identityId&&(0,M.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,title:`Linked — saving relates this identity to that organization`,children:(0,M.jsx)(f,{className:`h-3.5 w-3.5`})}),(0,M.jsx)(g,{value:e.role??``,onChange:e=>t({role:e.target.value}),placeholder:`Role`,className:`w-28 shrink-0`})]})})]})}export{U as a,j as c,ne as i,Y as n,z as o,X as r,N as s,ae as t};
|
|
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{L as i,Pt as a,Wr as o,X as s,fn as c,nt as l,pn as u,sn as d,vn as f,xr as p,yt as m}from"./ui-CDoK3F3U.js";import{t as h}from"./utils-2pl1SbIp.js";import{t as g}from"./input-BOtCd4HP.js";import{t as _}from"./label-BSTdjCWU.js";import{An as v,Rn as y,Wn as b,g as x,wt as S}from"./workspace-BJELPCNs.js";import{n as C}from"./tags-YamdPoBK.js";import{o as w}from"./useAddTarget-B3b6TyZr.js";import{i as T,n as E,r as D}from"./date-time-picker-txVhlNO0.js";import{t as O}from"./useEscapeClose-DR_xKT_k.js";import{n as k}from"./map-BxCwdK0d.js";var A=e(n(),1),j=(0,A.createContext)(null),M=t();function N({tags:e,onChange:t,placeholder:n=`Add tag, press Enter`,suggestions:r=[]}){let[a,o]=(0,A.useState)(``),[s,c]=(0,A.useState)(!1),l=a.trim().toLowerCase(),u=(l?r.filter(t=>t.toLowerCase().includes(l)&&!e.includes(t)):s?r.filter(t=>!e.includes(t)):[]).slice(0,8),d=()=>{let n=a.trim();n&&!e.includes(n)&&t([...e,n]),o(``)};return(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 rounded-md border border-input bg-transparent px-2 py-1.5 focus-within:ring-1 focus-within:ring-ring`,children:[e.map(n=>(0,M.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded bg-muted px-1.5 py-0.5 text-xs`,children:[n,(0,M.jsx)(`button`,{type:`button`,onClick:()=>t(e.filter(e=>e!==n)),className:`text-muted-foreground hover:text-foreground`,"aria-label":`Remove ${n}`,children:(0,M.jsx)(i,{className:`h-3 w-3`})})]},n)),(0,M.jsxs)(`div`,{className:`relative flex-1 min-w-[8ch]`,children:[(0,M.jsx)(`input`,{value:a,onChange:e=>o(e.target.value),onKeyDown:n=>{n.key===`Enter`||n.key===`,`?(n.preventDefault(),d()):n.key===`Backspace`&&!a&&e.length&&t(e.slice(0,-1))},onFocus:()=>c(!0),onBlur:()=>{setTimeout(d,150),c(!1)},placeholder:e.length?``:n,className:`w-full bg-transparent text-sm outline-none placeholder:text-muted-foreground`}),u.length>0&&(0,M.jsx)(`div`,{className:`absolute left-0 top-full z-50 mt-1 max-h-48 w-56 overflow-auto rounded-md border bg-popover p-1 text-sm shadow-elevation-2`,children:u.map(n=>(0,M.jsx)(`button`,{type:`button`,onMouseDown:r=>{r.preventDefault(),e.includes(n)||t([...e,n]),o(``)},className:`block w-full rounded px-2 py-1 text-left hover:bg-accent`,children:n},n))})]})]})}var ee=e(r(),1),P=e(k(),1),F=`#8b5cf6`,I=`https://nominatim.openstreetmap.org`,te=700,L=e=>Math.round(e*1e6)/1e6;function R(){let e=`<div style="display:flex;align-items:center;justify-content:center;width:28px;height:28px;border-radius:9999px 9999px 9999px 2px;transform:rotate(-45deg);background:${F};border:2px solid #fff;box-shadow:0 1px 4px rgba(0,0,0,.45)"><div style="width:8px;height:8px;border-radius:9999px;background:#fff"></div></div>`;return P.default.divIcon({html:e,className:`canvas-map-pick`,iconSize:[28,28],iconAnchor:[14,28]})}function z({initial:e,onPick:t,onClose:n}){let r=(0,A.useRef)(null),a=(0,A.useRef)(null),s=(0,A.useRef)(null),l=(0,A.useRef)(null);(0,A.useEffect)(()=>()=>l.current?.abort(),[]);let[f,g]=(0,A.useState)(e?{lat:e.lat,lon:e.lon}:null),[_,v]=(0,A.useState)(``),[y,b]=(0,A.useState)([]),[x,S]=(0,A.useState)(!1),[C,w]=(0,A.useState)(null),[T,E]=(0,A.useState)(!1),[D,k]=(0,A.useState)(!1),[j,N]=(0,A.useState)(!1);(0,A.useEffect)(()=>{let e=requestAnimationFrame(()=>N(!0));return()=>cancelAnimationFrame(e)},[]),O(n);let F=(0,A.useCallback)((e,t,n)=>{let r=a.current;if(!r)return;let i=P.default.latLng(e,t);s.current?s.current.setLatLng(i):(s.current=P.default.marker(i,{icon:R(),draggable:!0,autoPan:!0}).addTo(r),s.current.on(`dragend`,()=>{let e=s.current.getLatLng();g({lat:L(e.lat),lon:L(e.lng)})})),g({lat:L(e),lon:L(t),...n?{label:n}:{}})},[]);(0,A.useEffect)(()=>{let t=r.current;if(!t||a.current)return;let n=P.default.map(t,{center:e?[e.lat,e.lon]:[20,0],zoom:e?13:2,worldCopyJump:!0,zoomControl:!0});P.default.tileLayer(`https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png`,{attribution:`© OpenStreetMap contributors`,maxZoom:19}).addTo(n),a.current=n,e&&F(e.lat,e.lon),n.on(`click`,e=>F(e.latlng.lat,e.latlng.lng));let i=new ResizeObserver(()=>n.invalidateSize());i.observe(t);let o=setTimeout(()=>n.invalidateSize(),260);return()=>{clearTimeout(o),i.disconnect(),n.remove(),a.current=null,s.current=null}},[]),(0,A.useEffect)(()=>{if(!f||f.label)return;let{lat:e,lon:t}=f,n=new AbortController,r=setTimeout(()=>{E(!0),fetch(`${I}/reverse?format=jsonv2&zoom=16&lat=${e}&lon=${t}`,{signal:n.signal,headers:{Accept:`application/json`}}).then(e=>e.ok?e.json():null).then(n=>{let r=n?.display_name;typeof r==`string`&&r&&g(n=>n&&n.lat===e&&n.lon===t?{...n,label:r}:n)}).catch(()=>{}).finally(()=>E(!1))},te);return()=>{clearTimeout(r),n.abort()}},[f]);let z=(0,A.useCallback)(async()=>{let e=_.trim();if(e.length<2)return;l.current?.abort();let t=new AbortController;l.current=t;let n=!1,r=window.setTimeout(()=>{n=!0,t.abort()},12e3);S(!0),b([]),w(null);try{let n=await fetch(`${I}/search?format=jsonv2&limit=6&q=${encodeURIComponent(e)}`,{signal:t.signal,headers:{Accept:`application/json`}});if(n.status===429)throw Error(`Place search is busy. Wait a moment and try again, or click the map`);if(!n.ok)throw Error(`Place search is unavailable (${n.status}). Try again, or click the map`);let r=await n.json();if(!Array.isArray(r))throw Error(`Place search returned an invalid response. Try again, or click the map`);if(t.signal.aborted||l.current!==t)return;b(r),r.length||w(`No match. Try a different spelling, or just click the map`)}catch(e){if(l.current!==t||t.signal.aborted&&!n)return;w(n?`Place search timed out. Try again, or click the map`:e instanceof TypeError?`Could not reach place search. Check your connection, or click the map`:e instanceof Error?e.message:`Search is unavailable right now. Click the map to place a pin`)}finally{window.clearTimeout(r),l.current===t&&(!t.signal.aborted||n)&&S(!1)}},[_]),B=(0,A.useCallback)(()=>{if(!navigator.geolocation){w(`This browser has no geolocation`);return}k(!0),w(null),navigator.geolocation.getCurrentPosition(e=>{k(!1),a.current?.setView([e.coords.latitude,e.coords.longitude],16),F(e.coords.latitude,e.coords.longitude)},()=>{k(!1),w(`Could not read your location. Search or click the map instead`)},{enableHighAccuracy:!0,timeout:1e4,maximumAge:6e4})},[F]),V=(0,A.useCallback)(e=>{let t=a.current,n=Number(e.lat),r=Number(e.lon);if(!t||!Number.isFinite(n)||!Number.isFinite(r))return;let i=e.boundingbox?.map(Number);i&&i.length===4&&i.every(Number.isFinite)?t.fitBounds(P.default.latLngBounds([i[0],i[2]],[i[1],i[3]]),{maxZoom:16}):t.setView([n,r],15),F(n,r,e.display_name),b([])},[F]);return(0,ee.createPortal)((0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`div`,{className:h(`fixed inset-0 z-[60] bg-scrim transition-opacity duration-normal`,j?`opacity-100`:`opacity-0`),onClick:n}),(0,M.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-label":`Pick a location on the map`,className:h(`fixed inset-y-0 right-0 z-[61] flex w-[min(560px,100vw)] flex-col overflow-hidden rounded-(--panel-radius) bg-background shadow-elevation-4 transition-transform duration-normal ease-out`,j?`translate-x-0`:`translate-x-full`),children:[(0,M.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b px-3 py-2`,children:[(0,M.jsxs)(`span`,{className:`flex items-center gap-2 text-sm font-medium`,children:[(0,M.jsx)(d,{className:`h-4 w-4 text-info`}),`Custom geotag`]}),(0,M.jsx)(`button`,{type:`button`,onClick:n,"aria-label":`Close map`,className:`rounded p-1 text-muted-foreground hover:bg-muted hover:text-foreground`,children:(0,M.jsx)(i,{className:`h-4 w-4`})})]}),(0,M.jsxs)(`div`,{className:`relative z-10 shrink-0 border-b px-3 py-2`,children:[(0,M.jsxs)(`div`,{className:`flex gap-2`,children:[(0,M.jsxs)(`div`,{className:`relative flex-1`,children:[(0,M.jsx)(m,{className:`pointer-events-none absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground`}),(0,M.jsx)(`input`,{value:_,autoFocus:!0,onChange:e=>{l.current?.abort(),l.current=null,S(!1),b([]),v(e.target.value),w(null)},"aria-label":`Search for a place or address`,onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),z())},placeholder:`Search a place, e.g. Slavkovský štít`,spellCheck:!1,className:`h-8 w-full rounded-md border border-input bg-transparent pl-7 pr-2 text-sm outline-none placeholder:text-muted-foreground focus-visible:ring-1 focus-visible:ring-ring`})]}),(0,M.jsx)(`button`,{type:`button`,onClick:B,disabled:D,title:`Use my current location`,"aria-label":`Use my current location`,className:`inline-flex h-8 w-8 items-center justify-center rounded-md border border-border text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:opacity-50`,children:D?(0,M.jsx)(u,{className:`h-3.5 w-3.5 animate-spin`}):(0,M.jsx)(c,{className:`h-3.5 w-3.5`})}),(0,M.jsxs)(`button`,{type:`button`,onClick:z,disabled:x||_.trim().length<2,className:`inline-flex h-8 items-center gap-1.5 rounded-md bg-primary px-3 text-xs text-primary-foreground disabled:opacity-50`,children:[x?(0,M.jsx)(u,{className:`h-3.5 w-3.5 animate-spin`}):(0,M.jsx)(m,{className:`h-3.5 w-3.5`}),`Search`]})]}),C&&(0,M.jsx)(`p`,{role:`status`,className:`mt-1 text-xs text-warning`,children:C}),y.length>0&&(0,M.jsx)(`div`,{className:`absolute inset-x-3 top-full z-10 mt-1 max-h-64 overflow-y-auto rounded-md border bg-popover shadow-elevation-4`,children:y.map(e=>(0,M.jsx)(`button`,{type:`button`,onClick:()=>V(e),className:`block w-full border-b border-border/60 px-3 py-2 text-left text-xs last:border-0 hover:bg-muted`,children:e.display_name},`${e.lat},${e.lon},${e.display_name}`))})]}),(0,M.jsxs)(`div`,{className:`relative isolate z-0 min-h-0 flex-1`,children:[(0,M.jsx)(`div`,{ref:r,className:`h-full w-full`}),!f&&(0,M.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 bottom-3 z-[1000] flex justify-center`,children:(0,M.jsx)(`span`,{className:`rounded-full bg-background/90 px-3 py-1 text-xs text-muted-foreground shadow-elevation-2`,children:`Click the map to drop a pin, or drag it to fine-tune`})})]}),(0,M.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-3 border-t px-3 py-2`,children:[(0,M.jsx)(`div`,{className:`min-w-0 text-xs`,children:f?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-1.5 tabular-nums text-foreground`,children:[(0,M.jsx)(p,{className:`h-3 w-3 shrink-0 text-muted-foreground`}),f.lat.toFixed(5),`, `,f.lon.toFixed(5),T&&(0,M.jsx)(u,{className:`h-3 w-3 animate-spin text-muted-foreground`})]}),f.label&&(0,M.jsx)(`div`,{className:`truncate text-muted-foreground`,children:f.label})]}):(0,M.jsx)(`span`,{className:`text-muted-foreground`,children:`No point selected`})}),(0,M.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[(0,M.jsx)(`button`,{type:`button`,onClick:n,className:`rounded-md border border-border px-3 py-1.5 text-xs text-muted-foreground hover:bg-muted hover:text-foreground`,children:`Cancel`}),(0,M.jsxs)(`button`,{type:`button`,disabled:!f,onClick:()=>{f&&(t(f),n())},className:`inline-flex items-center gap-1.5 rounded-md bg-primary px-3 py-1.5 text-xs text-primary-foreground disabled:opacity-50`,children:[(0,M.jsx)(o,{className:`h-3.5 w-3.5`}),`Use this point`]})]})]})]})]}),document.body)}var B={1:`1: Highest`,2:`2`,3:`3: High`,4:`4`,5:`5: Medium`,6:`6`,7:`7: Low`,8:`8`,9:`9: Lowest`},V=`flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-elevation-1 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`,H=`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`;function U({title:e,setTitle:t,description:n,setDescription:r,status:i,setStatus:a,priority:o,setPriority:s,due:c,setDue:l,idPrefix:u=`todo`}){return(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,M.jsx)(_,{htmlFor:`${u}-title`,children:`Title`}),(0,M.jsx)(g,{id:`${u}-title`,value:e,onChange:e=>t(e.target.value),placeholder:`What needs doing?`})]}),(0,M.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,M.jsx)(_,{htmlFor:`${u}-desc`,children:`Description`}),(0,M.jsx)(`textarea`,{id:`${u}-desc`,value:n,onChange:e=>r(e.target.value),rows:3,placeholder:`Optional details…`,className:H})]}),(0,M.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,M.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,M.jsx)(_,{htmlFor:`${u}-due`,children:`Due`}),(0,M.jsx)(E,{id:`${u}-due`,value:c,onChange:l,placeholder:`No due date`})]}),(0,M.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,M.jsx)(_,{htmlFor:`${u}-priority`,children:`Priority`}),(0,M.jsxs)(`select`,{id:`${u}-priority`,value:o===``?``:String(o),onChange:e=>s(e.target.value===``?``:Number(e.target.value)),className:V,children:[(0,M.jsx)(`option`,{value:``,children:`None`}),[1,2,3,4,5,6,7,8,9].map(e=>(0,M.jsx)(`option`,{value:e,children:B[e]},e))]})]})]}),(0,M.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,M.jsx)(_,{htmlFor:`${u}-status`,children:`Status`}),(0,M.jsx)(`select`,{id:`${u}-status`,value:i,onChange:e=>a(e.target.value),className:V,children:D.map(e=>(0,M.jsx)(`option`,{value:e,children:T[e]},e))})]})]})}var W=`3.0`,G=[`person`,`organization`,`service`,`bot`],K={person:`Person`,organization:`Organization`,service:`Service`,bot:`Bot`},q=[`email`,`phone`,`sms`,`chat`,`web`],J=[`email`,`github`,`slack`,`matrix`,`gpg`,`url`];function Y(e){let t=e.primaryEmail.trim().toLowerCase(),n=e.channels.map(e=>({...e,kind:e.kind.trim(),value:e.value.trim(),label:e.label?.trim()||void 0})).filter(e=>e.kind&&e.value);if(t&&!n.some(e=>e.kind===`email`&&e.value===t)){for(let e of n)e.kind===`email`&&(e.primary=!1);n.push({kind:`email`,value:t,label:void 0,primary:!0})}let r=e.given.trim(),i=e.family.trim();return{displayName:e.displayName.trim(),...t?{primaryEmail:t}:{},...r||i?{name:{...r?{given:r}:{},...i?{family:i}:{}}}:{},channels:n,identifiers:e.identifiers.map(e=>({...e,type:e.type.trim(),identifier:e.identifier.trim(),provider:e.provider?.trim()||void 0})).filter(e=>e.type&&e.identifier),organizations:e.organizations.map(({identityId:e,...t})=>({...t,name:t.name.trim(),role:t.role?.trim()||void 0,...e?{metadata:{identityId:e}}:{}})).filter(e=>e.name)}}function X(e){let t=e?.data??{},n=t.name&&typeof t.name==`object`?t.name:{},r=e=>Array.isArray(e)?e:[],i=b(String(e?.schema||``),y);return{displayName:String(t.displayName||``),type:G.includes(i)?i:`person`,primaryEmail:String(t.primaryEmail||``),given:String(n.given||``),family:String(n.family||``),channels:r(t.channels),identifiers:r(t.identifiers),organizations:r(t.organizations).map(e=>({name:String(e.name||``),role:e.role?String(e.role):void 0,identityId:Number(e.metadata?.identityId)||void 0}))}}async function Z(e,t,n){if(!t||!e||e.mode!==`workspace`)return;let r=n.filter(e=>e.identityId);for(let n of r)try{await x(e.workspaceName,t,`member-of`,[n.identityId])}catch(e){console.error(`Failed to link organization`,n.name,e)}}function ne(e){let[t,n]=(0,A.useState)(e?.displayName??``),[r,i]=(0,A.useState)(e?.type??`person`),[a,o]=(0,A.useState)(e?.primaryEmail??``),[s,c]=(0,A.useState)(e?.given??``),[l,u]=(0,A.useState)(e?.family??``),[d,f]=(0,A.useState)(e?.channels??[]),[p,m]=(0,A.useState)(e?.identifiers??[]),[h,g]=(0,A.useState)(e?.organizations??[]),[_,v]=(0,A.useState)([]),[b,x]=(0,A.useState)(``),[S,T]=(0,A.useState)(!1),E={displayName:t,type:r,primaryEmail:a,given:s,family:l,channels:d,identifiers:p,organizations:h},D=!a.trim()||/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(a.trim()),O=t.trim().length>0&&D&&!S;async function k(e){T(!0);try{let t=b.trim(),n={schema:`${y}/${E.type}`,schemaVersion:W,data:Y(E),...t?{comment:t}:{},metadata:{features:C(_)}},r=await w(e,[n]);return await Z(e,r[0],h),r}finally{T(!1)}}return{displayName:t,setDisplayName:n,type:r,setType:i,primaryEmail:a,setPrimaryEmail:o,given:s,setGiven:c,family:l,setFamily:u,channels:d,setChannels:f,identifiers:p,setIdentifiers:m,organizations:h,setOrganizations:g,tags:_,setTags:v,comment:b,setComment:x,values:E,saving:S,canSave:O,emailValid:D,save:k}}var Q=`h-9 shrink-0 rounded-md border border-input bg-transparent px-2 text-sm shadow-elevation-1 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`;function $({label:e,rows:t,onChange:n,blank:r,addLabel:i,children:o}){return(0,M.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,M.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,M.jsx)(_,{children:e}),(0,M.jsxs)(`button`,{type:`button`,onClick:()=>n([...t,r()]),className:`inline-flex items-center gap-1 rounded-md px-1.5 py-1 text-xs text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,children:[(0,M.jsx)(a,{className:`h-3 w-3`}),` `,i]})]}),t.length===0?(0,M.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`None yet.`}):(0,M.jsx)(`div`,{className:`space-y-1.5`,children:t.map((r,i)=>(0,M.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[o(r,e=>n(t.map((t,n)=>n===i?{...t,...e}:t))),(0,M.jsx)(`button`,{type:`button`,onClick:()=>n(t.filter((e,t)=>t!==i)),className:`shrink-0 rounded p-1.5 text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive`,"aria-label":`Remove ${e.toLowerCase()} row`,children:(0,M.jsx)(s,{className:`h-3.5 w-3.5`})})]},i))})]})}function re(e,t){let n=e[t].kind,r=e[t].primary;return e.map((e,i)=>e.kind===n?{...e,primary:!r&&i===t}:e)}function ie(e){let[t,n]=(0,A.useState)([]);return(0,A.useEffect)(()=>{if(!e)return;let t=!1;async function r(){try{let r=await S(e,`organization`);t||n(r.map(e=>({id:e.id,name:v(e).title})))}catch{t||n([])}}return r(),()=>{t=!0}},[e]),t}function ae({idPrefix:e,workspaceName:t,displayName:n,setDisplayName:r,type:i,setType:a,primaryEmail:o,setPrimaryEmail:s,given:c,setGiven:u,family:d,setFamily:p,channels:m,setChannels:v,identifiers:y,setIdentifiers:b,organizations:x,setOrganizations:S,emailValid:C=!0}){let w=ie(t);return(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,M.jsx)(_,{htmlFor:`${e}-display-name`,children:`Display name`}),(0,M.jsx)(g,{id:`${e}-display-name`,value:n,onChange:e=>r(e.target.value),placeholder:`Jane Doe, Acme Ltd, build-bot…`,autoFocus:!0})]}),(0,M.jsxs)(`div`,{className:`flex gap-2`,children:[(0,M.jsxs)(`div`,{className:`w-40 space-y-1.5`,children:[(0,M.jsx)(_,{htmlFor:`${e}-type`,children:`Type`}),(0,M.jsx)(`select`,{id:`${e}-type`,value:i,onChange:e=>a(e.target.value),className:h(Q,`w-full`),children:G.map(e=>(0,M.jsx)(`option`,{value:e,children:K[e]},e))})]}),(0,M.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1.5`,children:[(0,M.jsx)(_,{htmlFor:`${e}-email`,children:`Primary email`}),(0,M.jsx)(g,{id:`${e}-email`,type:`email`,value:o,onChange:e=>s(e.target.value),placeholder:`jane@example.com`}),!C&&(0,M.jsx)(`p`,{className:`text-xs text-destructive`,children:`Enter a valid email address.`})]})]}),i===`person`&&(0,M.jsxs)(`div`,{className:`flex gap-2`,children:[(0,M.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1.5`,children:[(0,M.jsx)(_,{htmlFor:`${e}-given`,children:`Given name`}),(0,M.jsx)(g,{id:`${e}-given`,value:c,onChange:e=>u(e.target.value),placeholder:`Jane`})]}),(0,M.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1.5`,children:[(0,M.jsx)(_,{htmlFor:`${e}-family`,children:`Family name`}),(0,M.jsx)(g,{id:`${e}-family`,value:d,onChange:e=>p(e.target.value),placeholder:`Doe`})]})]}),(0,M.jsx)($,{label:`Channels`,rows:m,onChange:v,blank:()=>({kind:`email`,value:``}),addLabel:`Add channel`,children:(e,t)=>(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(`select`,{value:e.kind,onChange:e=>t({kind:e.target.value}),className:h(Q,`w-24`),children:[q.map(e=>(0,M.jsx)(`option`,{value:e,children:e},e)),!q.includes(e.kind)&&(0,M.jsx)(`option`,{value:e.kind,children:e.kind})]}),(0,M.jsx)(g,{value:e.value,onChange:e=>t({value:e.target.value}),placeholder:e.kind===`phone`?`+421…`:`address or handle`,className:`min-w-0 flex-1`}),(0,M.jsx)(`button`,{type:`button`,onClick:()=>v(re(m,m.indexOf(e))),className:h(`shrink-0 rounded p-1.5 transition-colors hover:bg-muted`,e.primary?`text-data-5`:`text-muted-foreground`),title:e.primary?`Primary for this kind`:`Make primary for this kind`,"aria-pressed":!!e.primary,children:(0,M.jsx)(l,{className:h(`h-3.5 w-3.5`,e.primary&&`fill-current`)})})]})}),(0,M.jsx)($,{label:`Identifiers`,rows:y,onChange:b,blank:()=>({type:`github`,identifier:``}),addLabel:`Add identifier`,children:(e,t)=>(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(`select`,{value:e.type,onChange:e=>t({type:e.target.value}),className:h(Q,`w-24`),children:[J.map(e=>(0,M.jsx)(`option`,{value:e,children:e},e)),!J.includes(e.type)&&(0,M.jsx)(`option`,{value:e.type,children:e.type})]}),(0,M.jsx)(g,{value:e.identifier,onChange:e=>t({identifier:e.target.value}),placeholder:`octocat, U024BE7LH, 0xABCD…`,className:`min-w-0 flex-1 font-mono text-xs`})]})}),(0,M.jsx)($,{label:`Organizations`,rows:x,onChange:S,blank:()=>({name:``}),addLabel:`Add organization`,children:(e,t)=>(0,M.jsxs)(M.Fragment,{children:[w.length>0?(0,M.jsxs)(`select`,{value:e.identityId?String(e.identityId):``,onChange:e=>{let n=w.find(t=>String(t.id)===e.target.value);t(n?{identityId:n.id,name:n.name}:{identityId:void 0})},className:h(Q,`min-w-0 flex-1`),children:[(0,M.jsx)(`option`,{value:``,children:`Other… (type a name)`}),w.map(e=>(0,M.jsx)(`option`,{value:e.id,children:e.name},e.id))]}):null,!e.identityId&&(0,M.jsx)(g,{value:e.name,onChange:e=>t({name:e.target.value}),placeholder:`Acme Ltd`,className:`min-w-0 flex-1`}),e.identityId&&(0,M.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,title:`Linked — saving relates this identity to that organization`,children:(0,M.jsx)(f,{className:`h-3.5 w-3.5`})}),(0,M.jsx)(g,{value:e.role??``,onChange:e=>t({role:e.target.value}),placeholder:`Role`,className:`w-28 shrink-0`})]})})]})}export{U as a,j as c,ne as i,Y as n,z as o,X as r,N as s,ae 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{$n as r,Gr as i,Nr as a,Xt as o}from"./ui-
|
|
1
|
+
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{$n as r,Gr as i,Nr as a,Xt as o}from"./ui-CDoK3F3U.js";import{t as s}from"./utils-2pl1SbIp.js";import{An as c,Nn as l}from"./workspace-BJELPCNs.js";import{t as u}from"./useDocumentThumbnail-wW0lSOEy.js";import{t as d}from"./DocumentIcon-9i1uCMQa.js";import{n as f}from"./use-document-modal-PG8bQyIB.js";import{n as p}from"./use-applet-target-ffIGaAqT.js";import{D as m,E as h,S as g,T as _,b as v,w as y,x as b}from"./index-DRHEGJ8I.js";var x=e(n(),1),S=t(),C=`h-8 rounded-md border border-input bg-transparent px-2 text-xs outline-none focus-visible:ring-2 focus-visible:ring-ring`,w=`h-8 rounded-md border border-input bg-transparent px-2 text-xs outline-none focus-visible:ring-1 focus-visible:ring-ring`;function T({workspaceRef:e,doc:t,distance:n,onOpen:r}){let i=l(t),{blobUrl:a}=u(e,t.id,256,{enabled:i}),o=c(t);return(0,S.jsxs)(`button`,{type:`button`,onClick:()=>r(t),title:`Open ${o.title}`,className:`rounded-(--card-radius) border border-border bg-card overflow-hidden flex flex-col text-left cursor-pointer transition-colors hover:border-foreground/30 hover:bg-muted/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,children:[(0,S.jsx)(`div`,{className:`aspect-square bg-muted/40 flex items-center justify-center overflow-hidden`,children:i&&a?(0,S.jsx)(`img`,{src:a,alt:o.title,className:`h-full w-full object-cover`}):(0,S.jsx)(d,{document:t,size:10})}),(0,S.jsxs)(`div`,{className:`p-2 min-w-0`,children:[(0,S.jsx)(`div`,{className:`text-xs font-medium truncate`,title:o.title,children:o.title}),(0,S.jsxs)(`div`,{className:`text-[10px] text-muted-foreground truncate`,children:[o.schemaLabel,n==null?``:` · d=${n.toFixed(3)}`]})]})]})}function E(){let e=p(),t=f(),n=h(),{rateMs:c,setRateMs:l,text:u,setText:d,maxDistance:E,setMaxDistance:D,latencyMs:O,error:k}=n,A=e?.mode===`workspace`?e.workspaceName:``,j=e?.mode===`workspace`&&e.path!==`/`?e.path:null,M=n.running&&n.consumer===`applet`,N=n.running&&n.consumer!==`applet`,P=M?n.hits:[];m(M);let F=M?n.snapshotSize??n.camera?.size:null,I=!!F&&F.height>F.width,L=e=>{A&&n.start(e,`applet`,{workspaceRef:A,contextPath:j})},{setContextPath:R}=n;return(0,x.useEffect)(()=>{M&&R(j)},[M,j,R]),e?.mode===`workspace`?(0,S.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col gap-3 overflow-y-auto p-3`,children:[(0,S.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[(0,S.jsx)(`select`,{className:C,value:c,onChange:e=>l(Number(e.target.value)),title:`Frame rate. High rates (10–30 fps) are experimental; the loop never overlaps requests, so the effective rate is capped by search latency.`,children:_.map(e=>(0,S.jsx)(`option`,{value:e.ms,children:e.label},e.ms))}),(0,S.jsx)(`input`,{className:s(w,`w-44`),placeholder:`Optional text (fused mode)`,value:u,onChange:e=>d(e.target.value)}),(0,S.jsx)(`input`,{className:s(w,`w-28`),placeholder:`max distance`,inputMode:`decimal`,value:E,onChange:e=>D(e.target.value),title:`Cosine-distance floor (0 = identical). Empty = top-K.`}),M?(0,S.jsxs)(`button`,{type:`button`,onClick:n.stop,className:`flex h-8 items-center gap-1 rounded-md bg-destructive px-3 text-xs font-medium text-destructive-foreground transition-colors hover:bg-destructive/90`,children:[(0,S.jsx)(a,{className:`h-3.5 w-3.5`}),` `,n.source===`photo`?`Close photo`:`Stop`]}):(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`button`,{type:`button`,onClick:()=>L(`camera`),disabled:N,className:`flex h-8 items-center gap-1 rounded-md bg-foreground px-3 text-xs font-medium text-background transition-colors hover:bg-foreground/90 disabled:opacity-50`,children:[(0,S.jsx)(i,{className:`h-3.5 w-3.5`}),` Camera`]}),(0,S.jsxs)(`button`,{type:`button`,onClick:()=>L(`screen`),disabled:N,className:`flex h-8 items-center gap-1 rounded-md bg-foreground px-3 text-xs font-medium text-background transition-colors hover:bg-foreground/90 disabled:opacity-50`,children:[(0,S.jsx)(o,{className:`h-3.5 w-3.5`}),` Desktop`]})]}),(0,S.jsx)(b,{consumer:`applet`,workspaceRef:A,contextPath:j,disabled:N,className:`flex h-8 items-center gap-1 rounded-md bg-foreground px-3 text-xs font-medium text-background transition-colors hover:bg-foreground/90 disabled:opacity-50`})]}),(0,S.jsxs)(`div`,{className:s(`relative shrink-0 overflow-hidden rounded-xl border border-border bg-black/80`,I?`aspect-[3/4] max-h-[60vh]`:`aspect-video max-h-80`),children:[M&&(0,S.jsx)(y,{className:`h-full w-full`,interactive:!0}),M&&(0,S.jsx)(g,{}),!M&&(0,S.jsxs)(`div`,{className:`absolute inset-0 flex items-center justify-center text-sm text-muted-foreground`,children:[(0,S.jsx)(r,{className:`mr-2 h-4 w-4`}),` camera off · or pick a photo`]})]}),M&&(0,S.jsx)(v,{className:`shrink-0`}),(0,S.jsx)(`div`,{className:`shrink-0 text-xs text-muted-foreground`,children:k?(0,S.jsx)(`span`,{className:`text-destructive`,children:k}):M?(0,S.jsxs)(S.Fragment,{children:[n.snapshot?`snapshot`:`live`,` · `,O==null?`searching…`:`${O} ms/frame`,` · `,P.length,` match`,P.length===1?``:`es`,j?` · scoped to ${j}`:``]}):N?`The Lens filter is using the camera. Stop it there first.`:`Frames are ephemeral: embedded for the query, never stored or indexed.`}),P.length===0?(0,S.jsx)(`div`,{className:`flex min-h-24 flex-1 items-center justify-center rounded-xl border border-dashed border-border text-sm text-muted-foreground`,children:M?n.snapshot?`Nothing similar in the snapshot`:`Nothing matching in view`:`Matches appear here`}):(0,S.jsx)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-3 lg:grid-cols-4`,children:P.map(e=>(0,S.jsx)(T,{workspaceRef:A,doc:e.doc,distance:e.distance,onOpen:e=>t.open(e,A)},e.doc.id))})]}):(0,S.jsx)(`div`,{className:`flex h-full items-center justify-center p-6 text-center text-sm text-muted-foreground`,children:`Lens searches a workspace. Bind it to a workspace path to start.`})}export{E as LensApplet};
|