efficient-shell 14.2.0 → 14.5.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 (101) hide show
  1. package/README.md +39 -1
  2. package/dist/{Browser-PL2P7EIZ.js → Browser-I3RIWI6Y.js} +14 -14
  3. package/dist/{Calculator-WMYHPFPA.js → Calculator-VUM3R6HA.js} +22 -22
  4. package/dist/CodeEditor-D6V_rQOK.d.ts +55 -0
  5. package/dist/CodeEditor-RKC5XRLP.js +1 -0
  6. package/dist/{CurrencyConverter-3B7YXRLL.js → CurrencyConverter-HEMRND5M.js} +5 -5
  7. package/dist/{Files-F3H7Z75F.js → Files-QOW4HU3G.js} +45 -45
  8. package/dist/{Notepad-EEULMM65.js → Notepad-UEIU7RJH.js} +9 -9
  9. package/dist/{PdfViewer-FWGHFO4N.js → PdfViewer-MSQ2RVGH.js} +1 -1
  10. package/dist/{PomodoroTimer-RZSYRTLV.js → PomodoroTimer-W6IPEIRY.js} +65 -65
  11. package/dist/{Preview-DUJIVUKT.js → Preview-YY5U3YZK.js} +55 -55
  12. package/dist/{Sidebar-2TYZENQL.js → Sidebar-6DMRN4XR.js} +1 -1
  13. package/dist/{Stock-FHC5TFGK.js → Stock-A6O3UHM4.js} +1 -1
  14. package/dist/{Weather-LYX5G6CZ.js → Weather-LUQQVJ2E.js} +20 -20
  15. package/dist/{WorldClock-MULNQEIS.js → WorldClock-ZO5EEEBS.js} +6 -6
  16. package/dist/ai/index.js +50 -50
  17. package/dist/apps/index.js +1 -1
  18. package/dist/bin/browser-check.js +1 -1
  19. package/dist/bin/media-host-check.js +1 -1
  20. package/dist/bin/ui-check.js +1 -1
  21. package/dist/brand.css +1 -1
  22. package/dist/charts/FlowChart.js +1 -1
  23. package/dist/{chunk-BUUAALHH.js → chunk-26BUX7P6.js} +7 -7
  24. package/dist/chunk-366URRSE.js +4 -0
  25. package/dist/{chunk-UYZJT3AS.js → chunk-45VBEFDG.js} +3 -3
  26. package/dist/{chunk-NGFBYHDM.js → chunk-6GDVURG7.js} +1 -1
  27. package/dist/{chunk-PWERFHOU.js → chunk-6JPSVHUK.js} +9 -9
  28. package/dist/{chunk-6GRTHDQC.js → chunk-7NUX4745.js} +1 -1
  29. package/dist/chunk-AKDPGEBE.js +1 -0
  30. package/dist/{chunk-3QRCPC7V.js → chunk-CG2GLJBL.js} +1 -1
  31. package/dist/{chunk-WNFZYTWW.js → chunk-D4Q33KXQ.js} +1 -1
  32. package/dist/{chunk-AZZ4NO2D.js → chunk-EEAOFYW5.js} +1 -1
  33. package/dist/{chunk-EHSK43WG.js → chunk-F7XL3XA2.js} +4 -4
  34. package/dist/{chunk-H56OE6Q5.js → chunk-J44PLTRE.js} +47 -47
  35. package/dist/chunk-JRRTJ3NV.js +1 -0
  36. package/dist/chunk-PDYCLML5.js +1 -0
  37. package/dist/{chunk-Y2M5PP2C.js → chunk-RUIHRZSH.js} +9 -9
  38. package/dist/chunk-SKMXSDRJ.js +1 -0
  39. package/dist/{chunk-PEA5Y6DD.js → chunk-TFQC67XR.js} +12 -12
  40. package/dist/{chunk-REFPTKRD.js → chunk-UYUNREAL.js} +2 -2
  41. package/dist/{chunk-Z2Z653OO.js → chunk-VR5MGNKG.js} +9 -9
  42. package/dist/{chunk-YTLUSBDY.js → chunk-W2HDWDS6.js} +10 -10
  43. package/dist/{chunk-Y7D2CZ4H.js → chunk-WTWAFKFN.js} +3 -3
  44. package/dist/{chunk-SFP5RZNY.js → chunk-XAPK3RVF.js} +1 -1
  45. package/dist/code/format.d.ts +16 -0
  46. package/dist/code/format.js +1 -0
  47. package/dist/code/index.d.ts +3 -15
  48. package/dist/code/index.js +1 -1
  49. package/dist/data/EntityList.js +1 -1
  50. package/dist/data/ListLoadError.js +1 -1
  51. package/dist/data/ResizableTable.js +1 -1
  52. package/dist/format/index.js +1 -1
  53. package/dist/forms/BorderInput.js +1 -1
  54. package/dist/forms/BrandAssetEditor.js +1 -1
  55. package/dist/forms/ColorPicker.js +1 -1
  56. package/dist/forms/ComposerAttachments.js +1 -1
  57. package/dist/forms/FilePicker.js +1 -1
  58. package/dist/forms/LinkPicker.js +1 -1
  59. package/dist/forms/MediaLibrary.js +1 -1
  60. package/dist/forms/MediaUploadField.js +1 -1
  61. package/dist/forms/MediaUploadGrid.js +1 -1
  62. package/dist/forms/MediaUsedInList.js +1 -1
  63. package/dist/forms/SplitButton.js +1 -1
  64. package/dist/icons/brands.node.js +1 -1
  65. package/dist/icons/efficient-glyphs.js +1 -1
  66. package/dist/icons/efficient-looks.js +1 -1
  67. package/dist/icons/efficient.js +1 -1
  68. package/dist/icons/looks/map.js +1 -1
  69. package/dist/icons/payment.js +3 -3
  70. package/dist/icons/sets.js +1 -1
  71. package/dist/index.js +152 -152
  72. package/dist/map/index.js +7 -7
  73. package/dist/pdf/index.js +1 -1
  74. package/dist/routine-index.json +1 -1
  75. package/dist/shell/AppUpdateBanner.js +1 -1
  76. package/dist/shell/EditableGrid.js +1 -1
  77. package/dist/shell/HelpCenter.js +1 -1
  78. package/dist/shell/ImageLightbox.js +1 -1
  79. package/dist/shell/LanguageSelect.js +1 -1
  80. package/dist/shell/Markdown.js +1 -1
  81. package/dist/shell/SearchableSelect.js +1 -1
  82. package/dist/shell/StepChain.js +1 -1
  83. package/dist/shell/Text.d.ts +4 -2
  84. package/dist/shell/Text.js +1 -1
  85. package/dist/telemetry/index.js +1 -1
  86. package/dist/templates/AuthScreen.js +1 -1
  87. package/dist/templates/ChatTemplate.js +1 -1
  88. package/dist/templates/CheckoutTemplate.js +1 -1
  89. package/dist/templates/DataTablePage.js +1 -1
  90. package/dist/templates/EmailTemplate.js +1 -1
  91. package/dist/templates/FormLayoutPage.js +1 -1
  92. package/dist/ui/index.js +1 -1
  93. package/dist/ui.css +6 -0
  94. package/dist/value-index.json +1 -1
  95. package/dist/version.js +1 -1
  96. package/package.json +11 -1
  97. package/dist/CodeEditor-VN76K3MD.js +0 -1
  98. package/dist/chunk-5KUE6IHF.js +0 -4
  99. package/dist/chunk-JBZ4WNI3.js +0 -1
  100. package/dist/chunk-QYRBRJDN.js +0 -1
  101. package/dist/chunk-RRVQT6RE.js +0 -1
package/README.md CHANGED
@@ -2045,6 +2045,13 @@ CodeMirror 6, on its own entry, loaded after the editor mounts, so a host that
2045
2045
  never edits code installs none of it (`scripts/verify-dist.mjs` holds the built
2046
2046
  graph to React plus, behind a dynamic import, the CodeMirror peers).
2047
2047
 
2048
+ The frame has a hairline rest edge in `--line-strong` (a kit field's rest edge)
2049
+ and the kit focus ring on focus; a host draws no border of its own. Pass
2050
+ `lineWrap` to wrap a line longer than the frame onto the next row (each wrapped
2051
+ row hangs under the first character of its line, and a word with a hyphen in
2052
+ it, such as `--fg-dim`, is never split across two rows); without it a line keeps one
2053
+ row and the editor scrolls.
2054
+
2048
2055
  ```bash
2049
2056
  npm i @codemirror/state @codemirror/view @codemirror/language @codemirror/commands @codemirror/lang-css @lezer/html @lezer/common @lezer/highlight
2050
2057
  ```
@@ -2060,7 +2067,7 @@ function SectionCode({ html, setHtml }: { html: string; setHtml: (next: string)
2060
2067
  return (
2061
2068
  <>
2062
2069
  <div className="h-[60vh]">
2063
- <CodeEditor ref={editor} value={html} onChange={setHtml} label="Section code" />
2070
+ <CodeEditor ref={editor} value={html} onChange={setHtml} label="Section code" lineWrap />
2064
2071
  </div>
2065
2072
  <Button onClick={() => editor.current?.insert('var(--sf-sec-fg)')}>Insert</Button>
2066
2073
  </>
@@ -2084,6 +2091,37 @@ colour the kit already has; `tests/browser/codeEditorInk` measures every one at
2084
2091
  4.5:1 or more in every kit theme (the `Theme` type's list, so a new theme is
2085
2092
  measured with no change to the check).
2086
2093
 
2094
+ `place(at)` applies an edit the host works out itself: `at(doc, from, to)`
2095
+ gets the text and the selection and returns `{ from, to, insert }` (and
2096
+ optionally `selectFrom` / `selectTo`), or `null` for no change. The edit is one
2097
+ undo step; the added text is selected, scrolled into view and focused, and the
2098
+ promise gives its first line and text (`{ line, text }`), so the host can say
2099
+ where it went.
2100
+
2101
+ **Format code.** Pass a `formatter` to opt in: `format()` (and Shift+Alt+F in
2102
+ the editor) tidies the whole text, indent and line breaks, in one undo step,
2103
+ with the cursor kept on the same code. It resolves `'formatted'`,
2104
+ `'unchanged'` (already tidy, or the text changed while it ran: a typed
2105
+ character is never lost), `'unavailable'` (no formatter, or read-only) or
2106
+ `'error'` (the formatter could not read the code; the text is kept). The kit's
2107
+ formatter is `prettierFormatter` from `efficient-shell/code/format`: prettier's
2108
+ HTML printer with its CSS printer for `<style>`. prettier is an optional peer
2109
+ that only a host importing that entry installs; it loads with `import()` on the
2110
+ first format, never with the page, and `efficient-shell/code` never reaches it,
2111
+ so a host without prettier builds and passes no formatter (then show no
2112
+ Format control: `format()` would say `'unavailable'`).
2113
+
2114
+ ```bash
2115
+ npm i prettier
2116
+ ```
2117
+
2118
+ ```tsx
2119
+ import { prettierFormatter } from 'efficient-shell/code/format';
2120
+
2121
+ <CodeEditor ref={editor} value={html} onChange={setHtml} label="Section code" formatter={prettierFormatter} />
2122
+ <Button variant="secondary" size="sm" onClick={() => editor.current?.format()}>Format code</Button>
2123
+ ```
2124
+
2087
2125
  #### The PDF reader without the window manager — `efficient-shell/pdf`
2088
2126
 
2089
2127
  `efficient-shell/apps` is the bundled window registry: importing it puts every
@@ -1,30 +1,30 @@
1
- import{InputEndActionButton as e}from"./chunk-W6REY3SV.js";import"./chunk-AYZY3YNC.js";import{peekBrowserStartUrl as t,claimBrowserStartUrl as o}from"./chunk-LWLCNQY7.js";import{AboutApp as r}from"./chunk-UYZJT3AS.js";import{WindowTitle as n}from"./chunk-H56OE6Q5.js";import"./chunk-4LXCCZDM.js";import"./chunk-KNUR2UEG.js";import"./chunk-JDCM2VHG.js";import"./chunk-YI4T5I5D.js";import"./chunk-PSVGB7KT.js";import"./chunk-TTD2M6RF.js";import"./chunk-5A7MWTXX.js";import"./chunk-TJ5YMXVB.js";import{confirm as s}from"./chunk-2XDO7FZC.js";import"./chunk-ZSVU44OB.js";import"./chunk-EIFNESXS.js";import"./chunk-7WF6LFOJ.js";import"./chunk-CJ4OEY3T.js";import"./chunk-AH5MLH54.js";import"./chunk-5YTZBYG4.js";import"./chunk-VWGWZY7A.js";import"./chunk-DBQNYJZ6.js";import"./chunk-6X32SWQI.js";import"./chunk-YPXONNBV.js";import"./chunk-4PJFL26P.js";import"./chunk-F3ZOO23R.js";import"./chunk-2QY5BJLA.js";import"./chunk-UGTRSRIW.js";import"./chunk-POBVGDZP.js";import"./chunk-AW7TOB6N.js";import"./chunk-QYRBRJDN.js";import"./chunk-M5IZ7QLQ.js";import"./chunk-XNKNX5L3.js";import"./chunk-DWGYC7OD.js";import"./chunk-MYH5H43C.js";import"./chunk-RTK77DMP.js";import"./chunk-URHGHXDN.js";import"./chunk-5QFPTDQF.js";import"./chunk-EDRELF6L.js";import"./chunk-MEP6CZJ3.js";import"./chunk-IVEM2BPC.js";import{Icon as a}from"./chunk-ISVODSRP.js";import"./chunk-J75ZT2JQ.js";import"./chunk-R2VKEMZH.js";import"./chunk-BWJZTHZ6.js";import"./chunk-G3TC2GIA.js";import"./chunk-AJPQJ7TC.js";import"./chunk-PGN5ME7B.js";import"./chunk-62LW225J.js";import"./chunk-TAHHZGRH.js";import"./chunk-KEFNQEXZ.js";import"./chunk-PU2GJVMG.js";import"./chunk-STKJA4PV.js";import"./chunk-M6UKCZHT.js";import"./chunk-UQYNPYF4.js";import"./chunk-MRJKZWWV.js";import"./chunk-TWVUQUUD.js";import"./chunk-5FYDNH4Y.js";import"./chunk-LNXBTK7Q.js";import"./chunk-MAFUXCPZ.js";import"./chunk-NRHG4R2Q.js";import"./chunk-C3QOHMR6.js";import{useRef as i,useEffect as c,useState as l}from"react";import{jsxs as m,jsx as u,Fragment as h}from"react/jsx-runtime";var p="react-os-shell:browser-bookmarks",d="react-os-shell:browser-homepage",k="https://en.wikipedia.org/wiki/Main_Page",b=[{label:"Wikipedia",url:"https://en.wikipedia.org/wiki/Main_Page"},{label:"DevDocs",url:"https://devdocs.io"},{label:"Example",url:"https://example.com"}],g=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 f(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&&g.has(t[2].toLowerCase())}(t)?"https://"+t:"https://duckduckgo.com/?q="+encodeURIComponent(t):""}var w=["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 b;try{const e=localStorage.getItem(p);if(!e)return b;const t=JSON.parse(e);if(Array.isArray(t)&&t.every(e=>"string"==typeof e?.url))return t}catch{}return b}function y(){return"undefined"==typeof window?k:localStorage.getItem(d)||k}function v(){const h=i(void 0);void 0===h.current&&(h.current=t()),c(()=>{null!=h.current&&o(h.current)},[]);const k=h.current?f(h.current.url):"",[b,g]=l(y),[w,v]=l(k||b),[C,R]=l(w),[W,T]=l([w]),[S,z]=l(0),[D,E]=l(0),[H,L]=l(x),[M,P]=l(!1),[Y,J]=l(null),Z=i(null),G=i(null);c(()=>{try{localStorage.setItem(p,JSON.stringify(H))}catch{}},[H]);const O=e=>{const t=f(e);t&&(v(t),R(t),T(e=>{const o=e.slice(0,S+1);return o.push(t),o}),z(e=>e+1),P(!1))},U=()=>{"undefined"!=typeof window&&window.open(w,"_blank","noopener,noreferrer")},F=()=>{const e=Y?.trim();e?(L(t=>[...t,{label:e,url:w}]),J(null)):J(null)};c(()=>{if(null===Y)return;Z.current?.focus(),Z.current?.select();const e=e=>{const t=e.target;t?.closest("[data-bookmark-popover]")||J(null)},t=setTimeout(()=>document.addEventListener("mousedown",e),0);return()=>{clearTimeout(t),document.removeEventListener("mousedown",e)}},[null!==Y]);const Q=e=>{L(t=>t.filter((t,o)=>o!==e))},B=S>0,X=S<W.length-1,A=H.some(e=>e.url===w),I="p-2 rounded hover:bg-gray-200 transition-colors text-gray-600 disabled:opacity-30";/* @__PURE__ */
1
+ import{InputEndActionButton as e}from"./chunk-W6REY3SV.js";import"./chunk-AYZY3YNC.js";import{peekBrowserStartUrl as t,claimBrowserStartUrl as o}from"./chunk-LWLCNQY7.js";import{AboutApp as r}from"./chunk-45VBEFDG.js";import{WindowTitle as n}from"./chunk-J44PLTRE.js";import"./chunk-4LXCCZDM.js";import"./chunk-KNUR2UEG.js";import"./chunk-JDCM2VHG.js";import"./chunk-YI4T5I5D.js";import"./chunk-PSVGB7KT.js";import"./chunk-TTD2M6RF.js";import"./chunk-5A7MWTXX.js";import"./chunk-TJ5YMXVB.js";import{confirm as s}from"./chunk-2XDO7FZC.js";import"./chunk-ZSVU44OB.js";import"./chunk-EIFNESXS.js";import"./chunk-7WF6LFOJ.js";import"./chunk-CJ4OEY3T.js";import"./chunk-AH5MLH54.js";import"./chunk-5YTZBYG4.js";import"./chunk-VWGWZY7A.js";import"./chunk-DBQNYJZ6.js";import"./chunk-6X32SWQI.js";import"./chunk-AW7TOB6N.js";import"./chunk-YPXONNBV.js";import"./chunk-4PJFL26P.js";import"./chunk-F3ZOO23R.js";import"./chunk-2QY5BJLA.js";import"./chunk-UGTRSRIW.js";import"./chunk-POBVGDZP.js";import"./chunk-PDYCLML5.js";import"./chunk-M5IZ7QLQ.js";import"./chunk-XNKNX5L3.js";import"./chunk-DWGYC7OD.js";import"./chunk-MYH5H43C.js";import"./chunk-EDRELF6L.js";import"./chunk-RTK77DMP.js";import"./chunk-URHGHXDN.js";import"./chunk-5QFPTDQF.js";import"./chunk-MEP6CZJ3.js";import"./chunk-IVEM2BPC.js";import"./chunk-R2VKEMZH.js";import{Icon as a}from"./chunk-ISVODSRP.js";import"./chunk-J75ZT2JQ.js";import"./chunk-BWJZTHZ6.js";import"./chunk-G3TC2GIA.js";import"./chunk-AJPQJ7TC.js";import"./chunk-PGN5ME7B.js";import"./chunk-62LW225J.js";import"./chunk-TAHHZGRH.js";import"./chunk-KEFNQEXZ.js";import"./chunk-PU2GJVMG.js";import"./chunk-STKJA4PV.js";import"./chunk-M6UKCZHT.js";import"./chunk-UQYNPYF4.js";import"./chunk-MRJKZWWV.js";import"./chunk-TWVUQUUD.js";import"./chunk-5FYDNH4Y.js";import"./chunk-LNXBTK7Q.js";import"./chunk-MAFUXCPZ.js";import"./chunk-NRHG4R2Q.js";import"./chunk-C3QOHMR6.js";import{useRef as i,useEffect as c,useState as l}from"react";import{jsxs as m,jsx as u,Fragment as h}from"react/jsx-runtime";var p="react-os-shell:browser-bookmarks",d="react-os-shell:browser-homepage",k="https://en.wikipedia.org/wiki/Main_Page",b=[{label:"Wikipedia",url:"https://en.wikipedia.org/wiki/Main_Page"},{label:"DevDocs",url:"https://devdocs.io"},{label:"Example",url:"https://example.com"}],g=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 f(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&&g.has(t[2].toLowerCase())}(t)?"https://"+t:"https://duckduckgo.com/?q="+encodeURIComponent(t):""}var w=["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 b;try{const e=localStorage.getItem(p);if(!e)return b;const t=JSON.parse(e);if(Array.isArray(t)&&t.every(e=>"string"==typeof e?.url))return t}catch{}return b}function y(){return"undefined"==typeof window?k:localStorage.getItem(d)||k}function v(){const h=i(void 0);void 0===h.current&&(h.current=t()),c(()=>{null!=h.current&&o(h.current)},[]);const k=h.current?f(h.current.url):"",[b,g]=l(y),[w,v]=l(k||b),[C,R]=l(w),[W,T]=l([w]),[L,D]=l(0),[E,z]=l(0),[P,S]=l(x),[H,M]=l(!1),[Y,G]=l(null),J=i(null),Z=i(null);c(()=>{try{localStorage.setItem(p,JSON.stringify(P))}catch{}},[P]);const F=e=>{const t=f(e);t&&(v(t),R(t),T(e=>{const o=e.slice(0,L+1);return o.push(t),o}),D(e=>e+1),M(!1))},O=()=>{"undefined"!=typeof window&&window.open(w,"_blank","noopener,noreferrer")},U=()=>{const e=Y?.trim();e?(S(t=>[...t,{label:e,url:w}]),G(null)):G(null)};c(()=>{if(null===Y)return;J.current?.focus(),J.current?.select();const e=e=>{const t=e.target;t?.closest("[data-bookmark-popover]")||G(null)},t=setTimeout(()=>document.addEventListener("mousedown",e),0);return()=>{clearTimeout(t),document.removeEventListener("mousedown",e)}},[null!==Y]);const B=e=>{S(t=>t.filter((t,o)=>o!==e))},Q=L>0,V=L<W.length-1,X=P.some(e=>e.url===w),I="p-2 rounded hover:bg-gray-200 transition-colors text-gray-600 disabled:opacity-30";/* @__PURE__ */
2
2
  return m("div",{className:"relative flex flex-col h-full bg-white",children:[
3
3
  /* @__PURE__ */u(n,{title:`Browser - ${j(w)}`}),
4
4
  /* @__PURE__ */u(r,{app:"browser"}),
5
5
  /* @__PURE__ */m("div",{className:"flex items-center gap-1 px-2 py-2 border-b border-line bg-surface-sunken shrink-0",children:[
6
- /* @__PURE__ */u("button",{onClick:()=>{if(S>0){const e=S-1;z(e),v(W[e]),R(W[e]),P(!1)}},disabled:!B,className:I,title:"Back",children:/* @__PURE__ */u(a,{name:"chevron-left",className:"h-4 w-4",strokeWidth:2})}),
7
- /* @__PURE__ */u("button",{onClick:()=>{if(S<W.length-1){const e=S+1;z(e),v(W[e]),R(W[e]),P(!1)}},disabled:!X,className:I,title:"Forward",children:/* @__PURE__ */u(a,{name:"chevron-right",className:"h-4 w-4",strokeWidth:2})}),
8
- /* @__PURE__ */u("button",{onClick:()=>E(e=>e+1),className:I,title:"Refresh",children:/* @__PURE__ */u(a,{name:"refresh",className:"h-4 w-4",strokeWidth:1.8})}),
9
- /* @__PURE__ */u("button",{onClick:()=>O(b),className:I,title:"Home",children:/* @__PURE__ */u(a,{name:"home",className:"h-4 w-4",strokeWidth:1.8})}),
10
- /* @__PURE__ */u("form",{onSubmit:e=>{e.preventDefault(),O(C)},className:"flex-1 flex items-center mx-1",children:/* @__PURE__ */m("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__ */u("button",{onClick:()=>{if(L>0){const e=L-1;D(e),v(W[e]),R(W[e]),M(!1)}},disabled:!Q,className:I,title:"Back",children:/* @__PURE__ */u(a,{name:"chevron-left",className:"h-4 w-4",strokeWidth:2})}),
7
+ /* @__PURE__ */u("button",{onClick:()=>{if(L<W.length-1){const e=L+1;D(e),v(W[e]),R(W[e]),M(!1)}},disabled:!V,className:I,title:"Forward",children:/* @__PURE__ */u(a,{name:"chevron-right",className:"h-4 w-4",strokeWidth:2})}),
8
+ /* @__PURE__ */u("button",{onClick:()=>z(e=>e+1),className:I,title:"Refresh",children:/* @__PURE__ */u(a,{name:"refresh",className:"h-4 w-4",strokeWidth:1.8})}),
9
+ /* @__PURE__ */u("button",{onClick:()=>F(b),className:I,title:"Home",children:/* @__PURE__ */u(a,{name:"home",className:"h-4 w-4",strokeWidth:1.8})}),
10
+ /* @__PURE__ */u("form",{onSubmit:e=>{e.preventDefault(),F(C)},className:"flex-1 flex items-center mx-1",children:/* @__PURE__ */m("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__ */u("span",{className:"px-2 text-gray-400 text-xs",children:w.startsWith("https://")?"🔒":"⚠️"}),
12
12
  /* @__PURE__ */u("input",{type:"text",value:C,onChange:e=>R(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…"}),w!==C&&
13
13
  /* @__PURE__ */u("span",{className:"flex pr-1",children:/* @__PURE__ */u(e,{action:{label:"Reset to current URL",icon:/* @__PURE__ */u(a,{name:"close"}),onClick:()=>R(w)}})})]})}),
14
- /* @__PURE__ */u("button",{"data-bookmark-popover":!0,onClick:()=>A?Q(H.findIndex(e=>e.url===w)):void J(j(w)),className:I+" "+(A?"text-yellow-500":""),title:A?"Remove bookmark":"Add bookmark",children:/* @__PURE__ */u(a,{name:"star",className:"h-4 w-4",fill:A?"currentColor":"none",strokeWidth:1.5})}),
15
- /* @__PURE__ */u("button",{onClick:U,className:I,title:"Open in new tab",children:/* @__PURE__ */u(a,{name:"external",className:"h-4 w-4",strokeWidth:1.5})}),
16
- /* @__PURE__ */u("button",{onClick:()=>P(e=>!e),className:I,title:"Embedding help",children:/* @__PURE__ */u(a,{name:"help",className:"h-4 w-4",strokeWidth:1.5})})]}),null!==Y&&/* @__PURE__ */m("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:[
14
+ /* @__PURE__ */u("button",{"data-bookmark-popover":!0,onClick:()=>X?B(P.findIndex(e=>e.url===w)):void G(j(w)),className:I+" "+(X?"text-yellow-500":""),title:X?"Remove bookmark":"Add bookmark",children:/* @__PURE__ */u(a,{name:"star",className:"h-4 w-4",fill:X?"currentColor":"none",strokeWidth:1.5})}),
15
+ /* @__PURE__ */u("button",{onClick:O,className:I,title:"Open in new tab",children:/* @__PURE__ */u(a,{name:"external",className:"h-4 w-4",strokeWidth:1.5})}),
16
+ /* @__PURE__ */u("button",{onClick:()=>M(e=>!e),className:I,title:"Embedding help",children:/* @__PURE__ */u(a,{name:"help",className:"h-4 w-4",strokeWidth:1.5})})]}),null!==Y&&/* @__PURE__ */m("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:[
17
17
  /* @__PURE__ */u("div",{className:"text-2xs font-semibold uppercase tracking-wide text-ink-faint mb-1",children:"Bookmark this page"}),
18
18
  /* @__PURE__ */u("div",{className:"text-2xs text-ink-faintest truncate mb-2 font-mono",title:w,children:w}),
19
- /* @__PURE__ */u("input",{ref:Z,type:"text",value:Y,onChange:e=>J(e.target.value),onKeyDown:e=>{"Enter"===e.key?F():"Escape"===e.key&&J(null)},placeholder:"Name",className:"w-full text-sm px-2 h-8 border border-line-strong rounded focus:outline-none focus:border-blue-400 focus:ring-1 focus:ring-blue-200"}),
19
+ /* @__PURE__ */u("input",{ref:J,type:"text",value:Y,onChange:e=>G(e.target.value),onKeyDown:e=>{"Enter"===e.key?U():"Escape"===e.key&&G(null)},placeholder:"Name",className:"w-full text-sm px-2 h-8 border border-line-strong rounded focus:outline-none focus:border-blue-400 focus:ring-1 focus:ring-blue-200"}),
20
20
  /* @__PURE__ */m("div",{className:"flex justify-end gap-1 mt-2",children:[
21
- /* @__PURE__ */u("button",{onClick:()=>J(null),className:"px-2 py-1 text-xs text-gray-600 hover:bg-gray-100 rounded",children:"Cancel"}),
22
- /* @__PURE__ */u("button",{onClick:F,disabled:!Y.trim(),className:"px-2 py-1 text-xs bg-blue-500 text-white rounded hover:bg-blue-600 disabled:opacity-40",children:"Save"})]})]}),
23
- /* @__PURE__ */m("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===H.length&&/* @__PURE__ */u("span",{className:"text-2xs text-ink-faintest italic px-2",children:"No bookmarks yet — star the address bar to add one."}),H.map((e,t)=>/* @__PURE__ */m("button",{onClick:()=>O(e.url),onContextMenu:async o=>{o.preventDefault();await s({title:"Remove bookmark",message:`"${e.label}" will be removed from your bookmarks.`,confirmLabel:"Remove",variant:"danger"})&&Q(t)},className:"flex items-center gap-2 px-2 py-0.5 rounded text-xs text-ink hover:bg-gray-100 whitespace-nowrap",title:`${e.url}\n(right-click to remove)`,children:[
21
+ /* @__PURE__ */u("button",{onClick:()=>G(null),className:"px-2 py-1 text-xs text-gray-600 hover:bg-gray-100 rounded",children:"Cancel"}),
22
+ /* @__PURE__ */u("button",{onClick:U,disabled:!Y.trim(),className:"px-2 py-1 text-xs bg-blue-500 text-white rounded hover:bg-blue-600 disabled:opacity-40",children:"Save"})]})]}),
23
+ /* @__PURE__ */m("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===P.length&&/* @__PURE__ */u("span",{className:"text-2xs text-ink-faintest italic px-2",children:"No bookmarks yet — star the address bar to add one."}),P.map((e,t)=>/* @__PURE__ */m("button",{onClick:()=>F(e.url),onContextMenu:async o=>{o.preventDefault();await s({title:"Remove bookmark",message:`"${e.label}" will be removed from your bookmarks.`,confirmLabel:"Remove",variant:"danger"})&&B(t)},className:"flex items-center gap-2 px-2 py-0.5 rounded text-xs text-ink hover:bg-gray-100 whitespace-nowrap",title:`${e.url}\n(right-click to remove)`,children:[
24
24
  /* @__PURE__ */u("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)),
25
25
  /* @__PURE__ */u("div",{className:"flex-1"}),
26
26
  /* @__PURE__ */u("button",{onClick:()=>{g(w);try{localStorage.setItem(d,w)}catch{}},className:"px-2 py-0.5 text-2xs text-ink-faint hover:text-ink-strong",title:"Set current page as homepage",children:"Set as home"})]}),
27
- /* @__PURE__ */u("div",{className:"flex-1 relative min-h-0 bg-gray-50",children:/* @__PURE__ */u(N,{url:w,iframeKey:D,iframeRef:G,openExternal:U,showHelp:M,dismissHelp:()=>P(!1)})})]})}function j(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[i,p]=l(!1);c(()=>{p(!1)},[e]);return function(e){try{const t=new URL(e).hostname.toLowerCase();return w.some(e=>t===e||t.endsWith("."+e))}catch{return!1}}(e)&&!i?/* @__PURE__ */u("div",{className:"absolute inset-0 flex items-center justify-center bg-white p-8",children:/* @__PURE__ */m("div",{className:"max-w-md text-center",children:[
27
+ /* @__PURE__ */u("div",{className:"flex-1 relative min-h-0 bg-gray-50",children:/* @__PURE__ */u(N,{url:w,iframeKey:E,iframeRef:Z,openExternal:O,showHelp:H,dismissHelp:()=>M(!1)})})]})}function j(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[i,p]=l(!1);c(()=>{p(!1)},[e]);return function(e){try{const t=new URL(e).hostname.toLowerCase();return w.some(e=>t===e||t.endsWith("."+e))}catch{return!1}}(e)&&!i?/* @__PURE__ */u("div",{className:"absolute inset-0 flex items-center justify-center bg-white p-8",children:/* @__PURE__ */m("div",{className:"max-w-md text-center",children:[
28
28
  /* @__PURE__ */u(a,{name:"no-symbol",className:"h-14 w-14 mx-auto text-gray-300 mb-3",strokeWidth:1.2}),
29
29
  /* @__PURE__ */m("h3",{className:"text-base font-semibold text-gray-800 mb-1",children:[j(e)," can't be embedded"]}),
30
30
  /* @__PURE__ */m("p",{className:"text-sm text-gray-500 mb-4",children:["This site sends an ",
@@ -1,29 +1,29 @@
1
- import{loadAppearance as t,WidgetSettingsModal as e}from"./chunk-3QRCPC7V.js";import{useWidgetSettings as n}from"./chunk-H56OE6Q5.js";import"./chunk-4LXCCZDM.js";import"./chunk-KNUR2UEG.js";import"./chunk-JDCM2VHG.js";import"./chunk-YI4T5I5D.js";import"./chunk-PSVGB7KT.js";import"./chunk-TTD2M6RF.js";import"./chunk-5A7MWTXX.js";import"./chunk-TJ5YMXVB.js";import"./chunk-2XDO7FZC.js";import"./chunk-ZSVU44OB.js";import"./chunk-EIFNESXS.js";import"./chunk-7WF6LFOJ.js";import"./chunk-CJ4OEY3T.js";import"./chunk-AH5MLH54.js";import"./chunk-5YTZBYG4.js";import"./chunk-VWGWZY7A.js";import"./chunk-DBQNYJZ6.js";import"./chunk-6X32SWQI.js";import"./chunk-YPXONNBV.js";import"./chunk-4PJFL26P.js";import"./chunk-F3ZOO23R.js";import"./chunk-2QY5BJLA.js";import"./chunk-UGTRSRIW.js";import"./chunk-POBVGDZP.js";import"./chunk-AW7TOB6N.js";import"./chunk-M5IZ7QLQ.js";import"./chunk-XNKNX5L3.js";import"./chunk-DWGYC7OD.js";import"./chunk-MYH5H43C.js";import"./chunk-RTK77DMP.js";import"./chunk-URHGHXDN.js";import"./chunk-5QFPTDQF.js";import"./chunk-EDRELF6L.js";import"./chunk-MEP6CZJ3.js";import"./chunk-IVEM2BPC.js";import{Icon as r}from"./chunk-ISVODSRP.js";import"./chunk-J75ZT2JQ.js";import"./chunk-R2VKEMZH.js";import"./chunk-BWJZTHZ6.js";import"./chunk-G3TC2GIA.js";import"./chunk-AJPQJ7TC.js";import"./chunk-PGN5ME7B.js";import"./chunk-62LW225J.js";import"./chunk-TAHHZGRH.js";import"./chunk-KEFNQEXZ.js";import"./chunk-PU2GJVMG.js";import"./chunk-STKJA4PV.js";import"./chunk-M6UKCZHT.js";import"./chunk-UQYNPYF4.js";import"./chunk-MRJKZWWV.js";import"./chunk-TWVUQUUD.js";import"./chunk-5FYDNH4Y.js";import"./chunk-LNXBTK7Q.js";import"./chunk-MAFUXCPZ.js";import"./chunk-NRHG4R2Q.js";import"./chunk-C3QOHMR6.js";import{useState as c,useRef as i,useCallback as o,useEffect as s}from"react";import{jsxs as l,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),[j,b]=c(null),[g,N]=c(!1),[C,y]=c(""),[x,f]=c([]),[v,T]=c(!1),[$,E]=c(()=>t(h)),[F,M]=c(!1),[P,Z]=c($),D=i(null);n(o(()=>{Z({...$}),M(!0)},[$]));const J=o(t=>{y(""),k(e=>g||"0"===e?(N(!1),"."===t?"0.":t):"."===t&&e.includes(".")?e:e+t)},[g]),W=o(()=>{k("0"),d(null),b(null),N(!1)},[]),H=o((t,e,n)=>{switch(n){case"+":return t+e;case"-":return t-e;case"×":return t*e;case"÷":return 0===e?0:t/e;default:return e}},[]),Q=o(t=>{const e=parseFloat(m);if(null!==p&&j&&!g){const t=H(p,e,j);k(String(t)),d(t),f(n=>[`${p} ${j} ${e} = ${t}`,...n].slice(0,20))}else d(e);b(t),N(!0)},[m,p,j,g,H]),R=o(()=>{if(null===p||!j)return;const t=parseFloat(m),e=H(p,t,j),n=`${p} ${j} ${t} =`;f(t=>[`${n} ${e}`,...t].slice(0,20)),y(n),k(String(e)),d(null),b(null),N(!0)},[m,p,j,H]),S=o(()=>{k(t=>String(parseFloat(t)/100))},[]),B=o(()=>{k(t=>t.startsWith("-")?t.slice(1):"0"===t?t:"-"+t)},[]);s(()=>{const t=t=>{const e=t.target.tagName;"INPUT"!==e&&"TEXTAREA"!==e&&"SELECT"!==e&&(t.key>="0"&&t.key<="9"?J(t.key):"."===t.key?J("."):"+"===t.key?Q("+"):"-"===t.key?Q("-"):"*"===t.key?Q("×"):"/"===t.key?(t.preventDefault(),Q("÷")):"Enter"===t.key||"="===t.key?("Enter"===t.key&&t.target instanceof Node&&D.current?.contains(t.target)&&t.preventDefault(),R()):"Escape"===t.key?W():"Backspace"===t.key?k(t=>t.length>1?t.slice(0,-1):"0"):"%"===t.key&&S())};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[J,Q,R,W,S]);const G="flex items-center justify-center rounded-lg text-sm font-medium transition-colors",O=`${G} bg-white border border-gray-200 text-gray-900 hover:bg-gray-50 active:bg-gray-100`,V=`${G} bg-blue-50 border border-blue-200 text-blue-700 hover:bg-blue-100 active:bg-blue-200`,X=`${G} bg-gray-100 border border-gray-200 text-gray-600 hover:bg-gray-200 active:bg-gray-300`,Y=`${G} bg-blue-600 text-white hover:bg-blue-700 active:bg-blue-800`;/* @__PURE__ */
1
+ import{loadAppearance as t,WidgetSettingsModal as e}from"./chunk-CG2GLJBL.js";import{useWidgetSettings as n}from"./chunk-J44PLTRE.js";import"./chunk-4LXCCZDM.js";import"./chunk-KNUR2UEG.js";import"./chunk-JDCM2VHG.js";import"./chunk-YI4T5I5D.js";import"./chunk-PSVGB7KT.js";import"./chunk-TTD2M6RF.js";import"./chunk-5A7MWTXX.js";import"./chunk-TJ5YMXVB.js";import"./chunk-2XDO7FZC.js";import"./chunk-ZSVU44OB.js";import"./chunk-EIFNESXS.js";import"./chunk-7WF6LFOJ.js";import"./chunk-CJ4OEY3T.js";import"./chunk-AH5MLH54.js";import"./chunk-5YTZBYG4.js";import"./chunk-VWGWZY7A.js";import"./chunk-DBQNYJZ6.js";import"./chunk-6X32SWQI.js";import"./chunk-AW7TOB6N.js";import"./chunk-YPXONNBV.js";import"./chunk-4PJFL26P.js";import"./chunk-F3ZOO23R.js";import"./chunk-2QY5BJLA.js";import"./chunk-UGTRSRIW.js";import"./chunk-POBVGDZP.js";import"./chunk-M5IZ7QLQ.js";import"./chunk-XNKNX5L3.js";import"./chunk-DWGYC7OD.js";import"./chunk-MYH5H43C.js";import"./chunk-EDRELF6L.js";import"./chunk-RTK77DMP.js";import"./chunk-URHGHXDN.js";import"./chunk-5QFPTDQF.js";import"./chunk-MEP6CZJ3.js";import"./chunk-IVEM2BPC.js";import"./chunk-R2VKEMZH.js";import{Icon as r}from"./chunk-ISVODSRP.js";import"./chunk-J75ZT2JQ.js";import"./chunk-BWJZTHZ6.js";import"./chunk-G3TC2GIA.js";import"./chunk-AJPQJ7TC.js";import"./chunk-PGN5ME7B.js";import"./chunk-62LW225J.js";import"./chunk-TAHHZGRH.js";import"./chunk-KEFNQEXZ.js";import"./chunk-PU2GJVMG.js";import"./chunk-STKJA4PV.js";import"./chunk-M6UKCZHT.js";import"./chunk-UQYNPYF4.js";import"./chunk-MRJKZWWV.js";import"./chunk-TWVUQUUD.js";import"./chunk-5FYDNH4Y.js";import"./chunk-LNXBTK7Q.js";import"./chunk-MAFUXCPZ.js";import"./chunk-NRHG4R2Q.js";import"./chunk-C3QOHMR6.js";import{useState as c,useRef as i,useCallback as o,useEffect as s}from"react";import{jsxs as l,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),[j,b]=c(null),[g,N]=c(!1),[C,y]=c(""),[x,f]=c([]),[v,T]=c(!1),[$,E]=c(()=>t(h)),[J,F]=c(!1),[M,P]=c($),Z=i(null);n(o(()=>{P({...$}),F(!0)},[$]));const D=o(t=>{y(""),k(e=>g||"0"===e?(N(!1),"."===t?"0.":t):"."===t&&e.includes(".")?e:e+t)},[g]),G=o(()=>{k("0"),d(null),b(null),N(!1)},[]),W=o((t,e,n)=>{switch(n){case"+":return t+e;case"-":return t-e;case"×":return t*e;case"÷":return 0===e?0:t/e;default:return e}},[]),B=o(t=>{const e=parseFloat(m);if(null!==p&&j&&!g){const t=W(p,e,j);k(String(t)),d(t),f(n=>[`${p} ${j} ${e} = ${t}`,...n].slice(0,20))}else d(e);b(t),N(!0)},[m,p,j,g,W]),L=o(()=>{if(null===p||!j)return;const t=parseFloat(m),e=W(p,t,j),n=`${p} ${j} ${t} =`;f(t=>[`${n} ${e}`,...t].slice(0,20)),y(n),k(String(e)),d(null),b(null),N(!0)},[m,p,j,W]),R=o(()=>{k(t=>String(parseFloat(t)/100))},[]),S=o(()=>{k(t=>t.startsWith("-")?t.slice(1):"0"===t?t:"-"+t)},[]);s(()=>{const t=t=>{const e=t.target.tagName;"INPUT"!==e&&"TEXTAREA"!==e&&"SELECT"!==e&&(t.key>="0"&&t.key<="9"?D(t.key):"."===t.key?D("."):"+"===t.key?B("+"):"-"===t.key?B("-"):"*"===t.key?B("×"):"/"===t.key?(t.preventDefault(),B("÷")):"Enter"===t.key||"="===t.key?("Enter"===t.key&&t.target instanceof Node&&Z.current?.contains(t.target)&&t.preventDefault(),L()):"Escape"===t.key?G():"Backspace"===t.key?k(t=>t.length>1?t.slice(0,-1):"0"):"%"===t.key&&R())};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[D,B,L,G,R]);const H="flex items-center justify-center rounded-lg text-sm font-medium transition-colors",Q=`${H} bg-white border border-gray-200 text-gray-900 hover:bg-gray-50 active:bg-gray-100`,X=`${H} bg-blue-50 border border-blue-200 text-blue-700 hover:bg-blue-100 active:bg-blue-200`,Y=`${H} bg-gray-100 border border-gray-200 text-gray-600 hover:bg-gray-200 active:bg-gray-300`,w=`${H} bg-blue-600 text-white hover:bg-blue-700 active:bg-blue-800`;/* @__PURE__ */
2
2
  return l(a,{children:[
3
- /* @__PURE__ */l("div",{ref:D,className:"flex flex-col h-full",style:{opacity:$.activeOpacity/100,backdropFilter:$.activeBlur>0?`blur(${$.activeBlur}px)`:void 0},children:[
3
+ /* @__PURE__ */l("div",{ref:Z,className:"flex flex-col h-full",style:{opacity:$.activeOpacity/100,backdropFilter:$.activeBlur>0?`blur(${$.activeBlur}px)`:void 0},children:[
4
4
  /* @__PURE__ */l("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:[
5
5
  /* @__PURE__ */u("div",{className:"flex flex-col justify-end flex-1 overflow-hidden",children:x.slice(0,3).reverse().map((t,e)=>/* @__PURE__ */u("div",{className:"text-2xs text-slate-400 text-right font-mono truncate",children:t},e))}),(C||j&&null!==p)&&/* @__PURE__ */u("div",{className:"text-base text-slate-600 text-right font-mono",children:C||`${p} ${j} ${g?"":m}`}),
6
6
  /* @__PURE__ */l("div",{className:"flex items-center gap-2",children:[
7
7
  /* @__PURE__ */u("button",{onClick:()=>{navigator.clipboard.writeText(m),T(!0),setTimeout(()=>T(!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:(t=>{const e=parseFloat(t);return isNaN(e)||t.endsWith(".")||t.endsWith(".0")||Math.abs(e)<1e15&&t.length<16?t:e.toExponential(6)})(m)})]})]}),
9
9
  /* @__PURE__ */l("div",{className:"grid grid-cols-4 grid-rows-5 gap-2 flex-1 min-h-0 p-2",children:[
10
- /* @__PURE__ */u("button",{onClick:W,className:X,children:"AC"}),
11
- /* @__PURE__ */u("button",{onClick:B,className:X,children:"+/−"}),
12
- /* @__PURE__ */u("button",{onClick:S,className:X,children:"%"}),
13
- /* @__PURE__ */u("button",{onClick:()=>Q("÷"),className:`${V} ${"÷"===j?"ring-2 ring-blue-400":""}`,children:"÷"}),
14
- /* @__PURE__ */u("button",{onClick:()=>J("7"),className:O,children:"7"}),
15
- /* @__PURE__ */u("button",{onClick:()=>J("8"),className:O,children:"8"}),
16
- /* @__PURE__ */u("button",{onClick:()=>J("9"),className:O,children:"9"}),
17
- /* @__PURE__ */u("button",{onClick:()=>Q("×"),className:`${V} ${"×"===j?"ring-2 ring-blue-400":""}`,children:"×"}),
18
- /* @__PURE__ */u("button",{onClick:()=>J("4"),className:O,children:"4"}),
19
- /* @__PURE__ */u("button",{onClick:()=>J("5"),className:O,children:"5"}),
20
- /* @__PURE__ */u("button",{onClick:()=>J("6"),className:O,children:"6"}),
21
- /* @__PURE__ */u("button",{onClick:()=>Q("-"),className:`${V} ${"-"===j?"ring-2 ring-blue-400":""}`,children:"−"}),
22
- /* @__PURE__ */u("button",{onClick:()=>J("1"),className:O,children:"1"}),
23
- /* @__PURE__ */u("button",{onClick:()=>J("2"),className:O,children:"2"}),
24
- /* @__PURE__ */u("button",{onClick:()=>J("3"),className:O,children:"3"}),
25
- /* @__PURE__ */u("button",{onClick:()=>Q("+"),className:`${V} ${"+"===j?"ring-2 ring-blue-400":""}`,children:"+"}),
26
- /* @__PURE__ */u("button",{onClick:()=>J("0"),className:`${O} col-span-2`,children:"0"}),
27
- /* @__PURE__ */u("button",{onClick:()=>J("."),className:O,children:"."}),
28
- /* @__PURE__ */u("button",{onClick:R,className:Y,children:"="})]})]}),
29
- /* @__PURE__ */u(e,{open:F,onClose:()=>M(!1),title:"Calculator Settings",appearance:P,onAppearanceChange:Z,onSave:()=>{E(P),localStorage.setItem(h,JSON.stringify(P)),M(!1)}})]})}export{m as default};
10
+ /* @__PURE__ */u("button",{onClick:G,className:Y,children:"AC"}),
11
+ /* @__PURE__ */u("button",{onClick:S,className:Y,children:"+/−"}),
12
+ /* @__PURE__ */u("button",{onClick:R,className:Y,children:"%"}),
13
+ /* @__PURE__ */u("button",{onClick:()=>B("÷"),className:`${X} ${"÷"===j?"ring-2 ring-blue-400":""}`,children:"÷"}),
14
+ /* @__PURE__ */u("button",{onClick:()=>D("7"),className:Q,children:"7"}),
15
+ /* @__PURE__ */u("button",{onClick:()=>D("8"),className:Q,children:"8"}),
16
+ /* @__PURE__ */u("button",{onClick:()=>D("9"),className:Q,children:"9"}),
17
+ /* @__PURE__ */u("button",{onClick:()=>B("×"),className:`${X} ${"×"===j?"ring-2 ring-blue-400":""}`,children:"×"}),
18
+ /* @__PURE__ */u("button",{onClick:()=>D("4"),className:Q,children:"4"}),
19
+ /* @__PURE__ */u("button",{onClick:()=>D("5"),className:Q,children:"5"}),
20
+ /* @__PURE__ */u("button",{onClick:()=>D("6"),className:Q,children:"6"}),
21
+ /* @__PURE__ */u("button",{onClick:()=>B("-"),className:`${X} ${"-"===j?"ring-2 ring-blue-400":""}`,children:"−"}),
22
+ /* @__PURE__ */u("button",{onClick:()=>D("1"),className:Q,children:"1"}),
23
+ /* @__PURE__ */u("button",{onClick:()=>D("2"),className:Q,children:"2"}),
24
+ /* @__PURE__ */u("button",{onClick:()=>D("3"),className:Q,children:"3"}),
25
+ /* @__PURE__ */u("button",{onClick:()=>B("+"),className:`${X} ${"+"===j?"ring-2 ring-blue-400":""}`,children:"+"}),
26
+ /* @__PURE__ */u("button",{onClick:()=>D("0"),className:`${Q} col-span-2`,children:"0"}),
27
+ /* @__PURE__ */u("button",{onClick:()=>D("."),className:Q,children:"."}),
28
+ /* @__PURE__ */u("button",{onClick:L,className:w,children:"="})]})]}),
29
+ /* @__PURE__ */u(e,{open:J,onClose:()=>F(!1),title:"Calculator Settings",appearance:M,onAppearanceChange:P,onSave:()=>{E(M),localStorage.setItem(h,JSON.stringify(M)),F(!1)}})]})}export{m as default};
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Tidies code: indent and line breaks. The kit's own is `prettierFormatter`
3
+ * (`efficient-shell/code/format`); a host hands it to the editor to opt in.
4
+ * `cursor` is an offset in `code`; the answer's `cursor` is the same place in
5
+ * the tidied code.
6
+ */
7
+ interface CodeFormatter {
8
+ format(code: string, cursor: number): Promise<{
9
+ code: string;
10
+ cursor: number;
11
+ }>;
12
+ }
13
+ /** What `format()` did: `unavailable` = no formatter (or read-only), `error` = the formatter could not read the code. */
14
+ type CodeFormatResult = 'formatted' | 'unchanged' | 'unavailable' | 'error';
15
+ /** One edit the host places itself, from the text and the selection. */
16
+ interface CodeEdit {
17
+ from: number;
18
+ to: number;
19
+ insert: string;
20
+ /** The part of the added text to select; the whole of it when left out. */
21
+ selectFrom?: number;
22
+ selectTo?: number;
23
+ }
24
+ /** Where `place()` put the edit: the first selected line and the selected text. */
25
+ interface CodePlaced {
26
+ line: number;
27
+ text: string;
28
+ }
29
+ interface CodeEditorHandle {
30
+ /** Replace the selection (or insert at the cursor) with `text`, then focus. */
31
+ insert(text: string): void;
32
+ /**
33
+ * Apply the edit `at` returns for the text and the selection, in one undo
34
+ * step; select the added text, show it and focus. `null` changes nothing.
35
+ */
36
+ place(at: (doc: string, from: number, to: number) => CodeEdit | null): Promise<CodePlaced | null>;
37
+ /** Tidy the whole code with the `formatter` prop, in one undo step; the cursor stays on the same code. */
38
+ format(): Promise<CodeFormatResult>;
39
+ focus(): void;
40
+ }
41
+ interface CodeEditorProps {
42
+ value: string;
43
+ onChange(value: string): void;
44
+ /** What the editable area is called for a screen reader. */
45
+ label: string;
46
+ readOnly?: boolean;
47
+ /** Wrap a line longer than the frame onto the next row, so no code is cut off
48
+ * at the right edge. Off by default: a line keeps its own row and scrolls. */
49
+ lineWrap?: boolean;
50
+ /** Opt in to `format()` and Shift+Alt+F. With none, the editor formats nothing. */
51
+ formatter?: CodeFormatter;
52
+ className?: string;
53
+ }
54
+
55
+ export type { CodeFormatter as C, CodeEditorProps as a, CodeEditorHandle as b, CodeEdit as c, CodeFormatResult as d, CodePlaced as e };
@@ -0,0 +1 @@
1
+ import{REST_EDGE as e}from"./chunk-AKDPGEBE.js";import{forwardRef as t,useRef as r,useEffect as o,useImperativeHandle as n}from"react";import{Annotation as a,Compartment as c,EditorState as i,Transaction as s,RangeSetBuilder as l,countColumn as d}from"@codemirror/state";import{EditorView as m,ViewPlugin as u,Decoration as f,lineNumbers as g,highlightActiveLine as h,drawSelection as p,keymap as v}from"@codemirror/view";import{history as b,defaultKeymap as y,historyKeymap as w,indentWithTab as x}from"@codemirror/commands";import{LanguageSupport as k,LRLanguage as C,HighlightStyle as N,indentOnInput as S,syntaxHighlighting as z}from"@codemirror/language";import{css as A}from"@codemirror/lang-css";import{parser as K}from"@lezer/html";import{parseMixed as L}from"@lezer/common";import{tags as O}from"@lezer/highlight";import{jsx as D}from"react/jsx-runtime";var E=a.define(),I=A().language,T=new k(C.define({name:"html",parser:K.configure({wrap:L(e=>"StyleText"===e.name?{parser:I.parser}:null)}),languageData:{commentTokens:{block:{open:"\x3c!--",close:"--\x3e"}}}}),[I.data.of({})]),B=N.define([{tag:[O.tagName,O.angleBracket],color:"var(--code-tag)"},{tag:O.attributeName,color:"var(--code-attribute)"},{tag:[O.string,O.attributeValue],color:"var(--code-string)"},{tag:[O.propertyName,O.definition(O.propertyName)],color:"var(--code-property)"},{tag:[O.number,O.unit,O.color,O.keyword,O.atom],color:"var(--code-value)"},{tag:[O.className,O.labelName,O.variableName,O.special(O.variableName)],color:"var(--code-selector)"},{tag:[O.comment,O.blockComment,O.lineComment],color:"var(--code-comment)",fontStyle:"italic"},{tag:[O.punctuation,O.separator,O.bracket],color:"var(--code-punctuation)"}]),R=m.theme({"&":{height:"100%",color:"var(--code-text)",backgroundColor:"var(--surface)",fontSize:"var(--text-xs, 12px)",isolation:"isolate"},"&.cm-focused":{outline:"0"},"&::after":{content:'""',position:"absolute",inset:"0",border:`${e.width} solid ${e.colour}`,borderRadius:"inherit",pointerEvents:"none",zIndex:2},"&.cm-focused::after":{border:"var(--border-strong) solid var(--rosh-focus-ring)"},".cm-scroller":{fontFamily:"var(--font-mono)",lineHeight:"var(--code-line-height)"},".cm-content":{padding:"var(--space-8) 0",caretColor:"var(--ink-strongest)"},".cm-line":{padding:"0 var(--space-12)"},".cm-gutters":{zIndex:1,backgroundColor:"var(--surface-sunken)",color:"var(--code-line-number)",borderRight:"var(--border-hairline) solid var(--line)"},".cm-lineNumbers .cm-gutterElement":{padding:"0 var(--space-8) 0 var(--space-12)"},".cm-activeLine":{backgroundColor:"var(--code-active-line)"},".cm-activeLineGutter":{backgroundColor:"var(--code-active-line)",color:"var(--code-text)"},"&.cm-editor.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, &.cm-editor > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{backgroundColor:"var(--code-selection)"}});function F(e){const t=new l,r=e.state.tabSize;for(const{from:o,to:n}of e.visibleRanges)for(let a=o;a<=n;){const o=e.state.doc.lineAt(a),n=d(o.text,r,o.text.length-o.text.trimStart().length);n>0&&t.add(o.from,o.from,f.line({attributes:{style:`--cm-hang: ${n}ch`}})),a=o.to+1}return t.finish()}var H=[u.fromClass(class{decorations;constructor(e){this.decorations=F(e)}update(e){(e.docChanged||e.viewportChanged)&&(this.decorations=F(e.view))}},{decorations:e=>e.decorations}),m.theme({".cm-content.cm-lineWrapping .cm-line":{paddingLeft:"calc(var(--space-12) + min(var(--cm-hang, 0ch), 50%))",textIndent:"calc(-1 * min(var(--cm-hang, 0ch), 50%))"}})],V=/-*[A-Za-z0-9_]+(?:-+[A-Za-z0-9_]+)*-*/g,W=f.mark({class:"cm-nobreak"});function $(e){const t=new l;for(const{from:r,to:o}of e.visibleRanges){const n=e.state.sliceDoc(r,o);for(const e of n.matchAll(V)){const o=e[0];!o.includes("-")||o.length>40||t.add(r+e.index,r+e.index+o.length,W)}}return t.finish()}var j=[u.fromClass(class{decorations;constructor(e){this.decorations=$(e)}update(e){(e.docChanged||e.viewportChanged)&&(this.decorations=$(e.view))}},{decorations:e=>e.decorations}),m.baseTheme({".cm-nobreak":{whiteSpace:"nowrap"}})],G=[m.lineWrapping,H,j];async function M(e,t){const r=e.state.doc,o=r.toString();let n;try{n=await t.format(o,e.state.selection.main.head)}catch{return"error"}if(!e.dom.parentNode||e.state.doc!==r||n.code===o)return"unchanged";const a=Math.min(Math.max(n.cursor,0),n.code.length);return e.dispatch({changes:{from:0,to:o.length,insert:n.code},selection:{anchor:a},scrollIntoView:!0}),"formatted"}var P=t(function({value:e,onChange:t,label:a,readOnly:l=!1,lineWrap:d=!1,formatter:u,className:f},k){const C=r(null),N=r(null),A=r(t);A.current=t;const K=r(u);K.current=u;const L=r(new c),O=r(new c),I=r(new c);return o(()=>{if(!C.current)return;const t=new m({parent:C.current,state:i.create({doc:e,extensions:[g(),h(),p(),b(),S(),m.domEventHandlers({keydown:(e,t)=>!("KeyF"!==e.code||!e.shiftKey||!e.altKey||e.ctrlKey||e.metaKey)&&(!(!K.current||t.state.readOnly)&&(e.preventDefault(),M(t,K.current),!0))}),v.of([...y,...w,x]),T,z(B),R,L.current.of(Z(l)),O.current.of(m.contentAttributes.of({"aria-label":a})),I.current.of(d?G:[]),m.updateListener.of(e=>{e.docChanged&&!e.transactions.some(e=>e.annotation(E))&&A.current(e.state.doc.toString())})]})});return N.current=t,()=>{t.destroy(),N.current=null}},[]),o(()=>{const t=N.current;t&&t.state.doc.toString()!==e&&t.dispatch({changes:{from:0,to:t.state.doc.length,insert:e},annotations:[E.of(!0),s.addToHistory.of(!1)]})},[e]),o(()=>{N.current?.dispatch({effects:L.current.reconfigure(Z(l))})},[l]),o(()=>{N.current?.dispatch({effects:O.current.reconfigure(m.contentAttributes.of({"aria-label":a}))})},[a]),o(()=>{N.current?.dispatch({effects:I.current.reconfigure(d?G:[])})},[d]),n(k,()=>({insert(e){const t=N.current;t&&!t.state.readOnly&&(t.dispatch(t.state.replaceSelection(e)),t.focus())},async place(e){const t=N.current;if(!t||t.state.readOnly)return null;const r=t.state.selection.main,o=e(t.state.doc.toString(),r.from,r.to);if(!o)return null;const n=o.selectFrom??o.from,a=o.selectTo??o.from+o.insert.length;return t.dispatch({changes:{from:o.from,to:o.to,insert:o.insert},selection:{anchor:n,head:a},scrollIntoView:!0}),t.focus(),{line:t.state.doc.lineAt(n).number,text:t.state.sliceDoc(n,a)}},format(){const e=N.current;return e&&K.current&&!e.state.readOnly?M(e,K.current):Promise.resolve("unavailable")},focus(){N.current?.focus()}}),[]),/* @__PURE__ */D("div",{ref:C,className:f,style:{height:"100%"}})});function Z(e){return[i.readOnly.of(e),m.editable.of(!e)]}export{P as default};
@@ -1,4 +1,4 @@
1
- import{loadAppearance as t,WidgetSettingsModal as e}from"./chunk-3QRCPC7V.js";import{useWidgetSettings as r}from"./chunk-H56OE6Q5.js";import"./chunk-4LXCCZDM.js";import"./chunk-KNUR2UEG.js";import"./chunk-JDCM2VHG.js";import"./chunk-YI4T5I5D.js";import"./chunk-PSVGB7KT.js";import"./chunk-TTD2M6RF.js";import"./chunk-5A7MWTXX.js";import"./chunk-TJ5YMXVB.js";import"./chunk-2XDO7FZC.js";import"./chunk-ZSVU44OB.js";import"./chunk-EIFNESXS.js";import"./chunk-7WF6LFOJ.js";import"./chunk-CJ4OEY3T.js";import"./chunk-AH5MLH54.js";import"./chunk-5YTZBYG4.js";import"./chunk-VWGWZY7A.js";import"./chunk-DBQNYJZ6.js";import"./chunk-6X32SWQI.js";import"./chunk-YPXONNBV.js";import"./chunk-4PJFL26P.js";import"./chunk-F3ZOO23R.js";import"./chunk-2QY5BJLA.js";import"./chunk-UGTRSRIW.js";import"./chunk-POBVGDZP.js";import"./chunk-AW7TOB6N.js";import"./chunk-M5IZ7QLQ.js";import"./chunk-XNKNX5L3.js";import"./chunk-DWGYC7OD.js";import"./chunk-MYH5H43C.js";import"./chunk-RTK77DMP.js";import"./chunk-URHGHXDN.js";import"./chunk-5QFPTDQF.js";import"./chunk-EDRELF6L.js";import"./chunk-MEP6CZJ3.js";import"./chunk-IVEM2BPC.js";import"./chunk-ISVODSRP.js";import"./chunk-J75ZT2JQ.js";import{LoadingSpinner as n}from"./chunk-R2VKEMZH.js";import"./chunk-BWJZTHZ6.js";import"./chunk-G3TC2GIA.js";import"./chunk-AJPQJ7TC.js";import"./chunk-PGN5ME7B.js";import"./chunk-62LW225J.js";import"./chunk-TAHHZGRH.js";import"./chunk-KEFNQEXZ.js";import"./chunk-PU2GJVMG.js";import"./chunk-STKJA4PV.js";import"./chunk-M6UKCZHT.js";import"./chunk-UQYNPYF4.js";import"./chunk-MRJKZWWV.js";import"./chunk-TWVUQUUD.js";import"./chunk-5FYDNH4Y.js";import"./chunk-LNXBTK7Q.js";import"./chunk-MAFUXCPZ.js";import"./chunk-NRHG4R2Q.js";import"./chunk-C3QOHMR6.js";import{useState as s,useCallback as o,useEffect as c}from"react";import{jsxs as i,Fragment as a,jsx as m}from"react/jsx-runtime";var l=["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 k(t){try{const e=JSON.parse(localStorage.getItem(d)||"{}")[t];if(e&&Date.now()-e.timestamp<36e5)return e.rates}catch{}return null}function j(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 g(){try{const t=JSON.parse(localStorage.getItem(p)||"");if(Array.isArray(t)&&t.length)return t.slice(0,4)}catch{}return u}var N={USD:"🇺🇸",CNY:"🇨🇳",AUD:"🇦🇺",GBP:"🇬🇧",JPY:"🇯🇵",CAD:"🇨🇦",EUR:"🇪🇺",THB:"🇹🇭",NZD:"🇳🇿",SGD:"🇸🇬",HKD:"🇭🇰",CHF:"🇨🇭",KRW:"🇰🇷",INR:"🇮🇳",MXN:"🇲🇽",BRL:"🇧🇷"};function f(){const[u,d]=s(g),[f,x]=s(()=>t(h)),[y,b]=s({}),[D,S]=s(!1),[C,v]=s(!1),[J,P]=s([]),[R,U]=s(f),[B,H]=s("USD"),[T,M]=s("CNY");r(o(()=>{P([...u]),U({...f}),v(!0)},[u,f])),c(()=>{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=k(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,j(e,n.rates))}catch{}}e&&(b(r),S(!1))}(),()=>{e=!1}},[u]);/* @__PURE__ */
1
+ import{loadAppearance as t,WidgetSettingsModal as e}from"./chunk-CG2GLJBL.js";import{useWidgetSettings as r}from"./chunk-J44PLTRE.js";import"./chunk-4LXCCZDM.js";import"./chunk-KNUR2UEG.js";import"./chunk-JDCM2VHG.js";import"./chunk-YI4T5I5D.js";import"./chunk-PSVGB7KT.js";import"./chunk-TTD2M6RF.js";import"./chunk-5A7MWTXX.js";import"./chunk-TJ5YMXVB.js";import"./chunk-2XDO7FZC.js";import"./chunk-ZSVU44OB.js";import"./chunk-EIFNESXS.js";import"./chunk-7WF6LFOJ.js";import"./chunk-CJ4OEY3T.js";import"./chunk-AH5MLH54.js";import"./chunk-5YTZBYG4.js";import"./chunk-VWGWZY7A.js";import"./chunk-DBQNYJZ6.js";import"./chunk-6X32SWQI.js";import"./chunk-AW7TOB6N.js";import"./chunk-YPXONNBV.js";import"./chunk-4PJFL26P.js";import"./chunk-F3ZOO23R.js";import"./chunk-2QY5BJLA.js";import"./chunk-UGTRSRIW.js";import"./chunk-POBVGDZP.js";import"./chunk-M5IZ7QLQ.js";import"./chunk-XNKNX5L3.js";import"./chunk-DWGYC7OD.js";import"./chunk-MYH5H43C.js";import"./chunk-EDRELF6L.js";import"./chunk-RTK77DMP.js";import"./chunk-URHGHXDN.js";import"./chunk-5QFPTDQF.js";import"./chunk-MEP6CZJ3.js";import"./chunk-IVEM2BPC.js";import{LoadingSpinner as n}from"./chunk-R2VKEMZH.js";import"./chunk-ISVODSRP.js";import"./chunk-J75ZT2JQ.js";import"./chunk-BWJZTHZ6.js";import"./chunk-G3TC2GIA.js";import"./chunk-AJPQJ7TC.js";import"./chunk-PGN5ME7B.js";import"./chunk-62LW225J.js";import"./chunk-TAHHZGRH.js";import"./chunk-KEFNQEXZ.js";import"./chunk-PU2GJVMG.js";import"./chunk-STKJA4PV.js";import"./chunk-M6UKCZHT.js";import"./chunk-UQYNPYF4.js";import"./chunk-MRJKZWWV.js";import"./chunk-TWVUQUUD.js";import"./chunk-5FYDNH4Y.js";import"./chunk-LNXBTK7Q.js";import"./chunk-MAFUXCPZ.js";import"./chunk-NRHG4R2Q.js";import"./chunk-C3QOHMR6.js";import{useState as s,useCallback as o,useEffect as c}from"react";import{jsxs as i,Fragment as a,jsx as m}from"react/jsx-runtime";var l=["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 k(t){try{const e=JSON.parse(localStorage.getItem(d)||"{}")[t];if(e&&Date.now()-e.timestamp<36e5)return e.rates}catch{}return null}function j(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 g(){try{const t=JSON.parse(localStorage.getItem(p)||"");if(Array.isArray(t)&&t.length)return t.slice(0,4)}catch{}return u}var N={USD:"🇺🇸",CNY:"🇨🇳",AUD:"🇦🇺",GBP:"🇬🇧",JPY:"🇯🇵",CAD:"🇨🇦",EUR:"🇪🇺",THB:"🇹🇭",NZD:"🇳🇿",SGD:"🇸🇬",HKD:"🇭🇰",CHF:"🇨🇭",KRW:"🇰🇷",INR:"🇮🇳",MXN:"🇲🇽",BRL:"🇧🇷"};function f(){const[u,d]=s(g),[f,x]=s(()=>t(h)),[y,b]=s({}),[D,S]=s(!1),[C,v]=s(!1),[J,P]=s([]),[B,R]=s(f),[T,U]=s("USD"),[G,H]=s("CNY");r(o(()=>{P([...u]),R({...f}),v(!0)},[u,f])),c(()=>{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=k(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,j(e,n.rates))}catch{}}e&&(b(r),S(!1))}(),()=>{e=!1}},[u]);/* @__PURE__ */
2
2
  return i(a,{children:[
3
3
  /* @__PURE__ */m("div",{style:{backgroundColor:`rgb(var(--taskbar-bg-rgb, 243 244 246) / ${f.activeOpacity/100})`,backdropFilter:f.activeBlur>0?`blur(${f.activeBlur}px)`:void 0},children:/* @__PURE__ */i("div",{className:"px-4 py-3 space-y-1",children:[D&&/* @__PURE__ */m(n,{size:"sm",padding:"py-4",label:"Loading rates"}),u.map(([t,e],r)=>{const n=y[t]?.[e];/* @__PURE__ */
4
4
  return i("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 i("button",{onClick:()=>{const t=u.map((t,e)=>e===r?[t[1],t[0]]:t);d(t),l
9
9
  /* @__PURE__ */m("span",{className:"text-base",children:N[e]||""}),
10
10
  /* @__PURE__ */m("span",{className:"text-sm font-semibold text-gray-700",children:e})]}),
11
11
  /* @__PURE__ */m("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__ */m(e,{open:C,onClose:()=>v(!1),title:"Currency Settings",appearance:R,onAppearanceChange:U,onSave:()=>{if(0===J.length)return;const t=J.slice(0,4);d(t),x(R),localStorage.setItem(p,JSON.stringify(t)),localStorage.setItem(h,JSON.stringify(R)),v(!1)},children:/* @__PURE__ */i("div",{children:[
12
+ /* @__PURE__ */m(e,{open:C,onClose:()=>v(!1),title:"Currency Settings",appearance:B,onAppearanceChange:R,onSave:()=>{if(0===J.length)return;const t=J.slice(0,4);d(t),x(B),localStorage.setItem(p,JSON.stringify(t)),localStorage.setItem(h,JSON.stringify(B)),v(!1)},children:/* @__PURE__ */i("div",{children:[
13
13
  /* @__PURE__ */i("h3",{className:"text-sm font-semibold text-ink mb-2",children:["Currency Pairs ",
14
14
  /* @__PURE__ */i("span",{className:"text-2xs font-normal text-ink-faintest",children:["(",J.length,"/",4,")"]})]}),
15
15
  /* @__PURE__ */m("div",{className:"space-y-1 mb-2",children:J.map(([t,e],r)=>/* @__PURE__ */i("div",{className:"flex items-center justify-between py-1 px-2 bg-gray-50 rounded",children:[
16
16
  /* @__PURE__ */i("span",{className:"text-sm",children:[N[t]||""," ",t," → ",N[e]||""," ",e]}),
17
17
  /* @__PURE__ */m("button",{onClick:()=>P(t=>t.filter((t,e)=>e!==r)),className:"text-red-400 hover:text-red-600",children:"×"})]},r))}),J.length<4?/* @__PURE__ */i("div",{className:"flex items-center gap-2",children:[
18
- /* @__PURE__ */m("select",{value:B,onChange:t=>H(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:l.map(t=>/* @__PURE__ */m("option",{children:t},t))}),
18
+ /* @__PURE__ */m("select",{value:T,onChange:t=>U(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:l.map(t=>/* @__PURE__ */m("option",{children:t},t))}),
19
19
  /* @__PURE__ */m("span",{className:"text-gray-400",children:"→"}),
20
- /* @__PURE__ */m("select",{value:T,onChange:t=>M(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:l.map(t=>/* @__PURE__ */m("option",{children:t},t))}),
21
- /* @__PURE__ */m("button",{onClick:()=>{B!==T&&J.length<4&&P(t=>[...t,[B,T]])},className:"text-sm font-medium text-blue-600 hover:text-blue-800 px-2",children:"+ Add"})]}):/* @__PURE__ */i("p",{className:"text-2xs text-ink-faintest italic",children:["Max ",4," pairs — remove one to add another."]})]})})]})}export{f as default};
20
+ /* @__PURE__ */m("select",{value:G,onChange:t=>H(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:l.map(t=>/* @__PURE__ */m("option",{children:t},t))}),
21
+ /* @__PURE__ */m("button",{onClick:()=>{T!==G&&J.length<4&&P(t=>[...t,[T,G]])},className:"text-sm font-medium text-blue-600 hover:text-blue-800 px-2",children:"+ Add"})]}):/* @__PURE__ */i("p",{className:"text-2xs text-ink-faintest italic",children:["Max ",4," pairs — remove one to add another."]})]})})]})}export{f as default};