strata-react 1.0.46 → 1.1.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
@@ -4011,6 +4011,10 @@ function MediaPlayer({ label, kind = "audio", src, sources, index: controlledInd
4011
4011
  });
4012
4012
  }
4013
4013
  // src/lib/transcript.ts
4014
+ /** The id of a word for marking (`TranscriptView`'s `marking`, `Mark`): its phrase and its place in it. */
4015
+ var wordId = (phraseId, index) => `${phraseId}:${index}`;
4016
+ /** The phrase an id made by `wordId` belongs to. */
4017
+ var phraseOfWordId = (id) => id.slice(0, id.lastIndexOf(":"));
4014
4018
  /** Whether a word is doubtful: the recogniser said so, or its confidence is under `below`. */
4015
4019
  function isDoubtful(word, below = .6) {
4016
4020
  return word.doubtful ?? (word.confidence !== void 0 && word.confidence < below);
@@ -4042,100 +4046,384 @@ function wordAt(phrase, time) {
4042
4046
  else break;
4043
4047
  return found;
4044
4048
  }
4045
- // src/components/virtual-list.tsx
4046
- var FOOTER = "\0footer";
4047
- /** A list that renders only its visible rows (React Aria's GridList and Virtualizer) from `virtualizeFrom` items, with arrow-key navigation between rows. */
4048
- function VirtualList({ label, items, itemKey, children, estimateSize = 48, rowHeight, height = 480, virtualizeFrom = 100, bounded = false, footer, className }) {
4049
- const virtual = items.length >= virtualizeFrom;
4050
- const rows = React.useMemo(() => items.map((item, index) => ({
4051
- id: itemKey(item),
4052
- item,
4053
- index
4054
- })), [items, itemKey]);
4055
- const layoutOptions = React.useMemo(() => rowHeight ? { rowHeight } : { estimatedRowHeight: estimateSize }, [rowHeight, estimateSize]);
4056
- const virtualise = virtual || bounded;
4057
- const scrolls = virtualise;
4058
- const list = /* @__PURE__ */ jsxs(GridList, {
4059
- "aria-label": label,
4060
- selectionMode: "none",
4061
- "data-strata-scroll": "",
4062
- className: cn("min-w-0 outline-none", scrolls && "overflow-y-auto", className),
4063
- style: scrolls ? virtual ? { height } : { maxHeight: height } : void 0,
4064
- children: [/* @__PURE__ */ jsx(Collection, {
4065
- items: rows,
4066
- children: (row) => /* @__PURE__ */ jsx(GridListItem, {
4067
- id: row.id,
4068
- textValue: row.id,
4069
- "data-index": row.index,
4070
- className: cn("min-w-0 outline-offset-[-2px]", row.index > 0 && "border-t border-border"),
4071
- children: children(row.item, row.index)
4072
- })
4073
- }), footer && /* @__PURE__ */ jsx(GridListItem, {
4074
- id: FOOTER,
4075
- textValue: "More",
4076
- className: "min-w-0",
4077
- children: footer
4049
+ // src/lib/marks.ts
4050
+ /** The ids from `a` to `b` inclusive, in document order whichever way round they are given. Empty when either is not in `ids`. */
4051
+ function rangeBetween(ids, a, b) {
4052
+ if (a === null || b === null) return [];
4053
+ const i = ids.indexOf(a);
4054
+ const j = ids.indexOf(b);
4055
+ if (i < 0 || j < 0) return [];
4056
+ return ids.slice(Math.min(i, j), Math.max(i, j) + 1);
4057
+ }
4058
+ /** How many ids carry each mark key. Ids with no mark are not counted. */
4059
+ function countMarks(marks, ids) {
4060
+ const out = {};
4061
+ for (const id of ids ?? Object.keys(marks)) {
4062
+ const m = marks[id];
4063
+ if (m) out[m] = (out[m] ?? 0) + 1;
4064
+ }
4065
+ return out;
4066
+ }
4067
+ /** The id `by` places from `from` in `ids`, held to the ends; the first (or last) when `from` is not set. */
4068
+ function stepId(ids, from, by) {
4069
+ if (ids.length === 0) return null;
4070
+ const i = from === null ? -1 : ids.indexOf(from);
4071
+ if (i < 0) return by >= 0 ? ids[0] : ids[ids.length - 1];
4072
+ return ids[Math.min(Math.max(i + by, 0), ids.length - 1)];
4073
+ }
4074
+ // src/components/markable-text.tsx
4075
+ var TONE$2 = {
4076
+ neutral: {
4077
+ fill: "var(--muted)",
4078
+ edge: "var(--muted-foreground)"
4079
+ },
4080
+ info: {
4081
+ fill: "var(--info-subtle)",
4082
+ edge: "var(--info)"
4083
+ },
4084
+ success: {
4085
+ fill: "var(--success-subtle)",
4086
+ edge: "var(--success)"
4087
+ },
4088
+ warning: {
4089
+ fill: "var(--warning-subtle)",
4090
+ edge: "var(--warning)"
4091
+ },
4092
+ danger: {
4093
+ fill: "var(--danger-subtle)",
4094
+ edge: "var(--danger)"
4095
+ }
4096
+ };
4097
+ var MarksContext = React.createContext(null);
4098
+ /** One word (or phrase, or clip) that can be marked. Draws its mark, its selection and the caret; inside a `MarkableText`. */
4099
+ function Mark({ id, children, className, onClick, onHover }) {
4100
+ const c = React.useContext(MarksContext);
4101
+ if (!c) return /* @__PURE__ */ jsx("span", {
4102
+ className,
4103
+ children
4104
+ });
4105
+ const kind = c.kinds.find((k) => k.key === c.marks[id]);
4106
+ const tone = kind && TONE$2[kind.tone];
4107
+ const on = c.selected.has(id);
4108
+ return /* @__PURE__ */ jsxs("span", {
4109
+ "data-mark-id": id,
4110
+ "data-mark": kind?.key,
4111
+ "data-selected": on || void 0,
4112
+ "data-caret": c.caret === id || void 0,
4113
+ onPointerDown: (e) => c.press(e, id),
4114
+ onPointerEnter: (e) => {
4115
+ c.over(id);
4116
+ onHover?.(e.currentTarget);
4117
+ },
4118
+ onPointerLeave: onHover ? () => onHover(null) : void 0,
4119
+ onClick,
4120
+ className: cn("cursor-text rounded-control px-px", on && "bg-primary/20", c.caret === id && "outline-2 outline-primary", className),
4121
+ style: kind && tone ? {
4122
+ backgroundColor: on ? void 0 : tone.fill,
4123
+ textDecorationLine: "underline",
4124
+ textDecorationStyle: kind.pattern,
4125
+ textDecorationColor: tone.edge,
4126
+ textDecorationThickness: "2px",
4127
+ textUnderlineOffset: "3px"
4128
+ } : void 0,
4129
+ children: [children, kind && /* @__PURE__ */ jsxs("span", {
4130
+ className: "sr-only",
4131
+ children: [
4132
+ " (",
4133
+ kind.label.toLowerCase(),
4134
+ ")"
4135
+ ]
4078
4136
  })]
4079
4137
  });
4080
- return virtualise ? /* @__PURE__ */ jsx(Virtualizer, {
4081
- layout: ListLayout,
4082
- layoutOptions,
4083
- children: list
4084
- }) : list;
4085
4138
  }
4086
- // src/components/transcript-view.tsx
4087
- var ALL = "all";
4088
- var capital = (s) => s.charAt(0).toUpperCase() + s.slice(1);
4089
- var range = (a, b) => `${format.runningTime(a)}–${format.runningTime(b)}`;
4090
- /** Timed text that follows playback: the heard word marked, any word or phrase pressed to play from, modes, speakers, follow and Jump to now. */
4091
- function TranscriptView({ label, groups, time, onSeek, mode: controlledMode, onModeChange, modeLabels = {}, speaker: controlledSpeaker, onSpeakerChange, follow = true, announce = false, renderPlay, doubtfulBelow = .6, states = [], onPhraseState, renderActions, onEdit, renderCard, cardDelay = 500, height = 480, className }) {
4092
- const [ownMode, setOwnMode] = React.useState("original");
4093
- const [ownSpeaker, setOwnSpeaker] = React.useState(ALL);
4094
- const mode = controlledMode ?? ownMode;
4095
- const speaker = controlledSpeaker ?? ownSpeaker;
4096
- const modes = React.useMemo(() => ["original", ...new Set(groups.flatMap((g) => g.phrases.flatMap((p) => Object.keys(p.alt ?? {}))))], [groups]);
4097
- const speakers = React.useMemo(() => [...new Set(groups.flatMap((g) => g.phrases.map((p) => p.speaker).filter((s) => Boolean(s))))], [groups]);
4098
- const [onlyDoubtful, setOnlyDoubtful] = React.useState(false);
4099
- const summary = React.useMemo(() => {
4100
- const mine = groups.flatMap((g) => g.phrases).filter((p) => speaker === ALL || p.speaker === speaker);
4101
- const doubtful = mine.filter((p) => phraseDoubtful(p, doubtfulBelow)).length;
4102
- const marked = /* @__PURE__ */ new Map();
4103
- for (const p of mine) if (p.state) marked.set(p.state.label, (marked.get(p.state.label) ?? 0) + 1);
4104
- return {
4105
- doubtful,
4106
- marked: [...marked]
4107
- };
4108
- }, [
4109
- groups,
4110
- speaker,
4111
- doubtfulBelow
4139
+ /** "12 words must use, 3 never": a count for each kind in use, with its icon. */
4140
+ function MarkSummary({ marks, kinds, unit = ["word", "words"], className }) {
4141
+ const counts = countMarks(marks);
4142
+ const used = kinds.filter((k) => counts[k.key]);
4143
+ if (!used.length) return /* @__PURE__ */ jsx("p", {
4144
+ className: cn("type-caption text-muted-foreground", className),
4145
+ children: "Nothing marked yet."
4146
+ });
4147
+ return /* @__PURE__ */ jsx("ul", {
4148
+ "aria-label": "Marked",
4149
+ className: cn("flex flex-wrap gap-x-4 gap-y-1 type-body-sm", className),
4150
+ children: used.map((k) => {
4151
+ const Icon = k.icon;
4152
+ return /* @__PURE__ */ jsxs("li", {
4153
+ className: "inline-flex items-center gap-1.5",
4154
+ children: [
4155
+ Icon && /* @__PURE__ */ jsx(Icon, {
4156
+ "aria-hidden": true,
4157
+ className: "size-4"
4158
+ }),
4159
+ /* @__PURE__ */ jsx("span", {
4160
+ className: "tabular-nums",
4161
+ children: format.count(counts[k.key], unit[0], unit[1])
4162
+ }),
4163
+ " ",
4164
+ k.label.toLowerCase()
4165
+ ]
4166
+ }, k.key);
4167
+ })
4168
+ });
4169
+ }
4170
+ /** Selects ids over `<Mark>` words by drag, Shift+click and Shift+arrows (a run in the app's order, so it holds across virtualised rows), offers the app's marks as chorded commands in a bar, says each change in words, and lists what is marked. */
4171
+ function MarkableText({ label, ids, marks, kinds, onMark, clearKeys = [], onActivate, onCaretChange, unit = ["word", "words"], summary = true, children, className }) {
4172
+ const [anchor, setAnchor] = React.useState(null);
4173
+ const [caret, setCaret] = React.useState(null);
4174
+ const [said, setSaid] = React.useState("");
4175
+ const dragging = React.useRef(false);
4176
+ const hintId = React.useId();
4177
+ const run = React.useMemo(() => rangeBetween(ids, anchor, caret), [
4178
+ ids,
4179
+ anchor,
4180
+ caret
4112
4181
  ]);
4113
- const filtering = onlyDoubtful && summary.doubtful > 0;
4114
- const { rows, phrases } = React.useMemo(() => {
4115
- const rows = [];
4116
- const phrases = [];
4117
- for (const g of groups) {
4118
- const mine = g.phrases.filter((p) => (speaker === ALL || p.speaker === speaker) && (!filtering || phraseDoubtful(p, doubtfulBelow)));
4119
- if (mine.length === 0) continue;
4120
- rows.push({
4121
- kind: "heading",
4122
- key: `group:${g.id}`,
4123
- group: {
4124
- ...g,
4125
- start: g.start ?? mine[0].start,
4126
- end: g.end ?? mine[mine.length - 1].end
4127
- }
4128
- });
4129
- for (const p of mine) {
4130
- rows.push({
4131
- kind: "phrase",
4132
- key: p.id,
4133
- phrase: p,
4134
- index: phrases.length
4135
- });
4136
- phrases.push(p);
4182
+ const selected = React.useMemo(() => new Set(run), [run]);
4183
+ const n = run.length;
4184
+ const counted = (k) => format.count(k, unit[0], unit[1]);
4185
+ const moveCaret = (id, extend) => {
4186
+ if (id === null) return;
4187
+ setCaret(id);
4188
+ if (!extend || anchor === null) setAnchor(id);
4189
+ onCaretChange?.(id);
4190
+ };
4191
+ const apply = (kind) => {
4192
+ if (!n) return;
4193
+ onMark(run, kind);
4194
+ const k = kinds.find((x) => x.key === kind);
4195
+ setSaid(kind === null ? `${counted(n)} cleared` : `${counted(n)} marked ${k?.label.toLowerCase() ?? kind}`);
4196
+ };
4197
+ const commands = [...kinds.map((k) => ({
4198
+ id: `mark-${k.key}`,
4199
+ label: k.label,
4200
+ keys: k.keys,
4201
+ icon: k.icon,
4202
+ disabled: n ? false : "Select words first",
4203
+ run: () => apply(k.key)
4204
+ })), {
4205
+ id: "mark-clear",
4206
+ label: "Clear mark",
4207
+ keys: clearKeys,
4208
+ disabled: n ? false : "Select words first",
4209
+ run: () => apply(null)
4210
+ }];
4211
+ useCommands(commands);
4212
+ React.useEffect(() => {
4213
+ const stop = () => dragging.current = false;
4214
+ window.addEventListener("pointerup", stop);
4215
+ return () => window.removeEventListener("pointerup", stop);
4216
+ }, []);
4217
+ const ctx = {
4218
+ kinds,
4219
+ marks,
4220
+ selected,
4221
+ caret,
4222
+ press: (e, id) => {
4223
+ if (e.button !== 0) return;
4224
+ dragging.current = true;
4225
+ if (e.shiftKey && anchor !== null) setCaret(id);
4226
+ else {
4227
+ setAnchor(id);
4228
+ setCaret(id);
4137
4229
  }
4138
- }
4230
+ onCaretChange?.(id);
4231
+ setSaid("");
4232
+ },
4233
+ over: (id) => {
4234
+ if (dragging.current && id !== caret) setCaret(id);
4235
+ }
4236
+ };
4237
+ React.useEffect(() => {
4238
+ if (n > 1) setSaid(`${counted(n)} selected`);
4239
+ else if (n === 1 && caret) setSaid(`${document.querySelector(`[data-mark-id="${CSS.escape(caret)}"]`)?.textContent ?? caret}`);
4240
+ }, [n, caret]);
4241
+ const keys = (e) => {
4242
+ if (e.target !== e.currentTarget) return;
4243
+ if (e.altKey || e.ctrlKey || e.metaKey) return;
4244
+ const to = e.key === "ArrowRight" ? stepId(ids, caret, 1) : e.key === "ArrowLeft" ? stepId(ids, caret, -1) : e.key === "Home" ? ids[0] ?? null : e.key === "End" ? ids[ids.length - 1] ?? null : void 0;
4245
+ if (to !== void 0) {
4246
+ e.preventDefault();
4247
+ moveCaret(to, e.shiftKey);
4248
+ } else if (e.key === "Enter" && caret !== null && onActivate) {
4249
+ e.preventDefault();
4250
+ onActivate(caret);
4251
+ } else if (e.key === "Escape" && (anchor !== null || caret !== null)) {
4252
+ e.preventDefault();
4253
+ setAnchor(null);
4254
+ setCaret(null);
4255
+ setSaid("Selection cleared");
4256
+ }
4257
+ };
4258
+ return /* @__PURE__ */ jsxs("div", {
4259
+ className: cn("space-y-2", className),
4260
+ children: [
4261
+ n > 0 && /* @__PURE__ */ jsxs(Toolbar, {
4262
+ label: "Marks",
4263
+ className: "sticky top-0 z-10 flex flex-wrap items-center gap-2 rounded-surface border border-border bg-background p-1.5",
4264
+ children: [
4265
+ /* @__PURE__ */ jsxs("span", {
4266
+ className: "px-1 type-label tabular-nums",
4267
+ children: [counted(n), " selected"]
4268
+ }),
4269
+ kinds.map((k) => {
4270
+ const Icon = k.icon;
4271
+ return /* @__PURE__ */ jsxs(Button, {
4272
+ size: "sm",
4273
+ onPress: () => apply(k.key),
4274
+ children: [
4275
+ Icon && /* @__PURE__ */ jsx(Icon, {}),
4276
+ " ",
4277
+ k.label
4278
+ ]
4279
+ }, k.key);
4280
+ }),
4281
+ /* @__PURE__ */ jsx(Button, {
4282
+ size: "sm",
4283
+ variant: "ghost",
4284
+ onPress: () => apply(null),
4285
+ children: "Clear mark"
4286
+ }),
4287
+ /* @__PURE__ */ jsx(Button, {
4288
+ size: "sm",
4289
+ variant: "ghost",
4290
+ onPress: () => {
4291
+ setAnchor(null);
4292
+ setCaret(null);
4293
+ },
4294
+ children: "Deselect"
4295
+ })
4296
+ ]
4297
+ }),
4298
+ /* @__PURE__ */ jsx(MarksContext.Provider, {
4299
+ value: ctx,
4300
+ children: /* @__PURE__ */ jsx("div", {
4301
+ role: "group",
4302
+ "aria-label": label,
4303
+ "aria-describedby": hintId,
4304
+ tabIndex: 0,
4305
+ onKeyDown: keys,
4306
+ className: "select-none rounded-surface outline-offset-2",
4307
+ children
4308
+ })
4309
+ }),
4310
+ /* @__PURE__ */ jsx("p", {
4311
+ id: hintId,
4312
+ className: "type-caption text-muted-foreground",
4313
+ children: "Drag across words, or Shift+click, to select. Left and Right move; Shift and arrows select; Escape clears."
4314
+ }),
4315
+ /* @__PURE__ */ jsx(CommandLegend, {
4316
+ commands,
4317
+ label: "Mark keys"
4318
+ }),
4319
+ summary && /* @__PURE__ */ jsx(MarkSummary, {
4320
+ marks,
4321
+ kinds,
4322
+ unit
4323
+ }),
4324
+ /* @__PURE__ */ jsx("div", {
4325
+ role: "status",
4326
+ "aria-live": "polite",
4327
+ className: "sr-only",
4328
+ children: said
4329
+ })
4330
+ ]
4331
+ });
4332
+ }
4333
+ // src/components/virtual-list.tsx
4334
+ var FOOTER = "\0footer";
4335
+ /** A list that renders only its visible rows (React Aria's GridList and Virtualizer) from `virtualizeFrom` items, with arrow-key navigation between rows. */
4336
+ function VirtualList({ label, items, itemKey, children, estimateSize = 48, rowHeight, height = 480, virtualizeFrom = 100, bounded = false, footer, className }) {
4337
+ const virtual = items.length >= virtualizeFrom;
4338
+ const rows = React.useMemo(() => items.map((item, index) => ({
4339
+ id: itemKey(item),
4340
+ item,
4341
+ index
4342
+ })), [items, itemKey]);
4343
+ const layoutOptions = React.useMemo(() => rowHeight ? { rowHeight } : { estimatedRowHeight: estimateSize }, [rowHeight, estimateSize]);
4344
+ const virtualise = virtual || bounded;
4345
+ const scrolls = virtualise;
4346
+ const list = /* @__PURE__ */ jsxs(GridList, {
4347
+ "aria-label": label,
4348
+ selectionMode: "none",
4349
+ "data-strata-scroll": "",
4350
+ className: cn("min-w-0 outline-none", scrolls && "overflow-y-auto", className),
4351
+ style: scrolls ? virtual ? { height } : { maxHeight: height } : void 0,
4352
+ children: [/* @__PURE__ */ jsx(Collection, {
4353
+ items: rows,
4354
+ children: (row) => /* @__PURE__ */ jsx(GridListItem, {
4355
+ id: row.id,
4356
+ textValue: row.id,
4357
+ "data-index": row.index,
4358
+ className: cn("min-w-0 outline-offset-[-2px]", row.index > 0 && "border-t border-border"),
4359
+ children: children(row.item, row.index)
4360
+ })
4361
+ }), footer && /* @__PURE__ */ jsx(GridListItem, {
4362
+ id: FOOTER,
4363
+ textValue: "More",
4364
+ className: "min-w-0",
4365
+ children: footer
4366
+ })]
4367
+ });
4368
+ return virtualise ? /* @__PURE__ */ jsx(Virtualizer, {
4369
+ layout: ListLayout,
4370
+ layoutOptions,
4371
+ children: list
4372
+ }) : list;
4373
+ }
4374
+ // src/components/transcript-view.tsx
4375
+ var ALL = "all";
4376
+ var capital = (s) => s.charAt(0).toUpperCase() + s.slice(1);
4377
+ var range = (a, b) => `${format.runningTime(a)}–${format.runningTime(b)}`;
4378
+ /** Timed text that follows playback: the heard word marked, any word or phrase pressed to play from, modes, speakers, follow and Jump to now. */
4379
+ function TranscriptView({ label, groups, time, onSeek, marking, onCorrectionPress, mode: controlledMode, onModeChange, modeLabels = {}, speaker: controlledSpeaker, onSpeakerChange, follow = true, announce = false, renderPlay, doubtfulBelow = .6, states = [], onPhraseState, renderActions, onEdit, renderCard, cardDelay = 500, height = 480, className }) {
4380
+ const [ownMode, setOwnMode] = React.useState("original");
4381
+ const [ownSpeaker, setOwnSpeaker] = React.useState(ALL);
4382
+ const mode = controlledMode ?? ownMode;
4383
+ const speaker = controlledSpeaker ?? ownSpeaker;
4384
+ const modes = React.useMemo(() => ["original", ...new Set(groups.flatMap((g) => g.phrases.flatMap((p) => Object.keys(p.alt ?? {}))))], [groups]);
4385
+ const speakers = React.useMemo(() => [...new Set(groups.flatMap((g) => g.phrases.map((p) => p.speaker).filter((s) => Boolean(s))))], [groups]);
4386
+ const [onlyDoubtful, setOnlyDoubtful] = React.useState(false);
4387
+ const summary = React.useMemo(() => {
4388
+ const mine = groups.flatMap((g) => g.phrases).filter((p) => speaker === ALL || p.speaker === speaker);
4389
+ const doubtful = mine.filter((p) => phraseDoubtful(p, doubtfulBelow)).length;
4390
+ const marked = /* @__PURE__ */ new Map();
4391
+ for (const p of mine) if (p.state) marked.set(p.state.label, (marked.get(p.state.label) ?? 0) + 1);
4392
+ return {
4393
+ doubtful,
4394
+ marked: [...marked]
4395
+ };
4396
+ }, [
4397
+ groups,
4398
+ speaker,
4399
+ doubtfulBelow
4400
+ ]);
4401
+ const filtering = onlyDoubtful && summary.doubtful > 0;
4402
+ const { rows, phrases } = React.useMemo(() => {
4403
+ const rows = [];
4404
+ const phrases = [];
4405
+ for (const g of groups) {
4406
+ const mine = g.phrases.filter((p) => (speaker === ALL || p.speaker === speaker) && (!filtering || phraseDoubtful(p, doubtfulBelow)));
4407
+ if (mine.length === 0) continue;
4408
+ rows.push({
4409
+ kind: "heading",
4410
+ key: `group:${g.id}`,
4411
+ group: {
4412
+ ...g,
4413
+ start: g.start ?? mine[0].start,
4414
+ end: g.end ?? mine[mine.length - 1].end
4415
+ }
4416
+ });
4417
+ for (const p of mine) {
4418
+ rows.push({
4419
+ kind: "phrase",
4420
+ key: p.id,
4421
+ phrase: p,
4422
+ index: phrases.length
4423
+ });
4424
+ phrases.push(p);
4425
+ }
4426
+ }
4139
4427
  return {
4140
4428
  rows,
4141
4429
  phrases
@@ -4146,9 +4434,9 @@ function TranscriptView({ label, groups, time, onSeek, mode: controlledMode, onM
4146
4434
  filtering,
4147
4435
  doubtfulBelow
4148
4436
  ]);
4149
- const heard = phraseAt(phrases, time);
4437
+ const heard = time === void 0 ? -1 : phraseAt(phrases, time);
4150
4438
  const heardPhrase = heard >= 0 ? phrases[heard] : null;
4151
- const heardWord = heardPhrase ? wordAt(heardPhrase, time) : -1;
4439
+ const heardWord = heardPhrase && time !== void 0 ? wordAt(heardPhrase, time) : -1;
4152
4440
  const heardText = heardPhrase ? mode === "original" ? heardPhrase.words.map((w) => w.text).join(" ") : heardPhrase.alt?.[mode] ?? heardPhrase.words.map((w) => w.text).join(" ") : "";
4153
4441
  const root = React.useRef(null);
4154
4442
  const [following, setFollowing] = React.useState(follow);
@@ -4281,10 +4569,13 @@ function TranscriptView({ label, groups, time, onSeek, mode: controlledMode, onM
4281
4569
  if (controlledSpeaker === void 0) setOwnSpeaker(s);
4282
4570
  onSpeakerChange?.(s);
4283
4571
  };
4284
- const seek = (t, from) => {
4572
+ const seek = onSeek ? (t, from) => {
4285
4573
  setFollowing(follow);
4286
4574
  onSeek(t, from);
4287
- };
4575
+ } : void 0;
4576
+ const marks = marking && mode === "original" ? marking : null;
4577
+ const wordIds = React.useMemo(() => marks ? phrases.flatMap((p) => p.words.map((_, i) => wordId(p.id, i))) : [], [marks, phrases]);
4578
+ const [hint, setHint] = React.useState(null);
4288
4579
  const modeOptions = modes.map((m) => ({
4289
4580
  value: m,
4290
4581
  label: m === "original" ? modeLabels.original ?? "Original" : modeLabels[m] ?? capital(m)
@@ -4296,6 +4587,72 @@ function TranscriptView({ label, groups, time, onSeek, mode: controlledMode, onM
4296
4587
  value: s,
4297
4588
  label: s
4298
4589
  }))];
4590
+ const list = /* @__PURE__ */ jsxs("div", {
4591
+ className: "relative",
4592
+ onKeyDown: onKeys,
4593
+ onFocus: (e) => showCard(phraseOfEvent(e.target)),
4594
+ onBlur: (e) => {
4595
+ if (!root.current?.contains(e.relatedTarget)) showCard(null);
4596
+ },
4597
+ onPointerLeave: () => {
4598
+ dismissed.current = null;
4599
+ showCard(null);
4600
+ },
4601
+ children: [/* @__PURE__ */ jsx(VirtualList, {
4602
+ label,
4603
+ items: rows,
4604
+ itemKey: (r) => r.key,
4605
+ estimateSize: 72,
4606
+ height,
4607
+ virtualizeFrom: 100,
4608
+ children: (row) => row.kind === "heading" ? /* @__PURE__ */ jsxs("div", {
4609
+ className: "flex items-baseline gap-3 bg-surface-sunken px-3 py-2",
4610
+ children: [/* @__PURE__ */ jsx("h3", {
4611
+ className: "type-label text-foreground",
4612
+ children: row.group.title
4613
+ }), /* @__PURE__ */ jsx("span", {
4614
+ className: "type-caption tabular-nums text-muted-foreground",
4615
+ children: range(row.group.start, row.group.end)
4616
+ })]
4617
+ }) : /* @__PURE__ */ jsx(PhraseRow, {
4618
+ phrase: row.phrase,
4619
+ marking: Boolean(marks),
4620
+ onCorrectionPress,
4621
+ onHint: setHint,
4622
+ mode,
4623
+ active: row.index === heard,
4624
+ word: row.index === heard ? heardWord : -1,
4625
+ onSeek: seek,
4626
+ play: renderPlay?.(row.phrase),
4627
+ doubtfulBelow,
4628
+ states,
4629
+ onPhraseState,
4630
+ actions: renderActions?.(row.phrase),
4631
+ edit: editing?.id === row.phrase.id ? {
4632
+ text: editing.text,
4633
+ change: (text) => setEditing({
4634
+ ...editing,
4635
+ text
4636
+ }),
4637
+ done: stopEdit
4638
+ } : void 0,
4639
+ onHover: (on) => {
4640
+ if (!on) dismissed.current = null;
4641
+ showCard(on ? row.phrase.id : null);
4642
+ }
4643
+ })
4644
+ }), follow && !following && heardPhrase && /* @__PURE__ */ jsx("div", {
4645
+ className: "pointer-events-none absolute inset-x-0 bottom-2 flex justify-center",
4646
+ children: /* @__PURE__ */ jsx(Button, {
4647
+ className: "pointer-events-auto max-w-full shadow-overlay",
4648
+ onPress: () => setFollowing(true),
4649
+ children: /* @__PURE__ */ jsxs("span", {
4650
+ className: "truncate",
4651
+ children: ["Jump to now: ", heardText]
4652
+ })
4653
+ })
4654
+ })]
4655
+ });
4299
4656
  return /* @__PURE__ */ jsxs("div", {
4300
4657
  ref: root,
4301
4658
  className: cn("grid min-w-0 gap-3", className),
@@ -4338,73 +4695,35 @@ function TranscriptView({ label, groups, time, onSeek, mode: controlledMode, onM
4338
4695
  })
4339
4696
  ]
4340
4697
  }),
4341
- /* @__PURE__ */ jsxs("div", {
4342
- className: "relative",
4343
- onKeyDown: onKeys,
4344
- onFocus: (e) => showCard(phraseOfEvent(e.target)),
4345
- onBlur: (e) => {
4346
- if (!root.current?.contains(e.relatedTarget)) showCard(null);
4347
- },
4348
- onPointerLeave: () => {
4349
- dismissed.current = null;
4350
- showCard(null);
4351
- },
4352
- children: [/* @__PURE__ */ jsx(VirtualList, {
4353
- label,
4354
- items: rows,
4355
- itemKey: (r) => r.key,
4356
- estimateSize: 72,
4357
- height,
4358
- virtualizeFrom: 100,
4359
- children: (row) => row.kind === "heading" ? /* @__PURE__ */ jsxs("div", {
4360
- className: "flex items-baseline gap-3 bg-surface-sunken px-3 py-2",
4361
- children: [/* @__PURE__ */ jsx("h3", {
4362
- className: "type-label text-foreground",
4363
- children: row.group.title
4364
- }), /* @__PURE__ */ jsx("span", {
4365
- className: "type-caption tabular-nums text-muted-foreground",
4366
- children: range(row.group.start, row.group.end)
4367
- })]
4368
- }) : /* @__PURE__ */ jsx(PhraseRow, {
4369
- phrase: row.phrase,
4370
- mode,
4371
- active: row.index === heard,
4372
- word: row.index === heard ? heardWord : -1,
4373
- onSeek: seek,
4374
- play: renderPlay?.(row.phrase),
4375
- doubtfulBelow,
4376
- states,
4377
- onPhraseState,
4378
- actions: renderActions?.(row.phrase),
4379
- edit: editing?.id === row.phrase.id ? {
4380
- text: editing.text,
4381
- change: (text) => setEditing({
4382
- ...editing,
4383
- text
4384
- }),
4385
- done: stopEdit
4386
- } : void 0,
4387
- onHover: (on) => {
4388
- if (!on) dismissed.current = null;
4389
- showCard(on ? row.phrase.id : null);
4390
- }
4391
- })
4392
- }), follow && !following && heardPhrase && /* @__PURE__ */ jsx("div", {
4393
- className: "pointer-events-none absolute inset-x-0 bottom-2 flex justify-center",
4394
- children: /* @__PURE__ */ jsx(Button, {
4395
- className: "pointer-events-auto max-w-full shadow-overlay",
4396
- onPress: () => setFollowing(true),
4397
- children: /* @__PURE__ */ jsxs("span", {
4398
- className: "truncate",
4399
- children: ["Jump to now: ", heardText]
4400
- })
4401
- })
4402
- })]
4403
- }),
4698
+ marks ? /* @__PURE__ */ jsx(MarkableText, {
4699
+ label: `${label}, for marking`,
4700
+ ids: wordIds,
4701
+ marks: marks.marks,
4702
+ kinds: marks.kinds,
4703
+ onMark: marks.onMark,
4704
+ clearKeys: marks.clearKeys,
4705
+ summary: marks.summary,
4706
+ onActivate: onCorrectionPress ? (id) => {
4707
+ const pid = phraseOfWordId(id);
4708
+ const i = Number(id.slice(pid.length + 1));
4709
+ if (phrases.find((x) => x.id === pid)?.words[i]?.correction) onCorrectionPress(pid, i);
4710
+ } : void 0,
4711
+ onCaretChange: (id) => scrollToHeard(phraseOfWordId(id)),
4712
+ children: list
4713
+ }) : list,
4404
4714
  /* @__PURE__ */ jsx(VisuallyHidden, { children: /* @__PURE__ */ jsx("span", {
4405
4715
  role: "status",
4406
4716
  children: said
4407
4717
  }) }),
4718
+ hint && /* @__PURE__ */ jsx(Popover$1, {
4719
+ triggerRef: { current: hint.el },
4720
+ isOpen: true,
4721
+ isNonModal: true,
4722
+ placement: "top",
4723
+ offset: 4,
4724
+ className: cn("layer-overlay max-w-xs px-2 py-1 type-caption", "rounded-overlay border border-border bg-popover text-popover-foreground shadow-overlay enter-overlay"),
4725
+ children: hint.text
4726
+ }),
4408
4727
  card && renderCard && (() => {
4409
4728
  const p = phrases.find((x) => x.id === card);
4410
4729
  const anchor = rowEl(card);
@@ -4424,7 +4743,7 @@ function TranscriptView({ label, groups, time, onSeek, mode: controlledMode, onM
4424
4743
  ]
4425
4744
  });
4426
4745
  }
4427
- function PhraseRow({ phrase, mode, active, word, onSeek, play, doubtfulBelow, states, onPhraseState, actions, edit, onHover }) {
4746
+ function PhraseRow({ phrase, mode, active, word, onSeek, marking, onCorrectionPress, onHint, play, doubtfulBelow, states, onPhraseState, actions, edit, onHover }) {
4428
4747
  const alt = mode === "original" ? null : phrase.alt?.[mode] ?? null;
4429
4748
  const doubtful = phraseDoubtful(phrase, doubtfulBelow);
4430
4749
  const marks = states.filter((s) => s.id !== phrase.state?.id).map((s) => ({
@@ -4457,11 +4776,14 @@ function PhraseRow({ phrase, mode, active, word, onSeek, play, doubtfulBelow, st
4457
4776
  className: "type-label text-muted-foreground",
4458
4777
  children: phrase.speaker
4459
4778
  }),
4460
- /* @__PURE__ */ jsx(Button$1, {
4779
+ onSeek ? /* @__PURE__ */ jsx(Button$1, {
4461
4780
  onPress: () => onSeek(phrase.start, { phraseId: phrase.id }),
4462
4781
  className: "rounded-control type-caption tabular-nums text-muted-foreground hover:text-foreground",
4463
4782
  "aria-label": `Play from ${format.runningTime(phrase.start)}`,
4464
4783
  children: format.runningTime(phrase.start)
4784
+ }) : /* @__PURE__ */ jsx("span", {
4785
+ className: "type-caption tabular-nums text-muted-foreground",
4786
+ children: format.runningTime(phrase.start)
4465
4787
  }),
4466
4788
  doubtful && /* @__PURE__ */ jsx(Status, {
4467
4789
  tone: "warning",
@@ -4499,22 +4821,58 @@ function PhraseRow({ phrase, mode, active, word, onSeek, play, doubtfulBelow, st
4499
4821
  children: "Cancel"
4500
4822
  })]
4501
4823
  })]
4502
- }) : alt !== null ? /* @__PURE__ */ jsx(Button$1, {
4824
+ }) : alt !== null ? onSeek ? /* @__PURE__ */ jsx(Button$1, {
4503
4825
  onPress: () => onSeek(phrase.start, { phraseId: phrase.id }),
4504
4826
  className: cn("rounded-control text-left type-body", active && "font-medium underline decoration-2 underline-offset-4"),
4505
4827
  children: alt
4828
+ }) : /* @__PURE__ */ jsx("p", {
4829
+ className: cn("type-body", active && "font-medium underline decoration-2 underline-offset-4"),
4830
+ children: alt
4506
4831
  }) : /* @__PURE__ */ jsx("p", {
4507
4832
  className: "type-body",
4508
- children: phrase.words.map((w, i) => /* @__PURE__ */ jsxs(React.Fragment, { children: [i > 0 && " ", /* @__PURE__ */ jsxs(Button$1, {
4509
- "aria-current": i === word ? "true" : void 0,
4510
- "data-doubtful": isDoubtful(w, doubtfulBelow) ? "" : void 0,
4511
- onPress: () => onSeek(w.start, {
4833
+ children: phrase.words.map((w, i) => {
4834
+ const doubt = isDoubtful(w, doubtfulBelow);
4835
+ const looks = cn(doubt && "underline decoration-dotted decoration-2 underline-offset-4", w.correction && "underline decoration-dotted decoration-primary decoration-2 underline-offset-4");
4836
+ const said = /* @__PURE__ */ jsxs(Fragment, { children: [
4837
+ w.text,
4838
+ doubt && /* @__PURE__ */ jsx(VisuallyHidden, { children: " (doubtful)" }),
4839
+ w.correction && /* @__PURE__ */ jsxs(VisuallyHidden, { children: [
4840
+ " (corrected, was ",
4841
+ w.correction.original,
4842
+ ")"
4843
+ ] })
4844
+ ] });
4845
+ const hint = w.correction ? (el) => onHint(el ? {
4846
+ el,
4847
+ text: `Was “${w.correction.original}”${w.correction.by ? `, corrected by ${w.correction.by}` : ""}`
4848
+ } : null) : void 0;
4849
+ const press = w.correction && onCorrectionPress ? () => onCorrectionPress(phrase.id, i) : onSeek ? () => onSeek(w.start, {
4512
4850
  phraseId: phrase.id,
4513
4851
  wordIndex: i
4514
- }),
4515
- className: cn("rounded-control hover:bg-muted", isDoubtful(w, doubtfulBelow) && "underline decoration-dotted decoration-2 underline-offset-4", i === word && "font-medium underline decoration-2 underline-offset-4"),
4516
- children: [w.text, isDoubtful(w, doubtfulBelow) && /* @__PURE__ */ jsx(VisuallyHidden, { children: " (doubtful)" })]
4517
- })] }, i))
4852
+ }) : void 0;
4853
+ return /* @__PURE__ */ jsxs(React.Fragment, { children: [i > 0 && " ", marking ? /* @__PURE__ */ jsx(Mark, {
4854
+ id: wordId(phrase.id, i),
4855
+ className: cn(looks, i === word && "font-medium"),
4856
+ onClick: w.correction && onCorrectionPress ? press : void 0,
4857
+ onHover: hint,
4858
+ children: said
4859
+ }) : press ? /* @__PURE__ */ jsx(Button$1, {
4860
+ "aria-current": i === word ? "true" : void 0,
4861
+ "data-doubtful": doubt ? "" : void 0,
4862
+ onPress: press,
4863
+ onHoverStart: hint ? (e) => hint(e.target) : void 0,
4864
+ onHoverEnd: hint ? () => hint(null) : void 0,
4865
+ className: cn("rounded-control hover:bg-muted", looks, i === word && "font-medium underline decoration-2 underline-offset-4"),
4866
+ children: said
4867
+ }) : /* @__PURE__ */ jsx("span", {
4868
+ "aria-current": i === word ? "true" : void 0,
4869
+ "data-doubtful": doubt ? "" : void 0,
4870
+ onPointerEnter: hint ? (e) => hint(e.currentTarget) : void 0,
4871
+ onPointerLeave: hint ? () => hint(null) : void 0,
4872
+ className: cn("rounded-control", looks, i === word && "font-medium underline decoration-2 underline-offset-4"),
4873
+ children: said
4874
+ })] }, i);
4875
+ })
4518
4876
  })]
4519
4877
  }),
4520
4878
  (commands.length > 0 || actions) && !edit && /* @__PURE__ */ jsxs("div", {
@@ -4632,7 +4990,7 @@ function clampView(from, span, duration) {
4632
4990
  return [a, a + s];
4633
4991
  }
4634
4992
  // src/components/waveform.tsx
4635
- var TONE$2 = {
4993
+ var TONE$1 = {
4636
4994
  neutral: {
4637
4995
  fill: "var(--muted)",
4638
4996
  edge: "var(--muted-foreground)"
@@ -4966,7 +5324,7 @@ function Waveform({ label, peaks, source, duration: given, time, onSeek, marks =
4966
5324
  spans.map((s) => {
4967
5325
  const a = clamp$2(px(s.from), 0, width);
4968
5326
  const b = clamp$2(px(s.to), 0, width);
4969
- const tone = TONE$2[s.tone ?? "neutral"];
5327
+ const tone = TONE$1[s.tone ?? "neutral"];
4970
5328
  return b > a ? /* @__PURE__ */ jsxs("g", { children: [/* @__PURE__ */ jsx("rect", {
4971
5329
  x: a,
4972
5330
  y: 0,
@@ -5107,8 +5465,8 @@ function Waveform({ label, peaks, source, duration: given, time, onSeek, marks =
5107
5465
  children: [/* @__PURE__ */ jsx("span", {
5108
5466
  className: "h-2 w-3.5 rounded-sm border border-border",
5109
5467
  style: {
5110
- background: TONE$2[s.tone ?? "neutral"].fill,
5111
- borderTopColor: TONE$2[s.tone ?? "neutral"].edge,
5468
+ background: TONE$1[s.tone ?? "neutral"].fill,
5469
+ borderTopColor: TONE$1[s.tone ?? "neutral"].edge,
5112
5470
  borderTopWidth: 3
5113
5471
  }
5114
5472
  }), s.label]
@@ -13797,7 +14155,7 @@ function moveGutter(left, right, dx, { bounds, min }) {
13797
14155
  }];
13798
14156
  }
13799
14157
  // src/components/region-editor.tsx
13800
- var TONE$1 = {
14158
+ var TONE = {
13801
14159
  neutral: {
13802
14160
  edge: "var(--foreground)",
13803
14161
  fill: "var(--muted)"
@@ -14216,7 +14574,7 @@ function RegionEditor({ label, children, size, regions, onChange, selectedId, on
14216
14574
  })]
14217
14575
  }),
14218
14576
  shown.map((r) => {
14219
- const tone = TONE$1[r.tone ?? "neutral"];
14577
+ const tone = TONE[r.tone ?? "neutral"];
14220
14578
  const active = r.id === selected;
14221
14579
  return /* @__PURE__ */ jsxs("div", {
14222
14580
  role: "group",
@@ -14878,1212 +15236,937 @@ function BoxList({ label, boxes, state, renderBox, className }) {
14878
15236
  return /* @__PURE__ */ jsx(ListBox, {
14879
15237
  ref,
14880
15238
  "aria-label": label,
14881
- selectionMode: "single",
14882
- disallowEmptySelection: true,
14883
- selectedKeys: state.active ? [state.active] : [],
14884
- onSelectionChange: (keys) => {
14885
- const id = [...keys][0];
14886
- if (id !== void 0) state.choose(String(id), "list");
14887
- },
14888
- className: cn("min-w-0 overflow-y-auto rounded-surface border border-border", className),
14889
- children: order.map((id) => {
14890
- const b = byId.get(id);
14891
- return /* @__PURE__ */ jsx(ListBoxItem, {
14892
- id,
14893
- textValue: b.label,
14894
- onHoverStart: () => state.point(id),
14895
- onHoverEnd: () => state.point(null),
14896
- className: cn("flex cursor-pointer items-baseline gap-2 border-l-2 px-3 py-1.5 type-body-sm outline-offset-[-2px] transition-state", "selected:bg-surface-sunken selected:font-medium hover:bg-surface-sunken", state.pointed === id && "bg-surface-sunken"),
14897
- style: { borderLeftColor: (b.tone ?? "neutral") === "neutral" ? "transparent" : STROKE[b.tone ?? "neutral"] },
14898
- children: renderBox ? renderBox(b) : b.label
14899
- }, id);
14900
- })
14901
- });
14902
- }
14903
- // src/lib/sequence.ts
14904
- var EPS = 1e-9;
14905
- /** The grid point nearest to `time`, or `time` itself when there is no grid. */
14906
- function snapToGrid(time, grid) {
14907
- if (grid === void 0) return time;
14908
- if (typeof grid === "number") return grid > 0 ? tidy(Math.round(time / grid) * grid) : time;
14909
- let best = time;
14910
- let gap = Infinity;
14911
- for (const p of grid) if (Math.abs(p - time) < gap) [best, gap] = [p, Math.abs(p - time)];
14912
- return best;
14913
- }
14914
- /** The next grid point after `time` in a direction (`1` later, `-1` earlier); `fallback` is the step when there is no grid. A point `time` is already on is stepped past. */
14915
- function stepOnGrid(time, dir, grid, fallback) {
14916
- if (grid === void 0) return tidy(time + dir * fallback);
14917
- if (typeof grid === "number") {
14918
- if (grid <= 0) return tidy(time + dir * fallback);
14919
- return tidy((dir > 0 ? Math.floor(time / grid + EPS) + 1 : Math.ceil(time / grid - EPS) - 1) * grid);
14920
- }
14921
- const points = [...grid].sort((a, b) => a - b);
14922
- return (dir > 0 ? points.find((p) => p > time + EPS) : [...points].reverse().find((p) => p < time - EPS)) ?? tidy(time + dir * fallback);
14923
- }
14924
- /** Grid points inside `[from, to]`, for drawing on a ruler. At most `limit`, so a fine grid on a long axis stays cheap. */
14925
- function gridPoints(grid, from, to, limit = 2e3) {
14926
- if (grid === void 0) return [];
14927
- if (typeof grid !== "number") return grid.filter((p) => p >= from - EPS && p <= to + EPS).slice(0, limit);
14928
- if (grid <= 0) return [];
14929
- const out = [];
14930
- for (let i = Math.ceil(from / grid - EPS); i * grid <= to + EPS && out.length < limit; i++) out.push(tidy(i * grid) || 0);
14931
- return out;
14932
- }
14933
- /** Puts `time` inside the room, and says which end held it (with the app's reason) when one did. */
14934
- function clampToRoom(time, room) {
14935
- const t = clamp$1(time, room.min, room.max);
14936
- if (t > time + EPS) return {
14937
- time: t,
14938
- limit: {
14939
- side: "min",
14940
- at: room.min,
14941
- reason: room.minReason
14942
- }
14943
- };
14944
- if (t < time - EPS) return {
14945
- time: t,
14946
- limit: {
14947
- side: "max",
14948
- at: room.max,
14949
- reason: room.maxReason
14950
- }
14951
- };
14952
- return {
14953
- time: t,
14954
- limit: null
14955
- };
14956
- }
14957
- /** Where a dragged cut lands: held by the room (saying which end, if the pointer is beyond it), otherwise snapped to the grid, and never to a grid point outside the room. */
14958
- function settleCut(wanted, grid, room) {
14959
- const held = clampToRoom(wanted, room);
14960
- const snapped = snapToGrid(held.time, grid);
14961
- return {
14962
- time: snapped >= room.min - EPS && snapped <= room.max + EPS ? snapped : held.time,
14963
- limit: held.limit
14964
- };
14965
- }
14966
- // src/components/sequence-timeline.tsx
14967
- var seconds = (n) => `${tidy(Math.round(n * 10) / 10)} s`;
14968
- var at = (t) => tickLabel(t, .1);
14969
- /** A gapless strip of windows whose cuts are dragged or stepped, snapping to a beat grid inside the room the app gives; each cut is a slider that announces both windows' new lengths; Shift+click chooses a run. */
14970
- function SequenceTimeline({ label, items, zoom, onCutChange, room, minLength = .1, grid, step = .1, selected = [], onSelectRange, renderItem, height = "5rem", className }) {
14971
- const start = items[0]?.start ?? 0;
14972
- const end = items[items.length - 1]?.end ?? 0;
14973
- const span = Math.max(end - start, 1e-6);
14974
- const track = React.useRef(null);
14975
- const [fit, setFit] = React.useState(800);
14976
- React.useLayoutEffect(() => {
14977
- const el = track.current?.parentElement;
14978
- if (!el || typeof ResizeObserver === "undefined") return;
14979
- const read = () => setFit(el.clientWidth || 800);
14980
- read();
14981
- const ro = new ResizeObserver(read);
14982
- ro.observe(el);
14983
- return () => ro.disconnect();
14984
- }, []);
14985
- const pxPerUnit = zoom ?? fit / span;
14986
- const [drag, setDrag] = React.useState(null);
14987
- const [said, setSaid] = React.useState("");
14988
- const anchor = React.useRef(null);
14989
- const roomFor = React.useCallback((i) => room?.(i) ?? {
14990
- min: items[i].start + minLength,
14991
- max: items[i + 1].end - minLength
14992
- }, [
14993
- room,
14994
- items,
14995
- minLength
14996
- ]);
14997
- const view = items.map((it, i) => ({
14998
- ...it,
14999
- start: drag && drag.index === i - 1 ? drag.time : it.start,
15000
- end: drag && drag.index === i ? drag.time : it.end
15001
- }));
15002
- const change = (i, time) => ({
15003
- before: {
15004
- ...items[i],
15005
- end: time
15006
- },
15007
- after: {
15008
- ...items[i + 1],
15009
- start: time
15010
- }
15011
- });
15012
- const words = (i, time) => `Cut ${i + 1} moved to ${at(time)}. Window ${i + 1} is ${seconds(time - items[i].start)}, window ${i + 2} is ${seconds(items[i + 1].end - time)}.`;
15013
- const timeAt = (clientX) => {
15014
- const box = track.current?.getBoundingClientRect();
15015
- if (!box || !box.width) return start;
15016
- return start + (clientX - box.left) / box.width * span;
15017
- };
15018
- const keys = (e, i) => {
15019
- const r = roomFor(i);
15020
- const now = items[i].end;
15021
- let target = null;
15022
- if (e.key === "ArrowLeft" || e.key === "ArrowRight") {
15023
- const dir = e.key === "ArrowRight" ? 1 : -1;
15024
- target = e.shiftKey ? now + dir : stepOnGrid(now, dir, grid, step);
15025
- } else if (e.key === "Home") target = r.min;
15026
- else if (e.key === "End") target = r.max;
15027
- if (target === null) return;
15028
- e.preventDefault();
15029
- const { time, limit } = clampToRoom(tidy(target), r);
15030
- if (Math.abs(time - now) < 1e-9) {
15031
- const why = limit?.reason ?? (e.key === "End" || e.key === "ArrowRight" ? r.maxReason : r.minReason);
15032
- setSaid(`Cut ${i + 1} stays at ${at(now)}.${why ? ` ${why}` : ""}`);
15033
- return;
15034
- }
15035
- onCutChange(i, time, change(i, time));
15036
- setSaid(words(i, time) + (limit?.reason ? ` ${limit.reason}` : ""));
15037
- };
15038
- const begin = (e, i) => {
15039
- if (e.button !== 0) return;
15040
- e.currentTarget.setPointerCapture?.(e.pointerId);
15041
- setDrag({
15042
- index: i,
15043
- time: items[i].end,
15044
- refused: null
15045
- });
15046
- };
15047
- const drive = (e) => {
15048
- if (!drag) return;
15049
- const { time, limit } = settleCut(timeAt(e.clientX), grid, roomFor(drag.index));
15050
- setDrag({
15051
- index: drag.index,
15052
- time,
15053
- refused: limit ? `Cut ${drag.index + 1} stops at ${at(limit.at)}.${limit.reason ? ` ${limit.reason}` : ""}` : null
15054
- });
15055
- };
15056
- const release = () => {
15057
- if (!drag) return;
15058
- const d = drag;
15059
- setDrag(null);
15060
- if (Math.abs(d.time - items[d.index].end) > 1e-9) {
15061
- onCutChange(d.index, d.time, change(d.index, d.time));
15062
- setSaid(words(d.index, d.time) + (d.refused ? ` ${d.refused}` : ""));
15063
- } else if (d.refused) setSaid(d.refused);
15064
- };
15065
- const step0 = tickStep(pxPerUnit);
15066
- const ticks = ticksBetween(start, end, step0);
15067
- const all = gridPoints(grid, start, end);
15068
- const beats = (end - start) / Math.max(all.length, 1) * pxPerUnit >= 4 ? all : [];
15069
- const pct = (t) => `${(t - start) / span * 100}%`;
15070
- const choose = (e, id) => {
15071
- if (!onSelectRange) return;
15072
- const here = items.findIndex((x) => x.id === id);
15073
- const from = anchor.current ? items.findIndex((x) => x.id === anchor.current) : -1;
15074
- if (e.shiftKey && from >= 0) {
15075
- const [a, b] = from <= here ? [from, here] : [here, from];
15076
- onSelectRange(items.slice(a, b + 1).map((x) => x.id));
15077
- } else {
15078
- anchor.current = id;
15079
- onSelectRange([id]);
15080
- }
15081
- };
15082
- return /* @__PURE__ */ jsxs("div", {
15083
- className: cn("min-w-0", className),
15084
- children: [
15085
- /* @__PURE__ */ jsx("div", {
15086
- role: "group",
15087
- "aria-label": label,
15088
- className: "overflow-x-auto pb-2",
15089
- children: /* @__PURE__ */ jsxs("div", {
15090
- ref: track,
15091
- className: "relative",
15092
- style: { width: zoom ? `${span * zoom}px` : "100%" },
15093
- children: [/* @__PURE__ */ jsxs("div", {
15094
- "aria-hidden": true,
15095
- className: "relative h-6 border-b border-border",
15096
- children: [ticks.map((t) => /* @__PURE__ */ jsx("span", {
15097
- className: "absolute top-0 -translate-x-1/2 type-caption tabular-nums text-muted-foreground",
15098
- style: { left: pct(t) },
15099
- children: tickLabel(t, step0)
15100
- }, t)), beats.map((p) => /* @__PURE__ */ jsx("span", {
15101
- "data-beat": true,
15102
- className: "absolute bottom-0 h-1.5 w-px bg-border",
15103
- style: { left: pct(p) }
15104
- }, `b${p}`))]
15105
- }), /* @__PURE__ */ jsxs("div", {
15106
- className: "relative mt-1",
15107
- style: { height },
15108
- children: [view.map((it) => {
15109
- const on = selected.includes(it.id);
15110
- return /* @__PURE__ */ jsx("button", {
15111
- type: "button",
15112
- "aria-pressed": on,
15113
- "aria-label": `${it.label}, ${at(it.start)} to ${at(it.end)}`,
15114
- onClick: (e) => choose(e, it.id),
15115
- className: cn("absolute inset-y-0 min-w-0 cursor-pointer overflow-hidden rounded-control border px-1.5 text-left transition-state", on ? "border-primary bg-primary/10" : "border-border bg-muted hover:bg-muted/70"),
15116
- style: {
15117
- left: pct(it.start),
15118
- width: `calc(${(it.end - it.start) / span * 100}% - 2px)`
15119
- },
15120
- children: renderItem ? renderItem(it, on) : /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("span", {
15121
- className: "block truncate type-label",
15122
- children: it.label
15123
- }), /* @__PURE__ */ jsx("span", {
15124
- className: "block truncate type-caption tabular-nums text-muted-foreground",
15125
- children: seconds(it.end - it.start)
15126
- })] })
15127
- }, it.id);
15128
- }), items.slice(0, -1).map((it, i) => {
15129
- const r = roomFor(i);
15130
- const now = drag?.index === i ? drag.time : it.end;
15131
- return /* @__PURE__ */ jsx("div", {
15132
- role: "slider",
15133
- tabIndex: 0,
15134
- "aria-label": `Cut ${i + 1}, between window ${i + 1} and window ${i + 2}`,
15135
- "aria-orientation": "horizontal",
15136
- "aria-valuemin": r.min,
15137
- "aria-valuemax": r.max,
15138
- "aria-valuenow": now,
15139
- "aria-valuetext": at(now),
15140
- "data-cut": i,
15141
- onKeyDown: (e) => keys(e, i),
15142
- onPointerDown: (e) => begin(e, i),
15143
- onPointerMove: drive,
15144
- onPointerUp: release,
15145
- onPointerCancel: () => setDrag(null),
15146
- className: "group absolute inset-y-0 z-10 w-3 -translate-x-1/2 cursor-ew-resize touch-none outline-offset-1",
15147
- style: { left: pct(now) },
15148
- children: /* @__PURE__ */ jsx("span", { className: "absolute inset-y-0 left-1/2 w-0.5 -translate-x-1/2 rounded-pill bg-foreground group-hover:w-1 group-focus-visible:w-1" })
15149
- }, `cut${it.id}`);
15150
- })]
15151
- })]
15152
- })
15153
- }),
15154
- drag?.refused && /* @__PURE__ */ jsxs("p", {
15155
- className: "mt-1 flex items-center gap-1.5 type-body-sm text-danger",
15156
- children: [
15157
- /* @__PURE__ */ jsx(Ban, {
15158
- className: "size-4 shrink-0",
15159
- "aria-hidden": true
15160
- }),
15161
- " ",
15162
- drag.refused
15163
- ]
15164
- }),
15165
- /* @__PURE__ */ jsx("div", {
15166
- role: "status",
15167
- "aria-live": "polite",
15168
- className: "sr-only",
15169
- children: said
15170
- })
15171
- ]
15172
- });
15173
- }
15174
- // src/components/tree.tsx
15175
- var Context = React.createContext(null);
15176
- var useCtx = () => React.useContext(Context);
15177
- var NOTE = "\0";
15178
- var isNote = (key) => key.includes(NOTE);
15179
- var ROW = "flex min-h-(--control-h-sm) min-w-0 items-center gap-1 rounded-control pr-2 type-body-sm";
15180
- function Row$1({ level, children }) {
15181
- return /* @__PURE__ */ jsx("div", {
15182
- className: ROW,
15183
- style: { paddingInlineStart: `${level * 1.25 + .25}rem` },
15184
- children
15185
- });
15186
- }
15187
- function Node$1({ node }) {
15188
- const c = useCtx();
15189
- const key = c.nodeKey(node);
15190
- c.nodes.set(key, node);
15191
- const branch = c.isBranch ? c.isBranch(node) : true;
15192
- const open = branch && c.expanded.isOpen(key);
15193
- const name = c.nodeLabel(node);
15194
- const nodeCount = c.count?.(node);
15195
- const badge = c.badge?.(node);
15196
- const because = c.choices?.implied.has(key) ? c.choices.because(key).map((k) => c.nodes.has(k) ? c.nodeLabel(c.nodes.get(k)) : k) : [];
15197
- return /* @__PURE__ */ jsxs(TreeItem, {
15198
- id: key,
15199
- textValue: name,
15200
- hasChildItems: branch,
15201
- className: "outline-none",
15202
- children: [/* @__PURE__ */ jsx(TreeItemContent, { children: ({ level, isSelected, isExpanded }) => /* @__PURE__ */ jsxs("div", {
15203
- title: name,
15204
- className: cn(ROW, "cursor-pointer outline-offset-[-2px] hover:bg-muted", (isSelected || c.current === key) && "bg-surface-sunken font-medium"),
15205
- style: { paddingInlineStart: `${(level - 1) * 1.25 + .25}rem` },
15206
- "data-selected": isSelected || void 0,
15207
- "aria-current": c.current === key ? "true" : void 0,
15208
- "data-current": c.current === key || void 0,
15209
- children: [
15210
- c.choices && /* @__PURE__ */ jsx(TableSelectionCheckbox, {
15211
- label: `Choose ${name}`,
15212
- mixed: c.stateOf(key) === "mixed"
15213
- }),
15214
- branch ? /* @__PURE__ */ jsx(Button$1, {
15215
- slot: "chevron",
15216
- className: "grid size-6 shrink-0 place-items-center rounded-control text-muted-foreground",
15217
- children: /* @__PURE__ */ jsx(ChevronRight, {
15218
- "aria-hidden": true,
15219
- className: cn("size-4", isExpanded && "rotate-90")
15220
- })
15221
- }) : /* @__PURE__ */ jsx("span", {
15222
- "aria-hidden": true,
15223
- className: "size-6 shrink-0"
15224
- }),
15225
- branch ? isExpanded ? /* @__PURE__ */ jsx(FolderOpen, {
15226
- "aria-hidden": true,
15227
- className: "size-4 shrink-0 text-muted-foreground"
15228
- }) : /* @__PURE__ */ jsx(Folder, {
15229
- "aria-hidden": true,
15230
- className: "size-4 shrink-0 text-muted-foreground"
15231
- }) : null,
15232
- /* @__PURE__ */ jsx("span", {
15233
- className: "min-w-0 flex-1 truncate",
15234
- children: c.renderNode ? c.renderNode(node, {
15235
- expanded: isExpanded,
15236
- selected: isSelected,
15237
- level,
15238
- branch
15239
- }) : name
15240
- }),
15241
- badge && /* @__PURE__ */ jsx(Status, {
15242
- tone: badge.tone ?? "info",
15243
- children: badge.label
15244
- }),
15245
- nodeCount != null && /* @__PURE__ */ jsx("span", {
15246
- className: "shrink-0 type-caption text-muted-foreground tabular-nums",
15247
- children: typeof nodeCount === "number" ? format.integer(nodeCount) : nodeCount
15248
- }),
15249
- because.length > 0 && /* @__PURE__ */ jsxs("span", {
15250
- className: "flex max-w-[50%] shrink-0 items-center gap-1 truncate type-caption text-muted-foreground",
15251
- title: `Included because of ${because.join(", ")}`,
15252
- children: [/* @__PURE__ */ jsx(Lock, {
15253
- "aria-hidden": true,
15254
- className: "size-3 shrink-0"
15255
- }), /* @__PURE__ */ jsxs("span", {
15256
- className: "truncate",
15257
- children: [
15258
- "Included because of ",
15259
- because.slice(0, 2).join(", "),
15260
- because.length > 2 ? ` and ${because.length - 2} more` : ""
15261
- ]
15262
- })]
15263
- })
15264
- ]
15265
- }) }), open ? /* @__PURE__ */ jsx(Children, { node }) : branch && /* @__PURE__ */ jsx(ClosedChild, { id: `${key}${NOTE}closed` })]
15266
- });
15267
- }
15268
- function ClosedChild({ id }) {
15269
- return /* @__PURE__ */ jsx(TreeItem, {
15270
- id,
15271
- textValue: "",
15272
- isDisabled: true,
15273
- children: /* @__PURE__ */ jsx(TreeItemContent, { children: () => null })
15274
- }, "closed");
15275
- }
15276
- function Nodes({ nodes }) {
15277
- const c = useCtx();
15278
- return /* @__PURE__ */ jsx(Fragment, { children: c.sorted(nodes).map((n) => /* @__PURE__ */ jsx(Node$1, { node: n }, c.nodeKey(n))) });
15279
- }
15280
- function Children({ node }) {
15281
- const c = useCtx();
15282
- const key = c.nodeKey(node);
15283
- const load = c.useChildren(node);
15284
- const ready = load.status === "ready" ? load.data : void 0;
15285
- React.useEffect(() => {
15286
- if (ready) c.settle(key, ready);
15287
- }, [ready]);
15288
- if (load.status === "loading") return /* @__PURE__ */ jsx(TreeItem, {
15289
- id: `${key}${NOTE}loading`,
15290
- textValue: "Loading",
15291
- isDisabled: true,
15292
- className: "outline-none",
15293
- children: /* @__PURE__ */ jsx(TreeItemContent, { children: ({ level }) => /* @__PURE__ */ jsxs(Row$1, {
15294
- level: level - 1,
15295
- children: [
15296
- /* @__PURE__ */ jsx("span", {
15297
- "aria-hidden": true,
15298
- className: "size-6 shrink-0"
15299
- }),
15300
- /* @__PURE__ */ jsx("span", {
15301
- role: "status",
15302
- className: "sr-only",
15303
- children: "Loading"
15304
- }),
15305
- c.loadingRow ?? /* @__PURE__ */ jsx("span", {
15306
- "aria-hidden": true,
15307
- className: "h-3 w-32 animate-pulse rounded-pill bg-muted"
15308
- })
15309
- ]
15310
- }) })
15311
- }, "loading");
15312
- if (load.status === "error") return /* @__PURE__ */ jsx(TreeItem, {
15313
- id: `${key}${NOTE}error`,
15314
- textValue: load.message,
15315
- className: "outline-none",
15316
- children: /* @__PURE__ */ jsx(TreeItemContent, { children: ({ level }) => /* @__PURE__ */ jsxs(Row$1, {
15317
- level: level - 1,
15318
- children: [
15319
- /* @__PURE__ */ jsx(CircleAlert, {
15320
- "aria-hidden": true,
15321
- className: "size-4 shrink-0 text-danger"
15322
- }),
15323
- /* @__PURE__ */ jsx("span", {
15324
- className: "min-w-0 flex-1 truncate text-danger",
15325
- title: load.message,
15326
- children: load.message
15327
- }),
15328
- /* @__PURE__ */ jsx(Button, {
15329
- size: "sm",
15330
- onPress: load.retry,
15331
- children: "Try again"
15332
- })
15333
- ]
15334
- }) })
15335
- }, "error");
15336
- if (load.data.length === 0) return /* @__PURE__ */ jsx(TreeItem, {
15337
- id: `${key}${NOTE}empty`,
15338
- textValue: c.emptyRow,
15339
- isDisabled: true,
15340
- className: "outline-none",
15341
- children: /* @__PURE__ */ jsx(TreeItemContent, { children: ({ level }) => /* @__PURE__ */ jsxs(Row$1, {
15342
- level: level - 1,
15343
- children: [/* @__PURE__ */ jsx("span", {
15344
- "aria-hidden": true,
15345
- className: "size-6 shrink-0"
15346
- }), /* @__PURE__ */ jsx("span", {
15347
- className: "text-muted-foreground",
15348
- children: c.emptyRow
15349
- })]
15350
- }) })
15351
- }, "empty");
15352
- c.childKeys.set(key, c.sorted(load.data).map(c.nodeKey));
15353
- return /* @__PURE__ */ jsx(Nodes, { nodes: load.data });
15354
- }
15355
- /** A hierarchy whose children load as each node opens (a `useChildren` hook per open node): a skeleton row, a Try again row and an "empty" row per node, type-ahead and arrow keys, single selection, open state optionally in the URL, always virtualised. */
15356
- function Tree({ label, roots, useChildren, nodeKey, nodeLabel, isBranch, renderNode, selected, onSelect, choices, current, onCurrentChange, count, badge, sortChildren, reveal, resolveBranch, coverNoun = ["item", "items"], expanded, beforeOpen, loadingRow, emptyRow, height = "24rem", className }) {
15357
- const nodes = React.useRef(/* @__PURE__ */ new Map()).current;
15358
- const [covered, setCovered] = React.useState("");
15359
- const scroller = React.useRef(null);
15360
- const scrollToReveal = React.useRef(() => {});
15361
- const sorted = React.useCallback((list) => sortChildren ? [...list].sort(sortChildren) : list, [sortChildren]);
15362
- const childKeys = React.useRef(/* @__PURE__ */ new Map()).current;
15363
- const resolved = React.useRef(/* @__PURE__ */ new Map()).current;
15364
- const below = (key) => [.../* @__PURE__ */ new Set([...(childKeys.get(key) ?? []).flatMap((k) => [k, ...below(k)]), ...resolved.get(key) ?? []])];
15365
- const stateOf = (key) => {
15366
- const all = choices?.selected;
15367
- const own = all?.has(key) ?? false;
15368
- const ds = below(key);
15369
- if (ds.length === 0) return own ? "on" : "off";
15370
- const chosen = ds.filter((k) => all?.has(k)).length;
15371
- if (chosen === ds.length) return "on";
15372
- return chosen === 0 && !own ? "off" : "mixed";
15373
- };
15374
- const awaiting = React.useRef(/* @__PURE__ */ new Set()).current;
15375
- const latest = React.useRef({
15376
- expanded,
15377
- choices
15239
+ selectionMode: "single",
15240
+ disallowEmptySelection: true,
15241
+ selectedKeys: state.active ? [state.active] : [],
15242
+ onSelectionChange: (keys) => {
15243
+ const id = [...keys][0];
15244
+ if (id !== void 0) state.choose(String(id), "list");
15245
+ },
15246
+ className: cn("min-w-0 overflow-y-auto rounded-surface border border-border", className),
15247
+ children: order.map((id) => {
15248
+ const b = byId.get(id);
15249
+ return /* @__PURE__ */ jsx(ListBoxItem, {
15250
+ id,
15251
+ textValue: b.label,
15252
+ onHoverStart: () => state.point(id),
15253
+ onHoverEnd: () => state.point(null),
15254
+ className: cn("flex cursor-pointer items-baseline gap-2 border-l-2 px-3 py-1.5 type-body-sm outline-offset-[-2px] transition-state", "selected:bg-surface-sunken selected:font-medium hover:bg-surface-sunken", state.pointed === id && "bg-surface-sunken"),
15255
+ style: { borderLeftColor: (b.tone ?? "neutral") === "neutral" ? "transparent" : STROKE[b.tone ?? "neutral"] },
15256
+ children: renderBox ? renderBox(b) : b.label
15257
+ }, id);
15258
+ })
15378
15259
  });
15379
- latest.current = {
15380
- expanded,
15381
- choices
15382
- };
15383
- const opening = React.useRef(/* @__PURE__ */ new Set()).current;
15384
- const open = (keys) => {
15385
- for (const k of keys) opening.add(k);
15386
- latest.current.expanded.onChange(/* @__PURE__ */ new Set([...latest.current.expanded.expanded, ...opening]));
15387
- };
15388
- const unread = (key) => {
15389
- const node = nodes.get(key);
15390
- return node !== void 0 && (isBranch ? isBranch(node) : true) && !childKeys.has(key);
15391
- };
15392
- const tick = (keys) => {
15393
- const toResolve = resolveBranch ? keys.filter(unread) : [];
15394
- for (const k of toResolve) {
15395
- const node = nodes.get(k);
15396
- resolveBranch(node).then((under) => {
15397
- resolved.set(k, under);
15398
- latest.current.choices?.add([k, ...under]);
15399
- setCovered(`${nodeLabel(node)} and its ${under.length === 1 ? `1 ${coverNoun[0]}` : `${format.integer(under.length)} ${coverNoun[1]}`}`);
15400
- });
15260
+ }
15261
+ // src/lib/sequence.ts
15262
+ var EPS = 1e-9;
15263
+ /** The grid point nearest to `time`, or `time` itself when there is no grid. */
15264
+ function snapToGrid(time, grid) {
15265
+ if (grid === void 0) return time;
15266
+ if (typeof grid === "number") return grid > 0 ? tidy(Math.round(time / grid) * grid) : time;
15267
+ let best = time;
15268
+ let gap = Infinity;
15269
+ for (const p of grid) if (Math.abs(p - time) < gap) [best, gap] = [p, Math.abs(p - time)];
15270
+ return best;
15271
+ }
15272
+ /** The next grid point after `time` in a direction (`1` later, `-1` earlier); `fallback` is the step when there is no grid. A point `time` is already on is stepped past. */
15273
+ function stepOnGrid(time, dir, grid, fallback) {
15274
+ if (grid === void 0) return tidy(time + dir * fallback);
15275
+ if (typeof grid === "number") {
15276
+ if (grid <= 0) return tidy(time + dir * fallback);
15277
+ return tidy((dir > 0 ? Math.floor(time / grid + EPS) + 1 : Math.ceil(time / grid - EPS) - 1) * grid);
15278
+ }
15279
+ const points = [...grid].sort((a, b) => a - b);
15280
+ return (dir > 0 ? points.find((p) => p > time + EPS) : [...points].reverse().find((p) => p < time - EPS)) ?? tidy(time + dir * fallback);
15281
+ }
15282
+ /** Grid points inside `[from, to]`, for drawing on a ruler. At most `limit`, so a fine grid on a long axis stays cheap. */
15283
+ function gridPoints(grid, from, to, limit = 2e3) {
15284
+ if (grid === void 0) return [];
15285
+ if (typeof grid !== "number") return grid.filter((p) => p >= from - EPS && p <= to + EPS).slice(0, limit);
15286
+ if (grid <= 0) return [];
15287
+ const out = [];
15288
+ for (let i = Math.ceil(from / grid - EPS); i * grid <= to + EPS && out.length < limit; i++) out.push(tidy(i * grid) || 0);
15289
+ return out;
15290
+ }
15291
+ /** Puts `time` inside the room, and says which end held it (with the app's reason) when one did. */
15292
+ function clampToRoom(time, room) {
15293
+ const t = clamp$1(time, room.min, room.max);
15294
+ if (t > time + EPS) return {
15295
+ time: t,
15296
+ limit: {
15297
+ side: "min",
15298
+ at: room.min,
15299
+ reason: room.minReason
15401
15300
  }
15402
- const toOpen = keys.filter((k) => unread(k) && !toResolve.includes(k));
15403
- for (const k of toOpen) awaiting.add(k);
15404
- if (toOpen.length) open(toOpen);
15405
15301
  };
15406
- const settle = (key, kids) => {
15407
- opening.delete(key);
15408
- scrollToReveal.current();
15409
- if (!awaiting.delete(key) || !latest.current.choices) return;
15410
- const keys = kids.map(nodeKey);
15411
- for (const kid of kids) nodes.set(nodeKey(kid), kid);
15412
- latest.current.choices.add(keys);
15413
- tick(keys);
15302
+ if (t < time - EPS) return {
15303
+ time: t,
15304
+ limit: {
15305
+ side: "max",
15306
+ at: room.max,
15307
+ reason: room.maxReason
15308
+ }
15414
15309
  };
15415
- const ctx = {
15416
- useChildren,
15417
- nodeKey,
15418
- nodeLabel,
15419
- isBranch,
15420
- renderNode,
15421
- expanded,
15422
- loadingRow,
15423
- emptyRow,
15424
- nodes,
15425
- childKeys,
15426
- choices,
15427
- stateOf,
15428
- settle,
15429
- current,
15430
- sorted,
15431
- count,
15432
- badge
15310
+ return {
15311
+ time: t,
15312
+ limit: null
15433
15313
  };
15434
- const revealed = reveal?.join("");
15435
- React.useEffect(() => {
15436
- if (!reveal || reveal.length === 0) return;
15437
- const ancestors = reveal.slice(0, -1).filter((k) => !latest.current.expanded.isOpen(k));
15438
- if (ancestors.length) latest.current.expanded.onChange(/* @__PURE__ */ new Set([...latest.current.expanded.expanded, ...ancestors]));
15439
- }, [revealed]);
15440
- scrollToReveal.current = () => {
15441
- if (!reveal || reveal.length === 0 || roots.status !== "ready" || !scroller.current) return;
15442
- const walk = (keys) => sorted(keys.map((k) => nodes.get(k)).filter((n) => n !== void 0)).map(nodeKey).flatMap((k) => latest.current.expanded.isOpen(k) && childKeys.has(k) ? [k, ...walk(childKeys.get(k))] : [k]);
15443
- const i = walk(sorted(roots.data).map(nodeKey)).indexOf(reveal[reveal.length - 1]);
15444
- if (i >= 0) scroller.current.scrollTop = Math.max(0, i * 32 - 32);
15314
+ }
15315
+ /** Where a dragged cut lands: held by the room (saying which end, if the pointer is beyond it), otherwise snapped to the grid, and never to a grid point outside the room. */
15316
+ function settleCut(wanted, grid, room) {
15317
+ const held = clampToRoom(wanted, room);
15318
+ const snapped = snapToGrid(held.time, grid);
15319
+ return {
15320
+ time: snapped >= room.min - EPS && snapped <= room.max + EPS ? snapped : held.time,
15321
+ limit: held.limit
15445
15322
  };
15446
- React.useEffect(() => scrollToReveal.current());
15447
- if (roots.status === "loading") return /* @__PURE__ */ jsx("div", {
15448
- role: "status",
15449
- "aria-label": `${label}: loading`,
15450
- className: cn("space-y-2 p-2", className),
15451
- children: [
15452
- 0,
15453
- 1,
15454
- 2,
15455
- 3
15456
- ].map((i) => /* @__PURE__ */ jsx("div", {
15457
- "aria-hidden": true,
15458
- className: "h-4 animate-pulse rounded-pill bg-muted",
15459
- style: { width: `${70 - i * 10}%` }
15460
- }, i))
15461
- });
15462
- if (roots.status === "error") return /* @__PURE__ */ jsxs("div", {
15463
- role: "alert",
15464
- className: cn("flex items-center gap-3 rounded-surface bg-danger-subtle p-3 text-danger", className),
15465
- children: [
15466
- /* @__PURE__ */ jsx(CircleAlert, {
15467
- "aria-hidden": true,
15468
- className: "size-5 shrink-0"
15469
- }),
15470
- /* @__PURE__ */ jsx("p", {
15471
- className: "min-w-0 flex-1 type-body-sm",
15472
- children: roots.message
15473
- }),
15474
- /* @__PURE__ */ jsx(Button, {
15475
- size: "sm",
15476
- onPress: roots.retry,
15477
- children: "Try again"
15478
- })
15479
- ]
15323
+ }
15324
+ // src/components/sequence-timeline.tsx
15325
+ var seconds = (n) => `${tidy(Math.round(n * 10) / 10)} s`;
15326
+ var at = (t) => tickLabel(t, .1);
15327
+ /** A gapless strip of windows whose cuts are dragged or stepped, snapping to a beat grid inside the room the app gives; each cut is a slider that announces both windows' new lengths; Shift+click chooses a run. */
15328
+ function SequenceTimeline({ label, items, zoom, onCutChange, room, minLength = .1, grid, step = .1, selected = [], onSelectRange, renderItem, height = "5rem", className }) {
15329
+ const start = items[0]?.start ?? 0;
15330
+ const end = items[items.length - 1]?.end ?? 0;
15331
+ const span = Math.max(end - start, 1e-6);
15332
+ const track = React.useRef(null);
15333
+ const [fit, setFit] = React.useState(800);
15334
+ React.useLayoutEffect(() => {
15335
+ const el = track.current?.parentElement;
15336
+ if (!el || typeof ResizeObserver === "undefined") return;
15337
+ const read = () => setFit(el.clientWidth || 800);
15338
+ read();
15339
+ const ro = new ResizeObserver(read);
15340
+ ro.observe(el);
15341
+ return () => ro.disconnect();
15342
+ }, []);
15343
+ const pxPerUnit = zoom ?? fit / span;
15344
+ const [drag, setDrag] = React.useState(null);
15345
+ const [said, setSaid] = React.useState("");
15346
+ const anchor = React.useRef(null);
15347
+ const roomFor = React.useCallback((i) => room?.(i) ?? {
15348
+ min: items[i].start + minLength,
15349
+ max: items[i + 1].end - minLength
15350
+ }, [
15351
+ room,
15352
+ items,
15353
+ minLength
15354
+ ]);
15355
+ const view = items.map((it, i) => ({
15356
+ ...it,
15357
+ start: drag && drag.index === i - 1 ? drag.time : it.start,
15358
+ end: drag && drag.index === i ? drag.time : it.end
15359
+ }));
15360
+ const change = (i, time) => ({
15361
+ before: {
15362
+ ...items[i],
15363
+ end: time
15364
+ },
15365
+ after: {
15366
+ ...items[i + 1],
15367
+ start: time
15368
+ }
15480
15369
  });
15481
- const choose = (keys) => {
15482
- const first = keys === "all" ? void 0 : [...keys][0];
15483
- if (first === void 0 || isNote(String(first))) return;
15484
- const key = String(first);
15485
- const node = nodes.get(key);
15486
- if (node !== void 0) onSelect?.(key, node);
15487
- };
15488
- const displayKeys = choices ? [.../* @__PURE__ */ new Set([...choices.selected, ...nodes.keys()])].filter((k) => stateOf(k) === "on" || choices.selected.has(k) && !nodes.has(k)) : [];
15489
- const shown = () => {
15490
- const walk = (keys) => keys.flatMap((k) => expanded.isOpen(k) && childKeys.has(k) ? [k, ...walk(childKeys.get(k))] : [k]);
15491
- return walk(roots.data.map(nodeKey));
15370
+ const words = (i, time) => `Cut ${i + 1} moved to ${at(time)}. Window ${i + 1} is ${seconds(time - items[i].start)}, window ${i + 2} is ${seconds(items[i + 1].end - time)}.`;
15371
+ const timeAt = (clientX) => {
15372
+ const box = track.current?.getBoundingClientRect();
15373
+ if (!box || !box.width) return start;
15374
+ return start + (clientX - box.left) / box.width * span;
15492
15375
  };
15493
- const chooseMany = (keys) => {
15494
- if (!choices) return;
15495
- const wanted = new Set(choices.selected);
15496
- if (keys === "all") {
15497
- const rows = shown().flatMap((k) => [k, ...below(k)]);
15498
- for (const x of rows) wanted.add(x);
15499
- choices.onChange(wanted);
15500
- tick(rows);
15376
+ const keys = (e, i) => {
15377
+ const r = roomFor(i);
15378
+ const now = items[i].end;
15379
+ let target = null;
15380
+ if (e.key === "ArrowLeft" || e.key === "ArrowRight") {
15381
+ const dir = e.key === "ArrowRight" ? 1 : -1;
15382
+ target = e.shiftKey ? now + dir : stepOnGrid(now, dir, grid, step);
15383
+ } else if (e.key === "Home") target = r.min;
15384
+ else if (e.key === "End") target = r.max;
15385
+ if (target === null) return;
15386
+ e.preventDefault();
15387
+ const { time, limit } = clampToRoom(tidy(target), r);
15388
+ if (Math.abs(time - now) < 1e-9) {
15389
+ const why = limit?.reason ?? (e.key === "End" || e.key === "ArrowRight" ? r.maxReason : r.minReason);
15390
+ setSaid(`Cut ${i + 1} stays at ${at(now)}.${why ? ` ${why}` : ""}`);
15501
15391
  return;
15502
15392
  }
15503
- const display = new Set(displayKeys);
15504
- const next = new Set([...keys].map(String).filter((k) => !isNote(k)));
15505
- for (const k of /* @__PURE__ */ new Set([...next, ...display])) {
15506
- if (next.has(k) === display.has(k)) continue;
15507
- const under = [k, ...below(k)];
15508
- for (const x of under) if (next.has(k)) wanted.add(x);
15509
- else {
15510
- wanted.delete(x);
15511
- awaiting.delete(x);
15512
- }
15513
- if (next.has(k)) tick(under);
15393
+ onCutChange(i, time, change(i, time));
15394
+ setSaid(words(i, time) + (limit?.reason ? ` ${limit.reason}` : ""));
15395
+ };
15396
+ const begin = (e, i) => {
15397
+ if (e.button !== 0) return;
15398
+ e.currentTarget.setPointerCapture?.(e.pointerId);
15399
+ setDrag({
15400
+ index: i,
15401
+ time: items[i].end,
15402
+ refused: null
15403
+ });
15404
+ };
15405
+ const drive = (e) => {
15406
+ if (!drag) return;
15407
+ const { time, limit } = settleCut(timeAt(e.clientX), grid, roomFor(drag.index));
15408
+ setDrag({
15409
+ index: drag.index,
15410
+ time,
15411
+ refused: limit ? `Cut ${drag.index + 1} stops at ${at(limit.at)}.${limit.reason ? ` ${limit.reason}` : ""}` : null
15412
+ });
15413
+ };
15414
+ const release = () => {
15415
+ if (!drag) return;
15416
+ const d = drag;
15417
+ setDrag(null);
15418
+ if (Math.abs(d.time - items[d.index].end) > 1e-9) {
15419
+ onCutChange(d.index, d.time, change(d.index, d.time));
15420
+ setSaid(words(d.index, d.time) + (d.refused ? ` ${d.refused}` : ""));
15421
+ } else if (d.refused) setSaid(d.refused);
15422
+ };
15423
+ const step0 = tickStep(pxPerUnit);
15424
+ const ticks = ticksBetween(start, end, step0);
15425
+ const all = gridPoints(grid, start, end);
15426
+ const beats = (end - start) / Math.max(all.length, 1) * pxPerUnit >= 4 ? all : [];
15427
+ const pct = (t) => `${(t - start) / span * 100}%`;
15428
+ const choose = (e, id) => {
15429
+ if (!onSelectRange) return;
15430
+ const here = items.findIndex((x) => x.id === id);
15431
+ const from = anchor.current ? items.findIndex((x) => x.id === anchor.current) : -1;
15432
+ if (e.shiftKey && from >= 0) {
15433
+ const [a, b] = from <= here ? [from, here] : [here, from];
15434
+ onSelectRange(items.slice(a, b + 1).map((x) => x.id));
15435
+ } else {
15436
+ anchor.current = id;
15437
+ onSelectRange([id]);
15514
15438
  }
15515
- choices.onChange(wanted);
15516
15439
  };
15517
- const tree = /* @__PURE__ */ jsx(Tree$1, {
15518
- ref: scroller,
15519
- "aria-label": label,
15520
- onAction: onCurrentChange ? (key) => {
15521
- const k = String(key);
15522
- const node = nodes.get(k);
15523
- if (!isNote(k) && node !== void 0) onCurrentChange(k, node);
15524
- } : void 0,
15525
- selectionMode: choices ? "multiple" : "single",
15526
- disallowEmptySelection: !choices,
15527
- selectedKeys: choices ? displayKeys : selected === null ? [] : [selected],
15528
- onSelectionChange: choices ? chooseMany : choose,
15529
- expandedKeys: expanded.expanded,
15530
- onExpandedChange: (keys) => {
15531
- const next = new Set([...keys].map(String).filter((k) => !isNote(k)));
15532
- if (beforeOpen) for (const k of [...next]) {
15533
- const node = nodes.get(k);
15534
- if (!expanded.isOpen(k) && node !== void 0 && beforeOpen(node) === false) next.delete(k);
15535
- }
15536
- expanded.onChange(next);
15537
- },
15538
- renderEmptyState: () => /* @__PURE__ */ jsx("p", {
15539
- className: "p-3 type-body-sm text-muted-foreground",
15540
- children: emptyRow
15541
- }),
15542
- className: cn("min-w-0 overflow-y-auto outline-none", !choices && className),
15543
- style: { maxHeight: height },
15544
- "data-strata-scroll": "",
15545
- children: /* @__PURE__ */ jsx(Nodes, { nodes: roots.data })
15546
- });
15547
- const body = /* @__PURE__ */ jsx(Context.Provider, {
15548
- value: ctx,
15549
- children: /* @__PURE__ */ jsx(Virtualizer, {
15550
- layout: ListLayout,
15551
- layoutOptions: { rowHeight: 32 },
15552
- children: tree
15553
- })
15554
- });
15555
- if (!choices) return body;
15556
15440
  return /* @__PURE__ */ jsxs("div", {
15557
- className: cn("grid min-w-0 gap-2", className),
15558
- children: [
15559
- /* @__PURE__ */ jsxs("div", {
15560
- className: "flex items-center gap-2",
15561
- children: [/* @__PURE__ */ jsx(Button, {
15562
- size: "sm",
15563
- variant: "ghost",
15564
- onPress: () => chooseMany("all"),
15565
- children: "Select all shown"
15566
- }), choices.count > 0 && /* @__PURE__ */ jsx(Button, {
15567
- size: "sm",
15568
- variant: "ghost",
15569
- onPress: choices.clear,
15570
- children: "Clear"
15571
- })]
15572
- }),
15573
- body,
15574
- /* @__PURE__ */ jsx("p", {
15575
- role: "status",
15576
- className: "sr-only",
15577
- children: covered || choices.note
15578
- })
15579
- ]
15580
- });
15581
- }
15582
- // src/components/folder-picker.tsx
15583
- var SEP = "/";
15584
- var parts = (path) => path.split(SEP).filter(Boolean);
15585
- var join = (parent, name) => `${parent === SEP ? "" : parent}${SEP}${name}`;
15586
- /** The parent of a path, or `null` at the top. */
15587
- var parentOf = (path) => {
15588
- const p = parts(path);
15589
- return p.length <= 1 ? null : `${SEP}${p.slice(0, -1).join(SEP)}`;
15590
- };
15591
- /** Every folder from the top down to `path`, which the tree must have open to show it. */
15592
- var ancestorsOf = (path) => parts(path).slice(0, -1).map((_, i, a) => `${SEP}${a.slice(0, i + 1).join(SEP)}`);
15593
- /** A server folder chooser: a lazy tree, a breadcrumb that is also editable text, Up, recents, a New folder field that shows the server's refusal, and Choose this folder as the one filled button. */
15594
- function FolderPicker({ label, useFolders: useListing, value, onChange, onChoose, expanded, recent, canChoose, chooseLabel = "Choose this folder", onOpen, onCreate, topLabel = "Top", emptyRow = "No folders", height = "18rem", className }) {
15595
- const useFolders = (path) => {
15596
- const l = useListing(path);
15597
- return l.status === "ready" && !Array.isArray(l.data) ? {
15598
- ...l,
15599
- data: l.data.folders
15600
- } : l;
15601
- };
15602
- const roots = useFolders(null);
15603
- const siblings = useFolders(value ? parentOf(value) : null);
15604
- const own = useListing(value);
15605
- const folder = value && siblings.status === "ready" ? siblings.data.find((f) => f.path === value) : void 0;
15606
- const footer = value && own.status === "ready" && !Array.isArray(own.data) ? own.data.footer : void 0;
15607
- const verdict = value && canChoose ? canChoose(value, folder) : true;
15608
- const reason = typeof verdict === "string" ? verdict : void 0;
15609
- const reasonId = React.useId();
15610
- const [editing, setEditing] = React.useState(false);
15611
- const [text, setText] = React.useState("");
15612
- const go = (path) => onChange(path);
15613
- React.useEffect(() => {
15614
- if (!value) return;
15615
- const open = ancestorsOf(value).filter((a) => !expanded.isOpen(a));
15616
- if (open.length) expanded.onChange(/* @__PURE__ */ new Set([...expanded.expanded, ...open]));
15617
- }, [value, expanded]);
15618
- const [name, setName] = React.useState("");
15619
- const created = useAsyncAction(async (name) => {
15620
- if (!value) return;
15621
- await onCreate?.(value, name);
15622
- setName("");
15623
- go(join(value, name));
15624
- expanded.setOpen(value, true);
15625
- }, { validate: (name) => name.trim() ? void 0 : { name: "Name the new folder." } });
15626
- const crumbs = value ? parts(value) : [];
15627
- return /* @__PURE__ */ jsxs("section", {
15628
- "aria-label": label,
15629
- className: cn("space-y-3", className),
15441
+ className: cn("min-w-0", className),
15630
15442
  children: [
15631
- /* @__PURE__ */ jsxs("div", {
15632
- className: "flex flex-wrap items-center gap-2",
15633
- children: [/* @__PURE__ */ jsx(IconButton, {
15634
- icon: ArrowUp,
15635
- label: "Up one folder",
15636
- onPress: () => go(value ? parentOf(value) : null),
15637
- disabled: !value
15638
- }), editing ? /* @__PURE__ */ jsxs("form", {
15639
- className: "flex min-w-0 flex-1 items-center gap-2",
15640
- onSubmit: (e) => {
15641
- e.preventDefault();
15642
- const typed = text.trim();
15643
- go(typed ? (typed.startsWith(SEP) ? typed : `${SEP}${typed}`).replace(/\/+$/, "") || SEP : null);
15644
- setEditing(false);
15645
- },
15646
- children: [/* @__PURE__ */ jsx(Input, {
15647
- "aria-label": "Folder path",
15648
- value: text,
15649
- autoFocus: true,
15650
- onChange: (e) => setText(e.target.value),
15651
- onKeyDown: (e) => e.key === "Escape" && (e.stopPropagation(), setEditing(false)),
15652
- className: "min-w-0 flex-1 font-mono",
15653
- size: "sm"
15654
- }), /* @__PURE__ */ jsx(Button, {
15655
- size: "sm",
15656
- type: "submit",
15657
- children: "Go"
15658
- })]
15659
- }) : /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("nav", {
15660
- "aria-label": "Folder path",
15661
- className: "min-w-0 flex-1",
15662
- children: /* @__PURE__ */ jsxs("ol", {
15663
- className: "flex flex-wrap items-center gap-x-1 type-body-sm",
15664
- children: [/* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx(Button, {
15665
- size: "sm",
15666
- variant: "ghost",
15667
- onPress: () => go(null),
15668
- "aria-current": value ? void 0 : "location",
15669
- children: topLabel
15670
- }) }), crumbs.map((c, i) => {
15671
- const path = `${SEP}${crumbs.slice(0, i + 1).join(SEP)}`;
15672
- const last = i === crumbs.length - 1;
15673
- return /* @__PURE__ */ jsxs("li", {
15674
- className: "flex min-w-0 items-center gap-1",
15675
- children: [/* @__PURE__ */ jsx("span", {
15676
- "aria-hidden": true,
15677
- className: "text-muted-foreground",
15678
- children: "/"
15679
- }), /* @__PURE__ */ jsx(Tooltip, {
15680
- label: path,
15681
- side: "bottom",
15682
- children: /* @__PURE__ */ jsx(Button, {
15683
- size: "sm",
15684
- variant: "ghost",
15685
- onPress: () => go(path),
15686
- "aria-current": last ? "location" : void 0,
15687
- className: cn("max-w-48 truncate", last && "font-medium"),
15688
- children: c
15689
- })
15690
- })]
15691
- }, path);
15443
+ /* @__PURE__ */ jsx("div", {
15444
+ role: "group",
15445
+ "aria-label": label,
15446
+ className: "overflow-x-auto pb-2",
15447
+ children: /* @__PURE__ */ jsxs("div", {
15448
+ ref: track,
15449
+ className: "relative",
15450
+ style: { width: zoom ? `${span * zoom}px` : "100%" },
15451
+ children: [/* @__PURE__ */ jsxs("div", {
15452
+ "aria-hidden": true,
15453
+ className: "relative h-6 border-b border-border",
15454
+ children: [ticks.map((t) => /* @__PURE__ */ jsx("span", {
15455
+ className: "absolute top-0 -translate-x-1/2 type-caption tabular-nums text-muted-foreground",
15456
+ style: { left: pct(t) },
15457
+ children: tickLabel(t, step0)
15458
+ }, t)), beats.map((p) => /* @__PURE__ */ jsx("span", {
15459
+ "data-beat": true,
15460
+ className: "absolute bottom-0 h-1.5 w-px bg-border",
15461
+ style: { left: pct(p) }
15462
+ }, `b${p}`))]
15463
+ }), /* @__PURE__ */ jsxs("div", {
15464
+ className: "relative mt-1",
15465
+ style: { height },
15466
+ children: [view.map((it) => {
15467
+ const on = selected.includes(it.id);
15468
+ return /* @__PURE__ */ jsx("button", {
15469
+ type: "button",
15470
+ "aria-pressed": on,
15471
+ "aria-label": `${it.label}, ${at(it.start)} to ${at(it.end)}`,
15472
+ onClick: (e) => choose(e, it.id),
15473
+ className: cn("absolute inset-y-0 min-w-0 cursor-pointer overflow-hidden rounded-control border px-1.5 text-left transition-state", on ? "border-primary bg-primary/10" : "border-border bg-muted hover:bg-muted/70"),
15474
+ style: {
15475
+ left: pct(it.start),
15476
+ width: `calc(${(it.end - it.start) / span * 100}% - 2px)`
15477
+ },
15478
+ children: renderItem ? renderItem(it, on) : /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("span", {
15479
+ className: "block truncate type-label",
15480
+ children: it.label
15481
+ }), /* @__PURE__ */ jsx("span", {
15482
+ className: "block truncate type-caption tabular-nums text-muted-foreground",
15483
+ children: seconds(it.end - it.start)
15484
+ })] })
15485
+ }, it.id);
15486
+ }), items.slice(0, -1).map((it, i) => {
15487
+ const r = roomFor(i);
15488
+ const now = drag?.index === i ? drag.time : it.end;
15489
+ return /* @__PURE__ */ jsx("div", {
15490
+ role: "slider",
15491
+ tabIndex: 0,
15492
+ "aria-label": `Cut ${i + 1}, between window ${i + 1} and window ${i + 2}`,
15493
+ "aria-orientation": "horizontal",
15494
+ "aria-valuemin": r.min,
15495
+ "aria-valuemax": r.max,
15496
+ "aria-valuenow": now,
15497
+ "aria-valuetext": at(now),
15498
+ "data-cut": i,
15499
+ onKeyDown: (e) => keys(e, i),
15500
+ onPointerDown: (e) => begin(e, i),
15501
+ onPointerMove: drive,
15502
+ onPointerUp: release,
15503
+ onPointerCancel: () => setDrag(null),
15504
+ className: "group absolute inset-y-0 z-10 w-3 -translate-x-1/2 cursor-ew-resize touch-none outline-offset-1",
15505
+ style: { left: pct(now) },
15506
+ children: /* @__PURE__ */ jsx("span", { className: "absolute inset-y-0 left-1/2 w-0.5 -translate-x-1/2 rounded-pill bg-foreground group-hover:w-1 group-focus-visible:w-1" })
15507
+ }, `cut${it.id}`);
15692
15508
  })]
15693
- })
15694
- }), /* @__PURE__ */ jsx(IconButton, {
15695
- icon: Pencil,
15696
- label: "Edit path",
15697
- onPress: () => {
15698
- setText(value ?? "");
15699
- setEditing(true);
15700
- }
15701
- })] })]
15702
- }),
15703
- /* @__PURE__ */ jsx("div", {
15704
- className: "rounded-surface border border-border",
15705
- children: /* @__PURE__ */ jsx(Tree, {
15706
- label: `${label}: folders`,
15707
- roots,
15708
- useChildren: (f) => useFolders(f.path),
15709
- nodeKey: (f) => f.path,
15710
- nodeLabel: (f) => f.badge ? `${f.name}, ${f.badge}` : f.name,
15711
- beforeOpen: onOpen ? (f) => {
15712
- if (onOpen(f) !== "choose") return true;
15713
- go(f.path);
15714
- onChoose(f.path);
15715
- return false;
15716
- } : void 0,
15717
- renderNode: (f) => /* @__PURE__ */ jsxs("span", {
15718
- className: "flex min-w-0 items-baseline gap-2",
15719
- children: [
15720
- /* @__PURE__ */ jsx("span", {
15721
- className: "truncate",
15722
- children: f.name
15723
- }),
15724
- f.badge && /* @__PURE__ */ jsx(Status, {
15725
- tone: f.tone ?? "neutral",
15726
- className: "self-center",
15727
- children: f.badge
15728
- }),
15729
- f.count !== void 0 && /* @__PURE__ */ jsx("span", {
15730
- className: "type-caption tabular-nums text-muted-foreground",
15731
- children: format.integer(f.count)
15732
- })
15733
- ]
15734
- }),
15735
- selected: value,
15736
- onSelect: (key) => onChange(key),
15737
- expanded,
15738
- emptyRow,
15739
- height
15509
+ })]
15740
15510
  })
15741
15511
  }),
15742
- recent && recent.length > 0 && /* @__PURE__ */ jsxs("div", {
15743
- role: "group",
15744
- "aria-label": "Recent folders",
15745
- className: "flex flex-wrap items-center gap-2",
15746
- children: [/* @__PURE__ */ jsx("span", {
15747
- className: "type-caption text-muted-foreground",
15748
- children: "Recent"
15749
- }), recent.map((r) => /* @__PURE__ */ jsx(Tooltip, {
15750
- label: r,
15751
- side: "bottom",
15752
- children: /* @__PURE__ */ jsx(Button, {
15753
- size: "sm",
15754
- variant: "outline",
15755
- onPress: () => go(r),
15756
- className: "max-w-64 truncate font-mono",
15757
- children: r
15758
- })
15759
- }, r))]
15760
- }),
15761
- onCreate && /* @__PURE__ */ jsx("form", {
15762
- onSubmit: (e) => {
15763
- e.preventDefault();
15764
- created.run(name.trim());
15765
- },
15766
- children: /* @__PURE__ */ jsx(Field, {
15767
- label: "New folder",
15768
- hint: value ? `It will be made in ${value}.` : "Open a folder first.",
15769
- error: created.fieldErrors.name ?? (created.phase === "error" ? created.error : void 0),
15770
- action: /* @__PURE__ */ jsx(AsyncButton, {
15771
- type: "submit",
15772
- phase: created.phase,
15773
- error: created.error,
15774
- disabled: !value,
15775
- labels: {
15776
- idle: "Make folder",
15777
- pending: "Making…",
15778
- done: "Made"
15779
- }
15512
+ drag?.refused && /* @__PURE__ */ jsxs("p", {
15513
+ className: "mt-1 flex items-center gap-1.5 type-body-sm text-danger",
15514
+ children: [
15515
+ /* @__PURE__ */ jsx(Ban, {
15516
+ className: "size-4 shrink-0",
15517
+ "aria-hidden": true
15780
15518
  }),
15781
- children: /* @__PURE__ */ jsx(Input, {
15782
- value: name,
15783
- disabled: !value,
15784
- onChange: (e) => {
15785
- setName(e.target.value);
15786
- created.clearFieldError("name");
15787
- }
15788
- })
15789
- })
15790
- }),
15791
- footer && /* @__PURE__ */ jsx("p", {
15792
- className: "type-body-sm text-muted-foreground",
15793
- children: footer
15519
+ " ",
15520
+ drag.refused
15521
+ ]
15794
15522
  }),
15795
- /* @__PURE__ */ jsxs("div", {
15796
- className: "flex flex-wrap items-center justify-end gap-3",
15797
- children: [reason && /* @__PURE__ */ jsx("p", {
15798
- id: reasonId,
15799
- className: "min-w-0 flex-1 type-body-sm text-muted-foreground",
15800
- children: reason
15801
- }), /* @__PURE__ */ jsx(Button, {
15802
- variant: "default",
15803
- disabled: !value || reason !== void 0,
15804
- "aria-describedby": reason ? reasonId : void 0,
15805
- onPress: () => value && onChoose(value),
15806
- children: chooseLabel
15807
- })]
15523
+ /* @__PURE__ */ jsx("div", {
15524
+ role: "status",
15525
+ "aria-live": "polite",
15526
+ className: "sr-only",
15527
+ children: said
15808
15528
  })
15809
15529
  ]
15810
15530
  });
15811
15531
  }
15812
- // src/lib/marks.ts
15813
- /** The ids from `a` to `b` inclusive, in document order whichever way round they are given. Empty when either is not in `ids`. */
15814
- function rangeBetween(ids, a, b) {
15815
- if (a === null || b === null) return [];
15816
- const i = ids.indexOf(a);
15817
- const j = ids.indexOf(b);
15818
- if (i < 0 || j < 0) return [];
15819
- return ids.slice(Math.min(i, j), Math.max(i, j) + 1);
15820
- }
15821
- /** How many ids carry each mark key. Ids with no mark are not counted. */
15822
- function countMarks(marks, ids) {
15823
- const out = {};
15824
- for (const id of ids ?? Object.keys(marks)) {
15825
- const m = marks[id];
15826
- if (m) out[m] = (out[m] ?? 0) + 1;
15827
- }
15828
- return out;
15532
+ // src/components/tree.tsx
15533
+ var Context = React.createContext(null);
15534
+ var useCtx = () => React.useContext(Context);
15535
+ var NOTE = "\0";
15536
+ var isNote = (key) => key.includes(NOTE);
15537
+ var ROW = "flex min-h-(--control-h-sm) min-w-0 items-center gap-1 rounded-control pr-2 type-body-sm";
15538
+ function Row$1({ level, children }) {
15539
+ return /* @__PURE__ */ jsx("div", {
15540
+ className: ROW,
15541
+ style: { paddingInlineStart: `${level * 1.25 + .25}rem` },
15542
+ children
15543
+ });
15544
+ }
15545
+ function Node$1({ node }) {
15546
+ const c = useCtx();
15547
+ const key = c.nodeKey(node);
15548
+ c.nodes.set(key, node);
15549
+ const branch = c.isBranch ? c.isBranch(node) : true;
15550
+ const open = branch && c.expanded.isOpen(key);
15551
+ const name = c.nodeLabel(node);
15552
+ const nodeCount = c.count?.(node);
15553
+ const badge = c.badge?.(node);
15554
+ const because = c.choices?.implied.has(key) ? c.choices.because(key).map((k) => c.nodes.has(k) ? c.nodeLabel(c.nodes.get(k)) : k) : [];
15555
+ return /* @__PURE__ */ jsxs(TreeItem, {
15556
+ id: key,
15557
+ textValue: name,
15558
+ hasChildItems: branch,
15559
+ className: "outline-none",
15560
+ children: [/* @__PURE__ */ jsx(TreeItemContent, { children: ({ level, isSelected, isExpanded }) => /* @__PURE__ */ jsxs("div", {
15561
+ title: name,
15562
+ className: cn(ROW, "cursor-pointer outline-offset-[-2px] hover:bg-muted", (isSelected || c.current === key) && "bg-surface-sunken font-medium"),
15563
+ style: { paddingInlineStart: `${(level - 1) * 1.25 + .25}rem` },
15564
+ "data-selected": isSelected || void 0,
15565
+ "aria-current": c.current === key ? "true" : void 0,
15566
+ "data-current": c.current === key || void 0,
15567
+ children: [
15568
+ c.choices && /* @__PURE__ */ jsx(TableSelectionCheckbox, {
15569
+ label: `Choose ${name}`,
15570
+ mixed: c.stateOf(key) === "mixed"
15571
+ }),
15572
+ branch ? /* @__PURE__ */ jsx(Button$1, {
15573
+ slot: "chevron",
15574
+ className: "grid size-6 shrink-0 place-items-center rounded-control text-muted-foreground",
15575
+ children: /* @__PURE__ */ jsx(ChevronRight, {
15576
+ "aria-hidden": true,
15577
+ className: cn("size-4", isExpanded && "rotate-90")
15578
+ })
15579
+ }) : /* @__PURE__ */ jsx("span", {
15580
+ "aria-hidden": true,
15581
+ className: "size-6 shrink-0"
15582
+ }),
15583
+ branch ? isExpanded ? /* @__PURE__ */ jsx(FolderOpen, {
15584
+ "aria-hidden": true,
15585
+ className: "size-4 shrink-0 text-muted-foreground"
15586
+ }) : /* @__PURE__ */ jsx(Folder, {
15587
+ "aria-hidden": true,
15588
+ className: "size-4 shrink-0 text-muted-foreground"
15589
+ }) : null,
15590
+ /* @__PURE__ */ jsx("span", {
15591
+ className: "min-w-0 flex-1 truncate",
15592
+ children: c.renderNode ? c.renderNode(node, {
15593
+ expanded: isExpanded,
15594
+ selected: isSelected,
15595
+ level,
15596
+ branch
15597
+ }) : name
15598
+ }),
15599
+ badge && /* @__PURE__ */ jsx(Status, {
15600
+ tone: badge.tone ?? "info",
15601
+ children: badge.label
15602
+ }),
15603
+ nodeCount != null && /* @__PURE__ */ jsx("span", {
15604
+ className: "shrink-0 type-caption text-muted-foreground tabular-nums",
15605
+ children: typeof nodeCount === "number" ? format.integer(nodeCount) : nodeCount
15606
+ }),
15607
+ because.length > 0 && /* @__PURE__ */ jsxs("span", {
15608
+ className: "flex max-w-[50%] shrink-0 items-center gap-1 truncate type-caption text-muted-foreground",
15609
+ title: `Included because of ${because.join(", ")}`,
15610
+ children: [/* @__PURE__ */ jsx(Lock, {
15611
+ "aria-hidden": true,
15612
+ className: "size-3 shrink-0"
15613
+ }), /* @__PURE__ */ jsxs("span", {
15614
+ className: "truncate",
15615
+ children: [
15616
+ "Included because of ",
15617
+ because.slice(0, 2).join(", "),
15618
+ because.length > 2 ? ` and ${because.length - 2} more` : ""
15619
+ ]
15620
+ })]
15621
+ })
15622
+ ]
15623
+ }) }), open ? /* @__PURE__ */ jsx(Children, { node }) : branch && /* @__PURE__ */ jsx(ClosedChild, { id: `${key}${NOTE}closed` })]
15624
+ });
15625
+ }
15626
+ function ClosedChild({ id }) {
15627
+ return /* @__PURE__ */ jsx(TreeItem, {
15628
+ id,
15629
+ textValue: "",
15630
+ isDisabled: true,
15631
+ children: /* @__PURE__ */ jsx(TreeItemContent, { children: () => null })
15632
+ }, "closed");
15829
15633
  }
15830
- /** The id `by` places from `from` in `ids`, held to the ends; the first (or last) when `from` is not set. */
15831
- function stepId(ids, from, by) {
15832
- if (ids.length === 0) return null;
15833
- const i = from === null ? -1 : ids.indexOf(from);
15834
- if (i < 0) return by >= 0 ? ids[0] : ids[ids.length - 1];
15835
- return ids[Math.min(Math.max(i + by, 0), ids.length - 1)];
15634
+ function Nodes({ nodes }) {
15635
+ const c = useCtx();
15636
+ return /* @__PURE__ */ jsx(Fragment, { children: c.sorted(nodes).map((n) => /* @__PURE__ */ jsx(Node$1, { node: n }, c.nodeKey(n))) });
15836
15637
  }
15837
- // src/components/markable-text.tsx
15838
- var TONE = {
15839
- neutral: {
15840
- fill: "var(--muted)",
15841
- edge: "var(--muted-foreground)"
15842
- },
15843
- info: {
15844
- fill: "var(--info-subtle)",
15845
- edge: "var(--info)"
15846
- },
15847
- success: {
15848
- fill: "var(--success-subtle)",
15849
- edge: "var(--success)"
15850
- },
15851
- warning: {
15852
- fill: "var(--warning-subtle)",
15853
- edge: "var(--warning)"
15854
- },
15855
- danger: {
15856
- fill: "var(--danger-subtle)",
15857
- edge: "var(--danger)"
15858
- }
15859
- };
15860
- var MarksContext = React.createContext(null);
15861
- /** One word (or phrase, or clip) that can be marked. Draws its mark, its selection and the caret; inside a `MarkableText`. */
15862
- function Mark({ id, children, className }) {
15863
- const c = React.useContext(MarksContext);
15864
- if (!c) return /* @__PURE__ */ jsx("span", {
15865
- className,
15866
- children
15867
- });
15868
- const kind = c.kinds.find((k) => k.key === c.marks[id]);
15869
- const tone = kind && TONE[kind.tone];
15870
- const on = c.selected.has(id);
15871
- return /* @__PURE__ */ jsxs("span", {
15872
- "data-mark-id": id,
15873
- "data-mark": kind?.key,
15874
- "data-selected": on || void 0,
15875
- "data-caret": c.caret === id || void 0,
15876
- onPointerDown: (e) => c.press(e, id),
15877
- onPointerEnter: () => c.over(id),
15878
- className: cn("cursor-text rounded-control px-px", on && "bg-primary/20", c.caret === id && "outline-2 outline-primary", className),
15879
- style: kind && tone ? {
15880
- backgroundColor: on ? void 0 : tone.fill,
15881
- textDecorationLine: "underline",
15882
- textDecorationStyle: kind.pattern,
15883
- textDecorationColor: tone.edge,
15884
- textDecorationThickness: "2px",
15885
- textUnderlineOffset: "3px"
15886
- } : void 0,
15887
- children: [children, kind && /* @__PURE__ */ jsxs("span", {
15888
- className: "sr-only",
15638
+ function Children({ node }) {
15639
+ const c = useCtx();
15640
+ const key = c.nodeKey(node);
15641
+ const load = c.useChildren(node);
15642
+ const ready = load.status === "ready" ? load.data : void 0;
15643
+ React.useEffect(() => {
15644
+ if (ready) c.settle(key, ready);
15645
+ }, [ready]);
15646
+ if (load.status === "loading") return /* @__PURE__ */ jsx(TreeItem, {
15647
+ id: `${key}${NOTE}loading`,
15648
+ textValue: "Loading",
15649
+ isDisabled: true,
15650
+ className: "outline-none",
15651
+ children: /* @__PURE__ */ jsx(TreeItemContent, { children: ({ level }) => /* @__PURE__ */ jsxs(Row$1, {
15652
+ level: level - 1,
15889
15653
  children: [
15890
- " (",
15891
- kind.label.toLowerCase(),
15892
- ")"
15654
+ /* @__PURE__ */ jsx("span", {
15655
+ "aria-hidden": true,
15656
+ className: "size-6 shrink-0"
15657
+ }),
15658
+ /* @__PURE__ */ jsx("span", {
15659
+ role: "status",
15660
+ className: "sr-only",
15661
+ children: "Loading"
15662
+ }),
15663
+ c.loadingRow ?? /* @__PURE__ */ jsx("span", {
15664
+ "aria-hidden": true,
15665
+ className: "h-3 w-32 animate-pulse rounded-pill bg-muted"
15666
+ })
15893
15667
  ]
15894
- })]
15895
- });
15668
+ }) })
15669
+ }, "loading");
15670
+ if (load.status === "error") return /* @__PURE__ */ jsx(TreeItem, {
15671
+ id: `${key}${NOTE}error`,
15672
+ textValue: load.message,
15673
+ className: "outline-none",
15674
+ children: /* @__PURE__ */ jsx(TreeItemContent, { children: ({ level }) => /* @__PURE__ */ jsxs(Row$1, {
15675
+ level: level - 1,
15676
+ children: [
15677
+ /* @__PURE__ */ jsx(CircleAlert, {
15678
+ "aria-hidden": true,
15679
+ className: "size-4 shrink-0 text-danger"
15680
+ }),
15681
+ /* @__PURE__ */ jsx("span", {
15682
+ className: "min-w-0 flex-1 truncate text-danger",
15683
+ title: load.message,
15684
+ children: load.message
15685
+ }),
15686
+ /* @__PURE__ */ jsx(Button, {
15687
+ size: "sm",
15688
+ onPress: load.retry,
15689
+ children: "Try again"
15690
+ })
15691
+ ]
15692
+ }) })
15693
+ }, "error");
15694
+ if (load.data.length === 0) return /* @__PURE__ */ jsx(TreeItem, {
15695
+ id: `${key}${NOTE}empty`,
15696
+ textValue: c.emptyRow,
15697
+ isDisabled: true,
15698
+ className: "outline-none",
15699
+ children: /* @__PURE__ */ jsx(TreeItemContent, { children: ({ level }) => /* @__PURE__ */ jsxs(Row$1, {
15700
+ level: level - 1,
15701
+ children: [/* @__PURE__ */ jsx("span", {
15702
+ "aria-hidden": true,
15703
+ className: "size-6 shrink-0"
15704
+ }), /* @__PURE__ */ jsx("span", {
15705
+ className: "text-muted-foreground",
15706
+ children: c.emptyRow
15707
+ })]
15708
+ }) })
15709
+ }, "empty");
15710
+ c.childKeys.set(key, c.sorted(load.data).map(c.nodeKey));
15711
+ return /* @__PURE__ */ jsx(Nodes, { nodes: load.data });
15896
15712
  }
15897
- /** "12 words must use, 3 never": a count for each kind in use, with its icon. */
15898
- function MarkSummary({ marks, kinds, unit = ["word", "words"], className }) {
15899
- const counts = countMarks(marks);
15900
- const used = kinds.filter((k) => counts[k.key]);
15901
- if (!used.length) return /* @__PURE__ */ jsx("p", {
15902
- className: cn("type-caption text-muted-foreground", className),
15903
- children: "Nothing marked yet."
15713
+ /** A hierarchy whose children load as each node opens (a `useChildren` hook per open node): a skeleton row, a Try again row and an "empty" row per node, type-ahead and arrow keys, single selection, open state optionally in the URL, always virtualised. */
15714
+ function Tree({ label, roots, useChildren, nodeKey, nodeLabel, isBranch, renderNode, selected, onSelect, choices, current, onCurrentChange, count, badge, sortChildren, reveal, resolveBranch, coverNoun = ["item", "items"], expanded, beforeOpen, loadingRow, emptyRow, height = "24rem", className }) {
15715
+ const nodes = React.useRef(/* @__PURE__ */ new Map()).current;
15716
+ const [covered, setCovered] = React.useState("");
15717
+ const scroller = React.useRef(null);
15718
+ const scrollToReveal = React.useRef(() => {});
15719
+ const sorted = React.useCallback((list) => sortChildren ? [...list].sort(sortChildren) : list, [sortChildren]);
15720
+ const childKeys = React.useRef(/* @__PURE__ */ new Map()).current;
15721
+ const resolved = React.useRef(/* @__PURE__ */ new Map()).current;
15722
+ const below = (key) => [.../* @__PURE__ */ new Set([...(childKeys.get(key) ?? []).flatMap((k) => [k, ...below(k)]), ...resolved.get(key) ?? []])];
15723
+ const stateOf = (key) => {
15724
+ const all = choices?.selected;
15725
+ const own = all?.has(key) ?? false;
15726
+ const ds = below(key);
15727
+ if (ds.length === 0) return own ? "on" : "off";
15728
+ const chosen = ds.filter((k) => all?.has(k)).length;
15729
+ if (chosen === ds.length) return "on";
15730
+ return chosen === 0 && !own ? "off" : "mixed";
15731
+ };
15732
+ const awaiting = React.useRef(/* @__PURE__ */ new Set()).current;
15733
+ const latest = React.useRef({
15734
+ expanded,
15735
+ choices
15736
+ });
15737
+ latest.current = {
15738
+ expanded,
15739
+ choices
15740
+ };
15741
+ const opening = React.useRef(/* @__PURE__ */ new Set()).current;
15742
+ const open = (keys) => {
15743
+ for (const k of keys) opening.add(k);
15744
+ latest.current.expanded.onChange(/* @__PURE__ */ new Set([...latest.current.expanded.expanded, ...opening]));
15745
+ };
15746
+ const unread = (key) => {
15747
+ const node = nodes.get(key);
15748
+ return node !== void 0 && (isBranch ? isBranch(node) : true) && !childKeys.has(key);
15749
+ };
15750
+ const tick = (keys) => {
15751
+ const toResolve = resolveBranch ? keys.filter(unread) : [];
15752
+ for (const k of toResolve) {
15753
+ const node = nodes.get(k);
15754
+ resolveBranch(node).then((under) => {
15755
+ resolved.set(k, under);
15756
+ latest.current.choices?.add([k, ...under]);
15757
+ setCovered(`${nodeLabel(node)} and its ${under.length === 1 ? `1 ${coverNoun[0]}` : `${format.integer(under.length)} ${coverNoun[1]}`}`);
15758
+ });
15759
+ }
15760
+ const toOpen = keys.filter((k) => unread(k) && !toResolve.includes(k));
15761
+ for (const k of toOpen) awaiting.add(k);
15762
+ if (toOpen.length) open(toOpen);
15763
+ };
15764
+ const settle = (key, kids) => {
15765
+ opening.delete(key);
15766
+ scrollToReveal.current();
15767
+ if (!awaiting.delete(key) || !latest.current.choices) return;
15768
+ const keys = kids.map(nodeKey);
15769
+ for (const kid of kids) nodes.set(nodeKey(kid), kid);
15770
+ latest.current.choices.add(keys);
15771
+ tick(keys);
15772
+ };
15773
+ const ctx = {
15774
+ useChildren,
15775
+ nodeKey,
15776
+ nodeLabel,
15777
+ isBranch,
15778
+ renderNode,
15779
+ expanded,
15780
+ loadingRow,
15781
+ emptyRow,
15782
+ nodes,
15783
+ childKeys,
15784
+ choices,
15785
+ stateOf,
15786
+ settle,
15787
+ current,
15788
+ sorted,
15789
+ count,
15790
+ badge
15791
+ };
15792
+ const revealed = reveal?.join("");
15793
+ React.useEffect(() => {
15794
+ if (!reveal || reveal.length === 0) return;
15795
+ const ancestors = reveal.slice(0, -1).filter((k) => !latest.current.expanded.isOpen(k));
15796
+ if (ancestors.length) latest.current.expanded.onChange(/* @__PURE__ */ new Set([...latest.current.expanded.expanded, ...ancestors]));
15797
+ }, [revealed]);
15798
+ scrollToReveal.current = () => {
15799
+ if (!reveal || reveal.length === 0 || roots.status !== "ready" || !scroller.current) return;
15800
+ const walk = (keys) => sorted(keys.map((k) => nodes.get(k)).filter((n) => n !== void 0)).map(nodeKey).flatMap((k) => latest.current.expanded.isOpen(k) && childKeys.has(k) ? [k, ...walk(childKeys.get(k))] : [k]);
15801
+ const i = walk(sorted(roots.data).map(nodeKey)).indexOf(reveal[reveal.length - 1]);
15802
+ if (i >= 0) scroller.current.scrollTop = Math.max(0, i * 32 - 32);
15803
+ };
15804
+ React.useEffect(() => scrollToReveal.current());
15805
+ if (roots.status === "loading") return /* @__PURE__ */ jsx("div", {
15806
+ role: "status",
15807
+ "aria-label": `${label}: loading`,
15808
+ className: cn("space-y-2 p-2", className),
15809
+ children: [
15810
+ 0,
15811
+ 1,
15812
+ 2,
15813
+ 3
15814
+ ].map((i) => /* @__PURE__ */ jsx("div", {
15815
+ "aria-hidden": true,
15816
+ className: "h-4 animate-pulse rounded-pill bg-muted",
15817
+ style: { width: `${70 - i * 10}%` }
15818
+ }, i))
15904
15819
  });
15905
- return /* @__PURE__ */ jsx("ul", {
15906
- "aria-label": "Marked",
15907
- className: cn("flex flex-wrap gap-x-4 gap-y-1 type-body-sm", className),
15908
- children: used.map((k) => {
15909
- const Icon = k.icon;
15910
- return /* @__PURE__ */ jsxs("li", {
15911
- className: "inline-flex items-center gap-1.5",
15912
- children: [
15913
- Icon && /* @__PURE__ */ jsx(Icon, {
15914
- "aria-hidden": true,
15915
- className: "size-4"
15916
- }),
15917
- /* @__PURE__ */ jsx("span", {
15918
- className: "tabular-nums",
15919
- children: format.count(counts[k.key], unit[0], unit[1])
15920
- }),
15921
- " ",
15922
- k.label.toLowerCase()
15923
- ]
15924
- }, k.key);
15925
- })
15820
+ if (roots.status === "error") return /* @__PURE__ */ jsxs("div", {
15821
+ role: "alert",
15822
+ className: cn("flex items-center gap-3 rounded-surface bg-danger-subtle p-3 text-danger", className),
15823
+ children: [
15824
+ /* @__PURE__ */ jsx(CircleAlert, {
15825
+ "aria-hidden": true,
15826
+ className: "size-5 shrink-0"
15827
+ }),
15828
+ /* @__PURE__ */ jsx("p", {
15829
+ className: "min-w-0 flex-1 type-body-sm",
15830
+ children: roots.message
15831
+ }),
15832
+ /* @__PURE__ */ jsx(Button, {
15833
+ size: "sm",
15834
+ onPress: roots.retry,
15835
+ children: "Try again"
15836
+ })
15837
+ ]
15926
15838
  });
15927
- }
15928
- /** Selects ids over `<Mark>` words by drag, Shift+click and Shift+arrows (a run in the app's order, so it holds across virtualised rows), offers the app's marks as chorded commands in a bar, says each change in words, and lists what is marked. */
15929
- function MarkableText({ label, ids, marks, kinds, onMark, clearKeys = [], onCaretChange, unit = ["word", "words"], summary = true, children, className }) {
15930
- const [anchor, setAnchor] = React.useState(null);
15931
- const [caret, setCaret] = React.useState(null);
15932
- const [said, setSaid] = React.useState("");
15933
- const dragging = React.useRef(false);
15934
- const hintId = React.useId();
15935
- const run = React.useMemo(() => rangeBetween(ids, anchor, caret), [
15936
- ids,
15937
- anchor,
15938
- caret
15939
- ]);
15940
- const selected = React.useMemo(() => new Set(run), [run]);
15941
- const n = run.length;
15942
- const counted = (k) => format.count(k, unit[0], unit[1]);
15943
- const moveCaret = (id, extend) => {
15944
- if (id === null) return;
15945
- setCaret(id);
15946
- if (!extend || anchor === null) setAnchor(id);
15947
- onCaretChange?.(id);
15839
+ const choose = (keys) => {
15840
+ const first = keys === "all" ? void 0 : [...keys][0];
15841
+ if (first === void 0 || isNote(String(first))) return;
15842
+ const key = String(first);
15843
+ const node = nodes.get(key);
15844
+ if (node !== void 0) onSelect?.(key, node);
15948
15845
  };
15949
- const apply = (kind) => {
15950
- if (!n) return;
15951
- onMark(run, kind);
15952
- const k = kinds.find((x) => x.key === kind);
15953
- setSaid(kind === null ? `${counted(n)} cleared` : `${counted(n)} marked ${k?.label.toLowerCase() ?? kind}`);
15846
+ const displayKeys = choices ? [.../* @__PURE__ */ new Set([...choices.selected, ...nodes.keys()])].filter((k) => stateOf(k) === "on" || choices.selected.has(k) && !nodes.has(k)) : [];
15847
+ const shown = () => {
15848
+ const walk = (keys) => keys.flatMap((k) => expanded.isOpen(k) && childKeys.has(k) ? [k, ...walk(childKeys.get(k))] : [k]);
15849
+ return walk(roots.data.map(nodeKey));
15954
15850
  };
15955
- const commands = [...kinds.map((k) => ({
15956
- id: `mark-${k.key}`,
15957
- label: k.label,
15958
- keys: k.keys,
15959
- icon: k.icon,
15960
- disabled: n ? false : "Select words first",
15961
- run: () => apply(k.key)
15962
- })), {
15963
- id: "mark-clear",
15964
- label: "Clear mark",
15965
- keys: clearKeys,
15966
- disabled: n ? false : "Select words first",
15967
- run: () => apply(null)
15968
- }];
15969
- useCommands(commands);
15970
- React.useEffect(() => {
15971
- const stop = () => dragging.current = false;
15972
- window.addEventListener("pointerup", stop);
15973
- return () => window.removeEventListener("pointerup", stop);
15974
- }, []);
15975
- const ctx = {
15976
- kinds,
15977
- marks,
15978
- selected,
15979
- caret,
15980
- press: (e, id) => {
15981
- if (e.button !== 0) return;
15982
- dragging.current = true;
15983
- if (e.shiftKey && anchor !== null) setCaret(id);
15851
+ const chooseMany = (keys) => {
15852
+ if (!choices) return;
15853
+ const wanted = new Set(choices.selected);
15854
+ if (keys === "all") {
15855
+ const rows = shown().flatMap((k) => [k, ...below(k)]);
15856
+ for (const x of rows) wanted.add(x);
15857
+ choices.onChange(wanted);
15858
+ tick(rows);
15859
+ return;
15860
+ }
15861
+ const display = new Set(displayKeys);
15862
+ const next = new Set([...keys].map(String).filter((k) => !isNote(k)));
15863
+ for (const k of /* @__PURE__ */ new Set([...next, ...display])) {
15864
+ if (next.has(k) === display.has(k)) continue;
15865
+ const under = [k, ...below(k)];
15866
+ for (const x of under) if (next.has(k)) wanted.add(x);
15984
15867
  else {
15985
- setAnchor(id);
15986
- setCaret(id);
15868
+ wanted.delete(x);
15869
+ awaiting.delete(x);
15987
15870
  }
15988
- onCaretChange?.(id);
15989
- setSaid("");
15990
- },
15991
- over: (id) => {
15992
- if (dragging.current && id !== caret) setCaret(id);
15993
- }
15994
- };
15995
- React.useEffect(() => {
15996
- if (n > 1) setSaid(`${counted(n)} selected`);
15997
- else if (n === 1 && caret) setSaid(`${document.querySelector(`[data-mark-id="${CSS.escape(caret)}"]`)?.textContent ?? caret}`);
15998
- }, [n, caret]);
15999
- const keys = (e) => {
16000
- if (e.altKey || e.ctrlKey || e.metaKey) return;
16001
- const to = e.key === "ArrowRight" ? stepId(ids, caret, 1) : e.key === "ArrowLeft" ? stepId(ids, caret, -1) : e.key === "Home" ? ids[0] ?? null : e.key === "End" ? ids[ids.length - 1] ?? null : void 0;
16002
- if (to !== void 0) {
16003
- e.preventDefault();
16004
- moveCaret(to, e.shiftKey);
16005
- } else if (e.key === "Escape" && (anchor !== null || caret !== null)) {
16006
- e.preventDefault();
16007
- setAnchor(null);
16008
- setCaret(null);
16009
- setSaid("Selection cleared");
15871
+ if (next.has(k)) tick(under);
16010
15872
  }
15873
+ choices.onChange(wanted);
16011
15874
  };
15875
+ const tree = /* @__PURE__ */ jsx(Tree$1, {
15876
+ ref: scroller,
15877
+ "aria-label": label,
15878
+ onAction: onCurrentChange ? (key) => {
15879
+ const k = String(key);
15880
+ const node = nodes.get(k);
15881
+ if (!isNote(k) && node !== void 0) onCurrentChange(k, node);
15882
+ } : void 0,
15883
+ selectionMode: choices ? "multiple" : "single",
15884
+ disallowEmptySelection: !choices,
15885
+ selectedKeys: choices ? displayKeys : selected === null ? [] : [selected],
15886
+ onSelectionChange: choices ? chooseMany : choose,
15887
+ expandedKeys: expanded.expanded,
15888
+ onExpandedChange: (keys) => {
15889
+ const next = new Set([...keys].map(String).filter((k) => !isNote(k)));
15890
+ if (beforeOpen) for (const k of [...next]) {
15891
+ const node = nodes.get(k);
15892
+ if (!expanded.isOpen(k) && node !== void 0 && beforeOpen(node) === false) next.delete(k);
15893
+ }
15894
+ expanded.onChange(next);
15895
+ },
15896
+ renderEmptyState: () => /* @__PURE__ */ jsx("p", {
15897
+ className: "p-3 type-body-sm text-muted-foreground",
15898
+ children: emptyRow
15899
+ }),
15900
+ className: cn("min-w-0 overflow-y-auto outline-none", !choices && className),
15901
+ style: { maxHeight: height },
15902
+ "data-strata-scroll": "",
15903
+ children: /* @__PURE__ */ jsx(Nodes, { nodes: roots.data })
15904
+ });
15905
+ const body = /* @__PURE__ */ jsx(Context.Provider, {
15906
+ value: ctx,
15907
+ children: /* @__PURE__ */ jsx(Virtualizer, {
15908
+ layout: ListLayout,
15909
+ layoutOptions: { rowHeight: 32 },
15910
+ children: tree
15911
+ })
15912
+ });
15913
+ if (!choices) return body;
16012
15914
  return /* @__PURE__ */ jsxs("div", {
16013
- className: cn("space-y-2", className),
15915
+ className: cn("grid min-w-0 gap-2", className),
15916
+ children: [
15917
+ /* @__PURE__ */ jsxs("div", {
15918
+ className: "flex items-center gap-2",
15919
+ children: [/* @__PURE__ */ jsx(Button, {
15920
+ size: "sm",
15921
+ variant: "ghost",
15922
+ onPress: () => chooseMany("all"),
15923
+ children: "Select all shown"
15924
+ }), choices.count > 0 && /* @__PURE__ */ jsx(Button, {
15925
+ size: "sm",
15926
+ variant: "ghost",
15927
+ onPress: choices.clear,
15928
+ children: "Clear"
15929
+ })]
15930
+ }),
15931
+ body,
15932
+ /* @__PURE__ */ jsx("p", {
15933
+ role: "status",
15934
+ className: "sr-only",
15935
+ children: covered || choices.note
15936
+ })
15937
+ ]
15938
+ });
15939
+ }
15940
+ // src/components/folder-picker.tsx
15941
+ var SEP = "/";
15942
+ var parts = (path) => path.split(SEP).filter(Boolean);
15943
+ var join = (parent, name) => `${parent === SEP ? "" : parent}${SEP}${name}`;
15944
+ /** The parent of a path, or `null` at the top. */
15945
+ var parentOf = (path) => {
15946
+ const p = parts(path);
15947
+ return p.length <= 1 ? null : `${SEP}${p.slice(0, -1).join(SEP)}`;
15948
+ };
15949
+ /** Every folder from the top down to `path`, which the tree must have open to show it. */
15950
+ var ancestorsOf = (path) => parts(path).slice(0, -1).map((_, i, a) => `${SEP}${a.slice(0, i + 1).join(SEP)}`);
15951
+ /** A server folder chooser: a lazy tree, a breadcrumb that is also editable text, Up, recents, a New folder field that shows the server's refusal, and Choose this folder as the one filled button. */
15952
+ function FolderPicker({ label, useFolders: useListing, value, onChange, onChoose, expanded, recent, canChoose, chooseLabel = "Choose this folder", onOpen, onCreate, topLabel = "Top", emptyRow = "No folders", height = "18rem", className }) {
15953
+ const useFolders = (path) => {
15954
+ const l = useListing(path);
15955
+ return l.status === "ready" && !Array.isArray(l.data) ? {
15956
+ ...l,
15957
+ data: l.data.folders
15958
+ } : l;
15959
+ };
15960
+ const roots = useFolders(null);
15961
+ const siblings = useFolders(value ? parentOf(value) : null);
15962
+ const own = useListing(value);
15963
+ const folder = value && siblings.status === "ready" ? siblings.data.find((f) => f.path === value) : void 0;
15964
+ const footer = value && own.status === "ready" && !Array.isArray(own.data) ? own.data.footer : void 0;
15965
+ const verdict = value && canChoose ? canChoose(value, folder) : true;
15966
+ const reason = typeof verdict === "string" ? verdict : void 0;
15967
+ const reasonId = React.useId();
15968
+ const [editing, setEditing] = React.useState(false);
15969
+ const [text, setText] = React.useState("");
15970
+ const go = (path) => onChange(path);
15971
+ React.useEffect(() => {
15972
+ if (!value) return;
15973
+ const open = ancestorsOf(value).filter((a) => !expanded.isOpen(a));
15974
+ if (open.length) expanded.onChange(/* @__PURE__ */ new Set([...expanded.expanded, ...open]));
15975
+ }, [value, expanded]);
15976
+ const [name, setName] = React.useState("");
15977
+ const created = useAsyncAction(async (name) => {
15978
+ if (!value) return;
15979
+ await onCreate?.(value, name);
15980
+ setName("");
15981
+ go(join(value, name));
15982
+ expanded.setOpen(value, true);
15983
+ }, { validate: (name) => name.trim() ? void 0 : { name: "Name the new folder." } });
15984
+ const crumbs = value ? parts(value) : [];
15985
+ return /* @__PURE__ */ jsxs("section", {
15986
+ "aria-label": label,
15987
+ className: cn("space-y-3", className),
16014
15988
  children: [
16015
- n > 0 && /* @__PURE__ */ jsxs(Toolbar, {
16016
- label: "Marks",
16017
- className: "sticky top-0 z-10 flex flex-wrap items-center gap-2 rounded-surface border border-border bg-background p-1.5",
16018
- children: [
16019
- /* @__PURE__ */ jsxs("span", {
16020
- className: "px-1 type-label tabular-nums",
16021
- children: [counted(n), " selected"]
16022
- }),
16023
- kinds.map((k) => {
16024
- const Icon = k.icon;
16025
- return /* @__PURE__ */ jsxs(Button, {
16026
- size: "sm",
16027
- onPress: () => apply(k.key),
16028
- children: [
16029
- Icon && /* @__PURE__ */ jsx(Icon, {}),
16030
- " ",
16031
- k.label
16032
- ]
16033
- }, k.key);
16034
- }),
16035
- /* @__PURE__ */ jsx(Button, {
16036
- size: "sm",
16037
- variant: "ghost",
16038
- onPress: () => apply(null),
16039
- children: "Clear mark"
16040
- }),
16041
- /* @__PURE__ */ jsx(Button, {
15989
+ /* @__PURE__ */ jsxs("div", {
15990
+ className: "flex flex-wrap items-center gap-2",
15991
+ children: [/* @__PURE__ */ jsx(IconButton, {
15992
+ icon: ArrowUp,
15993
+ label: "Up one folder",
15994
+ onPress: () => go(value ? parentOf(value) : null),
15995
+ disabled: !value
15996
+ }), editing ? /* @__PURE__ */ jsxs("form", {
15997
+ className: "flex min-w-0 flex-1 items-center gap-2",
15998
+ onSubmit: (e) => {
15999
+ e.preventDefault();
16000
+ const typed = text.trim();
16001
+ go(typed ? (typed.startsWith(SEP) ? typed : `${SEP}${typed}`).replace(/\/+$/, "") || SEP : null);
16002
+ setEditing(false);
16003
+ },
16004
+ children: [/* @__PURE__ */ jsx(Input, {
16005
+ "aria-label": "Folder path",
16006
+ value: text,
16007
+ autoFocus: true,
16008
+ onChange: (e) => setText(e.target.value),
16009
+ onKeyDown: (e) => e.key === "Escape" && (e.stopPropagation(), setEditing(false)),
16010
+ className: "min-w-0 flex-1 font-mono",
16011
+ size: "sm"
16012
+ }), /* @__PURE__ */ jsx(Button, {
16042
16013
  size: "sm",
16043
- variant: "ghost",
16044
- onPress: () => {
16045
- setAnchor(null);
16046
- setCaret(null);
16047
- },
16048
- children: "Deselect"
16014
+ type: "submit",
16015
+ children: "Go"
16016
+ })]
16017
+ }) : /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("nav", {
16018
+ "aria-label": "Folder path",
16019
+ className: "min-w-0 flex-1",
16020
+ children: /* @__PURE__ */ jsxs("ol", {
16021
+ className: "flex flex-wrap items-center gap-x-1 type-body-sm",
16022
+ children: [/* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx(Button, {
16023
+ size: "sm",
16024
+ variant: "ghost",
16025
+ onPress: () => go(null),
16026
+ "aria-current": value ? void 0 : "location",
16027
+ children: topLabel
16028
+ }) }), crumbs.map((c, i) => {
16029
+ const path = `${SEP}${crumbs.slice(0, i + 1).join(SEP)}`;
16030
+ const last = i === crumbs.length - 1;
16031
+ return /* @__PURE__ */ jsxs("li", {
16032
+ className: "flex min-w-0 items-center gap-1",
16033
+ children: [/* @__PURE__ */ jsx("span", {
16034
+ "aria-hidden": true,
16035
+ className: "text-muted-foreground",
16036
+ children: "/"
16037
+ }), /* @__PURE__ */ jsx(Tooltip, {
16038
+ label: path,
16039
+ side: "bottom",
16040
+ children: /* @__PURE__ */ jsx(Button, {
16041
+ size: "sm",
16042
+ variant: "ghost",
16043
+ onPress: () => go(path),
16044
+ "aria-current": last ? "location" : void 0,
16045
+ className: cn("max-w-48 truncate", last && "font-medium"),
16046
+ children: c
16047
+ })
16048
+ })]
16049
+ }, path);
16050
+ })]
16049
16051
  })
16050
- ]
16052
+ }), /* @__PURE__ */ jsx(IconButton, {
16053
+ icon: Pencil,
16054
+ label: "Edit path",
16055
+ onPress: () => {
16056
+ setText(value ?? "");
16057
+ setEditing(true);
16058
+ }
16059
+ })] })]
16051
16060
  }),
16052
- /* @__PURE__ */ jsx(MarksContext.Provider, {
16053
- value: ctx,
16054
- children: /* @__PURE__ */ jsx("div", {
16055
- role: "group",
16056
- "aria-label": label,
16057
- "aria-describedby": hintId,
16058
- tabIndex: 0,
16059
- onKeyDown: keys,
16060
- className: "select-none rounded-surface outline-offset-2",
16061
- children
16061
+ /* @__PURE__ */ jsx("div", {
16062
+ className: "rounded-surface border border-border",
16063
+ children: /* @__PURE__ */ jsx(Tree, {
16064
+ label: `${label}: folders`,
16065
+ roots,
16066
+ useChildren: (f) => useFolders(f.path),
16067
+ nodeKey: (f) => f.path,
16068
+ nodeLabel: (f) => f.badge ? `${f.name}, ${f.badge}` : f.name,
16069
+ beforeOpen: onOpen ? (f) => {
16070
+ if (onOpen(f) !== "choose") return true;
16071
+ go(f.path);
16072
+ onChoose(f.path);
16073
+ return false;
16074
+ } : void 0,
16075
+ renderNode: (f) => /* @__PURE__ */ jsxs("span", {
16076
+ className: "flex min-w-0 items-baseline gap-2",
16077
+ children: [
16078
+ /* @__PURE__ */ jsx("span", {
16079
+ className: "truncate",
16080
+ children: f.name
16081
+ }),
16082
+ f.badge && /* @__PURE__ */ jsx(Status, {
16083
+ tone: f.tone ?? "neutral",
16084
+ className: "self-center",
16085
+ children: f.badge
16086
+ }),
16087
+ f.count !== void 0 && /* @__PURE__ */ jsx("span", {
16088
+ className: "type-caption tabular-nums text-muted-foreground",
16089
+ children: format.integer(f.count)
16090
+ })
16091
+ ]
16092
+ }),
16093
+ selected: value,
16094
+ onSelect: (key) => onChange(key),
16095
+ expanded,
16096
+ emptyRow,
16097
+ height
16062
16098
  })
16063
16099
  }),
16064
- /* @__PURE__ */ jsx("p", {
16065
- id: hintId,
16066
- className: "type-caption text-muted-foreground",
16067
- children: "Drag across words, or Shift+click, to select. Left and Right move; Shift and arrows select; Escape clears."
16100
+ recent && recent.length > 0 && /* @__PURE__ */ jsxs("div", {
16101
+ role: "group",
16102
+ "aria-label": "Recent folders",
16103
+ className: "flex flex-wrap items-center gap-2",
16104
+ children: [/* @__PURE__ */ jsx("span", {
16105
+ className: "type-caption text-muted-foreground",
16106
+ children: "Recent"
16107
+ }), recent.map((r) => /* @__PURE__ */ jsx(Tooltip, {
16108
+ label: r,
16109
+ side: "bottom",
16110
+ children: /* @__PURE__ */ jsx(Button, {
16111
+ size: "sm",
16112
+ variant: "outline",
16113
+ onPress: () => go(r),
16114
+ className: "max-w-64 truncate font-mono",
16115
+ children: r
16116
+ })
16117
+ }, r))]
16068
16118
  }),
16069
- /* @__PURE__ */ jsx(CommandLegend, {
16070
- commands,
16071
- label: "Mark keys"
16119
+ onCreate && /* @__PURE__ */ jsx("form", {
16120
+ onSubmit: (e) => {
16121
+ e.preventDefault();
16122
+ created.run(name.trim());
16123
+ },
16124
+ children: /* @__PURE__ */ jsx(Field, {
16125
+ label: "New folder",
16126
+ hint: value ? `It will be made in ${value}.` : "Open a folder first.",
16127
+ error: created.fieldErrors.name ?? (created.phase === "error" ? created.error : void 0),
16128
+ action: /* @__PURE__ */ jsx(AsyncButton, {
16129
+ type: "submit",
16130
+ phase: created.phase,
16131
+ error: created.error,
16132
+ disabled: !value,
16133
+ labels: {
16134
+ idle: "Make folder",
16135
+ pending: "Making…",
16136
+ done: "Made"
16137
+ }
16138
+ }),
16139
+ children: /* @__PURE__ */ jsx(Input, {
16140
+ value: name,
16141
+ disabled: !value,
16142
+ onChange: (e) => {
16143
+ setName(e.target.value);
16144
+ created.clearFieldError("name");
16145
+ }
16146
+ })
16147
+ })
16072
16148
  }),
16073
- summary && /* @__PURE__ */ jsx(MarkSummary, {
16074
- marks,
16075
- kinds,
16076
- unit
16149
+ footer && /* @__PURE__ */ jsx("p", {
16150
+ className: "type-body-sm text-muted-foreground",
16151
+ children: footer
16077
16152
  }),
16078
- /* @__PURE__ */ jsx("div", {
16079
- role: "status",
16080
- "aria-live": "polite",
16081
- className: "sr-only",
16082
- children: said
16153
+ /* @__PURE__ */ jsxs("div", {
16154
+ className: "flex flex-wrap items-center justify-end gap-3",
16155
+ children: [reason && /* @__PURE__ */ jsx("p", {
16156
+ id: reasonId,
16157
+ className: "min-w-0 flex-1 type-body-sm text-muted-foreground",
16158
+ children: reason
16159
+ }), /* @__PURE__ */ jsx(Button, {
16160
+ variant: "default",
16161
+ disabled: !value || reason !== void 0,
16162
+ "aria-describedby": reason ? reasonId : void 0,
16163
+ onPress: () => value && onChoose(value),
16164
+ children: chooseLabel
16165
+ })]
16083
16166
  })
16084
16167
  ]
16085
16168
  });
16086
16169
  }
16087
- export { ActiveList, Alert, AlertDialog, AppShell, AsyncButton, BookViewer, BoxList, BoxOverlay, Breadcrumb, BulkBar, Button, COLOR_SCHEME_STORAGE_KEY, Checkbox, ChoiceGroup, ColorField, ColorSchemeChoice, CommandLegend, CommandMenu, Compare, CompareAudio, CompareGrid, CompareText, CompareVideo, CompareVideoGrid, Composer, CompositionBar, ContextMenu, Conversation, CursorScope, DEFAULT_TOLERANCE, DataTable, DataView, Density, Dialog, Disclosure, Done, EmptyState, FIT, Field, FileButton, FileDropZone, FileOutcomes, FolderPicker, FullscreenFrame, HttpError, IconButton, InfiniteList, Input, Inspector, InspectorSection, JobStatus, KeysLegend, Lightbox, LineChart, LineChartGroup, LinkCard, LinkCardList, LoadError, LoadMore, MAX_SCALE, MAX_SIDE, MIN_SCALE, MISSING, Mark, MarkSummary, MarkableText, MediaGroup, MediaPlayer, MediaStage, Menu, Meter, Metric, MetricStrip, MissingFile, NBSP, NativeSelect, NumberField, PageHeader, PairJudge, PairVote, Pane, PlayWindowButton, Popover, PropertyList, PropertyRow, RateChoice, RegionEditor, RichText, RowAction, SPEECH_RATES, SaveStatus, SecretField, SeekBar, SelectableGrid, SelectableGridSkeleton, SequenceTimeline, SideNav, Skeleton, Slider, SortableList, SpanActions, Split, StageGuides, StaleNotice, Status, StrataQueryProvider, StrataToastRegion, Switch, TableSkeleton, Tabs, Textarea, ThemeProvider, Thumbnail, ThumbnailSkeleton, TileGrid, TileGridSkeleton, TimeReadout, Timeline, TimelineZoomControls, Toggle, ToggleGroup, Toolbar, ToolbarSeparator, Tooltip, TranscriptView, Transport, Tree, UndoBar, ViewOptions, ViewportFrame, VirtualList, VolumeControl, Waveform, Workspace, actualPixelsScale, ancestorsOf, boxViewport, buttonVariants, canFullscreen, clampToRoom, clampViewport, cn, colorSchemeScript, commandShortcut, countMarks, createFormat, createQueryClient, crossedThreshold, describeActionError, describeHttpError, describeRegion, detectPlatform, diffWords, differences, drawRect, ease, fetchJson, fieldErrorsOf, findPage, fitRect, format, formatChord, gainToVolume, geo, gridPoints, gutterOf, isDoubtful, isReservedChord, isTypingTarget, jobProgressText, joinMediaGroup, joinRects, labelOf, lerpRect, logScale, loudnessOf, matchEntities, matchGains, matchesAccept, matchesChord, measureLoudness, moveGutter, moveRect, noOverlap, normaliseAngle, pageName, parentOf, parseChord, parseInline, parseRichText, parseSort, peaksFromAudio, phraseAt, phraseDoubtful, plainText, rangeBetween, readErrorBody, readPixels, readingOrder, regionShares, resample, resamplePeaks, resizeRect, safeHref, sayPosition, serialiseSort, settleCut, snapToGrid, sortRows, splitRect, staleOf, stepId, stepOnGrid, tickLabel, tickStep, ticksBetween, toDate, toLoad, toPeakPair, toast, toastTimeout, transportShortcuts, turnRect, turnedSize, typeSteps, useActiveItem, useAsyncAction, useAttachedSource, useAutoSave, useBookUrl, useBoxes, useChoices, useClientWork, useColorScheme, useCommands, useDifference, useExpanded, useFileIntake, useHistory, useHistoryState, useHotkeys, useInView, useInfiniteLoad, useJob, useJobAction, useLeaveGuard, useLightboxUrl, useLoad, useMediaElement, useMediaSpans, useSelection, useSharedCursor, useSystemColorScheme, useTimelineZoom, useUndoable, useViewOptions, useViewport, useWorkspaceState, valueAt, viewOf, viewsOf, wordAt, zoomAt, zoomToBox };
16170
+ export { ActiveList, Alert, AlertDialog, AppShell, AsyncButton, BookViewer, BoxList, BoxOverlay, Breadcrumb, BulkBar, Button, COLOR_SCHEME_STORAGE_KEY, Checkbox, ChoiceGroup, ColorField, ColorSchemeChoice, CommandLegend, CommandMenu, Compare, CompareAudio, CompareGrid, CompareText, CompareVideo, CompareVideoGrid, Composer, CompositionBar, ContextMenu, Conversation, CursorScope, DEFAULT_TOLERANCE, DataTable, DataView, Density, Dialog, Disclosure, Done, EmptyState, FIT, Field, FileButton, FileDropZone, FileOutcomes, FolderPicker, FullscreenFrame, HttpError, IconButton, InfiniteList, Input, Inspector, InspectorSection, JobStatus, KeysLegend, Lightbox, LineChart, LineChartGroup, LinkCard, LinkCardList, LoadError, LoadMore, MAX_SCALE, MAX_SIDE, MIN_SCALE, MISSING, Mark, MarkSummary, MarkableText, MediaGroup, MediaPlayer, MediaStage, Menu, Meter, Metric, MetricStrip, MissingFile, NBSP, NativeSelect, NumberField, PageHeader, PairJudge, PairVote, Pane, PlayWindowButton, Popover, PropertyList, PropertyRow, RateChoice, RegionEditor, RichText, RowAction, SPEECH_RATES, SaveStatus, SecretField, SeekBar, SelectableGrid, SelectableGridSkeleton, SequenceTimeline, SideNav, Skeleton, Slider, SortableList, SpanActions, Split, StageGuides, StaleNotice, Status, StrataQueryProvider, StrataToastRegion, Switch, TableSkeleton, Tabs, Textarea, ThemeProvider, Thumbnail, ThumbnailSkeleton, TileGrid, TileGridSkeleton, TimeReadout, Timeline, TimelineZoomControls, Toggle, ToggleGroup, Toolbar, ToolbarSeparator, Tooltip, TranscriptView, Transport, Tree, UndoBar, ViewOptions, ViewportFrame, VirtualList, VolumeControl, Waveform, Workspace, actualPixelsScale, ancestorsOf, boxViewport, buttonVariants, canFullscreen, clampToRoom, clampViewport, cn, colorSchemeScript, commandShortcut, countMarks, createFormat, createQueryClient, crossedThreshold, describeActionError, describeHttpError, describeRegion, detectPlatform, diffWords, differences, drawRect, ease, fetchJson, fieldErrorsOf, findPage, fitRect, format, formatChord, gainToVolume, geo, gridPoints, gutterOf, isDoubtful, isReservedChord, isTypingTarget, jobProgressText, joinMediaGroup, joinRects, labelOf, lerpRect, logScale, loudnessOf, matchEntities, matchGains, matchesAccept, matchesChord, measureLoudness, moveGutter, moveRect, noOverlap, normaliseAngle, pageName, parentOf, parseChord, parseInline, parseRichText, parseSort, peaksFromAudio, phraseAt, phraseDoubtful, phraseOfWordId, plainText, rangeBetween, readErrorBody, readPixels, readingOrder, regionShares, resample, resamplePeaks, resizeRect, safeHref, sayPosition, serialiseSort, settleCut, snapToGrid, sortRows, splitRect, staleOf, stepId, stepOnGrid, tickLabel, tickStep, ticksBetween, toDate, toLoad, toPeakPair, toast, toastTimeout, transportShortcuts, turnRect, turnedSize, typeSteps, useActiveItem, useAsyncAction, useAttachedSource, useAutoSave, useBookUrl, useBoxes, useChoices, useClientWork, useColorScheme, useCommands, useDifference, useExpanded, useFileIntake, useHistory, useHistoryState, useHotkeys, useInView, useInfiniteLoad, useJob, useJobAction, useLeaveGuard, useLightboxUrl, useLoad, useMediaElement, useMediaSpans, useSelection, useSharedCursor, useSystemColorScheme, useTimelineZoom, useUndoable, useViewOptions, useViewport, useWorkspaceState, valueAt, viewOf, viewsOf, wordAt, wordId, zoomAt, zoomToBox };
16088
16171
 
16089
16172
  //# sourceMappingURL=index.js.map