@burger-editor/local 4.0.0-alpha.34 → 4.0.0-alpha.42

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/client.js CHANGED
@@ -1294,7 +1294,7 @@ var style$b = "/* No Styling */\n";
1294
1294
  var template$b = "<a href=\"\" data-kind=\"link\" data-before-icon=\"none\" data-after-icon=\"none\" data-bge=\"link:href, target:target, kind:data-kind, before-icon:data-before-icon, after-icon:data-after-icon\">\n\t<div>\n\t\t<span data-bge=\"text\">ボタン</span>\n\t\t<span data-bge=\"subtext\">サブテキスト</span>\n\t</div>\n</a>\n";
1295
1295
 
1296
1296
  var button = createItem$1({
1297
- version: "4.0.0-alpha.33",
1297
+ version: "4.0.0-alpha.39",
1298
1298
  name: "button",
1299
1299
  template: template$b,
1300
1300
  style: style$b,
@@ -1350,7 +1350,7 @@ var style$a = "/* No Styling */\n";
1350
1350
  var template$a = "<details data-bge=\"open:open\">\n\t<summary data-bge=\"summary\">折りたたみコンテンツ</summary>\n\t<div data-bge=\"content\"><p>内容を入力してください</p></div>\n</details>\n";
1351
1351
 
1352
1352
  var details = createItem$1({
1353
- version: "4.0.0-alpha.33",
1353
+ version: "4.0.0-alpha.39",
1354
1354
  name: "details",
1355
1355
  template: template$a,
1356
1356
  style: style$a,
@@ -1364,7 +1364,7 @@ var style$9 = "[data-bgi='download-file'] {\n\t[data-bge*='size'] {\n\t\t&::befo
1364
1364
  var template$9 = "<a href=\"./files/bgeditor/bg-sample.pdf\" target=\"_blank\" data-bge=\"path:href, download:download\">\n\t<div>\n\t\t<span data-bge=\"name\">サンプルダウンロードファイル</span>\n\t\t<span data-bge=\"formated-size, size:data-size\" data-size=\"138158\">134.92kB</span>\n\t</div>\n</a>\n";
1365
1365
 
1366
1366
  var downloadFile = createItem$1({
1367
- version: "4.0.0-alpha.33",
1367
+ version: "4.0.0-alpha.39",
1368
1368
  name: "download-file",
1369
1369
  template: template$9,
1370
1370
  style: style$9,
@@ -1403,7 +1403,7 @@ var style$8 = "[data-bgi='google-maps'] {\n\tdiv {\n\t\tinline-size: 100%;\n\t\t
1403
1403
  var template$8 = "<div data-lat=\"35.681382\" data-lng=\"139.766084\" data-zoom=\"16\" data-bge=\"lat:data-lat, lng:data-lng, zoom:data-zoom\">\n\t<img data-bge=\"img:src\" src=\"https://maps.google.com/maps/api/staticmap?center=35.681382,139.766084&amp;zoom=16&amp;size=640x400&amp;markers=color:red|color:red|35.681382,139.766084&amp;scale=2&amp;key=%googleMapsApiKey%\" width=\"8\" height=\"5\" alt=\"Google Maps\" />\n</div>\n<a href=\"https://maps.apple.com/?q=35.681382,139.766084\" data-bge=\"url:href\" target=\"_blank\"><span>アプリで開く</span></a>\n";
1404
1404
 
1405
1405
  var googleMaps = createItem$1({
1406
- version: "4.0.0-alpha.33",
1406
+ version: "4.0.0-alpha.39",
1407
1407
  name: "google-maps",
1408
1408
  template: template$8,
1409
1409
  style: style$8,
@@ -1538,7 +1538,7 @@ var style$7 = "[data-bgi='hr'] {\n\t--inline-size: 100%;\n\t--border-color: #000
1538
1538
  var template$7 = "<div data-bgi-hr-kind=\"primary\" data-bge=\"kind:data-bgi-hr-kind\">\n\t<hr />\n</div>\n";
1539
1539
 
1540
1540
  var hr = createItem$1({
1541
- version: "4.0.0-alpha.33",
1541
+ version: "4.0.0-alpha.39",
1542
1542
  name: "hr",
1543
1543
  template: template$7,
1544
1544
  style: style$7,
@@ -1628,7 +1628,7 @@ function createWidthState() {
1628
1628
 
1629
1629
  const ORIGIN = "__org";
1630
1630
  var image = createItem$1({
1631
- version: "4.0.0-alpha.33",
1631
+ version: "4.0.0-alpha.39",
1632
1632
  name: "image",
1633
1633
  template: template$6,
1634
1634
  style: style$6,
@@ -1826,7 +1826,7 @@ var style$5 = "[data-bgi='import'] {\n\tbge-import {\n\t\t&::before {\n\t\t\tfon
1826
1826
  var template$5 = "<bge-import data-bge=\":src\" src=\"\"></bge-import>\n";
1827
1827
 
1828
1828
  var importItem = createItem$1({
1829
- version: "4.0.0-alpha.33",
1829
+ version: "4.0.0-alpha.39",
1830
1830
  name: "import",
1831
1831
  template: template$5,
1832
1832
  style: style$5,
@@ -1840,7 +1840,7 @@ var style$4 = "/* No Styling */\n";
1840
1840
  var template$4 = "<div data-bge=\":scrollable\" data-bge-scrollable=\"false\">\n\t<table>\n\t\t<caption data-bge=\"caption\">\n\t\t\tキャプションを入力してください\n\t\t</caption>\n\t\t<tbody data-bge-list>\n\t\t\t<tr>\n\t\t\t\t<th data-bge=\"th\">表組の見出し</th>\n\t\t\t\t<td data-bge=\"td\">表組の内容を入力してください</td>\n\t\t\t</tr>\n\t\t</tbody>\n\t</table>\n</div>\n";
1841
1841
 
1842
1842
  var table = createItem$1({
1843
- version: "4.0.0-alpha.33",
1843
+ version: "4.0.0-alpha.39",
1844
1844
  name: "table",
1845
1845
  template: template$4,
1846
1846
  style: style$4,
@@ -1868,7 +1868,7 @@ var style$3 = "/* No Styling */\n";
1868
1868
  var template$3 = "<h2 data-bge=\"title-h2\">見出しを入力してください</h2>\n";
1869
1869
 
1870
1870
  var titleH2 = createItem$1({
1871
- version: "4.0.0-alpha.33",
1871
+ version: "4.0.0-alpha.39",
1872
1872
  name: "title-h2",
1873
1873
  template: template$3,
1874
1874
  style: style$3,
@@ -1882,7 +1882,7 @@ var style$2 = "/* No Styling */\n";
1882
1882
  var template$2 = "<h3 data-bge=\"title-h3\">見出しを入力してください</h3>\n";
1883
1883
 
1884
1884
  var titleH3 = createItem$1({
1885
- version: "4.0.0-alpha.33",
1885
+ version: "4.0.0-alpha.39",
1886
1886
  name: "title-h3",
1887
1887
  template: template$2,
1888
1888
  style: style$2,
@@ -1896,7 +1896,7 @@ var style$1 = "/* No Styling */\n";
1896
1896
  var template$1 = "<div data-bge=\"wysiwyg\"><p>本文を入力してください</p></div>\n";
1897
1897
 
1898
1898
  var wysiwyg = createItem$1({
1899
- version: "4.0.0-alpha.33",
1899
+ version: "4.0.0-alpha.39",
1900
1900
  name: "wysiwyg",
1901
1901
  template: template$1,
1902
1902
  style: style$1,
@@ -1911,7 +1911,7 @@ var template = "<div data-id=\"3KtWfp0UopM\" data-title=\"YouTube動画\" data-w
1911
1911
 
1912
1912
  const FALLBACK_TITLE = "YouTube\u52D5\u753B";
1913
1913
  var youtube = createItem$1({
1914
- version: "4.0.0-alpha.33",
1914
+ version: "4.0.0-alpha.39",
1915
1915
  name: "youtube",
1916
1916
  template,
1917
1917
  style: style$c,
@@ -3373,6 +3373,68 @@ function shouldUseActiveX() {
3373
3373
  return useActiveX;
3374
3374
  }
3375
3375
  canParseHTMLNatively() ? root$c.DOMParser : createHTMLParser();
3376
+ function normalizeHtmlStructure(html1, html2) {
3377
+ const doc1 = new Range().createContextualFragment(html1);
3378
+ const doc2 = new Range().createContextualFragment(html2);
3379
+ return compareElements(doc1, doc2);
3380
+ }
3381
+ function compareElements(el1, el2) {
3382
+ const children1 = [...el1.children];
3383
+ const children2 = [...el2.children];
3384
+ if (children1.length !== children2.length) {
3385
+ return false;
3386
+ }
3387
+ if (children1.length === 0) {
3388
+ const text1 = normalizeText(el1.textContent ?? "");
3389
+ const text2 = normalizeText(el2.textContent ?? "");
3390
+ return text1 === text2;
3391
+ }
3392
+ for (const [i, child1] of children1.entries()) {
3393
+ const child2 = children2[i];
3394
+ if (!child1 || !child2 || !compareElementStructure(child1, child2)) {
3395
+ return false;
3396
+ }
3397
+ }
3398
+ return true;
3399
+ }
3400
+ function compareElementStructure(el1, el2) {
3401
+ if (el1.tagName !== el2.tagName) {
3402
+ return false;
3403
+ }
3404
+ const attrs1 = getNormalizedAttributes(el1);
3405
+ const attrs2 = getNormalizedAttributes(el2);
3406
+ if (!compareAttributes(attrs1, attrs2)) {
3407
+ return false;
3408
+ }
3409
+ return compareElements(el1, el2);
3410
+ }
3411
+ function getNormalizedAttributes(el) {
3412
+ const attrs = {};
3413
+ for (const attr of el.attributes) {
3414
+ attrs[attr.name] = attr.value;
3415
+ }
3416
+ return attrs;
3417
+ }
3418
+ function compareAttributes(attrs1, attrs2) {
3419
+ const keys1 = Object.keys(attrs1).sort();
3420
+ const keys2 = Object.keys(attrs2).sort();
3421
+ if (keys1.length !== keys2.length) {
3422
+ return false;
3423
+ }
3424
+ for (const [i, key1] of keys1.entries()) {
3425
+ const key2 = keys2[i];
3426
+ if (key1 !== key2) {
3427
+ return false;
3428
+ }
3429
+ if (attrs1[key1] !== attrs2[key2]) {
3430
+ return false;
3431
+ }
3432
+ }
3433
+ return true;
3434
+ }
3435
+ function normalizeText(text2) {
3436
+ return text2.replaceAll(/\s+/g, " ").trim();
3437
+ }
3376
3438
  function getDefaultExportFromCjs(x2) {
3377
3439
  return x2 && x2.__esModule && Object.prototype.hasOwnProperty.call(x2, "default") ? x2["default"] : x2;
3378
3440
  }
@@ -3681,6 +3743,16 @@ function formatByteSize(byteSize, digits = 2, autoFormat = true) {
3681
3743
  function formatDate(timestamp, format) {
3682
3744
  return dayjs.unix(timestamp).format(format);
3683
3745
  }
3746
+ function normalizeIndent(html2) {
3747
+ const trimmedHtml = html2.replace(/^(?:\r?\n)+/, "");
3748
+ const lines = trimmedHtml.split(/(?<=\r\n|\n|$)/);
3749
+ const firstLineIndent = lines[0]?.match(/^\s+/)?.[0] ?? "";
3750
+ if (firstLineIndent.length === 0) {
3751
+ return trimmedHtml.trimEnd();
3752
+ }
3753
+ const normalizedLines = lines.map((line) => line.replace(firstLineIndent, ""));
3754
+ return normalizedLines.join("").trimEnd();
3755
+ }
3684
3756
  const cache = /* @__PURE__ */ new Map();
3685
3757
  function parseFields(query) {
3686
3758
  const cached = cache.get(query);
@@ -3736,7 +3808,7 @@ function getValues(el, convertType = false, attr = "field", filter) {
3736
3808
  break;
3737
3809
  }
3738
3810
  case "html": {
3739
- value = el.innerHTML.trim();
3811
+ value = normalizeIndent(el.innerHTML);
3740
3812
  break;
3741
3813
  }
3742
3814
  case "style": {
@@ -3768,7 +3840,7 @@ function getValues(el, convertType = false, attr = "field", filter) {
3768
3840
  const val = el.value;
3769
3841
  value = convertType ? convert(val) : val;
3770
3842
  } else {
3771
- value = el.innerHTML.trim();
3843
+ value = normalizeIndent(el.innerHTML);
3772
3844
  }
3773
3845
  }
3774
3846
  if (filter) {
@@ -3921,15 +3993,21 @@ function sanitizeHtml(html2) {
3921
3993
  const regex = new RegExp(`<${tagName}[^>]*>(.*?)<\\/${tagName}>`, "gis");
3922
3994
  sanitized = sanitized.replace(regex, "$1");
3923
3995
  }
3924
- const doc2 = new DOMParser().parseFromString(sanitized, "text/html");
3925
- const body = doc2.body;
3926
- sanitizeElementAndChildren(body);
3927
- return body.innerHTML;
3996
+ const fragment = new Range().createContextualFragment(sanitized);
3997
+ sanitizeElementAndChildren(fragment);
3998
+ const newHtml = [...fragment.childNodes].map((node) => {
3999
+ if (node instanceof Element) {
4000
+ return node.outerHTML;
4001
+ }
4002
+ return node.textContent ?? node.nodeValue ?? "";
4003
+ }).join("");
4004
+ return newHtml;
3928
4005
  }
3929
- function sanitizeElementAndChildren(element2) {
3930
- sanitizeAttributes(element2);
3931
- const children = element2.children;
3932
- for (const child2 of children) {
4006
+ function sanitizeElementAndChildren(node) {
4007
+ if (node instanceof Element) {
4008
+ sanitizeAttributes(node);
4009
+ }
4010
+ for (const child2 of node.childNodes) {
3933
4011
  sanitizeElementAndChildren(child2);
3934
4012
  }
3935
4013
  }
@@ -20594,6 +20672,35 @@ function isNodeEmpty(node, {
20594
20672
  function isNodeSelection(value) {
20595
20673
  return value instanceof NodeSelection;
20596
20674
  }
20675
+ var MappablePosition = class _MappablePosition {
20676
+ constructor(position) {
20677
+ this.position = position;
20678
+ }
20679
+ /**
20680
+ * Creates a MappablePosition from a JSON object.
20681
+ */
20682
+ static fromJSON(json) {
20683
+ return new _MappablePosition(json.position);
20684
+ }
20685
+ /**
20686
+ * Converts the MappablePosition to a JSON object.
20687
+ */
20688
+ toJSON() {
20689
+ return {
20690
+ position: this.position
20691
+ };
20692
+ }
20693
+ };
20694
+ function getUpdatedPosition(position, transaction) {
20695
+ const mapResult = transaction.mapping.mapResult(position.position);
20696
+ return {
20697
+ position: new MappablePosition(mapResult.pos),
20698
+ mapResult
20699
+ };
20700
+ }
20701
+ function createMappablePosition(position) {
20702
+ return new MappablePosition(position);
20703
+ }
20597
20704
  function canSetMark(state2, tr2, newMarkType) {
20598
20705
  var _a2;
20599
20706
  const { selection } = tr2;
@@ -22723,6 +22830,10 @@ var Editor = class extends EventEmitter {
22723
22830
  };
22724
22831
  this.isCapturingTransaction = false;
22725
22832
  this.capturedTransaction = null;
22833
+ this.utils = {
22834
+ getUpdatedPosition,
22835
+ createMappablePosition
22836
+ };
22726
22837
  this.setOptions(options);
22727
22838
  this.createExtensionManager();
22728
22839
  this.createCommandManager();
@@ -23377,6 +23488,8 @@ var ResizableNodeView = class {
23377
23488
  this.startWidth = 0;
23378
23489
  this.startHeight = 0;
23379
23490
  this.isShiftKeyPressed = false;
23491
+ this.lastEditableState = void 0;
23492
+ this.handleMap = /* @__PURE__ */ new Map();
23380
23493
  this.handleMouseMove = (event2) => {
23381
23494
  if (!this.isResizing || !this.activeHandle) {
23382
23495
  return;
@@ -23425,8 +23538,9 @@ var ResizableNodeView = class {
23425
23538
  this.isShiftKeyPressed = false;
23426
23539
  }
23427
23540
  };
23428
- var _a2, _b, _c, _d, _e2;
23541
+ var _a2, _b, _c, _d, _e2, _f;
23429
23542
  this.node = options.node;
23543
+ this.editor = options.editor;
23430
23544
  this.element = options.element;
23431
23545
  this.contentElement = options.contentElement;
23432
23546
  this.getPos = options.getPos;
@@ -23456,10 +23570,14 @@ var ResizableNodeView = class {
23456
23570
  resizing: options.options.className.resizing || ""
23457
23571
  };
23458
23572
  }
23573
+ if ((_f = options.options) == null ? void 0 : _f.createCustomHandle) {
23574
+ this.createCustomHandle = options.options.createCustomHandle;
23575
+ }
23459
23576
  this.wrapper = this.createWrapper();
23460
23577
  this.container = this.createContainer();
23461
23578
  this.applyInitialSize();
23462
23579
  this.attachHandles();
23580
+ this.editor.on("update", this.handleEditorUpdate.bind(this));
23463
23581
  }
23464
23582
  /**
23465
23583
  * Returns the top-level DOM node that should be placed in the editor.
@@ -23475,6 +23593,18 @@ var ResizableNodeView = class {
23475
23593
  get contentDOM() {
23476
23594
  return this.contentElement;
23477
23595
  }
23596
+ handleEditorUpdate() {
23597
+ const isEditable = this.editor.isEditable;
23598
+ if (isEditable === this.lastEditableState) {
23599
+ return;
23600
+ }
23601
+ this.lastEditableState = isEditable;
23602
+ if (!isEditable) {
23603
+ this.removeHandles();
23604
+ } else if (isEditable && this.handleMap.size === 0) {
23605
+ this.attachHandles();
23606
+ }
23607
+ }
23478
23608
  /**
23479
23609
  * Called when the node's content or attributes change.
23480
23610
  *
@@ -23516,6 +23646,7 @@ var ResizableNodeView = class {
23516
23646
  this.isResizing = false;
23517
23647
  this.activeHandle = null;
23518
23648
  }
23649
+ this.editor.off("update", this.handleEditorUpdate.bind(this));
23519
23650
  this.container.remove();
23520
23651
  }
23521
23652
  /**
@@ -23532,8 +23663,6 @@ var ResizableNodeView = class {
23532
23663
  element2.dataset.resizeContainer = "";
23533
23664
  element2.dataset.node = this.node.type.name;
23534
23665
  element2.style.display = "flex";
23535
- element2.style.justifyContent = "flex-start";
23536
- element2.style.alignItems = "flex-start";
23537
23666
  if (this.classNames.container) {
23538
23667
  element2.className = this.classNames.container;
23539
23668
  }
@@ -23621,13 +23750,36 @@ var ResizableNodeView = class {
23621
23750
  */
23622
23751
  attachHandles() {
23623
23752
  this.directions.forEach((direction) => {
23624
- const handle = this.createHandle(direction);
23625
- this.positionHandle(handle, direction);
23753
+ let handle;
23754
+ if (this.createCustomHandle) {
23755
+ handle = this.createCustomHandle(direction);
23756
+ } else {
23757
+ handle = this.createHandle(direction);
23758
+ }
23759
+ if (!(handle instanceof HTMLElement)) {
23760
+ console.warn(
23761
+ `[ResizableNodeView] createCustomHandle("${direction}") did not return an HTMLElement. Falling back to default handle.`
23762
+ );
23763
+ handle = this.createHandle(direction);
23764
+ }
23765
+ if (!this.createCustomHandle) {
23766
+ this.positionHandle(handle, direction);
23767
+ }
23626
23768
  handle.addEventListener("mousedown", (event2) => this.handleResizeStart(event2, direction));
23627
23769
  handle.addEventListener("touchstart", (event2) => this.handleResizeStart(event2, direction));
23770
+ this.handleMap.set(direction, handle);
23628
23771
  this.wrapper.appendChild(handle);
23629
23772
  });
23630
23773
  }
23774
+ /**
23775
+ * Removes all resize handles from the wrapper.
23776
+ *
23777
+ * Cleans up the handle map and removes each handle element from the DOM.
23778
+ */
23779
+ removeHandles() {
23780
+ this.handleMap.forEach((el) => el.remove());
23781
+ this.handleMap.clear();
23782
+ }
23631
23783
  /**
23632
23784
  * Applies initial sizing from node attributes to the element.
23633
23785
  *
@@ -24148,9 +24300,15 @@ function createInlineMarkdownSpec(options) {
24148
24300
  return attrs;
24149
24301
  }
24150
24302
  const filtered = {};
24151
- allowedAttributes.forEach((key) => {
24152
- if (key in attrs) {
24153
- filtered[key] = attrs[key];
24303
+ allowedAttributes.forEach((attr) => {
24304
+ const attrName = typeof attr === "string" ? attr : attr.name;
24305
+ const skipIfDefault = typeof attr === "string" ? void 0 : attr.skipIfDefault;
24306
+ if (attrName in attrs) {
24307
+ const value = attrs[attrName];
24308
+ if (skipIfDefault !== void 0 && value === skipIfDefault) {
24309
+ return;
24310
+ }
24311
+ filtered[attrName] = value;
24154
24312
  }
24155
24313
  });
24156
24314
  return filtered;
@@ -26505,32 +26663,36 @@ function clickHandler(options) {
26505
26663
  if (!view.editable) {
26506
26664
  return false;
26507
26665
  }
26508
- let link2 = null;
26509
- if (event2.target instanceof HTMLAnchorElement) {
26510
- link2 = event2.target;
26511
- } else {
26512
- let a = event2.target;
26513
- const els = [];
26514
- while (a.nodeName !== "DIV") {
26515
- els.push(a);
26516
- a = a.parentNode;
26517
- }
26518
- link2 = els.find((value) => value.nodeName === "A");
26519
- }
26520
- if (!link2) {
26521
- return false;
26522
- }
26523
- const attrs = getAttributes(view.state, options.type.name);
26524
- const href = (_a2 = link2 == null ? void 0 : link2.href) != null ? _a2 : attrs.href;
26525
- const target = (_b = link2 == null ? void 0 : link2.target) != null ? _b : attrs.target;
26666
+ let handled = false;
26526
26667
  if (options.enableClickSelection) {
26527
- options.editor.commands.extendMarkRange(options.type.name);
26668
+ const commandResult = options.editor.commands.extendMarkRange(options.type.name);
26669
+ handled = commandResult;
26528
26670
  }
26529
- if (link2 && href) {
26530
- window.open(href, target);
26531
- return true;
26671
+ if (options.openOnClick) {
26672
+ let link2 = null;
26673
+ if (event2.target instanceof HTMLAnchorElement) {
26674
+ link2 = event2.target;
26675
+ } else {
26676
+ let a = event2.target;
26677
+ const els = [];
26678
+ while (a.nodeName !== "DIV") {
26679
+ els.push(a);
26680
+ a = a.parentNode;
26681
+ }
26682
+ link2 = els.find((value) => value.nodeName === "A");
26683
+ }
26684
+ if (!link2) {
26685
+ return handled;
26686
+ }
26687
+ const attrs = getAttributes(view.state, options.type.name);
26688
+ const href = (_a2 = link2 == null ? void 0 : link2.href) != null ? _a2 : attrs.href;
26689
+ const target = (_b = link2 == null ? void 0 : link2.target) != null ? _b : attrs.target;
26690
+ if (link2 && href) {
26691
+ window.open(href, target);
26692
+ handled = true;
26693
+ }
26532
26694
  }
26533
- return false;
26695
+ return handled;
26534
26696
  }
26535
26697
  }
26536
26698
  });
@@ -26771,15 +26933,14 @@ var Link = Mark2.create({
26771
26933
  })
26772
26934
  );
26773
26935
  }
26774
- if (this.options.openOnClick === true) {
26775
- plugins.push(
26776
- clickHandler({
26777
- type: this.type,
26778
- editor: this.editor,
26779
- enableClickSelection: this.options.enableClickSelection
26780
- })
26781
- );
26782
- }
26936
+ plugins.push(
26937
+ clickHandler({
26938
+ type: this.type,
26939
+ editor: this.editor,
26940
+ openOnClick: this.options.openOnClick === "whenNotEditable" ? true : this.options.openOnClick,
26941
+ enableClickSelection: this.options.enableClickSelection
26942
+ })
26943
+ );
26783
26944
  if (this.options.linkOnPaste) {
26784
26945
  plugins.push(
26785
26946
  pasteHandler({
@@ -29339,11 +29500,11 @@ var Image$2 = Node3.create({
29339
29500
  return title ? `![${alt}](${src} "${title}")` : `![${alt}](${src})`;
29340
29501
  },
29341
29502
  addNodeView() {
29342
- if (!this.options.resize || !this.options.resize.enabled || typeof document === "undefined" || !this.editor.isEditable) {
29503
+ if (!this.options.resize || !this.options.resize.enabled || typeof document === "undefined") {
29343
29504
  return null;
29344
29505
  }
29345
29506
  const { directions, minWidth, minHeight, alwaysPreserveAspectRatio } = this.options.resize;
29346
- return ({ node, getPos, HTMLAttributes }) => {
29507
+ return ({ node, getPos, HTMLAttributes, editor }) => {
29347
29508
  const el = document.createElement("img");
29348
29509
  Object.entries(HTMLAttributes).forEach(([key, value]) => {
29349
29510
  if (value != null) {
@@ -29360,6 +29521,7 @@ var Image$2 = Node3.create({
29360
29521
  el.src = HTMLAttributes.src;
29361
29522
  const nodeView = new ResizableNodeView({
29362
29523
  element: el,
29524
+ editor,
29363
29525
  node,
29364
29526
  getPos,
29365
29527
  onResize: (width, height) => {
@@ -32482,7 +32644,7 @@ var __privateGet$1 = (obj, member, getter) => (__accessCheck$1(obj, member, "rea
32482
32644
  var __privateAdd$1 = (obj, member, value) => member.has(obj) ? __typeError$1("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
32483
32645
  var __privateSet$1 = (obj, member, value, setter) => (__accessCheck$1(obj, member, "write to private field"), member.set(obj, value), value);
32484
32646
  var __privateMethod = (obj, member, method) => (__accessCheck$1(obj, member, "access private method"), method);
32485
- var _editor, _editorRoot, _previewStyle, _textarea, _textareaDescriptor, _BgeWysiwygElement_instances, setToTextarea_fn, transaction_fn;
32647
+ var _editor, _editorRoot, _hasStructureChange, _isExpectingHTML, _isInitializing, _previewStyle, _structureChangeMessage, _textarea, _textareaDescriptor, _BgeWysiwygElement_instances, checkStructureChange_fn, setStructureChange_fn, setToTextarea_fn, transaction_fn, updateStructureChangeMessage_fn;
32486
32648
  function defineBgeWysiwygElement(options, global = window) {
32487
32649
  if (options?.extensions) {
32488
32650
  BgeWysiwygElement.extensions = options.extensions;
@@ -32501,7 +32663,11 @@ const _BgeWysiwygElement = class _BgeWysiwygElement2 extends HTMLElement {
32501
32663
  __privateAdd$1(this, _BgeWysiwygElement_instances);
32502
32664
  __privateAdd$1(this, _editor, null);
32503
32665
  __privateAdd$1(this, _editorRoot, null);
32666
+ __privateAdd$1(this, _hasStructureChange, false);
32667
+ __privateAdd$1(this, _isExpectingHTML, false);
32668
+ __privateAdd$1(this, _isInitializing, true);
32504
32669
  __privateAdd$1(this, _previewStyle, null);
32670
+ __privateAdd$1(this, _structureChangeMessage, null);
32505
32671
  __privateAdd$1(this, _textarea, null);
32506
32672
  __privateAdd$1(this, _textareaDescriptor, null);
32507
32673
  this.attachShadow({ mode: "open" });
@@ -32510,40 +32676,87 @@ const _BgeWysiwygElement = class _BgeWysiwygElement2 extends HTMLElement {
32510
32676
  }
32511
32677
  }
32512
32678
  get value() {
32513
- return __privateGet$1(this, _textarea)?.value ?? "";
32679
+ if (!__privateGet$1(this, _textarea)) {
32680
+ throw new ReferenceError("<bge-wysiwyg> is not connected");
32681
+ }
32682
+ if (this.mode === "wysiwyg") {
32683
+ if (!__privateGet$1(this, _editor)) {
32684
+ throw new ReferenceError("<bge-wysiwyg> is not connected");
32685
+ }
32686
+ let html2 = __privateGet$1(this, _editor).getHTML();
32687
+ html2 = html2.replaceAll("<p></p>", "");
32688
+ return html2;
32689
+ }
32690
+ return __privateGet$1(this, _textarea).value;
32514
32691
  }
32515
32692
  set value(value) {
32516
32693
  if (!__privateGet$1(this, _textarea)) {
32517
32694
  throw new ReferenceError("<bge-wysiwyg> is not connected");
32518
32695
  }
32696
+ if (this.mode === "html") {
32697
+ __privateGet$1(this, _textareaDescriptor)?.set?.call(__privateGet$1(this, _textarea), value);
32698
+ return;
32699
+ }
32700
+ const isFirstValueSet = !__privateGet$1(this, _textarea).value || __privateGet$1(this, _textarea).value.trim() === "";
32701
+ const shouldCheckStructure = (__privateGet$1(this, _isInitializing) || isFirstValueSet) && __privateGet$1(this, _editor) && value;
32702
+ if (shouldCheckStructure) {
32703
+ const expectedHTML = this.expectHTML(value);
32704
+ const isStructureSame = normalizeHtmlStructure(value, expectedHTML);
32705
+ if (!isStructureSame) {
32706
+ __privateGet$1(this, _textareaDescriptor)?.set?.call(__privateGet$1(this, _textarea), value);
32707
+ this.shadowRoot.querySelector(`[data-bge-mode]`)?.setAttribute(
32708
+ "data-bge-mode",
32709
+ "html"
32710
+ );
32711
+ __privateMethod(this, _BgeWysiwygElement_instances, setStructureChange_fn).call(this, true);
32712
+ return;
32713
+ }
32714
+ }
32519
32715
  __privateGet$1(this, _textarea).value = value;
32520
32716
  }
32521
- get editor() {
32522
- if (!__privateGet$1(this, _editor)) {
32523
- throw new ReferenceError("<bge-wysiwyg> is not connected");
32524
- }
32525
- return __privateGet$1(this, _editor);
32717
+ get mode() {
32718
+ const modeAttr = this.shadowRoot?.querySelector(`[data-bge-mode]`)?.getAttribute("data-bge-mode");
32719
+ return modeAttr === "html" ? "html" : "wysiwyg";
32526
32720
  }
32527
32721
  set mode(mode) {
32528
32722
  if (!__privateGet$1(this, _editor) || !__privateGet$1(this, _textarea)) {
32529
32723
  return;
32530
32724
  }
32725
+ if (mode === "wysiwyg" && this.mode === "html" && __privateMethod(this, _BgeWysiwygElement_instances, checkStructureChange_fn).call(this)) {
32726
+ __privateMethod(this, _BgeWysiwygElement_instances, setStructureChange_fn).call(this, true);
32727
+ return;
32728
+ }
32531
32729
  this.shadowRoot.querySelector(`[data-bge-mode]`)?.setAttribute(
32532
32730
  "data-bge-mode",
32533
32731
  mode
32534
32732
  );
32535
32733
  if (mode === "wysiwyg") {
32536
32734
  __privateGet$1(this, _editor).commands.setContent(__privateGet$1(this, _textarea).value);
32735
+ __privateMethod(this, _BgeWysiwygElement_instances, setStructureChange_fn).call(this, false);
32736
+ } else if (!__privateGet$1(this, _isInitializing)) {
32737
+ __privateMethod(this, _BgeWysiwygElement_instances, setStructureChange_fn).call(this, __privateMethod(this, _BgeWysiwygElement_instances, checkStructureChange_fn).call(this));
32537
32738
  }
32739
+ __privateMethod(this, _BgeWysiwygElement_instances, updateStructureChangeMessage_fn).call(this);
32740
+ }
32741
+ get editor() {
32742
+ if (!__privateGet$1(this, _editor)) {
32743
+ throw new ReferenceError("<bge-wysiwyg> is not connected");
32744
+ }
32745
+ return __privateGet$1(this, _editor);
32746
+ }
32747
+ get hasStructureChange() {
32748
+ return __privateGet$1(this, _hasStructureChange);
32538
32749
  }
32539
32750
  connectedCallback() {
32540
32751
  if (!this.shadowRoot) {
32541
32752
  throw new Error("Not supported shadow DOM");
32542
32753
  }
32543
- const initialValue = this.innerHTML.trim();
32754
+ const initialValue = this.innerHTML;
32544
32755
  const label = this.getAttribute("label") ?? "内容";
32545
32756
  const itemName = this.getAttribute("item-name");
32546
- this.shadowRoot.innerHTML = `<div data-bge-mode="wysiwyg"><iframe></iframe><textarea aria-label="${label} HTML"></textarea></div>`;
32757
+ const messageId = `bge-structure-change-message-${Math.random().toString(36).slice(2, 11)}`;
32758
+ const structureChangeMessage = "HTMLの構造がWYSIWYG(デザイン)モードに対応していません。HTMLモードのみで編集可能です。";
32759
+ this.shadowRoot.innerHTML = `<div data-bge-mode="wysiwyg"><iframe></iframe><textarea aria-label="${label} HTML" aria-describedby="${messageId}"></textarea><div id="${messageId}" role="alert" aria-live="polite" style="display: none;">${structureChangeMessage}</div></div>`;
32547
32760
  const preview = this.shadowRoot.querySelector("iframe");
32548
32761
  if (!preview || !preview.contentWindow || !preview.contentDocument) {
32549
32762
  throw new Error("Not supported iframe in shadow DOM");
@@ -32589,6 +32802,16 @@ const _BgeWysiwygElement = class _BgeWysiwygElement2 extends HTMLElement {
32589
32802
  [data-bge-mode="html"] iframe {
32590
32803
  display: none;
32591
32804
  }
32805
+
32806
+ [role="alert"] {
32807
+ margin-block-start: 0.5rem;
32808
+ padding: 0.5rem;
32809
+ background-color: var(--bge-error-color, #fee);
32810
+ border: 1px solid var(--bge-error-border-color, #fcc);
32811
+ border-radius: var(--border-radius);
32812
+ color: var(--bge-error-text-color, #c00);
32813
+ font-size: 0.875rem;
32814
+ }
32592
32815
  `;
32593
32816
  preview.contentDocument.body.addEventListener("focusin", () => {
32594
32817
  preview.dataset.focusWithin = "true";
@@ -32608,6 +32831,9 @@ const _BgeWysiwygElement = class _BgeWysiwygElement2 extends HTMLElement {
32608
32831
  throw new Error("Not supported textarea in shadow DOM");
32609
32832
  }
32610
32833
  __privateSet$1(this, _textarea, textarea);
32834
+ __privateSet$1(this, _structureChangeMessage, this.shadowRoot.querySelector(
32835
+ `#${messageId}`
32836
+ ));
32611
32837
  const extensions = [
32612
32838
  index_default.configure({
32613
32839
  link: {
@@ -32656,8 +32882,46 @@ const _BgeWysiwygElement = class _BgeWysiwygElement2 extends HTMLElement {
32656
32882
  }
32657
32883
  });
32658
32884
  if (initialValue) {
32659
- __privateGet$1(this, _textarea).value = initialValue;
32885
+ const expectedHTML = this.expectHTML(initialValue);
32886
+ const isStructureSame = normalizeHtmlStructure(initialValue, expectedHTML);
32887
+ if (isStructureSame) {
32888
+ __privateGet$1(this, _textarea).value = initialValue;
32889
+ } else {
32890
+ __privateGet$1(this, _textareaDescriptor).set?.call(__privateGet$1(this, _textarea), initialValue);
32891
+ this.shadowRoot.querySelector(`[data-bge-mode]`)?.setAttribute("data-bge-mode", "html");
32892
+ __privateMethod(this, _BgeWysiwygElement_instances, setStructureChange_fn).call(this, true);
32893
+ }
32894
+ }
32895
+ __privateSet$1(this, _isInitializing, false);
32896
+ __privateGet$1(this, _textarea).addEventListener("blur", () => {
32897
+ if (this.mode !== "html") {
32898
+ return;
32899
+ }
32900
+ __privateMethod(this, _BgeWysiwygElement_instances, setStructureChange_fn).call(this, __privateMethod(this, _BgeWysiwygElement_instances, checkStructureChange_fn).call(this));
32901
+ });
32902
+ __privateGet$1(this, _textarea).addEventListener("input", () => {
32903
+ if (this.mode !== "html") {
32904
+ return;
32905
+ }
32906
+ __privateMethod(this, _BgeWysiwygElement_instances, setStructureChange_fn).call(this, __privateMethod(this, _BgeWysiwygElement_instances, checkStructureChange_fn).call(this));
32907
+ });
32908
+ }
32909
+ /**
32910
+ * tiptapのwysiwygが出力するであろうHTMLをレンダリングせずに文字列で返す
32911
+ * @param html 変換対象のHTML文字列
32912
+ * @returns 変換後のHTML文字列
32913
+ */
32914
+ expectHTML(html2) {
32915
+ if (!__privateGet$1(this, _editor)) {
32916
+ throw new ReferenceError("<bge-wysiwyg> is not connected");
32660
32917
  }
32918
+ const originalContent = __privateGet$1(this, _editor).getHTML();
32919
+ __privateSet$1(this, _isExpectingHTML, true);
32920
+ __privateGet$1(this, _editor).commands.setContent(html2);
32921
+ const result = __privateGet$1(this, _editor).getHTML().replaceAll("<p></p>", "");
32922
+ __privateGet$1(this, _editor).commands.setContent(originalContent);
32923
+ __privateSet$1(this, _isExpectingHTML, false);
32924
+ return result;
32661
32925
  }
32662
32926
  isActive(name) {
32663
32927
  return this.editor.isActive(name) ?? false;
@@ -32698,6 +32962,12 @@ const _BgeWysiwygElement = class _BgeWysiwygElement2 extends HTMLElement {
32698
32962
  `;
32699
32963
  }
32700
32964
  syncWysiwygToTextarea() {
32965
+ if (__privateGet$1(this, _isExpectingHTML)) {
32966
+ return;
32967
+ }
32968
+ if (this.mode === "html") {
32969
+ return;
32970
+ }
32701
32971
  let html2 = this.editor.getHTML();
32702
32972
  html2 = html2.replaceAll("<p></p>", "");
32703
32973
  __privateMethod(this, _BgeWysiwygElement_instances, setToTextarea_fn).call(this, html2);
@@ -32744,10 +33014,36 @@ const _BgeWysiwygElement = class _BgeWysiwygElement2 extends HTMLElement {
32744
33014
  };
32745
33015
  _editor = /* @__PURE__ */ new WeakMap();
32746
33016
  _editorRoot = /* @__PURE__ */ new WeakMap();
33017
+ _hasStructureChange = /* @__PURE__ */ new WeakMap();
33018
+ _isExpectingHTML = /* @__PURE__ */ new WeakMap();
33019
+ _isInitializing = /* @__PURE__ */ new WeakMap();
32747
33020
  _previewStyle = /* @__PURE__ */ new WeakMap();
33021
+ _structureChangeMessage = /* @__PURE__ */ new WeakMap();
32748
33022
  _textarea = /* @__PURE__ */ new WeakMap();
32749
33023
  _textareaDescriptor = /* @__PURE__ */ new WeakMap();
32750
33024
  _BgeWysiwygElement_instances = /* @__PURE__ */ new WeakSet();
33025
+ checkStructureChange_fn = function() {
33026
+ if (!__privateGet$1(this, _editor) || !__privateGet$1(this, _textarea) || this.mode !== "html") {
33027
+ return false;
33028
+ }
33029
+ const expectedHTML = this.expectHTML(__privateGet$1(this, _textarea).value);
33030
+ const isStructureSame = normalizeHtmlStructure(__privateGet$1(this, _textarea).value, expectedHTML);
33031
+ return !isStructureSame;
33032
+ };
33033
+ setStructureChange_fn = function(hasChange) {
33034
+ if (__privateGet$1(this, _hasStructureChange) === hasChange) {
33035
+ return;
33036
+ }
33037
+ __privateSet$1(this, _hasStructureChange, hasChange);
33038
+ __privateMethod(this, _BgeWysiwygElement_instances, updateStructureChangeMessage_fn).call(this);
33039
+ this.dispatchEvent(
33040
+ new CustomEvent("bge:structure-change", {
33041
+ detail: { hasStructureChange: hasChange },
33042
+ bubbles: true,
33043
+ composed: true
33044
+ })
33045
+ );
33046
+ };
32751
33047
  setToTextarea_fn = function(html2) {
32752
33048
  if (!__privateGet$1(this, _textarea) || !__privateGet$1(this, _textareaDescriptor)) {
32753
33049
  throw new ReferenceError("<bge-wysiwyg> is not connected");
@@ -32837,6 +33133,16 @@ transaction_fn = function(editor) {
32837
33133
  };
32838
33134
  return data;
32839
33135
  };
33136
+ updateStructureChangeMessage_fn = function() {
33137
+ if (!__privateGet$1(this, _structureChangeMessage)) {
33138
+ return;
33139
+ }
33140
+ if (this.mode === "html" && __privateGet$1(this, _hasStructureChange)) {
33141
+ __privateGet$1(this, _structureChangeMessage).style.display = "block";
33142
+ } else {
33143
+ __privateGet$1(this, _structureChangeMessage).style.display = "none";
33144
+ }
33145
+ };
32840
33146
  __publicField$1(_BgeWysiwygElement, "extensions", null);
32841
33147
  __publicField$1(_BgeWysiwygElement, "wrapperElement", null);
32842
33148
  let BgeWysiwygElement = _BgeWysiwygElement;
@@ -32961,13 +33267,28 @@ const _BgeWysiwygEditorElement = class _BgeWysiwygEditorElement2 extends HTMLEle
32961
33267
  const htmlModeButton = this.querySelector(
32962
33268
  '[data-bge-toolbar-button="html-mode"]'
32963
33269
  );
33270
+ __privateGet(this, _wysiwygElement).addEventListener("bge:structure-change", (event2) => {
33271
+ const hasStructureChange = event2.detail.hasStructureChange;
33272
+ const isHtmlMode = __privateGet(this, _wysiwygElement)?.mode === "html";
33273
+ htmlModeButton.disabled = isHtmlMode && hasStructureChange;
33274
+ });
33275
+ const initialHasStructureChange = __privateGet(this, _wysiwygElement).hasStructureChange;
33276
+ const initialIsHtmlMode = __privateGet(this, _wysiwygElement).mode === "html";
33277
+ htmlModeButton.disabled = initialIsHtmlMode && initialHasStructureChange;
32964
33278
  htmlModeButton.addEventListener("click", () => {
32965
- htmlModeButton.ariaPressed = htmlModeButton.ariaPressed === "true" ? "false" : "true";
32966
- const mode = htmlModeButton.ariaPressed === "true" ? "html" : "wysiwyg";
32967
33279
  if (!__privateGet(this, _wysiwygElement)) {
32968
33280
  throw new ReferenceError("<bge-wysiwyg-editor> is not connected");
32969
33281
  }
32970
- __privateGet(this, _wysiwygElement).mode = mode;
33282
+ const currentMode = __privateGet(this, _wysiwygElement).mode;
33283
+ const newMode = currentMode === "html" ? "wysiwyg" : "html";
33284
+ htmlModeButton.ariaPressed = newMode === "html" ? "true" : "false";
33285
+ __privateGet(this, _wysiwygElement).mode = newMode;
33286
+ if (__privateGet(this, _wysiwygElement).mode === newMode) {
33287
+ const hasStructureChange = __privateGet(this, _wysiwygElement).hasStructureChange;
33288
+ htmlModeButton.disabled = newMode === "html" && hasStructureChange;
33289
+ } else {
33290
+ htmlModeButton.ariaPressed = currentMode === "html" ? "true" : "false";
33291
+ }
32971
33292
  });
32972
33293
  }
32973
33294
  setStyle(css) {
@@ -33280,6 +33601,7 @@ const EAGER_EFFECT = 1 << 17;
33280
33601
  const HEAD_EFFECT = 1 << 18;
33281
33602
  const EFFECT_PRESERVED = 1 << 19;
33282
33603
  const USER_EFFECT = 1 << 20;
33604
+ const EFFECT_OFFSCREEN = 1 << 25;
33283
33605
  const WAS_MARKED = 1 << 15;
33284
33606
  const REACTION_IS_UPDATING = 1 << 21;
33285
33607
  const ASYNC = 1 << 22;
@@ -33867,7 +34189,7 @@ function flush_queued_effects(effects) {
33867
34189
  if ((effect2.f & (DESTROYED | INERT)) === 0 && is_dirty(effect2)) {
33868
34190
  eager_block_effects = /* @__PURE__ */ new Set();
33869
34191
  update_effect(effect2);
33870
- if (effect2.deps === null && effect2.first === null && effect2.nodes_start === null) {
34192
+ if (effect2.deps === null && effect2.first === null && effect2.nodes === null) {
33871
34193
  if (effect2.teardown === null && effect2.ac === null) {
33872
34194
  unlink_effect(effect2);
33873
34195
  } else {
@@ -34291,375 +34613,6 @@ class Boundary {
34291
34613
  }
34292
34614
  }
34293
34615
  }
34294
- function index(_2, i) {
34295
- return i;
34296
- }
34297
- function pause_effects(state2, to_destroy, controlled_anchor) {
34298
- var transitions = [];
34299
- var length = to_destroy.length;
34300
- for (var i = 0; i < length; i++) {
34301
- pause_children(to_destroy[i].e, transitions, true);
34302
- }
34303
- run_out_transitions(transitions, () => {
34304
- var fast_path = transitions.length === 0 && controlled_anchor !== null;
34305
- if (fast_path) {
34306
- var anchor = (
34307
- /** @type {Element} */
34308
- controlled_anchor
34309
- );
34310
- var parent_node = (
34311
- /** @type {Element} */
34312
- anchor.parentNode
34313
- );
34314
- clear_text_content(parent_node);
34315
- parent_node.append(anchor);
34316
- state2.items.clear();
34317
- link(state2, to_destroy[0].prev, to_destroy[length - 1].next);
34318
- }
34319
- for (var i2 = 0; i2 < length; i2++) {
34320
- var item = to_destroy[i2];
34321
- if (!fast_path) {
34322
- state2.items.delete(item.k);
34323
- link(state2, item.prev, item.next);
34324
- }
34325
- destroy_effect(item.e, !fast_path);
34326
- }
34327
- if (state2.first === to_destroy[0]) {
34328
- state2.first = to_destroy[0].prev;
34329
- }
34330
- });
34331
- }
34332
- function each(node, flags2, get_collection, get_key, render_fn, fallback_fn = null) {
34333
- var anchor = node;
34334
- var items = /* @__PURE__ */ new Map();
34335
- var first2 = null;
34336
- var is_controlled = (flags2 & EACH_IS_CONTROLLED) !== 0;
34337
- var is_reactive_value = (flags2 & EACH_ITEM_REACTIVE) !== 0;
34338
- var is_reactive_index = (flags2 & EACH_INDEX_REACTIVE) !== 0;
34339
- if (is_controlled) {
34340
- var parent_node = (
34341
- /** @type {Element} */
34342
- node
34343
- );
34344
- anchor = parent_node.appendChild(create_text());
34345
- }
34346
- var fallback = null;
34347
- var each_array = /* @__PURE__ */ derived_safe_equal(() => {
34348
- var collection = get_collection();
34349
- return is_array(collection) ? collection : collection == null ? [] : array_from(collection);
34350
- });
34351
- var array;
34352
- var first_run = true;
34353
- function commit() {
34354
- reconcile(state2, array, anchor, flags2, get_key);
34355
- if (fallback !== null) {
34356
- if (array.length === 0) {
34357
- if (fallback.fragment) {
34358
- anchor.before(fallback.fragment);
34359
- fallback.fragment = null;
34360
- } else {
34361
- resume_effect(fallback.effect);
34362
- }
34363
- effect2.first = fallback.effect;
34364
- } else {
34365
- pause_effect(fallback.effect, () => {
34366
- fallback = null;
34367
- });
34368
- }
34369
- }
34370
- }
34371
- var effect2 = block(() => {
34372
- array = /** @type {V[]} */
34373
- get2(each_array);
34374
- var length = array.length;
34375
- var keys2 = /* @__PURE__ */ new Set();
34376
- var prev = null;
34377
- for (var i = 0; i < length; i += 1) {
34378
- var value = array[i];
34379
- var key = get_key(value, i);
34380
- var item = first_run ? null : items.get(key);
34381
- if (item) {
34382
- if (is_reactive_value) {
34383
- internal_set(item.v, value);
34384
- }
34385
- if (is_reactive_index) {
34386
- internal_set(
34387
- /** @type {Value<number>} */
34388
- item.i,
34389
- i
34390
- );
34391
- } else {
34392
- item.i = i;
34393
- }
34394
- } else {
34395
- item = create_item(
34396
- first_run ? anchor : null,
34397
- prev,
34398
- value,
34399
- key,
34400
- i,
34401
- render_fn,
34402
- flags2,
34403
- get_collection
34404
- );
34405
- if (first_run) {
34406
- item.o = true;
34407
- if (prev === null) {
34408
- first2 = item;
34409
- } else {
34410
- prev.next = item;
34411
- }
34412
- prev = item;
34413
- }
34414
- items.set(key, item);
34415
- }
34416
- keys2.add(key);
34417
- }
34418
- if (length === 0 && fallback_fn && !fallback) {
34419
- if (first_run) {
34420
- fallback = {
34421
- fragment: null,
34422
- effect: branch(() => fallback_fn(anchor))
34423
- };
34424
- } else {
34425
- var fragment = document.createDocumentFragment();
34426
- var target = create_text();
34427
- fragment.append(target);
34428
- fallback = {
34429
- fragment,
34430
- effect: branch(() => fallback_fn(target))
34431
- };
34432
- }
34433
- }
34434
- if (!first_run) {
34435
- {
34436
- commit();
34437
- }
34438
- }
34439
- get2(each_array);
34440
- });
34441
- var state2 = { effect: effect2, items, first: first2 };
34442
- first_run = false;
34443
- }
34444
- function reconcile(state2, array, anchor, flags2, get_key) {
34445
- var is_animated = (flags2 & EACH_IS_ANIMATED) !== 0;
34446
- var length = array.length;
34447
- var items = state2.items;
34448
- var current = state2.first;
34449
- var seen;
34450
- var prev = null;
34451
- var to_animate;
34452
- var matched = [];
34453
- var stashed = [];
34454
- var value;
34455
- var key;
34456
- var item;
34457
- var i;
34458
- if (is_animated) {
34459
- for (i = 0; i < length; i += 1) {
34460
- value = array[i];
34461
- key = get_key(value, i);
34462
- item = /** @type {EachItem} */
34463
- items.get(key);
34464
- if (item.o) {
34465
- item.a?.measure();
34466
- (to_animate ??= /* @__PURE__ */ new Set()).add(item);
34467
- }
34468
- }
34469
- }
34470
- for (i = 0; i < length; i += 1) {
34471
- value = array[i];
34472
- key = get_key(value, i);
34473
- item = /** @type {EachItem} */
34474
- items.get(key);
34475
- state2.first ??= item;
34476
- if (!item.o) {
34477
- item.o = true;
34478
- var next = prev ? prev.next : current;
34479
- link(state2, prev, item);
34480
- link(state2, item, next);
34481
- move(item, next, anchor);
34482
- prev = item;
34483
- matched = [];
34484
- stashed = [];
34485
- current = prev.next;
34486
- continue;
34487
- }
34488
- if ((item.e.f & INERT) !== 0) {
34489
- resume_effect(item.e);
34490
- if (is_animated) {
34491
- item.a?.unfix();
34492
- (to_animate ??= /* @__PURE__ */ new Set()).delete(item);
34493
- }
34494
- }
34495
- if (item !== current) {
34496
- if (seen !== void 0 && seen.has(item)) {
34497
- if (matched.length < stashed.length) {
34498
- var start = stashed[0];
34499
- var j2;
34500
- prev = start.prev;
34501
- var a = matched[0];
34502
- var b2 = matched[matched.length - 1];
34503
- for (j2 = 0; j2 < matched.length; j2 += 1) {
34504
- move(matched[j2], start, anchor);
34505
- }
34506
- for (j2 = 0; j2 < stashed.length; j2 += 1) {
34507
- seen.delete(stashed[j2]);
34508
- }
34509
- link(state2, a.prev, b2.next);
34510
- link(state2, prev, a);
34511
- link(state2, b2, start);
34512
- current = start;
34513
- prev = b2;
34514
- i -= 1;
34515
- matched = [];
34516
- stashed = [];
34517
- } else {
34518
- seen.delete(item);
34519
- move(item, current, anchor);
34520
- link(state2, item.prev, item.next);
34521
- link(state2, item, prev === null ? state2.first : prev.next);
34522
- link(state2, prev, item);
34523
- prev = item;
34524
- }
34525
- continue;
34526
- }
34527
- matched = [];
34528
- stashed = [];
34529
- while (current !== null && current.k !== key) {
34530
- if ((current.e.f & INERT) === 0) {
34531
- (seen ??= /* @__PURE__ */ new Set()).add(current);
34532
- }
34533
- stashed.push(current);
34534
- current = current.next;
34535
- }
34536
- if (current === null) {
34537
- continue;
34538
- }
34539
- item = current;
34540
- }
34541
- matched.push(item);
34542
- prev = item;
34543
- current = item.next;
34544
- }
34545
- let has_offscreen_items = items.size > length;
34546
- if (current !== null || seen !== void 0) {
34547
- var to_destroy = seen === void 0 ? [] : array_from(seen);
34548
- while (current !== null) {
34549
- if ((current.e.f & INERT) === 0) {
34550
- to_destroy.push(current);
34551
- }
34552
- current = current.next;
34553
- }
34554
- var destroy_length = to_destroy.length;
34555
- has_offscreen_items = items.size - destroy_length > length;
34556
- if (destroy_length > 0) {
34557
- var controlled_anchor = (flags2 & EACH_IS_CONTROLLED) !== 0 && length === 0 ? anchor : null;
34558
- if (is_animated) {
34559
- for (i = 0; i < destroy_length; i += 1) {
34560
- to_destroy[i].a?.measure();
34561
- }
34562
- for (i = 0; i < destroy_length; i += 1) {
34563
- to_destroy[i].a?.fix();
34564
- }
34565
- }
34566
- pause_effects(state2, to_destroy, controlled_anchor);
34567
- }
34568
- }
34569
- if (has_offscreen_items) {
34570
- for (const item2 of items.values()) {
34571
- if (!item2.o) {
34572
- link(state2, prev, item2);
34573
- prev = item2;
34574
- }
34575
- }
34576
- }
34577
- state2.effect.last = prev && prev.e;
34578
- if (is_animated) {
34579
- queue_micro_task(() => {
34580
- if (to_animate === void 0) return;
34581
- for (item of to_animate) {
34582
- item.a?.apply();
34583
- }
34584
- });
34585
- }
34586
- }
34587
- function create_item(anchor, prev, value, key, index2, render_fn, flags2, get_collection) {
34588
- var reactive = (flags2 & EACH_ITEM_REACTIVE) !== 0;
34589
- var mutable = (flags2 & EACH_ITEM_IMMUTABLE) === 0;
34590
- var v2 = reactive ? mutable ? /* @__PURE__ */ mutable_source(value, false, false) : source(value) : value;
34591
- var i = (flags2 & EACH_INDEX_REACTIVE) === 0 ? index2 : source(index2);
34592
- var item = {
34593
- i,
34594
- v: v2,
34595
- k: key,
34596
- a: null,
34597
- // @ts-expect-error
34598
- e: null,
34599
- o: false,
34600
- prev,
34601
- next: null
34602
- };
34603
- try {
34604
- if (anchor === null) {
34605
- var fragment = document.createDocumentFragment();
34606
- fragment.append(anchor = create_text());
34607
- }
34608
- item.e = branch(() => render_fn(
34609
- /** @type {Node} */
34610
- anchor,
34611
- v2,
34612
- i,
34613
- get_collection
34614
- ));
34615
- if (prev !== null) {
34616
- prev.next = item;
34617
- }
34618
- return item;
34619
- } finally {
34620
- }
34621
- }
34622
- function move(item, next, anchor) {
34623
- var end = item.next ? (
34624
- /** @type {TemplateNode} */
34625
- item.next.e.nodes_start
34626
- ) : anchor;
34627
- var dest = next ? (
34628
- /** @type {TemplateNode} */
34629
- next.e.nodes_start
34630
- ) : anchor;
34631
- var node = (
34632
- /** @type {TemplateNode} */
34633
- item.e.nodes_start
34634
- );
34635
- while (node !== null && node !== end) {
34636
- var next_node = (
34637
- /** @type {TemplateNode} */
34638
- /* @__PURE__ */ get_next_sibling(node)
34639
- );
34640
- dest.before(node);
34641
- node = next_node;
34642
- }
34643
- }
34644
- function link(state2, prev, next) {
34645
- if (prev === null) {
34646
- state2.first = next;
34647
- state2.effect.first = next && next.e;
34648
- } else {
34649
- if (prev.e.next) {
34650
- prev.e.next.prev = null;
34651
- }
34652
- prev.next = next;
34653
- prev.e.next = next && next.e;
34654
- }
34655
- if (next !== null) {
34656
- if (next.e.prev) {
34657
- next.e.prev.next = null;
34658
- }
34659
- next.prev = prev;
34660
- next.e.prev = prev && prev.e;
34661
- }
34662
- }
34663
34616
  function flatten(blockers, sync, async, fn) {
34664
34617
  const d2 = is_runes() ? derived : derived_safe_equal;
34665
34618
  if (async.length === 0 && blockers.length === 0) {
@@ -35297,26 +35250,26 @@ function create_text(value = "") {
35297
35250
  }
35298
35251
  // @__NO_SIDE_EFFECTS__
35299
35252
  function get_first_child(node) {
35300
- return first_child_getter.call(node);
35253
+ return (
35254
+ /** @type {TemplateNode | null} */
35255
+ first_child_getter.call(node)
35256
+ );
35301
35257
  }
35302
35258
  // @__NO_SIDE_EFFECTS__
35303
35259
  function get_next_sibling(node) {
35304
- return next_sibling_getter.call(node);
35260
+ return (
35261
+ /** @type {TemplateNode | null} */
35262
+ next_sibling_getter.call(node)
35263
+ );
35305
35264
  }
35306
35265
  function child(node, is_text) {
35307
35266
  {
35308
35267
  return /* @__PURE__ */ get_first_child(node);
35309
35268
  }
35310
35269
  }
35311
- function first_child(fragment, is_text = false) {
35270
+ function first_child(node, is_text = false) {
35312
35271
  {
35313
- var first2 = (
35314
- /** @type {DocumentFragment} */
35315
- /* @__PURE__ */ get_first_child(
35316
- /** @type {Node} */
35317
- fragment
35318
- )
35319
- );
35272
+ var first2 = /* @__PURE__ */ get_first_child(node);
35320
35273
  if (first2 instanceof Comment && first2.data === "") return /* @__PURE__ */ get_next_sibling(first2);
35321
35274
  return first2;
35322
35275
  }
@@ -35423,8 +35376,7 @@ function create_effect(type, fn, sync) {
35423
35376
  var effect2 = {
35424
35377
  ctx: component_context,
35425
35378
  deps: null,
35426
- nodes_start: null,
35427
- nodes_end: null,
35379
+ nodes: null,
35428
35380
  f: type | DIRTY | CONNECTED,
35429
35381
  first: null,
35430
35382
  fn,
@@ -35434,7 +35386,6 @@ function create_effect(type, fn, sync) {
35434
35386
  b: parent && parent.b,
35435
35387
  prev: null,
35436
35388
  teardown: null,
35437
- transitions: null,
35438
35389
  wv: 0,
35439
35390
  ac: null
35440
35391
  };
@@ -35450,7 +35401,7 @@ function create_effect(type, fn, sync) {
35450
35401
  schedule_effect(effect2);
35451
35402
  }
35452
35403
  var e = effect2;
35453
- if (sync && e.deps === null && e.teardown === null && e.nodes_start === null && e.first === e.last && // either `null`, or a singular child
35404
+ if (sync && e.deps === null && e.teardown === null && e.nodes === null && e.first === e.last && // either `null`, or a singular child
35454
35405
  (e.f & EFFECT_PRESERVED) === 0) {
35455
35406
  e = e.first;
35456
35407
  if ((type & BLOCK_EFFECT) !== 0 && (type & EFFECT_TRANSPARENT) !== 0 && e !== null) {
@@ -35626,18 +35577,18 @@ function destroy_block_effect_children(signal) {
35626
35577
  }
35627
35578
  function destroy_effect(effect2, remove_dom = true) {
35628
35579
  var removed = false;
35629
- if ((remove_dom || (effect2.f & HEAD_EFFECT) !== 0) && effect2.nodes_start !== null && effect2.nodes_end !== null) {
35580
+ if ((remove_dom || (effect2.f & HEAD_EFFECT) !== 0) && effect2.nodes !== null && effect2.nodes.end !== null) {
35630
35581
  remove_effect_dom(
35631
- effect2.nodes_start,
35582
+ effect2.nodes.start,
35632
35583
  /** @type {TemplateNode} */
35633
- effect2.nodes_end
35584
+ effect2.nodes.end
35634
35585
  );
35635
35586
  removed = true;
35636
35587
  }
35637
35588
  destroy_effect_children(effect2, remove_dom && !removed);
35638
35589
  remove_reactions(effect2, 0);
35639
35590
  set_signal_status(effect2, DESTROYED);
35640
- var transitions = effect2.transitions;
35591
+ var transitions = effect2.nodes && effect2.nodes.t;
35641
35592
  if (transitions !== null) {
35642
35593
  for (const transition of transitions) {
35643
35594
  transition.stop();
@@ -35648,14 +35599,11 @@ function destroy_effect(effect2, remove_dom = true) {
35648
35599
  if (parent !== null && parent.first !== null) {
35649
35600
  unlink_effect(effect2);
35650
35601
  }
35651
- effect2.next = effect2.prev = effect2.teardown = effect2.ctx = effect2.deps = effect2.fn = effect2.nodes_start = effect2.nodes_end = effect2.ac = null;
35602
+ effect2.next = effect2.prev = effect2.teardown = effect2.ctx = effect2.deps = effect2.fn = effect2.nodes = effect2.ac = null;
35652
35603
  }
35653
35604
  function remove_effect_dom(node, end) {
35654
35605
  while (node !== null) {
35655
- var next = node === end ? null : (
35656
- /** @type {TemplateNode} */
35657
- /* @__PURE__ */ get_next_sibling(node)
35658
- );
35606
+ var next = node === end ? null : /* @__PURE__ */ get_next_sibling(node);
35659
35607
  node.remove();
35660
35608
  node = next;
35661
35609
  }
@@ -35674,12 +35622,10 @@ function unlink_effect(effect2) {
35674
35622
  function pause_effect(effect2, callback, destroy = true) {
35675
35623
  var transitions = [];
35676
35624
  pause_children(effect2, transitions, true);
35677
- run_out_transitions(transitions, () => {
35625
+ var fn = () => {
35678
35626
  if (destroy) destroy_effect(effect2);
35679
35627
  if (callback) callback();
35680
- });
35681
- }
35682
- function run_out_transitions(transitions, fn) {
35628
+ };
35683
35629
  var remaining = transitions.length;
35684
35630
  if (remaining > 0) {
35685
35631
  var check = () => --remaining || fn();
@@ -35693,8 +35639,9 @@ function run_out_transitions(transitions, fn) {
35693
35639
  function pause_children(effect2, transitions, local) {
35694
35640
  if ((effect2.f & INERT) !== 0) return;
35695
35641
  effect2.f ^= INERT;
35696
- if (effect2.transitions !== null) {
35697
- for (const transition of effect2.transitions) {
35642
+ var t = effect2.nodes && effect2.nodes.t;
35643
+ if (t !== null) {
35644
+ for (const transition of t) {
35698
35645
  if (transition.is_global || local) {
35699
35646
  transitions.push(transition);
35700
35647
  }
@@ -35728,8 +35675,9 @@ function resume_children(effect2, local) {
35728
35675
  resume_children(child2, transparent ? local : false);
35729
35676
  child2 = sibling2;
35730
35677
  }
35731
- if (effect2.transitions !== null) {
35732
- for (const transition of effect2.transitions) {
35678
+ var t = effect2.nodes && effect2.nodes.t;
35679
+ if (t !== null) {
35680
+ for (const transition of t) {
35733
35681
  if (transition.is_global || local) {
35734
35682
  transition.in();
35735
35683
  }
@@ -35737,13 +35685,11 @@ function resume_children(effect2, local) {
35737
35685
  }
35738
35686
  }
35739
35687
  function move_effect(effect2, fragment) {
35740
- var node = effect2.nodes_start;
35741
- var end = effect2.nodes_end;
35688
+ if (!effect2.nodes) return;
35689
+ var node = effect2.nodes.start;
35690
+ var end = effect2.nodes.end;
35742
35691
  while (node !== null) {
35743
- var next = node === end ? null : (
35744
- /** @type {TemplateNode} */
35745
- /* @__PURE__ */ get_next_sibling(node)
35746
- );
35692
+ var next = node === end ? null : /* @__PURE__ */ get_next_sibling(node);
35747
35693
  fragment.append(node);
35748
35694
  node = next;
35749
35695
  }
@@ -35919,7 +35865,7 @@ function update_reaction(reaction) {
35919
35865
  } else {
35920
35866
  reaction.deps = deps = new_deps;
35921
35867
  }
35922
- if (is_updating_effect && effect_tracking() && (reaction.f & CONNECTED) !== 0) {
35868
+ if (effect_tracking() && (reaction.f & CONNECTED) !== 0) {
35923
35869
  for (i = skipped_deps; i < deps.length; i++) {
35924
35870
  (deps[i].reactions ??= []).push(reaction);
35925
35871
  }
@@ -36325,9 +36271,8 @@ function assign_nodes(start, end) {
36325
36271
  /** @type {Effect} */
36326
36272
  active_effect
36327
36273
  );
36328
- if (effect2.nodes_start === null) {
36329
- effect2.nodes_start = start;
36330
- effect2.nodes_end = end;
36274
+ if (effect2.nodes === null) {
36275
+ effect2.nodes = { start, end, a: null, t: null };
36331
36276
  }
36332
36277
  }
36333
36278
  // @__NO_SIDE_EFFECTS__
@@ -36339,7 +36284,7 @@ function from_html(content, flags2) {
36339
36284
  return () => {
36340
36285
  if (node === void 0) {
36341
36286
  node = create_fragment_from_html(has_start ? content : "<!>" + content);
36342
- if (!is_fragment) node = /** @type {Node} */
36287
+ if (!is_fragment) node = /** @type {TemplateNode} */
36343
36288
  /* @__PURE__ */ get_first_child(node);
36344
36289
  }
36345
36290
  var clone = (
@@ -36756,6 +36701,363 @@ function if_block(node, fn, elseif = false) {
36756
36701
  }
36757
36702
  }, flags2);
36758
36703
  }
36704
+ function index(_2, i) {
36705
+ return i;
36706
+ }
36707
+ function pause_effects(state2, to_destroy, controlled_anchor) {
36708
+ var transitions = [];
36709
+ var length = to_destroy.length;
36710
+ var group;
36711
+ var remaining = to_destroy.length;
36712
+ for (var i = 0; i < length; i++) {
36713
+ let effect2 = to_destroy[i];
36714
+ pause_effect(
36715
+ effect2,
36716
+ () => {
36717
+ if (group) {
36718
+ group.pending.delete(effect2);
36719
+ group.done.add(effect2);
36720
+ if (group.pending.size === 0) {
36721
+ var groups = (
36722
+ /** @type {Set<EachOutroGroup>} */
36723
+ state2.outrogroups
36724
+ );
36725
+ destroy_effects(array_from(group.done));
36726
+ groups.delete(group);
36727
+ if (groups.size === 0) {
36728
+ state2.outrogroups = null;
36729
+ }
36730
+ }
36731
+ } else {
36732
+ remaining -= 1;
36733
+ }
36734
+ },
36735
+ false
36736
+ );
36737
+ }
36738
+ if (remaining === 0) {
36739
+ var fast_path = transitions.length === 0 && controlled_anchor !== null;
36740
+ if (fast_path) {
36741
+ var anchor = (
36742
+ /** @type {Element} */
36743
+ controlled_anchor
36744
+ );
36745
+ var parent_node = (
36746
+ /** @type {Element} */
36747
+ anchor.parentNode
36748
+ );
36749
+ clear_text_content(parent_node);
36750
+ parent_node.append(anchor);
36751
+ state2.items.clear();
36752
+ }
36753
+ destroy_effects(to_destroy, !fast_path);
36754
+ } else {
36755
+ group = {
36756
+ pending: new Set(to_destroy),
36757
+ done: /* @__PURE__ */ new Set()
36758
+ };
36759
+ (state2.outrogroups ??= /* @__PURE__ */ new Set()).add(group);
36760
+ }
36761
+ }
36762
+ function destroy_effects(to_destroy, remove_dom = true) {
36763
+ for (var i = 0; i < to_destroy.length; i++) {
36764
+ destroy_effect(to_destroy[i], remove_dom);
36765
+ }
36766
+ }
36767
+ var offscreen_anchor;
36768
+ function each(node, flags2, get_collection, get_key, render_fn, fallback_fn = null) {
36769
+ var anchor = node;
36770
+ var items = /* @__PURE__ */ new Map();
36771
+ var is_controlled = (flags2 & EACH_IS_CONTROLLED) !== 0;
36772
+ if (is_controlled) {
36773
+ var parent_node = (
36774
+ /** @type {Element} */
36775
+ node
36776
+ );
36777
+ anchor = parent_node.appendChild(create_text());
36778
+ }
36779
+ var fallback = null;
36780
+ var each_array = /* @__PURE__ */ derived_safe_equal(() => {
36781
+ var collection = get_collection();
36782
+ return is_array(collection) ? collection : collection == null ? [] : array_from(collection);
36783
+ });
36784
+ var array;
36785
+ var first_run = true;
36786
+ function commit() {
36787
+ state2.fallback = fallback;
36788
+ reconcile(state2, array, anchor, flags2, get_key);
36789
+ if (fallback !== null) {
36790
+ if (array.length === 0) {
36791
+ if ((fallback.f & EFFECT_OFFSCREEN) === 0) {
36792
+ resume_effect(fallback);
36793
+ } else {
36794
+ fallback.f ^= EFFECT_OFFSCREEN;
36795
+ move(fallback, null, anchor);
36796
+ }
36797
+ } else {
36798
+ pause_effect(fallback, () => {
36799
+ fallback = null;
36800
+ });
36801
+ }
36802
+ }
36803
+ }
36804
+ var effect2 = block(() => {
36805
+ array = /** @type {V[]} */
36806
+ get2(each_array);
36807
+ var length = array.length;
36808
+ var keys2 = /* @__PURE__ */ new Set();
36809
+ for (var index2 = 0; index2 < length; index2 += 1) {
36810
+ var value = array[index2];
36811
+ var key = get_key(value, index2);
36812
+ var item = first_run ? null : items.get(key);
36813
+ if (item) {
36814
+ if (item.v) internal_set(item.v, value);
36815
+ if (item.i) internal_set(item.i, index2);
36816
+ } else {
36817
+ item = create_item(
36818
+ items,
36819
+ first_run ? anchor : offscreen_anchor ??= create_text(),
36820
+ value,
36821
+ key,
36822
+ index2,
36823
+ render_fn,
36824
+ flags2,
36825
+ get_collection
36826
+ );
36827
+ if (!first_run) {
36828
+ item.e.f |= EFFECT_OFFSCREEN;
36829
+ }
36830
+ items.set(key, item);
36831
+ }
36832
+ keys2.add(key);
36833
+ }
36834
+ if (length === 0 && fallback_fn && !fallback) {
36835
+ if (first_run) {
36836
+ fallback = branch(() => fallback_fn(anchor));
36837
+ } else {
36838
+ fallback = branch(() => fallback_fn(offscreen_anchor ??= create_text()));
36839
+ fallback.f |= EFFECT_OFFSCREEN;
36840
+ }
36841
+ }
36842
+ if (!first_run) {
36843
+ {
36844
+ commit();
36845
+ }
36846
+ }
36847
+ get2(each_array);
36848
+ });
36849
+ var state2 = { effect: effect2, items, outrogroups: null, fallback };
36850
+ first_run = false;
36851
+ }
36852
+ function reconcile(state2, array, anchor, flags2, get_key) {
36853
+ var is_animated = (flags2 & EACH_IS_ANIMATED) !== 0;
36854
+ var length = array.length;
36855
+ var items = state2.items;
36856
+ var current = state2.effect.first;
36857
+ var seen;
36858
+ var prev = null;
36859
+ var to_animate;
36860
+ var matched = [];
36861
+ var stashed = [];
36862
+ var value;
36863
+ var key;
36864
+ var effect2;
36865
+ var i;
36866
+ if (is_animated) {
36867
+ for (i = 0; i < length; i += 1) {
36868
+ value = array[i];
36869
+ key = get_key(value, i);
36870
+ effect2 = /** @type {EachItem} */
36871
+ items.get(key).e;
36872
+ if ((effect2.f & EFFECT_OFFSCREEN) === 0) {
36873
+ effect2.nodes?.a?.measure();
36874
+ (to_animate ??= /* @__PURE__ */ new Set()).add(effect2);
36875
+ }
36876
+ }
36877
+ }
36878
+ for (i = 0; i < length; i += 1) {
36879
+ value = array[i];
36880
+ key = get_key(value, i);
36881
+ effect2 = /** @type {EachItem} */
36882
+ items.get(key).e;
36883
+ if (state2.outrogroups !== null) {
36884
+ for (const group of state2.outrogroups) {
36885
+ group.pending.delete(effect2);
36886
+ group.done.delete(effect2);
36887
+ }
36888
+ }
36889
+ if ((effect2.f & EFFECT_OFFSCREEN) !== 0) {
36890
+ effect2.f ^= EFFECT_OFFSCREEN;
36891
+ if (effect2 === current) {
36892
+ move(effect2, null, anchor);
36893
+ } else {
36894
+ var next = prev ? prev.next : current;
36895
+ if (effect2 === state2.effect.last) {
36896
+ state2.effect.last = effect2.prev;
36897
+ }
36898
+ if (effect2.prev) effect2.prev.next = effect2.next;
36899
+ if (effect2.next) effect2.next.prev = effect2.prev;
36900
+ link(state2, prev, effect2);
36901
+ link(state2, effect2, next);
36902
+ move(effect2, next, anchor);
36903
+ prev = effect2;
36904
+ matched = [];
36905
+ stashed = [];
36906
+ current = prev.next;
36907
+ continue;
36908
+ }
36909
+ }
36910
+ if ((effect2.f & INERT) !== 0) {
36911
+ resume_effect(effect2);
36912
+ if (is_animated) {
36913
+ effect2.nodes?.a?.unfix();
36914
+ (to_animate ??= /* @__PURE__ */ new Set()).delete(effect2);
36915
+ }
36916
+ }
36917
+ if (effect2 !== current) {
36918
+ if (seen !== void 0 && seen.has(effect2)) {
36919
+ if (matched.length < stashed.length) {
36920
+ var start = stashed[0];
36921
+ var j2;
36922
+ prev = start.prev;
36923
+ var a = matched[0];
36924
+ var b2 = matched[matched.length - 1];
36925
+ for (j2 = 0; j2 < matched.length; j2 += 1) {
36926
+ move(matched[j2], start, anchor);
36927
+ }
36928
+ for (j2 = 0; j2 < stashed.length; j2 += 1) {
36929
+ seen.delete(stashed[j2]);
36930
+ }
36931
+ link(state2, a.prev, b2.next);
36932
+ link(state2, prev, a);
36933
+ link(state2, b2, start);
36934
+ current = start;
36935
+ prev = b2;
36936
+ i -= 1;
36937
+ matched = [];
36938
+ stashed = [];
36939
+ } else {
36940
+ seen.delete(effect2);
36941
+ move(effect2, current, anchor);
36942
+ link(state2, effect2.prev, effect2.next);
36943
+ link(state2, effect2, prev === null ? state2.effect.first : prev.next);
36944
+ link(state2, prev, effect2);
36945
+ prev = effect2;
36946
+ }
36947
+ continue;
36948
+ }
36949
+ matched = [];
36950
+ stashed = [];
36951
+ while (current !== null && current !== effect2) {
36952
+ (seen ??= /* @__PURE__ */ new Set()).add(current);
36953
+ stashed.push(current);
36954
+ current = current.next;
36955
+ }
36956
+ if (current === null) {
36957
+ continue;
36958
+ }
36959
+ }
36960
+ if ((effect2.f & EFFECT_OFFSCREEN) === 0) {
36961
+ matched.push(effect2);
36962
+ }
36963
+ prev = effect2;
36964
+ current = effect2.next;
36965
+ }
36966
+ if (state2.outrogroups !== null) {
36967
+ for (const group of state2.outrogroups) {
36968
+ if (group.pending.size === 0) {
36969
+ destroy_effects(array_from(group.done));
36970
+ state2.outrogroups?.delete(group);
36971
+ }
36972
+ }
36973
+ if (state2.outrogroups.size === 0) {
36974
+ state2.outrogroups = null;
36975
+ }
36976
+ }
36977
+ if (current !== null || seen !== void 0) {
36978
+ var to_destroy = [];
36979
+ if (seen !== void 0) {
36980
+ for (effect2 of seen) {
36981
+ if ((effect2.f & INERT) === 0) {
36982
+ to_destroy.push(effect2);
36983
+ }
36984
+ }
36985
+ }
36986
+ while (current !== null) {
36987
+ if ((current.f & INERT) === 0 && current !== state2.fallback) {
36988
+ to_destroy.push(current);
36989
+ }
36990
+ current = current.next;
36991
+ }
36992
+ var destroy_length = to_destroy.length;
36993
+ if (destroy_length > 0) {
36994
+ var controlled_anchor = (flags2 & EACH_IS_CONTROLLED) !== 0 && length === 0 ? anchor : null;
36995
+ if (is_animated) {
36996
+ for (i = 0; i < destroy_length; i += 1) {
36997
+ to_destroy[i].nodes?.a?.measure();
36998
+ }
36999
+ for (i = 0; i < destroy_length; i += 1) {
37000
+ to_destroy[i].nodes?.a?.fix();
37001
+ }
37002
+ }
37003
+ pause_effects(state2, to_destroy, controlled_anchor);
37004
+ }
37005
+ }
37006
+ if (is_animated) {
37007
+ queue_micro_task(() => {
37008
+ if (to_animate === void 0) return;
37009
+ for (effect2 of to_animate) {
37010
+ effect2.nodes?.a?.apply();
37011
+ }
37012
+ });
37013
+ }
37014
+ }
37015
+ function create_item(items, anchor, value, key, index2, render_fn, flags2, get_collection) {
37016
+ var v2 = (flags2 & EACH_ITEM_REACTIVE) !== 0 ? (flags2 & EACH_ITEM_IMMUTABLE) === 0 ? /* @__PURE__ */ mutable_source(value, false, false) : source(value) : null;
37017
+ var i = (flags2 & EACH_INDEX_REACTIVE) !== 0 ? source(index2) : null;
37018
+ return {
37019
+ v: v2,
37020
+ i,
37021
+ e: branch(() => {
37022
+ render_fn(anchor, v2 ?? value, i ?? index2, get_collection);
37023
+ return () => {
37024
+ items.delete(key);
37025
+ };
37026
+ })
37027
+ };
37028
+ }
37029
+ function move(effect2, next, anchor) {
37030
+ if (!effect2.nodes) return;
37031
+ var node = effect2.nodes.start;
37032
+ var end = effect2.nodes.end;
37033
+ var dest = next && (next.f & EFFECT_OFFSCREEN) === 0 ? (
37034
+ /** @type {EffectNodes} */
37035
+ next.nodes.start
37036
+ ) : anchor;
37037
+ while (node !== null) {
37038
+ var next_node = (
37039
+ /** @type {TemplateNode} */
37040
+ /* @__PURE__ */ get_next_sibling(node)
37041
+ );
37042
+ dest.before(node);
37043
+ if (node === end) {
37044
+ return;
37045
+ }
37046
+ node = next_node;
37047
+ }
37048
+ }
37049
+ function link(state2, prev, next) {
37050
+ if (prev === null) {
37051
+ state2.effect.first = next;
37052
+ } else {
37053
+ prev.next = next;
37054
+ }
37055
+ if (next === null) {
37056
+ state2.effect.last = prev;
37057
+ } else {
37058
+ next.prev = prev;
37059
+ }
37060
+ }
36759
37061
  function html(node, get_value, svg = false, mathml = false, skip_warning = false) {
36760
37062
  var anchor = node;
36761
37063
  var value = "";
@@ -36767,13 +37069,13 @@ function html(node, get_value, svg = false, mathml = false, skip_warning = false
36767
37069
  if (value === (value = get_value() ?? "")) {
36768
37070
  return;
36769
37071
  }
36770
- if (effect2.nodes_start !== null) {
37072
+ if (effect2.nodes !== null) {
36771
37073
  remove_effect_dom(
36772
- effect2.nodes_start,
37074
+ effect2.nodes.start,
36773
37075
  /** @type {TemplateNode} */
36774
- effect2.nodes_end
37076
+ effect2.nodes.end
36775
37077
  );
36776
- effect2.nodes_start = effect2.nodes_end = null;
37078
+ effect2.nodes = null;
36777
37079
  }
36778
37080
  if (value === "") return;
36779
37081
  var html2 = value + "";
@@ -36793,7 +37095,7 @@ function html(node, get_value, svg = false, mathml = false, skip_warning = false
36793
37095
  if (svg || mathml) {
36794
37096
  while (/* @__PURE__ */ get_first_child(node2)) {
36795
37097
  anchor.before(
36796
- /** @type {Node} */
37098
+ /** @type {TemplateNode} */
36797
37099
  /* @__PURE__ */ get_first_child(node2)
36798
37100
  );
36799
37101
  }
@@ -36833,13 +37135,10 @@ function element(node, get_tag, is_svg, render_fn, get_namespace, location2) {
36833
37135
  element2 = document.createElementNS(ns, next_tag);
36834
37136
  assign_nodes(element2, element2);
36835
37137
  if (render_fn) {
36836
- var child_anchor = (
36837
- /** @type {TemplateNode} */
36838
- element2.appendChild(create_text())
36839
- );
37138
+ var child_anchor = element2.appendChild(create_text());
36840
37139
  render_fn(element2, child_anchor);
36841
37140
  }
36842
- active_effect.nodes_end = element2;
37141
+ active_effect.nodes.end = element2;
36843
37142
  anchor2.before(element2);
36844
37143
  }
36845
37144
  });