marko 6.0.0-next.3.25 → 6.0.0-next.3.27

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/dom.mjs CHANGED
@@ -45,46 +45,6 @@ function triggerMacroTask() {
45
45
  port2.postMessage(0);
46
46
  }
47
47
 
48
- // src/dom/scope.ts
49
- var pendingScopes = [];
50
- function createScope($global) {
51
- let scope = {
52
- e: 1,
53
- $global
54
- };
55
- return pendingScopes.push(scope), scope;
56
- }
57
- function finishPendingScopes() {
58
- for (let scope of pendingScopes)
59
- scope.e = 0;
60
- pendingScopes = [];
61
- }
62
- var emptyScope = createScope({});
63
- function getEmptyScope(marker) {
64
- return emptyScope.a = emptyScope.c = marker, emptyScope;
65
- }
66
- function destroyBranch(branch) {
67
- if (branch.y = 1, branch.m?.forEach(destroyBranch), branch.n)
68
- for (let scope of branch.n)
69
- for (let id in scope.j)
70
- scope.j[id]?.abort();
71
- }
72
- function removeAndDestroyBranch(branch) {
73
- destroyBranch(branch);
74
- let current = branch.a, stop = branch.c.nextSibling;
75
- for (; current !== stop; ) {
76
- let next = current.nextSibling;
77
- current.remove(), current = next;
78
- }
79
- }
80
- function insertBefore(scope, parent, nextSibling) {
81
- let current = scope.a, stop = scope.c.nextSibling;
82
- for (; current !== stop; ) {
83
- let next = current.nextSibling;
84
- parent.insertBefore(current, nextSibling), current = next;
85
- }
86
- }
87
-
88
48
  // src/common/helpers.ts
89
49
  function classValue(value2) {
90
50
  return toDelimitedString(value2, " ", stringifyClassObject);
@@ -131,83 +91,6 @@ function normalizeDynamicRenderer(value2) {
131
91
  if (value2) return value2.content || value2.default || value2;
132
92
  }
133
93
 
134
- // src/dom/reconcile.ts
135
- var WRONG_POS = 2147483647;
136
- function reconcile(parent, oldBranches, newBranches, afterReference) {
137
- let oldStart = 0, newStart = 0, oldEnd = oldBranches.length - 1, newEnd = newBranches.length - 1, oldStartBranch = oldBranches[oldStart], newStartBranch = newBranches[newStart], oldEndBranch = oldBranches[oldEnd], newEndBranch = newBranches[newEnd], i, j, k, nextSibling, oldBranch, newBranch;
138
- outer: {
139
- for (; oldStartBranch === newStartBranch; ) {
140
- if (++oldStart, ++newStart, oldStart > oldEnd || newStart > newEnd)
141
- break outer;
142
- oldStartBranch = oldBranches[oldStart], newStartBranch = newBranches[newStart];
143
- }
144
- for (; oldEndBranch === newEndBranch; ) {
145
- if (--oldEnd, --newEnd, oldStart > oldEnd || newStart > newEnd)
146
- break outer;
147
- oldEndBranch = oldBranches[oldEnd], newEndBranch = newBranches[newEnd];
148
- }
149
- }
150
- if (oldStart > oldEnd) {
151
- if (newStart <= newEnd) {
152
- k = newEnd + 1, nextSibling = k < newBranches.length ? newBranches[k].a : afterReference;
153
- do
154
- insertBefore(newBranches[newStart++], parent, nextSibling);
155
- while (newStart <= newEnd);
156
- }
157
- } else if (newStart > newEnd)
158
- do
159
- removeAndDestroyBranch(oldBranches[oldStart++]);
160
- while (oldStart <= oldEnd);
161
- else {
162
- let oldLength = oldEnd - oldStart + 1, newLength = newEnd - newStart + 1, aNullable = oldBranches, sources = new Array(newLength);
163
- for (i = 0; i < newLength; ++i)
164
- sources[i] = -1;
165
- let pos = 0, synced = 0, keyIndex = /* @__PURE__ */ new Map();
166
- for (j = newStart; j <= newEnd; ++j)
167
- keyIndex.set(newBranches[j], j);
168
- for (i = oldStart; i <= oldEnd && synced < newLength; ++i)
169
- oldBranch = oldBranches[i], j = keyIndex.get(oldBranch), j !== void 0 && (pos = pos > j ? WRONG_POS : j, ++synced, newBranch = newBranches[j], sources[j - newStart] = i, aNullable[i] = null);
170
- if (oldLength === oldBranches.length && synced === 0) {
171
- for (; newStart < newLength; ++newStart)
172
- insertBefore(newBranches[newStart], parent, afterReference);
173
- for (; oldStart < oldLength; ++oldStart)
174
- removeAndDestroyBranch(oldBranches[oldStart]);
175
- } else {
176
- for (i = oldLength - synced; i > 0; )
177
- oldBranch = aNullable[oldStart++], oldBranch !== null && (removeAndDestroyBranch(oldBranch), i--);
178
- if (pos === WRONG_POS) {
179
- let seq = longestIncreasingSubsequence(sources);
180
- for (j = seq.length - 1, k = newBranches.length, i = newLength - 1; i >= 0; --i)
181
- sources[i] === -1 ? (pos = i + newStart, newBranch = newBranches[pos++], nextSibling = pos < k ? newBranches[pos].a : afterReference, insertBefore(newBranch, parent, nextSibling)) : j < 0 || i !== seq[j] ? (pos = i + newStart, newBranch = newBranches[pos++], nextSibling = pos < k ? newBranches[pos].a : afterReference, insertBefore(newBranch, parent, nextSibling)) : --j;
182
- } else if (synced !== newLength)
183
- for (k = newBranches.length, i = newLength - 1; i >= 0; --i)
184
- sources[i] === -1 && (pos = i + newStart, newBranch = newBranches[pos++], nextSibling = pos < k ? newBranches[pos].a : afterReference, insertBefore(newBranch, parent, nextSibling));
185
- }
186
- }
187
- }
188
- function longestIncreasingSubsequence(a) {
189
- let p = a.slice(), result = [];
190
- result.push(0);
191
- let u, v;
192
- for (let i = 0, il = a.length; i < il; ++i) {
193
- if (a[i] === -1)
194
- continue;
195
- let j = result[result.length - 1];
196
- if (a[j] < a[i]) {
197
- p[i] = j, result.push(i);
198
- continue;
199
- }
200
- for (u = 0, v = result.length - 1; u < v; ) {
201
- let c = (u + v) / 2 | 0;
202
- a[result[c]] < a[i] ? u = c + 1 : v = c;
203
- }
204
- a[i] < a[result[u]] && (u > 0 && (p[i] = result[u - 1]), result[u] = i);
205
- }
206
- for (u = result.length, v = result[u - 1]; u-- > 0; )
207
- result[u] = v, v = p[v];
208
- return result;
209
- }
210
-
211
94
  // src/dom/event.ts
212
95
  var elementHandlersByEvent = /* @__PURE__ */ new Map(), defaultDelegator = createDelegator();
213
96
  function on(element, type, handler) {
@@ -222,7 +105,7 @@ function createDelegator() {
222
105
  };
223
106
  }
224
107
  function handleDelegated(ev) {
225
- let target = ev.target;
108
+ let target = !rendering && ev.target;
226
109
  if (target) {
227
110
  let handlersByElement = elementHandlersByEvent.get(ev.type);
228
111
  if (handlersByElement.get(target)?.(ev, target), ev.bubbles)
@@ -258,28 +141,28 @@ var DEFAULT_RUNTIME_ID = "M", DEFAULT_RENDER_ID = "_";
258
141
 
259
142
  // src/dom/resume.ts
260
143
  var registeredValues = {}, Render = class {
261
- o = [];
262
- p = {};
144
+ n = [];
145
+ o = {};
263
146
  z = {
264
147
  _: registeredValues
265
148
  };
266
149
  constructor(renders, runtimeId, renderId) {
267
- this.A = renders, this.B = runtimeId, this.q = renderId, this.s = renders[renderId], this.t();
150
+ this.A = renders, this.B = runtimeId, this.p = renderId, this.q = renders[renderId], this.s();
268
151
  }
269
152
  w() {
270
- this.s.w(), this.t();
153
+ this.q.w(), this.s();
271
154
  }
272
- t() {
273
- let data2 = this.s, serializeContext = this.z, scopeLookup = this.p, visits = data2.v, branchIds = /* @__PURE__ */ new Set(), parentBranchIds = /* @__PURE__ */ new Map();
155
+ s() {
156
+ let data2 = this.q, serializeContext = this.z, scopeLookup = this.o, visits = data2.v, branchIds = /* @__PURE__ */ new Set(), parentBranchIds = /* @__PURE__ */ new Map();
274
157
  if (visits.length) {
275
- let commentPrefixLen = data2.i.length, closestBranchMarkers = /* @__PURE__ */ new Map();
158
+ let commentPrefixLen = data2.i.length, closestBranchMarkers = /* @__PURE__ */ new Map(), visitNodes = new Set(visits), lastEndNode;
276
159
  data2.v = [];
277
- let branchEnd = (branchId, visit, curNode) => {
278
- let branch = scopeLookup[branchId] ||= {}, endNode = curNode;
279
- for (; (endNode = endNode.previousSibling).nodeType === 8; ) ;
280
- branch.c = endNode, branch.a ||= endNode;
160
+ let branchEnd = (branchId, visit, reference) => {
161
+ let branch = scopeLookup[branchId] ||= {}, endNode = reference;
162
+ for (; visitNodes.has(endNode = endNode.previousSibling); ) ;
163
+ endNode === lastEndNode && (endNode = reference.parentNode.insertBefore(new Text(), reference)), branch.b = lastEndNode = endNode, branch.a ||= endNode;
281
164
  for (let [markerScopeId, markerNode] of closestBranchMarkers)
282
- branch.a.compareDocumentPosition(markerNode) & 4 && curNode.compareDocumentPosition(markerNode) & 2 && (parentBranchIds.set(markerScopeId, branchId), closestBranchMarkers.delete(markerScopeId));
165
+ branch.a.compareDocumentPosition(markerNode) & 4 && reference.compareDocumentPosition(markerNode) & 2 && (parentBranchIds.set(markerScopeId, branchId), closestBranchMarkers.delete(markerScopeId));
283
166
  return branchIds.add(branchId), closestBranchMarkers.set(branchId, visit), branch;
284
167
  };
285
168
  for (let visit of visits) {
@@ -292,22 +175,22 @@ var registeredValues = {}, Render = class {
292
175
  else if (token === "$" /* ClosestBranch */)
293
176
  closestBranchMarkers.set(scopeId, visit);
294
177
  else if (token === "[" /* BranchStart */)
295
- this.h && (dataIndex && branchEnd(this.h, visit, visit), this.o.push(this.h)), this.h = scopeId, scope.a = visit;
178
+ this.e && (dataIndex && branchEnd(this.e, visit, visit), this.n.push(this.e)), this.e = scopeId, scope.a = visit;
296
179
  else if (token === "]" /* BranchEnd */) {
297
180
  scope[data3] = visit;
298
181
  let curParent = visit.parentNode, startNode = branchEnd(
299
- this.h,
182
+ this.e,
300
183
  visit,
301
184
  visit
302
185
  ).a;
303
- curParent !== startNode.parentNode && curParent.prepend(startNode), this.h = this.o.pop();
186
+ curParent !== startNode.parentNode && curParent.prepend(startNode), this.e = this.n.pop();
304
187
  } else if (token === "|" /* BranchSingleNode */) {
305
188
  let next = data3.indexOf(" "), curNode = scope[~next ? data3.slice(0, next) : data3] = visit;
306
189
  for (; ~next; ) {
307
190
  let start = next + 1;
308
191
  next = data3.indexOf(" ", start);
309
192
  let childScopeId = data3.slice(start, ~next ? next : data3.length);
310
- curNode = branchEnd(childScopeId, visit, curNode).c;
193
+ curNode = branchEnd(childScopeId, visit, curNode).b;
311
194
  }
312
195
  }
313
196
  }
@@ -321,7 +204,7 @@ var registeredValues = {}, Render = class {
321
204
  let resumeData = resumes[i++];
322
205
  if (typeof resumeData == "function") {
323
206
  let scopes = resumeData(serializeContext), { $global } = scopeLookup;
324
- $global || (scopeLookup.$global = $global = scopes.$ || {}, $global.runtimeId = this.B, $global.renderId = this.q);
207
+ $global || (scopeLookup.$global = $global = scopes.$ || {}, $global.runtimeId = this.B, $global.renderId = this.p);
325
208
  for (let scopeId in scopes)
326
209
  if (scopeId !== "$") {
327
210
  let scope = scopes[scopeId], prevScope = scopeLookup[scopeId];
@@ -330,12 +213,12 @@ var registeredValues = {}, Render = class {
330
213
  prevScope
331
214
  ));
332
215
  let parentBranchId = parentBranchIds.get(scopeId);
333
- if (parentBranchId && (scope.b = scopes[parentBranchId]), branchIds.has(scopeId)) {
334
- let branch = scope, parentBranch = branch.b;
335
- scope.b = branch, parentBranch && (branch.C = parentBranch, (parentBranch.m ||= /* @__PURE__ */ new Set()).add(branch));
216
+ if (parentBranchId && (scope.c = scopes[parentBranchId]), branchIds.has(scopeId)) {
217
+ let branch = scope, parentBranch = branch.c;
218
+ branch.f = +scopeId, scope.c = branch, parentBranch && (branch.t = parentBranch, (parentBranch.k ||= /* @__PURE__ */ new Set()).add(branch));
336
219
  }
337
220
  }
338
- } else i === len || typeof resumes[i] != "string" ? delete this.A[this.q] : registeredValues[resumes[i++]](
221
+ } else i === len || typeof resumes[i] != "string" ? delete this.A[this.p] : registeredValues[resumes[i++]](
339
222
  scopeLookup[resumeData],
340
223
  scopeLookup[resumeData]
341
224
  );
@@ -373,7 +256,7 @@ function init(runtimeId = DEFAULT_RUNTIME_ID) {
373
256
  }
374
257
  }
375
258
  function registerSubscriber(id, signal) {
376
- return register(id, signal.D), signal;
259
+ return register(id, signal.C), signal;
377
260
  }
378
261
  function nodeRef(id, key) {
379
262
  return register(id, (scope) => () => scope[key]);
@@ -552,7 +435,7 @@ function toValueProp(it) {
552
435
  }
553
436
 
554
437
  // src/dom/parse-html.ts
555
- var fallback = /* @__PURE__ */ new Text(), parser = /* @__PURE__ */ document.createElement("template");
438
+ var parser = /* @__PURE__ */ document.createElement("template");
556
439
  function parseHTML(html2) {
557
440
  return parser.innerHTML = html2, parser.content;
558
441
  }
@@ -567,7 +450,7 @@ function parseHTMLOrSingleNode(html2) {
567
450
  let fragment = new DocumentFragment();
568
451
  return fragment.appendChild(content), fragment;
569
452
  }
570
- return fallback;
453
+ return new Text();
571
454
  }
572
455
 
573
456
  // src/dom/dom.ts
@@ -706,14 +589,12 @@ function attrsEvents(scope, nodeAccessor) {
706
589
  for (let name in events)
707
590
  on(el, name, events[name]);
708
591
  }
709
- function html(scope, value2, index) {
710
- let firstChild = scope[index], lastChild = scope[index + "-"] || firstChild, parentNode = firstChild.parentNode, afterReference = lastChild.nextSibling, newContent = parseHTML(value2 || value2 === 0 ? value2 + "" : "<!>");
711
- scope[index] = newContent.firstChild, scope[index + "-" /* DynamicPlaceholderLastChild */] = newContent.lastChild, parentNode.insertBefore(newContent, firstChild);
712
- let current = firstChild;
713
- for (; current !== afterReference; ) {
714
- let next = current.nextSibling;
715
- current.remove(), current = next;
716
- }
592
+ function html(scope, value2, accessor) {
593
+ let firstChild = scope[accessor], lastChild = scope[accessor + "-" /* DynamicPlaceholderLastChild */] || firstChild, newContent = parseHTML(
594
+ value2 || value2 === 0 ? value2 + "" : "<!>"
595
+ // TODO: is the comment needed
596
+ );
597
+ scope[accessor] = newContent.firstChild, scope[accessor + "-" /* DynamicPlaceholderLastChild */] = newContent.lastChild, firstChild.parentNode.insertBefore(newContent, firstChild), removeChildNodes(firstChild, lastChild);
717
598
  }
718
599
  function props(scope, nodeIndex, index) {
719
600
  let nextProps = scope[index], prevProps = scope[index + "-"], node = scope[nodeIndex];
@@ -738,6 +619,128 @@ function lifecycle(scope, index, thisObj) {
738
619
  "-" /* LifecycleAbortController */ + index
739
620
  ).onabort = () => thisObj.onDestroy?.());
740
621
  }
622
+ function removeChildNodes(startNode, endNode) {
623
+ let stop = endNode.nextSibling, current = startNode;
624
+ for (; current !== stop; ) {
625
+ let next = current.nextSibling;
626
+ current.remove(), current = next;
627
+ }
628
+ }
629
+
630
+ // src/dom/scope.ts
631
+ var pendingScopes = [];
632
+ function createScope($global) {
633
+ let scope = {
634
+ g: 1,
635
+ $global
636
+ };
637
+ return pendingScopes.push(scope), scope;
638
+ }
639
+ function finishPendingScopes() {
640
+ for (let scope of pendingScopes)
641
+ scope.g = 0;
642
+ pendingScopes = [];
643
+ }
644
+ var emptyBranch = createScope({});
645
+ function getEmptyBranch(marker) {
646
+ return emptyBranch.a = emptyBranch.b = marker, emptyBranch;
647
+ }
648
+ function destroyBranch(branch) {
649
+ branch.t?.k?.delete(branch), destroyNestedBranches(branch);
650
+ }
651
+ function destroyNestedBranches(branch) {
652
+ branch.D = 1, branch.k?.forEach(destroyNestedBranches), branch.E?.forEach((scope) => {
653
+ for (let id in scope.h)
654
+ scope.h[id]?.abort();
655
+ });
656
+ }
657
+ function removeAndDestroyBranch(branch) {
658
+ destroyBranch(branch), removeChildNodes(branch.a, branch.b);
659
+ }
660
+ function insertBranchBefore(branch, parentNode, nextSibling) {
661
+ let current = branch.a, stop = branch.b.nextSibling;
662
+ for (; current !== stop; ) {
663
+ let next = current.nextSibling;
664
+ parentNode.insertBefore(current, nextSibling), current = next;
665
+ }
666
+ }
667
+
668
+ // src/dom/reconcile.ts
669
+ var WRONG_POS = 2147483647;
670
+ function reconcile(parent, oldBranches, newBranches, afterReference) {
671
+ let oldStart = 0, newStart = 0, oldEnd = oldBranches.length - 1, newEnd = newBranches.length - 1, oldStartBranch = oldBranches[oldStart], newStartBranch = newBranches[newStart], oldEndBranch = oldBranches[oldEnd], newEndBranch = newBranches[newEnd], i, j, k, nextSibling, oldBranch, newBranch;
672
+ outer: {
673
+ for (; oldStartBranch === newStartBranch; ) {
674
+ if (++oldStart, ++newStart, oldStart > oldEnd || newStart > newEnd)
675
+ break outer;
676
+ oldStartBranch = oldBranches[oldStart], newStartBranch = newBranches[newStart];
677
+ }
678
+ for (; oldEndBranch === newEndBranch; ) {
679
+ if (--oldEnd, --newEnd, oldStart > oldEnd || newStart > newEnd)
680
+ break outer;
681
+ oldEndBranch = oldBranches[oldEnd], newEndBranch = newBranches[newEnd];
682
+ }
683
+ }
684
+ if (oldStart > oldEnd) {
685
+ if (newStart <= newEnd) {
686
+ k = newEnd + 1, nextSibling = k < newBranches.length ? newBranches[k].a : afterReference;
687
+ do
688
+ insertBranchBefore(newBranches[newStart++], parent, nextSibling);
689
+ while (newStart <= newEnd);
690
+ }
691
+ } else if (newStart > newEnd)
692
+ do
693
+ removeAndDestroyBranch(oldBranches[oldStart++]);
694
+ while (oldStart <= oldEnd);
695
+ else {
696
+ let oldLength = oldEnd - oldStart + 1, newLength = newEnd - newStart + 1, aNullable = oldBranches, sources = new Array(newLength);
697
+ for (i = 0; i < newLength; ++i)
698
+ sources[i] = -1;
699
+ let pos = 0, synced = 0, keyIndex = /* @__PURE__ */ new Map();
700
+ for (j = newStart; j <= newEnd; ++j)
701
+ keyIndex.set(newBranches[j], j);
702
+ for (i = oldStart; i <= oldEnd && synced < newLength; ++i)
703
+ oldBranch = oldBranches[i], j = keyIndex.get(oldBranch), j !== void 0 && (pos = pos > j ? WRONG_POS : j, ++synced, newBranch = newBranches[j], sources[j - newStart] = i, aNullable[i] = null);
704
+ if (oldLength === oldBranches.length && synced === 0) {
705
+ for (; newStart < newLength; ++newStart)
706
+ insertBranchBefore(newBranches[newStart], parent, afterReference);
707
+ for (; oldStart < oldLength; ++oldStart)
708
+ removeAndDestroyBranch(oldBranches[oldStart]);
709
+ } else {
710
+ for (i = oldLength - synced; i > 0; )
711
+ oldBranch = aNullable[oldStart++], oldBranch !== null && (removeAndDestroyBranch(oldBranch), i--);
712
+ if (pos === WRONG_POS) {
713
+ let seq = longestIncreasingSubsequence(sources);
714
+ for (j = seq.length - 1, k = newBranches.length, i = newLength - 1; i >= 0; --i)
715
+ sources[i] === -1 ? (pos = i + newStart, newBranch = newBranches[pos++], nextSibling = pos < k ? newBranches[pos].a : afterReference, insertBranchBefore(newBranch, parent, nextSibling)) : j < 0 || i !== seq[j] ? (pos = i + newStart, newBranch = newBranches[pos++], nextSibling = pos < k ? newBranches[pos].a : afterReference, insertBranchBefore(newBranch, parent, nextSibling)) : --j;
716
+ } else if (synced !== newLength)
717
+ for (k = newBranches.length, i = newLength - 1; i >= 0; --i)
718
+ sources[i] === -1 && (pos = i + newStart, newBranch = newBranches[pos++], nextSibling = pos < k ? newBranches[pos].a : afterReference, insertBranchBefore(newBranch, parent, nextSibling));
719
+ }
720
+ }
721
+ }
722
+ function longestIncreasingSubsequence(a) {
723
+ let p = a.slice(), result = [];
724
+ result.push(0);
725
+ let u, v;
726
+ for (let i = 0, il = a.length; i < il; ++i) {
727
+ if (a[i] === -1)
728
+ continue;
729
+ let j = result[result.length - 1];
730
+ if (a[j] < a[i]) {
731
+ p[i] = j, result.push(i);
732
+ continue;
733
+ }
734
+ for (u = 0, v = result.length - 1; u < v; ) {
735
+ let c = (u + v) / 2 | 0;
736
+ a[result[c]] < a[i] ? u = c + 1 : v = c;
737
+ }
738
+ a[i] < a[result[u]] && (u > 0 && (p[i] = result[u - 1]), result[u] = i);
739
+ }
740
+ for (u = result.length, v = result[u - 1]; u-- > 0; )
741
+ result[u] = v, v = p[v];
742
+ return result;
743
+ }
741
744
 
742
745
  // src/dom/walker.ts
743
746
  var walker = /* @__PURE__ */ document.createTreeWalker(document);
@@ -746,8 +749,8 @@ function trimWalkString(walkString) {
746
749
  for (; walkString.charCodeAt(--end) > 47 /* BeginChild */; ) ;
747
750
  return walkString.slice(0, end + 1);
748
751
  }
749
- function walk(startNode, walkCodes, scope) {
750
- walker.currentNode = startNode, walkInternal(walkCodes, scope, 0), walker.currentNode = document;
752
+ function walk(startNode, walkCodes, branch) {
753
+ walker.currentNode = startNode, walkInternal(walkCodes, branch, 0), walker.currentNode = document;
751
754
  }
752
755
  function walkInternal(walkCodes, scope, currentWalkIndex) {
753
756
  let value2, storedMultiplier = 0, currentMultiplier = 0, currentScopeIndex = 0;
@@ -766,7 +769,7 @@ function walkInternal(walkCodes, scope, currentWalkIndex) {
766
769
  walker.nextNode();
767
770
  else if (value2 === 47 /* BeginChild */) {
768
771
  let childScope = scope[currentScopeIndex++] = createScope(scope.$global);
769
- childScope.a = walker.currentNode, childScope.b = scope.b, currentWalkIndex = walkInternal(walkCodes, childScope, currentWalkIndex);
772
+ childScope.c = scope.c, currentWalkIndex = walkInternal(walkCodes, childScope, currentWalkIndex);
770
773
  } else {
771
774
  if (value2 === 38 /* EndChild */)
772
775
  return currentWalkIndex;
@@ -787,7 +790,7 @@ function createBranchScopeWithRenderer(renderer, $global, parentScope) {
787
790
  renderer.u || parentScope,
788
791
  parentScope
789
792
  );
790
- return initRenderer(renderer, branch), branch;
793
+ return initBranch(renderer, branch), branch;
791
794
  }
792
795
  function createBranchScopeWithTagNameOrRenderer(tagNameOrRenderer, $global, parentScope) {
793
796
  if (typeof tagNameOrRenderer != "string")
@@ -797,19 +800,19 @@ function createBranchScopeWithTagNameOrRenderer(tagNameOrRenderer, $global, pare
797
800
  parentScope
798
801
  );
799
802
  let branch = createBranch($global, parentScope, parentScope);
800
- return branch[0] = branch.a = branch.c = document.createElement(tagNameOrRenderer), branch;
803
+ return branch[0] = branch.a = branch.b = document.createElement(tagNameOrRenderer), branch;
801
804
  }
802
805
  function createBranch($global, ownerScope, parentScope) {
803
- let branch = createScope($global), parentBranch = parentScope.b;
804
- return branch._ = ownerScope, branch.b = branch, parentBranch && (branch.C = parentBranch, (parentBranch.m ||= /* @__PURE__ */ new Set()).add(branch)), branch;
806
+ let branch = createScope($global), parentBranch = parentScope.c;
807
+ return branch._ = ownerScope, branch.c = branch, parentBranch ? (branch.f = parentBranch.f + 1, branch.t = parentBranch, (parentBranch.k ||= /* @__PURE__ */ new Set()).add(branch)) : branch.f = 1, branch;
805
808
  }
806
- function initRenderer(renderer, scope) {
809
+ function initBranch(renderer, branch) {
807
810
  let dom = renderer.l();
808
811
  return walk(
809
812
  dom.nodeType === 11 /* DocumentFragment */ ? dom.firstChild : dom,
810
- renderer.E,
811
- scope
812
- ), scope.a = dom.nodeType === 11 /* DocumentFragment */ ? dom.firstChild : dom, scope.c = dom.nodeType === 11 /* DocumentFragment */ ? dom.lastChild : dom, renderer.x && queueRender(scope, renderer.x), dom;
813
+ renderer.F,
814
+ branch
815
+ ), branch.a = dom.nodeType === 11 /* DocumentFragment */ ? dom.firstChild : dom, branch.b = dom.nodeType === 11 /* DocumentFragment */ ? dom.lastChild : dom, renderer.x && queueRender(branch, renderer.x), dom;
813
816
  }
814
817
  function dynamicTagAttrs(nodeAccessor, getContent, inputIsArgs) {
815
818
  return (scope, attrsOrOp) => {
@@ -818,13 +821,13 @@ function dynamicTagAttrs(nodeAccessor, getContent, inputIsArgs) {
818
821
  return;
819
822
  let childScope = scope[nodeAccessor + "!" /* ConditionalScope */];
820
823
  if (attrsOrOp === MARK || attrsOrOp === CLEAN)
821
- return renderer.f?.(childScope, attrsOrOp);
824
+ return renderer.d?.(childScope, attrsOrOp);
822
825
  let content = getContent?.(scope);
823
826
  if (typeof renderer == "string")
824
827
  setConditionalRendererOnlyChild(childScope, 0, content), attrs(childScope, 0, attrsOrOp());
825
- else if (renderer.f) {
828
+ else if (renderer.d) {
826
829
  let attributes = attrsOrOp();
827
- renderer.f(
830
+ renderer.d(
828
831
  childScope,
829
832
  inputIsArgs ? attributes : [
830
833
  content ? {
@@ -839,14 +842,14 @@ function dynamicTagAttrs(nodeAccessor, getContent, inputIsArgs) {
839
842
  function createRendererWithOwner(template, rawWalks, setup, getArgs) {
840
843
  let args, id = {}, walks = rawWalks ? /* @__PURE__ */ trimWalkString(rawWalks) : " ";
841
844
  return (owner) => ({
842
- k: id,
843
- F: template,
844
- E: walks,
845
+ j: id,
846
+ G: template,
847
+ F: walks,
845
848
  x: setup,
846
849
  l: _clone,
847
850
  u: owner,
848
- G: void 0,
849
- get f() {
851
+ H: void 0,
852
+ get d() {
850
853
  return args ||= getArgs?.();
851
854
  }
852
855
  });
@@ -855,8 +858,8 @@ function createRenderer(template, walks, setup, getArgs) {
855
858
  return createRendererWithOwner(template, walks, setup, getArgs)();
856
859
  }
857
860
  function _clone() {
858
- return (this.G ||= parseHTMLOrSingleNode(
859
- this.F
861
+ return (this.H ||= parseHTMLOrSingleNode(
862
+ this.G
860
863
  )).cloneNode(!0);
861
864
  }
862
865
 
@@ -871,18 +874,18 @@ var conditional = function(nodeAccessor, fn, getIntersection) {
871
874
  let currentRenderer = scope[rendererAccessor], op = newRendererOrOp;
872
875
  if (newRendererOrOp !== MARK && newRendererOrOp !== CLEAN) {
873
876
  let normalizedRenderer = normalizeDynamicRenderer(newRendererOrOp);
874
- isDifferentRenderer(normalizedRenderer, currentRenderer) ? (setConditionalRenderer(scope, nodeAccessor, normalizedRenderer), fn && fn(scope), op = DIRTY) : op = CLEAN;
877
+ isDifferentRenderer(normalizedRenderer, currentRenderer) ? (scope[rendererAccessor] = normalizedRenderer, setConditionalRenderer(scope, nodeAccessor, normalizedRenderer), fn && fn(scope), op = DIRTY) : op = CLEAN;
875
878
  }
876
879
  intersection2?.(scope, op);
877
880
  };
878
881
  };
879
882
  function setConditionalRenderer(scope, nodeAccessor, newRenderer) {
880
- let newBranch = newRenderer ? createBranchScopeWithTagNameOrRenderer(newRenderer, scope.$global, scope) : void 0, prevBranch = scope[nodeAccessor + "!" /* ConditionalScope */] || getEmptyScope(scope[nodeAccessor]);
881
- insertBefore(
882
- newBranch || getEmptyScope(scope[nodeAccessor]),
883
- prevBranch.a.parentNode,
884
- prevBranch.a
885
- ), removeAndDestroyBranch(prevBranch), scope[nodeAccessor + "(" /* ConditionalRenderer */] = newRenderer, scope[nodeAccessor + "!" /* ConditionalScope */] = newBranch;
883
+ let prevBranch = scope[nodeAccessor + "!" /* ConditionalScope */] || getEmptyBranch(scope[nodeAccessor]), newBranch = newRenderer ? createBranchScopeWithTagNameOrRenderer(newRenderer, scope.$global, scope) : getEmptyBranch(scope[nodeAccessor]);
884
+ insertBranchBefore(
885
+ newBranch,
886
+ prevBranch.b.parentNode,
887
+ prevBranch.b.nextSibling
888
+ ), removeAndDestroyBranch(prevBranch), scope[nodeAccessor + "!" /* ConditionalScope */] = newRenderer && newBranch;
886
889
  }
887
890
  var conditionalOnlyChild = function(nodeAccessor, fn, getIntersection) {
888
891
  let rendererAccessor = nodeAccessor + "(" /* ConditionalRenderer */, intersection2 = getIntersection && ((scope, op) => (intersection2 = getIntersection())(scope, op));
@@ -902,12 +905,12 @@ var conditionalOnlyChild = function(nodeAccessor, fn, getIntersection) {
902
905
  };
903
906
  function setConditionalRendererOnlyChild(scope, nodeAccessor, newRenderer) {
904
907
  let prevBranch = scope[nodeAccessor + "!" /* ConditionalScope */], referenceNode = scope[nodeAccessor], newBranch = newRenderer ? createBranchScopeWithTagNameOrRenderer(newRenderer, scope.$global, scope) : void 0;
905
- referenceNode.textContent = "", newBranch && insertBefore(newBranch, referenceNode, null), prevBranch && destroyBranch(prevBranch), scope[nodeAccessor + "!" /* ConditionalScope */] = newBranch;
908
+ referenceNode.textContent = "", newBranch && insertBranchBefore(newBranch, referenceNode, null), prevBranch && destroyBranch(prevBranch), scope[nodeAccessor + "!" /* ConditionalScope */] = newBranch;
906
909
  }
907
910
  var emptyMarkerMap = /* @__PURE__ */ new Map([
908
- [Symbol(), getEmptyScope(void 0)]
911
+ [Symbol(), getEmptyBranch(void 0)]
909
912
  ]), emptyMarkerArray = [
910
- /* @__PURE__ */ getEmptyScope(void 0)
913
+ /* @__PURE__ */ getEmptyBranch(void 0)
911
914
  ], emptyMap = /* @__PURE__ */ new Map(), emptyArray = [];
912
915
  function loopOf(nodeAccessor, renderer) {
913
916
  return loop(
@@ -936,7 +939,7 @@ function loopTo(nodeAccessor, renderer) {
936
939
  );
937
940
  }
938
941
  function loop(nodeAccessor, renderer, forEach) {
939
- let loopScopeAccessor = nodeAccessor + "!" /* LoopScopeArray */, params = renderer.f;
942
+ let loopScopeAccessor = nodeAccessor + "!" /* LoopScopeArray */, params = renderer.d;
940
943
  return (scope, valueOrOp) => {
941
944
  if (valueOrOp === DIRTY) return;
942
945
  if (valueOrOp === MARK || valueOrOp === CLEAN) {
@@ -950,11 +953,11 @@ function loop(nodeAccessor, renderer, forEach) {
950
953
  if (forEach(valueOrOp, (key, args) => {
951
954
  let branch = oldMap.get(key);
952
955
  branch || (branch = createBranchScopeWithRenderer(renderer, scope.$global, scope)), params && params(branch, args), newMap ? (newMap.set(key, branch), newArray.push(branch)) : (newMap = /* @__PURE__ */ new Map([[key, branch]]), newArray = [branch]);
953
- }), newMap || (referenceIsMarker ? (newMap = emptyMarkerMap, newArray = emptyMarkerArray, getEmptyScope(referenceNode)) : (oldArray.forEach(destroyBranch), referenceNode.textContent = "", newMap = emptyMap, newArray = emptyArray, needsReconciliation = !1)), needsReconciliation) {
956
+ }), newMap || (referenceIsMarker ? (newMap = emptyMarkerMap, newArray = emptyMarkerArray, getEmptyBranch(referenceNode)) : (oldArray.forEach(destroyBranch), referenceNode.textContent = "", newMap = emptyMap, newArray = emptyArray, needsReconciliation = !1)), needsReconciliation) {
954
957
  if (referenceIsMarker) {
955
- oldMap === emptyMarkerMap && getEmptyScope(referenceNode);
958
+ oldMap === emptyMarkerMap && getEmptyBranch(referenceNode);
956
959
  let oldLastChild = oldArray[oldArray.length - 1];
957
- afterReference = oldLastChild.c.nextSibling, parentNode = oldLastChild.a.parentNode;
960
+ afterReference = oldLastChild.b.nextSibling, parentNode = oldLastChild.a.parentNode;
958
961
  } else
959
962
  afterReference = null, parentNode = referenceNode;
960
963
  reconcile(parentNode, oldArray, newArray, afterReference);
@@ -969,7 +972,7 @@ function byFirstArg(name) {
969
972
  return name;
970
973
  }
971
974
  function isDifferentRenderer(a, b) {
972
- return a !== b && (a?.k || 0) !== b?.k;
975
+ return a !== b && (a?.j || 0) !== b?.j;
973
976
  }
974
977
 
975
978
  // src/dom/signals.ts
@@ -1010,24 +1013,24 @@ function loopClosure(ownerLoopNodeAccessor, fn, getIntersection) {
1010
1013
  let loopScopes = ownerScope[loopScopeAccessor] ?? ownerScope[loopScopeMapAccessor]?.values() ?? [];
1011
1014
  if (loopScopes !== emptyMarkerArray)
1012
1015
  for (let scope of loopScopes)
1013
- scope.e || queueSource(scope, signal, value2);
1016
+ scope.g || queueSource(scope, signal, value2);
1014
1017
  };
1015
1018
  return helperSignal._ = signal, helperSignal;
1016
1019
  }
1017
1020
  function conditionalClosure(ownerConditionalNodeAccessor, getRenderer, fn, getIntersection) {
1018
1021
  let signal = closure(fn, getIntersection), scopeAccessor = ownerConditionalNodeAccessor + "!" /* ConditionalScope */, rendererAccessor = ownerConditionalNodeAccessor + "(" /* ConditionalRenderer */, helperSignal = (scope, value2) => {
1019
1022
  let conditionalScope = scope[scopeAccessor];
1020
- conditionalScope && !conditionalScope.e && scope[rendererAccessor]?.k === getRenderer().k && queueSource(conditionalScope, signal, value2);
1023
+ conditionalScope && !conditionalScope.g && scope[rendererAccessor]?.j === getRenderer().j && queueSource(conditionalScope, signal, value2);
1021
1024
  };
1022
1025
  return helperSignal._ = signal, helperSignal;
1023
1026
  }
1024
1027
  var defaultGetOwnerScope = (scope) => scope._;
1025
- function dynamicClosure(ownerValueAccessor, fn, getOwnerScope = defaultGetOwnerScope, getIntersection) {
1026
- let ownerSubscribersAccessor = ownerValueAccessor + "*" /* Subscribers */, _signal = closure(fn, getIntersection), helperSignal = (ownerScope, value2) => {
1028
+ function dynamicClosure(fn, getOwnerScope = defaultGetOwnerScope, getIntersection) {
1029
+ let ownerSubscribersAccessor = "?" /* Dynamic */ + accessorId++, _signal = closure(fn, getIntersection), helperSignal = (ownerScope, value2) => {
1027
1030
  let subscribers = ownerScope[ownerSubscribersAccessor];
1028
1031
  if (subscribers)
1029
1032
  for (let subscriber of subscribers)
1030
- subscriber.e || queueSource(subscriber, _signal, value2);
1033
+ subscriber.g || queueSource(subscriber, _signal, value2);
1031
1034
  }, setupSignal = (scope, value2) => {
1032
1035
  _signal(scope, value2), subscribe(scope);
1033
1036
  }, subscribe = (scope) => {
@@ -1035,7 +1038,7 @@ function dynamicClosure(ownerValueAccessor, fn, getOwnerScope = defaultGetOwnerS
1035
1038
  getOwnerScope(scope)[ownerSubscribersAccessor].delete(scope);
1036
1039
  });
1037
1040
  };
1038
- return helperSignal._ = setupSignal, helperSignal.D = subscribe, helperSignal;
1041
+ return helperSignal._ = setupSignal, helperSignal.C = subscribe, helperSignal;
1039
1042
  }
1040
1043
  function setTagVar(scope, childAccessor, tagVarSignal2) {
1041
1044
  scope[childAccessor]["/" /* TagVariable */] = (valueOrOp) => tagVarSignal2(scope, valueOrOp);
@@ -1068,29 +1071,25 @@ function effect(id, fn) {
1068
1071
  }
1069
1072
 
1070
1073
  // src/dom/queue.ts
1071
- var pendingRender, pendingEffects = [], rendering = !1;
1074
+ var pendingRenders = [], pendingEffects = [], rendering = !1;
1072
1075
  function queueSource(scope, signal, value2) {
1073
1076
  schedule();
1074
1077
  let prevRendering = rendering;
1075
1078
  return rendering = !0, signal(scope, MARK), rendering = prevRendering, queueRender(scope, signal, value2), value2;
1076
1079
  }
1077
1080
  function queueRender(scope, signal, value2) {
1078
- let nextRender = {
1079
- g: scope,
1080
- H: signal,
1081
- I: value2,
1082
- d: void 0
1081
+ let i = pendingRenders.length, render = {
1082
+ m: scope,
1083
+ I: signal,
1084
+ J: value2,
1085
+ y: i
1083
1086
  };
1084
- if (!pendingRender)
1085
- pendingRender = nextRender;
1086
- else if (comparePendingRenders(pendingRender, nextRender) < 0)
1087
- nextRender.d = pendingRender, pendingRender = nextRender;
1088
- else {
1089
- let curRender = pendingRender;
1090
- for (; curRender.d && comparePendingRenders(curRender.d, nextRender) >= 0; )
1091
- curRender = curRender.d;
1092
- nextRender.d = curRender.d, curRender.d = nextRender;
1087
+ for (pendingRenders.push(render); i; ) {
1088
+ let parentIndex = i - 1 >> 1, parent = pendingRenders[parentIndex];
1089
+ if (comparePendingRenders(render, parent) >= 0) break;
1090
+ pendingRenders[i] = parent, i = parentIndex;
1093
1091
  }
1092
+ pendingRenders[i] = render;
1094
1093
  }
1095
1094
  function queueEffect(scope, fn) {
1096
1095
  pendingEffects.push(scope, fn);
@@ -1100,17 +1099,17 @@ function run() {
1100
1099
  try {
1101
1100
  rendering = !0, runRenders();
1102
1101
  } finally {
1103
- pendingRender = void 0, rendering = !1;
1102
+ pendingRenders = [], pendingEffects = [], rendering = !1;
1104
1103
  }
1105
- pendingEffects = [], runEffects(effects);
1104
+ runEffects(effects);
1106
1105
  }
1107
1106
  function prepareEffects(fn) {
1108
- let prevRender = pendingRender, prevEffects = pendingEffects, preparedEffects = pendingEffects = [];
1109
- pendingRender = void 0;
1107
+ let prevRenders = pendingRenders, prevEffects = pendingEffects, preparedEffects = pendingEffects = [];
1108
+ pendingRenders = [];
1110
1109
  try {
1111
1110
  rendering = !0, fn(), runRenders();
1112
1111
  } finally {
1113
- rendering = !1, pendingRender = prevRender, pendingEffects = prevEffects;
1112
+ rendering = !1, pendingRenders = prevRenders, pendingEffects = prevEffects;
1114
1113
  }
1115
1114
  return preparedEffects;
1116
1115
  }
@@ -1121,26 +1120,39 @@ function runEffects(effects = pendingEffects) {
1121
1120
  }
1122
1121
  }
1123
1122
  function runRenders() {
1124
- for (; pendingRender; )
1125
- pendingRender.g.b?.y || pendingRender.H(pendingRender.g, pendingRender.I), pendingRender = pendingRender.d;
1123
+ for (; pendingRenders.length; ) {
1124
+ let render = pendingRenders[0], next = pendingRenders.pop();
1125
+ if (render !== next) {
1126
+ let i = 0, mid = pendingRenders.length >> 1, item = pendingRenders[0] = next;
1127
+ for (; i < mid; ) {
1128
+ let bestChild = (i << 1) + 1, right = bestChild + 1;
1129
+ if (right < pendingRenders.length && comparePendingRenders(
1130
+ pendingRenders[right],
1131
+ pendingRenders[bestChild]
1132
+ ) < 0 && (bestChild = right), comparePendingRenders(pendingRenders[bestChild], item) >= 0)
1133
+ break;
1134
+ pendingRenders[i] = pendingRenders[bestChild], i = bestChild;
1135
+ }
1136
+ pendingRenders[i] = item;
1137
+ }
1138
+ render.m.c?.D || render.I(render.m, render.J);
1139
+ }
1126
1140
  finishPendingScopes();
1127
1141
  }
1128
1142
  function comparePendingRenders(a, b) {
1129
- if (a.g.e || b.g.e) return 0;
1130
- let aStart = ownerStartNode(a.g), bStart = ownerStartNode(b.g);
1131
- return aStart === bStart ? 0 : aStart ? bStart ? aStart.compareDocumentPosition(bStart) & 2 ? -1 : 1 : -1 : 1;
1143
+ return getBranchDepth(a) - getBranchDepth(b) || a.y - b.y;
1132
1144
  }
1133
- function ownerStartNode(scope) {
1134
- return (scope.b || scope).a;
1145
+ function getBranchDepth(render) {
1146
+ return render.m.c?.f || 0;
1135
1147
  }
1136
1148
 
1137
1149
  // src/dom/abort-signal.ts
1138
1150
  function resetAbortSignal(scope, id) {
1139
- let ctrl = scope.j?.[id];
1140
- ctrl && (queueEffect(ctrl, abort), scope.j[id] = void 0);
1151
+ let ctrl = scope.h?.[id];
1152
+ ctrl && (queueEffect(ctrl, abort), scope.h[id] = void 0);
1141
1153
  }
1142
1154
  function getAbortSignal(scope, id) {
1143
- return scope.b && (scope.b.n ||= /* @__PURE__ */ new Set()).add(scope), ((scope.j ||= {})[id] ||= new AbortController()).signal;
1155
+ return scope.c && (scope.c.E ||= /* @__PURE__ */ new Set()).add(scope), ((scope.h ||= {})[id] ||= new AbortController()).signal;
1144
1156
  }
1145
1157
  function abort(ctrl) {
1146
1158
  ctrl.abort();
@@ -1150,12 +1162,12 @@ function abort(ctrl) {
1150
1162
  var prefix = "$C_", RENDERER_REGISTER_ID = prefix + "r", SET_SCOPE_REGISTER_ID = prefix + "s";
1151
1163
 
1152
1164
  // src/dom/compat.ts
1153
- var classIdToScope = /* @__PURE__ */ new Map(), compat = {
1165
+ var classIdToBranch = /* @__PURE__ */ new Map(), compat = {
1154
1166
  patchConditionals,
1155
1167
  queueEffect,
1156
1168
  init() {
1157
- register(SET_SCOPE_REGISTER_ID, (scope) => {
1158
- classIdToScope.set(scope.m5c, scope);
1169
+ register(SET_SCOPE_REGISTER_ID, (branch) => {
1170
+ classIdToBranch.set(branch.m5c, branch);
1159
1171
  });
1160
1172
  },
1161
1173
  registerRenderer(fn) {
@@ -1167,11 +1179,11 @@ var classIdToScope = /* @__PURE__ */ new Map(), compat = {
1167
1179
  isRenderer(renderer) {
1168
1180
  return renderer.l !== void 0;
1169
1181
  },
1170
- getStartNode(scope) {
1171
- return scope.a;
1182
+ getStartNode(branch) {
1183
+ return branch.a;
1172
1184
  },
1173
- setScopeNodes(scope, startNode, endNode) {
1174
- scope.a = startNode, scope.c = endNode;
1185
+ setScopeNodes(branch, startNode, endNode) {
1186
+ branch.a = startNode, branch.b = endNode;
1175
1187
  },
1176
1188
  runComponentEffects() {
1177
1189
  runEffects(this.effects);
@@ -1185,7 +1197,7 @@ var classIdToScope = /* @__PURE__ */ new Map(), compat = {
1185
1197
  }) {
1186
1198
  return Array.isArray(value2) && typeof value2[0] == "string" ? getRegisteredWithScope(
1187
1199
  value2[0],
1188
- value2.length === 2 && window[runtimeId]?.[componentIdPrefix === "s" ? "_" : componentIdPrefix]?.p[value2[1]]
1200
+ value2.length === 2 && window[runtimeId]?.[componentIdPrefix === "s" ? "_" : componentIdPrefix]?.o[value2[1]]
1189
1201
  ) : value2;
1190
1202
  },
1191
1203
  createRenderer(setup, clone, args) {
@@ -1193,18 +1205,18 @@ var classIdToScope = /* @__PURE__ */ new Map(), compat = {
1193
1205
  return renderer.l = clone, renderer;
1194
1206
  },
1195
1207
  render(out, component, renderer, args) {
1196
- let scope = component.scope;
1197
- scope || (scope = classIdToScope.get(component.id), scope && (component.scope = scope, classIdToScope.delete(component.id)));
1198
- let applyArgs = renderer.f || noop, existing = !1;
1208
+ let branch = component.scope;
1209
+ branch || (branch = classIdToBranch.get(component.id), branch && (component.scope = branch, classIdToBranch.delete(component.id)));
1210
+ let applyArgs = renderer.d || noop, existing = !1;
1199
1211
  if (typeof args[0] == "object" && "renderBody" in args[0]) {
1200
1212
  let input = args[0], normalizedInput = args[0] = {};
1201
1213
  for (let key in input)
1202
1214
  normalizedInput[key === "renderBody" ? "content" : key] = input[key];
1203
1215
  }
1204
1216
  if (component.effects = prepareEffects(() => {
1205
- scope ? (applyArgs(scope, MARK), existing = !0) : (scope = component.scope = createScope(out.global), scope._ = renderer.u, initRenderer(renderer, scope)), applyArgs(scope, args);
1217
+ branch ? (applyArgs(branch, MARK), existing = !0) : (branch = component.scope = createScope(out.global), branch._ = renderer.u, initBranch(renderer, branch)), applyArgs(branch, args);
1206
1218
  }), !existing)
1207
- return scope.a === scope.c ? scope.a : scope.a.parentNode;
1219
+ return branch.a === branch.b ? branch.a : branch.a.parentNode;
1208
1220
  }
1209
1221
  };
1210
1222
  function noop() {
@@ -1216,33 +1228,29 @@ var createTemplate = (templateId, ...rendererArgs) => {
1216
1228
  return renderer.mount = mount, renderer._ = renderer, register(templateId, renderer);
1217
1229
  };
1218
1230
  function mount(input = {}, reference, position) {
1219
- let branch, dom, { $global } = input;
1220
- $global ? ({ $global, ...input } = input, $global = {
1231
+ let branch, dom, parentNode = reference, nextSibling = null, { $global } = input;
1232
+ switch ($global ? ({ $global, ...input } = input, $global = {
1221
1233
  runtimeId: DEFAULT_RUNTIME_ID,
1222
1234
  renderId: DEFAULT_RENDER_ID,
1223
1235
  ...$global
1224
1236
  }) : $global = {
1225
1237
  runtimeId: DEFAULT_RUNTIME_ID,
1226
1238
  renderId: DEFAULT_RENDER_ID
1227
- };
1228
- let args = this.f, effects = prepareEffects(() => {
1229
- branch = createScope($global), dom = initRenderer(this, branch), args && args(branch, [input]);
1230
- });
1231
- switch (position) {
1239
+ }, position) {
1232
1240
  case "beforebegin":
1233
- reference.parentNode.insertBefore(dom, reference);
1241
+ parentNode = reference.parentNode, nextSibling = reference;
1234
1242
  break;
1235
1243
  case "afterbegin":
1236
- reference.insertBefore(dom, reference.firstChild);
1244
+ nextSibling = reference.firstChild;
1237
1245
  break;
1238
1246
  case "afterend":
1239
- reference.parentNode.insertBefore(dom, reference.nextSibling);
1240
- break;
1241
- default:
1242
- reference.appendChild(dom);
1247
+ parentNode = reference.parentNode, nextSibling = reference.nextSibling;
1243
1248
  break;
1244
1249
  }
1245
- return runEffects(effects), {
1250
+ let args = this.d, effects = prepareEffects(() => {
1251
+ branch = createScope($global), dom = initBranch(this, branch), args?.(branch, [input]);
1252
+ });
1253
+ return parentNode.insertBefore(dom, nextSibling), runEffects(effects), {
1246
1254
  update: (newInput) => {
1247
1255
  args && runEffects(
1248
1256
  prepareEffects(() => {