marko 6.0.164 → 6.0.166

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
@@ -1,1663 +1,1109 @@
1
- // src/common/attr-tag.ts
2
- var empty = [], rest = /* @__PURE__ */ Symbol();
1
+ let empty = [], rest = Symbol(), toDelimitedString = function toDelimitedString(val, delimiter, stringify) {
2
+ let str = "", sep = "", part;
3
+ if (val) if (typeof val != "object") str += val;
4
+ else if (Array.isArray(val)) for (let v of val) part = toDelimitedString(v, delimiter, stringify), part && (str += sep + part, sep = delimiter);
5
+ else for (let name in val) part = stringify(name, val[name]), part && (str += sep + part, sep = delimiter);
6
+ return str;
7
+ }, decodeAccessor = (num) => (num + (num < 26 ? 10 : num < 962 ? 334 : 11998)).toString(36), defaultDelegator = /* @__PURE__ */ createDelegator(), R = /[^\p{L}\p{N}]/gu, parsers = {}, nextScopeId = 1e6, destroyNestedScopes = function destroyNestedScopes(scope) {
8
+ scope.I = 1, scope.D?.forEach(destroyNestedScopes), scope.B?.forEach(resetControllers);
9
+ }, isScheduled, channel, _return = (scope, value) => scope.T?.(value), _var_change = (scope, value) => scope.U?.(value), tagIdsByGlobal = /* @__PURE__ */ new WeakMap(), walker = /* @__PURE__ */ document.createTreeWalker(document), walkInternal = function walkInternal(currentWalkIndex, walkCodes, scope) {
10
+ let value, currentMultiplier, storedMultiplier = 0, currentScopeIndex = 0;
11
+ for (; currentWalkIndex < walkCodes.length;) if (value = walkCodes.charCodeAt(currentWalkIndex++), currentMultiplier = storedMultiplier, storedMultiplier = 0, value === 32) {
12
+ let node = walker.currentNode;
13
+ scope[decodeAccessor(currentScopeIndex++)] = node;
14
+ } else if (value === 37 || value === 49) walker.currentNode.replaceWith(walker.currentNode = scope[decodeAccessor(currentScopeIndex++)] = new Text()), value === 49 && (scope[decodeAccessor(currentScopeIndex++)] = skipScope());
15
+ else if (value === 38) return currentWalkIndex;
16
+ else if (value === 47 || value === 48) currentWalkIndex = walkInternal(currentWalkIndex, walkCodes, scope[decodeAccessor(currentScopeIndex++)] = createScope(scope.$, scope.F)), value === 48 && (scope[decodeAccessor(currentScopeIndex++)] = skipScope());
17
+ else if (value < 92) for (value = 20 * currentMultiplier + value - 67; value--;) walker.nextNode();
18
+ else if (value < 107) for (value = 10 * currentMultiplier + value - 97; value--;) walker.nextSibling();
19
+ else if (value < 117) {
20
+ for (value = 10 * currentMultiplier + value - 107; value--;) walker.parentNode();
21
+ walker.nextSibling();
22
+ } else storedMultiplier = currentMultiplier * 10 + value - 117;
23
+ }, cloneCache = {}, registeredValues = {}, curRuntimeId, readyLookup, branchesEnabled, embedEnabled, ready = /* @__PURE__ */ ((_) => (id) => {
24
+ readyLookup[id]?.(), readyLookup[id] = 1;
25
+ })(readyLookup = {}), isResuming, inputType = "", controllableDelegate = /* @__PURE__ */ createDelegator(), _dynamic_tag = function(nodeAccessor, getContent, getTagVar, inputIsArgs) {
26
+ nodeAccessor = decodeAccessor(nodeAccessor);
27
+ let childScopeAccessor = "A" + nodeAccessor, rendererAccessor = "D" + nodeAccessor;
28
+ return enableBranches(), (scope, newRenderer, getInput) => {
29
+ let normalizedRenderer = normalizeDynamicRenderer(newRenderer);
30
+ if (scope[rendererAccessor] !== (scope[rendererAccessor] = normalizedRenderer?.a || normalizedRenderer) || getContent && !(normalizedRenderer || scope[childScopeAccessor])) if (setConditionalRenderer(scope, nodeAccessor, normalizedRenderer || (getContent ? getContent(scope) : void 0), createBranchWithTagNameOrRenderer), getTagVar && (scope[childScopeAccessor].T = (value) => getTagVar()(scope, value)), typeof normalizedRenderer == "string") {
31
+ if (getContent) {
32
+ let content = getContent(scope);
33
+ setConditionalRenderer(scope[childScopeAccessor], "a", content, createAndSetupBranch), content.f && subscribeToScopeSet(content.e, content.f, scope[childScopeAccessor].Aa);
34
+ }
35
+ } else normalizedRenderer?.f && subscribeToScopeSet(normalizedRenderer.e, normalizedRenderer.f, scope[childScopeAccessor]);
36
+ if (normalizedRenderer) {
37
+ let childScope = scope[childScopeAccessor], args = getInput?.();
38
+ if (typeof normalizedRenderer == "string") (getContent ? _attrs : _attrs_content)(childScope, "a", (inputIsArgs ? args[0] : args) || {}), (childScope.Ia || childScope.Ea) && queueEffect(childScope, dynamicTagScript);
39
+ else {
40
+ for (let accessor in normalizedRenderer.g) normalizedRenderer.g[accessor](childScope, normalizedRenderer.h[accessor]);
41
+ if (normalizedRenderer.d) if (inputIsArgs) normalizedRenderer.d(childScope, normalizedRenderer._ ? args[0] : args);
42
+ else {
43
+ let inputWithContent = getContent ? {
44
+ ...args,
45
+ content: getContent(scope)
46
+ } : args || {};
47
+ normalizedRenderer.d(childScope, normalizedRenderer._ ? inputWithContent : [inputWithContent]);
48
+ }
49
+ }
50
+ }
51
+ };
52
+ }, _for_of = /* @__PURE__ */ loop(([all, by = bySecondArg], cb) => {
53
+ typeof by == "string" ? forOf(all, (item, i) => cb(item[by], [item, i])) : forOf(all, (item, i) => cb(by(item, i), [item, i]));
54
+ }), _for_in = /* @__PURE__ */ loop(([obj, by = byFirstArg], cb) => forIn(obj, (key, value) => cb(by(key, value), [key, value]))), _for_to = /* @__PURE__ */ loop(([to, from, step, by = byFirstArg], cb) => forTo(to, from, step, (v) => cb(by(v), [v]))), _for_until = /* @__PURE__ */ loop(([until, from, step, by = byFirstArg], cb) => forUntil(until, from, step, (v) => cb(by(v), [v]))), pendingRenders = [], pendingRendersLookup = /* @__PURE__ */ new Map(), asyncRendersLookup, caughtError = /* @__PURE__ */ new WeakSet(), placeholderShown = /* @__PURE__ */ new WeakSet(), pendingEffects = [], pendingScopes = [], rendering, runEffects = ((effects) => {
55
+ for (let i = 0; i < effects.length;) effects[i++](effects[i++]);
56
+ }), runRender = (render) => render.c(render.b, render.d), catchEnabled, classIdToBranch = /* @__PURE__ */ new Map(), compat = {
57
+ patchDynamicTag,
58
+ queueEffect,
59
+ init(warp10Noop) {
60
+ _resume("$C_s", (branch) => {
61
+ classIdToBranch.set(branch.m5c, branch);
62
+ }), _resume("$C_b", warp10Noop);
63
+ },
64
+ registerRenderer(fn) {
65
+ _resume("$C_r", fn);
66
+ },
67
+ isRenderer(renderer) {
68
+ return renderer.b;
69
+ },
70
+ getStartNode(branch) {
71
+ return branch.S;
72
+ },
73
+ setScopeNodes(branch, startNode, endNode) {
74
+ branch.S = startNode, branch.K = endNode;
75
+ },
76
+ runComponentEffects() {
77
+ this.effects && runEffects(this.effects);
78
+ },
79
+ runComponentDestroy() {
80
+ this.scope && destroyBranch(this.scope);
81
+ },
82
+ resolveRegistered(value, $global) {
83
+ return Array.isArray(value) && typeof value[0] == "string" ? getRegisteredWithScope(value[0], value.length === 2 && self[$global.runtimeId]?.[$global.renderId]?.s[value[1]]) : value;
84
+ },
85
+ createRenderer(params, clone) {
86
+ let renderer = _content("", 0, 0, 0, params)();
87
+ return renderer.b = (branch) => {
88
+ let cloned = clone();
89
+ branch.S = cloned.startNode, branch.K = cloned.endNode;
90
+ }, renderer;
91
+ },
92
+ render(out, component, renderer, args) {
93
+ let branch = component.scope, created = 0;
94
+ if (!branch && (branch = classIdToBranch.get(component.id)) && (component.scope = branch, classIdToBranch.delete(component.id)), typeof args[0] == "object" && "renderBody" in args[0]) {
95
+ let input = args[0], normalizedInput = args[0] = {};
96
+ for (let key in input) normalizedInput[key === "renderBody" ? "content" : key] = input[key];
97
+ }
98
+ if (component.effects = prepareEffects(() => {
99
+ branch ||= (created = 1, component.scope = createAndSetupBranch(out.global, renderer, renderer.e, document.body)), renderer.d?.(branch, renderer._ ? args[0] : args);
100
+ }), created) return toInsertNode(branch.S, branch.K);
101
+ }
102
+ }, _template = (id, template, walks, setup, inputSignal) => {
103
+ let renderer = _content(id, template, walks, setup, inputSignal)();
104
+ return renderer.mount = mount, renderer._ = renderer, _resume(id, renderer);
105
+ };
106
+ //#region src/common/attr-tag.ts
3
107
  function attrTag(attrs) {
4
- return attrs[Symbol.iterator] = attrTagIterator, attrs[rest] = empty, attrs;
108
+ return attrs[Symbol.iterator] = attrTagIterator, attrs[rest] = empty, attrs;
5
109
  }
6
110
  function attrTags(first, attrs) {
7
- return first ? (first[rest] === empty ? first[rest] = [attrs] : first[rest].push(attrs), first) : attrTag(attrs);
111
+ return first ? (first[rest] === empty ? first[rest] = [attrs] : first[rest].push(attrs), first) : attrTag(attrs);
8
112
  }
9
113
  function* attrTagIterator() {
10
- yield this, yield* this[rest];
11
- }
12
-
13
- // src/common/errors.ts
14
- function _assert_hoist(value) {
114
+ yield this, yield* this[rest];
15
115
  }
116
+ function _assert_hoist(value) {}
16
117
  function _assert_init(scope, accessor) {
17
- return scope[accessor];
118
+ return scope[accessor];
18
119
  }
19
-
20
- // src/common/for.ts
120
+ //#endregion
121
+ //#region src/common/for.ts
21
122
  function forIn(obj, cb) {
22
- for (let key in obj)
23
- cb(key, obj[key]);
123
+ for (let key in obj) cb(key, obj[key]);
24
124
  }
25
125
  function forOf(list, cb) {
26
- if (list) {
27
- let i = 0;
28
- for (let item of list)
29
- cb(item, i++);
30
- }
126
+ if (list) {
127
+ let i = 0;
128
+ for (let item of list) cb(item, i++);
129
+ }
31
130
  }
32
131
  function forTo(to, from, step, cb) {
33
- let start = from || 0, delta = step || 1;
34
- for (let steps = (to - start) / delta, i = 0; i <= steps; i++)
35
- cb(start + i * delta);
132
+ let start = from || 0, delta = step || 1;
133
+ for (let steps = (to - start) / delta, i = 0; i <= steps; i++) cb(start + i * delta);
36
134
  }
37
135
  function forUntil(until, from, step, cb) {
38
- let start = from || 0, delta = step || 1;
39
- for (let steps = (until - start) / delta, i = 0; i < steps; i++)
40
- cb(start + i * delta);
136
+ let start = from || 0, delta = step || 1;
137
+ for (let steps = (until - start) / delta, i = 0; i < steps; i++) cb(start + i * delta);
41
138
  }
42
-
43
- // src/common/helpers.ts
139
+ //#endregion
140
+ //#region src/common/helpers.ts
44
141
  function _call(fn, v) {
45
- return fn(v), v;
46
- }
47
- function classValue(classValue2) {
48
- return toDelimitedString(classValue2, " ", stringifyClassObject);
142
+ return fn(v), v;
49
143
  }
50
144
  function stringifyClassObject(name, value) {
51
- return value ? name : "";
52
- }
53
- function styleValue(styleValue2) {
54
- return toDelimitedString(styleValue2, ";", stringifyStyleObject);
145
+ return value ? name : "";
55
146
  }
56
147
  function stringifyStyleObject(name, value) {
57
- return value || value === 0 ? name + ":" + value : "";
58
- }
59
- function toDelimitedString(val, delimiter, stringify) {
60
- let str = "", sep = "", part;
61
- if (val)
62
- if (typeof val != "object")
63
- str += val;
64
- else if (Array.isArray(val))
65
- for (let v of val)
66
- part = toDelimitedString(v, delimiter, stringify), part && (str += sep + part, sep = delimiter);
67
- else
68
- for (let name in val)
69
- part = stringify(name, val[name]), part && (str += sep + part, sep = delimiter);
70
- return str;
148
+ return value || value === 0 ? name + ":" + value : "";
71
149
  }
72
150
  function isEventHandler(name) {
73
- return /^on[A-Z-]/.test(name);
151
+ return /^on[A-Z-]/.test(name);
74
152
  }
75
153
  function getEventHandlerName(name) {
76
- return name[2] === "-" ? name.slice(3) : name.slice(2).toLowerCase();
154
+ return name[2] === "-" ? name.slice(3) : name.slice(2).toLowerCase();
77
155
  }
78
156
  function normalizeDynamicRenderer(value) {
79
- if (value) {
80
- if (typeof value == "string") return value;
81
- let normalized = value.content || value.default || value;
82
- if (/* @__KEY__ */ "g" in normalized)
83
- return normalized;
84
- }
85
- }
86
- var decodeAccessor = (num) => (num + (num < 26 ? 10 : num < 962 ? 334 : 11998)).toString(36);
87
-
88
- // src/common/opt.ts
157
+ if (value) {
158
+ if (typeof value == "string") return value;
159
+ let normalized = value.content || value.default || value;
160
+ if ("a" in normalized) return normalized;
161
+ }
162
+ }
163
+ //#endregion
164
+ //#region src/common/opt.ts
89
165
  function toArray(opt) {
90
- return opt ? Array.isArray(opt) ? opt : [opt] : [];
166
+ return opt ? Array.isArray(opt) ? opt : [opt] : [];
91
167
  }
92
168
  function push(opt, item) {
93
- return opt ? Array.isArray(opt) ? (opt.push(item), opt) : [opt, item] : item;
169
+ return opt ? Array.isArray(opt) ? (opt.push(item), opt) : [opt, item] : item;
94
170
  }
95
-
96
- // src/dom/event.ts
97
- var defaultDelegator = createDelegator();
171
+ //#endregion
172
+ //#region src/dom/event.ts
98
173
  function _on(element, type, handler) {
99
- element["$" + type] === void 0 && defaultDelegator(element, type, handleDelegated), element["$" + type] = handler || null;
174
+ element["$" + type] === void 0 && defaultDelegator(element, type, handleDelegated), element["$" + type] = handler || null;
100
175
  }
176
+ /* @__NO_SIDE_EFFECTS__ */
101
177
  function createDelegator() {
102
- let kEvents = /* @__PURE__ */ Symbol();
103
- return function(node, type, handler) {
104
- ((node = node.getRootNode())[kEvents] ||= {})[type] ||= (node.addEventListener(type, handler, !0), 1);
105
- };
178
+ let kEvents = Symbol();
179
+ return function(node, type, handler) {
180
+ ((node = node.getRootNode())[kEvents] ||= {})[type] ||= (node.addEventListener(type, handler, !0), 1);
181
+ };
106
182
  }
107
183
  function handleDelegated(ev) {
108
- let target = !rendering && ev.target;
109
- for (; target; )
110
- target["$" + ev.type]?.(ev, target), target = ev.bubbles && !ev.cancelBubble && target.parentNode;
111
- }
112
-
113
- // src/dom/resolve-cursor-position.ts
114
- var R = /[^\p{L}\p{N}]/gu;
115
- function resolveCursorPosition(inputType2, initialPosition, initialValue, updatedValue) {
116
- if (
117
- // If initial position is null or false then
118
- // either this node is not the active element
119
- // or does not support selection ranges.
120
- (initialPosition || initialPosition === 0) && (initialPosition !== initialValue.length || // short regex to match input types that delete backwards
121
- /kw/.test(inputType2))
122
- ) {
123
- let before = initialValue.slice(0, initialPosition), after = initialValue.slice(initialPosition);
124
- if (updatedValue.startsWith(before)) return initialPosition;
125
- if (updatedValue.endsWith(after)) return updatedValue.length - after.length;
126
- let count = before.replace(R, "").length, pos = 0;
127
- for (; count && updatedValue[pos]; )
128
- updatedValue[pos++].replace(R, "") && count--;
129
- return pos;
130
- }
131
- return -1;
132
- }
133
-
134
- // src/dom/parse-html.ts
135
- var parsers = {};
184
+ let target = !rendering && ev.target;
185
+ for (; target;) target["$" + ev.type]?.(ev, target), target = ev.bubbles && !ev.cancelBubble && target.parentNode;
186
+ }
187
+ //#endregion
188
+ //#region src/dom/resolve-cursor-position.ts
189
+ function resolveCursorPosition(inputType, initialPosition, initialValue, updatedValue) {
190
+ if ((initialPosition || initialPosition === 0) && (initialPosition !== initialValue.length || /kw/.test(inputType))) {
191
+ let before = initialValue.slice(0, initialPosition), after = initialValue.slice(initialPosition);
192
+ if (updatedValue.startsWith(before)) return initialPosition;
193
+ if (updatedValue.endsWith(after)) return updatedValue.length - after.length;
194
+ let count = before.replace(R, "").length, pos = 0;
195
+ for (; count && updatedValue[pos];) updatedValue[pos++].replace(R, "") && count--;
196
+ return pos;
197
+ }
198
+ return -1;
199
+ }
200
+ //#endregion
201
+ //#region src/dom/parse-html.ts
136
202
  function parseHTML(html, ns) {
137
- let parser = parsers[ns] ||= document.createElementNS(ns, "template");
138
- return parser.innerHTML = html, parser.content || parser;
203
+ let parser = parsers[ns] ||= document.createElementNS(ns, "template");
204
+ return parser.innerHTML = html, parser.content || parser;
139
205
  }
140
-
141
- // src/dom/scope.ts
142
- var nextScopeId = 1e6;
206
+ //#endregion
207
+ //#region src/dom/scope.ts
143
208
  function createScope($global, closestBranch) {
144
- let scope = {
145
- L: nextScopeId++,
146
- H: 1,
147
- F: closestBranch,
148
- $: $global
149
- };
150
- return pendingScopes.push(scope), scope;
209
+ let scope = {
210
+ L: nextScopeId++,
211
+ H: 1,
212
+ F: closestBranch,
213
+ $: $global
214
+ };
215
+ return pendingScopes.push(scope), scope;
151
216
  }
152
217
  function skipScope() {
153
- return nextScopeId++;
218
+ return nextScopeId++;
154
219
  }
155
220
  function findBranchWithKey(scope, key) {
156
- let branch = scope.F;
157
- for (; branch && !branch[key]; )
158
- branch = branch.N;
159
- return branch;
221
+ let branch = scope.F;
222
+ for (; branch && branch[key] == null;) branch = branch.N;
223
+ return branch;
160
224
  }
161
225
  function destroyBranch(branch) {
162
- branch.N?.D?.delete(
163
- branch
164
- ), destroyNestedScopes(branch);
226
+ branch.N?.D?.delete(branch), destroyNestedScopes(branch);
165
227
  }
166
228
  function destroyScope(scope) {
167
- scope.I || (destroyNestedScopes(scope), resetControllers(scope));
168
- }
169
- function destroyNestedScopes(scope) {
170
- scope.I = 1, scope.D?.forEach(destroyNestedScopes), scope.B?.forEach(resetControllers);
229
+ scope.I || (destroyNestedScopes(scope), resetControllers(scope));
171
230
  }
172
231
  function resetControllers(scope) {
173
- for (let id in scope.A)
174
- $signalReset(scope, id);
232
+ for (let id in scope.A) $signalReset(scope, id);
175
233
  }
176
234
  function removeAndDestroyBranch(branch) {
177
- destroyBranch(branch), removeChildNodes(
178
- branch.S,
179
- branch.K
180
- );
235
+ destroyBranch(branch), removeChildNodes(branch.S, branch.K);
181
236
  }
182
237
  function insertBranchBefore(branch, parentNode, nextSibling) {
183
- insertChildNodes(
184
- parentNode,
185
- nextSibling,
186
- branch.S,
187
- branch.K
188
- );
238
+ insertChildNodes(parentNode, nextSibling, branch.S, branch.K);
189
239
  }
190
240
  function tempDetachBranch(branch) {
191
- let fragment = new DocumentFragment();
192
- fragment.namespaceURI = branch.S.parentNode.namespaceURI, insertChildNodes(
193
- fragment,
194
- null,
195
- branch.S,
196
- branch.K
197
- );
198
- }
199
-
200
- // src/dom/schedule.ts
201
- var isScheduled, channel;
241
+ let fragment = new DocumentFragment();
242
+ fragment.namespaceURI = branch.S.parentNode.namespaceURI, insertChildNodes(fragment, null, branch.S, branch.K);
243
+ }
244
+ //#endregion
245
+ //#region src/dom/schedule.ts
202
246
  function schedule() {
203
- isScheduled || (isScheduled = 1, queueMicrotask(flushAndWaitFrame));
247
+ isScheduled || (isScheduled = 1, queueMicrotask(flushAndWaitFrame));
204
248
  }
205
249
  function flushAndWaitFrame() {
206
- run(), requestAnimationFrame(triggerMacroTask);
250
+ run(), requestAnimationFrame(triggerMacroTask);
207
251
  }
208
252
  function triggerMacroTask() {
209
- channel || (channel = new MessageChannel(), channel.port1.onmessage = () => {
210
- isScheduled = 0, run();
211
- }), channel.port2.postMessage(0);
253
+ channel || (channel = new MessageChannel(), channel.port1.onmessage = () => {
254
+ isScheduled = 0, run();
255
+ }), channel.port2.postMessage(0);
212
256
  }
213
-
214
- // src/dom/signals.ts
257
+ //#endregion
258
+ //#region src/dom/signals.ts
215
259
  function _let(id, fn) {
216
- let valueAccessor = decodeAccessor(id), valueChangeAccessor = "M" /* TagVariableChange */ + valueAccessor;
217
- return (scope, value, valueChange) => (rendering ? ((scope[valueChangeAccessor] = valueChange) && scope[valueAccessor] !== value || scope.H) && (scope[valueAccessor] = value, fn?.(scope)) : scope[valueChangeAccessor] ? scope[valueChangeAccessor](value) : scope[valueAccessor] !== (scope[valueAccessor] = value) && fn && (schedule(), queueRender(scope, fn, id)), value);
260
+ let valueAccessor = decodeAccessor(id), valueChangeAccessor = "M" + valueAccessor;
261
+ return (scope, value, valueChange) => (rendering ? ((scope[valueChangeAccessor] = valueChange) && scope[valueAccessor] !== value || scope.H) && (scope[valueAccessor] = value, fn?.(scope)) : scope[valueChangeAccessor] ? scope[valueChangeAccessor](value) : scope[valueAccessor] !== (scope[valueAccessor] = value) && fn && (schedule(), queueRender(scope, fn, id)), value);
218
262
  }
219
263
  function _const(valueAccessor, fn) {
220
- return valueAccessor = decodeAccessor(valueAccessor), (scope, value) => {
221
- (!(valueAccessor in scope) || scope[valueAccessor] !== value) && (scope[valueAccessor] = value, fn?.(scope));
222
- };
264
+ return valueAccessor = decodeAccessor(valueAccessor), (scope, value) => {
265
+ (!(valueAccessor in scope) || scope[valueAccessor] !== value) && (scope[valueAccessor] = value, fn?.(scope));
266
+ };
223
267
  }
224
- function _or(id, fn, defaultPending = 1, scopeIdAccessor = "L" /* Id */) {
225
- return scopeIdAccessor !== "L" /* Id */ && (scopeIdAccessor = decodeAccessor(scopeIdAccessor)), (scope) => {
226
- scope.H ? id in scope ? --scope[id] || fn(scope) : scope[id] = defaultPending : queueRender(scope, fn, id, 0, scope[scopeIdAccessor]);
227
- };
268
+ function _or(id, fn, defaultPending = 1, scopeIdAccessor = "L") {
269
+ return scopeIdAccessor !== "L" && (scopeIdAccessor = decodeAccessor(scopeIdAccessor)), (scope) => {
270
+ scope.H ? id in scope ? --scope[id] || fn(scope) : scope[id] = defaultPending : queueRender(scope, fn, id, 0, scope[scopeIdAccessor]);
271
+ };
228
272
  }
229
273
  function _for_closure(ownerLoopNodeAccessor, fn) {
230
- ownerLoopNodeAccessor = decodeAccessor(ownerLoopNodeAccessor);
231
- let scopeAccessor = "A" /* BranchScopes */ + ownerLoopNodeAccessor, ownerSignal = (ownerScope) => {
232
- let scopes = toArray(ownerScope[scopeAccessor]);
233
- scopes.length && queueRender(
234
- ownerScope,
235
- () => {
236
- for (let scope of scopes)
237
- !scope.H && !scope.I && fn(scope);
238
- },
239
- -1,
240
- 0,
241
- scopes[0].L
242
- );
243
- };
244
- return ownerSignal._ = fn, ownerSignal;
274
+ ownerLoopNodeAccessor = decodeAccessor(ownerLoopNodeAccessor);
275
+ let scopeAccessor = "A" + ownerLoopNodeAccessor, ownerSignal = (ownerScope) => {
276
+ let scopes = toArray(ownerScope[scopeAccessor]);
277
+ scopes.length && queueRender(ownerScope, () => {
278
+ for (let scope of scopes) !scope.H && !scope.I && fn(scope);
279
+ }, -1, 0, scopes[0].L);
280
+ };
281
+ return ownerSignal._ = fn, ownerSignal;
245
282
  }
246
283
  function _if_closure(ownerConditionalNodeAccessor, branch, fn) {
247
- ownerConditionalNodeAccessor = decodeAccessor(
248
- ownerConditionalNodeAccessor
249
- );
250
- let scopeAccessor = "A" /* BranchScopes */ + ownerConditionalNodeAccessor, branchAccessor = "D" /* ConditionalRenderer */ + ownerConditionalNodeAccessor, ownerSignal = (scope) => {
251
- let ifScope = scope[scopeAccessor];
252
- ifScope && !ifScope.H && (scope[branchAccessor] || 0) === branch && queueRender(ifScope, fn, -1);
253
- };
254
- return ownerSignal._ = fn, ownerSignal;
284
+ ownerConditionalNodeAccessor = decodeAccessor(ownerConditionalNodeAccessor);
285
+ let scopeAccessor = "A" + ownerConditionalNodeAccessor, branchAccessor = "D" + ownerConditionalNodeAccessor, ownerSignal = (scope) => {
286
+ let ifScope = scope[scopeAccessor];
287
+ ifScope && !ifScope.H && (scope[branchAccessor] || 0) === branch && queueRender(ifScope, fn, -1);
288
+ };
289
+ return ownerSignal._ = fn, ownerSignal;
255
290
  }
256
291
  function subscribeToScopeSet(ownerScope, accessor, scope) {
257
- let subscribers = ownerScope[accessor] ||= /* @__PURE__ */ new Set();
258
- subscribers.has(scope) || (subscribers.add(scope), $signal(scope, -1).addEventListener(
259
- "abort",
260
- () => ownerScope[accessor].delete(scope)
261
- ));
292
+ let subscribers = ownerScope[accessor] ||= /* @__PURE__ */ new Set();
293
+ subscribers.has(scope) || (subscribers.add(scope), $signal(scope, -1).addEventListener("abort", () => ownerScope[accessor].delete(scope)));
262
294
  }
263
295
  function _closure(...closureSignals) {
264
- let [{ o: ___scopeInstancesAccessor, q: ___signalIndexAccessor }] = closureSignals;
265
- for (let i = closureSignals.length; i--; )
266
- closureSignals[i].x = i;
267
- return (scope) => {
268
- if (scope[___scopeInstancesAccessor])
269
- for (let childScope of scope[___scopeInstancesAccessor])
270
- childScope.H || queueRender(
271
- childScope,
272
- closureSignals[childScope[___signalIndexAccessor] || 0],
273
- -1
274
- );
275
- };
296
+ let [firstSignal] = closureSignals, scopeInstances = firstSignal.a, signalIndex = firstSignal.b;
297
+ for (let i = closureSignals.length; i--;) closureSignals[i].c = i;
298
+ return (scope) => {
299
+ if (scope[scopeInstances]) for (let childScope of scope[scopeInstances]) childScope.H || queueRender(childScope, closureSignals[childScope[signalIndex] || 0], -1);
300
+ };
276
301
  }
277
302
  function _closure_get(valueAccessor, fn, getOwnerScope, resumeId) {
278
- valueAccessor = decodeAccessor(valueAccessor);
279
- let closureSignal = ((scope) => {
280
- scope[closureSignal.q] = closureSignal.x, fn(scope), subscribeToScopeSet(
281
- getOwnerScope ? getOwnerScope(scope) : scope._,
282
- closureSignal.o,
283
- scope
284
- );
285
- });
286
- return closureSignal.o = "B" /* ClosureScopes */ + valueAccessor, closureSignal.q = "C" /* ClosureSignalIndex */ + valueAccessor, resumeId && _resume(resumeId, closureSignal), closureSignal;
303
+ valueAccessor = decodeAccessor(valueAccessor);
304
+ let closureSignal = ((scope) => {
305
+ scope[closureSignal.b] = closureSignal.c, fn(scope), subscribeToScopeSet(getOwnerScope ? getOwnerScope(scope) : scope._, closureSignal.a, scope);
306
+ });
307
+ return closureSignal.a = "B" + valueAccessor, closureSignal.b = "C" + valueAccessor, resumeId && _resume(resumeId, closureSignal), closureSignal;
287
308
  }
288
309
  function _child_setup(setup) {
289
- return setup._ = (scope, owner) => {
290
- scope._ = owner, queueRender(scope, setup, -1);
291
- }, setup;
310
+ return setup._ = (scope, owner) => {
311
+ scope._ = owner, queueRender(scope, setup, -1);
312
+ }, setup;
292
313
  }
293
314
  function _var(scope, childAccessor, signal) {
294
- scope[decodeAccessor(childAccessor)].T = (value) => signal(scope, value);
315
+ scope[decodeAccessor(childAccessor)].T = (value) => signal(scope, value);
295
316
  }
296
- var _return = (scope, value) => scope.T?.(value);
297
317
  function _return_change(scope, changeHandler) {
298
- changeHandler && (scope.U = changeHandler);
318
+ changeHandler && (scope.U = changeHandler);
299
319
  }
300
- var _var_change = (scope, value) => scope.U?.(value), tagIdsByGlobal = /* @__PURE__ */ new WeakMap();
301
- function _id({ ["$" /* Global */]: $global }) {
302
- let id = tagIdsByGlobal.get($global) || 0;
303
- return tagIdsByGlobal.set($global, id + 1), "c" + $global.runtimeId + $global.renderId + id.toString(36);
320
+ function _id({ $: $global }) {
321
+ let id = tagIdsByGlobal.get($global) || 0;
322
+ return tagIdsByGlobal.set($global, id + 1), "c" + $global.runtimeId + $global.renderId + id.toString(36);
304
323
  }
305
324
  function _script(id, fn) {
306
- return _resume(id, fn), (scope) => {
307
- queueEffect(scope, fn);
308
- };
325
+ return _resume(id, fn), (scope) => {
326
+ queueEffect(scope, fn);
327
+ };
309
328
  }
310
329
  function _el_read(value) {
311
- return rendering && void 0, value;
330
+ return value;
312
331
  }
313
332
  function* traverse(scope, path, i = path.length - 1) {
314
- if (scope)
315
- if (Symbol.iterator in scope)
316
- for (let childScope of scope.values())
317
- yield* traverse(childScope, path, i);
318
- else {
319
- let item = scope[path[i]];
320
- i ? yield* traverse(item, path, i - 1) : yield typeof item == "function" ? item() : item;
321
- }
333
+ if (scope) if (Symbol.iterator in scope) for (let childScope of scope.values()) yield* traverse(childScope, path, i);
334
+ else {
335
+ let item = scope[path[i]];
336
+ i ? yield* traverse(item, path, i - 1) : yield typeof item == "function" ? item() : item;
337
+ }
322
338
  }
323
339
  function _hoist(...path) {
324
- return path = path.map((p) => typeof p == "string" ? p : decodeAccessor(p)), (scope) => {
325
- let fn = () => traverse(scope, path).next().value;
326
- return fn[Symbol.iterator] = () => traverse(scope, path), fn;
327
- };
340
+ return path = path.map((p) => typeof p == "string" ? p : decodeAccessor(p)), (scope) => {
341
+ let fn = () => traverse(scope, path).next().value;
342
+ return fn[Symbol.iterator] = () => traverse(scope, path), fn;
343
+ };
328
344
  }
329
345
  function _hoist_resume(id, ...path) {
330
- return _resume(id, _hoist(...path));
346
+ return _resume(id, _hoist(...path));
331
347
  }
332
-
333
- // src/dom/walker.ts
334
- var walker = /* @__PURE__ */ document.createTreeWalker(document);
348
+ //#endregion
349
+ //#region src/dom/walker.ts
335
350
  function walk(startNode, walkCodes, branch) {
336
- walker.currentNode = startNode, walkInternal(0, walkCodes, branch);
337
- }
338
- function walkInternal(currentWalkIndex, walkCodes, scope) {
339
- let value, currentMultiplier, storedMultiplier = 0, currentScopeIndex = 0;
340
- for (; currentWalkIndex < walkCodes.length; )
341
- if (value = walkCodes.charCodeAt(currentWalkIndex++), currentMultiplier = storedMultiplier, storedMultiplier = 0, value === 32 /* Get */) {
342
- let node = walker.currentNode;
343
- scope[decodeAccessor(currentScopeIndex++)] = node;
344
- } else if (value === 37 /* Replace */ || value === 49 /* DynamicTagWithVar */)
345
- walker.currentNode.replaceWith(
346
- walker.currentNode = scope[decodeAccessor(currentScopeIndex++)] = new Text()
347
- ), value === 49 /* DynamicTagWithVar */ && (scope[decodeAccessor(currentScopeIndex++)] = skipScope());
348
- else {
349
- if (value === 38 /* EndChild */)
350
- return currentWalkIndex;
351
- if (value === 47 /* BeginChild */ || value === 48 /* BeginChildWithVar */)
352
- currentWalkIndex = walkInternal(
353
- currentWalkIndex,
354
- walkCodes,
355
- scope[decodeAccessor(currentScopeIndex++)] = createScope(
356
- scope.$,
357
- scope.F
358
- )
359
- ), value === 48 /* BeginChildWithVar */ && (scope[decodeAccessor(currentScopeIndex++)] = skipScope());
360
- else if (value < 92)
361
- for (value = 20 /* Next */ * currentMultiplier + value - 67 /* Next */; value--; )
362
- walker.nextNode();
363
- else if (value < 107)
364
- for (value = 10 /* Over */ * currentMultiplier + value - 97 /* Over */; value--; )
365
- walker.nextSibling();
366
- else if (value < 117) {
367
- for (value = 10 /* Out */ * currentMultiplier + value - 107 /* Out */; value--; )
368
- walker.parentNode();
369
- walker.nextSibling();
370
- } else
371
- storedMultiplier = currentMultiplier * 10 /* Multiplier */ + value - 117 /* Multiplier */;
372
- }
373
- }
374
-
375
- // src/dom/renderer.ts
351
+ walker.currentNode = startNode, walkInternal(0, walkCodes, branch);
352
+ }
353
+ //#endregion
354
+ //#region src/dom/renderer.ts
376
355
  function createBranch($global, renderer, parentScope, parentNode) {
377
- let branch = createScope($global);
378
- return branch._ = renderer.f || parentScope, setParentBranch(branch, parentScope?.F), renderer.k?.(
379
- branch,
380
- parentNode.namespaceURI
381
- ), branch;
356
+ let branch = createScope($global);
357
+ return branch._ = renderer.e || parentScope, setParentBranch(branch, parentScope?.F), renderer.b?.(branch, parentNode.namespaceURI), branch;
382
358
  }
383
359
  function setParentBranch(branch, parentBranch) {
384
- parentBranch && (branch.N = parentBranch, (parentBranch.D ||= /* @__PURE__ */ new Set()).add(branch)), branch.F = branch;
360
+ parentBranch && (branch.N = parentBranch, (parentBranch.D ||= /* @__PURE__ */ new Set()).add(branch)), branch.F = branch;
385
361
  }
386
362
  function createAndSetupBranch($global, renderer, parentScope, parentNode) {
387
- return setupBranch(
388
- renderer,
389
- createBranch($global, renderer, parentScope, parentNode)
390
- );
363
+ return setupBranch(renderer, createBranch($global, renderer, parentScope, parentNode));
391
364
  }
392
365
  function setupBranch(renderer, branch) {
393
- return renderer.l && queueRender(branch, renderer.l, -1), branch;
366
+ return renderer.c && queueRender(branch, renderer.c, -1), branch;
394
367
  }
395
368
  function _content(id, template, walks, setup, params, dynamicScopesAccessor) {
396
- walks = walks ? walks.replace(/[^\0-1]+$/, "") : "", setup = setup ? setup._ || setup : void 0, params ||= void 0;
397
- let clone = template ? (branch, ns) => {
398
- ((cloneCache[ns] ||= {})[template] ||= createCloneableHTML(
399
- template,
400
- ns
401
- ))(branch, walks);
402
- } : (branch) => {
403
- walk(
404
- branch.S = branch.K = new Text(),
405
- walks,
406
- branch
407
- );
408
- };
409
- return (owner) => ({
410
- g: id,
411
- k: clone,
412
- f: owner,
413
- l: setup,
414
- d: params,
415
- e: dynamicScopesAccessor
416
- });
369
+ walks = walks ? walks.replace(/[^\0-1]+$/, "") : "", setup = setup ? setup._ || setup : void 0, params ||= void 0;
370
+ let clone = template ? (branch, ns) => {
371
+ ((cloneCache[ns] ||= {})[template] ||= createCloneableHTML(template, ns))(branch, walks);
372
+ } : (branch) => {
373
+ walk(branch.S = branch.K = new Text(), walks, branch);
374
+ };
375
+ return (owner) => ({
376
+ a: id,
377
+ b: clone,
378
+ e: owner,
379
+ c: setup,
380
+ d: params,
381
+ f: dynamicScopesAccessor
382
+ });
417
383
  }
418
384
  function _content_resume(id, template, walks, setup, params, dynamicScopesAccessor) {
419
- return _resume(
420
- id,
421
- _content(id, template, walks, setup, params, dynamicScopesAccessor)
422
- );
385
+ return _resume(id, _content(id, template, walks, setup, params, dynamicScopesAccessor));
423
386
  }
424
387
  function _content_closures(renderer, closureFns) {
425
- let closureSignals = {};
426
- for (let key in closureFns)
427
- closureSignals[key] = _const(+key, closureFns[key]);
428
- return (owner, closureValues) => {
429
- let instance = renderer(owner);
430
- return instance.h = closureSignals, instance.t = closureValues, instance;
431
- };
432
- }
433
- var cloneCache = {};
388
+ let closureSignals = {};
389
+ for (let key in closureFns) closureSignals[key] = _const(+key, closureFns[key]);
390
+ return (owner, closureValues) => {
391
+ let instance = renderer(owner);
392
+ return instance.g = closureSignals, instance.h = closureValues, instance;
393
+ };
394
+ }
434
395
  function createCloneableHTML(html, ns) {
435
- let { firstChild, lastChild } = parseHTML(html, ns), parent = document.createElementNS(ns, "t");
436
- return insertChildNodes(parent, null, firstChild, lastChild), firstChild === lastChild && firstChild.nodeType < 8 /* Comment */ ? (branch, walks) => {
437
- walk(
438
- branch.S = branch.K = firstChild.cloneNode(!0),
439
- walks,
440
- branch
441
- );
442
- } : (branch, walks) => {
443
- let clone = parent.cloneNode(!0);
444
- walk(clone.firstChild, walks, branch), branch.S = clone.firstChild, branch.K = clone.lastChild;
445
- };
446
- }
447
-
448
- // src/dom/resume.ts
449
- var registeredValues = {}, curRuntimeId, readyLookup, branchesEnabled, embedEnabled;
396
+ let { firstChild, lastChild } = parseHTML(html, ns), parent = document.createElementNS(ns, "t");
397
+ return insertChildNodes(parent, null, firstChild, lastChild), firstChild === lastChild && firstChild.nodeType < 8 ? (branch, walks) => {
398
+ walk(branch.S = branch.K = firstChild.cloneNode(!0), walks, branch);
399
+ } : (branch, walks) => {
400
+ let clone = parent.cloneNode(!0);
401
+ walk(clone.firstChild, walks, branch), branch.S = clone.firstChild, branch.K = clone.lastChild;
402
+ };
403
+ }
404
+ //#endregion
405
+ //#region src/dom/resume.ts
450
406
  function enableBranches() {
451
- branchesEnabled = 1;
407
+ branchesEnabled = 1;
452
408
  }
453
- var ready = /* @__PURE__ */ ((_) => (id) => {
454
- readyLookup[id]?.(), readyLookup[id] = 1;
455
- })(readyLookup = {});
456
409
  function initEmbedded(readyId, runtimeId) {
457
- embedEnabled = 1, ready(readyId), init(runtimeId), new MutationObserver(() => {
458
- let renders = self[curRuntimeId];
459
- for (let renderId in renders) {
460
- let { s, n } = renders[renderId];
461
- if (n && !n.isConnected) {
462
- delete renders[renderId];
463
- for (let id in s)
464
- destroyScope(s[id]);
465
- }
466
- }
467
- }).observe(document.body, { childList: !0, subtree: !0 });
410
+ embedEnabled = 1, ready(readyId), init(runtimeId), new MutationObserver(() => {
411
+ let renders = self[curRuntimeId];
412
+ for (let renderId in renders) {
413
+ let { s, n } = renders[renderId];
414
+ if (n && !n.isConnected) {
415
+ delete renders[renderId];
416
+ for (let id in s) destroyScope(s[id]);
417
+ }
418
+ }
419
+ }).observe(document.body, {
420
+ childList: !0,
421
+ subtree: !0
422
+ });
468
423
  }
469
424
  function init(runtimeId = "M") {
470
- if (curRuntimeId)
471
- return;
472
- curRuntimeId = runtimeId;
473
- let resumeRender, renders = self[runtimeId], defineRuntime = (desc) => Object.defineProperty(self, runtimeId, desc), initRuntime = (renders2) => {
474
- defineRuntime({
475
- value: resumeRender = ((renderId) => {
476
- let render = resumeRender[renderId] = renders2[renderId] || renders2(renderId), walk2 = render.w, scopeLookup = render.s = {}, getScope = (id) => scopeLookup[id] ||= { L: +id }, serializeContext = {
477
- _: registeredValues
478
- }, visitBranches = branchesEnabled && /* @__PURE__ */ ((branchScopesStack = [], branchStarts = [], orphanBranches = [], curBranchScopes) => (branchId, branch, endedBranches, accessor, singleNode, parent = visit.parentNode, startVisit = visit, i = orphanBranches.length) => {
479
- for (visitType !== "[" /* BranchStart */ && (visitScope[nextToken(
480
- /* read accessor */
481
- )] = visitType === ")" /* BranchEndOnlyChildInParent */ || visitType === "}" /* BranchEndSingleNodeOnlyChildInParent */ ? parent : visit, accessor = "A" /* BranchScopes */ + lastToken, singleNode = visitType !== "]" /* BranchEnd */ && visitType !== ")" /* BranchEndOnlyChildInParent */, nextToken(
482
- /* read optional first branchId */
483
- )); branchId = +lastToken; ) {
484
- if ((endedBranches ||= []).push(
485
- branch = getScope(branchId)
486
- ), setParentBranch(branch, branch.F), (branch.O = render.p?.[branchId]) && (branch.O.m = render.m), singleNode) {
487
- for (; startVisit.previousSibling && ~visits.indexOf(
488
- startVisit = startVisit.previousSibling
489
- ); ) ;
490
- branch.K = branch.S = startVisit, visitType === "'" /* BranchEndNativeTag */ && (branch.a = startVisit);
491
- } else
492
- curBranchScopes = push(curBranchScopes, branch), accessor && (visitScope[accessor] = curBranchScopes, curBranchScopes = branchScopesStack.pop()), startVisit = branchStarts.pop(), parent !== startVisit.parentNode && parent.prepend(startVisit), branch.S = startVisit, branch.K = visit.previousSibling === startVisit ? startVisit : parent.insertBefore(new Text(), visit);
493
- for (; i && orphanBranches[--i].L > branchId; )
494
- setParentBranch(orphanBranches.pop(), branch);
495
- nextToken(
496
- /* read optional next branchId */
497
- );
498
- }
499
- endedBranches && (orphanBranches.push(...endedBranches), singleNode && (visitScope[accessor] = endedBranches.length > 1 ? endedBranches.reverse() : endedBranches[0])), visitType === "[" /* BranchStart */ && (endedBranches || (branchScopesStack.push(curBranchScopes), curBranchScopes = void 0), branchStarts.push(visit));
500
- })(), nextToken = () => lastToken = visitText.slice(
501
- lastTokenIndex,
502
- (lastTokenIndex = visitText.indexOf(" ", lastTokenIndex) + 1 || visitText.length + 1) - 1
503
- ), $global, lastEffect, visits, resumes, visit, visitText, visitType, visitScope, lastToken, lastTokenIndex, lastScopeId = 0;
504
- return render.m = (effects = []) => {
505
- if (readyLookup) {
506
- for (let readyId in render.b)
507
- if (readyLookup[readyId] !== 1)
508
- return readyLookup[readyId] = /* @__PURE__ */ ((prev) => () => {
509
- render.m(), prev?.();
510
- })(readyLookup[readyId]), effects;
511
- render.b = 0;
512
- }
513
- for (let serialized of resumes = render.r || [])
514
- if (typeof serialized == "string")
515
- for (lastTokenIndex = 0, visitText = serialized; nextToken(); )
516
- /\D/.test(lastToken) ? lastEffect = registeredValues[lastToken] : effects.push(lastEffect, getScope(lastToken));
517
- else
518
- for (let scope of serialized(serializeContext))
519
- $global ? typeof scope == "number" ? lastScopeId += scope : (scopeLookup[scope.L = ++lastScopeId] = scope, scope.$ = $global, branchesEnabled && (scope.F = getScope(
520
- scope.G
521
- ))) : ($global = scope || {}, $global.runtimeId = runtimeId, $global.renderId = renderId);
522
- for (visit of visits = render.v)
523
- if (lastTokenIndex = render.i.length, visitText = visit.data, visitType = visitText[lastTokenIndex++], visitScope = getScope(nextToken(
524
- /* read scope id */
525
- )), visitType === "*" /* Node */) {
526
- let prev = visit.previousSibling;
527
- visitScope[nextToken(
528
- /* read accessor */
529
- )] = prev && (prev.nodeType < 8 || prev.data) ? prev : visit.parentNode.insertBefore(new Text(), visit);
530
- } else branchesEnabled && visitBranches();
531
- return embedEnabled && (render.n ||= visit?.parentNode.insertBefore(
532
- new Text(),
533
- visit.nextSibling
534
- )), visits.length = resumes.length = 0, effects;
535
- }, render.w = () => {
536
- walk2(), runResumeEffects(render);
537
- }, render;
538
- })
539
- });
540
- };
541
- if (renders) {
542
- initRuntime(renders);
543
- for (let renderId in renders)
544
- runResumeEffects(resumeRender(renderId));
545
- } else
546
- defineRuntime({
547
- configurable: !0,
548
- set: initRuntime
549
- });
550
- }
551
- var isResuming;
425
+ if (curRuntimeId) return;
426
+ curRuntimeId = runtimeId;
427
+ let resumeRender, renders = self[runtimeId], defineRuntime = (desc) => Object.defineProperty(self, runtimeId, desc), initRuntime = (renders) => {
428
+ defineRuntime({ value: resumeRender = ((renderId) => {
429
+ let render = resumeRender[renderId] = renders[renderId] || renders(renderId), walk = render.w, scopeLookup = render.s = {}, getScope = (id) => scopeLookup[id] ||= { L: +id }, serializeContext = { _: registeredValues }, visitBranches = branchesEnabled && ((branchScopesStack = [], branchStarts = [], orphanBranches = [], curBranchScopes) => (branchId, branch, endedBranches, accessor, singleNode, parent = visit.parentNode, startVisit = visit, i = orphanBranches.length) => {
430
+ for (visitType !== "[" && (visitScope[nextToken()] = visitType === ")" || visitType === "}" ? parent : visit, accessor = "A" + lastToken, singleNode = visitType !== "]" && visitType !== ")", nextToken()); branchId = +lastToken;) {
431
+ if ((endedBranches ||= []).push(branch = getScope(branchId)), setParentBranch(branch, branch.F), (branch.O = render.p?.[branchId]) && (branch.O.m = render.m), singleNode) {
432
+ for (; startVisit.previousSibling && ~visits.indexOf(startVisit = startVisit.previousSibling););
433
+ branch.K = branch.S = startVisit, visitType === "'" && (branch.a = startVisit);
434
+ } else curBranchScopes = push(curBranchScopes, branch), accessor && (visitScope[accessor] = curBranchScopes, curBranchScopes = branchScopesStack.pop()), startVisit = branchStarts.pop(), parent !== startVisit.parentNode && parent.prepend(startVisit), branch.S = startVisit, branch.K = visit.previousSibling === startVisit ? startVisit : parent.insertBefore(new Text(), visit);
435
+ for (; i && orphanBranches[--i].L > branchId;) setParentBranch(orphanBranches.pop(), branch);
436
+ nextToken();
437
+ }
438
+ endedBranches && (orphanBranches.push(...endedBranches), singleNode && (visitScope[accessor] = endedBranches.length > 1 ? endedBranches.reverse() : endedBranches[0])), visitType === "[" && (endedBranches || (branchScopesStack.push(curBranchScopes), curBranchScopes = void 0), branchStarts.push(visit));
439
+ })(), nextToken = () => lastToken = visitText.slice(lastTokenIndex, (lastTokenIndex = visitText.indexOf(" ", lastTokenIndex) + 1 || visitText.length + 1) - 1), $global, lastEffect, visits, resumes, visit, visitText, visitType, visitScope, lastToken, lastTokenIndex, lastScopeId = 0;
440
+ return render.m = (effects = []) => {
441
+ if (readyLookup) {
442
+ for (let readyId in render.b) if (readyLookup[readyId] !== 1) return readyLookup[readyId] = ((prev) => () => {
443
+ render.m(), prev?.();
444
+ })(readyLookup[readyId]), effects;
445
+ render.b = 0;
446
+ }
447
+ for (let serialized of resumes = render.r || []) if (typeof serialized == "string") for (lastTokenIndex = 0, visitText = serialized; nextToken();) /\D/.test(lastToken) ? lastEffect = registeredValues[lastToken] : effects.push(lastEffect, getScope(lastToken));
448
+ else for (let scope of serialized(serializeContext)) $global ? typeof scope == "number" ? lastScopeId += scope : (scopeLookup[scope.L = ++lastScopeId] = scope, scope.$ = $global, branchesEnabled && (scope.F = getScope(scope.G))) : ($global = scope || {}, $global.runtimeId = runtimeId, $global.renderId = renderId);
449
+ for (visit of visits = render.v) if (lastTokenIndex = render.i.length, visitText = visit.data, visitType = visitText[lastTokenIndex++], visitScope = getScope(nextToken()), visitType === "*") {
450
+ let prev = visit.previousSibling;
451
+ visitScope[nextToken()] = prev && (prev.nodeType < 8 || prev.data) ? prev : visit.parentNode.insertBefore(new Text(), visit);
452
+ } else branchesEnabled && visitBranches();
453
+ return embedEnabled && (render.n ||= visit?.parentNode.insertBefore(new Text(), visit.nextSibling)), visits.length = resumes.length = 0, effects;
454
+ }, render.w = () => {
455
+ walk(), runResumeEffects(render);
456
+ }, render;
457
+ }) });
458
+ };
459
+ if (renders) {
460
+ initRuntime(renders);
461
+ for (let renderId in renders) runResumeEffects(resumeRender(renderId));
462
+ } else defineRuntime({
463
+ configurable: !0,
464
+ set: initRuntime
465
+ });
466
+ }
552
467
  function runResumeEffects(render) {
553
- try {
554
- isResuming = 1, runEffects(render.m(), 1);
555
- } finally {
556
- isResuming = 0;
557
- }
468
+ try {
469
+ isResuming = 1, runEffects(render.m(), 1);
470
+ } finally {
471
+ isResuming = 0;
472
+ }
558
473
  }
559
474
  function getRegisteredWithScope(id, scope) {
560
- let val = registeredValues[id];
561
- return scope ? val(scope) : val;
475
+ let val = registeredValues[id];
476
+ return scope ? val(scope) : val;
562
477
  }
563
478
  function _resume(id, obj) {
564
- return registeredValues[id] = obj;
479
+ return registeredValues[id] = obj;
565
480
  }
566
481
  function _var_resume(id, signal) {
567
- return _resume(id, (scope) => (value) => signal(scope, value)), signal;
482
+ return _resume(id, (scope) => (value) => signal(scope, value)), signal;
568
483
  }
569
484
  function _el(id, accessor) {
570
- return accessor = decodeAccessor(accessor), _resume(id, (scope) => () => scope[accessor]);
485
+ return accessor = decodeAccessor(accessor), _resume(id, (scope) => () => scope[accessor]);
571
486
  }
572
-
573
- // src/dom/controllable.ts
574
- var inputType = "", controllableDelegate = createDelegator();
487
+ //#endregion
488
+ //#region src/dom/controllable.ts
575
489
  function _attr_input_checked_default(scope, nodeAccessor, checked) {
576
- let el = scope[nodeAccessor], normalizedChecked = normalizeBoolProp(checked);
577
- if (el.defaultChecked !== normalizedChecked) {
578
- let restoreValue = scope.H ? normalizedChecked : el.checked;
579
- el.defaultChecked = normalizedChecked, restoreValue !== normalizedChecked && (el.checked = restoreValue);
580
- }
490
+ let el = scope[nodeAccessor], normalizedChecked = normalizeBoolProp(checked);
491
+ if (el.defaultChecked !== normalizedChecked) {
492
+ let restoreValue = scope.H ? normalizedChecked : el.checked;
493
+ el.defaultChecked = normalizedChecked, restoreValue !== normalizedChecked && (el.checked = restoreValue);
494
+ }
581
495
  }
582
496
  function _attr_input_checked(scope, nodeAccessor, checked, checkedChange) {
583
- let el = scope[nodeAccessor], normalizedChecked = normalizeBoolProp(checked);
584
- scope["E" /* ControlledHandler */ + nodeAccessor] = checkedChange, scope["F" /* ControlledType */ + nodeAccessor] = checkedChange ? 0 /* InputChecked */ : 5 /* None */, checkedChange && !scope.H ? el.checked = normalizedChecked : _attr_input_checked_default(scope, nodeAccessor, normalizedChecked);
497
+ let el = scope[nodeAccessor], normalizedChecked = normalizeBoolProp(checked);
498
+ scope["E" + nodeAccessor] = checkedChange, scope["F" + nodeAccessor] = checkedChange ? 0 : 5, checkedChange && !scope.H ? el.checked = normalizedChecked : _attr_input_checked_default(scope, nodeAccessor, normalizedChecked);
585
499
  }
586
500
  function _attr_input_checked_script(scope, nodeAccessor) {
587
- let el = scope[nodeAccessor];
588
- syncControllableFormInput(el, hasCheckboxChanged, () => {
589
- let checkedChange = scope["E" /* ControlledHandler */ + nodeAccessor];
590
- if (checkedChange) {
591
- let newValue = el.checked;
592
- el.checked = !newValue, checkedChange(newValue), run();
593
- }
594
- });
501
+ let el = scope[nodeAccessor];
502
+ syncControllableFormInput(el, hasCheckboxChanged, () => {
503
+ let checkedChange = scope["E" + nodeAccessor];
504
+ if (checkedChange) {
505
+ let newValue = el.checked;
506
+ el.checked = !newValue, checkedChange(newValue), run();
507
+ }
508
+ });
595
509
  }
596
510
  function _attr_input_checkedValue_default(scope, nodeAccessor, checkedValue, value) {
597
- let multiple = Array.isArray(checkedValue), normalizedValue = normalizeStrProp(value), normalizedCheckedValue = multiple ? checkedValue.map(normalizeStrProp) : normalizeStrProp(checkedValue);
598
- _attr(scope[nodeAccessor], "value", normalizedValue), _attr_input_checked_default(
599
- scope,
600
- nodeAccessor,
601
- multiple ? normalizedCheckedValue.includes(normalizedValue) : normalizedValue === normalizedCheckedValue
602
- );
511
+ let multiple = Array.isArray(checkedValue), normalizedValue = normalizeStrProp(value), normalizedCheckedValue = multiple ? checkedValue.map(normalizeStrProp) : normalizeStrProp(checkedValue);
512
+ _attr(scope[nodeAccessor], "value", normalizedValue), _attr_input_checked_default(scope, nodeAccessor, multiple ? normalizedCheckedValue.includes(normalizedValue) : normalizedValue === normalizedCheckedValue);
603
513
  }
604
514
  function _attr_input_checkedValue(scope, nodeAccessor, checkedValue, checkedValueChange, value) {
605
- let el = scope[nodeAccessor], multiple = Array.isArray(checkedValue), normalizedValue = normalizeStrProp(value), normalizedCheckedValue = scope["G" /* ControlledValue */ + nodeAccessor] = multiple ? checkedValue.map(normalizeStrProp) : normalizeStrProp(checkedValue);
606
- _attr(el, "value", normalizedValue), scope["E" /* ControlledHandler */ + nodeAccessor] = checkedValueChange, scope["F" /* ControlledType */ + nodeAccessor] = checkedValueChange ? 1 /* InputCheckedValue */ : 5 /* None */, checkedValueChange && !scope.H ? el.checked = multiple ? normalizedCheckedValue.includes(normalizedValue) : normalizedValue === normalizedCheckedValue : _attr_input_checkedValue_default(
607
- scope,
608
- nodeAccessor,
609
- normalizedCheckedValue,
610
- normalizedValue
611
- );
515
+ let el = scope[nodeAccessor], multiple = Array.isArray(checkedValue), normalizedValue = normalizeStrProp(value), normalizedCheckedValue = scope["G" + nodeAccessor] = multiple ? checkedValue.map(normalizeStrProp) : normalizeStrProp(checkedValue);
516
+ _attr(el, "value", normalizedValue), scope["E" + nodeAccessor] = checkedValueChange, scope["F" + nodeAccessor] = checkedValueChange ? 1 : 5, checkedValueChange && !scope.H ? el.checked = multiple ? normalizedCheckedValue.includes(normalizedValue) : normalizedValue === normalizedCheckedValue : _attr_input_checkedValue_default(scope, nodeAccessor, normalizedCheckedValue, normalizedValue);
612
517
  }
613
518
  function _attr_input_checkedValue_script(scope, nodeAccessor) {
614
- let el = scope[nodeAccessor];
615
- isResuming && el.defaultChecked && (scope["G" /* ControlledValue */ + nodeAccessor] ? scope["G" /* ControlledValue */ + nodeAccessor].push(
616
- el.value
617
- ) : scope["G" /* ControlledValue */ + nodeAccessor] = el.value), syncControllableFormInput(el, hasCheckboxChanged, () => {
618
- let checkedValueChange = scope["E" /* ControlledHandler */ + nodeAccessor];
619
- if (checkedValueChange) {
620
- let oldValue = scope["G" /* ControlledValue */ + nodeAccessor], newValue = Array.isArray(oldValue) ? updateList(oldValue, el.value, el.checked) : el.checked ? el.value : void 0;
621
- if (el.name && el.type[0] === "r")
622
- for (let radio of el.getRootNode().querySelectorAll(
623
- `[type=radio][name=${CSS.escape(el.name)}]`
624
- ))
625
- radio.form === el.form && (radio.checked = Array.isArray(oldValue) ? oldValue.includes(radio.value) : oldValue === radio.value);
626
- else
627
- el.checked = !el.checked;
628
- checkedValueChange(newValue), run();
629
- }
630
- });
519
+ let el = scope[nodeAccessor];
520
+ isResuming && el.defaultChecked && (scope["G" + nodeAccessor] ? scope["G" + nodeAccessor].push(el.value) : scope["G" + nodeAccessor] = el.value), syncControllableFormInput(el, hasCheckboxChanged, () => {
521
+ let checkedValueChange = scope["E" + nodeAccessor];
522
+ if (checkedValueChange) {
523
+ let oldValue = scope["G" + nodeAccessor], newValue = Array.isArray(oldValue) ? updateList(oldValue, el.value, el.checked) : el.checked ? el.value : void 0;
524
+ if (el.name && el.type[0] === "r") for (let radio of el.getRootNode().querySelectorAll(`[type=radio][name=${CSS.escape(el.name)}]`)) radio.form === el.form && (radio.checked = Array.isArray(oldValue) ? oldValue.includes(radio.value) : oldValue === radio.value);
525
+ else el.checked = !el.checked;
526
+ checkedValueChange(newValue), run();
527
+ }
528
+ });
631
529
  }
632
530
  function _attr_input_value_default(scope, nodeAccessor, value) {
633
- let el = scope[nodeAccessor], normalizedValue = normalizeStrProp(value);
634
- if (el.defaultValue !== normalizedValue) {
635
- let restoreValue = scope.H ? normalizedValue : el.value;
636
- el.defaultValue = normalizedValue, setInputValue(el, restoreValue);
637
- }
531
+ let el = scope[nodeAccessor], normalizedValue = normalizeStrProp(value);
532
+ if (el.defaultValue !== normalizedValue) {
533
+ let restoreValue = scope.H ? normalizedValue : el.value;
534
+ el.defaultValue = normalizedValue, setInputValue(el, restoreValue);
535
+ }
638
536
  }
639
537
  function _attr_input_value(scope, nodeAccessor, value, valueChange) {
640
- let el = scope[nodeAccessor], normalizedValue = normalizeStrProp(value);
641
- scope["E" /* ControlledHandler */ + nodeAccessor] = valueChange, scope["G" /* ControlledValue */ + nodeAccessor] = normalizedValue, scope["F" /* ControlledType */ + nodeAccessor] = valueChange ? 2 /* InputValue */ : 5 /* None */, valueChange && !scope.H ? setInputValue(el, normalizedValue) : _attr_input_value_default(scope, nodeAccessor, normalizedValue);
538
+ let el = scope[nodeAccessor], normalizedValue = normalizeStrProp(value);
539
+ scope["E" + nodeAccessor] = valueChange, scope["G" + nodeAccessor] = normalizedValue, scope["F" + nodeAccessor] = valueChange ? 2 : 5, valueChange && !scope.H ? setInputValue(el, normalizedValue) : _attr_input_value_default(scope, nodeAccessor, normalizedValue);
642
540
  }
643
541
  function _attr_input_value_script(scope, nodeAccessor) {
644
- let el = scope[nodeAccessor];
645
- isResuming && (scope["G" /* ControlledValue */ + nodeAccessor] = el.defaultValue), syncControllableFormInput(el, hasValueChanged, (ev) => {
646
- let valueChange = scope["E" /* ControlledHandler */ + nodeAccessor];
647
- valueChange && (inputType = ev?.inputType, valueChange(el.value), run(), setInputValue(el, scope["G" /* ControlledValue */ + nodeAccessor]), inputType = "");
648
- });
542
+ let el = scope[nodeAccessor];
543
+ isResuming && (scope["G" + nodeAccessor] = el.defaultValue), syncControllableFormInput(el, hasValueChanged, (ev) => {
544
+ let valueChange = scope["E" + nodeAccessor];
545
+ valueChange && (inputType = ev?.inputType, valueChange(el.value), run(), setInputValue(el, scope["G" + nodeAccessor]), inputType = "");
546
+ });
649
547
  }
650
548
  function setInputValue(el, value) {
651
- if (el.value !== value) {
652
- let updatedPosition = resolveCursorPosition(
653
- inputType,
654
- el.getRootNode().activeElement === el && el.selectionStart,
655
- el.value,
656
- el.value = value
657
- );
658
- ~updatedPosition && el.setSelectionRange(updatedPosition, updatedPosition);
659
- }
549
+ if (el.value !== value) {
550
+ let updatedPosition = resolveCursorPosition(inputType, el.getRootNode().activeElement === el && el.selectionStart, el.value, el.value = value);
551
+ ~updatedPosition && el.setSelectionRange(updatedPosition, updatedPosition);
552
+ }
660
553
  }
661
554
  function _attr_select_value_default(scope, nodeAccessor, value) {
662
- let restoreValue, el = scope[nodeAccessor], existing = !scope.H, multiple = Array.isArray(value), normalizedValue = multiple ? value.map(normalizeStrProp) : normalizeStrProp(value);
663
- pendingEffects.unshift(() => {
664
- for (let opt of el.options) {
665
- let selected = multiple ? normalizedValue.includes(opt.value) : opt.value === normalizedValue;
666
- opt.defaultSelected !== selected && (existing && (restoreValue ??= getSelectValue(el, multiple)), opt.defaultSelected = selected);
667
- }
668
- restoreValue !== void 0 && setSelectValue(el, restoreValue, multiple);
669
- }, scope);
555
+ let restoreValue, el = scope[nodeAccessor], existing = !scope.H, multiple = Array.isArray(value), normalizedValue = multiple ? value.map(normalizeStrProp) : normalizeStrProp(value);
556
+ pendingEffects.unshift(() => {
557
+ for (let opt of el.options) {
558
+ let selected = multiple ? normalizedValue.includes(opt.value) : opt.value === normalizedValue;
559
+ opt.defaultSelected !== selected && (existing && (restoreValue ??= getSelectValue(el, multiple)), opt.defaultSelected = selected);
560
+ }
561
+ restoreValue !== void 0 && setSelectValue(el, restoreValue, multiple);
562
+ }, scope);
670
563
  }
671
564
  function _attr_select_value(scope, nodeAccessor, value, valueChange) {
672
- let el = scope[nodeAccessor], existing = !scope.H, multiple = Array.isArray(value), normalizedValue = scope["G" /* ControlledValue */ + nodeAccessor] = multiple ? value.map(normalizeStrProp) : normalizeStrProp(value);
673
- scope["E" /* ControlledHandler */ + nodeAccessor] = valueChange, scope["F" /* ControlledType */ + nodeAccessor] = valueChange ? 3 /* SelectValue */ : 5 /* None */, valueChange && existing ? pendingEffects.unshift(
674
- () => setSelectValue(el, normalizedValue, multiple),
675
- scope
676
- ) : _attr_select_value_default(scope, nodeAccessor, normalizedValue);
565
+ let el = scope[nodeAccessor], existing = !scope.H, multiple = Array.isArray(value), normalizedValue = scope["G" + nodeAccessor] = multiple ? value.map(normalizeStrProp) : normalizeStrProp(value);
566
+ scope["E" + nodeAccessor] = valueChange, scope["F" + nodeAccessor] = valueChange ? 3 : 5, valueChange && existing ? pendingEffects.unshift(() => setSelectValue(el, normalizedValue, multiple), scope) : _attr_select_value_default(scope, nodeAccessor, normalizedValue);
677
567
  }
678
568
  function _attr_select_value_script(scope, nodeAccessor) {
679
- let el = scope[nodeAccessor], onChange = () => {
680
- let valueChange = scope["E" /* ControlledHandler */ + nodeAccessor];
681
- if (valueChange) {
682
- let oldValue = scope["G" /* ControlledValue */ + nodeAccessor], multiple = Array.isArray(oldValue), newValue = getSelectValue(el, multiple);
683
- setSelectValue(el, oldValue, multiple), valueChange(newValue), run();
684
- }
685
- };
686
- if (isResuming)
687
- if (el.multiple) {
688
- scope["G" /* ControlledValue */ + nodeAccessor] = [];
689
- for (let opt of el.options)
690
- opt.defaultSelected && scope["G" /* ControlledValue */ + nodeAccessor].push(opt.value);
691
- } else {
692
- scope["G" /* ControlledValue */ + nodeAccessor] = "";
693
- for (let opt of el.options)
694
- if (opt.defaultSelected) {
695
- scope["G" /* ControlledValue */ + nodeAccessor] = opt.value;
696
- break;
697
- }
698
- }
699
- syncControllableFormInput(el, hasSelectChanged, onChange), new MutationObserver(() => {
700
- let value = scope["G" /* ControlledValue */ + nodeAccessor];
701
- (Array.isArray(value) ? value.length !== el.selectedOptions.length || value.some((value2, i) => value2 != el.selectedOptions[i].value) : el.value !== value) && onChange();
702
- }).observe(el, { childList: !0, subtree: !0 });
569
+ let el = scope[nodeAccessor], onChange = () => {
570
+ let valueChange = scope["E" + nodeAccessor];
571
+ if (valueChange) {
572
+ let oldValue = scope["G" + nodeAccessor], multiple = Array.isArray(oldValue), newValue = getSelectValue(el, multiple);
573
+ setSelectValue(el, oldValue, multiple), valueChange(newValue), run();
574
+ }
575
+ };
576
+ if (isResuming) if (el.multiple) {
577
+ scope["G" + nodeAccessor] = [];
578
+ for (let opt of el.options) opt.defaultSelected && scope["G" + nodeAccessor].push(opt.value);
579
+ } else {
580
+ scope["G" + nodeAccessor] = "";
581
+ for (let opt of el.options) if (opt.defaultSelected) {
582
+ scope["G" + nodeAccessor] = opt.value;
583
+ break;
584
+ }
585
+ }
586
+ syncControllableFormInput(el, hasSelectChanged, onChange), new MutationObserver(() => {
587
+ let value = scope["G" + nodeAccessor];
588
+ (Array.isArray(value) ? value.length !== el.selectedOptions.length || value.some((value, i) => value != el.selectedOptions[i].value) : el.value !== value) && onChange();
589
+ }).observe(el, {
590
+ childList: !0,
591
+ subtree: !0
592
+ });
703
593
  }
704
594
  function setSelectValue(el, value, multiple) {
705
- if (multiple)
706
- for (let opt of el.options)
707
- opt.selected = value.includes(opt.value);
708
- else
709
- el.value = value;
595
+ if (multiple) for (let opt of el.options) opt.selected = value.includes(opt.value);
596
+ else el.value = value;
710
597
  }
711
598
  function getSelectValue(el, multiple) {
712
- return multiple ? Array.from(el.selectedOptions, (opt) => opt.value) : el.value;
599
+ return multiple ? Array.from(el.selectedOptions, (opt) => opt.value) : el.value;
713
600
  }
714
601
  function _attr_details_or_dialog_open_default(scope, nodeAccessor, open) {
715
- scope.H && (scope[nodeAccessor].open = normalizeBoolProp(open));
602
+ scope.H && (scope[nodeAccessor].open = normalizeBoolProp(open));
716
603
  }
717
604
  function _attr_details_or_dialog_open(scope, nodeAccessor, open, openChange) {
718
- let normalizedOpen = scope["G" /* ControlledValue */ + nodeAccessor] = normalizeBoolProp(open);
719
- scope["E" /* ControlledHandler */ + nodeAccessor] = openChange, scope["F" /* ControlledType */ + nodeAccessor] = openChange ? 4 /* DetailsOrDialogOpen */ : 5 /* None */, openChange && !scope.H ? scope[nodeAccessor].open = normalizedOpen : _attr_details_or_dialog_open_default(scope, nodeAccessor, normalizedOpen);
605
+ let normalizedOpen = scope["G" + nodeAccessor] = normalizeBoolProp(open);
606
+ scope["E" + nodeAccessor] = openChange, scope["F" + nodeAccessor] = openChange ? 4 : 5, openChange && !scope.H ? scope[nodeAccessor].open = normalizedOpen : _attr_details_or_dialog_open_default(scope, nodeAccessor, normalizedOpen);
720
607
  }
721
608
  function _attr_details_or_dialog_open_script(scope, nodeAccessor) {
722
- let el = scope[nodeAccessor];
723
- new MutationObserver(() => {
724
- let openChange = scope["E" /* ControlledHandler */ + nodeAccessor];
725
- if (openChange && el.open === !scope["G" /* ControlledValue */ + nodeAccessor]) {
726
- let newValue = el.open;
727
- el.open = !newValue, openChange(newValue), run();
728
- }
729
- }).observe(el, { attributes: !0, attributeFilter: ["open"] });
609
+ let el = scope[nodeAccessor];
610
+ new MutationObserver(() => {
611
+ let openChange = scope["E" + nodeAccessor];
612
+ if (openChange && el.open === !scope["G" + nodeAccessor]) {
613
+ let newValue = el.open;
614
+ el.open = !newValue, openChange(newValue), run();
615
+ }
616
+ }).observe(el, {
617
+ attributes: !0,
618
+ attributeFilter: ["open"]
619
+ });
730
620
  }
731
621
  function syncControllableFormInput(el, hasChanged, onChange) {
732
- el._ = onChange, controllableDelegate(el, "input", handleChange), el.form && controllableDelegate(el.form, "reset", handleFormReset), isResuming && hasChanged(el) && queueMicrotask(onChange);
622
+ el._ = onChange, controllableDelegate(el, "input", handleChange), el.form && controllableDelegate(el.form, "reset", handleFormReset), isResuming && hasChanged(el) && queueMicrotask(onChange);
733
623
  }
734
624
  function handleChange(ev) {
735
- ev.target._?.(ev);
625
+ ev.target._?.(ev);
736
626
  }
737
627
  function handleFormReset(ev) {
738
- let handlers = [];
739
- for (let el of ev.target.elements)
740
- el._ && hasFormElementChanged(el) && handlers.push(el._);
741
- requestAnimationFrame(() => {
742
- if (!ev.defaultPrevented)
743
- for (let change of handlers)
744
- change();
745
- });
628
+ let handlers = [];
629
+ for (let el of ev.target.elements) el._ && hasFormElementChanged(el) && handlers.push(el._);
630
+ requestAnimationFrame(() => {
631
+ if (!ev.defaultPrevented) for (let change of handlers) change();
632
+ });
746
633
  }
747
634
  function hasValueChanged(el) {
748
- return el.value !== el.defaultValue;
635
+ return el.value !== el.defaultValue;
749
636
  }
750
637
  function hasCheckboxChanged(el) {
751
- return el.checked !== el.defaultChecked;
638
+ return el.checked !== el.defaultChecked;
752
639
  }
753
640
  function hasSelectChanged(el) {
754
- for (let opt of el.options)
755
- if (opt.selected !== opt.defaultSelected)
756
- return !0;
641
+ for (let opt of el.options) if (opt.selected !== opt.defaultSelected) return !0;
757
642
  }
758
643
  function hasFormElementChanged(el) {
759
- return el.options ? hasSelectChanged(el) : hasValueChanged(el) || hasCheckboxChanged(el);
644
+ return el.options ? hasSelectChanged(el) : hasValueChanged(el) || hasCheckboxChanged(el);
760
645
  }
761
646
  function normalizeStrProp(value) {
762
- return normalizeAttrValue(value) || "";
647
+ return normalizeAttrValue(value) || "";
763
648
  }
764
649
  function normalizeBoolProp(value) {
765
- return value != null && value !== !1;
650
+ return value != null && value !== !1;
766
651
  }
767
- function updateList(arr, val, push2) {
768
- let index = arr.indexOf(val);
769
- return (push2 ? !~index && [...arr, val] : ~index && arr.slice(0, index).concat(arr.slice(index + 1))) || arr;
652
+ function updateList(arr, val, push) {
653
+ let index = arr.indexOf(val);
654
+ return (push ? !~index && [...arr, val] : ~index && arr.slice(0, index).concat(arr.slice(index + 1))) || arr;
770
655
  }
771
-
772
- // src/dom/dom.ts
656
+ //#endregion
657
+ //#region src/dom/dom.ts
773
658
  function _to_text(value) {
774
- return value || value === 0 ? value + "" : "";
659
+ return value || value === 0 ? value + "" : "";
775
660
  }
776
661
  function _attr(element, name, value) {
777
- setAttribute(element, name, normalizeAttrValue(value));
662
+ setAttribute(element, name, normalizeAttrValue(value));
778
663
  }
779
664
  function setAttribute(element, name, value) {
780
- element.getAttribute(name) != value && (value === void 0 ? element.removeAttribute(name) : element.setAttribute(name, value));
665
+ element.getAttribute(name) != value && (value === void 0 ? element.removeAttribute(name) : element.setAttribute(name, value));
781
666
  }
782
667
  function _attr_class(element, value) {
783
- setAttribute(element, "class", classValue(value) || void 0);
668
+ setAttribute(element, "class", toDelimitedString(value, " ", stringifyClassObject) || void 0);
784
669
  }
785
670
  function _attr_class_items(element, items) {
786
- for (let key in items)
787
- _attr_class_item(element, key, items[key]);
671
+ for (let key in items) _attr_class_item(element, key, items[key]);
788
672
  }
789
673
  function _attr_class_item(element, name, value) {
790
- element.classList.toggle(name, !!value);
674
+ element.classList.toggle(name, !!value);
791
675
  }
792
676
  function _attr_style(element, value) {
793
- setAttribute(element, "style", styleValue(value) || void 0);
677
+ setAttribute(element, "style", toDelimitedString(value, ";", stringifyStyleObject) || void 0);
794
678
  }
795
679
  function _attr_style_items(element, items) {
796
- for (let key in items)
797
- _attr_style_item(element, key, items[key]);
680
+ for (let key in items) _attr_style_item(element, key, items[key]);
798
681
  }
799
682
  function _attr_style_item(element, name, value) {
800
- element.style.setProperty(name, _to_text(value));
683
+ element.style.setProperty(name, _to_text(value));
801
684
  }
802
685
  function _attr_nonce(scope, nodeAccessor) {
803
- _attr(scope[nodeAccessor], "nonce", scope.$.cspNonce);
686
+ _attr(scope[nodeAccessor], "nonce", scope.$.cspNonce);
804
687
  }
805
688
  function _text(node, value) {
806
- let normalizedValue = _to_text(value);
807
- node.data !== normalizedValue && (node.data = normalizedValue);
689
+ let normalizedValue = _to_text(value);
690
+ node.data !== normalizedValue && (node.data = normalizedValue);
808
691
  }
809
692
  function _text_content(node, value) {
810
- let normalizedValue = _to_text(value);
811
- node.textContent !== normalizedValue && (node.textContent = normalizedValue);
693
+ let normalizedValue = _to_text(value);
694
+ node.textContent !== normalizedValue && (node.textContent = normalizedValue);
812
695
  }
813
696
  function _attrs(scope, nodeAccessor, nextAttrs) {
814
- let el = scope[nodeAccessor];
815
- for (let i = el.attributes.length; i--; ) {
816
- let { name } = el.attributes.item(i);
817
- nextAttrs && (name in nextAttrs || hasAttrAlias(el, name, nextAttrs)) || el.removeAttribute(name);
818
- }
819
- attrsInternal(scope, nodeAccessor, nextAttrs);
697
+ let el = scope[nodeAccessor];
698
+ for (let i = el.attributes.length; i--;) {
699
+ let { name } = el.attributes.item(i);
700
+ nextAttrs && (name in nextAttrs || hasAttrAlias(el, name, nextAttrs)) || el.removeAttribute(name);
701
+ }
702
+ attrsInternal(scope, nodeAccessor, nextAttrs);
820
703
  }
821
704
  function _attrs_content(scope, nodeAccessor, nextAttrs) {
822
- _attrs(scope, nodeAccessor, nextAttrs), _attr_content(scope, nodeAccessor, nextAttrs?.content);
705
+ _attrs(scope, nodeAccessor, nextAttrs), _attr_content(scope, nodeAccessor, nextAttrs?.content);
823
706
  }
824
707
  function hasAttrAlias(element, attr, nextAttrs) {
825
- return attr === "checked" && element.tagName === "INPUT" && "checkedValue" in nextAttrs;
708
+ return attr === "checked" && element.tagName === "INPUT" && "checkedValue" in nextAttrs;
826
709
  }
827
710
  function _attrs_partial(scope, nodeAccessor, nextAttrs, skip) {
828
- let el = scope[nodeAccessor], partial = {};
829
- for (let i = el.attributes.length; i--; ) {
830
- let { name } = el.attributes.item(i);
831
- !skip[name] && !(nextAttrs && name in nextAttrs) && el.removeAttribute(name);
832
- }
833
- for (let name in nextAttrs) {
834
- let key = isEventHandler(name) ? `on-${getEventHandlerName(name)}` : name;
835
- skip[key] || (partial[key] = nextAttrs[name]);
836
- }
837
- attrsInternal(scope, nodeAccessor, partial);
711
+ let el = scope[nodeAccessor], partial = {};
712
+ for (let i = el.attributes.length; i--;) {
713
+ let { name } = el.attributes.item(i);
714
+ !skip[name] && !(nextAttrs && name in nextAttrs) && el.removeAttribute(name);
715
+ }
716
+ for (let name in nextAttrs) {
717
+ let key = isEventHandler(name) ? `on-${getEventHandlerName(name)}` : name;
718
+ skip[key] || (partial[key] = nextAttrs[name]);
719
+ }
720
+ attrsInternal(scope, nodeAccessor, partial);
838
721
  }
839
722
  function _attrs_partial_content(scope, nodeAccessor, nextAttrs, skip) {
840
- _attrs_partial(scope, nodeAccessor, nextAttrs, skip), _attr_content(scope, nodeAccessor, nextAttrs?.content);
723
+ _attrs_partial(scope, nodeAccessor, nextAttrs, skip), _attr_content(scope, nodeAccessor, nextAttrs?.content);
841
724
  }
842
725
  function attrsInternal(scope, nodeAccessor, nextAttrs) {
843
- let el = scope[nodeAccessor], events, skip;
844
- switch (el.tagName) {
845
- case "INPUT":
846
- if ("checked" in nextAttrs || "checkedChange" in nextAttrs)
847
- _attr_input_checked(
848
- scope,
849
- nodeAccessor,
850
- nextAttrs.checked,
851
- nextAttrs.checkedChange
852
- );
853
- else if ("checkedValue" in nextAttrs || "checkedValueChange" in nextAttrs)
854
- _attr_input_checkedValue(
855
- scope,
856
- nodeAccessor,
857
- nextAttrs.checkedValue,
858
- nextAttrs.checkedValueChange,
859
- nextAttrs.value
860
- );
861
- else if ("value" in nextAttrs || "valueChange" in nextAttrs)
862
- _attr_input_value(
863
- scope,
864
- nodeAccessor,
865
- nextAttrs.value,
866
- nextAttrs.valueChange
867
- );
868
- else
869
- break;
870
- skip = /^(?:value|checked(?:Value)?)(?:Change)?$/;
871
- break;
872
- case "SELECT":
873
- ("value" in nextAttrs || "valueChange" in nextAttrs) && (_attr_select_value(
874
- scope,
875
- nodeAccessor,
876
- nextAttrs.value,
877
- nextAttrs.valueChange
878
- ), skip = /^value(?:Change)?$/);
879
- break;
880
- case "TEXTAREA":
881
- ("value" in nextAttrs || "valueChange" in nextAttrs) && (_attr_input_value(
882
- scope,
883
- nodeAccessor,
884
- nextAttrs.value,
885
- nextAttrs.valueChange
886
- ), skip = /^value(?:Change)?$/);
887
- break;
888
- case "DETAILS":
889
- case "DIALOG":
890
- ("open" in nextAttrs || "openChange" in nextAttrs) && (_attr_details_or_dialog_open(
891
- scope,
892
- nodeAccessor,
893
- nextAttrs.open,
894
- nextAttrs.openChange
895
- ), skip = /^open(?:Change)?$/);
896
- break;
897
- }
898
- for (let name in nextAttrs) {
899
- let value = nextAttrs[name];
900
- switch (name) {
901
- case "class":
902
- _attr_class(el, value);
903
- break;
904
- case "style":
905
- _attr_style(el, value);
906
- break;
907
- default: {
908
- isEventHandler(name) ? (events ||= scope["I" /* EventAttributes */ + nodeAccessor] = {})[getEventHandlerName(name)] = value : skip?.test(name) || name === "content" && el.tagName !== "META" || _attr(el, name, value);
909
- break;
910
- }
911
- }
912
- }
726
+ let el = scope[nodeAccessor], events, skip;
727
+ switch (el.tagName) {
728
+ case "INPUT":
729
+ if ("checked" in nextAttrs || "checkedChange" in nextAttrs) _attr_input_checked(scope, nodeAccessor, nextAttrs.checked, nextAttrs.checkedChange);
730
+ else if ("checkedValue" in nextAttrs || "checkedValueChange" in nextAttrs) _attr_input_checkedValue(scope, nodeAccessor, nextAttrs.checkedValue, nextAttrs.checkedValueChange, nextAttrs.value);
731
+ else if ("value" in nextAttrs || "valueChange" in nextAttrs) _attr_input_value(scope, nodeAccessor, nextAttrs.value, nextAttrs.valueChange);
732
+ else break;
733
+ skip = /^(?:value|checked(?:Value)?)(?:Change)?$/;
734
+ break;
735
+ case "SELECT":
736
+ ("value" in nextAttrs || "valueChange" in nextAttrs) && (_attr_select_value(scope, nodeAccessor, nextAttrs.value, nextAttrs.valueChange), skip = /^value(?:Change)?$/);
737
+ break;
738
+ case "TEXTAREA":
739
+ ("value" in nextAttrs || "valueChange" in nextAttrs) && (_attr_input_value(scope, nodeAccessor, nextAttrs.value, nextAttrs.valueChange), skip = /^value(?:Change)?$/);
740
+ break;
741
+ case "DETAILS":
742
+ case "DIALOG":
743
+ ("open" in nextAttrs || "openChange" in nextAttrs) && (_attr_details_or_dialog_open(scope, nodeAccessor, nextAttrs.open, nextAttrs.openChange), skip = /^open(?:Change)?$/);
744
+ break;
745
+ }
746
+ for (let name in nextAttrs) {
747
+ let value = nextAttrs[name];
748
+ switch (name) {
749
+ case "class":
750
+ _attr_class(el, value);
751
+ break;
752
+ case "style":
753
+ _attr_style(el, value);
754
+ break;
755
+ default:
756
+ isEventHandler(name) ? (events ||= scope["I" + nodeAccessor] = {})[getEventHandlerName(name)] = value : skip?.test(name) || name === "content" && el.tagName !== "META" || _attr(el, name, value);
757
+ break;
758
+ }
759
+ }
913
760
  }
914
761
  function _attr_content(scope, nodeAccessor, value) {
915
- let content = normalizeClientRender(value);
916
- scope["D" /* ConditionalRenderer */ + nodeAccessor] !== (scope["D" /* ConditionalRenderer */ + nodeAccessor] = content?.g) && (setConditionalRenderer(scope, nodeAccessor, content, createAndSetupBranch), content?.e && subscribeToScopeSet(
917
- content.f,
918
- content.e,
919
- scope["A" /* BranchScopes */ + nodeAccessor]
920
- ));
921
- for (let accessor in content?.h)
922
- content.h[accessor](
923
- scope["A" /* BranchScopes */ + nodeAccessor],
924
- content.t[accessor]
925
- );
762
+ let content = normalizeClientRender(value);
763
+ scope["D" + nodeAccessor] !== (scope["D" + nodeAccessor] = content?.a) && (setConditionalRenderer(scope, nodeAccessor, content, createAndSetupBranch), content?.f && subscribeToScopeSet(content.e, content.f, scope["A" + nodeAccessor]));
764
+ for (let accessor in content?.g) content.g[accessor](scope["A" + nodeAccessor], content.h[accessor]);
926
765
  }
927
766
  function _attrs_script(scope, nodeAccessor) {
928
- let el = scope[nodeAccessor], events = scope["I" /* EventAttributes */ + nodeAccessor];
929
- switch (scope["F" /* ControlledType */ + nodeAccessor]) {
930
- case 0 /* InputChecked */:
931
- _attr_input_checked_script(scope, nodeAccessor);
932
- break;
933
- case 1 /* InputCheckedValue */:
934
- _attr_input_checkedValue_script(scope, nodeAccessor);
935
- break;
936
- case 2 /* InputValue */:
937
- _attr_input_value_script(scope, nodeAccessor);
938
- break;
939
- case 3 /* SelectValue */:
940
- _attr_select_value_script(scope, nodeAccessor);
941
- break;
942
- case 4 /* DetailsOrDialogOpen */:
943
- _attr_details_or_dialog_open_script(scope, nodeAccessor);
944
- break;
945
- }
946
- for (let name in events)
947
- _on(el, name, events[name]);
767
+ let el = scope[nodeAccessor], events = scope["I" + nodeAccessor];
768
+ switch (scope["F" + nodeAccessor]) {
769
+ case 0:
770
+ _attr_input_checked_script(scope, nodeAccessor);
771
+ break;
772
+ case 1:
773
+ _attr_input_checkedValue_script(scope, nodeAccessor);
774
+ break;
775
+ case 2:
776
+ _attr_input_value_script(scope, nodeAccessor);
777
+ break;
778
+ case 3:
779
+ _attr_select_value_script(scope, nodeAccessor);
780
+ break;
781
+ case 4:
782
+ _attr_details_or_dialog_open_script(scope, nodeAccessor);
783
+ break;
784
+ }
785
+ for (let name in events) _on(el, name, events[name]);
948
786
  }
949
787
  function _html(scope, value, accessor) {
950
- let firstChild = scope[accessor], parentNode = firstChild.parentNode, lastChild = scope["H" /* DynamicHTMLLastChild */ + accessor] || firstChild, newContent = parseHTML(
951
- _to_text(value),
952
- parentNode.namespaceURI
953
- );
954
- insertChildNodes(
955
- parentNode,
956
- firstChild,
957
- scope[accessor] = newContent.firstChild || newContent.appendChild(new Text()),
958
- scope["H" /* DynamicHTMLLastChild */ + accessor] = newContent.lastChild
959
- ), removeChildNodes(firstChild, lastChild);
788
+ let firstChild = scope[accessor], parentNode = firstChild.parentNode, lastChild = scope["H" + accessor] || firstChild, newContent = parseHTML(_to_text(value), parentNode.namespaceURI);
789
+ insertChildNodes(parentNode, firstChild, scope[accessor] = newContent.firstChild || newContent.appendChild(new Text()), scope["H" + accessor] = newContent.lastChild), removeChildNodes(firstChild, lastChild);
960
790
  }
961
791
  function normalizeClientRender(value) {
962
- let renderer = normalizeDynamicRenderer(value);
963
- if (renderer && renderer.g)
964
- return renderer;
792
+ let renderer = normalizeDynamicRenderer(value);
793
+ if (renderer && renderer.a) return renderer;
965
794
  }
966
795
  function normalizeAttrValue(value) {
967
- if (value || value === 0)
968
- return value === !0 ? "" : value + "";
796
+ if (value || value === 0) return value === !0 ? "" : value + "";
969
797
  }
970
798
  function _lifecycle(scope, thisObj, index = 0) {
971
- let accessor = "K" /* Lifecycle */ + index, instance = scope[accessor];
972
- instance ? (Object.assign(instance, thisObj), instance.onUpdate?.()) : (scope[accessor] = thisObj, thisObj.onMount?.(), $signal(scope, accessor).onabort = () => thisObj.onDestroy?.());
799
+ let accessor = "K" + index, instance = scope[accessor];
800
+ instance ? (Object.assign(instance, thisObj), instance.onUpdate?.()) : (scope[accessor] = thisObj, thisObj.onMount?.(), $signal(scope, accessor).onabort = () => thisObj.onDestroy?.());
973
801
  }
974
802
  function removeChildNodes(startNode, endNode) {
975
- let stop = endNode.nextSibling, current = startNode;
976
- for (; current !== stop; ) {
977
- let next = current.nextSibling;
978
- current.remove(), current = next;
979
- }
803
+ let stop = endNode.nextSibling, current = startNode;
804
+ for (; current !== stop;) {
805
+ let next = current.nextSibling;
806
+ current.remove(), current = next;
807
+ }
980
808
  }
981
809
  function insertChildNodes(parentNode, referenceNode, startNode, endNode) {
982
- parentNode.insertBefore(toInsertNode(startNode, endNode), referenceNode);
810
+ parentNode.insertBefore(toInsertNode(startNode, endNode), referenceNode);
983
811
  }
984
812
  function toInsertNode(startNode, endNode) {
985
- if (startNode === endNode) return startNode;
986
- let parent = new DocumentFragment(), stop = endNode.nextSibling, current = startNode;
987
- for (; current !== stop; ) {
988
- let next = current.nextSibling;
989
- parent.appendChild(current), current = next;
990
- }
991
- return parent;
992
- }
993
-
994
- // src/dom/control-flow.ts
813
+ if (startNode === endNode) return startNode;
814
+ let parent = new DocumentFragment(), stop = endNode.nextSibling, current = startNode;
815
+ for (; current !== stop;) {
816
+ let next = current.nextSibling;
817
+ parent.appendChild(current), current = next;
818
+ }
819
+ return parent;
820
+ }
821
+ //#endregion
822
+ //#region src/dom/control-flow.ts
995
823
  function _await_promise(nodeAccessor, params) {
996
- nodeAccessor = decodeAccessor(nodeAccessor);
997
- let promiseAccessor = "L" /* Promise */ + nodeAccessor, branchAccessor = "A" /* BranchScopes */ + nodeAccessor;
998
- return _enable_catch(), (scope, promise) => {
999
- let awaitBranch = scope[branchAccessor], tryBranch = findBranchWithKey(scope, "Q" /* PlaceholderContent */) || awaitBranch, awaitCounter = tryBranch.O;
1000
- awaitCounter?.i || (awaitCounter = tryBranch.O = {
1001
- i: 0,
1002
- c() {
1003
- if (--awaitCounter.i) return 1;
1004
- if (tryBranch === scope[branchAccessor])
1005
- scope[nodeAccessor].parentNode && scope[nodeAccessor].replaceWith(
1006
- scope[branchAccessor].S.parentNode
1007
- );
1008
- else {
1009
- let placeholderBranch = tryBranch.P;
1010
- placeholderBranch && (tryBranch.P = 0, placeholderBranch.S.parentNode.insertBefore(
1011
- tryBranch.S.parentNode,
1012
- placeholderBranch.S
1013
- ), removeAndDestroyBranch(placeholderBranch));
1014
- }
1015
- queueEffect(tryBranch, (scope2) => {
1016
- let pendingEffects2 = scope2.J;
1017
- pendingEffects2 && (scope2.J = [], runEffects(pendingEffects2, 1));
1018
- });
1019
- }
1020
- }), placeholderShown.add(pendingEffects), scope[promiseAccessor] || (awaitBranch && (awaitBranch.W ||= []), awaitCounter.i++ || requestAnimationFrame(
1021
- () => awaitCounter.i && runEffects(
1022
- prepareEffects(
1023
- () => queueRender(
1024
- tryBranch === awaitBranch ? scope : tryBranch,
1025
- () => {
1026
- tryBranch.Q ? (insertBranchBefore(
1027
- tryBranch.P = createAndSetupBranch(
1028
- scope.$,
1029
- tryBranch.Q,
1030
- tryBranch._,
1031
- tryBranch.S.parentNode
1032
- ),
1033
- tryBranch.S.parentNode,
1034
- tryBranch.S
1035
- ), tempDetachBranch(tryBranch)) : awaitBranch.V || (awaitBranch.S.parentNode.insertBefore(
1036
- scope[nodeAccessor],
1037
- awaitBranch.S
1038
- ), tempDetachBranch(tryBranch));
1039
- },
1040
- -1
1041
- )
1042
- )
1043
- )
1044
- ));
1045
- let thisPromise = scope[promiseAccessor] = promise.then(
1046
- (data) => {
1047
- if (thisPromise === scope[promiseAccessor]) {
1048
- let referenceNode = scope[nodeAccessor];
1049
- scope[promiseAccessor] = 0, queueMicrotask(run), queueRender(
1050
- scope,
1051
- () => {
1052
- (awaitBranch = scope[branchAccessor]).V && (pendingScopes.push(awaitBranch), setupBranch(
1053
- awaitBranch.V,
1054
- awaitBranch
1055
- ), awaitBranch.V = 0, insertBranchBefore(
1056
- awaitBranch,
1057
- scope[nodeAccessor].parentNode,
1058
- scope[nodeAccessor]
1059
- ), referenceNode.remove()), params?.(awaitBranch, [data]);
1060
- let pendingRenders2 = awaitBranch.W;
1061
- if (awaitBranch.W = 0, pendingRenders2?.forEach(queuePendingRender), placeholderShown.add(pendingEffects), awaitCounter.c(), awaitCounter.m) {
1062
- let fnScopes = /* @__PURE__ */ new Map(), effects = awaitCounter.m();
1063
- for (let i = 0; i < pendingEffects.length; ) {
1064
- let fn = pendingEffects[i++], scopes = fnScopes.get(fn);
1065
- scopes || fnScopes.set(fn, scopes = /* @__PURE__ */ new Set()), scopes.add(pendingEffects[i++]);
1066
- }
1067
- for (let i = 0; i < effects.length; ) {
1068
- let fn = effects[i++], scope2 = effects[i++];
1069
- fnScopes.get(fn)?.has(scope2) || queueEffect(scope2, fn);
1070
- }
1071
- }
1072
- },
1073
- -1
1074
- );
1075
- }
1076
- },
1077
- (error) => {
1078
- thisPromise === scope[promiseAccessor] && (awaitCounter.i = scope[promiseAccessor] = 0, schedule(), queueRender(scope, renderCatch, -1, error));
1079
- }
1080
- );
1081
- };
824
+ nodeAccessor = decodeAccessor(nodeAccessor);
825
+ let promiseAccessor = "L" + nodeAccessor, branchAccessor = "A" + nodeAccessor;
826
+ return _enable_catch(), (scope, promise) => {
827
+ let awaitBranch = scope[branchAccessor], tryBranch = findBranchWithKey(scope, "Q") || awaitBranch, awaitCounter = tryBranch.O;
828
+ awaitCounter?.i || (awaitCounter = tryBranch.O = {
829
+ i: 0,
830
+ c() {
831
+ if (--awaitCounter.i) return 1;
832
+ if (tryBranch === scope[branchAccessor]) scope[nodeAccessor].parentNode && scope[nodeAccessor].replaceWith(scope[branchAccessor].S.parentNode);
833
+ else {
834
+ let placeholderBranch = tryBranch.P;
835
+ placeholderBranch && (tryBranch.P = 0, placeholderBranch.S.parentNode.insertBefore(tryBranch.S.parentNode, placeholderBranch.S), removeAndDestroyBranch(placeholderBranch));
836
+ }
837
+ queueEffect(tryBranch, (scope) => {
838
+ let pendingEffects = scope.J;
839
+ pendingEffects && (scope.J = [], runEffects(pendingEffects, 1));
840
+ });
841
+ }
842
+ }), placeholderShown.add(pendingEffects), scope[promiseAccessor] || (awaitBranch && (awaitBranch.W ||= []), awaitCounter.i++ || requestAnimationFrame(() => awaitCounter.i && runEffects(prepareEffects(() => queueRender(tryBranch === awaitBranch ? scope : tryBranch, () => {
843
+ tryBranch.Q ? (insertBranchBefore(tryBranch.P = createAndSetupBranch(scope.$, tryBranch.Q, tryBranch._, tryBranch.S.parentNode), tryBranch.S.parentNode, tryBranch.S), tempDetachBranch(tryBranch)) : awaitBranch.V || (awaitBranch.S.parentNode.insertBefore(scope[nodeAccessor], awaitBranch.S), tempDetachBranch(tryBranch));
844
+ }, -1)))));
845
+ let thisPromise = scope[promiseAccessor] = promise.then((data) => {
846
+ if (thisPromise === scope[promiseAccessor]) {
847
+ let referenceNode = scope[nodeAccessor];
848
+ scope[promiseAccessor] = 0, queueMicrotask(run), queueRender(scope, () => {
849
+ (awaitBranch = scope[branchAccessor]).V && (pendingScopes.push(awaitBranch), setupBranch(awaitBranch.V, awaitBranch), awaitBranch.V = 0, insertBranchBefore(awaitBranch, scope[nodeAccessor].parentNode, scope[nodeAccessor]), referenceNode.remove()), params?.(awaitBranch, [data]);
850
+ let pendingRenders = awaitBranch.W;
851
+ if (awaitBranch.W = 0, pendingRenders?.forEach(queuePendingRender), placeholderShown.add(pendingEffects), awaitCounter.c(), awaitCounter.m) {
852
+ let fnScopes = /* @__PURE__ */ new Map(), effects = awaitCounter.m();
853
+ for (let i = 0; i < pendingEffects.length;) {
854
+ let fn = pendingEffects[i++], scopes = fnScopes.get(fn);
855
+ scopes || fnScopes.set(fn, scopes = /* @__PURE__ */ new Set()), scopes.add(pendingEffects[i++]);
856
+ }
857
+ for (let i = 0; i < effects.length;) {
858
+ let fn = effects[i++], scope = effects[i++];
859
+ fnScopes.get(fn)?.has(scope) || queueEffect(scope, fn);
860
+ }
861
+ }
862
+ }, -1);
863
+ }
864
+ }, (error) => {
865
+ thisPromise === scope[promiseAccessor] && (awaitCounter.i = scope[promiseAccessor] = 0, schedule(), queueRender(scope, renderCatch, -1, error));
866
+ });
867
+ };
1082
868
  }
1083
869
  function _await_content(nodeAccessor, template, walks, setup) {
1084
- nodeAccessor = decodeAccessor(nodeAccessor);
1085
- let branchAccessor = "A" /* BranchScopes */ + nodeAccessor, renderer = _content("", template, walks, setup)();
1086
- return (scope) => {
1087
- (scope[branchAccessor] = createBranch(
1088
- scope.$,
1089
- renderer,
1090
- scope,
1091
- scope[nodeAccessor].parentNode
1092
- )).V = renderer, pendingScopes.pop();
1093
- };
870
+ nodeAccessor = decodeAccessor(nodeAccessor);
871
+ let branchAccessor = "A" + nodeAccessor, renderer = _content("", template, walks, setup)();
872
+ return (scope) => {
873
+ (scope[branchAccessor] = createBranch(scope.$, renderer, scope, scope[nodeAccessor].parentNode)).V = renderer, pendingScopes.pop();
874
+ };
1094
875
  }
1095
876
  function _try(nodeAccessor, template, walks, setup) {
1096
- nodeAccessor = decodeAccessor(nodeAccessor);
1097
- let branchAccessor = "A" /* BranchScopes */ + nodeAccessor, renderer = _content("", template, walks, setup)();
1098
- return (scope, input) => {
1099
- scope[branchAccessor] || setConditionalRenderer(
1100
- scope,
1101
- nodeAccessor,
1102
- renderer,
1103
- createAndSetupBranch
1104
- );
1105
- let branch = scope[branchAccessor];
1106
- branch && (branch.C = nodeAccessor, branch.E = normalizeDynamicRenderer(input.catch), branch.Q = normalizeDynamicRenderer(
1107
- input.placeholder
1108
- ));
1109
- };
877
+ nodeAccessor = decodeAccessor(nodeAccessor);
878
+ let branchAccessor = "A" + nodeAccessor, renderer = _content("", template, walks, setup)();
879
+ return (scope, input) => {
880
+ scope[branchAccessor] || setConditionalRenderer(scope, nodeAccessor, renderer, createAndSetupBranch);
881
+ let branch = scope[branchAccessor];
882
+ branch && (branch.C = nodeAccessor, branch.E = input.catch && (normalizeDynamicRenderer(input.catch) || 0), branch.Q = normalizeDynamicRenderer(input.placeholder));
883
+ };
1110
884
  }
1111
885
  function renderCatch(scope, error) {
1112
- let tryWithCatch = findBranchWithKey(scope, "E" /* CatchContent */);
1113
- if (tryWithCatch) {
1114
- let owner = tryWithCatch._, placeholderBranch = tryWithCatch.P;
1115
- placeholderBranch && (tryWithCatch.O && (tryWithCatch.O.i = 0), owner["A" /* BranchScopes */ + tryWithCatch.C] = placeholderBranch, destroyBranch(tryWithCatch)), caughtError.add(pendingEffects), setConditionalRenderer(
1116
- owner,
1117
- tryWithCatch.C,
1118
- tryWithCatch.E,
1119
- createAndSetupBranch
1120
- ), tryWithCatch.E.d?.(
1121
- owner["A" /* BranchScopes */ + tryWithCatch.C],
1122
- [error]
1123
- );
1124
- } else
1125
- throw error;
886
+ let tryWithCatch = findBranchWithKey(scope, "E");
887
+ if (tryWithCatch) {
888
+ let owner = tryWithCatch._, placeholderBranch = tryWithCatch.P;
889
+ placeholderBranch && (tryWithCatch.O && (tryWithCatch.O.i = 0), owner["A" + tryWithCatch.C] = placeholderBranch, destroyBranch(tryWithCatch)), caughtError.add(pendingEffects), setConditionalRenderer(owner, tryWithCatch.C, tryWithCatch.E, createAndSetupBranch), tryWithCatch.E?.d?.(owner["A" + tryWithCatch.C], [error]);
890
+ } else throw error;
1126
891
  }
1127
892
  function _if(nodeAccessor, ...branchesArgs) {
1128
- nodeAccessor = decodeAccessor(nodeAccessor);
1129
- let branchAccessor = "D" /* ConditionalRenderer */ + nodeAccessor, branches = [], i = 0;
1130
- for (; i < branchesArgs.length; )
1131
- branches.push(
1132
- _content(
1133
- "",
1134
- branchesArgs[i++],
1135
- branchesArgs[i++],
1136
- branchesArgs[i++]
1137
- )()
1138
- );
1139
- return enableBranches(), (scope, newBranch) => {
1140
- newBranch !== scope[branchAccessor] && setConditionalRenderer(
1141
- scope,
1142
- nodeAccessor,
1143
- branches[scope[branchAccessor] = newBranch],
1144
- createAndSetupBranch
1145
- );
1146
- };
893
+ nodeAccessor = decodeAccessor(nodeAccessor);
894
+ let branchAccessor = "D" + nodeAccessor, branches = [], i = 0;
895
+ for (; i < branchesArgs.length;) branches.push(_content("", branchesArgs[i++], branchesArgs[i++], branchesArgs[i++])());
896
+ return enableBranches(), (scope, newBranch) => {
897
+ newBranch !== scope[branchAccessor] && setConditionalRenderer(scope, nodeAccessor, branches[scope[branchAccessor] = newBranch], createAndSetupBranch);
898
+ };
1147
899
  }
1148
900
  function patchDynamicTag(fn) {
1149
- _dynamic_tag = fn(_dynamic_tag);
1150
- }
1151
- var _dynamic_tag = function(nodeAccessor, getContent, getTagVar, inputIsArgs) {
1152
- nodeAccessor = decodeAccessor(nodeAccessor);
1153
- let childScopeAccessor = "A" /* BranchScopes */ + nodeAccessor, rendererAccessor = "D" /* ConditionalRenderer */ + nodeAccessor;
1154
- return enableBranches(), (scope, newRenderer, getInput) => {
1155
- let normalizedRenderer = normalizeDynamicRenderer(newRenderer);
1156
- if (scope[rendererAccessor] !== (scope[rendererAccessor] = normalizedRenderer?.g || normalizedRenderer) || getContent && !(normalizedRenderer || scope[childScopeAccessor]))
1157
- if (setConditionalRenderer(
1158
- scope,
1159
- nodeAccessor,
1160
- normalizedRenderer || (getContent ? getContent(scope) : void 0),
1161
- createBranchWithTagNameOrRenderer
1162
- ), getTagVar && (scope[childScopeAccessor].T = (value) => getTagVar()(scope, value)), typeof normalizedRenderer == "string") {
1163
- if (getContent) {
1164
- let content = getContent(scope);
1165
- setConditionalRenderer(
1166
- scope[childScopeAccessor],
1167
- "a",
1168
- content,
1169
- createAndSetupBranch
1170
- ), content.e && subscribeToScopeSet(
1171
- content.f,
1172
- content.e,
1173
- scope[childScopeAccessor]["Aa"]
1174
- );
1175
- }
1176
- } else normalizedRenderer?.e && subscribeToScopeSet(
1177
- normalizedRenderer.f,
1178
- normalizedRenderer.e,
1179
- scope[childScopeAccessor]
1180
- );
1181
- if (normalizedRenderer) {
1182
- let childScope = scope[childScopeAccessor], args = getInput?.();
1183
- if (typeof normalizedRenderer == "string")
1184
- (getContent ? _attrs : _attrs_content)(
1185
- childScope,
1186
- "a",
1187
- (inputIsArgs ? args[0] : args) || {}
1188
- ), (childScope["Ia"] || childScope["Ea"]) && queueEffect(childScope, dynamicTagScript);
1189
- else {
1190
- for (let accessor in normalizedRenderer.h)
1191
- normalizedRenderer.h[accessor](
1192
- childScope,
1193
- normalizedRenderer.t[accessor]
1194
- );
1195
- if (normalizedRenderer.d)
1196
- if (inputIsArgs)
1197
- normalizedRenderer.d(
1198
- childScope,
1199
- normalizedRenderer._ ? args[0] : args
1200
- );
1201
- else {
1202
- let inputWithContent = getContent ? { ...args, content: getContent(scope) } : args || {};
1203
- normalizedRenderer.d(
1204
- childScope,
1205
- normalizedRenderer._ ? inputWithContent : [inputWithContent]
1206
- );
1207
- }
1208
- }
1209
- }
1210
- };
1211
- };
901
+ _dynamic_tag = fn(_dynamic_tag);
902
+ }
1212
903
  function _resume_dynamic_tag() {
1213
- _resume("d", dynamicTagScript);
904
+ _resume("d", dynamicTagScript);
1214
905
  }
1215
906
  function dynamicTagScript(branch) {
1216
- _attrs_script(
1217
- branch,
1218
- "a"
1219
- );
1220
- }
1221
- function setConditionalRenderer(scope, nodeAccessor, newRenderer, createBranch2) {
1222
- let referenceNode = scope[nodeAccessor], prevBranch = scope["A" /* BranchScopes */ + nodeAccessor], parentNode = referenceNode.nodeType > 1 /* Element */ ? (prevBranch?.S || referenceNode).parentNode : referenceNode, newBranch = scope["A" /* BranchScopes */ + nodeAccessor] = newRenderer && createBranch2(scope.$, newRenderer, scope, parentNode);
1223
- referenceNode === parentNode ? (prevBranch && (destroyBranch(prevBranch), referenceNode.textContent = ""), newBranch && insertBranchBefore(newBranch, parentNode, null)) : prevBranch ? (newBranch ? insertBranchBefore(
1224
- newBranch,
1225
- parentNode,
1226
- prevBranch.S
1227
- ) : parentNode.insertBefore(
1228
- referenceNode,
1229
- prevBranch.S
1230
- ), removeAndDestroyBranch(prevBranch)) : newBranch && (insertBranchBefore(newBranch, parentNode, referenceNode), referenceNode.remove());
1231
- }
1232
- var _for_of = loop(([all, by = bySecondArg], cb) => {
1233
- typeof by == "string" ? forOf(
1234
- all,
1235
- (item, i) => cb(item[by], [item, i])
1236
- ) : forOf(all, (item, i) => cb(by(item, i), [item, i]));
1237
- }), _for_in = loop(
1238
- ([obj, by = byFirstArg], cb) => forIn(obj, (key, value) => cb(by(key, value), [key, value]))
1239
- ), _for_to = loop(
1240
- ([to, from, step, by = byFirstArg], cb) => forTo(to, from, step, (v) => cb(by(v), [v]))
1241
- ), _for_until = loop(
1242
- ([until, from, step, by = byFirstArg], cb) => forUntil(until, from, step, (v) => cb(by(v), [v]))
1243
- );
907
+ _attrs_script(branch, "a");
908
+ }
909
+ function setConditionalRenderer(scope, nodeAccessor, newRenderer, createBranch) {
910
+ let referenceNode = scope[nodeAccessor], prevBranch = scope["A" + nodeAccessor], parentNode = referenceNode.nodeType > 1 ? (prevBranch?.S || referenceNode).parentNode : referenceNode, newBranch = scope["A" + nodeAccessor] = newRenderer && createBranch(scope.$, newRenderer, scope, parentNode);
911
+ referenceNode === parentNode ? (prevBranch && (destroyBranch(prevBranch), referenceNode.textContent = ""), newBranch && insertBranchBefore(newBranch, parentNode, null)) : prevBranch ? (newBranch ? insertBranchBefore(newBranch, parentNode, prevBranch.S) : parentNode.insertBefore(referenceNode, prevBranch.S), removeAndDestroyBranch(prevBranch)) : newBranch && (insertBranchBefore(newBranch, parentNode, referenceNode), referenceNode.remove());
912
+ }
913
+ /* @__NO_SIDE_EFFECTS__ */
1244
914
  function loop(forEach) {
1245
- return (nodeAccessor, template, walks, setup, params) => {
1246
- nodeAccessor = decodeAccessor(nodeAccessor);
1247
- let scopesAccessor = "A" /* BranchScopes */ + nodeAccessor, renderer = _content("", template, walks, setup)();
1248
- return enableBranches(), (scope, value) => {
1249
- let referenceNode = scope[nodeAccessor], oldScopes = toArray(scope[scopesAccessor]), newScopes = scope[scopesAccessor] = [], oldLen = oldScopes.length, parentNode = referenceNode.nodeType > 1 /* Element */ ? referenceNode.parentNode || oldScopes[0]?.S.parentNode : referenceNode, oldScopesByKey, hasPotentialMoves;
1250
- if (0)
1251
- var seenKeys;
1252
- forEach(value, (key, args) => {
1253
- let branch = oldLen && (oldScopesByKey ||= oldScopes.reduce(
1254
- (map, scope2, i) => map.set(scope2.M ?? i, scope2),
1255
- /* @__PURE__ */ new Map()
1256
- )).get(key);
1257
- branch ? hasPotentialMoves = oldScopesByKey.delete(key) : branch = createAndSetupBranch(
1258
- scope.$,
1259
- renderer,
1260
- scope,
1261
- parentNode
1262
- ), branch.M = key, newScopes.push(branch), params?.(branch, args);
1263
- });
1264
- let newLen = newScopes.length, hasSiblings = referenceNode !== parentNode, afterReference = null, oldEnd = oldLen - 1, newEnd = newLen - 1, start = 0;
1265
- if (hasSiblings && (oldLen ? (afterReference = oldScopes[oldEnd].K.nextSibling, newLen || parentNode.insertBefore(referenceNode, afterReference)) : newLen && (afterReference = referenceNode.nextSibling, referenceNode.remove())), !hasPotentialMoves) {
1266
- oldLen && (oldScopes.forEach(
1267
- hasSiblings ? removeAndDestroyBranch : destroyBranch
1268
- ), hasSiblings || (parentNode.textContent = ""));
1269
- for (let newScope of newScopes)
1270
- insertBranchBefore(newScope, parentNode, afterReference);
1271
- return;
1272
- }
1273
- for (let branch of oldScopesByKey.values())
1274
- removeAndDestroyBranch(branch);
1275
- for (; start < oldLen && start < newLen && oldScopes[start] === newScopes[start]; )
1276
- start++;
1277
- for (; oldEnd >= start && newEnd >= start && oldScopes[oldEnd] === newScopes[newEnd]; )
1278
- oldEnd--, newEnd--;
1279
- if (oldEnd + 1 < oldLen && (afterReference = oldScopes[oldEnd + 1].S), start > oldEnd) {
1280
- if (start <= newEnd)
1281
- for (let i = start; i <= newEnd; i++)
1282
- insertBranchBefore(newScopes[i], parentNode, afterReference);
1283
- return;
1284
- } else if (start > newEnd)
1285
- return;
1286
- let diffLen = newEnd - start + 1, oldPos = /* @__PURE__ */ new Map(), sources = new Array(diffLen), pred = new Array(diffLen), tails = [], tail = -1, lo, hi, mid;
1287
- for (let i = start; i <= oldEnd; i++)
1288
- oldPos.set(oldScopes[i], i);
1289
- for (let i = diffLen; i--; )
1290
- sources[i] = oldPos.get(newScopes[start + i]) ?? -1;
1291
- for (let i = 0; i < diffLen; i++)
1292
- if (~sources[i])
1293
- if (tail < 0 || sources[tails[tail]] < sources[i])
1294
- ~tail && (pred[i] = tails[tail]), tails[++tail] = i;
1295
- else {
1296
- for (lo = 0, hi = tail; lo < hi; )
1297
- mid = (lo + hi) / 2 | 0, sources[tails[mid]] < sources[i] ? lo = mid + 1 : hi = mid;
1298
- sources[i] < sources[tails[lo]] && (lo > 0 && (pred[i] = tails[lo - 1]), tails[lo] = i);
1299
- }
1300
- for (hi = tails[tail], lo = tail + 1; lo-- > 0; )
1301
- tails[lo] = hi, hi = pred[hi];
1302
- for (let i = diffLen; i--; )
1303
- ~tail && i === tails[tail] ? tail-- : insertBranchBefore(newScopes[start + i], parentNode, afterReference), afterReference = newScopes[start + i].S;
1304
- };
1305
- };
915
+ return (nodeAccessor, template, walks, setup, params) => {
916
+ nodeAccessor = decodeAccessor(nodeAccessor);
917
+ let scopesAccessor = "A" + nodeAccessor, renderer = _content("", template, walks, setup)();
918
+ return enableBranches(), (scope, value) => {
919
+ let referenceNode = scope[nodeAccessor], oldScopes = toArray(scope[scopesAccessor]), newScopes = scope[scopesAccessor] = [], oldLen = oldScopes.length, parentNode = referenceNode.nodeType > 1 ? referenceNode.parentNode || oldScopes[0]?.S.parentNode : referenceNode, oldScopesByKey, hasPotentialMoves;
920
+ forEach(value, (key, args) => {
921
+ let branch = oldLen && (oldScopesByKey ||= oldScopes.reduce((map, scope, i) => map.set(scope.M ?? i, scope), /* @__PURE__ */ new Map())).get(key);
922
+ branch ? hasPotentialMoves = oldScopesByKey.delete(key) : branch = createAndSetupBranch(scope.$, renderer, scope, parentNode), branch.M = key, newScopes.push(branch), params?.(branch, args);
923
+ });
924
+ let newLen = newScopes.length, hasSiblings = referenceNode !== parentNode, afterReference = null, oldEnd = oldLen - 1, newEnd = newLen - 1, start = 0;
925
+ if (hasSiblings && (oldLen ? (afterReference = oldScopes[oldEnd].K.nextSibling, newLen || parentNode.insertBefore(referenceNode, afterReference)) : newLen && (afterReference = referenceNode.nextSibling, referenceNode.remove())), !hasPotentialMoves) {
926
+ oldLen && (oldScopes.forEach(hasSiblings ? removeAndDestroyBranch : destroyBranch), hasSiblings || (parentNode.textContent = ""));
927
+ for (let newScope of newScopes) insertBranchBefore(newScope, parentNode, afterReference);
928
+ return;
929
+ }
930
+ for (let branch of oldScopesByKey.values()) removeAndDestroyBranch(branch);
931
+ for (; start < oldLen && start < newLen && oldScopes[start] === newScopes[start];) start++;
932
+ for (; oldEnd >= start && newEnd >= start && oldScopes[oldEnd] === newScopes[newEnd];) oldEnd--, newEnd--;
933
+ if (oldEnd + 1 < oldLen && (afterReference = oldScopes[oldEnd + 1].S), start > oldEnd) {
934
+ if (start <= newEnd) for (let i = start; i <= newEnd; i++) insertBranchBefore(newScopes[i], parentNode, afterReference);
935
+ return;
936
+ } else if (start > newEnd) return;
937
+ let diffLen = newEnd - start + 1, oldPos = /* @__PURE__ */ new Map(), sources = Array(diffLen), pred = Array(diffLen), tails = [], tail = -1, lo, hi, mid;
938
+ for (let i = start; i <= oldEnd; i++) oldPos.set(oldScopes[i], i);
939
+ for (let i = diffLen; i--;) sources[i] = oldPos.get(newScopes[start + i]) ?? -1;
940
+ for (let i = 0; i < diffLen; i++) if (~sources[i]) if (tail < 0 || sources[tails[tail]] < sources[i]) ~tail && (pred[i] = tails[tail]), tails[++tail] = i;
941
+ else {
942
+ for (lo = 0, hi = tail; lo < hi;) mid = (lo + hi) / 2 | 0, sources[tails[mid]] < sources[i] ? lo = mid + 1 : hi = mid;
943
+ sources[i] < sources[tails[lo]] && (lo > 0 && (pred[i] = tails[lo - 1]), tails[lo] = i);
944
+ }
945
+ for (hi = tails[tail], lo = tail + 1; lo-- > 0;) tails[lo] = hi, hi = pred[hi];
946
+ for (let i = diffLen; i--;) ~tail && i === tails[tail] ? tail-- : insertBranchBefore(newScopes[start + i], parentNode, afterReference), afterReference = newScopes[start + i].S;
947
+ };
948
+ };
1306
949
  }
1307
950
  function createBranchWithTagNameOrRenderer($global, tagNameOrRenderer, parentScope, parentNode) {
1308
- let branch = createBranch(
1309
- $global,
1310
- tagNameOrRenderer,
1311
- parentScope,
1312
- parentNode
1313
- );
1314
- return typeof tagNameOrRenderer == "string" ? branch.a = branch.S = branch.K = document.createElementNS(
1315
- tagNameOrRenderer === "svg" ? "http://www.w3.org/2000/svg" : tagNameOrRenderer === "math" ? "http://www.w3.org/1998/Math/MathML" : parentNode.namespaceURI,
1316
- tagNameOrRenderer
1317
- ) : setupBranch(tagNameOrRenderer, branch), branch;
951
+ let branch = createBranch($global, tagNameOrRenderer, parentScope, parentNode);
952
+ return typeof tagNameOrRenderer == "string" ? branch.a = branch.S = branch.K = document.createElementNS(tagNameOrRenderer === "svg" ? "http://www.w3.org/2000/svg" : tagNameOrRenderer === "math" ? "http://www.w3.org/1998/Math/MathML" : parentNode.namespaceURI, tagNameOrRenderer) : setupBranch(tagNameOrRenderer, branch), branch;
1318
953
  }
1319
954
  function bySecondArg(_item, index) {
1320
- return index;
955
+ return index;
1321
956
  }
1322
957
  function byFirstArg(name) {
1323
- return name;
958
+ return name;
1324
959
  }
1325
-
1326
- // src/dom/queue.ts
1327
- var pendingRenders = [], pendingRendersLookup = /* @__PURE__ */ new Map(), asyncRendersLookup, caughtError = /* @__PURE__ */ new WeakSet(), placeholderShown = /* @__PURE__ */ new WeakSet(), pendingEffects = [], pendingScopes = [], rendering, scopeKeyOffset = 1e3;
960
+ //#endregion
961
+ //#region src/dom/queue.ts
1328
962
  function queueRender(scope, signal, signalKey, value, scopeKey = scope.L) {
1329
- let key = scopeKey * scopeKeyOffset + signalKey, render = signalKey >= 0 && pendingRendersLookup.get(key);
1330
- render ? render.u = value : (queuePendingRender(
1331
- render = {
1332
- a: key,
1333
- j: scope,
1334
- y: signal,
1335
- u: value
1336
- }
1337
- ), signalKey >= 0 && pendingRendersLookup.set(key, render));
963
+ let key = scopeKey * 1e3 + signalKey, render = signalKey >= 0 && pendingRendersLookup.get(key);
964
+ render ? render.d = value : (queuePendingRender(render = {
965
+ a: key,
966
+ b: scope,
967
+ c: signal,
968
+ d: value
969
+ }), signalKey >= 0 && pendingRendersLookup.set(key, render));
1338
970
  }
1339
971
  function queuePendingRender(render) {
1340
- let i = pendingRenders.push(render) - 1;
1341
- for (; i; ) {
1342
- let parentIndex = i - 1 >> 1, parent = pendingRenders[parentIndex];
1343
- if (render.a - parent.a >= 0) break;
1344
- pendingRenders[i] = parent, i = parentIndex;
1345
- }
1346
- pendingRenders[i] = render;
972
+ let i = pendingRenders.push(render) - 1;
973
+ for (; i;) {
974
+ let parentIndex = i - 1 >> 1, parent = pendingRenders[parentIndex];
975
+ if (render.a - parent.a >= 0) break;
976
+ pendingRenders[i] = parent, i = parentIndex;
977
+ }
978
+ pendingRenders[i] = render;
1347
979
  }
1348
980
  function queueEffect(scope, fn) {
1349
- pendingEffects.push(fn, scope);
981
+ pendingEffects.push(fn, scope);
1350
982
  }
1351
983
  function run() {
1352
- let effects = pendingEffects;
1353
- asyncRendersLookup = /* @__PURE__ */ new Map();
1354
- try {
1355
- rendering = 1, runRenders();
1356
- } finally {
1357
- pendingRendersLookup = asyncRendersLookup, asyncRendersLookup = rendering = 0, pendingRenders = [], pendingEffects = [];
1358
- }
1359
- runEffects(effects);
984
+ let effects = pendingEffects;
985
+ asyncRendersLookup = /* @__PURE__ */ new Map();
986
+ try {
987
+ rendering = 1, runRenders();
988
+ } finally {
989
+ pendingRendersLookup = asyncRendersLookup, asyncRendersLookup = rendering = 0, pendingRenders = [], pendingEffects = [];
990
+ }
991
+ runEffects(effects);
1360
992
  }
1361
993
  function prepareEffects(fn) {
1362
- let prevRenders = pendingRenders, prevEffects = pendingEffects, prevLookup = asyncRendersLookup, preparedEffects = pendingEffects = [];
1363
- pendingRenders = [], asyncRendersLookup = pendingRendersLookup, pendingRendersLookup = /* @__PURE__ */ new Map();
1364
- try {
1365
- rendering = 1, fn(), runRenders();
1366
- } finally {
1367
- rendering = 0, pendingRendersLookup = asyncRendersLookup, asyncRendersLookup = prevLookup, pendingRenders = prevRenders, pendingEffects = prevEffects;
1368
- }
1369
- return preparedEffects;
1370
- }
1371
- var runEffects = ((effects) => {
1372
- for (let i = 0; i < effects.length; )
1373
- effects[i++](effects[i++]);
1374
- });
994
+ let prevRenders = pendingRenders, prevEffects = pendingEffects, prevLookup = asyncRendersLookup, preparedEffects = pendingEffects = [];
995
+ pendingRenders = [], asyncRendersLookup = pendingRendersLookup, pendingRendersLookup = /* @__PURE__ */ new Map();
996
+ try {
997
+ rendering = 1, fn(), runRenders();
998
+ } finally {
999
+ rendering = 0, pendingRendersLookup = asyncRendersLookup, asyncRendersLookup = prevLookup, pendingRenders = prevRenders, pendingEffects = prevEffects;
1000
+ }
1001
+ return preparedEffects;
1002
+ }
1375
1003
  function runRenders() {
1376
- for (; pendingRenders.length; ) {
1377
- let render = pendingRenders[0], item = pendingRenders.pop();
1378
- if (render !== item) {
1379
- let i = 0, mid = pendingRenders.length >> 1, key = (pendingRenders[0] = item).a;
1380
- for (; i < mid; ) {
1381
- let bestChild = (i << 1) + 1, right = bestChild + 1;
1382
- if (right < pendingRenders.length && pendingRenders[right].a - pendingRenders[bestChild].a < 0 && (bestChild = right), pendingRenders[bestChild].a - key >= 0)
1383
- break;
1384
- pendingRenders[i] = pendingRenders[bestChild], i = bestChild;
1385
- }
1386
- pendingRenders[i] = item;
1387
- }
1388
- render.j.F?.I || runRender(render);
1389
- }
1390
- for (let scope of pendingScopes)
1391
- scope.H = 0;
1392
- pendingScopes = [];
1393
- }
1394
- var runRender = (render) => render.y(render.j, render.u), _enable_catch = () => {
1395
- _enable_catch = () => {
1396
- }, enableBranches();
1397
- let handlePendingTry = (fn, scope, branch) => {
1398
- for (; branch; ) {
1399
- if (branch.O?.i)
1400
- return (branch.J ||= []).push(fn, scope);
1401
- branch = branch.N;
1402
- }
1403
- };
1404
- runEffects = /* @__PURE__ */ ((runEffects2) => (effects, checkPending = placeholderShown.has(effects)) => {
1405
- if (checkPending || caughtError.has(effects)) {
1406
- let i = 0, fn, scope, branch;
1407
- for (; i < effects.length; )
1408
- fn = effects[i++], scope = effects[i++], branch = scope.F, !branch?.I && !(checkPending && handlePendingTry(fn, scope, branch)) && fn(scope);
1409
- } else
1410
- runEffects2(effects);
1411
- })(runEffects), runRender = /* @__PURE__ */ ((runRender2) => (render) => {
1412
- try {
1413
- let branch = render.j.F;
1414
- for (; branch; ) {
1415
- if (branch.W)
1416
- return asyncRendersLookup.set(
1417
- render.a,
1418
- render
1419
- ), branch.W.push(render);
1420
- branch = branch.N;
1421
- }
1422
- runRender2(render);
1423
- } catch (error) {
1424
- renderCatch(render.j, error);
1425
- }
1426
- })(runRender);
1427
- };
1428
-
1429
- // src/dom/abort-signal.ts
1004
+ for (; pendingRenders.length;) {
1005
+ let render = pendingRenders[0], item = pendingRenders.pop();
1006
+ if (render !== item) {
1007
+ let i = 0, mid = pendingRenders.length >> 1, key = (pendingRenders[0] = item).a;
1008
+ for (; i < mid;) {
1009
+ let bestChild = (i << 1) + 1, right = bestChild + 1;
1010
+ if (right < pendingRenders.length && pendingRenders[right].a - pendingRenders[bestChild].a < 0 && (bestChild = right), pendingRenders[bestChild].a - key >= 0) break;
1011
+ pendingRenders[i] = pendingRenders[bestChild], i = bestChild;
1012
+ }
1013
+ pendingRenders[i] = item;
1014
+ }
1015
+ render.b.F?.I || runRender(render);
1016
+ }
1017
+ for (let scope of pendingScopes) scope.H = 0;
1018
+ pendingScopes = [];
1019
+ }
1020
+ function _enable_catch() {
1021
+ if (!catchEnabled) {
1022
+ catchEnabled = 1, enableBranches();
1023
+ let handlePendingTry = (fn, scope, branch) => {
1024
+ for (; branch;) {
1025
+ if (branch.O?.i) return (branch.J ||= []).push(fn, scope);
1026
+ branch = branch.N;
1027
+ }
1028
+ };
1029
+ runEffects = ((runEffects) => (effects, checkPending = placeholderShown.has(effects)) => {
1030
+ if (checkPending || caughtError.has(effects)) {
1031
+ let i = 0, fn, scope, branch;
1032
+ for (; i < effects.length;) fn = effects[i++], scope = effects[i++], branch = scope.F, !branch?.I && !(checkPending && handlePendingTry(fn, scope, branch)) && fn(scope);
1033
+ } else runEffects(effects);
1034
+ })(runEffects), runRender = ((runRender) => (render) => {
1035
+ try {
1036
+ let branch = render.b.F;
1037
+ for (; branch;) {
1038
+ if (branch.W) return asyncRendersLookup.set(render.a, render), branch.W.push(render);
1039
+ branch = branch.N;
1040
+ }
1041
+ runRender(render);
1042
+ } catch (error) {
1043
+ renderCatch(render.b, error);
1044
+ }
1045
+ })(runRender);
1046
+ }
1047
+ }
1048
+ //#endregion
1049
+ //#region src/dom/abort-signal.ts
1430
1050
  function $signalReset(scope, id) {
1431
- let ctrl = scope.A?.[id];
1432
- ctrl && (queueEffect(ctrl, abort), scope.A[id] = void 0);
1051
+ let ctrl = scope.A?.[id];
1052
+ ctrl && (queueEffect(ctrl, abort), scope.A[id] = void 0);
1433
1053
  }
1434
1054
  function $signal(scope, id) {
1435
- return scope.F && (scope.F.B ||= /* @__PURE__ */ new Set()).add(scope), ((scope.A ||= {})[id] ||= new AbortController()).signal;
1055
+ return scope.F && (scope.F.B ||= /* @__PURE__ */ new Set()).add(scope), ((scope.A ||= {})[id] ||= new AbortController()).signal;
1436
1056
  }
1437
1057
  function abort(ctrl) {
1438
- ctrl.abort();
1439
- }
1440
-
1441
- // src/common/compat-meta.ts
1442
- var RENDERER_REGISTER_ID = "$C_r", SET_SCOPE_REGISTER_ID = "$C_s", RENDER_BODY_ID = "$C_b";
1443
-
1444
- // src/dom/compat.ts
1445
- var classIdToBranch = /* @__PURE__ */ new Map(), compat = {
1446
- patchDynamicTag,
1447
- queueEffect,
1448
- init(warp10Noop) {
1449
- _resume(SET_SCOPE_REGISTER_ID, (branch) => {
1450
- classIdToBranch.set(branch.m5c, branch);
1451
- }), _resume(RENDER_BODY_ID, warp10Noop);
1452
- },
1453
- registerRenderer(fn) {
1454
- _resume(RENDERER_REGISTER_ID, fn);
1455
- },
1456
- isRenderer(renderer) {
1457
- return renderer.k;
1458
- },
1459
- getStartNode(branch) {
1460
- return branch.S;
1461
- },
1462
- setScopeNodes(branch, startNode, endNode) {
1463
- branch.S = startNode, branch.K = endNode;
1464
- },
1465
- runComponentEffects() {
1466
- this.effects && runEffects(this.effects);
1467
- },
1468
- runComponentDestroy() {
1469
- this.scope && destroyBranch(this.scope);
1470
- },
1471
- resolveRegistered(value, $global) {
1472
- return Array.isArray(value) && typeof value[0] == "string" ? getRegisteredWithScope(
1473
- value[0],
1474
- value.length === 2 && self[$global.runtimeId]?.[$global.renderId]?.s[value[1]]
1475
- ) : value;
1476
- },
1477
- createRenderer(params, clone) {
1478
- let renderer = _content("", 0, 0, 0, params)();
1479
- return renderer.k = (branch) => {
1480
- let cloned = clone();
1481
- branch.S = cloned.startNode, branch.K = cloned.endNode;
1482
- }, renderer;
1483
- },
1484
- render(out, component, renderer, args) {
1485
- let branch = component.scope, created = 0;
1486
- if (!branch && (branch = classIdToBranch.get(component.id)) && (component.scope = branch, classIdToBranch.delete(component.id)), typeof args[0] == "object" && "renderBody" in args[0]) {
1487
- let input = args[0], normalizedInput = args[0] = {};
1488
- for (let key in input)
1489
- normalizedInput[key === "renderBody" ? "content" : key] = input[key];
1490
- }
1491
- if (component.effects = prepareEffects(() => {
1492
- branch || (created = 1, branch = component.scope = createAndSetupBranch(
1493
- out.global,
1494
- renderer,
1495
- renderer.f,
1496
- document.body
1497
- )), renderer.d?.(branch, renderer._ ? args[0] : args);
1498
- }), created)
1499
- return toInsertNode(
1500
- branch.S,
1501
- branch.K
1502
- );
1503
- }
1504
- };
1505
-
1506
- // src/dom/template.ts
1507
- var _template = (id, template, walks, setup, inputSignal) => {
1508
- let renderer = _content(
1509
- id,
1510
- template,
1511
- walks,
1512
- setup,
1513
- inputSignal
1514
- )();
1515
- return renderer.mount = mount, renderer._ = renderer, _resume(id, renderer);
1516
- };
1058
+ ctrl.abort();
1059
+ }
1060
+ //#endregion
1061
+ //#region src/common/compat-meta.ts
1062
+ //#endregion
1063
+ //#region src/dom/compat.ts
1064
+ //#endregion
1065
+ //#region src/dom/template.ts
1517
1066
  function mount(input = {}, reference, position) {
1518
- let branch, parentNode = reference, nextSibling = null, { $global } = input;
1519
- switch ($global ? ({ $global, ...input } = input, $global = {
1520
- runtimeId: "M",
1521
- renderId: "_",
1522
- ...$global
1523
- }) : $global = {
1524
- runtimeId: "M",
1525
- renderId: "_"
1526
- }, position) {
1527
- case "beforebegin":
1528
- parentNode = reference.parentNode, nextSibling = reference;
1529
- break;
1530
- case "afterbegin":
1531
- nextSibling = reference.firstChild;
1532
- break;
1533
- case "afterend":
1534
- parentNode = reference.parentNode, nextSibling = reference.nextSibling;
1535
- break;
1536
- }
1537
- let curValue, args = this.d, effects = prepareEffects(() => {
1538
- branch = createBranch(
1539
- $global,
1540
- this,
1541
- void 0,
1542
- parentNode
1543
- ), branch.T = (newValue) => {
1544
- curValue = newValue;
1545
- }, this.l?.(branch), args?.(branch, input);
1546
- });
1547
- return insertChildNodes(
1548
- parentNode,
1549
- nextSibling,
1550
- branch.S,
1551
- branch.K
1552
- ), runEffects(effects), {
1553
- get value() {
1554
- return curValue;
1555
- },
1556
- set value(newValue) {
1557
- _var_change(branch, newValue);
1558
- },
1559
- update(newInput) {
1560
- args && runEffects(
1561
- prepareEffects(() => {
1562
- args(branch, newInput);
1563
- })
1564
- );
1565
- },
1566
- destroy() {
1567
- removeAndDestroyBranch(branch);
1568
- }
1569
- };
1570
- }
1571
- export {
1572
- $signal,
1573
- $signalReset,
1574
- _assert_hoist,
1575
- _assert_init,
1576
- _attr,
1577
- _attr_class,
1578
- _attr_class_item,
1579
- _attr_class_items,
1580
- _attr_content,
1581
- _attr_details_or_dialog_open as _attr_details_open,
1582
- _attr_details_or_dialog_open_default as _attr_details_open_default,
1583
- _attr_details_or_dialog_open_script as _attr_details_open_script,
1584
- _attr_details_or_dialog_open as _attr_dialog_open,
1585
- _attr_details_or_dialog_open_default as _attr_dialog_open_default,
1586
- _attr_details_or_dialog_open_script as _attr_dialog_open_script,
1587
- _attr_input_checked,
1588
- _attr_input_checkedValue,
1589
- _attr_input_checkedValue_default,
1590
- _attr_input_checkedValue_script,
1591
- _attr_input_checked_default,
1592
- _attr_input_checked_script,
1593
- _attr_input_value,
1594
- _attr_input_value_default,
1595
- _attr_input_value_script,
1596
- _attr_nonce,
1597
- _attr_select_value,
1598
- _attr_select_value_default,
1599
- _attr_select_value_script,
1600
- _attr_style,
1601
- _attr_style_item,
1602
- _attr_style_items,
1603
- _attr_input_value as _attr_textarea_value,
1604
- _attr_input_value_default as _attr_textarea_value_default,
1605
- _attr_input_value_script as _attr_textarea_value_script,
1606
- _attrs,
1607
- _attrs_content,
1608
- _attrs_partial,
1609
- _attrs_partial_content,
1610
- _attrs_script,
1611
- _await_content,
1612
- _await_promise,
1613
- _call,
1614
- _child_setup,
1615
- _closure,
1616
- _closure_get,
1617
- _const,
1618
- _content,
1619
- _content_closures,
1620
- _content_resume,
1621
- _dynamic_tag,
1622
- _el,
1623
- _el_read,
1624
- _enable_catch,
1625
- _for_closure,
1626
- _for_in,
1627
- _for_of,
1628
- _for_to,
1629
- _for_until,
1630
- _hoist,
1631
- _hoist_resume,
1632
- _html,
1633
- _id,
1634
- _if,
1635
- _if_closure,
1636
- _let,
1637
- _lifecycle,
1638
- _on,
1639
- _or,
1640
- _resume,
1641
- _resume_dynamic_tag,
1642
- _return,
1643
- _return_change,
1644
- _script,
1645
- _template,
1646
- _text,
1647
- _text_content,
1648
- _to_text,
1649
- _try,
1650
- _var,
1651
- _var_change,
1652
- _var_resume,
1653
- attrTag,
1654
- attrTags,
1655
- compat,
1656
- forIn,
1657
- forOf,
1658
- forTo,
1659
- forUntil,
1660
- init,
1661
- initEmbedded,
1662
- run
1663
- };
1067
+ let branch, parentNode = reference, nextSibling = null, { $global } = input;
1068
+ switch ($global ? ({$global, ...input} = input, $global = {
1069
+ runtimeId: "M",
1070
+ renderId: "_",
1071
+ ...$global
1072
+ }) : $global = {
1073
+ runtimeId: "M",
1074
+ renderId: "_"
1075
+ }, position) {
1076
+ case "beforebegin":
1077
+ parentNode = reference.parentNode, nextSibling = reference;
1078
+ break;
1079
+ case "afterbegin":
1080
+ nextSibling = reference.firstChild;
1081
+ break;
1082
+ case "afterend":
1083
+ parentNode = reference.parentNode, nextSibling = reference.nextSibling;
1084
+ break;
1085
+ }
1086
+ let curValue, args = this.d, effects = prepareEffects(() => {
1087
+ branch = createBranch($global, this, void 0, parentNode), branch.T = (newValue) => {
1088
+ curValue = newValue;
1089
+ }, this.c?.(branch), args?.(branch, input);
1090
+ });
1091
+ return insertChildNodes(parentNode, nextSibling, branch.S, branch.K), runEffects(effects), {
1092
+ get value() {
1093
+ return curValue;
1094
+ },
1095
+ set value(newValue) {
1096
+ _var_change(branch, newValue);
1097
+ },
1098
+ update(newInput) {
1099
+ args && runEffects(prepareEffects(() => {
1100
+ args(branch, newInput);
1101
+ }));
1102
+ },
1103
+ destroy() {
1104
+ removeAndDestroyBranch(branch);
1105
+ }
1106
+ };
1107
+ }
1108
+ //#endregion
1109
+ export { $signal, $signalReset, _assert_hoist, _assert_init, _attr, _attr_class, _attr_class_item, _attr_class_items, _attr_content, _attr_details_or_dialog_open as _attr_details_open, _attr_details_or_dialog_open as _attr_dialog_open, _attr_details_or_dialog_open_default as _attr_details_open_default, _attr_details_or_dialog_open_default as _attr_dialog_open_default, _attr_details_or_dialog_open_script as _attr_details_open_script, _attr_details_or_dialog_open_script as _attr_dialog_open_script, _attr_input_checked, _attr_input_checkedValue, _attr_input_checkedValue_default, _attr_input_checkedValue_script, _attr_input_checked_default, _attr_input_checked_script, _attr_input_value, _attr_input_value as _attr_textarea_value, _attr_input_value_default, _attr_input_value_default as _attr_textarea_value_default, _attr_input_value_script, _attr_input_value_script as _attr_textarea_value_script, _attr_nonce, _attr_select_value, _attr_select_value_default, _attr_select_value_script, _attr_style, _attr_style_item, _attr_style_items, _attrs, _attrs_content, _attrs_partial, _attrs_partial_content, _attrs_script, _await_content, _await_promise, _call, _child_setup, _closure, _closure_get, _const, _content, _content_closures, _content_resume, _dynamic_tag, _el, _el_read, _enable_catch, _for_closure, _for_in, _for_of, _for_to, _for_until, _hoist, _hoist_resume, _html, _id, _if, _if_closure, _let, _lifecycle, _on, _or, _resume, _resume_dynamic_tag, _return, _return_change, _script, _template, _text, _text_content, _to_text, _try, _var, _var_change, _var_resume, attrTag, attrTags, compat, forIn, forOf, forTo, forUntil, init, initEmbedded, run };