efficient-shell 8.18.0 → 8.18.1

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 (63) hide show
  1. package/dist/{Browser-H5OJL6TK.js → Browser-EE7TUWTN.js} +14 -14
  2. package/dist/{Calculator-VHXRKH2M.js → Calculator-YTIRFXXR.js} +21 -21
  3. package/dist/{CurrencyConverter-5AIXDNF6.js → CurrencyConverter-NDMWLX7M.js} +6 -6
  4. package/dist/{Documents-352IGNWY.js → Documents-XSDBD4T7.js} +1 -1
  5. package/dist/{Files-ODENHLKQ.js → Files-B5HKRQN3.js} +18 -18
  6. package/dist/{Notepad-DWPTCM2I.js → Notepad-2SXHFPFX.js} +10 -10
  7. package/dist/{PomodoroTimer-YWR6X3FT.js → PomodoroTimer-L72X22QZ.js} +37 -37
  8. package/dist/{Preview-LMUHIWNB.js → Preview-DJHBCRKW.js} +33 -33
  9. package/dist/{Sidebar-ZIHLBHKR.js → Sidebar-YCSGGCLW.js} +1 -1
  10. package/dist/{Spreadsheet-DAZUBPFY.js → Spreadsheet-VHFYYFLK.js} +11 -11
  11. package/dist/{Stock-C2EQYFNA.js → Stock-C3DDF3V3.js} +3 -3
  12. package/dist/{Weather-EZU5A7JW.js → Weather-2XG5AIW2.js} +15 -15
  13. package/dist/{WorldClock-SKUEYQXU.js → WorldClock-2MU5CFUN.js} +6 -6
  14. package/dist/ai/index.js +1 -1
  15. package/dist/apps/index.js +1 -1
  16. package/dist/bin/media-host-check.js +1 -1
  17. package/dist/bin/ui-check.js +1 -1
  18. package/dist/{chunk-7F5FURAC.js → chunk-2MMEGCYI.js} +1 -1
  19. package/dist/chunk-EUFALBK3.js +1 -0
  20. package/dist/{chunk-EJNFOBE3.js → chunk-FJ72DO6A.js} +4 -4
  21. package/dist/{chunk-HAZLMRTT.js → chunk-KAELFRN4.js} +1 -1
  22. package/dist/{chunk-ZSRYQW64.js → chunk-MVYOBV4I.js} +3 -3
  23. package/dist/{chunk-6YPZHG7O.js → chunk-MWGVFDEV.js} +2 -2
  24. package/dist/{chunk-XINUGME7.js → chunk-R6WJ2NTT.js} +27 -27
  25. package/dist/{chunk-6OPAUSMV.js → chunk-ZQGPJZY4.js} +2 -2
  26. package/dist/{chunk-M7JJOCBU.js → chunk-ZXI4CWTI.js} +1 -1
  27. package/dist/data/ListLoadError.js +1 -1
  28. package/dist/format/index.js +1 -1
  29. package/dist/forms/BorderInput.js +1 -1
  30. package/dist/forms/BrandAssetEditor.js +1 -1
  31. package/dist/forms/ColorPicker.js +1 -1
  32. package/dist/forms/ComposerAttachments.js +1 -1
  33. package/dist/forms/CornersInput.js +1 -1
  34. package/dist/forms/DisplayChips.js +1 -1
  35. package/dist/forms/IconPicker.js +1 -1
  36. package/dist/forms/InputNumber.js +1 -1
  37. package/dist/forms/LinkPicker.js +1 -1
  38. package/dist/forms/MediaUsedInList.js +1 -1
  39. package/dist/forms/PositionInput.js +1 -1
  40. package/dist/forms/SidesInput.js +1 -1
  41. package/dist/forms/Slider.js +1 -1
  42. package/dist/forms/Snippet.js +1 -1
  43. package/dist/forms/SplitButton.js +1 -1
  44. package/dist/forms/TextToolbar.js +1 -1
  45. package/dist/forms/WidthsBar.js +1 -1
  46. package/dist/index.d.ts +10 -1
  47. package/dist/index.js +170 -170
  48. package/dist/map/index.js +1 -1
  49. package/dist/shell/AppUpdateBanner.js +1 -1
  50. package/dist/shell/ImageLightbox.js +1 -1
  51. package/dist/shell/LanguageSelect.js +1 -1
  52. package/dist/shell/SearchableSelect.js +1 -1
  53. package/dist/shell/SettingReset.js +1 -1
  54. package/dist/telemetry/index.js +1 -1
  55. package/dist/templates/ChatTemplate.js +1 -1
  56. package/dist/templates/CheckoutTemplate.js +1 -1
  57. package/dist/templates/DataTablePage.js +1 -1
  58. package/dist/templates/EmailTemplate.js +1 -1
  59. package/dist/templates/FormLayoutPage.js +1 -1
  60. package/dist/ui/index.js +1 -1
  61. package/dist/version.js +1 -1
  62. package/package.json +1 -1
  63. package/dist/chunk-AJOWAZ46.js +0 -1
@@ -1,29 +1,29 @@
1
- import{peekBrowserStartUrl as e,claimBrowserStartUrl as t}from"./chunk-LWLCNQY7.js";import{AboutApp as o}from"./chunk-6OPAUSMV.js";import{WindowTitle as r}from"./chunk-XINUGME7.js";import"./chunk-TPDOOCFS.js";import"./chunk-AW7TOB6N.js";import"./chunk-KNUR2UEG.js";import"./chunk-JDCM2VHG.js";import"./chunk-SS7BG7BS.js";import"./chunk-Y53KNQKL.js";import"./chunk-5A7MWTXX.js";import"./chunk-O5PJELY7.js";import{confirm as n}from"./chunk-SGVIMTN6.js";import"./chunk-CGY5RNAF.js";import"./chunk-VWGWZY7A.js";import"./chunk-PKXQDCNR.js";import"./chunk-UPHXYWL6.js";import"./chunk-5QFPTDQF.js";import"./chunk-UGTRSRIW.js";import"./chunk-QR4RM7PO.js";import"./chunk-LWGNNVDA.js";import"./chunk-KC3EX26K.js";import"./chunk-CDAJKLGL.js";import"./chunk-5SULG7D5.js";import"./chunk-7T3COEQK.js";import"./chunk-AJOWAZ46.js";import"./chunk-UDD7GB4F.js";import"./chunk-K7U4RWXJ.js";import{Icon as a}from"./chunk-42BBJJDP.js";import"./chunk-J75ZT2JQ.js";import"./chunk-4TL3MRRE.js";import"./chunk-Q5MD3VY6.js";import"./chunk-MRJKZWWV.js";import"./chunk-2LXTJXWC.js";import"./chunk-PGN5ME7B.js";import"./chunk-62LW225J.js";import"./chunk-GLUJS42B.js";import"./chunk-D65T4H6J.js";import"./chunk-DTJRIWFR.js";import"./chunk-TWVUQUUD.js";import"./chunk-GTRUBA2R.js";import"./chunk-C3QOHMR6.js";import{useRef as s,useEffect as i,useState as l}from"react";import{jsxs as c,jsx as m,Fragment as u}from"react/jsx-runtime";var d="react-os-shell:browser-bookmarks",h="react-os-shell:browser-homepage",p="https://en.wikipedia.org/wiki/Main_Page",g=[{label:"Wikipedia",url:"https://en.wikipedia.org/wiki/Main_Page"},{label:"DevDocs",url:"https://devdocs.io"},{label:"Example",url:"https://example.com"}],b=new Set(["ac ad ae af ag ai al am ao aq ar as at au aw ax az ba bb bd be bf bg bh bi","bj bm bn bo br bs bt bw by bz ca cc cd cf cg ch ci ck cl cm cn co cr cu cv","cw cx cy cz de dj dk dm do dz ec ee eg er es et eu fi fj fk fm fo fr ga gd","ge gf gg gh gi gl gm gn gp gq gr gs gt gu gw gy hk hm hn hr ht hu id ie il","im in io iq ir is it je jm jo jp ke kg kh ki km kn kp kr kw ky kz la lb lc","li lk lr ls lt lu lv ly ma mc md me mg mh mk ml mm mn mo mp mq mr ms mt mu","mv mw mx my mz na nc ne nf ng ni nl no np nr nu nz om pa pe pf pg ph pk pl","pm pn pr ps pt pw py qa re ro rs ru rw sa sb sc sd se sg sh si sk sl sm sn","so sr ss st su sv sx sy sz tc td tf tg th tj tk tl tm tn to tr tt tv tw tz","ua ug uk us uy uz va vc ve vg vi vn vu wf ws ye yt za zm zw","com net org edu gov mil int info biz name pro app dev xyz online site tech","store shop cloud design digital agency studio media news blog live life","world today email systems solutions services software page link space host","press wiki team group works careers finance capital energy academy"].join(" ").split(" "));function k(e){let t=e.trim();return t?/^[a-z][a-z0-9+.-]*:\/\//i.test(t)?t:function(e){const t=/^([\w-]+\.)+([a-z]{2,})(\/.*)?$/i.exec(e);return null!==t&&b.has(t[2].toLowerCase())}(t)?"https://"+t:"https://duckduckgo.com/?q="+encodeURIComponent(t):""}var f=["duckduckgo.com","developer.mozilla.org","google.com","gmail.com","youtube.com","facebook.com","instagram.com","whatsapp.com","twitter.com","x.com","github.com","gitlab.com","linkedin.com","reddit.com","pinterest.com","amazon.com","amazon.ca","amazon.co.uk","apple.com","icloud.com","microsoft.com","outlook.com","live.com","office.com","netflix.com","spotify.com","paypal.com","stripe.com","chat.openai.com","chatgpt.com","claude.ai"];function x(){if("undefined"==typeof window)return g;try{const e=localStorage.getItem(d);if(!e)return g;const t=JSON.parse(e);if(Array.isArray(t)&&t.every(e=>"string"==typeof e?.url))return t}catch{}return g}function w(){return"undefined"==typeof window?p:localStorage.getItem(h)||p}function y(){const u=s(void 0);void 0===u.current&&(u.current=e()),i(()=>{null!=u.current&&t(u.current)},[]);const p=u.current?k(u.current.url):"",[g,b]=l(w),[f,y]=l(p||g),[j,C]=l(f),[W,R]=l([f]),[z,L]=l(0),[S,D]=l(0),[T,U]=l(x),[G,E]=l(!1),[J,M]=l(null),O=s(null),P=s(null);i(()=>{try{localStorage.setItem(d,JSON.stringify(T))}catch{}},[T]);const A=e=>{const t=k(e);t&&(y(t),C(t),R(e=>{const o=e.slice(0,z+1);return o.push(t),o}),L(e=>e+1),E(!1))},K=()=>{"undefined"!=typeof window&&window.open(f,"_blank","noopener,noreferrer")},B=()=>{const e=J?.trim();e?(U(t=>[...t,{label:e,url:f}]),M(null)):M(null)};i(()=>{if(null===J)return;O.current?.focus(),O.current?.select();const e=e=>{const t=e.target;t?.closest("[data-bookmark-popover]")||M(null)},t=setTimeout(()=>document.addEventListener("mousedown",e),0);return()=>{clearTimeout(t),document.removeEventListener("mousedown",e)}},[null!==J]);const H=e=>{U(t=>t.filter((t,o)=>o!==e))},Q=z>0,X=z<W.length-1,F=T.some(e=>e.url===f),I="p-2 rounded hover:bg-gray-200 transition-colors text-gray-600 disabled:opacity-30";/* @__PURE__ */
1
+ import{peekBrowserStartUrl as e,claimBrowserStartUrl as t}from"./chunk-LWLCNQY7.js";import{AboutApp as o}from"./chunk-ZQGPJZY4.js";import{WindowTitle as r}from"./chunk-R6WJ2NTT.js";import"./chunk-TPDOOCFS.js";import"./chunk-AW7TOB6N.js";import"./chunk-KNUR2UEG.js";import"./chunk-JDCM2VHG.js";import"./chunk-SS7BG7BS.js";import"./chunk-Y53KNQKL.js";import"./chunk-5A7MWTXX.js";import"./chunk-O5PJELY7.js";import{confirm as n}from"./chunk-SGVIMTN6.js";import"./chunk-CGY5RNAF.js";import"./chunk-VWGWZY7A.js";import"./chunk-PKXQDCNR.js";import"./chunk-KC3EX26K.js";import"./chunk-UPHXYWL6.js";import"./chunk-5QFPTDQF.js";import"./chunk-LWGNNVDA.js";import"./chunk-UGTRSRIW.js";import"./chunk-QR4RM7PO.js";import"./chunk-5SULG7D5.js";import"./chunk-CDAJKLGL.js";import"./chunk-7T3COEQK.js";import"./chunk-EUFALBK3.js";import"./chunk-UDD7GB4F.js";import"./chunk-K7U4RWXJ.js";import"./chunk-4TL3MRRE.js";import{Icon as a}from"./chunk-42BBJJDP.js";import"./chunk-J75ZT2JQ.js";import"./chunk-Q5MD3VY6.js";import"./chunk-MRJKZWWV.js";import"./chunk-2LXTJXWC.js";import"./chunk-PGN5ME7B.js";import"./chunk-62LW225J.js";import"./chunk-GLUJS42B.js";import"./chunk-D65T4H6J.js";import"./chunk-DTJRIWFR.js";import"./chunk-TWVUQUUD.js";import"./chunk-GTRUBA2R.js";import"./chunk-C3QOHMR6.js";import{useRef as s,useEffect as i,useState as l}from"react";import{jsxs as c,jsx as m,Fragment as u}from"react/jsx-runtime";var d="react-os-shell:browser-bookmarks",h="react-os-shell:browser-homepage",p="https://en.wikipedia.org/wiki/Main_Page",g=[{label:"Wikipedia",url:"https://en.wikipedia.org/wiki/Main_Page"},{label:"DevDocs",url:"https://devdocs.io"},{label:"Example",url:"https://example.com"}],b=new Set(["ac ad ae af ag ai al am ao aq ar as at au aw ax az ba bb bd be bf bg bh bi","bj bm bn bo br bs bt bw by bz ca cc cd cf cg ch ci ck cl cm cn co cr cu cv","cw cx cy cz de dj dk dm do dz ec ee eg er es et eu fi fj fk fm fo fr ga gd","ge gf gg gh gi gl gm gn gp gq gr gs gt gu gw gy hk hm hn hr ht hu id ie il","im in io iq ir is it je jm jo jp ke kg kh ki km kn kp kr kw ky kz la lb lc","li lk lr ls lt lu lv ly ma mc md me mg mh mk ml mm mn mo mp mq mr ms mt mu","mv mw mx my mz na nc ne nf ng ni nl no np nr nu nz om pa pe pf pg ph pk pl","pm pn pr ps pt pw py qa re ro rs ru rw sa sb sc sd se sg sh si sk sl sm sn","so sr ss st su sv sx sy sz tc td tf tg th tj tk tl tm tn to tr tt tv tw tz","ua ug uk us uy uz va vc ve vg vi vn vu wf ws ye yt za zm zw","com net org edu gov mil int info biz name pro app dev xyz online site tech","store shop cloud design digital agency studio media news blog live life","world today email systems solutions services software page link space host","press wiki team group works careers finance capital energy academy"].join(" ").split(" "));function k(e){let t=e.trim();return t?/^[a-z][a-z0-9+.-]*:\/\//i.test(t)?t:function(e){const t=/^([\w-]+\.)+([a-z]{2,})(\/.*)?$/i.exec(e);return null!==t&&b.has(t[2].toLowerCase())}(t)?"https://"+t:"https://duckduckgo.com/?q="+encodeURIComponent(t):""}var f=["duckduckgo.com","developer.mozilla.org","google.com","gmail.com","youtube.com","facebook.com","instagram.com","whatsapp.com","twitter.com","x.com","github.com","gitlab.com","linkedin.com","reddit.com","pinterest.com","amazon.com","amazon.ca","amazon.co.uk","apple.com","icloud.com","microsoft.com","outlook.com","live.com","office.com","netflix.com","spotify.com","paypal.com","stripe.com","chat.openai.com","chatgpt.com","claude.ai"];function x(){if("undefined"==typeof window)return g;try{const e=localStorage.getItem(d);if(!e)return g;const t=JSON.parse(e);if(Array.isArray(t)&&t.every(e=>"string"==typeof e?.url))return t}catch{}return g}function w(){return"undefined"==typeof window?p:localStorage.getItem(h)||p}function y(){const u=s(void 0);void 0===u.current&&(u.current=e()),i(()=>{null!=u.current&&t(u.current)},[]);const p=u.current?k(u.current.url):"",[g,b]=l(w),[f,y]=l(p||g),[j,C]=l(f),[R,W]=l([f]),[z,L]=l(0),[S,T]=l(0),[D,U]=l(x),[G,J]=l(!1),[E,K]=l(null),P=s(null),B=s(null);i(()=>{try{localStorage.setItem(d,JSON.stringify(D))}catch{}},[D]);const M=e=>{const t=k(e);t&&(y(t),C(t),W(e=>{const o=e.slice(0,z+1);return o.push(t),o}),L(e=>e+1),J(!1))},O=()=>{"undefined"!=typeof window&&window.open(f,"_blank","noopener,noreferrer")},Q=()=>{const e=E?.trim();e?(U(t=>[...t,{label:e,url:f}]),K(null)):K(null)};i(()=>{if(null===E)return;P.current?.focus(),P.current?.select();const e=e=>{const t=e.target;t?.closest("[data-bookmark-popover]")||K(null)},t=setTimeout(()=>document.addEventListener("mousedown",e),0);return()=>{clearTimeout(t),document.removeEventListener("mousedown",e)}},[null!==E]);const A=e=>{U(t=>t.filter((t,o)=>o!==e))},F=z>0,H=z<R.length-1,X=D.some(e=>e.url===f),I="p-2 rounded hover:bg-gray-200 transition-colors text-gray-600 disabled:opacity-30";/* @__PURE__ */
2
2
  return c("div",{className:"relative flex flex-col h-full bg-white",children:[
3
3
  /* @__PURE__ */m(r,{title:`Browser - ${v(f)}`}),
4
4
  /* @__PURE__ */m(o,{app:"browser"}),
5
5
  /* @__PURE__ */c("div",{className:"flex items-center gap-1 px-2 py-2 border-b border-gray-200 bg-gray-50 shrink-0",children:[
6
- /* @__PURE__ */m("button",{onClick:()=>{if(z>0){const e=z-1;L(e),y(W[e]),C(W[e]),E(!1)}},disabled:!Q,className:I,title:"Back",children:/* @__PURE__ */m(a,{name:"chevron-left",className:"h-4 w-4",strokeWidth:2})}),
7
- /* @__PURE__ */m("button",{onClick:()=>{if(z<W.length-1){const e=z+1;L(e),y(W[e]),C(W[e]),E(!1)}},disabled:!X,className:I,title:"Forward",children:/* @__PURE__ */m(a,{name:"chevron-right",className:"h-4 w-4",strokeWidth:2})}),
8
- /* @__PURE__ */m("button",{onClick:()=>D(e=>e+1),className:I,title:"Refresh",children:/* @__PURE__ */m(a,{name:"refresh",className:"h-4 w-4",strokeWidth:1.8})}),
9
- /* @__PURE__ */m("button",{onClick:()=>A(g),className:I,title:"Home",children:/* @__PURE__ */m(a,{name:"home",className:"h-4 w-4",strokeWidth:1.8})}),
10
- /* @__PURE__ */m("form",{onSubmit:e=>{e.preventDefault(),A(j)},className:"flex-1 flex items-center mx-1",children:/* @__PURE__ */c("div",{className:"flex items-center w-full bg-white border border-gray-300 rounded focus-within:border-blue-400 focus-within:ring-1 focus-within:ring-blue-200",children:[
6
+ /* @__PURE__ */m("button",{onClick:()=>{if(z>0){const e=z-1;L(e),y(R[e]),C(R[e]),J(!1)}},disabled:!F,className:I,title:"Back",children:/* @__PURE__ */m(a,{name:"chevron-left",className:"h-4 w-4",strokeWidth:2})}),
7
+ /* @__PURE__ */m("button",{onClick:()=>{if(z<R.length-1){const e=z+1;L(e),y(R[e]),C(R[e]),J(!1)}},disabled:!H,className:I,title:"Forward",children:/* @__PURE__ */m(a,{name:"chevron-right",className:"h-4 w-4",strokeWidth:2})}),
8
+ /* @__PURE__ */m("button",{onClick:()=>T(e=>e+1),className:I,title:"Refresh",children:/* @__PURE__ */m(a,{name:"refresh",className:"h-4 w-4",strokeWidth:1.8})}),
9
+ /* @__PURE__ */m("button",{onClick:()=>M(g),className:I,title:"Home",children:/* @__PURE__ */m(a,{name:"home",className:"h-4 w-4",strokeWidth:1.8})}),
10
+ /* @__PURE__ */m("form",{onSubmit:e=>{e.preventDefault(),M(j)},className:"flex-1 flex items-center mx-1",children:/* @__PURE__ */c("div",{className:"flex items-center w-full bg-white border border-gray-300 rounded focus-within:border-blue-400 focus-within:ring-1 focus-within:ring-blue-200",children:[
11
11
  /* @__PURE__ */m("span",{className:"px-2 text-gray-400 text-xs",children:f.startsWith("https://")?"🔒":"⚠️"}),
12
12
  /* @__PURE__ */m("input",{type:"text",value:j,onChange:e=>C(e.target.value),onFocus:e=>e.target.select(),className:"flex-1 px-1 py-1 text-sm bg-transparent outline-none font-mono",spellCheck:!1,placeholder:"Enter URL or search…"}),f!==j&&/* @__PURE__ */m("button",{type:"button",onClick:()=>C(f),className:"px-2 text-2xs text-gray-400 hover:text-gray-700",title:"Reset to current URL",children:"×"})]})}),
13
- /* @__PURE__ */m("button",{"data-bookmark-popover":!0,onClick:()=>F?H(T.findIndex(e=>e.url===f)):void M(v(f)),className:I+" "+(F?"text-yellow-500":""),title:F?"Remove bookmark":"Add bookmark",children:/* @__PURE__ */m(a,{name:"star",className:"h-4 w-4",fill:F?"currentColor":"none",strokeWidth:1.5})}),
14
- /* @__PURE__ */m("button",{onClick:K,className:I,title:"Open in new tab",children:/* @__PURE__ */m(a,{name:"external",className:"h-4 w-4",strokeWidth:1.5})}),
15
- /* @__PURE__ */m("button",{onClick:()=>E(e=>!e),className:I,title:"Embedding help",children:/* @__PURE__ */m(a,{name:"help",className:"h-4 w-4",strokeWidth:1.5})})]}),null!==J&&/* @__PURE__ */c("div",{"data-bookmark-popover":!0,className:"absolute right-3 top-12 z-30 w-72 bg-white border border-gray-200 rounded-md shadow-lg p-3",children:[
13
+ /* @__PURE__ */m("button",{"data-bookmark-popover":!0,onClick:()=>X?A(D.findIndex(e=>e.url===f)):void K(v(f)),className:I+" "+(X?"text-yellow-500":""),title:X?"Remove bookmark":"Add bookmark",children:/* @__PURE__ */m(a,{name:"star",className:"h-4 w-4",fill:X?"currentColor":"none",strokeWidth:1.5})}),
14
+ /* @__PURE__ */m("button",{onClick:O,className:I,title:"Open in new tab",children:/* @__PURE__ */m(a,{name:"external",className:"h-4 w-4",strokeWidth:1.5})}),
15
+ /* @__PURE__ */m("button",{onClick:()=>J(e=>!e),className:I,title:"Embedding help",children:/* @__PURE__ */m(a,{name:"help",className:"h-4 w-4",strokeWidth:1.5})})]}),null!==E&&/* @__PURE__ */c("div",{"data-bookmark-popover":!0,className:"absolute right-3 top-12 z-30 w-72 bg-white border border-gray-200 rounded-md shadow-lg p-3",children:[
16
16
  /* @__PURE__ */m("div",{className:"text-2xs font-semibold uppercase tracking-wide text-gray-500 mb-1",children:"Bookmark this page"}),
17
17
  /* @__PURE__ */m("div",{className:"text-2xs text-gray-400 truncate mb-2 font-mono",title:f,children:f}),
18
- /* @__PURE__ */m("input",{ref:O,type:"text",value:J,onChange:e=>M(e.target.value),onKeyDown:e=>{"Enter"===e.key?B():"Escape"===e.key&&M(null)},placeholder:"Name",className:"w-full text-sm px-2 h-8 border border-gray-300 rounded focus:outline-none focus:border-blue-400 focus:ring-1 focus:ring-blue-200"}),
18
+ /* @__PURE__ */m("input",{ref:P,type:"text",value:E,onChange:e=>K(e.target.value),onKeyDown:e=>{"Enter"===e.key?Q():"Escape"===e.key&&K(null)},placeholder:"Name",className:"w-full text-sm px-2 h-8 border border-gray-300 rounded focus:outline-none focus:border-blue-400 focus:ring-1 focus:ring-blue-200"}),
19
19
  /* @__PURE__ */c("div",{className:"flex justify-end gap-1 mt-2",children:[
20
- /* @__PURE__ */m("button",{onClick:()=>M(null),className:"px-2 py-1 text-xs text-gray-600 hover:bg-gray-100 rounded",children:"Cancel"}),
21
- /* @__PURE__ */m("button",{onClick:B,disabled:!J.trim(),className:"px-2 py-1 text-xs bg-blue-500 text-white rounded hover:bg-blue-600 disabled:opacity-40",children:"Save"})]})]}),
22
- /* @__PURE__ */c("div",{className:"flex items-center gap-0.5 px-2 py-1 border-b border-gray-200 bg-white shrink-0 overflow-x-auto",children:[0===T.length&&/* @__PURE__ */m("span",{className:"text-2xs text-gray-400 italic px-2",children:"No bookmarks yet — star the address bar to add one."}),T.map((e,t)=>/* @__PURE__ */c("button",{onClick:()=>A(e.url),onContextMenu:async o=>{o.preventDefault();await n({title:"Remove bookmark",message:`"${e.label}" will be removed from your bookmarks.`,confirmLabel:"Remove",variant:"danger"})&&H(t)},className:"flex items-center gap-2 px-2 py-0.5 rounded text-xs text-gray-700 hover:bg-gray-100 whitespace-nowrap",title:`${e.url}\n(right-click to remove)`,children:[
20
+ /* @__PURE__ */m("button",{onClick:()=>K(null),className:"px-2 py-1 text-xs text-gray-600 hover:bg-gray-100 rounded",children:"Cancel"}),
21
+ /* @__PURE__ */m("button",{onClick:Q,disabled:!E.trim(),className:"px-2 py-1 text-xs bg-blue-500 text-white rounded hover:bg-blue-600 disabled:opacity-40",children:"Save"})]})]}),
22
+ /* @__PURE__ */c("div",{className:"flex items-center gap-0.5 px-2 py-1 border-b border-gray-200 bg-white shrink-0 overflow-x-auto",children:[0===D.length&&/* @__PURE__ */m("span",{className:"text-2xs text-gray-400 italic px-2",children:"No bookmarks yet — star the address bar to add one."}),D.map((e,t)=>/* @__PURE__ */c("button",{onClick:()=>M(e.url),onContextMenu:async o=>{o.preventDefault();await n({title:"Remove bookmark",message:`"${e.label}" will be removed from your bookmarks.`,confirmLabel:"Remove",variant:"danger"})&&A(t)},className:"flex items-center gap-2 px-2 py-0.5 rounded text-xs text-gray-700 hover:bg-gray-100 whitespace-nowrap",title:`${e.url}\n(right-click to remove)`,children:[
23
23
  /* @__PURE__ */m("img",{src:`https://icons.duckduckgo.com/ip3/${new URL(e.url).hostname}.ico`,alt:"",className:"h-3.5 w-3.5",onError:e=>{e.target.style.visibility="hidden"}}),e.label]},t)),
24
24
  /* @__PURE__ */m("div",{className:"flex-1"}),
25
25
  /* @__PURE__ */m("button",{onClick:()=>{b(f);try{localStorage.setItem(h,f)}catch{}},className:"px-2 py-0.5 text-2xs text-gray-500 hover:text-gray-800",title:"Set current page as homepage",children:"Set as home"})]}),
26
- /* @__PURE__ */m("div",{className:"flex-1 relative min-h-0 bg-gray-50",children:/* @__PURE__ */m(N,{url:f,iframeKey:S,iframeRef:P,openExternal:K,showHelp:G,dismissHelp:()=>E(!1)})})]})}function v(e){try{return new URL(e).hostname.replace(/^www\./,"")}catch{return e}}function N({url:e,iframeKey:t,iframeRef:o,openExternal:r,showHelp:n,dismissHelp:s}){const[d,h]=l(!1);i(()=>{h(!1)},[e]);return function(e){try{const t=new URL(e).hostname.toLowerCase();return f.some(e=>t===e||t.endsWith("."+e))}catch{return!1}}(e)&&!d?/* @__PURE__ */m("div",{className:"absolute inset-0 flex items-center justify-center bg-white p-8",children:/* @__PURE__ */c("div",{className:"max-w-md text-center",children:[
26
+ /* @__PURE__ */m("div",{className:"flex-1 relative min-h-0 bg-gray-50",children:/* @__PURE__ */m(N,{url:f,iframeKey:S,iframeRef:B,openExternal:O,showHelp:G,dismissHelp:()=>J(!1)})})]})}function v(e){try{return new URL(e).hostname.replace(/^www\./,"")}catch{return e}}function N({url:e,iframeKey:t,iframeRef:o,openExternal:r,showHelp:n,dismissHelp:s}){const[d,h]=l(!1);i(()=>{h(!1)},[e]);return function(e){try{const t=new URL(e).hostname.toLowerCase();return f.some(e=>t===e||t.endsWith("."+e))}catch{return!1}}(e)&&!d?/* @__PURE__ */m("div",{className:"absolute inset-0 flex items-center justify-center bg-white p-8",children:/* @__PURE__ */c("div",{className:"max-w-md text-center",children:[
27
27
  /* @__PURE__ */m(a,{name:"no-symbol",className:"h-14 w-14 mx-auto text-gray-300 mb-3",strokeWidth:1.2}),
28
28
  /* @__PURE__ */c("h3",{className:"text-base font-semibold text-gray-800 mb-1",children:[v(e)," can't be embedded"]}),
29
29
  /* @__PURE__ */c("p",{className:"text-sm text-gray-500 mb-4",children:["This site sends an ",
@@ -1,4 +1,4 @@
1
- import{loadAppearance as e,WidgetSettingsModal as t}from"./chunk-M7JJOCBU.js";import{useWidgetSettings as n}from"./chunk-XINUGME7.js";import"./chunk-TPDOOCFS.js";import"./chunk-AW7TOB6N.js";import"./chunk-KNUR2UEG.js";import"./chunk-JDCM2VHG.js";import"./chunk-SS7BG7BS.js";import"./chunk-Y53KNQKL.js";import"./chunk-5A7MWTXX.js";import"./chunk-O5PJELY7.js";import"./chunk-SGVIMTN6.js";import"./chunk-CGY5RNAF.js";import"./chunk-VWGWZY7A.js";import"./chunk-PKXQDCNR.js";import"./chunk-UPHXYWL6.js";import"./chunk-5QFPTDQF.js";import"./chunk-UGTRSRIW.js";import"./chunk-QR4RM7PO.js";import"./chunk-LWGNNVDA.js";import"./chunk-KC3EX26K.js";import"./chunk-CDAJKLGL.js";import"./chunk-5SULG7D5.js";import"./chunk-7T3COEQK.js";import"./chunk-UDD7GB4F.js";import"./chunk-K7U4RWXJ.js";import{Icon as r}from"./chunk-42BBJJDP.js";import"./chunk-J75ZT2JQ.js";import"./chunk-4TL3MRRE.js";import"./chunk-Q5MD3VY6.js";import"./chunk-MRJKZWWV.js";import"./chunk-2LXTJXWC.js";import"./chunk-PGN5ME7B.js";import"./chunk-62LW225J.js";import"./chunk-GLUJS42B.js";import"./chunk-D65T4H6J.js";import"./chunk-DTJRIWFR.js";import"./chunk-TWVUQUUD.js";import"./chunk-GTRUBA2R.js";import"./chunk-C3QOHMR6.js";import{useState as c,useRef as i,useCallback as l,useEffect as o}from"react";import{jsxs as s,Fragment as a,jsx as u}from"react/jsx-runtime";var h="calc_appearance";function m(){const[m,k]=c("0"),[p,d]=c(null),[b,g]=c(null),[N,j]=c(!1),[y,x]=c(""),[f,C]=c([]),[v,$]=c(!1),[T,W]=c(()=>e(h)),[E,J]=c(!1),[R,D]=c(T),S=i(null);n(l(()=>{D({...T}),J(!0)},[T]));const G=l(e=>{x(""),k(t=>N||"0"===t?(j(!1),"."===e?"0.":e):"."===e&&t.includes(".")?t:t+e)},[N]),U=l(()=>{k("0"),d(null),g(null),j(!1)},[]),w=l((e,t,n)=>{switch(n){case"+":return e+t;case"-":return e-t;case"×":return e*t;case"÷":return 0===t?0:e/t;default:return t}},[]),L=l(e=>{const t=parseFloat(m);if(null!==p&&b&&!N){const e=w(p,t,b);k(String(e)),d(e),C(n=>[`${p} ${b} ${t} = ${e}`,...n].slice(0,20))}else d(t);g(e),j(!0)},[m,p,b,N,w]),B=l(()=>{if(null===p||!b)return;const e=parseFloat(m),t=w(p,e,b),n=`${p} ${b} ${e} =`;C(e=>[`${n} ${t}`,...e].slice(0,20)),x(n),k(String(t)),d(null),g(null),j(!0)},[m,p,b,w]),M=l(()=>{k(e=>String(parseFloat(e)/100))},[]),A=l(()=>{k(e=>e.startsWith("-")?e.slice(1):"0"===e?e:"-"+e)},[]);o(()=>{const e=e=>{const t=e.target.tagName;"INPUT"!==t&&"TEXTAREA"!==t&&"SELECT"!==t&&(e.key>="0"&&e.key<="9"?G(e.key):"."===e.key?G("."):"+"===e.key?L("+"):"-"===e.key?L("-"):"*"===e.key?L("×"):"/"===e.key?(e.preventDefault(),L("÷")):"Enter"===e.key||"="===e.key?("Enter"===e.key&&e.target instanceof Node&&S.current?.contains(e.target)&&e.preventDefault(),B()):"Escape"===e.key?U():"Backspace"===e.key?k(e=>e.length>1?e.slice(0,-1):"0"):"%"===e.key&&M())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[G,L,B,U,M]);const F="flex items-center justify-center rounded-lg text-sm font-medium transition-colors",K=`${F} bg-white border border-gray-200 text-gray-900 hover:bg-gray-50 active:bg-gray-100`,O=`${F} bg-blue-50 border border-blue-200 text-blue-700 hover:bg-blue-100 active:bg-blue-200`,Q=`${F} bg-gray-100 border border-gray-200 text-gray-600 hover:bg-gray-200 active:bg-gray-300`,X=`${F} bg-blue-600 text-white hover:bg-blue-700 active:bg-blue-800`;/* @__PURE__ */
1
+ import{loadAppearance as e,WidgetSettingsModal as t}from"./chunk-ZXI4CWTI.js";import{useWidgetSettings as n}from"./chunk-R6WJ2NTT.js";import"./chunk-TPDOOCFS.js";import"./chunk-AW7TOB6N.js";import"./chunk-KNUR2UEG.js";import"./chunk-JDCM2VHG.js";import"./chunk-SS7BG7BS.js";import"./chunk-Y53KNQKL.js";import"./chunk-5A7MWTXX.js";import"./chunk-O5PJELY7.js";import"./chunk-SGVIMTN6.js";import"./chunk-CGY5RNAF.js";import"./chunk-VWGWZY7A.js";import"./chunk-PKXQDCNR.js";import"./chunk-KC3EX26K.js";import"./chunk-UPHXYWL6.js";import"./chunk-5QFPTDQF.js";import"./chunk-LWGNNVDA.js";import"./chunk-UGTRSRIW.js";import"./chunk-QR4RM7PO.js";import"./chunk-5SULG7D5.js";import"./chunk-CDAJKLGL.js";import"./chunk-7T3COEQK.js";import"./chunk-UDD7GB4F.js";import"./chunk-K7U4RWXJ.js";import"./chunk-4TL3MRRE.js";import{Icon as r}from"./chunk-42BBJJDP.js";import"./chunk-J75ZT2JQ.js";import"./chunk-Q5MD3VY6.js";import"./chunk-MRJKZWWV.js";import"./chunk-2LXTJXWC.js";import"./chunk-PGN5ME7B.js";import"./chunk-62LW225J.js";import"./chunk-GLUJS42B.js";import"./chunk-D65T4H6J.js";import"./chunk-DTJRIWFR.js";import"./chunk-TWVUQUUD.js";import"./chunk-GTRUBA2R.js";import"./chunk-C3QOHMR6.js";import{useState as c,useRef as i,useCallback as l,useEffect as o}from"react";import{jsxs as s,Fragment as a,jsx as u}from"react/jsx-runtime";var h="calc_appearance";function m(){const[m,k]=c("0"),[p,d]=c(null),[b,g]=c(null),[N,j]=c(!1),[y,x]=c(""),[f,C]=c([]),[v,$]=c(!1),[T,W]=c(()=>e(h)),[R,D]=c(!1),[E,J]=c(T),S=i(null);n(l(()=>{J({...T}),D(!0)},[T]));const w=l(e=>{x(""),k(t=>N||"0"===t?(j(!1),"."===e?"0.":e):"."===e&&t.includes(".")?t:t+e)},[N]),G=l(()=>{k("0"),d(null),g(null),j(!1)},[]),L=l((e,t,n)=>{switch(n){case"+":return e+t;case"-":return e-t;case"×":return e*t;case"÷":return 0===t?0:e/t;default:return t}},[]),U=l(e=>{const t=parseFloat(m);if(null!==p&&b&&!N){const e=L(p,t,b);k(String(e)),d(e),C(n=>[`${p} ${b} ${t} = ${e}`,...n].slice(0,20))}else d(t);g(e),j(!0)},[m,p,b,N,L]),B=l(()=>{if(null===p||!b)return;const e=parseFloat(m),t=L(p,e,b),n=`${p} ${b} ${e} =`;C(e=>[`${n} ${t}`,...e].slice(0,20)),x(n),k(String(t)),d(null),g(null),j(!0)},[m,p,b,L]),A=l(()=>{k(e=>String(parseFloat(e)/100))},[]),F=l(()=>{k(e=>e.startsWith("-")?e.slice(1):"0"===e?e:"-"+e)},[]);o(()=>{const e=e=>{const t=e.target.tagName;"INPUT"!==t&&"TEXTAREA"!==t&&"SELECT"!==t&&(e.key>="0"&&e.key<="9"?w(e.key):"."===e.key?w("."):"+"===e.key?U("+"):"-"===e.key?U("-"):"*"===e.key?U("×"):"/"===e.key?(e.preventDefault(),U("÷")):"Enter"===e.key||"="===e.key?("Enter"===e.key&&e.target instanceof Node&&S.current?.contains(e.target)&&e.preventDefault(),B()):"Escape"===e.key?G():"Backspace"===e.key?k(e=>e.length>1?e.slice(0,-1):"0"):"%"===e.key&&A())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[w,U,B,G,A]);const K="flex items-center justify-center rounded-lg text-sm font-medium transition-colors",M=`${K} bg-white border border-gray-200 text-gray-900 hover:bg-gray-50 active:bg-gray-100`,Q=`${K} bg-blue-50 border border-blue-200 text-blue-700 hover:bg-blue-100 active:bg-blue-200`,X=`${K} bg-gray-100 border border-gray-200 text-gray-600 hover:bg-gray-200 active:bg-gray-300`,O=`${K} bg-blue-600 text-white hover:bg-blue-700 active:bg-blue-800`;/* @__PURE__ */
2
2
  return s(a,{children:[
3
3
  /* @__PURE__ */s("div",{ref:S,className:"flex flex-col h-full",style:{opacity:T.activeOpacity/100,backdropFilter:T.activeBlur>0?`blur(${T.activeBlur}px)`:void 0},children:[
4
4
  /* @__PURE__ */s("div",{className:"bg-slate-200 rounded-t-lg px-4 py-2 group/display relative flex flex-col justify-end min-h-[120px] border-b border-slate-300",children:[
@@ -7,23 +7,23 @@ return s(a,{children:[
7
7
  /* @__PURE__ */u("button",{onClick:()=>{navigator.clipboard.writeText(m),$(!0),setTimeout(()=>$(!1),1200)},title:"Copy result",className:"shrink-0 text-slate-300 hover:text-slate-500 transition-colors opacity-0 group-hover/display:opacity-100",children:/* @__PURE__ */u(r,v?{name:"check",className:"h-5 w-5 text-green-500",strokeWidth:2}:{name:"copy",className:"h-5 w-5",strokeWidth:2})}),
8
8
  /* @__PURE__ */u("div",{className:"text-right text-4xl font-mono font-bold text-slate-800 truncate flex-1",children:(e=>{const t=parseFloat(e);return isNaN(t)||e.endsWith(".")||e.endsWith(".0")||Math.abs(t)<1e15&&e.length<16?e:t.toExponential(6)})(m)})]})]}),
9
9
  /* @__PURE__ */s("div",{className:"grid grid-cols-4 grid-rows-5 gap-2 flex-1 min-h-0 p-2",children:[
10
- /* @__PURE__ */u("button",{onClick:U,className:Q,children:"AC"}),
11
- /* @__PURE__ */u("button",{onClick:A,className:Q,children:"+/−"}),
12
- /* @__PURE__ */u("button",{onClick:M,className:Q,children:"%"}),
13
- /* @__PURE__ */u("button",{onClick:()=>L("÷"),className:`${O} ${"÷"===b?"ring-2 ring-blue-400":""}`,children:"÷"}),
14
- /* @__PURE__ */u("button",{onClick:()=>G("7"),className:K,children:"7"}),
15
- /* @__PURE__ */u("button",{onClick:()=>G("8"),className:K,children:"8"}),
16
- /* @__PURE__ */u("button",{onClick:()=>G("9"),className:K,children:"9"}),
17
- /* @__PURE__ */u("button",{onClick:()=>L("×"),className:`${O} ${"×"===b?"ring-2 ring-blue-400":""}`,children:"×"}),
18
- /* @__PURE__ */u("button",{onClick:()=>G("4"),className:K,children:"4"}),
19
- /* @__PURE__ */u("button",{onClick:()=>G("5"),className:K,children:"5"}),
20
- /* @__PURE__ */u("button",{onClick:()=>G("6"),className:K,children:"6"}),
21
- /* @__PURE__ */u("button",{onClick:()=>L("-"),className:`${O} ${"-"===b?"ring-2 ring-blue-400":""}`,children:"−"}),
22
- /* @__PURE__ */u("button",{onClick:()=>G("1"),className:K,children:"1"}),
23
- /* @__PURE__ */u("button",{onClick:()=>G("2"),className:K,children:"2"}),
24
- /* @__PURE__ */u("button",{onClick:()=>G("3"),className:K,children:"3"}),
25
- /* @__PURE__ */u("button",{onClick:()=>L("+"),className:`${O} ${"+"===b?"ring-2 ring-blue-400":""}`,children:"+"}),
26
- /* @__PURE__ */u("button",{onClick:()=>G("0"),className:`${K} col-span-2`,children:"0"}),
27
- /* @__PURE__ */u("button",{onClick:()=>G("."),className:K,children:"."}),
28
- /* @__PURE__ */u("button",{onClick:B,className:X,children:"="})]})]}),
29
- /* @__PURE__ */u(t,{open:E,onClose:()=>J(!1),title:"Calculator Settings",appearance:R,onAppearanceChange:D,onSave:()=>{W(R),localStorage.setItem(h,JSON.stringify(R)),J(!1)}})]})}export{m as default};
10
+ /* @__PURE__ */u("button",{onClick:G,className:X,children:"AC"}),
11
+ /* @__PURE__ */u("button",{onClick:F,className:X,children:"+/−"}),
12
+ /* @__PURE__ */u("button",{onClick:A,className:X,children:"%"}),
13
+ /* @__PURE__ */u("button",{onClick:()=>U("÷"),className:`${Q} ${"÷"===b?"ring-2 ring-blue-400":""}`,children:"÷"}),
14
+ /* @__PURE__ */u("button",{onClick:()=>w("7"),className:M,children:"7"}),
15
+ /* @__PURE__ */u("button",{onClick:()=>w("8"),className:M,children:"8"}),
16
+ /* @__PURE__ */u("button",{onClick:()=>w("9"),className:M,children:"9"}),
17
+ /* @__PURE__ */u("button",{onClick:()=>U("×"),className:`${Q} ${"×"===b?"ring-2 ring-blue-400":""}`,children:"×"}),
18
+ /* @__PURE__ */u("button",{onClick:()=>w("4"),className:M,children:"4"}),
19
+ /* @__PURE__ */u("button",{onClick:()=>w("5"),className:M,children:"5"}),
20
+ /* @__PURE__ */u("button",{onClick:()=>w("6"),className:M,children:"6"}),
21
+ /* @__PURE__ */u("button",{onClick:()=>U("-"),className:`${Q} ${"-"===b?"ring-2 ring-blue-400":""}`,children:"−"}),
22
+ /* @__PURE__ */u("button",{onClick:()=>w("1"),className:M,children:"1"}),
23
+ /* @__PURE__ */u("button",{onClick:()=>w("2"),className:M,children:"2"}),
24
+ /* @__PURE__ */u("button",{onClick:()=>w("3"),className:M,children:"3"}),
25
+ /* @__PURE__ */u("button",{onClick:()=>U("+"),className:`${Q} ${"+"===b?"ring-2 ring-blue-400":""}`,children:"+"}),
26
+ /* @__PURE__ */u("button",{onClick:()=>w("0"),className:`${M} col-span-2`,children:"0"}),
27
+ /* @__PURE__ */u("button",{onClick:()=>w("."),className:M,children:"."}),
28
+ /* @__PURE__ */u("button",{onClick:B,className:O,children:"="})]})]}),
29
+ /* @__PURE__ */u(t,{open:R,onClose:()=>D(!1),title:"Calculator Settings",appearance:E,onAppearanceChange:J,onSave:()=>{W(E),localStorage.setItem(h,JSON.stringify(E)),D(!1)}})]})}export{m as default};
@@ -1,4 +1,4 @@
1
- import{loadAppearance as t,WidgetSettingsModal as e}from"./chunk-M7JJOCBU.js";import{useWidgetSettings as r}from"./chunk-XINUGME7.js";import"./chunk-TPDOOCFS.js";import"./chunk-AW7TOB6N.js";import"./chunk-KNUR2UEG.js";import"./chunk-JDCM2VHG.js";import"./chunk-SS7BG7BS.js";import"./chunk-Y53KNQKL.js";import"./chunk-5A7MWTXX.js";import"./chunk-O5PJELY7.js";import"./chunk-SGVIMTN6.js";import"./chunk-CGY5RNAF.js";import"./chunk-VWGWZY7A.js";import"./chunk-PKXQDCNR.js";import"./chunk-UPHXYWL6.js";import"./chunk-5QFPTDQF.js";import"./chunk-UGTRSRIW.js";import"./chunk-QR4RM7PO.js";import"./chunk-LWGNNVDA.js";import"./chunk-KC3EX26K.js";import"./chunk-CDAJKLGL.js";import"./chunk-5SULG7D5.js";import"./chunk-7T3COEQK.js";import"./chunk-UDD7GB4F.js";import"./chunk-K7U4RWXJ.js";import"./chunk-42BBJJDP.js";import"./chunk-J75ZT2JQ.js";import"./chunk-4TL3MRRE.js";import{LoadingSpinner as n}from"./chunk-Q5MD3VY6.js";import"./chunk-MRJKZWWV.js";import"./chunk-2LXTJXWC.js";import"./chunk-PGN5ME7B.js";import"./chunk-62LW225J.js";import"./chunk-GLUJS42B.js";import"./chunk-D65T4H6J.js";import"./chunk-DTJRIWFR.js";import"./chunk-TWVUQUUD.js";import"./chunk-GTRUBA2R.js";import"./chunk-C3QOHMR6.js";import{useState as s,useCallback as a,useEffect as o}from"react";import{jsxs as c,Fragment as i,jsx as l}from"react/jsx-runtime";var m=["USD","CNY","AUD","GBP","EUR","JPY","CAD","THB","NZD","SGD","HKD","CHF","KRW","INR","MXN","BRL"],u=[["USD","CNY"],["USD","AUD"],["GBP","USD"],["USD","JPY"]],p="currency_pairs",h="currency_appearance",d="currency_rates_cache";function g(t){try{const e=JSON.parse(localStorage.getItem(d)||"{}")[t];if(e&&Date.now()-e.timestamp<36e5)return e.rates}catch{}return null}function k(t,e){try{const r=JSON.parse(localStorage.getItem(d)||"{}");r[t]={rates:e,timestamp:Date.now()},localStorage.setItem(d,JSON.stringify(r))}catch{}}function N(){try{const t=JSON.parse(localStorage.getItem(p)||"");if(Array.isArray(t)&&t.length)return t.slice(0,4)}catch{}return u}var f={USD:"🇺🇸",CNY:"🇨🇳",AUD:"🇦🇺",GBP:"🇬🇧",JPY:"🇯🇵",CAD:"🇨🇦",EUR:"🇪🇺",THB:"🇹🇭",NZD:"🇳🇿",SGD:"🇸🇬",HKD:"🇭🇰",CHF:"🇨🇭",KRW:"🇰🇷",INR:"🇮🇳",MXN:"🇲🇽",BRL:"🇧🇷"};function j(){const[u,d]=s(N),[j,y]=s(()=>t(h)),[x,b]=s({}),[D,S]=s(!1),[v,C]=s(!1),[J,U]=s([]),[R,B]=s(j),[G,L]=s("USD"),[W,A]=s("CNY");r(a(()=>{U([...u]),B({...j}),C(!0)},[u,j])),o(()=>{const t=[...new Set(u.map(([t])=>t))];let e=!0;return async function(){S(!0);const r={};for(const e of t){const t=g(e);if(t)r[e]=t;else try{const t=await fetch(`https://open.er-api.com/v6/latest/${e}`),n=await t.json();n.rates&&(r[e]=n.rates,k(e,n.rates))}catch{}}e&&(b(r),S(!1))}(),()=>{e=!1}},[u]);/* @__PURE__ */
1
+ import{loadAppearance as t,WidgetSettingsModal as e}from"./chunk-ZXI4CWTI.js";import{useWidgetSettings as r}from"./chunk-R6WJ2NTT.js";import"./chunk-TPDOOCFS.js";import"./chunk-AW7TOB6N.js";import"./chunk-KNUR2UEG.js";import"./chunk-JDCM2VHG.js";import"./chunk-SS7BG7BS.js";import"./chunk-Y53KNQKL.js";import"./chunk-5A7MWTXX.js";import"./chunk-O5PJELY7.js";import"./chunk-SGVIMTN6.js";import"./chunk-CGY5RNAF.js";import"./chunk-VWGWZY7A.js";import"./chunk-PKXQDCNR.js";import"./chunk-KC3EX26K.js";import"./chunk-UPHXYWL6.js";import"./chunk-5QFPTDQF.js";import"./chunk-LWGNNVDA.js";import"./chunk-UGTRSRIW.js";import"./chunk-QR4RM7PO.js";import"./chunk-5SULG7D5.js";import"./chunk-CDAJKLGL.js";import"./chunk-7T3COEQK.js";import"./chunk-UDD7GB4F.js";import"./chunk-K7U4RWXJ.js";import"./chunk-4TL3MRRE.js";import"./chunk-42BBJJDP.js";import"./chunk-J75ZT2JQ.js";import{LoadingSpinner as n}from"./chunk-Q5MD3VY6.js";import"./chunk-MRJKZWWV.js";import"./chunk-2LXTJXWC.js";import"./chunk-PGN5ME7B.js";import"./chunk-62LW225J.js";import"./chunk-GLUJS42B.js";import"./chunk-D65T4H6J.js";import"./chunk-DTJRIWFR.js";import"./chunk-TWVUQUUD.js";import"./chunk-GTRUBA2R.js";import"./chunk-C3QOHMR6.js";import{useState as s,useCallback as a,useEffect as o}from"react";import{jsxs as c,Fragment as i,jsx as l}from"react/jsx-runtime";var m=["USD","CNY","AUD","GBP","EUR","JPY","CAD","THB","NZD","SGD","HKD","CHF","KRW","INR","MXN","BRL"],u=[["USD","CNY"],["USD","AUD"],["GBP","USD"],["USD","JPY"]],p="currency_pairs",h="currency_appearance",d="currency_rates_cache";function g(t){try{const e=JSON.parse(localStorage.getItem(d)||"{}")[t];if(e&&Date.now()-e.timestamp<36e5)return e.rates}catch{}return null}function k(t,e){try{const r=JSON.parse(localStorage.getItem(d)||"{}");r[t]={rates:e,timestamp:Date.now()},localStorage.setItem(d,JSON.stringify(r))}catch{}}function N(){try{const t=JSON.parse(localStorage.getItem(p)||"");if(Array.isArray(t)&&t.length)return t.slice(0,4)}catch{}return u}var f={USD:"🇺🇸",CNY:"🇨🇳",AUD:"🇦🇺",GBP:"🇬🇧",JPY:"🇯🇵",CAD:"🇨🇦",EUR:"🇪🇺",THB:"🇹🇭",NZD:"🇳🇿",SGD:"🇸🇬",HKD:"🇭🇰",CHF:"🇨🇭",KRW:"🇰🇷",INR:"🇮🇳",MXN:"🇲🇽",BRL:"🇧🇷"};function j(){const[u,d]=s(N),[j,y]=s(()=>t(h)),[x,b]=s({}),[D,S]=s(!1),[v,C]=s(!1),[J,R]=s([]),[U,B]=s(j),[G,T]=s("USD"),[W,L]=s("CNY");r(a(()=>{R([...u]),B({...j}),C(!0)},[u,j])),o(()=>{const t=[...new Set(u.map(([t])=>t))];let e=!0;return async function(){S(!0);const r={};for(const e of t){const t=g(e);if(t)r[e]=t;else try{const t=await fetch(`https://open.er-api.com/v6/latest/${e}`),n=await t.json();n.rates&&(r[e]=n.rates,k(e,n.rates))}catch{}}e&&(b(r),S(!1))}(),()=>{e=!1}},[u]);/* @__PURE__ */
2
2
  return c(i,{children:[
3
3
  /* @__PURE__ */l("div",{style:{backgroundColor:`rgb(var(--taskbar-bg-rgb, 243 244 246) / ${j.activeOpacity/100})`,backdropFilter:j.activeBlur>0?`blur(${j.activeBlur}px)`:void 0},children:/* @__PURE__ */c("div",{className:"px-4 py-3 space-y-1",children:[D&&/* @__PURE__ */l(n,{size:"sm",padding:"py-4",label:"Loading rates"}),u.map(([t,e],r)=>{const n=x[t]?.[e];/* @__PURE__ */
4
4
  return c("button",{onClick:()=>{const t=u.map((t,e)=>e===r?[t[1],t[0]]:t);d(t),localStorage.setItem(p,JSON.stringify(t))},className:"flex items-center justify-between px-2 py-2 border-b border-gray-200 last:border-0 w-full hover:bg-gray-100 rounded transition-colors cursor-pointer",children:[
@@ -9,13 +9,13 @@ return c("button",{onClick:()=>{const t=u.map((t,e)=>e===r?[t[1],t[0]]:t);d(t),l
9
9
  /* @__PURE__ */l("span",{className:"text-base",children:f[e]||""}),
10
10
  /* @__PURE__ */l("span",{className:"text-sm font-semibold text-gray-700",children:e})]}),
11
11
  /* @__PURE__ */l("div",{className:"text-base font-mono font-semibold text-gray-900 tabular-nums",children:null!=n?n.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:4}):"—"})]},`${t}-${e}-${r}`)})]})}),
12
- /* @__PURE__ */l(e,{open:v,onClose:()=>C(!1),title:"Currency Settings",appearance:R,onAppearanceChange:B,onSave:()=>{if(0===J.length)return;const t=J.slice(0,4);d(t),y(R),localStorage.setItem(p,JSON.stringify(t)),localStorage.setItem(h,JSON.stringify(R)),C(!1)},children:/* @__PURE__ */c("div",{children:[
12
+ /* @__PURE__ */l(e,{open:v,onClose:()=>C(!1),title:"Currency Settings",appearance:U,onAppearanceChange:B,onSave:()=>{if(0===J.length)return;const t=J.slice(0,4);d(t),y(U),localStorage.setItem(p,JSON.stringify(t)),localStorage.setItem(h,JSON.stringify(U)),C(!1)},children:/* @__PURE__ */c("div",{children:[
13
13
  /* @__PURE__ */c("h3",{className:"text-sm font-semibold text-gray-700 mb-2",children:["Currency Pairs ",
14
14
  /* @__PURE__ */c("span",{className:"text-2xs font-normal text-gray-400",children:["(",J.length,"/",4,")"]})]}),
15
15
  /* @__PURE__ */l("div",{className:"space-y-1 mb-2",children:J.map(([t,e],r)=>/* @__PURE__ */c("div",{className:"flex items-center justify-between py-1 px-2 bg-gray-50 rounded",children:[
16
16
  /* @__PURE__ */c("span",{className:"text-sm",children:[f[t]||""," ",t," → ",f[e]||""," ",e]}),
17
- /* @__PURE__ */l("button",{onClick:()=>U(t=>t.filter((t,e)=>e!==r)),className:"text-red-400 hover:text-red-600",children:"×"})]},r))}),J.length<4?/* @__PURE__ */c("div",{className:"flex items-center gap-2",children:[
18
- /* @__PURE__ */l("select",{value:G,onChange:t=>L(t.target.value),className:"bg-gray-50 border border-gray-200 rounded px-2 py-1 text-sm focus:outline-none focus:ring-1 focus:ring-blue-500",children:m.map(t=>/* @__PURE__ */l("option",{children:t},t))}),
17
+ /* @__PURE__ */l("button",{onClick:()=>R(t=>t.filter((t,e)=>e!==r)),className:"text-red-400 hover:text-red-600",children:"×"})]},r))}),J.length<4?/* @__PURE__ */c("div",{className:"flex items-center gap-2",children:[
18
+ /* @__PURE__ */l("select",{value:G,onChange:t=>T(t.target.value),className:"bg-gray-50 border border-gray-200 rounded px-2 py-1 text-sm focus:outline-none focus:ring-1 focus:ring-blue-500",children:m.map(t=>/* @__PURE__ */l("option",{children:t},t))}),
19
19
  /* @__PURE__ */l("span",{className:"text-gray-400",children:"→"}),
20
- /* @__PURE__ */l("select",{value:W,onChange:t=>A(t.target.value),className:"bg-gray-50 border border-gray-200 rounded px-2 py-1 text-sm focus:outline-none focus:ring-1 focus:ring-blue-500",children:m.map(t=>/* @__PURE__ */l("option",{children:t},t))}),
21
- /* @__PURE__ */l("button",{onClick:()=>{G!==W&&J.length<4&&U(t=>[...t,[G,W]])},className:"text-sm font-medium text-blue-600 hover:text-blue-800 px-2",children:"+ Add"})]}):/* @__PURE__ */c("p",{className:"text-2xs text-gray-400 italic",children:["Max ",4," pairs — remove one to add another."]})]})})]})}export{j as default};
20
+ /* @__PURE__ */l("select",{value:W,onChange:t=>L(t.target.value),className:"bg-gray-50 border border-gray-200 rounded px-2 py-1 text-sm focus:outline-none focus:ring-1 focus:ring-blue-500",children:m.map(t=>/* @__PURE__ */l("option",{children:t},t))}),
21
+ /* @__PURE__ */l("button",{onClick:()=>{G!==W&&J.length<4&&R(t=>[...t,[G,W]])},className:"text-sm font-medium text-blue-600 hover:text-blue-800 px-2",children:"+ Add"})]}):/* @__PURE__ */c("p",{className:"text-2xs text-gray-400 italic",children:["Max ",4," pairs — remove one to add another."]})]})})]})}export{j as default};
@@ -1,4 +1,4 @@
1
- import{escapeHtml as e}from"./chunk-BR22X7E5.js";import{AboutApp as t}from"./chunk-6OPAUSMV.js";import{WindowTitle as n}from"./chunk-XINUGME7.js";import"./chunk-TPDOOCFS.js";import"./chunk-AW7TOB6N.js";import"./chunk-KNUR2UEG.js";import"./chunk-JDCM2VHG.js";import"./chunk-SS7BG7BS.js";import"./chunk-Y53KNQKL.js";import"./chunk-5A7MWTXX.js";import"./chunk-O5PJELY7.js";import"./chunk-SGVIMTN6.js";import"./chunk-CGY5RNAF.js";import"./chunk-VWGWZY7A.js";import"./chunk-PKXQDCNR.js";import{toast_default as r}from"./chunk-HIDOSOI4.js";import{PopupMenu as o,PopupMenuLabel as i,PopupMenuItem as l,PopupMenuDivider as a}from"./chunk-UPHXYWL6.js";import"./chunk-5QFPTDQF.js";import"./chunk-UGTRSRIW.js";import"./chunk-QR4RM7PO.js";import"./chunk-LWGNNVDA.js";import"./chunk-KC3EX26K.js";import"./chunk-CDAJKLGL.js";import"./chunk-5SULG7D5.js";import"./chunk-7T3COEQK.js";import"./chunk-AJOWAZ46.js";import"./chunk-UDD7GB4F.js";import"./chunk-K7U4RWXJ.js";import{Icon as s}from"./chunk-42BBJJDP.js";import"./chunk-J75ZT2JQ.js";import"./chunk-4TL3MRRE.js";import{LoadingSpinner as c}from"./chunk-Q5MD3VY6.js";import"./chunk-MRJKZWWV.js";import"./chunk-2LXTJXWC.js";import"./chunk-PGN5ME7B.js";import"./chunk-62LW225J.js";import"./chunk-GLUJS42B.js";import"./chunk-D65T4H6J.js";import"./chunk-DTJRIWFR.js";import"./chunk-TWVUQUUD.js";import"./chunk-GTRUBA2R.js";import"./chunk-C3QOHMR6.js";import{useState as m,useRef as d}from"react";import{jsxs as h,jsx as u}from"react/jsx-runtime";var p=/* @__PURE__ */new Set(["txt","md","markdown","csv","tsv","log","json","xml","html","htm","css","js","jsx","ts","tsx","py","rb","go","rs","java","c","h","cpp","hpp","sh","bash","yml","yaml","toml","ini","conf","env","sql"]),g=/* @__PURE__ */new Set(["docx"]),x={filename:"Untitled",kind:"docx",content:"",ext:"docx"};function f(){const[f,y]=m(x),[k,v]=m(!1),[b,w]=m(!1),[j,N]=m(!1),[D,C]=m(null),L=d(null),M=d(null),R=d(null),U=(e,t)=>{R.current?.focus(),document.execCommand(e,!1,t),N(!0)},W=e=>{for(const t of e){if(!t.type.startsWith("image/"))continue;const e=new FileReader;e.onload=()=>{R.current?.focus(),document.execCommand("insertImage",!1,String(e.result)),N(!0)},e.readAsDataURL(t)}},T=e=>{D&&(D.el.removeAttribute("width"),D.el.removeAttribute("height"),D.el.style.width=e??"",D.el.style.height=e?"auto":"",N(!0),C(null))},B=async t=>{const n=(t.name.split(".").pop()||"").toLowerCase();v(!0);try{if(p.has(n)||!g.has(n)&&t.type.startsWith("text/")){const r=await t.text(),o=e(r).replace(/\n/g,"<br>");y({filename:t.name,kind:"text",content:o,ext:n}),N(!1)}else if(g.has(n))try{const e=await(import(
1
+ import{escapeHtml as e}from"./chunk-BR22X7E5.js";import{AboutApp as t}from"./chunk-ZQGPJZY4.js";import{WindowTitle as n}from"./chunk-R6WJ2NTT.js";import"./chunk-TPDOOCFS.js";import"./chunk-AW7TOB6N.js";import"./chunk-KNUR2UEG.js";import"./chunk-JDCM2VHG.js";import"./chunk-SS7BG7BS.js";import"./chunk-Y53KNQKL.js";import"./chunk-5A7MWTXX.js";import"./chunk-O5PJELY7.js";import"./chunk-SGVIMTN6.js";import"./chunk-CGY5RNAF.js";import"./chunk-VWGWZY7A.js";import"./chunk-PKXQDCNR.js";import"./chunk-KC3EX26K.js";import{toast_default as r}from"./chunk-HIDOSOI4.js";import{PopupMenu as o,PopupMenuLabel as i,PopupMenuItem as l,PopupMenuDivider as a}from"./chunk-UPHXYWL6.js";import"./chunk-5QFPTDQF.js";import"./chunk-LWGNNVDA.js";import"./chunk-UGTRSRIW.js";import"./chunk-QR4RM7PO.js";import"./chunk-5SULG7D5.js";import"./chunk-CDAJKLGL.js";import"./chunk-7T3COEQK.js";import"./chunk-EUFALBK3.js";import"./chunk-UDD7GB4F.js";import"./chunk-K7U4RWXJ.js";import"./chunk-4TL3MRRE.js";import{Icon as s}from"./chunk-42BBJJDP.js";import"./chunk-J75ZT2JQ.js";import{LoadingSpinner as c}from"./chunk-Q5MD3VY6.js";import"./chunk-MRJKZWWV.js";import"./chunk-2LXTJXWC.js";import"./chunk-PGN5ME7B.js";import"./chunk-62LW225J.js";import"./chunk-GLUJS42B.js";import"./chunk-D65T4H6J.js";import"./chunk-DTJRIWFR.js";import"./chunk-TWVUQUUD.js";import"./chunk-GTRUBA2R.js";import"./chunk-C3QOHMR6.js";import{useState as m,useRef as d}from"react";import{jsxs as h,jsx as u}from"react/jsx-runtime";var p=/* @__PURE__ */new Set(["txt","md","markdown","csv","tsv","log","json","xml","html","htm","css","js","jsx","ts","tsx","py","rb","go","rs","java","c","h","cpp","hpp","sh","bash","yml","yaml","toml","ini","conf","env","sql"]),g=/* @__PURE__ */new Set(["docx"]),x={filename:"Untitled",kind:"docx",content:"",ext:"docx"};function f(){const[f,y]=m(x),[k,v]=m(!1),[b,w]=m(!1),[j,N]=m(!1),[D,C]=m(null),L=d(null),M=d(null),R=d(null),U=(e,t)=>{R.current?.focus(),document.execCommand(e,!1,t),N(!0)},W=e=>{for(const t of e){if(!t.type.startsWith("image/"))continue;const e=new FileReader;e.onload=()=>{R.current?.focus(),document.execCommand("insertImage",!1,String(e.result)),N(!0)},e.readAsDataURL(t)}},T=e=>{D&&(D.el.removeAttribute("width"),D.el.removeAttribute("height"),D.el.style.width=e??"",D.el.style.height=e?"auto":"",N(!0),C(null))},B=async t=>{const n=(t.name.split(".").pop()||"").toLowerCase();v(!0);try{if(p.has(n)||!g.has(n)&&t.type.startsWith("text/")){const r=await t.text(),o=e(r).replace(/\n/g,"<br>");y({filename:t.name,kind:"text",content:o,ext:n}),N(!1)}else if(g.has(n))try{const e=await(import(
2
2
  /* @vite-ignore */
3
3
  "mammoth")),r=await t.arrayBuffer(),o=await e.convertToHtml({arrayBuffer:r});y({filename:t.name,kind:"docx",content:o.value||"<p><em>(empty document)</em></p>",ext:n}),N(!1)}catch(e){r.error('Install the optional "mammoth" peer dep to read .docx files.')}else"doc"===n?r.error(".doc is the legacy Word binary format — convert to .docx first."):r.error(`Unsupported file type: .${n||"unknown"}`)}finally{v(!1)}},O=f?.filename?(S=f.filename).length>24?`${S.slice(0,23)}…`:S:"Untitled";var S;/* @__PURE__ */
4
4
  return h("div",{className:"relative flex flex-col h-full",onDragOver:e=>{e.preventDefault(),b||w(!0)},onDragLeave:e=>{e.currentTarget===e.target&&w(!1)},onDrop:e=>{e.preventDefault(),w(!1);const t=Array.from(e.dataTransfer.files??[]);0!==t.length&&(t.every(e=>e.type.startsWith("image/"))?W(t):B(t[0]))},children:[
@@ -1,4 +1,4 @@
1
- import{openPreviewFile as e}from"./chunk-RPY7FBYY.js";import{SidebarLayout as t}from"./chunk-YFY2LSWZ.js";import"./chunk-QWK6DRSN.js";import"./chunk-7NOU275V.js";import{Breadcrumbs as r}from"./chunk-DBBUHXRT.js";import{formatBytes as a}from"./chunk-X2S2XDZI.js";import"./chunk-5OTS2G3M.js";import"./chunk-36BRD5J3.js";import{getFilesDemoTree as n}from"./chunk-HBBTB6RW.js";import{AboutApp as s}from"./chunk-6OPAUSMV.js";import{peekFilesViewRequest as i,consumeFilesViewRequest as o,FILES_SHOW_TRASH_EVENT as l,FILES_OPEN_DESKTOP_FOLDER_EVENT as c,subscribeDesktopFolders as d,getDesktopFoldersSnapshot as m,FolderGlyph as h,DesktopItemMiniIcon as p,desktopItemTypeLabel as u}from"./chunk-BVDGHZ4H.js";import"./chunk-ESL5TDNA.js";import"./chunk-VTVSMRFX.js";import{useWindowManager as f,WindowTitle as x}from"./chunk-XINUGME7.js";import"./chunk-TPDOOCFS.js";import"./chunk-AW7TOB6N.js";import"./chunk-KNUR2UEG.js";import"./chunk-JDCM2VHG.js";import"./chunk-SS7BG7BS.js";import"./chunk-Y53KNQKL.js";import"./chunk-5A7MWTXX.js";import"./chunk-O5PJELY7.js";import{confirm as g,prompt as y}from"./chunk-SGVIMTN6.js";import"./chunk-CGY5RNAF.js";import"./chunk-VWGWZY7A.js";import"./chunk-PKXQDCNR.js";import{toast_default as b}from"./chunk-HIDOSOI4.js";import"./chunk-UPHXYWL6.js";import"./chunk-5QFPTDQF.js";import"./chunk-UGTRSRIW.js";import"./chunk-QR4RM7PO.js";import"./chunk-LWGNNVDA.js";import"./chunk-KC3EX26K.js";import"./chunk-CDAJKLGL.js";import"./chunk-5SULG7D5.js";import{TH_ONE_LINE as k}from"./chunk-7T3COEQK.js";import"./chunk-AJOWAZ46.js";import"./chunk-UDD7GB4F.js";import"./chunk-K7U4RWXJ.js";import{Icon as N}from"./chunk-42BBJJDP.js";import"./chunk-J75ZT2JQ.js";import"./chunk-4TL3MRRE.js";import{LoadingSpinner as w}from"./chunk-Q5MD3VY6.js";import"./chunk-MRJKZWWV.js";import"./chunk-2LXTJXWC.js";import"./chunk-PGN5ME7B.js";import"./chunk-62LW225J.js";import"./chunk-GLUJS42B.js";import"./chunk-D65T4H6J.js";import"./chunk-DTJRIWFR.js";import"./chunk-TWVUQUUD.js";import"./chunk-GTRUBA2R.js";import"./chunk-C3QOHMR6.js";import{useState as v,useEffect as j,useSyncExternalStore as $,useRef as C,useCallback as D}from"react";import{jsxs as T,jsx as L,Fragment as R}from"react/jsx-runtime";var E="undefined"!=typeof window&&window.__REACT_OS_SHELL_FILE_SERVER__||"http://localhost:4000",S={pdf:"pdf",dxf:"dxf",csv:"csv",jpg:"image",jpeg:"image",png:"image",gif:"image",webp:"image",svg:"image",avif:"image",bmp:"image",stp:"3d",step:"3d",stl:"3d",obj:"3d",gltf:"3d",glb:"3d","3mf":"3d",iges:"3d",igs:"3d",ply:"3d",fbx:"3d"};function W(e,t){return"/"===e||""===e?"/"+t:e.replace(/\/$/,"")+"/"+t}function P(e){if(!e)return"—";try{const t=new Date(e);return isNaN(t.getTime())?"—":t.toLocaleString(void 0,{dateStyle:"short",timeStyle:"short"})}catch{return e}}function U(){const U=E.replace(/\/$/,""),O=null!==n(),[F,M]=v("/"),[A,I]=v([]),[B,J]=v([]),[V,G]=v(null),[K,H]=v(!0),[X,Q]=v(!1),[z,Y]=v(null),[_,Z]=v(!1),[q,ee]=v(()=>{const e=i();return"trash"===e?"trash":e?{desktopFolderId:e.folderId}:"files"});j(()=>{o()},[]);const[te,re]=v([]);j(()=>{const e=()=>{o(),ee("trash")},t=e=>{o();const t=e.detail?.folderId;t&&ee({desktopFolderId:t})};return window.addEventListener(l,e),window.addEventListener(c,t),()=>{window.removeEventListener(l,e),window.removeEventListener(c,t)}},[]);const ae=$(d,m,m),ne="object"==typeof q?q.desktopFolderId:null,se=ne?ae?.folders.find(e=>e.id===ne)??null:null,ie=ne&&ae?.itemsByFolder[ne]||[];j(()=>{ne&&ae&&!ae.folders.some(e=>e.id===ne)&&ee("files")},[ne,ae]);const oe=C(0),le=C(null),{openPage:ce,openEntity:de}=f(),me=t=>{"preview-file"===t.entityType&&t.filePath&&t.fileKind?e({filePath:t.filePath,filename:t.label,kind:t.fileKind,onStaged:e=>ce(e)}):"page"===t.entityType?ce(t.entityId):de(t.entityType,t.entityId,null,t.label)},he=D((e,t={})=>fetch(e,{...t,credentials:"include"}),[]),pe=D(async()=>{try{const e=await he(`${U}/api/quota`);if(e.ok){const t=await e.json();Y({used:t.used,limit:t.limit})}}catch{}},[he,U]),ue=D(async e=>{if(G(null),O){const t=function(e){const t=n();if(!t)return[];let r=t;for(const t of e.split("/").filter(Boolean)){const e=r.find(e=>"folder"===e.kind&&e.name===t);if(!e||!e.children)return[];r=e.children}return r.map(e=>({name:e.name,kind:e.kind,size:e.size??0,modifiedAt:e.modifiedAt??""}))}(e);return I(t),M(e),Q(!1),H(!1),void("/"===e&&J(t.filter(e=>"folder"===e.kind).map(e=>e.name)))}H(!0);try{const t=await he(`${U}/api/files?path=${encodeURIComponent(e)}`);if(!t.ok){const e=await t.json().catch(()=>({}));return void b.error(e.error||`Failed to list (${t.status})`)}const r=await t.json(),a=r.entries||[];I(a),M(r.path||e),Q(!1),"/"===(r.path||e)&&J(a.filter(e=>"folder"===e.kind).map(e=>e.name))}catch(e){Q(!0)}finally{H(!1)}pe()},[he,U,pe,O]),fe=D(async()=>{if(O)return re([]),void H(!1);H(!0),G(null);try{const e=await he(`${U}/api/trash`);if(!e.ok){const t=await e.json().catch(()=>({}));return void b.error(t.error||`Failed to list trash (${e.status})`)}const t=await e.json();re(t.entries||[]),Q(!1)}catch{Q(!0)}finally{H(!1)}pe()},[he,U,pe,O]);j(()=>{"files"===q?ue(F):"trash"===q&&fe()},[F,q]);const xe=async e=>{const t=W(F,e.name);try{const r=await he(`${U}/api/file?path=${encodeURIComponent(t)}`);if(!r.ok)return void b.error(`Download failed (${r.status})`);const a=await r.blob(),n=URL.createObjectURL(a),s=document.createElement("a");s.href=n,s.download=e.name,s.click(),setTimeout(()=>URL.revokeObjectURL(n),1e3)}catch(e){b.error(e?.message||"Download failed")}},ge=async e=>{const t=Array.from(e);for(const e of t){const t=new FormData;t.append("file",e);try{const r=await he(`${U}/api/upload?path=${encodeURIComponent(F)}`,{method:"POST",body:t});if(!r.ok){const t=await r.json().catch(()=>({}));if(413===r.status){const r=Math.max(0,(t.limit||0)-(t.used||0));b.error(`Quota exceeded — ${a(r)} free, ${e.name} is ${a(t.attempted||e.size)}`)}else b.error(`Upload ${e.name}: ${t.error||r.status}`)}}catch(t){b.error(`Upload ${e.name}: ${t?.message||"failed"}`)}}ue(F)},ye=()=>{oe.current=0,Z(!1)};if(j(()=>{const e=()=>ye();return window.addEventListener("dragend",e),window.addEventListener("drop",e),()=>{window.removeEventListener("dragend",e),window.removeEventListener("drop",e)}},[]),X)/* @__PURE__ */
1
+ import{openPreviewFile as e}from"./chunk-RPY7FBYY.js";import{SidebarLayout as t}from"./chunk-YFY2LSWZ.js";import"./chunk-QWK6DRSN.js";import"./chunk-7NOU275V.js";import{Breadcrumbs as r}from"./chunk-DBBUHXRT.js";import{formatBytes as a}from"./chunk-X2S2XDZI.js";import"./chunk-5OTS2G3M.js";import"./chunk-36BRD5J3.js";import{getFilesDemoTree as n}from"./chunk-HBBTB6RW.js";import{AboutApp as s}from"./chunk-ZQGPJZY4.js";import{peekFilesViewRequest as i,consumeFilesViewRequest as o,FILES_SHOW_TRASH_EVENT as l,FILES_OPEN_DESKTOP_FOLDER_EVENT as c,subscribeDesktopFolders as d,getDesktopFoldersSnapshot as m,FolderGlyph as h,DesktopItemMiniIcon as p,desktopItemTypeLabel as u}from"./chunk-BVDGHZ4H.js";import"./chunk-ESL5TDNA.js";import"./chunk-VTVSMRFX.js";import{useWindowManager as f,WindowTitle as x}from"./chunk-R6WJ2NTT.js";import"./chunk-TPDOOCFS.js";import"./chunk-AW7TOB6N.js";import"./chunk-KNUR2UEG.js";import"./chunk-JDCM2VHG.js";import"./chunk-SS7BG7BS.js";import"./chunk-Y53KNQKL.js";import"./chunk-5A7MWTXX.js";import"./chunk-O5PJELY7.js";import{confirm as g,prompt as y}from"./chunk-SGVIMTN6.js";import"./chunk-CGY5RNAF.js";import"./chunk-VWGWZY7A.js";import"./chunk-PKXQDCNR.js";import"./chunk-KC3EX26K.js";import{toast_default as b}from"./chunk-HIDOSOI4.js";import"./chunk-UPHXYWL6.js";import"./chunk-5QFPTDQF.js";import"./chunk-LWGNNVDA.js";import"./chunk-UGTRSRIW.js";import"./chunk-QR4RM7PO.js";import"./chunk-5SULG7D5.js";import"./chunk-CDAJKLGL.js";import{TH_ONE_LINE as k}from"./chunk-7T3COEQK.js";import"./chunk-EUFALBK3.js";import"./chunk-UDD7GB4F.js";import"./chunk-K7U4RWXJ.js";import"./chunk-4TL3MRRE.js";import{Icon as N}from"./chunk-42BBJJDP.js";import"./chunk-J75ZT2JQ.js";import{LoadingSpinner as w}from"./chunk-Q5MD3VY6.js";import"./chunk-MRJKZWWV.js";import"./chunk-2LXTJXWC.js";import"./chunk-PGN5ME7B.js";import"./chunk-62LW225J.js";import"./chunk-GLUJS42B.js";import"./chunk-D65T4H6J.js";import"./chunk-DTJRIWFR.js";import"./chunk-TWVUQUUD.js";import"./chunk-GTRUBA2R.js";import"./chunk-C3QOHMR6.js";import{useState as v,useEffect as j,useSyncExternalStore as $,useRef as C,useCallback as D}from"react";import{jsxs as T,jsx as L,Fragment as R}from"react/jsx-runtime";var E="undefined"!=typeof window&&window.__REACT_OS_SHELL_FILE_SERVER__||"http://localhost:4000",W={pdf:"pdf",dxf:"dxf",csv:"csv",jpg:"image",jpeg:"image",png:"image",gif:"image",webp:"image",svg:"image",avif:"image",bmp:"image",stp:"3d",step:"3d",stl:"3d",obj:"3d",gltf:"3d",glb:"3d","3mf":"3d",iges:"3d",igs:"3d",ply:"3d",fbx:"3d"};function S(e,t){return"/"===e||""===e?"/"+t:e.replace(/\/$/,"")+"/"+t}function P(e){if(!e)return"—";try{const t=new Date(e);return isNaN(t.getTime())?"—":t.toLocaleString(void 0,{dateStyle:"short",timeStyle:"short"})}catch{return e}}function U(){const U=E.replace(/\/$/,""),F=null!==n(),[O,B]=v("/"),[M,I]=v([]),[A,J]=v([]),[G,V]=v(null),[K,H]=v(!0),[Q,X]=v(!1),[Y,z]=v(null),[Z,_]=v(!1),[q,ee]=v(()=>{const e=i();return"trash"===e?"trash":e?{desktopFolderId:e.folderId}:"files"});j(()=>{o()},[]);const[te,re]=v([]);j(()=>{const e=()=>{o(),ee("trash")},t=e=>{o();const t=e.detail?.folderId;t&&ee({desktopFolderId:t})};return window.addEventListener(l,e),window.addEventListener(c,t),()=>{window.removeEventListener(l,e),window.removeEventListener(c,t)}},[]);const ae=$(d,m,m),ne="object"==typeof q?q.desktopFolderId:null,se=ne?ae?.folders.find(e=>e.id===ne)??null:null,ie=ne&&ae?.itemsByFolder[ne]||[];j(()=>{ne&&ae&&!ae.folders.some(e=>e.id===ne)&&ee("files")},[ne,ae]);const oe=C(0),le=C(null),{openPage:ce,openEntity:de}=f(),me=t=>{"preview-file"===t.entityType&&t.filePath&&t.fileKind?e({filePath:t.filePath,filename:t.label,kind:t.fileKind,onStaged:e=>ce(e)}):"page"===t.entityType?ce(t.entityId):de(t.entityType,t.entityId,null,t.label)},he=D((e,t={})=>fetch(e,{...t,credentials:"include"}),[]),pe=D(async()=>{try{const e=await he(`${U}/api/quota`);if(e.ok){const t=await e.json();z({used:t.used,limit:t.limit})}}catch{}},[he,U]),ue=D(async e=>{if(V(null),F){const t=function(e){const t=n();if(!t)return[];let r=t;for(const t of e.split("/").filter(Boolean)){const e=r.find(e=>"folder"===e.kind&&e.name===t);if(!e||!e.children)return[];r=e.children}return r.map(e=>({name:e.name,kind:e.kind,size:e.size??0,modifiedAt:e.modifiedAt??""}))}(e);return I(t),B(e),X(!1),H(!1),void("/"===e&&J(t.filter(e=>"folder"===e.kind).map(e=>e.name)))}H(!0);try{const t=await he(`${U}/api/files?path=${encodeURIComponent(e)}`);if(!t.ok){const e=await t.json().catch(()=>({}));return void b.error(e.error||`Failed to list (${t.status})`)}const r=await t.json(),a=r.entries||[];I(a),B(r.path||e),X(!1),"/"===(r.path||e)&&J(a.filter(e=>"folder"===e.kind).map(e=>e.name))}catch(e){X(!0)}finally{H(!1)}pe()},[he,U,pe,F]),fe=D(async()=>{if(F)return re([]),void H(!1);H(!0),V(null);try{const e=await he(`${U}/api/trash`);if(!e.ok){const t=await e.json().catch(()=>({}));return void b.error(t.error||`Failed to list trash (${e.status})`)}const t=await e.json();re(t.entries||[]),X(!1)}catch{X(!0)}finally{H(!1)}pe()},[he,U,pe,F]);j(()=>{"files"===q?ue(O):"trash"===q&&fe()},[O,q]);const xe=async e=>{const t=S(O,e.name);try{const r=await he(`${U}/api/file?path=${encodeURIComponent(t)}`);if(!r.ok)return void b.error(`Download failed (${r.status})`);const a=await r.blob(),n=URL.createObjectURL(a),s=document.createElement("a");s.href=n,s.download=e.name,s.click(),setTimeout(()=>URL.revokeObjectURL(n),1e3)}catch(e){b.error(e?.message||"Download failed")}},ge=async e=>{const t=Array.from(e);for(const e of t){const t=new FormData;t.append("file",e);try{const r=await he(`${U}/api/upload?path=${encodeURIComponent(O)}`,{method:"POST",body:t});if(!r.ok){const t=await r.json().catch(()=>({}));if(413===r.status){const r=Math.max(0,(t.limit||0)-(t.used||0));b.error(`Quota exceeded — ${a(r)} free, ${e.name} is ${a(t.attempted||e.size)}`)}else b.error(`Upload ${e.name}: ${t.error||r.status}`)}}catch(t){b.error(`Upload ${e.name}: ${t?.message||"failed"}`)}}ue(O)},ye=()=>{oe.current=0,_(!1)};if(j(()=>{const e=()=>ye();return window.addEventListener("dragend",e),window.addEventListener("drop",e),()=>{window.removeEventListener("dragend",e),window.removeEventListener("drop",e)}},[]),Q)/* @__PURE__ */
2
2
  return T("div",{className:"flex flex-col h-full bg-white",children:[
3
3
  /* @__PURE__ */L(x,{title:"Files - offline"}),
4
4
  /* @__PURE__ */L("div",{className:"flex-1 flex items-center justify-center p-8 text-center",children:/* @__PURE__ */T("div",{className:"max-w-md",children:[
@@ -7,25 +7,25 @@ return T("div",{className:"flex flex-col h-full bg-white",children:[
7
7
  /* @__PURE__ */T("p",{className:"text-sm text-gray-500 mb-3",children:["No response from ",
8
8
  /* @__PURE__ */L("span",{className:"font-mono",children:U}),". Make sure the server is running — see ",
9
9
  /* @__PURE__ */L("span",{className:"font-mono",children:"examples/file-server/README.md"}),"."]}),
10
- /* @__PURE__ */L("button",{onClick:()=>ue(F),className:"px-3 h-8 text-sm bg-blue-500 text-white rounded hover:bg-blue-600",children:"Retry"})]})})]});const be="/"===F?[]:F.split("/").filter(Boolean),ke=z&&z.limit>0?Math.min(100,Math.round(z.used/z.limit*100)):0,Ne=ke>90?"bg-red-500":ke>75?"bg-amber-500":"bg-blue-500",we=[{label:"My files",onClick:()=>M("/")},...be.map((e,t)=>({label:e,onClick:()=>M("/"+be.slice(0,t+1).join("/"))}))],ve=e=>"flex w-full items-center gap-2 rounded-md px-3 min-h-(--row-height-menu) py-2 text-left text-sm transition-colors "+(e?"bg-blue-50 font-medium text-blue-700":"text-gray-700 hover:bg-gray-100"),je=e=>/* @__PURE__ */L("svg",{className:"h-4 w-4 shrink-0 text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.6,children:/* @__PURE__ */L("path",{strokeLinecap:"round",strokeLinejoin:"round",d:e})}),$e=/* @__PURE__ */T("nav",{className:"p-2",children:[
10
+ /* @__PURE__ */L("button",{onClick:()=>ue(O),className:"px-3 h-8 text-sm bg-blue-500 text-white rounded hover:bg-blue-600",children:"Retry"})]})})]});const be="/"===O?[]:O.split("/").filter(Boolean),ke=Y&&Y.limit>0?Math.min(100,Math.round(Y.used/Y.limit*100)):0,Ne=ke>90?"bg-red-500":ke>75?"bg-amber-500":"bg-blue-500",we=[{label:"My files",onClick:()=>B("/")},...be.map((e,t)=>({label:e,onClick:()=>B("/"+be.slice(0,t+1).join("/"))}))],ve=e=>"flex w-full items-center gap-2 rounded-md px-3 min-h-(--row-height-menu) py-2 text-left text-sm transition-colors "+(e?"bg-blue-50 font-medium text-blue-700":"text-gray-700 hover:bg-gray-100"),je=e=>/* @__PURE__ */L("svg",{className:"h-4 w-4 shrink-0 text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.6,children:/* @__PURE__ */L("path",{strokeLinecap:"round",strokeLinejoin:"round",d:e})}),$e=/* @__PURE__ */T("nav",{className:"p-2",children:[
11
11
  /* @__PURE__ */L("div",{className:"px-2 py-2 text-2xs font-semibold uppercase tracking-wide text-gray-400",children:"Locations"}),
12
- /* @__PURE__ */T("button",{onClick:()=>{ee("files"),M("/")},className:ve("files"===q&&"/"===F),children:[je("M2.25 12l8.954-8.955a1.5 1.5 0 012.122 0L21.75 12M4.5 9.75v9.75a.75.75 0 00.75.75H9V15a.75.75 0 01.75-.75h4.5A.75.75 0 0115 15v5.25h3.75a.75.75 0 00.75-.75V9.75"),"My files"]}),B.map(e=>/* @__PURE__ */T("button",{onClick:()=>{ee("files"),M("/"+e)},className:ve("files"===q&&F==="/"+e),children:[je("M2.25 12.75V12A2.25 2.25 0 014.5 9.75h15A2.25 2.25 0 0121.75 12v.75m-8.69-6.44l-2.12-2.12a1.5 1.5 0 00-1.061-.44H4.5A2.25 2.25 0 002.25 6v12a2.25 2.25 0 002.25 2.25h15A2.25 2.25 0 0021.75 18V9a2.25 2.25 0 00-2.25-2.25h-5.379a1.5 1.5 0 01-1.06-.44z"),
13
- /* @__PURE__ */L("span",{className:"truncate",children:e})]},e)),!O&&/* @__PURE__ */T("button",{onClick:()=>ee("trash"),className:ve("trash"===q),children:[je("M14.74 9l-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 01-2.244 2.077H8.084a2.25 2.25 0 01-2.244-2.077L4.772 5.79"),"Trash"]}),ae&&ae.folders.length>0&&/* @__PURE__ */T(R,{children:[
12
+ /* @__PURE__ */T("button",{onClick:()=>{ee("files"),B("/")},className:ve("files"===q&&"/"===O),children:[je("M2.25 12l8.954-8.955a1.5 1.5 0 012.122 0L21.75 12M4.5 9.75v9.75a.75.75 0 00.75.75H9V15a.75.75 0 01.75-.75h4.5A.75.75 0 0115 15v5.25h3.75a.75.75 0 00.75-.75V9.75"),"My files"]}),A.map(e=>/* @__PURE__ */T("button",{onClick:()=>{ee("files"),B("/"+e)},className:ve("files"===q&&O==="/"+e),children:[je("M2.25 12.75V12A2.25 2.25 0 014.5 9.75h15A2.25 2.25 0 0121.75 12v.75m-8.69-6.44l-2.12-2.12a1.5 1.5 0 00-1.061-.44H4.5A2.25 2.25 0 002.25 6v12a2.25 2.25 0 002.25 2.25h15A2.25 2.25 0 0021.75 18V9a2.25 2.25 0 00-2.25-2.25h-5.379a1.5 1.5 0 01-1.06-.44z"),
13
+ /* @__PURE__ */L("span",{className:"truncate",children:e})]},e)),!F&&/* @__PURE__ */T("button",{onClick:()=>ee("trash"),className:ve("trash"===q),children:[je("M14.74 9l-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 01-2.244 2.077H8.084a2.25 2.25 0 01-2.244-2.077L4.772 5.79"),"Trash"]}),ae&&ae.folders.length>0&&/* @__PURE__ */T(R,{children:[
14
14
  /* @__PURE__ */L("div",{className:"px-2 pt-3 pb-2 text-2xs font-semibold uppercase tracking-wide text-gray-400",children:"Desktop"}),ae.folders.map(e=>/* @__PURE__ */T("button",{onClick:()=>ee({desktopFolderId:e.id}),className:ve(ne===e.id),children:[
15
15
  /* @__PURE__ */L(h,{className:"h-4 w-4 shrink-0 text-amber-500"}),
16
16
  /* @__PURE__ */L("span",{className:"truncate",children:e.name}),e.itemCount>0&&/* @__PURE__ */L("span",{className:"ml-auto text-2xs text-gray-400 tabular-nums",children:e.itemCount})]},e.id))]})]});/* @__PURE__ */
17
- return T("div",{className:"relative flex flex-col h-full bg-white",onDragEnter:e=>{O||"object"==typeof q||e.dataTransfer?.types?.includes?.("Files")&&(e.preventDefault(),oe.current++,_||Z(!0))},onDragOver:e=>{e.dataTransfer?.types?.includes?.("Files")&&e.preventDefault()},onDragLeave:()=>{oe.current>0&&oe.current--,0===oe.current&&Z(!1)},onDrop:e=>{e.preventDefault(),ye(),O||"object"==typeof q||e.dataTransfer.files?.length&&ge(e.dataTransfer.files)},children:[
18
- /* @__PURE__ */L(x,{title:se?`Files - ${se.name}`:"Files"+("/"===F?"":" - "+F)}),
17
+ return T("div",{className:"relative flex flex-col h-full bg-white",onDragEnter:e=>{F||"object"==typeof q||e.dataTransfer?.types?.includes?.("Files")&&(e.preventDefault(),oe.current++,Z||_(!0))},onDragOver:e=>{e.dataTransfer?.types?.includes?.("Files")&&e.preventDefault()},onDragLeave:()=>{oe.current>0&&oe.current--,0===oe.current&&_(!1)},onDrop:e=>{e.preventDefault(),ye(),F||"object"==typeof q||e.dataTransfer.files?.length&&ge(e.dataTransfer.files)},children:[
18
+ /* @__PURE__ */L(x,{title:se?`Files - ${se.name}`:"Files"+("/"===O?"":" - "+O)}),
19
19
  /* @__PURE__ */L(s,{app:"files"}),
20
20
  /* @__PURE__ */L("input",{ref:le,type:"file",multiple:!0,className:"hidden",onChange:e=>{e.target.files?.length&&ge(e.target.files),le.current&&(le.current.value="")}}),
21
21
  /* @__PURE__ */L("div",{className:"flex-1 min-h-0",children:/* @__PURE__ */L(t,{sidebar:$e,storageKey:"files.sidebarWidth",defaultWidth:200,minWidth:150,maxWidth:320,children:/* @__PURE__ */T("div",{className:"flex h-full min-w-0 flex-col",children:[
22
22
  /* @__PURE__ */T("div",{className:"flex items-center gap-1 px-2 py-2 border-b border-gray-200 bg-gray-50 shrink-0 text-xs",children:[/* @__PURE__ */T(R,"files"===q?{children:[
23
- /* @__PURE__ */L("button",{onClick:()=>M(function(e){if("/"===e||""===e)return"/";const t=e.replace(/\/$/,""),r=t.lastIndexOf("/");return r<=0?"/":t.slice(0,r)}(F)),disabled:"/"===F,className:"px-2 py-1 rounded hover:bg-gray-200 disabled:opacity-30 text-gray-600",title:"Parent folder",children:/* @__PURE__ */L(N,{name:"arrow-left",className:"h-3.5 w-3.5",strokeWidth:2})}),
23
+ /* @__PURE__ */L("button",{onClick:()=>B(function(e){if("/"===e||""===e)return"/";const t=e.replace(/\/$/,""),r=t.lastIndexOf("/");return r<=0?"/":t.slice(0,r)}(O)),disabled:"/"===O,className:"px-2 py-1 rounded hover:bg-gray-200 disabled:opacity-30 text-gray-600",title:"Parent folder",children:/* @__PURE__ */L(N,{name:"arrow-left",className:"h-3.5 w-3.5",strokeWidth:2})}),
24
24
  /* @__PURE__ */L("div",{className:"flex-1 min-w-0",children:/* @__PURE__ */L(r,{items:we,maxItems:5})}),
25
- /* @__PURE__ */L("button",{onClick:()=>ue(F),className:"px-2 py-1 rounded hover:bg-gray-200 text-gray-600",title:"Refresh",children:/* @__PURE__ */L(N,{name:"refresh",className:"h-3.5 w-3.5",strokeWidth:1.8})}),!O&&/* @__PURE__ */T(R,{children:[
25
+ /* @__PURE__ */L("button",{onClick:()=>ue(O),className:"px-2 py-1 rounded hover:bg-gray-200 text-gray-600",title:"Refresh",children:/* @__PURE__ */L(N,{name:"refresh",className:"h-3.5 w-3.5",strokeWidth:1.8})}),!F&&/* @__PURE__ */T(R,{children:[
26
26
  /* @__PURE__ */T("button",{onClick:()=>ee("trash"),className:"px-2 py-1 rounded hover:bg-gray-200 text-gray-600 flex items-center gap-1",title:"Open trash",children:[
27
27
  /* @__PURE__ */L(N,{name:"trash",className:"h-3.5 w-3.5",strokeWidth:1.5}),"Trash"]}),
28
- /* @__PURE__ */T("button",{onClick:async()=>{const e=await y({title:"New folder",placeholder:"Folder name",confirmLabel:"Create"});if(!e)return;if(/[\\/]/.test(e))return void b.error("Folder names cannot contain slashes");const t=W(F,e),r=await he(`${U}/api/folder`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:t})});if(!r.ok){const e=await r.json().catch(()=>({}));return void b.error(e.error||`Create folder failed (${r.status})`)}ue(F)},className:"px-2 py-1 rounded hover:bg-gray-200 text-gray-600 flex items-center gap-1",children:[
28
+ /* @__PURE__ */T("button",{onClick:async()=>{const e=await y({title:"New folder",placeholder:"Folder name",confirmLabel:"Create"});if(!e)return;if(/[\\/]/.test(e))return void b.error("Folder names cannot contain slashes");const t=S(O,e),r=await he(`${U}/api/folder`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:t})});if(!r.ok){const e=await r.json().catch(()=>({}));return void b.error(e.error||`Create folder failed (${r.status})`)}ue(O)},className:"px-2 py-1 rounded hover:bg-gray-200 text-gray-600 flex items-center gap-1",children:[
29
29
  /* @__PURE__ */L(N,{name:"folder-plus",className:"h-3.5 w-3.5",strokeWidth:1.5}),"New Folder"]}),
30
30
  /* @__PURE__ */T("button",{onClick:()=>le.current?.click(),className:"px-2 py-1 rounded bg-blue-500 text-white hover:bg-blue-600 flex items-center gap-1",children:[
31
31
  /* @__PURE__ */L(N,{name:"upload",className:"h-3.5 w-3.5",strokeWidth:1.8}),"Upload"]})]})]}:"trash"===q?{children:[
@@ -36,18 +36,18 @@ return T("div",{className:"relative flex flex-col h-full bg-white",onDragEnter:e
36
36
  /* @__PURE__ */L("button",{onClick:()=>ee("files"),className:"px-2 py-1 rounded hover:bg-gray-200 text-gray-600",title:"Back to files",children:/* @__PURE__ */L(N,{name:"arrow-left",className:"h-3.5 w-3.5",strokeWidth:2})}),
37
37
  /* @__PURE__ */L(h,{className:"h-4 w-4 text-amber-500 ml-1"}),
38
38
  /* @__PURE__ */L("span",{className:"flex-1 text-gray-700 font-medium px-1 truncate",children:se?.name??"Desktop folder"}),
39
- /* @__PURE__ */L("span",{className:"text-2xs text-gray-400 px-2",children:"Desktop shortcuts"})]}),z&&/* @__PURE__ */T(R,{children:[
39
+ /* @__PURE__ */L("span",{className:"text-2xs text-gray-400 px-2",children:"Desktop shortcuts"})]}),Y&&/* @__PURE__ */T(R,{children:[
40
40
  /* @__PURE__ */L("div",{className:"h-4 w-px bg-gray-300 mx-1"}),
41
- /* @__PURE__ */T("div",{className:"flex items-center gap-2",title:`${a(z.used)} of ${a(z.limit)} used`,children:[
41
+ /* @__PURE__ */T("div",{className:"flex items-center gap-2",title:`${a(Y.used)} of ${a(Y.limit)} used`,children:[
42
42
  /* @__PURE__ */L("div",{className:"w-20 h-1.5 rounded-full bg-gray-200 overflow-hidden",children:/* @__PURE__ */L("div",{className:`h-full ${Ne} transition-all`,style:{width:`${ke}%`}})}),
43
- /* @__PURE__ */T("span",{className:"text-2xs text-gray-500 tabular-nums whitespace-nowrap",children:[a(z.used)," / ",a(z.limit)]})]})]})]}),
43
+ /* @__PURE__ */T("span",{className:"text-2xs text-gray-500 tabular-nums whitespace-nowrap",children:[a(Y.used)," / ",a(Y.limit)]})]})]})]}),
44
44
  /* @__PURE__ */L("div",{className:"flex-1 overflow-auto",children:"object"==typeof q?0===ie.length?/* @__PURE__ */L("div",{className:"p-10 text-center text-sm text-gray-400",children:"This desktop folder is empty. Drag shortcuts onto it on the desktop."}):/* @__PURE__ */T("table",{className:"w-full text-sm",children:[
45
45
  /* @__PURE__ */L("thead",{className:"bg-gray-50 text-2xs uppercase tracking-wide text-gray-500",children:/* @__PURE__ */T("tr",{children:[
46
46
  /* @__PURE__ */L("th",{className:`${k} text-left font-medium px-3 h-8`,children:"Name"}),
47
47
  /* @__PURE__ */L("th",{className:`${k} text-left font-medium px-3 h-8 w-28`,children:"Type"}),
48
48
  /* @__PURE__ */L("th",{className:`${k} w-56`})]})}),
49
49
  /* @__PURE__ */L("tbody",{children:ie.map(e=>{const t=`${e.entityType}|${e.entityId}`;/* @__PURE__ */
50
- return T("tr",{onClick:()=>G(t),onDoubleClick:()=>me(e),className:"cursor-default border-b border-gray-100 "+(V===t?"bg-blue-50":"hover:bg-gray-50"),children:[
50
+ return T("tr",{onClick:()=>V(t),onDoubleClick:()=>me(e),className:"cursor-default border-b border-gray-100 "+(G===t?"bg-blue-50":"hover:bg-gray-50"),children:[
51
51
  /* @__PURE__ */T("td",{className:"px-3 h-8 flex items-center gap-2",children:[
52
52
  /* @__PURE__ */L(p,{item:e}),
53
53
  /* @__PURE__ */L("span",{className:"truncate",title:e.label,children:e.label})]}),
@@ -70,18 +70,18 @@ return T("tr",{onClick:()=>G(t),onDoubleClick:()=>me(e),className:"cursor-defaul
70
70
  /* @__PURE__ */L("td",{className:"px-3 h-8 text-right text-gray-500 tabular-nums",children:e.deletedAt?P(e.deletedAt):"—"}),
71
71
  /* @__PURE__ */T("td",{className:"px-3 h-8 text-right whitespace-nowrap",children:[
72
72
  /* @__PURE__ */L("button",{onClick:()=>(async e=>{const t=await he(`${U}/api/trash/restore`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e.id})});if(!t.ok){const e=await t.json().catch(()=>({}));return void b.error(e.error||`Restore failed (${t.status})`)}b.success(`Restored "${e.name}"`),fe()})(e),className:"px-2 py-0.5 rounded hover:bg-gray-200 text-blue-600 text-2xs",children:"Restore"}),
73
- /* @__PURE__ */L("button",{onClick:()=>(async e=>{if(!await g({title:"Permanently delete",message:`"${e.name}" will be permanently removed. This can't be undone.`,confirmLabel:"Delete forever",variant:"danger"}))return;const t=await he(`${U}/api/trash/${encodeURIComponent(e.id)}`,{method:"DELETE"});if(!t.ok){const e=await t.json().catch(()=>({}));return void b.error(e.error||`Delete failed (${t.status})`)}fe()})(e),className:"px-2 py-0.5 rounded hover:bg-red-100 text-red-600 text-2xs ml-1",children:"Delete forever"})]})]},e.id))})]}):K&&0===A.length?/* @__PURE__ */L(w,{size:"sm",padding:"p-6",label:"Loading"}):0===A.length?/* @__PURE__ */T("div",{className:"p-10 text-center text-sm text-gray-400",children:["Empty folder.",!O&&/* @__PURE__ */T(R,{children:[" Drop files here or click ",
73
+ /* @__PURE__ */L("button",{onClick:()=>(async e=>{if(!await g({title:"Permanently delete",message:`"${e.name}" will be permanently removed. This can't be undone.`,confirmLabel:"Delete forever",variant:"danger"}))return;const t=await he(`${U}/api/trash/${encodeURIComponent(e.id)}`,{method:"DELETE"});if(!t.ok){const e=await t.json().catch(()=>({}));return void b.error(e.error||`Delete failed (${t.status})`)}fe()})(e),className:"px-2 py-0.5 rounded hover:bg-red-100 text-red-600 text-2xs ml-1",children:"Delete forever"})]})]},e.id))})]}):K&&0===M.length?/* @__PURE__ */L(w,{size:"sm",padding:"p-6",label:"Loading"}):0===M.length?/* @__PURE__ */T("div",{className:"p-10 text-center text-sm text-gray-400",children:["Empty folder.",!F&&/* @__PURE__ */T(R,{children:[" Drop files here or click ",
74
74
  /* @__PURE__ */L("span",{className:"font-medium",children:"Upload"}),"."]})]}):/* @__PURE__ */T("table",{className:"w-full text-sm",children:[
75
75
  /* @__PURE__ */L("thead",{className:"bg-gray-50 text-2xs uppercase tracking-wide text-gray-500",children:/* @__PURE__ */T("tr",{children:[
76
76
  /* @__PURE__ */L("th",{className:`${k} text-left font-medium px-3 h-8`,children:"Name"}),
77
77
  /* @__PURE__ */L("th",{className:`${k} text-right font-medium px-3 h-8 w-24`,children:"Size"}),
78
78
  /* @__PURE__ */L("th",{className:`${k} text-right font-medium px-3 h-8 w-40`,children:"Modified"}),
79
79
  /* @__PURE__ */L("th",{className:`${k} w-32`})]})}),
80
- /* @__PURE__ */L("tbody",{children:A.map(t=>/* @__PURE__ */T("tr",{onClick:()=>G(t.name),onDoubleClick:()=>{"folder"===t.kind?M(W(F,t.name)):(async t=>{if(O)return;const r=W(F,t.name),a=(t.name.split(".").pop()||"").toLowerCase(),n=S[a];n?await e({filePath:r,filename:t.name,kind:n,onStaged:e=>ce(e)}):xe(t)})(t)},className:"cursor-default border-b border-gray-100 "+(V===t.name?"bg-blue-50":"hover:bg-gray-50"),children:[
80
+ /* @__PURE__ */L("tbody",{children:M.map(t=>/* @__PURE__ */T("tr",{onClick:()=>V(t.name),onDoubleClick:()=>{"folder"===t.kind?B(S(O,t.name)):(async t=>{if(F)return;const r=S(O,t.name),a=(t.name.split(".").pop()||"").toLowerCase(),n=W[a];n?await e({filePath:r,filename:t.name,kind:n,onStaged:e=>ce(e)}):xe(t)})(t)},className:"cursor-default border-b border-gray-100 "+(G===t.name?"bg-blue-50":"hover:bg-gray-50"),children:[
81
81
  /* @__PURE__ */T("td",{className:"px-3 h-8 flex items-center gap-2",children:["folder"===t.kind?/* @__PURE__ */L(N,{name:"folder",look:"solid",className:"h-4 w-4 text-amber-500 shrink-0"}):/* @__PURE__ */L(N,{name:"page",className:"h-4 w-4 text-gray-400 shrink-0",strokeWidth:1.5}),
82
82
  /* @__PURE__ */L("span",{className:"truncate",title:t.name,children:t.name})]}),
83
83
  /* @__PURE__ */L("td",{className:"px-3 h-8 text-right tabular-nums text-gray-500",children:"folder"===t.kind?"—":a(t.size)}),
84
84
  /* @__PURE__ */L("td",{className:"px-3 h-8 text-right text-gray-500 tabular-nums",children:P(t.modifiedAt)}),
85
- /* @__PURE__ */L("td",{className:"px-3 h-8 text-right whitespace-nowrap",children:!O&&/* @__PURE__ */T(R,{children:["file"===t.kind&&/* @__PURE__ */L("button",{onClick:e=>{e.stopPropagation(),xe(t)},className:"px-2 py-0.5 rounded hover:bg-gray-200 text-gray-500 text-2xs",children:"Download"}),
86
- /* @__PURE__ */L("button",{onClick:e=>{e.stopPropagation(),(async e=>{const t=await y({title:`Rename ${e.kind}`,defaultValue:e.name,confirmLabel:"Rename"});if(!t||t===e.name)return;if(/[\\/]/.test(t))return void b.error("Names cannot contain slashes");const r=W(F,e.name),a=W(F,t),n=await he(`${U}/api/rename`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({from:r,to:a})});if(!n.ok){const e=await n.json().catch(()=>({}));return void b.error(e.error||`Rename failed (${n.status})`)}ue(F)})(t)},className:"px-2 py-0.5 rounded hover:bg-gray-200 text-gray-500 text-2xs ml-1",children:"Rename"}),
87
- /* @__PURE__ */L("button",{onClick:e=>{e.stopPropagation(),(async e=>{if(!await g({title:`Delete ${e.kind}`,message:`"${e.name}"${"folder"===e.kind?" and everything inside":""} will be permanently removed.`,confirmLabel:"Delete",variant:"danger"}))return;const t=W(F,e.name),r=await he(`${U}/api/files?path=${encodeURIComponent(t)}`,{method:"DELETE"});if(!r.ok){const e=await r.json().catch(()=>({}));return void b.error(e.error||`Delete failed (${r.status})`)}ue(F)})(t)},className:"px-2 py-0.5 rounded hover:bg-red-100 text-red-600 text-2xs ml-1",children:"Delete"})]})})]},t.name))})]})})]})})}),_&&/* @__PURE__ */L("div",{className:"absolute inset-0 bg-blue-500/15 border-4 border-dashed border-blue-500 pointer-events-none flex items-center justify-center z-20",children:/* @__PURE__ */L("div",{className:"px-4 py-2 rounded-md bg-blue-600 text-white text-sm font-medium shadow-lg",children:"Drop to upload"})})]})}export{U as default};
85
+ /* @__PURE__ */L("td",{className:"px-3 h-8 text-right whitespace-nowrap",children:!F&&/* @__PURE__ */T(R,{children:["file"===t.kind&&/* @__PURE__ */L("button",{onClick:e=>{e.stopPropagation(),xe(t)},className:"px-2 py-0.5 rounded hover:bg-gray-200 text-gray-500 text-2xs",children:"Download"}),
86
+ /* @__PURE__ */L("button",{onClick:e=>{e.stopPropagation(),(async e=>{const t=await y({title:`Rename ${e.kind}`,defaultValue:e.name,confirmLabel:"Rename"});if(!t||t===e.name)return;if(/[\\/]/.test(t))return void b.error("Names cannot contain slashes");const r=S(O,e.name),a=S(O,t),n=await he(`${U}/api/rename`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({from:r,to:a})});if(!n.ok){const e=await n.json().catch(()=>({}));return void b.error(e.error||`Rename failed (${n.status})`)}ue(O)})(t)},className:"px-2 py-0.5 rounded hover:bg-gray-200 text-gray-500 text-2xs ml-1",children:"Rename"}),
87
+ /* @__PURE__ */L("button",{onClick:e=>{e.stopPropagation(),(async e=>{if(!await g({title:`Delete ${e.kind}`,message:`"${e.name}"${"folder"===e.kind?" and everything inside":""} will be permanently removed.`,confirmLabel:"Delete",variant:"danger"}))return;const t=S(O,e.name),r=await he(`${U}/api/files?path=${encodeURIComponent(t)}`,{method:"DELETE"});if(!r.ok){const e=await r.json().catch(()=>({}));return void b.error(e.error||`Delete failed (${r.status})`)}ue(O)})(t)},className:"px-2 py-0.5 rounded hover:bg-red-100 text-red-600 text-2xs ml-1",children:"Delete"})]})})]},t.name))})]})})]})})}),Z&&/* @__PURE__ */L("div",{className:"absolute inset-0 bg-blue-500/15 border-4 border-dashed border-blue-500 pointer-events-none flex items-center justify-center z-20",children:/* @__PURE__ */L("div",{className:"px-4 py-2 rounded-md bg-blue-600 text-white text-sm font-medium shadow-lg",children:"Drop to upload"})})]})}export{U as default};
@@ -1,8 +1,8 @@
1
- import{getNumberingConfigs as e}from"./chunk-HAZLMRTT.js";import{SidebarLayout as t}from"./chunk-YFY2LSWZ.js";import"./chunk-QWK6DRSN.js";import"./chunk-7NOU275V.js";import{timeAgo as r}from"./chunk-X2S2XDZI.js";import"./chunk-5OTS2G3M.js";import"./chunk-36BRD5J3.js";import{AboutApp as n}from"./chunk-6OPAUSMV.js";import{useWindowManager as o,client_default as i}from"./chunk-XINUGME7.js";import"./chunk-TPDOOCFS.js";import"./chunk-AW7TOB6N.js";import"./chunk-KNUR2UEG.js";import"./chunk-JDCM2VHG.js";import"./chunk-SS7BG7BS.js";import"./chunk-Y53KNQKL.js";import"./chunk-5A7MWTXX.js";import"./chunk-O5PJELY7.js";import"./chunk-SGVIMTN6.js";import"./chunk-CGY5RNAF.js";import"./chunk-VWGWZY7A.js";import"./chunk-PKXQDCNR.js";import{toast_default as s}from"./chunk-HIDOSOI4.js";import"./chunk-UPHXYWL6.js";import"./chunk-5QFPTDQF.js";import"./chunk-UGTRSRIW.js";import"./chunk-QR4RM7PO.js";import"./chunk-LWGNNVDA.js";import{useShellPrefs as c}from"./chunk-KC3EX26K.js";import"./chunk-CDAJKLGL.js";import"./chunk-5SULG7D5.js";import"./chunk-7T3COEQK.js";import"./chunk-AJOWAZ46.js";import"./chunk-UDD7GB4F.js";import"./chunk-K7U4RWXJ.js";import{Icon as a}from"./chunk-42BBJJDP.js";import"./chunk-J75ZT2JQ.js";import"./chunk-4TL3MRRE.js";import"./chunk-Q5MD3VY6.js";import"./chunk-MRJKZWWV.js";import"./chunk-2LXTJXWC.js";import"./chunk-PGN5ME7B.js";import"./chunk-62LW225J.js";import"./chunk-GLUJS42B.js";import"./chunk-D65T4H6J.js";import"./chunk-DTJRIWFR.js";import"./chunk-TWVUQUUD.js";import"./chunk-GTRUBA2R.js";import"./chunk-C3QOHMR6.js";import{useRef as l,useEffect as p,useState as d,useCallback as m}from"react";import{useQuery as u}from"@tanstack/react-query";import{jsxs as h,Fragment as y,jsx as g}from"react/jsx-runtime";var x=[{key:"yellow",bg:"bg-yellow-100",border:"border-yellow-300",text:"text-yellow-900",dot:"bg-yellow-400"},{key:"blue",bg:"bg-blue-100",border:"border-blue-300",text:"text-blue-900",dot:"bg-blue-400"},{key:"green",bg:"bg-green-100",border:"border-green-300",text:"text-green-900",dot:"bg-green-400"},{key:"pink",bg:"bg-pink-100",border:"border-pink-300",text:"text-pink-900",dot:"bg-pink-400"},{key:"purple",bg:"bg-purple-100",border:"border-purple-300",text:"text-purple-900",dot:"bg-purple-400"},{key:"orange",bg:"bg-orange-100",border:"border-orange-300",text:"text-orange-900",dot:"bg-orange-400"},{key:"white",bg:"bg-white",border:"border-gray-300",text:"text-gray-900",dot:"bg-gray-300"}];var k={sales_order:{entityType:"order",endpoint:"/orders/sales-orders/"},purchase_order:{entityType:"purchase_order",endpoint:"/purchase-orders/"},invoice:{entityType:"invoice",endpoint:"/invoicing/invoices/"},vendor_invoice:{entityType:"vendor_invoice",endpoint:"/invoicing/vendor-invoices/"},shipment:{entityType:"shipment",endpoint:"/shipments/delivery-notes/"},receipt:{entityType:"payment",endpoint:"/invoicing/payments/"},vendor_payment:{entityType:"vendor_payment",endpoint:"/invoicing/vendor-payments/"},vendor_price_sheet:{entityType:"vendor_price_sheet",endpoint:"/pricing/manufacturer-price-sheets/"},client_price_sheet:{entityType:"price_sheet",endpoint:"/pricing/price-sheets/"},qc_report:{entityType:"qc_report",endpoint:"/qc-reports/"},warranty_claim:{entityType:"warranty_claim",endpoint:"/warranty-claims/claims/"},vendor_shipment:{entityType:"vendor_shipment",endpoint:"/shipments/goods-receipts/"}},b=/\[([ xX]?)\]/g;function f(){const{openEntity:f}=o(),{prefs:N,save:v}=c(),{data:j}=u({queryKey:["numbering-configs"],queryFn:()=>e(),retry:!1}),w=l({});p(()=>{if(!j)return;const e={};for(const t of j){const r=k[t.entity_type];if(!r)continue;const n=(t.prefix||"").replace("#","").toUpperCase();if(n&&(e[n]={...r,prefix:t.prefix}),t.alt_prefix){const n=t.alt_prefix.replace("#","").toUpperCase();n&&(e[n]={...r,prefix:t.alt_prefix})}}w.current=e},[j]);const T=N.notepad_notes||[],[_,W]=d(null),[C,S]=d(""),[D,R]=d(""),[O,$]=d("yellow"),[U,X]=d(!1),[G,J]=d(!1),L=l(null),M=l(),K=T.find(e=>e.id===_);p(()=>{if(!_&&T.length>0){const e=T[0];W(e.id),S(e.title),R(e.content),$(e.color)}},[T.length]);const P=m(e=>{v({notepad_notes:e})},[v]),A=m(()=>{if(!_||!U)return;const e=T.map(e=>e.id===_?{...e,title:C,content:D,color:O,updated_at:/* @__PURE__ */(new Date).toISOString()}:e);P(e),X(!1)},[_,U,C,D,O,T,P]);p(()=>{if(U)return M.current&&clearTimeout(M.current),M.current=setTimeout(A,800),()=>{M.current&&clearTimeout(M.current)}},[U,A]),p(()=>()=>{U&&A()},[]);const I=e=>{U&&A(),W(e.id),S(e.title),R(e.content),$(e.color),X(!1),J(!1)},B=e=>{const t=D.slice(0,e),r=D.slice(e).match(/^\[([ xX]?)\]/);if(!r)return;const n="x"===r[1]||"X"===r[1]?"[ ]":"[x]",o=D.slice(e+r[0].length);R(t+n+o),X(!0)},Q=async(e,t)=>{const r=w.current[e];if(!r)return;const n=`${e}#${t}`;try{const{data:e}=await i.get(r.endpoint,{params:{search:n,page_size:1}}),t=(e?.results??e??[])[0];t?f(r.entityType,t.id,t,n):s.error(`${n} not found`)}catch{s.error(`Failed to look up ${n}`)}},E="Start writing...\n\nTips:\n [] Type [] for a checkbox, click to toggle\n SO#35001 Type XX#NNNNN to link entities (SO, PO, CI, VI, PL, etc.)",V=/* @__PURE__ */h(y,{children:[
2
- /* @__PURE__ */g("div",{className:"p-2 border-b border-gray-200",children:/* @__PURE__ */h("button",{onClick:()=>{U&&A();const e={id:`note-${Date.now()}-${Math.random().toString(36).slice(2,6)}`,title:"",content:"",color:"yellow",sticky:!1,updated_at:/* @__PURE__ */(new Date).toISOString()},t=[e,...T];P(t),W(e.id),S(""),R(""),$("yellow"),X(!1),J(!0),setTimeout(()=>L.current?.focus(),50)},className:"w-full flex items-center justify-center gap-2 rounded-lg bg-blue-600 text-white px-3 min-h-8 py-1 text-sm font-medium hover:bg-blue-700 transition-colors",children:[
1
+ import{getNumberingConfigs as e}from"./chunk-KAELFRN4.js";import{SidebarLayout as t}from"./chunk-YFY2LSWZ.js";import"./chunk-QWK6DRSN.js";import"./chunk-7NOU275V.js";import{timeAgo as r}from"./chunk-X2S2XDZI.js";import"./chunk-5OTS2G3M.js";import"./chunk-36BRD5J3.js";import{AboutApp as n}from"./chunk-ZQGPJZY4.js";import{useWindowManager as o,client_default as i}from"./chunk-R6WJ2NTT.js";import"./chunk-TPDOOCFS.js";import"./chunk-AW7TOB6N.js";import"./chunk-KNUR2UEG.js";import"./chunk-JDCM2VHG.js";import"./chunk-SS7BG7BS.js";import"./chunk-Y53KNQKL.js";import"./chunk-5A7MWTXX.js";import"./chunk-O5PJELY7.js";import"./chunk-SGVIMTN6.js";import"./chunk-CGY5RNAF.js";import"./chunk-VWGWZY7A.js";import"./chunk-PKXQDCNR.js";import{useShellPrefs as s}from"./chunk-KC3EX26K.js";import{toast_default as c}from"./chunk-HIDOSOI4.js";import"./chunk-UPHXYWL6.js";import"./chunk-5QFPTDQF.js";import"./chunk-LWGNNVDA.js";import"./chunk-UGTRSRIW.js";import"./chunk-QR4RM7PO.js";import"./chunk-5SULG7D5.js";import"./chunk-CDAJKLGL.js";import"./chunk-7T3COEQK.js";import"./chunk-EUFALBK3.js";import"./chunk-UDD7GB4F.js";import"./chunk-K7U4RWXJ.js";import"./chunk-4TL3MRRE.js";import{Icon as a}from"./chunk-42BBJJDP.js";import"./chunk-J75ZT2JQ.js";import"./chunk-Q5MD3VY6.js";import"./chunk-MRJKZWWV.js";import"./chunk-2LXTJXWC.js";import"./chunk-PGN5ME7B.js";import"./chunk-62LW225J.js";import"./chunk-GLUJS42B.js";import"./chunk-D65T4H6J.js";import"./chunk-DTJRIWFR.js";import"./chunk-TWVUQUUD.js";import"./chunk-GTRUBA2R.js";import"./chunk-C3QOHMR6.js";import{useRef as l,useEffect as p,useState as d,useCallback as m}from"react";import{useQuery as u}from"@tanstack/react-query";import{jsxs as h,Fragment as y,jsx as g}from"react/jsx-runtime";var x=[{key:"yellow",bg:"bg-yellow-100",border:"border-yellow-300",text:"text-yellow-900",dot:"bg-yellow-400"},{key:"blue",bg:"bg-blue-100",border:"border-blue-300",text:"text-blue-900",dot:"bg-blue-400"},{key:"green",bg:"bg-green-100",border:"border-green-300",text:"text-green-900",dot:"bg-green-400"},{key:"pink",bg:"bg-pink-100",border:"border-pink-300",text:"text-pink-900",dot:"bg-pink-400"},{key:"purple",bg:"bg-purple-100",border:"border-purple-300",text:"text-purple-900",dot:"bg-purple-400"},{key:"orange",bg:"bg-orange-100",border:"border-orange-300",text:"text-orange-900",dot:"bg-orange-400"},{key:"white",bg:"bg-white",border:"border-gray-300",text:"text-gray-900",dot:"bg-gray-300"}];var k={sales_order:{entityType:"order",endpoint:"/orders/sales-orders/"},purchase_order:{entityType:"purchase_order",endpoint:"/purchase-orders/"},invoice:{entityType:"invoice",endpoint:"/invoicing/invoices/"},vendor_invoice:{entityType:"vendor_invoice",endpoint:"/invoicing/vendor-invoices/"},shipment:{entityType:"shipment",endpoint:"/shipments/delivery-notes/"},receipt:{entityType:"payment",endpoint:"/invoicing/payments/"},vendor_payment:{entityType:"vendor_payment",endpoint:"/invoicing/vendor-payments/"},vendor_price_sheet:{entityType:"vendor_price_sheet",endpoint:"/pricing/manufacturer-price-sheets/"},client_price_sheet:{entityType:"price_sheet",endpoint:"/pricing/price-sheets/"},qc_report:{entityType:"qc_report",endpoint:"/qc-reports/"},warranty_claim:{entityType:"warranty_claim",endpoint:"/warranty-claims/claims/"},vendor_shipment:{entityType:"vendor_shipment",endpoint:"/shipments/goods-receipts/"}},b=/\[([ xX]?)\]/g;function f(){const{openEntity:f}=o(),{prefs:N,save:v}=s(),{data:j}=u({queryKey:["numbering-configs"],queryFn:()=>e(),retry:!1}),w=l({});p(()=>{if(!j)return;const e={};for(const t of j){const r=k[t.entity_type];if(!r)continue;const n=(t.prefix||"").replace("#","").toUpperCase();if(n&&(e[n]={...r,prefix:t.prefix}),t.alt_prefix){const n=t.alt_prefix.replace("#","").toUpperCase();n&&(e[n]={...r,prefix:t.alt_prefix})}}w.current=e},[j]);const T=N.notepad_notes||[],[_,W]=d(null),[C,S]=d(""),[D,R]=d(""),[$,J]=d("yellow"),[O,U]=d(!1),[X,G]=d(!1),K=l(null),L=l(),P=T.find(e=>e.id===_);p(()=>{if(!_&&T.length>0){const e=T[0];W(e.id),S(e.title),R(e.content),J(e.color)}},[T.length]);const B=m(e=>{v({notepad_notes:e})},[v]),Q=m(()=>{if(!_||!O)return;const e=T.map(e=>e.id===_?{...e,title:C,content:D,color:$,updated_at:/* @__PURE__ */(new Date).toISOString()}:e);B(e),U(!1)},[_,O,C,D,$,T,B]);p(()=>{if(O)return L.current&&clearTimeout(L.current),L.current=setTimeout(Q,800),()=>{L.current&&clearTimeout(L.current)}},[O,Q]),p(()=>()=>{O&&Q()},[]);const E=e=>{O&&Q(),W(e.id),S(e.title),R(e.content),J(e.color),U(!1),G(!1)},F=e=>{const t=D.slice(0,e),r=D.slice(e).match(/^\[([ xX]?)\]/);if(!r)return;const n="x"===r[1]||"X"===r[1]?"[ ]":"[x]",o=D.slice(e+r[0].length);R(t+n+o),U(!0)},I=async(e,t)=>{const r=w.current[e];if(!r)return;const n=`${e}#${t}`;try{const{data:e}=await i.get(r.endpoint,{params:{search:n,page_size:1}}),t=(e?.results??e??[])[0];t?f(r.entityType,t.id,t,n):c.error(`${n} not found`)}catch{c.error(`Failed to look up ${n}`)}},M="Start writing...\n\nTips:\n [] Type [] for a checkbox, click to toggle\n SO#35001 Type XX#NNNNN to link entities (SO, PO, CI, VI, PL, etc.)",A=/* @__PURE__ */h(y,{children:[
2
+ /* @__PURE__ */g("div",{className:"p-2 border-b border-gray-200",children:/* @__PURE__ */h("button",{onClick:()=>{O&&Q();const e={id:`note-${Date.now()}-${Math.random().toString(36).slice(2,6)}`,title:"",content:"",color:"yellow",sticky:!1,updated_at:/* @__PURE__ */(new Date).toISOString()},t=[e,...T];B(t),W(e.id),S(""),R(""),J("yellow"),U(!1),G(!0),setTimeout(()=>K.current?.focus(),50)},className:"w-full flex items-center justify-center gap-2 rounded-lg bg-blue-600 text-white px-3 min-h-8 py-1 text-sm font-medium hover:bg-blue-700 transition-colors",children:[
3
3
  /* @__PURE__ */g(a,{name:"add",className:"h-4 w-4",strokeWidth:2}),"New Note"]})}),
4
4
  /* @__PURE__ */g("div",{className:"flex-1 overflow-y-auto",children:0===T.length?/* @__PURE__ */g("p",{className:"text-sm text-gray-400 text-center py-8 px-4",children:"No notes yet. Create one to get started."}):T.map(e=>{const t=(n=e.color,x.find(e=>e.key===n)||x[0]);var n;/* @__PURE__ */
5
- return h("button",{onClick:()=>I(e),className:"w-full text-left px-3 py-3 border-b border-gray-100 transition-colors "+(_===e.id?"bg-blue-50":"hover:bg-gray-50"),children:[
5
+ return h("button",{onClick:()=>E(e),className:"w-full text-left px-3 py-3 border-b border-gray-100 transition-colors "+(_===e.id?"bg-blue-50":"hover:bg-gray-50"),children:[
6
6
  /* @__PURE__ */h("div",{className:"flex items-center gap-2",children:[
7
7
  /* @__PURE__ */g("div",{className:`w-3 h-3 rounded-full shrink-0 ${t.dot}`}),
8
8
  /* @__PURE__ */g("span",{className:"text-sm font-medium text-gray-900 truncate flex-1",children:e.title||"Untitled"}),e.sticky&&/* @__PURE__ */g(a,{name:"bookmark",look:"solid",className:"h-3 w-3 text-amber-500 shrink-0"})]}),
@@ -10,16 +10,16 @@ return h("button",{onClick:()=>I(e),className:"w-full text-left px-3 py-3 border
10
10
  /* @__PURE__ */g("p",{className:"text-2xs text-gray-300 mt-0.5 ml-5",children:r(e.updated_at)})]},e.id)})})]});/* @__PURE__ */
11
11
  return h("div",{className:"h-full",children:[
12
12
  /* @__PURE__ */g(n,{app:"notepad"}),
13
- /* @__PURE__ */g(t,{sidebar:V,storageKey:"notepad.sidebarWidth",defaultWidth:224,minWidth:180,maxWidth:360,children:_?/* @__PURE__ */h("div",{className:"flex-1 flex flex-col min-w-0",children:[
13
+ /* @__PURE__ */g(t,{sidebar:A,storageKey:"notepad.sidebarWidth",defaultWidth:224,minWidth:180,maxWidth:360,children:_?/* @__PURE__ */h("div",{className:"flex-1 flex flex-col min-w-0",children:[
14
14
  /* @__PURE__ */h("div",{className:"flex items-center gap-2 px-4 py-2 border-b border-gray-200",children:[
15
- /* @__PURE__ */g("input",{value:C,onChange:e=>{S(e.target.value),X(!0)},placeholder:"Note title...",className:"flex-1 text-lg font-semibold text-gray-900 outline-none bg-transparent placeholder:text-gray-300"}),
16
- /* @__PURE__ */g("div",{className:"flex gap-1",children:x.map(e=>/* @__PURE__ */g("button",{onClick:()=>{$(e.key),X(!0)},className:`w-5 h-5 rounded-full border-2 transition-all ${e.dot} ${O===e.key?"border-gray-600 scale-110":"border-transparent hover:border-gray-400"}`,title:e.key},e.key))}),
17
- /* @__PURE__ */g("button",{onClick:()=>(e=>{const t=T.map(t=>t.id===e?{...t,sticky:!t.sticky}:t);P(t);const r=t.find(t=>t.id===e);s.success(r?.sticky?"Pinned to desktop":"Removed from desktop")})(_),title:K?.sticky?"Remove from desktop":"Pin to desktop",className:"p-1 rounded transition-colors "+(K?.sticky?"text-amber-500 hover:text-amber-600":"text-gray-300 hover:text-amber-400"),children:/* @__PURE__ */g(a,{name:"bookmark",className:"h-4 w-4",fill:K?.sticky?"currentColor":"none",strokeWidth:1.5})}),
18
- /* @__PURE__ */g("button",{onClick:()=>(e=>{const t=T.filter(t=>t.id!==e);if(P(t),_===e){const e=t[0];e?I(e):(W(null),S(""),R(""))}})(_),title:"Delete note",className:"p-1 rounded text-gray-300 hover:text-red-500 transition-colors",children:/* @__PURE__ */g(a,{name:"trash",className:"h-4 w-4",strokeWidth:1.5})})]}),G?/* @__PURE__ */g("textarea",{ref:L,value:D,onChange:e=>{R(e.target.value),X(!0)},onBlur:()=>{J(!1),U&&A()},placeholder:E,className:"flex-1 p-4 text-sm text-gray-700 outline-none resize-none bg-transparent leading-relaxed placeholder:text-gray-300 font-mono"}):/* @__PURE__ */g("div",{onClick:()=>{J(!0),setTimeout(()=>L.current?.focus(),50)},className:"flex-1 p-4 text-sm text-gray-700 overflow-y-auto leading-relaxed cursor-text",children:D?(e=>{if(!e)return[];const t=e.split("\n");return t.map((e,r)=>{const n=[];let o=0;const i=[],s=/([A-Z]{2,4})#(\d{4,6})/g;let c;for(;null!==(c=s.exec(e));){const e=c[1],t=c[2];if(w.current[e]){const n=c.index,o=c[0];i.push({idx:n,len:o.length,render:()=>/* @__PURE__ */g("button",{onClick:()=>Q(e,t),className:"text-blue-600 hover:text-blue-800 hover:underline font-medium cursor-pointer",children:o},`ref-${r}-${n}`)})}}b.lastIndex=0;let l=0;for(let e=0;e<r;e++)l+=t[e].length+1;for(;null!==(c=b.exec(e));){const e="x"===c[1]||"X"===c[1],t=c.index,n=l+t;i.push({idx:t,len:c[0].length,render:()=>/* @__PURE__ */g("button",{onClick:()=>B(n),className:`inline-flex items-center justify-center w-4 h-4 rounded border ${e?"bg-blue-500 border-blue-500 text-white":"border-gray-400 bg-white hover:border-blue-400"} cursor-pointer align-text-bottom mr-0.5`,children:e&&/* @__PURE__ */g(a,{name:"check",className:"w-3 h-3",strokeWidth:3})},`cb-${r}-${t}`)})}i.sort((e,t)=>e.idx-t.idx);for(const t of i)t.idx>o&&n.push(/* @__PURE__ */g("span",{children:e.slice(o,t.idx)},`t-${r}-${o}`)),n.push(t.render()),o=t.idx+t.len;o<e.length&&n.push(/* @__PURE__ */g("span",{children:e.slice(o)},`t-${r}-${o}`)),0===n.length&&n.push(/* @__PURE__ */g("span",{children:"​"},`empty-${r}`));const p=/^\[x\]/i.test(e.trimStart());/* @__PURE__ */
19
- return g("div",{className:p?"line-through text-gray-400":"",children:n},r)})})(D):/* @__PURE__ */g("p",{className:"text-gray-300 whitespace-pre-line",children:E})}),
15
+ /* @__PURE__ */g("input",{value:C,onChange:e=>{S(e.target.value),U(!0)},placeholder:"Note title...",className:"flex-1 text-lg font-semibold text-gray-900 outline-none bg-transparent placeholder:text-gray-300"}),
16
+ /* @__PURE__ */g("div",{className:"flex gap-1",children:x.map(e=>/* @__PURE__ */g("button",{onClick:()=>{J(e.key),U(!0)},className:`w-5 h-5 rounded-full border-2 transition-all ${e.dot} ${$===e.key?"border-gray-600 scale-110":"border-transparent hover:border-gray-400"}`,title:e.key},e.key))}),
17
+ /* @__PURE__ */g("button",{onClick:()=>(e=>{const t=T.map(t=>t.id===e?{...t,sticky:!t.sticky}:t);B(t);const r=t.find(t=>t.id===e);c.success(r?.sticky?"Pinned to desktop":"Removed from desktop")})(_),title:P?.sticky?"Remove from desktop":"Pin to desktop",className:"p-1 rounded transition-colors "+(P?.sticky?"text-amber-500 hover:text-amber-600":"text-gray-300 hover:text-amber-400"),children:/* @__PURE__ */g(a,{name:"bookmark",className:"h-4 w-4",fill:P?.sticky?"currentColor":"none",strokeWidth:1.5})}),
18
+ /* @__PURE__ */g("button",{onClick:()=>(e=>{const t=T.filter(t=>t.id!==e);if(B(t),_===e){const e=t[0];e?E(e):(W(null),S(""),R(""))}})(_),title:"Delete note",className:"p-1 rounded text-gray-300 hover:text-red-500 transition-colors",children:/* @__PURE__ */g(a,{name:"trash",className:"h-4 w-4",strokeWidth:1.5})})]}),X?/* @__PURE__ */g("textarea",{ref:K,value:D,onChange:e=>{R(e.target.value),U(!0)},onBlur:()=>{G(!1),O&&Q()},placeholder:M,className:"flex-1 p-4 text-sm text-gray-700 outline-none resize-none bg-transparent leading-relaxed placeholder:text-gray-300 font-mono"}):/* @__PURE__ */g("div",{onClick:()=>{G(!0),setTimeout(()=>K.current?.focus(),50)},className:"flex-1 p-4 text-sm text-gray-700 overflow-y-auto leading-relaxed cursor-text",children:D?(e=>{if(!e)return[];const t=e.split("\n");return t.map((e,r)=>{const n=[];let o=0;const i=[],s=/([A-Z]{2,4})#(\d{4,6})/g;let c;for(;null!==(c=s.exec(e));){const e=c[1],t=c[2];if(w.current[e]){const n=c.index,o=c[0];i.push({idx:n,len:o.length,render:()=>/* @__PURE__ */g("button",{onClick:()=>I(e,t),className:"text-blue-600 hover:text-blue-800 hover:underline font-medium cursor-pointer",children:o},`ref-${r}-${n}`)})}}b.lastIndex=0;let l=0;for(let e=0;e<r;e++)l+=t[e].length+1;for(;null!==(c=b.exec(e));){const e="x"===c[1]||"X"===c[1],t=c.index,n=l+t;i.push({idx:t,len:c[0].length,render:()=>/* @__PURE__ */g("button",{onClick:()=>F(n),className:`inline-flex items-center justify-center w-4 h-4 rounded border ${e?"bg-blue-500 border-blue-500 text-white":"border-gray-400 bg-white hover:border-blue-400"} cursor-pointer align-text-bottom mr-0.5`,children:e&&/* @__PURE__ */g(a,{name:"check",className:"w-3 h-3",strokeWidth:3})},`cb-${r}-${t}`)})}i.sort((e,t)=>e.idx-t.idx);for(const t of i)t.idx>o&&n.push(/* @__PURE__ */g("span",{children:e.slice(o,t.idx)},`t-${r}-${o}`)),n.push(t.render()),o=t.idx+t.len;o<e.length&&n.push(/* @__PURE__ */g("span",{children:e.slice(o)},`t-${r}-${o}`)),0===n.length&&n.push(/* @__PURE__ */g("span",{children:"​"},`empty-${r}`));const p=/^\[x\]/i.test(e.trimStart());/* @__PURE__ */
19
+ return g("div",{className:p?"line-through text-gray-400":"",children:n},r)})})(D):/* @__PURE__ */g("p",{className:"text-gray-300 whitespace-pre-line",children:M})}),
20
20
  /* @__PURE__ */h("div",{className:"px-4 min-h-8 py-1 border-t border-gray-100 flex items-center gap-4 text-2xs text-gray-400",children:[
21
21
  /* @__PURE__ */g("span",{children:"[] checkbox"}),
22
22
  /* @__PURE__ */g("span",{children:"SO#35001 entity link"}),
23
- /* @__PURE__ */g("span",{className:"ml-auto",children:G?"Editing":"Click to edit"})]})]}):/* @__PURE__ */g("div",{className:"flex-1 flex items-center justify-center",children:/* @__PURE__ */h("div",{className:"text-center text-gray-400",children:[
23
+ /* @__PURE__ */g("span",{className:"ml-auto",children:X?"Editing":"Click to edit"})]})]}):/* @__PURE__ */g("div",{className:"flex-1 flex items-center justify-center",children:/* @__PURE__ */h("div",{className:"text-center text-gray-400",children:[
24
24
  /* @__PURE__ */g(a,{name:"page",className:"h-12 w-12 mx-auto mb-3 text-gray-300",strokeWidth:1}),
25
25
  /* @__PURE__ */g("p",{className:"text-sm",children:"Select a note or create a new one"})]})})})]})}export{f as default};