@almadar/ui 6.8.0 → 6.10.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.
Files changed (33) hide show
  1. package/dist/{EntityBindingContext-Bn3ePJQC.d.cts → EntityBindingContext-Y4zXyNJZ.d.cts} +14 -2
  2. package/dist/{EntityBindingContext-Bn3ePJQC.d.ts → EntityBindingContext-Y4zXyNJZ.d.ts} +14 -2
  3. package/dist/avl/index.cjs +531 -48
  4. package/dist/avl/index.js +531 -48
  5. package/dist/{cn-sgpqpN0U.d.ts → cn-C7fvp9gH.d.ts} +37 -10
  6. package/dist/{cn-CCjFspAo.d.cts → cn-DnLYahyL.d.cts} +37 -10
  7. package/dist/components/index.cjs +557 -47
  8. package/dist/components/index.d.cts +6 -4
  9. package/dist/components/index.d.ts +6 -4
  10. package/dist/components/index.js +556 -48
  11. package/dist/hooks/index.cjs +30 -1
  12. package/dist/hooks/index.d.cts +2 -2
  13. package/dist/hooks/index.d.ts +2 -2
  14. package/dist/hooks/index.js +29 -2
  15. package/dist/lib/drawable/three/index.cjs +21 -2
  16. package/dist/lib/drawable/three/index.js +21 -2
  17. package/dist/lib/index.cjs +238 -9
  18. package/dist/lib/index.d.cts +1 -1
  19. package/dist/lib/index.d.ts +1 -1
  20. package/dist/lib/index.js +234 -10
  21. package/dist/marketing/index.cjs +12 -3
  22. package/dist/marketing/index.js +12 -3
  23. package/dist/providers/index.cjs +556 -56
  24. package/dist/providers/index.d.cts +1 -1
  25. package/dist/providers/index.d.ts +1 -1
  26. package/dist/providers/index.js +556 -56
  27. package/dist/runtime/index.cjs +545 -52
  28. package/dist/runtime/index.d.cts +13 -6
  29. package/dist/runtime/index.d.ts +13 -6
  30. package/dist/runtime/index.js +545 -52
  31. package/dist/{useKeyboardRouter-D84cNWmA.d.ts → useKeyboardRouter-B1pIi9jo.d.ts} +11 -1
  32. package/dist/{useKeyboardRouter-DQEE_9mq.d.cts → useKeyboardRouter-CVn8lfiX.d.cts} +11 -1
  33. package/package.json +3 -3
@@ -1023,6 +1023,33 @@ function useEmitEvent() {
1023
1023
  [eventBus]
1024
1024
  );
1025
1025
  }
1026
+ function mergeCaptureTables(tables) {
1027
+ const merged = {};
1028
+ for (const table of tables) {
1029
+ for (const [target, entry] of Object.entries(table)) {
1030
+ const current = merged[target];
1031
+ if (!current) {
1032
+ merged[target] = { mode: entry.mode, keys: new Set(entry.keys) };
1033
+ continue;
1034
+ }
1035
+ for (const key of entry.keys) current.keys.add(key);
1036
+ if (current.mode === "any" || entry.mode === "any") current.mode = "any";
1037
+ else if (current.mode !== entry.mode) {
1038
+ current.mode = Array.from(/* @__PURE__ */ new Set([...current.mode.split("|"), entry.mode])).sort().join("|");
1039
+ }
1040
+ }
1041
+ }
1042
+ return merged;
1043
+ }
1044
+ function keyChord(event) {
1045
+ const parts = [];
1046
+ if (event.ctrlKey) parts.push("Control");
1047
+ if (event.altKey) parts.push("Alt");
1048
+ if (event.shiftKey) parts.push("Shift");
1049
+ if (event.metaKey) parts.push("Meta");
1050
+ parts.push(event.key);
1051
+ return parts.join("+");
1052
+ }
1026
1053
  function useKeyboardRouter(options) {
1027
1054
  const {
1028
1055
  captureTable,
@@ -1059,7 +1086,7 @@ function useKeyboardRouter(options) {
1059
1086
  if (event.isComposing) return;
1060
1087
  const target = focusedEditorIdRef.current ?? "shell";
1061
1088
  const entry = captureTableRef.current[target];
1062
- const captured = entry !== void 0 && (entry.mode === "any" || entry.keys.has(event.key));
1089
+ const captured = entry !== void 0 && (entry.keys.has(event.key) || entry.keys.has(keyChord(event)));
1063
1090
  if (captured) {
1064
1091
  event.preventDefault();
1065
1092
  }
@@ -2982,6 +3009,8 @@ exports.I18nProvider = I18nProvider;
2982
3009
  exports.SharedEntityStoreContext = SharedEntityStoreContext;
2983
3010
  exports.createSharedEntityStore = createSharedEntityStore;
2984
3011
  exports.createTranslate = createTranslate;
3012
+ exports.keyChord = keyChord;
3013
+ exports.mergeCaptureTables = mergeCaptureTables;
2985
3014
  exports.parseQueryBinding = parseQueryBinding;
2986
3015
  exports.runTickFrame = runTickFrame;
2987
3016
  exports.useAgentChat = useAgentChat;
@@ -1,7 +1,7 @@
1
1
  import { OrbitalSchema, FieldValue, EventPayload, EntityFrameState, EntityFieldWrite } from '@almadar/core';
2
2
  export { BusEvent, BusEventListener, BusEventSource, BusEventListener as EventListener, UISlot, Unsubscribe } from '@almadar/core';
3
- import { b as useEventBus } from '../useKeyboardRouter-DQEE_9mq.cjs';
4
- export { E as EditorKeyEvent, a as KeyCaptureEntry, K as KeyCaptureTable, U as UseKeyboardRouterOptions, u as useEmitEvent, c as useEventListener, d as useKeyboardRouter } from '../useKeyboardRouter-DQEE_9mq.cjs';
3
+ import { b as useEventBus } from '../useKeyboardRouter-CVn8lfiX.cjs';
4
+ export { E as EditorKeyEvent, a as KeyCaptureEntry, K as KeyCaptureTable, U as UseKeyboardRouterOptions, k as keyChord, m as mergeCaptureTables, u as useEmitEvent, c as useEventListener, d as useKeyboardRouter } from '../useKeyboardRouter-CVn8lfiX.cjs';
5
5
  export { E as EventBusContextType } from '../event-bus-types-Bl78kokd.cjs';
6
6
  export { D as DEFAULT_SLOTS, S as SlotAnimation, a as SlotChangeCallback, b as SlotContent, c as SlotRenderConfig, U as UISlotManager, u as useUISlotManager } from '../useUISlots-GNwGLlW2.cjs';
7
7
  export { a as NavStackApi, u as useNavStack } from '../NavStackContext-bw2nlBgT.cjs';
@@ -1,7 +1,7 @@
1
1
  import { OrbitalSchema, FieldValue, EventPayload, EntityFrameState, EntityFieldWrite } from '@almadar/core';
2
2
  export { BusEvent, BusEventListener, BusEventSource, BusEventListener as EventListener, UISlot, Unsubscribe } from '@almadar/core';
3
- import { b as useEventBus } from '../useKeyboardRouter-D84cNWmA.js';
4
- export { E as EditorKeyEvent, a as KeyCaptureEntry, K as KeyCaptureTable, U as UseKeyboardRouterOptions, u as useEmitEvent, c as useEventListener, d as useKeyboardRouter } from '../useKeyboardRouter-D84cNWmA.js';
3
+ import { b as useEventBus } from '../useKeyboardRouter-B1pIi9jo.js';
4
+ export { E as EditorKeyEvent, a as KeyCaptureEntry, K as KeyCaptureTable, U as UseKeyboardRouterOptions, k as keyChord, m as mergeCaptureTables, u as useEmitEvent, c as useEventListener, d as useKeyboardRouter } from '../useKeyboardRouter-B1pIi9jo.js';
5
5
  export { E as EventBusContextType } from '../event-bus-types-Bl78kokd.js';
6
6
  export { D as DEFAULT_SLOTS, S as SlotAnimation, a as SlotChangeCallback, b as SlotContent, c as SlotRenderConfig, U as UISlotManager, u as useUISlotManager } from '../useUISlots-GNwGLlW2.js';
7
7
  export { a as NavStackApi, u as useNavStack } from '../NavStackContext-bw2nlBgT.js';
@@ -1018,6 +1018,33 @@ function useEmitEvent() {
1018
1018
  [eventBus]
1019
1019
  );
1020
1020
  }
1021
+ function mergeCaptureTables(tables) {
1022
+ const merged = {};
1023
+ for (const table of tables) {
1024
+ for (const [target, entry] of Object.entries(table)) {
1025
+ const current = merged[target];
1026
+ if (!current) {
1027
+ merged[target] = { mode: entry.mode, keys: new Set(entry.keys) };
1028
+ continue;
1029
+ }
1030
+ for (const key of entry.keys) current.keys.add(key);
1031
+ if (current.mode === "any" || entry.mode === "any") current.mode = "any";
1032
+ else if (current.mode !== entry.mode) {
1033
+ current.mode = Array.from(/* @__PURE__ */ new Set([...current.mode.split("|"), entry.mode])).sort().join("|");
1034
+ }
1035
+ }
1036
+ }
1037
+ return merged;
1038
+ }
1039
+ function keyChord(event) {
1040
+ const parts = [];
1041
+ if (event.ctrlKey) parts.push("Control");
1042
+ if (event.altKey) parts.push("Alt");
1043
+ if (event.shiftKey) parts.push("Shift");
1044
+ if (event.metaKey) parts.push("Meta");
1045
+ parts.push(event.key);
1046
+ return parts.join("+");
1047
+ }
1021
1048
  function useKeyboardRouter(options) {
1022
1049
  const {
1023
1050
  captureTable,
@@ -1054,7 +1081,7 @@ function useKeyboardRouter(options) {
1054
1081
  if (event.isComposing) return;
1055
1082
  const target = focusedEditorIdRef.current ?? "shell";
1056
1083
  const entry = captureTableRef.current[target];
1057
- const captured = entry !== void 0 && (entry.mode === "any" || entry.keys.has(event.key));
1084
+ const captured = entry !== void 0 && (entry.keys.has(event.key) || entry.keys.has(keyChord(event)));
1058
1085
  if (captured) {
1059
1086
  event.preventDefault();
1060
1087
  }
@@ -2967,4 +2994,4 @@ function useGitHubBranches(owner, repo, enabled = true) {
2967
2994
  });
2968
2995
  }
2969
2996
 
2970
- export { ALMADAR_DND_MIME, DEFAULT_SLOTS, I18nProvider, SharedEntityStoreContext, createSharedEntityStore, createTranslate, parseQueryBinding, runTickFrame, useAgentChat, useAuthContext, useCanvasGestures, useCompile, useConnectGitHub, useDeepAgentGeneration, useDisconnectGitHub, useDragReorder, useDraggable, useDropZone, useEmitEvent, useEventBus, useEventListener, useExtensions, useFileEditor, useFileSystem, useGitHubBranches, useGitHubRepo, useGitHubRepos, useGitHubStatus, useInfiniteScroll, useKeyboardRouter, useLongPress, useMediaQuery, useOrbitalHistory, usePreview, usePullToRefresh, useQuerySingleton, useRenderInterpolation, useSharedEntitySnapshot, useSharedEntityStore, useSharedEntityStoreContext, useSwipeGesture, useTapReveal, useTraitListens, useTranslate, useUIEvents, useUISlotManager, useValidation };
2997
+ export { ALMADAR_DND_MIME, DEFAULT_SLOTS, I18nProvider, SharedEntityStoreContext, createSharedEntityStore, createTranslate, keyChord, mergeCaptureTables, parseQueryBinding, runTickFrame, useAgentChat, useAuthContext, useCanvasGestures, useCompile, useConnectGitHub, useDeepAgentGeneration, useDisconnectGitHub, useDragReorder, useDraggable, useDropZone, useEmitEvent, useEventBus, useEventListener, useExtensions, useFileEditor, useFileSystem, useGitHubBranches, useGitHubRepo, useGitHubRepos, useGitHubStatus, useInfiniteScroll, useKeyboardRouter, useLongPress, useMediaQuery, useOrbitalHistory, usePreview, usePullToRefresh, useQuerySingleton, useRenderInterpolation, useSharedEntitySnapshot, useSharedEntityStore, useSharedEntityStoreContext, useSwipeGesture, useTapReveal, useTraitListens, useTranslate, useUIEvents, useUISlotManager, useValidation };
@@ -180,6 +180,10 @@ function isValidScenePos(pos) {
180
180
  }
181
181
 
182
182
  // lib/drawable/hitTest.ts
183
+ function shapeDrawnItem(n) {
184
+ if (n.shape !== "rect") return { pos: n.position, id: n.id };
185
+ return { pos: n.position, id: n.id, anchor: n.anchor, width: n.width, height: n.height, rotation: n.rotate };
186
+ }
183
187
  function collectDrawnItems(nodes) {
184
188
  const out = [];
185
189
  for (const n of nodes) {
@@ -188,6 +192,8 @@ function collectDrawnItems(nodes) {
188
192
  if (isValidScenePos(n.position)) out.push({ pos: n.position, id: n.id, anchor: n.anchor, width: n.width, height: n.height, rotation: n.rotation });
189
193
  break;
190
194
  case "draw-shape":
195
+ if (isValidScenePos(n.position)) out.push(shapeDrawnItem(n));
196
+ break;
191
197
  case "draw-text":
192
198
  case "draw-group":
193
199
  case "draw-mesh":
@@ -199,6 +205,10 @@ function collectDrawnItems(nodes) {
199
205
  }
200
206
  break;
201
207
  case "draw-shape-layer":
208
+ for (const it of n.items) {
209
+ if (isValidScenePos(it.position)) out.push(shapeDrawnItem(it));
210
+ }
211
+ break;
202
212
  case "draw-text-layer":
203
213
  for (const it of n.items) {
204
214
  if (isValidScenePos(it.position)) out.push({ pos: it.position, id: it.id });
@@ -3971,8 +3981,17 @@ var Typography = ({
3971
3981
  weight && weightStyles[weight],
3972
3982
  size && typographySizeStyles[size],
3973
3983
  align && `text-${align}`,
3974
- truncate && "truncate overflow-hidden text-ellipsis",
3975
- overflow && overflowStyles2[overflow],
3984
+ // `min-w-0` rides along with truncate/wrap/clamp: a flex or grid
3985
+ // item's default `min-width: auto` refuses to shrink below its
3986
+ // content's intrinsic width, so ellipsis/wrap silently does nothing
3987
+ // in the single most common placement (a row next to a fixed-width
3988
+ // control) unless the item can also shrink to zero. (Spelled out as
3989
+ // just "truncate", not "truncate overflow-hidden text-ellipsis" —
3990
+ // tailwind-merge treats those as the same conflict group and drops
3991
+ // "truncate" as the earlier-declared class, silently losing its
3992
+ // `white-space: nowrap`.)
3993
+ truncate && "truncate min-w-0",
3994
+ overflow && cn(overflowStyles2[overflow], overflow !== "visible" && "min-w-0"),
3976
3995
  className
3977
3996
  ),
3978
3997
  style
@@ -156,6 +156,10 @@ function isValidScenePos(pos) {
156
156
  }
157
157
 
158
158
  // lib/drawable/hitTest.ts
159
+ function shapeDrawnItem(n) {
160
+ if (n.shape !== "rect") return { pos: n.position, id: n.id };
161
+ return { pos: n.position, id: n.id, anchor: n.anchor, width: n.width, height: n.height, rotation: n.rotate };
162
+ }
159
163
  function collectDrawnItems(nodes) {
160
164
  const out = [];
161
165
  for (const n of nodes) {
@@ -164,6 +168,8 @@ function collectDrawnItems(nodes) {
164
168
  if (isValidScenePos(n.position)) out.push({ pos: n.position, id: n.id, anchor: n.anchor, width: n.width, height: n.height, rotation: n.rotation });
165
169
  break;
166
170
  case "draw-shape":
171
+ if (isValidScenePos(n.position)) out.push(shapeDrawnItem(n));
172
+ break;
167
173
  case "draw-text":
168
174
  case "draw-group":
169
175
  case "draw-mesh":
@@ -175,6 +181,10 @@ function collectDrawnItems(nodes) {
175
181
  }
176
182
  break;
177
183
  case "draw-shape-layer":
184
+ for (const it of n.items) {
185
+ if (isValidScenePos(it.position)) out.push(shapeDrawnItem(it));
186
+ }
187
+ break;
178
188
  case "draw-text-layer":
179
189
  for (const it of n.items) {
180
190
  if (isValidScenePos(it.position)) out.push({ pos: it.position, id: it.id });
@@ -3947,8 +3957,17 @@ var Typography = ({
3947
3957
  weight && weightStyles[weight],
3948
3958
  size && typographySizeStyles[size],
3949
3959
  align && `text-${align}`,
3950
- truncate && "truncate overflow-hidden text-ellipsis",
3951
- overflow && overflowStyles2[overflow],
3960
+ // `min-w-0` rides along with truncate/wrap/clamp: a flex or grid
3961
+ // item's default `min-width: auto` refuses to shrink below its
3962
+ // content's intrinsic width, so ellipsis/wrap silently does nothing
3963
+ // in the single most common placement (a row next to a fixed-width
3964
+ // control) unless the item can also shrink to zero. (Spelled out as
3965
+ // just "truncate", not "truncate overflow-hidden text-ellipsis" —
3966
+ // tailwind-merge treats those as the same conflict group and drops
3967
+ // "truncate" as the earlier-declared class, silently losing its
3968
+ // `white-space: nowrap`.)
3969
+ truncate && "truncate min-w-0",
3970
+ overflow && cn(overflowStyles2[overflow], overflow !== "visible" && "min-w-0"),
3952
3971
  className
3953
3972
  ),
3954
3973
  style
@@ -2095,6 +2095,48 @@ var JAZARI_COLORS = {
2095
2095
  };
2096
2096
 
2097
2097
  // lib/editorMotions.ts
2098
+ var EDITOR_MOTIONS = [
2099
+ "left",
2100
+ "right",
2101
+ "up",
2102
+ "down",
2103
+ "word-forward",
2104
+ "word-back",
2105
+ "word-end",
2106
+ "line-start",
2107
+ "line-end",
2108
+ "first-nonblank",
2109
+ "doc-start",
2110
+ "doc-end",
2111
+ "paragraph-forward",
2112
+ "paragraph-back",
2113
+ "line",
2114
+ "selection",
2115
+ "match-bracket"
2116
+ ];
2117
+ var EDITOR_OPERATORS = [
2118
+ "delete",
2119
+ "yank",
2120
+ "change",
2121
+ "put",
2122
+ "put-before",
2123
+ "undo",
2124
+ "redo",
2125
+ "join",
2126
+ "toggle-case",
2127
+ "indent",
2128
+ "dedent",
2129
+ "replace"
2130
+ ];
2131
+ var EDITOR_MOTION_SET = new Set(EDITOR_MOTIONS);
2132
+ var EDITOR_OPERATOR_SET = new Set(EDITOR_OPERATORS);
2133
+ function isEditorMotion(value) {
2134
+ return EDITOR_MOTION_SET.has(value);
2135
+ }
2136
+ function isEditorOperator(value) {
2137
+ return EDITOR_OPERATOR_SET.has(value);
2138
+ }
2139
+ var INDENT_UNIT = " ";
2098
2140
  function clamp(value, min, max) {
2099
2141
  return Math.max(min, Math.min(max, value));
2100
2142
  }
@@ -2162,6 +2204,39 @@ function prevParagraphBoundary(lines, fromLineIdx) {
2162
2204
  }
2163
2205
  return 0;
2164
2206
  }
2207
+ var BRACKET_PARTNER = {
2208
+ "(": ")",
2209
+ ")": "(",
2210
+ "[": "]",
2211
+ "]": "[",
2212
+ "{": "}",
2213
+ "}": "{"
2214
+ };
2215
+ var OPEN_BRACKETS = /* @__PURE__ */ new Set(["(", "[", "{"]);
2216
+ function matchBracket(text, pos) {
2217
+ const ch = text[pos];
2218
+ const partner = ch !== void 0 ? BRACKET_PARTNER[ch] : void 0;
2219
+ if (partner === void 0) return null;
2220
+ let depth = 1;
2221
+ if (OPEN_BRACKETS.has(ch)) {
2222
+ for (let i = pos + 1; i < text.length; i++) {
2223
+ if (text[i] === ch) depth++;
2224
+ else if (text[i] === partner) {
2225
+ depth--;
2226
+ if (depth === 0) return i;
2227
+ }
2228
+ }
2229
+ } else {
2230
+ for (let i = pos - 1; i >= 0; i--) {
2231
+ if (text[i] === ch) depth++;
2232
+ else if (text[i] === partner) {
2233
+ depth--;
2234
+ if (depth === 0) return i;
2235
+ }
2236
+ }
2237
+ }
2238
+ return null;
2239
+ }
2165
2240
  function applyMotion(text, caret, motion, count) {
2166
2241
  const n = Math.max(1, count);
2167
2242
  const lines = computeLines(text);
@@ -2223,6 +2298,20 @@ function applyMotion(text, caret, motion, count) {
2223
2298
  }
2224
2299
  return pos;
2225
2300
  }
2301
+ case "match-bracket": {
2302
+ const chAtCaret = text[caret];
2303
+ if (chAtCaret !== void 0 && BRACKET_PARTNER[chAtCaret] !== void 0) {
2304
+ const target = matchBracket(text, caret);
2305
+ return target === null ? caret : target;
2306
+ }
2307
+ for (let i = caret; i < line.end; i++) {
2308
+ if (BRACKET_PARTNER[text[i]] !== void 0) {
2309
+ const target = matchBracket(text, i);
2310
+ return target === null ? caret : target;
2311
+ }
2312
+ }
2313
+ return caret;
2314
+ }
2226
2315
  case "line":
2227
2316
  case "selection":
2228
2317
  return caret;
@@ -2250,8 +2339,8 @@ function motionRange(text, caret, motion, count, selection) {
2250
2339
  const newCaret = applyMotion(text, caret, motion, count);
2251
2340
  let start = Math.min(caret, newCaret);
2252
2341
  let end = Math.max(caret, newCaret);
2253
- if (motion === "word-end" || motion === "line-end") {
2254
- end = Math.min(Math.max(start, newCaret) + 1, text.length);
2342
+ if ((motion === "word-end" || motion === "line-end" || motion === "match-bracket") && newCaret !== caret) {
2343
+ end = Math.min(Math.max(caret, newCaret) + 1, text.length);
2255
2344
  } else if (motion === "word-forward" && newCaret > caret) {
2256
2345
  const startLine = lineIndexAt(lines, caret);
2257
2346
  const endLine = lineIndexAt(lines, newCaret);
@@ -2261,14 +2350,149 @@ function motionRange(text, caret, motion, count, selection) {
2261
2350
  }
2262
2351
  return [start, end];
2263
2352
  }
2264
- function applyOperator(text, range, operator, register) {
2265
- const start = clamp(range[0], 0, text.length);
2266
- const end = clamp(range[1], start, text.length);
2267
- const removed = text.slice(start, end);
2268
- if (operator === "yank") {
2269
- return { text, caret: start, register: removed };
2353
+ function toggleCase(s) {
2354
+ return s.replace(/[a-zA-Z]/g, (c) => c === c.toUpperCase() ? c.toLowerCase() : c.toUpperCase());
2355
+ }
2356
+ function applyJoin(text, caret, count, register, registerLinewise) {
2357
+ const lines = computeLines(text);
2358
+ const startIdx = lineIndexAt(lines, caret);
2359
+ const n = Math.max(2, count);
2360
+ const endIdx = clamp(startIdx + n - 1, 0, lines.length - 1);
2361
+ if (endIdx <= startIdx) {
2362
+ return { text, caret, register, registerLinewise };
2363
+ }
2364
+ const joinCaret = lines[startIdx].end;
2365
+ let joined = text.slice(lines[startIdx].start, lines[startIdx].end);
2366
+ for (let i = startIdx + 1; i <= endIdx; i++) {
2367
+ const raw = text.slice(lines[i].start, lines[i].end);
2368
+ joined += " " + raw.replace(/^[ \t]+/, "");
2369
+ }
2370
+ const newText = text.slice(0, lines[startIdx].start) + joined + text.slice(lines[endIdx].end);
2371
+ return { text: newText, caret: joinCaret, register, registerLinewise };
2372
+ }
2373
+ function applyIndent(text, start, end, operator, register, registerLinewise) {
2374
+ const lines = computeLines(text);
2375
+ const startLineIdx = lineIndexAt(lines, start);
2376
+ const lastTouchedPos = end > start ? end - 1 : start;
2377
+ const endLineIdx = lineIndexAt(lines, lastTouchedPos);
2378
+ let result = text;
2379
+ for (let i = endLineIdx; i >= startLineIdx; i--) {
2380
+ const lineStart = lines[i].start;
2381
+ if (operator === "indent") {
2382
+ result = result.slice(0, lineStart) + INDENT_UNIT + result.slice(lineStart);
2383
+ } else if (result[lineStart] === " ") {
2384
+ result = result.slice(0, lineStart) + result.slice(lineStart + 1);
2385
+ } else {
2386
+ let removeCount = 0;
2387
+ while (removeCount < INDENT_UNIT.length && result[lineStart + removeCount] === " ") removeCount++;
2388
+ result = result.slice(0, lineStart) + result.slice(lineStart + removeCount);
2389
+ }
2390
+ }
2391
+ const newLines = computeLines(result);
2392
+ const caret = firstNonBlank(result, newLines[startLineIdx]);
2393
+ return { text: result, caret, register, registerLinewise };
2394
+ }
2395
+ function applyPut(text, caret, operator, register, registerLinewise, count) {
2396
+ if (register.length === 0) {
2397
+ return { text, caret, register, registerLinewise };
2398
+ }
2399
+ const content = register.repeat(count);
2400
+ const lines = computeLines(text);
2401
+ const line = lines[lineIndexAt(lines, caret)];
2402
+ if (registerLinewise) {
2403
+ if (operator === "put-before") {
2404
+ const insertPos3 = line.start;
2405
+ return {
2406
+ text: text.slice(0, insertPos3) + content + text.slice(insertPos3),
2407
+ caret: insertPos3,
2408
+ register,
2409
+ registerLinewise
2410
+ };
2411
+ }
2412
+ const nextLineIdx = lineIndexAt(lines, caret) + 1;
2413
+ if (nextLineIdx < lines.length) {
2414
+ const insertPos3 = lines[nextLineIdx].start;
2415
+ return {
2416
+ text: text.slice(0, insertPos3) + content + text.slice(insertPos3),
2417
+ caret: insertPos3,
2418
+ register,
2419
+ registerLinewise
2420
+ };
2421
+ }
2422
+ const insertPos2 = text.length;
2423
+ return {
2424
+ text: text.slice(0, insertPos2) + "\n" + content,
2425
+ caret: insertPos2 + 1,
2426
+ register,
2427
+ registerLinewise
2428
+ };
2429
+ }
2430
+ const insertPos = operator === "put-before" ? clamp(caret, 0, text.length) : clamp(caret + 1, line.start, line.end);
2431
+ return {
2432
+ text: text.slice(0, insertPos) + content + text.slice(insertPos),
2433
+ caret: insertPos + content.length - 1,
2434
+ register,
2435
+ registerLinewise
2436
+ };
2437
+ }
2438
+ function applyOperator(input) {
2439
+ const { text, caret, operator, motion, register, registerLinewise } = input;
2440
+ const count = Math.max(1, input.count);
2441
+ const start = clamp(input.range[0], 0, text.length);
2442
+ const end = clamp(input.range[1], start, text.length);
2443
+ switch (operator) {
2444
+ case "yank":
2445
+ return { text, caret: start, register: text.slice(start, end), registerLinewise: motion === "line" };
2446
+ case "delete":
2447
+ case "replace": {
2448
+ const removed = text.slice(start, end);
2449
+ return {
2450
+ text: text.slice(0, start) + text.slice(end),
2451
+ caret: start,
2452
+ register: removed,
2453
+ registerLinewise: motion === "line"
2454
+ };
2455
+ }
2456
+ case "change": {
2457
+ if (motion === "line") {
2458
+ const hasTrailingNewline = end > start && text[end - 1] === "\n";
2459
+ const removeEnd = hasTrailingNewline ? end - 1 : end;
2460
+ const removed2 = text.slice(start, removeEnd);
2461
+ return {
2462
+ text: text.slice(0, start) + text.slice(removeEnd),
2463
+ caret: start,
2464
+ register: removed2,
2465
+ registerLinewise: true
2466
+ };
2467
+ }
2468
+ const removed = text.slice(start, end);
2469
+ return {
2470
+ text: text.slice(0, start) + text.slice(end),
2471
+ caret: start,
2472
+ register: removed,
2473
+ registerLinewise: false
2474
+ };
2475
+ }
2476
+ case "put":
2477
+ case "put-before":
2478
+ return applyPut(text, caret, operator, register, registerLinewise, count);
2479
+ case "join":
2480
+ return applyJoin(text, caret, count, register, registerLinewise);
2481
+ case "toggle-case": {
2482
+ const toggled = toggleCase(text.slice(start, end));
2483
+ return { text: text.slice(0, start) + toggled + text.slice(end), caret: end, register, registerLinewise };
2484
+ }
2485
+ case "indent":
2486
+ case "dedent":
2487
+ return applyIndent(text, start, end, operator, register, registerLinewise);
2488
+ case "undo":
2489
+ case "redo":
2490
+ return { text, caret, register, registerLinewise };
2491
+ default: {
2492
+ const _exhaustive = operator;
2493
+ return _exhaustive;
2494
+ }
2270
2495
  }
2271
- return { text: text.slice(0, start) + text.slice(end), caret: start, register: removed };
2272
2496
  }
2273
2497
 
2274
2498
  Object.defineProperty(exports, "PERF_NAMESPACE", {
@@ -2301,6 +2525,9 @@ Object.defineProperty(exports, "perfTimeAsync", {
2301
2525
  });
2302
2526
  exports.ApiError = ApiError;
2303
2527
  exports.DEFAULT_CONFIG = DEFAULT_CONFIG;
2528
+ exports.EDITOR_MOTIONS = EDITOR_MOTIONS;
2529
+ exports.EDITOR_OPERATORS = EDITOR_OPERATORS;
2530
+ exports.INDENT_UNIT = INDENT_UNIT;
2304
2531
  exports.JAZARI_COLORS = JAZARI_COLORS;
2305
2532
  exports.apiClient = apiClient;
2306
2533
  exports.applyMotion = applyMotion;
@@ -2371,6 +2598,8 @@ exports.humanizeEnumValue = humanizeEnumValue;
2371
2598
  exports.humanizeFieldName = humanizeFieldName;
2372
2599
  exports.initDebugShortcut = initDebugShortcut;
2373
2600
  exports.isDebugEnabled = isDebugEnabled;
2601
+ exports.isEditorMotion = isEditorMotion;
2602
+ exports.isEditorOperator = isEditorOperator;
2374
2603
  exports.lockIconPath = lockIconPath;
2375
2604
  exports.logDebugEvent = logDebugEvent;
2376
2605
  exports.logEffectExecuted = logEffectExecuted;
@@ -1,4 +1,4 @@
1
- export { C as ContentSegment, D as DEFAULT_CONFIG, a as DomEntityBox, b as DomLayoutData, c as DomOutputsBox, d as DomStateNode, e as DomTransitionLabel, f as DomTransitionPath, E as EditorMotion, g as EditorOperator, h as EntityDefinition, L as LessonSegment, R as RenderOptions, S as StateDefinition, i as StateMachineDefinition, T as TraitSnapshotGetter, j as TransitionDefinition, V as VisualizerConfig, k as applyMotion, l as applyOperator, m as bindCanvasCapture, n as bindEventBus, o as bindLastDrawables, p as bindTraitStateGetter, q as clearVerification, r as cn, s as extractOutputsFromTransitions, t as extractStateMachine, u as formatGuard, v as getAllChecks, w as getBridgeHealth, x as getEffectSummary, y as getSnapshot, z as getSummary, A as getTraitSnapshots, B as getTransitions, F as getTransitionsForTrait, G as motionRange, H as parseContentSegments, I as parseLessonSegments, J as parseMarkdownWithCodeBlocks, K as recordServerResponse, M as recordTransition, N as registerCheck, O as registerTraitSnapshot, P as renderStateMachineToDomData, Q as renderStateMachineToSvg, U as subscribeToVerification, W as updateAssetStatus, X as updateBridgeHealth, Y as updateCheck, Z as waitForTransition } from '../cn-CCjFspAo.cjs';
1
+ export { A as ApplyOperatorInput, a as ApplyOperatorResult, C as ContentSegment, D as DEFAULT_CONFIG, b as DomEntityBox, c as DomLayoutData, d as DomOutputsBox, e as DomStateNode, f as DomTransitionLabel, g as DomTransitionPath, E as EDITOR_MOTIONS, h as EDITOR_OPERATORS, i as EditorMotion, j as EditorOperator, k as EntityDefinition, I as INDENT_UNIT, L as LessonSegment, R as RenderOptions, S as StateDefinition, l as StateMachineDefinition, T as TraitSnapshotGetter, m as TransitionDefinition, V as VisualizerConfig, n as applyMotion, o as applyOperator, p as bindCanvasCapture, q as bindEventBus, r as bindLastDrawables, s as bindTraitStateGetter, t as clearVerification, u as cn, v as extractOutputsFromTransitions, w as extractStateMachine, x as formatGuard, y as getAllChecks, z as getBridgeHealth, B as getEffectSummary, F as getSnapshot, G as getSummary, H as getTraitSnapshots, J as getTransitions, K as getTransitionsForTrait, M as isEditorMotion, N as isEditorOperator, O as motionRange, P as parseContentSegments, Q as parseLessonSegments, U as parseMarkdownWithCodeBlocks, W as recordServerResponse, X as recordTransition, Y as registerCheck, Z as registerTraitSnapshot, _ as renderStateMachineToDomData, $ as renderStateMachineToSvg, a0 as subscribeToVerification, a1 as updateAssetStatus, a2 as updateBridgeHealth, a3 as updateCheck, a4 as waitForTransition } from '../cn-DnLYahyL.cjs';
2
2
  import { FieldValue, EntityRow, EventPayload } from '@almadar/core';
3
3
  export { AssetLoadStatus, BridgeHealth, CheckStatus, EffectTrace, EventLogEntry, OrbitalVerificationAPI, ServerResponseTrace, TraitStateSnapshot, TransitionTrace, VerificationCheck, VerificationSnapshot, VerificationSummary } from '@almadar/core';
4
4
  export { p as profilerOnRender, u as usePerfBuffer } from '../perf-DaVdsbU0.cjs';
@@ -1,4 +1,4 @@
1
- export { C as ContentSegment, D as DEFAULT_CONFIG, a as DomEntityBox, b as DomLayoutData, c as DomOutputsBox, d as DomStateNode, e as DomTransitionLabel, f as DomTransitionPath, E as EditorMotion, g as EditorOperator, h as EntityDefinition, L as LessonSegment, R as RenderOptions, S as StateDefinition, i as StateMachineDefinition, T as TraitSnapshotGetter, j as TransitionDefinition, V as VisualizerConfig, k as applyMotion, l as applyOperator, m as bindCanvasCapture, n as bindEventBus, o as bindLastDrawables, p as bindTraitStateGetter, q as clearVerification, r as cn, s as extractOutputsFromTransitions, t as extractStateMachine, u as formatGuard, v as getAllChecks, w as getBridgeHealth, x as getEffectSummary, y as getSnapshot, z as getSummary, A as getTraitSnapshots, B as getTransitions, F as getTransitionsForTrait, G as motionRange, H as parseContentSegments, I as parseLessonSegments, J as parseMarkdownWithCodeBlocks, K as recordServerResponse, M as recordTransition, N as registerCheck, O as registerTraitSnapshot, P as renderStateMachineToDomData, Q as renderStateMachineToSvg, U as subscribeToVerification, W as updateAssetStatus, X as updateBridgeHealth, Y as updateCheck, Z as waitForTransition } from '../cn-sgpqpN0U.js';
1
+ export { A as ApplyOperatorInput, a as ApplyOperatorResult, C as ContentSegment, D as DEFAULT_CONFIG, b as DomEntityBox, c as DomLayoutData, d as DomOutputsBox, e as DomStateNode, f as DomTransitionLabel, g as DomTransitionPath, E as EDITOR_MOTIONS, h as EDITOR_OPERATORS, i as EditorMotion, j as EditorOperator, k as EntityDefinition, I as INDENT_UNIT, L as LessonSegment, R as RenderOptions, S as StateDefinition, l as StateMachineDefinition, T as TraitSnapshotGetter, m as TransitionDefinition, V as VisualizerConfig, n as applyMotion, o as applyOperator, p as bindCanvasCapture, q as bindEventBus, r as bindLastDrawables, s as bindTraitStateGetter, t as clearVerification, u as cn, v as extractOutputsFromTransitions, w as extractStateMachine, x as formatGuard, y as getAllChecks, z as getBridgeHealth, B as getEffectSummary, F as getSnapshot, G as getSummary, H as getTraitSnapshots, J as getTransitions, K as getTransitionsForTrait, M as isEditorMotion, N as isEditorOperator, O as motionRange, P as parseContentSegments, Q as parseLessonSegments, U as parseMarkdownWithCodeBlocks, W as recordServerResponse, X as recordTransition, Y as registerCheck, Z as registerTraitSnapshot, _ as renderStateMachineToDomData, $ as renderStateMachineToSvg, a0 as subscribeToVerification, a1 as updateAssetStatus, a2 as updateBridgeHealth, a3 as updateCheck, a4 as waitForTransition } from '../cn-C7fvp9gH.js';
2
2
  import { FieldValue, EntityRow, EventPayload } from '@almadar/core';
3
3
  export { AssetLoadStatus, BridgeHealth, CheckStatus, EffectTrace, EventLogEntry, OrbitalVerificationAPI, ServerResponseTrace, TraitStateSnapshot, TransitionTrace, VerificationCheck, VerificationSnapshot, VerificationSummary } from '@almadar/core';
4
4
  export { p as profilerOnRender, u as usePerfBuffer } from '../perf-DaVdsbU0.js';