efficient-shell 4.161.0 → 4.163.0

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.
Files changed (61) hide show
  1. package/README.md +161 -2
  2. package/dist/{Browser-56UAG7EF.js → Browser-2I27OQFE.js} +14 -14
  3. package/dist/Calculator-2EB2RAT7.js +29 -0
  4. package/dist/ConfirmDialog-4LZXI6FM.js +1 -0
  5. package/dist/{CurrencyConverter-XT37LTUQ.js → CurrencyConverter-4EEIPAVX.js} +7 -7
  6. package/dist/{Documents-6DCVHA5H.js → Documents-24YAA5UU.js} +14 -14
  7. package/dist/{Files-R5QVRKMV.js → Files-BU7FY2VD.js} +24 -24
  8. package/dist/{Notepad-5IVPFPDK.js → Notepad-3D4L3K5W.js} +9 -9
  9. package/dist/PdfViewer-5VBKCPCM.js +1 -0
  10. package/dist/{PomodoroTimer-DBOGYNE4.js → PomodoroTimer-B4OPUTJL.js} +13 -13
  11. package/dist/{Preview-ZW6SHMLE.js → Preview-VZSNH76G.js} +15 -15
  12. package/dist/{Sidebar-PS3KIZNN.js → Sidebar-7AY5WJZC.js} +27 -27
  13. package/dist/{Spreadsheet-HUJKMGJK.js → Spreadsheet-TAJ24BQS.js} +13 -13
  14. package/dist/{Stock-ZDS7COTN.js → Stock-VEPDDIMJ.js} +4 -4
  15. package/dist/{Weather-X6QGZVE6.js → Weather-KGZF4DDW.js} +7 -7
  16. package/dist/{WorldClock-5MWMG2UP.js → WorldClock-UGADOCFW.js} +7 -7
  17. package/dist/apps/index.js +1 -1
  18. package/dist/brand.css +1 -1
  19. package/dist/chunk-2FZGALCU.js +21 -0
  20. package/dist/{chunk-7B5HMN5K.js → chunk-4GOHPACN.js} +1 -1
  21. package/dist/{chunk-YNBAOTST.js → chunk-6A7BN7EN.js} +4 -4
  22. package/dist/chunk-6KO2U66R.js +3 -0
  23. package/dist/chunk-A6O4Y63A.js +1 -0
  24. package/dist/{chunk-7U37VFLE.js → chunk-E4JWTNG5.js} +19 -19
  25. package/dist/{chunk-A3XBNDFH.js → chunk-FWY5IRGL.js} +2 -2
  26. package/dist/{chunk-X4VJWQTO.js → chunk-GSBX7KIS.js} +21 -21
  27. package/dist/{chunk-65HF6TOM.js → chunk-IJ3V2YOS.js} +8 -8
  28. package/dist/{chunk-M74BPJXH.js → chunk-J5HNLMGZ.js} +13 -13
  29. package/dist/chunk-L7ZMDZAB.js +9 -0
  30. package/dist/{chunk-TOENMGDE.js → chunk-MAMJHPFN.js} +1 -1
  31. package/dist/{chunk-VBQOHZEM.js → chunk-NLASNJNY.js} +1 -1
  32. package/dist/{chunk-753UFF7V.js → chunk-PX435JG4.js} +1 -1
  33. package/dist/chunk-QRJ2ERKR.js +9 -0
  34. package/dist/chunk-TBM3ZIAN.js +112 -0
  35. package/dist/{chunk-JIHTLW46.js → chunk-TZ2EFTST.js} +6 -6
  36. package/dist/{chunk-GAXAMRUZ.js → chunk-UMOVLVTC.js} +1 -1
  37. package/dist/chunk-VWTYRICQ.js +963 -0
  38. package/dist/{chunk-HGALBDOZ.js → chunk-WURTAA2S.js} +1 -1
  39. package/dist/chunk-YJX2IWHB.js +1 -0
  40. package/dist/{chunk-C3BIYUIZ.js → chunk-ZAJPQAGP.js} +1 -1
  41. package/dist/file-intake/index.js +1 -1
  42. package/dist/{index-D-KwOzhB.d.ts → index-JQXMH_km.d.ts} +546 -69
  43. package/dist/index.d.ts +47 -49
  44. package/dist/index.js +645 -645
  45. package/dist/map/index.js +3 -3
  46. package/dist/page-tabs/index.d.ts +9 -1
  47. package/dist/page-tabs/index.js +5 -5
  48. package/dist/pdf/index.js +1 -1
  49. package/dist/ui/index.d.ts +1 -1
  50. package/dist/ui/index.js +1 -1
  51. package/package.json +3 -2
  52. package/dist/Calculator-MDKSVQWZ.js +0 -29
  53. package/dist/ConfirmDialog-JRHVCPKS.js +0 -1
  54. package/dist/PdfViewer-7YLJE5RU.js +0 -1
  55. package/dist/chunk-CFZRCRHL.js +0 -113
  56. package/dist/chunk-KCCRQ3Z4.js +0 -18
  57. package/dist/chunk-LID5IFAT.js +0 -1
  58. package/dist/chunk-RQ6BKTSJ.js +0 -1
  59. package/dist/chunk-SJZN26D3.js +0 -942
  60. package/dist/chunk-VNEH2Y6H.js +0 -9
  61. package/dist/chunk-ZP7WIUAR.js +0 -4
@@ -0,0 +1,21 @@
1
+ import{useCopyText as e,CopyGlyph as t}from"./chunk-6KO2U66R.js";import{PopupMenu as n,PopupMenuItem as r,PopupMenuDivider as l}from"./chunk-L7ZMDZAB.js";import{useShellStrings as i}from"./chunk-YJX2IWHB.js";import{useState as a,useEffect as o,Fragment as s}from"react";import{jsxs as c,jsx as d,Fragment as m}from"react/jsx-runtime";var u="outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-blue-500";function p(){/* @__PURE__ */
2
+ return d("svg",{viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",className:"size-3.5",children:/* @__PURE__ */d("path",{d:"M6.28 5.22a.75.75 0 00-1.06 1.06L8.94 10l-3.72 3.72a.75.75 0 101.06 1.06L10 11.06l3.72 3.72a.75.75 0 101.06-1.06L11.06 10l3.72-3.72a.75.75 0 00-1.06-1.06L10 8.94 6.28 5.22z"})})}function y({text:n,label:r,copiedLabel:l}){const{copied:i,copy:a}=e(n);/* @__PURE__ */
3
+ return d("button",{type:"button",tabIndex:-1,"aria-label":i?l:r,title:i?l:r,onClick:a,className:"flex size-5 shrink-0 items-center justify-center rounded text-gray-400 hover:bg-gray-200 hover:text-gray-700 @max-[10rem]:hidden",children:/* @__PURE__ */d(t,{copied:i,className:"size-3.5"})})}function h({tabs:e,activeKey:t,idFor:h,panelMounted:b,onActivate:f,onClose:g,onCloseMany:x,label:k,className:v,activeClassName:w,end:N,onIconMenu:C,menuItems:$}){const j=i().pageTabs,[z,I]=a(null),M=e.length;o(()=>{if(!t)return;const e=document.getElementById(h(t,"tab"));e?.scrollIntoView?.({block:"nearest",inline:"nearest"})},[h,t,M]);const D=e.some(e=>e.key===t)?t:e[0]?.key,L=t=>{const n=e[(t+e.length)%e.length];n&&document.getElementById(h(n.key,"tab"))?.focus()},B=z?e.find(e=>e.key===z.key):void 0,A=B&&$?$(B.key):[],_=B?e.indexOf(B):-1,E=e=>e.some(e=>!e.pinned),R=e=>()=>{I(null),e()};/* @__PURE__ */
4
+ return c("div",{className:v??"relative flex h-10 shrink-0 items-end gap-3 bg-gray-100 px-3",children:[
5
+ /* @__PURE__ */d("div",{"aria-hidden":"true",className:"pointer-events-none absolute inset-x-0 bottom-0 h-px bg-gray-200"}),
6
+ /* @__PURE__ */d("div",{role:"tablist","aria-label":k,onKeyDown:t=>{const n=e.findIndex(e=>document.getElementById(h(e.key,"tab"))===t.target);if(!(n<0)){if("ArrowRight"===t.key)L(n+1);else if("ArrowLeft"===t.key)L(n-1);else if("Home"===t.key)L(0);else if("End"===t.key)L(e.length-1);else{if("Delete"!==t.key||e[n].pinned)return;g(e[n].key)}t.preventDefault()}},className:"flex min-w-0 flex-1 items-end overflow-x-auto overflow-y-hidden [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:e.map((n,r)=>{const l=n.key===t,i=!!n.dirty,a=n.icon,o=l?w??"z-[1] border-gray-200 bg-gray-50 text-gray-900":"border-transparent text-gray-600 hover:bg-gray-200/70 hover:text-gray-900",m=r>0&&!l&&e[r-1].key!==t,x={type:"button",role:"tab",id:h(n.key,"tab"),"aria-selected":l,"aria-controls":b?.(n.key)?h(n.key,"panel"):void 0,tabIndex:n.key===D?0:-1,title:n.title,onClick:()=>f(n.key)},k={onContextMenu:e=>((e,t)=>{e.preventDefault(),I({x:e.clientX,y:e.clientY,key:t.key})})(e,n),onAuxClick:e=>((e,t)=>{1!==e.button||t.pinned||(e.preventDefault(),g(t.key))})(e,n),onMouseDown:e=>{1===e.button&&e.preventDefault()}},v=a&&
7
+ /* @__PURE__ */c("span",{className:"relative flex size-4 shrink-0 items-center justify-center text-gray-500 [&>svg]:size-4","aria-hidden":"true",children:[a,i&&!l&&!n.pinned&&
8
+ /* @__PURE__ */d("span",{className:"absolute -right-1 -top-1 hidden size-2 rounded-full bg-gray-500 ring-2 ring-gray-100 @max-[6.5rem]:block @max-[6.5rem]:group-hover:hidden"})]}),N=l&&!!C&&!!a;return n.pinned?/* @__PURE__ */d("div",{role:"presentation",className:`group relative flex h-9 flex-none items-center justify-center rounded-t-md border border-b-0 transition-colors ${a?"w-10":""} ${o}`,...k,children:/* @__PURE__ */c("button",{...x,className:`flex h-full items-center justify-center rounded-t-md ${a?"w-full":"px-3"} ${u}`,children:[v,
9
+ /* @__PURE__ */d("span",{className:a?"sr-only":"whitespace-nowrap text-[13px]",children:n.title})]})},n.key):/* @__PURE__ */c(s,{children:[m&&/* @__PURE__ */d("span",{"aria-hidden":"true",className:"mb-2.5 h-4 w-px shrink-0 self-end border-l border-gray-300"}),
10
+ /* @__PURE__ */c("div",{role:"presentation",className:`group @container relative flex h-9 items-center rounded-t-md border border-b-0 text-[13px] transition-colors ${l&&(n.copy||N)?"flex-[0_1_20rem]":"flex-[0_1_15rem]"} ${l?"min-w-[4.25rem]":"min-w-[2.75rem]"} ${o}`,...k,children:[N&&
11
+ /* @__PURE__ */d("button",{type:"button",tabIndex:-1,"aria-haspopup":"menu","aria-label":j.tabMenu??"Window menu",title:j.tabMenu??"Window menu",onClick:e=>{const t=e.currentTarget.getBoundingClientRect();C?.(n.key,t.left,t.bottom+4)},className:`ml-2 flex size-6 shrink-0 items-center justify-center rounded hover:bg-gray-200 @max-[5rem]:ml-1.5 ${u}`,children:v}),
12
+ /* @__PURE__ */c("button",{...x,className:`flex h-full min-w-0 flex-1 items-center gap-2 rounded-t-md pr-1 text-left ${N?"pl-1.5":"pl-3"} ${u} ${l?N?"":"@max-[5rem]:pl-2.5":"@max-[6.5rem]:pr-3 @max-[6.5rem]:group-hover:pr-1 @max-[4.5rem]:justify-center @max-[4.5rem]:px-0 @max-[4.5rem]:group-hover:pl-1.5"}`,children:[!N&&v,
13
+ /* @__PURE__ */d("span",{className:"min-w-0 flex-1 overflow-hidden whitespace-nowrap [mask-image:linear-gradient(to_right,#000_calc(100%-1rem),transparent)] "+(a?l?"@max-[5rem]:sr-only":"@max-[4.5rem]:sr-only":""),children:n.title})]}),l&&n.copy&&/* @__PURE__ */d(y,{text:n.copy,label:j.copy?.(n.copy)??`Copy ${n.copy}`,copiedLabel:j.copied??"Copied"}),
14
+ /* @__PURE__ */c("span",{className:"mr-1.5 flex size-5 shrink-0 items-center justify-center "+(l?"":"@max-[6.5rem]:hidden @max-[6.5rem]:group-hover:flex"),children:[i&&/* @__PURE__ */d("span",{role:"img","aria-label":j.unsaved,className:"size-2 rounded-full bg-gray-500 group-hover:hidden"}),
15
+ /* @__PURE__ */d("button",{type:"button",tabIndex:-1,"aria-label":j.closeTab?.(n.title)??`${j.close} ${n.title}`,onClick:()=>g(n.key),className:"size-5 items-center justify-center rounded text-gray-400 hover:bg-gray-200 hover:text-gray-700 "+(i?"hidden group-hover:flex":l?"flex":"flex opacity-0 group-hover:opacity-100 focus-visible:opacity-100"),children:/* @__PURE__ */d(p,{})})]})]})]},n.key)})}),N&&/* @__PURE__ */d("div",{className:"flex shrink-0 items-center gap-2 self-center",children:N}),z&&B&&/* @__PURE__ */c(n,{portal:!0,style:{left:z.x,top:z.y},onClose:()=>I(null),children:[A.length>0&&/* @__PURE__ */c(m,{children:[A.map((e,t)=>/* @__PURE__ */c(r,{onClick:R(e.onSelect),children:[e.icon,e.label]},t)),
16
+ /* @__PURE__ */d(l,{})]}),
17
+ /* @__PURE__ */d(r,{disabled:B.pinned,onClick:R(()=>g(B.key)),children:j.close}),
18
+ /* @__PURE__ */d(l,{}),
19
+ /* @__PURE__ */d(r,{disabled:!E(e.filter(e=>e.key!==B.key)),onClick:R(()=>x("others",B.key)),children:j.closeOthers}),
20
+ /* @__PURE__ */d(r,{disabled:!E(e.slice(_+1)),onClick:R(()=>x("right",B.key)),children:j.closeRight}),
21
+ /* @__PURE__ */d(r,{disabled:!E(e),onClick:R(()=>x("all",null)),children:j.closeAll})]})]})}export{h as TabStrip};
@@ -1,4 +1,4 @@
1
- import{VERSION as e}from"./chunk-LID5IFAT.js";import{useWindowMenuItem as t,Modal as r}from"./chunk-CFZRCRHL.js";import{navIcons as o}from"./chunk-DSSLOQDW.js";import{useState as n,useCallback as s,isValidElement as i,cloneElement as a}from"react";import{jsx as l,jsxs as d}from"react/jsx-runtime";var c={spreadsheet:{name:"Spreadsheets",version:"1.1.3",route:"/spreadsheet",description:"Multi-sheet spreadsheet editor with CSV / TSV import and export."},notepad:{name:"Notepad",version:"1.0.1",route:"/notepad",description:"Color-coded notes with checklists, desktop stickies and entity autolinking."},documents:{name:"Documents",version:"1.1.0",route:"/documents",description:"Letter-page editor for Word documents and plain-text files — images, lists, alignment."},preview:{name:"Preview",version:"1.4.1",route:"/preview",description:"Viewer for PDF documents, images, DXF drawings and 3D models — CAD-style measuring with object snap and an AutoCAD-like command bar."},files:{name:"Files",version:"1.1.1",route:"/files",description:"Personal file manager with folders, uploads, quota, trash and desktop shortcut folders."},browser:{name:"Browser",version:"1.0.1",route:"/browser",description:"Minimal web browser with bookmarks, history and navigation bar."}},m=/* @__PURE__ */l("svg",{className:"h-4 w-4 text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:/* @__PURE__ */l("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M11.25 11.25l.041-.02a.75.75 0 011.063.852l-.708 2.836a.75.75 0 001.063.853l.041-.021M21 12a9 9 0 11-18 0 9 9 0 0118 0zm-9-3.75h.008v.008H12V8.25z"})}),p=/* @__PURE__ */l("svg",{className:"h-9 w-9",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:/* @__PURE__ */l("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3.75 6.75A2.25 2.25 0 016 4.5h12a2.25 2.25 0 012.25 2.25v10.5A2.25 2.25 0 0118 19.5H6a2.25 2.25 0 01-2.25-2.25V6.75z M3.75 9h16.5"})});function h({app:h}){const u=c[h],[x,f]=n(!1),g=s(()=>f(!0),[]);if(t(`About ${u.name}`,g,m),!x)return null;const v=o[u.route],w=i(v)?a(v,{className:"h-9 w-9"}):p;/* @__PURE__ */
1
+ import{VERSION as e}from"./chunk-A6O4Y63A.js";import{useWindowMenuItem as t,Modal as r}from"./chunk-TBM3ZIAN.js";import{navIcons as o}from"./chunk-DSSLOQDW.js";import{useState as n,useCallback as s,isValidElement as i,cloneElement as a}from"react";import{jsx as l,jsxs as d}from"react/jsx-runtime";var c={spreadsheet:{name:"Spreadsheets",version:"1.1.3",route:"/spreadsheet",description:"Multi-sheet spreadsheet editor with CSV / TSV import and export."},notepad:{name:"Notepad",version:"1.0.1",route:"/notepad",description:"Color-coded notes with checklists, desktop stickies and entity autolinking."},documents:{name:"Documents",version:"1.1.0",route:"/documents",description:"Letter-page editor for Word documents and plain-text files — images, lists, alignment."},preview:{name:"Preview",version:"1.4.1",route:"/preview",description:"Viewer for PDF documents, images, DXF drawings and 3D models — CAD-style measuring with object snap and an AutoCAD-like command bar."},files:{name:"Files",version:"1.1.1",route:"/files",description:"Personal file manager with folders, uploads, quota, trash and desktop shortcut folders."},browser:{name:"Browser",version:"1.0.1",route:"/browser",description:"Minimal web browser with bookmarks, history and navigation bar."}},m=/* @__PURE__ */l("svg",{className:"h-4 w-4 text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:/* @__PURE__ */l("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M11.25 11.25l.041-.02a.75.75 0 011.063.852l-.708 2.836a.75.75 0 001.063.853l.041-.021M21 12a9 9 0 11-18 0 9 9 0 0118 0zm-9-3.75h.008v.008H12V8.25z"})}),p=/* @__PURE__ */l("svg",{className:"h-9 w-9",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:/* @__PURE__ */l("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3.75 6.75A2.25 2.25 0 016 4.5h12a2.25 2.25 0 012.25 2.25v10.5A2.25 2.25 0 0118 19.5H6a2.25 2.25 0 01-2.25-2.25V6.75z M3.75 9h16.5"})});function h({app:h}){const u=c[h],[x,f]=n(!1),g=s(()=>f(!0),[]);if(t(`About ${u.name}`,g,m),!x)return null;const v=o[u.route],w=i(v)?a(v,{className:"h-9 w-9"}):p;/* @__PURE__ */
2
2
  return l(r,{open:!0,onClose:()=>f(!1),title:`About ${u.name}`,size:"sm",compact:!0,bodyScroll:!1,autoHeight:!0,dimensions:[320,320],children:/* @__PURE__ */d("div",{className:"flex flex-col items-center text-center px-5 pt-5 pb-4",children:[
3
3
  /* @__PURE__ */l("div",{className:"flex h-16 w-16 items-center justify-center rounded-2xl bg-gray-100 text-gray-600 shrink-0",children:w}),
4
4
  /* @__PURE__ */l("h2",{className:"mt-3 text-lg font-bold text-gray-900",children:u.name}),
@@ -1,4 +1,4 @@
1
- import{useShellStrings as e}from"./chunk-RQ6BKTSJ.js";import{useHydrated as t,useBrowserState as r}from"./chunk-D65T4H6J.js";import{createContext as n,useSyncExternalStore as o,useCallback as i,useContext as a,useMemo as s}from"react";import{jsxs as l,jsx as c}from"react/jsx-runtime";var d="(max-width: 767px), (pointer: coarse)";function u(){return!("undefined"==typeof window||!window.matchMedia)&&window.matchMedia(d).matches}function f(){return!1}function m(e){if("undefined"==typeof window||!window.matchMedia)return()=>{};const t=window.matchMedia(d);return t.addEventListener?(t.addEventListener("change",e),()=>t.removeEventListener("change",e)):(t.addListener(e),()=>t.removeListener(e))}function h(){return o(m,u,f)}var w={success:"success",error:"error",warning:"warning",info:"info",404:"info",403:"warning",500:"error"},p={success:"text-green-600 bg-green-100",error:"text-red-600 bg-red-100",warning:"text-amber-600 bg-amber-100",info:"text-blue-600 bg-blue-100"},g={404:e=>e.notFound,403:e=>e.noAccess,500:e=>e.serverError};function v({tone:e}){const t={className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,"aria-hidden":!0};switch(e){case"success":/* @__PURE__ */
1
+ import{useShellStrings as e}from"./chunk-YJX2IWHB.js";import{useHydrated as t,useBrowserState as r}from"./chunk-D65T4H6J.js";import{createContext as n,useSyncExternalStore as o,useCallback as i,useContext as a,useMemo as s}from"react";import{jsxs as l,jsx as c}from"react/jsx-runtime";var d="(max-width: 767px), (pointer: coarse)";function u(){return!("undefined"==typeof window||!window.matchMedia)&&window.matchMedia(d).matches}function f(){return!1}function m(e){if("undefined"==typeof window||!window.matchMedia)return()=>{};const t=window.matchMedia(d);return t.addEventListener?(t.addEventListener("change",e),()=>t.removeEventListener("change",e)):(t.addListener(e),()=>t.removeListener(e))}function h(){return o(m,u,f)}var w={success:"success",error:"error",warning:"warning",info:"info",404:"info",403:"warning",500:"error"},p={success:"text-green-600 bg-green-100",error:"text-red-600 bg-red-100",warning:"text-amber-600 bg-amber-100",info:"text-blue-600 bg-blue-100"},g={404:e=>e.notFound,403:e=>e.noAccess,500:e=>e.serverError};function v({tone:e}){const t={className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,"aria-hidden":!0};switch(e){case"success":/* @__PURE__ */
2
2
  return c("svg",{...t,children:/* @__PURE__ */c("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4.5 12.75l6 6 9-13.5"})});case"error":/* @__PURE__ */
3
3
  return c("svg",{...t,children:/* @__PURE__ */c("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})});case"warning":/* @__PURE__ */
4
4
  return c("svg",{...t,children:/* @__PURE__ */c("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 9v3.75m9-.75a9 9 0 11-18 0 9 9 0 0118 0zm-9 3.75h.008v.008H12v-.008z"})});default:/* @__PURE__ */
@@ -6,6 +6,6 @@ return c("svg",{...t,children:/* @__PURE__ */c("path",{strokeLinecap:"round",str
6
6
  return l("div",{role:"error"===d?"alert":void 0,className:`flex flex-col items-center justify-center px-6 py-12 text-center ${s}`.trim(),children:[
7
7
  /* @__PURE__ */c("div",{className:`flex h-14 w-14 items-center justify-center rounded-full ${p[d]}`,children:i??/* @__PURE__ */c(v,{tone:d})}),
8
8
  /* @__PURE__ */c("h2",{className:"mt-4 text-lg font-semibold text-gray-900",children:r??g[t]?.(u)??""}),n&&/* @__PURE__ */c("p",{className:"mt-1 max-w-md text-sm text-gray-500",children:n}),a&&/* @__PURE__ */c("div",{className:"mt-4 w-full max-w-md text-left",children:a}),o&&/* @__PURE__ */c("div",{className:"mt-6 flex flex-wrap items-center justify-center gap-3",children:o})]})}function x({size:e="md",padding:t="py-12",label:r,className:n=""}){const o=/* @__PURE__ */c("div",{className:`${"sm"===e?"h-5 w-5":"lg"===e?"h-12 w-12":"h-8 w-8"} animate-spin rounded-full border-2 border-gray-200 border-t-blue-600`});return null==r?/* @__PURE__ */c("div",{className:`flex items-center justify-center ${t} ${n}`,children:o}):/* @__PURE__ */l("div",{role:"status",className:`flex flex-col items-center justify-center gap-3 ${t} ${n}`,children:[o,
9
- /* @__PURE__ */c("p",{className:"text-sm text-gray-500",children:r})]})}var L="undefined"!=typeof window&&"undefined"!=typeof navigator&&/Mac|iPhone|iPad/.test(navigator.platform||navigator.userAgent),M={MOD:["⌘","Ctrl"],ALT:["⌥","Alt"],CMD_ENTER:["⌘⏎","Ctrl⏎"],CMD_S:["⌘S","Ctrl+S"],CMD_K:["⌘K","Ctrl+K"],CMD_DOT:["⌘.","Ctrl+."],CMD_A:["⌘A","Ctrl+A"],CMD_Z:["⌘Z","Ctrl+Z"],CMD_SHIFT_Z:["⌘⇧Z","Ctrl+Shift+Z"],ALT_SHIFT_D:["⌥⇧D","Alt+Shift+D"],ALT_SHIFT_E:["⌥⇧E","Alt+Shift+E"],ALT_SHIFT_N:["⌥⇧N","Alt+Shift+N"]},_=L?0:1,S=M.MOD[_],b=M.ALT[_],C="⇧",N="⏎",D=M.CMD_ENTER[_],E=M.CMD_S[_],T=M.CMD_K[_],k=M.CMD_DOT[_],A=M.CMD_A[_],j=M.CMD_Z[_],H=M.CMD_SHIFT_Z[_],I=M.ALT_SHIFT_D[_],F=M.ALT_SHIFT_E[_],z=M.ALT_SHIFT_N[_],Z=new Map(L?Object.values(M).map(([e,t])=>[e,t]):[]);function O(e){return t()?e:Z.get(e)??e}var P="inline-flex items-center justify-center rounded border border-gray-200 bg-gray-50 font-medium text-gray-500",$={sm:"px-1 py-0.5 text-[10px]",md:"px-1.5 py-0.5 text-[11px]"};function K({keys:e,size:t="md",className:r=""}){const n=O(e);/* @__PURE__ */
10
- return c("kbd",{className:[P,$[t],r].filter(Boolean).join(" "),children:n})}var R=n(null);function J({value:e,children:t}){/* @__PURE__ */
11
- return c(R.Provider,{value:e,children:t})}function B(e="react-os-shell:prefs",t){const[n,o]=r(()=>{try{const r=JSON.parse(localStorage.getItem(e)||"{}");return{...t??{},...r}}catch{return{...t??{}}}},{...t??{}});return{prefs:n,save:i(t=>{o(r=>{const n={...r,...t};try{localStorage.setItem(e,JSON.stringify(n))}catch{}return n})},[e])}}var U={prefs:{},save:()=>{}};function W(){return a(R)??U}function Q(){const{prefs:e,save:t}=W(),r=i(e=>{const r=t(e);return r&&"function"==typeof r.then?r.catch(()=>{}):r},[t]);return s(()=>({prefs:e,save:r}),[e,r])}var V="react-os-shell:stale-chunk-reload-at",q=3e4,G="vite:preloadError",X="/_next/static/",Y=/Failed to fetch dynamically imported module|error loading dynamically imported module|Importing a module script failed|Unable to preload CSS/i;function ee(e){if(e instanceof Error&&"ChunkLoadError"===e.name)return!0;const t=e instanceof Error?e.message:"string"==typeof e?e:"";return Y.test(t)}function te(e={}){if("undefined"==typeof window)return()=>{};const t=e.cooldownMs??3e4,r=e.reload??(()=>window.location.reload()),n=e.now??Date.now,o=void 0===e.storage?function(){try{const e=window.sessionStorage;return e.getItem(V),e}catch{return null}}():e.storage,i=void 0===e.chunkPathPrefix?X:e.chunkPathPrefix,a=e=>{const r=n(),i=function(e){if(!e)return null;try{const t=e.getItem(V),r=null===t?NaN:Number(t);return Number.isFinite(r)?r:null}catch{return null}}(o);return null!==i&&r-i<t?(console.error("[efficient-shell] a lazy chunk is still missing after a reload; letting the failure through:",e),!1):(function(e,t){if(e)try{e.setItem(V,String(t))}catch{}}(o,r),console.warn("[efficient-shell] a lazy chunk is no longer on the server (new deploy?); reloading onto the current build:",e),!0)},s=e=>{const t=e.payload;ee(t)&&a(t)&&(e.preventDefault(),r())};let l=!0,c=!1;const d=/* @__PURE__ */new Set,u=null===i?null:e=>{const t=function(e,t){const r=e.target;let n="";if(r instanceof window.HTMLScriptElement?n=r.src:r instanceof window.HTMLLinkElement&&function(e){const t=e.rel.toLowerCase().split(/\s+/);if(t.includes("stylesheet")||t.includes("modulepreload"))return!0;const r=(e.getAttribute("as")??"").toLowerCase();return t.includes("preload")&&("script"===r||"style"===r)}(r)?n=r.href:e instanceof window.ErrorEvent&&"SyntaxError"===e.error?.name&&(n=e.filename),!n)return null;try{const e=new URL(t,window.location.origin).href,r=new URL(n,window.location.href).href;return r.startsWith(e)?r:null}catch{return null}}(e,i);!t||c||d.has(t)||(d.add(t),async function(e){try{const t=await fetch(e,{method:"HEAD",cache:"no-store"});return 404===t.status||410===t.status||t.ok&&/\btext\/html\b/i.test(t.headers.get("content-type")??"")}catch{return!1}}(t).then(e=>{d.delete(t),e&&l&&!c&&a(t)&&(c=!0,r())}))};return window.addEventListener(G,s),u&&window.addEventListener("error",u,!0),()=>{l=!1,window.removeEventListener(G,s),u&&window.removeEventListener("error",u,!0)}}export{b as ALT,I as ALT_SHIFT_D,F as ALT_SHIFT_E,z as ALT_SHIFT_N,A as CMD_A,k as CMD_DOT,D as CMD_ENTER,T as CMD_K,E as CMD_S,H as CMD_SHIFT_Z,j as CMD_Z,N as ENTER,K as Kbd,x as LoadingSpinner,S as MOD,X as NEXT_CHUNK_PATH_PREFIX,y as Result,C as SHIFT,q as STALE_CHUNK_RELOAD_COOLDOWN_MS,V as STALE_CHUNK_RELOAD_KEY,J as ShellPrefsProvider,G as VITE_PRELOAD_ERROR_EVENT,te as installStaleChunkReload,L as isMac,ee as isStaleChunkError,h as useIsMobile,B as useLocalStoragePrefs,Q as useShellPrefs,W as useShellPrefsAdapter,O as useShortcutLabel};
9
+ /* @__PURE__ */c("p",{className:"text-sm text-gray-500",children:r})]})}var L="undefined"!=typeof window&&"undefined"!=typeof navigator&&/Mac|iPhone|iPad/.test(navigator.platform||navigator.userAgent),M={MOD:["⌘","Ctrl"],ALT:["⌥","Alt"],CMD_ENTER:["⌘⏎","Ctrl⏎"],CMD_S:["⌘S","Ctrl+S"],CMD_K:["⌘K","Ctrl+K"],CMD_DOT:["⌘.","Ctrl+."],CMD_A:["⌘A","Ctrl+A"],CMD_Z:["⌘Z","Ctrl+Z"],CMD_SHIFT_Z:["⌘⇧Z","Ctrl+Shift+Z"],ALT_SHIFT_D:["⌥⇧D","Alt+Shift+D"],ALT_SHIFT_E:["⌥⇧E","Alt+Shift+E"],ALT_SHIFT_N:["⌥⇧N","Alt+Shift+N"]},_=L?0:1,b=M.MOD[_],C=M.ALT[_],N="⇧",S="⏎",D=M.CMD_ENTER[_],E=M.CMD_S[_],T=M.CMD_K[_],k=M.CMD_DOT[_],A=M.CMD_A[_],j=M.CMD_Z[_],H=M.CMD_SHIFT_Z[_],I=M.ALT_SHIFT_D[_],F=M.ALT_SHIFT_E[_],z=M.ALT_SHIFT_N[_],Z=new Map(L?Object.values(M).map(([e,t])=>[e,t]):[]);function O(e){return t()?e:Z.get(e)??e}var P="inline-flex items-center justify-center rounded border border-gray-200 bg-gray-50 font-medium text-gray-500",$={sm:"px-1 py-0.5 text-[10px]",md:"px-1.5 py-0.5 text-[11px]"};function J({keys:e,size:t="md",className:r=""}){const n=O(e);/* @__PURE__ */
10
+ return c("kbd",{className:[P,$[t],r].filter(Boolean).join(" "),children:n})}var K=n(null);function R({value:e,children:t}){/* @__PURE__ */
11
+ return c(K.Provider,{value:e,children:t})}function B(e="react-os-shell:prefs",t){const[n,o]=r(()=>{try{const r=JSON.parse(localStorage.getItem(e)||"{}");return{...t??{},...r}}catch{return{...t??{}}}},{...t??{}});return{prefs:n,save:i(t=>{o(r=>{const n={...r,...t};try{localStorage.setItem(e,JSON.stringify(n))}catch{}return n})},[e])}}var U={prefs:{},save:()=>{}};function W(){return a(K)??U}function V(){const{prefs:e,save:t}=W(),r=i(e=>{const r=t(e);return r&&"function"==typeof r.then?r.catch(()=>{}):r},[t]);return s(()=>({prefs:e,save:r}),[e,r])}var X="react-os-shell:stale-chunk-reload-at",Y=3e4,q="vite:preloadError",G="/_next/static/",Q=/Failed to fetch dynamically imported module|error loading dynamically imported module|Importing a module script failed|Unable to preload CSS/i;function ee(e){if(e instanceof Error&&"ChunkLoadError"===e.name)return!0;const t=e instanceof Error?e.message:"string"==typeof e?e:"";return Q.test(t)}function te(e={}){if("undefined"==typeof window)return()=>{};const t=e.cooldownMs??3e4,r=e.reload??(()=>window.location.reload()),n=e.now??Date.now,o=void 0===e.storage?function(){try{const e=window.sessionStorage;return e.getItem(X),e}catch{return null}}():e.storage,i=void 0===e.chunkPathPrefix?G:e.chunkPathPrefix,a=e=>{const r=n(),i=function(e){if(!e)return null;try{const t=e.getItem(X),r=null===t?NaN:Number(t);return Number.isFinite(r)?r:null}catch{return null}}(o);return null!==i&&r-i<t?(console.error("[efficient-shell] a lazy chunk is still missing after a reload; letting the failure through:",e),!1):(function(e,t){if(e)try{e.setItem(X,String(t))}catch{}}(o,r),console.warn("[efficient-shell] a lazy chunk is no longer on the server (new deploy?); reloading onto the current build:",e),!0)},s=e=>{const t=e.payload;ee(t)&&a(t)&&(e.preventDefault(),r())};let l=!0,c=!1;const d=/* @__PURE__ */new Set,u=null===i?null:e=>{const t=function(e,t){const r=e.target;let n="";if(r instanceof window.HTMLScriptElement?n=r.src:r instanceof window.HTMLLinkElement&&function(e){const t=e.rel.toLowerCase().split(/\s+/);if(t.includes("stylesheet")||t.includes("modulepreload"))return!0;const r=(e.getAttribute("as")??"").toLowerCase();return t.includes("preload")&&("script"===r||"style"===r)}(r)?n=r.href:e instanceof window.ErrorEvent&&"SyntaxError"===e.error?.name&&(n=e.filename),!n)return null;try{const e=new URL(t,window.location.origin).href,r=new URL(n,window.location.href).href;return r.startsWith(e)?r:null}catch{return null}}(e,i);!t||c||d.has(t)||(d.add(t),async function(e){try{const t=await fetch(e,{method:"HEAD",cache:"no-store"});return 404===t.status||410===t.status||t.ok&&/\btext\/html\b/i.test(t.headers.get("content-type")??"")}catch{return!1}}(t).then(e=>{d.delete(t),e&&l&&!c&&a(t)&&(c=!0,r())}))};return window.addEventListener(q,s),u&&window.addEventListener("error",u,!0),()=>{l=!1,window.removeEventListener(q,s),u&&window.removeEventListener("error",u,!0)}}export{C as ALT,I as ALT_SHIFT_D,F as ALT_SHIFT_E,z as ALT_SHIFT_N,A as CMD_A,k as CMD_DOT,D as CMD_ENTER,T as CMD_K,E as CMD_S,H as CMD_SHIFT_Z,j as CMD_Z,S as ENTER,J as Kbd,x as LoadingSpinner,b as MOD,G as NEXT_CHUNK_PATH_PREFIX,y as Result,N as SHIFT,Y as STALE_CHUNK_RELOAD_COOLDOWN_MS,X as STALE_CHUNK_RELOAD_KEY,R as ShellPrefsProvider,q as VITE_PRELOAD_ERROR_EVENT,te as installStaleChunkReload,L as isMac,ee as isStaleChunkError,h as useIsMobile,B as useLocalStoragePrefs,V as useShellPrefs,W as useShellPrefsAdapter,O as useShortcutLabel};
@@ -0,0 +1,3 @@
1
+ import{useState as e,useRef as r,useEffect as t,useCallback as o}from"react";import{jsx as n}from"react/jsx-runtime";function i(n){const[i,a]=e(!1),c=r(void 0);t(()=>()=>clearTimeout(c.current),[]);return{copied:i,copy:o(e=>{e?.stopPropagation(),navigator.clipboard?.writeText(n).then(()=>{a(!0),clearTimeout(c.current),c.current=setTimeout(()=>a(!1),1500)},()=>{})},[n])}}function a({copied:e,className:r="w-4 h-4"}){/* @__PURE__ */
2
+ return n("svg",e?{className:`${r} text-green-600`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:/* @__PURE__ */n("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}:{className:r,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:/* @__PURE__ */n("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})}function c({text:e}){const{copied:r,copy:t}=i(e);/* @__PURE__ */
3
+ return n("button",{onClick:t,title:r?"Copied!":`Copy ${e}`,className:"shrink-0 text-gray-400 hover:text-gray-600 transition-colors",children:/* @__PURE__ */n(a,{copied:r})})}export{c as CopyButton,a as CopyGlyph,i as useCopyText};
@@ -0,0 +1 @@
1
+ var r="4.163.0",a=r;export{a as APP_VERSION,r as VERSION};
@@ -1,29 +1,29 @@
1
- import{useDismissPopupsOnOpen as e,registerModalEscapeInterceptor as t,Z_LAYERS as n}from"./chunk-OSJ3ADF2.js";import{useShellStrings as r,splitAround as o}from"./chunk-RQ6BKTSJ.js";import{createContext as l,useEffect as i,useRef as a,useId as s,useContext as c,useState as d,useCallback as u}from"react";import{jsxs as m,jsx as f,Fragment as h}from"react/jsx-runtime";var b=["a[href]","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])",'[tabindex]:not([tabindex="-1"])'].join(",");function g(e){return Array.from(e.querySelectorAll(b)).filter(e=>null!==e.offsetParent||e===document.activeElement)}var p=[];function v(e){const t=p.findIndex(t=>t!==e&&e.contains(t));-1===t?p.push(e):p.splice(t,0,e)}function x(e){const t=p.lastIndexOf(e);-1!==t&&p.splice(t,1)}var y=/* @__PURE__ */new WeakSet;function w(e){return g(e)}function N(e,t){i(()=>{if(!t)return;const n=e.current;return n?(y.add(n),v(n),()=>{x(n),y.delete(n)}):void 0},[e,t])}function k(e,t){const n=p.lastIndexOf(t),r=n>0?p[n-1]:-1===n?p[p.length-1]??null:null,o=g(r??e.ownerDocument.body).filter(n=>!t.contains(n)&&!e.contains(n)),l=o.find(t=>0!==(e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING));return l||(r&&!y.has(r)?o[0]??null:null)}function C(e,t,n){i(()=>{if(!t)return;const r=e.current;if(!r)return;const o=document.activeElement,l=n?.current??g(r)[0]??r;l!==r||r.hasAttribute("tabindex")||r.setAttribute("tabindex","-1"),l.focus();const i=e=>{if("Tab"!==e.key)return;if(p[p.length-1]!==r)return;const t=g(r);if(0===t.length)return void e.preventDefault();const n=t[0],o=t[t.length-1],l=document.activeElement;!e.shiftKey||l!==n&&r.contains(l)?e.shiftKey||l!==o&&r.contains(l)||(e.preventDefault(),n.focus()):(e.preventDefault(),o.focus())};return v(r),document.addEventListener("keydown",i,!0),()=>{x(r),document.removeEventListener("keydown",i,!0),(r.contains(document.activeElement)||document.activeElement===document.body)&&o?.focus?.()}},[e,t,n])}var L=0,E=null;function P(e){i(()=>{if(!e)return;const t=document.body;if(0===L){E={overflow:t.style.overflow,paddingRight:t.style.paddingRight};const e=window.innerWidth-document.documentElement.clientWidth;t.style.overflow="hidden",e>0&&(t.style.paddingRight=`${e}px`)}return L+=1,()=>{0===(L-=1)&&E&&(t.style.overflow=E.overflow,t.style.paddingRight=E.paddingRight,E=null)}},[e])}var j={sm:"max-w-sm",md:"max-w-md",lg:"max-w-lg",xl:"max-w-4xl"};function D({open:o,onClose:l,title:c,description:d,role:u="dialog",children:h,footer:b,blocking:g=!1,size:p="md",initialFocus:v,"aria-label":x,"aria-labelledby":y,"aria-describedby":w,className:N=""}){const k=a(null),L=s(),E=s(),D=!g&&!b,T=s(),F=r().dialog;return e(o),C(k,o,v),P(o),i(()=>{if(o)return t(()=>(g||l(),!0))},[o,g,l]),o?/* @__PURE__ */m("div",{className:"fixed inset-0",style:{zIndex:n.overlay},role:"presentation",children:[
1
+ import{useDismissPopupsOnOpen as e,registerModalEscapeInterceptor as t,Z_LAYERS as n}from"./chunk-OSJ3ADF2.js";import{useShellStrings as r,splitAround as o}from"./chunk-YJX2IWHB.js";import{createContext as l,useEffect as i,useRef as a,useId as s,useContext as c,useState as d,useCallback as u}from"react";import{jsxs as m,jsx as f,Fragment as h}from"react/jsx-runtime";var b=["a[href]","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])",'[tabindex]:not([tabindex="-1"])'].join(",");function g(e){return Array.from(e.querySelectorAll(b)).filter(e=>null!==e.offsetParent||e===document.activeElement)}var p=[];function v(e){const t=p.findIndex(t=>t!==e&&e.contains(t));-1===t?p.push(e):p.splice(t,0,e)}function x(e){const t=p.lastIndexOf(e);-1!==t&&p.splice(t,1)}var y=/* @__PURE__ */new WeakSet;function w(e){return g(e)}function N(e,t){i(()=>{if(!t)return;const n=e.current;return n?(y.add(n),v(n),()=>{x(n),y.delete(n)}):void 0},[e,t])}function k(e,t){const n=p.lastIndexOf(t),r=n>0?p[n-1]:-1===n?p[p.length-1]??null:null,o=g(r??e.ownerDocument.body).filter(n=>!t.contains(n)&&!e.contains(n)),l=o.find(t=>0!==(e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING));return l||(r&&!y.has(r)?o[0]??null:null)}function C(e,t,n){i(()=>{if(!t)return;const r=e.current;if(!r)return;const o=document.activeElement,l=n?.current??g(r)[0]??r;l!==r||r.hasAttribute("tabindex")||r.setAttribute("tabindex","-1"),l.focus();const i=e=>{if("Tab"!==e.key)return;if(p[p.length-1]!==r)return;const t=g(r);if(0===t.length)return void e.preventDefault();const n=t[0],o=t[t.length-1],l=document.activeElement;!e.shiftKey||l!==n&&r.contains(l)?e.shiftKey||l!==o&&r.contains(l)||(e.preventDefault(),n.focus()):(e.preventDefault(),o.focus())};return v(r),document.addEventListener("keydown",i,!0),()=>{x(r),document.removeEventListener("keydown",i,!0),(r.contains(document.activeElement)||document.activeElement===document.body)&&o?.focus?.()}},[e,t,n])}var L=0,E=null;function P(e){i(()=>{if(!e)return;const t=document.body;if(0===L){E={overflow:t.style.overflow,paddingRight:t.style.paddingRight};const e=window.innerWidth-document.documentElement.clientWidth;t.style.overflow="hidden",e>0&&(t.style.paddingRight=`${e}px`)}return L+=1,()=>{0===(L-=1)&&E&&(t.style.overflow=E.overflow,t.style.paddingRight=E.paddingRight,E=null)}},[e])}var j={sm:"max-w-sm",md:"max-w-md",lg:"max-w-lg",xl:"max-w-4xl"};function D({open:o,onClose:l,title:c,description:d,role:u="dialog",children:h,footer:b,blocking:g=!1,size:p="md",initialFocus:v,"aria-label":x,"aria-labelledby":y,"aria-describedby":w,className:N=""}){const k=a(null),L=s(),E=s(),D=!g&&!b,W=s(),F=r().dialog;return e(o),C(k,o,v),P(o),i(()=>{if(o)return t(()=>(g||l(),!0))},[o,g,l]),o?/* @__PURE__ */m("div",{className:"fixed inset-0",style:{zIndex:n.overlay},role:"presentation",children:[
2
2
  /* @__PURE__ */f("div",{className:"fixed inset-0 bg-black/30","aria-hidden":"true"}),
3
- /* @__PURE__ */f("div",{className:"fixed inset-0 flex items-center justify-center p-4",onClick:g?void 0:e=>{e.target===e.currentTarget&&l()},children:/* @__PURE__ */m("div",{ref:k,role:u,"aria-modal":"true","aria-labelledby":c?T:y,"aria-label":c||y?void 0:x,"aria-describedby":w??(d?E:h?L:void 0),className:`relative max-h-full w-full ${j[p]} overflow-y-auto overscroll-contain rounded-lg bg-white p-6 shadow-xl ${N}`.trim(),children:[c&&/* @__PURE__ */f("h2",{id:T,className:(D?"pr-8 ":"")+"text-base font-semibold text-gray-900",children:c}),d&&/* @__PURE__ */f("p",{id:E,className:((c?"mt-1":D?"pr-8":"")+" text-sm text-gray-500").trim(),children:d}),h&&/* @__PURE__ */f("div",{id:L,className:"mt-2 text-sm text-gray-600",children:h}),b&&/* @__PURE__ */f("div",{className:"mt-6 flex flex-wrap justify-end gap-3",children:b}),D&&/* @__PURE__ */f("button",{type:"button",onClick:l,"aria-label":F.close,className:"absolute right-3 top-3 rounded-md p-1 text-gray-400 hover:bg-gray-100 hover:text-gray-600 rosh-focus-ring focus-visible:ring-2 focus-visible:ring-[color:var(--rosh-focus-ring-solid)]",children:/* @__PURE__ */f("svg",{className:"h-5 w-5",viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round","aria-hidden":"true",children:/* @__PURE__ */f("path",{d:"M6 6l8 8M14 6l-8 8"})})})]})})]}):null}var T=l(()=>Promise.resolve(!1)),F=()=>c(T),O=()=>Promise.resolve(!1),W=e=>O(e),I=()=>Promise.resolve(!1),M=e=>I(e),$=()=>Promise.resolve(null),R=e=>$(e),A={danger:{icon:"text-red-600 bg-red-100",button:"bg-red-600 hover:bg-red-700 text-white"},warning:{icon:"text-yellow-600 bg-yellow-100",button:"bg-yellow-600 hover:bg-yellow-700 text-white"},info:{icon:"text-blue-600 bg-blue-100",button:"bg-blue-600 hover:bg-blue-700 text-white"}},K="bg-white text-gray-700 border border-gray-300 px-4 py-2 text-sm font-medium rounded-lg hover:bg-gray-50";function S(){/* @__PURE__ */
4
- return f("svg",{className:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,"aria-hidden":"true",children:/* @__PURE__ */f("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 9v3.75m-9.303 3.376c-.866 1.5.217 3.374 1.948 3.374h14.71c1.73 0 2.813-1.874 1.948-3.374L13.949 3.378c-.866-1.5-3.032-1.5-3.898 0L2.697 16.126zM12 15.75h.007v.008H12v-.008z"})})}function z(){/* @__PURE__ */
5
- return f("svg",{className:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,"aria-hidden":"true",children:/* @__PURE__ */f("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})}function B({children:e}){const[t,n]=d(!1),[l,s]=d({message:""}),[c,b]=d(0),g=a(),p=a(null),v=a(0),x=a([]),y=a(null),w=a(null),N=u(e=>{p.current=e.id,g.current=e.resolve,b(e.id),s(e.options),n(!0)},[]),k=u(e=>{const t="string"==typeof e?{message:e}:e;return new Promise(e=>{const n={id:++v.current,options:t,resolve:e};null===p.current?N(n):x.current.push(n)})},[N]),[C,L]=d(!1),[E,P]=d({message:""}),[j,F]=d(""),W=a(),M=u(e=>(P(e),F(""),L(!0),new Promise(e=>{W.current=e})),[]),[R,B]=d(!1),[J,_]=d({}),[q,G]=d(""),H=a(),Q=u(e=>{const t="string"==typeof e?{message:e}:e;return _(t),G(t.defaultValue??""),B(!0),new Promise(e=>{H.current=e})},[]);i(()=>{O=k,I=M,$=Q},[k,M,Q]);const U=(e,t)=>{if(p.current!==e)return;const r=g.current,o=x.current.shift();o?N(o):(p.current=null,g.current=void 0,n(!1)),r?.(t)},V=e=>{L(!1),F(""),W.current?.(e)},X=e=>{if(e){const e=q.trim();if(!e&&!J.allowEmpty)return B(!1),void H.current?.(null);B(!1),H.current?.(e)}else B(!1),H.current?.(null)},Y=l.variant||(l.confirmLabel?.toLowerCase().includes("delete")||l.message.toLowerCase().includes("delete")?"danger":"info"),Z=A[Y],ee=A["warning"===E.variant?"warning":"danger"],te=E.confirmWord,ne=null==te||j===te,re=r().dialog,[oe,le]=o(re.typeToConfirm);/* @__PURE__ */
6
- return m(T.Provider,{value:k,children:[e,
7
- /* @__PURE__ */f(D,{open:t,onClose:()=>U(c,!1),initialFocus:y,footer:/* @__PURE__ */m(h,{children:[
8
- /* @__PURE__ */f("button",{ref:y,type:"button",onClick:()=>U(c,!1),className:K,children:l.cancelLabel||re.cancel}),
9
- /* @__PURE__ */f("button",{type:"button",onClick:()=>U(c,!0),className:`px-4 py-2 text-sm font-medium rounded-lg ${Z.button}`,children:l.confirmLabel||re.ok})]}),children:/* @__PURE__ */m("div",{className:"flex gap-4",children:[
10
- /* @__PURE__ */f("div",{className:`shrink-0 w-10 h-10 rounded-full flex items-center justify-center ${Z.icon}`,children:/* @__PURE__ */f(S,{})}),
3
+ /* @__PURE__ */f("div",{className:"fixed inset-0 flex items-center justify-center p-4",onClick:g?void 0:e=>{e.target===e.currentTarget&&l()},children:/* @__PURE__ */m("div",{ref:k,role:u,"aria-modal":"true","aria-labelledby":c?W:y,"aria-label":c||y?void 0:x,"aria-describedby":w??(d?E:h?L:void 0),className:`relative max-h-full w-full ${j[p]} overflow-y-auto overscroll-contain rounded-lg bg-white p-6 shadow-xl ${N}`.trim(),children:[c&&/* @__PURE__ */f("h2",{id:W,className:(D?"pr-8 ":"")+"text-base font-semibold text-gray-900",children:c}),d&&/* @__PURE__ */f("p",{id:E,className:((c?"mt-1":D?"pr-8":"")+" text-sm text-gray-500").trim(),children:d}),h&&/* @__PURE__ */f("div",{id:L,className:"mt-2 text-sm text-gray-600",children:h}),b&&/* @__PURE__ */f("div",{className:"mt-6 flex flex-wrap justify-end gap-3",children:b}),D&&/* @__PURE__ */f("button",{type:"button",onClick:l,"aria-label":F.close,className:"absolute right-3 top-3 rounded-md p-1 text-gray-400 hover:bg-gray-100 hover:text-gray-600 rosh-focus-ring focus-visible:ring-2 focus-visible:ring-[color:var(--rosh-focus-ring-solid)]",children:/* @__PURE__ */f("svg",{className:"h-5 w-5",viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round","aria-hidden":"true",children:/* @__PURE__ */f("path",{d:"M6 6l8 8M14 6l-8 8"})})})]})})]}):null}var W=l(()=>Promise.resolve(!1)),F=()=>c(W),I=()=>Promise.resolve(!1),O=e=>I(e),T=()=>Promise.resolve(!1),M=e=>T(e),$=()=>Promise.resolve(null),A=e=>$(e),R={danger:{icon:"text-red-600 bg-red-100",button:"bg-red-600 hover:bg-red-700 text-white"},warning:{icon:"text-yellow-600 bg-yellow-100",button:"bg-yellow-600 hover:bg-yellow-700 text-white"},info:{icon:"text-blue-600 bg-blue-100",button:"bg-blue-600 hover:bg-blue-700 text-white"}},z="bg-white text-gray-700 border border-gray-300 px-4 py-2 text-sm font-medium rounded-lg hover:bg-gray-50";function B(){/* @__PURE__ */
4
+ return f("svg",{className:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,"aria-hidden":"true",children:/* @__PURE__ */f("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 9v3.75m-9.303 3.376c-.866 1.5.217 3.374 1.948 3.374h14.71c1.73 0 2.813-1.874 1.948-3.374L13.949 3.378c-.866-1.5-3.032-1.5-3.898 0L2.697 16.126zM12 15.75h.007v.008H12v-.008z"})})}function K(){/* @__PURE__ */
5
+ return f("svg",{className:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,"aria-hidden":"true",children:/* @__PURE__ */f("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})}function S({children:e}){const[t,n]=d(!1),[l,s]=d({message:""}),[c,b]=d(0),g=a(),p=a(null),v=a(0),x=a([]),y=a(null),w=a(null),N=u(e=>{p.current=e.id,g.current=e.resolve,b(e.id),s(e.options),n(!0)},[]),k=u(e=>{const t="string"==typeof e?{message:e}:e;return new Promise(e=>{const n={id:++v.current,options:t,resolve:e};null===p.current?N(n):x.current.push(n)})},[N]),[C,L]=d(!1),[E,P]=d({message:""}),[j,F]=d(""),O=a(),M=u(e=>(P(e),F(""),L(!0),new Promise(e=>{O.current=e})),[]),[A,S]=d(!1),[H,J]=d({}),[_,q]=d(""),G=a(),U=u(e=>{const t="string"==typeof e?{message:e}:e;return J(t),q(t.defaultValue??""),S(!0),new Promise(e=>{G.current=e})},[]);i(()=>{I=k,T=M,$=U},[k,M,U]);const V=(e,t)=>{if(p.current!==e)return;const r=g.current,o=x.current.shift();o?N(o):(p.current=null,g.current=void 0,n(!1)),r?.(t)},X=e=>{L(!1),F(""),O.current?.(e)},Y=e=>{if(e){const e=_.trim();if(!e&&!H.allowEmpty)return S(!1),void G.current?.(null);S(!1),G.current?.(e)}else S(!1),G.current?.(null)},Q=l.variant||(l.confirmLabel?.toLowerCase().includes("delete")||l.message.toLowerCase().includes("delete")?"danger":"info"),Z=R[Q],ee=R["warning"===E.variant?"warning":"danger"],te=E.confirmWord,ne=null==te||j===te,re=r().dialog,[oe,le]=o(re.typeToConfirm);/* @__PURE__ */
6
+ return m(W.Provider,{value:k,children:[e,
7
+ /* @__PURE__ */f(D,{open:t,onClose:()=>V(c,!1),initialFocus:y,footer:/* @__PURE__ */m(h,{children:[
8
+ /* @__PURE__ */f("button",{ref:y,type:"button",onClick:()=>V(c,!1),className:z,children:l.cancelLabel||re.cancel}),
9
+ /* @__PURE__ */f("button",{type:"button",onClick:()=>V(c,!0),className:`px-4 py-2 text-sm font-medium rounded-lg ${Z.button}`,children:l.confirmLabel||re.ok})]}),children:/* @__PURE__ */m("div",{className:"flex gap-4",children:[
10
+ /* @__PURE__ */f("div",{className:`shrink-0 w-10 h-10 rounded-full flex items-center justify-center ${Z.icon}`,children:/* @__PURE__ */f(B,{})}),
11
11
  /* @__PURE__ */m("div",{className:"flex-1",children:[
12
12
  /* @__PURE__ */f("h2",{className:"text-base font-semibold text-gray-900",children:l.title||re.confirmTitle}),
13
13
  /* @__PURE__ */f("p",{className:"mt-2 text-sm text-gray-600",children:l.message})]})]})}),
14
- /* @__PURE__ */m(D,{open:C,onClose:()=>V(!1),initialFocus:null!=te?void 0:w,footer:/* @__PURE__ */m(h,{children:[
15
- /* @__PURE__ */f("button",{ref:w,type:"button",onClick:()=>V(!1),className:K,children:E.cancelLabel||re.destructiveCancel}),
16
- /* @__PURE__ */f("button",{type:"button",onClick:()=>V(!0),disabled:!ne,className:`px-4 py-2 text-sm font-medium rounded-lg disabled:opacity-40 ${ee.button}`,children:te??E.confirmLabel??re.destructiveConfirm})]}),children:[
17
- /* @__PURE__ */f("button",{type:"button",onClick:()=>V(!1),"aria-label":re.close,className:"absolute right-4 top-4 rounded-md p-1 text-gray-400 hover:bg-gray-100 hover:text-gray-600",children:/* @__PURE__ */f(z,{})}),
14
+ /* @__PURE__ */m(D,{open:C,onClose:()=>X(!1),initialFocus:null!=te?void 0:w,footer:/* @__PURE__ */m(h,{children:[
15
+ /* @__PURE__ */f("button",{ref:w,type:"button",onClick:()=>X(!1),className:z,children:E.cancelLabel||re.destructiveCancel}),
16
+ /* @__PURE__ */f("button",{type:"button",onClick:()=>X(!0),disabled:!ne,className:`px-4 py-2 text-sm font-medium rounded-lg disabled:opacity-40 ${ee.button}`,children:te??E.confirmLabel??re.destructiveConfirm})]}),children:[
17
+ /* @__PURE__ */f("button",{type:"button",onClick:()=>X(!1),"aria-label":re.close,className:"absolute right-4 top-4 rounded-md p-1 text-gray-400 hover:bg-gray-100 hover:text-gray-600",children:/* @__PURE__ */f(K,{})}),
18
18
  /* @__PURE__ */m("div",{className:"flex gap-4",children:[
19
- /* @__PURE__ */f("div",{className:`shrink-0 w-10 h-10 rounded-full flex items-center justify-center ${ee.icon}`,children:/* @__PURE__ */f(S,{})}),
19
+ /* @__PURE__ */f("div",{className:`shrink-0 w-10 h-10 rounded-full flex items-center justify-center ${ee.icon}`,children:/* @__PURE__ */f(B,{})}),
20
20
  /* @__PURE__ */m("div",{className:"flex-1",children:[
21
21
  /* @__PURE__ */f("h2",{className:"text-base font-semibold text-gray-900 pr-6",children:E.title||re.destructiveTitle}),
22
22
  /* @__PURE__ */f("p",{className:"mt-2 text-sm text-gray-600",children:E.message}),null!=te&&/* @__PURE__ */m(h,{children:[
23
23
  /* @__PURE__ */m("p",{className:"mt-3 text-sm text-gray-700",children:[oe,
24
24
  /* @__PURE__ */f("kbd",{className:"rounded border border-gray-300 bg-gray-50 px-1.5 py-0.5 text-xs font-bold text-red-600 font-mono",children:te}),le]}),
25
- /* @__PURE__ */f("input",{autoFocus:!0,type:"text",value:j,onChange:e=>F(e.target.value),onKeyDown:e=>{"Enter"===e.key&&j===te&&V(!0)},placeholder:te,className:"mt-2 w-full rounded-md border border-gray-300 px-3 py-2 text-sm focus:border-red-500"})]})]})]})]}),
26
- /* @__PURE__ */m(D,{open:R,onClose:()=>X(!1),title:J.title||re.promptTitle,footer:/* @__PURE__ */m(h,{children:[
27
- /* @__PURE__ */f("button",{type:"button",onClick:()=>X(!1),className:K,children:J.cancelLabel||re.cancel}),
28
- /* @__PURE__ */f("button",{type:"button",onClick:()=>X(!0),disabled:!J.allowEmpty&&!q.trim(),className:"bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 text-sm font-medium rounded-lg disabled:opacity-40",children:J.confirmLabel||re.ok})]}),children:[J.message&&/* @__PURE__ */f("p",{className:"text-sm text-gray-600",children:J.message}),
29
- /* @__PURE__ */f("input",{autoFocus:!0,type:"text",value:q,onChange:e=>G(e.target.value),onKeyDown:e=>{"Enter"===e.key?X(!0):"Escape"===e.key&&X(!1)},onFocus:e=>e.target.select(),placeholder:J.placeholder,className:"mt-3 w-full rounded-md border border-gray-300 px-3 py-2 text-sm focus:border-blue-500 rosh-focus-ring focus-visible:ring-1 focus-visible:ring-[color:var(--rosh-focus-ring-accent)]"})]})]})}export{B as ConfirmProvider,D as Dialog,W as confirm,M as confirmDestructive,w as focusableIn,R as prompt,k as stopAfter,F as useConfirm,C as useFocusTrap,P as useScrollLock,N as useTabLayer};
25
+ /* @__PURE__ */f("input",{autoFocus:!0,type:"text",value:j,onChange:e=>F(e.target.value),onKeyDown:e=>{"Enter"===e.key&&j===te&&X(!0)},placeholder:te,className:"mt-2 w-full rounded-md border border-gray-300 px-3 py-2 text-sm focus:border-red-500"})]})]})]})]}),
26
+ /* @__PURE__ */m(D,{open:A,onClose:()=>Y(!1),title:H.title||re.promptTitle,footer:/* @__PURE__ */m(h,{children:[
27
+ /* @__PURE__ */f("button",{type:"button",onClick:()=>Y(!1),className:z,children:H.cancelLabel||re.cancel}),
28
+ /* @__PURE__ */f("button",{type:"button",onClick:()=>Y(!0),disabled:!H.allowEmpty&&!_.trim(),className:"bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 text-sm font-medium rounded-lg disabled:opacity-40",children:H.confirmLabel||re.ok})]}),children:[H.message&&/* @__PURE__ */f("p",{className:"text-sm text-gray-600",children:H.message}),
29
+ /* @__PURE__ */f("input",{autoFocus:!0,type:"text",value:_,onChange:e=>q(e.target.value),onKeyDown:e=>{"Enter"===e.key?Y(!0):"Escape"===e.key&&Y(!1)},onFocus:e=>e.target.select(),placeholder:H.placeholder,className:"mt-3 w-full rounded-md border border-gray-300 px-3 py-2 text-sm focus:border-blue-500 rosh-focus-ring focus-visible:ring-1 focus-visible:ring-[color:var(--rosh-focus-ring-accent)]"})]})]})}export{S as ConfirmProvider,D as Dialog,O as confirm,M as confirmDestructive,w as focusableIn,A as prompt,k as stopAfter,F as useConfirm,C as useFocusTrap,P as useScrollLock,N as useTabLayer};
@@ -1,2 +1,2 @@
1
- import{toast_default as t}from"./chunk-VBQOHZEM.js";import{useShellPrefs as e}from"./chunk-YNBAOTST.js";import{useSyncExternalStore as n,useCallback as o,useMemo as a}from"react";var r=[{id:"bell",label:"Bell",description:"Soft bell with one harmonic"},{id:"chime",label:"Chime",description:"Two-note ascending chime"},{id:"bowl",label:"Singing Bowl",description:"Long-decay meditation tone"},{id:"wind-chimes",label:"Wind Chimes",description:"Four soft tones in succession"},{id:"off",label:"Off (silent)",description:"No sound — only desktop notification"}],i=[{id:"none",label:"None"},{id:"tick-fast",label:"Ticking Fast"},{id:"tick-slow",label:"Ticking Slow"},{id:"rain",label:"Rain"},{id:"fireplace",label:"Fireplace"},{id:"white",label:"White Noise"},{id:"pink",label:"Pink Noise"},{id:"brown",label:"Brown Noise"}],c=()=>`pomodoro-${/* @__PURE__ */(new Date).toISOString().slice(0,10)}`,l={focus:1500,short:300,long:900},s="bell",u=100,d=1,f="none",m=50,h={autoStartBreaks:!1,autoStartPomodoros:!1,longBreakInterval:4},g={running:!1,remaining:l.focus,mode:"focus",total:l.focus,streak:0,count:"undefined"!=typeof localStorage?(()=>{try{return parseInt(localStorage.getItem(c())||"0",10)||0}catch{return 0}})():0},p=null,k=/* @__PURE__ */new Set,w=t=>{g={...g,...t},k.forEach(t=>t())};function M(){return g}function S(t){return k.add(t),()=>{k.delete(t)}}function b(t){l=t,g.running||g.remaining!==g.total||w({remaining:t[g.mode],total:t[g.mode]})}function y(t){s=t}function v(t,e){u=Math.max(0,Math.min(100,Math.round(t))),d=Math.max(1,Math.min(5,Math.round(e)))}function T(t){h={autoStartBreaks:!!t.autoStartBreaks,autoStartPomodoros:!!t.autoStartPomodoros,longBreakInterval:Math.max(1,Math.min(20,Math.round(t.longBreakInterval||4)))}}function A(t,e){f=t,m=Math.max(0,Math.min(100,Math.round(e))),g.running&&"focus"===g.mode?(V(),R()):"none"!==t&&0!==m||V()}function I(){g.running||(w({running:!0}),p=setInterval(N,1e3),"focus"===g.mode&&R())}function x(){(g.running||null!==p)&&(null!==p&&(clearInterval(p),p=null),w({running:!1}),V())}function B(t){x(),w({mode:t,remaining:l[t],total:l[t]})}function N(){g.remaining<=1?function(){null!==p&&(clearInterval(p),p=null);V(),C(s,{volume:u,repeat:d});const e="focus"===g.mode?"Pomodoro complete — time for a break! 🍅":"Break's over — back to work!";if("undefined"!=typeof Notification&&"granted"===Notification.permission)try{new Notification(e)}catch{}try{t.info(e)}catch{}if("focus"===g.mode){const t=g.streak+1,e=g.count+1;(t=>{try{localStorage.setItem(c(),String(t))}catch{}})(e);const n=t%h.longBreakInterval===0?"long":"short";w({running:!1,streak:t,count:e,mode:n,remaining:l[n],total:l[n]}),h.autoStartBreaks&&setTimeout(()=>I(),50)}else w({running:!1,mode:"focus",remaining:l.focus,total:l.focus}),h.autoStartPomodoros&&setTimeout(()=>I(),50)}():w({remaining:g.remaining-1})}function C(t=s,e={}){if("off"===t)return;const n=Math.max(0,Math.min(100,e.volume??100))/100;if(0===n)return;const o=Math.max(1,Math.min(5,e.repeat??1));for(let e=0;e<o;e++)setTimeout(()=>P(t,n),2500*e)}function P(t,e){try{const n=window.AudioContext||window.webkitAudioContext;if(!n)return;const o=new n,a=(t,n,a,r=.22,i="sine")=>{const c=o.createOscillator(),l=o.createGain();c.connect(l),l.connect(o.destination),c.type=i,c.frequency.value=t;const s=o.currentTime+n;l.gain.setValueAtTime(0,s),l.gain.linearRampToValueAtTime(r*e,s+.03),l.gain.exponentialRampToValueAtTime(1e-4,s+a),c.start(s),c.stop(s+a)};let r=2;"bell"===t?(a(880,0,1.8),a(1320,0,1.4,.1),r=2):"chime"===t?(a(659.25,0,.7),a(880,.2,1.3),r=2):"bowl"===t?(a(440,0,3.4,.22),a(660,0,3,.08),a(880,.05,2.8,.05),r=4):"wind-chimes"===t&&(a(1175,0,1.1,.16),a(880,.15,1.3,.16),a(1318,.3,1.5,.16),a(1047,.5,1.7,.13),r=3),setTimeout(()=>{try{o.close()}catch{}},1e3*r+500)}catch{}}var O=null,D={none:0,white:.3,pink:.3,brown:.3,"tick-fast":.6,"tick-slow":.6,rain:.4,fireplace:.5};function _(t,e){if("none"===e)return null;const n=t.sampleRate,o="white"===e||"pink"===e||"brown"===e?2:4,a=n*o,r=t.createBuffer(1,a,n),i=r.getChannelData(0);if("white"===e)for(let t=0;t<a;t++)i[t]=.5*(2*Math.random()-1);else if("pink"===e){let t=0,e=0,n=0,o=0,r=0,c=0,l=0;for(let s=0;s<a;s++){const a=2*Math.random()-1;t=.99886*t+.0555179*a,e=.99332*e+.0750759*a,n=.969*n+.153852*a,o=.8665*o+.3104856*a,r=.55*r+.5329522*a,c=-.7616*c-.016898*a,i[s]=.11*(t+e+n+o+r+c+l+.5362*a)*.55,l=.115926*a}}else if("brown"===e){let t=0;for(let e=0;e<a;e++){t=(t+.02*(2*Math.random()-1))/1.02,i[e]=3.5*t*.5}}else if("tick-fast"===e||"tick-slow"===e){const t="tick-fast"===e?.5:1,r=Math.floor(.045*n);for(let e=0;e<o;e+=t){const t=Math.floor(e*n);for(let e=0;e<r&&t+e<a;e++){const o=Math.exp(-e/n*180),a=2*Math.random()-1,r=Math.sin(2*Math.PI*1100*(e/n));i[t+e]+=(.7*a+.25*r)*o*.55}}}else if("rain"===e){let t=0;for(let e=0;e<a;e++){const o=2*Math.random()-1,a=o-.93*t;t=o;const r=.7+.3*Math.sin(e/n*2*Math.PI*.25);i[e]=a*r*.4}}else if("fireplace"===e){let t=0;for(let e=0;e<a;e++){t=(t+.02*(2*Math.random()-1))/1.02,i[e]=1.6*t}let e=.4*Math.random()*n;for(;e<a;){const t=Math.floor((.012+.05*Math.random())*n),o=.35+.45*Math.random(),r=Math.floor(e);for(let e=0;e<t&&r+e<a;e++){const t=Math.exp(-e/n*90);i[r+e]+=(2*Math.random()-1)*t*o}e+=(.08+.62*Math.random())*n}}return r}function R(){if(!O&&"none"!==f&&0!==m)try{const t=window.AudioContext||window.webkitAudioContext;if(!t)return;const e=new t,n=_(e,f);if(!n){try{e.close()}catch{}return}const o=e.createBufferSource();o.buffer=n,o.loop=!0;const a=e.createGain();a.gain.value=m/100*D[f],o.connect(a).connect(e.destination),o.start(),O={ctx:e,src:o,gain:a}}catch{}}function V(){if(O){try{O.src.stop()}catch{}try{O.ctx.close()}catch{}O=null}}function F(t,e){if("none"!==t&&0!==e)try{const n=window.AudioContext||window.webkitAudioContext;if(!n)return;const o=new n,a=_(o,t);if(!a){try{o.close()}catch{}return}const r=o.createBufferSource();r.buffer=a,r.loop=!0;const i=o.createGain();i.gain.value=e/100*D[t],r.connect(i).connect(o.destination),r.start(),setTimeout(()=>{try{r.stop()}catch{}try{o.close()}catch{}},3e3)}catch{}}var G="pomodoro_tasks",j="pomodoro_tasks_migrated";function E(){return Math.random().toString(36).slice(2,11)}function W(){/* @__PURE__ */
2
- return(new Date).toISOString()}var q=null,H=[],J=!1,L=null,Q=/* @__PURE__ */new Set;function Y(){for(const t of Q)t()}function Z(t){H=t,Y()}function $(){const t=q;return t?L=t.list().then(e=>{q===t&&(H=e,J=!0,Y())}).catch(()=>{q===t&&(J=!0,Y())}).finally(()=>{L=null}):(H=[],J=!0,Y(),Promise.resolve())}function z(t){q=t,H=[],J=!1,t?$():Y()}function K(t){return Q.add(t),!q||J||L||$(),()=>{Q.delete(t)}}function U(){return H}function X(){const t=function(){const{prefs:t,save:n}=e(),r=a(()=>{const e=t.todo_tasks;return Array.isArray(e)?e:[]},[t.todo_tasks]),i=o(t=>{n({todo_tasks:t})},[n]),c=o(t=>{const e=E(),n=W(),o={done:!1,...t,name:t.name.trim(),id:e,createdAt:n,updatedAt:n};return i([...r,o]),e},[r,i]),l=o((t,e)=>{i(r.map(n=>n.id===t?{...n,...e,id:n.id,updatedAt:W()}:n))},[r,i]),s=o(t=>{i(r.filter(e=>e.id!==t))},[r,i]),u=o(t=>{const e=r.find(e=>e.id===t);e&&l(t,{done:!e.done})},[r,l]);return{tasks:r,addTask:c,updateTask:l,removeTask:s,toggleDone:u,setAllTasks:i}}(),r=n(K,U,U),i=o(e=>{const n=q;if(!n)return t.addTask(e);const o="tmp-"+E(),a=W(),r={done:!1,...e,name:e.name.trim(),id:o,createdAt:a,updatedAt:a};return Z([...H,r]),n.create({...e,name:e.name.trim()}).then(t=>Z(H.map(e=>e.id===o?{...r,...t}:e))).catch(()=>Z(H.filter(t=>t.id!==o))),o},[t]),c=o((e,n)=>{const o=q;if(!o)return t.updateTask(e,n);Z(H.map(t=>t.id===e?{...t,...n,id:e,updatedAt:W()}:t)),o.update(e,n).catch(()=>{$()})},[t]),l=o(e=>{const n=q;if(!n)return t.removeTask(e);const o=H;Z(H.filter(t=>t.id!==e)),n.remove(e).catch(()=>Z(o))},[t]),s=o(e=>{if(!q)return t.toggleDone(e);const n=H.find(t=>t.id===e);n&&c(e,{done:!n.done})},[t,c]),u=o(e=>{q||t.setAllTasks(e)},[t]);return null===q?t:{tasks:r,addTask:i,updateTask:c,removeTask:l,toggleDone:s,setAllTasks:u}}function tt(t,e){try{if(localStorage.getItem(j))return;const n=localStorage.getItem(G);if(!n)return void localStorage.setItem(j,"1");const o=JSON.parse(n);if(!Array.isArray(o)||0===o.length)return localStorage.removeItem(G),void localStorage.setItem(j,"1");const a=W(),r=o.filter(t=>"string"==typeof t?.name).map(t=>({id:t.id||E(),name:String(t.name),done:!!t.done,estimated:"number"==typeof t.estimated?t.estimated:void 0,completed:"number"==typeof t.completed?t.completed:void 0,createdAt:a,updatedAt:a})),i=new Set(t.map(t=>t.id));e([...r.filter(t=>!i.has(t.id)),...t]),localStorage.removeItem(G),localStorage.setItem(j,"1")}catch{try{localStorage.setItem(j,"1")}catch{}}}export{r as ALARM_OPTIONS,i as FOCUS_SOUND_OPTIONS,M as getPomoSnapshot,tt as migratePomodoroTasksOnce,C as playAlarm,x as pomoPause,I as pomoStart,B as pomoSwitchMode,F as previewFocusSound,y as setPomoAlarm,v as setPomoAlarmConfig,T as setPomoBehaviour,b as setPomoDurations,A as setPomoFocusSound,z as setShellTodoProvider,S as subscribePomo,X as useTodoTasks};
1
+ import{toast_default as t}from"./chunk-NLASNJNY.js";import{useShellPrefs as e}from"./chunk-6A7BN7EN.js";import{useSyncExternalStore as n,useCallback as o,useMemo as a}from"react";var r=[{id:"bell",label:"Bell",description:"Soft bell with one harmonic"},{id:"chime",label:"Chime",description:"Two-note ascending chime"},{id:"bowl",label:"Singing Bowl",description:"Long-decay meditation tone"},{id:"wind-chimes",label:"Wind Chimes",description:"Four soft tones in succession"},{id:"off",label:"Off (silent)",description:"No sound — only desktop notification"}],i=[{id:"none",label:"None"},{id:"tick-fast",label:"Ticking Fast"},{id:"tick-slow",label:"Ticking Slow"},{id:"rain",label:"Rain"},{id:"fireplace",label:"Fireplace"},{id:"white",label:"White Noise"},{id:"pink",label:"Pink Noise"},{id:"brown",label:"Brown Noise"}],c=()=>`pomodoro-${/* @__PURE__ */(new Date).toISOString().slice(0,10)}`,l={focus:1500,short:300,long:900},s="bell",u=100,d=1,f="none",m=50,h={autoStartBreaks:!1,autoStartPomodoros:!1,longBreakInterval:4},g={running:!1,remaining:l.focus,mode:"focus",total:l.focus,streak:0,count:"undefined"!=typeof localStorage?(()=>{try{return parseInt(localStorage.getItem(c())||"0",10)||0}catch{return 0}})():0},p=null,k=/* @__PURE__ */new Set,w=t=>{g={...g,...t},k.forEach(t=>t())};function M(){return g}function S(t){return k.add(t),()=>{k.delete(t)}}function b(t){l=t,g.running||g.remaining!==g.total||w({remaining:t[g.mode],total:t[g.mode]})}function y(t){s=t}function v(t,e){u=Math.max(0,Math.min(100,Math.round(t))),d=Math.max(1,Math.min(5,Math.round(e)))}function A(t){h={autoStartBreaks:!!t.autoStartBreaks,autoStartPomodoros:!!t.autoStartPomodoros,longBreakInterval:Math.max(1,Math.min(20,Math.round(t.longBreakInterval||4)))}}function T(t,e){f=t,m=Math.max(0,Math.min(100,Math.round(e))),g.running&&"focus"===g.mode?(F(),R()):"none"!==t&&0!==m||F()}function I(){g.running||(w({running:!0}),p=setInterval(N,1e3),"focus"===g.mode&&R())}function x(){(g.running||null!==p)&&(null!==p&&(clearInterval(p),p=null),w({running:!1}),F())}function B(t){x(),w({mode:t,remaining:l[t],total:l[t]})}function N(){g.remaining<=1?function(){null!==p&&(clearInterval(p),p=null);F(),C(s,{volume:u,repeat:d});const e="focus"===g.mode?"Pomodoro complete — time for a break! 🍅":"Break's over — back to work!";if("undefined"!=typeof Notification&&"granted"===Notification.permission)try{new Notification(e)}catch{}try{t.info(e)}catch{}if("focus"===g.mode){const t=g.streak+1,e=g.count+1;(t=>{try{localStorage.setItem(c(),String(t))}catch{}})(e);const n=t%h.longBreakInterval===0?"long":"short";w({running:!1,streak:t,count:e,mode:n,remaining:l[n],total:l[n]}),h.autoStartBreaks&&setTimeout(()=>I(),50)}else w({running:!1,mode:"focus",remaining:l.focus,total:l.focus}),h.autoStartPomodoros&&setTimeout(()=>I(),50)}():w({remaining:g.remaining-1})}function C(t=s,e={}){if("off"===t)return;const n=Math.max(0,Math.min(100,e.volume??100))/100;if(0===n)return;const o=Math.max(1,Math.min(5,e.repeat??1));for(let e=0;e<o;e++)setTimeout(()=>P(t,n),2500*e)}function P(t,e){try{const n=window.AudioContext||window.webkitAudioContext;if(!n)return;const o=new n,a=(t,n,a,r=.22,i="sine")=>{const c=o.createOscillator(),l=o.createGain();c.connect(l),l.connect(o.destination),c.type=i,c.frequency.value=t;const s=o.currentTime+n;l.gain.setValueAtTime(0,s),l.gain.linearRampToValueAtTime(r*e,s+.03),l.gain.exponentialRampToValueAtTime(1e-4,s+a),c.start(s),c.stop(s+a)};let r=2;"bell"===t?(a(880,0,1.8),a(1320,0,1.4,.1),r=2):"chime"===t?(a(659.25,0,.7),a(880,.2,1.3),r=2):"bowl"===t?(a(440,0,3.4,.22),a(660,0,3,.08),a(880,.05,2.8,.05),r=4):"wind-chimes"===t&&(a(1175,0,1.1,.16),a(880,.15,1.3,.16),a(1318,.3,1.5,.16),a(1047,.5,1.7,.13),r=3),setTimeout(()=>{try{o.close()}catch{}},1e3*r+500)}catch{}}var D=null,_={none:0,white:.3,pink:.3,brown:.3,"tick-fast":.6,"tick-slow":.6,rain:.4,fireplace:.5};function O(t,e){if("none"===e)return null;const n=t.sampleRate,o="white"===e||"pink"===e||"brown"===e?2:4,a=n*o,r=t.createBuffer(1,a,n),i=r.getChannelData(0);if("white"===e)for(let t=0;t<a;t++)i[t]=.5*(2*Math.random()-1);else if("pink"===e){let t=0,e=0,n=0,o=0,r=0,c=0,l=0;for(let s=0;s<a;s++){const a=2*Math.random()-1;t=.99886*t+.0555179*a,e=.99332*e+.0750759*a,n=.969*n+.153852*a,o=.8665*o+.3104856*a,r=.55*r+.5329522*a,c=-.7616*c-.016898*a,i[s]=.11*(t+e+n+o+r+c+l+.5362*a)*.55,l=.115926*a}}else if("brown"===e){let t=0;for(let e=0;e<a;e++){t=(t+.02*(2*Math.random()-1))/1.02,i[e]=3.5*t*.5}}else if("tick-fast"===e||"tick-slow"===e){const t="tick-fast"===e?.5:1,r=Math.floor(.045*n);for(let e=0;e<o;e+=t){const t=Math.floor(e*n);for(let e=0;e<r&&t+e<a;e++){const o=Math.exp(-e/n*180),a=2*Math.random()-1,r=Math.sin(2*Math.PI*1100*(e/n));i[t+e]+=(.7*a+.25*r)*o*.55}}}else if("rain"===e){let t=0;for(let e=0;e<a;e++){const o=2*Math.random()-1,a=o-.93*t;t=o;const r=.7+.3*Math.sin(e/n*2*Math.PI*.25);i[e]=a*r*.4}}else if("fireplace"===e){let t=0;for(let e=0;e<a;e++){t=(t+.02*(2*Math.random()-1))/1.02,i[e]=1.6*t}let e=.4*Math.random()*n;for(;e<a;){const t=Math.floor((.012+.05*Math.random())*n),o=.35+.45*Math.random(),r=Math.floor(e);for(let e=0;e<t&&r+e<a;e++){const t=Math.exp(-e/n*90);i[r+e]+=(2*Math.random()-1)*t*o}e+=(.08+.62*Math.random())*n}}return r}function R(){if(!D&&"none"!==f&&0!==m)try{const t=window.AudioContext||window.webkitAudioContext;if(!t)return;const e=new t,n=O(e,f);if(!n){try{e.close()}catch{}return}const o=e.createBufferSource();o.buffer=n,o.loop=!0;const a=e.createGain();a.gain.value=m/100*_[f],o.connect(a).connect(e.destination),o.start(),D={ctx:e,src:o,gain:a}}catch{}}function F(){if(D){try{D.src.stop()}catch{}try{D.ctx.close()}catch{}D=null}}function G(t,e){if("none"!==t&&0!==e)try{const n=window.AudioContext||window.webkitAudioContext;if(!n)return;const o=new n,a=O(o,t);if(!a){try{o.close()}catch{}return}const r=o.createBufferSource();r.buffer=a,r.loop=!0;const i=o.createGain();i.gain.value=e/100*_[t],r.connect(i).connect(o.destination),r.start(),setTimeout(()=>{try{r.stop()}catch{}try{o.close()}catch{}},3e3)}catch{}}var V="pomodoro_tasks",j="pomodoro_tasks_migrated";function E(){return Math.random().toString(36).slice(2,11)}function J(){/* @__PURE__ */
2
+ return(new Date).toISOString()}var L=null,W=[],q=!1,Y=null,$=/* @__PURE__ */new Set;function z(){for(const t of $)t()}function H(t){W=t,z()}function K(){const t=L;return t?Y=t.list().then(e=>{L===t&&(W=e,q=!0,z())}).catch(()=>{L===t&&(q=!0,z())}).finally(()=>{Y=null}):(W=[],q=!0,z(),Promise.resolve())}function Q(t){L=t,W=[],q=!1,t?K():z()}function U(t){return $.add(t),!L||q||Y||K(),()=>{$.delete(t)}}function X(){return W}function Z(){const t=function(){const{prefs:t,save:n}=e(),r=a(()=>{const e=t.todo_tasks;return Array.isArray(e)?e:[]},[t.todo_tasks]),i=o(t=>{n({todo_tasks:t})},[n]),c=o(t=>{const e=E(),n=J(),o={done:!1,...t,name:t.name.trim(),id:e,createdAt:n,updatedAt:n};return i([...r,o]),e},[r,i]),l=o((t,e)=>{i(r.map(n=>n.id===t?{...n,...e,id:n.id,updatedAt:J()}:n))},[r,i]),s=o(t=>{i(r.filter(e=>e.id!==t))},[r,i]),u=o(t=>{const e=r.find(e=>e.id===t);e&&l(t,{done:!e.done})},[r,l]);return{tasks:r,addTask:c,updateTask:l,removeTask:s,toggleDone:u,setAllTasks:i}}(),r=n(U,X,X),i=o(e=>{const n=L;if(!n)return t.addTask(e);const o="tmp-"+E(),a=J(),r={done:!1,...e,name:e.name.trim(),id:o,createdAt:a,updatedAt:a};return H([...W,r]),n.create({...e,name:e.name.trim()}).then(t=>H(W.map(e=>e.id===o?{...r,...t}:e))).catch(()=>H(W.filter(t=>t.id!==o))),o},[t]),c=o((e,n)=>{const o=L;if(!o)return t.updateTask(e,n);H(W.map(t=>t.id===e?{...t,...n,id:e,updatedAt:J()}:t)),o.update(e,n).catch(()=>{K()})},[t]),l=o(e=>{const n=L;if(!n)return t.removeTask(e);const o=W;H(W.filter(t=>t.id!==e)),n.remove(e).catch(()=>H(o))},[t]),s=o(e=>{if(!L)return t.toggleDone(e);const n=W.find(t=>t.id===e);n&&c(e,{done:!n.done})},[t,c]),u=o(e=>{L||t.setAllTasks(e)},[t]);return null===L?t:{tasks:r,addTask:i,updateTask:c,removeTask:l,toggleDone:s,setAllTasks:u}}function tt(t,e){try{if(localStorage.getItem(j))return;const n=localStorage.getItem(V);if(!n)return void localStorage.setItem(j,"1");const o=JSON.parse(n);if(!Array.isArray(o)||0===o.length)return localStorage.removeItem(V),void localStorage.setItem(j,"1");const a=J(),r=o.filter(t=>"string"==typeof t?.name).map(t=>({id:t.id||E(),name:String(t.name),done:!!t.done,estimated:"number"==typeof t.estimated?t.estimated:void 0,completed:"number"==typeof t.completed?t.completed:void 0,createdAt:a,updatedAt:a})),i=new Set(t.map(t=>t.id));e([...r.filter(t=>!i.has(t.id)),...t]),localStorage.removeItem(V),localStorage.setItem(j,"1")}catch{try{localStorage.setItem(j,"1")}catch{}}}export{r as ALARM_OPTIONS,i as FOCUS_SOUND_OPTIONS,M as getPomoSnapshot,tt as migratePomodoroTasksOnce,C as playAlarm,x as pomoPause,I as pomoStart,B as pomoSwitchMode,G as previewFocusSound,y as setPomoAlarm,v as setPomoAlarmConfig,A as setPomoBehaviour,b as setPomoDurations,T as setPomoFocusSound,Q as setShellTodoProvider,S as subscribePomo,Z as useTodoTasks};
@@ -1,54 +1,54 @@
1
- import{toast_default as e}from"./chunk-VBQOHZEM.js";import{forwardRef as t,useRef as r,useState as n,useMemo as o,useEffect as i,useImperativeHandle as a}from"react";import{jsx as l,jsxs as s,Fragment as c}from"react/jsx-runtime";var d=["#ef4444","#f97316","#eab308","#22c55e","#3b82f6","#8b5cf6","#000000","#ffffff"],h=[{id:"system",label:"System",css:"-apple-system, system-ui, sans-serif"},{id:"serif",label:"Serif",css:'Georgia, "Times New Roman", serif'},{id:"mono",label:"Mono",css:'ui-monospace, "SF Mono", Menlo, monospace'},{id:"cursive",label:"Cursive",css:'"Brush Script MT", "Comic Sans MS", cursive'}],u=()=>Math.random().toString(36).slice(2,9),p=t(function({src:t,filename:p,onApply:x,onCancel:m},M){const N=r(null),L=r(null),D=r(null),z=r(null),[E,P]=n("select"),[$,I]=n(d[0]),[W,B]=n(4),[S,R]=n(24),[j,A]=n(h[0].id),[T,F]=n(!0),[H,U]=n(!1),[O,Z]=n(!1),[K,V]=n(null),[X,q]=n(null),[G,Y]=n(6),[_,Q]=n(12),[J,ee]=n([]),[te,re]=n(null),[ne,oe]=n(null),[ie,ae]=n(null),[le,se]=n(1),[ce,de]=n(null),[he,ue]=n(null),[pe,ye]=n(null),xe=r(null),[me,ge]=n(!1),we=o(()=>ie?{w:ie.w*le,h:ie.h*le}:null,[ie,le]),fe=we&&ne?we.w/ne.w:1,be=o(()=>J.find(e=>e.id===te)??null,[J,te]);i(()=>{"select"===E&&be&&("color"in be&&I(be.color),"stroke"in be&&B(be.stroke),"rect"===be.type&&Q(be.radius),"text"===be.type&&(R(be.size),A(be.font),F(be.bold),U(be.italic),Z(be.underline),V(be.borderColor),q(be.background),Y(be.padding)))},[te]),i(()=>{const r=new Image;r.crossOrigin="anonymous",r.onload=()=>{z.current=r,oe({w:r.naturalWidth,h:r.naturalHeight}),ee([]),re(null)},r.onerror=()=>e.error("Failed to load image"),r.src=t},[t]),i(()=>{if(!ne)return;const e=()=>{const e=N.current;if(!e)return;const t=e.getBoundingClientRect(),r=Math.max(0,t.width-32),n=Math.max(0,t.height-32);if(0===r||0===n)return;const o=ne.w/ne.h;let i=ne.w,a=ne.h;i>r&&(i=r,a=i/o),a>n&&(a=n,i=a*o),ae({w:i,h:a})};e();const t=new ResizeObserver(e);return N.current&&t.observe(N.current),()=>t.disconnect()},[ne]);const ve=o(()=>J.filter(e=>"mosaic"===e.type),[J]);i(()=>{const e=z.current,t=L.current;if(!e||!t||!ne)return;t.width=ne.w,t.height=ne.h;const r=t.getContext("2d");r.drawImage(e,0,0);for(const e of ve)C(r,e)},[ne,ve,ie]);const ke=e=>{const t=D.current;if(!t)return{x:0,y:0};const r=t.createSVGPoint();r.x=e.clientX,r.y=e.clientY;const n=t.getScreenCTM();if(!n)return{x:0,y:0};const o=r.matrixTransform(n.inverse());return{x:o.x,y:o.y}},Me=e=>{xe.current=e,ge(!0)};i(()=>{if(!me)return;const e=e=>{const t=xe.current;if(!t)return;const r=ke(e);if("draw"===t.kind)de(f(E,t.start,r,$,W,_));else if("pen"===t.kind){const e=t.points[t.points.length-1];(Math.abs(r.x-e.x)>1||Math.abs(r.y-e.y)>1)&&(t.points.push(r),de({id:"",type:"draw",points:t.points.slice(),color:$,stroke:W}))}else if("crop"===t.kind)ye(k(t.start,r));else if("move"===t.kind){const e=r.x-t.start.x,n=r.y-t.start.y;ee(r=>r.map(r=>r.id===t.id?b(t.original,e,n):r))}else"resize"===t.kind&&ee(e=>e.map(e=>e.id===t.id?function(e,t,r){if("arrow"===e.type)return"start"===t?{...e,x1:r.x,y1:r.y}:"end"===t?{...e,x2:r.x,y2:r.y}:e;if("text"===e.type||"draw"===e.type)return e;const n=e.x,o=e.x+e.w,i=e.y,a=e.y+e.h;let l=n,s=i,c=o,d=a;"nw"===t&&(l=r.x,s=r.y);"ne"===t&&(c=r.x,s=r.y);"se"===t&&(c=r.x,d=r.y);"sw"===t&&(l=r.x,d=r.y);const h=k({x:l,y:s},{x:c,y:d});return{...e,x:h.x,y:h.y,w:h.w,h:h.h}}(t.original,t.corner,r):e))},t=()=>{const e=xe.current;if(xe.current=null,ge(!1),"draw"===e?.kind)de(e=>{if(!e||("arrow"===(t=e).type?Math.abs(t.x2-t.x1)<4&&Math.abs(t.y2-t.y1)<4:"draw"===t.type?t.points.length<2:"w"in t&&"h"in t&&(t.w<4||t.h<4)))return null;var t;const r={...e,id:u()};return ee(e=>[...e,r]),re(r.id),P("select"),null});else if("pen"===e?.kind){if(e.points.length<2)return void de(null);const t={id:u(),type:"draw",points:e.points,color:$,stroke:W};ee(e=>[...e,t]),re(t.id),P("select"),de(null)}};return window.addEventListener("pointermove",e),window.addEventListener("pointerup",t),window.addEventListener("pointercancel",t),()=>{window.removeEventListener("pointermove",e),window.removeEventListener("pointerup",t),window.removeEventListener("pointercancel",t)}},[me,E,$,W,_]);i(()=>{const e=e=>{if(!document.activeElement||!/^(INPUT|TEXTAREA)$/.test(document.activeElement.tagName))return!e.metaKey&&!e.ctrlKey||"z"!==e.key&&"Z"!==e.key||e.shiftKey?void(te&&("Delete"===e.key||"Backspace"===e.key?(e.preventDefault(),ee(e=>e.filter(e=>e.id!==te)),re(null)):"Escape"===e.key&&re(null))):(e.preventDefault(),ee(e=>e.slice(0,-1)),void re(null))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[te]);const Ce=e=>{const t=!{bold:T,italic:H,underline:O}[e];"bold"===e&&F(t),"italic"===e&&U(t),"underline"===e&&Z(t),te&&ee(r=>r.map(r=>r.id===te&&"text"===r.type?{...r,[e]:t}:r))},Ne=e=>{V(e),te&&ee(t=>t.map(t=>t.id===te&&"text"===t.type?{...t,borderColor:e}:t))},Le=e=>{q(e),te&&ee(t=>t.map(t=>t.id===te&&"text"===t.type?{...t,background:e}:t))},De=e=>{if(!he)return;const t=e??he.value;if(!t.trim())return he.editingId&&ee(e=>e.filter(e=>e.id!==he.editingId)),void ue(null);if(he.editingId)ee(e=>e.map(e=>e.id===he.editingId&&"text"===e.type?{...e,text:t}:e));else{const e={id:u(),type:"text",x:he.x,y:he.y,text:t,color:$,size:S,font:j,bold:T,italic:H,underline:O,borderColor:K,background:X,padding:G};ee(t=>[...t,e]),re(e.id),P("select")}ue(null)},ze=async()=>{const e=L.current,t=D.current;if(!e||!t||!ne)return null;const r=document.createElement("canvas");r.width=ne.w,r.height=ne.h;const n=r.getContext("2d");n.drawImage(e,0,0);const o=t.cloneNode(!0);o.querySelectorAll("[data-chrome]").forEach(e=>e.remove());const i=(new XMLSerializer).serializeToString(o),a=new Blob([i],{type:"image/svg+xml;charset=utf-8"}),l=URL.createObjectURL(a),s=new Image;return await new Promise(e=>{s.onload=()=>e(),s.onerror=()=>e(),s.src=l}),n.drawImage(s,0,0,ne.w,ne.h),URL.revokeObjectURL(l),r};a(M,()=>({save:async()=>{const t=await ze();t&&t.toBlob(t=>{if(!t)return void e.error("Failed to export");const r=URL.createObjectURL(t),n=document.createElement("a");n.href=r;const o=p.replace(/\.[^.]+$/,"");n.download=`${o}-annotated.png`,n.click(),URL.revokeObjectURL(r)},"image/png")},copy:async()=>{if(!("clipboard"in navigator)||"undefined"==typeof ClipboardItem)return void e.error("Clipboard images not supported in this browser");const t=await ze();t&&t.toBlob(async t=>{if(t)try{await navigator.clipboard.write([new ClipboardItem({"image/png":t})]),e.success("Copied to clipboard")}catch{e.error("Copy failed (clipboard permission?)")}else e.error("Failed to copy")},"image/png")}}),[ne,p]);const Ee=o(()=>[{id:"select",label:"Select / Move",icon:/* @__PURE__ */l("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */l("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 3l7 17 2-7 7-2L5 3z"})})},{id:"draw",label:"Pen / Draw",icon:/* @__PURE__ */l("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */l("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M16.862 4.487l1.687-1.688a1.875 1.875 0 112.652 2.652L6.832 19.82a4.5 4.5 0 01-1.897 1.13l-2.685.8.8-2.685a4.5 4.5 0 011.13-1.897L16.863 4.487z"})})},{id:"rect",label:"Rectangle",icon:/* @__PURE__ */l("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */l("rect",{x:"4",y:"6",width:"16",height:"12",rx:"3"})})},{id:"circle",label:"Ellipse",icon:/* @__PURE__ */l("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */l("ellipse",{cx:"12",cy:"12",rx:"8",ry:"6"})})},{id:"arrow",label:"Arrow",icon:/* @__PURE__ */l("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */l("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 19L19 5m0 0h-7m7 0v7"})})},{id:"mosaic",label:"Mosaic",icon:/* @__PURE__ */l("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */l("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 4h6v6H4zM14 4h6v6h-6zM4 14h6v6H4zM14 14h6v6h-6z"})})},{id:"text",label:"Text",icon:/* @__PURE__ */l("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */l("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 6h16M12 6v14M9 20h6"})})},{id:"crop",label:"Crop",icon:/* @__PURE__ */l("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */l("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 2v15a1 1 0 001 1h15M2 6h15a1 1 0 011 1v15"})})}],[]),Pe=e=>"p-1.5 rounded transition-colors "+(e?"bg-blue-500 text-white":"text-gray-700 hover:bg-gray-200"),$e=be?.type??("select"===E?null:E),Ie="rect"===$e||"circle"===$e||"arrow"===$e||"draw"===$e,We="rect"===$e,Be="text"===$e;/* @__PURE__ */
1
+ import{toast_default as e}from"./chunk-NLASNJNY.js";import{forwardRef as t,useRef as r,useState as n,useMemo as o,useEffect as i,useImperativeHandle as a}from"react";import{jsx as l,jsxs as s,Fragment as c}from"react/jsx-runtime";var d=["#ef4444","#f97316","#eab308","#22c55e","#3b82f6","#8b5cf6","#000000","#ffffff"],h=[{id:"system",label:"System",css:"-apple-system, system-ui, sans-serif"},{id:"serif",label:"Serif",css:'Georgia, "Times New Roman", serif'},{id:"mono",label:"Mono",css:'ui-monospace, "SF Mono", Menlo, monospace'},{id:"cursive",label:"Cursive",css:'"Brush Script MT", "Comic Sans MS", cursive'}],u=()=>Math.random().toString(36).slice(2,9),p=t(function({src:t,filename:p,onApply:x,onCancel:m},M){const C=r(null),L=r(null),D=r(null),z=r(null),[P,E]=n("select"),[$,I]=n(d[0]),[W,S]=n(4),[B,R]=n(24),[A,j]=n(h[0].id),[T,F]=n(!0),[U,H]=n(!1),[O,Z]=n(!1),[K,V]=n(null),[X,Y]=n(null),[q,G]=n(6),[_,J]=n(12),[Q,ee]=n([]),[te,re]=n(null),[ne,oe]=n(null),[ie,ae]=n(null),[le,se]=n(1),[ce,de]=n(null),[he,ue]=n(null),[pe,ye]=n(null),xe=r(null),[me,ge]=n(!1),we=o(()=>ie?{w:ie.w*le,h:ie.h*le}:null,[ie,le]),fe=we&&ne?we.w/ne.w:1,be=o(()=>Q.find(e=>e.id===te)??null,[Q,te]);i(()=>{"select"===P&&be&&("color"in be&&I(be.color),"stroke"in be&&S(be.stroke),"rect"===be.type&&J(be.radius),"text"===be.type&&(R(be.size),j(be.font),F(be.bold),H(be.italic),Z(be.underline),V(be.borderColor),Y(be.background),G(be.padding)))},[te]),i(()=>{const r=new Image;r.crossOrigin="anonymous",r.onload=()=>{z.current=r,oe({w:r.naturalWidth,h:r.naturalHeight}),ee([]),re(null)},r.onerror=()=>e.error("Failed to load image"),r.src=t},[t]),i(()=>{if(!ne)return;const e=()=>{const e=C.current;if(!e)return;const t=e.getBoundingClientRect(),r=Math.max(0,t.width-32),n=Math.max(0,t.height-32);if(0===r||0===n)return;const o=ne.w/ne.h;let i=ne.w,a=ne.h;i>r&&(i=r,a=i/o),a>n&&(a=n,i=a*o),ae({w:i,h:a})};e();const t=new ResizeObserver(e);return C.current&&t.observe(C.current),()=>t.disconnect()},[ne]);const ve=o(()=>Q.filter(e=>"mosaic"===e.type),[Q]);i(()=>{const e=z.current,t=L.current;if(!e||!t||!ne)return;t.width=ne.w,t.height=ne.h;const r=t.getContext("2d");r.drawImage(e,0,0);for(const e of ve)N(r,e)},[ne,ve,ie]);const ke=e=>{const t=D.current;if(!t)return{x:0,y:0};const r=t.createSVGPoint();r.x=e.clientX,r.y=e.clientY;const n=t.getScreenCTM();if(!n)return{x:0,y:0};const o=r.matrixTransform(n.inverse());return{x:o.x,y:o.y}},Me=e=>{xe.current=e,ge(!0)};i(()=>{if(!me)return;const e=e=>{const t=xe.current;if(!t)return;const r=ke(e);if("draw"===t.kind)de(f(P,t.start,r,$,W,_));else if("pen"===t.kind){const e=t.points[t.points.length-1];(Math.abs(r.x-e.x)>1||Math.abs(r.y-e.y)>1)&&(t.points.push(r),de({id:"",type:"draw",points:t.points.slice(),color:$,stroke:W}))}else if("crop"===t.kind)ye(k(t.start,r));else if("move"===t.kind){const e=r.x-t.start.x,n=r.y-t.start.y;ee(r=>r.map(r=>r.id===t.id?b(t.original,e,n):r))}else"resize"===t.kind&&ee(e=>e.map(e=>e.id===t.id?function(e,t,r){if("arrow"===e.type)return"start"===t?{...e,x1:r.x,y1:r.y}:"end"===t?{...e,x2:r.x,y2:r.y}:e;if("text"===e.type||"draw"===e.type)return e;const n=e.x,o=e.x+e.w,i=e.y,a=e.y+e.h;let l=n,s=i,c=o,d=a;"nw"===t&&(l=r.x,s=r.y);"ne"===t&&(c=r.x,s=r.y);"se"===t&&(c=r.x,d=r.y);"sw"===t&&(l=r.x,d=r.y);const h=k({x:l,y:s},{x:c,y:d});return{...e,x:h.x,y:h.y,w:h.w,h:h.h}}(t.original,t.corner,r):e))},t=()=>{const e=xe.current;if(xe.current=null,ge(!1),"draw"===e?.kind)de(e=>{if(!e||("arrow"===(t=e).type?Math.abs(t.x2-t.x1)<4&&Math.abs(t.y2-t.y1)<4:"draw"===t.type?t.points.length<2:"w"in t&&"h"in t&&(t.w<4||t.h<4)))return null;var t;const r={...e,id:u()};return ee(e=>[...e,r]),re(r.id),E("select"),null});else if("pen"===e?.kind){if(e.points.length<2)return void de(null);const t={id:u(),type:"draw",points:e.points,color:$,stroke:W};ee(e=>[...e,t]),re(t.id),E("select"),de(null)}};return window.addEventListener("pointermove",e),window.addEventListener("pointerup",t),window.addEventListener("pointercancel",t),()=>{window.removeEventListener("pointermove",e),window.removeEventListener("pointerup",t),window.removeEventListener("pointercancel",t)}},[me,P,$,W,_]);i(()=>{const e=e=>{if(!document.activeElement||!/^(INPUT|TEXTAREA)$/.test(document.activeElement.tagName))return!e.metaKey&&!e.ctrlKey||"z"!==e.key&&"Z"!==e.key||e.shiftKey?void(te&&("Delete"===e.key||"Backspace"===e.key?(e.preventDefault(),ee(e=>e.filter(e=>e.id!==te)),re(null)):"Escape"===e.key&&re(null))):(e.preventDefault(),ee(e=>e.slice(0,-1)),void re(null))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[te]);const Ne=e=>{const t=!{bold:T,italic:U,underline:O}[e];"bold"===e&&F(t),"italic"===e&&H(t),"underline"===e&&Z(t),te&&ee(r=>r.map(r=>r.id===te&&"text"===r.type?{...r,[e]:t}:r))},Ce=e=>{V(e),te&&ee(t=>t.map(t=>t.id===te&&"text"===t.type?{...t,borderColor:e}:t))},Le=e=>{Y(e),te&&ee(t=>t.map(t=>t.id===te&&"text"===t.type?{...t,background:e}:t))},De=e=>{if(!he)return;const t=e??he.value;if(!t.trim())return he.editingId&&ee(e=>e.filter(e=>e.id!==he.editingId)),void ue(null);if(he.editingId)ee(e=>e.map(e=>e.id===he.editingId&&"text"===e.type?{...e,text:t}:e));else{const e={id:u(),type:"text",x:he.x,y:he.y,text:t,color:$,size:B,font:A,bold:T,italic:U,underline:O,borderColor:K,background:X,padding:q};ee(t=>[...t,e]),re(e.id),E("select")}ue(null)},ze=async()=>{const e=L.current,t=D.current;if(!e||!t||!ne)return null;const r=document.createElement("canvas");r.width=ne.w,r.height=ne.h;const n=r.getContext("2d");n.drawImage(e,0,0);const o=t.cloneNode(!0);o.querySelectorAll("[data-chrome]").forEach(e=>e.remove());const i=(new XMLSerializer).serializeToString(o),a=new Blob([i],{type:"image/svg+xml;charset=utf-8"}),l=URL.createObjectURL(a),s=new Image;return await new Promise(e=>{s.onload=()=>e(),s.onerror=()=>e(),s.src=l}),n.drawImage(s,0,0,ne.w,ne.h),URL.revokeObjectURL(l),r};a(M,()=>({save:async()=>{const t=await ze();t&&t.toBlob(t=>{if(!t)return void e.error("Failed to export");const r=URL.createObjectURL(t),n=document.createElement("a");n.href=r;const o=p.replace(/\.[^.]+$/,"");n.download=`${o}-annotated.png`,n.click(),URL.revokeObjectURL(r)},"image/png")},copy:async()=>{if(!("clipboard"in navigator)||"undefined"==typeof ClipboardItem)return void e.error("Clipboard images not supported in this browser");const t=await ze();t&&t.toBlob(async t=>{if(t)try{await navigator.clipboard.write([new ClipboardItem({"image/png":t})]),e.success("Copied to clipboard")}catch{e.error("Copy failed (clipboard permission?)")}else e.error("Failed to copy")},"image/png")}}),[ne,p]);const Pe=o(()=>[{id:"select",label:"Select / Move",icon:/* @__PURE__ */l("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */l("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 3l7 17 2-7 7-2L5 3z"})})},{id:"draw",label:"Pen / Draw",icon:/* @__PURE__ */l("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */l("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M16.862 4.487l1.687-1.688a1.875 1.875 0 112.652 2.652L6.832 19.82a4.5 4.5 0 01-1.897 1.13l-2.685.8.8-2.685a4.5 4.5 0 011.13-1.897L16.863 4.487z"})})},{id:"rect",label:"Rectangle",icon:/* @__PURE__ */l("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */l("rect",{x:"4",y:"6",width:"16",height:"12",rx:"3"})})},{id:"circle",label:"Ellipse",icon:/* @__PURE__ */l("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */l("ellipse",{cx:"12",cy:"12",rx:"8",ry:"6"})})},{id:"arrow",label:"Arrow",icon:/* @__PURE__ */l("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */l("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 19L19 5m0 0h-7m7 0v7"})})},{id:"mosaic",label:"Mosaic",icon:/* @__PURE__ */l("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */l("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 4h6v6H4zM14 4h6v6h-6zM4 14h6v6H4zM14 14h6v6h-6z"})})},{id:"text",label:"Text",icon:/* @__PURE__ */l("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */l("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 6h16M12 6v14M9 20h6"})})},{id:"crop",label:"Crop",icon:/* @__PURE__ */l("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */l("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 2v15a1 1 0 001 1h15M2 6h15a1 1 0 011 1v15"})})}],[]),Ee=e=>"p-1.5 rounded transition-colors "+(e?"bg-blue-500 text-white":"text-gray-700 hover:bg-gray-200"),$e=be?.type??("select"===P?null:P),Ie="rect"===$e||"circle"===$e||"arrow"===$e||"draw"===$e,We="rect"===$e,Se="text"===$e;/* @__PURE__ */
2
2
  return s("div",{className:"flex flex-col h-full bg-gray-100",children:[
3
- /* @__PURE__ */s("div",{className:"flex items-center gap-1.5 px-3 py-2 border-b border-gray-200 bg-white shrink-0 flex-wrap text-[12px]",children:[Ee.map(e=>/* @__PURE__ */l("button",{onClick:()=>{P(e.id),re(null)},title:e.label,className:Pe(E===e.id),children:e.icon},e.id)),
3
+ /* @__PURE__ */s("div",{className:"flex items-center gap-1.5 px-3 py-2 border-b border-gray-200 bg-white shrink-0 flex-wrap text-[12px]",children:[Pe.map(e=>/* @__PURE__ */l("button",{onClick:()=>{E(e.id),re(null)},title:e.label,className:Ee(P===e.id),children:e.icon},e.id)),
4
4
  /* @__PURE__ */l("div",{className:"h-5 w-px bg-gray-300 mx-1"}),
5
5
  /* @__PURE__ */l("div",{className:"flex items-center gap-1",children:d.map(e=>/* @__PURE__ */l("button",{onClick:()=>(e=>{I(e),te&&ee(t=>t.map(t=>t.id!==te||"mosaic"===t.type?t:{...t,color:e}))})(e),title:e,className:"h-5 w-5 rounded-full border "+($===e?"ring-2 ring-blue-500 ring-offset-1":"border-gray-300"),style:{background:e}},e))}),Ie&&/* @__PURE__ */s(c,{children:[
6
6
  /* @__PURE__ */l("div",{className:"h-5 w-px bg-gray-300 mx-1"}),
7
7
  /* @__PURE__ */s("label",{className:"flex items-center gap-1.5 text-gray-600",children:[
8
8
  /* @__PURE__ */l("span",{children:"Weight"}),
9
- /* @__PURE__ */l("input",{type:"range",min:1,max:20,step:1,value:W,onChange:e=>{return t=Number(e.target.value),B(t),void(te&&ee(e=>e.map(e=>e.id!==te?e:"rect"===e.type||"circle"===e.type||"arrow"===e.type||"draw"===e.type?{...e,stroke:t}:e)));var t},className:"w-16 accent-blue-500"}),
9
+ /* @__PURE__ */l("input",{type:"range",min:1,max:20,step:1,value:W,onChange:e=>{return t=Number(e.target.value),S(t),void(te&&ee(e=>e.map(e=>e.id!==te?e:"rect"===e.type||"circle"===e.type||"arrow"===e.type||"draw"===e.type?{...e,stroke:t}:e)));var t},className:"w-16 accent-blue-500"}),
10
10
  /* @__PURE__ */l("span",{className:"tabular-nums w-5 text-right",children:W})]})]}),We&&/* @__PURE__ */s(c,{children:[
11
11
  /* @__PURE__ */l("div",{className:"h-5 w-px bg-gray-300 mx-1"}),
12
12
  /* @__PURE__ */s("label",{className:"flex items-center gap-1.5 text-gray-600",children:[
13
13
  /* @__PURE__ */l("span",{children:"Radius"}),
14
- /* @__PURE__ */l("input",{type:"range",min:0,max:48,step:1,value:_,onChange:e=>{return t=Number(e.target.value),Q(t),void(te&&ee(e=>e.map(e=>e.id===te&&"rect"===e.type?{...e,radius:t}:e)));var t},className:"w-16 accent-blue-500"}),
15
- /* @__PURE__ */l("span",{className:"tabular-nums w-6 text-right",children:_})]})]}),Be&&/* @__PURE__ */s(c,{children:[
14
+ /* @__PURE__ */l("input",{type:"range",min:0,max:48,step:1,value:_,onChange:e=>{return t=Number(e.target.value),J(t),void(te&&ee(e=>e.map(e=>e.id===te&&"rect"===e.type?{...e,radius:t}:e)));var t},className:"w-16 accent-blue-500"}),
15
+ /* @__PURE__ */l("span",{className:"tabular-nums w-6 text-right",children:_})]})]}),Se&&/* @__PURE__ */s(c,{children:[
16
16
  /* @__PURE__ */l("div",{className:"h-5 w-px bg-gray-300 mx-1"}),
17
- /* @__PURE__ */l("select",{value:j,onChange:e=>{return t=e.target.value,A(t),void(te&&ee(e=>e.map(e=>e.id===te&&"text"===e.type?{...e,font:t}:e)));var t},className:"text-xs border border-gray-300 rounded px-1 py-0.5 bg-white",children:h.map(e=>/* @__PURE__ */l("option",{value:e.id,children:e.label},e.id))}),
18
- /* @__PURE__ */l("button",{onClick:()=>Ce("bold"),className:Pe(T),title:"Bold",children:/* @__PURE__ */l("span",{className:"font-bold",children:"B"})}),
19
- /* @__PURE__ */l("button",{onClick:()=>Ce("italic"),className:Pe(H),title:"Italic",children:/* @__PURE__ */l("span",{className:"italic",children:"I"})}),
20
- /* @__PURE__ */l("button",{onClick:()=>Ce("underline"),className:Pe(O),title:"Underline",children:/* @__PURE__ */l("span",{className:"underline",children:"U"})}),
17
+ /* @__PURE__ */l("select",{value:A,onChange:e=>{return t=e.target.value,j(t),void(te&&ee(e=>e.map(e=>e.id===te&&"text"===e.type?{...e,font:t}:e)));var t},className:"text-xs border border-gray-300 rounded px-1 py-0.5 bg-white",children:h.map(e=>/* @__PURE__ */l("option",{value:e.id,children:e.label},e.id))}),
18
+ /* @__PURE__ */l("button",{onClick:()=>Ne("bold"),className:Ee(T),title:"Bold",children:/* @__PURE__ */l("span",{className:"font-bold",children:"B"})}),
19
+ /* @__PURE__ */l("button",{onClick:()=>Ne("italic"),className:Ee(U),title:"Italic",children:/* @__PURE__ */l("span",{className:"italic",children:"I"})}),
20
+ /* @__PURE__ */l("button",{onClick:()=>Ne("underline"),className:Ee(O),title:"Underline",children:/* @__PURE__ */l("span",{className:"underline",children:"U"})}),
21
21
  /* @__PURE__ */s("label",{className:"flex items-center gap-1.5 text-gray-600",children:[
22
22
  /* @__PURE__ */l("span",{children:"Size"}),
23
- /* @__PURE__ */l("input",{type:"range",min:10,max:96,step:1,value:S,onChange:e=>{return t=Number(e.target.value),R(t),void(te&&ee(e=>e.map(e=>e.id===te&&"text"===e.type?{...e,size:t}:e)));var t},className:"w-16 accent-blue-500"}),
24
- /* @__PURE__ */l("span",{className:"tabular-nums w-7 text-right",children:S})]}),
23
+ /* @__PURE__ */l("input",{type:"range",min:10,max:96,step:1,value:B,onChange:e=>{return t=Number(e.target.value),R(t),void(te&&ee(e=>e.map(e=>e.id===te&&"text"===e.type?{...e,size:t}:e)));var t},className:"w-16 accent-blue-500"}),
24
+ /* @__PURE__ */l("span",{className:"tabular-nums w-7 text-right",children:B})]}),
25
25
  /* @__PURE__ */s("label",{className:"flex items-center gap-1 text-gray-600",children:[
26
26
  /* @__PURE__ */l("span",{children:"Border"}),K?/* @__PURE__ */s(c,{children:[
27
- /* @__PURE__ */l("input",{type:"color",value:K,onChange:e=>Ne(e.target.value),title:"Text-box border color",className:"h-5 w-6 rounded border border-gray-300 bg-white p-0 cursor-pointer"}),
28
- /* @__PURE__ */l("button",{onClick:()=>Ne(null),title:"Remove border",className:"px-0.5 text-gray-400 hover:text-gray-700",children:"✕"})]}):/* @__PURE__ */l("button",{onClick:()=>Ne($),title:"Add a border",className:"px-1.5 py-0.5 rounded border border-gray-300 text-gray-600 hover:bg-gray-100",children:"Add"})]}),
27
+ /* @__PURE__ */l("input",{type:"color",value:K,onChange:e=>Ce(e.target.value),title:"Text-box border color",className:"h-5 w-6 rounded border border-gray-300 bg-white p-0 cursor-pointer"}),
28
+ /* @__PURE__ */l("button",{onClick:()=>Ce(null),title:"Remove border",className:"px-0.5 text-gray-400 hover:text-gray-700",children:"✕"})]}):/* @__PURE__ */l("button",{onClick:()=>Ce($),title:"Add a border",className:"px-1.5 py-0.5 rounded border border-gray-300 text-gray-600 hover:bg-gray-100",children:"Add"})]}),
29
29
  /* @__PURE__ */s("label",{className:"flex items-center gap-1 text-gray-600",children:[
30
30
  /* @__PURE__ */l("span",{children:"Fill"}),X?/* @__PURE__ */s(c,{children:[
31
31
  /* @__PURE__ */l("input",{type:"color",value:X,onChange:e=>Le(e.target.value),title:"Text-box background color",className:"h-5 w-6 rounded border border-gray-300 bg-white p-0 cursor-pointer"}),
32
32
  /* @__PURE__ */l("button",{onClick:()=>Le(null),title:"Remove fill",className:"px-0.5 text-gray-400 hover:text-gray-700",children:"✕"})]}):/* @__PURE__ */l("button",{onClick:()=>Le("#ffffff"),title:"Add a background fill",className:"px-1.5 py-0.5 rounded border border-gray-300 text-gray-600 hover:bg-gray-100",children:"Add"})]}),
33
33
  /* @__PURE__ */s("label",{className:"flex items-center gap-1.5 text-gray-600",children:[
34
34
  /* @__PURE__ */l("span",{children:"Pad"}),
35
- /* @__PURE__ */l("input",{type:"range",min:0,max:40,step:1,value:G,onChange:e=>{return t=Number(e.target.value),Y(t),void(te&&ee(e=>e.map(e=>e.id===te&&"text"===e.type?{...e,padding:t}:e)));var t},className:"w-14 accent-blue-500"}),
36
- /* @__PURE__ */l("span",{className:"tabular-nums w-6 text-right",children:G})]})]}),
35
+ /* @__PURE__ */l("input",{type:"range",min:0,max:40,step:1,value:q,onChange:e=>{return t=Number(e.target.value),G(t),void(te&&ee(e=>e.map(e=>e.id===te&&"text"===e.type?{...e,padding:t}:e)));var t},className:"w-14 accent-blue-500"}),
36
+ /* @__PURE__ */l("span",{className:"tabular-nums w-6 text-right",children:q})]})]}),
37
37
  /* @__PURE__ */l("div",{className:"h-5 w-px bg-gray-300 mx-1"}),
38
38
  /* @__PURE__ */l("button",{onClick:()=>se(e=>Math.max(.25,Math.round(100*(e-.25))/100)),className:"px-2 py-1 rounded hover:bg-gray-200 text-gray-700",title:"Zoom out",children:"−"}),
39
39
  /* @__PURE__ */s("span",{className:"text-gray-600 tabular-nums w-10 text-center",children:[Math.round(100*le),"%"]}),
40
40
  /* @__PURE__ */l("button",{onClick:()=>se(e=>Math.min(4,Math.round(100*(e+.25))/100)),className:"px-2 py-1 rounded hover:bg-gray-200 text-gray-700",title:"Zoom in",children:"+"}),
41
41
  /* @__PURE__ */l("button",{onClick:()=>se(1),className:"px-2 py-1 rounded hover:bg-gray-200 text-gray-700",title:"Fit to area",children:"Fit"}),
42
42
  /* @__PURE__ */l("div",{className:"h-5 w-px bg-gray-300 mx-1"}),
43
- /* @__PURE__ */l("button",{onClick:()=>{ee(e=>e.slice(0,-1)),re(null)},disabled:0===J.length,className:"px-2 py-1 rounded hover:bg-gray-200 disabled:opacity-30 text-gray-700",children:"Undo"}),
43
+ /* @__PURE__ */l("button",{onClick:()=>{ee(e=>e.slice(0,-1)),re(null)},disabled:0===Q.length,className:"px-2 py-1 rounded hover:bg-gray-200 disabled:opacity-30 text-gray-700",children:"Undo"}),
44
44
  /* @__PURE__ */s("div",{className:"ml-auto flex items-center gap-2",children:[pe&&/* @__PURE__ */s(c,{children:[
45
- /* @__PURE__ */l("button",{onClick:()=>{if(!pe||!z.current||!ne)return;const e=pe,t=document.createElement("canvas");t.width=Math.round(e.w),t.height=Math.round(e.h);const r=t.getContext("2d"),n=document.createElement("canvas");n.width=ne.w,n.height=ne.h;const o=n.getContext("2d");o.drawImage(z.current,0,0);for(const e of ve)C(o,e);r.drawImage(n,e.x,e.y,e.w,e.h,0,0,e.w,e.h);const i=new Image;i.onload=()=>{z.current=i,oe({w:i.naturalWidth,h:i.naturalHeight}),ee(t=>t.filter(e=>"mosaic"!==e.type).map(t=>b(t,-e.x,-e.y)).filter(e=>function(e,t,r){const n=v(e);return n.x+n.w>0&&n.y+n.h>0&&n.x<t&&n.y<r}(e,i.naturalWidth,i.naturalHeight))),ye(null)},i.src=t.toDataURL("image/png")},className:"px-2 py-1 rounded bg-blue-500 text-white hover:bg-blue-600",children:"Apply Crop"}),
45
+ /* @__PURE__ */l("button",{onClick:()=>{if(!pe||!z.current||!ne)return;const e=pe,t=document.createElement("canvas");t.width=Math.round(e.w),t.height=Math.round(e.h);const r=t.getContext("2d"),n=document.createElement("canvas");n.width=ne.w,n.height=ne.h;const o=n.getContext("2d");o.drawImage(z.current,0,0);for(const e of ve)N(o,e);r.drawImage(n,e.x,e.y,e.w,e.h,0,0,e.w,e.h);const i=new Image;i.onload=()=>{z.current=i,oe({w:i.naturalWidth,h:i.naturalHeight}),ee(t=>t.filter(e=>"mosaic"!==e.type).map(t=>b(t,-e.x,-e.y)).filter(e=>function(e,t,r){const n=v(e);return n.x+n.w>0&&n.y+n.h>0&&n.x<t&&n.y<r}(e,i.naturalWidth,i.naturalHeight))),ye(null)},i.src=t.toDataURL("image/png")},className:"px-2 py-1 rounded bg-blue-500 text-white hover:bg-blue-600",children:"Apply Crop"}),
46
46
  /* @__PURE__ */l("button",{onClick:()=>ye(null),className:"px-2 py-1 rounded hover:bg-gray-200 text-gray-700",children:"Cancel"})]}),x&&!pe&&/* @__PURE__ */s(c,{children:[m&&/* @__PURE__ */l("button",{onClick:m,className:"px-3 py-1 rounded hover:bg-gray-200 text-gray-700 text-xs font-medium",children:"Cancel"}),
47
47
  /* @__PURE__ */l("button",{onClick:async()=>{const t=await ze();t?t.toBlob(t=>{t?x(t):e.error("Failed to export")},"image/png"):e.error("Failed to export")},className:"px-3 py-1 rounded bg-blue-500 text-white hover:bg-blue-600 text-xs font-medium",children:"Apply"})]})]})]}),
48
- /* @__PURE__ */l("div",{ref:N,className:"flex-1 overflow-auto bg-gray-200 flex items-center justify-center p-4 relative",children:we&&ne&&/* @__PURE__ */s("div",{className:"relative shadow-lg rounded overflow-hidden bg-white shrink-0",style:{width:we.w,height:we.h},children:[
48
+ /* @__PURE__ */l("div",{ref:C,className:"flex-1 overflow-auto bg-gray-200 flex items-center justify-center p-4 relative",children:we&&ne&&/* @__PURE__ */s("div",{className:"relative shadow-lg rounded overflow-hidden bg-white shrink-0",style:{width:we.w,height:we.h},children:[
49
49
  /* @__PURE__ */l("canvas",{ref:L,style:{position:"absolute",inset:0,width:"100%",height:"100%",display:"block"}}),
50
- /* @__PURE__ */s("svg",{ref:D,viewBox:`0 0 ${ne.w} ${ne.h}`,preserveAspectRatio:"none",style:{position:"absolute",inset:0,width:"100%",height:"100%",touchAction:"none",cursor:"select"===E?"default":"text"===E?"text":"crosshair"},onPointerDown:e=>{if("select"===E)return void re(null);if("text"===E){if(he)return void De();const t=ke(e);return void ue({x:t.x,y:t.y,value:""})}const t=ke(e);if("crop"!==E){if("draw"===E)return Me({kind:"pen",points:[t]}),void de({id:"",type:"draw",points:[t],color:$,stroke:W});de(f(E,t,t,$,W,_)),Me({kind:"draw",start:t})}else Me({kind:"crop",start:t})},children:[J.map(e=>/* @__PURE__ */l(y,{anno:e,selected:te===e.id,zoom:le,onPointerDown:t=>((e,t)=>{"select"===E&&(e.stopPropagation(),re(t.id),Me({kind:"move",id:t.id,start:ke(e),original:t}))})(t,e),onDoubleClick:()=>{var t;"text"===(t=e).type&&ue({x:t.x,y:t.y,value:t.text,editingId:t.id})},onHandlePointerDown:(t,r)=>((e,t,r)=>{e.stopPropagation(),Me({kind:"resize",id:t.id,corner:r,start:ke(e),original:t})})(t,e,r)},e.id)),ce&&/* @__PURE__ */l(y,{anno:{...ce,id:"__preview"},preview:!0}),pe&&/* @__PURE__ */l(g,{rect:pe,imageSize:ne})]}),he&&/* @__PURE__ */l(w,{pendingText:he,color:$,size:S,font:h.find(e=>e.id===j)?.css??h[0].css,bold:T,italic:H,underline:O,borderColor:K,background:X,padding:G,scale:fe,onChange:e=>ue({...he,value:e}),onCommit:De,onCancel:()=>ue(null)})]})}),
51
- /* @__PURE__ */l("div",{className:"px-3 py-1.5 border-t border-gray-200 bg-white text-[11px] text-gray-500 shrink-0",children:"select"===E?te?"Drag to move. Drag a corner to resize. Delete / Backspace removes. Click outside to deselect.":"Tap a shape to select. Double-click text to edit.":"text"===E?"Click to drop a text label.":"crop"===E?"Drag a rectangle to set the crop region.":"draw"===E?"Drag to draw freehand.":"Drag on the image to draw."})]})});function y({anno:e,selected:t,preview:r,zoom:n=1,onPointerDown:o,onDoubleClick:i,onHandlePointerDown:a}){const d=v(e),u=o?{onPointerDown:o,pointerEvents:"all",style:{cursor:"move"}}:{},p=i?{onDoubleClick:i}:{};let y;if("rect"===e.type)y=/* @__PURE__ */l("rect",{x:e.x,y:e.y,width:e.w,height:e.h,rx:e.radius,ry:e.radius,fill:"none",stroke:e.color,strokeWidth:e.stroke,strokeLinecap:"round",strokeLinejoin:"round",...u});else if("circle"===e.type)y=/* @__PURE__ */l("ellipse",{cx:e.x+e.w/2,cy:e.y+e.h/2,rx:e.w/2,ry:e.h/2,fill:"none",stroke:e.color,strokeWidth:e.stroke,...u});else if("arrow"===e.type)y=/* @__PURE__ */l(m,{anno:e,interactive:u});else if("draw"===e.type)y=/* @__PURE__ */l("path",{d:M(e.points),fill:"none",stroke:e.color,strokeWidth:e.stroke,strokeLinecap:"round",strokeLinejoin:"round",...u});else if("mosaic"===e.type)y=/* @__PURE__ */l("rect",{x:e.x,y:e.y,width:e.w,height:e.h,fill:"rgba(0,0,0,0.001)",stroke:t?"#3b82f6":"none",strokeWidth:t?2:0,strokeDasharray:t?"6,4":void 0,...u});else{const t=h.find(t=>t.id===e.font)?.css??h[0].css,r=e.padding??0,n=!!e.borderColor||!!e.background,o=v(e),i=e.borderColor?Math.max(1,Math.round(e.size/12)):0;y=/* @__PURE__ */s("g",{...u,...p,children:[n&&/* @__PURE__ */l("rect",{x:o.x-r,y:o.y-r,width:Math.max(0,o.w)+2*r,height:Math.max(0,o.h)+2*r,rx:Math.min(8,r),ry:Math.min(8,r),fill:e.background??"none",stroke:e.borderColor??"none",strokeWidth:i}),
50
+ /* @__PURE__ */s("svg",{ref:D,viewBox:`0 0 ${ne.w} ${ne.h}`,preserveAspectRatio:"none",style:{position:"absolute",inset:0,width:"100%",height:"100%",touchAction:"none",cursor:"select"===P?"default":"text"===P?"text":"crosshair"},onPointerDown:e=>{if("select"===P)return void re(null);if("text"===P){if(he)return void De();const t=ke(e);return void ue({x:t.x,y:t.y,value:""})}const t=ke(e);if("crop"!==P){if("draw"===P)return Me({kind:"pen",points:[t]}),void de({id:"",type:"draw",points:[t],color:$,stroke:W});de(f(P,t,t,$,W,_)),Me({kind:"draw",start:t})}else Me({kind:"crop",start:t})},children:[Q.map(e=>/* @__PURE__ */l(y,{anno:e,selected:te===e.id,zoom:le,onPointerDown:t=>((e,t)=>{"select"===P&&(e.stopPropagation(),re(t.id),Me({kind:"move",id:t.id,start:ke(e),original:t}))})(t,e),onDoubleClick:()=>{var t;"text"===(t=e).type&&ue({x:t.x,y:t.y,value:t.text,editingId:t.id})},onHandlePointerDown:(t,r)=>((e,t,r)=>{e.stopPropagation(),Me({kind:"resize",id:t.id,corner:r,start:ke(e),original:t})})(t,e,r)},e.id)),ce&&/* @__PURE__ */l(y,{anno:{...ce,id:"__preview"},preview:!0}),pe&&/* @__PURE__ */l(g,{rect:pe,imageSize:ne})]}),he&&/* @__PURE__ */l(w,{pendingText:he,color:$,size:B,font:h.find(e=>e.id===A)?.css??h[0].css,bold:T,italic:U,underline:O,borderColor:K,background:X,padding:q,scale:fe,onChange:e=>ue({...he,value:e}),onCommit:De,onCancel:()=>ue(null)})]})}),
51
+ /* @__PURE__ */l("div",{className:"px-3 py-1.5 border-t border-gray-200 bg-white text-[11px] text-gray-500 shrink-0",children:"select"===P?te?"Drag to move. Drag a corner to resize. Delete / Backspace removes. Click outside to deselect.":"Tap a shape to select. Double-click text to edit.":"text"===P?"Click to drop a text label.":"crop"===P?"Drag a rectangle to set the crop region.":"draw"===P?"Drag to draw freehand.":"Drag on the image to draw."})]})});function y({anno:e,selected:t,preview:r,zoom:n=1,onPointerDown:o,onDoubleClick:i,onHandlePointerDown:a}){const d=v(e),u=o?{onPointerDown:o,pointerEvents:"all",style:{cursor:"move"}}:{},p=i?{onDoubleClick:i}:{};let y;if("rect"===e.type)y=/* @__PURE__ */l("rect",{x:e.x,y:e.y,width:e.w,height:e.h,rx:e.radius,ry:e.radius,fill:"none",stroke:e.color,strokeWidth:e.stroke,strokeLinecap:"round",strokeLinejoin:"round",...u});else if("circle"===e.type)y=/* @__PURE__ */l("ellipse",{cx:e.x+e.w/2,cy:e.y+e.h/2,rx:e.w/2,ry:e.h/2,fill:"none",stroke:e.color,strokeWidth:e.stroke,...u});else if("arrow"===e.type)y=/* @__PURE__ */l(m,{anno:e,interactive:u});else if("draw"===e.type)y=/* @__PURE__ */l("path",{d:M(e.points),fill:"none",stroke:e.color,strokeWidth:e.stroke,strokeLinecap:"round",strokeLinejoin:"round",...u});else if("mosaic"===e.type)y=/* @__PURE__ */l("rect",{x:e.x,y:e.y,width:e.w,height:e.h,fill:"rgba(0,0,0,0.001)",stroke:t?"#3b82f6":"none",strokeWidth:t?2:0,strokeDasharray:t?"6,4":void 0,...u});else{const t=h.find(t=>t.id===e.font)?.css??h[0].css,r=e.padding??0,n=!!e.borderColor||!!e.background,o=v(e),i=e.borderColor?Math.max(1,Math.round(e.size/12)):0;y=/* @__PURE__ */s("g",{...u,...p,children:[n&&/* @__PURE__ */l("rect",{x:o.x-r,y:o.y-r,width:Math.max(0,o.w)+2*r,height:Math.max(0,o.h)+2*r,rx:Math.min(8,r),ry:Math.min(8,r),fill:e.background??"none",stroke:e.borderColor??"none",strokeWidth:i}),
52
52
  /* @__PURE__ */l("text",{x:e.x,y:e.y+e.size,fill:e.color,fontSize:e.size,fontWeight:e.bold?700:400,fontStyle:e.italic?"italic":"normal",textDecoration:e.underline?"underline":void 0,fontFamily:t,style:{userSelect:"none"},children:e.text.split("\n").map((t,r)=>/* @__PURE__ */l("tspan",{x:e.x,dy:0===r?0:1.2*e.size,children:t},r))})]})}/* @__PURE__ */
53
53
  return s("g",{children:[y,t&&!r&&/* @__PURE__ */s(c,{children:[
54
54
  /* @__PURE__ */l("rect",{"data-chrome":"selection",x:d.x-4,y:d.y-4,width:d.w+8,height:d.h+8,fill:"none",stroke:"#3b82f6",strokeWidth:2/n,strokeDasharray:`${6/n},${4/n}`,pointerEvents:"none"}),a&&/* @__PURE__ */l(x,{anno:e,zoom:n,onHandlePointerDown:a})]})]})}function x({anno:e,zoom:t,onHandlePointerDown:r}){const n=6/t,o=1.5/t,i=e=>({fill:"#fff",stroke:"#3b82f6",strokeWidth:o,pointerEvents:"all",style:{cursor:e},"data-chrome":"handle"});if("arrow"===e.type)/* @__PURE__ */
@@ -66,4 +66,4 @@ return s("g",{...t,children:[
66
66
  return s("g",{pointerEvents:"none",children:[
67
67
  /* @__PURE__ */l("path",{d:`M0,0 H${t.w} V${t.h} H0 Z M${e.x},${e.y} V${e.y+e.h} H${e.x+e.w} V${e.y} Z`,fill:"rgba(0,0,0,0.45)",fillRule:"evenodd"}),
68
68
  /* @__PURE__ */l("rect",{x:e.x,y:e.y,width:e.w,height:e.h,fill:"none",stroke:"#fff",strokeWidth:2,strokeDasharray:"8,6"})]})}function w({pendingText:e,color:t,size:n,font:o,bold:a,italic:s,underline:c,borderColor:d,background:h,padding:u,scale:p,onChange:y,onCommit:x,onCancel:m}){const g=r(null);i(()=>{const e=requestAnimationFrame(()=>{g.current?.focus(),g.current?.select?.()});return()=>cancelAnimationFrame(e)},[]);const w=()=>x(g.current?.value),f=d?Math.max(1,Math.round(n/12)):0;/* @__PURE__ */
69
- return l("div",{style:{position:"absolute",left:e.x*p+"px",top:e.y*p+"px",transform:"translateY(-2px)",zIndex:5},onPointerDown:e=>e.stopPropagation(),children:/* @__PURE__ */l("textarea",{ref:g,value:e.value,onChange:e=>y(e.target.value),onBlur:w,onKeyDown:e=>{"Escape"===e.key?(e.preventDefault(),m()):"Enter"!==e.key||e.shiftKey||(e.preventDefault(),w())},placeholder:"Type then Enter…",rows:1,className:"outline-none resize-none shadow-md",style:{color:t,fontSize:n*p+"px",fontFamily:o,fontWeight:a?700:400,fontStyle:s?"italic":"normal",textDecoration:c?"underline":void 0,minWidth:80,padding:u*p+"px",borderRadius:Math.min(8,u)*p+"px",border:d?`${f*p}px solid ${d}`:"1px dashed #60a5fa",background:h??"rgba(255,255,255,0.95)"}})})}function f(e,t,r,n,o,i){if("rect"===e){const e=k(t,r);return{id:"",type:"rect",x:e.x,y:e.y,w:e.w,h:e.h,color:n,stroke:o,radius:i}}if("circle"===e){const e=k(t,r);return{id:"",type:"circle",x:e.x,y:e.y,w:e.w,h:e.h,color:n,stroke:o}}if("arrow"===e)return{id:"",type:"arrow",x1:t.x,y1:t.y,x2:r.x,y2:r.y,color:n,stroke:o};if("mosaic"===e){const e=k(t,r);return{id:"",type:"mosaic",x:e.x,y:e.y,w:e.w,h:e.h}}return null}function b(e,t,r){return"arrow"===e.type?{...e,x1:e.x1+t,y1:e.y1+r,x2:e.x2+t,y2:e.y2+r}:"draw"===e.type?{...e,points:e.points.map(e=>({x:e.x+t,y:e.y+r}))}:(e.type,{...e,x:e.x+t,y:e.y+r})}function v(e){if("arrow"===e.type){return{x:Math.min(e.x1,e.x2),y:Math.min(e.y1,e.y2),w:Math.abs(e.x2-e.x1),h:Math.abs(e.y2-e.y1)}}if("draw"===e.type){if(0===e.points.length)return{x:0,y:0,w:0,h:0};let t=e.points[0].x,r=e.points[0].x,n=e.points[0].y,o=e.points[0].y;for(const i of e.points)i.x<t&&(t=i.x),i.x>r&&(r=i.x),i.y<n&&(n=i.y),i.y>o&&(o=i.y);return{x:t,y:n,w:r-t,h:o-n}}if("text"===e.type){const t=e.text.split("\n"),r=t.reduce((e,t)=>Math.max(e,t.length),0);return{x:e.x,y:e.y,w:r*e.size*.55,h:t.length*e.size*1.2}}return{x:e.x,y:e.y,w:e.w,h:e.h}}function k(e,t){return{x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),w:Math.abs(e.x-t.x),h:Math.abs(e.y-t.y)}}function M(e){if(0===e.length)return"";let t=`M ${e[0].x} ${e[0].y}`;for(let r=1;r<e.length;r++)t+=` L ${e[r].x} ${e[r].y}`;return t}function C(e,t){const r=Math.round(Math.max(0,t.x)),n=Math.round(Math.max(0,t.y)),o=Math.round(Math.min(e.canvas.width-r,t.w)),i=Math.round(Math.min(e.canvas.height-n,t.h));if(o<2||i<2)return;const a=e.getImageData(r,n,o,i);for(let e=0;e<i;e+=12)for(let t=0;t<o;t+=12){let r=0,n=0,l=0,s=0,c=0;const d=Math.min(12,o-t),h=Math.min(12,i-e);for(let i=0;i<h;i++)for(let h=0;h<d;h++){const d=4*((e+i)*o+(t+h));r+=a.data[d],n+=a.data[d+1],l+=a.data[d+2],s+=a.data[d+3],c++}r=Math.round(r/c),n=Math.round(n/c),l=Math.round(l/c),s=Math.round(s/c);for(let i=0;i<h;i++)for(let c=0;c<d;c++){const d=4*((e+i)*o+(t+c));a.data[d]=r,a.data[d+1]=n,a.data[d+2]=l,a.data[d+3]=s}}e.putImageData(a,r,n)}export{p as ImageAnnotator_default};
69
+ return l("div",{style:{position:"absolute",left:e.x*p+"px",top:e.y*p+"px",transform:"translateY(-2px)",zIndex:5},onPointerDown:e=>e.stopPropagation(),children:/* @__PURE__ */l("textarea",{ref:g,value:e.value,onChange:e=>y(e.target.value),onBlur:w,onKeyDown:e=>{"Escape"===e.key?(e.preventDefault(),m()):"Enter"!==e.key||e.shiftKey||(e.preventDefault(),w())},placeholder:"Type then Enter…",rows:1,className:"outline-none resize-none shadow-md",style:{color:t,fontSize:n*p+"px",fontFamily:o,fontWeight:a?700:400,fontStyle:s?"italic":"normal",textDecoration:c?"underline":void 0,minWidth:80,padding:u*p+"px",borderRadius:Math.min(8,u)*p+"px",border:d?`${f*p}px solid ${d}`:"1px dashed #60a5fa",background:h??"rgba(255,255,255,0.95)"}})})}function f(e,t,r,n,o,i){if("rect"===e){const e=k(t,r);return{id:"",type:"rect",x:e.x,y:e.y,w:e.w,h:e.h,color:n,stroke:o,radius:i}}if("circle"===e){const e=k(t,r);return{id:"",type:"circle",x:e.x,y:e.y,w:e.w,h:e.h,color:n,stroke:o}}if("arrow"===e)return{id:"",type:"arrow",x1:t.x,y1:t.y,x2:r.x,y2:r.y,color:n,stroke:o};if("mosaic"===e){const e=k(t,r);return{id:"",type:"mosaic",x:e.x,y:e.y,w:e.w,h:e.h}}return null}function b(e,t,r){return"arrow"===e.type?{...e,x1:e.x1+t,y1:e.y1+r,x2:e.x2+t,y2:e.y2+r}:"draw"===e.type?{...e,points:e.points.map(e=>({x:e.x+t,y:e.y+r}))}:(e.type,{...e,x:e.x+t,y:e.y+r})}function v(e){if("arrow"===e.type){return{x:Math.min(e.x1,e.x2),y:Math.min(e.y1,e.y2),w:Math.abs(e.x2-e.x1),h:Math.abs(e.y2-e.y1)}}if("draw"===e.type){if(0===e.points.length)return{x:0,y:0,w:0,h:0};let t=e.points[0].x,r=e.points[0].x,n=e.points[0].y,o=e.points[0].y;for(const i of e.points)i.x<t&&(t=i.x),i.x>r&&(r=i.x),i.y<n&&(n=i.y),i.y>o&&(o=i.y);return{x:t,y:n,w:r-t,h:o-n}}if("text"===e.type){const t=e.text.split("\n"),r=t.reduce((e,t)=>Math.max(e,t.length),0);return{x:e.x,y:e.y,w:r*e.size*.55,h:t.length*e.size*1.2}}return{x:e.x,y:e.y,w:e.w,h:e.h}}function k(e,t){return{x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),w:Math.abs(e.x-t.x),h:Math.abs(e.y-t.y)}}function M(e){if(0===e.length)return"";let t=`M ${e[0].x} ${e[0].y}`;for(let r=1;r<e.length;r++)t+=` L ${e[r].x} ${e[r].y}`;return t}function N(e,t){const r=Math.round(Math.max(0,t.x)),n=Math.round(Math.max(0,t.y)),o=Math.round(Math.min(e.canvas.width-r,t.w)),i=Math.round(Math.min(e.canvas.height-n,t.h));if(o<2||i<2)return;const a=e.getImageData(r,n,o,i);for(let e=0;e<i;e+=12)for(let t=0;t<o;t+=12){let r=0,n=0,l=0,s=0,c=0;const d=Math.min(12,o-t),h=Math.min(12,i-e);for(let i=0;i<h;i++)for(let h=0;h<d;h++){const d=4*((e+i)*o+(t+h));r+=a.data[d],n+=a.data[d+1],l+=a.data[d+2],s+=a.data[d+3],c++}r=Math.round(r/c),n=Math.round(n/c),l=Math.round(l/c),s=Math.round(s/c);for(let i=0;i<h;i++)for(let c=0;c<d;c++){const d=4*((e+i)*o+(t+c));a.data[d]=r,a.data[d+1]=n,a.data[d+2]=l,a.data[d+3]=s}}e.putImageData(a,r,n)}export{p as ImageAnnotator_default};
@@ -1,19 +1,19 @@
1
- import{escapeHtml as e}from"./chunk-BR22X7E5.js";import{useShellStrings as t}from"./chunk-RQ6BKTSJ.js";import{useBrowserLayoutEffect as n}from"./chunk-D65T4H6J.js";import{useRef as r,useState as o,useEffect as l,useCallback as c,useMemo as a}from"react";import{createPortal as s}from"react-dom";import{jsxs as i,jsx as u,Fragment as d}from"react/jsx-runtime";function h(e,t){const n=e[e.length-1];return n&&!n.some(e=>e.trim())?e:[...e,Array(t).fill("")]}function w({text:t,...n}){const r=a(()=>({__html:e(t)}),[t]);/* @__PURE__ */
2
- return u("div",{...n,dangerouslySetInnerHTML:r})}function g({columns:e,data:g,onChange:m,onColumnsChange:f,fixedRows:p=!1,minRows:y=15,maxHeight:b="260px",cellStyles:v,onFocusChange:x,onSelectionChange:M}){const D=r(null),k=t().grid,[C,E]=o(null);l(()=>{x?.(C)},[C,x]);const[S,L]=o({}),$=r(null),[N,A]=o({}),z=r(null),[T,O]=o(null),[R,K]=o(null),[P,F]=o(null),[I,X]=o(null),[H,Y]=o(null),j=r(null);n(()=>{const e=j.current;if(!e||e.row!==H?.row||e.col!==H?.col)return;j.current=null;const t=D.current?.querySelector(`[data-row="${e.row}"][data-col="${e.col}"]`);if(!t)return;t.focus();const n=document.createRange();n.selectNodeContents(t),n.collapse(!1);const r=window.getSelection();r?.removeAllRanges(),r?.addRange(n)},[H]);const[B,q]=o(null),[W,J]=o(null);l(()=>{M?.(B&&W?{anchor:B,end:W}:null)},[B,W,M]);const _=r(!1),[Q,U]=o(null),V=r(!1),G=r({a:null,e:null});G.current={a:B,e:W};const Z=B&&W&&(B.row!==W.row||B.col!==W.col),ee=[...g];if(!p)for(;ee.length<y;)ee.push(Array(e.length).fill(""));const te=c((t,n,r)=>{const o=ee.map(e=>[...e]);for(;o.length<=t;)o.push(Array(e.length).fill(""));for(;o[t].length<e.length;)o[t].push("");o[t][n]=r,m(o)},[ee,e.length,m]),ne=c((e,t,n)=>{if(0!==e.button)return;const r=document.activeElement;if(r?.dataset?.row&&r?.dataset?.col){const e=parseInt(r.dataset.row),t=parseInt(r.dataset.col),n=r.textContent||"";if(n!==(ee[e]?.[t]||"")){const r=ee.map(e=>[...e]);r[e]&&(r[e][t]=n,m(r))}}_.current=!0,e.shiftKey&&B||q({row:t,col:n}),J({row:t,col:n})},[ee,m,B]),re=c((e,t)=>{_.current&&J({row:e,col:t})},[]);l(()=>{const e=()=>{_.current=!1};return window.addEventListener("mouseup",e),()=>window.removeEventListener("mouseup",e)},[]),l(()=>{const e=e=>{if(!e.ctrlKey&&!e.metaKey||"c"!==e.key)return;if(!B||!W)return;const t=window.getSelection();if(t&&t.toString().length>0&&!Z)return;const n=Math.min(B.row,W.row),r=Math.max(B.row,W.row),o=Math.min(B.col,W.col),l=Math.max(B.col,W.col),c=[];for(let e=n;e<=r;e++){const t=[];for(let n=o;n<=l;n++)t.push(ee[e]?.[n]||"");c.push(t.join("\t"))}const a=c.join("\n");a&&(e.preventDefault(),navigator.clipboard.writeText(a))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[B,W,ee,Z]),l(()=>{const t=t=>{if(!C)return;const n=document.activeElement;if(n?.isContentEditable)return;if(!D.current?.contains(n))return;const r=t.clipboardData?.getData("text/plain");if(!r)return;t.preventDefault();const o=r.split("\n").filter(e=>e).map(e=>e.split("\t")),l=ee.map(e=>[...e]);for(let t=0;t<o.length;t++){const n=C.row+t;for(;l.length<=n;)l.push(Array(e.length).fill(""));for(;l[n].length<e.length;)l[n].push("");for(let r=0;r<o[t].length;r++){const c=C.col+r;if(c>=e.length)break;e[c].readOnly||(l[n][c]=o[t][r].trim())}}m(p?l:h(l,e.length)),q({row:C.row,col:C.col}),J({row:Math.min(C.row+o.length-1,l.length-1),col:Math.min(C.col+(o[0]?.length||1)-1,e.length-1)})};return window.addEventListener("paste",t),()=>window.removeEventListener("paste",t)},[C,ee,e,m,p]);const oe=c((t,n,r)=>{const o=t.clipboardData.getData("text/plain");if(!o)return;const l=o.split("\n").map(e=>e.split("\t"));if(l.length<=1&&l[0]?.length<=1)return;t.preventDefault();const c=ee.map(e=>[...e]);for(let t=0;t<l.length;t++){const o=n+t;for(;c.length<=o;)c.push(Array(e.length).fill(""));for(;c[o].length<e.length;)c[o].push("");for(let n=0;n<l[t].length;n++){const a=r+n;if(a>=e.length)break;e[a].readOnly||(c[o][a]=l[t][n].trim())}}m(p?c:h(c,e.length))},[ee,e,m,p]),le=c((t,n,r)=>{let o=n,l=r;if("Tab"===t.key)t.preventDefault(),l=t.shiftKey?r-1:r+1,l>=e.length&&(l=0,o=n+1),l<0&&(l=e.length-1,o=n-1);else if("Enter"===t.key)t.preventDefault(),o=t.shiftKey?n-1:n+1;else if("ArrowDown"===t.key)t.preventDefault(),o=n+1;else if("ArrowUp"===t.key)t.preventDefault(),o=n-1;else if("ArrowLeft"===t.key)t.preventDefault(),l=r-1;else{if("ArrowRight"!==t.key){if("Delete"===t.key||"Backspace"===t.key){const o=t.target;if(o.isContentEditable)return void(o.textContent&&window.getSelection()?.toString()===o.textContent&&(t.preventDefault(),te(n,r,"")));if(t.preventDefault(),B&&W){const t=Math.min(B.row,W.row),n=Math.max(B.row,W.row),r=Math.min(B.col,W.col),o=Math.max(B.col,W.col),l=ee.map(e=>[...e]);for(let c=t;c<=n;c++)for(let t=r;t<=o;t++)l[c]&&!e[t]?.readOnly&&(l[c][t]="");m(l)}else te(n,r,"");return}return}t.preventDefault(),l=r+1}for(;l>=0&&l<e.length&&e[l].readOnly;)l+="Tab"===t.key&&t.shiftKey?-1:1;if(o>=0&&o<ee.length&&l>=0&&l<e.length){const e=D.current?.querySelector(`[data-row="${o}"][data-col="${l}"]`);e&&(e.focus({preventScroll:!0}),e.scrollIntoView({block:"nearest",inline:"nearest"}),E({row:o,col:l}),Y(null),q({row:o,col:l}),J({row:o,col:l}))}},[e,ee,ee.length,te,B,W,m]),ce=c(t=>{if(!p&&t>=ee.length-2){const t=ee.map(e=>[...e]);for(let n=0;n<5;n++)t.push(Array(e.length).fill(""));m(t)}},[p,ee,e.length,m]),[ae,se]=o(null);l(()=>{if(!ae)return;const e=()=>se(null);return window.addEventListener("pointerdown",e),()=>window.removeEventListener("pointerdown",e)},[ae]);const ie=c(t=>{const n=ee.map(e=>[...e]);n.splice(t,0,Array(e.length).fill("")),m(n)},[ee,e.length,m]),ue=c(e=>{if(ee.length<=1)return;const t=ee.filter((t,n)=>n!==e);m(t)},[ee,m]),de=c(e=>{const t=ee.map(t=>{const n=[...t];return n.splice(e,0,""),n});m(t)},[ee,m]),he=c(t=>{if(e.length<=1)return;const n=ee.map(e=>{const n=[...e];return n.splice(t,1),n});m(n)},[ee,e.length,m]),we=c((e,t)=>{e.preventDefault(),p||se({x:e.clientX,y:e.clientY,items:[{label:k.insertRowAbove,onClick:()=>{ie(t),se(null)}},{label:k.insertRowBelow,onClick:()=>{ie(t+1),se(null)}},{label:k.deleteRow(t+1),onClick:()=>{ue(t),se(null)}}]})},[p,ie,ue,k]),ge=c((t,n)=>{t.preventDefault(),p||se({x:t.clientX,y:t.clientY,items:[{label:k.insertColumnLeft,onClick:()=>{de(n),se(null)}},{label:k.insertColumnRight,onClick:()=>{de(n+1),se(null)}},{label:k.deleteColumn(String(e[n]?.title||n+1)),onClick:()=>{he(n),se(null)}}]})},[p,e,de,he,k]),me=t=>S[t]??e[t]?.width??150;l(()=>{const t=e=>{if(!$.current)return;const t=e.clientX-$.current.startX,n=Math.max(40,$.current.startW+t);L(e=>({...e,[$.current.col]:n}))},n=()=>{if($.current&&f){const t=e.map((e,t)=>({...e,width:S[t]??e.width}));t[$.current.col]={...t[$.current.col],width:S[$.current.col]??e[$.current.col].width},f(t)}$.current=null,document.body.style.cursor=""};return window.addEventListener("mousemove",t),window.addEventListener("mouseup",n),()=>{window.removeEventListener("mousemove",t),window.removeEventListener("mouseup",n)}},[e,S,f]);const fe=e=>N[e]??28;l(()=>{const e=e=>{if(!z.current)return;const t=e.clientY-z.current.startY,n=Math.max(20,z.current.startH+t);A(e=>({...e,[z.current.row]:n}))},t=()=>{z.current=null,document.body.style.cursor=""};return window.addEventListener("mousemove",e),window.addEventListener("mouseup",t),()=>{window.removeEventListener("mousemove",e),window.removeEventListener("mouseup",t)}},[]);const pe=c(t=>{const n=document.createElement("canvas").getContext("2d");if(!n)return;n.font="12px ui-monospace, SFMono-Regular, Menlo, monospace";let r=0;for(const e of ee){const o=String(e[t]??"").replace(/<[^>]*>/g,""),l=n.measureText(o).width;l>r&&(r=l)}const o=n.measureText(e[t]?.title??"").width;o>r&&(r=o);const l=Math.max(40,Math.ceil(r+24));if(L(e=>({...e,[t]:l})),f){const n=e.map((e,n)=>({...e,width:n===t?l:S[n]??e.width}));f(n)}},[ee,e,S,f]),ye=c(e=>{A(t=>{const n={...t};return delete n[e],n})},[]),be=c(t=>{const{a:n,e:r}=G.current;if(!n||!r)return;const o=Math.min(n.row,r.row),l=Math.max(n.row,r.row),c=Math.min(n.col,r.col),a=Math.max(n.col,r.col);let s=o,i=l,u=c,d=a;t.row>l?i=t.row:t.row<o&&(s=t.row),t.col>a?d=t.col:t.col<c&&(u=t.col);const h=l-o+1,w=a-c+1,g=ee.map(e=>[...e]);for(;g.length<=i;)g.push(Array(e.length).fill(""));for(const e of g)for(;e.length<=d;)e.push("");function f(e){const t=e.map(e=>parseFloat(e));if(t.length<2||t.some(e=>Number.isNaN(e)))return null;const n=t[1]-t[0];for(let e=2;e<t.length;e++)if(Math.abs(t[e]-t[e-1]-n)>1e-9)return null;return{step:n}}for(let e=s;e<=i;e++)for(let t=u;t<=d;t++){if(e>=o&&e<=l&&t>=c&&t<=a)continue;let n;if(1===w&&u===c&&d===a){const r=f(Array.from({length:h},(e,n)=>g[o+n]?.[t]??""));if(r){const c=parseFloat(g[l]?.[t]??"0"),a=parseFloat(g[o]?.[t]??"0"),s=e>l?e-l:-(o-e);n=String((e>l?c:a)+r.step*s)}else{const r=((e-o)%h+h)%h;n=g[o+r]?.[t]??""}}else if(1===h&&s===o&&i===l){const r=f(Array.from({length:w},(t,n)=>g[e]?.[c+n]??""));if(r){const o=parseFloat(g[e]?.[a]??"0"),l=parseFloat(g[e]?.[c]??"0"),s=t>a?t-a:-(c-t);n=String((t>a?o:l)+r.step*s)}else{const r=((t-c)%w+w)%w;n=g[e]?.[c+r]??""}}else{const r=((e-o)%h+h)%h,l=((t-c)%w+w)%w;n=g[o+r]?.[c+l]??""}g[e][t]=n}m(g),q({row:s,col:u}),J({row:i,col:d})},[ee,e.length,m]);l(()=>{const e=e=>{if(!V.current)return;const t=document.elementFromPoint(e.clientX,e.clientY),n=t?.closest?.("[data-row][data-col]");if(!n)return;const r=parseInt(n.dataset.row),o=parseInt(n.dataset.col);U({row:r,col:o})},t=()=>{V.current&&Q&&be(Q),V.current=!1,U(null),document.body.style.cursor=""};return window.addEventListener("mousemove",e),window.addEventListener("mouseup",t),()=>{window.removeEventListener("mousemove",e),window.removeEventListener("mouseup",t)}},[Q,be]);const ve=e=>{e.preventDefault(),e.stopPropagation(),V.current=!0,document.body.style.cursor="crosshair"},xe=r(null),[Me,De]=o(0),[ke,Ce]=o(800);l(()=>{const e=xe.current;if(!e)return;const t=()=>Ce(e.clientHeight||800);t();const n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]);const Ee=ee.length>100,Se=Ee?Math.max(0,Math.floor(Me/28)-20):0,Le=Ee?Math.min(ee.length,Math.ceil((Me+ke)/28)+20):ee.length,$e=a(()=>ee.slice(Se,Le),[ee,Se,Le]),Ne=28*Se,Ae=28*(ee.length-Le),ze="px-2 py-1.5 text-left text-xs font-medium text-gray-500 uppercase bg-gray-100 border-b border-r border-gray-200 select-none";/* @__PURE__ */
1
+ import{escapeHtml as e}from"./chunk-BR22X7E5.js";import{useShellStrings as t}from"./chunk-YJX2IWHB.js";import{useBrowserLayoutEffect as n}from"./chunk-D65T4H6J.js";import{useRef as r,useState as o,useEffect as l,useCallback as c,useMemo as a}from"react";import{createPortal as s}from"react-dom";import{jsxs as i,jsx as u,Fragment as d}from"react/jsx-runtime";function h(e,t){const n=e[e.length-1];return n&&!n.some(e=>e.trim())?e:[...e,Array(t).fill("")]}function w({text:t,...n}){const r=a(()=>({__html:e(t)}),[t]);/* @__PURE__ */
2
+ return u("div",{...n,dangerouslySetInnerHTML:r})}function g({columns:e,data:g,onChange:m,onColumnsChange:f,fixedRows:p=!1,minRows:y=15,maxHeight:b="260px",cellStyles:v,onFocusChange:x,onSelectionChange:M}){const D=r(null),k=t().grid,[C,E]=o(null);l(()=>{x?.(C)},[C,x]);const[L,S]=o({}),$=r(null),[N,A]=o({}),z=r(null),[O,T]=o(null),[R,K]=o(null),[P,F]=o(null),[I,X]=o(null),[H,Y]=o(null),j=r(null);n(()=>{const e=j.current;if(!e||e.row!==H?.row||e.col!==H?.col)return;j.current=null;const t=D.current?.querySelector(`[data-row="${e.row}"][data-col="${e.col}"]`);if(!t)return;t.focus();const n=document.createRange();n.selectNodeContents(t),n.collapse(!1);const r=window.getSelection();r?.removeAllRanges(),r?.addRange(n)},[H]);const[B,W]=o(null),[q,J]=o(null);l(()=>{M?.(B&&q?{anchor:B,end:q}:null)},[B,q,M]);const _=r(!1),[U,V]=o(null),G=r(!1),Q=r({a:null,e:null});Q.current={a:B,e:q};const Z=B&&q&&(B.row!==q.row||B.col!==q.col),ee=[...g];if(!p)for(;ee.length<y;)ee.push(Array(e.length).fill(""));const te=c((t,n,r)=>{const o=ee.map(e=>[...e]);for(;o.length<=t;)o.push(Array(e.length).fill(""));for(;o[t].length<e.length;)o[t].push("");o[t][n]=r,m(o)},[ee,e.length,m]),ne=c((e,t,n)=>{if(0!==e.button)return;const r=document.activeElement;if(r?.dataset?.row&&r?.dataset?.col){const e=parseInt(r.dataset.row),t=parseInt(r.dataset.col),n=r.textContent||"";if(n!==(ee[e]?.[t]||"")){const r=ee.map(e=>[...e]);r[e]&&(r[e][t]=n,m(r))}}_.current=!0,e.shiftKey&&B||W({row:t,col:n}),J({row:t,col:n})},[ee,m,B]),re=c((e,t)=>{_.current&&J({row:e,col:t})},[]);l(()=>{const e=()=>{_.current=!1};return window.addEventListener("mouseup",e),()=>window.removeEventListener("mouseup",e)},[]),l(()=>{const e=e=>{if(!e.ctrlKey&&!e.metaKey||"c"!==e.key)return;if(!B||!q)return;const t=window.getSelection();if(t&&t.toString().length>0&&!Z)return;const n=Math.min(B.row,q.row),r=Math.max(B.row,q.row),o=Math.min(B.col,q.col),l=Math.max(B.col,q.col),c=[];for(let e=n;e<=r;e++){const t=[];for(let n=o;n<=l;n++)t.push(ee[e]?.[n]||"");c.push(t.join("\t"))}const a=c.join("\n");a&&(e.preventDefault(),navigator.clipboard.writeText(a))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[B,q,ee,Z]),l(()=>{const t=t=>{if(!C)return;const n=document.activeElement;if(n?.isContentEditable)return;if(!D.current?.contains(n))return;const r=t.clipboardData?.getData("text/plain");if(!r)return;t.preventDefault();const o=r.split("\n").filter(e=>e).map(e=>e.split("\t")),l=ee.map(e=>[...e]);for(let t=0;t<o.length;t++){const n=C.row+t;for(;l.length<=n;)l.push(Array(e.length).fill(""));for(;l[n].length<e.length;)l[n].push("");for(let r=0;r<o[t].length;r++){const c=C.col+r;if(c>=e.length)break;e[c].readOnly||(l[n][c]=o[t][r].trim())}}m(p?l:h(l,e.length)),W({row:C.row,col:C.col}),J({row:Math.min(C.row+o.length-1,l.length-1),col:Math.min(C.col+(o[0]?.length||1)-1,e.length-1)})};return window.addEventListener("paste",t),()=>window.removeEventListener("paste",t)},[C,ee,e,m,p]);const oe=c((t,n,r)=>{const o=t.clipboardData.getData("text/plain");if(!o)return;const l=o.split("\n").map(e=>e.split("\t"));if(l.length<=1&&l[0]?.length<=1)return;t.preventDefault();const c=ee.map(e=>[...e]);for(let t=0;t<l.length;t++){const o=n+t;for(;c.length<=o;)c.push(Array(e.length).fill(""));for(;c[o].length<e.length;)c[o].push("");for(let n=0;n<l[t].length;n++){const a=r+n;if(a>=e.length)break;e[a].readOnly||(c[o][a]=l[t][n].trim())}}m(p?c:h(c,e.length))},[ee,e,m,p]),le=c((t,n,r)=>{let o=n,l=r;if("Tab"===t.key)t.preventDefault(),l=t.shiftKey?r-1:r+1,l>=e.length&&(l=0,o=n+1),l<0&&(l=e.length-1,o=n-1);else if("Enter"===t.key)t.preventDefault(),o=t.shiftKey?n-1:n+1;else if("ArrowDown"===t.key)t.preventDefault(),o=n+1;else if("ArrowUp"===t.key)t.preventDefault(),o=n-1;else if("ArrowLeft"===t.key)t.preventDefault(),l=r-1;else{if("ArrowRight"!==t.key){if("Delete"===t.key||"Backspace"===t.key){const o=t.target;if(o.isContentEditable)return void(o.textContent&&window.getSelection()?.toString()===o.textContent&&(t.preventDefault(),te(n,r,"")));if(t.preventDefault(),B&&q){const t=Math.min(B.row,q.row),n=Math.max(B.row,q.row),r=Math.min(B.col,q.col),o=Math.max(B.col,q.col),l=ee.map(e=>[...e]);for(let c=t;c<=n;c++)for(let t=r;t<=o;t++)l[c]&&!e[t]?.readOnly&&(l[c][t]="");m(l)}else te(n,r,"");return}return}t.preventDefault(),l=r+1}for(;l>=0&&l<e.length&&e[l].readOnly;)l+="Tab"===t.key&&t.shiftKey?-1:1;if(o>=0&&o<ee.length&&l>=0&&l<e.length){const e=D.current?.querySelector(`[data-row="${o}"][data-col="${l}"]`);e&&(e.focus({preventScroll:!0}),e.scrollIntoView({block:"nearest",inline:"nearest"}),E({row:o,col:l}),Y(null),W({row:o,col:l}),J({row:o,col:l}))}},[e,ee,ee.length,te,B,q,m]),ce=c(t=>{if(!p&&t>=ee.length-2){const t=ee.map(e=>[...e]);for(let n=0;n<5;n++)t.push(Array(e.length).fill(""));m(t)}},[p,ee,e.length,m]),[ae,se]=o(null);l(()=>{if(!ae)return;const e=()=>se(null);return window.addEventListener("pointerdown",e),()=>window.removeEventListener("pointerdown",e)},[ae]);const ie=c(t=>{const n=ee.map(e=>[...e]);n.splice(t,0,Array(e.length).fill("")),m(n)},[ee,e.length,m]),ue=c(e=>{if(ee.length<=1)return;const t=ee.filter((t,n)=>n!==e);m(t)},[ee,m]),de=c(e=>{const t=ee.map(t=>{const n=[...t];return n.splice(e,0,""),n});m(t)},[ee,m]),he=c(t=>{if(e.length<=1)return;const n=ee.map(e=>{const n=[...e];return n.splice(t,1),n});m(n)},[ee,e.length,m]),we=c((e,t)=>{e.preventDefault(),p||se({x:e.clientX,y:e.clientY,items:[{label:k.insertRowAbove,onClick:()=>{ie(t),se(null)}},{label:k.insertRowBelow,onClick:()=>{ie(t+1),se(null)}},{label:k.deleteRow(t+1),onClick:()=>{ue(t),se(null)}}]})},[p,ie,ue,k]),ge=c((t,n)=>{t.preventDefault(),p||se({x:t.clientX,y:t.clientY,items:[{label:k.insertColumnLeft,onClick:()=>{de(n),se(null)}},{label:k.insertColumnRight,onClick:()=>{de(n+1),se(null)}},{label:k.deleteColumn(String(e[n]?.title||n+1)),onClick:()=>{he(n),se(null)}}]})},[p,e,de,he,k]),me=t=>L[t]??e[t]?.width??150;l(()=>{const t=e=>{if(!$.current)return;const t=e.clientX-$.current.startX,n=Math.max(40,$.current.startW+t);S(e=>({...e,[$.current.col]:n}))},n=()=>{if($.current&&f){const t=e.map((e,t)=>({...e,width:L[t]??e.width}));t[$.current.col]={...t[$.current.col],width:L[$.current.col]??e[$.current.col].width},f(t)}$.current=null,document.body.style.cursor=""};return window.addEventListener("mousemove",t),window.addEventListener("mouseup",n),()=>{window.removeEventListener("mousemove",t),window.removeEventListener("mouseup",n)}},[e,L,f]);const fe=e=>N[e]??28;l(()=>{const e=e=>{if(!z.current)return;const t=e.clientY-z.current.startY,n=Math.max(20,z.current.startH+t);A(e=>({...e,[z.current.row]:n}))},t=()=>{z.current=null,document.body.style.cursor=""};return window.addEventListener("mousemove",e),window.addEventListener("mouseup",t),()=>{window.removeEventListener("mousemove",e),window.removeEventListener("mouseup",t)}},[]);const pe=c(t=>{const n=document.createElement("canvas").getContext("2d");if(!n)return;n.font="12px ui-monospace, SFMono-Regular, Menlo, monospace";let r=0;for(const e of ee){const o=String(e[t]??"").replace(/<[^>]*>/g,""),l=n.measureText(o).width;l>r&&(r=l)}const o=n.measureText(e[t]?.title??"").width;o>r&&(r=o);const l=Math.max(40,Math.ceil(r+24));if(S(e=>({...e,[t]:l})),f){const n=e.map((e,n)=>({...e,width:n===t?l:L[n]??e.width}));f(n)}},[ee,e,L,f]),ye=c(e=>{A(t=>{const n={...t};return delete n[e],n})},[]),be=c(t=>{const{a:n,e:r}=Q.current;if(!n||!r)return;const o=Math.min(n.row,r.row),l=Math.max(n.row,r.row),c=Math.min(n.col,r.col),a=Math.max(n.col,r.col);let s=o,i=l,u=c,d=a;t.row>l?i=t.row:t.row<o&&(s=t.row),t.col>a?d=t.col:t.col<c&&(u=t.col);const h=l-o+1,w=a-c+1,g=ee.map(e=>[...e]);for(;g.length<=i;)g.push(Array(e.length).fill(""));for(const e of g)for(;e.length<=d;)e.push("");function f(e){const t=e.map(e=>parseFloat(e));if(t.length<2||t.some(e=>Number.isNaN(e)))return null;const n=t[1]-t[0];for(let e=2;e<t.length;e++)if(Math.abs(t[e]-t[e-1]-n)>1e-9)return null;return{step:n}}for(let e=s;e<=i;e++)for(let t=u;t<=d;t++){if(e>=o&&e<=l&&t>=c&&t<=a)continue;let n;if(1===w&&u===c&&d===a){const r=f(Array.from({length:h},(e,n)=>g[o+n]?.[t]??""));if(r){const c=parseFloat(g[l]?.[t]??"0"),a=parseFloat(g[o]?.[t]??"0"),s=e>l?e-l:-(o-e);n=String((e>l?c:a)+r.step*s)}else{const r=((e-o)%h+h)%h;n=g[o+r]?.[t]??""}}else if(1===h&&s===o&&i===l){const r=f(Array.from({length:w},(t,n)=>g[e]?.[c+n]??""));if(r){const o=parseFloat(g[e]?.[a]??"0"),l=parseFloat(g[e]?.[c]??"0"),s=t>a?t-a:-(c-t);n=String((t>a?o:l)+r.step*s)}else{const r=((t-c)%w+w)%w;n=g[e]?.[c+r]??""}}else{const r=((e-o)%h+h)%h,l=((t-c)%w+w)%w;n=g[o+r]?.[c+l]??""}g[e][t]=n}m(g),W({row:s,col:u}),J({row:i,col:d})},[ee,e.length,m]);l(()=>{const e=e=>{if(!G.current)return;const t=document.elementFromPoint(e.clientX,e.clientY),n=t?.closest?.("[data-row][data-col]");if(!n)return;const r=parseInt(n.dataset.row),o=parseInt(n.dataset.col);V({row:r,col:o})},t=()=>{G.current&&U&&be(U),G.current=!1,V(null),document.body.style.cursor=""};return window.addEventListener("mousemove",e),window.addEventListener("mouseup",t),()=>{window.removeEventListener("mousemove",e),window.removeEventListener("mouseup",t)}},[U,be]);const ve=e=>{e.preventDefault(),e.stopPropagation(),G.current=!0,document.body.style.cursor="crosshair"},xe=r(null),[Me,De]=o(0),[ke,Ce]=o(800);l(()=>{const e=xe.current;if(!e)return;const t=()=>Ce(e.clientHeight||800);t();const n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]);const Ee=ee.length>100,Le=Ee?Math.max(0,Math.floor(Me/28)-20):0,Se=Ee?Math.min(ee.length,Math.ceil((Me+ke)/28)+20):ee.length,$e=a(()=>ee.slice(Le,Se),[ee,Le,Se]),Ne=28*Le,Ae=28*(ee.length-Se),ze="px-2 py-1.5 text-left text-xs font-medium text-gray-500 uppercase bg-gray-100 border-b border-r border-gray-200 select-none";/* @__PURE__ */
3
3
  return i("div",{ref:xe,className:"border border-gray-300 rounded overflow-scroll grid-scroll",style:{maxHeight:b,height:b},onScroll:e=>De(e.target.scrollTop),children:[
4
4
  /* @__PURE__ */i("table",{ref:D,className:"border-collapse select-none",style:{tableLayout:"fixed",minWidth:36+e.reduce((t,n)=>t+me(e.indexOf(n)),0)},children:[
5
5
  /* @__PURE__ */i("colgroup",{children:[
6
6
  /* @__PURE__ */u("col",{style:{width:36}}),e.map((e,t)=>/* @__PURE__ */u("col",{style:{width:me(t)}},e.key))]}),
7
7
  /* @__PURE__ */u("thead",{className:"sticky top-0 z-10",children:/* @__PURE__ */i("tr",{children:[
8
- /* @__PURE__ */u("th",{className:ze+" text-center w-9 cursor-pointer hover:bg-gray-200",onClick:()=>{q({row:0,col:0}),J({row:ee.length-1,col:e.length-1})},title:k.selectAll,children:"#"}),e.map((t,n)=>{const r=B&&W&&Math.min(B.col,W.col)<=n&&n<=Math.max(B.col,W.col)&&0===Math.min(B.row,W.row)&&Math.max(B.row,W.row)===ee.length-1;/* @__PURE__ */
9
- return i("th",{className:`${ze} cursor-pointer hover:bg-gray-200 relative${r?" !bg-blue-200":""}${I===n?" !bg-blue-100":""}`,style:{width:me(n)},draggable:!0,onDragStart:()=>(e=>F(e))(n),onDragOver:e=>((e,t)=>{e.preventDefault(),X(t)})(e,n),onDrop:()=>(t=>{if(null===P||P===t)return F(null),void X(null);const n=ee.map(e=>{const n=[...e],[r]=n.splice(P,1);return n.splice(t,0,r),n});if(m(n),f){const n=[...e],[r]=n.splice(P,1);n.splice(t,0,r),f(n)}F(null),X(null)})(n),onDragEnd:()=>{F(null),X(null)},onClick:e=>{e.shiftKey&&B||q({row:0,col:n}),J({row:ee.length-1,col:n})},onContextMenu:e=>ge(e,n),children:[t.title,
8
+ /* @__PURE__ */u("th",{className:ze+" text-center w-9 cursor-pointer hover:bg-gray-200",onClick:()=>{W({row:0,col:0}),J({row:ee.length-1,col:e.length-1})},title:k.selectAll,children:"#"}),e.map((t,n)=>{const r=B&&q&&Math.min(B.col,q.col)<=n&&n<=Math.max(B.col,q.col)&&0===Math.min(B.row,q.row)&&Math.max(B.row,q.row)===ee.length-1;/* @__PURE__ */
9
+ return i("th",{className:`${ze} cursor-pointer hover:bg-gray-200 relative${r?" !bg-blue-200":""}${I===n?" !bg-blue-100":""}`,style:{width:me(n)},draggable:!0,onDragStart:()=>(e=>F(e))(n),onDragOver:e=>((e,t)=>{e.preventDefault(),X(t)})(e,n),onDrop:()=>(t=>{if(null===P||P===t)return F(null),void X(null);const n=ee.map(e=>{const n=[...e],[r]=n.splice(P,1);return n.splice(t,0,r),n});if(m(n),f){const n=[...e],[r]=n.splice(P,1);n.splice(t,0,r),f(n)}F(null),X(null)})(n),onDragEnd:()=>{F(null),X(null)},onClick:e=>{e.shiftKey&&B||W({row:0,col:n}),J({row:ee.length-1,col:n})},onContextMenu:e=>ge(e,n),children:[t.title,
10
10
  /* @__PURE__ */u("div",{className:"absolute -right-1 top-0 bottom-0 w-2 cursor-col-resize z-20",onMouseDown:e=>((e,t)=>{e.preventDefault(),e.stopPropagation(),$.current={col:t,startX:e.clientX,startW:me(t)},document.body.style.cursor="col-resize"})(e,n),onDoubleClick:e=>{e.stopPropagation(),pe(n)},title:k.resize})]},t.key)})]})}),
11
- /* @__PURE__ */i("tbody",{children:[Ne>0&&/* @__PURE__ */u("tr",{style:{height:Ne}}),$e.map((t,n)=>{const r=Se+n,o=B&&W&&Math.min(B.row,W.row)<=r&&r<=Math.max(B.row,W.row)&&0===Math.min(B.col,W.col)&&Math.max(B.col,W.col)===e.length-1;/* @__PURE__ */
11
+ /* @__PURE__ */i("tbody",{children:[Ne>0&&/* @__PURE__ */u("tr",{style:{height:Ne}}),$e.map((t,n)=>{const r=Le+n,o=B&&q&&Math.min(B.row,q.row)<=r&&r<=Math.max(B.row,q.row)&&0===Math.min(B.col,q.col)&&Math.max(B.col,q.col)===e.length-1;/* @__PURE__ */
12
12
  return i("tr",{style:{height:fe(r)},children:[
13
- /* @__PURE__ */i("td",{className:`relative px-1 py-1 text-center text-[10px] text-gray-400 border-b border-r border-gray-200 bg-gray-50 select-none cursor-pointer hover:bg-gray-200${o?" !bg-blue-200 !text-gray-700":""}${R===r?" !bg-blue-100":""}`,draggable:!0,onDragStart:()=>(e=>O(e))(r),onDragOver:e=>((e,t)=>{e.preventDefault(),K(t)})(e,r),onDrop:()=>(e=>{if(null===T||T===e)return O(null),void K(null);const t=ee.map(e=>[...e]),[n]=t.splice(T,1);t.splice(e,0,n),m(t),O(null),K(null)})(r),onDragEnd:()=>{O(null),K(null)},onClick:t=>{t.shiftKey&&B||q({row:r,col:0}),J({row:r,col:e.length-1})},onContextMenu:e=>we(e,r),children:[r+1,
14
- /* @__PURE__ */u("div",{className:"absolute -bottom-1 left-0 right-0 h-2 cursor-row-resize z-20",onMouseDown:e=>((e,t)=>{e.preventDefault(),e.stopPropagation(),z.current={row:t,startY:e.clientY,startH:fe(t)},document.body.style.cursor="row-resize"})(e,r),onDoubleClick:e=>{e.stopPropagation(),ye(r)},title:k.resize})]}),e.map((e,n)=>{const o=B&&W&&function(e,t,n,r){const o=Math.min(e.row,t.row),l=Math.max(e.row,t.row),c=Math.min(e.col,t.col),a=Math.max(e.col,t.col);return n>=o&&n<=l&&r>=c&&r<=a}(B,W,r,n),l=H?.row===r&&H?.col===n&&!e.readOnly,c=C?.row===r&&C?.col===n,a=v?.[`${r}:${n}`],s=B&&W?Math.max(B.row,W.row):-1,d=B&&W?Math.max(B.col,W.col):-1,h=B&&W&&r===s&&n===d,g=V.current&&Q&&B&&W&&(()=>{const e=Math.min(B.row,W.row),t=Math.max(B.row,W.row),o=Math.min(B.col,W.col),l=Math.max(B.col,W.col);let c=e,a=t,s=o,i=l;return Q.row>t?a=Q.row:Q.row<e&&(c=Q.row),Q.col>l?i=Q.col:Q.col<o&&(s=Q.col),r>=c&&r<=a&&n>=s&&n<=i&&!(r>=e&&r<=t&&n>=o&&n<=l)})(),m="sm"===a?.fontSize?"text-[11px]":"lg"===a?.fontSize?"text-sm":"xl"===a?.fontSize?"text-base":"text-xs",f=`${a?.bold?" font-bold":""}${a?.italic?" italic":""}${a?.underline?" underline":""}`;/* @__PURE__ */
13
+ /* @__PURE__ */i("td",{className:`relative px-1 py-1 text-center text-[10px] text-gray-400 border-b border-r border-gray-200 bg-gray-50 select-none cursor-pointer hover:bg-gray-200${o?" !bg-blue-200 !text-gray-700":""}${R===r?" !bg-blue-100":""}`,draggable:!0,onDragStart:()=>(e=>T(e))(r),onDragOver:e=>((e,t)=>{e.preventDefault(),K(t)})(e,r),onDrop:()=>(e=>{if(null===O||O===e)return T(null),void K(null);const t=ee.map(e=>[...e]),[n]=t.splice(O,1);t.splice(e,0,n),m(t),T(null),K(null)})(r),onDragEnd:()=>{T(null),K(null)},onClick:t=>{t.shiftKey&&B||W({row:r,col:0}),J({row:r,col:e.length-1})},onContextMenu:e=>we(e,r),children:[r+1,
14
+ /* @__PURE__ */u("div",{className:"absolute -bottom-1 left-0 right-0 h-2 cursor-row-resize z-20",onMouseDown:e=>((e,t)=>{e.preventDefault(),e.stopPropagation(),z.current={row:t,startY:e.clientY,startH:fe(t)},document.body.style.cursor="row-resize"})(e,r),onDoubleClick:e=>{e.stopPropagation(),ye(r)},title:k.resize})]}),e.map((e,n)=>{const o=B&&q&&function(e,t,n,r){const o=Math.min(e.row,t.row),l=Math.max(e.row,t.row),c=Math.min(e.col,t.col),a=Math.max(e.col,t.col);return n>=o&&n<=l&&r>=c&&r<=a}(B,q,r,n),l=H?.row===r&&H?.col===n&&!e.readOnly,c=C?.row===r&&C?.col===n,a=v?.[`${r}:${n}`],s=B&&q?Math.max(B.row,q.row):-1,d=B&&q?Math.max(B.col,q.col):-1,h=B&&q&&r===s&&n===d,g=G.current&&U&&B&&q&&(()=>{const e=Math.min(B.row,q.row),t=Math.max(B.row,q.row),o=Math.min(B.col,q.col),l=Math.max(B.col,q.col);let c=e,a=t,s=o,i=l;return U.row>t?a=U.row:U.row<e&&(c=U.row),U.col>l?i=U.col:U.col<o&&(s=U.col),r>=c&&r<=a&&n>=s&&n<=i&&!(r>=e&&r<=t&&n>=o&&n<=l)})(),m="sm"===a?.fontSize?"text-[11px]":"lg"===a?.fontSize?"text-sm":"xl"===a?.fontSize?"text-base":"text-xs",f=`${a?.bold?" font-bold":""}${a?.italic?" italic":""}${a?.underline?" underline":""}`;/* @__PURE__ */
15
15
  return i("td",{className:`relative px-0 py-0 border-b border-r border-gray-200 text-sm${e.readOnly?" bg-gray-50 text-gray-500 cursor-default":" cursor-cell"}${o?" !bg-blue-100":""}${c&&!o?" ring-2 ring-inset ring-blue-400":""}${g?" !bg-blue-50 ring-1 ring-inset ring-blue-300":""}`,onMouseDown:e=>{if(e.target===e.currentTarget){ne(e,r,n);const t=e.currentTarget.querySelector("[data-row][data-col]");t?.focus()}},onMouseEnter:()=>re(r,n),onClick:e=>{if(e.target===e.currentTarget){const t=e.currentTarget.querySelector("[data-row][data-col]");t?.focus()}},onDoubleClick:t=>{t.target!==t.currentTarget||e.readOnly||Y({row:r,col:n})},children:[
16
- /* @__PURE__ */u(w,{contentEditable:l,suppressContentEditableWarning:!0,tabIndex:0,"data-row":r,"data-col":n,className:`w-full h-full px-2 py-1 rosh-focus-ring whitespace-nowrap overflow-hidden ${"right"===e.align?"text-right":"center"===e.align?"text-center":""} ${e.readOnly?"cursor-default":"cursor-cell"} font-mono ${m}${f}`,onMouseDown:e=>ne(e,r,n),onMouseEnter:()=>re(r,n),onDoubleClick:()=>{e.readOnly||Y({row:r,col:n})},onFocus:()=>{E({row:r,col:n}),_.current||(q({row:r,col:n}),J({row:r,col:n}))},onBlur:e=>{const o=e.currentTarget.textContent||"";o!==(t[n]||"")&&te(r,n,o),Y(null)},onInput:()=>ce(r),onPaste:e=>oe(e,r,n),onKeyDown:t=>{if(!(l||e.readOnly||1!==t.key.length||t.ctrlKey||t.metaKey||t.altKey))return t.preventDefault(),te(r,n,t.key),j.current={row:r,col:n},void Y({row:r,col:n});le(t,r,n)},text:t[n]||""}),h&&/* @__PURE__ */u("div",{onMouseDown:ve,title:k.fill,className:"absolute -bottom-[3px] -right-[3px] w-[7px] h-[7px] bg-blue-500 border border-white cursor-crosshair z-30 hover:bg-blue-600"})]},n)})]},r)}),Ae>0&&/* @__PURE__ */u("tr",{style:{height:Ae}})]})]}),ae&&s(
16
+ /* @__PURE__ */u(w,{contentEditable:l,suppressContentEditableWarning:!0,tabIndex:0,"data-row":r,"data-col":n,className:`w-full h-full px-2 py-1 rosh-focus-ring whitespace-nowrap overflow-hidden ${"right"===e.align?"text-right":"center"===e.align?"text-center":""} ${e.readOnly?"cursor-default":"cursor-cell"} font-mono ${m}${f}`,onMouseDown:e=>ne(e,r,n),onMouseEnter:()=>re(r,n),onDoubleClick:()=>{e.readOnly||Y({row:r,col:n})},onFocus:()=>{E({row:r,col:n}),_.current||(W({row:r,col:n}),J({row:r,col:n}))},onBlur:e=>{const o=e.currentTarget.textContent||"";o!==(t[n]||"")&&te(r,n,o),Y(null)},onInput:()=>ce(r),onPaste:e=>oe(e,r,n),onKeyDown:t=>{if(!(l||e.readOnly||1!==t.key.length||t.ctrlKey||t.metaKey||t.altKey))return t.preventDefault(),te(r,n,t.key),j.current={row:r,col:n},void Y({row:r,col:n});le(t,r,n)},text:t[n]||""}),h&&/* @__PURE__ */u("div",{onMouseDown:ve,title:k.fill,className:"absolute -bottom-[3px] -right-[3px] w-[7px] h-[7px] bg-blue-500 border border-white cursor-crosshair z-30 hover:bg-blue-600"})]},n)})]},r)}),Ae>0&&/* @__PURE__ */u("tr",{style:{height:Ae}})]})]}),ae&&s(
17
17
  /* @__PURE__ */i(d,{children:[
18
18
  /* @__PURE__ */u("div",{className:"fixed inset-0 z-[200]",onPointerDown:()=>se(null)}),
19
19
  /* @__PURE__ */u("div",{className:"fixed z-[201] bg-white rounded-lg shadow-lg border border-gray-200 py-1 min-w-[160px]",style:{left:ae.x,top:ae.y},children:ae.items.map((e,t)=>/* @__PURE__ */u("button",{onPointerDown:t=>{t.stopPropagation(),e.onClick()},className:"w-full text-left px-3 py-1.5 text-sm text-gray-700 hover:bg-gray-100",children:e.label},t))})]}),document.body)]})}export{g as EditableGrid,h as withSpareRow};