reifyui 0.6.1 → 0.7.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/dist/index.js CHANGED
@@ -182,6 +182,15 @@ var IcPanelRight = ({ size = 17 }) => /* @__PURE__ */ jsxs(Svg, { s: size, child
182
182
  /* @__PURE__ */ jsx("rect", { x: "3", y: "4", width: "18", height: "16", rx: "2" }),
183
183
  /* @__PURE__ */ jsx("path", { d: "M15 4v16" })
184
184
  ] });
185
+ var IcDownload = ({ size = 16 }) => /* @__PURE__ */ jsxs(Svg, { s: size, children: [
186
+ /* @__PURE__ */ jsx("path", { d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" }),
187
+ /* @__PURE__ */ jsx("path", { d: "M7 10l5 5 5-5" }),
188
+ /* @__PURE__ */ jsx("path", { d: "M12 15V3" })
189
+ ] });
190
+ var IcEye = ({ size = 15 }) => /* @__PURE__ */ jsxs(Svg, { s: size, children: [
191
+ /* @__PURE__ */ jsx("path", { d: "M2 12s3.6-7 10-7 10 7 10 7-3.6 7-10 7-10-7-10-7z" }),
192
+ /* @__PURE__ */ jsx("circle", { cx: "12", cy: "12", r: "3" })
193
+ ] });
185
194
 
186
195
  // src/components/toolMeta.js
187
196
  function humanize(s) {
@@ -1118,8 +1127,8 @@ function canonicalLang(tag) {
1118
1127
  var _ready = /* @__PURE__ */ new Map();
1119
1128
  function ensureLanguage(name) {
1120
1129
  if (!_ready.has(name)) {
1121
- const p = Promise.all([loadHljs(), GRAMMARS[name]()]).then(([hljs, mod]) => {
1122
- if (!hljs.getLanguage(name)) hljs.registerLanguage(name, mod.default || mod);
1130
+ const p = Promise.all([loadHljs(), GRAMMARS[name]()]).then(([hljs, mod2]) => {
1131
+ if (!hljs.getLanguage(name)) hljs.registerLanguage(name, mod2.default || mod2);
1123
1132
  return hljs;
1124
1133
  }).catch(() => null);
1125
1134
  _ready.set(name, p);
@@ -1573,7 +1582,7 @@ function PromptBody({ spec, onClose, t, titleId }) {
1573
1582
  const [value, setValue] = useState5(spec.defaultValue ?? "");
1574
1583
  const [err, setErr] = useState5(null);
1575
1584
  const inputId = useId();
1576
- const Field = spec.multiline ? "textarea" : "input";
1585
+ const Field2 = spec.multiline ? "textarea" : "input";
1577
1586
  const submit = () => {
1578
1587
  const invalid = spec.validate?.(value);
1579
1588
  if (invalid) {
@@ -1592,7 +1601,7 @@ function PromptBody({ spec, onClose, t, titleId }) {
1592
1601
  spec.message ? /* @__PURE__ */ jsx10("div", { className: "rui-dlg-msg", children: spec.message }) : null,
1593
1602
  spec.label ? /* @__PURE__ */ jsx10("label", { className: "rui-dlg-label", htmlFor: inputId, children: spec.label }) : null,
1594
1603
  /* @__PURE__ */ jsx10(
1595
- Field,
1604
+ Field2,
1596
1605
  {
1597
1606
  id: inputId,
1598
1607
  className: `rui-dlg-input${err ? " is-err" : ""}`,
@@ -1904,7 +1913,7 @@ var GOOGLE_ENABLED = !!CLIENT_ID;
1904
1913
 
1905
1914
  // src/auth/AuthForm.jsx
1906
1915
  import { Fragment as Fragment7, jsx as jsx12, jsxs as jsxs11 } from "react/jsx-runtime";
1907
- function AuthForm({ onDone, subtitle, brand = null, productName = "" }) {
1916
+ function AuthForm({ onDone, subtitle: subtitle2, brand = null, productName = "" }) {
1908
1917
  const [mode, setMode] = useState7("signin");
1909
1918
  const [email, setEmail] = useState7("");
1910
1919
  const [password, setPassword] = useState7("");
@@ -1980,7 +1989,7 @@ function AuthForm({ onDone, subtitle, brand = null, productName = "" }) {
1980
1989
  return /* @__PURE__ */ jsxs11("form", { onSubmit: submit, children: [
1981
1990
  /* @__PURE__ */ jsx12("div", { className: "logo", children: brand }),
1982
1991
  /* @__PURE__ */ jsx12("h1", { children: mode === "register" ? "Create your account" : mode === "forgot" ? "Reset password" : "Sign in" }),
1983
- /* @__PURE__ */ jsx12("p", { className: "sub", children: mode === "register" ? "Get started in seconds." : mode === "forgot" ? "We will email you a reset link." : subtitle || "Welcome back." }),
1992
+ /* @__PURE__ */ jsx12("p", { className: "sub", children: mode === "register" ? "Get started in seconds." : mode === "forgot" ? "We will email you a reset link." : subtitle2 || "Welcome back." }),
1984
1993
  mode === "forgot" ? resetSent ? /* @__PURE__ */ jsxs11(Fragment7, { children: [
1985
1994
  /* @__PURE__ */ jsxs11("div", { className: "auth-note", children: [
1986
1995
  "If an account exists for ",
@@ -2580,30 +2589,51 @@ function SheetGrid({
2580
2589
  },
2581
2590
  title: c.error || "",
2582
2591
  children: [
2583
- peer && /* @__PURE__ */ jsx13("span", { className: "shg-peer-flag", style: { background: peer.color }, children: peer.name }),
2584
- isEditing ? renderEditor(col) : /* @__PURE__ */ jsx13(
2585
- "div",
2586
- {
2587
- className: "shg-val",
2588
- style: { maxWidth: colWidth(col) ? colWidth(col) - 20 : 400 },
2589
- children: custom !== void 0 ? custom : /* @__PURE__ */ jsxs12(Fragment8, { children: [
2590
- computed && /* @__PURE__ */ jsx13(StatusDot, { status: c.status }),
2591
- /* @__PURE__ */ jsx13(CellValue, { cell: c, col, fetchBlobUrl, onOpenResource }),
2592
- computed && !readOnly && onRunCell && /* @__PURE__ */ jsx13(
2593
- "button",
2594
- {
2595
- className: "shg-runcell",
2596
- title: "Run this cell",
2597
- onClick: (e) => {
2598
- e.stopPropagation();
2599
- onRunCell(row.id, col.id);
2600
- },
2601
- children: "\u25B6"
2602
- }
2592
+ !readOnly && /* @__PURE__ */ jsxs12(Fragment8, { children: [
2593
+ /* @__PURE__ */ jsx13(
2594
+ "span",
2595
+ {
2596
+ className: "shg-resize-col shg-resize-in-cell",
2597
+ onClick: (e) => e.stopPropagation(),
2598
+ onMouseDown: (e) => startResize(
2599
+ e,
2600
+ "col",
2601
+ col.id,
2602
+ colWidth(col) || e.currentTarget.closest("td").offsetWidth
2603
+ )
2604
+ }
2605
+ ),
2606
+ /* @__PURE__ */ jsx13(
2607
+ "span",
2608
+ {
2609
+ className: "shg-resize-row shg-resize-in-cell",
2610
+ onClick: (e) => e.stopPropagation(),
2611
+ onMouseDown: (e) => startResize(
2612
+ e,
2613
+ "row",
2614
+ row.id,
2615
+ rowHeight(row) || e.currentTarget.closest("tr").offsetHeight
2603
2616
  )
2604
- ] })
2605
- }
2606
- )
2617
+ }
2618
+ )
2619
+ ] }),
2620
+ peer && /* @__PURE__ */ jsx13("span", { className: "shg-peer-flag", style: { background: peer.color }, children: peer.name }),
2621
+ isEditing ? renderEditor(col) : /* @__PURE__ */ jsx13("div", { className: "shg-val", children: custom !== void 0 ? custom : /* @__PURE__ */ jsxs12(Fragment8, { children: [
2622
+ computed && /* @__PURE__ */ jsx13(StatusDot, { status: c.status }),
2623
+ /* @__PURE__ */ jsx13(CellValue, { cell: c, col, fetchBlobUrl, onOpenResource }),
2624
+ computed && !readOnly && onRunCell && /* @__PURE__ */ jsx13(
2625
+ "button",
2626
+ {
2627
+ className: "shg-runcell",
2628
+ title: "Run this cell",
2629
+ onClick: (e) => {
2630
+ e.stopPropagation();
2631
+ onRunCell(row.id, col.id);
2632
+ },
2633
+ children: "\u25B6"
2634
+ }
2635
+ )
2636
+ ] }) })
2607
2637
  ]
2608
2638
  },
2609
2639
  col.id
@@ -2848,14 +2878,418 @@ function sheetToAoA(sheet, { cellText = defaultCellValue } = {}) {
2848
2878
  ];
2849
2879
  }
2850
2880
 
2881
+ // src/components/FileTypeIcon.jsx
2882
+ import { useEffect as useEffect9, useState as useState9 } from "react";
2883
+ import { jsx as jsx14 } from "react/jsx-runtime";
2884
+ function extOf(name) {
2885
+ const m = String(name || "").toLowerCase().match(/\.([a-z0-9]+)$/);
2886
+ return m ? m[1] : "";
2887
+ }
2888
+ var mod = null;
2889
+ var tried = false;
2890
+ function FileTypeIcon({ name, size = 36 }) {
2891
+ const [, force] = useState9(0);
2892
+ const ext = extOf(name);
2893
+ useEffect9(() => {
2894
+ if (tried || mod) return;
2895
+ tried = true;
2896
+ import("react-file-icon").then((m) => {
2897
+ mod = m;
2898
+ force((n) => n + 1);
2899
+ }).catch(() => {
2900
+ });
2901
+ }, []);
2902
+ const box = { width: size, height: Math.round(size * 1.16), display: "inline-block", flex: "0 0 auto" };
2903
+ if (!mod) {
2904
+ return /* @__PURE__ */ jsx14("span", { className: "uic-fileglyph", style: box, "aria-hidden": "true", children: /* @__PURE__ */ jsx14("span", { className: "uic-fileglyph-ext", children: (ext || "file").slice(0, 4) }) });
2905
+ }
2906
+ const { FileIcon, defaultStyles } = mod;
2907
+ const style = defaultStyles?.[ext] || {};
2908
+ return /* @__PURE__ */ jsx14("span", { style: box, children: /* @__PURE__ */ jsx14(FileIcon, { extension: ext || void 0, ...style }) });
2909
+ }
2910
+
2911
+ // src/components/FileCard.jsx
2912
+ import { Fragment as Fragment9 } from "react";
2913
+ import { jsx as jsx15, jsxs as jsxs13 } from "react/jsx-runtime";
2914
+ function subtitle(name, origin, bytes) {
2915
+ const parts = [(extOf(name) || "file").toUpperCase()];
2916
+ if (origin) parts.push(origin);
2917
+ if (bytes != null) parts.push(bytesLabel2(bytes));
2918
+ return parts.join(" \xB7 ");
2919
+ }
2920
+ function bytesLabel2(n) {
2921
+ if (n == null) return "";
2922
+ if (n < 1024) return `${n} B`;
2923
+ if (n < 1048576) return `${Math.round(n / 1024)} KB`;
2924
+ return `${(n / 1048576).toFixed(1)} MB`;
2925
+ }
2926
+ function FileCard({
2927
+ name,
2928
+ origin,
2929
+ bytes,
2930
+ onPreview,
2931
+ onDownload,
2932
+ compact = false,
2933
+ className = ""
2934
+ }) {
2935
+ const open = onPreview ? (e) => {
2936
+ e.stopPropagation();
2937
+ onPreview();
2938
+ } : void 0;
2939
+ return /* @__PURE__ */ jsxs13(
2940
+ "div",
2941
+ {
2942
+ className: "uic-filecard" + (compact ? " is-compact" : "") + (open ? " is-clickable" : "") + (className ? " " + className : ""),
2943
+ onClick: open,
2944
+ role: open ? "button" : void 0,
2945
+ tabIndex: open ? 0 : void 0,
2946
+ onKeyDown: open ? (e) => {
2947
+ if (e.key === "Enter" || e.key === " ") {
2948
+ e.preventDefault();
2949
+ open(e);
2950
+ }
2951
+ } : void 0,
2952
+ title: name,
2953
+ children: [
2954
+ /* @__PURE__ */ jsx15("span", { className: "uic-filecard-ic", children: /* @__PURE__ */ jsx15(FileTypeIcon, { name, size: compact ? 20 : 30 }) }),
2955
+ /* @__PURE__ */ jsxs13("span", { className: "uic-filecard-meta", children: [
2956
+ /* @__PURE__ */ jsx15("span", { className: "uic-filecard-name", children: name }),
2957
+ !compact && /* @__PURE__ */ jsx15("span", { className: "uic-filecard-sub", children: subtitle(name, origin, bytes) })
2958
+ ] }),
2959
+ /* @__PURE__ */ jsxs13(Fragment9, { children: [
2960
+ onDownload && /* @__PURE__ */ jsx15(
2961
+ "button",
2962
+ {
2963
+ type: "button",
2964
+ className: "uic-filecard-btn",
2965
+ "aria-label": `Download ${name}`,
2966
+ title: "Download",
2967
+ onClick: (e) => {
2968
+ e.stopPropagation();
2969
+ onDownload();
2970
+ },
2971
+ children: /* @__PURE__ */ jsx15(IcDownload, {})
2972
+ }
2973
+ ),
2974
+ onPreview && /* @__PURE__ */ jsx15(
2975
+ "button",
2976
+ {
2977
+ type: "button",
2978
+ className: "uic-filecard-btn",
2979
+ "aria-label": `Preview ${name}`,
2980
+ title: "Preview",
2981
+ onClick: open,
2982
+ children: /* @__PURE__ */ jsx15(IcEye, {})
2983
+ }
2984
+ )
2985
+ ] })
2986
+ ]
2987
+ }
2988
+ );
2989
+ }
2990
+
2991
+ // src/components/FilePreview.jsx
2992
+ import { useEffect as useEffect10, useState as useState10 } from "react";
2993
+ import { jsx as jsx16, jsxs as jsxs14 } from "react/jsx-runtime";
2994
+ var LANG = {
2995
+ js: "javascript",
2996
+ mjs: "javascript",
2997
+ cjs: "javascript",
2998
+ jsx: "javascript",
2999
+ ts: "typescript",
3000
+ tsx: "typescript",
3001
+ py: "python",
3002
+ rb: "ruby",
3003
+ go: "go",
3004
+ rs: "rust",
3005
+ java: "java",
3006
+ c: "c",
3007
+ h: "c",
3008
+ cpp: "cpp",
3009
+ hpp: "cpp",
3010
+ cs: "csharp",
3011
+ php: "php",
3012
+ swift: "swift",
3013
+ kt: "kotlin",
3014
+ scala: "scala",
3015
+ sh: "bash",
3016
+ bash: "bash",
3017
+ zsh: "bash",
3018
+ sql: "sql",
3019
+ css: "css",
3020
+ scss: "scss",
3021
+ less: "less",
3022
+ html: "xml",
3023
+ htm: "xml",
3024
+ xml: "xml",
3025
+ svg: "xml",
3026
+ json: "json",
3027
+ yaml: "yaml",
3028
+ yml: "yaml",
3029
+ toml: "ini",
3030
+ ini: "ini",
3031
+ r: "r",
3032
+ lua: "lua",
3033
+ pl: "perl",
3034
+ dockerfile: "dockerfile",
3035
+ diff: "diff"
3036
+ };
3037
+ var OFFICE = /* @__PURE__ */ new Set(["pptx", "ppt", "pptm", "odp", "doc", "docx", "odt", "rtf"]);
3038
+ var SHEET = /* @__PURE__ */ new Set(["xls", "xlsx", "xlsm", "xlsb", "ods"]);
3039
+ function kindOf(name, mime = "") {
3040
+ const e = extOf(name);
3041
+ if (mime.startsWith("image/") || /^(png|jpe?g|gif|webp|svg|bmp|ico|avif)$/.test(e)) return "image";
3042
+ if (mime === "application/pdf" || e === "pdf") return "pdf";
3043
+ if (mime.startsWith("video/") || ["mp4", "webm", "mov", "m4v"].includes(e)) return "video";
3044
+ if (mime.startsWith("audio/") || ["mp3", "wav", "ogg", "m4a", "flac"].includes(e)) return "audio";
3045
+ if (e === "csv" || e === "tsv") return "csv";
3046
+ if (e === "md" || e === "markdown") return "markdown";
3047
+ if (SHEET.has(e)) return "sheet";
3048
+ if (OFFICE.has(e)) return "office";
3049
+ if (mime.startsWith("text/") || LANG[e] || /^(txt|log|env|conf|cfg|gitignore)$/.test(e)) return "code";
3050
+ return "binary";
3051
+ }
3052
+ function delimitedToRows(text, sep) {
3053
+ return text.split(/\r?\n/).filter((l) => l.length).slice(0, 1e3).map((line) => {
3054
+ const out = [];
3055
+ let cur = "";
3056
+ let q = false;
3057
+ for (const ch of line) {
3058
+ if (ch === '"') q = !q;
3059
+ else if (ch === sep && !q) {
3060
+ out.push(cur);
3061
+ cur = "";
3062
+ } else cur += ch;
3063
+ }
3064
+ out.push(cur);
3065
+ return out.map((c) => c.replace(/^"|"$/g, ""));
3066
+ });
3067
+ }
3068
+ function Grid({ rows }) {
3069
+ if (!rows?.length) return /* @__PURE__ */ jsx16("div", { className: "uic-fp-empty", children: "This file is empty." });
3070
+ const [head, ...body] = rows;
3071
+ return /* @__PURE__ */ jsx16("div", { className: "uic-fp-sheet", children: /* @__PURE__ */ jsxs14("table", { children: [
3072
+ /* @__PURE__ */ jsx16("thead", { children: /* @__PURE__ */ jsx16("tr", { children: head.map((c, i) => /* @__PURE__ */ jsx16("th", { children: c }, i)) }) }),
3073
+ /* @__PURE__ */ jsx16("tbody", { children: body.map((r, i) => /* @__PURE__ */ jsx16("tr", { children: r.map((c, j) => /* @__PURE__ */ jsx16("td", { children: c }, j)) }, i)) })
3074
+ ] }) });
3075
+ }
3076
+ var defaultDownload = (url, name) => {
3077
+ const a = document.createElement("a");
3078
+ a.href = url;
3079
+ a.download = name;
3080
+ a.rel = "noreferrer";
3081
+ document.body.appendChild(a);
3082
+ a.click();
3083
+ a.remove();
3084
+ };
3085
+ function FilePreview({
3086
+ file,
3087
+ onClose,
3088
+ fetchFile,
3089
+ officePdfUrl,
3090
+ renderMarkdown,
3091
+ onDownload,
3092
+ title
3093
+ }) {
3094
+ const { url, name } = file || {};
3095
+ const [st, setSt] = useState10({ kind: "loading" });
3096
+ const [tab, setTab] = useState10(0);
3097
+ useEffect10(() => {
3098
+ if (!url) return void 0;
3099
+ let alive = true;
3100
+ let obj;
3101
+ setSt({ kind: "loading" });
3102
+ setTab(0);
3103
+ const get = fetchFile || ((u) => fetch(u, { cache: "no-store" }));
3104
+ (async () => {
3105
+ const res = await get(url);
3106
+ if (!res.ok) throw new Error(`${res.status}`);
3107
+ const mime = (res.headers.get("content-type") || "").toLowerCase();
3108
+ const kind = kindOf(name, mime);
3109
+ if (kind === "office") {
3110
+ if (!officePdfUrl) {
3111
+ setSt({ kind: "binary", error: "This format has no inline preview here \u2014 download it to open it." });
3112
+ return;
3113
+ }
3114
+ const r = await get(officePdfUrl(url));
3115
+ if (!r.ok) throw new Error(`${r.status}`);
3116
+ obj = URL.createObjectURL(await r.blob());
3117
+ if (alive) setSt({ kind: "pdf", objUrl: obj });
3118
+ return;
3119
+ }
3120
+ if (kind === "sheet") {
3121
+ try {
3122
+ const buf = await res.arrayBuffer();
3123
+ const XLSX = await import("xlsx");
3124
+ const wb = XLSX.read(buf, { type: "array" });
3125
+ const sheets = wb.SheetNames.map((n) => {
3126
+ const ws = wb.Sheets[n] || {};
3127
+ const filled = Boolean(ws["!ref"]);
3128
+ return { name: n, filled, rows: filled ? XLSX.utils.sheet_to_json(ws, { header: 1, raw: false }) : [] };
3129
+ });
3130
+ const first = sheets.findIndex((s) => s.filled);
3131
+ if (alive) {
3132
+ setTab(first < 0 ? 0 : first);
3133
+ setSt({ kind: "sheet", sheets });
3134
+ }
3135
+ } catch (e) {
3136
+ if (alive) setSt({ kind: "binary", error: `This spreadsheet couldn\u2019t be read (${String(e?.message || "parse failed").slice(0, 80)}).` });
3137
+ }
3138
+ return;
3139
+ }
3140
+ if (kind === "csv" || kind === "markdown" || kind === "code") {
3141
+ const text = await res.text();
3142
+ if (!alive) return;
3143
+ if (kind === "csv") setSt({ kind: "csv", rows: delimitedToRows(text, extOf(name) === "tsv" ? " " : ",") });
3144
+ else setSt({ kind, text: text.slice(0, 4e5) });
3145
+ return;
3146
+ }
3147
+ if (kind === "binary") {
3148
+ if (alive) setSt({ kind: "binary" });
3149
+ return;
3150
+ }
3151
+ obj = URL.createObjectURL(await res.blob());
3152
+ if (alive) setSt({ kind, objUrl: obj });
3153
+ })().catch(() => {
3154
+ if (alive) setSt({ kind: "binary", error: "Could not load this file." });
3155
+ });
3156
+ return () => {
3157
+ alive = false;
3158
+ if (obj) URL.revokeObjectURL(obj);
3159
+ };
3160
+ }, [url, name, fetchFile, officePdfUrl]);
3161
+ const download = () => onDownload ? onDownload(url, name) : defaultDownload(url, name);
3162
+ return /* @__PURE__ */ jsxs14("aside", { className: "uic-fp", "aria-label": title || `Preview of ${name}`, children: [
3163
+ /* @__PURE__ */ jsxs14("header", { className: "uic-fp-head", children: [
3164
+ /* @__PURE__ */ jsx16("span", { className: "uic-fp-ic", children: /* @__PURE__ */ jsx16(FileTypeIcon, { name, size: 20 }) }),
3165
+ /* @__PURE__ */ jsx16("span", { className: "uic-fp-name", title: name, children: name }),
3166
+ /* @__PURE__ */ jsx16(
3167
+ "button",
3168
+ {
3169
+ type: "button",
3170
+ className: "uic-fp-btn",
3171
+ "aria-label": `Download ${name}`,
3172
+ title: "Download",
3173
+ onClick: download,
3174
+ children: /* @__PURE__ */ jsx16(IcDownload, {})
3175
+ }
3176
+ ),
3177
+ onClose && /* @__PURE__ */ jsx16(
3178
+ "button",
3179
+ {
3180
+ type: "button",
3181
+ className: "uic-fp-btn",
3182
+ "aria-label": "Close preview",
3183
+ title: "Close",
3184
+ onClick: onClose,
3185
+ children: /* @__PURE__ */ jsx16(IcX, { size: 18 })
3186
+ }
3187
+ )
3188
+ ] }),
3189
+ /* @__PURE__ */ jsxs14("div", { className: "uic-fp-body", children: [
3190
+ st.kind === "loading" && /* @__PURE__ */ jsx16("div", { className: "uic-fp-pad", children: /* @__PURE__ */ jsx16("span", { className: "uic-skel uic-fp-skel" }) }),
3191
+ st.kind === "image" && st.objUrl && /* @__PURE__ */ jsx16("div", { className: "uic-fp-center", children: /* @__PURE__ */ jsx16("img", { className: "uic-fp-img", src: st.objUrl, alt: name }) }),
3192
+ st.kind === "pdf" && st.objUrl && /* @__PURE__ */ jsx16("iframe", { className: "uic-fp-frame", src: st.objUrl, title: name }),
3193
+ st.kind === "video" && st.objUrl && /* @__PURE__ */ jsx16("div", { className: "uic-fp-center", children: /* @__PURE__ */ jsx16("video", { className: "uic-fp-media", src: st.objUrl, controls: true }) }),
3194
+ st.kind === "audio" && st.objUrl && /* @__PURE__ */ jsx16("div", { className: "uic-fp-center", children: /* @__PURE__ */ jsx16("audio", { src: st.objUrl, controls: true }) }),
3195
+ st.kind === "markdown" && /* @__PURE__ */ jsx16("div", { className: "uic-fp-doc", children: renderMarkdown ? renderMarkdown(st.text || "") : /* @__PURE__ */ jsx16("pre", { className: "uic-fp-pre", children: st.text }) }),
3196
+ st.kind === "code" && /* @__PURE__ */ jsx16(CodeBlock, { code: st.text || "", lang: LANG[extOf(name)] || "plaintext" }),
3197
+ st.kind === "csv" && /* @__PURE__ */ jsx16(Grid, { rows: st.rows }),
3198
+ st.kind === "sheet" && st.sheets && /* @__PURE__ */ jsxs14("div", { className: "uic-fp-xlsx", children: [
3199
+ st.sheets[tab]?.filled ? /* @__PURE__ */ jsx16(Grid, { rows: st.sheets[tab].rows }) : /* @__PURE__ */ jsx16("div", { className: "uic-fp-empty", children: "This sheet is empty." }),
3200
+ /* @__PURE__ */ jsx16("div", { className: "uic-fp-tabs", children: st.sheets.map((s, i) => /* @__PURE__ */ jsx16(
3201
+ "button",
3202
+ {
3203
+ type: "button",
3204
+ className: "uic-fp-tab" + (i === tab ? " is-on" : "") + (s.filled ? "" : " is-empty"),
3205
+ onClick: () => setTab(i),
3206
+ title: s.filled ? s.name : `${s.name} (empty)`,
3207
+ children: s.name
3208
+ },
3209
+ s.name + i
3210
+ )) })
3211
+ ] }),
3212
+ st.kind === "binary" && /* @__PURE__ */ jsx16("div", { className: "uic-fp-center", children: /* @__PURE__ */ jsxs14("div", { className: "uic-fp-fallback", children: [
3213
+ /* @__PURE__ */ jsx16(FileTypeIcon, { name, size: 56 }),
3214
+ /* @__PURE__ */ jsx16("p", { children: st.error || "No inline preview for this file type." }),
3215
+ /* @__PURE__ */ jsx16("button", { type: "button", className: "uic-fp-dl", onClick: download, children: "Download" })
3216
+ ] }) })
3217
+ ] })
3218
+ ] });
3219
+ }
3220
+
3221
+ // src/components/form.jsx
3222
+ import { useId as useId2 } from "react";
3223
+ import { jsx as jsx17, jsxs as jsxs15 } from "react/jsx-runtime";
3224
+ function Field({ label, hint, error, htmlFor, required, children, className = "" }) {
3225
+ return /* @__PURE__ */ jsxs15("div", { className: "uic-field" + (error ? " is-error" : "") + (className ? " " + className : ""), children: [
3226
+ label && /* @__PURE__ */ jsxs15("label", { className: "uic-field-label", htmlFor, children: [
3227
+ label,
3228
+ required && /* @__PURE__ */ jsx17("span", { className: "uic-field-req", "aria-hidden": "true", children: "*" })
3229
+ ] }),
3230
+ children,
3231
+ error ? /* @__PURE__ */ jsx17("p", { className: "uic-field-err", children: error }) : hint ? /* @__PURE__ */ jsx17("p", { className: "uic-field-hint", children: hint }) : null
3232
+ ] });
3233
+ }
3234
+ function withField(Control) {
3235
+ return function Fielded({ label, hint, error, required, id, className, ...rest }) {
3236
+ const auto = useId2();
3237
+ const inputId = id || auto;
3238
+ return /* @__PURE__ */ jsx17(Field, { label, hint, error, required, htmlFor: inputId, className, children: /* @__PURE__ */ jsx17(Control, { id: inputId, invalid: !!error, required, ...rest }) });
3239
+ };
3240
+ }
3241
+ function BareInput({ invalid, ...rest }) {
3242
+ return /* @__PURE__ */ jsx17("input", { className: "uic-input" + (invalid ? " is-error" : ""), "aria-invalid": invalid || void 0, ...rest });
3243
+ }
3244
+ function BareTextarea({ invalid, rows = 4, ...rest }) {
3245
+ return /* @__PURE__ */ jsx17(
3246
+ "textarea",
3247
+ {
3248
+ className: "uic-input uic-textarea" + (invalid ? " is-error" : ""),
3249
+ rows,
3250
+ "aria-invalid": invalid || void 0,
3251
+ ...rest
3252
+ }
3253
+ );
3254
+ }
3255
+ function BareSelect({ invalid, options = [], placeholder, ...rest }) {
3256
+ return /* @__PURE__ */ jsxs15("span", { className: "uic-select-wrap", children: [
3257
+ /* @__PURE__ */ jsxs15(
3258
+ "select",
3259
+ {
3260
+ className: "uic-input uic-select" + (invalid ? " is-error" : ""),
3261
+ "aria-invalid": invalid || void 0,
3262
+ ...rest,
3263
+ children: [
3264
+ placeholder && /* @__PURE__ */ jsx17("option", { value: "", children: placeholder }),
3265
+ options.map((o) => {
3266
+ const opt = typeof o === "string" ? { value: o, label: o } : o;
3267
+ return /* @__PURE__ */ jsx17("option", { value: opt.value, disabled: opt.disabled, children: opt.label }, opt.value);
3268
+ })
3269
+ ]
3270
+ }
3271
+ ),
3272
+ /* @__PURE__ */ jsx17("span", { className: "uic-select-chev", "aria-hidden": "true", children: /* @__PURE__ */ jsx17(Chevron, { dir: "down", size: 14 }) })
3273
+ ] });
3274
+ }
3275
+ var Input = withField(BareInput);
3276
+ var Textarea = withField(BareTextarea);
3277
+ var Select = withField(BareSelect);
3278
+ function FormActions({ children, align = "end", className = "" }) {
3279
+ return /* @__PURE__ */ jsx17("div", { className: `uic-form-actions is-${align}${className ? " " + className : ""}`, children });
3280
+ }
3281
+ function Button({ variant = "default", size = "md", type = "button", className = "", ...rest }) {
3282
+ return /* @__PURE__ */ jsx17("button", { type, className: `uic-btn is-${variant} is-${size}${className ? " " + className : ""}`, ...rest });
3283
+ }
3284
+
2851
3285
  // src/components/Carousel.jsx
2852
- import React9, { useCallback as useCallback5, useEffect as useEffect9, useRef as useRef8, useState as useState9 } from "react";
2853
- import { jsx as jsx14, jsxs as jsxs13 } from "react/jsx-runtime";
3286
+ import React9, { useCallback as useCallback5, useEffect as useEffect11, useRef as useRef8, useState as useState11 } from "react";
3287
+ import { jsx as jsx18, jsxs as jsxs16 } from "react/jsx-runtime";
2854
3288
  var EDGE = 2;
2855
3289
  function Carousel(props) {
2856
3290
  const { label, step, children, classNames = {} } = props;
2857
3291
  const ref = useRef8(null);
2858
- const [edges, setEdges] = useState9({ start: true, end: true, overflow: false });
3292
+ const [edges, setEdges] = useState11({ start: true, end: true, overflow: false });
2859
3293
  const measure = useCallback5(() => {
2860
3294
  const el = ref.current;
2861
3295
  if (!el) return;
@@ -2866,7 +3300,7 @@ function Carousel(props) {
2866
3300
  end: el.scrollLeft >= el.scrollWidth - el.clientWidth - EDGE
2867
3301
  });
2868
3302
  }, []);
2869
- useEffect9(() => {
3303
+ useEffect11(() => {
2870
3304
  const el = ref.current;
2871
3305
  if (!el) return void 0;
2872
3306
  measure();
@@ -2880,8 +3314,8 @@ function Carousel(props) {
2880
3314
  if (!el) return;
2881
3315
  el.scrollBy({ left: dir * (step || Math.round(el.clientWidth * 0.9)), behavior: "smooth" });
2882
3316
  };
2883
- return /* @__PURE__ */ jsxs13("div", { className: ["uic-carousel-wrap", classNames.root || ""].filter(Boolean).join(" "), children: [
2884
- edges.overflow ? /* @__PURE__ */ jsx14(
3317
+ return /* @__PURE__ */ jsxs16("div", { className: ["uic-carousel-wrap", classNames.root || ""].filter(Boolean).join(" "), children: [
3318
+ edges.overflow ? /* @__PURE__ */ jsx18(
2885
3319
  "button",
2886
3320
  {
2887
3321
  type: "button",
@@ -2889,10 +3323,10 @@ function Carousel(props) {
2889
3323
  onClick: () => scroll(-1),
2890
3324
  disabled: edges.start,
2891
3325
  "aria-label": `Scroll ${label} left`,
2892
- children: /* @__PURE__ */ jsx14(Chevron, { dir: "left" })
3326
+ children: /* @__PURE__ */ jsx18(Chevron, { dir: "left" })
2893
3327
  }
2894
3328
  ) : null,
2895
- /* @__PURE__ */ jsx14(
3329
+ /* @__PURE__ */ jsx18(
2896
3330
  "div",
2897
3331
  {
2898
3332
  className: ["uic-carousel", classNames.viewport || ""].filter(Boolean).join(" "),
@@ -2903,7 +3337,7 @@ function Carousel(props) {
2903
3337
  children
2904
3338
  }
2905
3339
  ),
2906
- edges.overflow ? /* @__PURE__ */ jsx14(
3340
+ edges.overflow ? /* @__PURE__ */ jsx18(
2907
3341
  "button",
2908
3342
  {
2909
3343
  type: "button",
@@ -2911,7 +3345,7 @@ function Carousel(props) {
2911
3345
  onClick: () => scroll(1),
2912
3346
  disabled: edges.end,
2913
3347
  "aria-label": `Scroll ${label} right`,
2914
- children: /* @__PURE__ */ jsx14(Chevron, { dir: "right" })
3348
+ children: /* @__PURE__ */ jsx18(Chevron, { dir: "right" })
2915
3349
  }
2916
3350
  ) : null
2917
3351
  ] });
@@ -2919,34 +3353,34 @@ function Carousel(props) {
2919
3353
 
2920
3354
  // src/components/Card.jsx
2921
3355
  import React10 from "react";
2922
- import { jsx as jsx15, jsxs as jsxs14 } from "react/jsx-runtime";
3356
+ import { jsx as jsx19, jsxs as jsxs17 } from "react/jsx-runtime";
2923
3357
  function Card(props) {
2924
- const { art, title, subtitle, onClick, selected = false, overlay, actions, classNames = {} } = props;
2925
- const foot = /* @__PURE__ */ jsxs14("span", { className: "uic-card-foot", children: [
2926
- /* @__PURE__ */ jsx15("span", { className: "uic-card-name", children: title }),
2927
- subtitle ? /* @__PURE__ */ jsx15("span", { className: "uic-card-sub", children: subtitle }) : null
3358
+ const { art, title, subtitle: subtitle2, onClick, selected = false, overlay, actions, classNames = {} } = props;
3359
+ const foot = /* @__PURE__ */ jsxs17("span", { className: "uic-card-foot", children: [
3360
+ /* @__PURE__ */ jsx19("span", { className: "uic-card-name", children: title }),
3361
+ subtitle2 ? /* @__PURE__ */ jsx19("span", { className: "uic-card-sub", children: subtitle2 }) : null
2928
3362
  ] });
2929
- return /* @__PURE__ */ jsxs14("div", { className: ["uic-card", selected ? "is-selected" : "", classNames.root || ""].filter(Boolean).join(" "), children: [
2930
- onClick ? /* @__PURE__ */ jsxs14("button", { type: "button", className: "uic-card-main", onClick, "aria-pressed": selected || void 0, children: [
2931
- /* @__PURE__ */ jsx15("span", { className: "uic-card-art", children: art }),
3363
+ return /* @__PURE__ */ jsxs17("div", { className: ["uic-card", selected ? "is-selected" : "", classNames.root || ""].filter(Boolean).join(" "), children: [
3364
+ onClick ? /* @__PURE__ */ jsxs17("button", { type: "button", className: "uic-card-main", onClick, "aria-pressed": selected || void 0, children: [
3365
+ /* @__PURE__ */ jsx19("span", { className: "uic-card-art", children: art }),
2932
3366
  foot
2933
- ] }) : /* @__PURE__ */ jsxs14("div", { className: "uic-card-main", children: [
2934
- /* @__PURE__ */ jsx15("span", { className: "uic-card-art", children: art }),
3367
+ ] }) : /* @__PURE__ */ jsxs17("div", { className: "uic-card-main", children: [
3368
+ /* @__PURE__ */ jsx19("span", { className: "uic-card-art", children: art }),
2935
3369
  foot
2936
3370
  ] }),
2937
- overlay ? /* @__PURE__ */ jsx15("div", { className: "uic-card-overlay", children: overlay }) : null,
2938
- actions ? /* @__PURE__ */ jsx15("div", { className: "uic-card-actions", children: actions }) : null
3371
+ overlay ? /* @__PURE__ */ jsx19("div", { className: "uic-card-overlay", children: overlay }) : null,
3372
+ actions ? /* @__PURE__ */ jsx19("div", { className: "uic-card-actions", children: actions }) : null
2939
3373
  ] });
2940
3374
  }
2941
3375
 
2942
3376
  // src/components/SearchField.jsx
2943
3377
  import React11 from "react";
2944
- import { jsx as jsx16, jsxs as jsxs15 } from "react/jsx-runtime";
3378
+ import { jsx as jsx20, jsxs as jsxs18 } from "react/jsx-runtime";
2945
3379
  function SearchField(props) {
2946
3380
  const { value, onChange, placeholder, clearLabel = "Clear search", className } = props;
2947
- return /* @__PURE__ */ jsxs15("label", { className: ["uic-search", className || ""].filter(Boolean).join(" "), children: [
2948
- /* @__PURE__ */ jsx16("span", { className: "uic-search-ic", "aria-hidden": "true", children: /* @__PURE__ */ jsx16(IcSearch, {}) }),
2949
- /* @__PURE__ */ jsx16(
3381
+ return /* @__PURE__ */ jsxs18("label", { className: ["uic-search", className || ""].filter(Boolean).join(" "), children: [
3382
+ /* @__PURE__ */ jsx20("span", { className: "uic-search-ic", "aria-hidden": "true", children: /* @__PURE__ */ jsx20(IcSearch, {}) }),
3383
+ /* @__PURE__ */ jsx20(
2950
3384
  "input",
2951
3385
  {
2952
3386
  type: "search",
@@ -2956,14 +3390,14 @@ function SearchField(props) {
2956
3390
  onChange: (e) => onChange(e.target.value)
2957
3391
  }
2958
3392
  ),
2959
- value ? /* @__PURE__ */ jsx16("button", { type: "button", className: "uic-search-x", "aria-label": clearLabel, onClick: () => onChange(""), children: /* @__PURE__ */ jsx16(IcX, { size: 12 }) }) : null
3393
+ value ? /* @__PURE__ */ jsx20("button", { type: "button", className: "uic-search-x", "aria-label": clearLabel, onClick: () => onChange(""), children: /* @__PURE__ */ jsx20(IcX, { size: 12 }) }) : null
2960
3394
  ] });
2961
3395
  }
2962
3396
 
2963
3397
  // src/components/Popover.jsx
2964
- import React12, { useCallback as useCallback6, useEffect as useEffect10, useRef as useRef9, useState as useState10 } from "react";
3398
+ import React12, { useCallback as useCallback6, useEffect as useEffect12, useRef as useRef9, useState as useState12 } from "react";
2965
3399
  import { createPortal as createPortal3 } from "react-dom";
2966
- import { jsx as jsx17 } from "react/jsx-runtime";
3400
+ import { jsx as jsx21 } from "react/jsx-runtime";
2967
3401
  var GAP = 6;
2968
3402
  var MARGIN = 8;
2969
3403
  function Popover(props) {
@@ -2979,8 +3413,8 @@ function Popover(props) {
2979
3413
  label
2980
3414
  } = props;
2981
3415
  const popRef = useRef9(null);
2982
- const [pos, setPos] = useState10(null);
2983
- useEffect10(() => {
3416
+ const [pos, setPos] = useState12(null);
3417
+ useEffect12(() => {
2984
3418
  if (!open) {
2985
3419
  setPos(null);
2986
3420
  return void 0;
@@ -3007,7 +3441,7 @@ function Popover(props) {
3007
3441
  window.removeEventListener("scroll", place, true);
3008
3442
  };
3009
3443
  }, [open, anchorRef, width, minHeight, placement]);
3010
- useEffect10(() => {
3444
+ useEffect12(() => {
3011
3445
  if (!open) return void 0;
3012
3446
  const onDown = (e) => {
3013
3447
  if (popRef.current?.contains(e.target)) return;
@@ -3021,7 +3455,7 @@ function Popover(props) {
3021
3455
  useOverlayEscape(open, escape);
3022
3456
  if (!open || !pos || typeof document === "undefined") return null;
3023
3457
  return createPortal3(
3024
- /* @__PURE__ */ jsx17(
3458
+ /* @__PURE__ */ jsx21(
3025
3459
  "div",
3026
3460
  {
3027
3461
  ref: popRef,
@@ -3037,9 +3471,9 @@ function Popover(props) {
3037
3471
  }
3038
3472
 
3039
3473
  // src/components/Modal.jsx
3040
- import React13, { useCallback as useCallback7, useEffect as useEffect11, useId as useId2 } from "react";
3474
+ import React13, { useCallback as useCallback7, useEffect as useEffect13, useId as useId3 } from "react";
3041
3475
  import { createPortal as createPortal4 } from "react-dom";
3042
- import { jsx as jsx18, jsxs as jsxs16 } from "react/jsx-runtime";
3476
+ import { jsx as jsx22, jsxs as jsxs19 } from "react/jsx-runtime";
3043
3477
  function Modal(props) {
3044
3478
  const {
3045
3479
  open,
@@ -3053,10 +3487,10 @@ function Modal(props) {
3053
3487
  children,
3054
3488
  classNames = {}
3055
3489
  } = props;
3056
- const titleId = useId2();
3490
+ const titleId = useId3();
3057
3491
  const escape = useCallback7(() => onClose?.(), [onClose]);
3058
3492
  useOverlayEscape(open, escape);
3059
- useEffect11(() => {
3493
+ useEffect13(() => {
3060
3494
  if (!open || typeof document === "undefined") return void 0;
3061
3495
  const prev = document.body.style.overflow;
3062
3496
  document.body.style.overflow = "hidden";
@@ -3069,12 +3503,12 @@ function Modal(props) {
3069
3503
  if (e.target === e.currentTarget) onClose?.();
3070
3504
  };
3071
3505
  return createPortal4(
3072
- /* @__PURE__ */ jsx18(
3506
+ /* @__PURE__ */ jsx22(
3073
3507
  "div",
3074
3508
  {
3075
3509
  className: ["uic-modal-backdrop", classNames.backdrop || ""].filter(Boolean).join(" "),
3076
3510
  onMouseDown: onBackdrop,
3077
- children: /* @__PURE__ */ jsxs16(
3511
+ children: /* @__PURE__ */ jsxs19(
3078
3512
  "div",
3079
3513
  {
3080
3514
  className: ["uic-modal", `is-${size}`, classNames.root || ""].filter(Boolean).join(" "),
@@ -3083,15 +3517,15 @@ function Modal(props) {
3083
3517
  "aria-modal": "true",
3084
3518
  "aria-labelledby": labelledBy || (title ? titleId : void 0),
3085
3519
  children: [
3086
- title || actions ? /* @__PURE__ */ jsxs16("div", { className: "uic-modal-h", children: [
3087
- /* @__PURE__ */ jsxs16("div", { className: "uic-modal-title", children: [
3088
- title ? /* @__PURE__ */ jsx18("h3", { id: titleId, children: title }) : null,
3089
- description ? /* @__PURE__ */ jsx18("p", { children: description }) : null
3520
+ title || actions ? /* @__PURE__ */ jsxs19("div", { className: "uic-modal-h", children: [
3521
+ /* @__PURE__ */ jsxs19("div", { className: "uic-modal-title", children: [
3522
+ title ? /* @__PURE__ */ jsx22("h3", { id: titleId, children: title }) : null,
3523
+ description ? /* @__PURE__ */ jsx22("p", { children: description }) : null
3090
3524
  ] }),
3091
3525
  actions,
3092
- /* @__PURE__ */ jsx18("button", { type: "button", className: "uic-modal-x", "aria-label": "Close", onClick: onClose, children: /* @__PURE__ */ jsx18(IcX, { size: 18 }) })
3526
+ /* @__PURE__ */ jsx22("button", { type: "button", className: "uic-modal-x", "aria-label": "Close", onClick: onClose, children: /* @__PURE__ */ jsx22(IcX, { size: 18 }) })
3093
3527
  ] }) : null,
3094
- /* @__PURE__ */ jsx18("div", { className: ["uic-modal-b", classNames.body || ""].filter(Boolean).join(" "), children })
3528
+ /* @__PURE__ */ jsx22("div", { className: ["uic-modal-b", classNames.body || ""].filter(Boolean).join(" "), children })
3095
3529
  ]
3096
3530
  }
3097
3531
  )
@@ -3102,15 +3536,15 @@ function Modal(props) {
3102
3536
  }
3103
3537
 
3104
3538
  // src/hooks/useTypewriter.js
3105
- import { useEffect as useEffect12, useRef as useRef10, useState as useState11 } from "react";
3539
+ import { useEffect as useEffect14, useRef as useRef10, useState as useState13 } from "react";
3106
3540
  var CHAR_MS = 26;
3107
3541
  var HOLD_MS = 2600;
3108
3542
  function useTypewriter(phrases, { active = true } = {}) {
3109
3543
  const list = phrases && phrases.length ? phrases : [""];
3110
- const [text, setText] = useState11(list[0]);
3544
+ const [text, setText] = useState13(list[0]);
3111
3545
  const listRef = useRef10(list);
3112
3546
  listRef.current = list;
3113
- useEffect12(() => {
3547
+ useEffect14(() => {
3114
3548
  if (!active) return void 0;
3115
3549
  if (typeof window === "undefined") return void 0;
3116
3550
  if (window.matchMedia?.("(prefers-reduced-motion: reduce)")?.matches) {
@@ -3142,6 +3576,7 @@ function useTypewriter(phrases, { active = true } = {}) {
3142
3576
  export {
3143
3577
  AssistantTurn,
3144
3578
  AuthForm,
3579
+ Button,
3145
3580
  Card,
3146
3581
  Carousel,
3147
3582
  ChatMessages,
@@ -3153,10 +3588,17 @@ export {
3153
3588
  Composer,
3154
3589
  DEFAULT_STATUS_LABELS,
3155
3590
  DialogHost,
3591
+ Field,
3592
+ FileCard,
3593
+ FilePreview,
3594
+ FileTypeIcon,
3595
+ FormActions,
3156
3596
  GOOGLE_ENABLED,
3157
3597
  GoogleButton,
3158
3598
  IcCheck,
3159
3599
  IcDoc,
3600
+ IcDownload,
3601
+ IcEye,
3160
3602
  IcGlobe,
3161
3603
  IcList,
3162
3604
  IcMic,
@@ -3172,14 +3614,17 @@ export {
3172
3614
  IcThink,
3173
3615
  IcTool,
3174
3616
  IcX,
3617
+ Input,
3175
3618
  Modal,
3176
3619
  PaneResizer,
3177
3620
  Popover,
3178
3621
  SESSION_EVENT,
3179
3622
  SearchField,
3623
+ Select,
3180
3624
  SheetGrid,
3181
3625
  Svg,
3182
3626
  TaskList,
3627
+ Textarea,
3183
3628
  ToolGroup,
3184
3629
  ToolRow,
3185
3630
  UserTurn,
@@ -3193,6 +3638,7 @@ export {
3193
3638
  createConversationStore,
3194
3639
  createDictation,
3195
3640
  createResponsesDispatcher,
3641
+ extOf,
3196
3642
  fetchBalance,
3197
3643
  getSession,
3198
3644
  getToken,