@shortfuse/materialdesignweb 0.10.3 → 0.11.2
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/README.md +1 -1
- package/core/Composition.js +40 -32
- package/core/CompositionAdapter.js +40 -25
- package/dist/CustomElement.min.js +1 -1
- package/dist/CustomElement.min.js.map +3 -3
- package/dist/index.min.js +57 -57
- package/dist/index.min.js.map +3 -3
- package/dist/meta.json +1 -1
- package/package.json +1 -1
- package/types/core/Composition.d.ts +1 -2
- package/types/core/Composition.d.ts.map +1 -1
- package/types/core/CompositionAdapter.d.ts +6 -4
- package/types/core/CompositionAdapter.d.ts.map +1 -1
package/README.md
CHANGED
|
@@ -72,7 +72,7 @@ Notes:
|
|
|
72
72
|
|
|
73
73
|
## Documentation
|
|
74
74
|
|
|
75
|
-
Material Design Web (MDW) is components-first. If you just want to build UI, start with the component docs and use HTML only — no JavaScript required.
|
|
75
|
+
Material Design Web (MDW) is components-first. If you just want to build a UI, start with the component docs and use HTML only — no custom JavaScript required.
|
|
76
76
|
|
|
77
77
|
### 1) Use the components
|
|
78
78
|
- [Getting started](docs/components/getting-started.md)
|
package/core/Composition.js
CHANGED
|
@@ -28,7 +28,6 @@ import { generateUID } from './uid.js';
|
|
|
28
28
|
* @prop {ShadowRoot} [shadowRoot] where
|
|
29
29
|
* @prop {any} [context] `this` on callbacks/events
|
|
30
30
|
* @prop {any} [injections]
|
|
31
|
-
* @prop {number} [iterationIndex]
|
|
32
31
|
*/
|
|
33
32
|
|
|
34
33
|
/**
|
|
@@ -196,7 +195,7 @@ function writeDynamicNode({ nodeStates, comments, nodes }, value) {
|
|
|
196
195
|
const { commentIndex, nodeIndex } = this;
|
|
197
196
|
const nodeState = nodeStates[nodeIndex];
|
|
198
197
|
// eslint-disable-next-line no-bitwise
|
|
199
|
-
const hidden = nodeState & 0b0001;
|
|
198
|
+
const hidden = nodeState & 0b0001; // has hidden bit
|
|
200
199
|
const show = value != null && value !== false;
|
|
201
200
|
if (!show) {
|
|
202
201
|
// Should be hidden
|
|
@@ -209,16 +208,26 @@ function writeDynamicNode({ nodeStates, comments, nodes }, value) {
|
|
|
209
208
|
}
|
|
210
209
|
nodes[nodeIndex].replaceWith(comment);
|
|
211
210
|
// eslint-disable-next-line no-bitwise
|
|
212
|
-
nodeStates[nodeIndex] |= 0b0001;
|
|
211
|
+
nodeStates[nodeIndex] |= 0b0001; // set hidden bit
|
|
213
212
|
return;
|
|
214
213
|
}
|
|
215
214
|
// Must be shown
|
|
216
215
|
// Update node first (offscreen rendering)
|
|
217
216
|
const node = nodes[nodeIndex];
|
|
218
217
|
// eslint-disable-next-line no-bitwise
|
|
219
|
-
const isDynamicNode = nodeState & 0b0010;
|
|
220
|
-
|
|
221
|
-
if (
|
|
218
|
+
const isDynamicNode = nodeState & 0b0010; // has dynamic-node bit (non-text)
|
|
219
|
+
|
|
220
|
+
if (value instanceof Node) {
|
|
221
|
+
const DOCUMENT_FRAGMENT_NODE = 11; // Node.DOCUMENT_FRAGMENT_NODE
|
|
222
|
+
if (value.nodeType === DOCUMENT_FRAGMENT_NODE) {
|
|
223
|
+
console.warn('Dynamic nodes do not support DocumentFragment yet');
|
|
224
|
+
} else if (node !== value) {
|
|
225
|
+
node.replaceWith(value);
|
|
226
|
+
nodes[nodeIndex] = /** @type {Element} */ (value);
|
|
227
|
+
}
|
|
228
|
+
// eslint-disable-next-line no-bitwise
|
|
229
|
+
nodeStates[nodeIndex] |= 0b0010; // set dynamic-node bit
|
|
230
|
+
} else if (typeof value === 'object') {
|
|
222
231
|
// Not string data, need to replace
|
|
223
232
|
console.warn('Dynamic nodes not supported yet');
|
|
224
233
|
} else if (isDynamicNode) {
|
|
@@ -226,7 +235,7 @@ function writeDynamicNode({ nodeStates, comments, nodes }, value) {
|
|
|
226
235
|
node.replaceWith(textNode);
|
|
227
236
|
nodes[nodeIndex] = textNode;
|
|
228
237
|
// eslint-disable-next-line no-bitwise
|
|
229
|
-
nodeStates[nodeIndex] &= ~0b0010;
|
|
238
|
+
nodeStates[nodeIndex] &= ~0b0010; // unset dynamic-node bit
|
|
230
239
|
} else {
|
|
231
240
|
/** @type {Text} */ (node).data = value;
|
|
232
241
|
}
|
|
@@ -237,7 +246,7 @@ function writeDynamicNode({ nodeStates, comments, nodes }, value) {
|
|
|
237
246
|
const comment = comments[commentIndex];
|
|
238
247
|
comment.replaceWith(node);
|
|
239
248
|
// eslint-disable-next-line no-bitwise
|
|
240
|
-
nodeStates[nodeIndex] &= ~0b0001;
|
|
249
|
+
nodeStates[nodeIndex] &= ~0b0001; // unset hidden bit
|
|
241
250
|
}
|
|
242
251
|
// Done
|
|
243
252
|
}
|
|
@@ -249,7 +258,7 @@ function writeDynamicNode({ nodeStates, comments, nodes }, value) {
|
|
|
249
258
|
function writeDOMElementAttachedState({ nodeStates, nodes, comments }, value) {
|
|
250
259
|
const { commentIndex, nodeIndex } = this;
|
|
251
260
|
// eslint-disable-next-line no-bitwise
|
|
252
|
-
const hidden = nodeStates[nodeIndex] & 1;
|
|
261
|
+
const hidden = nodeStates[nodeIndex] & 1; // has hidden bit
|
|
253
262
|
const show = value != null && value !== false;
|
|
254
263
|
if (show === !hidden) return;
|
|
255
264
|
|
|
@@ -262,11 +271,11 @@ function writeDOMElementAttachedState({ nodeStates, nodes, comments }, value) {
|
|
|
262
271
|
if (show) {
|
|
263
272
|
comment.replaceWith(element);
|
|
264
273
|
// eslint-disable-next-line no-bitwise
|
|
265
|
-
nodeStates[nodeIndex] &= ~0b0001;
|
|
274
|
+
nodeStates[nodeIndex] &= ~0b0001; // unset hidden bit
|
|
266
275
|
} else {
|
|
267
276
|
element.replaceWith(comment);
|
|
268
277
|
// eslint-disable-next-line no-bitwise
|
|
269
|
-
nodeStates[nodeIndex] |= 0b0001;
|
|
278
|
+
nodeStates[nodeIndex] |= 0b0001; // set hidden bit
|
|
270
279
|
}
|
|
271
280
|
}
|
|
272
281
|
|
|
@@ -280,7 +289,7 @@ function writeDOMHideNodeOnInit({ comments, nodeStates, nodes }) {
|
|
|
280
289
|
const comment = createEmptyComment();
|
|
281
290
|
comments[commentIndex] = comment;
|
|
282
291
|
// eslint-disable-next-line no-bitwise
|
|
283
|
-
nodeStates[nodeIndex] |= 1;
|
|
292
|
+
nodeStates[nodeIndex] |= 1; // set hidden bit
|
|
284
293
|
|
|
285
294
|
nodes[nodeIndex].replaceWith(comment);
|
|
286
295
|
}
|
|
@@ -364,7 +373,7 @@ function searchWithProp(state, changes) {
|
|
|
364
373
|
function searchWithDeepProp(state, changes, data) {
|
|
365
374
|
let scope = changes;
|
|
366
375
|
for (const prop of this.deepProp) {
|
|
367
|
-
if (scope
|
|
376
|
+
if (scope == null) return scope;
|
|
368
377
|
if (prop in scope === false) return undefined;
|
|
369
378
|
scope = scope[prop];
|
|
370
379
|
}
|
|
@@ -389,7 +398,7 @@ function searchWithDeepProp(state, changes, data) {
|
|
|
389
398
|
* @prop {HTMLElement[]} refs
|
|
390
399
|
* @prop {number} lastChildNodeIndex
|
|
391
400
|
* @prop {RenderOptions<?>} options
|
|
392
|
-
* @prop {CompositionAdapter<any>[]
|
|
401
|
+
* @prop {CompositionAdapter<any>[]} adapters
|
|
393
402
|
*/
|
|
394
403
|
|
|
395
404
|
/** Splits: `{template}text{template}` as `['', 'template', 'text', 'template', '']` */
|
|
@@ -1020,7 +1029,7 @@ export default class Composition {
|
|
|
1020
1029
|
expression = inlineFunctionOptions.fn;
|
|
1021
1030
|
invocation = searchWithExpression;
|
|
1022
1031
|
if (inlineFunctionOptions.props) {
|
|
1023
|
-
|
|
1032
|
+
// console.log('This function has already been called. Reuse props', inlineFunctionOptions, this);
|
|
1024
1033
|
propsUsed = inlineFunctionOptions.props;
|
|
1025
1034
|
deepPropsUsed = inlineFunctionOptions.deepProps;
|
|
1026
1035
|
defaultValue = inlineFunctionOptions.defaultValue ?? null;
|
|
@@ -1040,7 +1049,7 @@ export default class Composition {
|
|
|
1040
1049
|
|
|
1041
1050
|
if (!propsUsed) {
|
|
1042
1051
|
if (typeof defaultValue === 'function') {
|
|
1043
|
-
|
|
1052
|
+
// Value must be reinterpolated and function observed
|
|
1044
1053
|
const observeResult = observeFunction.call(this, defaultValue, options?.defaults, options?.injections);
|
|
1045
1054
|
const uniqueProps = new Set([
|
|
1046
1055
|
...observeResult.props.this,
|
|
@@ -1056,9 +1065,9 @@ export default class Composition {
|
|
|
1056
1065
|
propsUsed = [...uniqueProps];
|
|
1057
1066
|
deepPropsUsed = [...uniqueDeepProps].map((deepPropString) => deepPropString.split('.'));
|
|
1058
1067
|
invocation = searchWithExpression;
|
|
1059
|
-
|
|
1068
|
+
// console.log(this.static.name, fn.name || parsedValue, combinedSet);
|
|
1060
1069
|
} else {
|
|
1061
|
-
|
|
1070
|
+
// property binding
|
|
1062
1071
|
const parsedProps = parsedValue.split('.');
|
|
1063
1072
|
if (parsedProps.length === 1) {
|
|
1064
1073
|
prop = parsedValue;
|
|
@@ -1321,10 +1330,8 @@ export default class Composition {
|
|
|
1321
1330
|
injections,
|
|
1322
1331
|
invocation(state, value, changes, data) {
|
|
1323
1332
|
// Optimistic get
|
|
1324
|
-
let
|
|
1325
|
-
|
|
1326
|
-
let adapter;
|
|
1327
|
-
if (!adaptersArray || (!(adapter = adaptersArray[iterationIndex]))) {
|
|
1333
|
+
let adapter = state.adapters[this.adapterIndex];
|
|
1334
|
+
if (!adapter) {
|
|
1328
1335
|
const instanceAnchorElement = state.nodes[this.nodeIndex];
|
|
1329
1336
|
const anchorNode = createEmptyComment();
|
|
1330
1337
|
|
|
@@ -1337,6 +1344,9 @@ export default class Composition {
|
|
|
1337
1344
|
|
|
1338
1345
|
// @ts-ignore DocumentFragment in documents can be replaced (bad typings)
|
|
1339
1346
|
instanceAnchorElement.replaceWith(anchorNode);
|
|
1347
|
+
// Store parent props that nested composition needs
|
|
1348
|
+
const parentProps = newComposition.props.filter((p) => p !== valueName && p !== iterableName);
|
|
1349
|
+
|
|
1340
1350
|
adapter = new CompositionAdapter({
|
|
1341
1351
|
anchorNode,
|
|
1342
1352
|
composition: newComposition,
|
|
@@ -1346,11 +1356,10 @@ export default class Composition {
|
|
|
1346
1356
|
store: state.options.store,
|
|
1347
1357
|
injections: this.injections,
|
|
1348
1358
|
},
|
|
1359
|
+
parentProps,
|
|
1349
1360
|
});
|
|
1350
1361
|
|
|
1351
|
-
|
|
1352
|
-
adaptersArray = ((state.adapters[this.adapterIndex] ??= []));
|
|
1353
|
-
adaptersArray[iterationIndex] = adapter;
|
|
1362
|
+
state.adapters[this.adapterIndex] = adapter;
|
|
1354
1363
|
}
|
|
1355
1364
|
|
|
1356
1365
|
const currentInjections = state.options.injections ?? this.injections;
|
|
@@ -1370,11 +1379,12 @@ export default class Composition {
|
|
|
1370
1379
|
const changeList = iterableDeepProp
|
|
1371
1380
|
? deepPropFromObject(iterableDeepProp, changes)
|
|
1372
1381
|
: changes[iterableName];
|
|
1382
|
+
const needTargetAll = newComposition.props
|
|
1383
|
+
.some((prop) => prop !== valueName && prop !== iterableName && prop in changes);
|
|
1373
1384
|
|
|
1374
|
-
if (changeList === undefined) return;
|
|
1385
|
+
if (changeList === undefined && !needTargetAll) return;
|
|
1375
1386
|
|
|
1376
1387
|
const innerChanges = { ...changes };
|
|
1377
|
-
const needTargetAll = newComposition.props.some((prop) => prop !== iterableName && prop in changes);
|
|
1378
1388
|
|
|
1379
1389
|
adapter.startBatch();
|
|
1380
1390
|
let isArray;
|
|
@@ -1393,8 +1403,7 @@ export default class Composition {
|
|
|
1393
1403
|
currentInjections[valueName] = resource;
|
|
1394
1404
|
currentInjections.index = index;
|
|
1395
1405
|
adapter.renderOptions.injections = currentInjections;
|
|
1396
|
-
adapter.
|
|
1397
|
-
adapter.renderData(index, innerChanges, data, resource, change);
|
|
1406
|
+
adapter.renderData(index, innerChanges, source, resource, change);
|
|
1398
1407
|
}
|
|
1399
1408
|
} else {
|
|
1400
1409
|
if (!changeList) {
|
|
@@ -1419,8 +1428,7 @@ export default class Composition {
|
|
|
1419
1428
|
currentInjections[valueName] = resource;
|
|
1420
1429
|
currentInjections.index = index;
|
|
1421
1430
|
adapter.renderOptions.injections = currentInjections;
|
|
1422
|
-
adapter.
|
|
1423
|
-
adapter.renderData(index, innerChanges, data, resource, change);
|
|
1431
|
+
adapter.renderData(index, innerChanges, source, resource, change);
|
|
1424
1432
|
// adapter.renderIndex(index, innerChanges, data, resource);
|
|
1425
1433
|
}
|
|
1426
1434
|
}
|
|
@@ -1500,7 +1508,7 @@ export default class Composition {
|
|
|
1500
1508
|
break;
|
|
1501
1509
|
case Node.TEXT_NODE:
|
|
1502
1510
|
element = node.parentElement;
|
|
1503
|
-
if (this.#interpolateNode(/** @type {Text} */
|
|
1511
|
+
if (this.#interpolateNode(/** @type {Text} */(node), element, options)) {
|
|
1504
1512
|
const nextNode = treeWalker.nextNode();
|
|
1505
1513
|
/** @type {Text} */ (node).remove();
|
|
1506
1514
|
node = nextNode;
|
|
@@ -12,11 +12,12 @@ import { createEmptyComment } from './optimizations.js';
|
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* @template T
|
|
15
|
-
* @typedef {Object}
|
|
15
|
+
* @typedef {Object} CompositionAdapterCreateOptions
|
|
16
16
|
* @prop {Comment} anchorNode
|
|
17
17
|
* @prop {(...args:any[]) => HTMLElement} [create]
|
|
18
18
|
* @prop {Composition<T>} composition
|
|
19
19
|
* @prop {RenderOptions<T>} renderOptions
|
|
20
|
+
* @prop {string[]} [parentProps]
|
|
20
21
|
*/
|
|
21
22
|
|
|
22
23
|
/**
|
|
@@ -47,23 +48,31 @@ function restoreFocus(focused) {
|
|
|
47
48
|
/**
|
|
48
49
|
* @param {Element|Comment} node
|
|
49
50
|
* @param {ChildNode} beforeNode
|
|
51
|
+
* @param {ParentNode} parentNode
|
|
50
52
|
*/
|
|
51
|
-
function moveNode(node, beforeNode) {
|
|
53
|
+
function moveNode(node, beforeNode, parentNode) {
|
|
52
54
|
const focused = captureFocus(node);
|
|
53
55
|
if (beforeNode) {
|
|
54
56
|
beforeNode.before(node);
|
|
55
57
|
} else {
|
|
56
|
-
|
|
58
|
+
parentNode.append(node);
|
|
57
59
|
}
|
|
58
60
|
restoreFocus(focused);
|
|
59
61
|
}
|
|
60
62
|
|
|
61
63
|
// @ts-expect-error Bad typings
|
|
62
64
|
const hasMoveBefore = typeof Element.prototype.moveBefore === 'function';
|
|
65
|
+
/** @type {(node: Element|Comment, beforeNode: ChildNode, parentNode: Node) => void} */
|
|
66
|
+
const moveBeforeNode = hasMoveBefore
|
|
67
|
+
? (node, beforeNode, parentNode) => {
|
|
68
|
+
// @ts-ignore Bad typings
|
|
69
|
+
parentNode.moveBefore(node, beforeNode);
|
|
70
|
+
}
|
|
71
|
+
: moveNode;
|
|
63
72
|
|
|
64
73
|
/** @template T */
|
|
65
74
|
export default class CompositionAdapter {
|
|
66
|
-
/** @param {
|
|
75
|
+
/** @param {CompositionAdapterCreateOptions<T>} options */
|
|
67
76
|
constructor(options) {
|
|
68
77
|
this.anchorNode = options.anchorNode;
|
|
69
78
|
|
|
@@ -98,6 +107,8 @@ export default class CompositionAdapter {
|
|
|
98
107
|
this.batchStartIndex = null;
|
|
99
108
|
/** @type {number|null} */
|
|
100
109
|
this.batchEndIndex = null;
|
|
110
|
+
|
|
111
|
+
this.parentProps = options.parentProps || [];
|
|
101
112
|
}
|
|
102
113
|
|
|
103
114
|
/**
|
|
@@ -137,11 +148,14 @@ export default class CompositionAdapter {
|
|
|
137
148
|
}
|
|
138
149
|
|
|
139
150
|
/** @param {number} index */
|
|
140
|
-
|
|
151
|
+
moveToEndByIndex(index) {
|
|
141
152
|
const [metadata] = this.metadata.splice(index, 1);
|
|
142
153
|
const { domNode, key } = metadata;
|
|
143
154
|
this.keys.splice(index, 1);
|
|
144
|
-
domNode.
|
|
155
|
+
const removalContainer = domNode.parentNode;
|
|
156
|
+
if (removalContainer) {
|
|
157
|
+
moveNode(domNode, null, removalContainer);
|
|
158
|
+
}
|
|
145
159
|
|
|
146
160
|
// Don't release in case we may need it later
|
|
147
161
|
if (this.metadataCache) {
|
|
@@ -213,8 +227,8 @@ export default class CompositionAdapter {
|
|
|
213
227
|
this.metadata.splice(newIndex, 0, previousMetadata);
|
|
214
228
|
this.keys.splice(newIndex, 0, key);
|
|
215
229
|
|
|
216
|
-
|
|
217
|
-
|
|
230
|
+
moveBeforeNode(previousMetadata.domNode, metadataAtIndex.domNode, metadataAtIndex.domNode.parentNode);
|
|
231
|
+
previousMetadata.render(changes, data);
|
|
218
232
|
metadataCache.delete(key);
|
|
219
233
|
return;
|
|
220
234
|
}
|
|
@@ -233,11 +247,11 @@ export default class CompositionAdapter {
|
|
|
233
247
|
// console.warn('Found key for', newIndex, '@', oldIndex);
|
|
234
248
|
// console.warn('swapping', newIndex, '<=>', oldIndex);
|
|
235
249
|
if ((newIndex - oldIndex) === -1) {
|
|
236
|
-
// (Optimistic
|
|
237
|
-
// If element should be one step sooner,
|
|
250
|
+
// (Optimistic move-to-end)
|
|
251
|
+
// If element should be one step sooner, move current to end to shift up.
|
|
238
252
|
// If should have been swap, will correct itself next step.
|
|
239
|
-
// console.warn('
|
|
240
|
-
this.
|
|
253
|
+
// console.warn('Moving', newIndex, 'to end instead');
|
|
254
|
+
this.moveToEndByIndex(newIndex);
|
|
241
255
|
return;
|
|
242
256
|
}
|
|
243
257
|
// Swap with other element
|
|
@@ -256,18 +270,9 @@ export default class CompositionAdapter {
|
|
|
256
270
|
|
|
257
271
|
const removalContainer = domNodeToRemove.parentNode;
|
|
258
272
|
const correctNext = correctMetadata.domNode.nextSibling;
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
if (correctNext) {
|
|
263
|
-
// @ts-expect-error Bad typings
|
|
264
|
-
removalContainer.moveBefore(domNodeToRemove, correctNext);
|
|
265
|
-
}
|
|
266
|
-
} else {
|
|
267
|
-
moveNode(correctMetadata.domNode, domNodeToRemove);
|
|
268
|
-
if (correctNext) {
|
|
269
|
-
moveNode(domNodeToRemove, correctNext);
|
|
270
|
-
}
|
|
273
|
+
moveBeforeNode(correctMetadata.domNode, domNodeToRemove, removalContainer);
|
|
274
|
+
if (correctNext) {
|
|
275
|
+
moveBeforeNode(domNodeToRemove, correctNext, removalContainer);
|
|
271
276
|
}
|
|
272
277
|
|
|
273
278
|
if (!skipOnMatch) {
|
|
@@ -284,7 +289,17 @@ export default class CompositionAdapter {
|
|
|
284
289
|
}
|
|
285
290
|
}
|
|
286
291
|
|
|
287
|
-
const
|
|
292
|
+
const initialChanges = { ...changes };
|
|
293
|
+
|
|
294
|
+
if (this.parentProps.length) {
|
|
295
|
+
for (const prop of this.parentProps) {
|
|
296
|
+
if (prop in data) {
|
|
297
|
+
initialChanges[prop] = data[prop];
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
const render = this.render(initialChanges, data);
|
|
288
303
|
const element = /** @type {Element} */ (render.target);
|
|
289
304
|
|
|
290
305
|
this.metadata[newIndex] = {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var De,Ue;function me(){return(De??=new Text).cloneNode()}function W(){return(Ue??=new Comment).cloneNode()}function Ve(i){var e,t;return(e=i==null?void 0:i.matches)!=null&&e.call(i,":focus")?i:(t=i==null?void 0:i.querySelector)==null?void 0:t.call(i,":focus")}function qe(i){i&&i.isConnected&&!i.matches(":focus")&&i.focus()}function ye(i,e){var n;let t=Ve(i);e?e.before(i):(n=i.parentNode)==null||n.append(i),qe(t)}var $e=typeof Element.prototype.moveBefore=="function",q=class{constructor(e){this.anchorNode=e.anchorNode,this.metadata=[],this.keys=[],this.needsArrayKeyFastPath=!1,this.composition=e.composition,this.renderOptions=e.renderOptions,this.metadataCache=null,this.queuedElements=[],this.batchStartIndex=null,this.batchEndIndex=null}render(e,t){return this.composition.render(e,t,this.renderOptions)}startBatch(){this.needsArrayKeyFastPath=!0}writeBatch(){var t;if(!this.queuedElements.length)return;(((t=this.metadata[this.batchStartIndex-1])==null?void 0:t.domNode)??this.anchorNode).after(...this.queuedElements),this.queuedElements.length=0}stopBatch(){if(this.writeBatch(),this.needsArrayKeyFastPath=!1,this.batchStartIndex=null,this.batchEndIndex=null,this.metadataCache){for(let{domNode:e}of this.metadataCache.values())e.remove();this.metadataCache.clear()}}removeByIndex(e){let[t]=this.metadata.splice(e,1),{domNode:n,key:s}=t;this.keys.splice(e,1),n.remove(),this.metadataCache?this.metadataCache.set(s,t):this.metadataCache=new Map([[s,t]])}renderData(e,t,n,s,r,o){var l;if(e<this.metadata.length){let u=this.metadata[e],p=u.key,x=p===s,g=r!==s;if(x){g?u.render(t,n):o||u.render(t,n);return}let y=this.metadataCache??=new Map,h=!1;this.needsArrayKeyFastPath&&(h=!this.keys.includes(s),this.needsArrayFastPath=!1);let f=h?-1:this.keys.indexOf(s,e+1);if(f===-1){if(y.has(s)){let d=y.get(s);this.metadata.splice(e,0,d),this.keys.splice(e,0,s),(((l=this.metadata[e-1])==null?void 0:l.domNode)??this.anchorNode).after(d.domNode),y.delete(s);return}y.set(p,u)}else{if(e-f===-1){this.removeByIndex(e);return}let d=this.metadata[f];this.metadata[e]=d,this.metadata[f]=u;let{domNode:m}=u,b=m.parentNode,w=d.domNode.nextSibling;$e?(b.moveBefore(d.domNode,m),w&&b.moveBefore(m,w)):(ye(d.domNode,m),w&&ye(m,w)),o||d.render(t,n),this.keys[e]=s,this.keys[f]=p;return}}let a=this.render(t,n),c=a.target;this.metadata[e]={render:a,element:c,key:s,domNode:c},this.keys[e]=s,(this.batchEndIndex===null||this.batchEndIndex!==e-1)&&(this.writeBatch(),this.batchStartIndex=e),this.batchEndIndex=e,this.queuedElements.push(c)}removeEntries(e=0){let{length:t}=this.metadata;for(let n=t-1;n>=e;n--){let s=this.metadata[n];!s||!s.domNode||s.domNode.remove()}this.metadata.length=e,this.keys.length=e}hide(e,t,n){if(!t&&(e==null&&(e=this.keys.indexOf(n)),t=this.metadata[e],!t)||t.hidden)return!1;let{comment:s,element:r}=t;return s||(s=W(),t.comment=s),r.replaceWith(s),t.domNode=s,t.hidden=!0,!0}show(e,t,n){if(!t&&(e==null&&(e=this.keys.indexOf(n)),t=this.metadata[e],!t)||!t.hidden)return!1;let{comment:s,element:r}=t;return s.replaceWith(r),t.domNode=r,t.hidden=!1,!0}};var ee=new Map;function G(i,e=!0){if(e&&ee.has(i))return ee.get(i);let t=new CSSStyleSheet;return t.replaceSync(i),e&&ee.set(i,t),t}var te=new Map,be;function He(i,e=!0){let t;return e&&te.has(i)?t=te.get(i):(be??=document.implementation.createHTMLDocument(),t=be.createElement("style"),t.textContent=i,e&&te.set(i,t)),t.cloneNode(!0)}var Q;function ge(i,e=!0){if(Q==null)try{let t=G(i,e);return Q=!0,t}catch{Q=!1}return Q?G(i,e):He(i,e)}function*xe(i,e=!0){for(let t of i)t instanceof HTMLStyleElement?yield G(t.textContent,e):t.ownerNode?yield G([...t.cssRules].map(n=>n.cssText).join(""),e):yield t}var ne=new WeakMap;function*Ce(i,e=!0){for(let t of i)if(t instanceof HTMLStyleElement)yield t;else if(t.ownerNode instanceof HTMLStyleElement)yield t.ownerNode.cloneNode(!0);else if(e&&ne.has(t))yield ne.get(t).cloneNode(!0);else{let n=document.createElement("style");n.textContent=[...t.cssRules].map(s=>s.cssText).join(""),e&&ne.set(t,n),yield n.cloneNode(!0)}}function Se(i,...e){return ge(typeof i=="string"?i:String.raw({raw:i},...e))}function Ie(i){switch(i){case void 0:case null:case!1:return null;case!0:return"";default:return`${i}`}}var X;function D(i){if(X??=new Map,X.has(i))return X.get(i);let e=i.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`);return X.set(i,e),e}var we,Ke=Number.parseFloat((we=navigator.userAgent.match(/Chrome\/([\d.]+)/))==null?void 0:we[1]),Pe,ut=Number.parseFloat((Pe=navigator.userAgent.match(/Firefox\/([\d.]+)/))==null?void 0:Pe[1]),ke,dt=Ke||!navigator.userAgent.includes("AppleWebKit")?Number.NaN:Number.parseFloat((ke=navigator.userAgent.match(/Version\/([\d.]+)/))==null?void 0:ke[1]);function Ee(i,e){if(i===e)return i;if(Array.isArray(e)||i==null||e==null||typeof e!="object")return e;typeof i!="object"&&(i={});for(let[t,n]of Object.entries(e))n==null?t in i&&delete i[t]:i[t]=Ee(i[t],n);return i}function Ne(i,e){if(i===e)return i;let t=e!=null&&typeof e=="object"&&!Array.isArray(e),n=i!=null&&typeof i=="object"&&!Array.isArray(i);if(!t||!n)return e;for(let[s,r]of Object.entries(e))r==null?s in i&&delete i[s]:i[s]=Ne(i[s],r);return i}function ve(i,e,t="reference"){switch(t){case"clone":case"object":return Ee(i,e);default:return Ne(i,e)}}function _e(i,e){if(i===e)return null;if(e==null||typeof e!="object")return e;if(i==null||typeof i!="object")return structuredClone(e);let t={};if(Array.isArray(e))return e;let n=new Set(Object.keys(i));for(let[s,r]of Object.entries(e)){if(n.delete(s),r===null){t[s]=null;continue}if(r==null)continue;let o=_e(i[s],r);o!==null&&(t[s]=o)}for(let s of n)t[s]=null;return t}function Ae(i,e){if(i===e)return null;if(e==null||typeof e!="object")return e;if(i==null||typeof i!="object")return structuredClone(e);let t={};if(Array.isArray(e))return structuredClone(e);let n=new Set(Object.keys(i));for(let[s,r]of Object.entries(e)){if(n.delete(s),r===null){t[s]=null;continue}if(r==null)continue;let o=Ae(i[s],r);o!==null&&(t[s]=o)}for(let s of n)t[s]=null;return t}function se(i,e){if(i===e)return null;if(e==null||typeof e!="object")return e;if(i==null||typeof i!="object")return structuredClone(e);let t={};if(Array.isArray(e)){for(let[s,r]of e.entries()){if(r===null){t[s]=null;continue}if(r==null)continue;let o=se(i[s],r);o!==null&&(t[s]=o)}return e.length!==i.length&&(t.length=e.length),t}let n=new Set(Object.keys(i));for(let[s,r]of Object.entries(e)){if(n.delete(s),r===null){t[s]=null;continue}if(r==null)continue;let o=se(i[s],r);o!==null&&(t[s]=o)}for(let s of n)t[s]=null;return t}function Oe(i,e,t="reference"){switch(t){case"clone":return Ae(i,e);case"object":return se(i,e);default:return _e(i,e)}}function ie(i,e){if(i===e)return!1;if(e==null||typeof e!="object"||i!=null&&typeof i!="object")return!0;for(let[t,n]of Object.entries(e))if(n==null){if(t in i)return!0}else if(ie(i[t],n))return!0;return!1}function Qe(i,e){return Array.isArray(e)?i!==e:ie(i,e)}function Me(i,e,t="reference"){switch(t){case"clone":case"object":return Qe(i,e);default:return ie(i,e)}}function je(i){switch(i){case"boolean":return!1;case"integer":case"float":case"number":return 0;case"map":return new Map;case"set":return new Set;case"array":return[];case"proxy":case"object":return null;default:case"string":return""}}function re(i,e,t,n){return i??={},new Proxy(i,{get(s,r){let o=s[r];if(typeof r!="symbol"){let a=n?`${n}.${r}`:r;if(n?t.add(a):e.add(a),typeof o=="object"&&o!=null)return re(o,e,t,a)}return o},has(s,r){let o=Reflect.has(s,r);if(typeof r!="symbol"){let a=n?`${n}.${r}`:r;n?t.add(a):e.add(a)}return o}})}var Y=new WeakMap,oe=new WeakMap;function Ge(i){if(i==null||typeof i!="object")return null;let e=oe.get(i);if(!e){let t=new Set;e={subscribe(n){t.add(n)},unsubscribe(n){t.delete(n)},emit(n){for(let s of t)s(n)}},oe.set(i,e)}return e}function z(i,e){let t={},n=t;for(let s=0;s<i.length-1;s++)n[i[s]]={},n=n[i[s]];return n[i.at(-1)]=e,t}function Te(i,e,t,n,s){if(i==null||typeof i!="object")return i;let r=Ge(i);s||(s=r);let o=Y.get(i);if(o||(o=new Map,Y.set(i,o)),o.has(n))return o.get(n);let a=new Proxy(i,{get(c,l){if(typeof l=="symbol")return c[l];let u=c[l];return Te(u,e,t.concat(l),n,s)},set(c,l,u){if(c[l]=u,typeof l!="symbol"){let p=z(t.concat(l),u);if(e(p),s==null||s.emit(p),r&&r!==s){let x=z([l],u);r.emit(x)}}return!0},deleteProperty(c,l){if(typeof l!="symbol"){let u=z(t.concat(l),null);if(e(u),s==null||s.emit(u),r&&r!==s){let p=z([l],null);r.emit(p)}}return Reflect.deleteProperty(c,l)}});return Y.set(a,o),r&&oe.set(a,r),o.set(n,a),a}function Xe(i){switch(i){case"boolean":return e=>!!e;case"integer":return Math.round;case"float":case"number":return e=>+e;case"map":return Map;case"set":return Set;case"object":case"array":case"proxy":return e=>e;default:case"string":return e=>`${e}`}}function ae(i,...e){let t=new Set,n=new Set,s=e.map(c=>{let l=new Set,u=new Set,p=re(c,l,u);return{poked:l,pokedDeep:u,proxy:p}}),r=re(this??{},t,n),o=i.apply(r,s.map(c=>c.proxy)),a=i.name?!0:!t.size;return{props:{this:[...t],args:s.map(c=>[...c.poked])},deepPropStrings:{this:[...n],args:s.map(c=>[...c.pokedDeep])},deepProps:{this:[...n].map(c=>c.split(".")),args:s.map(c=>[...c.pokedDeep].map(l=>l.split(".")))},defaultValue:o,reusable:a}}function ze(){return null}function Ye(i,e,t){let n=typeof e=="string"?{type:e}:e,{watchers:s,value:r,readonly:o,empty:a,type:c,enumerable:l,reflect:u,attr:p,nullable:x,parser:g,nullParser:y,get:h,is:f,diff:d,props:m}=n;if(s??=[],o??=!1,a===void 0&&(a=null),r??=a,h&&!m){let b=ae(h.bind(t),t,()=>r);r??=b.defaultValue,m=new Set([...b.props.this,...b.props.args[0]])}if(!c)if(r==null)c="string";else{let b=typeof r;c=b==="number"?Number.isInteger(r)?"integer":"float":b}return l??=i[0]!=="_",x??=c==="boolean"?!1:a==null,x||(a??=je(c),r??=a),u??=l?c!=="object":p?"write":!1,p??=u?D(i):null,g??=Xe(c),y||(x?y=ze:y=a===null?()=>je(c):()=>a),f??=c==="object"||c==="proxy"?(b,w)=>!Me(b,w):c==="array"?()=>!1:Object.is,d===void 0&&(d=c==="object"?(b,w)=>Oe(b,w):null),{...n,type:c,is:f,diff:d,attr:p,reflect:u,readonly:o,enumerable:l,value:r,parser:g,nullParser:y,key:i,props:m,watchers:s}}function $(i,e,t){var r,o;i.get;let n=t==null?i.nullParser.call(this,t):i.parser.call(this,t),s=n;if(e==null){if(n==null)return!1}else if(n!=null){if(i.diff){if(s=i.diff.call(this,e,n),s==null)return!1}else if(i.is.call(this,e,n))return!1}return i.values?i.values.set(this,n):i.values=new WeakMap([[this,n]]),(r=i.propChangedCallback)==null||r.call(this,i.key,e,n,s),(o=i.changedCallback)==null||o.call(this,e,n,s),!0}function ce(i,e,t){let n=Ye(e,t,i);function s(h){if(n.type!=="proxy"||h==null||typeof h!="object")return h;let f=Y.get(h);if(f&&f.has(this))return f.get(this);let d=this;return Te(h,b=>{var P,j,T;let w=((P=n.values)==null?void 0:P.get(d))??h;(j=n.propChangedCallback)==null||j.call(d,n.key,w,w,b),(T=n.changedCallback)==null||T.call(d,w,w,b)},[],d,null)}function r(){var h;return(h=n.values)!=null&&h.has(this)?n.values.get(this):n.value}function o(){var f;if((f=n.values)!=null&&f.has(this))return n.values.get(this);let h=s.call(this,n.value);return h!==n.value&&(n.values?n.values.set(this,h):n.values=new WeakMap([[this,h]])),h}function a(h){var d;if(i===this&&((d=this==null?void 0:this.constructor)==null?void 0:d.prototype)===this)return;let f=this[e];$.call(this,n,f,h)}function c(h){var m;if(i===this&&((m=this==null?void 0:this.constructor)==null?void 0:m.prototype)===this)return;let f=this[e],d=s.call(this,h);$.call(this,n,f,d)}function l(){var d,m;let h=(d=n.computedValues)==null?void 0:d.get(this),f=this[e];(m=n.needsSelfInvalidation)==null||m.delete(this),$.call(this,n,h,f)}if(n.props)for(let h of n.props)n.watchers.push([h,l]);function u(){let h=n.get.call(this,this,r.bind(this));return(n.computedValues??=new WeakMap).set(this,h),h}function p(){let h=n.get.call(this,this,o.bind(this)),f=s.call(this,h);return(n.computedValues??=new WeakMap).set(this,f),f}function x(h){n.needsSelfInvalidation?n.needsSelfInvalidation.add(this):n.needsSelfInvalidation=new WeakSet([this]);let f=this[e];n.set.call(this,h,a.bind(this));let d=this[e];n.needsSelfInvalidation.has(this)&&(n.needsSelfInvalidation.delete(this),$.call(this,n,f,d))}function g(h){n.needsSelfInvalidation?n.needsSelfInvalidation.add(this):n.needsSelfInvalidation=new WeakSet([this]);let f=this[e];n.set.call(this,h,c.bind(this));let d=this[e];n.needsSelfInvalidation.has(this)&&(n.needsSelfInvalidation.delete(this),$.call(this,n,f,d))}let y={enumerable:n.enumerable,configurable:!0,get:n.get?n.type==="proxy"?p:u:n.type==="proxy"?o:r,set:n.set?n.type==="proxy"?g:x:n.type==="proxy"?c:a};return Object.defineProperty(i,e,y),n}var Fe=new Set;function H(i="mdw_",e=4){let t;for(;Fe.has(t=Math.random().toString(36).slice(2,e+2)););return Fe.add(t),`${i}${t}`}var le,Be,Re;function U(i){return le??=document.implementation.createHTMLDocument(),i?(Re??=le.createRange(),Re.createContextualFragment(i)):(Be??=le.createDocumentFragment(),Be.cloneNode())}var Z=new Map;function ue(i){let e=`#${H()}`;return Z.set(e,{fn:i}),`{${e}}`}var he=new Map;function de(i,...e){let t,n=e.map(o=>{switch(typeof o){case"string":return o;case"function":return ue(o);case"object":{if(o==null)return"";let a=H();return t??=new Map,t.set(a,o),`<div id="${a}"></div>`}default:throw new Error(`Unexpected substitution: ${o}`)}}),s=String.raw({raw:i},...n);if(t){let o=U(s);for(let[a,c]of t)o.getElementById(a).replaceWith(c);return o}let r;return he.has(s)?r=he.get(s):(r=U(s),he.set(s,r)),r.cloneNode(!0)}function Ze({nodes:i},e){let{nodeIndex:t,attrName:n}=this,s=i[t];switch(e){case void 0:case null:case!1:return s.removeAttribute(n),!1;case!0:return s.setAttribute(n,""),"";default:return s.setAttribute(n,e),e}}function Je({nodeStates:i,comments:e,nodes:t},n){let{commentIndex:s,nodeIndex:r}=this,o=i[r],a=o&1;if(!(n!=null&&n!==!1)){if(a)return;let p=e[s];p||(p=W(),e[s]=p),t[r].replaceWith(p),i[r]|=1;return}let l=t[r],u=o&2;if(typeof n!="object")if(u){let p=new Text(n);l.replaceWith(p),t[r]=p,i[r]&=-3}else l.data=n;a&&(e[s].replaceWith(l),i[r]&=-2)}function et({nodeStates:i,nodes:e,comments:t},n){let{commentIndex:s,nodeIndex:r}=this,o=i[r]&1,a=n!=null&&n!==!1;if(a===!o)return;let c=e[r],l=t[s];l||(l=W(),t[s]=l),a?(l.replaceWith(c),i[r]&=-2):(c.replaceWith(l),i[r]|=1)}function tt({comments:i,nodeStates:e,nodes:t}){let{commentIndex:n,nodeIndex:s}=this,r=W();i[n]=r,e[s]|=1,t[s].replaceWith(r)}function fe(i,...e){let[{caches:t,searchStates:n}]=e,{cacheIndex:s,searchIndex:r,subSearch:o,invocation:a}=i,c=t[s],l=n[r];if(l&1)return{value:c,dirty:(l&2)===2};n[r]|=1;let u;if(a){if(o){let p=fe(o,...e);if(!p.dirty&&c!==void 0)return n[r]&=-3,{value:c,dirty:!1};u=i.invocation(p.value)}else u=i.invocation(...e);if(u===void 0||c===u)return{value:u,dirty:!1}}return t[s]=u,n[r]|=2,{value:u,dirty:!0}}function We({options:{context:i,store:e,injections:t}},n,s){return this.expression.call(i,e??s,t)}function nt(i,e){return e[this.prop]}function st(i,e,t){let n=e;for(let s of this.deepProp){if(n===null)return null;if(!(s in n))return;n=n[s]}return n}var it=/{([^}]*)}/g;function rt(i,e){if(e)return e[i]}function K(i,e){if(!e)return;let t=e,n;for(n of i)if(typeof t=="object"){if(t===null)return null;if(!(n in t))return;t=t[n]}else return t[n];return t}function ot(i,e){let t=e;for(let n of i.split("."))if(!n||(t=t[n],t==null))return null;return t===e?null:t}var Le=new Map,V=class i{static EVENT_PREFIX_REGEX=/^([*1~]+)?(.*)$/;_interpolationState={nodeIndex:-1,searchIndex:0,cacheIndex:0,commentIndex:0,adapterIndex:0,nodeEntry:null};static shadowRootTag=Symbol();nodesToBind=[];props=[];searches=[];initCache=[];searchByQuery;actionsByPropsUsed;postInitActions=[];tagsWithBindings;tags=[];adapter;events;cloneable;styles=[];adoptedStyleSheets=[];stylesFragment;allIds=[];temporaryIds;interpolated=!1;constructor(...e){this.template=U(),this.append(...e)}*[Symbol.iterator](){for(let e of this.styles)yield e;yield this.template}static compose(...e){for(let[n,s]of Le)if(n.length===e.length&&e.every((r,o)=>r===n[o]))return s;let t=new i(...e);return Le.set(e,t),t}append(...e){for(let t of e)typeof t=="string"?this.append(U(t.trim())):t instanceof i?this.append(...t):t instanceof DocumentFragment?this.template.append(t):(t instanceof CSSStyleSheet||t instanceof HTMLStyleElement)&&this.styles.push(t);return this}addCompositionEventListener(e){let t=e.tag??"",n=this.events??=new Map;return n.has(t)?n.get(t).push(e):n.set(t,[e]),this}#s(e,t,n){var s;if((s=this.events)!=null&&s.has(e))for(let r of this.events.get(e)){let o;r.handleEvent?o=r.handleEvent:r.deepProp.length?o=K(r.deepProp,this.interpolateOptions.defaults):o=rt(r.prop,this.interpolateOptions.defaults),t.addEventListener(r.type,n?o.bind(n):o,r)}}render(e,t,n={}){this.interpolated||this.interpolate({defaults:t??e,...n});let s=this.cloneable.cloneNode(!0),r=n.shadowRoot,o=r??n.target??s.firstElementChild,a={lastChildNode:null,lastChildNodeIndex:0,lastElement:null,nodeStates:new Uint8Array(this._interpolationState.nodeIndex+1),searchStates:new Uint8Array(this._interpolationState.searchIndex),comments:[],nodes:[],caches:this.initCache.slice(),refs:[],adapters:[],options:n},{nodes:c,refs:l,searchStates:u,caches:p}=a;for(let{tag:g,textNodes:y}of this.nodesToBind){let h;if(g===""){if(!y.length)continue;l.push(null),c.push(null),h=s.firstChild}else{let d=s.getElementById(g);if(l.push(d),c.push(d),this.#s(g,d,n.context),!y.length)continue;h=d.firstChild}let f=0;for(let d of y){for(;d!==f;)h=h.nextSibling,f++;c.push(h)}}this.#s("",n.context),this.#s(i.shadowRootTag,n.context.shadowRoot,n.context);for(let g of this.postInitActions)g.invocation(a);let x=(g,y)=>{var f;if(!g)return;let h=!1;for(let d of this.props){if(!((f=this.actionsByPropsUsed)!=null&&f.has(d))||!(d in g))continue;let m=this.actionsByPropsUsed.get(d);for(let b of m){h=!0;let{dirty:w,value:P}=fe(b.search,a,g,y);w&&b.invocation(a,P,g,y)}}h&&u.fill(0)};return r?(n.context??=r.host,"adoptedStyleSheets"in r?this.adoptedStyleSheets.length&&(r.adoptedStyleSheets=[...r.adoptedStyleSheets,...this.adoptedStyleSheets]):this.stylesFragment.hasChildNodes()&&s.prepend(this.stylesFragment.cloneNode(!0))):n.context??=o,e!==this.interpolateOptions.defaults&&x(e,t),r&&(r.append(s),customElements.upgrade(r)),x.target=o,x.byProp=(g,y,h)=>{var b,w;if(!((b=this.actionsByPropsUsed)!=null&&b.has(g)))return;let f=!1;if((w=this.searchByQuery)!=null&&w.has(g)){f=!0;let P=this.searchByQuery.get(g);if(p[P.cacheIndex]===y)return;p[P.cacheIndex]=y,u[P.searchIndex]=3}let d,m=this.actionsByPropsUsed.get(g);for(let P of m)if(P.search.query===g)P.invocation(a,y);else{d??={[g]:y},h??=d,f=!0;let j=fe(P.search,a,d,h);j.dirty&&P.invocation(a,j.value,d,h)}f&&u.fill(0)},x.state=a,x}#n(e,t,n,s){var j,T;let{nodeValue:r,nodeName:o,nodeType:a}=e,c,l;if(a===Node.ATTRIBUTE_NODE?c=e:l=e,s==null){if(!r)return;let E=r.trim();if(!E)return;if(c||(t==null?void 0:t.tagName)==="STYLE"){if(E[0]!=="{")return;let{length:v}=E;if(E[v-1]!=="}")return;s=E.slice(1,-1)}else{let v=E.split(it);if(v.length<3)return;if(v.length===3&&!v[0]&&!v[2])s=v[1];else{for(let[C,S]of v.entries())if(C%2){let N=me();l.before(N),this.#n(N,t,n,S)}else S&&l.before(S);return!0}}}let u=s,p=s[0]==="!",x=!1;p&&(s=s.slice(1),x=s[0]==="!",x&&(s=s.slice(1)));let g,y;if(l){t!==l.parentElement&&(t=l.parentElement),y=0;let E=l;for(;E=E.previousSibling;)y++}else if(t!==c.ownerElement&&(t=c.ownerElement),o.startsWith("on")){let E=o.indexOf("-");if(E===-1)return;g=E===2}if(g){t.removeAttribute(o);let E=this.#t(t),v=o.slice(3),[,C,S]=v.match(/^([*1~]+)?(.*)$/),N,O,k=[];if(s.startsWith("#"))N=Z.get(s).fn;else{let _=s.split(".");_.length===1?(O=s,k=[]):(O=_[0],k=_)}this.addCompositionEventListener({tag:E,type:S,handleEvent:N,prop:O,deepProp:k,once:C==null?void 0:C.includes("1"),passive:C==null?void 0:C.includes("~"),capture:C==null?void 0:C.includes("*")});return}let h;if((j=this.searchByQuery)!=null&&j.has(u))h=this.searchByQuery.get(u);else{let E=s,v=E!==u,C;if(v&&((T=this.searchByQuery)!=null&&T.has(E)))C=this.searchByQuery.get(E);else{let S,N,O,k,_,B,R,A;if(s.startsWith("#")){if(A=Z.get(s),!A)return;S=A.fn,R=We,A.props?(N=A.props,O=A.deepProps,k=A.defaultValue??null):k=A.fn}else k=null,n!=null&&n.defaults&&(k=K(s.split("."),n.defaults)??null),k==null&&(n!=null&&n.injections)&&(k=ot(s,n.injections));if(!N)if(typeof k=="function"){let I=ae.call(this,k,n==null?void 0:n.defaults,n==null?void 0:n.injections),M=new Set([...I.props.this,...I.props.args[0],...I.props.args[1]]),F=new Set([...I.deepPropStrings.this,...I.deepPropStrings.args[0]]);S=k,k=I.defaultValue,N=[...M],O=[...F].map(L=>L.split(".")),R=We}else{let I=s.split(".");I.length===1?(_=s,N=[_],R=nt):(N=[I[0]],B=I,O=[I],R=st)}A&&(A.defaultValue=k,A.props=N,A.deepProps=O),C={cacheIndex:this._interpolationState.cacheIndex++,searchIndex:this._interpolationState.searchIndex++,query:E,defaultValue:k,subSearch:null,prop:_,propsUsed:N,deepProp:B,deepPropsUsed:O,invocation:R,expression:S},this.addSearch(C)}v?(h={cacheIndex:this._interpolationState.cacheIndex++,searchIndex:this._interpolationState.searchIndex++,query:u,subSearch:C,negate:p,doubleNegate:x,prop:C.prop,deepProp:C.deepProp,propsUsed:C.propsUsed,deepPropsUsed:C.deepPropsUsed,defaultValue:x?!!C.defaultValue:p?!C.defaultValue:C.defaultValue,invocation(S){return this.doubleNegate?!!S:this.negate?!S:S}},this.addSearch(h)):h=C}let f,d=null,m=h.defaultValue;l?d=y:o==="mdw-if"?(f=this.#t(t),t.removeAttribute(o),m=m!=null&&m!==!1):(d=o,o==="id"||m==null||m===!1?t.removeAttribute(o):t.setAttribute(o,m===!0?"":m)),f??=this.#t(t);let b=this._interpolationState.nodeEntry;(!b||b.tag!==f)&&(b={tag:f,textNodes:[]},this._interpolationState.nodeEntry=b,this.nodesToBind.push(b),this._interpolationState.nodeIndex++);let w;if(l)switch(b.textNodes.push(y),this._interpolationState.nodeIndex++,w={nodeIndex:this._interpolationState.nodeIndex,commentIndex:this._interpolationState.commentIndex++,invocation:Je,defaultValue:m,search:h},typeof m){case"string":l.data=m;break;case"number":l.data=`${m}`;break;default:l.data="";break}else d?w={nodeIndex:this._interpolationState.nodeIndex,attrName:d,defaultValue:m,invocation:Ze,search:h}:(w={nodeIndex:this._interpolationState.nodeIndex,commentIndex:this._interpolationState.commentIndex++,defaultValue:m,invocation:et,search:h},m||this.postInitActions.push({...w,invocation:tt}));this.addAction(w),(this.tagsWithBindings??=new Set).add(f)}#t(e){if(!e)return"";let t=e.id;return t?this.allIds.includes(t)||this.allIds.push(t):(t=H(),(this.temporaryIds??=new Set).add(t),this.allIds.push(t),e.id=t),t}#e(e,t){let n=e.getAttribute("mdw-for"),s=n==null?void 0:n.trim();if(!s||s[0]!=="{")return null;let{length:r}=s;if(s[r-1]!=="}")return null;let o=s.slice(1,-1),[a,c]=o.split(/\s+of\s+/);e.removeAttribute("mdw-for");let l=e.ownerDocument.createElement("template");e.replaceWith(l);let u=this.#t(l),p=this._interpolationState.nodeEntry;(!p||p.tag!==u)&&(p={tag:u,textNodes:[]},this._interpolationState.nodeEntry=p,this.nodesToBind.push(p),this._interpolationState.nodeIndex++);let x=new i;x.template.append(e);let g={...t.injections,[a]:null,index:null},y=c.split("."),h=y.length>1?y:null,f=h?y[0]:c,d=[f],m={cacheIndex:this._interpolationState.cacheIndex++,searchIndex:this._interpolationState.searchIndex++,query:null,prop:null,deepProp:h,propsUsed:d,deepPropsUsed:h?[h]:[[f]],defaultValue:{},invocation:null},b={defaultValue:null,nodeIndex:this._interpolationState.nodeIndex,search:m,commentIndex:this._interpolationState.commentIndex++,adapterIndex:this._interpolationState.adapterIndex++,injections:g,invocation(P,j,T,E){let v=P.adapters[this.adapterIndex],C=P.options.iterationIndex??0,S;if(!v||!(S=v[C])){let I=P.nodes[this.nodeIndex],M=W();if(P.comments[this.commentIndex])throw new Error("Comment already exists at index");P.comments[this.commentIndex]=M,I.replaceWith(M),S=new q({anchorNode:M,composition:x,renderOptions:{target:null,context:P.options.context,store:P.options.store,injections:this.injections}}),v=P.adapters[this.adapterIndex]??=[],v[C]=S}let N=P.options.injections??this.injections,O=E??P.options.store,k=h?K(h,O):O[f];if(k===void 0&&h&&N&&(k=K(h,N)),!k||k.length===0){S.removeEntries();return}let _=h?K(h,T):T[f];if(_===void 0)return;let B={...T},R=x.props.some(I=>I!==f&&I in T);S.startBatch();let A;if(!R&&!(A=Array.isArray(_))){let I=A?_.entries():Object.entries(_);for(let[M,F]of I){if(M==="length"||F===null)continue;let L=+M,pe=k[L];B[a]=F,N[a]=pe,N.index=L,S.renderOptions.injections=N,S.renderOptions.iterationIndex=L,S.renderData(L,B,E,pe,F)}}else{_||delete B[a];for(let[I,M]of k.entries()){let F;if(_){if(!R&&!(I in _)||(F=_[I],F===null))continue;B[a]=F}N[a]=M,N.index=I,S.renderOptions.injections=N,S.renderOptions.iterationIndex=I,S.renderData(I,B,E,M,F)}}S.stopBatch(),S.removeEntries(k.length)}};return x.interpolate({defaults:t.defaults,injections:g}),d.push(...x.props),this.addSearch(m),this.addAction(b),(this.tagsWithBindings??=new Set).add(u),x}interpolate(e){var r;this.interpolateOptions=e,this.cloneable=this.template.cloneNode(!0);let n=document.createTreeWalker(this.cloneable,5),s=n.nextNode();for(;s;){let o=null;switch(s.nodeType){case Node.ELEMENT_NODE:if(o=s,o.tagName==="TEMPLATE"){for(;o.contains(s=n.nextNode()););continue}if(o.tagName==="SCRIPT"){for(;o.contains(s=n.nextNode()););continue}if(o.hasAttribute("mdw-for")){for(;o.contains(s=n.nextNode()););this.#e(o,e);continue}else{let a=o.attributes.id;a&&(this.#n(a,o,e),this.#t(o));for(let c of[...o.attributes].reverse())c.nodeName!=="id"&&this.#n(c,o,e)}break;case Node.TEXT_NODE:if(o=s.parentElement,this.#n(s,o,e)){let a=n.nextNode();s.remove(),s=a;continue}break;default:throw new Error(`Unexpected node type: ${s.nodeType}`)}s=n.nextNode()}"adoptedStyleSheets"in document?this.adoptedStyleSheets=[...xe(this.styles)]:(this.stylesFragment=U(),this.stylesFragment.append(...Ce(this.styles))),this.props=this.actionsByPropsUsed?[...this.actionsByPropsUsed.keys()]:[];for(let o of this.allIds)(r=this.tagsWithBindings)!=null&&r.has(o)||this.nodesToBind.push({tag:o,textNodes:[]});this.tags=this.nodesToBind.map(o=>o.tag),this.interpolated=!0}addSearch(e){return this.searches.push(e),e.query&&((this.searchByQuery??=new Map).set(e.query,e),this.initCache[e.cacheIndex]=e.defaultValue),e}addAction(e){let t=this.actionsByPropsUsed??=new Map;for(let n of e.search.propsUsed)t.has(n)?t.get(n).push(e):t.set(n,[e]);return e}};function Tt(i,e){return(t,n,s)=>{n==null?s.refs[e].removeAttribute(i):s.refs[e].setAttribute(i,n)}}var J=class i extends HTMLElement{static elementName;static get observedAttributes(){return this.attrList.keys()}compose(){return this.#e??=new V}static _composition=null;static _props=new Map;static _attrs=new Map;static _propChangedCallbacks=new Map;static _attributeChangedCallbacks=new Map;static _onComposeCallbacks=[];static _onConnectedCallbacks=[];static _onDisconnectedCallbacks=[];static _onConstructedCallbacks=[];static interpolatesTemplate=!0;static supportsElementInternals="attachInternals"in HTMLElement.prototype;static supportsElementInternalsRole=i.supportsElementInternals&&"role"in ElementInternals.prototype;static defined=!1;static registrations=new Map;static expressions=this.set;static methods=this.set;static overrides=this.set;static props=this.observe;static idl=this.prop;static _addCallback(e,t){if(!this.hasOwnProperty(e)){this[e]=[...this[e],t];return}this[e].push(t)}static _removeCallback(e,t){this.hasOwnProperty(e)||(this[e]=[...this[e]]),this[e]=this[e].filter(n=>n!==t)}static _removeFromCallbackMap(e,t,n){if(!e.has(t))return;if(!n){e.delete(t);return}let s=e.get(t).filter(r=>r!==n);s.length===0?e.delete(t):e.set(t,s)}static append(...e){return this._onComposeCallbacks.push(({composition:t})=>{t.append(...e)}),this._addCallback("_onComposeCallbacks",(t=>{let{composition:n}=t;n.append(...e)})),this}static recompose(e){return this._addCallback("_onComposeCallbacks",e),this}static css(e,...t){return this._addCallback("_onComposeCallbacks",(n=>{let{composition:s}=n;typeof e=="string"||Array.isArray(e)?s.append(Se(e,...t)):s.append(e,...t)})),this}static autoRegister(e){return this.hasOwnProperty("defined")&&this.defined?this:(this.register(e),this)}static html(e,...t){return this._addCallback("_onComposeCallbacks",(n=>{let{composition:s}=n;s.append(de(e,...t))})),this}static extend(e){return e?e(this):class extends this{}}static setStatic(e){return Object.assign(this,e),this}static readonly(e,t){return this.set(e,{...t,writable:!1})}static set(e,t){return Object.defineProperties(this.prototype,Object.fromEntries([...Object.entries(e).map(([n,s])=>(this.undefine(n),[n,{enumerable:n[0]!=="_",configurable:!0,value:s,writable:!0,...t}])),...Object.getOwnPropertySymbols(e).map(n=>[n,{enumerable:!1,configurable:!0,value:e[n],writable:!0,...t}])])),this}static mixin(e){return e(this)}static register(e){return e&&(this.elementName=e),customElements.define(this.elementName,this),i.registrations.set(this.elementName,this),this.defined=!0,this}static get propList(){return this.hasOwnProperty("_props")||(this._props=new Map(this._props)),this._props}static get attrList(){return this.hasOwnProperty("_attrs")||(this._attrs=new Map(this._attrs)),this._attrs}static get propChangedCallbacks(){return this.hasOwnProperty("_propChangedCallbacks")||(this._propChangedCallbacks=new Map([...this._propChangedCallbacks].map(([e,t])=>[e,t.slice()]))),this._propChangedCallbacks}static get attributeChangedCallbacks(){return this.hasOwnProperty("_attributeChangedCallbacks")||(this._attributeChangedCallbacks=new Map([...this._attributeChangedCallbacks].map(([e,t])=>[e,t.slice()]))),this._attributeChangedCallbacks}static prop(e,t){let n=ce(this.prototype,e,t),{changedCallback:s,attr:r,reflect:o,watchers:a}=n;return s&&a.push([e,s]),n.changedCallback=function(l,u,p){this.#l.call(this,e,l,u,p)},this.propList.set(e,n),r&&(o===!0||o==="read")&&(n.enumerable||!this.attrList.has(r)||!this.attrList.get(r).enumerable)&&this.attrList.set(r,n),this.onPropChanged(a),this}static setPrototype(e,t){return this.prop(e,t),null}static define(e){return Object.defineProperties(this.prototype,Object.fromEntries(Object.entries(e).map(([t,n])=>(this.undefine(t),[t,{enumerable:t[0]!=="_",configurable:!0,...typeof n=="function"?{get:n}:n}])))),this}static undefine(e){if(Reflect.deleteProperty(this.prototype,e),this.propList.has(e)){let{watchers:t,attr:n,reflect:s}=this.propList.get(e);if(t.length&&this.propChangedCallbacks.has(e)){let r=this.propChangedCallbacks.get(e);for(let[o,a]of t){let c=r.indexOf(a);c!==-1&&r.splice(c,1)}}n&&(s===!0||s==="read")&&this.attrList.delete(n),this.propList.delete(e)}return this}static observe(e){for(let[t,n]of Object.entries(e??{})){let s=typeof n=="function"?{reflect:!1,get:n}:n;this.prop(t,s)}return this}static defineStatic(e){for(let[t,n]of Object.entries(e??{}))ce(this,t,{reflect:!1,...typeof n=="function"?{get:n}:typeof n=="string"?{type:n}:n});return this}static events(e,t){return this.on({composed({composition:n}){for(let[s,r]of Object.entries(e)){let[,o,a]=s.match(/^([*1~]+)?(.*)$/),c,l=[];if(typeof r=="string"){let u=r.split(".");u.length===1?(c=r,l=[]):(c=u[0],l=u)}n.addCompositionEventListener({type:a,once:o==null?void 0:o.includes("1"),passive:o==null?void 0:o.includes("~"),capture:o==null?void 0:o.includes("*"),...typeof r=="function"?{handleEvent:r}:typeof r=="string"?{prop:c,deepProp:l}:r,...t})}}}),this}static childEvents(e,t){for(let[n,s]of Object.entries(e))this.events(s,{tag:D(n),...t});return this}static rootEvents(e,t){return this.events(e,{tag:V.shadowRootTag,...t})}static on(e,t){let n=typeof e=="string"?{[e]:t}:e;for(let[s,r]of Object.entries(n)){let o;switch(s){case"composed":o="_onComposeCallbacks";break;case"constructed":o="_onConstructedCallbacks";break;case"connected":o="_onConnectedCallbacks";break;case"disconnected":o="_onDisconnectedCallbacks";break;case"props":this.onPropChanged(r);continue;case"attrs":this.onAttributeChanged(r);continue;default:if(s.endsWith("Changed")){let a=s.slice(0,s.length-7);this.onPropChanged({[a]:r});continue}throw new Error("Invalid callback name")}this._addCallback(o,r)}return this}static off(e,t){let n=typeof e=="string"?{[e]:t}:e;for(let[s,r]of Object.entries(n)){let o;switch(s){case"composed":o="_onComposeCallbacks";break;case"constructed":o="_onConstructedCallbacks";break;case"connected":o="_onConnectedCallbacks";break;case"disconnected":o="_onDisconnectedCallbacks";break;case"props":this.offPropChanged(r);continue;case"attrs":this.offAttributeChanged(r);continue;default:if(s.endsWith("Changed")){let a=s.slice(0,s.length-7);this.offPropChanged({[a]:r});continue}throw new Error("Invalid callback name")}this._removeCallback(o,r)}return this}static offPropChanged(e){let t=Array.isArray(e)?e:Object.entries(e),{propChangedCallbacks:n}=this;for(let[s,r]of t)this._removeFromCallbackMap(n,s,r);return this}static offAttributeChanged(e){let t=Array.isArray(e)?e:Object.entries(e),{attributeChangedCallbacks:n}=this;for(let[s,r]of t)this._removeFromCallbackMap(n,s,r);return this}static onPropChanged(e){let t=Array.isArray(e)?e:Object.entries(e),{propChangedCallbacks:n}=this;for(let[s,r]of t)n.has(s)?n.get(s).push(r):n.set(s,[r]);return this}static onAttributeChanged(e){let t=Array.isArray(e)?e:Object.entries(e),{attributeChangedCallbacks:n}=this;for(let[s,r]of t)n.has(s)?n.get(s).push(r):n.set(s,[r]);return this}#s;#n=new Map;#t=new Map;#e;#r=!1;#i=[];#o;#a=null;constructor(...e){super(),i.supportsElementInternals&&(this.elementInternals=this.attachInternals()),this.attachShadow({mode:"open",delegatesFocus:this.delegatesFocus}),this.render=this.composition.render(this.constructor.prototype,this,{defaults:this.constructor.prototype,store:this,shadowRoot:this.shadowRoot,context:this});for(let t of this.static._onConstructedCallbacks)t.call(this,this.callbackArguments)}propChangedCallback(e,t,n,s=n){this.#r?this.#i.push([e,s,this]):this.render.byProp(e,s,this);let{_propChangedCallbacks:r}=this.static;if(r.has(e))for(let o of r.get(e))o.call(this,t,n,s,this)}attributeChangedCallback(e,t,n){let{attributeChangedCallbacks:s}=this.static;if(s.has(e))for(let u of s.get(e))u.call(this,t,n,this);let{attrList:r}=this.static;if(!r.has(e))return;let o=r.get(e);if(o.attributeChangedCallback){o.attributeChangedCallback.call(this,e,t,n);return}let a;if(this.attributeCache.has(e)&&(a=this.attributeCache.get(e),a.stringValue===n))return;let c=this[o.key],l=n===null?o.nullParser(n):o.type==="boolean"?!0:o.parser(n);l!==c&&(a?(a.stringValue=n,a.parsedValue=l):this.attributeCache.set(e,{stringValue:n,parsedValue:l}),this[o.key]=l)}get#c(){var e;return(e=this.#e)==null?void 0:e.template}#l(e,t,n,s){let{propList:r}=this.static;if(r.has(e)){let{reflect:o,attr:a}=r.get(e);if(a&&(o===!0||o==="write")){let c,l=!1,{attributeCache:u}=this;if(u.has(a)?(c=u.get(a),l=c.parsedValue!==n):(c={},u.set(a,c),l=!0),l){let p=Ie(n);c.parsedValue=n,c.stringValue=p,p==null?this.removeAttribute(a):this.setAttribute(a,p)}}}this.propChangedCallback(e,t,n,s)}get static(){return this.constructor}patch(e){this.#r=!0,ve(this,e,"object");for(let[t,n,s]of this.#i)t in e||this.render.byProp(t,n,s);this.#i.slice(0,this.#i.length),this.render(e),this.#r=!1}get refs(){return this.#s??=new Proxy({},{get:(e,t)=>{let n=this.composition,s;if(!n.interpolated){if(this.#t.has(t)&&(s=this.#t.get(t).deref(),s))return s;let a=D(t);return s=n.template.getElementById(a),s?(this.#t.set(t,new WeakRef(s)),s):null}if(this.#n.has(t)&&(s=this.#n.get(t).deref(),s))return s;let r=D(t),o=this.composition.tags.indexOf(r);return s=this.render.state.refs[o],s?(this.#n.set(t,new WeakRef(s)),s):null}})}get attributeCache(){return this.#o??=new Map}get callbackArguments(){return this.#a??={composition:this.#e,refs:this.refs,html:de.bind(this),inline:ue,template:this.#c,element:this}}get composition(){if(this.#e)return this.#e;if(this.static.hasOwnProperty("_composition"))return this.#e=this.static._composition,this.static._composition;this.compose();for(let e of this.static._onComposeCallbacks)e.call(this,this.callbackArguments);return this.static._composition=this.#e,this.#e}connectedCallback(){for(let e of this.static._onConnectedCallbacks)e.call(this,this.callbackArguments)}disconnectedCallback(){for(let e of this.static._onDisconnectedCallbacks)e.call(this,this.callbackArguments)}};J.prototype.delegatesFocus=!1;export{Tt as cloneAttributeCallback,J as default};
|
|
1
|
+
var Le,Ue;function pe(){return(Le??=new Text).cloneNode()}function R(){return(Ue??=new Comment).cloneNode()}function Ve(i){var e,n;return(e=i==null?void 0:i.matches)!=null&&e.call(i,":focus")?i:(n=i==null?void 0:i.querySelector)==null?void 0:n.call(i,":focus")}function qe(i){i&&i.isConnected&&!i.matches(":focus")&&i.focus()}function me(i,e,n){let t=Ve(i);e?e.before(i):n.append(i),qe(t)}var $e=typeof Element.prototype.moveBefore=="function",J=$e?(i,e,n)=>{n.moveBefore(i,e)}:me,U=class{constructor(e){this.anchorNode=e.anchorNode,this.metadata=[],this.keys=[],this.needsArrayKeyFastPath=!1,this.composition=e.composition,this.renderOptions=e.renderOptions,this.metadataCache=null,this.queuedElements=[],this.batchStartIndex=null,this.batchEndIndex=null,this.parentProps=e.parentProps||[]}render(e,n){return this.composition.render(e,n,this.renderOptions)}startBatch(){this.needsArrayKeyFastPath=!0}writeBatch(){var n;if(!this.queuedElements.length)return;(((n=this.metadata[this.batchStartIndex-1])==null?void 0:n.domNode)??this.anchorNode).after(...this.queuedElements),this.queuedElements.length=0}stopBatch(){if(this.writeBatch(),this.needsArrayKeyFastPath=!1,this.batchStartIndex=null,this.batchEndIndex=null,this.metadataCache){for(let{domNode:e}of this.metadataCache.values())e.remove();this.metadataCache.clear()}}moveToEndByIndex(e){let[n]=this.metadata.splice(e,1),{domNode:t,key:s}=n;this.keys.splice(e,1);let r=t.parentNode;r&&me(t,null,r),this.metadataCache?this.metadataCache.set(s,n):this.metadataCache=new Map([[s,n]])}renderData(e,n,t,s,r,o){if(e<this.metadata.length){let u=this.metadata[e],p=u.key,x=p===s,C=r!==s;if(x){C?u.render(n,t):o||u.render(n,t);return}let b=this.metadataCache??=new Map,h=!1;this.needsArrayKeyFastPath&&(h=!this.keys.includes(s),this.needsArrayFastPath=!1);let f=h?-1:this.keys.indexOf(s,e+1);if(f===-1){if(b.has(s)){let d=b.get(s);this.metadata.splice(e,0,d),this.keys.splice(e,0,s),J(d.domNode,u.domNode,u.domNode.parentNode),d.render(n,t),b.delete(s);return}b.set(p,u)}else{if(e-f===-1){this.moveToEndByIndex(e);return}let d=this.metadata[f];this.metadata[e]=d,this.metadata[f]=u;let{domNode:m}=u,g=m.parentNode,S=d.domNode.nextSibling;J(d.domNode,m,g),S&&J(m,S,g),o||d.render(n,t),this.keys[e]=s,this.keys[f]=p;return}}let a={...n};if(this.parentProps.length)for(let u of this.parentProps)u in t&&(a[u]=t[u]);let c=this.render(a,t),l=c.target;this.metadata[e]={render:c,element:l,key:s,domNode:l},this.keys[e]=s,(this.batchEndIndex===null||this.batchEndIndex!==e-1)&&(this.writeBatch(),this.batchStartIndex=e),this.batchEndIndex=e,this.queuedElements.push(l)}removeEntries(e=0){let{length:n}=this.metadata;for(let t=n-1;t>=e;t--){let s=this.metadata[t];!s||!s.domNode||s.domNode.remove()}this.metadata.length=e,this.keys.length=e}hide(e,n,t){if(!n&&(e==null&&(e=this.keys.indexOf(t)),n=this.metadata[e],!n)||n.hidden)return!1;let{comment:s,element:r}=n;return s||(s=R(),n.comment=s),r.replaceWith(s),n.domNode=s,n.hidden=!0,!0}show(e,n,t){if(!n&&(e==null&&(e=this.keys.indexOf(t)),n=this.metadata[e],!n)||!n.hidden)return!1;let{comment:s,element:r}=n;return s.replaceWith(r),n.domNode=r,n.hidden=!1,!0}};var ee=new Map;function G(i,e=!0){if(e&&ee.has(i))return ee.get(i);let n=new CSSStyleSheet;return n.replaceSync(i),e&&ee.set(i,n),n}var te=new Map,ye;function He(i,e=!0){let n;return e&&te.has(i)?n=te.get(i):(ye??=document.implementation.createHTMLDocument(),n=ye.createElement("style"),n.textContent=i,e&&te.set(i,n)),n.cloneNode(!0)}var K;function be(i,e=!0){if(K==null)try{let n=G(i,e);return K=!0,n}catch{K=!1}return K?G(i,e):He(i,e)}function*ge(i,e=!0){for(let n of i)n instanceof HTMLStyleElement?yield G(n.textContent,e):n.ownerNode?yield G([...n.cssRules].map(t=>t.cssText).join(""),e):yield n}var ne=new WeakMap;function*Ce(i,e=!0){for(let n of i)if(n instanceof HTMLStyleElement)yield n;else if(n.ownerNode instanceof HTMLStyleElement)yield n.ownerNode.cloneNode(!0);else if(e&&ne.has(n))yield ne.get(n).cloneNode(!0);else{let t=document.createElement("style");t.textContent=[...n.cssRules].map(s=>s.cssText).join(""),e&&ne.set(n,t),yield t.cloneNode(!0)}}function xe(i,...e){return be(typeof i=="string"?i:String.raw({raw:i},...e))}function ke(i){switch(i){case void 0:case null:case!1:return null;case!0:return"";default:return`${i}`}}var Q;function B(i){if(Q??=new Map,Q.has(i))return Q.get(i);let e=i.replace(/[A-Z]/g,n=>`-${n.toLowerCase()}`);return Q.set(i,e),e}var we,Ke=Number.parseFloat((we=navigator.userAgent.match(/Chrome\/([\d.]+)/))==null?void 0:we[1]),Se,ut=Number.parseFloat((Se=navigator.userAgent.match(/Firefox\/([\d.]+)/))==null?void 0:Se[1]),Pe,dt=Ke||!navigator.userAgent.includes("AppleWebKit")?Number.NaN:Number.parseFloat((Pe=navigator.userAgent.match(/Version\/([\d.]+)/))==null?void 0:Pe[1]);function Ee(i,e){if(i===e)return i;if(Array.isArray(e)||i==null||e==null||typeof e!="object")return e;typeof i!="object"&&(i={});for(let[n,t]of Object.entries(e))t==null?n in i&&delete i[n]:i[n]=Ee(i[n],t);return i}function Ne(i,e){if(i===e)return i;let n=e!=null&&typeof e=="object"&&!Array.isArray(e),t=i!=null&&typeof i=="object"&&!Array.isArray(i);if(!n||!t)return e;for(let[s,r]of Object.entries(e))r==null?s in i&&delete i[s]:i[s]=Ne(i[s],r);return i}function Ie(i,e,n="reference"){switch(n){case"clone":case"object":return Ee(i,e);default:return Ne(i,e)}}function ve(i,e){if(i===e)return null;if(e==null||typeof e!="object")return e;if(i==null||typeof i!="object")return structuredClone(e);let n={};if(Array.isArray(e))return e;let t=new Set(Object.keys(i));for(let[s,r]of Object.entries(e)){if(t.delete(s),r===null){n[s]=null;continue}if(r==null)continue;let o=ve(i[s],r);o!==null&&(n[s]=o)}for(let s of t)n[s]=null;return n}function _e(i,e){if(i===e)return null;if(e==null||typeof e!="object")return e;if(i==null||typeof i!="object")return structuredClone(e);let n={};if(Array.isArray(e))return structuredClone(e);let t=new Set(Object.keys(i));for(let[s,r]of Object.entries(e)){if(t.delete(s),r===null){n[s]=null;continue}if(r==null)continue;let o=_e(i[s],r);o!==null&&(n[s]=o)}for(let s of t)n[s]=null;return n}function se(i,e){if(i===e)return null;if(e==null||typeof e!="object")return e;if(i==null||typeof i!="object")return structuredClone(e);let n={};if(Array.isArray(e)){for(let[s,r]of e.entries()){if(r===null){n[s]=null;continue}if(r==null)continue;let o=se(i[s],r);o!==null&&(n[s]=o)}return e.length!==i.length&&(n.length=e.length),n}let t=new Set(Object.keys(i));for(let[s,r]of Object.entries(e)){if(t.delete(s),r===null){n[s]=null;continue}if(r==null)continue;let o=se(i[s],r);o!==null&&(n[s]=o)}for(let s of t)n[s]=null;return n}function Ae(i,e,n="reference"){switch(n){case"clone":return _e(i,e);case"object":return se(i,e);default:return ve(i,e)}}function ie(i,e){if(i===e)return!1;if(e==null||typeof e!="object"||i!=null&&typeof i!="object")return!0;for(let[n,t]of Object.entries(e))if(t==null){if(n in i)return!0}else if(ie(i[n],t))return!0;return!1}function Ge(i,e){return Array.isArray(e)?i!==e:ie(i,e)}function Me(i,e,n="reference"){switch(n){case"clone":case"object":return Ge(i,e);default:return ie(i,e)}}function Oe(i){switch(i){case"boolean":return!1;case"integer":case"float":case"number":return 0;case"map":return new Map;case"set":return new Set;case"array":return[];case"proxy":case"object":return null;default:case"string":return""}}function re(i,e,n,t){return i??={},new Proxy(i,{get(s,r){let o=s[r];if(typeof r!="symbol"){let a=t?`${t}.${r}`:r;if(t?n.add(a):e.add(a),typeof o=="object"&&o!=null)return re(o,e,n,a)}return o},has(s,r){let o=Reflect.has(s,r);if(typeof r!="symbol"){let a=t?`${t}.${r}`:r;t?n.add(a):e.add(a)}return o}})}var z=new WeakMap,oe=new WeakMap;function Qe(i){if(i==null||typeof i!="object")return null;let e=oe.get(i);if(!e){let n=new Set;e={subscribe(t){n.add(t)},unsubscribe(t){n.delete(t)},emit(t){for(let s of n)s(t)}},oe.set(i,e)}return e}function X(i,e){let n={},t=n;for(let s=0;s<i.length-1;s++)t[i[s]]={},t=t[i[s]];return t[i.at(-1)]=e,n}function je(i,e,n,t,s){if(i==null||typeof i!="object")return i;let r=Qe(i);s||(s=r);let o=z.get(i);if(o||(o=new Map,z.set(i,o)),o.has(t))return o.get(t);let a=new Proxy(i,{get(c,l){if(typeof l=="symbol")return c[l];let u=c[l];return je(u,e,n.concat(l),t,s)},set(c,l,u){if(c[l]=u,typeof l!="symbol"){let p=X(n.concat(l),u);if(e(p),s==null||s.emit(p),r&&r!==s){let x=X([l],u);r.emit(x)}}return!0},deleteProperty(c,l){if(typeof l!="symbol"){let u=X(n.concat(l),null);if(e(u),s==null||s.emit(u),r&&r!==s){let p=X([l],null);r.emit(p)}}return Reflect.deleteProperty(c,l)}});return z.set(a,o),r&&oe.set(a,r),o.set(t,a),a}function Xe(i){switch(i){case"boolean":return e=>!!e;case"integer":return Math.round;case"float":case"number":return e=>+e;case"map":return Map;case"set":return Set;case"object":case"array":case"proxy":return e=>e;default:case"string":return e=>`${e}`}}function ae(i,...e){let n=new Set,t=new Set,s=e.map(c=>{let l=new Set,u=new Set,p=re(c,l,u);return{poked:l,pokedDeep:u,proxy:p}}),r=re(this??{},n,t),o=i.apply(r,s.map(c=>c.proxy)),a=i.name?!0:!n.size;return{props:{this:[...n],args:s.map(c=>[...c.poked])},deepPropStrings:{this:[...t],args:s.map(c=>[...c.pokedDeep])},deepProps:{this:[...t].map(c=>c.split(".")),args:s.map(c=>[...c.pokedDeep].map(l=>l.split(".")))},defaultValue:o,reusable:a}}function ze(){return null}function Ye(i,e,n){let t=typeof e=="string"?{type:e}:e,{watchers:s,value:r,readonly:o,empty:a,type:c,enumerable:l,reflect:u,attr:p,nullable:x,parser:C,nullParser:b,get:h,is:f,diff:d,props:m}=t;if(s??=[],o??=!1,a===void 0&&(a=null),r??=a,h&&!m){let g=ae(h.bind(n),n,()=>r);r??=g.defaultValue,m=new Set([...g.props.this,...g.props.args[0]])}if(!c)if(r==null)c="string";else{let g=typeof r;c=g==="number"?Number.isInteger(r)?"integer":"float":g}return l??=i[0]!=="_",x??=c==="boolean"?!1:a==null,x||(a??=Oe(c),r??=a),u??=l?c!=="object":p?"write":!1,p??=u?B(i):null,C??=Xe(c),b||(x?b=ze:b=a===null?()=>Oe(c):()=>a),f??=c==="object"||c==="proxy"?(g,S)=>!Me(g,S):c==="array"?()=>!1:Object.is,d===void 0&&(d=c==="object"?(g,S)=>Ae(g,S):null),{...t,type:c,is:f,diff:d,attr:p,reflect:u,readonly:o,enumerable:l,value:r,parser:C,nullParser:b,key:i,props:m,watchers:s}}function V(i,e,n){var r,o;i.get;let t=n==null?i.nullParser.call(this,n):i.parser.call(this,n),s=t;if(e==null){if(t==null)return!1}else if(t!=null){if(i.diff){if(s=i.diff.call(this,e,t),s==null)return!1}else if(i.is.call(this,e,t))return!1}return i.values?i.values.set(this,t):i.values=new WeakMap([[this,t]]),(r=i.propChangedCallback)==null||r.call(this,i.key,e,t,s),(o=i.changedCallback)==null||o.call(this,e,t,s),!0}function ce(i,e,n){let t=Ye(e,n,i);function s(h){if(t.type!=="proxy"||h==null||typeof h!="object")return h;let f=z.get(h);if(f&&f.has(this))return f.get(this);let d=this;return je(h,g=>{var P,j,T;let S=((P=t.values)==null?void 0:P.get(d))??h;(j=t.propChangedCallback)==null||j.call(d,t.key,S,S,g),(T=t.changedCallback)==null||T.call(d,S,S,g)},[],d,null)}function r(){var h;return(h=t.values)!=null&&h.has(this)?t.values.get(this):t.value}function o(){var f;if((f=t.values)!=null&&f.has(this))return t.values.get(this);let h=s.call(this,t.value);return h!==t.value&&(t.values?t.values.set(this,h):t.values=new WeakMap([[this,h]])),h}function a(h){var d;if(i===this&&((d=this==null?void 0:this.constructor)==null?void 0:d.prototype)===this)return;let f=this[e];V.call(this,t,f,h)}function c(h){var m;if(i===this&&((m=this==null?void 0:this.constructor)==null?void 0:m.prototype)===this)return;let f=this[e],d=s.call(this,h);V.call(this,t,f,d)}function l(){var d,m;let h=(d=t.computedValues)==null?void 0:d.get(this),f=this[e];(m=t.needsSelfInvalidation)==null||m.delete(this),V.call(this,t,h,f)}if(t.props)for(let h of t.props)t.watchers.push([h,l]);function u(){let h=t.get.call(this,this,r.bind(this));return(t.computedValues??=new WeakMap).set(this,h),h}function p(){let h=t.get.call(this,this,o.bind(this)),f=s.call(this,h);return(t.computedValues??=new WeakMap).set(this,f),f}function x(h){t.needsSelfInvalidation?t.needsSelfInvalidation.add(this):t.needsSelfInvalidation=new WeakSet([this]);let f=this[e];t.set.call(this,h,a.bind(this));let d=this[e];t.needsSelfInvalidation.has(this)&&(t.needsSelfInvalidation.delete(this),V.call(this,t,f,d))}function C(h){t.needsSelfInvalidation?t.needsSelfInvalidation.add(this):t.needsSelfInvalidation=new WeakSet([this]);let f=this[e];t.set.call(this,h,c.bind(this));let d=this[e];t.needsSelfInvalidation.has(this)&&(t.needsSelfInvalidation.delete(this),V.call(this,t,f,d))}let b={enumerable:t.enumerable,configurable:!0,get:t.get?t.type==="proxy"?p:u:t.type==="proxy"?o:r,set:t.set?t.type==="proxy"?C:x:t.type==="proxy"?c:a};return Object.defineProperty(i,e,b),t}var Te=new Set;function q(i="mdw_",e=4){let n;for(;Te.has(n=Math.random().toString(36).slice(2,e+2)););return Te.add(n),`${i}${n}`}var le,Fe,Re;function W(i){return le??=document.implementation.createHTMLDocument(),i?(Re??=le.createRange(),Re.createContextualFragment(i)):(Fe??=le.createDocumentFragment(),Fe.cloneNode())}var Y=new Map;function ue(i){let e=`#${q()}`;return Y.set(e,{fn:i}),`{${e}}`}var he=new Map;function de(i,...e){let n,t=e.map(o=>{switch(typeof o){case"string":return o;case"function":return ue(o);case"object":{if(o==null)return"";let a=q();return n??=new Map,n.set(a,o),`<div id="${a}"></div>`}default:throw new Error(`Unexpected substitution: ${o}`)}}),s=String.raw({raw:i},...t);if(n){let o=W(s);for(let[a,c]of n)o.getElementById(a).replaceWith(c);return o}let r;return he.has(s)?r=he.get(s):(r=W(s),he.set(s,r)),r.cloneNode(!0)}function Ze({nodes:i},e){let{nodeIndex:n,attrName:t}=this,s=i[n];switch(e){case void 0:case null:case!1:return s.removeAttribute(t),!1;case!0:return s.setAttribute(t,""),"";default:return s.setAttribute(t,e),e}}function Je({nodeStates:i,comments:e,nodes:n},t){let{commentIndex:s,nodeIndex:r}=this,o=i[r],a=o&1;if(!(t!=null&&t!==!1)){if(a)return;let p=e[s];p||(p=R(),e[s]=p),n[r].replaceWith(p),i[r]|=1;return}let l=n[r],u=o&2;if(t instanceof Node)t.nodeType===11||l!==t&&(l.replaceWith(t),n[r]=t),i[r]|=2;else if(typeof t!="object")if(u){let p=new Text(t);l.replaceWith(p),n[r]=p,i[r]&=-3}else l.data=t;a&&(e[s].replaceWith(l),i[r]&=-2)}function et({nodeStates:i,nodes:e,comments:n},t){let{commentIndex:s,nodeIndex:r}=this,o=i[r]&1,a=t!=null&&t!==!1;if(a===!o)return;let c=e[r],l=n[s];l||(l=R(),n[s]=l),a?(l.replaceWith(c),i[r]&=-2):(c.replaceWith(l),i[r]|=1)}function tt({comments:i,nodeStates:e,nodes:n}){let{commentIndex:t,nodeIndex:s}=this,r=R();i[t]=r,e[s]|=1,n[s].replaceWith(r)}function fe(i,...e){let[{caches:n,searchStates:t}]=e,{cacheIndex:s,searchIndex:r,subSearch:o,invocation:a}=i,c=n[s],l=t[r];if(l&1)return{value:c,dirty:(l&2)===2};t[r]|=1;let u;if(a){if(o){let p=fe(o,...e);if(!p.dirty&&c!==void 0)return t[r]&=-3,{value:c,dirty:!1};u=i.invocation(p.value)}else u=i.invocation(...e);if(u===void 0||c===u)return{value:u,dirty:!1}}return n[s]=u,t[r]|=2,{value:u,dirty:!0}}function Be({options:{context:i,store:e,injections:n}},t,s){return this.expression.call(i,e??s,n)}function nt(i,e){return e[this.prop]}function st(i,e,n){let t=e;for(let s of this.deepProp){if(t==null)return t;if(!(s in t))return;t=t[s]}return t}var it=/{([^}]*)}/g;function rt(i,e){if(e)return e[i]}function $(i,e){if(!e)return;let n=e,t;for(t of i)if(typeof n=="object"){if(n===null)return null;if(!(t in n))return;n=n[t]}else return n[t];return n}function ot(i,e){let n=e;for(let t of i.split("."))if(!t||(n=n[t],n==null))return null;return n===e?null:n}var We=new Map,D=class i{static EVENT_PREFIX_REGEX=/^([*1~]+)?(.*)$/;_interpolationState={nodeIndex:-1,searchIndex:0,cacheIndex:0,commentIndex:0,adapterIndex:0,nodeEntry:null};static shadowRootTag=Symbol();nodesToBind=[];props=[];searches=[];initCache=[];searchByQuery;actionsByPropsUsed;postInitActions=[];tagsWithBindings;tags=[];adapter;events;cloneable;styles=[];adoptedStyleSheets=[];stylesFragment;allIds=[];temporaryIds;interpolated=!1;constructor(...e){this.template=W(),this.append(...e)}*[Symbol.iterator](){for(let e of this.styles)yield e;yield this.template}static compose(...e){for(let[t,s]of We)if(t.length===e.length&&e.every((r,o)=>r===t[o]))return s;let n=new i(...e);return We.set(e,n),n}append(...e){for(let n of e)typeof n=="string"?this.append(W(n.trim())):n instanceof i?this.append(...n):n instanceof DocumentFragment?this.template.append(n):(n instanceof CSSStyleSheet||n instanceof HTMLStyleElement)&&this.styles.push(n);return this}addCompositionEventListener(e){let n=e.tag??"",t=this.events??=new Map;return t.has(n)?t.get(n).push(e):t.set(n,[e]),this}#s(e,n,t){var s;if((s=this.events)!=null&&s.has(e))for(let r of this.events.get(e)){let o;r.handleEvent?o=r.handleEvent:r.deepProp.length?o=$(r.deepProp,this.interpolateOptions.defaults):o=rt(r.prop,this.interpolateOptions.defaults),n.addEventListener(r.type,t?o.bind(t):o,r)}}render(e,n,t={}){this.interpolated||this.interpolate({defaults:n??e,...t});let s=this.cloneable.cloneNode(!0),r=t.shadowRoot,o=r??t.target??s.firstElementChild,a={lastChildNode:null,lastChildNodeIndex:0,lastElement:null,nodeStates:new Uint8Array(this._interpolationState.nodeIndex+1),searchStates:new Uint8Array(this._interpolationState.searchIndex),comments:[],nodes:[],caches:this.initCache.slice(),refs:[],adapters:[],options:t},{nodes:c,refs:l,searchStates:u,caches:p}=a;for(let{tag:C,textNodes:b}of this.nodesToBind){let h;if(C===""){if(!b.length)continue;l.push(null),c.push(null),h=s.firstChild}else{let d=s.getElementById(C);if(l.push(d),c.push(d),this.#s(C,d,t.context),!b.length)continue;h=d.firstChild}let f=0;for(let d of b){for(;d!==f;)h=h.nextSibling,f++;c.push(h)}}this.#s("",t.context),this.#s(i.shadowRootTag,t.context.shadowRoot,t.context);for(let C of this.postInitActions)C.invocation(a);let x=(C,b)=>{var f;if(!C)return;let h=!1;for(let d of this.props){if(!((f=this.actionsByPropsUsed)!=null&&f.has(d))||!(d in C))continue;let m=this.actionsByPropsUsed.get(d);for(let g of m){h=!0;let{dirty:S,value:P}=fe(g.search,a,C,b);S&&g.invocation(a,P,C,b)}}h&&u.fill(0)};return r?(t.context??=r.host,"adoptedStyleSheets"in r?this.adoptedStyleSheets.length&&(r.adoptedStyleSheets=[...r.adoptedStyleSheets,...this.adoptedStyleSheets]):this.stylesFragment.hasChildNodes()&&s.prepend(this.stylesFragment.cloneNode(!0))):t.context??=o,e!==this.interpolateOptions.defaults&&x(e,n),r&&(r.append(s),customElements.upgrade(r)),x.target=o,x.byProp=(C,b,h)=>{var g,S;if(!((g=this.actionsByPropsUsed)!=null&&g.has(C)))return;let f=!1;if((S=this.searchByQuery)!=null&&S.has(C)){f=!0;let P=this.searchByQuery.get(C);if(p[P.cacheIndex]===b)return;p[P.cacheIndex]=b,u[P.searchIndex]=3}let d,m=this.actionsByPropsUsed.get(C);for(let P of m)if(P.search.query===C)P.invocation(a,b);else{d??={[C]:b},h??=d,f=!0;let j=fe(P.search,a,d,h);j.dirty&&P.invocation(a,j.value,d,h)}f&&u.fill(0)},x.state=a,x}#n(e,n,t,s){var j,T;let{nodeValue:r,nodeName:o,nodeType:a}=e,c,l;if(a===Node.ATTRIBUTE_NODE?c=e:l=e,s==null){if(!r)return;let N=r.trim();if(!N)return;if(c||(n==null?void 0:n.tagName)==="STYLE"){if(N[0]!=="{")return;let{length:w}=N;if(N[w-1]!=="}")return;s=N.slice(1,-1)}else{let w=N.split(it);if(w.length<3)return;if(w.length===3&&!w[0]&&!w[2])s=w[1];else{for(let[y,_]of w.entries())if(y%2){let I=pe();l.before(I),this.#n(I,n,t,_)}else _&&l.before(_);return!0}}}let u=s,p=s[0]==="!",x=!1;p&&(s=s.slice(1),x=s[0]==="!",x&&(s=s.slice(1)));let C,b;if(l){n!==l.parentElement&&(n=l.parentElement),b=0;let N=l;for(;N=N.previousSibling;)b++}else if(n!==c.ownerElement&&(n=c.ownerElement),o.startsWith("on")){let N=o.indexOf("-");if(N===-1)return;C=N===2}if(C){n.removeAttribute(o);let N=this.#t(n),w=o.slice(3),[,y,_]=w.match(/^([*1~]+)?(.*)$/),I,A,v=[];if(s.startsWith("#"))I=Y.get(s).fn;else{let O=s.split(".");O.length===1?(A=s,v=[]):(A=O[0],v=O)}this.addCompositionEventListener({tag:N,type:_,handleEvent:I,prop:A,deepProp:v,once:y==null?void 0:y.includes("1"),passive:y==null?void 0:y.includes("~"),capture:y==null?void 0:y.includes("*")});return}let h;if((j=this.searchByQuery)!=null&&j.has(u))h=this.searchByQuery.get(u);else{let N=s,w=N!==u,y;if(w&&((T=this.searchByQuery)!=null&&T.has(N)))y=this.searchByQuery.get(N);else{let _,I,A,v,O,L,M,k;if(s.startsWith("#")){if(k=Y.get(s),!k)return;_=k.fn,M=Be,k.props?(I=k.props,A=k.deepProps,v=k.defaultValue??null):v=k.fn}else v=null,t!=null&&t.defaults&&(v=$(s.split("."),t.defaults)??null),v==null&&(t!=null&&t.injections)&&(v=ot(s,t.injections));if(!I)if(typeof v=="function"){let E=ae.call(this,v,t==null?void 0:t.defaults,t==null?void 0:t.injections),F=new Set([...E.props.this,...E.props.args[0],...E.props.args[1]]),H=new Set([...E.deepPropStrings.this,...E.deepPropStrings.args[0]]);_=v,v=E.defaultValue,I=[...F],A=[...H].map(De=>De.split(".")),M=Be}else{let E=s.split(".");E.length===1?(O=s,I=[O],M=nt):(I=[E[0]],L=E,A=[E],M=st)}k&&(k.defaultValue=v,k.props=I,k.deepProps=A),y={cacheIndex:this._interpolationState.cacheIndex++,searchIndex:this._interpolationState.searchIndex++,query:N,defaultValue:v,subSearch:null,prop:O,propsUsed:I,deepProp:L,deepPropsUsed:A,invocation:M,expression:_},this.addSearch(y)}w?(h={cacheIndex:this._interpolationState.cacheIndex++,searchIndex:this._interpolationState.searchIndex++,query:u,subSearch:y,negate:p,doubleNegate:x,prop:y.prop,deepProp:y.deepProp,propsUsed:y.propsUsed,deepPropsUsed:y.deepPropsUsed,defaultValue:x?!!y.defaultValue:p?!y.defaultValue:y.defaultValue,invocation(_){return this.doubleNegate?!!_:this.negate?!_:_}},this.addSearch(h)):h=y}let f,d=null,m=h.defaultValue;l?d=b:o==="mdw-if"?(f=this.#t(n),n.removeAttribute(o),m=m!=null&&m!==!1):(d=o,o==="id"||m==null||m===!1?n.removeAttribute(o):n.setAttribute(o,m===!0?"":m)),f??=this.#t(n);let g=this._interpolationState.nodeEntry;(!g||g.tag!==f)&&(g={tag:f,textNodes:[]},this._interpolationState.nodeEntry=g,this.nodesToBind.push(g),this._interpolationState.nodeIndex++);let S;if(l)switch(g.textNodes.push(b),this._interpolationState.nodeIndex++,S={nodeIndex:this._interpolationState.nodeIndex,commentIndex:this._interpolationState.commentIndex++,invocation:Je,defaultValue:m,search:h},typeof m){case"string":l.data=m;break;case"number":l.data=`${m}`;break;default:l.data="";break}else d?S={nodeIndex:this._interpolationState.nodeIndex,attrName:d,defaultValue:m,invocation:Ze,search:h}:(S={nodeIndex:this._interpolationState.nodeIndex,commentIndex:this._interpolationState.commentIndex++,defaultValue:m,invocation:et,search:h},m||this.postInitActions.push({...S,invocation:tt}));this.addAction(S),(this.tagsWithBindings??=new Set).add(f)}#t(e){if(!e)return"";let n=e.id;return n?this.allIds.includes(n)||this.allIds.push(n):(n=q(),(this.temporaryIds??=new Set).add(n),this.allIds.push(n),e.id=n),n}#e(e,n){let t=e.getAttribute("mdw-for"),s=t==null?void 0:t.trim();if(!s||s[0]!=="{")return null;let{length:r}=s;if(s[r-1]!=="}")return null;let o=s.slice(1,-1),[a,c]=o.split(/\s+of\s+/);e.removeAttribute("mdw-for");let l=e.ownerDocument.createElement("template");e.replaceWith(l);let u=this.#t(l),p=this._interpolationState.nodeEntry;(!p||p.tag!==u)&&(p={tag:u,textNodes:[]},this._interpolationState.nodeEntry=p,this.nodesToBind.push(p),this._interpolationState.nodeIndex++);let x=new i;x.template.append(e);let C={...n.injections,[a]:null,index:null},b=c.split("."),h=b.length>1?b:null,f=h?b[0]:c,d=[f],m={cacheIndex:this._interpolationState.cacheIndex++,searchIndex:this._interpolationState.searchIndex++,query:null,prop:null,deepProp:h,propsUsed:d,deepPropsUsed:h?[h]:[[f]],defaultValue:{},invocation:null},g={defaultValue:null,nodeIndex:this._interpolationState.nodeIndex,search:m,commentIndex:this._interpolationState.commentIndex++,adapterIndex:this._interpolationState.adapterIndex++,injections:C,invocation(P,j,T,N){let w=P.adapters[this.adapterIndex];if(!w){let M=P.nodes[this.nodeIndex],k=R();if(P.comments[this.commentIndex])throw new Error("Comment already exists at index");P.comments[this.commentIndex]=k,M.replaceWith(k);let E=x.props.filter(F=>F!==a&&F!==f);w=new U({anchorNode:k,composition:x,renderOptions:{target:null,context:P.options.context,store:P.options.store,injections:this.injections},parentProps:E}),P.adapters[this.adapterIndex]=w}let y=P.options.injections??this.injections,_=N??P.options.store,I=h?$(h,_):_[f];if(I===void 0&&h&&y&&(I=$(h,y)),!I||I.length===0){w.removeEntries();return}let A=h?$(h,T):T[f],v=x.props.some(M=>M!==a&&M!==f&&M in T);if(A===void 0&&!v)return;let O={...T};w.startBatch();let L;if(!v&&!(L=Array.isArray(A))){let M=L?A.entries():Object.entries(A);for(let[k,E]of M){if(k==="length"||E===null)continue;let F=+k,H=I[F];O[a]=E,y[a]=H,y.index=F,w.renderOptions.injections=y,w.renderData(F,O,_,H,E)}}else{A||delete O[a];for(let[M,k]of I.entries()){let E;if(A){if(!v&&!(M in A)||(E=A[M],E===null))continue;O[a]=E}y[a]=k,y.index=M,w.renderOptions.injections=y,w.renderData(M,O,_,k,E)}}w.stopBatch(),w.removeEntries(I.length)}};return x.interpolate({defaults:n.defaults,injections:C}),d.push(...x.props),this.addSearch(m),this.addAction(g),(this.tagsWithBindings??=new Set).add(u),x}interpolate(e){var r;this.interpolateOptions=e,this.cloneable=this.template.cloneNode(!0);let t=document.createTreeWalker(this.cloneable,5),s=t.nextNode();for(;s;){let o=null;switch(s.nodeType){case Node.ELEMENT_NODE:if(o=s,o.tagName==="TEMPLATE"){for(;o.contains(s=t.nextNode()););continue}if(o.tagName==="SCRIPT"){for(;o.contains(s=t.nextNode()););continue}if(o.hasAttribute("mdw-for")){for(;o.contains(s=t.nextNode()););this.#e(o,e);continue}else{let a=o.attributes.id;a&&(this.#n(a,o,e),this.#t(o));for(let c of[...o.attributes].reverse())c.nodeName!=="id"&&this.#n(c,o,e)}break;case Node.TEXT_NODE:if(o=s.parentElement,this.#n(s,o,e)){let a=t.nextNode();s.remove(),s=a;continue}break;default:throw new Error(`Unexpected node type: ${s.nodeType}`)}s=t.nextNode()}"adoptedStyleSheets"in document?this.adoptedStyleSheets=[...ge(this.styles)]:(this.stylesFragment=W(),this.stylesFragment.append(...Ce(this.styles))),this.props=this.actionsByPropsUsed?[...this.actionsByPropsUsed.keys()]:[];for(let o of this.allIds)(r=this.tagsWithBindings)!=null&&r.has(o)||this.nodesToBind.push({tag:o,textNodes:[]});this.tags=this.nodesToBind.map(o=>o.tag),this.interpolated=!0}addSearch(e){return this.searches.push(e),e.query&&((this.searchByQuery??=new Map).set(e.query,e),this.initCache[e.cacheIndex]=e.defaultValue),e}addAction(e){let n=this.actionsByPropsUsed??=new Map;for(let t of e.search.propsUsed)n.has(t)?n.get(t).push(e):n.set(t,[e]);return e}};function Tt(i,e){return(n,t,s)=>{t==null?s.refs[e].removeAttribute(i):s.refs[e].setAttribute(i,t)}}var Z=class i extends HTMLElement{static elementName;static get observedAttributes(){return this.attrList.keys()}compose(){return this.#e??=new D}static _composition=null;static _props=new Map;static _attrs=new Map;static _propChangedCallbacks=new Map;static _attributeChangedCallbacks=new Map;static _onComposeCallbacks=[];static _onConnectedCallbacks=[];static _onDisconnectedCallbacks=[];static _onConstructedCallbacks=[];static interpolatesTemplate=!0;static supportsElementInternals="attachInternals"in HTMLElement.prototype;static supportsElementInternalsRole=i.supportsElementInternals&&"role"in ElementInternals.prototype;static defined=!1;static registrations=new Map;static expressions=this.set;static methods=this.set;static overrides=this.set;static props=this.observe;static idl=this.prop;static _addCallback(e,n){if(!this.hasOwnProperty(e)){this[e]=[...this[e],n];return}this[e].push(n)}static _removeCallback(e,n){this.hasOwnProperty(e)||(this[e]=[...this[e]]),this[e]=this[e].filter(t=>t!==n)}static _removeFromCallbackMap(e,n,t){if(!e.has(n))return;if(!t){e.delete(n);return}let s=e.get(n).filter(r=>r!==t);s.length===0?e.delete(n):e.set(n,s)}static append(...e){return this._onComposeCallbacks.push(({composition:n})=>{n.append(...e)}),this._addCallback("_onComposeCallbacks",(n=>{let{composition:t}=n;t.append(...e)})),this}static recompose(e){return this._addCallback("_onComposeCallbacks",e),this}static css(e,...n){return this._addCallback("_onComposeCallbacks",(t=>{let{composition:s}=t;typeof e=="string"||Array.isArray(e)?s.append(xe(e,...n)):s.append(e,...n)})),this}static autoRegister(e){return this.hasOwnProperty("defined")&&this.defined?this:(this.register(e),this)}static html(e,...n){return this._addCallback("_onComposeCallbacks",(t=>{let{composition:s}=t;s.append(de(e,...n))})),this}static extend(e){return e?e(this):class extends this{}}static setStatic(e){return Object.assign(this,e),this}static readonly(e,n){return this.set(e,{...n,writable:!1})}static set(e,n){return Object.defineProperties(this.prototype,Object.fromEntries([...Object.entries(e).map(([t,s])=>(this.undefine(t),[t,{enumerable:t[0]!=="_",configurable:!0,value:s,writable:!0,...n}])),...Object.getOwnPropertySymbols(e).map(t=>[t,{enumerable:!1,configurable:!0,value:e[t],writable:!0,...n}])])),this}static mixin(e){return e(this)}static register(e){return e&&(this.elementName=e),customElements.define(this.elementName,this),i.registrations.set(this.elementName,this),this.defined=!0,this}static get propList(){return this.hasOwnProperty("_props")||(this._props=new Map(this._props)),this._props}static get attrList(){return this.hasOwnProperty("_attrs")||(this._attrs=new Map(this._attrs)),this._attrs}static get propChangedCallbacks(){return this.hasOwnProperty("_propChangedCallbacks")||(this._propChangedCallbacks=new Map([...this._propChangedCallbacks].map(([e,n])=>[e,n.slice()]))),this._propChangedCallbacks}static get attributeChangedCallbacks(){return this.hasOwnProperty("_attributeChangedCallbacks")||(this._attributeChangedCallbacks=new Map([...this._attributeChangedCallbacks].map(([e,n])=>[e,n.slice()]))),this._attributeChangedCallbacks}static prop(e,n){let t=ce(this.prototype,e,n),{changedCallback:s,attr:r,reflect:o,watchers:a}=t;return s&&a.push([e,s]),t.changedCallback=function(l,u,p){this.#l.call(this,e,l,u,p)},this.propList.set(e,t),r&&(o===!0||o==="read")&&(t.enumerable||!this.attrList.has(r)||!this.attrList.get(r).enumerable)&&this.attrList.set(r,t),this.onPropChanged(a),this}static setPrototype(e,n){return this.prop(e,n),null}static define(e){return Object.defineProperties(this.prototype,Object.fromEntries(Object.entries(e).map(([n,t])=>(this.undefine(n),[n,{enumerable:n[0]!=="_",configurable:!0,...typeof t=="function"?{get:t}:t}])))),this}static undefine(e){if(Reflect.deleteProperty(this.prototype,e),this.propList.has(e)){let{watchers:n,attr:t,reflect:s}=this.propList.get(e);if(n.length&&this.propChangedCallbacks.has(e)){let r=this.propChangedCallbacks.get(e);for(let[o,a]of n){let c=r.indexOf(a);c!==-1&&r.splice(c,1)}}t&&(s===!0||s==="read")&&this.attrList.delete(t),this.propList.delete(e)}return this}static observe(e){for(let[n,t]of Object.entries(e??{})){let s=typeof t=="function"?{reflect:!1,get:t}:t;this.prop(n,s)}return this}static defineStatic(e){for(let[n,t]of Object.entries(e??{}))ce(this,n,{reflect:!1,...typeof t=="function"?{get:t}:typeof t=="string"?{type:t}:t});return this}static events(e,n){return this.on({composed({composition:t}){for(let[s,r]of Object.entries(e)){let[,o,a]=s.match(/^([*1~]+)?(.*)$/),c,l=[];if(typeof r=="string"){let u=r.split(".");u.length===1?(c=r,l=[]):(c=u[0],l=u)}t.addCompositionEventListener({type:a,once:o==null?void 0:o.includes("1"),passive:o==null?void 0:o.includes("~"),capture:o==null?void 0:o.includes("*"),...typeof r=="function"?{handleEvent:r}:typeof r=="string"?{prop:c,deepProp:l}:r,...n})}}}),this}static childEvents(e,n){for(let[t,s]of Object.entries(e))this.events(s,{tag:B(t),...n});return this}static rootEvents(e,n){return this.events(e,{tag:D.shadowRootTag,...n})}static on(e,n){let t=typeof e=="string"?{[e]:n}:e;for(let[s,r]of Object.entries(t)){let o;switch(s){case"composed":o="_onComposeCallbacks";break;case"constructed":o="_onConstructedCallbacks";break;case"connected":o="_onConnectedCallbacks";break;case"disconnected":o="_onDisconnectedCallbacks";break;case"props":this.onPropChanged(r);continue;case"attrs":this.onAttributeChanged(r);continue;default:if(s.endsWith("Changed")){let a=s.slice(0,s.length-7);this.onPropChanged({[a]:r});continue}throw new Error("Invalid callback name")}this._addCallback(o,r)}return this}static off(e,n){let t=typeof e=="string"?{[e]:n}:e;for(let[s,r]of Object.entries(t)){let o;switch(s){case"composed":o="_onComposeCallbacks";break;case"constructed":o="_onConstructedCallbacks";break;case"connected":o="_onConnectedCallbacks";break;case"disconnected":o="_onDisconnectedCallbacks";break;case"props":this.offPropChanged(r);continue;case"attrs":this.offAttributeChanged(r);continue;default:if(s.endsWith("Changed")){let a=s.slice(0,s.length-7);this.offPropChanged({[a]:r});continue}throw new Error("Invalid callback name")}this._removeCallback(o,r)}return this}static offPropChanged(e){let n=Array.isArray(e)?e:Object.entries(e),{propChangedCallbacks:t}=this;for(let[s,r]of n)this._removeFromCallbackMap(t,s,r);return this}static offAttributeChanged(e){let n=Array.isArray(e)?e:Object.entries(e),{attributeChangedCallbacks:t}=this;for(let[s,r]of n)this._removeFromCallbackMap(t,s,r);return this}static onPropChanged(e){let n=Array.isArray(e)?e:Object.entries(e),{propChangedCallbacks:t}=this;for(let[s,r]of n)t.has(s)?t.get(s).push(r):t.set(s,[r]);return this}static onAttributeChanged(e){let n=Array.isArray(e)?e:Object.entries(e),{attributeChangedCallbacks:t}=this;for(let[s,r]of n)t.has(s)?t.get(s).push(r):t.set(s,[r]);return this}#s;#n=new Map;#t=new Map;#e;#r=!1;#i=[];#o;#a=null;constructor(...e){super(),i.supportsElementInternals&&(this.elementInternals=this.attachInternals()),this.attachShadow({mode:"open",delegatesFocus:this.delegatesFocus}),this.render=this.composition.render(this.constructor.prototype,this,{defaults:this.constructor.prototype,store:this,shadowRoot:this.shadowRoot,context:this});for(let n of this.static._onConstructedCallbacks)n.call(this,this.callbackArguments)}propChangedCallback(e,n,t,s=t){this.#r?this.#i.push([e,s,this]):this.render.byProp(e,s,this);let{_propChangedCallbacks:r}=this.static;if(r.has(e))for(let o of r.get(e))o.call(this,n,t,s,this)}attributeChangedCallback(e,n,t){let{attributeChangedCallbacks:s}=this.static;if(s.has(e))for(let u of s.get(e))u.call(this,n,t,this);let{attrList:r}=this.static;if(!r.has(e))return;let o=r.get(e);if(o.attributeChangedCallback){o.attributeChangedCallback.call(this,e,n,t);return}let a;if(this.attributeCache.has(e)&&(a=this.attributeCache.get(e),a.stringValue===t))return;let c=this[o.key],l=t===null?o.nullParser(t):o.type==="boolean"?!0:o.parser(t);l!==c&&(a?(a.stringValue=t,a.parsedValue=l):this.attributeCache.set(e,{stringValue:t,parsedValue:l}),this[o.key]=l)}get#c(){var e;return(e=this.#e)==null?void 0:e.template}#l(e,n,t,s){let{propList:r}=this.static;if(r.has(e)){let{reflect:o,attr:a}=r.get(e);if(a&&(o===!0||o==="write")){let c,l=!1,{attributeCache:u}=this;if(u.has(a)?(c=u.get(a),l=c.parsedValue!==t):(c={},u.set(a,c),l=!0),l){let p=ke(t);c.parsedValue=t,c.stringValue=p,p==null?this.removeAttribute(a):this.setAttribute(a,p)}}}this.propChangedCallback(e,n,t,s)}get static(){return this.constructor}patch(e){this.#r=!0,Ie(this,e,"object");for(let[n,t,s]of this.#i)n in e||this.render.byProp(n,t,s);this.#i.slice(0,this.#i.length),this.render(e),this.#r=!1}get refs(){return this.#s??=new Proxy({},{get:(e,n)=>{let t=this.composition,s;if(!t.interpolated){if(this.#t.has(n)&&(s=this.#t.get(n).deref(),s))return s;let a=B(n);return s=t.template.getElementById(a),s?(this.#t.set(n,new WeakRef(s)),s):null}if(this.#n.has(n)&&(s=this.#n.get(n).deref(),s))return s;let r=B(n),o=this.composition.tags.indexOf(r);return s=this.render.state.refs[o],s?(this.#n.set(n,new WeakRef(s)),s):null}})}get attributeCache(){return this.#o??=new Map}get callbackArguments(){return this.#a??={composition:this.#e,refs:this.refs,html:de.bind(this),inline:ue,template:this.#c,element:this}}get composition(){if(this.#e)return this.#e;if(this.static.hasOwnProperty("_composition"))return this.#e=this.static._composition,this.static._composition;this.compose();for(let e of this.static._onComposeCallbacks)e.call(this,this.callbackArguments);return this.static._composition=this.#e,this.#e}connectedCallback(){for(let e of this.static._onConnectedCallbacks)e.call(this,this.callbackArguments)}disconnectedCallback(){for(let e of this.static._onDisconnectedCallbacks)e.call(this,this.callbackArguments)}};Z.prototype.delegatesFocus=!1;export{Tt as cloneAttributeCallback,Z as default};
|
|
2
2
|
//# sourceMappingURL=CustomElement.min.js.map
|