@pie-element/simple-cloze 0.1.4-next.15 → 0.1.4-next.17

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 (34) hide show
  1. package/dist/author/index.js +346 -315
  2. package/dist/author/index.js.map +1 -1
  3. package/dist/browser/author/index.js +2586 -2563
  4. package/dist/browser/author/index.js.map +1 -1
  5. package/dist/browser/{client-C4zbv8nl.js → client-e4ZTphpa.js} +727 -712
  6. package/dist/browser/client-e4ZTphpa.js.map +1 -0
  7. package/dist/browser/delivery/index.js +2 -2
  8. package/dist/browser/delivery/index.js.map +1 -1
  9. package/dist/browser/editor-runtime/author/index.js +1 -1
  10. package/dist/browser/editor-runtime/author/index.js.map +1 -1
  11. package/dist/browser/editor-runtime/{client-C4zbv8nl.js → client-e4ZTphpa.js} +727 -712
  12. package/dist/browser/editor-runtime/client-e4ZTphpa.js.map +1 -0
  13. package/dist/browser/editor-runtime/delivery/index.js +2 -2
  14. package/dist/browser/editor-runtime/delivery/index.js.map +1 -1
  15. package/dist/browser/editor-runtime/{i18n-gsOjC7sf.js → i18n-C7YV9VIN.js} +291 -217
  16. package/dist/browser/editor-runtime/i18n-C7YV9VIN.js.map +1 -0
  17. package/dist/browser/editor-runtime/print/index.js +2 -2
  18. package/dist/browser/editor-runtime/print/index.js.map +1 -1
  19. package/dist/browser/{i18n-gsOjC7sf.js → i18n-C7YV9VIN.js} +291 -217
  20. package/dist/browser/i18n-C7YV9VIN.js.map +1 -0
  21. package/dist/browser/print/index.js +2 -2
  22. package/dist/browser/print/index.js.map +1 -1
  23. package/dist/delivery/index.js +282 -199
  24. package/dist/delivery/index.js.map +1 -1
  25. package/dist/index.iife.js +4 -4
  26. package/dist/print/index.js +280 -197
  27. package/dist/print/index.js.map +1 -1
  28. package/module/print.js +847 -758
  29. package/module/print.js.map +1 -1
  30. package/package.json +1 -1
  31. package/dist/browser/client-C4zbv8nl.js.map +0 -1
  32. package/dist/browser/editor-runtime/client-C4zbv8nl.js.map +0 -1
  33. package/dist/browser/editor-runtime/i18n-gsOjC7sf.js.map +0 -1
  34. package/dist/browser/i18n-gsOjC7sf.js.map +0 -1
@@ -1,16 +1,16 @@
1
- //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/disclose-version.js
1
+ //#region ../../../node_modules/.bun/svelte@5.57.1/node_modules/svelte/src/internal/disclose-version.js
2
2
  if (typeof window !== "undefined") {
3
3
  var _window$__svelte, _window;
4
4
  ((_window$__svelte = (_window = window).__svelte ?? (_window.__svelte = {})).v ?? (_window$__svelte.v = /* @__PURE__ */ new Set())).add("5");
5
5
  }
6
6
  //#endregion
7
- //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/constants.js
7
+ //#region ../../../node_modules/.bun/svelte@5.57.1/node_modules/svelte/src/constants.js
8
8
  var HYDRATION_ERROR = {};
9
9
  var UNINITIALIZED = Symbol("uninitialized");
10
10
  var NAMESPACE_SVG = "http://www.w3.org/2000/svg";
11
11
  var NAMESPACE_MATHML = "http://www.w3.org/1998/Math/MathML";
12
12
  //#endregion
13
- //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/shared/utils.js
13
+ //#region ../../../node_modules/.bun/svelte@5.57.1/node_modules/svelte/src/internal/shared/utils.js
14
14
  var is_array = Array.isArray;
15
15
  var index_of = Array.prototype.indexOf;
16
16
  var includes = Array.prototype.includes;
@@ -121,13 +121,6 @@ var EFFECT_TRANSPARENT = 65536;
121
121
  var EFFECT_PRESERVED = 1 << 19;
122
122
  var USER_EFFECT = 1 << 20;
123
123
  var EFFECT_OFFSCREEN = 1 << 25;
124
- /**
125
- * Tells that we marked this derived and its reactions as visited during the "mark as (maybe) dirty"-phase.
126
- * Will be lifted during execution of the derived and during checking its dirty state (both are necessary
127
- * because a derived might be checked but not executed). This is a pure performance optimization flag and
128
- * should not be used for any other purpose!
129
- */
130
- var WAS_MARKED = 65536;
131
124
  var REACTION_IS_UPDATING = 1 << 21;
132
125
  var ASYNC = 1 << 22;
133
126
  var ERROR_VALUE = 1 << 23;
@@ -170,7 +163,7 @@ function svelte_boundary_reset_noop() {
170
163
  console.warn(`https://svelte.dev/e/svelte_boundary_reset_noop`);
171
164
  }
172
165
  //#endregion
173
- //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/dom/hydration.js
166
+ //#region ../../../node_modules/.bun/svelte@5.57.1/node_modules/svelte/src/internal/client/dom/hydration.js
174
167
  /** @import { TemplateNode } from '#client' */
175
168
  /**
176
169
  * Use this variable to guard everything related to hydration code so it can be treeshaken out
@@ -249,7 +242,7 @@ function read_hydration_instruction(node) {
249
242
  return node.data;
250
243
  }
251
244
  //#endregion
252
- //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/reactivity/equality.js
245
+ //#region ../../../node_modules/.bun/svelte@5.57.1/node_modules/svelte/src/internal/client/reactivity/equality.js
253
246
  /** @import { Equals } from '#client' */
254
247
  /** @type {Equals} */
255
248
  function equals(value) {
@@ -276,7 +269,7 @@ function lifecycle_outside_component(name) {
276
269
  throw new Error(`https://svelte.dev/e/lifecycle_outside_component`);
277
270
  }
278
271
  //#endregion
279
- //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/errors.js
272
+ //#region ../../../node_modules/.bun/svelte@5.57.1/node_modules/svelte/src/internal/client/errors.js
280
273
  /**
281
274
  * Cannot create a `$derived(...)` with an `await` expression outside of an effect tree
282
275
  * @returns {never}
@@ -368,13 +361,13 @@ function svelte_boundary_reset_onerror() {
368
361
  throw new Error(`https://svelte.dev/e/svelte_boundary_reset_onerror`);
369
362
  }
370
363
  //#endregion
371
- //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/flags/index.js
364
+ //#region ../../../node_modules/.bun/svelte@5.57.1/node_modules/svelte/src/internal/flags/index.js
372
365
  /** True if experimental.async=true */
373
366
  var async_mode_flag = false;
374
367
  /** True if we're not certain that we only have Svelte 5 code in the compilation */
375
368
  var legacy_mode_flag = false;
376
369
  //#endregion
377
- //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/context.js
370
+ //#region ../../../node_modules/.bun/svelte@5.57.1/node_modules/svelte/src/internal/client/context.js
378
371
  /** @import { ComponentContext, DevStackEntry, Effect } from '#client' */
379
372
  /** @type {ComponentContext | null} */
380
373
  var component_context = null;
@@ -434,7 +427,7 @@ function is_runes() {
434
427
  return !legacy_mode_flag || component_context !== null && component_context.l === null;
435
428
  }
436
429
  //#endregion
437
- //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/dom/task.js
430
+ //#region ../../../node_modules/.bun/svelte@5.57.1/node_modules/svelte/src/internal/client/dom/task.js
438
431
  /** @type {Array<() => void>} */
439
432
  var micro_tasks = [];
440
433
  function run_micro_tasks() {
@@ -461,7 +454,7 @@ function flush_tasks() {
461
454
  while (micro_tasks.length > 0) run_micro_tasks();
462
455
  }
463
456
  //#endregion
464
- //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/reactivity/status.js
457
+ //#region ../../../node_modules/.bun/svelte@5.57.1/node_modules/svelte/src/internal/client/reactivity/status.js
465
458
  /** @import { Derived, Signal } from '#client' */
466
459
  var STATUS_MASK = ~(DIRTY | MAYBE_DIRTY | CLEAN);
467
460
  /**
@@ -480,22 +473,8 @@ function update_derived_status(derived) {
480
473
  else set_signal_status(derived, MAYBE_DIRTY);
481
474
  }
482
475
  //#endregion
483
- //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/reactivity/utils.js
484
- /** @import { Derived, Effect, Value } from '#client' */
485
- /**
486
- * @param {Value[] | null} deps
487
- */
488
- function clear_marked(deps) {
489
- if (deps === null) return;
490
- for (const dep of deps) {
491
- if ((dep.f & 2) === 0 || (dep.f & 65536) === 0) continue;
492
- dep.f ^= WAS_MARKED;
493
- clear_marked(
494
- /** @type {Derived} */
495
- dep.deps
496
- );
497
- }
498
- }
476
+ //#region ../../../node_modules/.bun/svelte@5.57.1/node_modules/svelte/src/internal/client/reactivity/utils.js
477
+ /** @import { Effect } from '#client' */
499
478
  /**
500
479
  * @param {Effect} effect
501
480
  * @param {Set<Effect>} dirty_effects
@@ -504,41 +483,10 @@ function clear_marked(deps) {
504
483
  function defer_effect(effect, dirty_effects, maybe_dirty_effects) {
505
484
  if ((effect.f & 2048) !== 0) dirty_effects.add(effect);
506
485
  else if ((effect.f & 4096) !== 0) maybe_dirty_effects.add(effect);
507
- clear_marked(effect.deps);
508
486
  set_signal_status(effect, CLEAN);
509
487
  }
510
488
  //#endregion
511
- //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/reactivity/store.js
512
- /**
513
- * We set this to `true` when updating a store so that we correctly
514
- * schedule effects if the update takes place inside a `$:` effect
515
- */
516
- var legacy_is_updating_store = false;
517
- /**
518
- * Whether or not the prop currently being read is a store binding, as in
519
- * `<Child bind:x={$y} />`. If it is, we treat the prop as mutable even in
520
- * runes mode, and skip `binding_property_non_reactive` validation
521
- */
522
- var is_store_binding = false;
523
- /**
524
- * Returns a tuple that indicates whether `fn()` reads a prop that is a store binding.
525
- * Used to prevent `binding_property_non_reactive` validation false positives and
526
- * ensure that these props are treated as mutable even in runes mode
527
- * @template T
528
- * @param {() => T} fn
529
- * @returns {[T, boolean]}
530
- */
531
- function capture_store_binding(fn) {
532
- var previous_is_store_binding = is_store_binding;
533
- try {
534
- is_store_binding = false;
535
- return [fn(), is_store_binding];
536
- } finally {
537
- is_store_binding = previous_is_store_binding;
538
- }
539
- }
540
- //#endregion
541
- //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/dom/elements/misc.js
489
+ //#region ../../../node_modules/.bun/svelte@5.57.1/node_modules/svelte/src/internal/client/dom/elements/misc.js
542
490
  var listening_to_form_reset = false;
543
491
  function add_form_reset_listener() {
544
492
  if (!listening_to_form_reset) {
@@ -552,7 +500,7 @@ function add_form_reset_listener() {
552
500
  }
553
501
  }
554
502
  //#endregion
555
- //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/dom/elements/bindings/shared.js
503
+ //#region ../../../node_modules/.bun/svelte@5.57.1/node_modules/svelte/src/internal/client/dom/elements/bindings/shared.js
556
504
  /**
557
505
  * @template T
558
506
  * @param {() => T} fn
@@ -570,7 +518,7 @@ function without_reactive_context(fn) {
570
518
  }
571
519
  }
572
520
  //#endregion
573
- //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/reactivity/async.js
521
+ //#region ../../../node_modules/.bun/svelte@5.57.1/node_modules/svelte/src/internal/client/reactivity/async.js
574
522
  /** @import { Blocker, Effect, Source, Value } from '#client' */
575
523
  /**
576
524
  * @param {Blocker[]} blockers
@@ -803,7 +751,6 @@ function execute_derived(derived) {
803
751
  }
804
752
  set_active_effect(parent);
805
753
  try {
806
- derived.f &= ~WAS_MARKED;
807
754
  destroy_derived_effects(derived);
808
755
  value = update_reaction(derived);
809
756
  } finally {
@@ -890,7 +837,7 @@ function _classPrivateFieldGet2(s, a) {
890
837
  return s.get(_assertClassBrand(s, a));
891
838
  }
892
839
  //#endregion
893
- //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/reactivity/batch.js
840
+ //#region ../../../node_modules/.bun/svelte@5.57.1/node_modules/svelte/src/internal/client/reactivity/batch.js
894
841
  /** @import { Fork } from 'svelte' */
895
842
  /** @import { Derived, Effect, Reaction, Source, Value } from '#client' */
896
843
  var _Batch;
@@ -941,7 +888,7 @@ var _discard_callbacks = /* @__PURE__ */ new WeakMap();
941
888
  var _pending = /* @__PURE__ */ new WeakMap();
942
889
  var _blocking_pending = /* @__PURE__ */ new WeakMap();
943
890
  var _deferred = /* @__PURE__ */ new WeakMap();
944
- var _roots = /* @__PURE__ */ new WeakMap();
891
+ var _scheduled = /* @__PURE__ */ new WeakMap();
945
892
  var _new_effects = /* @__PURE__ */ new WeakMap();
946
893
  var _dirty_effects$1 = /* @__PURE__ */ new WeakMap();
947
894
  var _maybe_dirty_effects$1 = /* @__PURE__ */ new WeakMap();
@@ -989,7 +936,7 @@ var Batch = class Batch {
989
936
  _classPrivateFieldInitSpec(this, _pending, 0);
990
937
  _classPrivateFieldInitSpec(this, _blocking_pending, /* @__PURE__ */ new Map());
991
938
  _classPrivateFieldInitSpec(this, _deferred, null);
992
- _classPrivateFieldInitSpec(this, _roots, []);
939
+ _classPrivateFieldInitSpec(this, _scheduled, []);
993
940
  _classPrivateFieldInitSpec(this, _new_effects, []);
994
941
  _classPrivateFieldInitSpec(this, _dirty_effects$1, /* @__PURE__ */ new Set());
995
942
  _classPrivateFieldInitSpec(this, _maybe_dirty_effects$1, /* @__PURE__ */ new Set());
@@ -1178,20 +1125,7 @@ var Batch = class Batch {
1178
1125
  effect.b.defer_effect(effect);
1179
1126
  return;
1180
1127
  }
1181
- var e = effect;
1182
- while (e.parent !== null) {
1183
- e = e.parent;
1184
- var flags = e.f;
1185
- if (collected_effects !== null && e === active_effect) {
1186
- if (async_mode_flag) return;
1187
- if ((active_reaction === null || (active_reaction.f & 2) === 0) && !legacy_is_updating_store) return;
1188
- }
1189
- if ((flags & 96) !== 0) {
1190
- if ((flags & 1024) === 0) return;
1191
- e.f ^= CLEAN;
1192
- }
1193
- }
1194
- _classPrivateFieldGet2(_roots, this).push(e);
1128
+ _classPrivateFieldGet2(_scheduled, this).push(effect);
1195
1129
  }
1196
1130
  };
1197
1131
  _Batch = Batch;
@@ -1211,12 +1145,40 @@ function _is_deferred() {
1211
1145
  }
1212
1146
  return false;
1213
1147
  }
1148
+ /**
1149
+ * Convert the effects that were scheduled in this batch into the root effects
1150
+ * that need to be traversed, marking the path to each effect (by clearing the
1151
+ * `CLEAN` flag on ancestor branches) so that the traversal can find them.
1152
+ * This happens right before traversal rather than at scheduling time, so that
1153
+ * the markers left on the (shared) effect tree are created and consumed within
1154
+ * a single traversal — scheduling into other batches can never observe them
1155
+ * @returns {Effect[]}
1156
+ */
1157
+ function _resolve$1() {
1158
+ /** @type {Effect[]} */
1159
+ var roots = [];
1160
+ for (const effect of _classPrivateFieldGet2(_scheduled, this)) {
1161
+ if ((effect.f & 16384) !== 0 || (effect.f & 6144) === 0) continue;
1162
+ var e = effect;
1163
+ var covered = false;
1164
+ while (e.parent !== null) {
1165
+ e = e.parent;
1166
+ var flags = e.f;
1167
+ if ((flags & 96) !== 0) {
1168
+ if ((flags & 1024) === 0) {
1169
+ covered = true;
1170
+ break;
1171
+ }
1172
+ e.f ^= CLEAN;
1173
+ }
1174
+ }
1175
+ if (!covered) roots.push(e);
1176
+ }
1177
+ _classPrivateFieldSet2(_scheduled, this, []);
1178
+ return roots;
1179
+ }
1214
1180
  function _process() {
1215
1181
  _classPrivateFieldSet2(_started, this, true);
1216
- if (flush_count++ > 1e3) {
1217
- _assertClassBrand(_Batch_brand, this, _unlink).call(this);
1218
- infinite_loop_guard();
1219
- }
1220
1182
  for (const e of _classPrivateFieldGet2(_dirty_effects$1, this)) {
1221
1183
  _classPrivateFieldGet2(_maybe_dirty_effects$1, this).delete(e);
1222
1184
  set_signal_status(e, DIRTY);
@@ -1226,8 +1188,6 @@ function _process() {
1226
1188
  set_signal_status(e, MAYBE_DIRTY);
1227
1189
  this.schedule(e);
1228
1190
  }
1229
- const roots = _classPrivateFieldGet2(_roots, this);
1230
- _classPrivateFieldSet2(_roots, this, []);
1231
1191
  this.apply();
1232
1192
  /** @type {Effect[]} */
1233
1193
  var effects = collected_effects = [];
@@ -1238,12 +1198,18 @@ function _process() {
1238
1198
  * @deprecated when we get rid of legacy mode and stores, we can get rid of this
1239
1199
  */
1240
1200
  var updates = legacy_updates = [];
1241
- for (const root of roots) try {
1242
- _assertClassBrand(_Batch_brand, this, _traverse).call(this, root, effects, render_effects);
1243
- } catch (e) {
1244
- reset_all(root);
1245
- if (!_assertClassBrand(_Batch_brand, this, _is_deferred).call(this)) this.discard();
1246
- throw e;
1201
+ while (_classPrivateFieldGet2(_scheduled, this).length > 0) {
1202
+ if (flush_count++ > 1e3) {
1203
+ _assertClassBrand(_Batch_brand, this, _unlink).call(this);
1204
+ infinite_loop_guard();
1205
+ }
1206
+ for (const root of _assertClassBrand(_Batch_brand, this, _resolve$1).call(this)) try {
1207
+ _assertClassBrand(_Batch_brand, this, _traverse).call(this, root, effects, render_effects);
1208
+ } catch (e) {
1209
+ reset_all(root);
1210
+ if (!_assertClassBrand(_Batch_brand, this, _is_deferred).call(this)) this.discard();
1211
+ throw e;
1212
+ }
1247
1213
  }
1248
1214
  current_batch = null;
1249
1215
  if (updates.length > 0) {
@@ -1277,16 +1243,16 @@ function _process() {
1277
1243
  previous_batch = null;
1278
1244
  _classPrivateFieldGet2(_deferred, this)?.resolve();
1279
1245
  var next_batch = current_batch;
1280
- if (_classPrivateFieldGet2(_pending, this) === 0 && (_classPrivateFieldGet2(_roots, this).length === 0 || next_batch !== null)) {
1246
+ if (_classPrivateFieldGet2(_pending, this) === 0 && (_classPrivateFieldGet2(_scheduled, this).length === 0 || next_batch !== null)) {
1281
1247
  _assertClassBrand(_Batch_brand, this, _unlink).call(this);
1282
1248
  if (async_mode_flag) {
1283
1249
  _assertClassBrand(_Batch_brand, this, _commit$1).call(this);
1284
1250
  current_batch = next_batch;
1285
1251
  }
1286
1252
  }
1287
- if (_classPrivateFieldGet2(_roots, this).length > 0) if (next_batch !== null) {
1288
- const batch = next_batch;
1289
- _classPrivateFieldGet2(_roots, batch).push(..._classPrivateFieldGet2(_roots, this).filter((r) => !_classPrivateFieldGet2(_roots, batch).includes(r)));
1253
+ if (_classPrivateFieldGet2(_scheduled, this).length > 0) if (next_batch !== null) {
1254
+ for (const e of _classPrivateFieldGet2(_scheduled, this)) _classPrivateFieldGet2(_scheduled, next_batch).push(e);
1255
+ _classPrivateFieldSet2(_scheduled, this, []);
1290
1256
  } else next_batch = this;
1291
1257
  if (next_batch !== null) {
1292
1258
  old_values.clear();
@@ -1436,10 +1402,9 @@ function _commit$1() {
1436
1402
  batch.schedule(effect);
1437
1403
  } else _classPrivateFieldGet2(_dirty_effects$1, batch).add(effect);
1438
1404
  }
1439
- if (_classPrivateFieldGet2(_roots, batch).length > 0 && !_classPrivateFieldGet2(_decrement_queued, batch)) {
1405
+ if (_classPrivateFieldGet2(_scheduled, batch).length > 0 && !_classPrivateFieldGet2(_decrement_queued, batch)) {
1440
1406
  batch.apply();
1441
- for (var root of _classPrivateFieldGet2(_roots, batch)) _assertClassBrand(_Batch_brand, batch, _traverse).call(batch, root, [], []);
1442
- _classPrivateFieldSet2(_roots, batch, []);
1407
+ for (var root of _assertClassBrand(_Batch_brand, batch, _resolve$1).call(batch)) _assertClassBrand(_Batch_brand, batch, _traverse).call(batch, root, [], []);
1443
1408
  }
1444
1409
  batch.deactivate();
1445
1410
  }
@@ -1606,7 +1571,7 @@ function reset_all(effect) {
1606
1571
  }
1607
1572
  }
1608
1573
  //#endregion
1609
- //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/reactivity/sources.js
1574
+ //#region ../../../node_modules/.bun/svelte@5.57.1/node_modules/svelte/src/internal/client/reactivity/sources.js
1610
1575
  /** @import { Derived, Effect, Source, Value } from '#client' */
1611
1576
  /** @type {Set<Effect>} */
1612
1577
  var eager_effects = /* @__PURE__ */ new Set();
@@ -1668,6 +1633,16 @@ function set(source, value, should_proxy = false) {
1668
1633
  return internal_set(source, should_proxy ? proxy(value) : value, legacy_updates);
1669
1634
  }
1670
1635
  /**
1636
+ * A set of signals we have already seen while traversing in mark_reactions.
1637
+ * Not always set to balance the common case of sources only having a couple
1638
+ * of (transitive) dependencies (where always creating a Set would be bad for perf)
1639
+ * with the edge case of extremely deep or wide dependency arrays with cycles.
1640
+ * @type {Set<any> | null}
1641
+ */
1642
+ var seen = null;
1643
+ /** Number of transitive dependencies, see {@link seen} for more info */
1644
+ var count_deps = 0;
1645
+ /**
1671
1646
  * @template V
1672
1647
  * @param {Source<V>} source
1673
1648
  * @param {V} value
@@ -1686,7 +1661,10 @@ function internal_set(source, value, updated_during_traversal = null) {
1686
1661
  if (batch_values === null) update_derived_status(derived);
1687
1662
  }
1688
1663
  source.wv = increment_write_version();
1664
+ seen = null;
1665
+ count_deps = 0;
1689
1666
  mark_reactions(source, DIRTY, updated_during_traversal);
1667
+ seen = null;
1690
1668
  if (is_runes() && active_effect !== null && (active_effect.f & 1024) !== 0 && (active_effect.f & 96) === 0) if (untracked_writes === null) set_untracked_writes([source]);
1691
1669
  else untracked_writes.push(source);
1692
1670
  if (!batch.is_fork && eager_effects.size > 0 && !eager_effects_deferred) flush_eager_effects();
@@ -1725,6 +1703,12 @@ function mark_reactions(signal, status, updated_during_traversal) {
1725
1703
  if (reactions === null) return;
1726
1704
  var runes = is_runes();
1727
1705
  var length = reactions.length;
1706
+ count_deps += length;
1707
+ if (count_deps > 1e5 && seen === null) seen = /* @__PURE__ */ new Set();
1708
+ if (seen !== null) {
1709
+ if (seen.has(signal)) return;
1710
+ seen.add(signal);
1711
+ }
1728
1712
  for (var i = 0; i < length; i++) {
1729
1713
  var reaction = reactions[i];
1730
1714
  var flags = reaction.f;
@@ -1735,10 +1719,7 @@ function mark_reactions(signal, status, updated_during_traversal) {
1735
1719
  else if ((flags & 2) !== 0) {
1736
1720
  var derived = reaction;
1737
1721
  batch_values?.delete(derived);
1738
- if ((flags & 65536) === 0) {
1739
- if (flags & 512 && (active_effect === null || (active_effect.f & 2097152) === 0)) reaction.f |= WAS_MARKED;
1740
- mark_reactions(derived, MAYBE_DIRTY, updated_during_traversal);
1741
- }
1722
+ mark_reactions(derived, MAYBE_DIRTY, updated_during_traversal);
1742
1723
  } else if (not_dirty) {
1743
1724
  var effect = reaction;
1744
1725
  if ((flags & 16) !== 0 && eager_block_effects !== null) eager_block_effects.add(effect);
@@ -1826,14 +1807,14 @@ function proxy(value) {
1826
1807
  return Reflect.get(target, prop, receiver);
1827
1808
  },
1828
1809
  getOwnPropertyDescriptor(target, prop) {
1810
+ this.has?.(target, prop);
1829
1811
  var descriptor = Reflect.getOwnPropertyDescriptor(target, prop);
1830
- if (descriptor && "value" in descriptor) {
1831
- var s = sources.get(prop);
1832
- if (s) descriptor.value = get(s);
1833
- } else if (descriptor === void 0) {
1834
- var source = sources.get(prop);
1835
- var value = source?.v;
1836
- if (source !== void 0 && value !== UNINITIALIZED) return {
1812
+ var s = sources.get(prop);
1813
+ if (s !== void 0) {
1814
+ var value = get(s);
1815
+ if (value === UNINITIALIZED) return;
1816
+ if (descriptor && "value" in descriptor) descriptor.value = value;
1817
+ else return {
1837
1818
  enumerable: true,
1838
1819
  configurable: true,
1839
1820
  value,
@@ -1906,7 +1887,7 @@ function proxy(value) {
1906
1887
  });
1907
1888
  }
1908
1889
  //#endregion
1909
- //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/dom/operations.js
1890
+ //#region ../../../node_modules/.bun/svelte@5.57.1/node_modules/svelte/src/internal/client/dom/operations.js
1910
1891
  /** @import { Effect, TemplateNode } from '#client' */
1911
1892
  /** @type {Window} */
1912
1893
  var $window;
@@ -2131,7 +2112,7 @@ function invoke_error_boundary(error, effect) {
2131
2112
  throw error;
2132
2113
  }
2133
2114
  //#endregion
2134
- //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/reactivity/effects.js
2115
+ //#region ../../../node_modules/.bun/svelte@5.57.1/node_modules/svelte/src/internal/client/reactivity/effects.js
2135
2116
  /** @import { Blocker, ComponentContext, ComponentContextLegacy, Derived, Effect, TemplateNode, TransitionManager } from '#client' */
2136
2117
  /**
2137
2118
  * @param {'$effect' | '$effect.pre' | '$inspect'} rune
@@ -2522,14 +2503,14 @@ function move_effect(effect, fragment) {
2522
2503
  }
2523
2504
  }
2524
2505
  //#endregion
2525
- //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/legacy.js
2506
+ //#region ../../../node_modules/.bun/svelte@5.57.1/node_modules/svelte/src/internal/client/legacy.js
2526
2507
  /**
2527
2508
  * @type {Set<Value> | null}
2528
2509
  * @deprecated
2529
2510
  */
2530
2511
  var captured_signals = null;
2531
2512
  //#endregion
2532
- //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/runtime.js
2513
+ //#region ../../../node_modules/.bun/svelte@5.57.1/node_modules/svelte/src/internal/client/runtime.js
2533
2514
  /** @import { Derived, Effect, Reaction, Source, Value } from '#client' */
2534
2515
  /**
2535
2516
  * True if updating in an effect context that is reactive (i.e. not branch/root effects)
@@ -2561,7 +2542,7 @@ function set_active_effect(effect) {
2561
2542
  var current_sources = null;
2562
2543
  /** @param {Value} value */
2563
2544
  function push_reaction_value(value) {
2564
- if (active_reaction !== null && (!async_mode_flag || (active_reaction.f & 2) !== 0)) (current_sources ?? (current_sources = /* @__PURE__ */ new Set())).add(value);
2545
+ if (active_reaction !== null && (!async_mode_flag && (active_reaction.f & 2097152) !== 0 || (active_reaction.f & 2) !== 0)) (current_sources ?? (current_sources = /* @__PURE__ */ new Set())).add(value);
2565
2546
  }
2566
2547
  /**
2567
2548
  * The dependencies of the reaction that is currently being executed. In many cases,
@@ -2605,7 +2586,6 @@ function increment_write_version() {
2605
2586
  function is_dirty(reaction) {
2606
2587
  var flags = reaction.f;
2607
2588
  if ((flags & 2048) !== 0) return true;
2608
- if (flags & 2) reaction.f &= ~WAS_MARKED;
2609
2589
  if ((flags & 4096) !== 0) {
2610
2590
  var dependencies = reaction.deps;
2611
2591
  var length = dependencies.length;
@@ -2737,10 +2717,7 @@ function remove_reaction(signal, dependency) {
2737
2717
  }
2738
2718
  if (reactions === null && (dependency.f & 2) !== 0 && (new_deps === null || !includes.call(new_deps, dependency))) {
2739
2719
  var derived = dependency;
2740
- if ((derived.f & 512) !== 0) {
2741
- derived.f ^= 512;
2742
- derived.f &= ~WAS_MARKED;
2743
- }
2720
+ if ((derived.f & 512) !== 0) derived.f ^= 512;
2744
2721
  if (derived.v !== UNINITIALIZED) update_derived_status(derived);
2745
2722
  if (derived.ac !== null) without_reactive_context(() => {
2746
2723
  /** @type {AbortController} */ derived.ac.abort(STALE_REACTION);
@@ -2889,7 +2866,7 @@ function untrack(fn) {
2889
2866
  }
2890
2867
  }
2891
2868
  //#endregion
2892
- //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/dom/elements/events.js
2869
+ //#region ../../../node_modules/.bun/svelte@5.57.1/node_modules/svelte/src/internal/client/dom/elements/events.js
2893
2870
  /**
2894
2871
  * Used on elements, as a map of event type -> event handler,
2895
2872
  * and on events themselves to track which element handled an event
@@ -2997,7 +2974,7 @@ function handle_event_propagation(event) {
2997
2974
  }
2998
2975
  }
2999
2976
  //#endregion
3000
- //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/dom/reconciler.js
2977
+ //#region ../../../node_modules/.bun/svelte@5.57.1/node_modules/svelte/src/internal/client/dom/reconciler.js
3001
2978
  var policy = globalThis?.window?.trustedTypes && /* @__PURE__ */ globalThis.window.trustedTypes.createPolicy("svelte-trusted-html", {
3002
2979
  /** @param {string} html */
3003
2980
  createHTML: (html) => {
@@ -3016,7 +2993,7 @@ function create_fragment_from_html(html) {
3016
2993
  return elem.content;
3017
2994
  }
3018
2995
  //#endregion
3019
- //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/dom/template.js
2996
+ //#region ../../../node_modules/.bun/svelte@5.57.1/node_modules/svelte/src/internal/client/dom/template.js
3020
2997
  /** @import { Effect, EffectNodes, TemplateNode } from '#client' */
3021
2998
  /** @import { TemplateStructure } from './types' */
3022
2999
  /**
@@ -3115,7 +3092,7 @@ function is_passive_event(name) {
3115
3092
  return PASSIVE_EVENTS.includes(name);
3116
3093
  }
3117
3094
  //#endregion
3118
- //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/reactivity/create-subscriber.js
3095
+ //#region ../../../node_modules/.bun/svelte@5.57.1/node_modules/svelte/src/reactivity/create-subscriber.js
3119
3096
  /**
3120
3097
  * Returns a `subscribe` function that integrates external event-based systems with Svelte's reactivity.
3121
3098
  * It's particularly useful for integrating with web APIs like `MediaQuery`, `IntersectionObserver`, or `WebSocket`.
@@ -3188,7 +3165,7 @@ function createSubscriber(start) {
3188
3165
  };
3189
3166
  }
3190
3167
  //#endregion
3191
- //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/dom/blocks/boundary.js
3168
+ //#region ../../../node_modules/.bun/svelte@5.57.1/node_modules/svelte/src/internal/client/dom/blocks/boundary.js
3192
3169
  /** @import { Effect, Source, TemplateNode, } from '#client' */
3193
3170
  /**
3194
3171
  * @typedef {{
@@ -3758,7 +3735,7 @@ function unmount(component, options) {
3758
3735
  return Promise.resolve();
3759
3736
  }
3760
3737
  //#endregion
3761
- //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/dom/blocks/branches.js
3738
+ //#region ../../../node_modules/.bun/svelte@5.57.1/node_modules/svelte/src/internal/client/dom/blocks/branches.js
3762
3739
  /** @import { Effect, TemplateNode } from '#client' */
3763
3740
  var _batches = /* @__PURE__ */ new WeakMap();
3764
3741
  var _onscreen = /* @__PURE__ */ new WeakMap();
@@ -3881,7 +3858,7 @@ var BranchManager = class {
3881
3858
  }
3882
3859
  };
3883
3860
  //#endregion
3884
- //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/dom/blocks/snippet.js
3861
+ //#region ../../../node_modules/.bun/svelte@5.57.1/node_modules/svelte/src/internal/client/dom/blocks/snippet.js
3885
3862
  /** @import { Snippet } from 'svelte' */
3886
3863
  /** @import { TemplateNode } from '#client' */
3887
3864
  /** @import { Getters } from '#shared' */
@@ -3947,7 +3924,7 @@ function init_update_callbacks(context) {
3947
3924
  });
3948
3925
  }
3949
3926
  //#endregion
3950
- //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/dom/blocks/if.js
3927
+ //#region ../../../node_modules/.bun/svelte@5.57.1/node_modules/svelte/src/internal/client/dom/blocks/if.js
3951
3928
  /** @import { TemplateNode } from '#client' */
3952
3929
  /**
3953
3930
  * @param {TemplateNode} node
@@ -3993,7 +3970,7 @@ function if_block(node, fn, elseif = false) {
3993
3970
  }, flags);
3994
3971
  }
3995
3972
  //#endregion
3996
- //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/dom/blocks/each.js
3973
+ //#region ../../../node_modules/.bun/svelte@5.57.1/node_modules/svelte/src/internal/client/dom/blocks/each.js
3997
3974
  /** @import { EachItem, EachOutroGroup, EachState, Effect, EffectNodes, MaybeSource, Source, TemplateNode, TransitionManager, Value } from '#client' */
3998
3975
  /** @import { Batch } from '../../reactivity/batch.js'; */
3999
3976
  /**
@@ -4458,7 +4435,7 @@ function html(node, get_value, is_controlled = false, svg = false, mathml = fals
4458
4435
  });
4459
4436
  }
4460
4437
  //#endregion
4461
- //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/dom/css.js
4438
+ //#region ../../../node_modules/.bun/svelte@5.57.1/node_modules/svelte/src/internal/client/dom/css.js
4462
4439
  /**
4463
4440
  * @param {Node} anchor
4464
4441
  * @param {{ hash: string, code: string }} css
@@ -4477,7 +4454,7 @@ function append_styles(anchor, css) {
4477
4454
  });
4478
4455
  }
4479
4456
  //#endregion
4480
- //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/shared/attributes.js
4457
+ //#region ../../../node_modules/.bun/svelte@5.57.1/node_modules/svelte/src/internal/shared/attributes.js
4481
4458
  var whitespace$1 = [..." \n\r\f\xA0\v"];
4482
4459
  /**
4483
4460
  * @param {any} value
@@ -4503,7 +4480,7 @@ function to_class(value, hash, directives) {
4503
4480
  return classname === "" ? null : classname;
4504
4481
  }
4505
4482
  //#endregion
4506
- //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/dom/elements/class.js
4483
+ //#region ../../../node_modules/.bun/svelte@5.57.1/node_modules/svelte/src/internal/client/dom/elements/class.js
4507
4484
  /**
4508
4485
  * @param {Element} dom
4509
4486
  * @param {boolean | number} is_html
@@ -4528,7 +4505,7 @@ function set_class(dom, is_html, value, hash, prev_classes, next_classes) {
4528
4505
  return next_classes;
4529
4506
  }
4530
4507
  //#endregion
4531
- //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/dom/elements/attributes.js
4508
+ //#region ../../../node_modules/.bun/svelte@5.57.1/node_modules/svelte/src/internal/client/dom/elements/attributes.js
4532
4509
  /** @import { Blocker, Effect } from '#client' */
4533
4510
  var IS_CUSTOM_ELEMENT = Symbol("is custom element");
4534
4511
  var IS_HTML = Symbol("is html");
@@ -4629,7 +4606,7 @@ function get_setters(element) {
4629
4606
  return setters;
4630
4607
  }
4631
4608
  //#endregion
4632
- //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/dom/elements/bindings/size.js
4609
+ //#region ../../../node_modules/.bun/svelte@5.57.1/node_modules/svelte/src/internal/client/dom/elements/bindings/size.js
4633
4610
  var _ResizeObserverSingleton;
4634
4611
  var _listeners = /* @__PURE__ */ new WeakMap();
4635
4612
  var _observer = /* @__PURE__ */ new WeakMap();
@@ -4681,7 +4658,7 @@ function _getObserver() {
4681
4658
  }
4682
4659
  _defineProperty(ResizeObserverSingleton, "entries", /* @__PURE__ */ new WeakMap());
4683
4660
  //#endregion
4684
- //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/dom/elements/bindings/this.js
4661
+ //#region ../../../node_modules/.bun/svelte@5.57.1/node_modules/svelte/src/internal/client/dom/elements/bindings/this.js
4685
4662
  /** @import { ComponentContext, Effect } from '#client' */
4686
4663
  /**
4687
4664
  * @param {any} bound_value
@@ -4733,7 +4710,32 @@ function bind_this(element_or_component = mark_as_component(), update, get_value
4733
4710
  return element_or_component;
4734
4711
  }
4735
4712
  //#endregion
4736
- //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/reactivity/props.js
4713
+ //#region ../../../node_modules/.bun/svelte@5.57.1/node_modules/svelte/src/internal/client/reactivity/store.js
4714
+ /**
4715
+ * Whether or not the prop currently being read is a store binding, as in
4716
+ * `<Child bind:x={$y} />`. If it is, we treat the prop as mutable even in
4717
+ * runes mode, and skip `binding_property_non_reactive` validation
4718
+ */
4719
+ var is_store_binding = false;
4720
+ /**
4721
+ * Returns a tuple that indicates whether `fn()` reads a prop that is a store binding.
4722
+ * Used to prevent `binding_property_non_reactive` validation false positives and
4723
+ * ensure that these props are treated as mutable even in runes mode
4724
+ * @template T
4725
+ * @param {() => T} fn
4726
+ * @returns {[T, boolean]}
4727
+ */
4728
+ function capture_store_binding(fn) {
4729
+ var previous_is_store_binding = is_store_binding;
4730
+ try {
4731
+ is_store_binding = false;
4732
+ return [fn(), is_store_binding];
4733
+ } finally {
4734
+ is_store_binding = previous_is_store_binding;
4735
+ }
4736
+ }
4737
+ //#endregion
4738
+ //#region ../../../node_modules/.bun/svelte@5.57.1/node_modules/svelte/src/internal/client/reactivity/props.js
4737
4739
  /** @import { Derived, Effect, Source } from './types.js' */
4738
4740
  /**
4739
4741
  * This function is responsible for synchronizing a possibly bound prop with the inner component state.
@@ -4826,7 +4828,7 @@ function prop(props, key, flags, fallback) {
4826
4828
  });
4827
4829
  }
4828
4830
  //#endregion
4829
- //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/legacy/legacy-client.js
4831
+ //#region ../../../node_modules/.bun/svelte@5.57.1/node_modules/svelte/src/legacy/legacy-client.js
4830
4832
  /** @import { ComponentConstructorOptions, ComponentType, SvelteComponent, Component } from 'svelte' */
4831
4833
  /**
4832
4834
  * Takes the same options as a Svelte 4 component and the component function and returns a Svelte 4 compatible component.
@@ -4945,7 +4947,7 @@ var Svelte4Component = class {
4945
4947
  }
4946
4948
  };
4947
4949
  //#endregion
4948
- //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/dom/elements/custom-element.js
4950
+ //#region ../../../node_modules/.bun/svelte@5.57.1/node_modules/svelte/src/internal/client/dom/elements/custom-element.js
4949
4951
  /**
4950
4952
  * @typedef {Object} CustomElementPropDefinition
4951
4953
  * @property {string} [attribute]
@@ -5486,7 +5488,7 @@ OrderedMap.from = function(value) {
5486
5488
  return new OrderedMap(content);
5487
5489
  };
5488
5490
  //#endregion
5489
- //#region ../../../node_modules/.bun/prosemirror-model@1.25.11/node_modules/prosemirror-model/dist/index.js
5491
+ //#region ../../../node_modules/.bun/prosemirror-model@1.25.12/node_modules/prosemirror-model/dist/index.js
5490
5492
  function findDiffStart(a, b, pos) {
5491
5493
  for (let i = 0;; i++) {
5492
5494
  if (i == a.childCount || i == b.childCount) return a.childCount == b.childCount ? null : pos;
@@ -5932,9 +5934,7 @@ var Mark$1 = class Mark$1 {
5932
5934
  if (!json) throw new RangeError("Invalid input for Mark.fromJSON");
5933
5935
  let type = schema.marks[json.type];
5934
5936
  if (!type) throw new RangeError(`There is no mark type ${json.type} in this schema`);
5935
- let mark = type.create(json.attrs);
5936
- type.checkAttrs(mark.attrs);
5937
- return mark;
5937
+ return type.create(json.attrs);
5938
5938
  }
5939
5939
  /**
5940
5940
  Test whether two sets of marks are identical.
@@ -6831,11 +6831,11 @@ var Node$2 = class Node$2 {
6831
6831
  */
6832
6832
  check() {
6833
6833
  this.type.checkContent(this.content);
6834
- this.type.checkAttrs(this.attrs);
6834
+ checkAttrs(this.type.attrs, this.attrs, "node", this.type.name);
6835
6835
  let copy = Mark$1.none;
6836
6836
  for (let i = 0; i < this.marks.length; i++) {
6837
6837
  let mark = this.marks[i];
6838
- mark.type.checkAttrs(mark.attrs);
6838
+ checkAttrs(mark.type.attrs, mark.attrs, "mark", mark.type.name);
6839
6839
  copy = mark.addToSet(copy);
6840
6840
  }
6841
6841
  if (!Mark$1.sameSet(copy, this.marks)) throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map((m) => m.type.name)}`);
@@ -6869,9 +6869,7 @@ var Node$2 = class Node$2 {
6869
6869
  return schema.text(json.text, marks);
6870
6870
  }
6871
6871
  let content = Fragment.fromJSON(schema, json.content);
6872
- let node = schema.nodeType(json.type).create(json.attrs, content, marks);
6873
- node.type.checkAttrs(node.attrs);
6874
- return node;
6872
+ return schema.nodeType(json.type).create(json.attrs, content, marks);
6875
6873
  }
6876
6874
  };
6877
6875
  Node$2.prototype.text = void 0;
@@ -6921,6 +6919,10 @@ function wrapMarks(marks, str) {
6921
6919
  for (let i = marks.length - 1; i >= 0; i--) str = marks[i].type.name + "(" + str + ")";
6922
6920
  return str;
6923
6921
  }
6922
+ function checkAttrs(attrs, values, type, name) {
6923
+ for (let attr in values) if (!(attr in attrs)) throw new RangeError(`Unsupported attribute ${attr} for ${type} of type ${name}`);
6924
+ for (let attr in attrs) if (attrs[attr].validate) attrs[attr].validate(values[attr]);
6925
+ }
6924
6926
  /**
6925
6927
  Instances of this class represent a match state of a node type's
6926
6928
  [content expression](https://prosemirror.net/docs/ref/#model.NodeSpec.content), and can be used to
@@ -7329,20 +7331,15 @@ function defaultAttrs(attrs) {
7329
7331
  function computeAttrs(attrs, value) {
7330
7332
  let built = Object.create(null);
7331
7333
  for (let name in attrs) {
7334
+ let attr = attrs[name];
7332
7335
  let given = value && value[name];
7333
- if (given === void 0) {
7334
- let attr = attrs[name];
7335
- if (attr.hasDefault) given = attr.default;
7336
- else throw new RangeError("No value supplied for attribute " + name);
7337
- }
7336
+ if (given === void 0) if (attr.hasDefault) given = attr.default;
7337
+ else throw new RangeError("No value supplied for attribute " + name);
7338
+ else if (attr.validate) attr.validate(given);
7338
7339
  built[name] = given;
7339
7340
  }
7340
7341
  return built;
7341
7342
  }
7342
- function checkAttrs(attrs, values, type, name) {
7343
- for (let attr in values) if (!(attr in attrs)) throw new RangeError(`Unsupported attribute ${attr} for ${type} of type ${name}`);
7344
- for (let attr in attrs) if (attrs[attr].validate) attrs[attr].validate(values[attr]);
7345
- }
7346
7343
  function initAttrs(typeName, attrs) {
7347
7344
  let result = Object.create(null);
7348
7345
  if (attrs) for (let name in attrs) result[name] = new Attribute(typeName, name, attrs[name]);
@@ -7497,11 +7494,9 @@ var NodeType$1 = class NodeType$1 {
7497
7494
  if (!this.validContent(content)) throw new RangeError(`Invalid content for node ${this.name}: ${content.toString().slice(0, 50)}`);
7498
7495
  }
7499
7496
  /**
7500
- @internal
7497
+ @internal no longer useful, but called by old prosemirror-view versions
7501
7498
  */
7502
- checkAttrs(attrs) {
7503
- checkAttrs(this.attrs, attrs, "node", this.name);
7504
- }
7499
+ checkAttrs(attrs) {}
7505
7500
  /**
7506
7501
  Check whether the given mark type is allowed in this node.
7507
7502
  */
@@ -7612,12 +7607,6 @@ var MarkType = class MarkType {
7612
7607
  for (let i = 0; i < set.length; i++) if (set[i].type == this) return set[i];
7613
7608
  }
7614
7609
  /**
7615
- @internal
7616
- */
7617
- checkAttrs(attrs) {
7618
- checkAttrs(this.attrs, attrs, "mark", this.name);
7619
- }
7620
- /**
7621
7610
  Queries whether a given mark type is
7622
7611
  [excluded](https://prosemirror.net/docs/ref/#model.MarkSpec.excludes) by this one.
7623
7612
  */
@@ -8476,7 +8465,7 @@ function renderSpec(doc, structure, xmlNS, blockArraysIn) {
8476
8465
  };
8477
8466
  }
8478
8467
  //#endregion
8479
- //#region ../../../node_modules/.bun/prosemirror-transform@1.12.0/node_modules/prosemirror-transform/dist/index.js
8468
+ //#region ../../../node_modules/.bun/prosemirror-transform@1.12.2/node_modules/prosemirror-transform/dist/index.js
8480
8469
  var lower16 = 65535;
8481
8470
  var factor16 = Math.pow(2, 16);
8482
8471
  function makeRecover(index, offset) {
@@ -8579,8 +8568,11 @@ var StepMap = class StepMap {
8579
8568
  let result = start + diff + (side < 0 ? 0 : newSize);
8580
8569
  if (simple) return result;
8581
8570
  let recover = pos == (assoc < 0 ? start : end) ? null : makeRecover(i / 3, pos - start);
8582
- let del = pos == start ? DEL_AFTER : pos == end ? DEL_BEFORE : DEL_ACROSS;
8583
- if (assoc < 0 ? pos != start : pos != end) del |= DEL_SIDE;
8571
+ let del = 0;
8572
+ if (oldSize) {
8573
+ del |= pos == start ? DEL_AFTER : pos == end ? DEL_BEFORE : DEL_ACROSS;
8574
+ if (assoc < 0 ? pos != start : pos != end) del |= DEL_SIDE;
8575
+ }
8584
8576
  return new MapResult(result, del, recover);
8585
8577
  }
8586
8578
  diff += newSize - oldSize;
@@ -9701,9 +9693,9 @@ var Fitter = class {
9701
9693
  }
9702
9694
  openMore() {
9703
9695
  let { content, openStart, openEnd } = this.unplaced;
9704
- let inner = contentAt(content, openStart);
9705
- if (!inner.childCount || inner.firstChild.isLeaf) return false;
9706
- this.unplaced = new Slice(content, openStart + 1, Math.max(openEnd, inner.size + openStart >= content.size - openEnd ? openStart + 1 : 0));
9696
+ if (maxOpen(content, -1) <= openStart) return false;
9697
+ if (this.unplaced.size > 1 && maxOpen(content, 1) > openEnd) openEnd++;
9698
+ this.unplaced = new Slice(content, openStart + 1, openEnd);
9707
9699
  return true;
9708
9700
  }
9709
9701
  dropNode() {
@@ -9837,6 +9829,13 @@ function invalidMarks(type, fragment, start) {
9837
9829
  function definesContent(type) {
9838
9830
  return type.spec.defining || type.spec.definingForContent;
9839
9831
  }
9832
+ function maxOpen(frag, side) {
9833
+ for (let count = 0;; count++) {
9834
+ let ch = side < 0 ? frag.firstChild : frag.lastChild;
9835
+ if (!ch || ch.isAtom) return count;
9836
+ frag = ch.content;
9837
+ }
9838
+ }
9840
9839
  function replaceRange(tr, from, to, slice) {
9841
9840
  if (!slice.size) return tr.deleteRange(from, to);
9842
9841
  let $from = tr.doc.resolve(from), $to = tr.doc.resolve(to);
@@ -11282,7 +11281,7 @@ var PluginKey = class {
11282
11281
  }
11283
11282
  };
11284
11283
  //#endregion
11285
- //#region ../../../node_modules/.bun/prosemirror-commands@1.7.1/node_modules/prosemirror-commands/dist/index.js
11284
+ //#region ../../../node_modules/.bun/prosemirror-commands@1.7.2/node_modules/prosemirror-commands/dist/index.js
11286
11285
  /**
11287
11286
  Delete the selection, if there is one.
11288
11287
  */
@@ -11604,20 +11603,23 @@ a custom function to determine the type of the newly split off block.
11604
11603
  */
11605
11604
  function splitBlockAs(splitNode) {
11606
11605
  return (state, dispatch) => {
11607
- let { $from, $to } = state.selection;
11608
11606
  if (state.selection instanceof NodeSelection && state.selection.node.isBlock) {
11607
+ let { $from } = state.selection;
11609
11608
  if (!$from.parentOffset || !canSplit(state.doc, $from.pos)) return false;
11610
11609
  if (dispatch) dispatch(state.tr.split($from.pos).scrollIntoView());
11611
11610
  return true;
11612
11611
  }
11613
- if (!$from.depth) return false;
11612
+ if (!state.selection.$from.depth) return false;
11613
+ let tr = state.tr;
11614
+ if (!state.selection.empty && (state.selection instanceof TextSelection || state.selection instanceof AllSelection)) tr.deleteSelection();
11615
+ let { $from } = tr.selection, mapFrom = tr.steps.length;
11614
11616
  let types = [];
11615
11617
  let splitDepth, deflt, atEnd = false, atStart = false;
11616
11618
  for (let d = $from.depth;; d--) if ($from.node(d).isBlock) {
11617
11619
  atEnd = $from.end(d) == $from.pos + ($from.depth - d);
11618
11620
  atStart = $from.start(d) == $from.pos - ($from.depth - d);
11619
11621
  deflt = defaultBlockAt$1($from.node(d - 1).contentMatchAt($from.indexAfter(d - 1)));
11620
- let splitType = splitNode && splitNode($to.parent, atEnd, $from);
11622
+ let splitType = splitNode && splitNode($from.parent, atEnd, $from);
11621
11623
  types.unshift(splitType || (atEnd && deflt ? { type: deflt } : null));
11622
11624
  splitDepth = d;
11623
11625
  break;
@@ -11625,9 +11627,7 @@ function splitBlockAs(splitNode) {
11625
11627
  if (d == 1) return false;
11626
11628
  types.unshift(null);
11627
11629
  }
11628
- let tr = state.tr;
11629
- if (state.selection instanceof TextSelection || state.selection instanceof AllSelection) tr.deleteSelection();
11630
- let splitPos = tr.mapping.map($from.pos);
11630
+ let splitPos = $from.pos;
11631
11631
  let can = canSplit(tr.doc, splitPos, types.length, types);
11632
11632
  if (!can) {
11633
11633
  types[0] = deflt ? { type: deflt } : null;
@@ -11636,8 +11636,9 @@ function splitBlockAs(splitNode) {
11636
11636
  if (!can) return false;
11637
11637
  tr.split(splitPos, types.length, types);
11638
11638
  if (!atEnd && atStart && $from.node(splitDepth).type != deflt) {
11639
- let first = tr.mapping.map($from.before(splitDepth)), $first = tr.doc.resolve(first);
11640
- if (deflt && $from.node(splitDepth - 1).canReplaceWith($first.index(), $first.index() + 1, deflt)) tr.setNodeMarkup(tr.mapping.map($from.before(splitDepth)), deflt);
11639
+ let mapping = tr.mapping.slice(mapFrom);
11640
+ let first = mapping.map($from.before(splitDepth)), $first = tr.doc.resolve(first);
11641
+ if (deflt && $from.node(splitDepth - 1).canReplaceWith($first.index(), $first.index() + 1, deflt)) tr.setNodeMarkup(mapping.map($from.before(splitDepth)), deflt);
11641
11642
  }
11642
11643
  if (dispatch) dispatch(tr.scrollIntoView());
11643
11644
  return true;
@@ -11963,7 +11964,7 @@ function sinkListItem(itemType) {
11963
11964
  };
11964
11965
  }
11965
11966
  //#endregion
11966
- //#region ../../../node_modules/.bun/prosemirror-view@1.42.3/node_modules/prosemirror-view/dist/index.js
11967
+ //#region ../../../node_modules/.bun/prosemirror-view@1.42.6/node_modules/prosemirror-view/dist/index.js
11967
11968
  var domIndex = function(node) {
11968
11969
  for (var index = 0;; index++) {
11969
11970
  node = node.previousSibling;
@@ -11994,12 +11995,12 @@ function scanFor(node, off, targetNode, targetOff, dir) {
11994
11995
  if (node == targetNode && off == targetOff) return true;
11995
11996
  if (off == (dir < 0 ? 0 : nodeSize(node))) {
11996
11997
  let parent = node.parentNode;
11997
- if (!parent || parent.nodeType != 1 || hasBlockDesc(node) || atomElements.test(node.nodeName) || node.contentEditable == "false") return false;
11998
+ if (!parent || !isElt(parent) || hasBlockDesc(node) || atomElements.test(node.nodeName) || node.contentEditable == "false") return false;
11998
11999
  off = domIndex(node) + (dir < 0 ? 0 : 1);
11999
12000
  node = parent;
12000
- } else if (node.nodeType == 1) {
12001
+ } else if (isElt(node)) {
12001
12002
  let child = node.childNodes[off + (dir < 0 ? -1 : 0)];
12002
- if (child.nodeType == 1 && child.contentEditable == "false") if ((_a = child.pmViewDesc) === null || _a === void 0 ? void 0 : _a.ignoreForSelection) off += dir;
12003
+ if (isElt(child) && child.contentEditable == "false") if ((_a = child.pmViewDesc) === null || _a === void 0 ? void 0 : _a.ignoreForSelection) off += dir;
12003
12004
  else return false;
12004
12005
  else {
12005
12006
  node = child;
@@ -12011,10 +12012,19 @@ function scanFor(node, off, targetNode, targetOff, dir) {
12011
12012
  function nodeSize(node) {
12012
12013
  return node.nodeType == 3 ? node.nodeValue.length : node.childNodes.length;
12013
12014
  }
12015
+ function isElt(node) {
12016
+ return node.nodeType == 1;
12017
+ }
12018
+ function isText(node) {
12019
+ return node.nodeType == 3;
12020
+ }
12021
+ function contains(parent, child) {
12022
+ return child ? parent.contains(isElt(child) ? child : child.parentNode) : false;
12023
+ }
12014
12024
  function textNodeBefore$1(node, offset) {
12015
12025
  for (;;) {
12016
- if (node.nodeType == 3 && offset) return node;
12017
- if (node.nodeType == 1 && offset > 0) {
12026
+ if (isText(node) && offset) return node;
12027
+ if (isElt(node) && offset > 0) {
12018
12028
  if (node.contentEditable == "false") return null;
12019
12029
  node = node.childNodes[offset - 1];
12020
12030
  offset = nodeSize(node);
@@ -12026,8 +12036,8 @@ function textNodeBefore$1(node, offset) {
12026
12036
  }
12027
12037
  function textNodeAfter$1(node, offset) {
12028
12038
  for (;;) {
12029
- if (node.nodeType == 3 && offset < node.nodeValue.length) return node;
12030
- if (node.nodeType == 1 && offset < node.childNodes.length) {
12039
+ if (isText(node) && offset < node.nodeValue.length) return node;
12040
+ if (isElt(node) && offset < node.childNodes.length) {
12031
12041
  if (node.contentEditable == "false") return null;
12032
12042
  node = node.childNodes[offset];
12033
12043
  offset = 0;
@@ -12138,13 +12148,12 @@ function scrollRectIntoView(view, rect, startDOM) {
12138
12148
  let doc = view.dom.ownerDocument;
12139
12149
  for (let parent = startDOM || view.dom;;) {
12140
12150
  if (!parent) break;
12141
- if (parent.nodeType != 1) {
12151
+ if (!isElt(parent)) {
12142
12152
  parent = parentNode(parent);
12143
12153
  continue;
12144
12154
  }
12145
- let elt = parent;
12146
- let atTop = elt == doc.body;
12147
- let bounding = atTop ? windowRect(doc) : clientRect(elt);
12155
+ let atTop = parent == doc.body;
12156
+ let bounding = atTop ? windowRect(doc) : clientRect(parent);
12148
12157
  let moveX = 0, moveY = 0;
12149
12158
  if (rect.top < bounding.top + getSide(scrollThreshold, "top")) moveY = -(bounding.top - rect.top + getSide(scrollMargin, "top"));
12150
12159
  else if (rect.bottom > bounding.bottom - getSide(scrollThreshold, "bottom")) moveY = rect.bottom - rect.top > bounding.bottom - bounding.top ? rect.top + getSide(scrollMargin, "top") - bounding.top : rect.bottom - bounding.bottom + getSide(scrollMargin, "bottom");
@@ -12152,10 +12161,10 @@ function scrollRectIntoView(view, rect, startDOM) {
12152
12161
  else if (rect.right > bounding.right - getSide(scrollThreshold, "right")) moveX = rect.right - bounding.right + getSide(scrollMargin, "right");
12153
12162
  if (moveX || moveY) if (atTop) doc.defaultView.scrollBy(moveX, moveY);
12154
12163
  else {
12155
- let startX = elt.scrollLeft, startY = elt.scrollTop;
12156
- if (moveY) elt.scrollTop += moveY;
12157
- if (moveX) elt.scrollLeft += moveX;
12158
- let dX = elt.scrollLeft - startX, dY = elt.scrollTop - startY;
12164
+ let startX = parent.scrollLeft, startY = parent.scrollTop;
12165
+ if (moveY) parent.scrollTop += moveY;
12166
+ if (moveX) parent.scrollLeft += moveX;
12167
+ let dX = parent.scrollLeft - startX, dY = parent.scrollTop - startY;
12159
12168
  rect = {
12160
12169
  left: rect.left - dX,
12161
12170
  top: rect.top - dY,
@@ -12225,13 +12234,14 @@ function focusPreventScroll(dom) {
12225
12234
  }
12226
12235
  }
12227
12236
  function findOffsetInNode(node, coords) {
12228
- let closest, dxClosest = 2e8, coordsClosest, offset = 0;
12237
+ let closest;
12238
+ let dxClosest = 2e8, coordsClosest, offset = 0;
12229
12239
  let rowBot = coords.top, rowTop = coords.top;
12230
12240
  let firstBelow, coordsBelow;
12231
12241
  for (let child = node.firstChild, childIndex = 0; child; child = child.nextSibling, childIndex++) {
12232
12242
  let rects;
12233
- if (child.nodeType == 1) rects = child.getClientRects();
12234
- else if (child.nodeType == 3) rects = textRange(child).getClientRects();
12243
+ if (isElt(child)) rects = child.getClientRects();
12244
+ else if (isText(child)) rects = textRange(child).getClientRects();
12235
12245
  else continue;
12236
12246
  for (let i = 0; i < rects.length; i++) {
12237
12247
  let rect = rects[i];
@@ -12242,11 +12252,11 @@ function findOffsetInNode(node, coords) {
12242
12252
  if (dx < dxClosest) {
12243
12253
  closest = child;
12244
12254
  dxClosest = dx;
12245
- coordsClosest = dx && closest.nodeType == 3 ? {
12255
+ coordsClosest = dx && isText(closest) ? {
12246
12256
  left: rect.right < coords.left ? rect.right : rect.left,
12247
12257
  top: coords.top
12248
12258
  } : coords;
12249
- if (child.nodeType == 1 && dx) offset = childIndex + (coords.left >= (rect.left + rect.right) / 2 ? 1 : 0);
12259
+ if (isElt(child) && dx) offset = childIndex + (coords.left >= (rect.left + rect.right) / 2 ? 1 : 0);
12250
12260
  continue;
12251
12261
  }
12252
12262
  } else if (rect.top > coords.top && !firstBelow && rect.left <= coords.left && rect.right >= coords.left) {
@@ -12264,8 +12274,8 @@ function findOffsetInNode(node, coords) {
12264
12274
  coordsClosest = coordsBelow;
12265
12275
  dxClosest = 0;
12266
12276
  }
12267
- if (closest && closest.nodeType == 3) return findOffsetInText(closest, coordsClosest);
12268
- if (!closest || dxClosest && closest.nodeType == 1) return {
12277
+ if (closest && isText(closest)) return findOffsetInText(closest, coordsClosest);
12278
+ if (!closest || dxClosest) return {
12269
12279
  node,
12270
12280
  offset
12271
12281
  };
@@ -12303,7 +12313,7 @@ function targetKludge(dom, coords) {
12303
12313
  }
12304
12314
  function posFromElement(view, elt, coords) {
12305
12315
  let { node, offset } = findOffsetInNode(elt, coords), bias = -1;
12306
- if (node.nodeType == 1 && !node.firstChild) {
12316
+ if (isElt(node) && !node.firstChild) {
12307
12317
  let rect = node.getBoundingClientRect();
12308
12318
  bias = rect.left != rect.right && coords.left > (rect.left + rect.right) / 2 ? 1 : -1;
12309
12319
  }
@@ -12315,7 +12325,7 @@ function posFromCaret(view, node, offset, coords) {
12315
12325
  if (cur == view.dom) break;
12316
12326
  let desc = view.docView.nearestDesc(cur, true), rect;
12317
12327
  if (!desc) return null;
12318
- if (desc.dom.nodeType == 1 && (desc.node.isBlock && desc.parent || !desc.contentDOM) && ((rect = desc.dom.getBoundingClientRect()).width || rect.height)) {
12328
+ if (isElt(desc.dom) && (desc.node.isBlock && desc.parent || !desc.contentDOM) && ((rect = desc.dom.getBoundingClientRect()).width || rect.height)) {
12319
12329
  if (desc.node.isBlock && desc.parent && !/^T(R|BODY|HEAD|FOOT)$/.test(desc.dom.nodeName)) {
12320
12330
  if (!sawBlock && rect.left > coords.left || rect.top > coords.top) outsideBlock = desc.posBefore;
12321
12331
  else if (!sawBlock && rect.right < coords.left || rect.bottom < coords.top) outsideBlock = desc.posAfter;
@@ -12331,7 +12341,7 @@ function elementFromPoint(element, coords, box) {
12331
12341
  let len = element.childNodes.length;
12332
12342
  if (len && box.top < box.bottom) for (let startI = Math.max(0, Math.min(len - 1, Math.floor(len * (coords.top - box.top) / (box.bottom - box.top)) - 2)), i = startI;;) {
12333
12343
  let child = element.childNodes[i];
12334
- if (child.nodeType == 1) {
12344
+ if (isElt(child)) {
12335
12345
  let rects = child.getClientRects();
12336
12346
  for (let j = 0; j < rects.length; j++) {
12337
12347
  let rect = rects[j];
@@ -12348,7 +12358,7 @@ function posAtCoords(view, coords) {
12348
12358
  if (caret) ({node, offset} = caret);
12349
12359
  let elt = (view.root.elementFromPoint ? view.root : doc).elementFromPoint(coords.left, coords.top);
12350
12360
  let pos;
12351
- if (!elt || !view.dom.contains(elt.nodeType != 1 ? elt.parentNode : elt)) {
12361
+ if (!elt || !view.dom.contains(elt)) {
12352
12362
  let box = view.dom.getBoundingClientRect();
12353
12363
  if (!inRect(coords, box)) return null;
12354
12364
  elt = elementFromPoint(view.dom, coords, box);
@@ -12359,7 +12369,7 @@ function posAtCoords(view, coords) {
12359
12369
  }
12360
12370
  elt = targetKludge(elt, coords);
12361
12371
  if (node) {
12362
- if (gecko && node.nodeType == 1) {
12372
+ if (gecko && isElt(node)) {
12363
12373
  offset = Math.min(offset, node.childNodes.length);
12364
12374
  if (offset < node.childNodes.length) {
12365
12375
  let next = node.childNodes[offset], box;
@@ -12367,9 +12377,9 @@ function posAtCoords(view, coords) {
12367
12377
  }
12368
12378
  }
12369
12379
  let prev;
12370
- if (webkit && offset && node.nodeType == 1 && (prev = node.childNodes[offset - 1]).nodeType == 1 && prev.contentEditable == "false" && prev.getBoundingClientRect().top >= coords.top) offset--;
12371
- if (node == view.dom && offset == node.childNodes.length - 1 && node.lastChild.nodeType == 1 && coords.top > node.lastChild.getBoundingClientRect().bottom) pos = view.state.doc.content.size;
12372
- else if (offset == 0 || node.nodeType != 1 || node.childNodes[offset - 1].nodeName != "BR") pos = posFromCaret(view, node, offset, coords);
12380
+ if (webkit && offset && isElt(node) && isElt(prev = node.childNodes[offset - 1]) && prev.contentEditable == "false" && prev.getBoundingClientRect().top >= coords.top) offset--;
12381
+ if (node == view.dom && offset == node.childNodes.length - 1 && isElt(node.lastChild) && coords.top > node.lastChild.getBoundingClientRect().bottom) pos = view.state.doc.content.size;
12382
+ else if (offset == 0 || !isElt(node) || node.childNodes[offset - 1].nodeName != "BR") pos = posFromCaret(view, node, offset, coords);
12373
12383
  }
12374
12384
  if (pos == null) pos = posFromElement(view, elt, coords);
12375
12385
  let desc = view.docView.nearestDesc(elt, true);
@@ -12393,7 +12403,7 @@ var BIDI = /[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;
12393
12403
  function coordsAtPos(view, pos, side) {
12394
12404
  let { node, offset, atom } = view.docView.domFromPos(pos, side < 0 ? -1 : 1);
12395
12405
  let supportEmptyRange = webkit || gecko;
12396
- if (node.nodeType == 3) if (supportEmptyRange && (BIDI.test(node.nodeValue) || (side < 0 ? !offset : offset == node.nodeValue.length))) {
12406
+ if (isText(node)) if (supportEmptyRange && (BIDI.test(node.nodeValue) || (side < 0 ? !offset : offset == node.nodeValue.length))) {
12397
12407
  let rect = singleRect(textRange(node, offset, offset), side);
12398
12408
  if (gecko && offset && /\s/.test(node.nodeValue[offset - 1]) && offset < node.nodeValue.length) {
12399
12409
  let rectBefore = singleRect(textRange(node, offset - 1, offset - 1), -1);
@@ -12418,26 +12428,26 @@ function coordsAtPos(view, pos, side) {
12418
12428
  if (!view.state.doc.resolve(pos - (atom || 0)).parent.inlineContent) {
12419
12429
  if (atom == null && offset && (side < 0 || offset == nodeSize(node))) {
12420
12430
  let before = node.childNodes[offset - 1];
12421
- if (before.nodeType == 1) return flattenH(before.getBoundingClientRect(), false);
12431
+ if (isElt(before)) return flattenH(before.getBoundingClientRect(), false);
12422
12432
  }
12423
12433
  if (atom == null && offset < nodeSize(node)) {
12424
12434
  let after = node.childNodes[offset];
12425
- if (after.nodeType == 1) return flattenH(after.getBoundingClientRect(), true);
12435
+ if (isElt(after)) return flattenH(after.getBoundingClientRect(), true);
12426
12436
  }
12427
12437
  return flattenH(node.getBoundingClientRect(), side >= 0);
12428
12438
  }
12429
12439
  if (atom == null && offset && (side < 0 || offset == nodeSize(node))) {
12430
12440
  let before = node.childNodes[offset - 1];
12431
- let target = before.nodeType == 3 ? textRange(before, nodeSize(before) - (supportEmptyRange ? 0 : 1)) : before.nodeType == 1 && (before.nodeName != "BR" || !before.nextSibling) ? before : null;
12441
+ let target = isText(before) ? textRange(before, nodeSize(before) - (supportEmptyRange ? 0 : 1)) : isElt(before) && (before.nodeName != "BR" || !before.nextSibling) ? before : null;
12432
12442
  if (target) return flattenV(singleRect(target, 1), false);
12433
12443
  }
12434
12444
  if (atom == null && offset < nodeSize(node)) {
12435
12445
  let after = node.childNodes[offset];
12436
12446
  while (after.pmViewDesc && after.pmViewDesc.ignoreForCoords) after = after.nextSibling;
12437
- let target = !after ? null : after.nodeType == 3 ? textRange(after, 0, supportEmptyRange ? 0 : 1) : after.nodeType == 1 ? after : null;
12447
+ let target = !after ? null : isText(after) ? textRange(after, 0, supportEmptyRange ? 0 : 1) : isElt(after) ? after : null;
12438
12448
  if (target) return flattenV(singleRect(target, -1), true);
12439
12449
  }
12440
- return flattenV(singleRect(node.nodeType == 3 ? textRange(node) : node, -side), side >= 0);
12450
+ return flattenV(singleRect(isText(node) ? textRange(node) : node, -side), side >= 0);
12441
12451
  }
12442
12452
  function flattenV(rect, left) {
12443
12453
  if (rect.width == 0) return rect;
@@ -12487,8 +12497,8 @@ function endOfTextblockVertical(view, state, dir) {
12487
12497
  let coords = coordsAtPos(view, $pos.pos, 1);
12488
12498
  for (let child = dom.firstChild; child; child = child.nextSibling) {
12489
12499
  let boxes;
12490
- if (child.nodeType == 1) boxes = child.getClientRects();
12491
- else if (child.nodeType == 3) boxes = textRange(child, 0, child.nodeValue.length).getClientRects();
12500
+ if (isElt(child)) boxes = child.getClientRects();
12501
+ else if (isText(child)) boxes = textRange(child, 0, child.nodeValue.length).getClientRects();
12492
12502
  else continue;
12493
12503
  for (let i = 0; i < boxes.length; i++) {
12494
12504
  let box = boxes[i];
@@ -12512,7 +12522,7 @@ function endOfTextblockHorizontal(view, state, dir) {
12512
12522
  sel.modify("move", dir, "character");
12513
12523
  let parentDOM = $head.depth ? view.docView.domAfterPos($head.before()) : view.dom;
12514
12524
  let { focusNode: newNode, focusOffset: newOff } = view.domSelectionRange();
12515
- let result = newNode && !parentDOM.contains(newNode.nodeType == 1 ? newNode : newNode.parentNode) || oldNode == newNode && oldOff == newOff;
12525
+ let result = newNode && !contains(parentDOM, newNode) || oldNode == newNode && oldOff == newOff;
12516
12526
  try {
12517
12527
  sel.collapse(anchorNode, anchorOffset);
12518
12528
  if (oldNode && (oldNode != anchorNode || oldOff != anchorOffset) && sel.extend) sel.extend(oldNode, oldOff);
@@ -12594,7 +12604,7 @@ var ViewDesc = class {
12594
12604
  return this.posAtStart + this.size - 2 * this.border;
12595
12605
  }
12596
12606
  localPosFromDOM(dom, offset, bias) {
12597
- if (this.contentDOM && this.contentDOM.contains(dom.nodeType == 1 ? dom : dom.parentNode)) if (bias < 0) {
12607
+ if (this.contentDOM && contains(this.contentDOM, dom)) if (bias < 0) {
12598
12608
  let domBefore, desc;
12599
12609
  if (dom == this.contentDOM) domBefore = dom.childNodes[offset - 1];
12600
12610
  else {
@@ -12615,7 +12625,7 @@ var ViewDesc = class {
12615
12625
  }
12616
12626
  let atEnd;
12617
12627
  if (dom == this.dom && this.contentDOM) atEnd = offset > domIndex(this.contentDOM);
12618
- else if (this.contentDOM && this.contentDOM != this.dom && this.dom.contains(this.contentDOM)) atEnd = dom.compareDocumentPosition(this.contentDOM) & 2;
12628
+ else if (this.contentDOM && this.contentDOM != this.dom && this.dom.contains(this.contentDOM)) atEnd = !!(dom.compareDocumentPosition(this.contentDOM) & 4);
12619
12629
  else if (this.dom.firstChild) {
12620
12630
  if (offset == 0) for (let search = dom;; search = search.parentNode) {
12621
12631
  if (search == this.dom) {
@@ -12637,7 +12647,7 @@ var ViewDesc = class {
12637
12647
  nearestDesc(dom, onlyNodes = false) {
12638
12648
  for (let first = true, cur = dom; cur; cur = cur.parentNode) {
12639
12649
  let desc = this.getDesc(cur), nodeDOM;
12640
- if (desc && (!onlyNodes || desc.node)) if (first && (nodeDOM = desc.nodeDOM) && !(nodeDOM.nodeType == 1 ? nodeDOM.contains(dom.nodeType == 1 ? dom : dom.parentNode) : nodeDOM == dom)) first = false;
12650
+ if (desc && (!onlyNodes || desc.node)) if (first && (nodeDOM = desc.nodeDOM) && !(isElt(nodeDOM) ? contains(nodeDOM, dom) : nodeDOM == dom)) first = false;
12641
12651
  else return desc;
12642
12652
  }
12643
12653
  }
@@ -12678,14 +12688,17 @@ var ViewDesc = class {
12678
12688
  let i = 0, offset = 0;
12679
12689
  for (let curPos = 0; i < this.children.length; i++) {
12680
12690
  let child = this.children[i], end = curPos + child.size;
12681
- if (end > pos || child instanceof TrailingHackViewDesc) {
12691
+ if (end > pos) {
12682
12692
  offset = pos - curPos;
12683
12693
  break;
12684
12694
  }
12685
12695
  curPos = end;
12686
12696
  }
12687
12697
  if (offset) return this.children[i].domFromPos(offset - this.children[i].border, side);
12688
- for (let prev; i && !(prev = this.children[i - 1]).size && prev instanceof WidgetViewDesc && prev.side >= 0; i--);
12698
+ for (; i > 0; i--) {
12699
+ let prev = this.children[i - 1];
12700
+ if (prev.size || !(prev instanceof BufferHackViewDesc || prev instanceof WidgetViewDesc && prev.side >= 0)) break;
12701
+ }
12689
12702
  if (side <= 0) {
12690
12703
  let prev, enter = true;
12691
12704
  for (;; i--, enter = false) {
@@ -12765,7 +12778,7 @@ var ViewDesc = class {
12765
12778
  }
12766
12779
  domAfterPos(pos) {
12767
12780
  let { node, offset } = this.domFromPos(pos, 0);
12768
- if (node.nodeType != 1 || offset == node.childNodes.length) throw new RangeError("No node after pos " + pos);
12781
+ if (!isElt(node) || offset == node.childNodes.length) throw new RangeError("No node after pos " + pos);
12769
12782
  return node.childNodes[offset];
12770
12783
  }
12771
12784
  setSelection(anchor, head, view, force = false) {
@@ -12782,7 +12795,7 @@ var ViewDesc = class {
12782
12795
  let brKludge = false;
12783
12796
  if ((gecko || safari) && anchor == head) {
12784
12797
  let { node, offset } = anchorDOM;
12785
- if (node.nodeType == 3) {
12798
+ if (isText(node)) {
12786
12799
  brKludge = !!(offset && node.nodeValue[offset - 1] == "\n");
12787
12800
  if (brKludge && offset == node.nodeValue.length) for (let scan = node, after; scan; scan = scan.parentNode) {
12788
12801
  if (after = scan.nextSibling) {
@@ -12800,7 +12813,7 @@ var ViewDesc = class {
12800
12813
  brKludge = prev && (prev.nodeName == "BR" || prev.contentEditable == "false");
12801
12814
  }
12802
12815
  }
12803
- if (gecko && selRange.focusNode && selRange.focusNode != headDOM.node && selRange.focusNode.nodeType == 1) {
12816
+ if (gecko && selRange.focusNode && selRange.focusNode != headDOM.node && isElt(selRange.focusNode)) {
12804
12817
  let after = selRange.focusNode.childNodes[selRange.focusOffset];
12805
12818
  if (after && after.contentEditable == "false") force = true;
12806
12819
  }
@@ -12876,13 +12889,10 @@ var WidgetViewDesc = class extends ViewDesc {
12876
12889
  if (self.parent) return self.parent.posBeforeChild(self);
12877
12890
  });
12878
12891
  if (!widget.type.spec.raw) {
12879
- if (dom.nodeType != 1) {
12880
- let wrap = document.createElement("span");
12881
- wrap.appendChild(dom);
12882
- dom = wrap;
12883
- }
12884
- if (!dom.hasAttribute("contenteditable")) dom.contentEditable = "false";
12885
- dom.classList.add("ProseMirror-widget");
12892
+ let elt = isElt(dom) ? dom : document.createElement("span");
12893
+ if (elt != dom) elt.appendChild(dom);
12894
+ if (!elt.hasAttribute("contenteditable")) elt.contentEditable = "false";
12895
+ elt.classList.add("ProseMirror-widget");
12886
12896
  }
12887
12897
  super(parent, [], dom, null);
12888
12898
  this.widget = widget;
@@ -13005,7 +13015,7 @@ var NodeViewDesc = class NodeViewDesc extends ViewDesc {
13005
13015
  let dom = spec && spec.dom, contentDOM = spec && spec.contentDOM;
13006
13016
  if (node.isText) {
13007
13017
  if (!dom) dom = document.createTextNode(node.text);
13008
- else if (dom.nodeType != 3) throw new RangeError("Text must be rendered as a DOM text node");
13018
+ else if (!isText(dom)) throw new RangeError("Text must be rendered as a DOM text node");
13009
13019
  } else if (!dom) {
13010
13020
  let spec = DOMSerializer.renderSpec(document, node.type.spec.toDOM(node), null, node.attrs);
13011
13021
  ({dom, contentDOM} = spec);
@@ -13038,7 +13048,7 @@ var NodeViewDesc = class NodeViewDesc extends ViewDesc {
13038
13048
  }
13039
13049
  }
13040
13050
  if (!rule.contentElement) {
13041
- let found = addedNodes && addedNodes.find((n) => n.nodeType == 1 && addedNodes.indexOf(n.parentNode) < 0 && this.dom.contains(n));
13051
+ let found = addedNodes && addedNodes.find((n) => isElt(n) && addedNodes.indexOf(n.parentNode) < 0 && this.dom.contains(n));
13042
13052
  if (found) rule.contentElement = found;
13043
13053
  else rule.getContent = () => Fragment.empty;
13044
13054
  }
@@ -13060,18 +13070,21 @@ var NodeViewDesc = class NodeViewDesc extends ViewDesc {
13060
13070
  let localComposition = composition && composition.pos > -1 ? composition : null;
13061
13071
  let compositionInChild = composition && composition.pos < 0;
13062
13072
  let updater = new ViewTreeUpdater(this, localComposition && localComposition.node, view);
13073
+ let addBuffers = this.node.inlineContent, atBufferPos = addBuffers && this.node.isBlock;
13063
13074
  iterDeco(this.node, this.innerDeco, (widget, i, insideNode) => {
13064
13075
  if (widget.spec.marks) updater.syncToMarks(widget.spec.marks, inline, view, i);
13065
13076
  else if (widget.type.side >= 0 && !insideNode) updater.syncToMarks(i == this.node.childCount ? Mark$1.none : this.node.child(i).marks, inline, view, i);
13066
13077
  updater.placeWidget(widget, view, off);
13067
13078
  }, (child, outerDeco, innerDeco, i) => {
13068
13079
  updater.syncToMarks(child.marks, inline, view, i);
13080
+ if (atBufferPos && child.isAtom && !child.isText) updater.addHackNode("IMG", updater.top);
13069
13081
  let compIndex;
13070
13082
  if (updater.findNodeMatch(child, outerDeco, innerDeco, i));
13071
13083
  else if (compositionInChild && view.state.selection.from > off && view.state.selection.to < off + child.nodeSize && (compIndex = updater.findIndexWithChild(composition.node)) > -1 && updater.updateNodeAt(child, outerDeco, innerDeco, compIndex, view));
13072
13084
  else if (updater.updateNextNode(child, outerDeco, innerDeco, view, i, off));
13073
13085
  else updater.addNode(child, outerDeco, innerDeco, view, off);
13074
13086
  off += child.nodeSize;
13087
+ if (addBuffers) atBufferPos = child.isAtom && !child.isText;
13075
13088
  });
13076
13089
  updater.syncToMarks([], inline, view, 0);
13077
13090
  if (this.node.isTextblock) updater.addTextblockHacks();
@@ -13128,7 +13141,7 @@ var NodeViewDesc = class NodeViewDesc extends ViewDesc {
13128
13141
  }
13129
13142
  updateOuterDeco(outerDeco) {
13130
13143
  if (sameOuterDeco(outerDeco, this.outerDeco)) return;
13131
- let needsWrap = this.nodeDOM.nodeType != 1;
13144
+ let needsWrap = !isElt(this.nodeDOM);
13132
13145
  let oldDOM = this.dom;
13133
13146
  this.dom = patchOuterDeco(this.dom, this.nodeDOM, computeOuterDeco(this.outerDeco, this.node, needsWrap), computeOuterDeco(outerDeco, this.node, needsWrap));
13134
13147
  if (this.dom != oldDOM) {
@@ -13138,13 +13151,13 @@ var NodeViewDesc = class NodeViewDesc extends ViewDesc {
13138
13151
  this.outerDeco = outerDeco;
13139
13152
  }
13140
13153
  selectNode() {
13141
- if (this.nodeDOM.nodeType == 1) {
13154
+ if (isElt(this.nodeDOM)) {
13142
13155
  this.nodeDOM.classList.add("ProseMirror-selectednode");
13143
13156
  if (this.contentDOM || !this.node.type.spec.draggable) this.nodeDOM.draggable = true;
13144
13157
  }
13145
13158
  }
13146
13159
  deselectNode() {
13147
- if (this.nodeDOM.nodeType == 1) {
13160
+ if (isElt(this.nodeDOM)) {
13148
13161
  this.nodeDOM.classList.remove("ProseMirror-selectednode");
13149
13162
  if (this.contentDOM || !this.node.type.spec.draggable) this.nodeDOM.removeAttribute("draggable");
13150
13163
  }
@@ -13212,7 +13225,7 @@ var TextViewDesc = class TextViewDesc extends NodeViewDesc {
13212
13225
  return this.node.text == text;
13213
13226
  }
13214
13227
  };
13215
- var TrailingHackViewDesc = class extends ViewDesc {
13228
+ var BufferHackViewDesc = class extends ViewDesc {
13216
13229
  parseRule() {
13217
13230
  return { ignore: true };
13218
13231
  }
@@ -13348,7 +13361,7 @@ function patchAttributes(dom, prev, cur) {
13348
13361
  }
13349
13362
  }
13350
13363
  function applyOuterDeco(dom, deco, node) {
13351
- return patchOuterDeco(dom, dom, noDeco, computeOuterDeco(deco, node, dom.nodeType != 1));
13364
+ return patchOuterDeco(dom, dom, noDeco, computeOuterDeco(deco, node, !isElt(dom)));
13352
13365
  }
13353
13366
  function sameOuterDeco(a, b) {
13354
13367
  if (a.length != b.length) return false;
@@ -13538,14 +13551,14 @@ var ViewTreeUpdater = class {
13538
13551
  dom.alt = "";
13539
13552
  }
13540
13553
  if (nodeName == "BR") dom.className = "ProseMirror-trailingBreak";
13541
- let hack = new TrailingHackViewDesc(this.top, [], dom, null);
13554
+ let hack = new BufferHackViewDesc(this.top, [], dom, null);
13542
13555
  if (parent != this.top) parent.children.push(hack);
13543
13556
  else parent.children.splice(this.index++, 0, hack);
13544
13557
  this.changed = true;
13545
13558
  }
13546
13559
  }
13547
13560
  isLocked(node) {
13548
- return this.lock && (node == this.lock || node.nodeType == 1 && node.contains(this.lock.parentNode));
13561
+ return this.lock && (node == this.lock || isElt(node) && node.contains(this.lock.parentNode));
13549
13562
  }
13550
13563
  };
13551
13564
  function preMatch(frag, parentDesc) {
@@ -13689,10 +13702,15 @@ function selectionFromDOM(view, origin = null) {
13689
13702
  if (selectionCollapsed(domSel)) {
13690
13703
  anchor = head;
13691
13704
  while (nearestDesc && !nearestDesc.node) nearestDesc = nearestDesc.parent;
13692
- let nearestDescNode = nearestDesc.node;
13693
- if (nearestDesc && nearestDescNode.isAtom && NodeSelection.isSelectable(nearestDescNode) && nearestDesc.parent && !(nearestDescNode.isInline && isOnEdge(domSel.focusNode, domSel.focusOffset, nearestDesc.dom))) {
13705
+ if (nearestDesc && nearestDesc.node.isAtom && NodeSelection.isSelectable(nearestDesc.node) && nearestDesc.parent && !(nearestDesc.node.isInline && isOnEdge(domSel.focusNode, domSel.focusOffset, nearestDesc.dom))) {
13694
13706
  let pos = nearestDesc.posBefore;
13695
13707
  selection = new NodeSelection(head == pos ? $head : doc.resolve(pos));
13708
+ } else if (gecko && origin == "key" && head > view.state.selection.to && isElt(domSel.focusNode) && domSel.focusOffset == domSel.focusNode.childNodes.length && nearestDesc && nearestDesc.posAtStart > view.state.selection.to) for (let scan = domSel.focusNode;; scan = scan.parentNode) {
13709
+ if (getComputedStyle(scan).overflow != "visible") {
13710
+ selection = Selection$1.findFrom(doc.resolve(nearestDesc.posAtStart), 1);
13711
+ break;
13712
+ }
13713
+ if (scan == nearestDesc.dom || scan.nextSibling || !scan.parentNode || !isElt(scan.parentNode)) break;
13696
13714
  }
13697
13715
  } else {
13698
13716
  if (domSel instanceof view.dom.ownerDocument.defaultView.Selection && domSel.rangeCount > 1) {
@@ -13830,7 +13848,7 @@ function hasSelection(view) {
13830
13848
  let sel = view.domSelectionRange();
13831
13849
  if (!sel.anchorNode) return false;
13832
13850
  try {
13833
- return view.dom.contains(sel.anchorNode.nodeType == 3 ? sel.anchorNode.parentNode : sel.anchorNode) && (view.editable || view.dom.contains(sel.focusNode.nodeType == 3 ? sel.focusNode.parentNode : sel.focusNode));
13851
+ return contains(view.dom, sel.anchorNode) && (view.editable || contains(view.dom, sel.focusNode));
13834
13852
  } catch (_) {
13835
13853
  return false;
13836
13854
  }
@@ -13869,8 +13887,7 @@ function selectHorizontally(view, dir, mods) {
13869
13887
  let nodePos = dir < 0 ? $head.pos - node.nodeSize : $head.pos;
13870
13888
  if (!(node.isAtom || (desc = view.docView.descAt(nodePos)) && !desc.contentDOM)) return false;
13871
13889
  if (NodeSelection.isSelectable(node)) return apply(view, new NodeSelection(dir < 0 ? view.state.doc.resolve($head.pos - node.nodeSize) : $head));
13872
- else if (webkit) return apply(view, new TextSelection(view.state.doc.resolve(dir < 0 ? nodePos : nodePos + node.nodeSize)));
13873
- else return false;
13890
+ else return apply(view, new TextSelection(view.state.doc.resolve(dir < 0 ? nodePos : nodePos + node.nodeSize)));
13874
13891
  }
13875
13892
  } else if (sel instanceof NodeSelection && sel.node.isInline) return apply(view, new TextSelection(dir > 0 ? sel.$to : sel.$from));
13876
13893
  else {
@@ -13879,12 +13896,9 @@ function selectHorizontally(view, dir, mods) {
13879
13896
  return false;
13880
13897
  }
13881
13898
  }
13882
- function nodeLen(node) {
13883
- return node.nodeType == 3 ? node.nodeValue.length : node.childNodes.length;
13884
- }
13885
13899
  function isIgnorable(dom, dir) {
13886
13900
  let desc = dom.pmViewDesc;
13887
- return desc && desc.size == 0 && (dir < 0 || dom.nextSibling || dom.nodeName != "BR");
13901
+ return desc ? desc.size == 0 && (dir < 0 || dom.nextSibling || dom.nodeName != "BR") : isElt(dom) && dom.contentEditable == "false";
13888
13902
  }
13889
13903
  function skipIgnoredNodes(view, dir) {
13890
13904
  return dir < 0 ? skipIgnoredNodesBefore(view) : skipIgnoredNodesAfter(view);
@@ -13894,19 +13908,18 @@ function skipIgnoredNodesBefore(view) {
13894
13908
  let node = sel.focusNode, offset = sel.focusOffset;
13895
13909
  if (!node) return;
13896
13910
  let moveNode, moveOffset, force = false;
13897
- if (gecko && node.nodeType == 1 && offset < nodeLen(node) && isIgnorable(node.childNodes[offset], -1)) force = true;
13898
- for (;;) if (offset > 0) if (node.nodeType != 1) break;
13899
- else {
13911
+ if (gecko && isElt(node) && offset < nodeSize(node) && isIgnorable(node.childNodes[offset], -1)) force = true;
13912
+ for (;;) if (offset > 0) {
13913
+ if (!isElt(node)) break;
13900
13914
  let before = node.childNodes[offset - 1];
13901
13915
  if (isIgnorable(before, -1)) {
13902
13916
  moveNode = node;
13903
13917
  moveOffset = --offset;
13904
- } else if (before.nodeType == 3) {
13918
+ } else if (isText(before)) {
13905
13919
  node = before;
13906
13920
  offset = node.nodeValue.length;
13907
13921
  } else break;
13908
- }
13909
- else if (isBlockNode(node)) break;
13922
+ } else if (isBlockNode(node)) break;
13910
13923
  else {
13911
13924
  let prev = node.previousSibling;
13912
13925
  while (prev && isIgnorable(prev, -1)) {
@@ -13920,7 +13933,7 @@ function skipIgnoredNodesBefore(view) {
13920
13933
  offset = 0;
13921
13934
  } else {
13922
13935
  node = prev;
13923
- offset = nodeLen(node);
13936
+ offset = nodeSize(node);
13924
13937
  }
13925
13938
  }
13926
13939
  if (force) setSelFocus(view, node, offset);
@@ -13930,10 +13943,10 @@ function skipIgnoredNodesAfter(view) {
13930
13943
  let sel = view.domSelectionRange();
13931
13944
  let node = sel.focusNode, offset = sel.focusOffset;
13932
13945
  if (!node) return;
13933
- let len = nodeLen(node);
13946
+ let len = nodeSize(node);
13934
13947
  let moveNode, moveOffset;
13935
13948
  for (;;) if (offset < len) {
13936
- if (node.nodeType != 1) break;
13949
+ if (!isElt(node)) break;
13937
13950
  let after = node.childNodes[offset];
13938
13951
  if (isIgnorable(after, 1)) {
13939
13952
  moveNode = node;
@@ -13954,7 +13967,7 @@ function skipIgnoredNodesAfter(view) {
13954
13967
  } else {
13955
13968
  node = next;
13956
13969
  offset = 0;
13957
- len = nodeLen(node);
13970
+ len = nodeSize(node);
13958
13971
  }
13959
13972
  }
13960
13973
  if (moveNode) setSelFocus(view, moveNode, moveOffset);
@@ -13970,8 +13983,8 @@ function textNodeAfter(node, offset) {
13970
13983
  }
13971
13984
  while (node && offset < node.childNodes.length) {
13972
13985
  let next = node.childNodes[offset];
13973
- if (next.nodeType == 3) return next;
13974
- if (next.nodeType == 1 && next.contentEditable == "false") break;
13986
+ if (isText(next)) return next;
13987
+ if (isElt(next) && next.contentEditable == "false") break;
13975
13988
  node = next;
13976
13989
  offset = 0;
13977
13990
  }
@@ -13983,14 +13996,14 @@ function textNodeBefore(node, offset) {
13983
13996
  }
13984
13997
  while (node && offset) {
13985
13998
  let next = node.childNodes[offset - 1];
13986
- if (next.nodeType == 3) return next;
13987
- if (next.nodeType == 1 && next.contentEditable == "false") break;
13999
+ if (isText(next)) return next;
14000
+ if (isElt(next) && next.contentEditable == "false") break;
13988
14001
  node = next;
13989
14002
  offset = node.childNodes.length;
13990
14003
  }
13991
14004
  }
13992
14005
  function setSelFocus(view, node, offset) {
13993
- if (node.nodeType != 3) {
14006
+ if (!isText(node)) {
13994
14007
  let before, after;
13995
14008
  if (after = textNodeAfter(node, offset)) {
13996
14009
  node = after;
@@ -14072,7 +14085,7 @@ function switchEditable(view, node, state) {
14072
14085
  function safariDownArrowBug(view) {
14073
14086
  if (!safari || view.state.selection.$head.parentOffset > 0) return false;
14074
14087
  let { focusNode, focusOffset } = view.domSelectionRange();
14075
- if (focusNode && focusNode.nodeType == 1 && focusOffset == 0 && focusNode.firstChild && focusNode.firstChild.contentEditable == "false") {
14088
+ if (focusNode && isElt(focusNode) && focusOffset == 0 && focusNode.firstChild && isElt(focusNode.firstChild) && focusNode.firstChild.contentEditable == "false") {
14076
14089
  let child = focusNode.firstChild;
14077
14090
  switchEditable(view, child, "true");
14078
14091
  setTimeout(() => switchEditable(view, child, "false"), 20);
@@ -14119,7 +14132,7 @@ function serializeForClipboard(view, slice) {
14119
14132
  let doc = detachedDoc(), wrap = doc.createElement("div");
14120
14133
  wrap.appendChild(serializer.serializeFragment(content, { document: doc }));
14121
14134
  let firstChild = wrap.firstChild, needsWrap, wrappers = 0;
14122
- while (firstChild && firstChild.nodeType == 1 && (needsWrap = wrapMap[firstChild.nodeName.toLowerCase()])) {
14135
+ while (firstChild && isElt(firstChild) && (needsWrap = wrapMap[firstChild.nodeName.toLowerCase()])) {
14123
14136
  for (let i = needsWrap.length - 1; i >= 0; i--) {
14124
14137
  let wrapper = doc.createElement(needsWrap[i]);
14125
14138
  while (wrap.firstChild) wrapper.appendChild(wrap.firstChild);
@@ -14128,7 +14141,7 @@ function serializeForClipboard(view, slice) {
14128
14141
  }
14129
14142
  firstChild = wrap.firstChild;
14130
14143
  }
14131
- if (firstChild && firstChild.nodeType == 1) firstChild.setAttribute("data-pm-slice", `${openStart} ${openEnd}${wrappers ? ` -${wrappers}` : ""} ${JSON.stringify(context)}`);
14144
+ if (firstChild && isElt(firstChild)) firstChild.setAttribute("data-pm-slice", `${openStart} ${openEnd}${wrappers ? ` -${wrappers}` : ""} ${JSON.stringify(context)}`);
14132
14145
  return {
14133
14146
  dom: wrap,
14134
14147
  text: view.someProp("clipboardTextSerializer", (f) => f(slice, view)) || slice.content.textBetween(0, slice.content.size, "\n\n"),
@@ -14173,7 +14186,7 @@ function parseFromClipboard(view, text, html, plainText, $context) {
14173
14186
  let sliceData = contextNode && /^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(contextNode.getAttribute("data-pm-slice") || "");
14174
14187
  if (sliceData && sliceData[3]) for (let i = +sliceData[3]; i > 0; i--) {
14175
14188
  let child = dom.firstChild;
14176
- while (child && child.nodeType != 1) child = child.nextSibling;
14189
+ while (child && !isElt(child)) child = child.nextSibling;
14177
14190
  if (!child) break;
14178
14191
  dom = child;
14179
14192
  }
@@ -14326,11 +14339,10 @@ function addContext(slice, context) {
14326
14339
  let type = schema.nodes[array[i]];
14327
14340
  if (!type || type.hasRequiredAttrs()) break;
14328
14341
  try {
14329
- type.checkAttrs(array[i + 1]);
14342
+ content = Fragment.from(type.create(array[i + 1], content));
14330
14343
  } catch (e) {
14331
14344
  break;
14332
14345
  }
14333
- content = Fragment.from(type.create(array[i + 1], content));
14334
14346
  openStart++;
14335
14347
  openEnd++;
14336
14348
  }
@@ -14474,14 +14486,14 @@ function updateSelection(view, selection, origin) {
14474
14486
  if (!view.focused) view.focus();
14475
14487
  if (view.state.selection.eq(selection)) return;
14476
14488
  let tr = view.state.tr.setSelection(selection);
14477
- if (origin == "pointer") tr.setMeta("pointer", true);
14489
+ tr.setMeta("pointer", true);
14478
14490
  view.dispatch(tr);
14479
14491
  }
14480
14492
  function selectClickedLeaf(view, inside) {
14481
14493
  if (inside == -1) return false;
14482
14494
  let $pos = view.state.doc.resolve(inside), node = $pos.nodeAfter;
14483
14495
  if (node && node.isAtom && NodeSelection.isSelectable(node)) {
14484
- updateSelection(view, new NodeSelection($pos), "pointer");
14496
+ updateSelection(view, new NodeSelection($pos));
14485
14497
  return true;
14486
14498
  }
14487
14499
  return false;
@@ -14500,7 +14512,7 @@ function selectClickedNode(view, inside) {
14500
14512
  }
14501
14513
  }
14502
14514
  if (selectAt != null) {
14503
- updateSelection(view, NodeSelection.create(view.state.doc, selectAt), "pointer");
14515
+ updateSelection(view, NodeSelection.create(view.state.doc, selectAt));
14504
14516
  return true;
14505
14517
  } else return false;
14506
14518
  }
@@ -14517,7 +14529,7 @@ function defaultTripleClick(view, inside, event) {
14517
14529
  if (event.button != 0) return false;
14518
14530
  let selection = selectionForTripleClick(view, inside, true), doc = view.state.doc;
14519
14531
  if (!selection) return false;
14520
- updateSelection(view, selection, "pointer");
14532
+ updateSelection(view, selection);
14521
14533
  if (selection instanceof TextSelection && doc.eq(view.state.doc)) view.input.mouseDown = new TripleClickDrag(view, selection);
14522
14534
  return true;
14523
14535
  }
@@ -14603,7 +14615,7 @@ var LeftMouseDown = class extends MouseDown {
14603
14615
  }
14604
14616
  const target = flushed ? null : event.target;
14605
14617
  const targetDesc = target ? view.docView.nearestDesc(target, true) : null;
14606
- this.target = targetDesc && targetDesc.nodeDOM.nodeType == 1 ? targetDesc.nodeDOM : null;
14618
+ this.target = targetDesc && isElt(targetDesc.nodeDOM) ? targetDesc.nodeDOM : null;
14607
14619
  let { selection } = view.state;
14608
14620
  if (event.button == 0 && (targetNode.type.spec.draggable && targetNode.type.spec.selectable !== false || selection instanceof NodeSelection && selection.from <= targetPos && selection.to > targetPos)) this.mightDrag = {
14609
14621
  node: targetNode,
@@ -14642,7 +14654,7 @@ var LeftMouseDown = class extends MouseDown {
14642
14654
  if (this.allowDefault || !pos) setSelectionOrigin(this.view, "pointer");
14643
14655
  else if (handleSingleClick(this.view, pos.pos, pos.inside, event, this.selectNode)) event.preventDefault();
14644
14656
  else if (event.button == 0 && (this.flushed || safari && this.mightDrag && !this.mightDrag.node.isAtom || chrome && !this.view.state.selection.visible && Math.min(Math.abs(pos.pos - this.view.state.selection.from), Math.abs(pos.pos - this.view.state.selection.to)) <= 2)) {
14645
- updateSelection(this.view, Selection$1.near(this.view.state.doc.resolve(pos.pos)), "pointer");
14657
+ updateSelection(this.view, Selection$1.near(this.view.state.doc.resolve(pos.pos)));
14646
14658
  event.preventDefault();
14647
14659
  } else setSelectionOrigin(this.view, "pointer");
14648
14660
  }
@@ -14678,7 +14690,7 @@ var TripleClickDrag = class extends MouseDown {
14678
14690
  if (!target) return;
14679
14691
  let { doc } = this.view.state, start = this.startSelection;
14680
14692
  let [anchor, head] = target.from < start.from ? [start.to, target.from] : [start.from, target.to];
14681
- updateSelection(this.view, TextSelection.create(doc, anchor, head), "pointer");
14693
+ updateSelection(this.view, TextSelection.create(doc, anchor, head));
14682
14694
  }
14683
14695
  };
14684
14696
  handlers.touchstart = (view) => {
@@ -14704,7 +14716,7 @@ editHandlers.compositionstart = editHandlers.compositionupdate = (view) => {
14704
14716
  if (!view.composing) {
14705
14717
  view.domObserver.flush();
14706
14718
  let { state } = view, $pos = state.selection.$to;
14707
- if (state.selection instanceof TextSelection && (state.storedMarks || !$pos.textOffset && $pos.parentOffset && $pos.nodeBefore.marks.some((m) => m.type.spec.inclusive === false) || chrome && windows$1 && selectionBeforeUneditable(view))) {
14719
+ if (state.selection instanceof TextSelection && state.selection.empty && (state.storedMarks || !$pos.textOffset && $pos.parentOffset && $pos.nodeBefore.marks.some((m) => m.type.spec.inclusive === false) || chrome && windows$1 && selectionBeforeUneditable(view))) {
14708
14720
  view.markCursor = view.state.storedMarks || $pos.marks();
14709
14721
  endComposition(view, true);
14710
14722
  view.markCursor = null;
@@ -14712,10 +14724,10 @@ editHandlers.compositionstart = editHandlers.compositionupdate = (view) => {
14712
14724
  endComposition(view, !state.selection.empty);
14713
14725
  if (gecko && state.selection.empty && $pos.parentOffset && !$pos.textOffset && $pos.nodeBefore.marks.length) {
14714
14726
  let sel = view.domSelectionRange();
14715
- for (let node = sel.focusNode, offset = sel.focusOffset; node && node.nodeType == 1 && offset != 0;) {
14727
+ for (let node = sel.focusNode, offset = sel.focusOffset; node && isElt(node) && offset != 0;) {
14716
14728
  let before = offset < 0 ? node.lastChild : node.childNodes[offset - 1];
14717
14729
  if (!before) break;
14718
- if (before.nodeType == 3) {
14730
+ if (isText(before)) {
14719
14731
  let sel = view.domSelection();
14720
14732
  if (sel) sel.collapse(before, before.nodeValue.length);
14721
14733
  break;
@@ -14732,9 +14744,9 @@ editHandlers.compositionstart = editHandlers.compositionupdate = (view) => {
14732
14744
  };
14733
14745
  function selectionBeforeUneditable(view) {
14734
14746
  let { focusNode, focusOffset } = view.domSelectionRange();
14735
- if (!focusNode || focusNode.nodeType != 1 || focusOffset >= focusNode.childNodes.length) return false;
14747
+ if (!focusNode || !isElt(focusNode) || focusOffset >= focusNode.childNodes.length) return false;
14736
14748
  let next = focusNode.childNodes[focusOffset];
14737
- return next.nodeType == 1 && next.contentEditable == "false";
14749
+ return isElt(next) && next.contentEditable == "false";
14738
14750
  }
14739
14751
  editHandlers.compositionend = (view, event) => {
14740
14752
  if (view.composing) {
@@ -14887,7 +14899,7 @@ handlers.dragstart = (view, _event) => {
14887
14899
  let node;
14888
14900
  if (pos && pos.pos >= sel.from && pos.pos <= (sel instanceof NodeSelection ? sel.to - 1 : sel.to));
14889
14901
  else if (mouseDown && mouseDown.mightDrag) node = NodeSelection.create(view.state.doc, mouseDown.mightDrag.pos);
14890
- else if (event.target && event.target.nodeType == 1) {
14902
+ else if (event.target && isElt(event.target)) {
14891
14903
  let desc = view.docView.nearestDesc(event.target, true);
14892
14904
  if (desc && desc.node.type.spec.draggable && desc != view.docView) node = NodeSelection.create(view.state.doc, desc.posBefore);
14893
14905
  }
@@ -15660,7 +15672,7 @@ var DOMObserver = class {
15660
15672
  let desc = container && this.view.docView.nearestDesc(container);
15661
15673
  if (desc && desc.ignoreMutation({
15662
15674
  type: "selection",
15663
- target: container.nodeType == 3 ? container.parentNode : container
15675
+ target: isText(container) ? container.parentNode : container
15664
15676
  })) {
15665
15677
  this.setCurSelection();
15666
15678
  return true;
@@ -15689,7 +15701,7 @@ var DOMObserver = class {
15689
15701
  if (added.some((n) => n.nodeName == "BR") && (view.input.lastKeyCode == 8 || view.input.lastKeyCode == 46 || chrome && (view.composing || view.input.compositionEndedAt > Date.now() - 50) && mutations.some((m) => m.type == "childList" && m.removedNodes.length))) {
15690
15702
  for (let node of added) if (node.nodeName == "BR" && node.parentNode) {
15691
15703
  let after = node.nextSibling;
15692
- while (after && after.nodeType == 1) {
15704
+ while (after && isElt(after)) {
15693
15705
  if (after.contentEditable == "false") {
15694
15706
  node.parentNode.removeChild(node);
15695
15707
  break;
@@ -15741,7 +15753,7 @@ var DOMObserver = class {
15741
15753
  for (let i = 0; i < mut.addedNodes.length; i++) {
15742
15754
  let node = mut.addedNodes[i];
15743
15755
  added.push(node);
15744
- if (node.nodeType == 3) this.lastChangedTextNode = node;
15756
+ if (isText(node)) this.lastChangedTextNode = node;
15745
15757
  }
15746
15758
  if (desc.contentDOM && desc.contentDOM != desc.dom && !desc.contentDOM.contains(mut.target)) return {
15747
15759
  from: desc.posBefore,
@@ -15840,7 +15852,7 @@ function fixUpBadSafariComposition(view, addedNodes) {
15840
15852
  let parent = nextCell;
15841
15853
  for (;;) {
15842
15854
  let first = parent.firstChild;
15843
- if (!first || first.nodeType != 1 || first.contentEditable == "false" || /^(BR|IMG)$/.test(first.nodeName)) break;
15855
+ if (!first || !isElt(first) || first.contentEditable == "false" || /^(BR|IMG)$/.test(first.nodeName)) break;
15844
15856
  parent = first;
15845
15857
  }
15846
15858
  parent.insertBefore(node, parent.firstChild);
@@ -15853,7 +15865,7 @@ function parseBetween(view, from_, to_, addedNodes) {
15853
15865
  let domSel = view.domSelectionRange();
15854
15866
  let find;
15855
15867
  let anchor = domSel.anchorNode;
15856
- if (anchor && view.dom.contains(anchor.nodeType == 1 ? anchor : anchor.parentNode)) {
15868
+ if (anchor && contains(view.dom, anchor)) {
15857
15869
  find = [{
15858
15870
  node: anchor,
15859
15871
  offset: domSel.anchorOffset
@@ -15947,7 +15959,7 @@ function readDOMChange(view, from, to, typeOver, addedNodes) {
15947
15959
  view.input.lastKeyCode = null;
15948
15960
  let change = findDiff(compare.content, parse.doc.content, parse.from, preferredPos, preferredSide);
15949
15961
  if (change) view.input.domChangeCount++;
15950
- if ((ios && view.input.lastIOSEnter > Date.now() - 225 || android) && addedNodes.some((n) => n.nodeType == 1 && !isInline.test(n.nodeName)) && (!change || change.endA >= change.endB) && view.someProp("handleKeyDown", (f) => f(view, keyEvent(13, "Enter")))) {
15962
+ if ((ios && view.input.lastIOSEnter > Date.now() - 225 || android) && addedNodes.some((n) => isElt(n) && !isInline.test(n.nodeName)) && (!change || change.endA >= change.endB) && view.someProp("handleKeyDown", (f) => f(view, keyEvent(13, "Enter")))) {
15951
15963
  view.input.lastIOSEnter = 0;
15952
15964
  return;
15953
15965
  }
@@ -15983,7 +15995,7 @@ function readDOMChange(view, from, to, typeOver, addedNodes) {
15983
15995
  let $to = parse.doc.resolveNoCache(change.endB - parse.from);
15984
15996
  let $fromA = doc.resolve(change.start);
15985
15997
  let inlineChange = $from.sameParent($to) && $from.parent.inlineContent && $fromA.end() >= change.endA;
15986
- if ((ios && view.input.lastIOSEnter > Date.now() - 225 && (!inlineChange || addedNodes.some((n) => n.nodeName == "DIV" || n.nodeName == "P")) || !inlineChange && $from.pos < parse.doc.content.size && (!$from.sameParent($to) || !$from.parent.inlineContent) && $from.pos < $to.pos && !/\S/.test(parse.doc.textBetween($from.pos, $to.pos, "", ""))) && view.someProp("handleKeyDown", (f) => f(view, keyEvent(13, "Enter")))) {
15998
+ if ((ios && view.input.lastIOSEnter > Date.now() - 225 && (!inlineChange || addedNodes.some((n) => n.nodeName == "DIV" || n.nodeName == "P")) || !inlineChange && looksLikeEnter(parse.doc, $from.pos, $to.pos)) && view.someProp("handleKeyDown", (f) => f(view, keyEvent(13, "Enter")))) {
15987
15999
  view.input.lastIOSEnter = 0;
15988
16000
  return;
15989
16001
  }
@@ -16070,6 +16082,14 @@ function looksLikeBackspace(old, start, end, $newStart, $newEnd) {
16070
16082
  if (!$next.parent.isTextblock || $next.pos > end || skipClosingAndOpening($next, true, false) < end) return false;
16071
16083
  return $newStart.parent.content.cut($newStart.parentOffset).eq($next.parent.content);
16072
16084
  }
16085
+ function looksLikeEnter(content, from, to) {
16086
+ let newTextlines = 0, newLeaves = 0;
16087
+ content.nodesBetween(from, to, (node, pos) => {
16088
+ if (node.isTextblock && pos >= from && pos < to) newTextlines++;
16089
+ else if (node.isText ? /\S/.test(node.text.slice(Math.max(0, from - pos), Math.min(node.nodeSize, to - pos))) : node.isLeaf) newLeaves++;
16090
+ });
16091
+ return newLeaves == 0 && newTextlines == 1;
16092
+ }
16073
16093
  function skipClosingAndOpening($pos, fromEnd, mayOpen) {
16074
16094
  let depth = $pos.depth, end = fromEnd ? $pos.end() : $pos.pos;
16075
16095
  while (depth > 0 && (fromEnd || $pos.indexAfter(depth) == $pos.node(depth).childCount)) {
@@ -16294,11 +16314,11 @@ var EditorView = class {
16294
16314
  */
16295
16315
  scrollToSelection() {
16296
16316
  let startDOM = this.domSelectionRange().focusNode;
16297
- if (!startDOM || !this.dom.contains(startDOM.nodeType == 1 ? startDOM : startDOM.parentNode));
16317
+ if (!startDOM || !contains(this.dom, startDOM));
16298
16318
  else if (this.someProp("handleScrollToSelection", (f) => f(this)));
16299
16319
  else if (this.state.selection instanceof NodeSelection) {
16300
16320
  let target = this.docView.domAfterPos(this.state.selection.from);
16301
- if (target.nodeType == 1) scrollRectIntoView(this, target.getBoundingClientRect(), startDOM);
16321
+ if (isElt(target)) scrollRectIntoView(this, target.getBoundingClientRect(), startDOM);
16302
16322
  } else scrollRectIntoView(this, this.coordsAtPos(this.state.selection.head, 1), startDOM);
16303
16323
  }
16304
16324
  destroyPluginViews() {
@@ -16527,7 +16547,7 @@ var EditorView = class {
16527
16547
  @internal
16528
16548
  */
16529
16549
  domSelectionRange() {
16530
- let sel = this.domSelection();
16550
+ let sel = this.dom.isConnected !== false && this.domSelection();
16531
16551
  if (!sel) return {
16532
16552
  focusNode: null,
16533
16553
  focusOffset: 0,
@@ -27105,7 +27125,7 @@ var Underline = Mark.create({
27105
27125
  }
27106
27126
  });
27107
27127
  //#endregion
27108
- //#region ../../../node_modules/.bun/prosemirror-dropcursor@1.8.2/node_modules/prosemirror-dropcursor/dist/index.js
27128
+ //#region ../../../node_modules/.bun/prosemirror-dropcursor@1.8.4/node_modules/prosemirror-dropcursor/dist/index.js
27109
27129
  /**
27110
27130
  Create a plugin that, when added to a ProseMirror instance,
27111
27131
  causes a decoration to show up at the drop position when something
@@ -27128,6 +27148,7 @@ var DropCursorView = class {
27128
27148
  this.cursorPos = null;
27129
27149
  this.element = null;
27130
27150
  this.timeout = -1;
27151
+ this.lastDragEvent = null;
27131
27152
  this.width = (_a = options.width) !== null && _a !== void 0 ? _a : 1;
27132
27153
  this.color = options.color === false ? void 0 : options.color || "black";
27133
27154
  this.class = options.class;
@@ -27148,11 +27169,15 @@ var DropCursorView = class {
27148
27169
  });
27149
27170
  }
27150
27171
  destroy() {
27172
+ this.setCursor(null);
27151
27173
  this.handlers.forEach(({ name, handler }) => this.editorView.dom.removeEventListener(name, handler));
27152
27174
  }
27153
27175
  update(editorView, prevState) {
27154
- if (this.cursorPos != null && prevState.doc != editorView.state.doc) if (this.cursorPos > editorView.state.doc.content.size) this.setCursor(null);
27155
- else this.updateOverlay();
27176
+ if (this.cursorPos != null && prevState.doc != editorView.state.doc) if (this.lastDragEvent) {
27177
+ let target = this.computeTarget(this.lastDragEvent);
27178
+ if (target == this.cursorPos) this.updateOverlay();
27179
+ else this.setCursor(target);
27180
+ } else this.updateOverlay();
27156
27181
  }
27157
27182
  setCursor(pos) {
27158
27183
  if (pos == this.cursorPos) return;
@@ -27223,8 +27248,7 @@ var DropCursorView = class {
27223
27248
  clearTimeout(this.timeout);
27224
27249
  this.timeout = setTimeout(() => this.setCursor(null), timeout);
27225
27250
  }
27226
- dragover(event) {
27227
- if (!this.editorView.editable) return;
27251
+ computeTarget(event) {
27228
27252
  let pos = this.editorView.posAtCoords({
27229
27253
  left: event.clientX,
27230
27254
  top: event.clientY
@@ -27232,12 +27256,19 @@ var DropCursorView = class {
27232
27256
  let node = pos && pos.inside >= 0 && this.editorView.state.doc.nodeAt(pos.inside);
27233
27257
  let disableDropCursor = node && node.type.spec.disableDropCursor;
27234
27258
  let disabled = typeof disableDropCursor == "function" ? disableDropCursor(this.editorView, pos, event) : disableDropCursor;
27235
- if (pos && !disabled) {
27236
- let target = pos.pos;
27237
- if (this.editorView.dragging && this.editorView.dragging.slice) {
27238
- let point = dropPoint(this.editorView.state.doc, target, this.editorView.dragging.slice);
27239
- if (point != null) target = point;
27240
- }
27259
+ if (!pos || disabled) return null;
27260
+ let target = pos.pos;
27261
+ if (this.editorView.dragging && this.editorView.dragging.slice) {
27262
+ let point = dropPoint(this.editorView.state.doc, target, this.editorView.dragging.slice);
27263
+ if (point != null) target = point;
27264
+ }
27265
+ return target;
27266
+ }
27267
+ dragover(event) {
27268
+ if (!this.editorView.editable) return;
27269
+ this.lastDragEvent = event;
27270
+ let target = this.computeTarget(event);
27271
+ if (target != null) {
27241
27272
  this.setCursor(target);
27242
27273
  this.scheduleRemoval(5e3);
27243
27274
  }