efficient-shell 8.25.0 → 8.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -1
- package/dist/{Browser-RJEKM63G.js → Browser-5DL5WHEM.js} +13 -13
- package/dist/{Calculator-OFKUHJMM.js → Calculator-WW7WTG43.js} +22 -22
- package/dist/{CurrencyConverter-LUDRYE35.js → CurrencyConverter-XBC732QI.js} +5 -5
- package/dist/{Documents-JBPK256V.js → Documents-7MFHD73Z.js} +4 -4
- package/dist/{Files-CWO6JJRY.js → Files-4DKRC3S2.js} +87 -87
- package/dist/{Notepad-P32DNQV3.js → Notepad-BCK4LMG2.js} +9 -9
- package/dist/{PomodoroTimer-773FYTGF.js → PomodoroTimer-KH4PYCYQ.js} +68 -68
- package/dist/{Preview-C56RWJL7.js → Preview-FP6XMPQR.js} +22 -22
- package/dist/{Spreadsheet-F3UZ7I6T.js → Spreadsheet-FSDGQCKT.js} +13 -13
- package/dist/{Stock-US3UN5TD.js → Stock-M4EEWA57.js} +3 -3
- package/dist/{Weather-TOY4CXLT.js → Weather-WLAS7FBY.js} +15 -15
- package/dist/{WorldClock-6JV67SYH.js → WorldClock-WRD7DV2S.js} +6 -6
- package/dist/ai/index.d.ts +38 -3
- package/dist/ai/index.js +37 -36
- package/dist/ai.css +1 -1
- package/dist/apps/index.d.ts +6 -2
- package/dist/apps/index.js +1 -1
- package/dist/bin/media-host-check.js +1 -1
- package/dist/bin/ui-check.js +1 -1
- package/dist/charts/BoxPlotChart.js +1 -1
- package/dist/charts/CandlestickChart.js +1 -1
- package/dist/charts/CartesianPlot.js +1 -1
- package/dist/charts/ChordChart.js +1 -1
- package/dist/charts/ColumnChart.js +1 -1
- package/dist/charts/HeatmapChart.js +1 -1
- package/dist/charts/HistogramChart.js +1 -1
- package/dist/charts/RadarChart.js +1 -1
- package/dist/charts/RangeChart.js +1 -1
- package/dist/charts/SankeyChart.js +1 -1
- package/dist/charts/ScatterChart.js +1 -1
- package/dist/charts/SpecChart.js +1 -1
- package/dist/charts/SunburstChart.js +1 -1
- package/dist/charts/TimeSeriesChart.js +1 -1
- package/dist/charts/TreemapChart.js +1 -1
- package/dist/charts/WaterfallChart.js +1 -1
- package/dist/chunk-24AL3CDS.js +1 -0
- package/dist/{chunk-VV37BGSY.js → chunk-2OLSY4GE.js} +12 -12
- package/dist/{chunk-PPFMXLEX.js → chunk-2RBWQVDC.js} +8 -8
- package/dist/{chunk-IFLIGOSU.js → chunk-3H74IBFS.js} +2 -2
- package/dist/{chunk-H33Z4ZIY.js → chunk-3WC6ITJ3.js} +6 -6
- package/dist/{chunk-7IMJJT2K.js → chunk-3ZRZWOFZ.js} +1 -1
- package/dist/{chunk-K4BEWZBI.js → chunk-6CNFVUT6.js} +1 -1
- package/dist/{chunk-IFDW5QW6.js → chunk-BIYL7CEI.js} +2 -2
- package/dist/chunk-CUZQVBPC.js +1 -0
- package/dist/chunk-DPDA3AJL.js +1 -0
- package/dist/{chunk-IYZO6ADE.js → chunk-E6ZXYTTQ.js} +1 -1
- package/dist/{chunk-37CCKGHU.js → chunk-EYX6KLCZ.js} +1 -1
- package/dist/{chunk-ZNCU3UIW.js → chunk-FRPNTDP4.js} +4 -4
- package/dist/{chunk-ATX4N3L4.js → chunk-I62MCTYI.js} +4 -4
- package/dist/{chunk-FOLZVO2Z.js → chunk-KWMMIOHD.js} +1 -1
- package/dist/{chunk-JUGPTBMS.js → chunk-LBLV64XG.js} +1 -1
- package/dist/{chunk-WSPO4N72.js → chunk-OSA24YH6.js} +14 -14
- package/dist/{chunk-I4VD5D43.js → chunk-RSO67DWS.js} +4 -4
- package/dist/chunk-S6OB6HJB.js +1 -0
- package/dist/{chunk-BKZGI76S.js → chunk-TFMC2WAS.js} +1 -1
- package/dist/chunk-V3UIAX5G.js +21 -0
- package/dist/{chunk-QR6V44P5.js → chunk-VEO34YZK.js} +1 -1
- package/dist/{chunk-ETF7LAYZ.js → chunk-W5M6P4DZ.js} +5 -5
- package/dist/{chunk-WISGY2OI.js → chunk-WPTG7ZC5.js} +20 -20
- package/dist/chunk-WZNGOA4Z.js +1 -0
- package/dist/{chunk-2C6IG7LG.js → chunk-Z2YGQBLZ.js} +1 -1
- package/dist/chunk-Z37R2OCE.js +10 -0
- package/dist/{chunk-ZNXBKFV7.js → chunk-ZOSIPTXM.js} +5 -5
- package/dist/format/index.d.ts +3 -0
- package/dist/format/index.js +1 -1
- package/dist/forms/BorderInput.js +1 -1
- package/dist/forms/ColorPicker.js +1 -1
- package/dist/forms/color.d.ts +35 -1
- package/dist/forms/color.js +1 -1
- package/dist/hooks/useTheme.js +1 -1
- package/dist/icons/efficient-glyphs.js +1 -1
- package/dist/icons/efficient-looks.js +1 -1
- package/dist/icons/efficient.js +1 -1
- package/dist/icons/looks/map.js +1 -1
- package/dist/icons/sets.js +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.js +140 -140
- package/dist/map-site.css +43 -0
- package/dist/shell/EditableGrid.js +1 -1
- package/dist/shell/HelpCenter.js +1 -1
- package/dist/shell/Markdown.d.ts +26 -2
- package/dist/shell/Markdown.js +1 -1
- package/dist/shell/TopNav.d.ts +3 -1
- package/dist/shell/TopNav.js +1 -1
- package/dist/telemetry/index.js +1 -1
- package/dist/templates/DashboardTemplate.js +1 -1
- package/dist/ui/index.d.ts +4 -2
- package/dist/ui/index.js +1 -1
- package/dist/utils/escapeHtml.d.ts +14 -0
- package/dist/utils/escapeHtml.js +1 -0
- package/dist/utils/slugify.d.ts +16 -0
- package/dist/utils/slugify.js +1 -0
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-4DAN4Q6P.js +0 -21
- package/dist/chunk-4LXH6DCN.js +0 -1
- package/dist/chunk-BF7NTCLU.js +0 -1
- package/dist/chunk-H245LLX4.js +0 -1
- package/dist/chunk-KBGC53FI.js +0 -1
- package/dist/chunk-Q2YDR6GF.js +0 -7
- /package/dist/{chunk-A5ALFLWZ.js → chunk-2HDDCXTW.js} +0 -0
- /package/dist/{chunk-BR22X7E5.js → chunk-G6DKCCWH.js} +0 -0
package/README.md
CHANGED
|
@@ -1033,7 +1033,13 @@ hue it was dragged from. Two more exports cover a host with its own layout.
|
|
|
1033
1033
|
`ColorPickerPanel` is the picker in the host's flow (with `onClose` for
|
|
1034
1034
|
Escape). `ColorSwatch` is a button painted with a colour (`selected` sets
|
|
1035
1035
|
`aria-pressed`). Beside them are `colorSwatchClasses`, `colorFill`, `HexInput`,
|
|
1036
|
-
and the maths: `parseHexColor`, `hexToHsv`, `hsvToHex`.
|
|
1036
|
+
and the maths: `parseHexColor`, `hexToHsv`, `hsvToHex`. The WCAG contrast maths
|
|
1037
|
+
sits beside them (also on `efficient-shell/format`): `hexToRgb(hex)` reads a
|
|
1038
|
+
stored `#rgb`, `#rrggbb` or `#rrggbbaa` (alpha dropped; the `#` is required) as
|
|
1039
|
+
`{ r, g, b }` or `null`; `relativeLuminance(colour)` and `contrastRatio(a, b)`
|
|
1040
|
+
take a hex or an `Rgb` and answer `null` for a colour they cannot read;
|
|
1041
|
+
`readableInk(surface, inks?)` is the ink with the highest contrast on `surface`
|
|
1042
|
+
(black or white by default, the first ink when it cannot tell).
|
|
1037
1043
|
|
|
1038
1044
|
**`ImageFocusPoint`** is a picture with a dot on it. Drag the dot, or press
|
|
1039
1045
|
anywhere on the picture, to choose which part of the picture stays in view when
|
|
@@ -4231,6 +4237,14 @@ import { AssistantChat } from 'efficient-shell/ai';
|
|
|
4231
4237
|
input behind Details as a list, never as JSON. Reasoning and tool output
|
|
4232
4238
|
show only in `window`. A tool that needs approval shows Approve / Deny; the
|
|
4233
4239
|
answer continues the turn on its own.
|
|
4240
|
+
* **Where a figure came from.** A read the server gave an account of — a
|
|
4241
|
+
`data-tool-summary` part keyed by its `tool_call_id`, with `rows` of
|
|
4242
|
+
`{label, value, warn?}` — shows that account under its step, unfolded: the
|
|
4243
|
+
date range ("Order date · 1 Jul – 30 Sep 2026") and time zone, what was left
|
|
4244
|
+
out, how many rows it read and whether that is all of them (a `warn` row, in
|
|
4245
|
+
amber), what a total summed and grouped by. The server writes it from the
|
|
4246
|
+
call and its result, never from the model's words; the input and output stay
|
|
4247
|
+
behind Details. `toolSummariesOf(message)` reads them by call id.
|
|
4234
4248
|
* To show a person's reply the moment it is sent, pass `subscribe`: called once
|
|
4235
4249
|
the conversation exists with `(conversation, refresh)`, it opens the host's
|
|
4236
4250
|
live channel (the storefront opens the backend's chat socket) and calls
|
|
@@ -4291,6 +4305,8 @@ read a stored focus on a server.
|
|
|
4291
4305
|
| `formatMoney(amount, currency?, { whole? })` | `A$1,234.50`, `-€50.00`, `CHF 1,200.00`. The catalog's symbol — an unknown code prints as the code, never a guessed `$`. Minus first, commas, the catalog's decimals (2 by default); `whole` drops them (`A$3,841`) for a storefront card. No currency prints the bare figure. Takes a number or the API's string. |
|
|
4292
4306
|
| `currencySymbol(code)`, `currencyDecimals(code)` | The two catalog lookups `formatMoney` uses. A missing code has no symbol (`''`) and 2 decimals. |
|
|
4293
4307
|
| `formatBytes(bytes)` | `512 B`, `1.5 KB`, `40.0 MB`, `2.3 GB`, `1.0 TB` — 1024 base, one decimal, whole bytes. |
|
|
4308
|
+
| `slugify(text)` | `" Hello, World! "` → `hello-world`: lower case, each run of other characters one `-`, none at the ends. Latin letters and digits only. The site builder's anchors use the same rule. |
|
|
4309
|
+
| `escapeHtml(text)` | Escapes `& < > " '` for a string written into HTML outside React. |
|
|
4294
4310
|
| `<EmptyValue label? />`, `EMPTY_VALUE` | The empty value: a `text-gray-400` dash that a screen reader reads as `label` (`Not available` by default; `Not set` when nothing was chosen). JSX uses the component; a string can only carry `EMPTY_VALUE`. |
|
|
4295
4311
|
| `useDebouncedValue(value, delay = 300)` | The value, changed only after `delay` ms with no new change — feed it to a search query, not the raw one. |
|
|
4296
4312
|
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import{peekBrowserStartUrl as e,claimBrowserStartUrl as t}from"./chunk-LWLCNQY7.js";import{AboutApp as o}from"./chunk-
|
|
1
|
+
import{peekBrowserStartUrl as e,claimBrowserStartUrl as t}from"./chunk-LWLCNQY7.js";import{AboutApp as o}from"./chunk-3ZRZWOFZ.js";import{WindowTitle as r}from"./chunk-WPTG7ZC5.js";import"./chunk-CY5N5OA3.js";import"./chunk-AW7TOB6N.js";import"./chunk-KNUR2UEG.js";import"./chunk-JDCM2VHG.js";import"./chunk-HVX37PKU.js";import"./chunk-5A7MWTXX.js";import"./chunk-Y53KNQKL.js";import"./chunk-FL2PUQX7.js";import{confirm as n}from"./chunk-ZN3O2KJ7.js";import"./chunk-YCQVEJOT.js";import"./chunk-VWGWZY7A.js";import"./chunk-PKXQDCNR.js";import"./chunk-XWLWG4HS.js";import"./chunk-UGTRSRIW.js";import"./chunk-CDAJKLGL.js";import"./chunk-D323R2FT.js";import"./chunk-KC3EX26K.js";import"./chunk-DPDA3AJL.js";import"./chunk-O6JX6RDX.js";import"./chunk-5QFPTDQF.js";import"./chunk-QR4RM7PO.js";import"./chunk-4IU5BSVE.js";import"./chunk-K7U4RWXJ.js";import{Icon as a}from"./chunk-KIBL6M3T.js";import"./chunk-J75ZT2JQ.js";import"./chunk-VH6GB73Q.js";import"./chunk-Q5MD3VY6.js";import"./chunk-MRJKZWWV.js";import"./chunk-6KO5VTL7.js";import"./chunk-22S6LG6D.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-E6UCGCOC.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),[D,S]=l(0),[T,U]=l(x),[E,J]=l(!1),[K,O]=l(null),G=s(null),H=s(null);i(()=>{try{localStorage.setItem(d,JSON.stringify(T))}catch{}},[T]);const P=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),J(!1))},Q=()=>{"undefined"!=typeof window&&window.open(f,"_blank","noopener,noreferrer")},M=()=>{const e=K?.trim();e?(U(t=>[...t,{label:e,url:f}]),O(null)):O(null)};i(()=>{if(null===K)return;G.current?.focus(),G.current?.select();const e=e=>{const t=e.target;t?.closest("[data-bookmark-popover]")||O(null)},t=setTimeout(()=>document.addEventListener("mousedown",e),0);return()=>{clearTimeout(t),document.removeEventListener("mousedown",e)}},[null!==K]);const X=e=>{U(t=>t.filter((t,o)=>o!==e))},A=z>0,F=z<W.length-1,I=T.some(e=>e.url===f),V="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]),
|
|
7
|
-
/* @__PURE__ */m("button",{onClick:()=>{if(z<W.length-1){const e=z+1;L(e),y(W[e]),C(W[e]),
|
|
8
|
-
/* @__PURE__ */m("button",{onClick:()=>
|
|
9
|
-
/* @__PURE__ */m("button",{onClick:()=>
|
|
10
|
-
/* @__PURE__ */m("form",{onSubmit:e=>{e.preventDefault(),
|
|
6
|
+
/* @__PURE__ */m("button",{onClick:()=>{if(z>0){const e=z-1;L(e),y(W[e]),C(W[e]),J(!1)}},disabled:!A,className:V,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]),J(!1)}},disabled:!F,className:V,title:"Forward",children:/* @__PURE__ */m(a,{name:"chevron-right",className:"h-4 w-4",strokeWidth:2})}),
|
|
8
|
+
/* @__PURE__ */m("button",{onClick:()=>S(e=>e+1),className:V,title:"Refresh",children:/* @__PURE__ */m(a,{name:"refresh",className:"h-4 w-4",strokeWidth:1.8})}),
|
|
9
|
+
/* @__PURE__ */m("button",{onClick:()=>P(g),className:V,title:"Home",children:/* @__PURE__ */m(a,{name:"home",className:"h-4 w-4",strokeWidth:1.8})}),
|
|
10
|
+
/* @__PURE__ */m("form",{onSubmit:e=>{e.preventDefault(),P(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:()=>
|
|
14
|
-
/* @__PURE__ */m("button",{onClick:
|
|
15
|
-
/* @__PURE__ */m("button",{onClick:()=>
|
|
13
|
+
/* @__PURE__ */m("button",{"data-bookmark-popover":!0,onClick:()=>I?X(T.findIndex(e=>e.url===f)):void O(v(f)),className:V+" "+(I?"text-yellow-500":""),title:I?"Remove bookmark":"Add bookmark",children:/* @__PURE__ */m(a,{name:"star",className:"h-4 w-4",fill:I?"currentColor":"none",strokeWidth:1.5})}),
|
|
14
|
+
/* @__PURE__ */m("button",{onClick:Q,className:V,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:V,title:"Embedding help",children:/* @__PURE__ */m(a,{name:"help",className:"h-4 w-4",strokeWidth:1.5})})]}),null!==K&&/* @__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:G,type:"text",value:
|
|
18
|
+
/* @__PURE__ */m("input",{ref:G,type:"text",value:K,onChange:e=>O(e.target.value),onKeyDown:e=>{"Enter"===e.key?M():"Escape"===e.key&&O(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
20
|
/* @__PURE__ */m("button",{onClick:()=>O(null),className:"px-2 py-1 text-xs text-gray-600 hover:bg-gray-100 rounded",children:"Cancel"}),
|
|
21
|
-
/* @__PURE__ */m("button",{onClick:
|
|
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===
|
|
21
|
+
/* @__PURE__ */m("button",{onClick:M,disabled:!K.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:()=>P(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"})&&X(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:
|
|
26
|
+
/* @__PURE__ */m("div",{className:"flex-1 relative min-h-0 bg-gray-50",children:/* @__PURE__ */m(N,{url:f,iframeKey:D,iframeRef:H,openExternal:Q,showHelp:E,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,29 +1,29 @@
|
|
|
1
|
-
import{loadAppearance as e,WidgetSettingsModal as t}from"./chunk-
|
|
1
|
+
import{loadAppearance as e,WidgetSettingsModal as t}from"./chunk-E6ZXYTTQ.js";import{useWidgetSettings as n}from"./chunk-WPTG7ZC5.js";import"./chunk-CY5N5OA3.js";import"./chunk-AW7TOB6N.js";import"./chunk-KNUR2UEG.js";import"./chunk-JDCM2VHG.js";import"./chunk-HVX37PKU.js";import"./chunk-5A7MWTXX.js";import"./chunk-Y53KNQKL.js";import"./chunk-FL2PUQX7.js";import"./chunk-ZN3O2KJ7.js";import"./chunk-YCQVEJOT.js";import"./chunk-VWGWZY7A.js";import"./chunk-PKXQDCNR.js";import"./chunk-XWLWG4HS.js";import"./chunk-UGTRSRIW.js";import"./chunk-CDAJKLGL.js";import"./chunk-D323R2FT.js";import"./chunk-KC3EX26K.js";import"./chunk-O6JX6RDX.js";import"./chunk-5QFPTDQF.js";import"./chunk-QR4RM7PO.js";import"./chunk-4IU5BSVE.js";import"./chunk-K7U4RWXJ.js";import{Icon as r}from"./chunk-KIBL6M3T.js";import"./chunk-J75ZT2JQ.js";import"./chunk-VH6GB73Q.js";import"./chunk-Q5MD3VY6.js";import"./chunk-MRJKZWWV.js";import"./chunk-6KO5VTL7.js";import"./chunk-22S6LG6D.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-E6UCGCOC.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),[j,N]=c(!1),[y,x]=c(""),[C,f]=c([]),[v,$]=c(!1),[T,W]=c(()=>e(h)),[E,w]=c(!1),[J,R]=c(T),D=i(null);n(l(()=>{R({...T}),w(!0)},[T]));const K=l(e=>{x(""),k(t=>j||"0"===t?(N(!1),"."===e?"0.":e):"."===e&&t.includes(".")?t:t+e)},[j]),L=l(()=>{k("0"),d(null),g(null),N(!1)},[]),Q=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}},[]),S=l(e=>{const t=parseFloat(m);if(null!==p&&b&&!j){const e=Q(p,t,b);k(String(e)),d(e),f(n=>[`${p} ${b} ${t} = ${e}`,...n].slice(0,20))}else d(t);g(e),N(!0)},[m,p,b,j,Q]),U=l(()=>{if(null===p||!b)return;const e=parseFloat(m),t=Q(p,e,b),n=`${p} ${b} ${e} =`;f(e=>[`${n} ${t}`,...e].slice(0,20)),x(n),k(String(t)),d(null),g(null),N(!0)},[m,p,b,Q]),G=l(()=>{k(e=>String(parseFloat(e)/100))},[]),X=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"?K(e.key):"."===e.key?K("."):"+"===e.key?S("+"):"-"===e.key?S("-"):"*"===e.key?S("×"):"/"===e.key?(e.preventDefault(),S("÷")):"Enter"===e.key||"="===e.key?("Enter"===e.key&&e.target instanceof Node&&D.current?.contains(e.target)&&e.preventDefault(),U()):"Escape"===e.key?L():"Backspace"===e.key?k(e=>e.length>1?e.slice(0,-1):"0"):"%"===e.key&&G())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[K,S,U,L,G]);const O="flex items-center justify-center rounded-lg text-sm font-medium transition-colors",F=`${O} bg-white border border-gray-200 text-gray-900 hover:bg-gray-50 active:bg-gray-100`,V=`${O} bg-blue-50 border border-blue-200 text-blue-700 hover:bg-blue-100 active:bg-blue-200`,A=`${O} bg-gray-100 border border-gray-200 text-gray-600 hover:bg-gray-200 active:bg-gray-300`,B=`${O} bg-blue-600 text-white hover:bg-blue-700 active:bg-blue-800`;/* @__PURE__ */
|
|
2
2
|
return s(a,{children:[
|
|
3
|
-
/* @__PURE__ */s("div",{ref:
|
|
3
|
+
/* @__PURE__ */s("div",{ref:D,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:[
|
|
5
|
-
/* @__PURE__ */u("div",{className:"flex flex-col justify-end flex-1 overflow-hidden",children:
|
|
5
|
+
/* @__PURE__ */u("div",{className:"flex flex-col justify-end flex-1 overflow-hidden",children:C.slice(0,3).reverse().map((e,t)=>/* @__PURE__ */u("div",{className:"text-2xs text-slate-400 text-right font-mono truncate",children:e},t))}),(y||b&&null!==p)&&/* @__PURE__ */u("div",{className:"text-base text-slate-600 text-right font-mono",children:y||`${p} ${b} ${j?"":m}`}),
|
|
6
6
|
/* @__PURE__ */s("div",{className:"flex items-center gap-2",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:
|
|
11
|
-
/* @__PURE__ */u("button",{onClick:
|
|
12
|
-
/* @__PURE__ */u("button",{onClick:G,className:
|
|
13
|
-
/* @__PURE__ */u("button",{onClick:()=>
|
|
14
|
-
/* @__PURE__ */u("button",{onClick:()=>
|
|
15
|
-
/* @__PURE__ */u("button",{onClick:()=>
|
|
16
|
-
/* @__PURE__ */u("button",{onClick:()=>
|
|
17
|
-
/* @__PURE__ */u("button",{onClick:()=>
|
|
18
|
-
/* @__PURE__ */u("button",{onClick:()=>
|
|
19
|
-
/* @__PURE__ */u("button",{onClick:()=>
|
|
20
|
-
/* @__PURE__ */u("button",{onClick:()=>
|
|
21
|
-
/* @__PURE__ */u("button",{onClick:()=>
|
|
22
|
-
/* @__PURE__ */u("button",{onClick:()=>
|
|
23
|
-
/* @__PURE__ */u("button",{onClick:()=>
|
|
24
|
-
/* @__PURE__ */u("button",{onClick:()=>
|
|
25
|
-
/* @__PURE__ */u("button",{onClick:()=>
|
|
26
|
-
/* @__PURE__ */u("button",{onClick:()=>
|
|
27
|
-
/* @__PURE__ */u("button",{onClick:()=>
|
|
10
|
+
/* @__PURE__ */u("button",{onClick:L,className:A,children:"AC"}),
|
|
11
|
+
/* @__PURE__ */u("button",{onClick:X,className:A,children:"+/−"}),
|
|
12
|
+
/* @__PURE__ */u("button",{onClick:G,className:A,children:"%"}),
|
|
13
|
+
/* @__PURE__ */u("button",{onClick:()=>S("÷"),className:`${V} ${"÷"===b?"ring-2 ring-blue-400":""}`,children:"÷"}),
|
|
14
|
+
/* @__PURE__ */u("button",{onClick:()=>K("7"),className:F,children:"7"}),
|
|
15
|
+
/* @__PURE__ */u("button",{onClick:()=>K("8"),className:F,children:"8"}),
|
|
16
|
+
/* @__PURE__ */u("button",{onClick:()=>K("9"),className:F,children:"9"}),
|
|
17
|
+
/* @__PURE__ */u("button",{onClick:()=>S("×"),className:`${V} ${"×"===b?"ring-2 ring-blue-400":""}`,children:"×"}),
|
|
18
|
+
/* @__PURE__ */u("button",{onClick:()=>K("4"),className:F,children:"4"}),
|
|
19
|
+
/* @__PURE__ */u("button",{onClick:()=>K("5"),className:F,children:"5"}),
|
|
20
|
+
/* @__PURE__ */u("button",{onClick:()=>K("6"),className:F,children:"6"}),
|
|
21
|
+
/* @__PURE__ */u("button",{onClick:()=>S("-"),className:`${V} ${"-"===b?"ring-2 ring-blue-400":""}`,children:"−"}),
|
|
22
|
+
/* @__PURE__ */u("button",{onClick:()=>K("1"),className:F,children:"1"}),
|
|
23
|
+
/* @__PURE__ */u("button",{onClick:()=>K("2"),className:F,children:"2"}),
|
|
24
|
+
/* @__PURE__ */u("button",{onClick:()=>K("3"),className:F,children:"3"}),
|
|
25
|
+
/* @__PURE__ */u("button",{onClick:()=>S("+"),className:`${V} ${"+"===b?"ring-2 ring-blue-400":""}`,children:"+"}),
|
|
26
|
+
/* @__PURE__ */u("button",{onClick:()=>K("0"),className:`${F} col-span-2`,children:"0"}),
|
|
27
|
+
/* @__PURE__ */u("button",{onClick:()=>K("."),className:F,children:"."}),
|
|
28
28
|
/* @__PURE__ */u("button",{onClick:U,className:B,children:"="})]})]}),
|
|
29
|
-
/* @__PURE__ */u(t,{open:E,onClose:()=>w(!1),title:"Calculator Settings",appearance:
|
|
29
|
+
/* @__PURE__ */u(t,{open:E,onClose:()=>w(!1),title:"Calculator Settings",appearance:J,onAppearanceChange:R,onSave:()=>{W(J),localStorage.setItem(h,JSON.stringify(J)),w(!1)}})]})}export{m as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{loadAppearance as t,WidgetSettingsModal as e}from"./chunk-
|
|
1
|
+
import{loadAppearance as t,WidgetSettingsModal as e}from"./chunk-E6ZXYTTQ.js";import{useWidgetSettings as r}from"./chunk-WPTG7ZC5.js";import"./chunk-CY5N5OA3.js";import"./chunk-AW7TOB6N.js";import"./chunk-KNUR2UEG.js";import"./chunk-JDCM2VHG.js";import"./chunk-HVX37PKU.js";import"./chunk-5A7MWTXX.js";import"./chunk-Y53KNQKL.js";import"./chunk-FL2PUQX7.js";import"./chunk-ZN3O2KJ7.js";import"./chunk-YCQVEJOT.js";import"./chunk-VWGWZY7A.js";import"./chunk-PKXQDCNR.js";import"./chunk-XWLWG4HS.js";import"./chunk-UGTRSRIW.js";import"./chunk-CDAJKLGL.js";import"./chunk-D323R2FT.js";import"./chunk-KC3EX26K.js";import"./chunk-O6JX6RDX.js";import"./chunk-5QFPTDQF.js";import"./chunk-QR4RM7PO.js";import"./chunk-4IU5BSVE.js";import"./chunk-K7U4RWXJ.js";import"./chunk-KIBL6M3T.js";import"./chunk-J75ZT2JQ.js";import"./chunk-VH6GB73Q.js";import{LoadingSpinner as n}from"./chunk-Q5MD3VY6.js";import"./chunk-MRJKZWWV.js";import"./chunk-6KO5VTL7.js";import"./chunk-22S6LG6D.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-E6UCGCOC.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),[C,v]=s(!1),[U,J]=s([]),[R,G]=s(j),[K,L]=s("USD"),[O,T]=s("CNY");r(a(()=>{J([...u]),G({...j}),v(!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:
|
|
12
|
+
/* @__PURE__ */l(e,{open:C,onClose:()=>v(!1),title:"Currency Settings",appearance:R,onAppearanceChange:G,onSave:()=>{if(0===U.length)return;const t=U.slice(0,4);d(t),y(R),localStorage.setItem(p,JSON.stringify(t)),localStorage.setItem(h,JSON.stringify(R)),v(!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:["(",U.length,"/",4,")"]})]}),
|
|
15
15
|
/* @__PURE__ */l("div",{className:"space-y-1 mb-2",children:U.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
17
|
/* @__PURE__ */l("button",{onClick:()=>J(t=>t.filter((t,e)=>e!==r)),className:"text-red-400 hover:text-red-600",children:"×"})]},r))}),U.length<4?/* @__PURE__ */c("div",{className:"flex items-center gap-2",children:[
|
|
18
|
-
/* @__PURE__ */l("select",{value:
|
|
18
|
+
/* @__PURE__ */l("select",{value:K,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))}),
|
|
19
19
|
/* @__PURE__ */l("span",{className:"text-gray-400",children:"→"}),
|
|
20
|
-
/* @__PURE__ */l("select",{value:
|
|
21
|
-
/* @__PURE__ */l("button",{onClick:()=>{
|
|
20
|
+
/* @__PURE__ */l("select",{value:O,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))}),
|
|
21
|
+
/* @__PURE__ */l("button",{onClick:()=>{K!==O&&U.length<4&&J(t=>[...t,[K,O]])},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,6 +1,6 @@
|
|
|
1
|
-
import{escapeHtml as e}from"./chunk-
|
|
1
|
+
import{escapeHtml as e}from"./chunk-G6DKCCWH.js";import{AboutApp as t}from"./chunk-3ZRZWOFZ.js";import{WindowTitle as n}from"./chunk-WPTG7ZC5.js";import"./chunk-CY5N5OA3.js";import"./chunk-AW7TOB6N.js";import"./chunk-KNUR2UEG.js";import"./chunk-JDCM2VHG.js";import"./chunk-HVX37PKU.js";import"./chunk-5A7MWTXX.js";import"./chunk-Y53KNQKL.js";import"./chunk-FL2PUQX7.js";import"./chunk-ZN3O2KJ7.js";import"./chunk-YCQVEJOT.js";import"./chunk-VWGWZY7A.js";import"./chunk-PKXQDCNR.js";import{toast_default as r}from"./chunk-4NXMMWL6.js";import"./chunk-XWLWG4HS.js";import"./chunk-UGTRSRIW.js";import"./chunk-CDAJKLGL.js";import"./chunk-D323R2FT.js";import"./chunk-KC3EX26K.js";import"./chunk-DPDA3AJL.js";import{PopupMenu as o,PopupMenuLabel as i,PopupMenuItem as l,PopupMenuDivider as a}from"./chunk-O6JX6RDX.js";import"./chunk-5QFPTDQF.js";import"./chunk-QR4RM7PO.js";import"./chunk-4IU5BSVE.js";import"./chunk-K7U4RWXJ.js";import{Icon as s}from"./chunk-KIBL6M3T.js";import"./chunk-J75ZT2JQ.js";import"./chunk-VH6GB73Q.js";import{LoadingSpinner as c}from"./chunk-Q5MD3VY6.js";import"./chunk-MRJKZWWV.js";import"./chunk-6KO5VTL7.js";import"./chunk-22S6LG6D.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-E6UCGCOC.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,C]=m(!1),[N,D]=m(null),L=d(null),M=d(null),U=d(null),R=(e,t)=>{U.current?.focus(),document.execCommand(e,!1,t),C(!0)},W=e=>{for(const t of e){if(!t.type.startsWith("image/"))continue;const e=new FileReader;e.onload=()=>{U.current?.focus(),document.execCommand("insertImage",!1,String(e.result)),C(!0)},e.readAsDataURL(t)}},T=e=>{N&&(N.el.removeAttribute("width"),N.el.removeAttribute("height"),N.el.style.width=e??"",N.el.style.height=e?"auto":"",C(!0),D(null))},O=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}),C(!1)}else if(g.has(n))try{const e=await(import(
|
|
2
2
|
/* @vite-ignore */
|
|
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}),
|
|
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}),C(!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)}},B=f?.filename?(A=f.filename).length>24?`${A.slice(0,23)}…`:A:"Untitled";var A;/* @__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):O(t[0]))},children:[
|
|
5
5
|
/* @__PURE__ */u(n,{title:`${B}${j?" •":""} - Documents`}),
|
|
6
6
|
/* @__PURE__ */u(t,{app:"documents"}),
|
|
@@ -41,7 +41,7 @@ return h("div",{className:"relative flex flex-col h-full",onDragOver:e=>{e.preve
|
|
|
41
41
|
/* @__PURE__ */u("input",{ref:M,type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:e=>{e.target.files?.length&&W(Array.from(e.target.files)),M.current&&(M.current.value="")}}),
|
|
42
42
|
/* @__PURE__ */h("button",{onClick:()=>M.current?.click(),className:"px-2 py-1 text-xs rounded text-gray-700 hover:bg-gray-200 transition-colors flex items-center gap-1",title:"Insert image (or paste / drop one)",children:[
|
|
43
43
|
/* @__PURE__ */u(s,{name:"image",className:"h-3.5 w-3.5",strokeWidth:1.5}),"Image"]})]}),
|
|
44
|
-
/* @__PURE__ */u("div",{className:"flex-1 min-h-0 overflow-hidden",children:k?/* @__PURE__ */u(c,{size:"sm",padding:"",className:"h-full",label:"Loading"}):/* @__PURE__ */u("div",{className:"h-full overflow-auto "+("docx"===f.kind?"bg-gray-100 px-6 py-8":"bg-white"),children:/* @__PURE__ */u("div",{ref:U,contentEditable:!0,suppressContentEditableWarning:!0,spellCheck:!1,onInput:()=>
|
|
44
|
+
/* @__PURE__ */u("div",{className:"flex-1 min-h-0 overflow-hidden",children:k?/* @__PURE__ */u(c,{size:"sm",padding:"",className:"h-full",label:"Loading"}):/* @__PURE__ */u("div",{className:"h-full overflow-auto "+("docx"===f.kind?"bg-gray-100 px-6 py-8":"bg-white"),children:/* @__PURE__ */u("div",{ref:U,contentEditable:!0,suppressContentEditableWarning:!0,spellCheck:!1,onInput:()=>C(!0),onPaste:e=>{const t=Array.from(e.clipboardData?.items??[]).filter(e=>"file"===e.kind&&e.type.startsWith("image/")).map(e=>e.getAsFile()).filter(e=>!!e);t.length&&(e.preventDefault(),W(t))},onClick:e=>{const t=e.target;"IMG"===t.tagName&&(e.preventDefault(),D({x:e.clientX,y:e.clientY,el:t}))},dangerouslySetInnerHTML:{__html:f.content},className:"docx"===f.kind?"docs-editor mx-auto w-[8.5in] min-h-[11in] bg-white p-[1in] shadow text-sm leading-relaxed text-gray-800 outline-none focus:ring-2 focus:ring-blue-400/40":"docs-editor block w-full min-h-full p-4 font-mono text-sm leading-relaxed text-gray-800 bg-white outline-none whitespace-pre-wrap"})})}),b&&/* @__PURE__ */u("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__ */u("div",{className:"px-4 py-2 rounded-md bg-blue-600 text-white text-sm font-medium shadow-lg",children:"Drop a document to open · images insert into the page"})}),N&&/* @__PURE__ */h(o,{minWidth:150,style:{left:N.x,top:N.y},onClose:()=>D(null),children:[
|
|
45
45
|
/* @__PURE__ */u(i,{children:"Image width"}),
|
|
46
46
|
/* @__PURE__ */u(l,{onClick:()=>T("25%"),children:"25%"}),
|
|
47
47
|
/* @__PURE__ */u(l,{onClick:()=>T("50%"),children:"50%"}),
|
|
@@ -49,4 +49,4 @@ return h("div",{className:"relative flex flex-col h-full",onDragOver:e=>{e.preve
|
|
|
49
49
|
/* @__PURE__ */u(l,{onClick:()=>T("100%"),children:"100%"}),
|
|
50
50
|
/* @__PURE__ */u(l,{onClick:()=>T(null),children:"Original size"}),
|
|
51
51
|
/* @__PURE__ */u(a,{}),
|
|
52
|
-
/* @__PURE__ */u(l,{danger:!0,onClick:()=>{
|
|
52
|
+
/* @__PURE__ */u(l,{danger:!0,onClick:()=>{N?.el.remove(),C(!0),D(null)},children:"Remove image"})]})]})}export{f as default};
|