efficient-shell 7.62.0 → 7.64.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 (72) hide show
  1. package/README.md +1 -1
  2. package/dist/{Browser-F4MUAORU.js → Browser-DEK65GGL.js} +14 -14
  3. package/dist/Calculator-2TQXXQTL.js +29 -0
  4. package/dist/ConfirmDialog-BSUSUHKJ.js +1 -0
  5. package/dist/{CurrencyConverter-2KRM3NFL.js → CurrencyConverter-N237EF2N.js} +9 -9
  6. package/dist/{Documents-4O7TTUHG.js → Documents-T6L323BV.js} +26 -26
  7. package/dist/{Files-GXDMKGPZ.js → Files-HNE3DY3I.js} +70 -70
  8. package/dist/{Notepad-PGLADU6N.js → Notepad-TLPBE3NP.js} +16 -16
  9. package/dist/PdfViewer-NT3MMNPO.js +1 -0
  10. package/dist/{PomodoroTimer-WLVH3BFM.js → PomodoroTimer-DMP6EY5F.js} +52 -52
  11. package/dist/{Preview-SL4HBPBL.js → Preview-RKQVILVT.js} +57 -57
  12. package/dist/Sidebar-75YOMDJZ.js +44 -0
  13. package/dist/{Spreadsheet-MA5CAMIM.js → Spreadsheet-RN6ROHUK.js} +14 -14
  14. package/dist/{Stock-FCPI7TKU.js → Stock-MC3S66WG.js} +3 -3
  15. package/dist/{Weather-5VWETSF5.js → Weather-UKY7EJO2.js} +17 -17
  16. package/dist/{WorldClock-G7CBN3J2.js → WorldClock-R7MIP7F6.js} +6 -6
  17. package/dist/ai/index.js +21 -21
  18. package/dist/apps/index.js +1 -1
  19. package/dist/bin/ui-check.js +1 -1
  20. package/dist/brand.css +1 -1
  21. package/dist/{chunk-O5MZAN43.js → chunk-2YLR3CWQ.js} +17 -17
  22. package/dist/{chunk-MHGVLZYL.js → chunk-35UBO4T7.js} +3 -3
  23. package/dist/chunk-3IML3Y3Y.js +1 -0
  24. package/dist/{chunk-4G4FU2ML.js → chunk-4A4GD2NL.js} +4 -4
  25. package/dist/{chunk-RWIFSTEK.js → chunk-4RUTVPTH.js} +1 -1
  26. package/dist/{chunk-N5REB25E.js → chunk-4TJ6N5QS.js} +1 -1
  27. package/dist/chunk-5BFEZCIV.js +1039 -0
  28. package/dist/{chunk-UYKGVCZO.js → chunk-7KBOLC6O.js} +1 -1
  29. package/dist/{chunk-UUDDYDSC.js → chunk-AAHMUDUP.js} +2 -2
  30. package/dist/{chunk-TJR6B3YD.js → chunk-BHKRSEVI.js} +1 -1
  31. package/dist/{chunk-BJ47M4AR.js → chunk-BJ4APV4M.js} +1 -1
  32. package/dist/{chunk-KYBZBZEP.js → chunk-BRK2GETX.js} +11 -11
  33. package/dist/{chunk-SMFD6EID.js → chunk-BVFQGLAJ.js} +2 -2
  34. package/dist/{chunk-CICDIRBN.js → chunk-GMZ2J6XQ.js} +1 -1
  35. package/dist/chunk-HQJSOBDE.js +15 -0
  36. package/dist/{chunk-XVHILN6Q.js → chunk-JQ2345TZ.js} +1 -1
  37. package/dist/{chunk-C6IR6W7P.js → chunk-KOBUXTHU.js} +20 -20
  38. package/dist/{chunk-DSSLOQDW.js → chunk-LHHIRTEG.js} +1 -1
  39. package/dist/{chunk-54ZASFCH.js → chunk-LPGG6DRT.js} +51 -51
  40. package/dist/{chunk-TFNELC3A.js → chunk-LW5XF5JD.js} +1 -1
  41. package/dist/{chunk-5THIN3JV.js → chunk-OF7EOZVS.js} +17 -17
  42. package/dist/chunk-QXAPPMUE.js +1 -0
  43. package/dist/{chunk-UCZFCKKS.js → chunk-R2FANVKE.js} +15 -15
  44. package/dist/{chunk-OKPYIQ2Q.js → chunk-R4XNK5UJ.js} +8 -8
  45. package/dist/{chunk-UNBLH4EQ.js → chunk-RFANAC7P.js} +15 -15
  46. package/dist/{chunk-JDS2IFBP.js → chunk-T5J7AFTD.js} +1 -1
  47. package/dist/{chunk-S2PS4IOT.js → chunk-TT6QOFWA.js} +1 -1
  48. package/dist/{chunk-RUBR4GCW.js → chunk-ZOJJB5BQ.js} +7 -7
  49. package/dist/file-intake/index.js +1 -1
  50. package/dist/i18n/index.d.ts +1 -1
  51. package/dist/{index-Ci1RMKEn.d.ts → index-D6mP2zYB.d.ts} +18 -6
  52. package/dist/index.d.ts +3 -3
  53. package/dist/index.js +224 -224
  54. package/dist/locales/zh-Hans.d.ts +1 -1
  55. package/dist/locales/zh-Hans.js +1 -1
  56. package/dist/map/index.js +8 -8
  57. package/dist/page-tabs/index.js +5 -5
  58. package/dist/pdf/index.js +1 -1
  59. package/dist/{strings-mUwozHxH.d.ts → strings-BYsxAKI5.d.ts} +6 -1
  60. package/dist/telemetry/index.js +1 -1
  61. package/dist/ui/index.d.ts +2 -2
  62. package/dist/ui/index.js +1 -1
  63. package/dist/ui.css +1 -1
  64. package/package.json +1 -1
  65. package/dist/Calculator-PWG4G3MY.js +0 -29
  66. package/dist/ConfirmDialog-IZ3NJINY.js +0 -1
  67. package/dist/PdfViewer-EVJRMYTK.js +0 -1
  68. package/dist/Sidebar-EJKBAFU4.js +0 -44
  69. package/dist/chunk-A2MMRPU4.js +0 -1040
  70. package/dist/chunk-I33KGECT.js +0 -5
  71. package/dist/chunk-W7W4JMOT.js +0 -1
  72. package/dist/chunk-YFK4COYT.js +0 -1
@@ -1,8 +1,8 @@
1
- import{toast_default as e}from"./chunk-BJ47M4AR.js";import{useShellStrings as t}from"./chunk-W7W4JMOT.js";import{forwardRef as r,useRef as n,useState as o,useMemo as i,useEffect as a,useImperativeHandle as l}from"react";import{jsx as c,jsxs as s,Fragment as d}from"react/jsx-runtime";var h=["#ef4444","#f97316","#eab308","#22c55e","#3b82f6","#8b5cf6","#000000","#ffffff"],u=[{id:"system",name:"fontSystem",css:"-apple-system, system-ui, sans-serif"},{id:"serif",name:"fontSerif",css:'Georgia, "Times New Roman", serif'},{id:"mono",name:"fontMono",css:'ui-monospace, "SF Mono", Menlo, monospace'},{id:"cursive",name:"fontCursive",css:'"Brush Script MT", "Comic Sans MS", cursive'}],p=()=>Math.random().toString(36).slice(2,9),y=r(function({src:r,filename:y,onApply:m,onCancel:g},N){const L=n(null),z=n(null),D=n(null),P=n(null),$=t().annotator,E=n($);E.current=$;const[W,I]=o("select"),[S,B]=o(h[0]),[R,j]=o(4),[H,T]=o(24),[F,U]=o(u[0].id),[A,O]=o(!0),[K,V]=o(!1),[Z,X]=o(!1),[q,G]=o(null),[J,Y]=o(null),[_,Q]=o(6),[ee,te]=o(12),[re,ne]=o([]),[oe,ie]=o(null),[ae,le]=o(null),[ce,se]=o(null),[de,he]=o(1),[ue,pe]=o(null),[ye,xe]=o(null),[me,ge]=o(null),we=n(null),[fe,be]=o(!1),ve=i(()=>ce?{w:ce.w*de,h:ce.h*de}:null,[ce,de]),ke=ve&&ae?ve.w/ae.w:1,Me=i(()=>re.find(e=>e.id===oe)??null,[re,oe]);a(()=>{"select"===W&&Me&&("color"in Me&&B(Me.color),"stroke"in Me&&j(Me.stroke),"rect"===Me.type&&te(Me.radius),"text"===Me.type&&(T(Me.size),U(Me.font),O(Me.bold),V(Me.italic),X(Me.underline),G(Me.borderColor),Y(Me.background),Q(Me.padding)))},[oe]),a(()=>{const t=new Image;t.crossOrigin="anonymous",t.onload=()=>{P.current=t,le({w:t.naturalWidth,h:t.naturalHeight}),ne([]),ie(null)},t.onerror=()=>e.error(E.current.loadFailed),t.src=r},[r]),a(()=>{if(!ae)return;const e=()=>{const e=L.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=ae.w/ae.h;let i=ae.w,a=ae.h;i>r&&(i=r,a=i/o),a>n&&(a=n,i=a*o),se({w:i,h:a})};e();const t=new ResizeObserver(e);return L.current&&t.observe(L.current),()=>t.disconnect()},[ae]);const Ne=i(()=>re.filter(e=>"mosaic"===e.type),[re]);a(()=>{const e=P.current,t=z.current;if(!e||!t||!ae)return;t.width=ae.w,t.height=ae.h;const r=t.getContext("2d");r.drawImage(e,0,0);for(const e of Ne)C(r,e)},[ae,Ne,ce]);const Ce=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}},Le=e=>{we.current=e,be(!0)};a(()=>{if(!fe)return;const e=e=>{const t=we.current;if(!t)return;const r=Ce(e);if("draw"===t.kind)pe(b(W,t.start,r,S,R,ee));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),pe({id:"",type:"draw",points:t.points.slice(),color:S,stroke:R}))}else if("crop"===t.kind)ge(M(t.start,r));else if("move"===t.kind){const e=r.x-t.start.x,n=r.y-t.start.y;ne(r=>r.map(r=>r.id===t.id?v(t.original,e,n):r))}else"resize"===t.kind&&ne(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,c=i,s=o,d=a;"nw"===t&&(l=r.x,c=r.y);"ne"===t&&(s=r.x,c=r.y);"se"===t&&(s=r.x,d=r.y);"sw"===t&&(l=r.x,d=r.y);const h=M({x:l,y:c},{x:s,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=we.current;if(we.current=null,be(!1),"draw"===e?.kind)pe(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:p()};return ne(e=>[...e,r]),ie(r.id),I("select"),null});else if("pen"===e?.kind){if(e.points.length<2)return void pe(null);const t={id:p(),type:"draw",points:e.points,color:S,stroke:R};ne(e=>[...e,t]),ie(t.id),I("select"),pe(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)}},[fe,W,S,R,ee]);a(()=>{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(oe&&("Delete"===e.key||"Backspace"===e.key?(e.preventDefault(),ne(e=>e.filter(e=>e.id!==oe)),ie(null)):"Escape"===e.key&&ie(null))):(e.preventDefault(),ne(e=>e.slice(0,-1)),void ie(null))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[oe]);const ze=e=>{const t=!{bold:A,italic:K,underline:Z}[e];"bold"===e&&O(t),"italic"===e&&V(t),"underline"===e&&X(t),oe&&ne(r=>r.map(r=>r.id===oe&&"text"===r.type?{...r,[e]:t}:r))},De=e=>{G(e),oe&&ne(t=>t.map(t=>t.id===oe&&"text"===t.type?{...t,borderColor:e}:t))},Pe=e=>{Y(e),oe&&ne(t=>t.map(t=>t.id===oe&&"text"===t.type?{...t,background:e}:t))},$e=e=>{if(!ye)return;const t=e??ye.value;if(!t.trim())return ye.editingId&&ne(e=>e.filter(e=>e.id!==ye.editingId)),void xe(null);if(ye.editingId)ne(e=>e.map(e=>e.id===ye.editingId&&"text"===e.type?{...e,text:t}:e));else{const e={id:p(),type:"text",x:ye.x,y:ye.y,text:t,color:S,size:H,font:F,bold:A,italic:K,underline:Z,borderColor:q,background:J,padding:_};ne(t=>[...t,e]),ie(e.id),I("select")}xe(null)},Ee=async()=>{const e=z.current,t=D.current;if(!e||!t||!ae)return null;const r=document.createElement("canvas");r.width=ae.w,r.height=ae.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),c=new Image;return await new Promise(e=>{c.onload=()=>e(),c.onerror=()=>e(),c.src=l}),n.drawImage(c,0,0,ae.w,ae.h),URL.revokeObjectURL(l),r};l(N,()=>({save:async()=>{const t=await Ee();t&&t.toBlob(t=>{if(!t)return void e.error(E.current.exportFailed);const r=URL.createObjectURL(t),n=document.createElement("a");n.href=r;const o=y.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(E.current.clipboardUnsupported);const t=await Ee();t&&t.toBlob(async t=>{if(t)try{await navigator.clipboard.write([new ClipboardItem({"image/png":t})]),e.success(E.current.copied)}catch{e.error(E.current.copyRefused)}else e.error(E.current.copyFailed)},"image/png")}}),[ae,y]);const We=i(()=>[{id:"select",label:$.toolSelect,icon:/* @__PURE__ */c("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */c("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 3l7 17 2-7 7-2L5 3z"})})},{id:"draw",label:$.toolDraw,icon:/* @__PURE__ */c("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */c("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:$.toolRect,icon:/* @__PURE__ */c("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */c("rect",{x:"4",y:"6",width:"16",height:"12",rx:"3"})})},{id:"circle",label:$.toolEllipse,icon:/* @__PURE__ */c("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */c("ellipse",{cx:"12",cy:"12",rx:"8",ry:"6"})})},{id:"arrow",label:$.toolArrow,icon:/* @__PURE__ */c("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */c("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 19L19 5m0 0h-7m7 0v7"})})},{id:"mosaic",label:$.toolMosaic,icon:/* @__PURE__ */c("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */c("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 4h6v6H4zM14 4h6v6h-6zM4 14h6v6H4zM14 14h6v6h-6z"})})},{id:"text",label:$.toolText,icon:/* @__PURE__ */c("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */c("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 6h16M12 6v14M9 20h6"})})},{id:"crop",label:$.toolCrop,icon:/* @__PURE__ */c("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */c("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 2v15a1 1 0 001 1h15M2 6h15a1 1 0 011 1v15"})})}],[$]),Ie=e=>"p-2 rounded transition-colors "+(e?"bg-blue-500 text-white":"text-gray-700 hover:bg-gray-200"),Se=Me?.type??("select"===W?null:W),Be="rect"===Se||"circle"===Se||"arrow"===Se||"draw"===Se,Re="rect"===Se,je="text"===Se;/* @__PURE__ */
1
+ import{toast_default as e}from"./chunk-BJ4APV4M.js";import{useShellStrings as t}from"./chunk-3IML3Y3Y.js";import{forwardRef as r,useRef as n,useState as o,useMemo as i,useEffect as a,useImperativeHandle as l}from"react";import{jsx as c,jsxs as s,Fragment as d}from"react/jsx-runtime";var h=["#ef4444","#f97316","#eab308","#22c55e","#3b82f6","#8b5cf6","#000000","#ffffff"],u=[{id:"system",name:"fontSystem",css:"-apple-system, system-ui, sans-serif"},{id:"serif",name:"fontSerif",css:'Georgia, "Times New Roman", serif'},{id:"mono",name:"fontMono",css:'ui-monospace, "SF Mono", Menlo, monospace'},{id:"cursive",name:"fontCursive",css:'"Brush Script MT", "Comic Sans MS", cursive'}],p=()=>Math.random().toString(36).slice(2,9),y=r(function({src:r,filename:y,onApply:m,onCancel:g},N){const L=n(null),z=n(null),D=n(null),P=n(null),$=t().annotator,E=n($);E.current=$;const[I,S]=o("select"),[W,B]=o(h[0]),[R,j]=o(4),[H,F]=o(24),[T,U]=o(u[0].id),[A,O]=o(!0),[K,V]=o(!1),[Y,Z]=o(!1),[X,q]=o(null),[G,_]=o(null),[J,Q]=o(6),[ee,te]=o(12),[re,ne]=o([]),[oe,ie]=o(null),[ae,le]=o(null),[ce,se]=o(null),[de,he]=o(1),[ue,pe]=o(null),[ye,xe]=o(null),[me,ge]=o(null),we=n(null),[fe,be]=o(!1),ve=i(()=>ce?{w:ce.w*de,h:ce.h*de}:null,[ce,de]),ke=ve&&ae?ve.w/ae.w:1,Me=i(()=>re.find(e=>e.id===oe)??null,[re,oe]);a(()=>{"select"===I&&Me&&("color"in Me&&B(Me.color),"stroke"in Me&&j(Me.stroke),"rect"===Me.type&&te(Me.radius),"text"===Me.type&&(F(Me.size),U(Me.font),O(Me.bold),V(Me.italic),Z(Me.underline),q(Me.borderColor),_(Me.background),Q(Me.padding)))},[oe]),a(()=>{const t=new Image;t.crossOrigin="anonymous",t.onload=()=>{P.current=t,le({w:t.naturalWidth,h:t.naturalHeight}),ne([]),ie(null)},t.onerror=()=>e.error(E.current.loadFailed),t.src=r},[r]),a(()=>{if(!ae)return;const e=()=>{const e=L.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=ae.w/ae.h;let i=ae.w,a=ae.h;i>r&&(i=r,a=i/o),a>n&&(a=n,i=a*o),se({w:i,h:a})};e();const t=new ResizeObserver(e);return L.current&&t.observe(L.current),()=>t.disconnect()},[ae]);const Ne=i(()=>re.filter(e=>"mosaic"===e.type),[re]);a(()=>{const e=P.current,t=z.current;if(!e||!t||!ae)return;t.width=ae.w,t.height=ae.h;const r=t.getContext("2d");r.drawImage(e,0,0);for(const e of Ne)C(r,e)},[ae,Ne,ce]);const Ce=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}},Le=e=>{we.current=e,be(!0)};a(()=>{if(!fe)return;const e=e=>{const t=we.current;if(!t)return;const r=Ce(e);if("draw"===t.kind)pe(b(I,t.start,r,W,R,ee));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),pe({id:"",type:"draw",points:t.points.slice(),color:W,stroke:R}))}else if("crop"===t.kind)ge(M(t.start,r));else if("move"===t.kind){const e=r.x-t.start.x,n=r.y-t.start.y;ne(r=>r.map(r=>r.id===t.id?v(t.original,e,n):r))}else"resize"===t.kind&&ne(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,c=i,s=o,d=a;"nw"===t&&(l=r.x,c=r.y);"ne"===t&&(s=r.x,c=r.y);"se"===t&&(s=r.x,d=r.y);"sw"===t&&(l=r.x,d=r.y);const h=M({x:l,y:c},{x:s,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=we.current;if(we.current=null,be(!1),"draw"===e?.kind)pe(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:p()};return ne(e=>[...e,r]),ie(r.id),S("select"),null});else if("pen"===e?.kind){if(e.points.length<2)return void pe(null);const t={id:p(),type:"draw",points:e.points,color:W,stroke:R};ne(e=>[...e,t]),ie(t.id),S("select"),pe(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)}},[fe,I,W,R,ee]);a(()=>{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(oe&&("Delete"===e.key||"Backspace"===e.key?(e.preventDefault(),ne(e=>e.filter(e=>e.id!==oe)),ie(null)):"Escape"===e.key&&ie(null))):(e.preventDefault(),ne(e=>e.slice(0,-1)),void ie(null))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[oe]);const ze=e=>{const t=!{bold:A,italic:K,underline:Y}[e];"bold"===e&&O(t),"italic"===e&&V(t),"underline"===e&&Z(t),oe&&ne(r=>r.map(r=>r.id===oe&&"text"===r.type?{...r,[e]:t}:r))},De=e=>{q(e),oe&&ne(t=>t.map(t=>t.id===oe&&"text"===t.type?{...t,borderColor:e}:t))},Pe=e=>{_(e),oe&&ne(t=>t.map(t=>t.id===oe&&"text"===t.type?{...t,background:e}:t))},$e=e=>{if(!ye)return;const t=e??ye.value;if(!t.trim())return ye.editingId&&ne(e=>e.filter(e=>e.id!==ye.editingId)),void xe(null);if(ye.editingId)ne(e=>e.map(e=>e.id===ye.editingId&&"text"===e.type?{...e,text:t}:e));else{const e={id:p(),type:"text",x:ye.x,y:ye.y,text:t,color:W,size:H,font:T,bold:A,italic:K,underline:Y,borderColor:X,background:G,padding:J};ne(t=>[...t,e]),ie(e.id),S("select")}xe(null)},Ee=async()=>{const e=z.current,t=D.current;if(!e||!t||!ae)return null;const r=document.createElement("canvas");r.width=ae.w,r.height=ae.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),c=new Image;return await new Promise(e=>{c.onload=()=>e(),c.onerror=()=>e(),c.src=l}),n.drawImage(c,0,0,ae.w,ae.h),URL.revokeObjectURL(l),r};l(N,()=>({save:async()=>{const t=await Ee();t&&t.toBlob(t=>{if(!t)return void e.error(E.current.exportFailed);const r=URL.createObjectURL(t),n=document.createElement("a");n.href=r;const o=y.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(E.current.clipboardUnsupported);const t=await Ee();t&&t.toBlob(async t=>{if(t)try{await navigator.clipboard.write([new ClipboardItem({"image/png":t})]),e.success(E.current.copied)}catch{e.error(E.current.copyRefused)}else e.error(E.current.copyFailed)},"image/png")}}),[ae,y]);const Ie=i(()=>[{id:"select",label:$.toolSelect,icon:/* @__PURE__ */c("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */c("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 3l7 17 2-7 7-2L5 3z"})})},{id:"draw",label:$.toolDraw,icon:/* @__PURE__ */c("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */c("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:$.toolRect,icon:/* @__PURE__ */c("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */c("rect",{x:"4",y:"6",width:"16",height:"12",rx:"3"})})},{id:"circle",label:$.toolEllipse,icon:/* @__PURE__ */c("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */c("ellipse",{cx:"12",cy:"12",rx:"8",ry:"6"})})},{id:"arrow",label:$.toolArrow,icon:/* @__PURE__ */c("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */c("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 19L19 5m0 0h-7m7 0v7"})})},{id:"mosaic",label:$.toolMosaic,icon:/* @__PURE__ */c("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */c("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 4h6v6H4zM14 4h6v6h-6zM4 14h6v6H4zM14 14h6v6h-6z"})})},{id:"text",label:$.toolText,icon:/* @__PURE__ */c("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */c("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 6h16M12 6v14M9 20h6"})})},{id:"crop",label:$.toolCrop,icon:/* @__PURE__ */c("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */c("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 2v15a1 1 0 001 1h15M2 6h15a1 1 0 011 1v15"})})}],[$]),Se=e=>"p-2 rounded transition-colors "+(e?"bg-blue-500 text-white":"text-gray-700 hover:bg-gray-200"),We=Me?.type??("select"===I?null:I),Be="rect"===We||"circle"===We||"arrow"===We||"draw"===We,Re="rect"===We,je="text"===We;/* @__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-2 px-3 py-2 border-b border-gray-200 bg-white shrink-0 flex-wrap text-xs",children:[We.map(e=>/* @__PURE__ */c("button",{onClick:()=>{I(e.id),ie(null)},title:e.label,className:Ie(W===e.id),children:e.icon},e.id)),
3
+ /* @__PURE__ */s("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-gray-200 bg-white shrink-0 flex-wrap text-xs",children:[Ie.map(e=>/* @__PURE__ */c("button",{onClick:()=>{S(e.id),ie(null)},title:e.label,className:Se(I===e.id),children:e.icon},e.id)),
4
4
  /* @__PURE__ */c("div",{className:"h-5 w-px bg-gray-300 mx-1"}),
5
- /* @__PURE__ */c("div",{className:"flex items-center gap-1",children:h.map(e=>/* @__PURE__ */c("button",{onClick:()=>(e=>{B(e),oe&&ne(t=>t.map(t=>t.id!==oe||"mosaic"===t.type?t:{...t,color:e}))})(e),title:e,className:"h-5 w-5 rounded-full border "+(S===e?"ring-2 ring-blue-500 ring-offset-1":"border-gray-300"),style:{background:e}},e))}),Be&&/* @__PURE__ */s(d,{children:[
5
+ /* @__PURE__ */c("div",{className:"flex items-center gap-1",children:h.map(e=>/* @__PURE__ */c("button",{onClick:()=>(e=>{B(e),oe&&ne(t=>t.map(t=>t.id!==oe||"mosaic"===t.type?t:{...t,color:e}))})(e),title:e,className:"h-5 w-5 rounded-full border "+(W===e?"ring-2 ring-blue-500 ring-offset-1":"border-gray-300"),style:{background:e}},e))}),Be&&/* @__PURE__ */s(d,{children:[
6
6
  /* @__PURE__ */c("div",{className:"h-5 w-px bg-gray-300 mx-1"}),
7
7
  /* @__PURE__ */s("label",{className:"flex items-center gap-2 text-gray-600",children:[
8
8
  /* @__PURE__ */c("span",{children:$.weight}),
@@ -14,26 +14,26 @@ return s("div",{className:"flex flex-col h-full bg-gray-100",children:[
14
14
  /* @__PURE__ */c("input",{type:"range",min:0,max:48,step:1,value:ee,onChange:e=>{return t=Number(e.target.value),te(t),void(oe&&ne(e=>e.map(e=>e.id===oe&&"rect"===e.type?{...e,radius:t}:e)));var t},className:"w-16 accent-blue-500"}),
15
15
  /* @__PURE__ */c("span",{className:"tabular-nums w-6 text-right",children:ee})]})]}),je&&/* @__PURE__ */s(d,{children:[
16
16
  /* @__PURE__ */c("div",{className:"h-5 w-px bg-gray-300 mx-1"}),
17
- /* @__PURE__ */c("select",{value:F,onChange:e=>{return t=e.target.value,U(t),void(oe&&ne(e=>e.map(e=>e.id===oe&&"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:u.map(e=>/* @__PURE__ */c("option",{value:e.id,children:$[e.name]},e.id))}),
18
- /* @__PURE__ */c("button",{onClick:()=>ze("bold"),className:Ie(A),title:$.bold,children:/* @__PURE__ */c("span",{className:"font-bold",children:$.boldLetter})}),
19
- /* @__PURE__ */c("button",{onClick:()=>ze("italic"),className:Ie(K),title:$.italic,children:/* @__PURE__ */c("span",{className:"italic",children:$.italicLetter})}),
20
- /* @__PURE__ */c("button",{onClick:()=>ze("underline"),className:Ie(Z),title:$.underline,children:/* @__PURE__ */c("span",{className:"underline",children:$.underlineLetter})}),
17
+ /* @__PURE__ */c("select",{value:T,onChange:e=>{return t=e.target.value,U(t),void(oe&&ne(e=>e.map(e=>e.id===oe&&"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:u.map(e=>/* @__PURE__ */c("option",{value:e.id,children:$[e.name]},e.id))}),
18
+ /* @__PURE__ */c("button",{onClick:()=>ze("bold"),className:Se(A),title:$.bold,children:/* @__PURE__ */c("span",{className:"font-bold",children:$.boldLetter})}),
19
+ /* @__PURE__ */c("button",{onClick:()=>ze("italic"),className:Se(K),title:$.italic,children:/* @__PURE__ */c("span",{className:"italic",children:$.italicLetter})}),
20
+ /* @__PURE__ */c("button",{onClick:()=>ze("underline"),className:Se(Y),title:$.underline,children:/* @__PURE__ */c("span",{className:"underline",children:$.underlineLetter})}),
21
21
  /* @__PURE__ */s("label",{className:"flex items-center gap-2 text-gray-600",children:[
22
22
  /* @__PURE__ */c("span",{children:$.size}),
23
- /* @__PURE__ */c("input",{type:"range",min:10,max:96,step:1,value:H,onChange:e=>{return t=Number(e.target.value),T(t),void(oe&&ne(e=>e.map(e=>e.id===oe&&"text"===e.type?{...e,size:t}:e)));var t},className:"w-16 accent-blue-500"}),
23
+ /* @__PURE__ */c("input",{type:"range",min:10,max:96,step:1,value:H,onChange:e=>{return t=Number(e.target.value),F(t),void(oe&&ne(e=>e.map(e=>e.id===oe&&"text"===e.type?{...e,size:t}:e)));var t},className:"w-16 accent-blue-500"}),
24
24
  /* @__PURE__ */c("span",{className:"tabular-nums w-7 text-right",children:H})]}),
25
25
  /* @__PURE__ */s("label",{className:"flex items-center gap-1 text-gray-600",children:[
26
- /* @__PURE__ */c("span",{children:$.border}),q?/* @__PURE__ */s(d,{children:[
27
- /* @__PURE__ */c("input",{type:"color",value:q,onChange:e=>De(e.target.value),title:$.borderColor,className:"h-5 w-6 rounded border border-gray-300 bg-white p-0 cursor-pointer"}),
28
- /* @__PURE__ */c("button",{onClick:()=>De(null),title:$.removeBorder,className:"px-0.5 text-gray-400 hover:text-gray-700",children:"✕"})]}):/* @__PURE__ */c("button",{onClick:()=>De(S),title:$.addBorder,className:"px-2 py-0.5 rounded border border-gray-300 text-gray-600 hover:bg-gray-100",children:$.add})]}),
26
+ /* @__PURE__ */c("span",{children:$.border}),X?/* @__PURE__ */s(d,{children:[
27
+ /* @__PURE__ */c("input",{type:"color",value:X,onChange:e=>De(e.target.value),title:$.borderColor,className:"h-5 w-6 rounded border border-gray-300 bg-white p-0 cursor-pointer"}),
28
+ /* @__PURE__ */c("button",{onClick:()=>De(null),title:$.removeBorder,className:"px-0.5 text-gray-400 hover:text-gray-700",children:"✕"})]}):/* @__PURE__ */c("button",{onClick:()=>De(W),title:$.addBorder,className:"px-2 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
- /* @__PURE__ */c("span",{children:$.fill}),J?/* @__PURE__ */s(d,{children:[
31
- /* @__PURE__ */c("input",{type:"color",value:J,onChange:e=>Pe(e.target.value),title:$.fillColor,className:"h-5 w-6 rounded border border-gray-300 bg-white p-0 cursor-pointer"}),
30
+ /* @__PURE__ */c("span",{children:$.fill}),G?/* @__PURE__ */s(d,{children:[
31
+ /* @__PURE__ */c("input",{type:"color",value:G,onChange:e=>Pe(e.target.value),title:$.fillColor,className:"h-5 w-6 rounded border border-gray-300 bg-white p-0 cursor-pointer"}),
32
32
  /* @__PURE__ */c("button",{onClick:()=>Pe(null),title:$.removeFill,className:"px-0.5 text-gray-400 hover:text-gray-700",children:"✕"})]}):/* @__PURE__ */c("button",{onClick:()=>Pe("#ffffff"),title:$.addFill,className:"px-2 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-2 text-gray-600",children:[
34
34
  /* @__PURE__ */c("span",{children:$.padding}),
35
- /* @__PURE__ */c("input",{type:"range",min:0,max:40,step:1,value:_,onChange:e=>{return t=Number(e.target.value),Q(t),void(oe&&ne(e=>e.map(e=>e.id===oe&&"text"===e.type?{...e,padding:t}:e)));var t},className:"w-14 accent-blue-500"}),
36
- /* @__PURE__ */c("span",{className:"tabular-nums w-6 text-right",children:_})]})]}),
35
+ /* @__PURE__ */c("input",{type:"range",min:0,max:40,step:1,value:J,onChange:e=>{return t=Number(e.target.value),Q(t),void(oe&&ne(e=>e.map(e=>e.id===oe&&"text"===e.type?{...e,padding:t}:e)));var t},className:"w-14 accent-blue-500"}),
36
+ /* @__PURE__ */c("span",{className:"tabular-nums w-6 text-right",children:J})]})]}),
37
37
  /* @__PURE__ */c("div",{className:"h-5 w-px bg-gray-300 mx-1"}),
38
38
  /* @__PURE__ */c("button",{onClick:()=>he(e=>Math.max(.25,Math.round(100*(e-.25))/100)),className:"px-2 py-1 rounded hover:bg-gray-200 text-gray-700",title:$.zoomOut,children:"−"}),
39
39
  /* @__PURE__ */s("span",{className:"text-gray-600 tabular-nums w-10 text-center",children:[Math.round(100*de),"%"]}),
@@ -47,8 +47,8 @@ return s("div",{className:"flex flex-col h-full bg-gray-100",children:[
47
47
  /* @__PURE__ */c("button",{onClick:async()=>{const t=await Ee();t?t.toBlob(t=>{t?m(t):e.error(E.current.exportFailed)},"image/png"):e.error(E.current.exportFailed)},className:"px-3 py-1 rounded bg-blue-500 text-white hover:bg-blue-600 text-xs font-medium",children:$.apply})]})]})]}),
48
48
  /* @__PURE__ */c("div",{ref:L,className:"flex-1 overflow-auto bg-gray-200 flex items-center justify-center p-4 relative",children:ve&&ae&&/* @__PURE__ */s("div",{className:"relative shadow-lg rounded overflow-hidden bg-white shrink-0",style:{width:ve.w,height:ve.h},children:[
49
49
  /* @__PURE__ */c("canvas",{ref:z,style:{position:"absolute",inset:0,width:"100%",height:"100%",display:"block"}}),
50
- /* @__PURE__ */s("svg",{ref:D,viewBox:`0 0 ${ae.w} ${ae.h}`,preserveAspectRatio:"none",style:{position:"absolute",inset:0,width:"100%",height:"100%",touchAction:"none",cursor:"select"===W?"default":"text"===W?"text":"crosshair"},onPointerDown:e=>{if("select"===W)return void ie(null);if("text"===W){if(ye)return void $e();const t=Ce(e);return void xe({x:t.x,y:t.y,value:""})}const t=Ce(e);if("crop"!==W){if("draw"===W)return Le({kind:"pen",points:[t]}),void pe({id:"",type:"draw",points:[t],color:S,stroke:R});pe(b(W,t,t,S,R,ee)),Le({kind:"draw",start:t})}else Le({kind:"crop",start:t})},children:[re.map(e=>/* @__PURE__ */c(x,{anno:e,selected:oe===e.id,zoom:de,onPointerDown:t=>((e,t)=>{"select"===W&&(e.stopPropagation(),ie(t.id),Le({kind:"move",id:t.id,start:Ce(e),original:t}))})(t,e),onDoubleClick:()=>{var t;"text"===(t=e).type&&xe({x:t.x,y:t.y,value:t.text,editingId:t.id})},onHandlePointerDown:(t,r)=>((e,t,r)=>{e.stopPropagation(),Le({kind:"resize",id:t.id,corner:r,start:Ce(e),original:t})})(t,e,r)},e.id)),ue&&/* @__PURE__ */c(x,{anno:{...ue,id:"__preview"},preview:!0}),me&&/* @__PURE__ */c(w,{rect:me,imageSize:ae})]}),ye&&/* @__PURE__ */c(f,{pendingText:ye,color:S,size:H,font:u.find(e=>e.id===F)?.css??u[0].css,bold:A,italic:K,underline:Z,borderColor:q,background:J,padding:_,scale:ke,onChange:e=>xe({...ye,value:e}),onCommit:$e,onCancel:()=>xe(null)})]})}),
51
- /* @__PURE__ */c("div",{className:"px-3 py-2 border-t border-gray-200 bg-white text-2xs text-gray-500 shrink-0",children:"select"===W?oe?$.hintSelected:$.hintSelect:"text"===W?$.hintText:"crop"===W?$.hintCrop:"draw"===W?$.hintDraw:$.hintShape})]})});function x({anno:e,selected:t,preview:r,zoom:n=1,onPointerDown:o,onDoubleClick:i,onHandlePointerDown:a}){const l=k(e),h=o?{onPointerDown:o,pointerEvents:"all",style:{cursor:"move"}}:{},p=i?{onDoubleClick:i}:{};let y;if("rect"===e.type)y=/* @__PURE__ */c("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",...h});else if("circle"===e.type)y=/* @__PURE__ */c("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,...h});else if("arrow"===e.type)y=/* @__PURE__ */c(g,{anno:e,interactive:h});else if("draw"===e.type)y=/* @__PURE__ */c("path",{d:N(e.points),fill:"none",stroke:e.color,strokeWidth:e.stroke,strokeLinecap:"round",strokeLinejoin:"round",...h});else if("mosaic"===e.type)y=/* @__PURE__ */c("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,...h});else{const t=u.find(t=>t.id===e.font)?.css??u[0].css,r=e.padding??0,n=!!e.borderColor||!!e.background,o=k(e),i=e.borderColor?Math.max(1,Math.round(e.size/12)):0;y=/* @__PURE__ */s("g",{...h,...p,children:[n&&/* @__PURE__ */c("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 ${ae.w} ${ae.h}`,preserveAspectRatio:"none",style:{position:"absolute",inset:0,width:"100%",height:"100%",touchAction:"none",cursor:"select"===I?"default":"text"===I?"text":"crosshair"},onPointerDown:e=>{if("select"===I)return void ie(null);if("text"===I){if(ye)return void $e();const t=Ce(e);return void xe({x:t.x,y:t.y,value:""})}const t=Ce(e);if("crop"!==I){if("draw"===I)return Le({kind:"pen",points:[t]}),void pe({id:"",type:"draw",points:[t],color:W,stroke:R});pe(b(I,t,t,W,R,ee)),Le({kind:"draw",start:t})}else Le({kind:"crop",start:t})},children:[re.map(e=>/* @__PURE__ */c(x,{anno:e,selected:oe===e.id,zoom:de,onPointerDown:t=>((e,t)=>{"select"===I&&(e.stopPropagation(),ie(t.id),Le({kind:"move",id:t.id,start:Ce(e),original:t}))})(t,e),onDoubleClick:()=>{var t;"text"===(t=e).type&&xe({x:t.x,y:t.y,value:t.text,editingId:t.id})},onHandlePointerDown:(t,r)=>((e,t,r)=>{e.stopPropagation(),Le({kind:"resize",id:t.id,corner:r,start:Ce(e),original:t})})(t,e,r)},e.id)),ue&&/* @__PURE__ */c(x,{anno:{...ue,id:"__preview"},preview:!0}),me&&/* @__PURE__ */c(w,{rect:me,imageSize:ae})]}),ye&&/* @__PURE__ */c(f,{pendingText:ye,color:W,size:H,font:u.find(e=>e.id===T)?.css??u[0].css,bold:A,italic:K,underline:Y,borderColor:X,background:G,padding:J,scale:ke,onChange:e=>xe({...ye,value:e}),onCommit:$e,onCancel:()=>xe(null)})]})}),
51
+ /* @__PURE__ */c("div",{className:"px-3 py-2 border-t border-gray-200 bg-white text-2xs text-gray-500 shrink-0",children:"select"===I?oe?$.hintSelected:$.hintSelect:"text"===I?$.hintText:"crop"===I?$.hintCrop:"draw"===I?$.hintDraw:$.hintShape})]})});function x({anno:e,selected:t,preview:r,zoom:n=1,onPointerDown:o,onDoubleClick:i,onHandlePointerDown:a}){const l=k(e),h=o?{onPointerDown:o,pointerEvents:"all",style:{cursor:"move"}}:{},p=i?{onDoubleClick:i}:{};let y;if("rect"===e.type)y=/* @__PURE__ */c("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",...h});else if("circle"===e.type)y=/* @__PURE__ */c("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,...h});else if("arrow"===e.type)y=/* @__PURE__ */c(g,{anno:e,interactive:h});else if("draw"===e.type)y=/* @__PURE__ */c("path",{d:N(e.points),fill:"none",stroke:e.color,strokeWidth:e.stroke,strokeLinecap:"round",strokeLinejoin:"round",...h});else if("mosaic"===e.type)y=/* @__PURE__ */c("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,...h});else{const t=u.find(t=>t.id===e.font)?.css??u[0].css,r=e.padding??0,n=!!e.borderColor||!!e.background,o=k(e),i=e.borderColor?Math.max(1,Math.round(e.size/12)):0;y=/* @__PURE__ */s("g",{...h,...p,children:[n&&/* @__PURE__ */c("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__ */c("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__ */c("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(d,{children:[
54
54
  /* @__PURE__ */c("rect",{"data-chrome":"selection",x:l.x-4,y:l.y-4,width:l.w+8,height:l.h+8,fill:"none",stroke:"#3b82f6",strokeWidth:2/n,strokeDasharray:`${6/n},${4/n}`,pointerEvents:"none"}),a&&/* @__PURE__ */c(m,{anno:e,zoom:n,onHandlePointerDown:a})]})]})}function m({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__ */
@@ -0,0 +1 @@
1
+ var r="7.64.0",a=r;export{a as APP_VERSION,r as VERSION};
@@ -1,23 +1,23 @@
1
- import{toast_default as e}from"./chunk-BJ47M4AR.js";import{Icon as t}from"./chunk-76DRQSJM.js";import{useShellStrings as n}from"./chunk-W7W4JMOT.js";import{LoadingSpinner as r}from"./chunk-2J6F4EE7.js";import{createContext as a,useContext as o,useRef as i,useState as s,useEffect as l}from"react";import*as c from"pdfjs-dist";import{createPortal as d}from"react-dom";import{jsx as u,jsxs as m}from"react/jsx-runtime";function h(e,t,n){return new Error(`The response for ${e} is not a WebAssembly module (got ${function(e){if(0===e.length)return"an empty response";const t=Array.from(e.subarray(0,24)).map(e=>e>=32&&e<127?String.fromCharCode(e):".").join("");return`${e.length} bytes starting "${t}"`}(n)}). The bundler did not emit "${t}" as an asset, and the host answered with a fallback page instead of a 404. Serve pdfjs-dist/wasm/ yourself and point window.__REACT_OS_SHELL_PDF_WASM__ at it.`)}var p=a(null);function f({children:e}){const t=o(p);return t?d(e,t):
2
- /* @__PURE__ */u("div",{className:"flex shrink-0 flex-wrap items-center gap-1 border-b border-gray-200 bg-gray-50 px-3 py-2 text-xs",children:e})}"undefined"==typeof window||c.GlobalWorkerOptions.workerSrc||(c.GlobalWorkerOptions.workerSrc=`https://unpkg.com/pdfjs-dist@${c.version}/build/pdf.worker.min.mjs`);var g={"jbig2.wasm":new URL("pdfjs-dist/wasm/jbig2.wasm",import.meta.url).href,"openjpeg.wasm":new URL("pdfjs-dist/wasm/openjpeg.wasm",import.meta.url).href},w=class{async fetch({kind:e,filename:t}){if("wasmUrl"!==e)throw new Error(`Ensure that the \`${e}\` API parameter is provided.`);const n=g[t];if(!n)throw new Error(`No bundled pdf.js wasm module for "${t}".`);const r=await fetch(n);if(!r.ok)throw new Error(`Unable to load wasm data at: ${n}`);const a=new Uint8Array(await r.arrayBuffer());if(!function(e){return e.length>=4&&0===e[0]&&97===e[1]&&115===e[2]&&109===e[3]}(a))throw h(n,t,a);return a}};function y(e){const t=e||("undefined"!=typeof window?window.__REACT_OS_SHELL_PDF_WASM__:void 0);return"string"==typeof t&&t?{wasmUrl:t.endsWith("/")?t:`${t}/`}:{BinaryDataFactory:w}}var v=[50,75,100,125,150,200,300,400];function b(e,t,n){const r=(t.width-40)/n.width,a="page"===e?Math.min(r,(t.height-40)/n.height):r;return Math.min(Math.max(a,.3),4)}function x({url:a,filename:o,fit:d="width",onDownload:h,onEmail:p,workerSrc:g,wasmUrl:w}){const x=n().pdf,k=i(null),C=i(null),N=i(null),[M,j]=s(null),[E,z]=s(1),[W,_]=s(0),[D,P]=s(1),[S,L]=s(!0),[T,$]=s(!0),A=i(x.loadFailed);A.current=x.loadFailed,l(()=>{let t=!1;return $(!0),z(1),g&&(c.GlobalWorkerOptions.workerSrc=g),c.getDocument({url:a,...y(w)}).promise.then(e=>{t||(j(e),_(e.numPages),$(!1))}).catch(()=>{t||(e.error(A.current),$(!1))}),()=>{t=!0}},[a,g,w]),l(()=>{if(!M||!S||!N.current)return;const e=()=>{const e=N.current;e&&M.getPage(E).then(t=>{if(!N.current)return;const n=t.getViewport({scale:1}),r=b(d,{width:e.clientWidth,height:e.clientHeight},{width:n.width,height:n.height});P(e=>Math.abs(e-r)<.005?e:r)})};e();const t=new ResizeObserver(e);return t.observe(N.current),()=>t.disconnect()},[M,E,S,d]),l(()=>{if(!M||!k.current)return;let e=!1,t=null,n=null;return M.getPage(E).then(r=>{if(e||!k.current)return;const a=r.getViewport({scale:D}),o=k.current;o.width=a.width,o.height=a.height,o.style.width=`${a.width}px`,o.style.height=`${a.height}px`;const i=o.getContext("2d");t=r.render({canvas:o,canvasContext:i,viewport:a}),t.promise.catch(()=>{});const s=C.current;s&&(s.replaceChildren(),s.style.setProperty("--total-scale-factor",String(a.scale)),n=new c.TextLayer({textContentSource:r.streamTextContent(),container:s,viewport:a}),n.render().then(()=>{if(e)return;const t=document.createElement("div");t.className="endOfContent",s.append(t)}).catch(()=>{}))}),()=>{e=!0,t?.cancel(),n?.cancel()}},[M,E,D]),l(()=>{const e=()=>C.current?.classList.remove("selecting");return window.addEventListener("pointerup",e),()=>window.removeEventListener("pointerup",e)},[]);const O="page"===d?x.fitPage:x.fitWidth,R="px-2 py-1 rounded hover:bg-gray-200 transition-colors text-gray-600 flex items-center gap-1";/* @__PURE__ */
1
+ import{toast_default as e}from"./chunk-BJ4APV4M.js";import{useShellStrings as t}from"./chunk-3IML3Y3Y.js";import{LoadingSpinner as n}from"./chunk-2J6F4EE7.js";import{Icon as r}from"./chunk-76DRQSJM.js";import{createContext as a,useContext as o,useRef as i,useState as s,useEffect as l}from"react";import*as c from"pdfjs-dist";import{createPortal as d}from"react-dom";import{jsx as u,jsxs as m}from"react/jsx-runtime";function h(e,t,n){return new Error(`The response for ${e} is not a WebAssembly module (got ${function(e){if(0===e.length)return"an empty response";const t=Array.from(e.subarray(0,24)).map(e=>e>=32&&e<127?String.fromCharCode(e):".").join("");return`${e.length} bytes starting "${t}"`}(n)}). The bundler did not emit "${t}" as an asset, and the host answered with a fallback page instead of a 404. Serve pdfjs-dist/wasm/ yourself and point window.__REACT_OS_SHELL_PDF_WASM__ at it.`)}var p=a(null);function f({children:e}){const t=o(p);return t?d(e,t):
2
+ /* @__PURE__ */u("div",{className:"flex shrink-0 flex-wrap items-center gap-1 border-b border-gray-200 bg-gray-50 px-3 py-2 text-xs",children:e})}"undefined"==typeof window||c.GlobalWorkerOptions.workerSrc||(c.GlobalWorkerOptions.workerSrc=`https://unpkg.com/pdfjs-dist@${c.version}/build/pdf.worker.min.mjs`);var g={"jbig2.wasm":new URL("pdfjs-dist/wasm/jbig2.wasm",import.meta.url).href,"openjpeg.wasm":new URL("pdfjs-dist/wasm/openjpeg.wasm",import.meta.url).href},w=class{async fetch({kind:e,filename:t}){if("wasmUrl"!==e)throw new Error(`Ensure that the \`${e}\` API parameter is provided.`);const n=g[t];if(!n)throw new Error(`No bundled pdf.js wasm module for "${t}".`);const r=await fetch(n);if(!r.ok)throw new Error(`Unable to load wasm data at: ${n}`);const a=new Uint8Array(await r.arrayBuffer());if(!function(e){return e.length>=4&&0===e[0]&&97===e[1]&&115===e[2]&&109===e[3]}(a))throw h(n,t,a);return a}};function y(e){const t=e||("undefined"!=typeof window?window.__REACT_OS_SHELL_PDF_WASM__:void 0);return"string"==typeof t&&t?{wasmUrl:t.endsWith("/")?t:`${t}/`}:{BinaryDataFactory:w}}var v=[50,75,100,125,150,200,300,400];function b(e,t,n){const r=(t.width-40)/n.width,a="page"===e?Math.min(r,(t.height-40)/n.height):r;return Math.min(Math.max(a,.3),4)}function x({url:a,filename:o,fit:d="width",onDownload:h,onEmail:p,workerSrc:g,wasmUrl:w}){const x=t().pdf,k=i(null),C=i(null),N=i(null),[M,j]=s(null),[E,z]=s(1),[P,_]=s(0),[D,L]=s(1),[S,W]=s(!0),[$,A]=s(!0),T=i(x.loadFailed);T.current=x.loadFailed,l(()=>{let t=!1;return A(!0),z(1),g&&(c.GlobalWorkerOptions.workerSrc=g),c.getDocument({url:a,...y(w)}).promise.then(e=>{t||(j(e),_(e.numPages),A(!1))}).catch(()=>{t||(e.error(T.current),A(!1))}),()=>{t=!0}},[a,g,w]),l(()=>{if(!M||!S||!N.current)return;const e=()=>{const e=N.current;e&&M.getPage(E).then(t=>{if(!N.current)return;const n=t.getViewport({scale:1}),r=b(d,{width:e.clientWidth,height:e.clientHeight},{width:n.width,height:n.height});L(e=>Math.abs(e-r)<.005?e:r)})};e();const t=new ResizeObserver(e);return t.observe(N.current),()=>t.disconnect()},[M,E,S,d]),l(()=>{if(!M||!k.current)return;let e=!1,t=null,n=null;return M.getPage(E).then(r=>{if(e||!k.current)return;const a=r.getViewport({scale:D}),o=k.current;o.width=a.width,o.height=a.height,o.style.width=`${a.width}px`,o.style.height=`${a.height}px`;const i=o.getContext("2d");t=r.render({canvas:o,canvasContext:i,viewport:a}),t.promise.catch(()=>{});const s=C.current;s&&(s.replaceChildren(),s.style.setProperty("--total-scale-factor",String(a.scale)),n=new c.TextLayer({textContentSource:r.streamTextContent(),container:s,viewport:a}),n.render().then(()=>{if(e)return;const t=document.createElement("div");t.className="endOfContent",s.append(t)}).catch(()=>{}))}),()=>{e=!0,t?.cancel(),n?.cancel()}},[M,E,D]),l(()=>{const e=()=>C.current?.classList.remove("selecting");return window.addEventListener("pointerup",e),()=>window.removeEventListener("pointerup",e)},[]);const O="page"===d?x.fitPage:x.fitWidth,U="px-2 py-1 rounded hover:bg-gray-200 transition-colors text-gray-600 flex items-center gap-1";/* @__PURE__ */
3
3
  return m("div",{className:"flex flex-col h-full",children:[
4
4
  /* @__PURE__ */m(f,{children:[
5
- /* @__PURE__ */u("button",{type:"button","aria-label":x.previousPage,onClick:()=>z(e=>Math.max(1,e-1)),disabled:E<=1,className:"px-1 py-1 rounded hover:bg-gray-200 disabled:opacity-30 text-gray-600",children:/* @__PURE__ */u(t,{name:"chevron-left",className:"h-3.5 w-3.5",strokeWidth:2})}),
6
- /* @__PURE__ */u("span",{className:"text-gray-600 font-medium tabular-nums whitespace-nowrap",children:x.pageOf(E,W)}),
7
- /* @__PURE__ */u("button",{type:"button","aria-label":x.nextPage,onClick:()=>z(e=>Math.min(W,e+1)),disabled:E>=W,className:"px-1 py-1 rounded hover:bg-gray-200 disabled:opacity-30 text-gray-600",children:/* @__PURE__ */u(t,{name:"chevron-right",className:"h-3.5 w-3.5",strokeWidth:2})}),
5
+ /* @__PURE__ */u("button",{type:"button","aria-label":x.previousPage,onClick:()=>z(e=>Math.max(1,e-1)),disabled:E<=1,className:"px-1 py-1 rounded hover:bg-gray-200 disabled:opacity-30 text-gray-600",children:/* @__PURE__ */u(r,{name:"chevron-left",className:"h-3.5 w-3.5",strokeWidth:2})}),
6
+ /* @__PURE__ */u("span",{className:"text-gray-600 font-medium tabular-nums whitespace-nowrap",children:x.pageOf(E,P)}),
7
+ /* @__PURE__ */u("button",{type:"button","aria-label":x.nextPage,onClick:()=>z(e=>Math.min(P,e+1)),disabled:E>=P,className:"px-1 py-1 rounded hover:bg-gray-200 disabled:opacity-30 text-gray-600",children:/* @__PURE__ */u(r,{name:"chevron-right",className:"h-3.5 w-3.5",strokeWidth:2})}),
8
8
  /* @__PURE__ */u("div",{className:"h-4 w-px bg-gray-300 mx-1"}),
9
- /* @__PURE__ */u("button",{type:"button","aria-label":x.zoomOut,title:x.zoomOut,onClick:()=>{L(!1),P(e=>Math.max(.3,Math.round(100*(e-.25))/100))},className:R,children:/* @__PURE__ */u("span",{"aria-hidden":"true",children:"−"})}),
10
- /* @__PURE__ */m("select",{value:S?"fit":v.includes(Math.round(100*D))?Math.round(100*D):"custom",onChange:e=>{const t=e.target.value;"fit"!==t?"custom"!==t&&(L(!1),P(Number(t)/100)):L(!0)},className:"bg-transparent hover:bg-gray-200 rounded px-1 py-1 text-gray-600 tabular-nums cursor-pointer focus:outline-none focus:ring-1 focus:ring-blue-400","aria-label":x.zoom,title:x.zoom,children:[
9
+ /* @__PURE__ */u("button",{type:"button","aria-label":x.zoomOut,title:x.zoomOut,onClick:()=>{W(!1),L(e=>Math.max(.3,Math.round(100*(e-.25))/100))},className:U,children:/* @__PURE__ */u("span",{"aria-hidden":"true",children:"−"})}),
10
+ /* @__PURE__ */m("select",{value:S?"fit":v.includes(Math.round(100*D))?Math.round(100*D):"custom",onChange:e=>{const t=e.target.value;"fit"!==t?"custom"!==t&&(W(!1),L(Number(t)/100)):W(!0)},className:"bg-transparent hover:bg-gray-200 rounded px-1 py-1 text-gray-600 tabular-nums cursor-pointer focus:outline-none focus:ring-1 focus:ring-blue-400","aria-label":x.zoom,title:x.zoom,children:[
11
11
  /* @__PURE__ */u("option",{value:"fit",children:O}),!S&&!v.includes(Math.round(100*D))&&/* @__PURE__ */m("option",{value:"custom",children:[Math.round(100*D),"%"]}),v.map(e=>/* @__PURE__ */m("option",{value:e,children:[e,"%"]},e))]}),
12
- /* @__PURE__ */u("button",{type:"button","aria-label":x.zoomIn,title:x.zoomIn,onClick:()=>{L(!1),P(e=>Math.min(4,Math.round(100*(e+.25))/100))},className:R,children:/* @__PURE__ */u("span",{"aria-hidden":"true",children:"+"})}),
13
- /* @__PURE__ */u("button",{type:"button",onClick:()=>L(!0),"aria-pressed":S,className:R+(S?" bg-gray-200 text-gray-900":""),title:x.fitHint,children:x.fit}),
12
+ /* @__PURE__ */u("button",{type:"button","aria-label":x.zoomIn,title:x.zoomIn,onClick:()=>{W(!1),L(e=>Math.min(4,Math.round(100*(e+.25))/100))},className:U,children:/* @__PURE__ */u("span",{"aria-hidden":"true",children:"+"})}),
13
+ /* @__PURE__ */u("button",{type:"button",onClick:()=>W(!0),"aria-pressed":S,className:U+(S?" bg-gray-200 text-gray-900":""),title:x.fitHint,children:x.fit}),
14
14
  /* @__PURE__ */u("div",{className:"h-4 w-px bg-gray-300 mx-1"}),
15
- /* @__PURE__ */m("button",{type:"button",onClick:()=>{if(!M)return;const t=window.open("","_blank");if(!t)return void e.error(x.allowPopups);const n=[];for(let e=1;e<=W;e++)n.push(M.getPage(e).then(e=>{const t=e.getViewport({scale:2}),n=document.createElement("canvas");return n.width=t.width,n.height=t.height,e.render({canvas:n,canvasContext:n.getContext("2d"),viewport:t}).promise.then(()=>n.toDataURL())}));Promise.all(n).then(e=>{var n;t.document.write(`<html><head><title>${n=o,n.replace(/[&<>"]/g,e=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;"}[e]))}</title><style>@media print{body{margin:0}img{width:100%;page-break-after:always}}</style></head><body>`),t.document.write(e.map(e=>`<img src="${e}"/>`).join("")),t.document.write("</body></html>"),t.document.close(),setTimeout(()=>{t.print(),t.close()},300)})},className:R,children:[
16
- /* @__PURE__ */u(t,{name:"print",className:"h-3.5 w-3.5",strokeWidth:1.5}),x.print]}),
17
- /* @__PURE__ */m("button",{type:"button",onClick:h??(()=>{const e=document.createElement("a");e.href=a,e.download=o,e.click()}),className:R,children:[
18
- /* @__PURE__ */u(t,{name:"download",className:"h-3.5 w-3.5",strokeWidth:1.5}),x.download]}),p&&/* @__PURE__ */m("button",{type:"button",onClick:p,className:R,children:[
19
- /* @__PURE__ */u(t,{name:"email",className:"h-3.5 w-3.5",strokeWidth:1.5}),x.email]})]}),
20
- /* @__PURE__ */u("div",{ref:N,className:"flex-1 overflow-auto bg-gray-100 outline-none",tabIndex:0,onWheel:e=>{if(!M)return;if(e.ctrlKey||e.metaKey)return;const t=N.current;if(!t)return;const n=t.scrollTop<=0,r=t.scrollTop+t.clientHeight>=t.scrollHeight-1;e.deltaY>0&&r&&E<W?(e.preventDefault(),z(e=>Math.min(W,e+1)),requestAnimationFrame(()=>{N.current&&(N.current.scrollTop=0)})):e.deltaY<0&&n&&E>1&&(e.preventDefault(),z(e=>Math.max(1,e-1)),requestAnimationFrame(()=>{N.current&&(N.current.scrollTop=N.current.scrollHeight)}))},onKeyDown:e=>{if(!M)return;const t=(document.activeElement?.tagName||"").toLowerCase();"input"===t||"textarea"===t||document.activeElement?.isContentEditable||("PageDown"===e.key||"ArrowRight"===e.key?E<W&&(e.preventDefault(),z(e=>Math.min(W,e+1))):"PageUp"===e.key||"ArrowLeft"===e.key?E>1&&(e.preventDefault(),z(e=>Math.max(1,e-1))):"Home"===e.key?(e.preventDefault(),z(1)):"End"===e.key&&(e.preventDefault(),z(W)))},children:T?/* @__PURE__ */u(r,{size:"sm",padding:"",className:"h-full",label:x.loading}):/* @__PURE__ */m("div",{className:"min-h-full flex items-center justify-center p-4",children:[
15
+ /* @__PURE__ */m("button",{type:"button",onClick:()=>{if(!M)return;const t=window.open("","_blank");if(!t)return void e.error(x.allowPopups);const n=[];for(let e=1;e<=P;e++)n.push(M.getPage(e).then(e=>{const t=e.getViewport({scale:2}),n=document.createElement("canvas");return n.width=t.width,n.height=t.height,e.render({canvas:n,canvasContext:n.getContext("2d"),viewport:t}).promise.then(()=>n.toDataURL())}));Promise.all(n).then(e=>{var n;t.document.write(`<html><head><title>${n=o,n.replace(/[&<>"]/g,e=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;"}[e]))}</title><style>@media print{body{margin:0}img{width:100%;page-break-after:always}}</style></head><body>`),t.document.write(e.map(e=>`<img src="${e}"/>`).join("")),t.document.write("</body></html>"),t.document.close(),setTimeout(()=>{t.print(),t.close()},300)})},className:U,children:[
16
+ /* @__PURE__ */u(r,{name:"print",className:"h-3.5 w-3.5",strokeWidth:1.5}),x.print]}),
17
+ /* @__PURE__ */m("button",{type:"button",onClick:h??(()=>{const e=document.createElement("a");e.href=a,e.download=o,e.click()}),className:U,children:[
18
+ /* @__PURE__ */u(r,{name:"download",className:"h-3.5 w-3.5",strokeWidth:1.5}),x.download]}),p&&/* @__PURE__ */m("button",{type:"button",onClick:p,className:U,children:[
19
+ /* @__PURE__ */u(r,{name:"email",className:"h-3.5 w-3.5",strokeWidth:1.5}),x.email]})]}),
20
+ /* @__PURE__ */u("div",{ref:N,className:"flex-1 overflow-auto bg-gray-100 outline-none",tabIndex:0,onWheel:e=>{if(!M)return;if(e.ctrlKey||e.metaKey)return;const t=N.current;if(!t)return;const n=t.scrollTop<=0,r=t.scrollTop+t.clientHeight>=t.scrollHeight-1;e.deltaY>0&&r&&E<P?(e.preventDefault(),z(e=>Math.min(P,e+1)),requestAnimationFrame(()=>{N.current&&(N.current.scrollTop=0)})):e.deltaY<0&&n&&E>1&&(e.preventDefault(),z(e=>Math.max(1,e-1)),requestAnimationFrame(()=>{N.current&&(N.current.scrollTop=N.current.scrollHeight)}))},onKeyDown:e=>{if(!M)return;const t=(document.activeElement?.tagName||"").toLowerCase();"input"===t||"textarea"===t||document.activeElement?.isContentEditable||("PageDown"===e.key||"ArrowRight"===e.key?E<P&&(e.preventDefault(),z(e=>Math.min(P,e+1))):"PageUp"===e.key||"ArrowLeft"===e.key?E>1&&(e.preventDefault(),z(e=>Math.max(1,e-1))):"Home"===e.key?(e.preventDefault(),z(1)):"End"===e.key&&(e.preventDefault(),z(P)))},children:$?/* @__PURE__ */u(n,{size:"sm",padding:"",className:"h-full",label:x.loading}):/* @__PURE__ */m("div",{className:"min-h-full flex items-center justify-center p-4",children:[
21
21
  /* @__PURE__ */u("style",{children:'\n.preview-pdf-textlayer {\n position: absolute;\n inset: 0;\n overflow: clip;\n line-height: 1;\n text-align: initial;\n text-size-adjust: none;\n forced-color-adjust: none;\n transform-origin: 0 0;\n caret-color: CanvasText;\n --min-font-size: 1;\n --text-scale-factor: calc(var(--total-scale-factor, 1) * var(--min-font-size));\n --min-font-size-inv: calc(1 / var(--min-font-size));\n}\n.preview-pdf-textlayer :is(span, br) {\n color: transparent;\n position: absolute;\n white-space: pre;\n cursor: text;\n transform-origin: 0% 0%;\n}\n.preview-pdf-textlayer > :not(.markedContent),\n.preview-pdf-textlayer .markedContent span:not(.markedContent) {\n z-index: 1;\n --font-height: 0;\n font-size: calc(var(--text-scale-factor) * var(--font-height));\n --scale-x: 1;\n --rotate: 0deg;\n transform: rotate(var(--rotate)) scaleX(var(--scale-x)) scale(var(--min-font-size-inv));\n}\n.preview-pdf-textlayer .markedContent {\n display: contents;\n}\n.preview-pdf-textlayer span[role="img"] {\n user-select: none;\n cursor: default;\n}\n.preview-pdf-textlayer ::selection {\n background: rgba(0, 80, 255, 0.25);\n}\n.preview-pdf-textlayer br::selection {\n background: transparent;\n}\n.preview-pdf-textlayer .endOfContent {\n display: block;\n position: absolute;\n inset: 100% 0 0;\n z-index: 0;\n cursor: default;\n user-select: none;\n}\n.preview-pdf-textlayer.selecting .endOfContent {\n top: 0;\n}\n'}),
22
22
  /* @__PURE__ */m("div",{className:"relative shadow-lg rounded",children:[
23
23
  /* @__PURE__ */u("canvas",{ref:k,className:"block rounded"}),
@@ -1,19 +1,19 @@
1
- import{escapeHtml as e}from"./chunk-BR22X7E5.js";import{TH_ONE_LINE as t}from"./chunk-KYBZBZEP.js";import{useBrowserLayoutEffect as n}from"./chunk-D65T4H6J.js";import{useShellStrings as r}from"./chunk-W7W4JMOT.js";import{useRef as o,useState as l,useEffect as c,useCallback as a,useMemo as s}from"react";import{createPortal as i}from"react-dom";import{jsxs as u,jsx as h,Fragment as d}from"react/jsx-runtime";function w(e,t){const n=e[e.length-1];return n&&!n.some(e=>e.trim())?e:[...e,Array(t).fill("")]}function g({text:t,...n}){const r=s(()=>({__html:e(t)}),[t]);/* @__PURE__ */
2
- return h("div",{...n,dangerouslySetInnerHTML:r})}function m({columns:e,data:m,onChange:p,onColumnsChange:f,fixedRows:y=!1,minRows:b=15,maxHeight:v="260px",cellStyles:x,onFocusChange:M,onSelectionChange:D}){const k=o(null),C=r().grid,[E,$]=l(null);c(()=>{M?.(E)},[E,M]);const[L,S]=l({}),z=o(null),[N,A]=l({}),O=o(null),[T,K]=l(null),[R,P]=l(null),[F,I]=l(null),[X,Y]=l(null),[j,H]=l(null),B=o(null);n(()=>{const e=B.current;if(!e||e.row!==j?.row||e.col!==j?.col)return;B.current=null;const t=k.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)},[j]);const[W,q]=l(null),[J,Z]=l(null);c(()=>{D?.(W&&J?{anchor:W,end:J}:null)},[W,J,D]);const _=o(!1),[U,V]=l(null),G=o(!1),Q=o({a:null,e:null});Q.current={a:W,e:J};const ee=W&&J&&(W.row!==J.row||W.col!==J.col),te=[...m];if(!y)for(;te.length<b;)te.push(Array(e.length).fill(""));const ne=a((t,n,r)=>{const o=te.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,p(o)},[te,e.length,p]),re=a((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!==(te[e]?.[t]||"")){const r=te.map(e=>[...e]);r[e]&&(r[e][t]=n,p(r))}}_.current=!0,e.shiftKey&&W||q({row:t,col:n}),Z({row:t,col:n})},[te,p,W]),oe=a((e,t)=>{_.current&&Z({row:e,col:t})},[]);c(()=>{const e=()=>{_.current=!1};return window.addEventListener("mouseup",e),()=>window.removeEventListener("mouseup",e)},[]),c(()=>{const e=e=>{if(!e.ctrlKey&&!e.metaKey||"c"!==e.key)return;if(!W||!J)return;const t=window.getSelection();if(t&&t.toString().length>0&&!ee)return;const n=Math.min(W.row,J.row),r=Math.max(W.row,J.row),o=Math.min(W.col,J.col),l=Math.max(W.col,J.col),c=[];for(let e=n;e<=r;e++){const t=[];for(let n=o;n<=l;n++)t.push(te[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)},[W,J,te,ee]),c(()=>{const t=t=>{if(!E)return;const n=document.activeElement;if(n?.isContentEditable)return;if(!k.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=te.map(e=>[...e]);for(let t=0;t<o.length;t++){const n=E.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=E.col+r;if(c>=e.length)break;e[c].readOnly||(l[n][c]=o[t][r].trim())}}p(y?l:w(l,e.length)),q({row:E.row,col:E.col}),Z({row:Math.min(E.row+o.length-1,l.length-1),col:Math.min(E.col+(o[0]?.length||1)-1,e.length-1)})};return window.addEventListener("paste",t),()=>window.removeEventListener("paste",t)},[E,te,e,p,y]);const le=a((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=te.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())}}p(y?c:w(c,e.length))},[te,e,p,y]),ce=a((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(),ne(n,r,"")));if(t.preventDefault(),W&&J){const t=Math.min(W.row,J.row),n=Math.max(W.row,J.row),r=Math.min(W.col,J.col),o=Math.max(W.col,J.col),l=te.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]="");p(l)}else ne(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<te.length&&l>=0&&l<e.length){const e=k.current?.querySelector(`[data-row="${o}"][data-col="${l}"]`);e&&(e.focus({preventScroll:!0}),e.scrollIntoView({block:"nearest",inline:"nearest"}),$({row:o,col:l}),H(null),q({row:o,col:l}),Z({row:o,col:l}))}},[e,te,te.length,ne,W,J,p]),ae=a(t=>{if(!y&&t>=te.length-2){const t=te.map(e=>[...e]);for(let n=0;n<5;n++)t.push(Array(e.length).fill(""));p(t)}},[y,te,e.length,p]),[se,ie]=l(null);c(()=>{if(!se)return;const e=()=>ie(null);return window.addEventListener("pointerdown",e),()=>window.removeEventListener("pointerdown",e)},[se]);const ue=a(t=>{const n=te.map(e=>[...e]);n.splice(t,0,Array(e.length).fill("")),p(n)},[te,e.length,p]),he=a(e=>{if(te.length<=1)return;const t=te.filter((t,n)=>n!==e);p(t)},[te,p]),de=a(e=>{const t=te.map(t=>{const n=[...t];return n.splice(e,0,""),n});p(t)},[te,p]),we=a(t=>{if(e.length<=1)return;const n=te.map(e=>{const n=[...e];return n.splice(t,1),n});p(n)},[te,e.length,p]),ge=a((e,t)=>{e.preventDefault(),y||ie({x:e.clientX,y:e.clientY,items:[{label:C.insertRowAbove,onClick:()=>{ue(t),ie(null)}},{label:C.insertRowBelow,onClick:()=>{ue(t+1),ie(null)}},{label:C.deleteRow(t+1),onClick:()=>{he(t),ie(null)}}]})},[y,ue,he,C]),me=a((t,n)=>{t.preventDefault(),y||ie({x:t.clientX,y:t.clientY,items:[{label:C.insertColumnLeft,onClick:()=>{de(n),ie(null)}},{label:C.insertColumnRight,onClick:()=>{de(n+1),ie(null)}},{label:C.deleteColumn(String(e[n]?.title||n+1)),onClick:()=>{we(n),ie(null)}}]})},[y,e,de,we,C]),pe=t=>L[t]??e[t]?.width??150;c(()=>{const t=e=>{if(!z.current)return;const t=e.clientX-z.current.startX,n=Math.max(40,z.current.startW+t);S(e=>({...e,[z.current.col]:n}))},n=()=>{if(z.current&&f){const t=e.map((e,t)=>({...e,width:L[t]??e.width}));t[z.current.col]={...t[z.current.col],width:L[z.current.col]??e[z.current.col].width},f(t)}z.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;c(()=>{const e=e=>{if(!O.current)return;const t=e.clientY-O.current.startY,n=Math.max(20,O.current.startH+t);A(e=>({...e,[O.current.row]:n}))},t=()=>{O.current=null,document.body.style.cursor=""};return window.addEventListener("mousemove",e),window.addEventListener("mouseup",t),()=>{window.removeEventListener("mousemove",e),window.removeEventListener("mouseup",t)}},[]);const ye=a(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 te){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)}},[te,e,L,f]),be=a(e=>{A(t=>{const n={...t};return delete n[e],n})},[]),ve=a(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,h=a;t.row>l?i=t.row:t.row<o&&(s=t.row),t.col>a?h=t.col:t.col<c&&(u=t.col);const d=l-o+1,w=a-c+1,g=te.map(e=>[...e]);for(;g.length<=i;)g.push(Array(e.length).fill(""));for(const e of g)for(;e.length<=h;)e.push("");function m(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<=h;t++){if(e>=o&&e<=l&&t>=c&&t<=a)continue;let n;if(1===w&&u===c&&h===a){const r=m(Array.from({length:d},(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)%d+d)%d;n=g[o+r]?.[t]??""}}else if(1===d&&s===o&&i===l){const r=m(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)%d+d)%d,l=((t-c)%w+w)%w;n=g[o+r]?.[c+l]??""}g[e][t]=n}p(g),q({row:s,col:u}),Z({row:i,col:h})},[te,e.length,p]);c(()=>{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&&ve(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,ve]);const xe=e=>{e.preventDefault(),e.stopPropagation(),G.current=!0,document.body.style.cursor="crosshair"},Me=o(null),[De,ke]=l(0),[Ce,Ee]=l(800);c(()=>{const e=Me.current;if(!e)return;const t=()=>Ee(e.clientHeight||800);t();const n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]);const $e=te.length>100,Le=$e?Math.max(0,Math.floor(De/28)-20):0,Se=$e?Math.min(te.length,Math.ceil((De+Ce)/28)+20):te.length,ze=s(()=>te.slice(Le,Se),[te,Le,Se]),Ne=28*Le,Ae=28*(te.length-Se),Oe="px-2 h-8 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{TH_ONE_LINE as t}from"./chunk-BRK2GETX.js";import{useBrowserLayoutEffect as n}from"./chunk-D65T4H6J.js";import{useShellStrings as r}from"./chunk-3IML3Y3Y.js";import{useRef as o,useState as l,useEffect as c,useCallback as a,useMemo as s}from"react";import{createPortal as i}from"react-dom";import{jsxs as u,jsx as h,Fragment as d}from"react/jsx-runtime";function w(e,t){const n=e[e.length-1];return n&&!n.some(e=>e.trim())?e:[...e,Array(t).fill("")]}function g({text:t,...n}){const r=s(()=>({__html:e(t)}),[t]);/* @__PURE__ */
2
+ return h("div",{...n,dangerouslySetInnerHTML:r})}function m({columns:e,data:m,onChange:p,onColumnsChange:f,fixedRows:y=!1,minRows:b=15,maxHeight:v="260px",cellStyles:x,onFocusChange:M,onSelectionChange:D}){const k=o(null),C=r().grid,[E,L]=l(null);c(()=>{M?.(E)},[E,M]);const[$,S]=l({}),z=o(null),[N,A]=l({}),T=o(null),[O,R]=l(null),[K,P]=l(null),[F,I]=l(null),[X,Y]=l(null),[j,H]=l(null),B=o(null);n(()=>{const e=B.current;if(!e||e.row!==j?.row||e.col!==j?.col)return;B.current=null;const t=k.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)},[j]);const[q,W]=l(null),[_,G]=l(null);c(()=>{D?.(q&&_?{anchor:q,end:_}:null)},[q,_,D]);const J=o(!1),[U,V]=l(null),Q=o(!1),Z=o({a:null,e:null});Z.current={a:q,e:_};const ee=q&&_&&(q.row!==_.row||q.col!==_.col),te=[...m];if(!y)for(;te.length<b;)te.push(Array(e.length).fill(""));const ne=a((t,n,r)=>{const o=te.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,p(o)},[te,e.length,p]),re=a((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!==(te[e]?.[t]||"")){const r=te.map(e=>[...e]);r[e]&&(r[e][t]=n,p(r))}}J.current=!0,e.shiftKey&&q||W({row:t,col:n}),G({row:t,col:n})},[te,p,q]),oe=a((e,t)=>{J.current&&G({row:e,col:t})},[]);c(()=>{const e=()=>{J.current=!1};return window.addEventListener("mouseup",e),()=>window.removeEventListener("mouseup",e)},[]),c(()=>{const e=e=>{if(!e.ctrlKey&&!e.metaKey||"c"!==e.key)return;if(!q||!_)return;const t=window.getSelection();if(t&&t.toString().length>0&&!ee)return;const n=Math.min(q.row,_.row),r=Math.max(q.row,_.row),o=Math.min(q.col,_.col),l=Math.max(q.col,_.col),c=[];for(let e=n;e<=r;e++){const t=[];for(let n=o;n<=l;n++)t.push(te[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)},[q,_,te,ee]),c(()=>{const t=t=>{if(!E)return;const n=document.activeElement;if(n?.isContentEditable)return;if(!k.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=te.map(e=>[...e]);for(let t=0;t<o.length;t++){const n=E.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=E.col+r;if(c>=e.length)break;e[c].readOnly||(l[n][c]=o[t][r].trim())}}p(y?l:w(l,e.length)),W({row:E.row,col:E.col}),G({row:Math.min(E.row+o.length-1,l.length-1),col:Math.min(E.col+(o[0]?.length||1)-1,e.length-1)})};return window.addEventListener("paste",t),()=>window.removeEventListener("paste",t)},[E,te,e,p,y]);const le=a((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=te.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())}}p(y?c:w(c,e.length))},[te,e,p,y]),ce=a((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(),ne(n,r,"")));if(t.preventDefault(),q&&_){const t=Math.min(q.row,_.row),n=Math.max(q.row,_.row),r=Math.min(q.col,_.col),o=Math.max(q.col,_.col),l=te.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]="");p(l)}else ne(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<te.length&&l>=0&&l<e.length){const e=k.current?.querySelector(`[data-row="${o}"][data-col="${l}"]`);e&&(e.focus({preventScroll:!0}),e.scrollIntoView({block:"nearest",inline:"nearest"}),L({row:o,col:l}),H(null),W({row:o,col:l}),G({row:o,col:l}))}},[e,te,te.length,ne,q,_,p]),ae=a(t=>{if(!y&&t>=te.length-2){const t=te.map(e=>[...e]);for(let n=0;n<5;n++)t.push(Array(e.length).fill(""));p(t)}},[y,te,e.length,p]),[se,ie]=l(null);c(()=>{if(!se)return;const e=()=>ie(null);return window.addEventListener("pointerdown",e),()=>window.removeEventListener("pointerdown",e)},[se]);const ue=a(t=>{const n=te.map(e=>[...e]);n.splice(t,0,Array(e.length).fill("")),p(n)},[te,e.length,p]),he=a(e=>{if(te.length<=1)return;const t=te.filter((t,n)=>n!==e);p(t)},[te,p]),de=a(e=>{const t=te.map(t=>{const n=[...t];return n.splice(e,0,""),n});p(t)},[te,p]),we=a(t=>{if(e.length<=1)return;const n=te.map(e=>{const n=[...e];return n.splice(t,1),n});p(n)},[te,e.length,p]),ge=a((e,t)=>{e.preventDefault(),y||ie({x:e.clientX,y:e.clientY,items:[{label:C.insertRowAbove,onClick:()=>{ue(t),ie(null)}},{label:C.insertRowBelow,onClick:()=>{ue(t+1),ie(null)}},{label:C.deleteRow(t+1),onClick:()=>{he(t),ie(null)}}]})},[y,ue,he,C]),me=a((t,n)=>{t.preventDefault(),y||ie({x:t.clientX,y:t.clientY,items:[{label:C.insertColumnLeft,onClick:()=>{de(n),ie(null)}},{label:C.insertColumnRight,onClick:()=>{de(n+1),ie(null)}},{label:C.deleteColumn(String(e[n]?.title||n+1)),onClick:()=>{we(n),ie(null)}}]})},[y,e,de,we,C]),pe=t=>$[t]??e[t]?.width??150;c(()=>{const t=e=>{if(!z.current)return;const t=e.clientX-z.current.startX,n=Math.max(40,z.current.startW+t);S(e=>({...e,[z.current.col]:n}))},n=()=>{if(z.current&&f){const t=e.map((e,t)=>({...e,width:$[t]??e.width}));t[z.current.col]={...t[z.current.col],width:$[z.current.col]??e[z.current.col].width},f(t)}z.current=null,document.body.style.cursor=""};return window.addEventListener("mousemove",t),window.addEventListener("mouseup",n),()=>{window.removeEventListener("mousemove",t),window.removeEventListener("mouseup",n)}},[e,$,f]);const fe=e=>N[e]??28;c(()=>{const e=e=>{if(!T.current)return;const t=e.clientY-T.current.startY,n=Math.max(20,T.current.startH+t);A(e=>({...e,[T.current.row]:n}))},t=()=>{T.current=null,document.body.style.cursor=""};return window.addEventListener("mousemove",e),window.addEventListener("mouseup",t),()=>{window.removeEventListener("mousemove",e),window.removeEventListener("mouseup",t)}},[]);const ye=a(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 te){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:$[n]??e.width}));f(n)}},[te,e,$,f]),be=a(e=>{A(t=>{const n={...t};return delete n[e],n})},[]),ve=a(t=>{const{a:n,e:r}=Z.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,h=a;t.row>l?i=t.row:t.row<o&&(s=t.row),t.col>a?h=t.col:t.col<c&&(u=t.col);const d=l-o+1,w=a-c+1,g=te.map(e=>[...e]);for(;g.length<=i;)g.push(Array(e.length).fill(""));for(const e of g)for(;e.length<=h;)e.push("");function m(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<=h;t++){if(e>=o&&e<=l&&t>=c&&t<=a)continue;let n;if(1===w&&u===c&&h===a){const r=m(Array.from({length:d},(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)%d+d)%d;n=g[o+r]?.[t]??""}}else if(1===d&&s===o&&i===l){const r=m(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)%d+d)%d,l=((t-c)%w+w)%w;n=g[o+r]?.[c+l]??""}g[e][t]=n}p(g),W({row:s,col:u}),G({row:i,col:h})},[te,e.length,p]);c(()=>{const e=e=>{if(!Q.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=()=>{Q.current&&U&&ve(U),Q.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,ve]);const xe=e=>{e.preventDefault(),e.stopPropagation(),Q.current=!0,document.body.style.cursor="crosshair"},Me=o(null),[De,ke]=l(0),[Ce,Ee]=l(800);c(()=>{const e=Me.current;if(!e)return;const t=()=>Ee(e.clientHeight||800);t();const n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]);const Le=te.length>100,$e=Le?Math.max(0,Math.floor(De/28)-20):0,Se=Le?Math.min(te.length,Math.ceil((De+Ce)/28)+20):te.length,ze=s(()=>te.slice($e,Se),[te,$e,Se]),Ne=28*$e,Ae=28*(te.length-Se),Te="px-2 h-8 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 u("div",{ref:Me,className:"border border-gray-300 rounded overflow-scroll grid-scroll",style:{maxHeight:v,height:v},onScroll:e=>ke(e.target.scrollTop),children:[
4
4
  /* @__PURE__ */u("table",{ref:k,className:"border-collapse select-none",style:{tableLayout:"fixed",minWidth:36+e.reduce((t,n)=>t+pe(e.indexOf(n)),0)},children:[
5
5
  /* @__PURE__ */u("colgroup",{children:[
6
6
  /* @__PURE__ */h("col",{style:{width:36}}),e.map((e,t)=>/* @__PURE__ */h("col",{style:{width:pe(t)}},e.key))]}),
7
7
  /* @__PURE__ */h("thead",{className:"sticky top-0 z-10",children:/* @__PURE__ */u("tr",{children:[
8
- /* @__PURE__ */h("th",{className:`${t} ${Oe} text-center w-9 cursor-pointer hover:bg-gray-200`,onClick:()=>{q({row:0,col:0}),Z({row:te.length-1,col:e.length-1})},title:C.selectAll,children:"#"}),e.map((n,r)=>{const o=W&&J&&Math.min(W.col,J.col)<=r&&r<=Math.max(W.col,J.col)&&0===Math.min(W.row,J.row)&&Math.max(W.row,J.row)===te.length-1;/* @__PURE__ */
9
- return u("th",{className:`${t} ${Oe} cursor-pointer hover:bg-gray-200 relative${o?" !bg-blue-200":""}${X===r?" !bg-blue-100":""}`,style:{width:pe(r)},draggable:!0,onDragStart:()=>(e=>I(e))(r),onDragOver:e=>((e,t)=>{e.preventDefault(),Y(t)})(e,r),onDrop:()=>(t=>{if(null===F||F===t)return I(null),void Y(null);const n=te.map(e=>{const n=[...e],[r]=n.splice(F,1);return n.splice(t,0,r),n});if(p(n),f){const n=[...e],[r]=n.splice(F,1);n.splice(t,0,r),f(n)}I(null),Y(null)})(r),onDragEnd:()=>{I(null),Y(null)},onClick:e=>{e.shiftKey&&W||q({row:0,col:r}),Z({row:te.length-1,col:r})},onContextMenu:e=>me(e,r),children:[n.title,
8
+ /* @__PURE__ */h("th",{className:`${t} ${Te} text-center w-9 cursor-pointer hover:bg-gray-200`,onClick:()=>{W({row:0,col:0}),G({row:te.length-1,col:e.length-1})},title:C.selectAll,children:"#"}),e.map((n,r)=>{const o=q&&_&&Math.min(q.col,_.col)<=r&&r<=Math.max(q.col,_.col)&&0===Math.min(q.row,_.row)&&Math.max(q.row,_.row)===te.length-1;/* @__PURE__ */
9
+ return u("th",{className:`${t} ${Te} cursor-pointer hover:bg-gray-200 relative${o?" !bg-blue-200":""}${X===r?" !bg-blue-100":""}`,style:{width:pe(r)},draggable:!0,onDragStart:()=>(e=>I(e))(r),onDragOver:e=>((e,t)=>{e.preventDefault(),Y(t)})(e,r),onDrop:()=>(t=>{if(null===F||F===t)return I(null),void Y(null);const n=te.map(e=>{const n=[...e],[r]=n.splice(F,1);return n.splice(t,0,r),n});if(p(n),f){const n=[...e],[r]=n.splice(F,1);n.splice(t,0,r),f(n)}I(null),Y(null)})(r),onDragEnd:()=>{I(null),Y(null)},onClick:e=>{e.shiftKey&&q||W({row:0,col:r}),G({row:te.length-1,col:r})},onContextMenu:e=>me(e,r),children:[n.title,
10
10
  /* @__PURE__ */h("div",{className:"absolute -right-1 top-0 bottom-0 w-2 cursor-col-resize z-20",onMouseDown:e=>((e,t)=>{e.preventDefault(),e.stopPropagation(),z.current={col:t,startX:e.clientX,startW:pe(t)},document.body.style.cursor="col-resize"})(e,r),onDoubleClick:e=>{e.stopPropagation(),ye(r)},title:C.resize})]},n.key)})]})}),
11
- /* @__PURE__ */u("tbody",{children:[Ne>0&&/* @__PURE__ */h("tr",{style:{height:Ne}}),ze.map((t,n)=>{const r=Le+n,o=W&&J&&Math.min(W.row,J.row)<=r&&r<=Math.max(W.row,J.row)&&0===Math.min(W.col,J.col)&&Math.max(W.col,J.col)===e.length-1;/* @__PURE__ */
11
+ /* @__PURE__ */u("tbody",{children:[Ne>0&&/* @__PURE__ */h("tr",{style:{height:Ne}}),ze.map((t,n)=>{const r=$e+n,o=q&&_&&Math.min(q.row,_.row)<=r&&r<=Math.max(q.row,_.row)&&0===Math.min(q.col,_.col)&&Math.max(q.col,_.col)===e.length-1;/* @__PURE__ */
12
12
  return u("tr",{style:{height:fe(r)},children:[
13
- /* @__PURE__ */u("td",{className:`relative px-1 py-1 text-center text-2xs 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=>K(e))(r),onDragOver:e=>((e,t)=>{e.preventDefault(),P(t)})(e,r),onDrop:()=>(e=>{if(null===T||T===e)return K(null),void P(null);const t=te.map(e=>[...e]),[n]=t.splice(T,1);t.splice(e,0,n),p(t),K(null),P(null)})(r),onDragEnd:()=>{K(null),P(null)},onClick:t=>{t.shiftKey&&W||q({row:r,col:0}),Z({row:r,col:e.length-1})},onContextMenu:e=>ge(e,r),children:[r+1,
14
- /* @__PURE__ */h("div",{className:"absolute -bottom-1 left-0 right-0 h-2 cursor-row-resize z-20",onMouseDown:e=>((e,t)=>{e.preventDefault(),e.stopPropagation(),O.current={row:t,startY:e.clientY,startH:fe(t)},document.body.style.cursor="row-resize"})(e,r),onDoubleClick:e=>{e.stopPropagation(),be(r)},title:C.resize})]}),e.map((e,n)=>{const o=W&&J&&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}(W,J,r,n),l=j?.row===r&&j?.col===n&&!e.readOnly,c=E?.row===r&&E?.col===n,a=x?.[`${r}:${n}`],s=W&&J?Math.max(W.row,J.row):-1,i=W&&J?Math.max(W.col,J.col):-1,d=W&&J&&r===s&&n===i,w=G.current&&U&&W&&J&&(()=>{const e=Math.min(W.row,J.row),t=Math.max(W.row,J.row),o=Math.min(W.col,J.col),l=Math.max(W.col,J.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-2xs":"lg"===a?.fontSize?"text-sm":"xl"===a?.fontSize?"text-base":"text-xs",p=`${a?.bold?" font-bold":""}${a?.italic?" italic":""}${a?.underline?" underline":""}`;/* @__PURE__ */
13
+ /* @__PURE__ */u("td",{className:`relative px-1 py-1 text-center text-2xs 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":""}${K===r?" !bg-blue-100":""}`,draggable:!0,onDragStart:()=>(e=>R(e))(r),onDragOver:e=>((e,t)=>{e.preventDefault(),P(t)})(e,r),onDrop:()=>(e=>{if(null===O||O===e)return R(null),void P(null);const t=te.map(e=>[...e]),[n]=t.splice(O,1);t.splice(e,0,n),p(t),R(null),P(null)})(r),onDragEnd:()=>{R(null),P(null)},onClick:t=>{t.shiftKey&&q||W({row:r,col:0}),G({row:r,col:e.length-1})},onContextMenu:e=>ge(e,r),children:[r+1,
14
+ /* @__PURE__ */h("div",{className:"absolute -bottom-1 left-0 right-0 h-2 cursor-row-resize z-20",onMouseDown:e=>((e,t)=>{e.preventDefault(),e.stopPropagation(),T.current={row:t,startY:e.clientY,startH:fe(t)},document.body.style.cursor="row-resize"})(e,r),onDoubleClick:e=>{e.stopPropagation(),be(r)},title:C.resize})]}),e.map((e,n)=>{const o=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}(q,_,r,n),l=j?.row===r&&j?.col===n&&!e.readOnly,c=E?.row===r&&E?.col===n,a=x?.[`${r}:${n}`],s=q&&_?Math.max(q.row,_.row):-1,i=q&&_?Math.max(q.col,_.col):-1,d=q&&_&&r===s&&n===i,w=Q.current&&U&&q&&_&&(()=>{const e=Math.min(q.row,_.row),t=Math.max(q.row,_.row),o=Math.min(q.col,_.col),l=Math.max(q.col,_.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-2xs":"lg"===a?.fontSize?"text-sm":"xl"===a?.fontSize?"text-base":"text-xs",p=`${a?.bold?" font-bold":""}${a?.italic?" italic":""}${a?.underline?" underline":""}`;/* @__PURE__ */
15
15
  return u("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":""}${w?" !bg-blue-50 ring-1 ring-inset ring-blue-300":""}`,onMouseDown:e=>{if(e.target===e.currentTarget){re(e,r,n);const t=e.currentTarget.querySelector("[data-row][data-col]");t?.focus()}},onMouseEnter:()=>oe(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||H({row:r,col:n})},children:[
16
- /* @__PURE__ */h(g,{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}${p}`,onMouseDown:e=>re(e,r,n),onMouseEnter:()=>oe(r,n),onDoubleClick:()=>{e.readOnly||H({row:r,col:n})},onFocus:()=>{$({row:r,col:n}),_.current||(q({row:r,col:n}),Z({row:r,col:n}))},onBlur:e=>{const o=e.currentTarget.textContent||"";o!==(t[n]||"")&&ne(r,n,o),H(null)},onInput:()=>ae(r),onPaste:e=>le(e,r,n),onKeyDown:t=>{if(!(l||e.readOnly||1!==t.key.length||t.ctrlKey||t.metaKey||t.altKey))return t.preventDefault(),ne(r,n,t.key),B.current={row:r,col:n},void H({row:r,col:n});ce(t,r,n)},text:t[n]||""}),d&&/* @__PURE__ */h("div",{onMouseDown:xe,title:C.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__ */h("tr",{style:{height:Ae}})]})]}),se&&i(
16
+ /* @__PURE__ */h(g,{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}${p}`,onMouseDown:e=>re(e,r,n),onMouseEnter:()=>oe(r,n),onDoubleClick:()=>{e.readOnly||H({row:r,col:n})},onFocus:()=>{L({row:r,col:n}),J.current||(W({row:r,col:n}),G({row:r,col:n}))},onBlur:e=>{const o=e.currentTarget.textContent||"";o!==(t[n]||"")&&ne(r,n,o),H(null)},onInput:()=>ae(r),onPaste:e=>le(e,r,n),onKeyDown:t=>{if(!(l||e.readOnly||1!==t.key.length||t.ctrlKey||t.metaKey||t.altKey))return t.preventDefault(),ne(r,n,t.key),B.current={row:r,col:n},void H({row:r,col:n});ce(t,r,n)},text:t[n]||""}),d&&/* @__PURE__ */h("div",{onMouseDown:xe,title:C.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__ */h("tr",{style:{height:Ae}})]})]}),se&&i(
17
17
  /* @__PURE__ */u(d,{children:[
18
18
  /* @__PURE__ */h("div",{className:"fixed inset-0 z-(--z-popup)",onPointerDown:()=>ie(null)}),
19
19
  /* @__PURE__ */h("div",{className:"fixed z-(--z-popup) bg-white rounded-lg shadow-lg border border-gray-200 py-1 min-w-[160px]",style:{left:se.x,top:se.y},children:se.items.map((e,t)=>/* @__PURE__ */h("button",{onPointerDown:t=>{t.stopPropagation(),e.onClick()},className:"w-full text-left px-3 min-h-(--row-height-menu) py-2 leading-5 text-sm text-gray-700 hover:bg-gray-100",children:e.label},t))})]}),document.body)]})}export{m as EditableGrid,w as withSpareRow};
@@ -1,29 +1,29 @@
1
- import{useDismissPopupsOnOpen as e}from"./chunk-UVBK6YSR.js";import{registerModalEscapeInterceptor as t,Z_LAYERS as n}from"./chunk-FIEA5CGB.js";import{buttonClasses as r}from"./chunk-K7PQXJO7.js";import{Icon as l}from"./chunk-76DRQSJM.js";import{useShellStrings as o,splitAround as i}from"./chunk-W7W4JMOT.js";import{createContext as a,useEffect as s,useRef as c,useId as d,useContext as u,useState as m,useCallback as f}from"react";import{jsxs as h,jsx as b,Fragment as g}from"react/jsx-runtime";var v=["a[href]","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])",'[tabindex]:not([tabindex="-1"])'].join(",");function p(e){return Array.from(e.querySelectorAll(v)).filter(e=>null!==e.offsetParent||e===document.activeElement)}var y=[];function x(e){const t=y.findIndex(t=>t!==e&&e.contains(t));-1===t?y.push(e):y.splice(t,0,e)}function w(e){const t=y.lastIndexOf(e);-1!==t&&y.splice(t,1)}var N=/* @__PURE__ */new WeakSet;function k(e){return p(e)}function C(e,t){s(()=>{if(!t)return;const n=e.current;return n?(N.add(n),x(n),()=>{w(n),N.delete(n)}):void 0},[e,t])}function E(e,t){const n=y.lastIndexOf(t),r=n>0?y[n-1]:-1===n?y[y.length-1]??null:null,l=p(r??e.ownerDocument.body).filter(n=>!t.contains(n)&&!e.contains(n)),o=l.find(t=>0!==(e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING));return o||(r&&!N.has(r)?l[0]??null:null)}function L(e,t,n){s(()=>{if(!t)return;const r=e.current;if(!r)return;const l=document.activeElement,o=n?.current??p(r)[0]??r;o!==r||r.hasAttribute("tabindex")||r.setAttribute("tabindex","-1"),o.focus();const i=e=>{if("Tab"!==e.key)return;if(y[y.length-1]!==r)return;const t=p(r);if(0===t.length)return void e.preventDefault();const n=t[0],l=t[t.length-1],o=document.activeElement;!e.shiftKey||o!==n&&r.contains(o)?e.shiftKey||o!==l&&r.contains(o)||(e.preventDefault(),n.focus()):(e.preventDefault(),l.focus())};return x(r),document.addEventListener("keydown",i,!0),()=>{w(r),document.removeEventListener("keydown",i,!0),(r.contains(document.activeElement)||document.activeElement===document.body)&&l?.focus?.()}},[e,t,n])}var P=0,j=null;function I(e){s(()=>{if(!e)return;const t=document.body;if(0===P){j={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 P+=1,()=>{0===(P-=1)&&j&&(t.style.overflow=j.overflow,t.style.paddingRight=j.paddingRight,j=null)}},[e])}function W({role:e="dialog",modal:t,titleId:n,labelledBy:r,label:l}){const o=n??r;return{role:e,"aria-modal":!!t||void 0,"aria-labelledby":o,"aria-label":o?void 0:l}}var D={sm:"max-w-sm",md:"max-w-md",lg:"max-w-lg",xl:"max-w-4xl"};function O({open:r,onClose:i,title:a,description:u,role:m="dialog",children:f,footer:g,blocking:v=!1,size:p="md",initialFocus:y,"aria-label":x,"aria-labelledby":w,"aria-describedby":N,className:k=""}){const C=c(null),E=d(),P=d(),j=!v&&!g,O=d(),T=o().dialog;return e(r),L(C,r,y),I(r),s(()=>{if(r)return t(()=>(v||i(),!0),()=>C.current)},[r,v,i]),r?/* @__PURE__ */h("div",{className:"fixed inset-0",style:{zIndex:n.overlay},role:"presentation",children:[
1
+ import{useDismissPopupsOnOpen as e}from"./chunk-UVBK6YSR.js";import{registerModalEscapeInterceptor as t,Z_LAYERS as n}from"./chunk-FIEA5CGB.js";import{buttonClasses as r}from"./chunk-K7PQXJO7.js";import{useShellStrings as l,splitAround as o}from"./chunk-3IML3Y3Y.js";import{Icon as i}from"./chunk-76DRQSJM.js";import{createContext as a,useEffect as s,useRef as c,useId as d,useContext as u,useState as m,useCallback as f}from"react";import{jsxs as h,jsx as b,Fragment as g}from"react/jsx-runtime";var v=["a[href]","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])",'[tabindex]:not([tabindex="-1"])'].join(",");function p(e){return Array.from(e.querySelectorAll(v)).filter(e=>null!==e.offsetParent||e===document.activeElement)}var y=[];function x(e){const t=y.findIndex(t=>t!==e&&e.contains(t));-1===t?y.push(e):y.splice(t,0,e)}function w(e){const t=y.lastIndexOf(e);-1!==t&&y.splice(t,1)}var N=/* @__PURE__ */new WeakSet;function k(e){return p(e)}function C(e,t){s(()=>{if(!t)return;const n=e.current;return n?(N.add(n),x(n),()=>{w(n),N.delete(n)}):void 0},[e,t])}function E(e,t){const n=y.lastIndexOf(t),r=n>0?y[n-1]:-1===n?y[y.length-1]??null:null,l=p(r??e.ownerDocument.body).filter(n=>!t.contains(n)&&!e.contains(n)),o=l.find(t=>0!==(e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING));return o||(r&&!N.has(r)?l[0]??null:null)}function L(e,t,n){s(()=>{if(!t)return;const r=e.current;if(!r)return;const l=document.activeElement,o=n?.current??p(r)[0]??r;o!==r||r.hasAttribute("tabindex")||r.setAttribute("tabindex","-1"),o.focus();const i=e=>{if("Tab"!==e.key)return;if(y[y.length-1]!==r)return;const t=p(r);if(0===t.length)return void e.preventDefault();const n=t[0],l=t[t.length-1],o=document.activeElement;!e.shiftKey||o!==n&&r.contains(o)?e.shiftKey||o!==l&&r.contains(o)||(e.preventDefault(),n.focus()):(e.preventDefault(),l.focus())};return x(r),document.addEventListener("keydown",i,!0),()=>{w(r),document.removeEventListener("keydown",i,!0),(r.contains(document.activeElement)||document.activeElement===document.body)&&l?.focus?.()}},[e,t,n])}var P=0,j=null;function I(e){s(()=>{if(!e)return;const t=document.body;if(0===P){j={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 P+=1,()=>{0===(P-=1)&&j&&(t.style.overflow=j.overflow,t.style.paddingRight=j.paddingRight,j=null)}},[e])}function D({role:e="dialog",modal:t,titleId:n,labelledBy:r,label:l}){const o=n??r;return{role:e,"aria-modal":!!t||void 0,"aria-labelledby":o,"aria-label":o?void 0:l}}var F={sm:"max-w-sm",md:"max-w-md",lg:"max-w-lg",xl:"max-w-4xl"};function O({open:r,onClose:o,title:a,description:u,role:m="dialog",children:f,footer:g,blocking:v=!1,size:p="md",initialFocus:y,"aria-label":x,"aria-labelledby":w,"aria-describedby":N,className:k=""}){const C=c(null),E=d(),P=d(),j=!v&&!g,O=d(),T=l().dialog;return e(r),L(C,r,y),I(r),s(()=>{if(r)return t(()=>(v||o(),!0),()=>C.current)},[r,v,o]),r?/* @__PURE__ */h("div",{className:"fixed inset-0",style:{zIndex:n.overlay},role:"presentation",children:[
2
2
  /* @__PURE__ */b("div",{className:"fixed inset-0 bg-black/30","aria-hidden":"true"}),
3
- /* @__PURE__ */b("div",{className:"fixed inset-0 flex items-center justify-center p-4",onClick:v?void 0:e=>{e.target===e.currentTarget&&i()},children:/* @__PURE__ */h("div",{ref:C,...W({role:m,modal:!0,titleId:a?O:void 0,labelledBy:w,label:x}),"aria-describedby":N??(u?P:f?E:void 0),className:`relative max-h-full w-full ${D[p]} overflow-y-auto overscroll-contain rounded-(--radius-card) bg-white p-6 shadow-xl ${k}`.trim(),children:[a&&/* @__PURE__ */b("h2",{id:O,className:(j?"pr-8 ":"")+"text-base font-semibold text-gray-900",children:a}),u&&/* @__PURE__ */b("p",{id:P,className:((a?"mt-1":j?"pr-8":"")+" text-sm text-gray-500").trim(),children:u}),f&&/* @__PURE__ */b("div",{id:E,className:"mt-2 text-sm text-gray-600",children:f}),g&&/* @__PURE__ */b("div",{className:"mt-6 flex flex-wrap justify-end gap-3",children:g}),j&&/* @__PURE__ */b("button",{type:"button",onClick:i,"aria-label":T.close,className:"absolute right-3 top-3 rounded-(--radius-control) 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__ */b(l,{name:"close",className:"h-5 w-5",strokeWidth:"2",strokeLinecap:"round","aria-hidden":"true"})})]})})]}):null}var T=a(()=>Promise.resolve(!1)),F=()=>u(T),R=()=>Promise.resolve(!1),$=e=>R(e),K=()=>Promise.resolve(!1),A=e=>K(e),S=()=>Promise.resolve(null),B=e=>S(e),J={danger:{icon:"text-red-600 bg-red-100",button:r({variant:"danger"})},warning:{icon:"text-yellow-600 bg-yellow-100",button:r({variant:"warning"})},info:{icon:"text-blue-600 bg-blue-100",button:r({variant:"primary"})}},M=r({variant:"secondary"}),z=r({variant:"primary"}),G="w-full rounded-md border border-gray-300 h-8 px-3 text-sm";function Q(){/* @__PURE__ */
4
- return b(l,{name:"warning",className:"h-5 w-5",strokeWidth:1.5,"aria-hidden":"true"})}function U(){/* @__PURE__ */
5
- return b(l,{name:"close",className:"h-5 w-5",strokeWidth:1.5,"aria-hidden":"true"})}function V({children:e}){const[t,n]=m(!1),[r,l]=m({message:""}),[a,d]=m(0),u=c(),v=c(null),p=c(0),y=c([]),x=c(null),w=c(null),N=f(e=>{v.current=e.id,u.current=e.resolve,d(e.id),l(e.options),n(!0)},[]),k=f(e=>{const t="string"==typeof e?{message:e}:e;return new Promise(e=>{const n={id:++p.current,options:t,resolve:e};null===v.current?N(n):y.current.push(n)})},[N]),[C,E]=m(!1),[L,P]=m({message:""}),[j,I]=m(""),W=c(),D=f(e=>(P(e),I(""),E(!0),new Promise(e=>{W.current=e})),[]),[F,$]=m(!1),[A,B]=m({}),[V,_]=m(""),q=c(),X=f(e=>{const t="string"==typeof e?{message:e}:e;return B(t),_(t.defaultValue??""),$(!0),new Promise(e=>{q.current=e})},[]);s(()=>{R=k,K=D,S=X},[k,D,X]);const Y=(e,t)=>{if(v.current!==e)return;const r=u.current,l=y.current.shift();l?N(l):(v.current=null,u.current=void 0,n(!1)),r?.(t)},H=e=>{E(!1),I(""),W.current?.(e)},Z=e=>{if(e){const e=V.trim();if(!e&&!A.allowEmpty)return $(!1),void q.current?.(null);$(!1),q.current?.(e)}else $(!1),q.current?.(null)},ee=r.variant||(r.confirmLabel?.toLowerCase().includes("delete")||r.message.toLowerCase().includes("delete")?"danger":"info"),te=J[ee],ne=J["warning"===L.variant?"warning":"danger"],re=L.confirmWord,le=null==re||j===re,oe=o().dialog,[ie,ae]=i(oe.typeToConfirm);/* @__PURE__ */
3
+ /* @__PURE__ */b("div",{className:"fixed inset-0 flex items-center justify-center p-4",onClick:v?void 0:e=>{e.target===e.currentTarget&&o()},children:/* @__PURE__ */h("div",{ref:C,...D({role:m,modal:!0,titleId:a?O:void 0,labelledBy:w,label:x}),"aria-describedby":N??(u?P:f?E:void 0),className:`relative max-h-full w-full ${F[p]} overflow-y-auto overscroll-contain rounded-(--radius-card) bg-white p-6 shadow-xl ${k}`.trim(),children:[a&&/* @__PURE__ */b("h2",{id:O,className:(j?"pr-8 ":"")+"text-base font-semibold text-gray-900",children:a}),u&&/* @__PURE__ */b("p",{id:P,className:((a?"mt-1":j?"pr-8":"")+" text-sm text-gray-500").trim(),children:u}),f&&/* @__PURE__ */b("div",{id:E,className:"mt-2 text-sm text-gray-600",children:f}),g&&/* @__PURE__ */b("div",{className:"mt-6 flex flex-wrap justify-end gap-3",children:g}),j&&/* @__PURE__ */b("button",{type:"button",onClick:o,"aria-label":T.close,className:"absolute right-3 top-3 rounded-(--radius-control) 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__ */b(i,{name:"close",className:"h-5 w-5",strokeWidth:"2",strokeLinecap:"round","aria-hidden":"true"})})]})})]}):null}var T=a(()=>Promise.resolve(!1)),W=()=>u(T),R=()=>Promise.resolve(!1),$=e=>R(e),K=()=>Promise.resolve(!1),A=e=>K(e),S=()=>Promise.resolve(null),B=e=>S(e),M={danger:{icon:"text-red-600 bg-red-100",button:r({variant:"danger"})},warning:{icon:"text-yellow-600 bg-yellow-100",button:r({variant:"warning"})},info:{icon:"text-blue-600 bg-blue-100",button:r({variant:"primary"})}},Y=r({variant:"secondary"}),z=r({variant:"primary"}),G="w-full rounded-md border border-gray-300 h-8 px-3 text-sm";function J(){/* @__PURE__ */
4
+ return b(i,{name:"warning",className:"h-5 w-5",strokeWidth:1.5,"aria-hidden":"true"})}function Q(){/* @__PURE__ */
5
+ return b(i,{name:"close",className:"h-5 w-5",strokeWidth:1.5,"aria-hidden":"true"})}function U({children:e}){const[t,n]=m(!1),[r,i]=m({message:""}),[a,d]=m(0),u=c(),v=c(null),p=c(0),y=c([]),x=c(null),w=c(null),N=f(e=>{v.current=e.id,u.current=e.resolve,d(e.id),i(e.options),n(!0)},[]),k=f(e=>{const t="string"==typeof e?{message:e}:e;return new Promise(e=>{const n={id:++p.current,options:t,resolve:e};null===v.current?N(n):y.current.push(n)})},[N]),[C,E]=m(!1),[L,P]=m({message:""}),[j,I]=m(""),D=c(),F=f(e=>(P(e),I(""),E(!0),new Promise(e=>{D.current=e})),[]),[W,$]=m(!1),[A,B]=m({}),[U,V]=m(""),_=c(),q=f(e=>{const t="string"==typeof e?{message:e}:e;return B(t),V(t.defaultValue??""),$(!0),new Promise(e=>{_.current=e})},[]);s(()=>{R=k,K=F,S=q},[k,F,q]);const X=(e,t)=>{if(v.current!==e)return;const r=u.current,l=y.current.shift();l?N(l):(v.current=null,u.current=void 0,n(!1)),r?.(t)},H=e=>{E(!1),I(""),D.current?.(e)},Z=e=>{if(e){const e=U.trim();if(!e&&!A.allowEmpty)return $(!1),void _.current?.(null);$(!1),_.current?.(e)}else $(!1),_.current?.(null)},ee=r.variant||(r.confirmLabel?.toLowerCase().includes("delete")||r.message.toLowerCase().includes("delete")?"danger":"info"),te=M[ee],ne=M["warning"===L.variant?"warning":"danger"],re=L.confirmWord,le=null==re||j===re,oe=l().dialog,[ie,ae]=o(oe.typeToConfirm);/* @__PURE__ */
6
6
  return h(T.Provider,{value:k,children:[e,
7
- /* @__PURE__ */b(O,{open:t,onClose:()=>Y(a,!1),initialFocus:x,footer:/* @__PURE__ */h(g,{children:[
8
- /* @__PURE__ */b("button",{ref:x,type:"button",onClick:()=>Y(a,!1),className:M,children:r.cancelLabel||oe.cancel}),
9
- /* @__PURE__ */b("button",{type:"button",onClick:()=>Y(a,!0),className:te.button,children:r.confirmLabel||oe.ok})]}),children:/* @__PURE__ */h("div",{className:"flex gap-4",children:[
10
- /* @__PURE__ */b("div",{className:`shrink-0 w-10 h-10 rounded-full flex items-center justify-center ${te.icon}`,children:/* @__PURE__ */b(Q,{})}),
7
+ /* @__PURE__ */b(O,{open:t,onClose:()=>X(a,!1),initialFocus:x,footer:/* @__PURE__ */h(g,{children:[
8
+ /* @__PURE__ */b("button",{ref:x,type:"button",onClick:()=>X(a,!1),className:Y,children:r.cancelLabel||oe.cancel}),
9
+ /* @__PURE__ */b("button",{type:"button",onClick:()=>X(a,!0),className:te.button,children:r.confirmLabel||oe.ok})]}),children:/* @__PURE__ */h("div",{className:"flex gap-4",children:[
10
+ /* @__PURE__ */b("div",{className:`shrink-0 w-10 h-10 rounded-full flex items-center justify-center ${te.icon}`,children:/* @__PURE__ */b(J,{})}),
11
11
  /* @__PURE__ */h("div",{className:"flex-1",children:[
12
12
  /* @__PURE__ */b("h2",{className:"text-base font-semibold text-gray-900",children:r.title||oe.confirmTitle}),
13
13
  /* @__PURE__ */b("p",{className:"mt-2 text-sm text-gray-600",children:r.message})]})]})}),
14
14
  /* @__PURE__ */h(O,{open:C,onClose:()=>H(!1),initialFocus:null!=re?void 0:w,footer:/* @__PURE__ */h(g,{children:[
15
- /* @__PURE__ */b("button",{ref:w,type:"button",onClick:()=>H(!1),className:M,children:L.cancelLabel||oe.destructiveCancel}),
15
+ /* @__PURE__ */b("button",{ref:w,type:"button",onClick:()=>H(!1),className:Y,children:L.cancelLabel||oe.destructiveCancel}),
16
16
  /* @__PURE__ */b("button",{type:"button",onClick:()=>H(!0),disabled:!le,className:ne.button,children:re??L.confirmLabel??oe.destructiveConfirm})]}),children:[
17
- /* @__PURE__ */b("button",{type:"button",onClick:()=>H(!1),"aria-label":oe.close,className:"absolute right-4 top-4 rounded-md p-1 text-gray-400 hover:bg-gray-100 hover:text-gray-600",children:/* @__PURE__ */b(U,{})}),
17
+ /* @__PURE__ */b("button",{type:"button",onClick:()=>H(!1),"aria-label":oe.close,className:"absolute right-4 top-4 rounded-md p-1 text-gray-400 hover:bg-gray-100 hover:text-gray-600",children:/* @__PURE__ */b(Q,{})}),
18
18
  /* @__PURE__ */h("div",{className:"flex gap-4",children:[
19
- /* @__PURE__ */b("div",{className:`shrink-0 w-10 h-10 rounded-full flex items-center justify-center ${ne.icon}`,children:/* @__PURE__ */b(Q,{})}),
19
+ /* @__PURE__ */b("div",{className:`shrink-0 w-10 h-10 rounded-full flex items-center justify-center ${ne.icon}`,children:/* @__PURE__ */b(J,{})}),
20
20
  /* @__PURE__ */h("div",{className:"flex-1",children:[
21
21
  /* @__PURE__ */b("h2",{className:"text-base font-semibold text-gray-900 pr-6",children:L.title||oe.destructiveTitle}),
22
22
  /* @__PURE__ */b("p",{className:"mt-2 text-sm text-gray-600",children:L.message}),null!=re&&/* @__PURE__ */h(g,{children:[
23
23
  /* @__PURE__ */h("p",{className:"mt-3 text-sm text-gray-700",children:[ie,
24
24
  /* @__PURE__ */b("kbd",{className:"rounded border border-gray-300 bg-gray-50 px-2 py-0.5 text-xs font-bold text-red-600 font-mono",children:re}),ae]}),
25
25
  /* @__PURE__ */b("input",{autoFocus:!0,type:"text",value:j,onChange:e=>I(e.target.value),onKeyDown:e=>{"Enter"===e.key&&j===re&&H(!0)},placeholder:re,className:`mt-2 ${G} focus:border-red-500`})]})]})]})]}),
26
- /* @__PURE__ */h(O,{open:F,onClose:()=>Z(!1),title:A.title||oe.promptTitle,footer:/* @__PURE__ */h(g,{children:[
27
- /* @__PURE__ */b("button",{type:"button",onClick:()=>Z(!1),className:M,children:A.cancelLabel||oe.cancel}),
28
- /* @__PURE__ */b("button",{type:"button",onClick:()=>Z(!0),disabled:!A.allowEmpty&&!V.trim(),className:z,children:A.confirmLabel||oe.ok})]}),children:[A.message&&/* @__PURE__ */b("p",{className:"text-sm text-gray-600",children:A.message}),
29
- /* @__PURE__ */b("input",{autoFocus:!0,type:"text",value:V,onChange:e=>_(e.target.value),onKeyDown:e=>{"Enter"===e.key?Z(!0):"Escape"===e.key&&Z(!1)},onFocus:e=>e.target.select(),placeholder:A.placeholder,className:`mt-3 ${G} focus:border-blue-500 rosh-focus-ring focus-visible:ring-1 focus-visible:ring-[color:var(--rosh-focus-ring-accent)]`})]})]})}export{V as ConfirmProvider,O as Dialog,$ as confirm,A as confirmDestructive,W as dialogA11y,k as focusableIn,B as prompt,E as stopAfter,F as useConfirm,L as useFocusTrap,I as useScrollLock,C as useTabLayer};
26
+ /* @__PURE__ */h(O,{open:W,onClose:()=>Z(!1),title:A.title||oe.promptTitle,footer:/* @__PURE__ */h(g,{children:[
27
+ /* @__PURE__ */b("button",{type:"button",onClick:()=>Z(!1),className:Y,children:A.cancelLabel||oe.cancel}),
28
+ /* @__PURE__ */b("button",{type:"button",onClick:()=>Z(!0),disabled:!A.allowEmpty&&!U.trim(),className:z,children:A.confirmLabel||oe.ok})]}),children:[A.message&&/* @__PURE__ */b("p",{className:"text-sm text-gray-600",children:A.message}),
29
+ /* @__PURE__ */b("input",{autoFocus:!0,type:"text",value:U,onChange:e=>V(e.target.value),onKeyDown:e=>{"Enter"===e.key?Z(!0):"Escape"===e.key&&Z(!1)},onFocus:e=>e.target.select(),placeholder:A.placeholder,className:`mt-3 ${G} focus:border-blue-500 rosh-focus-ring focus-visible:ring-1 focus-visible:ring-[color:var(--rosh-focus-ring-accent)]`})]})]})}export{U as ConfirmProvider,O as Dialog,$ as confirm,A as confirmDestructive,D as dialogA11y,k as focusableIn,B as prompt,E as stopAfter,W as useConfirm,L as useFocusTrap,I as useScrollLock,C as useTabLayer};
@@ -1 +1 @@
1
- import{DEFAULT_SHELL_STRINGS as e,useShellStrings as t}from"./chunk-W7W4JMOT.js";import{useRef as r,useState as n,useCallback as s}from"react";import{jsx as a}from"react/jsx-runtime";function o(e,t){const r=(t??"").split(",").map(e=>e.trim().toLocaleLowerCase()).filter(Boolean);if(0===r.length||r.includes("*")||r.includes("*/*"))return!0;const n=e.name.toLocaleLowerCase(),s=e.type.toLocaleLowerCase();return r.some(e=>e.startsWith(".")?n.endsWith(e):e.endsWith("/*")?s.startsWith(e.slice(0,-1)):s===e)}var l=(t,r=e.files)=>t<1024?r.bytes(t):t<1048576?r.kilobytes(Math.round(t/1024)):r.megabytes(t/1048576),i=e=>Array.from(e.dataTransfer?.types??[]).includes("Files");function c({onAccept:e,accept:a,maxSizeBytes:c,maxFiles:u,multiple:f=!0,currentCount:p=0,acceptHint:m,disabled:d=!1}){const h=t().files,g=r(null),[y,x]=n(!1),[v,D]=n([]),L=r(0),b="string"==typeof m?m:"",A=s(t=>{if(d||!t)return;const r=Array.from(t);if(0===r.length)return;const n=[],s=[];for(const e of f?r:r.slice(0,1))o(e,a)?null!=c&&e.size>c?s.push({file:e,reason:"size",message:h.tooLarge(e.name,l(e.size,h),l(c,h))}):f&&null!=u&&p+n.length>=u?s.push({file:e,reason:"count",message:h.tooMany(e.name,u)}):n.push(e):s.push({file:e,reason:"type",message:h.notAccepted(e.name,b)});D(s),n.length&&e(n),g.current&&(g.current.value="")},[d,f,a,b,c,u,p,e,h]),W=s(()=>{d||g.current?.click()},[d]),j=s(()=>D([]),[]);return{inputRef:g,inputProps:{ref:g,type:"file",accept:a||void 0,multiple:f,disabled:d,tabIndex:-1,"aria-hidden":!0,className:"hidden",onChange:e=>A(e.target.files)},zoneProps:d?{}:{onDragEnter:e=>{i(e)&&(e.preventDefault(),L.current+=1,x(!0))},onDragOver:e=>{i(e)&&(e.preventDefault(),y||x(!0))},onDragLeave:e=>{i(e)&&(L.current=Math.max(0,L.current-1),0===L.current&&x(!1))},onDrop:e=>{i(e)&&(e.preventDefault(),L.current=0,x(!1),A(e.dataTransfer.files))}},pasteProps:d?{}:{onPaste:e=>{const t=function(e){const t=e.clipboardData;if(!t)return[];if(t.files&&t.files.length>0)return Array.from(t.files);const r=[];for(const e of Array.from(t.items??[]))if("file"===e.kind){const t=e.getAsFile();t&&r.push(t)}return r}(e);0!==t.length&&(e.preventDefault(),A(t))}},open:W,take:A,dragOver:y,rejections:v,clearRejections:j}}function u({rejections:e,className:t="mt-2"}){return 0===e.length?null:/* @__PURE__ */a("ul",{role:"alert",className:`${t} flex flex-col gap-0.5`,children:e.map(({file:e,message:t},r)=>/* @__PURE__ */a("li",{className:"text-xs text-red-600",children:t},`${e.name}-${r}`))})}export{u as FileIntakeAlert,o as acceptsFile,l as humanSize,c as useFileIntake};
1
+ import{DEFAULT_SHELL_STRINGS as e,useShellStrings as t}from"./chunk-3IML3Y3Y.js";import{useRef as r,useState as n,useCallback as s}from"react";import{jsx as a}from"react/jsx-runtime";function o(e,t){const r=(t??"").split(",").map(e=>e.trim().toLocaleLowerCase()).filter(Boolean);if(0===r.length||r.includes("*")||r.includes("*/*"))return!0;const n=e.name.toLocaleLowerCase(),s=e.type.toLocaleLowerCase();return r.some(e=>e.startsWith(".")?n.endsWith(e):e.endsWith("/*")?s.startsWith(e.slice(0,-1)):s===e)}var l=(t,r=e.files)=>t<1024?r.bytes(t):t<1048576?r.kilobytes(Math.round(t/1024)):r.megabytes(t/1048576),i=e=>Array.from(e.dataTransfer?.types??[]).includes("Files");function c({onAccept:e,accept:a,maxSizeBytes:c,maxFiles:u,multiple:f=!0,currentCount:p=0,acceptHint:m,disabled:d=!1}){const h=t().files,g=r(null),[y,x]=n(!1),[v,D]=n([]),L=r(0),b="string"==typeof m?m:"",A=s(t=>{if(d||!t)return;const r=Array.from(t);if(0===r.length)return;const n=[],s=[];for(const e of f?r:r.slice(0,1))o(e,a)?null!=c&&e.size>c?s.push({file:e,reason:"size",message:h.tooLarge(e.name,l(e.size,h),l(c,h))}):f&&null!=u&&p+n.length>=u?s.push({file:e,reason:"count",message:h.tooMany(e.name,u)}):n.push(e):s.push({file:e,reason:"type",message:h.notAccepted(e.name,b)});D(s),n.length&&e(n),g.current&&(g.current.value="")},[d,f,a,b,c,u,p,e,h]),j=s(()=>{d||g.current?.click()},[d]),k=s(()=>D([]),[]);return{inputRef:g,inputProps:{ref:g,type:"file",accept:a||void 0,multiple:f,disabled:d,tabIndex:-1,"aria-hidden":!0,className:"hidden",onChange:e=>A(e.target.files)},zoneProps:d?{}:{onDragEnter:e=>{i(e)&&(e.preventDefault(),L.current+=1,x(!0))},onDragOver:e=>{i(e)&&(e.preventDefault(),y||x(!0))},onDragLeave:e=>{i(e)&&(L.current=Math.max(0,L.current-1),0===L.current&&x(!1))},onDrop:e=>{i(e)&&(e.preventDefault(),L.current=0,x(!1),A(e.dataTransfer.files))}},pasteProps:d?{}:{onPaste:e=>{const t=function(e){const t=e.clipboardData;if(!t)return[];if(t.files&&t.files.length>0)return Array.from(t.files);const r=[];for(const e of Array.from(t.items??[]))if("file"===e.kind){const t=e.getAsFile();t&&r.push(t)}return r}(e);0!==t.length&&(e.preventDefault(),A(t))}},open:j,take:A,dragOver:y,rejections:v,clearRejections:k}}function u({rejections:e,className:t="mt-2"}){return 0===e.length?null:/* @__PURE__ */a("ul",{role:"alert",className:`${t} flex flex-col gap-0.5`,children:e.map(({file:e,message:t},r)=>/* @__PURE__ */a("li",{className:"text-xs text-red-600",children:t},`${e.name}-${r}`))})}export{u as FileIntakeAlert,o as acceptsFile,l as humanSize,c as useFileIntake};
@@ -1,2 +1,2 @@
1
- import{useShellAuth as e}from"./chunk-DSSLOQDW.js";var t={};function r(e){t=e}function n(){const{hasAnyPerm:r}=e();return{user:t.user,logout:t.logout??(()=>{}),hasAnyPerm:r}}var o="react-os-shell:sidebar-collapsed",c="react-os-shell:sidebar-open-sections";function s(e,t){return"true"===e||"false"!==e&&t<1024}function a(e){if(!e)/* @__PURE__ */return new Set;try{const t=JSON.parse(e);if(Array.isArray(t)&&t.every(e=>"string"==typeof e))return new Set(t)}catch{}/* @__PURE__ */
1
+ import{useShellAuth as e}from"./chunk-LHHIRTEG.js";var t={};function r(e){t=e}function n(){const{hasAnyPerm:r}=e();return{user:t.user,logout:t.logout??(()=>{}),hasAnyPerm:r}}var o="react-os-shell:sidebar-collapsed",c="react-os-shell:sidebar-open-sections";function s(e,t){return"true"===e||"false"!==e&&t<1024}function a(e){if(!e)/* @__PURE__ */return new Set;try{const t=JSON.parse(e);if(Array.isArray(t)&&t.every(e=>"string"==typeof e))return new Set(t)}catch{}/* @__PURE__ */
2
2
  return new Set}function u(e,t){const r=new Set(e);return r.has(t)?r.delete(t):r.add(t),r}function l(e){try{return localStorage.getItem(e)}catch{return null}}function i(e,t){try{localStorage.setItem(e,t)}catch{}}export{o as RAIL_COLLAPSED_KEY,c as RAIL_OPEN_SECTIONS_KEY,s as initialRailCollapsed,a as parseOpenSections,l as readStored,r as setShellAuthBridge,u as toggleOpenSection,n as useAuth,i as writeStored};
@@ -1,27 +1,27 @@
1
- import{navVisible as e,isReachable as t,visibleChildren as n,isSection as r}from"./chunk-5A7MWTXX.js";import{useDismissPopupsOnOpen as a}from"./chunk-UVBK6YSR.js";import{glassStyle as l}from"./chunk-7IQ3B77H.js";import{Z_LAYERS as o}from"./chunk-FIEA5CGB.js";import{useShellStrings as s}from"./chunk-W7W4JMOT.js";import{SpinnerRing as i,LoadingSpinner as c}from"./chunk-2J6F4EE7.js";import{useState as d,useEffect as u,useRef as p,useMemo as y,useId as f,useCallback as m}from"react";import{jsx as h,jsxs as b}from"react/jsx-runtime";import{createPortal as g}from"react-dom";var k={favicon:"h-8 w-8",compact:"h-10 w-10",wordmark:"h-10 w-40"};function x(e){return e.trim().charAt(0).toLocaleUpperCase()||"·"}function v(e,t,n){return!1===e?"framed":null==e||null==t?"plate-light":t?"light"===n?"plate-dark":"bare":"dark"===n?"plate-light":"bare"}var w={"plate-light":"bg-white shadow-[0_2px_12px_var(--rosh-mark-plate-shadow)]","plate-dark":"bg-neutral-900 shadow-[0_2px_12px_var(--rosh-mark-plate-shadow-strong)]",framed:"border border-black/10 shadow-[0_2px_12px_var(--rosh-mark-plate-shadow)]",bare:""};function N(e,t,n){return"bare"===e?{}:"framed"===e?{borderRadius:t}:{borderRadius:t,padding:n}}function _({src:e,fallbackSrc:t,fallbackHasAlpha:n=null,fallbackIsLight:r=null,fallbackAdaptive:a,alt:l,slot:o="compact",surface:s="light",size:i,width:c,height:p,decorative:y=!1,fallbackMode:f="monogram",adaptive:m=!1,hasAlpha:b=null,isLight:g=null,treatmentPadding:_=4,treatmentRadius:L=8,className:A="",style:C}){const[E,$]=d(e||t||"");u(()=>{$(e||t||"")},[e,t]);const T=Boolean(t&&E===t&&E!==e),I=(T?a??m:m)?v(T?n:b,T?r:g,s):"bare",j=["inline-flex shrink-0 items-center justify-center overflow-hidden",null==i&&null==c&&null==p?k[o]:"","dark"===s?"text-white":"text-gray-700",w[I],A].filter(Boolean).join(" "),S={...N(I,L,_),...null==i?{width:c,height:p}:{width:i,height:i},...C};return E?/* @__PURE__ */h("span",{className:j,"data-brand-treatment":I,style:S,children:/* @__PURE__ */h("img",{src:E,alt:y?"":l,"data-brand-slot":o,className:"block max-h-full max-w-full",style:{objectFit:"contain"},onError:()=>$(e=>t&&e!==t?t:"")})}):"none"===f?null:/* @__PURE__ */h("span",{"data-brand-fallback":!0,"data-brand-slot":o,"aria-label":y?void 0:l,"aria-hidden":y||void 0,role:y?void 0:"img",className:`${j} rounded-md bg-gray-100 font-semibold`,style:S,children:y?null:x(l)})}function L(n,r){return e(n,r)?n.items.filter(n=>e(n,r)&&t(n,r)):[]}function A(e,r){return n(e,r).filter(e=>t(e,r))}function C(n,a,l){const o=new Set(a.erp),s=new Set(a.system),i=new Set(a.footer??[]),c=n.filter(r),d=e=>c.filter(t=>e.has(t.label)&&L(t,l).length>0);return{topItems:n.filter(e=>!r(e)).filter(n=>e(n,l)&&t(n,l)),erpSections:d(o),systemSections:d(s),virtualSections:(a.virtual??[]).filter(e=>e.items.length>0),footerSections:d(i),footerItems:(a.footerItems??[]).filter(n=>e(n,l)&&t(n,l))}}function E(e,t,n){return!!t&&e.some(e=>e.to===t||E(A(e,n),t,n))}var $="__page__";function T(e){const t=e.indexOf("?");if(t<0)return{path:e,search:""};const n=new URLSearchParams(e.slice(t+1));return{path:e.slice(0,t),search:n.get("search")??""}}function I(e,t,n){const r=function(e,t){const n=[],r=e=>{const a=A(e,t);0===a.length?n.push(e):a.forEach(r)};e.topItems.forEach(r);for(const n of[...e.erpSections,...e.systemSections,...e.footerSections])L(n,t).forEach(r);for(const t of e.virtualSections)t.items.forEach(r);return e.footerItems.forEach(r),n}(e,t);return Object.assign(async e=>{const t=e.trim().toLowerCase();if(!t)return[];const a=/* @__PURE__ */new Set,l=[];for(const e of r){const r=e.menuLabel??e.label;a.has(e.to)||!e.label.toLowerCase().includes(t)&&!r.toLowerCase().includes(t)||(a.add(e.to),l.push({type:n,label:e.label,entity_type:$,entity_id:e.to}))}return l.slice(0,8)},{destinations:r})}function j(e,t){if(!Array.isArray(e))return[];const n=[];for(const r of e){if(!r||"string"!=typeof r.entityType||"string"!=typeof r.entityId||"string"!=typeof r.label)continue;if("preview-file"===r.entityType)continue;const e="page"===r.entityType;n.push({type:e?t:"",label:r.label,entity_type:e?$:r.entityType,entity_id:r.entityId})}return n}var S="M21 21l-5.197-5.197m0 0A7.5 7.5 0 105.196 5.196a7.5 7.5 0 0010.607 10.607z";function M(e){return e.typeKey??e.type}function R(e,t){return t?.[M(e)]??e.type}function K(e,t,n){return 0===n.length?null:{key:e,title:t,rows:n.map((e,t)=>({kind:"action",key:`action:${t}:${e.label}`,label:e.label,icon:e.icon,action:e})),count:n.length}}function B(e,t,n,r){return{type:e,label:t,entity_type:$,entity_id:`${n}?search=${encodeURIComponent(r.trim())}`}}function D(e,t,n,r,a){const l=function(e){const t=/* @__PURE__ */new Map;for(const n of e){const e=M(n),r=t.get(e);r?r.results.push(n):t.set(e,{type:n.type,results:[n]})}return Array.from(t,([e,t])=>({key:e,...t}))}(e).map(e=>{const t=e.results.map((t,n)=>({kind:"result",key:`result:${e.key}:${t.entity_type}:${t.entity_id}:${n}`,label:t.label,sub:t.sub,result:t})),r=!!a?.truncatedTypes?.includes(e.key),l=r?a?.listRoutes?.[e.key]:void 0,o=a?.typeLabels?.[e.key]??e.type;if(a&&l){const r=a.seeAllLabel(l.label);t.push({kind:"seeAll",key:`seeall:${e.key}`,label:r,result:B(o,r,l.path,n)})}return{key:`type:${e.key}`,title:o,rows:t,count:e.results.length,truncated:r}}),o=K("actions",r,function(e,t){const n=t.trim().toLowerCase();return e&&n?e.filter(e=>e.label.toLowerCase().includes(n)||(e.keywords??[]).some(e=>e.toLowerCase().includes(n))):[]}(t,n));return o?[...l,o]:l}function P(e,t,n){return 0===n?0:Math.min(Math.max(e+t,0),n-1)}var z=(e,t)=>e.entity_type===t.entity_type&&e.entity_id===t.entity_id;function F(e,t,n=8){return[t,...e.filter(e=>!z(e,t))].slice(0,n)}function H(e){if(!Array.isArray(e))return[];const t=[];for(const n of e){if(!n||"object"!=typeof n)continue;const e=n;if("string"!=typeof e.type||"string"!=typeof e.label||"string"!=typeof e.entity_type||"string"!=typeof e.entity_id)continue;const r={type:e.type,label:e.label,entity_type:e.entity_type,entity_id:e.entity_id};"string"==typeof e.sub&&(r.sub=e.sub),"string"==typeof e.typeKey&&(r.typeKey=e.typeKey),t.some(e=>z(e,r))||t.push(r)}return t.slice(0,8)}function U(e){if(Array.isArray(e))return{results:e,truncatedTypes:[]};if(e&&"object"==typeof e&&Array.isArray(e.results)){const{results:t,truncatedTypes:n}=e;return{results:t,truncatedTypes:Array.isArray(n)?n:[]}}return{results:[],truncatedTypes:[]}}var W=[];function O(e,t,n){const[r,a]=d([]),[l,o]=d(W),[s,i]=d(!1),[c,y]=d("none"),f=p(function(){let e=0,t=null;const n=()=>{e+=1,t?.abort(),t=null};return{begin:()=>{n();const r=e,a=new AbortController;return t=a,{signal:a.signal,isCurrent:()=>r===e}},cancel:n}}());u(()=>{const r=f.current;if(e.length<n||!t||0===t.length)return r.cancel(),a(e=>0===e.length?e:[]),o(W),y("none"),void i(!1);i(!0);const l=setTimeout(async()=>{const n=r.begin(),l=await async function(e,t,n){const r=await Promise.all(e.map(async e=>{try{return{failed:!1,...U(await e(t,{signal:n}))}}catch(e){const t=n.aborted||function(e){if(!e||"object"!=typeof e)return!1;const{name:t,code:n}=e;return"AbortError"===t||"CanceledError"===t||"ERR_CANCELED"===n}(e);return{failed:!t,results:[],truncatedTypes:[]}}}));return{results:r.flatMap(e=>e.results),truncatedTypes:Array.from(new Set(r.flatMap(e=>e.truncatedTypes))),failed:r.filter(e=>e.failed).length}}(t,e,n.signal);n.isCurrent()&&(a(l.results),o(l.truncatedTypes),y(0===l.failed?"none":l.failed>=t.length?"all":"some"),i(!1))},250);return()=>{clearTimeout(l),r.cancel()}},[e,t,n]);return{results:r,truncatedTypes:l,loading:s,failure:c,reset:m(()=>{f.current.cancel(),a(e=>0===e.length?e:[]),o(W),y("none"),i(!1)},[])}}var G=(e,t)=>`${e}-opt-${t}`;function J(e,t){if("seeAll"===e.kind)return"M13.5 4.5L21 12m0 0l-7.5 7.5M21 12H3";if("action"===e.kind)return e.icon??S;if(e.icon)return e.icon;const n=t?.[M(e.result)];return n||S}function V({sections:e,activeIdx:t,listId:n,label:r,typeIcons:a,groupCount:l,groupLabel:o,onHover:s,onPick:i}){let c=0;/* @__PURE__ */
1
+ import{navVisible as e,isReachable as t,visibleChildren as n,isSection as r}from"./chunk-5A7MWTXX.js";import{useDismissPopupsOnOpen as a}from"./chunk-UVBK6YSR.js";import{glassStyle as l}from"./chunk-7IQ3B77H.js";import{Z_LAYERS as o}from"./chunk-FIEA5CGB.js";import{useShellStrings as s}from"./chunk-3IML3Y3Y.js";import{SpinnerRing as i,LoadingSpinner as c}from"./chunk-2J6F4EE7.js";import{useState as d,useEffect as u,useRef as p,useMemo as y,useId as f,useCallback as m}from"react";import{jsx as h,jsxs as b}from"react/jsx-runtime";import{createPortal as g}from"react-dom";var k={favicon:"h-8 w-8",compact:"h-10 w-10",wordmark:"h-10 w-40"};function x(e){return e.trim().charAt(0).toLocaleUpperCase()||"·"}function v(e,t,n){return!1===e?"framed":null==e||null==t?"plate-light":t?"light"===n?"plate-dark":"bare":"dark"===n?"plate-light":"bare"}var w={"plate-light":"bg-white shadow-[0_2px_12px_var(--rosh-mark-plate-shadow)]","plate-dark":"bg-neutral-900 shadow-[0_2px_12px_var(--rosh-mark-plate-shadow-strong)]",framed:"border border-black/10 shadow-[0_2px_12px_var(--rosh-mark-plate-shadow)]",bare:""};function N(e,t,n){return"bare"===e?{}:"framed"===e?{borderRadius:t}:{borderRadius:t,padding:n}}function L({src:e,fallbackSrc:t,fallbackHasAlpha:n=null,fallbackIsLight:r=null,fallbackAdaptive:a,alt:l,slot:o="compact",surface:s="light",size:i,width:c,height:p,decorative:y=!1,fallbackMode:f="monogram",adaptive:m=!1,hasAlpha:b=null,isLight:g=null,treatmentPadding:L=4,treatmentRadius:_=8,className:A="",style:C}){const[E,$]=d(e||t||"");u(()=>{$(e||t||"")},[e,t]);const I=Boolean(t&&E===t&&E!==e),T=(I?a??m:m)?v(I?n:b,I?r:g,s):"bare",j=["inline-flex shrink-0 items-center justify-center overflow-hidden",null==i&&null==c&&null==p?k[o]:"","dark"===s?"text-white":"text-gray-700",w[T],A].filter(Boolean).join(" "),S={...N(T,_,L),...null==i?{width:c,height:p}:{width:i,height:i},...C};return E?/* @__PURE__ */h("span",{className:j,"data-brand-treatment":T,style:S,children:/* @__PURE__ */h("img",{src:E,alt:y?"":l,"data-brand-slot":o,className:"block max-h-full max-w-full",style:{objectFit:"contain"},onError:()=>$(e=>t&&e!==t?t:"")})}):"none"===f?null:/* @__PURE__ */h("span",{"data-brand-fallback":!0,"data-brand-slot":o,"aria-label":y?void 0:l,"aria-hidden":y||void 0,role:y?void 0:"img",className:`${j} rounded-md bg-gray-100 font-semibold`,style:S,children:y?null:x(l)})}function _(n,r){return e(n,r)?n.items.filter(n=>e(n,r)&&t(n,r)):[]}function A(e,r){return n(e,r).filter(e=>t(e,r))}function C(n,a,l){const o=new Set(a.erp),s=new Set(a.system),i=new Set(a.footer??[]),c=n.filter(r),d=e=>c.filter(t=>e.has(t.label)&&_(t,l).length>0);return{topItems:n.filter(e=>!r(e)).filter(n=>e(n,l)&&t(n,l)),erpSections:d(o),systemSections:d(s),virtualSections:(a.virtual??[]).filter(e=>e.items.length>0),footerSections:d(i),footerItems:(a.footerItems??[]).filter(n=>e(n,l)&&t(n,l))}}function E(e,t,n){return!!t&&e.some(e=>e.to===t||E(A(e,n),t,n))}var $="__page__";function I(e){const t=e.indexOf("?");if(t<0)return{path:e,search:""};const n=new URLSearchParams(e.slice(t+1));return{path:e.slice(0,t),search:n.get("search")??""}}function T(e,t,n){const r=function(e,t){const n=[],r=e=>{const a=A(e,t);0===a.length?n.push(e):a.forEach(r)};e.topItems.forEach(r);for(const n of[...e.erpSections,...e.systemSections,...e.footerSections])_(n,t).forEach(r);for(const t of e.virtualSections)t.items.forEach(r);return e.footerItems.forEach(r),n}(e,t);return Object.assign(async e=>{const t=e.trim().toLowerCase();if(!t)return[];const a=/* @__PURE__ */new Set,l=[];for(const e of r){const r=e.menuLabel??e.label;a.has(e.to)||!e.label.toLowerCase().includes(t)&&!r.toLowerCase().includes(t)||(a.add(e.to),l.push({type:n,label:e.label,entity_type:$,entity_id:e.to}))}return l.slice(0,8)},{destinations:r})}function j(e,t){if(!Array.isArray(e))return[];const n=[];for(const r of e){if(!r||"string"!=typeof r.entityType||"string"!=typeof r.entityId||"string"!=typeof r.label)continue;if("preview-file"===r.entityType)continue;const e="page"===r.entityType;n.push({type:e?t:"",label:r.label,entity_type:e?$:r.entityType,entity_id:r.entityId})}return n}var S="M21 21l-5.197-5.197m0 0A7.5 7.5 0 105.196 5.196a7.5 7.5 0 0010.607 10.607z";function M(e){return e.typeKey??e.type}function R(e,t){return t?.[M(e)]??e.type}function K(e,t,n){return 0===n.length?null:{key:e,title:t,rows:n.map((e,t)=>({kind:"action",key:`action:${t}:${e.label}`,label:e.label,icon:e.icon,action:e})),count:n.length}}function B(e,t,n,r){return{type:e,label:t,entity_type:$,entity_id:`${n}?search=${encodeURIComponent(r.trim())}`}}function D(e,t,n,r,a){const l=function(e){const t=/* @__PURE__ */new Map;for(const n of e){const e=M(n),r=t.get(e);r?r.results.push(n):t.set(e,{type:n.type,results:[n]})}return Array.from(t,([e,t])=>({key:e,...t}))}(e).map(e=>{const t=e.results.map((t,n)=>({kind:"result",key:`result:${e.key}:${t.entity_type}:${t.entity_id}:${n}`,label:t.label,sub:t.sub,result:t})),r=!!a?.truncatedTypes?.includes(e.key),l=r?a?.listRoutes?.[e.key]:void 0,o=a?.typeLabels?.[e.key]??e.type;if(a&&l){const r=a.seeAllLabel(l.label);t.push({kind:"seeAll",key:`seeall:${e.key}`,label:r,result:B(o,r,l.path,n)})}return{key:`type:${e.key}`,title:o,rows:t,count:e.results.length,truncated:r}}),o=K("actions",r,function(e,t){const n=t.trim().toLowerCase();return e&&n?e.filter(e=>e.label.toLowerCase().includes(n)||(e.keywords??[]).some(e=>e.toLowerCase().includes(n))):[]}(t,n));return o?[...l,o]:l}function P(e,t,n){return 0===n?0:Math.min(Math.max(e+t,0),n-1)}var z=(e,t)=>e.entity_type===t.entity_type&&e.entity_id===t.entity_id;function F(e,t,n=8){return[t,...e.filter(e=>!z(e,t))].slice(0,n)}function H(e){if(!Array.isArray(e))return[];const t=[];for(const n of e){if(!n||"object"!=typeof n)continue;const e=n;if("string"!=typeof e.type||"string"!=typeof e.label||"string"!=typeof e.entity_type||"string"!=typeof e.entity_id)continue;const r={type:e.type,label:e.label,entity_type:e.entity_type,entity_id:e.entity_id};"string"==typeof e.sub&&(r.sub=e.sub),"string"==typeof e.typeKey&&(r.typeKey=e.typeKey),t.some(e=>z(e,r))||t.push(r)}return t.slice(0,8)}function U(e){if(Array.isArray(e))return{results:e,truncatedTypes:[]};if(e&&"object"==typeof e&&Array.isArray(e.results)){const{results:t,truncatedTypes:n}=e;return{results:t,truncatedTypes:Array.isArray(n)?n:[]}}return{results:[],truncatedTypes:[]}}var W=[];function Y(e,t,n){const[r,a]=d([]),[l,o]=d(W),[s,i]=d(!1),[c,y]=d("none"),f=p(function(){let e=0,t=null;const n=()=>{e+=1,t?.abort(),t=null};return{begin:()=>{n();const r=e,a=new AbortController;return t=a,{signal:a.signal,isCurrent:()=>r===e}},cancel:n}}());u(()=>{const r=f.current;if(e.length<n||!t||0===t.length)return r.cancel(),a(e=>0===e.length?e:[]),o(W),y("none"),void i(!1);i(!0);const l=setTimeout(async()=>{const n=r.begin(),l=await async function(e,t,n){const r=await Promise.all(e.map(async e=>{try{return{failed:!1,...U(await e(t,{signal:n}))}}catch(e){const t=n.aborted||function(e){if(!e||"object"!=typeof e)return!1;const{name:t,code:n}=e;return"AbortError"===t||"CanceledError"===t||"ERR_CANCELED"===n}(e);return{failed:!t,results:[],truncatedTypes:[]}}}));return{results:r.flatMap(e=>e.results),truncatedTypes:Array.from(new Set(r.flatMap(e=>e.truncatedTypes))),failed:r.filter(e=>e.failed).length}}(t,e,n.signal);n.isCurrent()&&(a(l.results),o(l.truncatedTypes),y(0===l.failed?"none":l.failed>=t.length?"all":"some"),i(!1))},250);return()=>{clearTimeout(l),r.cancel()}},[e,t,n]);return{results:r,truncatedTypes:l,loading:s,failure:c,reset:m(()=>{f.current.cancel(),a(e=>0===e.length?e:[]),o(W),y("none"),i(!1)},[])}}var G=(e,t)=>`${e}-opt-${t}`;function O(e,t){if("seeAll"===e.kind)return"M13.5 4.5L21 12m0 0l-7.5 7.5M21 12H3";if("action"===e.kind)return e.icon??S;if(e.icon)return e.icon;const n=t?.[M(e.result)];return n||S}function V({sections:e,activeIdx:t,listId:n,label:r,typeIcons:a,groupCount:l,groupLabel:o,onHover:s,onPick:i}){let c=0;/* @__PURE__ */
2
2
  return h("div",{id:n,role:"listbox","aria-label":r,className:"py-1",children:e.map(e=>/* @__PURE__ */b("div",{role:"group","aria-label":o(e.title,e.count,!!e.truncated),children:[
3
3
  /* @__PURE__ */b("div",{"aria-hidden":"true",className:"flex items-center justify-between px-4 pt-2 pb-1 text-2xs font-semibold uppercase tracking-wide text-gray-400",children:[
4
4
  /* @__PURE__ */h("span",{children:e.title}),
5
5
  /* @__PURE__ */h("span",{className:"font-medium normal-case tracking-normal",children:l(e.count,!!e.truncated)})]}),e.rows.map(e=>{const r=c++,l=r===t,o="action"===e.kind||"seeAll"===e.kind?void 0:e.badge,d="action"===e.kind||"seeAll"===e.kind?void 0:e.sub,u="seeAll"===e.kind;/* @__PURE__ */
6
6
  return b("div",{id:G(n,r),role:"option","aria-selected":l,className:"flex items-center gap-3 w-full px-4 py-3 text-left cursor-pointer transition-colors "+(l?"bg-blue-50":"hover:bg-gray-50"),onMouseDown:e=>e.preventDefault(),onClick:()=>i(e),onMouseEnter:()=>s(r),children:[
7
- /* @__PURE__ */h("svg",{className:"h-4 w-4 text-gray-400 shrink-0",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,"aria-hidden":"true",children:/* @__PURE__ */h("path",{strokeLinecap:"round",strokeLinejoin:"round",d:J(e,a)})}),
7
+ /* @__PURE__ */h("svg",{className:"h-4 w-4 text-gray-400 shrink-0",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,"aria-hidden":"true",children:/* @__PURE__ */h("path",{strokeLinecap:"round",strokeLinejoin:"round",d:O(e,a)})}),
8
8
  /* @__PURE__ */b("div",{className:"flex-1 min-w-0",children:[
9
- /* @__PURE__ */h("p",{className:"text-sm font-medium truncate "+(u?"text-blue-600":"text-gray-900"),children:e.label}),d&&/* @__PURE__ */h("p",{className:"text-xs text-gray-400 truncate",children:d})]}),o&&/* @__PURE__ */h("span",{className:"shrink-0 rounded-full bg-gray-100 px-2 py-0.5 text-3xs font-medium text-gray-500",children:o})]},e.key)})]},e.key))})}var X="react-os-shell:open-global-search";function q(){"undefined"!=typeof window&&window.dispatchEvent(new CustomEvent(X))}function Q({providers:e,typeIcons:t,typeLabels:n,listRoutes:r,placeholder:k,quickActions:x,onSelect:v,recent:w,onRecord:N,favorites:_,hotkey:L=!0}={}){const A=s().search,C=k??A.placeholder,[E,$]=d(!1),[T,I]=d(""),[j,M]=d(0),B=p(null),{results:z,truncatedTypes:F,loading:H,failure:U,reset:W}=O(T,e,2);u(()=>{const e=e=>{L&&!e.defaultPrevented&&(e.ctrlKey||e.metaKey)&&"k"===e.key&&(e.preventDefault(),$(e=>!e)),"Escape"===e.key&&E&&$(!1)},t=()=>$(!0);return window.addEventListener("keydown",e),window.addEventListener(X,t),()=>{window.removeEventListener("keydown",e),window.removeEventListener(X,t)}},[E,L]),a(E);const[J,q]=d(!1);E!==J&&(q(E),E&&(I(""),M(0),W())),u(()=>{E?setTimeout(()=>B.current?.focus(),50):I("")},[E]),u(()=>{M(0)},[z]);const Q=T.length>=2,Y=y(()=>Q?D(z,x,T,A.actions,{truncatedTypes:F,listRoutes:r,typeLabels:n,seeAllLabel:A.seeAll}):function(e,t){const n=[];e.recent?.length&&n.push({key:"recent",title:t.recent,rows:e.recent.map((t,n)=>({kind:"recent",key:`recent:${t.entity_type}:${t.entity_id}:${n}`,label:t.label,sub:t.sub,badge:R(t,e.typeLabels),result:t})),count:e.recent.length}),e.favorites?.length&&n.push({key:"favorites",title:t.favorites,rows:e.favorites.map((t,n)=>({kind:"favorite",key:`favorite:${t.entity_type}:${t.entity_id}:${n}`,label:t.label,sub:t.sub,badge:R(t,e.typeLabels)||void 0,icon:"M11.48 3.499a.562.562 0 011.04 0l2.125 5.111a.563.563 0 00.475.345l5.518.442c.499.04.701.663.321.988l-4.204 3.602a.563.563 0 00-.182.557l1.285 5.385a.562.562 0 01-.84.61l-4.725-2.885a.563.563 0 00-.586 0L6.982 20.54a.562.562 0 01-.84-.61l1.285-5.386a.562.562 0 00-.182-.557l-4.204-3.602a.563.563 0 01.321-.988l5.518-.442a.563.563 0 00.475-.345L11.48 3.5z",result:t})),count:e.favorites.length});const r=K("actions",t.actions,e.actions??[]);return r&&n.push(r),n}({recent:w,favorites:_,actions:x,typeLabels:n},A),[Q,z,F,r,n,x,T,w,_,A]),Z=y(()=>function(e){return e.flatMap(e=>e.rows)}(Y),[Y]),ee=Math.min(j,Math.max(Z.length-1,0)),te=f(),ne=Z.length>0;u(()=>{E&&0!==Z.length&&document.getElementById(G(te,ee))?.scrollIntoView?.({block:"nearest"})},[E,ee,Z.length,te]);const re=m(e=>{$(!1),"action"!==e.kind?("result"!==e.kind&&"recent"!==e.kind||N?.(e.result),v?.(e.result)):e.action.onSelect()},[v,N]);return E?g(
9
+ /* @__PURE__ */h("p",{className:"text-sm font-medium truncate "+(u?"text-blue-600":"text-gray-900"),children:e.label}),d&&/* @__PURE__ */h("p",{className:"text-xs text-gray-400 truncate",children:d})]}),o&&/* @__PURE__ */h("span",{className:"shrink-0 rounded-full bg-gray-100 px-2 py-0.5 text-3xs font-medium text-gray-500",children:o})]},e.key)})]},e.key))})}var X="react-os-shell:open-global-search";function q(){"undefined"!=typeof window&&window.dispatchEvent(new CustomEvent(X))}function J({providers:e,typeIcons:t,typeLabels:n,listRoutes:r,placeholder:k,quickActions:x,onSelect:v,recent:w,onRecord:N,favorites:L,hotkey:_=!0}={}){const A=s().search,C=k??A.placeholder,[E,$]=d(!1),[I,T]=d(""),[j,M]=d(0),B=p(null),{results:z,truncatedTypes:F,loading:H,failure:U,reset:W}=Y(I,e,2);u(()=>{const e=e=>{_&&!e.defaultPrevented&&(e.ctrlKey||e.metaKey)&&"k"===e.key&&(e.preventDefault(),$(e=>!e)),"Escape"===e.key&&E&&$(!1)},t=()=>$(!0);return window.addEventListener("keydown",e),window.addEventListener(X,t),()=>{window.removeEventListener("keydown",e),window.removeEventListener(X,t)}},[E,_]),a(E);const[O,q]=d(!1);E!==O&&(q(E),E&&(T(""),M(0),W())),u(()=>{E?setTimeout(()=>B.current?.focus(),50):T("")},[E]),u(()=>{M(0)},[z]);const J=I.length>=2,Q=y(()=>J?D(z,x,I,A.actions,{truncatedTypes:F,listRoutes:r,typeLabels:n,seeAllLabel:A.seeAll}):function(e,t){const n=[];e.recent?.length&&n.push({key:"recent",title:t.recent,rows:e.recent.map((t,n)=>({kind:"recent",key:`recent:${t.entity_type}:${t.entity_id}:${n}`,label:t.label,sub:t.sub,badge:R(t,e.typeLabels),result:t})),count:e.recent.length}),e.favorites?.length&&n.push({key:"favorites",title:t.favorites,rows:e.favorites.map((t,n)=>({kind:"favorite",key:`favorite:${t.entity_type}:${t.entity_id}:${n}`,label:t.label,sub:t.sub,badge:R(t,e.typeLabels)||void 0,icon:"M11.48 3.499a.562.562 0 011.04 0l2.125 5.111a.563.563 0 00.475.345l5.518.442c.499.04.701.663.321.988l-4.204 3.602a.563.563 0 00-.182.557l1.285 5.385a.562.562 0 01-.84.61l-4.725-2.885a.563.563 0 00-.586 0L6.982 20.54a.562.562 0 01-.84-.61l1.285-5.386a.562.562 0 00-.182-.557l-4.204-3.602a.563.563 0 01.321-.988l5.518-.442a.563.563 0 00.475-.345L11.48 3.5z",result:t})),count:e.favorites.length});const r=K("actions",t.actions,e.actions??[]);return r&&n.push(r),n}({recent:w,favorites:L,actions:x,typeLabels:n},A),[J,z,F,r,n,x,I,w,L,A]),Z=y(()=>function(e){return e.flatMap(e=>e.rows)}(Q),[Q]),ee=Math.min(j,Math.max(Z.length-1,0)),te=f(),ne=Z.length>0;u(()=>{E&&0!==Z.length&&document.getElementById(G(te,ee))?.scrollIntoView?.({block:"nearest"})},[E,ee,Z.length,te]);const re=m(e=>{$(!1),"action"!==e.kind?("result"!==e.kind&&"recent"!==e.kind||N?.(e.result),v?.(e.result)):e.action.onSelect()},[v,N]);return E?g(
10
10
  /* @__PURE__ */b("div",{"data-global-search":"",className:"fixed inset-0 flex items-start justify-center pt-[15vh]",style:{zIndex:o.overlay},onClick:()=>$(!1),children:[
11
11
  /* @__PURE__ */h("div",{"data-global-search-backdrop":"",className:"absolute inset-0 bg-black/50 backdrop-blur-sm"}),
12
12
  /* @__PURE__ */b("div",{className:"relative z-10 w-full max-w-xl rounded-(--radius-popup) overflow-hidden",onClick:e=>e.stopPropagation(),style:l(),children:[
13
13
  /* @__PURE__ */b("div",{className:"flex items-center gap-3 px-4 py-3 border-b border-gray-200",children:[
14
14
  /* @__PURE__ */h("svg",{className:"h-5 w-5 text-gray-400 shrink-0",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:/* @__PURE__ */h("path",{strokeLinecap:"round",strokeLinejoin:"round",d:S})}),
15
- /* @__PURE__ */h("input",{ref:B,type:"text",value:T,onChange:e=>{I(e.target.value),M(0)},onKeyDown:e=>{"ArrowDown"===e.key?(e.preventDefault(),M(P(ee,1,Z.length))):"ArrowUp"===e.key?(e.preventDefault(),M(P(ee,-1,Z.length))):"Tab"===e.key&&Z.length>0?(e.preventDefault(),M(function(e,t,n){const r=e.length;if(0===r)return 0;const a=[];let l=0;for(const t of e)a.push(l),l+=t;let o=0;for(let e=0;e<r;e++)t>=a[e]&&(o=e);return a[(o+n+r)%r]}(Y.map(e=>e.rows.length),ee,e.shiftKey?-1:1))):"Enter"===e.key&&Z[ee]&&re(Z[ee])},placeholder:C,role:"combobox","aria-expanded":ne,"aria-controls":ne?te:void 0,"aria-activedescendant":ne?G(te,ee):void 0,"aria-autocomplete":"list",className:"flex-1 text-sm bg-transparent border-0 rosh-focus-ring placeholder-gray-400"}),H&&/* @__PURE__ */h("span",{"data-global-search-spinner":"",role:"status","aria-label":A.searching,className:"flex shrink-0",children:/* @__PURE__ */h(i,{className:"h-4 w-4",ink:"text-gray-500"})}),
15
+ /* @__PURE__ */h("input",{ref:B,type:"text",value:I,onChange:e=>{T(e.target.value),M(0)},onKeyDown:e=>{"ArrowDown"===e.key?(e.preventDefault(),M(P(ee,1,Z.length))):"ArrowUp"===e.key?(e.preventDefault(),M(P(ee,-1,Z.length))):"Tab"===e.key&&Z.length>0?(e.preventDefault(),M(function(e,t,n){const r=e.length;if(0===r)return 0;const a=[];let l=0;for(const t of e)a.push(l),l+=t;let o=0;for(let e=0;e<r;e++)t>=a[e]&&(o=e);return a[(o+n+r)%r]}(Q.map(e=>e.rows.length),ee,e.shiftKey?-1:1))):"Enter"===e.key&&Z[ee]&&re(Z[ee])},placeholder:C,role:"combobox","aria-expanded":ne,"aria-controls":ne?te:void 0,"aria-activedescendant":ne?G(te,ee):void 0,"aria-autocomplete":"list",className:"flex-1 text-sm bg-transparent border-0 rosh-focus-ring placeholder-gray-400"}),H&&/* @__PURE__ */h("span",{"data-global-search-spinner":"",role:"status","aria-label":A.searching,className:"flex shrink-0",children:/* @__PURE__ */h(i,{className:"h-4 w-4",ink:"text-gray-500"})}),
16
16
  /* @__PURE__ */h("kbd",{className:"hidden sm:inline-flex items-center rounded border border-gray-300 px-2 py-0.5 text-2xs font-medium text-gray-400",children:A.escBadge})]}),
17
- /* @__PURE__ */b("div",{className:"max-h-[50vh] overflow-y-auto",children:[H&&0===Z.length&&/* @__PURE__ */h(c,{size:"sm",padding:"py-6",label:A.searching}),!H&&"all"===U&&Q&&/* @__PURE__ */h("div",{role:"alert",className:"px-4 py-3 text-center text-sm text-red-600",children:A.searchFailed}),!H&&Q&&0===Z.length&&"all"!==U&&/* @__PURE__ */h("div",{className:"px-4 py-6 text-center text-sm text-gray-400",children:A.noResults}),ne&&/* @__PURE__ */h(V,{sections:Y,activeIdx:ee,listId:te,label:A.listLabel,typeIcons:t,groupCount:A.groupCount,groupLabel:A.groupLabel,onHover:M,onPick:re}),!H&&"some"===U&&Q&&/* @__PURE__ */h("div",{role:"status",className:"px-4 py-2 text-xs text-amber-600",children:A.partialFailure}),!H&&!Q&&0===Z.length&&/* @__PURE__ */h("div",{className:"px-4 py-6 text-center text-sm text-gray-400",children:A.minChars(2)})]}),
17
+ /* @__PURE__ */b("div",{className:"max-h-[50vh] overflow-y-auto",children:[H&&0===Z.length&&/* @__PURE__ */h(c,{size:"sm",padding:"py-6",label:A.searching}),!H&&"all"===U&&J&&/* @__PURE__ */h("div",{role:"alert",className:"px-4 py-3 text-center text-sm text-red-600",children:A.searchFailed}),!H&&J&&0===Z.length&&"all"!==U&&/* @__PURE__ */h("div",{className:"px-4 py-6 text-center text-sm text-gray-400",children:A.noResults}),ne&&/* @__PURE__ */h(V,{sections:Q,activeIdx:ee,listId:te,label:A.listLabel,typeIcons:t,groupCount:A.groupCount,groupLabel:A.groupLabel,onHover:M,onPick:re}),!H&&"some"===U&&J&&/* @__PURE__ */h("div",{role:"status",className:"px-4 py-2 text-xs text-amber-600",children:A.partialFailure}),!H&&!J&&0===Z.length&&/* @__PURE__ */h("div",{className:"px-4 py-6 text-center text-sm text-gray-400",children:A.minChars(2)})]}),
18
18
  /* @__PURE__ */b("div",{className:"flex items-center justify-between px-4 py-2 border-t border-gray-100 bg-gray-50 text-2xs text-gray-400",children:[
19
19
  /* @__PURE__ */b("div",{className:"flex items-center gap-3",children:[
20
20
  /* @__PURE__ */b("span",{className:"flex items-center gap-1",children:[
21
21
  /* @__PURE__ */h("kbd",{className:"rounded border border-gray-300 px-1 py-0.5 font-medium",children:"↑"}),
22
22
  /* @__PURE__ */h("kbd",{className:"rounded border border-gray-300 px-1 py-0.5 font-medium",children:"↓"}),` ${A.navigate}`]}),
23
23
  /* @__PURE__ */b("span",{className:"flex items-center gap-1",children:[
24
- /* @__PURE__ */h("kbd",{className:"rounded border border-gray-300 px-1 py-0.5 font-medium",children:A.enterKey}),` ${A.open}`]}),Y.length>1&&/* @__PURE__ */b("span",{className:"flex items-center gap-1",children:[
24
+ /* @__PURE__ */h("kbd",{className:"rounded border border-gray-300 px-1 py-0.5 font-medium",children:A.enterKey}),` ${A.open}`]}),Q.length>1&&/* @__PURE__ */b("span",{className:"flex items-center gap-1",children:[
25
25
  /* @__PURE__ */h("kbd",{className:"rounded border border-gray-300 px-1 py-0.5 font-medium",children:A.tabKey}),` ${A.nextGroup}`]})]}),
26
26
  /* @__PURE__ */b("span",{className:"flex items-center gap-1",children:[
27
- /* @__PURE__ */h("kbd",{className:"rounded border border-gray-300 px-1 py-0.5 font-medium",children:A.escKey}),` ${A.close}`]})]})]})]}),document.body):null}export{_ as BrandMark,Q as GlobalSearch,$ as PAGE_RESULT_ENTITY,j as favoritesToResults,I as navPagesProvider,q as openGlobalSearch,T as parsePageResultTarget,C as partitionNav,F as pushRecent,v as resolveBrandMarkTreatment,E as rowsContainRoute,H as sanitizeRecent,A as visibleNavChildren,L as visibleSectionItems};
27
+ /* @__PURE__ */h("kbd",{className:"rounded border border-gray-300 px-1 py-0.5 font-medium",children:A.escKey}),` ${A.close}`]})]})]})]}),document.body):null}export{L as BrandMark,J as GlobalSearch,$ as PAGE_RESULT_ENTITY,j as favoritesToResults,T as navPagesProvider,q as openGlobalSearch,I as parsePageResultTarget,C as partitionNav,F as pushRecent,v as resolveBrandMarkTreatment,E as rowsContainRoute,H as sanitizeRecent,A as visibleNavChildren,_ as visibleSectionItems};