reifyui 0.15.2 → 0.16.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.
package/dist/index.cjs CHANGED
@@ -6010,7 +6010,13 @@ function FileTypeIcon({ name, size = 36 }) {
6010
6010
  }
6011
6011
 
6012
6012
  // src/components/FileCard.jsx
6013
+ var import_react22 = require("react");
6013
6014
  var import_jsx_runtime19 = require("react/jsx-runtime");
6015
+ var IcCopy = () => /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("svg", { width: "17", height: "17", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.9", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: [
6016
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("rect", { x: "9", y: "9", width: "11", height: "11", rx: "2" }),
6017
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("path", { d: "M5 15V6a2 2 0 0 1 2-2h9" })
6018
+ ] });
6019
+ var IcCheckMark = () => /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("svg", { width: "17", height: "17", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("path", { d: "M5 12l5 5L20 7" }) });
6014
6020
  function subtitle(name, origin, bytes) {
6015
6021
  const parts = [(extOf(name) || "file").toUpperCase()];
6016
6022
  if (origin) parts.push(origin);
@@ -6023,7 +6029,13 @@ function bytesLabel2(n) {
6023
6029
  if (n < 1048576) return `${Math.round(n / 1024)} KB`;
6024
6030
  return `${(n / 1048576).toFixed(1)} MB`;
6025
6031
  }
6026
- function FileCard({ name, origin = "output", bytes, onPreview, onDownload, className = "" }) {
6032
+ function FileCard({ name, origin = "output", bytes, onPreview, onDownload, onCopy, active = false, thumb, className = "" }) {
6033
+ const [copied, setCopied] = (0, import_react22.useState)("");
6034
+ (0, import_react22.useEffect)(() => {
6035
+ if (!copied) return void 0;
6036
+ const t = setTimeout(() => setCopied(""), 1600);
6037
+ return () => clearTimeout(t);
6038
+ }, [copied]);
6027
6039
  const open = onPreview ? (e) => {
6028
6040
  e.stopPropagation();
6029
6041
  onPreview();
@@ -6031,7 +6043,8 @@ function FileCard({ name, origin = "output", bytes, onPreview, onDownload, class
6031
6043
  return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
6032
6044
  "div",
6033
6045
  {
6034
- className: "uic-filecard" + (open ? " is-clickable" : "") + (className ? " " + className : ""),
6046
+ className: "uic-filecard" + (open ? " is-clickable" : "") + (active ? " is-active" : "") + (className ? " " + className : ""),
6047
+ "aria-current": active ? "true" : void 0,
6035
6048
  onClick: open,
6036
6049
  role: open ? "button" : void 0,
6037
6050
  tabIndex: open ? 0 : void 0,
@@ -6043,11 +6056,30 @@ function FileCard({ name, origin = "output", bytes, onPreview, onDownload, class
6043
6056
  } : void 0,
6044
6057
  title: name,
6045
6058
  children: [
6046
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "uic-filecard-ic", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(FileTypeIcon, { name, size: 32 }) }),
6059
+ thumb ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "uic-filecard-thumb", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("img", { src: thumb, alt: "" }) }) : /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "uic-filecard-ic", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(FileTypeIcon, { name, size: 32 }) }),
6047
6060
  /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("span", { className: "uic-filecard-meta", children: [
6048
6061
  /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "uic-filecard-name", children: name }),
6049
6062
  /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "uic-filecard-sub", children: subtitle(name, origin, bytes) })
6050
6063
  ] }),
6064
+ onCopy && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
6065
+ "button",
6066
+ {
6067
+ type: "button",
6068
+ className: "uic-filecard-dl uic-filecard-copy",
6069
+ "aria-label": copied === "ok" ? "Copied" : `Copy ${name}`,
6070
+ title: copied === "ok" ? "Copied" : copied === "no" ? "Could not copy" : "Copy",
6071
+ onClick: async (e) => {
6072
+ e.stopPropagation();
6073
+ try {
6074
+ await onCopy();
6075
+ setCopied("ok");
6076
+ } catch {
6077
+ setCopied("no");
6078
+ }
6079
+ },
6080
+ children: copied === "ok" ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(IcCheckMark, {}) : /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(IcCopy, {})
6081
+ }
6082
+ ),
6051
6083
  onDownload && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
6052
6084
  "button",
6053
6085
  {
@@ -6069,7 +6101,7 @@ function FileCard({ name, origin = "output", bytes, onPreview, onDownload, class
6069
6101
  }
6070
6102
 
6071
6103
  // src/components/FilePreview.jsx
6072
- var import_react22 = require("react");
6104
+ var import_react23 = require("react");
6073
6105
  var import_jsx_runtime20 = require("react/jsx-runtime");
6074
6106
  var LANG = {
6075
6107
  js: "javascript",
@@ -6175,13 +6207,14 @@ function FilePreview({
6175
6207
  renderMarkdown,
6176
6208
  parseWorkbook,
6177
6209
  onDownload,
6178
- title
6210
+ title,
6211
+ before
6179
6212
  }) {
6180
6213
  const { url, name } = file || {};
6181
- const [st, setSt] = (0, import_react22.useState)({ kind: "loading" });
6182
- const [tab, setTab] = (0, import_react22.useState)(0);
6183
- const [view, setView] = (0, import_react22.useState)("preview");
6184
- (0, import_react22.useEffect)(() => {
6214
+ const [st, setSt] = (0, import_react23.useState)({ kind: "loading" });
6215
+ const [tab, setTab] = (0, import_react23.useState)(0);
6216
+ const [view, setView] = (0, import_react23.useState)("preview");
6217
+ (0, import_react23.useEffect)(() => {
6185
6218
  if (!url) return void 0;
6186
6219
  let alive = true;
6187
6220
  let obj;
@@ -6244,7 +6277,23 @@ function FilePreview({
6244
6277
  };
6245
6278
  }, [url, name, fetchFile, officePdfUrl, parseWorkbook]);
6246
6279
  const download = () => onDownload ? onDownload(url, name) : defaultDownload(url, name);
6280
+ const [copied, setCopied] = (0, import_react23.useState)("");
6281
+ (0, import_react23.useEffect)(() => {
6282
+ if (!copied) return void 0;
6283
+ const t = setTimeout(() => setCopied(""), 1600);
6284
+ return () => clearTimeout(t);
6285
+ }, [copied]);
6286
+ const copyText = typeof st.text === "string" ? st.text : null;
6287
+ const copy = async () => {
6288
+ try {
6289
+ await navigator.clipboard.writeText(copyText || "");
6290
+ setCopied("ok");
6291
+ } catch {
6292
+ setCopied("no");
6293
+ }
6294
+ };
6247
6295
  return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("aside", { className: "uic-fp", "aria-label": title || `Preview of ${name}`, children: [
6296
+ before,
6248
6297
  /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("header", { className: "uic-fp-head", children: [
6249
6298
  /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { className: "uic-fp-ic", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(FileTypeIcon, { name, size: 20 }) }),
6250
6299
  /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { className: "uic-fp-name", title: name, children: name }),
@@ -6260,6 +6309,20 @@ function FilePreview({
6260
6309
  },
6261
6310
  id
6262
6311
  )) }),
6312
+ copyText != null && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
6313
+ "button",
6314
+ {
6315
+ type: "button",
6316
+ className: "uic-fp-btn uic-fp-copy",
6317
+ "aria-label": copied === "ok" ? "Copied" : `Copy ${name}`,
6318
+ title: copied === "ok" ? "Copied" : copied === "no" ? "Could not copy" : "Copy",
6319
+ onClick: copy,
6320
+ children: copied === "ok" ? /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("path", { d: "M5 12l5 5L20 7" }) }) : /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.9", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: [
6321
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("rect", { x: "9", y: "9", width: "11", height: "11", rx: "2" }),
6322
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("path", { d: "M5 15V6a2 2 0 0 1 2-2h9" })
6323
+ ] })
6324
+ }
6325
+ ),
6263
6326
  /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
6264
6327
  "button",
6265
6328
  {
@@ -6320,7 +6383,7 @@ function FilePreview({
6320
6383
  }
6321
6384
 
6322
6385
  // src/components/form.jsx
6323
- var import_react23 = require("react");
6386
+ var import_react24 = require("react");
6324
6387
  var import_jsx_runtime21 = require("react/jsx-runtime");
6325
6388
  function Field({ label, hint, error, htmlFor, required, children, className = "" }) {
6326
6389
  return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "uic-field" + (error ? " is-error" : "") + (className ? " " + className : ""), children: [
@@ -6334,7 +6397,7 @@ function Field({ label, hint, error, htmlFor, required, children, className = ""
6334
6397
  }
6335
6398
  function withField(Control) {
6336
6399
  return function Fielded({ label, hint, error, required, id, className, ...rest }) {
6337
- const auto = (0, import_react23.useId)();
6400
+ const auto = (0, import_react24.useId)();
6338
6401
  const inputId = id || auto;
6339
6402
  return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Field, { label, hint, error, required, htmlFor: inputId, className, children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Control, { id: inputId, invalid: !!error, required, ...rest }) });
6340
6403
  };
@@ -6384,14 +6447,14 @@ function Button({ variant = "default", size = "md", type = "button", className =
6384
6447
  }
6385
6448
 
6386
6449
  // src/components/Carousel.jsx
6387
- var import_react24 = __toESM(require("react"), 1);
6450
+ var import_react25 = __toESM(require("react"), 1);
6388
6451
  var import_jsx_runtime22 = require("react/jsx-runtime");
6389
6452
  var EDGE = 2;
6390
6453
  function Carousel(props) {
6391
6454
  const { label, step, children, classNames = {} } = props;
6392
- const ref = (0, import_react24.useRef)(null);
6393
- const [edges, setEdges] = (0, import_react24.useState)({ start: true, end: true, overflow: false });
6394
- const measure = (0, import_react24.useCallback)(() => {
6455
+ const ref = (0, import_react25.useRef)(null);
6456
+ const [edges, setEdges] = (0, import_react25.useState)({ start: true, end: true, overflow: false });
6457
+ const measure = (0, import_react25.useCallback)(() => {
6395
6458
  const el = ref.current;
6396
6459
  if (!el) return;
6397
6460
  const overflow = el.scrollWidth - el.clientWidth > EDGE;
@@ -6401,7 +6464,7 @@ function Carousel(props) {
6401
6464
  end: el.scrollLeft >= el.scrollWidth - el.clientWidth - EDGE
6402
6465
  });
6403
6466
  }, []);
6404
- (0, import_react24.useEffect)(() => {
6467
+ (0, import_react25.useEffect)(() => {
6405
6468
  const el = ref.current;
6406
6469
  if (!el) return void 0;
6407
6470
  measure();
@@ -6453,7 +6516,7 @@ function Carousel(props) {
6453
6516
  }
6454
6517
 
6455
6518
  // src/components/Card.jsx
6456
- var import_react25 = __toESM(require("react"), 1);
6519
+ var import_react26 = __toESM(require("react"), 1);
6457
6520
  var import_jsx_runtime23 = require("react/jsx-runtime");
6458
6521
  function Card(props) {
6459
6522
  const { art, title, subtitle: subtitle2, onClick, selected = false, overlay, actions, classNames = {} } = props;
@@ -6475,7 +6538,7 @@ function Card(props) {
6475
6538
  }
6476
6539
 
6477
6540
  // src/components/SearchField.jsx
6478
- var import_react26 = __toESM(require("react"), 1);
6541
+ var import_react27 = __toESM(require("react"), 1);
6479
6542
  var import_jsx_runtime24 = require("react/jsx-runtime");
6480
6543
  function SearchField(props) {
6481
6544
  const { value, onChange, placeholder, clearLabel = "Clear search", className } = props;
@@ -6496,7 +6559,7 @@ function SearchField(props) {
6496
6559
  }
6497
6560
 
6498
6561
  // src/components/CascadeMenu.jsx
6499
- var import_react27 = __toESM(require("react"), 1);
6562
+ var import_react28 = __toESM(require("react"), 1);
6500
6563
  var import_jsx_runtime25 = require("react/jsx-runtime");
6501
6564
  var Tick = () => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Svg, { s: 14, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("path", { d: "M20 6 9 17l-5-5" }) });
6502
6565
  var FILTER_PAST = 8;
@@ -6522,21 +6585,21 @@ function CascadeMenu(props) {
6522
6585
  className,
6523
6586
  value
6524
6587
  } = props;
6525
- const rootRef = (0, import_react27.useRef)(null);
6526
- const [q, setQ] = (0, import_react27.useState)("");
6527
- const [activeId, setActiveId] = (0, import_react27.useState)(null);
6528
- const [stage, setStage] = (0, import_react27.useState)("items");
6529
- const [stacked, setStacked] = (0, import_react27.useState)(false);
6530
- const visible = (0, import_react27.useMemo)(() => {
6588
+ const rootRef = (0, import_react28.useRef)(null);
6589
+ const [q, setQ] = (0, import_react28.useState)("");
6590
+ const [activeId, setActiveId] = (0, import_react28.useState)(null);
6591
+ const [stage, setStage] = (0, import_react28.useState)("items");
6592
+ const [stacked, setStacked] = (0, import_react28.useState)(false);
6593
+ const visible = (0, import_react28.useMemo)(() => {
6531
6594
  const needle = q.trim().toLowerCase();
6532
6595
  if (!needle) return groups.filter((g) => g.items.length > 0);
6533
6596
  return groups.map((g) => ({ ...g, items: g.items.filter((it) => String(it.label).toLowerCase().includes(needle)) })).filter((g) => g.items.length > 0);
6534
6597
  }, [groups, q]);
6535
- const flat = (0, import_react27.useMemo)(() => itemsOf(visible), [visible]);
6598
+ const flat = (0, import_react28.useMemo)(() => itemsOf(visible), [visible]);
6536
6599
  const active = flat.find((it) => it.id === activeId) || flat[0] || null;
6537
- const options = (0, import_react27.useMemo)(() => active && optionsOf ? optionsOf(active) : [], [active, optionsOf]);
6600
+ const options = (0, import_react28.useMemo)(() => active && optionsOf ? optionsOf(active) : [], [active, optionsOf]);
6538
6601
  const showFilter = filter === true || filter === "auto" && itemsOf(groups).length > FILTER_PAST;
6539
- (0, import_react27.useEffect)(() => {
6602
+ (0, import_react28.useEffect)(() => {
6540
6603
  if (!open) return void 0;
6541
6604
  setQ("");
6542
6605
  setActiveId(value?.item ?? null);
@@ -6555,14 +6618,14 @@ function CascadeMenu(props) {
6555
6618
  anchor?.focus?.({ preventScroll: true });
6556
6619
  };
6557
6620
  }, [open, stackBelow]);
6558
- const focusIn = (0, import_react27.useCallback)((col, index = 0) => {
6621
+ const focusIn = (0, import_react28.useCallback)((col, index = 0) => {
6559
6622
  const list = rootRef.current?.querySelectorAll(`.uic-cascade-${col} .uic-pop-item:not(:disabled)`);
6560
6623
  if (!list || !list.length) return false;
6561
6624
  const i = Math.max(0, Math.min(index, list.length - 1));
6562
6625
  list[i].focus({ preventScroll: true });
6563
6626
  return true;
6564
6627
  }, []);
6565
- const enterOptions = (0, import_react27.useCallback)(() => {
6628
+ const enterOptions = (0, import_react28.useCallback)(() => {
6566
6629
  if (stacked) {
6567
6630
  setStage("options");
6568
6631
  requestAnimationFrame(() => focusIn("options"));
@@ -6616,7 +6679,7 @@ function CascadeMenu(props) {
6616
6679
  showItems && /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "uic-cascade-col uic-cascade-items", children: [
6617
6680
  showFilter ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(SearchField, { className: "uic-cascade-filter", value: q, onChange: setQ, placeholder: filterPlaceholder }) : null,
6618
6681
  /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "uic-pop-list", children: [
6619
- visible.map((g, gi) => /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(import_react27.Fragment, { children: [
6682
+ visible.map((g, gi) => /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(import_react28.Fragment, { children: [
6620
6683
  g.label ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "uic-cascade-group", children: g.label }) : null,
6621
6684
  g.items.map((it) => {
6622
6685
  const on = active?.id === it.id;
@@ -6695,7 +6758,7 @@ function CascadeMenu(props) {
6695
6758
  }
6696
6759
 
6697
6760
  // src/components/Modal.jsx
6698
- var import_react28 = __toESM(require("react"), 1);
6761
+ var import_react29 = __toESM(require("react"), 1);
6699
6762
  var import_react_dom4 = require("react-dom");
6700
6763
  var import_jsx_runtime26 = require("react/jsx-runtime");
6701
6764
  function Modal(props) {
@@ -6711,10 +6774,10 @@ function Modal(props) {
6711
6774
  children,
6712
6775
  classNames = {}
6713
6776
  } = props;
6714
- const titleId = (0, import_react28.useId)();
6715
- const escape = (0, import_react28.useCallback)(() => onClose?.(), [onClose]);
6777
+ const titleId = (0, import_react29.useId)();
6778
+ const escape = (0, import_react29.useCallback)(() => onClose?.(), [onClose]);
6716
6779
  useOverlayEscape(open, escape);
6717
- (0, import_react28.useEffect)(() => {
6780
+ (0, import_react29.useEffect)(() => {
6718
6781
  if (!open || typeof document === "undefined") return void 0;
6719
6782
  const prev = document.body.style.overflow;
6720
6783
  document.body.style.overflow = "hidden";
@@ -6760,15 +6823,15 @@ function Modal(props) {
6760
6823
  }
6761
6824
 
6762
6825
  // src/hooks/useTypewriter.js
6763
- var import_react29 = require("react");
6826
+ var import_react30 = require("react");
6764
6827
  var CHAR_MS = 26;
6765
6828
  var HOLD_MS = 2600;
6766
6829
  function useTypewriter(phrases, { active = true } = {}) {
6767
6830
  const list = phrases && phrases.length ? phrases : [""];
6768
- const [text, setText] = (0, import_react29.useState)(list[0]);
6769
- const listRef = (0, import_react29.useRef)(list);
6831
+ const [text, setText] = (0, import_react30.useState)(list[0]);
6832
+ const listRef = (0, import_react30.useRef)(list);
6770
6833
  listRef.current = list;
6771
- (0, import_react29.useEffect)(() => {
6834
+ (0, import_react30.useEffect)(() => {
6772
6835
  if (!active) return void 0;
6773
6836
  if (typeof window === "undefined") return void 0;
6774
6837
  if (window.matchMedia?.("(prefers-reduced-motion: reduce)")?.matches) {
@@ -6857,7 +6920,7 @@ function Panel(props) {
6857
6920
  }
6858
6921
 
6859
6922
  // src/grid/PanelGrid.jsx
6860
- var import_react30 = __toESM(require("react"), 1);
6923
+ var import_react31 = __toESM(require("react"), 1);
6861
6924
 
6862
6925
  // src/grid/layout.js
6863
6926
  function sortLayout(layout2) {
@@ -6932,9 +6995,9 @@ function sameLayout(a, b) {
6932
6995
  // src/grid/PanelGrid.jsx
6933
6996
  var import_jsx_runtime28 = require("react/jsx-runtime");
6934
6997
  function useMeasuredWidth() {
6935
- const ref = (0, import_react30.useRef)(null);
6936
- const [width, setWidth] = (0, import_react30.useState)(0);
6937
- (0, import_react30.useLayoutEffect)(() => {
6998
+ const ref = (0, import_react31.useRef)(null);
6999
+ const [width, setWidth] = (0, import_react31.useState)(0);
7000
+ (0, import_react31.useLayoutEffect)(() => {
6938
7001
  const el = ref.current;
6939
7002
  if (!el) return void 0;
6940
7003
  const measure = () => setWidth(el.clientWidth);
@@ -6961,9 +7024,9 @@ function PanelGrid(props) {
6961
7024
  className = ""
6962
7025
  } = props;
6963
7026
  const [wrapRef, width] = useMeasuredWidth();
6964
- const [drag, setDrag] = (0, import_react30.useState)(null);
6965
- const dragRef = (0, import_react30.useRef)(null);
6966
- const swallowClick = (0, import_react30.useRef)(false);
7027
+ const [drag, setDrag] = (0, import_react31.useState)(null);
7028
+ const dragRef = (0, import_react31.useRef)(null);
7029
+ const swallowClick = (0, import_react31.useRef)(false);
6967
7030
  const stacked = width > 0 && width < stackAt;
6968
7031
  const arrangeable = editable && !stacked;
6969
7032
  const live = drag ? drag.preview : layout2;
@@ -6971,7 +7034,7 @@ function PanelGrid(props) {
6971
7034
  const cellW = colW + gap;
6972
7035
  const cellH = rowHeight + gap;
6973
7036
  const rowsToPx = (h) => h * rowHeight + (h - 1) * gap;
6974
- const stack2 = (0, import_react30.useMemo)(() => {
7037
+ const stack2 = (0, import_react31.useMemo)(() => {
6975
7038
  if (!stacked) return null;
6976
7039
  const tops = /* @__PURE__ */ new Map();
6977
7040
  let y = 0;
@@ -6983,11 +7046,11 @@ function PanelGrid(props) {
6983
7046
  }, [stacked, live, rowHeight, gap]);
6984
7047
  const rows = layoutRows(live);
6985
7048
  const height = stacked ? stack2.height : rows ? rowsToPx(rows) : 0;
6986
- const commit = (0, import_react30.useCallback)((next) => {
7049
+ const commit = (0, import_react31.useCallback)((next) => {
6987
7050
  if (onLayoutChange && !sameLayout(next, layout2)) onLayoutChange(next);
6988
7051
  }, [onLayoutChange, layout2]);
6989
- const detach = (0, import_react30.useRef)(null);
6990
- (0, import_react30.useEffect)(() => () => detach.current?.(), []);
7052
+ const detach = (0, import_react31.useRef)(null);
7053
+ (0, import_react31.useEffect)(() => () => detach.current?.(), []);
6991
7054
  const start = (id, mode) => (e) => {
6992
7055
  if (!arrangeable || e.button !== 0) return;
6993
7056
  const item = layout2.find((it) => it.i === id);
@@ -7064,8 +7127,8 @@ function PanelGrid(props) {
7064
7127
  },
7065
7128
  children: [
7066
7129
  ghost ? /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: "uic-pg-ghost", "aria-hidden": "true", style: ghost }) : null,
7067
- width > 0 && import_react30.default.Children.map(children, (child) => {
7068
- if (!import_react30.default.isValidElement(child) || child.key == null) return null;
7130
+ width > 0 && import_react31.default.Children.map(children, (child) => {
7131
+ if (!import_react31.default.isValidElement(child) || child.key == null) return null;
7069
7132
  const id = String(child.key).replace(/^\.\$/, "");
7070
7133
  const it = byId.get(id);
7071
7134
  if (!it) return null;
@@ -7104,7 +7167,7 @@ function packLayout(layout2, cols = 12) {
7104
7167
  }
7105
7168
 
7106
7169
  // src/timeline/Timeline.jsx
7107
- var import_react31 = require("react");
7170
+ var import_react32 = require("react");
7108
7171
  var import_jsx_runtime29 = require("react/jsx-runtime");
7109
7172
  var TL_MIN_PPS = 4;
7110
7173
  var TL_MAX_PPS = 400;
@@ -7194,21 +7257,21 @@ function Timeline({
7194
7257
  emptyLabel = "Nothing here yet.",
7195
7258
  className = ""
7196
7259
  }) {
7197
- const scroller = (0, import_react31.useRef)(null);
7198
- const innerRef = (0, import_react31.useRef)(null);
7199
- const [pps, setPps] = (0, import_react31.useState)(() => {
7260
+ const scroller = (0, import_react32.useRef)(null);
7261
+ const innerRef = (0, import_react32.useRef)(null);
7262
+ const [pps, setPps] = (0, import_react32.useState)(() => {
7200
7263
  if (zoomStorageKey && typeof window !== "undefined") {
7201
7264
  const n = parseFloat(window.localStorage.getItem(zoomStorageKey) || "");
7202
7265
  if (Number.isFinite(n)) return clamp(n, TL_MIN_PPS, TL_MAX_PPS);
7203
7266
  }
7204
7267
  return TL_DEFAULT_PPS;
7205
7268
  });
7206
- const [snapping, setSnapping] = (0, import_react31.useState)(() => snapStorageKey && typeof window !== "undefined" ? window.localStorage.getItem(snapStorageKey) !== "0" : true);
7207
- const gesture = (0, import_react31.useRef)(null);
7208
- const [drag, setDrag] = (0, import_react31.useState)(null);
7209
- const anchor = (0, import_react31.useRef)(null);
7210
- const [dropAt, setDropAt] = (0, import_react31.useState)(null);
7211
- const rows = (0, import_react31.useMemo)(
7269
+ const [snapping, setSnapping] = (0, import_react32.useState)(() => snapStorageKey && typeof window !== "undefined" ? window.localStorage.getItem(snapStorageKey) !== "0" : true);
7270
+ const gesture = (0, import_react32.useRef)(null);
7271
+ const [drag, setDrag] = (0, import_react32.useState)(null);
7272
+ const anchor = (0, import_react32.useRef)(null);
7273
+ const [dropAt, setDropAt] = (0, import_react32.useState)(null);
7274
+ const rows = (0, import_react32.useMemo)(
7212
7275
  () => tracks.map((t) => ({
7213
7276
  ...t,
7214
7277
  sequential: t.sequential !== false,
@@ -7216,12 +7279,12 @@ function Timeline({
7216
7279
  })),
7217
7280
  [tracks, pps]
7218
7281
  );
7219
- const contentSeconds = (0, import_react31.useMemo)(() => {
7282
+ const contentSeconds = (0, import_react32.useMemo)(() => {
7220
7283
  let end = 0;
7221
7284
  for (const t of rows) for (const l of t.laid) end = Math.max(end, l.t0 + l.w / pps);
7222
7285
  return end;
7223
7286
  }, [rows, pps]);
7224
- const snapTimes = (0, import_react31.useMemo)(() => {
7287
+ const snapTimes = (0, import_react32.useMemo)(() => {
7225
7288
  const out = [0, currentTime];
7226
7289
  for (const t of rows) for (const l of t.laid) {
7227
7290
  out.push(l.t0);
@@ -7229,7 +7292,7 @@ function Timeline({
7229
7292
  }
7230
7293
  return out;
7231
7294
  }, [rows, pps, currentTime]);
7232
- const setZoom = (0, import_react31.useCallback)((next, clientX) => {
7295
+ const setZoom = (0, import_react32.useCallback)((next, clientX) => {
7233
7296
  const v = clamp(next, TL_MIN_PPS, TL_MAX_PPS);
7234
7297
  const el = scroller.current;
7235
7298
  if (el) {
@@ -7245,21 +7308,21 @@ function Timeline({
7245
7308
  }
7246
7309
  }
7247
7310
  }, [pps, zoomStorageKey]);
7248
- const fitPps = (0, import_react31.useCallback)((seconds) => {
7311
+ const fitPps = (0, import_react32.useCallback)((seconds) => {
7249
7312
  const el = scroller.current;
7250
7313
  if (!el || !(seconds > 0)) return null;
7251
7314
  const room = el.clientWidth - TL_HEAD_W - 56;
7252
7315
  return room > 0 ? clamp(room / seconds, TL_MIN_PPS, TL_MAX_PPS) : null;
7253
7316
  }, []);
7254
- const fit = (0, import_react31.useCallback)(() => {
7317
+ const fit = (0, import_react32.useCallback)(() => {
7255
7318
  const v = fitPps(contentSeconds);
7256
7319
  if (v !== null) {
7257
7320
  setPps(v);
7258
7321
  if (scroller.current) scroller.current.scrollLeft = 0;
7259
7322
  }
7260
7323
  }, [fitPps, contentSeconds]);
7261
- const fitted = (0, import_react31.useRef)(false);
7262
- (0, import_react31.useLayoutEffect)(() => {
7324
+ const fitted = (0, import_react32.useRef)(false);
7325
+ (0, import_react32.useLayoutEffect)(() => {
7263
7326
  if (fitted.current || !(contentSeconds > 0)) return;
7264
7327
  if (zoomStorageKey && typeof window !== "undefined" && window.localStorage.getItem(zoomStorageKey)) {
7265
7328
  fitted.current = true;
@@ -7271,13 +7334,13 @@ function Timeline({
7271
7334
  setPps(v);
7272
7335
  }
7273
7336
  }, [contentSeconds, fitPps, zoomStorageKey]);
7274
- (0, import_react31.useLayoutEffect)(() => {
7337
+ (0, import_react32.useLayoutEffect)(() => {
7275
7338
  const a = anchor.current;
7276
7339
  if (!a || !scroller.current) return;
7277
7340
  anchor.current = null;
7278
7341
  scroller.current.scrollLeft = Math.max(0, TL_HEAD_W + a.t * pps - a.vx);
7279
7342
  }, [pps]);
7280
- (0, import_react31.useEffect)(() => {
7343
+ (0, import_react32.useEffect)(() => {
7281
7344
  const el = scroller.current;
7282
7345
  if (!el) return void 0;
7283
7346
  const onWheel = (e) => {
@@ -7288,12 +7351,12 @@ function Timeline({
7288
7351
  el.addEventListener("wheel", onWheel, { passive: false });
7289
7352
  return () => el.removeEventListener("wheel", onWheel);
7290
7353
  }, [pps, setZoom]);
7291
- const timeAt = (0, import_react31.useCallback)((clientX) => {
7354
+ const timeAt = (0, import_react32.useCallback)((clientX) => {
7292
7355
  const el = innerRef.current;
7293
7356
  if (!el) return 0;
7294
7357
  return Math.max(0, (clientX - el.getBoundingClientRect().left - TL_HEAD_W) / pps);
7295
7358
  }, [pps]);
7296
- const beginGesture = (0, import_react31.useCallback)((e, spec) => {
7359
+ const beginGesture = (0, import_react32.useCallback)((e, spec) => {
7297
7360
  e.preventDefault();
7298
7361
  e.stopPropagation();
7299
7362
  gesture.current = { ...spec, startX: e.clientX, active: false, value: null };
@@ -7327,12 +7390,12 @@ function Timeline({
7327
7390
  window.addEventListener("pointermove", move);
7328
7391
  window.addEventListener("pointerup", up);
7329
7392
  }, [timeAt, snapping, snapTimes, pps, onSeek]);
7330
- const onScrub = (0, import_react31.useCallback)((e) => {
7393
+ const onScrub = (0, import_react32.useCallback)((e) => {
7331
7394
  if (!onSeek) return;
7332
7395
  onSeek(timeAt(e.clientX));
7333
7396
  beginGesture(e, { kind: "scrub" });
7334
7397
  }, [onSeek, timeAt, beginGesture]);
7335
- const splitTarget = (0, import_react31.useMemo)(() => {
7398
+ const splitTarget = (0, import_react32.useMemo)(() => {
7336
7399
  if (!onSplit) return null;
7337
7400
  for (const track of rows) {
7338
7401
  for (const l of track.laid) {
@@ -7344,17 +7407,17 @@ function Timeline({
7344
7407
  }
7345
7408
  return null;
7346
7409
  }, [rows, currentTime, onSplit]);
7347
- const doSplit = (0, import_react31.useCallback)(() => {
7410
+ const doSplit = (0, import_react32.useCallback)(() => {
7348
7411
  if (!splitTarget) return;
7349
7412
  onSplit(splitTarget.l.clip, currentTime - splitTarget.l.t0, splitTarget.track);
7350
7413
  }, [splitTarget, currentTime, onSplit]);
7351
- const selected = (0, import_react31.useMemo)(() => {
7414
+ const selected = (0, import_react32.useMemo)(() => {
7352
7415
  for (const track of rows) for (const l of track.laid) {
7353
7416
  if (l.clip.id === selectedClipId) return { track, l };
7354
7417
  }
7355
7418
  return null;
7356
7419
  }, [rows, selectedClipId]);
7357
- const onKeyDown = (0, import_react31.useCallback)((e) => {
7420
+ const onKeyDown = (0, import_react32.useCallback)((e) => {
7358
7421
  const tag = e.target?.tagName;
7359
7422
  if (tag === "INPUT" || tag === "TEXTAREA" || e.target?.isContentEditable) return;
7360
7423
  if (e.key === "+" || e.key === "=") {
@@ -7371,7 +7434,7 @@ function Timeline({
7371
7434
  onDeleteClip(selected.l.clip, selected.track);
7372
7435
  }
7373
7436
  }, [pps, setZoom, doSplit, selected, onDeleteClip]);
7374
- const toggleSnap = (0, import_react31.useCallback)(() => {
7437
+ const toggleSnap = (0, import_react32.useCallback)(() => {
7375
7438
  setSnapping((v) => {
7376
7439
  const next = !v;
7377
7440
  if (snapStorageKey && typeof window !== "undefined") {