From e8ba625d104d7f0a038cf3d3fa6fdbcfe0237e98 Mon Sep 17 00:00:00 2001 From: Keven McDowell Date: Fri, 26 Jan 2024 10:10:25 -0600 Subject: [PATCH 1/3] Upgrade to uhtml 4 - Updated dependencies that were outdated. Major version upgrades include rollup and ascjs. - Updated uhtml to v4.4.7. - Added DocumentFragment to globalThis for tests. --- package.json | 26 +++++++++++++------------- test/index.js | 3 ++- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/package.json b/package.json index c08d2f8..f37168b 100644 --- a/package.json +++ b/package.json @@ -24,28 +24,28 @@ "author": "Andrea Giammarchi", "license": "ISC", "devDependencies": { - "@babel/core": "^7.21.8", - "@babel/plugin-transform-runtime": "^7.21.4", - "@babel/preset-env": "^7.21.5", - "@babel/runtime": "^7.21.5", - "@rollup/plugin-babel": "^6.0.3", - "@rollup/plugin-node-resolve": "^15.0.2", - "@rollup/plugin-terser": "^0.4.1", + "@babel/core": "^7.23.9", + "@babel/plugin-transform-runtime": "^7.23.9", + "@babel/preset-env": "^7.23.9", + "@babel/runtime": "^7.23.9", + "@rollup/plugin-babel": "^6.0.4", + "@rollup/plugin-node-resolve": "^15.2.3", + "@rollup/plugin-terser": "^0.4.4", "@ungap/degap": "^0.2.8", - "ascjs": "^5.0.1", - "c8": "^7.13.0", + "ascjs": "^6.0.3", + "c8": "^9.1.0", "coveralls": "^3.1.1", - "linkedom": "^0.14.26", - "rollup": "^3.21.6", + "linkedom": "^0.16.8", + "rollup": "^4.9.6", "rollup-plugin-includepaths": "^0.2.4", - "terser": "^5.17.3" + "terser": "^5.27.0" }, "module": "esm/index.js", "unpkg": "min.js", "dependencies": { "plain-tag": "^0.1.3", "reactive-props": "^0.2.2", - "uhtml": "^3.1.0", + "uhtml": "^4.4.7", "umap": "^1.0.2" }, "repository": { diff --git a/test/index.js b/test/index.js index c8c1901..c550a41 100644 --- a/test/index.js +++ b/test/index.js @@ -3,13 +3,14 @@ const {parseHTML} = require('linkedom'); -const {document, customElements, HTMLElement,} = parseHTML(''); +const {document, customElements, HTMLElement, DocumentFragment} = parseHTML(''); const items = []; globalThis.document = document; globalThis.customElements = customElements; globalThis.HTMLElement = HTMLElement; +globalThis.DocumentFragment = DocumentFragment; const uhtml = require('uhtml'); const {define, css} = require('../cjs'); From 35bec627c45871a8c1a3036845205e3310987003 Mon Sep 17 00:00:00 2001 From: Keven McDowell <36285281+kpmcdowellmo@users.noreply.github.com> Date: Wed, 10 Dec 2025 12:50:31 -0600 Subject: [PATCH 2/3] Uhtml5 update, removes cjs support, updates coveralls to coveralls-next - Looks to update uce to use uhtml5. - Uhtml5 looks to drop cjs support. ESM is the thing nowadays, so this looks to align with that - Adds unit test for formAssociated static to achieve 100% coverage - Moves coveralls to coveralls-next re: https://github.com/nickmerwin/node-coveralls/issues/331 --- cjs/index.js | 200 ---- cjs/package.json | 1 - esm/index.js | 2 +- index.js | 2664 ++++++++++++++++++++++++++++++++------------- min.js | 2 +- new.js | 3 +- package.json | 13 +- test/index.js | 176 +-- test/package.json | 2 +- 9 files changed, 1990 insertions(+), 1073 deletions(-) delete mode 100644 cjs/index.js delete mode 100644 cjs/package.json diff --git a/cjs/index.js b/cjs/index.js deleted file mode 100644 index fbf4c3d..0000000 --- a/cjs/index.js +++ /dev/null @@ -1,200 +0,0 @@ -'use strict'; -const {render, html, svg} = require('uhtml'); -const umap = (m => /* c8 ignore start */ m.__esModule ? m.default : m /* c8 ignore stop */)(require('umap')); -const css = (m => /* c8 ignore start */ m.__esModule ? m.default : m /* c8 ignore stop */)(require('plain-tag')); - -const domHandler = (m => /* c8 ignore start */ m.__esModule ? m.default : m /* c8 ignore stop */)(require('reactive-props/dom')); -const reactive = domHandler({dom: true}); - -const CE = customElements; -const {define: defineCustomElement} = CE; -const {parse, stringify} = JSON; -const {create, defineProperties, getOwnPropertyDescriptor, keys} = Object; - -const element = 'element'; -const ownProps = new WeakMap; -const constructors = umap(new Map([[element, {c: HTMLElement, e: element}]])); - -const el = name => document.createElement(name); - -const info = e => constructors.get(e) || constructors.set(e, { - c: el(e).constructor, - e -}); - -const define = (tagName, definition) => { - const { - attachShadow, - attributeChanged, - bound, - connected, - disconnected, - formAssociated, - handleEvent, - init, - observedAttributes, - props, - render, - style - } = definition; - const initialized = new WeakMap; - const statics = {}; - const proto = {}; - const listeners = []; - const retype = create(null); - const bootstrap = (element, key, value) => { - if (!initialized.has(element)) { - initialized.set(element, 0); - defineProperties(element, { - html: { - configurable: true, - value: content.bind( - attachShadow ? element.attachShadow(attachShadow) : element - ) - } - }); - for (let i = 0; i < length; i++) { - const {type, options} = listeners[i]; - element.addEventListener(type, element, options); - } - if (bound) - bound.forEach(bind, element); - if (props) { - const reProps = {}; - for (let k = keys(props), i = 0; i < k.length; i++) { - const key = k[i]; - const value = props[key]; - reProps[key] = typeof value === 'object' ? parse(stringify(value)) : value; - } - ownProps.set(element, reProps); - reactive(element, reProps, render); - } - if (init || render) - (init || render).call(element); - if (key) - element[key] = value; - } - }; - for (let k = keys(definition), i = 0, {length} = k; i < length; i++) { - const key = k[i]; - if (/^on./.test(key) && !/Options$/.test(key)) { - const options = definition[key + 'Options'] || false; - const lower = key.toLowerCase(); - let type = lower.slice(2); - listeners.push({type, options}); - retype[type] = key; - if (lower !== key) { - type = lower.slice(2, 3) + key.slice(3); - retype[type] = key; - listeners.push({type, options}); - } - } - switch (key) { - case 'attachShadow': - case 'constructor': - case 'observedAttributes': - case 'style': - break; - default: - proto[key] = getOwnPropertyDescriptor(definition, key); - } - } - const {length} = listeners; - if (length && !handleEvent) - proto.handleEvent = {value(event) { - this[retype[event.type]](event); - }}; - - // [props] - if (props !== null) { - if (props) { - for (let k = keys(props), i = 0; i < k.length; i++) { - const key = k[i]; - proto[key] = { - get() { - bootstrap(this); - return ownProps.get(this)[key]; - }, - set(value) { - bootstrap(this, key, value); - } - }; - } - } - else { - proto.props = {get() { - const props = {}; - for (let {attributes} = this, {length} = attributes, i = 0; i < length; i++) { - const {name, value} = attributes[i]; - props[name] = value; - } - return props; - }}; - } - } - // [/props] - - if (observedAttributes) - statics.observedAttributes = {value: observedAttributes}; - proto.attributeChangedCallback = {value() { - bootstrap(this); - if (attributeChanged) - attributeChanged.apply(this, arguments); - }}; - - if (formAssociated) { - statics.formAssociated = {value: formAssociated}; - } - - proto.connectedCallback = {value() { - bootstrap(this); - if (connected) - connected.call(this); - }}; - - if (disconnected) - proto.disconnectedCallback = {value: disconnected}; - - const {c, e} = info(definition.extends || element); - class MicroElement extends c {}; - defineProperties(MicroElement, statics); - defineProperties(MicroElement.prototype, proto); - const args = [tagName, MicroElement]; - if (e !== element) - args.push({extends: e}); - defineCustomElement.apply(CE, args); - constructors.set(tagName, {c: MicroElement, e}); - if (style) - document.head.appendChild(el('style')).textContent = style( - e === element ? tagName : (e + '[is="' + tagName + '"]') - ); - return MicroElement; -}; - -exports.define = define; -exports.render = render; -exports.html = html; -exports.svg = svg; -exports.css = css; - -/* istanbul ignore else */ -if (!CE.get('uce-lib')) - // theoretically this could be just class { ... } - // however, if there is for whatever reason a - // element on the page, it will break once the registry - // will try to upgrade such element so ... HTMLElement it is. - CE.define('uce-lib', class extends info(element).c { - static get define() { return define; } - static get render() { return render; } - static get html() { return html; } - static get svg() { return svg; } - static get css() { return css; } - }); - -function bind(method) { - this[method] = this[method].bind(this); -} - -function content() { - return render(this, html.apply(null, arguments)); -} diff --git a/cjs/package.json b/cjs/package.json deleted file mode 100644 index 0292b99..0000000 --- a/cjs/package.json +++ /dev/null @@ -1 +0,0 @@ -{"type":"commonjs"} \ No newline at end of file diff --git a/esm/index.js b/esm/index.js index fb0b85d..ba0125a 100644 --- a/esm/index.js +++ b/esm/index.js @@ -1,4 +1,4 @@ -import {render, html, svg} from 'uhtml'; +import {render, html, svg} from 'uhtml/dom'; import umap from 'umap'; import css from 'plain-tag'; diff --git a/index.js b/index.js index f3186b6..b236936 100644 --- a/index.js +++ b/index.js @@ -1,435 +1,1326 @@ var uce = (function (exports) { 'use strict'; - function _typeof(obj) { + function _typeof(o) { "@babel/helpers - typeof"; - return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { - return typeof obj; - } : function (obj) { - return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; - }, _typeof(obj); + return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { + return typeof o; + } : function (o) { + return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; + }, _typeof(o); } - function _toPrimitive(input, hint) { - if (_typeof(input) !== "object" || input === null) return input; - var prim = input[Symbol.toPrimitive]; - if (prim !== undefined) { - var res = prim.call(input, hint || "default"); - if (_typeof(res) !== "object") return res; + function toPrimitive(t, r) { + if ("object" != _typeof(t) || !t) return t; + var e = t[Symbol.toPrimitive]; + if (void 0 !== e) { + var i = e.call(t, r); + if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } - return (hint === "string" ? String : Number)(input); + return (String )(t); } - function _toPropertyKey(arg) { - var key = _toPrimitive(arg, "string"); - return _typeof(key) === "symbol" ? key : String(key); + function toPropertyKey(t) { + var i = toPrimitive(t, "string"); + return "symbol" == _typeof(i) ? i : i + ""; } - function _defineProperties(target, props) { - for (var i = 0; i < props.length; i++) { - var descriptor = props[i]; - descriptor.enumerable = descriptor.enumerable || false; - descriptor.configurable = true; - if ("value" in descriptor) descriptor.writable = true; - Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); + function _defineProperties(e, r) { + for (var t = 0; t < r.length; t++) { + var o = r[t]; + o.enumerable = o.enumerable || false, o.configurable = true, "value" in o && (o.writable = true), Object.defineProperty(e, toPropertyKey(o.key), o); } } - function _createClass(Constructor, protoProps, staticProps) { - if (protoProps) _defineProperties(Constructor.prototype, protoProps); - if (staticProps) _defineProperties(Constructor, staticProps); - Object.defineProperty(Constructor, "prototype", { + function _createClass(e, r, t) { + return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: false - }); - return Constructor; + }), e; } - function _classCallCheck(instance, Constructor) { - if (!(instance instanceof Constructor)) { - throw new TypeError("Cannot call a class as a function"); - } + function _classCallCheck(a, n) { + if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); } - function _setPrototypeOf(o, p) { - _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { - o.__proto__ = p; - return o; - }; - return _setPrototypeOf(o, p); + function _assertThisInitialized(e) { + if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + return e; } - function _inherits(subClass, superClass) { - if (typeof superClass !== "function" && superClass !== null) { - throw new TypeError("Super expression must either be null or a function"); - } - subClass.prototype = Object.create(superClass && superClass.prototype, { + function _possibleConstructorReturn(t, e) { + if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; + if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); + return _assertThisInitialized(t); + } + + function _getPrototypeOf(t) { + return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { + return t.__proto__ || Object.getPrototypeOf(t); + }, _getPrototypeOf(t); + } + + function _setPrototypeOf(t, e) { + return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { + return t.__proto__ = e, t; + }, _setPrototypeOf(t, e); + } + + function _inherits(t, e) { + if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); + t.prototype = Object.create(e && e.prototype, { constructor: { - value: subClass, + value: t, writable: true, configurable: true } - }); - Object.defineProperty(subClass, "prototype", { + }), Object.defineProperty(t, "prototype", { writable: false - }); - if (superClass) _setPrototypeOf(subClass, superClass); + }), e && _setPrototypeOf(t, e); } - function _assertThisInitialized(self) { - if (self === void 0) { - throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); - } - return self; + var DEBUG = true; + + function _superPropBase(t, o) { + for (; !{}.hasOwnProperty.call(t, o) && null !== (t = _getPrototypeOf(t));); + return t; } - function _possibleConstructorReturn(self, call) { - if (call && (_typeof(call) === "object" || typeof call === "function")) { - return call; - } else if (call !== void 0) { - throw new TypeError("Derived constructors may only return object or undefined"); - } - return _assertThisInitialized(self); + function _defineProperty(e, r, t) { + return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, { + value: t, + enumerable: true, + configurable: true, + writable: true + }) : e[r] = t, e; } - function _getPrototypeOf(o) { - _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { - return o.__proto__ || Object.getPrototypeOf(o); - }; - return _getPrototypeOf(o); + function _get$1() { + return _get$1 = "undefined" != typeof Reflect && Reflect.get ? Reflect.get.bind() : function (e, t, r) { + var p = _superPropBase(e, t); + if (p) { + var n = Object.getOwnPropertyDescriptor(p, t); + return n.get ? n.get.call(arguments.length < 3 ? e : r) : n.value; + } + }, _get$1.apply(null, arguments); } - function _superPropBase(object, property) { - while (!Object.prototype.hasOwnProperty.call(object, property)) { - object = _getPrototypeOf(object); - if (object === null) break; + var ReactiveFlags; + (function (ReactiveFlags) { + ReactiveFlags[ReactiveFlags["None"] = 0] = "None"; + ReactiveFlags[ReactiveFlags["Mutable"] = 1] = "Mutable"; + ReactiveFlags[ReactiveFlags["Watching"] = 2] = "Watching"; + ReactiveFlags[ReactiveFlags["RecursedCheck"] = 4] = "RecursedCheck"; + ReactiveFlags[ReactiveFlags["Recursed"] = 8] = "Recursed"; + ReactiveFlags[ReactiveFlags["Dirty"] = 16] = "Dirty"; + ReactiveFlags[ReactiveFlags["Pending"] = 32] = "Pending"; + })(ReactiveFlags || (ReactiveFlags = {})); + function createReactiveSystem(_ref) { + var update = _ref.update, + notify = _ref.notify, + unwatched = _ref.unwatched; + var currentVersion = 0; + return { + link: link, + unlink: unlink, + propagate: propagate, + checkDirty: checkDirty, + endTracking: endTracking, + startTracking: startTracking, + shallowPropagate: shallowPropagate + }; + function link(dep, sub) { + var prevDep = sub.depsTail; + if (prevDep !== undefined && prevDep.dep === dep) { + return; + } + var nextDep = prevDep !== undefined ? prevDep.nextDep : sub.deps; + if (nextDep !== undefined && nextDep.dep === dep) { + nextDep.version = currentVersion; + sub.depsTail = nextDep; + return; + } + var prevSub = dep.subsTail; + if (prevSub !== undefined && prevSub.version === currentVersion && prevSub.sub === sub) { + return; + } + var newLink = sub.depsTail = dep.subsTail = { + version: currentVersion, + dep: dep, + sub: sub, + prevDep: prevDep, + nextDep: nextDep, + prevSub: prevSub, + nextSub: undefined + }; + if (nextDep !== undefined) { + nextDep.prevDep = newLink; + } + if (prevDep !== undefined) { + prevDep.nextDep = newLink; + } else { + sub.deps = newLink; + } + if (prevSub !== undefined) { + prevSub.nextSub = newLink; + } else { + dep.subs = newLink; + } + } + function unlink(link) { + var sub = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : link.sub; + var dep = link.dep; + var prevDep = link.prevDep; + var nextDep = link.nextDep; + var nextSub = link.nextSub; + var prevSub = link.prevSub; + if (nextDep !== undefined) { + nextDep.prevDep = prevDep; + } else { + sub.depsTail = prevDep; + } + if (prevDep !== undefined) { + prevDep.nextDep = nextDep; + } else { + sub.deps = nextDep; + } + if (nextSub !== undefined) { + nextSub.prevSub = prevSub; + } else { + dep.subsTail = prevSub; + } + if (prevSub !== undefined) { + prevSub.nextSub = nextSub; + } else if ((dep.subs = nextSub) === undefined) { + unwatched(dep); + } + return nextDep; + } + function propagate(link) { + var next = link.nextSub; + var stack; + top: do { + var sub = link.sub; + var flags = sub.flags; + if (!(flags & 60)) { + sub.flags = flags | 32; + } else if (!(flags & 12)) { + flags = 0; + } else if (!(flags & 4)) { + sub.flags = flags & -9 | 32; + } else if (!(flags & 48) && isValidLink(link, sub)) { + sub.flags = flags | 40; + flags &= 1; + } else { + flags = 0; + } + if (flags & 2) { + notify(sub); + } + if (flags & 1) { + var subSubs = sub.subs; + if (subSubs !== undefined) { + var nextSub = (link = subSubs).nextSub; + if (nextSub !== undefined) { + stack = { + value: next, + prev: stack + }; + next = nextSub; + } + continue; + } + } + if ((link = next) !== undefined) { + next = link.nextSub; + continue; + } + while (stack !== undefined) { + link = stack.value; + stack = stack.prev; + if (link !== undefined) { + next = link.nextSub; + continue top; + } + } + break; + } while (true); + } + function startTracking(sub) { + ++currentVersion; + sub.depsTail = undefined; + sub.flags = sub.flags & -57 | 4; + } + function endTracking(sub) { + var depsTail = sub.depsTail; + var toRemove = depsTail !== undefined ? depsTail.nextDep : sub.deps; + while (toRemove !== undefined) { + toRemove = unlink(toRemove, sub); + } + sub.flags &= -5; + } + function checkDirty(link, sub) { + var stack; + var checkDepth = 0; + var dirty = false; + top: do { + var dep = link.dep; + var flags = dep.flags; + if (sub.flags & 16) { + dirty = true; + } else if ((flags & 17) === 17) { + if (update(dep)) { + var subs = dep.subs; + if (subs.nextSub !== undefined) { + shallowPropagate(subs); + } + dirty = true; + } + } else if ((flags & 33) === 33) { + if (link.nextSub !== undefined || link.prevSub !== undefined) { + stack = { + value: link, + prev: stack + }; + } + link = dep.deps; + sub = dep; + ++checkDepth; + continue; + } + if (!dirty) { + var nextDep = link.nextDep; + if (nextDep !== undefined) { + link = nextDep; + continue; + } + } + while (checkDepth--) { + var firstSub = sub.subs; + var hasMultipleSubs = firstSub.nextSub !== undefined; + if (hasMultipleSubs) { + link = stack.value; + stack = stack.prev; + } else { + link = firstSub; + } + if (dirty) { + if (update(sub)) { + if (hasMultipleSubs) { + shallowPropagate(firstSub); + } + sub = link.sub; + continue; + } + dirty = false; + } else { + sub.flags &= -33; + } + sub = link.sub; + var _nextDep = link.nextDep; + if (_nextDep !== undefined) { + link = _nextDep; + continue top; + } + } + return dirty; + } while (true); + } + function shallowPropagate(link) { + do { + var sub = link.sub; + var flags = sub.flags; + if ((flags & 48) === 32) { + sub.flags = flags | 16; + if (flags & 2) { + notify(sub); + } + } + } while ((link = link.nextSub) !== undefined); + } + function isValidLink(checkLink, sub) { + var link = sub.depsTail; + while (link !== undefined) { + if (link === checkLink) { + return true; + } + link = link.prevDep; + } + return false; } - return object; } - function _get() { - if (typeof Reflect !== "undefined" && Reflect.get) { - _get = Reflect.get.bind(); - } else { - _get = function _get(target, property, receiver) { - var base = _superPropBase(target, property); - if (!base) return; - var desc = Object.getOwnPropertyDescriptor(base, property); - if (desc.get) { - return desc.get.call(arguments.length < 3 ? target : receiver); + var pauseStack = []; + var _createReactiveSystem = createReactiveSystem({ + update: function update(signal) { + if ('getter' in signal) { + return updateComputed(signal); + } else { + return updateSignal(signal, signal.value); } - return desc.value; - }; + }, + notify: notify, + unwatched: function unwatched(node) { + if ('getter' in node) { + var toRemove = node.deps; + if (toRemove !== undefined) { + node.flags = 17; + do { + toRemove = unlink(toRemove, node); + } while (toRemove !== undefined); + } + } else if (!('previousValue' in node)) { + effectOper.call(node); + } + } + }), + link = _createReactiveSystem.link, + unlink = _createReactiveSystem.unlink; + _createReactiveSystem.propagate; + _createReactiveSystem.checkDirty; + var endTracking = _createReactiveSystem.endTracking, + startTracking = _createReactiveSystem.startTracking; + _createReactiveSystem.shallowPropagate; + var activeSub; + var activeScope; + function setCurrentSub(sub) { + var prevSub = activeSub; + activeSub = sub; + return prevSub; + } + function setCurrentScope(scope) { + var prevScope = activeScope; + activeScope = scope; + return prevScope; + } + function pauseTracking() { + pauseStack.push(setCurrentSub(undefined)); + } + function resumeTracking() { + setCurrentSub(pauseStack.pop()); + } + function effect(fn) { + var e = { + fn: fn, + subs: undefined, + subsTail: undefined, + deps: undefined, + depsTail: undefined, + flags: 2 + }; + if (activeSub !== undefined) { + link(e, activeSub); + } else if (activeScope !== undefined) { + link(e, activeScope); } - return _get.apply(this, arguments); + var prev = setCurrentSub(e); + try { + e.fn(); + } finally { + setCurrentSub(prev); + } + return effectOper.bind(e); } - - function _isNativeFunction(fn) { - return Function.toString.call(fn).indexOf("[native code]") !== -1; + function effectScope(fn) { + var e = { + deps: undefined, + depsTail: undefined, + subs: undefined, + subsTail: undefined, + flags: 0 + }; + if (activeScope !== undefined) { + link(e, activeScope); + } + var prevSub = setCurrentSub(undefined); + var prevScope = setCurrentScope(e); + try { + fn(); + } finally { + setCurrentScope(prevScope); + setCurrentSub(prevSub); + } + return effectOper.bind(e); } - - function _isNativeReflectConstruct$2() { - if (typeof Reflect === "undefined" || !Reflect.construct) return false; - if (Reflect.construct.sham) return false; - if (typeof Proxy === "function") return true; + function updateComputed(c) { + var prevSub = setCurrentSub(c); + startTracking(c); try { - Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); - return true; - } catch (e) { - return false; + var oldValue = c.value; + return oldValue !== (c.value = c.getter(oldValue)); + } finally { + setCurrentSub(prevSub); + endTracking(c); } } - - function _construct(Parent, args, Class) { - if (_isNativeReflectConstruct$2()) { - _construct = Reflect.construct.bind(); - } else { - _construct = function _construct(Parent, args, Class) { - var a = [null]; - a.push.apply(a, args); - var Constructor = Function.bind.apply(Parent, a); - var instance = new Constructor(); - if (Class) _setPrototypeOf(instance, Class.prototype); - return instance; - }; + function updateSignal(s, value) { + s.flags = 1; + return s.previousValue !== (s.previousValue = value); + } + function notify(e) { + var flags = e.flags; + if (!(flags & 64)) { + e.flags = flags | 64; + var subs = e.subs; + if (subs !== undefined) { + notify(subs.sub); + } + } + } + function effectOper() { + var dep = this.deps; + while (dep !== undefined) { + dep = unlink(dep, this); + } + var sub = this.subs; + if (sub !== undefined) { + unlink(sub); } - return _construct.apply(null, arguments); + this.flags = 0; } - function _wrapNativeSuper(Class) { - var _cache = typeof Map === "function" ? new Map() : undefined; - _wrapNativeSuper = function _wrapNativeSuper(Class) { - if (Class === null || !_isNativeFunction(Class)) return Class; - if (typeof Class !== "function") { - throw new TypeError("Super expression must either be null or a function"); + /** + * @template T + * @param {function(): T} fn + * @returns {T} + */ + var untracked = function untracked(fn) { + pauseTracking(); + try { + return fn(); + } finally { + resumeTracking(); + } + }; + + /** + * @template T + */ + var Signal = /*#__PURE__*/function () { + /** + * @param {(value: T) => T} fn + * @param {T} value + */ + function Signal(fn, value) { + _classCallCheck(this, Signal); + this._ = fn(value); + } + + /** @returns {T} */ + return _createClass(Signal, [{ + key: "value", + get: function get() { + return this._(); } - if (typeof _cache !== "undefined") { - if (_cache.has(Class)) return _cache.get(Class); - _cache.set(Class, Wrapper); + + /** @param {T} value */, + set: function set(value) { + this._(value); } - function Wrapper() { - return _construct(Class, arguments, _getPrototypeOf(this).constructor); + + /** @returns {T} */ + }, { + key: "peek", + value: function peek() { + return untracked(this._); } - Wrapper.prototype = Object.create(Class.prototype, { - constructor: { - value: Wrapper, - enumerable: false, - writable: true, - configurable: true - } - }); - return _setPrototypeOf(Wrapper, Class); - }; - return _wrapNativeSuper(Class); - } - function _createSuper$1(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$1(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } - function _isNativeReflectConstruct$1() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } - var MapSet = /*#__PURE__*/function (_Map) { - _inherits(MapSet, _Map); - var _super = _createSuper$1(MapSet); - function MapSet() { - _classCallCheck(this, MapSet); - return _super.apply(this, arguments); + /** @returns {T} */ + }, { + key: "valueOf", + value: function valueOf() { + return this.value; + } + }]); + }(); + + function _classPrivateFieldInitSpec(e, t, a) { _checkPrivateRedeclaration(e, t), t.set(e, a); } + function _checkPrivateRedeclaration(e, t) { if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object"); } + function _classPrivateFieldGet(s, a) { return s.get(_assertClassBrand(s, a)); } + function _classPrivateFieldSet(s, a, r) { return s.set(_assertClassBrand(s, a), r), r; } + function _assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n; throw new TypeError("Private element is not present on this object"); } + var isArray = Array.isArray; + var assign = Object.assign, + defineProperties$2 = Object.defineProperties, + entries = Object.entries, + freeze = Object.freeze; + var _data = /*#__PURE__*/new WeakMap(); + var Unsafe = /*#__PURE__*/function () { + function Unsafe(data) { + _classCallCheck(this, Unsafe); + _classPrivateFieldInitSpec(this, _data, void 0); + _classPrivateFieldSet(_data, this, data); } - _createClass(MapSet, [{ - key: "set", - value: function set(key, value) { - _get(_getPrototypeOf(MapSet.prototype), "set", this).call(this, key, value); - return value; + return _createClass(Unsafe, [{ + key: "valueOf", + value: function valueOf() { + return _classPrivateFieldGet(_data, this); + } + }, { + key: "toString", + value: function toString() { + return String(_classPrivateFieldGet(_data, this)); } }]); - return MapSet; - }( /*#__PURE__*/_wrapNativeSuper(Map)); - var WeakMapSet = /*#__PURE__*/function (_WeakMap) { - _inherits(WeakMapSet, _WeakMap); - var _super2 = _createSuper$1(WeakMapSet); - function WeakMapSet() { - _classCallCheck(this, WeakMapSet); - return _super2.apply(this, arguments); + }(); + var createComment = function createComment(value) { + return document.createComment(value); + }; + /* c8 ignore stop */ + + function _callSuper$2(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct$3() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); } + function _isNativeReflectConstruct$3() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct$3 = function _isNativeReflectConstruct() { return !!t; })(); } + var ELEMENT = 1; + var ATTRIBUTE$1 = 2; + var TEXT$1 = 3; + var COMMENT$1 = 8; + var DOCUMENT_TYPE = 10; + var FRAGMENT = 11; + var COMPONENT$1 = 42; + var TEXT_ELEMENTS = new Set(['plaintext', 'script', 'style', 'textarea', 'title', 'xmp']); + var VOID_ELEMENTS = new Set(['area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'keygen', 'link', 'menuitem', 'meta', 'param', 'source', 'track', 'wbr']); + var props$1 = freeze({}); + var children = freeze([]); + var append = function append(node, child) { + if (node.children === children) node.children = []; + node.children.push(child); + child.parent = node; + return child; + }; + var prop = function prop(node, name, value) { + if (node.props === props$1) node.props = {}; + node.props[name] = value; + }; + var addJSON = function addJSON(value, comp, json) { + if (value !== comp) json.push(value); + }; + var Node = /*#__PURE__*/function () { + function Node(type) { + _classCallCheck(this, Node); + this.type = type; + this.parent = null; } - _createClass(WeakMapSet, [{ - key: "set", - value: function set(key, value) { - _get(_getPrototypeOf(WeakMapSet.prototype), "set", this).call(this, key, value); - return value; + return _createClass(Node, [{ + key: "toJSON", + value: function toJSON() { + //@ts-ignore + return [this.type, this.data]; } }]); - return WeakMapSet; - }( /*#__PURE__*/_wrapNativeSuper(WeakMap)); - - /*! (c) Andrea Giammarchi - ISC */ - var empty = /^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i; - var elements = /<([a-z]+[a-z0-9:._-]*)([^>]*?)(\/?)>/g; - var attributes = /([^\s\\>"'=]+)\s*=\s*(['"]?)\x01/g; - var holes = /[\x01\x02]/g; - - // \x01 Node.ELEMENT_NODE - // \x02 Node.ATTRIBUTE_NODE - - /** - * Given a template, find holes as both nodes and attributes and - * return a string with holes as either comment nodes or named attributes. - * @param {string[]} template a template literal tag array - * @param {string} prefix prefix to use per each comment/attribute - * @param {boolean} svg enforces self-closing tags - * @returns {string} X/HTML with prefixed comments or attributes - */ - var instrument = (function (template, prefix, svg) { - var i = 0; - return template.join('\x01').trim().replace(elements, function (_, name, attrs, selfClosing) { - var ml = name + attrs.replace(attributes, '\x02=$2$1').trimEnd(); - if (selfClosing.length) ml += svg || empty.test(name) ? ' /' : '>'; - }).replace(holes, function (hole) { - return hole === '\x01' ? '' : prefix + i++; - }); - }); + }(); + var Comment = /*#__PURE__*/function (_Node) { + function Comment(data) { + var _this; + _classCallCheck(this, Comment); + _this = _callSuper$2(this, Comment, [COMMENT$1]); + _this.data = data; + return _this; + } + _inherits(Comment, _Node); + return _createClass(Comment, [{ + key: "toString", + value: function toString() { + return ""); + } + }]); + }(Node); + var DocumentType = /*#__PURE__*/function (_Node2) { + function DocumentType(data) { + var _this2; + _classCallCheck(this, DocumentType); + _this2 = _callSuper$2(this, DocumentType, [DOCUMENT_TYPE]); + _this2.data = data; + return _this2; + } + _inherits(DocumentType, _Node2); + return _createClass(DocumentType, [{ + key: "toString", + value: function toString() { + return ""); + } + }]); + }(Node); + var Text = /*#__PURE__*/function (_Node3) { + function Text(data) { + var _this3; + _classCallCheck(this, Text); + _this3 = _callSuper$2(this, Text, [TEXT$1]); + _this3.data = data; + return _this3; + } + _inherits(Text, _Node3); + return _createClass(Text, [{ + key: "toString", + value: function toString() { + return this.data; + } + }]); + }(Node); + var Component = /*#__PURE__*/function (_Node4) { + function Component() { + var _this4; + _classCallCheck(this, Component); + _this4 = _callSuper$2(this, Component, [COMPONENT$1]); + _this4.name = 'template'; + _this4.props = props$1; + _this4.children = children; + return _this4; + } + _inherits(Component, _Node4); + return _createClass(Component, [{ + key: "toJSON", + value: function toJSON() { + var json = [COMPONENT$1]; + addJSON(this.props, props$1, json); + addJSON(this.children, children, json); + return json; + } + }, { + key: "toString", + value: function toString() { + var attrs = ''; + for (var key in this.props) { + var value = this.props[key]; + if (value != null) { + /* c8 ignore start */ + if (typeof value === 'boolean') { + if (value) attrs += " ".concat(key); + } else attrs += " ".concat(key, "=\"").concat(value, "\""); + /* c8 ignore stop */ + } + } + return "").concat(this.children.join(''), ""); + } + }]); + }(Node); + var Element = /*#__PURE__*/function (_Node5) { + function Element(name) { + var _this5; + var xml = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; + _classCallCheck(this, Element); + _this5 = _callSuper$2(this, Element, [ELEMENT]); + _this5.name = name; + _this5.xml = xml; + _this5.props = props$1; + _this5.children = children; + return _this5; + } + _inherits(Element, _Node5); + return _createClass(Element, [{ + key: "toJSON", + value: function toJSON() { + var json = [ELEMENT, this.name, +this.xml]; + addJSON(this.props, props$1, json); + addJSON(this.children, children, json); + return json; + } + }, { + key: "toString", + value: function toString() { + var xml = this.xml, + name = this.name, + props = this.props, + children = this.children; + var length = children.length; + var html = "<".concat(name); + for (var key in props) { + var value = props[key]; + if (value != null) { + if (typeof value === 'boolean') { + if (value) html += xml ? " ".concat(key, "=\"\"") : " ".concat(key); + } else html += " ".concat(key, "=\"").concat(value, "\""); + } + } + if (length) { + html += '>'; + for (var text = !xml && TEXT_ELEMENTS.has(name), i = 0; i < length; i++) html += text ? children[i].data : children[i]; + html += ""); + } else if (xml) html += ' />';else html += VOID_ELEMENTS.has(name) ? '>' : ">"); + return html; + } + }]); + }(Node); + var Fragment = /*#__PURE__*/function (_Node6) { + function Fragment() { + var _this6; + _classCallCheck(this, Fragment); + _this6 = _callSuper$2(this, Fragment, [FRAGMENT]); + _this6.name = '#fragment'; + _this6.children = children; + return _this6; + } + _inherits(Fragment, _Node6); + return _createClass(Fragment, [{ + key: "toJSON", + value: function toJSON() { + var json = [FRAGMENT]; + addJSON(this.children, children, json); + return json; + } + }, { + key: "toString", + value: function toString() { + return this.children.join(''); + } + }]); + }(Node); - function _arrayLikeToArray(arr, len) { - if (len == null || len > arr.length) len = arr.length; - for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; - return arr2; + function _arrayWithHoles(r) { + if (Array.isArray(r)) return r; } - function _arrayWithoutHoles(arr) { - if (Array.isArray(arr)) return _arrayLikeToArray(arr); + function _iterableToArrayLimit(r, l) { + var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; + if (null != t) { + var e, + n, + i, + u, + a = [], + f = true, + o = false; + try { + if (i = (t = t.call(r)).next, 0 === l) { + if (Object(t) !== t) return; + f = !1; + } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); + } catch (r) { + o = true, n = r; + } finally { + try { + if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; + } finally { + if (o) throw n; + } + } + return a; + } } - function _iterableToArray(iter) { - if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); + function _arrayLikeToArray$3(r, a) { + (null == a || a > r.length) && (a = r.length); + for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; + return n; } - function _unsupportedIterableToArray(o, minLen) { - if (!o) return; - if (typeof o === "string") return _arrayLikeToArray(o, minLen); - var n = Object.prototype.toString.call(o).slice(8, -1); - if (n === "Object" && o.constructor) n = o.constructor.name; - if (n === "Map" || n === "Set") return Array.from(o); - if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); + function _unsupportedIterableToArray$3(r, a) { + if (r) { + if ("string" == typeof r) return _arrayLikeToArray$3(r, a); + var t = {}.toString.call(r).slice(8, -1); + return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$3(r, a) : void 0; + } } - function _nonIterableSpread() { - throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); + function _nonIterableRest() { + throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } - function _toConsumableArray(arr) { - return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); + function _slicedToArray(r, e) { + return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray$3(r, e) || _nonIterableRest(); } - var ELEMENT_NODE = 1; - var nodeType = 111; - var remove = function remove(_ref) { - var firstChild = _ref.firstChild, - lastChild = _ref.lastChild; - var range = document.createRange(); - range.setStartAfter(firstChild); - range.setEndAfter(lastChild); - range.deleteContents(); - return firstChild; - }; - var diffable = function diffable(node, operation) { - return node.nodeType === nodeType ? 1 / operation < 0 ? operation ? remove(node) : node.lastChild : operation ? node.valueOf() : node.firstChild : node; + /* c8 ignore start */ + var asTemplate = function asTemplate(template) { + var _ref, _ref$join; + return ((_ref = (template === null || template === void 0 ? void 0 : template.raw) || template) === null || _ref === void 0 || (_ref$join = _ref.join) === null || _ref$join === void 0 ? void 0 : _ref$join.call(_ref, ',')) || 'unknown'; }; - var persistent = function persistent(fragment) { - var firstChild = fragment.firstChild, - lastChild = fragment.lastChild; - if (firstChild === lastChild) return lastChild || fragment; - var childNodes = fragment.childNodes; - var nodes = _toConsumableArray(childNodes); - return { - ELEMENT_NODE: ELEMENT_NODE, - nodeType: nodeType, - firstChild: firstChild, - lastChild: lastChild, - valueOf: function valueOf() { - if (childNodes.length !== nodes.length) fragment.append.apply(fragment, _toConsumableArray(nodes)); - return fragment; - } - }; + /* c8 ignore stop */ + + var errors = { + text: function text(template, tag, value) { + return new SyntaxError("Mixed text and interpolations found in text only <".concat(tag, "> element ").concat(JSON.stringify(String(value)), " in template ").concat(asTemplate(template))); + }, + unclosed: function unclosed(template, tag) { + return new SyntaxError("The text only <".concat(tag, "> element requires explicit closing tag in template ").concat(asTemplate(template))); + }, + unclosed_element: function unclosed_element(template, tag) { + return new SyntaxError("Unclosed element <".concat(tag, "> found in template ").concat(asTemplate(template))); + }, + invalid_content: function invalid_content(template) { + return new SyntaxError("Invalid content \" found in template ".concat(asTemplate(template))); + }, + invalid_layout: function invalid_layout(template) { + return new SyntaxError("Too many closing tags found in template ".concat(asTemplate(template))); + }, + invalid_doctype: function invalid_doctype(template, value) { + return new SyntaxError("Invalid doctype: ".concat(value, " found in template ").concat(asTemplate(template))); + }, + // DOM ONLY + /* c8 ignore start */ + invalid_template: function invalid_template(template) { + return new SyntaxError("Invalid template - the amount of values does not match the amount of updates: ".concat(asTemplate(template))); + }, + invalid_path: function invalid_path(template, path) { + return new SyntaxError("Invalid path - unreachable node at the path [".concat(path.join(', '), "] found in template ").concat(asTemplate(template))); + }, + invalid_attribute: function invalid_attribute(template, kind) { + return new SyntaxError("Invalid ".concat(kind, " attribute in template definition\n").concat(asTemplate(template))); + }, + invalid_interpolation: function invalid_interpolation(template, value) { + return new SyntaxError("Invalid interpolation - expected hole or array: ".concat(String(value), " found in template ").concat(asTemplate(template))); + }, + invalid_hole: function invalid_hole(value) { + return new SyntaxError("Invalid interpolation - expected hole: ".concat(String(value))); + }, + invalid_key: function invalid_key(value) { + return new SyntaxError("Invalid key attribute or position in template: ".concat(String(value))); + }, + invalid_array: function invalid_array(value) { + return new SyntaxError("Invalid array - expected html/svg but found something else: ".concat(String(value))); + }, + invalid_component: function invalid_component(value) { + return new SyntaxError("Invalid component: ".concat(String(value))); + } }; - var isArray$1 = Array.isArray; + function _createForOfIteratorHelper$2(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray$2(r)) || e) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: true } : { done: false, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = true, u = false; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = true, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; } + function _unsupportedIterableToArray$2(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray$2(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$2(r, a) : void 0; } } + function _arrayLikeToArray$2(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; } + var NUL = '\x00'; + var DOUBLE_QUOTED_NUL = "\"".concat(NUL, "\""); + var SINGLE_QUOTED_NUL = "'".concat(NUL, "'"); + var NEXT = /\x00|<[^><\s]+/g; + var ATTRS = /([^\s/>=]+)(?:=(\x00|(?:(['"])[\s\S]*?\3)))?/g; + + // // YAGNI: NUL char in the wild is a shenanigan + // // usage: template.map(safe).join(NUL).trim() + // const NUL_RE = /\x00/g; + // const safe = s => s.replace(NUL_RE, '�'); + + /** @typedef {import('../dom/ish.js').Node} Node */ + /** @typedef {import('../dom/ish.js').Element} Element */ + /** @typedef {import('../dom/ish.js').Component} Component */ + /** @typedef {(node: import('../dom/ish.js').Node, type: typeof ATTRIBUTE | typeof TEXT | typeof COMMENT | typeof COMPONENT, path: number[], name: string, hint: unknown) => unknown} update */ + /** @typedef {Element | Component} Container */ + + /** @type {update} */ + var defaultUpdate = function defaultUpdate(_, type, path, name, hint) { + return [type, path, name]; + }; - var aria = function aria(node) { - return function (values) { - for (var key in values) { - var name = key === 'role' ? key : "aria-".concat(key); - var value = values[key]; - if (value == null) node.removeAttribute(name);else node.setAttribute(name, value); + /** + * @param {Node} node + * @returns {number[]} + */ + var path = function path(node) { + var insideout = []; + while (node.parent) { + switch (node.type) { + /* c8 ignore start */ + case COMPONENT$1: + // fallthrough + /* c8 ignore stop */ + case ELEMENT: + { + if (/** @type {Container} */node.name === 'template') insideout.push(-1); + break; + } } - }; + insideout.push(node.parent.children.indexOf(node)); + node = node.parent; + } + return insideout; }; - var getValue = function getValue(value) { - return value == null ? value : value.valueOf(); + + /** + * @param {Node} node + * @param {Set} ignore + * @returns {Node} + */ + var parent = function parent(node, ignore) { + do { + node = node.parent; + } while (ignore.has(node)); + return node; }; - var attribute = function attribute(node, name) { - var oldValue, - orphan = true; - var attributeNode = document.createAttributeNS(null, name); - return function (newValue) { - var value = getValue(newValue); - if (oldValue !== value) { - if ((oldValue = value) == null) { - if (!orphan) { - node.removeAttributeNode(attributeNode); - orphan = true; - } - } else { - attributeNode.value = value; - if (orphan) { - node.setAttributeNodeNS(attributeNode); - orphan = false; + var parser = (function (_ref) { + var _ref$Comment = _ref.Comment, + Comment$1 = _ref$Comment === void 0 ? Comment : _ref$Comment, + _ref$DocumentType = _ref.DocumentType, + DocumentType$1 = _ref$DocumentType === void 0 ? DocumentType : _ref$DocumentType, + _ref$Text = _ref.Text, + Text$1 = _ref$Text === void 0 ? Text : _ref$Text, + _ref$Fragment = _ref.Fragment, + Fragment$1 = _ref$Fragment === void 0 ? Fragment : _ref$Fragment, + _ref$Element = _ref.Element, + Element$1 = _ref$Element === void 0 ? Element : _ref$Element, + _ref$Component = _ref.Component, + Component$1 = _ref$Component === void 0 ? Component : _ref$Component, + _ref$update = _ref.update, + update = _ref$update === void 0 ? defaultUpdate : _ref$update; + return ( + /** + * Parse a template string into a crawable JS literal tree and provide a list of updates. + * @param {TemplateStringsArray|string[]} template + * @param {unknown[]} holes + * @param {boolean} xml + * @returns {[Node, unknown[]]} + */ + function (template, holes, xml) { + if (template.some(function (chunk) { + return chunk.includes(NUL); + })) throw errors.invalid_nul(template); + var content = template.join(NUL).trim(); + if (content.replace(/(\S+)=(['"])([\S\s]+?)\2/g, function () { + return /^[^\x00]+\x00|\x00[^\x00]+$/.test(arguments.length <= 3 ? undefined : arguments[3]) ? xml = arguments.length <= 1 ? undefined : arguments[1] : arguments.length <= 0 ? undefined : arguments[0]; + }) !== content) throw errors.invalid_attribute(template, xml); + var ignore = new Set(); + var values = []; + var node = new Fragment$1(), + pos = 0, + skip = 0, + hole = 0, + resolvedPath = children; + var _iterator = _createForOfIteratorHelper$2(content.matchAll(NEXT)), + _step; + try { + for (_iterator.s(); !(_step = _iterator.n()).done;) { + var match = _step.value; + // already handled via attributes or text content nodes + if (0 < skip) { + skip--; + continue; + } + var chunk = match[0]; + var index = match.index; + + // prepend previous content, if any + if (pos < index) append(node, new Text$1(content.slice(pos, index))); + + // holes + if (chunk === NUL) { + if (node.name === 'table') { + node = append(node, new Element$1('tbody', xml)); + ignore.add(node); + } + var comment = append(node, new Comment$1('◦')); + values.push(update(comment, COMMENT$1, path(comment), '', holes[hole++])); + pos = index + 1; + } + // comments or doctype + else if (chunk.startsWith('', index + 2); + if (DEBUG && i < 0) throw errors.invalid_content(template); + if (content.slice(i - 2, i + 1) === '-->') { + if (DEBUG && i - index < 6) throw errors.invalid_comment(template); + var data = content.slice(index + 4, i - 2); + if (data[0] === '!') append(node, new Comment$1(data.slice(1).replace(/!$/, ''))); + } else { + if (DEBUG && !content.slice(index + 2, i).toLowerCase().startsWith('doctype')) throw errors.invalid_doctype(template, content.slice(index + 2, i)); + append(node, new DocumentType$1(content.slice(index + 2, i))); + } + pos = i + 1; + } + // closing tag or + else if (chunk.startsWith('', index + 2); + if (DEBUG && _i < 0) throw errors.invalid_closing(template); + if (xml && node.name === 'svg') xml = false; + node = /** @type {Container} */parent(node, ignore); + if (DEBUG && !node) throw errors.invalid_layout(template); + pos = _i + 1; + } + // opening tag or + else { + var _i2 = index + chunk.length; + var j = content.indexOf('>', _i2); + var name = chunk.slice(1); + if (DEBUG && j < 0) throw errors.unclosed_element(template, name); + var tag = name; + // <${Component} ... /> + if (name === NUL) { + tag = 'template'; + node = append(node, new Component$1()); + resolvedPath = path(node).slice(1); + //@ts-ignore + values.push(update(node, COMPONENT$1, resolvedPath, '', holes[hole++])); + } + // any other element + else { + if (!xml) { + tag = tag.toLowerCase(); + // patch automatic elements insertion with + // or path will fail once live on the DOM + if (node.name === 'table' && (tag === 'tr' || tag === 'td')) { + node = append(node, new Element$1('tbody', xml)); + ignore.add(node); + } + if (node.name === 'tbody' && tag === 'td') { + node = append(node, new Element$1('tr', xml)); + ignore.add(node); + } + } + node = append(node, new Element$1(tag, xml ? tag !== 'svg' : false)); + resolvedPath = children; + } + + // attributes + if (_i2 < j) { + var dot = false; + var _iterator2 = _createForOfIteratorHelper$2(content.slice(_i2, j).matchAll(ATTRS)), + _step2; + try { + for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) { + var _step2$value = _slicedToArray(_step2.value, 3), + _ = _step2$value[0], + _name = _step2$value[1], + value = _step2$value[2]; + if (value === NUL || value === DOUBLE_QUOTED_NUL || value === SINGLE_QUOTED_NUL || (dot = _name.endsWith(NUL))) { + var p = resolvedPath === children ? resolvedPath = path(node) : resolvedPath; + //@ts-ignore + values.push(update(node, ATTRIBUTE$1, p, dot ? _name.slice(0, -1) : _name, holes[hole++])); + dot = false; + skip++; + } else prop(node, _name, value ? value.slice(1, -1) : true); + } + } catch (err) { + _iterator2.e(err); + } finally { + _iterator2.f(); + } + resolvedPath = children; + } + pos = j + 1; + + // to handle self-closing tags + var closed = 0 < j && content[j - 1] === '/'; + if (xml) { + if (closed) { + node = node.parent; + /* c8 ignore start unable to reproduce, still worth a guard */ + if (DEBUG && !node) throw errors.invalid_layout(template); + /* c8 ignore stop */ + } + } else if (closed || VOID_ELEMENTS.has(tag)) { + // void elements are never td or tr + node = closed ? parent(node, ignore) : node.parent; + + /* c8 ignore start unable to reproduce, still worth a guard */ + if (DEBUG && !node) throw errors.invalid_layout(); + /* c8 ignore stop */ + } + // switches to xml mode + else if (tag === 'svg') xml = true; + // text content / data elements content handling + else if (TEXT_ELEMENTS.has(tag)) { + var _index = content.indexOf(""), pos); + if (DEBUG && _index < 0) throw errors.unclosed(template, tag); + var _value = content.slice(pos, _index); + // interpolation as text + if (_value.trim() === NUL) { + skip++; + values.push(update(node, TEXT$1, path(node), '', holes[hole++])); + } else if (DEBUG && _value.includes(NUL)) throw errors.text(template, tag, _value);else append(node, new Text$1(_value)); + // text elements are never td or tr + node = node.parent; + /* c8 ignore start unable to reproduce, still worth a guard */ + if (DEBUG && !node) throw errors.invalid_layout(template); + /* c8 ignore stop */ + pos = _index + name.length + 3; + // ignore the closing tag regardless of the content + skip++; + continue; + } + } } + } catch (err) { + _iterator.e(err); + } finally { + _iterator.f(); } + if (pos < content.length) append(node, new Text$1(content.slice(pos))); + + /* c8 ignore start */ + if (hole < holes.length) throw errors.invalid_template(template); + /* c8 ignore stop */ + + return [node, values]; } - }; + ); + }); + + function _arrayWithoutHoles(r) { + if (Array.isArray(r)) return _arrayLikeToArray$3(r); + } + + function _iterableToArray(r) { + if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); + } + + function _nonIterableSpread() { + throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); + } + + function _toConsumableArray(r) { + return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray$3(r) || _nonIterableSpread(); + } + + var tree = function (node, i) { + var _node$childNodes; + return i < 0 ? node === null || node === void 0 ? void 0 : node.content : node === null || node === void 0 || (_node$childNodes = node.childNodes) === null || _node$childNodes === void 0 ? void 0 : _node$childNodes[i]; + } ; + var resolve = (function (root, path) { + return path.reduceRight(tree, root); + }); + + var checkType = false, + range; + + /** + * @param {DocumentFragment} fragment + * @returns {Node | Element} + */ + var drop = function drop(_ref) { + var firstChild = _ref.firstChild, + lastChild = _ref.lastChild; + var r = range || (range = document.createRange()); + r.setStartAfter(firstChild); + r.setEndAfter(lastChild); + r.deleteContents(); + //@ts-ignore + return firstChild; }; - var _boolean = function _boolean(node, key, oldValue) { - return function (newValue) { - var value = !!getValue(newValue); - if (oldValue !== value) { - // when IE won't be around anymore ... - // node.toggleAttribute(key, oldValue = !!value); - if (oldValue = value) node.setAttribute(key, '');else node.removeAttribute(key); - } - }; + + /** + * @param {Node} node + * @param {1 | 0 | -0 | -1} operation + * @returns {Node} + */ + var diffFragment = function diffFragment(node, operation) { + return checkType && node.nodeType === 11 ? 1 / operation < 0 ? + //@ts-ignore + operation ? drop(node) : node.lastChild : + //@ts-ignore + operation ? node.valueOf() : node.firstChild : node; }; - var data = function data(_ref) { - var dataset = _ref.dataset; - return function (values) { - for (var key in values) { - var value = values[key]; - if (value == null) delete dataset[key];else dataset[key] = value; - } - }; + var nodes = Symbol('nodes'); + var parentNode = { + get: function get() { + return this.firstChild.parentNode; + } }; - var event = function event(node, name) { - var oldValue, - lower, - type = name.slice(2); - if (!(name in node) && (lower = name.toLowerCase()) in node) type = lower.slice(2); - return function (newValue) { - var info = isArray$1(newValue) ? newValue : [newValue, false]; - if (oldValue !== info[0]) { - if (oldValue) node.removeEventListener(type, oldValue, info[1]); - if (oldValue = info[0]) node.addEventListener(type, oldValue, info[1]); - } - }; + //@ts-ignore + var replaceWith = { + value: function value(node) { + drop(this).replaceWith(node); + } }; - var ref = function ref(node) { - var oldValue; - return function (value) { - if (oldValue !== value) { - oldValue = value; - if (typeof value === 'function') value(node);else value.current = node; - } - }; + //@ts-ignore + var remove = { + value: function value() { + drop(this).remove(); + } }; - var setter = function setter(node, key) { - return key === 'dataset' ? data(node) : function (value) { - node[key] = value; - }; + var valueOf = { + value: function value() { + var parentNode = this.parentNode; + if (parentNode === this) { + if (this[nodes] === children) this[nodes] = _toConsumableArray(this.childNodes); + } else { + // TODO: verify fragments in lists don't call this twice + if (parentNode) { + var firstChild = this.firstChild, + lastChild = this.lastChild; + this[nodes] = [firstChild]; + while (firstChild !== lastChild) this[nodes].push(firstChild = firstChild.nextSibling); + } + this.replaceChildren.apply(this, _toConsumableArray(this[nodes])); + } + return this; + } }; - var text = function text(node) { - var oldValue; - return function (newValue) { - var value = getValue(newValue); - if (oldValue != value) { - oldValue = value; - node.textContent = value == null ? '' : value; + + /** + * @param {DocumentFragment} fragment + * @returns {DocumentFragment} + */ + function PersistentFragment(fragment) { + var firstChild = createComment('<>'), + lastChild = createComment(''); + //@ts-ignore + fragment.replaceChildren.apply(fragment, [firstChild].concat(_toConsumableArray(fragment.childNodes), [lastChild])); + checkType = true; + return defineProperties$2(fragment, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, nodes, { + writable: true, + value: children + }), "firstChild", { + value: firstChild + }), "lastChild", { + value: lastChild + }), "parentNode", parentNode), "valueOf", valueOf), "replaceWith", replaceWith), "remove", remove)); + } + PersistentFragment.prototype = DocumentFragment.prototype; + + // @ts-check + + /** + * @param {Document} document + * @returns + */ + var creator = (function () { + var document = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : (/** @type {Document} */globalThis.document); + var tpl = document.createElement('template'), + range; + /** + * @param {string} content + * @param {boolean} [xml=false] + * @returns {DocumentFragment} + */ + return function (content) { + var xml = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; + if (xml) { + if (!range) { + range = document.createRange(); + range.selectNodeContents(document.createElementNS('http://www.w3.org/2000/svg', 'svg')); + } + return range.createContextualFragment(content); } + tpl.innerHTML = content; + var fragment = tpl.content; + tpl = /** @type {HTMLTemplateElement} */tpl.cloneNode(false); + return fragment; }; - }; + }); - /** - * ISC License - * - * Copyright (c) 2020, Andrea Giammarchi, @WebReflection - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH - * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, - * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM - * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE - * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. + // @see https://github.com/WebReflection/udomdiff + + /** + * ISC License + * + * Copyright (c) 2020, Andrea Giammarchi, @WebReflection + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH + * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, + * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE + * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. */ - /** - * @param {Node} parentNode The container where children live - * @param {Node[]} a The list of current/live children - * @param {Node[]} b The list of future children - * @param {(entry: Node, action: number) => Node} get - * The callback invoked per each entry related DOM operation. - * @param {Node} [before] The optional node used as anchor to insert before. - * @returns {Node[]} The same list of future children. + /** + * @param {Node[]} a The list of current/live children + * @param {Node[]} b The list of future children + * @param {(entry: Node, action: number) => Node} get + * The callback invoked per each entry related DOM operation. + * @param {Node} [before] The optional node used as anchor to insert before. + * @returns {Node[]} The same list of future children. */ - var udomdiff = (function (parentNode, a, b, get, before) { + var diff = (function (a, b, get, before) { + var parentNode = before.parentNode; var bLength = b.length; var aEnd = a.length; var bEnd = bLength; @@ -443,14 +1334,16 @@ var uce = (function (exports) { // need to be added are not at the end, and in such case // the node to `insertBefore`, if the index is more than 0 // must be retrieved, otherwise it's gonna be the first item. - var node = bEnd < bLength ? bStart ? get(b[bStart - 1], -0).nextSibling : get(b[bEnd - bStart], 0) : before; + var node = bEnd < bLength ? bStart ? get(b[bStart - 1], -0).nextSibling : get(b[bEnd], 0) : before; while (bStart < bEnd) parentNode.insertBefore(get(b[bStart++], 1), node); } // remove head or tail: fast path else if (bEnd === bStart) { while (aStart < aEnd) { // remove the node only if it's unknown or not live - if (!map || !map.has(a[aStart])) parentNode.removeChild(get(a[aStart], -1)); + if (!map || !map.has(a[aStart])) + //@ts-ignore + get(a[aStart], -1).remove(); aStart++; } } @@ -474,8 +1367,8 @@ var uce = (function (exports) { // or asymmetric too // [1, 2, 3, 4, 5] // [1, 2, 3, 5, 6, 4] - var _node = get(a[--aEnd], -1).nextSibling; - parentNode.insertBefore(get(b[bStart++], 1), get(a[aStart++], -1).nextSibling); + var _node = get(a[--aEnd], -0).nextSibling; + parentNode.insertBefore(get(b[bStart++], 1), get(a[aStart++], -0).nextSibling); parentNode.insertBefore(get(b[--bEnd], 1), _node); // mark the future index as identical (yeah, it's dirty, but cheap 👍) // The main reason to do this, is that when a[aEnd] will be reached, @@ -487,6 +1380,7 @@ var uce = (function (exports) { } // map based fallback, "slow" path else { + var _map$get; // the map requires an O(bEnd - bStart) operation once // to store all future nodes indexes for later purposes. // In the worst case scenario, this is a full O(N) cost, @@ -497,10 +1391,15 @@ var uce = (function (exports) { var i = bStart; while (i < bEnd) map.set(b[i], i++); } - // if it's a future node, hence it needs some handling - if (map.has(a[aStart])) { - // grab the index of such node, 'cause it might have been processed - var index = map.get(a[aStart]); + var index = (_map$get = map.get(a[aStart])) !== null && _map$get !== void 0 ? _map$get : -1; + + // this node has no meaning in the future list, so it's more than safe + // to remove it, and check the next live node out instead, meaning + // that only the live list index should be forwarded + //@ts-ignore + if (index < 0) get(a[aStart++], -1).remove(); + // it's a future node, hence it needs some handling + else { // if it's not already processed, look on demand for the next LCS if (bStart < index && index < bEnd) { var _i = aStart; @@ -525,481 +1424,699 @@ var uce = (function (exports) { // moving both source and target indexes forward, hoping that some // similar node will be found later on, to go back to the fast path else { + // TODO: benchmark replaceWith instead parentNode.replaceChild(get(b[bStart++], 1), get(a[aStart++], -1)); } } // otherwise move the source forward, 'cause there's nothing to do else aStart++; } - // this node has no meaning in the future list, so it's more than safe - // to remove it, and check the next live node out instead, meaning - // that only the live list index should be forwarded - else parentNode.removeChild(get(a[aStart++], -1)); } } return b; }); - var isArray = Array.isArray, - prototype = Array.prototype; - var indexOf = prototype.indexOf; - var _Proxy = new Proxy(document, { - get: function get(target, method) { - return target[method].bind(target); + function _createForOfIteratorHelper$1(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray$1(r)) || e) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: true } : { done: false, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = true, u = false; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = true, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; } + function _unsupportedIterableToArray$1(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray$1(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$1(r, a) : void 0; } } + function _arrayLikeToArray$1(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; } + var ARRAY = 1 << 0; + var ARIA = 1 << 1; + var ATTRIBUTE = 1 << 2; + var COMMENT = 1 << 3; + var COMPONENT = 1 << 4; + var DATA = 1 << 5; + var DIRECT = 1 << 6; + var DOTS = 1 << 7; + var EVENT = 1 << 8; + var KEY = 1 << 9; + var PROP = 1 << 10; + var TEXT = 1 << 11; + var TOGGLE = 1 << 12; + var UNSAFE = 1 << 13; + var REF = 1 << 14; + var SIGNAL = 1 << 15; + + // COMPONENT flags + var COMPONENT_DIRECT = COMPONENT | DIRECT; + var COMPONENT_DOTS = COMPONENT | DOTS; + var COMPONENT_PROP = COMPONENT | PROP; + var EVENT_ARRAY = EVENT | ARRAY; + var COMMENT_ARRAY = COMMENT | ARRAY; + var fragment = creator(document); + var ref = Symbol('ref'); + var aria = function aria(node, values) { + var _iterator = _createForOfIteratorHelper$1(entries(values)), + _step; + try { + for (_iterator.s(); !(_step = _iterator.n()).done;) { + var _step$value = _slicedToArray(_step.value, 2), + key = _step$value[0], + value = _step$value[1]; + var name = key === 'role' ? key : "aria-".concat(key.toLowerCase()); + if (value == null) node.removeAttribute(name);else node.setAttribute(name, value); } - }), - createDocumentFragment = _Proxy.createDocumentFragment, - createElement = _Proxy.createElement, - createElementNS = _Proxy.createElementNS, - createTextNode = _Proxy.createTextNode, - createTreeWalker = _Proxy.createTreeWalker, - importNode = _Proxy.importNode; - var createHTML = function createHTML(html) { - var template = createElement('template'); - template.innerHTML = html; - return template.content; + } catch (err) { + _iterator.e(err); + } finally { + _iterator.f(); + } }; - var xml; - var createSVG = function createSVG(svg) { - if (!xml) xml = createElementNS('http://www.w3.org/2000/svg', 'svg'); - xml.innerHTML = svg; - var content = createDocumentFragment(); - content.append.apply(content, _toConsumableArray(xml.childNodes)); - return content; + var attribute = function attribute(name) { + return function (node, value) { + if (value == null) node.removeAttribute(name);else node.setAttribute(name, value); + }; }; - var createContent = function createContent(text, svg) { - return svg ? createSVG(text) : createHTML(text); + var comment_array = function comment_array(node, value) { + node[nodes] = diff(node[nodes] || children, value, diffFragment, node); }; - - // from a generic path, retrieves the exact targeted node - var reducePath = function reducePath(_ref, i) { - var childNodes = _ref.childNodes; - return childNodes[i]; + var text = new WeakMap(); + var getText = function getText(ref, value) { + var node = text.get(ref); + if (node) node.data = value;else text.set(ref, node = document.createTextNode(value)); + return node; }; - - // this helper avoid code bloat around handleAnything() callback - var diff = function diff(comment, oldNodes, newNodes) { - return udomdiff(comment.parentNode, - // TODO: there is a possible edge case where a node has been - // removed manually, or it was a keyed one, attached - // to a shared reference between renders. - // In this case udomdiff might fail at removing such node - // as its parent won't be the expected one. - // The best way to avoid this issue is to filter oldNodes - // in search of those not live, or not in the current parent - // anymore, but this would require both a change to uwire, - // exposing a parentNode from the firstChild, as example, - // but also a filter per each diff that should exclude nodes - // that are not in there, penalizing performance quite a lot. - // As this has been also a potential issue with domdiff, - // and both lighterhtml and hyperHTML might fail with this - // very specific edge case, I might as well document this possible - // "diffing shenanigan" and call it a day. - oldNodes, newNodes, diffable, comment); + var comment_hole = function comment_hole(node, value) { + var _node$nodes; + var current = _typeof(value) === 'object' ? value !== null && value !== void 0 ? value : node : getText(node, value); + var prev = (_node$nodes = node[nodes]) !== null && _node$nodes !== void 0 ? _node$nodes : node; + if (current !== prev) prev.replaceWith(diffFragment(node[nodes] = current, 1)); }; - - // if an interpolation represents a comment, the whole - // diffing will be related to such comment. - // This helper is in charge of understanding how the new - // content for such interpolation/hole should be updated - var handleAnything = function handleAnything(comment) { - var oldValue, - text, - nodes = []; - var anyContent = function anyContent(newValue) { - switch (_typeof(newValue)) { - // primitives are handled as text content - case 'string': - case 'number': - case 'boolean': - if (oldValue !== newValue) { - oldValue = newValue; - if (!text) text = createTextNode(''); - text.data = newValue; - nodes = diff(comment, nodes, [text]); - } - break; - // null, and undefined are used to cleanup previous content - case 'object': - case 'undefined': - if (newValue == null) { - if (oldValue != newValue) { - oldValue = newValue; - nodes = diff(comment, nodes, []); - } - break; - } - // arrays and nodes have a special treatment - if (isArray(newValue)) { - oldValue = newValue; - // arrays can be used to cleanup, if empty - if (newValue.length === 0) nodes = diff(comment, nodes, []); - // or diffed, if these contains nodes or "wires" - else if (_typeof(newValue[0]) === 'object') nodes = diff(comment, nodes, newValue); - // in all other cases the content is stringified as is - else anyContent(String(newValue)); - break; - } - // if the new value is a DOM node, or a wire, and it's - // different from the one already live, then it's diffed. - // if the node is a fragment, it's appended once via its childNodes - // There is no `else` here, meaning if the content - // is not expected one, nothing happens, as easy as that. - if (oldValue !== newValue) { - if ('ELEMENT_NODE' in newValue) { - oldValue = newValue; - nodes = diff(comment, nodes, newValue.nodeType === 11 ? _toConsumableArray(newValue.childNodes) : [newValue]); - } else { - var value = newValue.valueOf(); - if (value !== newValue) anyContent(value); - } - } - break; - case 'function': - anyContent(newValue(comment)); - break; + var comment_unsafe = function comment_unsafe(xml) { + return function (node, value) { + var _node$ref; + var prev = (_node$ref = node[ref]) !== null && _node$ref !== void 0 ? _node$ref : node[ref] = {}; + if (prev.v !== value) { + prev.f = PersistentFragment(fragment(value, xml)); + prev.v = value; } + comment_hole(node, prev.f); }; - return anyContent; }; - - // attributes can be: - // * ref=${...} for hooks and other purposes - // * aria=${...} for aria attributes - // * ?boolean=${...} for boolean attributes - // * .dataset=${...} for dataset related attributes - // * .setter=${...} for Custom Elements setters or nodes with setters - // such as buttons, details, options, select, etc - // * @event=${...} to explicitly handle event listeners - // * onevent=${...} to automatically handle event listeners - // * generic=${...} to handle an attribute just like an attribute - var handleAttribute = function handleAttribute(node, name /*, svg*/) { - switch (name[0]) { - case '?': - return _boolean(node, name.slice(1), false); - case '.': - return setter(node, name.slice(1)); - case '@': - return event(node, 'on' + name.slice(1)); - case 'o': - if (name[1] === 'n') return event(node, name); - } - switch (name) { - case 'ref': - return ref(node); - case 'aria': - return aria(node); + var comment_signal = function comment_signal(node, value) { + comment_hole(node, value instanceof Signal ? value.value : value); + }; + var data = function data(_ref, values) { + var dataset = _ref.dataset; + var _iterator2 = _createForOfIteratorHelper$1(entries(values)), + _step2; + try { + for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) { + var _step2$value = _slicedToArray(_step2.value, 2), + key = _step2$value[0], + value = _step2$value[1]; + if (value == null) delete dataset[key];else dataset[key] = value; + } + } catch (err) { + _iterator2.e(err); + } finally { + _iterator2.f(); } - return attribute(node, name /*, svg*/); }; - // each mapped update carries the update type and its path - // the type is either node, attribute, or text, while - // the path is how to retrieve the related node to update. - // In the attribute case, the attribute name is also carried along. - function handlers(options) { - var type = options.type, - path = options.path; - var node = path.reduceRight(reducePath, this); - return type === 'node' ? handleAnything(node) : type === 'attr' ? handleAttribute(node, options.name /*, options.svg*/) : text(node); - } + /** @type {Map} */ + var directRefs = new Map(); - // from a fragment container, create an array of indexes - // related to its child nodes, so that it's possible - // to retrieve later on exact node via reducePath - var createPath = function createPath(node) { - var path = []; - var _node = node, - parentNode = _node.parentNode; - while (parentNode) { - path.push(indexOf.call(parentNode.childNodes, node)); - node = parentNode; - var _node2 = node; - parentNode = _node2.parentNode; + /** + * @param {string|Symbol} name + * @returns {Function} + */ + var directFor = function directFor(name) { + var fn = directRefs.get(name); + if (!fn) directRefs.set(name, fn = direct$1(name)); + return fn; + }; + var direct$1 = function direct(name) { + return function (node, value) { + node[name] = value; + }; + }; + var dots = function dots(node, values) { + var _iterator3 = _createForOfIteratorHelper$1(entries(values)), + _step3; + try { + for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) { + var _step3$value = _slicedToArray(_step3.value, 2), + name = _step3$value[0], + value = _step3$value[1]; + attribute(name)(node, value); + } + } catch (err) { + _iterator3.e(err); + } finally { + _iterator3.f(); } - return path; }; - - // the prefix is used to identify either comments, attributes, or nodes - // that contain the related unique id. In the attribute cases - // isµX="attribute-name" will be used to map current X update to that - // attribute name, while comments will be like , to map - // the update to that specific comment node, hence its parent. - // style and textarea will have text content, and are handled - // directly through text-only updates. - var prefix = 'isµ'; - - // Template Literals are unique per scope and static, meaning a template - // should be parsed once, and once only, as it will always represent the same - // content, within the exact same amount of updates each time. - // This cache relates each template to its unique content and updates. - var cache$1 = new WeakMapSet(); - - // a RegExp that helps checking nodes that cannot contain comments - var textOnly = /^(?:textarea|script|style|title|plaintext|xmp)$/; - var createCache = function createCache() { - return { - stack: [], - // each template gets a stack for each interpolation "hole" - - entry: null, - // each entry contains details, such as: - // * the template that is representing - // * the type of node it represents (html or svg) - // * the content fragment with all nodes - // * the list of updates per each node (template holes) - // * the "wired" node or fragment that will get updates - // if the template or type are different from the previous one - // the entry gets re-created each time - - wire: null // each rendered node represent some wired content and - // this reference to the latest one. If different, the node - // will be cleaned up and the new "wire" will be appended + var event = function event(type, at, array) { + return array ? function (node, value) { + var prev = node[at]; + if (prev !== null && prev !== void 0 && prev.length) node.removeEventListener.apply(node, [type].concat(_toConsumableArray(prev))); + if (value) node.addEventListener.apply(node, [type].concat(_toConsumableArray(value))); + node[at] = value; + } : function (node, value) { + var prev = node[at]; + if (prev) node.removeEventListener(type, prev); + if (value) node.addEventListener(type, value); + node[at] = value; }; }; - - // the entry stored in the rendered node cache, and per each "hole" - var createEntry = function createEntry(type, template) { - var _mapUpdates = mapUpdates(type, template), - content = _mapUpdates.content, - updates = _mapUpdates.updates; - return { - type: type, - template: template, - content: content, - updates: updates, - wire: null + var toggle = function toggle(name) { + return function (node, value) { + node.toggleAttribute(name, !!value); }; }; - - // a template is instrumented to be able to retrieve where updates are needed. - // Each unique template becomes a fragment, cloned once per each other - // operation based on the same template, i.e. data => html`

${data}

` - var mapTemplate = function mapTemplate(type, template) { - var svg = type === 'svg'; - var text = instrument(template, prefix, svg); - var content = createContent(text, svg); - // once instrumented and reproduced as fragment, it's crawled - // to find out where each update is in the fragment tree - var tw = createTreeWalker(content, 1 | 128); - var nodes = []; - var length = template.length - 1; - var i = 0; - // updates are searched via unique names, linearly increased across the tree - //
- var search = "".concat(prefix).concat(i); - while (i < length) { - var node = tw.nextNode(); - // if not all updates are bound but there's nothing else to crawl - // it means that there is something wrong with the template. - if (!node) throw "bad template: ".concat(text); - // if the current node is a comment, and it contains isµX - // it means the update should take care of any content - if (node.nodeType === 8) { - // The only comments to be considered are those - // which content is exactly the same as the searched one. - if (node.data === search) { - nodes.push({ - type: 'node', - path: createPath(node) - }); - search = "".concat(prefix).concat(++i); - } - } else { - // if the node is not a comment, loop through all its attributes - // named isµX and relate attribute updates to this node and the - // attribute name, retrieved through node.getAttribute("isµX") - // the isµX attribute will be removed as irrelevant for the layout - // let svg = -1; - while (node.hasAttribute(search)) { - nodes.push({ - type: 'attr', - path: createPath(node), - name: node.getAttribute(search) - }); - node.removeAttribute(search); - search = "".concat(prefix).concat(++i); + var k = false; + var isKeyed = function isKeyed() { + var wasKeyed = k; + k = false; + return wasKeyed; + }; + var update = function update(node, type, path, name, hint) { + switch (type) { + case COMPONENT$1: + return [path, hint, COMPONENT]; + case COMMENT$1: + { + if (isArray(hint)) return [path, comment_array, COMMENT_ARRAY]; + if (hint instanceof Unsafe) return [path, comment_unsafe(node.xml), UNSAFE]; + if (hint instanceof Signal) return [path, comment_signal, COMMENT | SIGNAL]; + return [path, comment_hole, COMMENT]; } - // if the node was a style, textarea, or others, check its content - // and if it is then update tex-only this node - if (textOnly.test(node.localName) && node.textContent.trim() === "")) { - node.textContent = ''; - nodes.push({ - type: 'text', - path: createPath(node) - }); - search = "".concat(prefix).concat(++i); + case TEXT$1: + return [path, directFor('textContent'), TEXT]; + case ATTRIBUTE$1: + { + var isComponent = node.type === COMPONENT$1; + switch (name.at(0)) { + case '@': + { + if (isComponent) throw errors.invalid_attribute([], name); + var array = isArray(hint); + return [path, event(name.slice(1), Symbol(name), array), array ? EVENT_ARRAY : EVENT]; + } + case '?': + if (isComponent) throw errors.invalid_attribute([], name); + return [path, toggle(name.slice(1)), TOGGLE]; + case '.': + { + return name === '...' ? [path, isComponent ? assign : dots, isComponent ? COMPONENT_DOTS : DOTS] : [path, direct$1(name.slice(1)), isComponent ? COMPONENT_DIRECT : DIRECT]; + } + default: + { + if (isComponent) return [path, direct$1(name), COMPONENT_PROP]; + if (name === 'aria') return [path, aria, ARIA]; + if (name === 'data' && !/^object$/i.test(node.name)) return [path, data, DATA]; + if (name === 'key') { + if (1 < path.length) throw errors.invalid_key(hint); + return [path, k = true, KEY]; + } + if (name === 'ref') return [path, directFor(ref), REF]; + if (name.startsWith('on')) return [path, directFor(name.toLowerCase()), DIRECT]; + return [path, attribute(name), ATTRIBUTE]; + } + } } - } } - // once all nodes to update, or their attributes, are known, the content - // will be cloned in the future to represent the template, and all updates - // related to such content retrieved right away without needing to re-crawl - // the exact same template, and its content, more than once. - return { - content: content, - nodes: nodes - }; }; - // if a template is unknown, perform the previous mapping, otherwise grab - // its details such as the fragment with all nodes, and updates info. - var mapUpdates = function mapUpdates(type, template) { - var _ref = cache$1.get(template) || cache$1.set(template, mapTemplate(type, template)), - content = _ref.content, - nodes = _ref.nodes; - // clone deeply the fragment - var fragment = importNode(content, true); - // and relate an update handler per each node that needs one - var updates = nodes.map(handlers, fragment); - // return the fragment and all updates to use within its nodes - return { - content: fragment, - updates: updates - }; + var direct = true; + + /** @param {boolean} value */ + var _set = function _set(value) { + direct = value; }; - // as html and svg can be nested calls, but no parent node is known - // until rendered somewhere, the unroll operation is needed to - // discover what to do with each interpolation, which will result - // into an update operation. - var unroll = function unroll(info, _ref2) { - var type = _ref2.type, - template = _ref2.template, - values = _ref2.values; - // interpolations can contain holes and arrays, so these need - // to be recursively discovered - var length = unrollValues(info, values); - var entry = info.entry; - // if the cache entry is either null or different from the template - // and the type this unroll should resolve, create a new entry - // assigning a new content fragment and the list of updates. - if (!entry || entry.template !== template || entry.type !== type) info.entry = entry = createEntry(type, template); - var _entry = entry, - content = _entry.content, - updates = _entry.updates, - wire = _entry.wire; - // even if the fragment and its nodes is not live yet, - // it is already possible to update via interpolations values. - for (var i = 0; i < length; i++) updates[i](values[i]); - // if the entry was new, or representing a different template or type, - // create a new persistent entity to use during diffing. - // This is simply a DOM node, when the template has a single container, - // as in `

`, or a "wire" in `

` and similar cases. - return wire || (entry.wire = persistent(content)); + /** @returns {boolean} */ + var _get = function _get() { + return direct; }; - // the stack retains, per each interpolation value, the cache - // related to each interpolation value, or null, if the render - // was conditional and the value is not special (Array or Hole) - var unrollValues = function unrollValues(_ref3, values) { - var stack = _ref3.stack; - var length = values.length; - for (var i = 0; i < length; i++) { - var hole = values[i]; - // each Hole gets unrolled and re-assigned as value - // so that domdiff will deal with a node/wire, not with a hole - if (hole instanceof Hole) values[i] = unroll(stack[i] || (stack[i] = createCache()), hole); - // arrays are recursively resolved so that each entry will contain - // also a DOM node or a wire, hence it can be diffed if/when needed - else if (isArray(hole)) unrollValues(stack[i] || (stack[i] = createCache()), hole); - // if the value is nothing special, the stack doesn't need to retain data - // this is useful also to cleanup previously retained data, if the value - // was a Hole, or an Array, but not anymore, i.e.: - // const update = content => html`
${content}
`; - // update(listOfItems); update(null); update(html`hole`) - else stack[i] = null; + function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: true } : { done: false, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = true, u = false; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = true, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; } + function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } } + function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; } + + /** + * @param {Hole} hole + * @returns + */ + var dom = function dom(hole) { + return diffFragment(hole.n ? hole.update(hole) : hole.valueOf(false), 1); + }; + var holed = function holed(prev, current) { + var changes = [], + h = prev.length, + l = current.length; + for (var c, p, j = 0, i = 0; i < l; i++) { + c = current[i]; + changes[i] = j < h && (p = prev[j++]).t === c.t ? (current[i] = p).update(c) : c.valueOf(false); } - if (length < stack.length) stack.splice(length); - return length; + return changes; + }; + + /** + * @param {Hole} hole + * @param {unknown} value + * @returns {Node} + */ + var keyed$1 = function keyed(hole, value) { + var _hole$t$2$get$update, _hole$t$2$get; + return /** @type {import('./keyed.js').Keyed} */(_hole$t$2$get$update = (_hole$t$2$get = hole.t[2].get(value)) === null || _hole$t$2$get === void 0 ? void 0 : _hole$t$2$get.update(hole)) !== null && _hole$t$2$get$update !== void 0 ? _hole$t$2$get$update : hole.valueOf(false); }; - /** - * Holds all details wrappers needed to render the content further on. - * @constructor - * @param {string} type The hole type, either `html` or `svg`. - * @param {string[]} template The template literals used to the define the content. - * @param {Array} values Zero, one, or more interpolated values to render. + /** + * + * @param {Function} Component + * @param {Object} obj + * @param {unknown[]} signals + * @returns {Hole} */ - var Hole = /*#__PURE__*/_createClass(function Hole(type, template, values) { - _classCallCheck(this, Hole); - this.type = type; - this.template = template; - this.values = values; + var component = function component(Component, obj, signals) { + signals.length; + var wasDirect = _get(); + if (wasDirect) _set(!wasDirect); + try { + return Component(obj, global); + } finally { + if (wasDirect) _set(wasDirect); + } + }; + + /** + * @param {Hole} hole + * @param {Hole} value + * @returns {Hole} + */ + var getHole = function getHole(hole, value) { + if (hole.t === value.t) { + hole.update(value); + } else { + hole.n.replaceWith(dom(value)); + hole = value; + } + return hole; + }; + var createEffect = function createEffect(node, value, obj) { + var signals = [], + entry = [COMPONENT, null, obj], + bootstrap = true, + hole; + effect(function () { + if (bootstrap) { + bootstrap = false; + hole = component(value, obj, signals); + if (!signals.length) signals = children; + if (hole) { + node.replaceWith(dom(hole)); + entry[1] = hole; + } else node.remove(); + } else { + var result = component(value, obj, signals); + if (hole) { + if (!(result instanceof Hole)) throw errors.invalid_component(value); + if (getHole(hole, /** @type {Hole} */result) === result) entry[2] = hole = result; + } + } + }); + return entry; + }; + var updateRefs = function updateRefs(refs) { + var _iterator = _createForOfIteratorHelper(refs), + _step; + try { + for (_iterator.s(); !(_step = _iterator.n()).done;) { + var node = _step.value; + var value = node[ref]; + if (typeof value === 'function') value(node);else if (value instanceof Signal) value.value = node;else if (value) value.current = node; + } + } catch (err) { + _iterator.e(err); + } finally { + _iterator.f(); + } + }; + var props = Symbol(); + var global = {}; + var Hole = /*#__PURE__*/function () { + /** + * @param {[DocumentFragment, unknown[], import('./keyed.js').Keyed?]} template + * @param {unknown[]} values + */ + function Hole(template, values) { + _classCallCheck(this, Hole); + this.t = template; + this.v = values; + this.n = null; + this.k = -1; + } + + /** + * @param {boolean} [direct] + * @returns {Node} + */ + return _createClass(Hole, [{ + key: "valueOf", + value: function valueOf() { + var direct = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _get(); + var _this$t = _slicedToArray(this.t, 3), + fragment = _this$t[0], + updates = _this$t[1], + keys = _this$t[2]; + var root = document.importNode(fragment, true); + var values = this.v; + var length = values.length; + var changes = children; + var node, prev, refs; + if (length !== updates.length) throw errors.invalid_interpolation(this.t[3], values); + if (0 < length) { + changes = updates.slice(0); + while (length--) { + var _updates$length = _slicedToArray(updates[length], 3), + path = _updates$length[0], + update = _updates$length[1], + type = _updates$length[2]; + var value = values[length]; + if (prev !== path) { + node = resolve(root, path); + prev = path; + if (!node) throw errors.invalid_path(this.t[3], path); + } + if (type & COMPONENT) { + var obj = node[props] || (node[props] = {}); + if (type === COMPONENT) { + var _obj$children; + var _iterator2 = _createForOfIteratorHelper(node.attributes), + _step2; + try { + for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) { + var _obj$name; + var _step2$value = _step2.value, + name = _step2$value.name, + _value = _step2$value.value; + (_obj$name = obj[name]) !== null && _obj$name !== void 0 ? _obj$name : obj[name] = _value; + } + } catch (err) { + _iterator2.e(err); + } finally { + _iterator2.f(); + } + (_obj$children = obj.children) !== null && _obj$children !== void 0 ? _obj$children : obj.children = _toConsumableArray(node.content.childNodes); + changes[length] = createEffect(node, value, obj); + } else { + update(obj, value); + changes[length] = [type, update, obj]; + } + } else { + var commit = true; + if (type & ARRAY && !isArray(value)) throw errors.invalid_interpolation(this.t[3], value); + if (!direct && type & COMMENT && !(type & SIGNAL)) { + if (type & ARRAY) { + commit = false; + if (value.length) update(node, value[0] instanceof Hole ? holed(children, value) : value); + } else if (value instanceof Hole) { + commit = false; + update(node, dom(value)); + } + } + if (commit) { + if (type === KEY) { + if (!keys) throw errors.invalid_key(value); + this.k = length; + } else { + if (type === REF) (refs !== null && refs !== void 0 ? refs : refs = new Set()).add(node); + update(node, value); + } + } + changes[length] = [type, update, value, node]; + if (direct && type & COMMENT) node.remove(); + } + } + if (refs) updateRefs(refs); + } + var childNodes = root.childNodes; + var size = childNodes.length; + var n = size === 1 ? childNodes[0] : size ? PersistentFragment(root) : root; + this.v = changes; + this.n = n; + if (-1 < this.k) keys.set(changes[this.k][2], n, this); + return n; + } + + /** + * @param {Hole} hole + * @returns {Node} + */ + }, { + key: "update", + value: function update(hole) { + var key = this.k; + var changes = this.v; + var values = hole.v; + if (-1 < key && changes[key][2] !== values[key]) return keyed$1(hole, values[key]); + var length = changes.length; + while (length--) { + var entry = changes[length]; + var _entry = _slicedToArray(entry, 3), + type = _entry[0], + _update = _entry[1], + prev = _entry[2]; + if (type === KEY) continue; + var value = values[length]; + if (type & COMPONENT) { + if (type === COMPONENT) { + if (typeof value !== 'function') throw errors.invalid_component(value); + var result = value(prev, global); + if (_update) { + if (!(result instanceof Hole)) throw errors.invalid_component(value); + if (getHole(_update, /** @type {Hole} */result) === result) entry[2] = result; + } + } else _update(prev, value); + } else { + var change = value; + if (type & ARRAY) { + if (!isArray(value)) throw errors.invalid_interpolation([], value); + if (type & COMMENT) { + // TODO: a smarter differ that does not require 2 loops + if (value.length) { + if (value[0] instanceof Hole) { + if (prev.length && !(prev[0] instanceof Hole)) throw errors.invalid_interpolation([], value[0]); + change = holed(prev, value); + } + } + } else if (type & EVENT && value[0] === prev[0]) continue; + } else if (type & COMMENT) { + if (type & SIGNAL) { + if (value === prev) { + _update(entry[3], change); + continue; + } + } else if (prev instanceof Hole) { + if (!(value instanceof Hole)) throw errors.invalid_interpolation([], value); + value = getHole(prev, /** @type {Hole} */value); + change = value.n; + } + } + if (value !== prev) { + entry[2] = value; + _update(entry[3], change); + } + } + } + return /** @type {Node} */this.n; + } + }]); + }(); + + function _isNativeFunction(t) { + try { + return -1 !== Function.toString.call(t).indexOf("[native code]"); + } catch (n) { + return "function" == typeof t; + } + } + + function _isNativeReflectConstruct$2() { + try { + var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); + } catch (t) {} + return (_isNativeReflectConstruct$2 = function _isNativeReflectConstruct() { + return !!t; + })(); + } + + function _construct(t, e, r) { + if (_isNativeReflectConstruct$2()) return Reflect.construct.apply(null, arguments); + var o = [null]; + o.push.apply(o, e); + var p = new (t.bind.apply(t, o))(); + return r && _setPrototypeOf(p, r.prototype), p; + } + + function _wrapNativeSuper(t) { + var r = "function" == typeof Map ? new Map() : void 0; + return _wrapNativeSuper = function _wrapNativeSuper(t) { + if (null === t || !_isNativeFunction(t)) return t; + if ("function" != typeof t) throw new TypeError("Super expression must either be null or a function"); + if (void 0 !== r) { + if (r.has(t)) return r.get(t); + r.set(t, Wrapper); + } + function Wrapper() { + return _construct(t, arguments, _getPrototypeOf(this).constructor); + } + return Wrapper.prototype = Object.create(t.prototype, { + constructor: { + value: Wrapper, + enumerable: false, + writable: true, + configurable: true + } + }), _setPrototypeOf(Wrapper, t); + }, _wrapNativeSuper(t); + } + + function _callSuper$1(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct$1() ? Reflect.construct(o, [], _getPrototypeOf(t).constructor) : o.apply(t, e)); } + function _isNativeReflectConstruct$1() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct$1 = function _isNativeReflectConstruct() { return !!t; })(); } + function _superPropGet(t, o, e, r) { var p = _get$1(_getPrototypeOf(t.prototype ), o, e); return 2 & r && "function" == typeof p ? function (t) { return p.apply(e, t); } : p; } + var keyed = new WeakMap(); + + //@ts-ignore + var Keyed = /*#__PURE__*/function (_Map) { + function Keyed() { + var _this; + _classCallCheck(this, Keyed); + //@ts-ignore + (_this = _callSuper$1(this, Keyed))._ = new FinalizationRegistry(function (key) { + return _this["delete"](key); + }); + return _this; + } + _inherits(Keyed, _Map); + return _createClass(Keyed, [{ + key: "get", + value: function get(key) { + var _superPropGet2; + var node = (_superPropGet2 = _superPropGet(Keyed, "get", this, 3)([key])) === null || _superPropGet2 === void 0 ? void 0 : _superPropGet2.deref(); + return node && keyed.get(node); + } + + /** + * @param {any} key + * @param {Node} node + * @param {import('./rabbit.js').Hole} hole + */ + //@ts-ignore + }, { + key: "set", + value: function set(key, node, hole) { + keyed.set(node, hole); + //@ts-ignore + this._.register(node, key); + _superPropGet(Keyed, "set", this, 3)([key, new WeakRef(node)]); + } + }]); + }(/*#__PURE__*/_wrapNativeSuper(Map)); + + //@ts-check + + + /** @typedef {globalThis.Element | globalThis.HTMLElement | globalThis.SVGSVGElement | globalThis.DocumentFragment} Container */ + + var parse$1 = parser({ + Comment: Comment, + DocumentType: DocumentType, + Text: Text, + Fragment: Fragment, + Element: Element, + Component: Component, + update: update }); - // both `html` and `svg` template literal tags are polluted - // with a `for(ref[, id])` and a `node` tag too - var tag = function tag(type) { - // both `html` and `svg` tags have their own cache - var keyed = new WeakMapSet(); - // keyed operations always re-use the same cache and unroll - // the template and its interpolations right away - var fixed = function fixed(cache) { - return function (template) { + /** + * @param {boolean} xml + * @param {WeakMap} twm + * @returns + */ + var create$1 = function create(xml) { + var twm = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new WeakMap(); + return ( + /** + * @param {TemplateStringsArray | string[]} template + * @param {unknown[]} values + * @returns {Hole} + */ + function (template) { + var parsed = twm.get(template); for (var _len = arguments.length, values = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { values[_key - 1] = arguments[_key]; } - return unroll(cache, { - type: type, - template: template, - values: values - }); - }; - }; - return Object.assign( - // non keyed operations are recognized as instance of Hole - // during the "unroll", recursively resolved and updated - function (template) { - for (var _len2 = arguments.length, values = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { - values[_key2 - 1] = arguments[_key2]; - } - return new Hole(type, template, values); - }, { - // keyed operations need a reference object, usually the parent node - // which is showing keyed results, and optionally a unique id per each - // related node, handy with JSON results and mutable list of objects - // that usually carry a unique identifier - "for": function _for(ref, id) { - var memo = keyed.get(ref) || keyed.set(ref, new MapSet()); - return memo.get(id) || memo.set(id, fixed(createCache())); - }, - // it is possible to create one-off content out of the box via node tag - // this might return the single created node, or a fragment with all - // nodes present at the root level and, of course, their child nodes - node: function node(template) { - for (var _len3 = arguments.length, values = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) { - values[_key3 - 1] = arguments[_key3]; + if (!parsed) { + parsed = parse$1(template, values, xml); + parsed.push(isKeyed() ? new Keyed() : null); + parsed.push(template); + parsed[0] = fragment(parsed[0].toString(), xml); + twm.set(template, parsed); } - return unroll(createCache(), new Hole(type, template, values)).valueOf(); + return new Hole(parsed, values); } - }); + ); }; + var htmlHole = create$1(false); + var svgHole = create$1(true); + var rendered = new WeakMap(); + + /** + * @param {TemplateStringsArray | string[]} template + * @param {any[]} values + * @returns {Node | HTMLElement | Hole} + */ + function html(template) { + for (var _len2 = arguments.length, values = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { + values[_key2 - 1] = arguments[_key2]; + } + var hole = htmlHole.apply(null, arguments); + return _get() ? hole.valueOf(true) : hole; + } - // each rendered node gets its own cache - var cache = new WeakMapSet(); + /** + * @param {TemplateStringsArray | string[]} template + * @param {any[]} values + * @returns {Node | SVGSVGElement | Hole} + */ + function svg(template) { + for (var _len3 = arguments.length, values = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) { + values[_key3 - 1] = arguments[_key3]; + } + var hole = svgHole.apply(null, arguments); + return _get() ? hole.valueOf(true) : hole; + } - // rendering means understanding what `html` or `svg` tags returned - // and it relates a specific node to its own unique cache. - // Each time the content to render changes, the node is cleaned up - // and the new new content is appended, and if such content is a Hole - // then it's "unrolled" to resolve all its inner nodes. + /** + * @param {Container} where + * @param {Function | Node | Container} what + * @returns + */ var render = function render(where, what) { - var hole = typeof what === 'function' ? what() : what; - var info = cache.get(where) || cache.set(where, createCache()); - var wire = hole instanceof Hole ? unroll(info, hole) : hole; - if (wire !== info.wire) { - info.wire = wire; - // valueOf() simply returns the node itself, but in case it was a "wire" - // it will eventually re-append all nodes to its fragment so that such - // fragment can be re-appended many times in a meaningful way - // (wires are basically persistent fragments facades with special behavior) - where.replaceChildren(wire.valueOf()); + var known = rendered.get(where); + if (known) known[0](); + if (typeof what === 'function') { + _set(false); + var hole; + var scope = effectScope(function () { + hole = what(); + }); + //@ts-ignore + if (!known || known[1].t !== hole.t) { + //@ts-ignore + var d = hole.valueOf(false); + where.replaceChildren(d); + } else known[1].update(hole); + rendered.set(where, [scope, hole]); + } else { + _set(true); + rendered["delete"](where); + where.replaceChildren(what instanceof Hole ? dom(what) : diffFragment(what, 1)); } return where; }; - var html = tag('html'); - var svg = tag('svg'); var umap = (function (_) { return { @@ -1082,8 +2199,8 @@ var uce = (function (exports) { }; }); - function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } - function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } + function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); } + function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); } var reactive = domHandler({ dom: true }); @@ -1257,12 +2374,11 @@ var uce = (function (exports) { c = _info.c, e = _info.e; var MicroElement = /*#__PURE__*/function (_c) { - _inherits(MicroElement, _c); - var _super = _createSuper(MicroElement); function MicroElement() { _classCallCheck(this, MicroElement); - return _super.apply(this, arguments); + return _callSuper(this, MicroElement, arguments); } + _inherits(MicroElement, _c); return _createClass(MicroElement); }(c); defineProperties(MicroElement, statics); @@ -1287,13 +2403,12 @@ var uce = (function (exports) { // element on the page, it will break once the registry // will try to upgrade such element so ... HTMLElement it is. CE.define('uce-lib', /*#__PURE__*/function (_info$c) { - _inherits(_class, _info$c); - var _super2 = _createSuper(_class); function _class() { _classCallCheck(this, _class); - return _super2.apply(this, arguments); + return _callSuper(this, _class, arguments); } - _createClass(_class, null, [{ + _inherits(_class, _info$c); + return _createClass(_class, null, [{ key: "define", get: function get() { return define; @@ -1319,7 +2434,6 @@ var uce = (function (exports) { return css; } }]); - return _class; }(info(element).c)); function bind(method) { this[method] = this[method].bind(this); diff --git a/min.js b/min.js index 388d4f6..691b364 100644 --- a/min.js +++ b/min.js @@ -1 +1 @@ -var uce=function(t){"use strict";function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},e(t)}function n(t){var n=function(t,n){if("object"!==e(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var o=r.call(t,n||"default");if("object"!==e(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===n?String:Number)(t)}(t,"string");return"symbol"===e(n)?n:String(n)}function r(t,e){for(var r=0;r]*?)(\/?)>/g,g=/([^\s\\>"'=]+)\s*=\s*(['"]?)\x01/g,m=/[\x01\x02]/g;function w(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);nd-l)for(var b=r(e[a],0);l"})).replace(m,(function(t){return""===t?"\x3c!--"+e+r+++"--\x3e":e+r++}))}(e,I,n),o=L(r,n),i=_(o,129),u=[],c=e.length-1,a=0,l="".concat(I).concat(a);a1?n-1:0),o=1;o1?r-1:0),i=1;i1?n-1:0),o=1;o0&&void 0!==arguments[0]?arguments[0]:{},n=t.all,r=void 0!==n&&n,o=t.shallow,i=void 0===o||o,u=t.useState,c=void 0===u?it:u,a=t.getAttribute,l=void 0===a?function(t,e){return t.getAttribute(e)}:a;return function(t,n,o){var u=function(t,e,n,r,o,i){for(var u={},c=o!==it,a=[n,r,c],l=rt(t),f=0;f1&&void 0!==arguments[1]?arguments[1]:t.sub,n=t.dep,i=t.prevDep,o=t.nextDep,a=t.nextSub,u=t.prevSub;return void 0!==o?o.prevDep=i:e.depsTail=i,void 0!==i?i.nextDep=o:e.deps=o,void 0!==a?a.prevSub=u:n.subsTail=u,void 0!==u?u.nextSub=a:void 0===(n.subs=a)&&r(n),o}function a(t){do{var e=t.sub,r=e.flags;32==(48&r)&&(e.flags=16|r,2&r&&n(e))}while(void 0!==(t=t.nextSub))}function u(t,e){for(var n=e.depsTail;void 0!==n;){if(n===t)return!0;n=n.prevDep}return!1}}({update:function(t){return"getter"in t?function(t){var e=S(t);w(t);try{var n=t.value;return n!==(t.value=t.getter(n))}finally{S(e),m(t)}}(t):(e=t,n=t.value,e.flags=1,e.previousValue!==(e.previousValue=n));var e,n},notify:function t(e){var n=e.flags;if(!(64&n)){e.flags=64|n;var r=e.subs;void 0!==r&&t(r.sub)}},unwatched:function(t){if("getter"in t){var e=t.deps;if(void 0!==e){t.flags=17;do{e=y(e,t)}while(void 0!==e)}}else"previousValue"in t||O.call(t)}}),p=h.link,y=h.unlink;h.propagate,h.checkDirty;var b,g,m=h.endTracking,w=h.startTracking;function S(t){var e=b;return b=t,e}function x(t){var e=g;return g=t,e}function O(){for(var t=this.deps;void 0!==t;)t=y(t,this);var e=this.subs;void 0!==e&&y(e),this.flags=0}h.shallowPropagate;var k=function(t){d.push(S(void 0));try{return t()}finally{S(d.pop())}},A=function(){return i(function t(e,n){o(this,t),this._=e(n)},[{key:"value",get:function(){return this._()},set:function(t){this._(t)}},{key:"peek",value:function(){return k(this._)}},{key:"valueOf",value:function(){return this.value}}])}();function j(t,e,n){(function(t,e){if(e.has(t))throw new TypeError("Cannot initialize the same private elements twice on an object")})(t,e),e.set(t,n)}function E(t,e){return t.get(C(t,e))}function C(t,e,n){if("function"==typeof t?t===e:t.has(e))return arguments.length<3?e:n;throw new TypeError("Private element is not present on this object")}var T=Array.isArray,I=Object.assign,N=Object.defineProperties,D=Object.entries,P=Object.freeze,M=new WeakMap,R=function(){return i(function t(e){var n,r,i;o(this,t),j(this,M,void 0),r=this,i=e,(n=M).set(C(n,r),i)},[{key:"valueOf",value:function(){return E(M,this)}},{key:"toString",value:function(){return String(E(M,this))}}])}(),W=function(t){return document.createComment(t)};function _(t,e,n){return e=u(e),a(t,L()?Reflect.construct(e,n||[],u(t).constructor):e.apply(t,n))}function L(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(L=function(){return!!t})()}var B=42,$=new Set(["plaintext","script","style","textarea","title","xmp"]),J=new Set(["area","base","br","col","embed","hr","img","input","keygen","link","menuitem","meta","param","source","track","wbr"]),F=P({}),U=P([]),z=function(t,e){return t.children===U&&(t.children=[]),t.children.push(e),e.parent=t,e},V=function(t,e,n){t.props===F&&(t.props={}),t.props[e]=n},H=function(t,e,n){t!==e&&n.push(t)},q=function(){return i(function t(e){o(this,t),this.type=e,this.parent=null},[{key:"toJSON",value:function(){return[this.type,this.data]}}])}(),G=function(t){function e(t){var n;return o(this,e),(n=_(this,e,[8])).data=t,n}return l(e,t),i(e,[{key:"toString",value:function(){return"\x3c!--".concat(this.data,"--\x3e")}}])}(q),K=function(t){function e(t){var n;return o(this,e),(n=_(this,e,[10])).data=t,n}return l(e,t),i(e,[{key:"toString",value:function(){return"")}}])}(q),Q=function(t){function e(t){var n;return o(this,e),(n=_(this,e,[3])).data=t,n}return l(e,t),i(e,[{key:"toString",value:function(){return this.data}}])}(q),X=function(t){function e(){var t;return o(this,e),(t=_(this,e,[B])).name="template",t.props=F,t.children=U,t}return l(e,t),i(e,[{key:"toJSON",value:function(){var t=[B];return H(this.props,F,t),H(this.children,U,t),t}},{key:"toString",value:function(){var t="";for(var e in this.props){var n=this.props[e];null!=n&&("boolean"==typeof n?n&&(t+=" ".concat(e)):t+=" ".concat(e,'="').concat(n,'"'))}return"").concat(this.children.join(""),"")}}])}(q),Y=function(t){function e(t){var n,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return o(this,e),(n=_(this,e,[1])).name=t,n.xml=r,n.props=F,n.children=U,n}return l(e,t),i(e,[{key:"toJSON",value:function(){var t=[1,this.name,+this.xml];return H(this.props,F,t),H(this.children,U,t),t}},{key:"toString",value:function(){var t=this.xml,e=this.name,n=this.props,r=this.children,i=r.length,o="<".concat(e);for(var a in n){var u=n[a];null!=u&&("boolean"==typeof u?u&&(o+=t?" ".concat(a,'=""'):" ".concat(a)):o+=" ".concat(a,'="').concat(u,'"'))}if(i){o+=">";for(var c=!t&&$.has(e),l=0;l")}else o+=t?" />":J.has(e)?">":">");return o}}])}(q),Z=function(t){function e(){var t;return o(this,e),(t=_(this,e,[11])).name="#fragment",t.children=U,t}return l(e,t),i(e,[{key:"toJSON",value:function(){var t=[11];return H(this.children,U,t),t}},{key:"toString",value:function(){return this.children.join("")}}])}(q);function tt(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n element ").concat(JSON.stringify(String(n))," in template ").concat(rt(t)))},ot=function(t,e){return new SyntaxError("The text only <".concat(e,"> element requires explicit closing tag in template ").concat(rt(t)))},at=function(t,e){return new SyntaxError("Unclosed element <".concat(e,"> found in template ").concat(rt(t)))},ut=function(t){return new SyntaxError('Invalid content "=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,u=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return a=t.done,t},e:function(t){u=!0,o=t},f:function(){try{a||null==n.return||n.return()}finally{if(u)throw o}}}}function wt(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<\s]+/g,At=/([^\s/>=]+)(?:=(\x00|(?:(['"])[\s\S]*?\3)))?/g,jt=function(t,e,n,r,i){return[e,n,r]},Et=function(t){for(var e=[];t.parent;){switch(t.type){case B:case 1:"template"===t.name&&e.push(-1)}e.push(t.parent.children.indexOf(t)),t=t.parent}return e},Ct=function(t,e){do{t=t.parent}while(e.has(t));return t};function Tt(t){return function(t){if(Array.isArray(t))return tt(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||et(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var It,Nt=function(t,e){var n;return e<0?null==t?void 0:t.content:null==t||null===(n=t.childNodes)||void 0===n?void 0:n[e]},Dt=function(t,e){return e.reduceRight(Nt,t)},Pt=!1,Mt=function(t){var e=t.firstChild,n=t.lastChild,r=It||(It=document.createRange());return r.setStartAfter(e),r.setEndAfter(n),r.deleteContents(),e},Rt=function(t,e){return Pt&&11===t.nodeType?1/e<0?e?Mt(t):t.lastChild:e?t.valueOf():t.firstChild:t},Wt=Symbol("nodes"),_t={get:function(){return this.firstChild.parentNode}},Lt={value:function(t){Mt(this).replaceWith(t)}},Bt={value:function(){Mt(this).remove()}},$t={value:function(){var t=this.parentNode;if(t===this)this[Wt]===U&&(this[Wt]=Tt(this.childNodes));else{if(t){var e=this.firstChild,n=this.lastChild;for(this[Wt]=[e];e!==n;)this[Wt].push(e=e.nextSibling)}this.replaceChildren.apply(this,Tt(this[Wt]))}return this}};function Jt(t){var e=W("<>"),n=W("");return t.replaceChildren.apply(t,[e].concat(Tt(t.childNodes),[n])),Pt=!0,N(t,s(s(s(s(s(s(s({},Wt,{writable:!0,value:U}),"firstChild",{value:e}),"lastChild",{value:n}),"parentNode",_t),"valueOf",$t),"replaceWith",Lt),"remove",Bt))}Jt.prototype=DocumentFragment.prototype;function Ft(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=function(t,e){if(t){if("string"==typeof t)return Ut(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Ut(t,e):void 0}}(t))||e){n&&(t=n);var r=0,i=function(){};return{s:i,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,u=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return a=t.done,t},e:function(t){u=!0,o=t},f:function(){try{a||null==n.return||n.return()}finally{if(u)throw o}}}}function Ut(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n0&&void 0!==arguments[0]?arguments[0]:globalThis.document,n=e.createElement("template");return function(r){if(arguments.length>1&&void 0!==arguments[1]&&arguments[1])return t||(t=e.createRange()).selectNodeContents(e.createElementNS("http://www.w3.org/2000/svg","svg")),t.createContextualFragment(r);n.innerHTML=r;var i=n.content;return n=n.cloneNode(!1),i}}(document),qt=Symbol("ref"),Gt=function(t,e){var n,r=Ft(D(e));try{for(r.s();!(n=r.n()).done;){var i=nt(n.value,2),o=i[0],a=i[1],u="role"===o?o:"aria-".concat(o.toLowerCase());null==a?t.removeAttribute(u):t.setAttribute(u,a)}}catch(t){r.e(t)}finally{r.f()}},Kt=function(t){return function(e,n){null==n?e.removeAttribute(t):e.setAttribute(t,n)}},Qt=function(t,e){t[Wt]=function(t,e,n,r){for(var i=r.parentNode,o=e.length,a=t.length,u=o,c=0,l=0,f=null;cp-l)for(var g=n(t[c],0);l=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,u=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return a=t.done,t},e:function(t){u=!0,o=t},f:function(){try{a||null==n.return||n.return()}finally{if(u)throw o}}}}function ve(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n0&&void 0!==arguments[0]?arguments[0]:fe(),o=nt(this.t,3),a=o[0],u=o[1],c=o[2],l=document.importNode(a,!0),f=this.v,s=f.length,v=U;if(s!==u.length)throw yt(this.t[3],f);if(0",x+2);if(k<0)throw ut(t);if("--\x3e"===o.slice(k-2,k+1)){if(k-x<6)throw ft(t);var A=o.slice(x+4,k-2);"!"===A[0]&&z(d,new n(A.slice(1).replace(/!$/,"")))}else{if(!o.slice(x+2,k).toLowerCase().startsWith("doctype"))throw vt(t,o.slice(x+2,k));z(d,new i(o.slice(x+2,k)))}p=k+1}else if(S.startsWith("",x+2);if(j<0)throw ct(t);if(r&&"svg"===d.name&&(r=!1),!(d=Ct(d,l)))throw st(t);p=j+1}else{var E=x+S.length,C=o.indexOf(">",E),T=S.slice(1);if(C<0)throw at(t,T);var I=T;if(T===St?(I="template",d=z(d,new v),g=Et(d).slice(1),s.push(h(d,B,g,"",e[b++]))):(r||(I=I.toLowerCase(),"table"!==d.name||"tr"!==I&&"td"!==I||(d=z(d,new f("tbody",r)),l.add(d)),"tbody"===d.name&&"td"===I&&(d=z(d,new f("tr",r)),l.add(d))),d=z(d,new f(I,!!r&&"svg"!==I)),g=U),E"),p);if(F<0)throw ot(t,I);var H=o.slice(p,F);if(H.trim()===St)y++,s.push(h(d,3,Et(d),"",e[b++]));else{if(H.includes(St))throw it(t,I,H);z(d,new a(H))}if(!(d=d.parent))throw st(t);p=F+T.length+3,y++;continue}}}}}catch(t){m.e(t)}finally{m.f()}if(p1&&void 0!==arguments[1]?arguments[1]:new WeakMap;return function(n){for(var r,i=e.get(n),o=arguments.length,a=new Array(o>1?o-1:0),u=1;u1?e-1:0),r=1;r1?e-1:0),r=1;r0&&void 0!==arguments[0]?arguments[0]:{},n=t.all,r=void 0!==n&&n,i=t.shallow,o=void 0===i||i,a=t.useState,u=void 0===a?Be:a,c=t.getAttribute,l=void 0===c?function(t,e){return t.getAttribute(e)}:c;return function(t,n,i){var a=function(t,e,n,r,i,o){for(var a={},u=i!==Be,c=[n,r,u],l=_e(t),f=0;f]*?)(\/?)>/g,l=/([^\s\\>"'=]+)\s*=\s*(['"]?)\x01/g,o=/[\x01\x02]/g;const a=(e,t)=>111===e.nodeType?1/t<0?t?(({firstChild:e,lastChild:t})=>{const n=document.createRange();return n.setStartAfter(e),n.setEndAfter(t),n.deleteContents(),e})(e):e.lastChild:t?e.valueOf():e.firstChild:e,{isArray:c}=Array,i=e=>null==e?e:e.valueOf(),u=(e,t)=>{let n,s,r=t.slice(2);return!(t in e)&&(s=t.toLowerCase())in e&&(r=s.slice(2)),t=>{const s=c(t)?t:[t,!1];n!==s[0]&&(n&&e.removeEventListener(r,n,s[1]),(n=s[0])&&e.addEventListener(r,n,s[1]))}};const{isArray:d,prototype:p}=Array,{indexOf:h}=p,{createDocumentFragment:f,createElement:g,createElementNS:b,createTextNode:m,createTreeWalker:y,importNode:v}=new Proxy(document,{get:(e,t)=>e[t].bind(e)});let w;const x=(e,t)=>t?(e=>{w||(w=b("http://www.w3.org/2000/svg","svg")),w.innerHTML=e;const t=f();return t.append(...w.childNodes),t})(e):(e=>{const t=g("template");return t.innerHTML=e,t.content})(e),C=({childNodes:e},t)=>e[t],A=(e,t,n)=>((e,t,n,s,r)=>{const l=n.length;let o=t.length,a=l,c=0,i=0,u=null;for(;cr-i){const l=s(t[c],0);for(;i{switch(t[0]){case"?":return((e,t,n)=>s=>{const r=!!i(s);n!==r&&((n=r)?e.setAttribute(t,""):e.removeAttribute(t))})(e,t.slice(1),!1);case".":return((e,t)=>"dataset"===t?(({dataset:e})=>t=>{for(const n in t){const s=t[n];null==s?delete e[n]:e[n]=s}})(e):n=>{e[t]=n})(e,t.slice(1));case"@":return u(e,"on"+t.slice(1));case"o":if("n"===t[1])return u(e,t)}switch(t){case"ref":return(e=>{let t;return n=>{t!==n&&(t=n,"function"==typeof n?n(e):n.current=e)}})(e);case"aria":return(e=>t=>{for(const n in t){const s="role"===n?n:`aria-${n}`,r=t[n];null==r?e.removeAttribute(s):e.setAttribute(s,r)}})(e)}return((e,t)=>{let n,s=!0;const r=document.createAttributeNS(null,t);return t=>{const l=i(t);n!==l&&(null==(n=l)?s||(e.removeAttributeNode(r),s=!0):(r.value=l,s&&(e.setAttributeNodeNS(r),s=!1)))}})(e,t)};function N(e){const{type:t,path:n}=e,s=n.reduceRight(C,this);return"node"===t?(e=>{let t,n,s=[];const r=l=>{switch(typeof l){case"string":case"number":case"boolean":t!==l&&(t=l,n||(n=m("")),n.data=l,s=A(e,s,[n]));break;case"object":case"undefined":if(null==l){t!=l&&(t=l,s=A(e,s,[]));break}if(d(l)){t=l,0===l.length?s=A(e,s,[]):"object"==typeof l[0]?s=A(e,s,l):r(String(l));break}if(t!==l)if("ELEMENT_NODE"in l)t=l,s=A(e,s,11===l.nodeType?[...l.childNodes]:[l]);else{const e=l.valueOf();e!==l&&r(e)}break;case"function":r(l(e))}};return r})(s):"attr"===t?k(s,e.name):(e=>{let t;return n=>{const s=i(n);t!=s&&(t=s,e.textContent=null==s?"":s)}})(s)}const E=e=>{const t=[];let{parentNode:n}=e;for(;n;)t.push(h.call(n.childNodes,e)),e=n,({parentNode:n}=e);return t},O="isµ",$=new n,S=/^(?:textarea|script|style|title|plaintext|xmp)$/,M=(e,t)=>{const n="svg"===e,a=((e,t,n)=>{let a=0;return e.join("").trim().replace(r,((e,t,r,o)=>{let a=t+r.replace(l,"=$2$1").trimEnd();return o.length&&(a+=n||s.test(t)?" /":">"})).replace(o,(e=>""===e?"\x3c!--"+t+a+++"--\x3e":t+a++))})(t,O,n),c=x(a,n),i=y(c,129),u=[],d=t.length-1;let p=0,h=`${O}${p}`;for(;p{const{content:n,nodes:s}=$.get(t)||$.set(t,M(e,t)),r=v(n,!0);return{content:r,updates:s.map(N,r)}},L=(e,{type:t,template:n,values:s})=>{const r=j(e,s);let{entry:l}=e;l&&l.template===n&&l.type===t||(e.entry=l=((e,t)=>{const{content:n,updates:s}=T(e,t);return{type:e,template:t,content:n,updates:s,wire:null}})(t,n));const{content:o,updates:a,wire:c}=l;for(let e=0;e{const{firstChild:t,lastChild:n}=e;if(t===n)return n||e;const{childNodes:s}=e,r=[...s];return{ELEMENT_NODE:1,nodeType:111,firstChild:t,lastChild:n,valueOf:()=>(s.length!==r.length&&e.append(...r),e)}})(o))},j=({stack:e},t)=>{const{length:n}=t;for(let s=0;s{const s=new n;return Object.assign(((t,...n)=>new P(e,t,n)),{for(n,r){const l=s.get(n)||s.set(n,new t);return l.get(r)||l.set(r,(t=>(n,...s)=>L(t,{type:e,template:n,values:s}))({stack:[],entry:null,wire:null}))},node:(t,...n)=>L({stack:[],entry:null,wire:null},new P(e,t,n)).valueOf()})},D=new n,W=(e,t)=>{const n="function"==typeof t?t():t,s=D.get(e)||D.set(e,{stack:[],entry:null,wire:null}),r=n instanceof P?L(s,n):n;return r!==s.wire&&(s.wire=r,e.replaceChildren(r.valueOf())),e},H=B("html"),_=B("svg");function z(e){for(var t=e[0],n=1,s=arguments.length;n({configurable:!0,get:()=>s,set(l){(e||l!==s||t&&"object"==typeof l&&l)&&(s=l,n?r.call(this,s):r.call(this))}}),q=()=>{};const G=(({all:e=!1,shallow:t=!0,useState:n=q,getAttribute:s=((e,t)=>e.getAttribute(t))}={})=>(r,l,o)=>{const a=((e,t,n,s,r,l)=>{const o={},a=r!==q,c=[n,s,a];for(let n=F(e),s=0;s{let n=e[t],l=typeof n;return r.hasOwnProperty(t)?(n=r[t],delete r[t]):r.hasAttribute(t)&&(n=s(r,t),"number"==l?n=+n:"boolean"==l&&(n=!/^(?:false|0|)$/.test(n))),n}),e,t,n,o);return R(r,a)})({dom:!0}),I=customElements,{define:K}=I,{parse:Q,stringify:U}=JSON,{create:V,defineProperties:X,getOwnPropertyDescriptor:Y,keys:Z}=Object,ee="element",te=new WeakMap,ne=(se=new Map([[ee,{c:HTMLElement,e:ee}]]),{get:e=>se.get(e),set:(e,t)=>(se.set(e,t),t)});var se;const re=e=>document.createElement(e),le=e=>ne.get(e)||ne.set(e,{c:re(e).constructor,e:e}),oe=(e,t)=>{const{attachShadow:n,attributeChanged:s,bound:r,connected:l,disconnected:o,formAssociated:a,handleEvent:c,init:i,observedAttributes:u,props:d,render:p,style:h}=t,f=new WeakMap,g={},b={},m=[],y=V(null),v=(e,t,s)=>{if(!f.has(e)){f.set(e,0),X(e,{html:{configurable:!0,value:ce.bind(n?e.attachShadow(n):e)}});for(let t=0;t{n.push(d(void 0));try{return e()}finally{d(n.pop())}};class g{constructor(e,t){this._=e(t)}get value(){return this._()}set value(e){this._(e)}peek(){return v(this._)}valueOf(){return this.value}}const{isArray:m}=Array,{assign:b,defineProperties:w,entries:y,freeze:x}=Object;class S{#e;constructor(e){this.#e=e}valueOf(){return this.#e}toString(){return String(this.#e)}}const $=e=>document.createComment(e),k=42,C=new Set(["plaintext","script","style","textarea","title","xmp"]),E=new Set(["area","base","br","col","embed","hr","img","input","keygen","link","menuitem","meta","param","source","track","wbr"]),O=x({}),T=x([]),N=(e,t)=>(e.children===T&&(e.children=[]),e.children.push(t),t.parent=e,t),D=(e,t,n)=>{e.props===O&&(e.props={}),e.props[t]=n},A=(e,t,n)=>{e!==t&&n.push(e)};class W{constructor(e){this.type=e,this.parent=null}toJSON(){return[this.type,this.data]}}class M extends W{constructor(e){super(8),this.data=e}toString(){return`\x3c!--${this.data}--\x3e`}}class L extends W{constructor(e){super(10),this.data=e}toString(){return``}}class j extends W{constructor(e){super(3),this.data=e}toString(){return this.data}}class I extends W{constructor(){super(k),this.name="template",this.props=O,this.children=T}toJSON(){const e=[k];return A(this.props,O,e),A(this.children,T,e),e}toString(){let e="";for(const t in this.props){const n=this.props[t];null!=n&&("boolean"==typeof n?n&&(e+=` ${t}`):e+=` ${t}="${n}"`)}return`${this.children.join("")}`}}class P extends W{constructor(e,t=!1){super(1),this.name=e,this.xml=t,this.props=O,this.children=T}toJSON(){const e=[1,this.name,+this.xml];return A(this.props,O,e),A(this.children,T,e),e}toString(){const{xml:e,name:t,props:n,children:s}=this,{length:i}=s;let r=`<${t}`;for(const t in n){const s=n[t];null!=s&&("boolean"==typeof s?s&&(r+=e?` ${t}=""`:` ${t}`):r+=` ${t}="${s}"`)}if(i){r+=">";for(let n=!e&&C.has(t),o=0;o`}else r+=e?" />":E.has(t)?">":`>`;return r}}class R extends W{constructor(){super(11),this.name="#fragment",this.children=T}toJSON(){const e=[11];return A(this.children,T,e),e}toString(){return this.children.join("")}}const J=e=>(e?.raw||e)?.join?.(",")||"unknown";var _=(e,t,n)=>new SyntaxError(`Mixed text and interpolations found in text only <${t}> element ${JSON.stringify(String(n))} in template ${J(e)}`),F=(e,t)=>new SyntaxError(`The text only <${t}> element requires explicit closing tag in template ${J(e)}`),B=(e,t)=>new SyntaxError(`Unclosed element <${t}> found in template ${J(e)}`),V=e=>new SyntaxError(`Invalid content "new SyntaxError(`Invalid closing tag: new SyntaxError(`Invalid content: NUL char \\x00 found in template: ${J(e)}`),U=e=>new SyntaxError(`Invalid comment: no closing --\x3e found in template ${J(e)}`),q=e=>new SyntaxError(`Too many closing tags found in template ${J(e)}`),G=(e,t)=>new SyntaxError(`Invalid doctype: ${t} found in template ${J(e)}`),K=e=>new SyntaxError(`Invalid template - the amount of values does not match the amount of updates: ${J(e)}`),Q=(e,t)=>new SyntaxError(`Invalid path - unreachable node at the path [${t.join(", ")}] found in template ${J(e)}`),X=(e,t)=>new SyntaxError(`Invalid ${t} attribute in template definition\n${J(e)}`),Y=(e,t)=>new SyntaxError(`Invalid interpolation - expected hole or array: ${String(t)} found in template ${J(e)}`),Z=e=>new SyntaxError(`Invalid key attribute or position in template: ${String(e)}`),ee=e=>new SyntaxError(`Invalid component: ${String(e)}`);const te="\0",ne=`"${te}"`,se=`'${te}'`,ie=/\x00|<[^><\s]+/g,re=/([^\s/>=]+)(?:=(\x00|(?:(['"])[\s\S]*?\3)))?/g,oe=(e,t,n,s,i)=>[t,n,s],le=e=>{const t=[];for(;e.parent;){switch(e.type){case k:case 1:"template"===e.name&&t.push(-1)}t.push(e.parent.children.indexOf(e)),e=e.parent}return t},ae=(e,t)=>{do{e=e.parent}while(t.has(e));return e};const ce=(e,t)=>t<0?e?.content:e?.childNodes?.[t];var ue=(e,t)=>t.reduceRight(ce,e);let fe,de=!1;const he=({firstChild:e,lastChild:t})=>{const n=fe||(fe=document.createRange());return n.setStartAfter(e),n.setEndAfter(t),n.deleteContents(),e},pe=(e,t)=>de&&11===e.nodeType?1/t<0?t?he(e):e.lastChild:t?e.valueOf():e.firstChild:e,ve=Symbol("nodes"),ge={get(){return this.firstChild.parentNode}},me={value(e){he(this).replaceWith(e)}},be={value(){he(this).remove()}},we={value(){const{parentNode:e}=this;if(e===this)this[ve]===T&&(this[ve]=[...this.childNodes]);else{if(e){let{firstChild:e,lastChild:t}=this;for(this[ve]=[e];e!==t;)this[ve].push(e=e.nextSibling)}this.replaceChildren(...this[ve])}return this}};function ye(e){const t=$("<>"),n=$("");return e.replaceChildren(t,...e.childNodes,n),de=!0,w(e,{[ve]:{writable:!0,value:T},firstChild:{value:t},lastChild:{value:n},parentNode:ge,valueOf:we,replaceWith:me,remove:be})}ye.prototype=DocumentFragment.prototype;const xe=16,Se=32768,$e=((e=globalThis.document)=>{let t,n=e.createElement("template");return(s,i=!1)=>{if(i)return t||(t=e.createRange(),t.selectNodeContents(e.createElementNS("http://www.w3.org/2000/svg","svg"))),t.createContextualFragment(s);n.innerHTML=s;const r=n.content;return n=n.cloneNode(!1),r}})(document),ke=Symbol("ref"),Ce=(e,t)=>{for(const[n,s]of y(t)){const t="role"===n?n:`aria-${n.toLowerCase()}`;null==s?e.removeAttribute(t):e.setAttribute(t,s)}},Ee=e=>(t,n)=>{null==n?t.removeAttribute(e):t.setAttribute(e,n)},Oe=(e,t)=>{e[ve]=((e,t,n,s)=>{const i=s.parentNode,r=t.length;let o=e.length,l=r,a=0,c=0,u=null;for(;as-c){const r=n(e[a],0);for(;c{const n="object"==typeof t?t??e:((e,t)=>{let n=Te.get(e);return n?n.data=t:Te.set(e,n=document.createTextNode(t)),n})(e,t),s=e[ve]??e;n!==s&&s.replaceWith(pe(e[ve]=n,1))},De=(e,t)=>{Ne(e,t instanceof g?t.value:t)},Ae=({dataset:e},t)=>{for(const[n,s]of y(t))null==s?delete e[n]:e[n]=s},We=new Map,Me=e=>{let t=We.get(e);return t||We.set(e,t=Le(e)),t},Le=e=>(t,n)=>{t[e]=n},je=(e,t)=>{for(const[n,s]of y(t))Ee(n)(e,s)},Ie=(e,t,n)=>n?(n,s)=>{const i=n[t];i?.length&&n.removeEventListener(e,...i),s&&n.addEventListener(e,...s),n[t]=s}:(n,s)=>{const i=n[t];i&&n.removeEventListener(e,i),s&&n.addEventListener(e,s),n[t]=s},Pe=e=>(t,n)=>{t.toggleAttribute(e,!!n)};let Re=!1;let Je=!0;const _e=e=>{Je=e},Fe=()=>Je,Be=e=>pe(e.n?e.update(e):e.valueOf(!1),1),Ve=(e,t)=>{const n=[],s=e.length,i=t.length;for(let r,o,l=0,a=0;a{n.length;const s=Fe();s&&_e(!s);try{return e(t,Ge)}finally{s&&_e(s)}},He=(e,t)=>(e.t===t.t?e.update(t):(e.n.replaceWith(Be(t)),e=t),e),Ue=(e,t,n)=>{let i,r=[],o=[xe,null,n],l=!0;return function(e){const t={fn:e,subs:void 0,subsTail:void 0,deps:void 0,depsTail:void 0,flags:2};void 0!==u?s(t,u):void 0!==f&&s(t,f);const n=d(t);try{t.fn()}finally{d(n)}p.bind(t)}(()=>{if(l)l=!1,i=ze(t,n,r),r.length||(r=T),i?(e.replaceWith(Be(i)),o[1]=i):e.remove();else{const e=ze(t,n,r);if(i){if(!(e instanceof Ke))throw ee(t);He(i,e)===e&&(o[2]=i=e)}}}),o},qe=Symbol(),Ge={};class Ke{constructor(e,t){this.t=e,this.v=t,this.n=null,this.k=-1}valueOf(e=Fe()){const[t,n,s]=this.t,i=document.importNode(t,!0),r=this.v;let o,l,a,c=r.length,u=T;if(c!==n.length)throw Y(this.t[3],r);if(0{for(const t of e){const e=t[ke];"function"==typeof e?e(t):e instanceof g?e.value=t:e&&(e.current=t)}})(a)}const{childNodes:f}=i,d=f.length,h=1===d?f[0]:d?ye(i):i;return this.v=u,this.n=h,-1e.t[2].get(t)?.update(e)??e.valueOf(!1))(e,s[t]);let{length:i}=n;for(;i--;){const e=n[i],[t,r,o]=e;if(512===t)continue;let l=s[i];if(t&xe)if(t===xe){if("function"!=typeof l)throw ee(l);const t=l(o,Ge);if(r){if(!(t instanceof Ke))throw ee(l);He(r,t)===t&&(e[2]=t)}}else r(o,l);else{let n=l;if(1&t){if(!m(l))throw Y([],l);if(8&t){if(l.length&&l[0]instanceof Ke){if(o.length&&!(o[0]instanceof Ke))throw Y([],l[0]);n=Ve(o,l)}}else if(256&t&&l[0]===o[0])continue}else if(8&t)if(t&Se){if(l===o){r(e[3],n);continue}}else if(o instanceof Ke){if(!(l instanceof Ke))throw Y([],l);l=He(o,l),n=l.n}l!==o&&(e[2]=l,r(e[3],n))}}return this.n}}const Qe=new WeakMap;class Xe extends Map{constructor(){super()._=new FinalizationRegistry(e=>this.delete(e))}get(e){const t=super.get(e)?.deref();return t&&Qe.get(t)}set(e,t,n){Qe.set(t,n),this._.register(t,e),super.set(e,new WeakRef(t))}}const Ye=(({Comment:e=M,DocumentType:t=L,Text:n=j,Fragment:s=R,Element:i=P,Component:r=I,update:o=oe})=>(l,a,c)=>{if(l.some(e=>e.includes(te)))throw H(l);const u=l.join(te).trim();if(u.replace(/(\S+)=(['"])([\S\s]+?)\2/g,(...e)=>/^[^\x00]+\x00|\x00[^\x00]+$/.test(e[3])?c=e[1]:e[0])!==u)throw X(l,c);const f=new Set,d=[];let h=new s,p=0,v=0,g=0,m=T;for(const s of u.matchAll(ie)){if(0",w+2);if(n<0)throw V(l);if("--\x3e"===u.slice(n-2,n+1)){if(n-w<6)throw U(l);const t=u.slice(w+4,n-2);"!"===t[0]&&N(h,new e(t.slice(1).replace(/!$/,"")))}else{if(!u.slice(w+2,n).toLowerCase().startsWith("doctype"))throw G(l,u.slice(w+2,n));N(h,new t(u.slice(w+2,n)))}p=n+1}else if(b.startsWith("",w+2);if(e<0)throw z(l);if(c&&"svg"===h.name&&(c=!1),h=ae(h,f),!h)throw q(l);p=e+1}else{const e=w+b.length,t=u.indexOf(">",e),s=b.slice(1);if(t<0)throw B(l,s);let y=s;if(s===te?(y="template",h=N(h,new r),m=le(h).slice(1),d.push(o(h,k,m,"",a[g++]))):(c||(y=y.toLowerCase(),"table"!==h.name||"tr"!==y&&"td"!==y||(h=N(h,new i("tbody",c)),f.add(h)),"tbody"===h.name&&"td"===y&&(h=N(h,new i("tr",c)),f.add(h))),h=N(h,new i(y,!!c&&"svg"!==y)),m=T),e`,p);if(e<0)throw F(l,y);const t=u.slice(p,e);if(t.trim()===te)v++,d.push(o(h,3,le(h),"",a[g++]));else{if(t.includes(te))throw _(l,y,t);N(h,new n(t))}if(h=h.parent,!h)throw q(l);p=e+s.length+3,v++;continue}}}if(p{switch(t){case k:return[n,i,xe];case 8:return m(i)?[n,Oe,9]:i instanceof S?[n,(r=e.xml,(e,t)=>{const n=e[ke]??(e[ke]={});n.v!==t&&(n.f=ye($e(t,r)),n.v=t),Ne(e,n.f)}),8192]:i instanceof g?[n,De,32776]:[n,Ne,8];case 3:return[n,Me("textContent"),2048];case 2:{const t=e.type===k;switch(s.at(0)){case"@":{if(t)throw X([],s);const e=m(i);return[n,Ie(s.slice(1),Symbol(s),e),e?257:256]}case"?":if(t)throw X([],s);return[n,Pe(s.slice(1)),4096];case".":return"..."===s?[n,t?b:je,t?144:128]:[n,Le(s.slice(1)),t?80:64];default:if(t)return[n,Le(s),1040];if("aria"===s)return[n,Ce,2];if("data"===s&&!/^object$/i.test(e.name))return[n,Ae,32];if("key"===s){if(1(n,...s)=>{let i=t.get(n);return i||(i=Ye(n,s,e),i.push((()=>{const e=Re;return Re=!1,e})()?new Xe:null),i.push(n),i[0]=$e(i[0].toString(),e),t.set(n,i)),new Ke(i,s)},et=Ze(!1),tt=Ze(!0),nt=new WeakMap;function st(e,...t){const n=et.apply(null,arguments);return Fe()?n.valueOf(!0):n}function it(e,...t){const n=tt.apply(null,arguments);return Fe()?n.valueOf(!0):n}const rt=(e,t)=>{const n=nt.get(e);if(n&&n[0](),"function"==typeof t){let i;_e(!1);const r=function(e){const t={deps:void 0,depsTail:void 0,subs:void 0,subsTail:void 0,flags:0};void 0!==f&&s(t,f);const n=d(void 0),i=h(t);try{e()}finally{h(i),d(n)}return p.bind(t)}(()=>{i=t()});if(n&&n[1].t===i.t)n[1].update(i);else{const t=i.valueOf(!1);e.replaceChildren(t)}nt.set(e,[r,i])}else _e(!0),nt.delete(e),e.replaceChildren(t instanceof Ke?Be(t):pe(t,1));return e};function ot(e){for(var t=e[0],n=1,s=arguments.length;n({configurable:!0,get:()=>s,set(r){(e||r!==s||t&&"object"==typeof r&&r)&&(s=r,n?i.call(this,s):i.call(this))}}),ut=()=>{};const ft=(({all:e=!1,shallow:t=!0,useState:n=ut,getAttribute:s=(e,t)=>e.getAttribute(t)}={})=>(i,r,o)=>{const l=((e,t,n,s,i,r)=>{const o={},l=i!==ut,a=[n,s,l];for(let n=at(e),s=0;s{let n=e[t],r=typeof n;return i.hasOwnProperty(t)?(n=i[t],delete i[t]):i.hasAttribute(t)&&(n=s(i,t),"number"==r?n=+n:"boolean"==r&&(n=!/^(?:false|0|)$/.test(n))),n},e,t,n,o);return lt(i,l)})({}),dt=customElements,{define:ht}=dt,{parse:pt,stringify:vt}=JSON,{create:gt,defineProperties:mt,getOwnPropertyDescriptor:bt,keys:wt}=Object,yt="element",xt=new WeakMap,St=($t=new Map([[yt,{c:HTMLElement,e:yt}]]),{get:e=>$t.get(e),set:(e,t)=>($t.set(e,t),t)});var $t;const kt=e=>document.createElement(e),Ct=e=>St.get(e)||St.set(e,{c:kt(e).constructor,e:e}),Et=(e,t)=>{const{attachShadow:n,attributeChanged:s,bound:i,connected:r,disconnected:o,formAssociated:l,handleEvent:a,init:c,observedAttributes:u,props:f,render:d,style:h}=t,p=new WeakMap,v={},g={},m=[],b=gt(null),w=(e,t,s)=>{if(!p.has(e)){p.set(e,0),mt(e,{html:{configurable:!0,value:Tt.bind(n?e.attachShadow(n):e)}});for(let t=0;t'); @@ -12,87 +12,93 @@ globalThis.customElements = customElements; globalThis.HTMLElement = HTMLElement; globalThis.DocumentFragment = DocumentFragment; -const uhtml = require('uhtml'); -const {define, css} = require('../cjs'); - -console.assert(css`1${2}3` === '123', 'css works'); - -define('el-0', {props: {}, attachShadow: {mode: 'open'}}); -define('el-1', {init() {}, style(selector) { return `${selector}{color:green}` }}); -define('el-2', {onClick() {}, ontest() {}, onCamelCase() {}}); -define('el-3', {onClick() {}, onClickOptions: true}); -define('el-4', {props: null, onClick() {}, handleEvent() {}}); -define('el-5', { - props: {test: true}, - attachShadow: {mode: 'open'}, - observedAttributes: ['test'], - attributeChanged() {} -}); -define('el-6', { - observedAttributes: ['test'], - props: {test: true, items}, - bound: ['render'], - constructor() {}, - connected() {}, - disconnected() {}, - render() {} -}); - -define('el-7', {extends: 'div', style(selector) { return `${selector}{color:green}` }}); - -const El1 = customElements.get('el-1'); -const el1 = new El1(document); -el1.connectedCallback(); -el1.attributeChangedCallback(); -el1.setAttribute('test', 123); -console.assert(el1.props.test == 123, 'props working'); - -const El2 = customElements.get('el-2'); -const el2 = new El2(document); -el2.connectedCallback(); -el2.handleEvent({type: 'click'}); -el2.handleEvent({type: 'test'}); -el2.handleEvent({type: 'camelCase'}); - -const El5 = customElements.get('el-5'); -const el5 = new El5(document); -console.assert(el5.test === true, 'defined props working as getter'); -el5.test = false; -console.assert(el5.test === false, 'defined props working as setter'); -el5.attributeChangedCallback('test'); - -const el5b = new El5(document); -el5b.test = false; -console.assert(el5.test === false, 'defined props working as setter'); - -const El6 = customElements.get('el-6'); -const el6 = new El6(document); -console.assert(el6.test === true, 'defined props working as getter'); -el6.test = false; -console.assert(el6.test === false, 'defined props working as setter'); -el6.connectedCallback(); - -const el7 = document.createElement('div', {is: 'el-7'}); -el7.connectedCallback(); -el7.html``; - -el7.innerHTML = ``; -console.assert(el7.firstChild.test === false, 'props over attributes'); -console.assert(el7.firstChild.items !== items, 'props not shared'); -console.assert(el7.firstChild.items.join('') === '', 'props not shared'); - -/* https://github.com/whatwg/html/issues/5552 -((c,w,m)=>{ - m=c[w];c[w]=n=>m.call(c,n).then(()=>c.get(n)); -})(customElements,'whenDefined'); -//*/ -customElements.whenDefined('uce-lib').then( - ({css, html, svg, render, define: udefine} = customElements.get('uce-lib')) => { - console.assert(css`1${2}3` === '123', 'css works'); - console.assert(udefine === define, 'define is OK'); - console.assert(typeof html === 'function', 'html is OK'); - console.assert(typeof svg === 'function', 'svg is OK'); - console.assert(typeof render === 'function', 'render is OK'); - console.log('OK'); - } -); +(async () => { + await import("uhtml"); + const {css, define } = await import('../esm/index.js'); + console.assert(css`1${2}3` === '123', 'css works'); + + define('el-0', {props: {}, attachShadow: {mode: 'open'}}); + define('el-1', {init() {}, style(selector) { return `${selector}{color:green}` }}); + define('el-2', {onClick() {}, ontest() {}, onCamelCase() {}}); + define('el-3', {onClick() {}, onClickOptions: true}); + define('el-4', {props: null, onClick() {}, handleEvent() {}}); + define('el-5', { + props: {test: true}, + attachShadow: {mode: 'open'}, + observedAttributes: ['test'], + attributeChanged() {} + }); + define('el-6', { + observedAttributes: ['test'], + props: {test: true, items}, + bound: ['render'], + constructor() {}, + connected() {}, + disconnected() {}, + render() {} + }); + + define('el-7', {extends: 'div', style(selector) { return `${selector}{color:green}` }}); + define('el-8', {props: {}, formAssociated: true}) + + const El1 = customElements.get('el-1'); + const el1 = new El1(document); + el1.connectedCallback(); + el1.attributeChangedCallback(); + el1.setAttribute('test', 123); + console.assert(el1.props.test == 123, 'props working'); + + const El2 = customElements.get('el-2'); + const el2 = new El2(document); + el2.connectedCallback(); + el2.handleEvent({type: 'click'}); + el2.handleEvent({type: 'test'}); + el2.handleEvent({type: 'camelCase'}); + + const El5 = customElements.get('el-5'); + const el5 = new El5(document); + console.assert(el5.test === true, 'defined props working as getter'); + el5.test = false; + console.assert(el5.test === false, 'defined props working as setter'); + el5.attributeChangedCallback('test'); + + const el5b = new El5(document); + el5b.test = false; + console.assert(el5.test === false, 'defined props working as setter'); + + const El6 = customElements.get('el-6'); + const el6 = new El6(document); + console.assert(el6.test === true, 'defined props working as getter'); + el6.test = false; + console.assert(el6.test === false, 'defined props working as setter'); + el6.connectedCallback(); + + const el7 = document.createElement('div', {is: 'el-7'}); + el7.connectedCallback(); + el7.html``; + + el7.innerHTML = ``; + console.assert(el7.firstChild.test === false, 'props over attributes'); + console.assert(el7.firstChild.items !== items, 'props not shared'); + console.assert(el7.firstChild.items.join('') === '', 'props not shared'); + + const e18 = document.createElement("el-8"); + console.assert(e18.formAssociated === true) + + /* https://github.com/whatwg/html/issues/5552 + ((c,w,m)=>{ + m=c[w];c[w]=n=>m.call(c,n).then(()=>c.get(n)); + })(customElements,'whenDefined'); + //*/ + customElements.whenDefined('uce-lib').then( + ({css, html, svg, render, define: udefine} = customElements.get('uce-lib')) => { + console.assert(css`1${2}3` === '123', 'css works'); + console.assert(udefine === define, 'define is OK'); + console.assert(typeof html === 'function', 'html is OK'); + console.assert(typeof svg === 'function', 'svg is OK'); + console.assert(typeof render === 'function', 'render is OK'); + console.log('OK'); + } + ); +})(); + diff --git a/test/package.json b/test/package.json index 0292b99..7c34deb 100644 --- a/test/package.json +++ b/test/package.json @@ -1 +1 @@ -{"type":"commonjs"} \ No newline at end of file +{"type":"module"} \ No newline at end of file From c15299d9d55c79b79da26deee0ade878f4d4c977 Mon Sep 17 00:00:00 2001 From: Keven McDowell <36285281+kpmcdowellmo@users.noreply.github.com> Date: Wed, 10 Dec 2025 20:27:23 -0600 Subject: [PATCH 3/3] Add exports from uhtml5 - Exports new signal utilities, etc from uhtml 5 from uce --- esm/index.js | 4 +- index.js | 3000 ++++++++++++++++++++------------------------------ min.js | 2 +- new.js | 2 +- 4 files changed, 1171 insertions(+), 1837 deletions(-) diff --git a/esm/index.js b/esm/index.js index ba0125a..658532e 100644 --- a/esm/index.js +++ b/esm/index.js @@ -1,4 +1,4 @@ -import {render, html, svg} from 'uhtml/dom'; +import {render, html, svg, unsafe, Hole, signal, computed, effect, untracked, batch, fragment} from 'uhtml'; import umap from 'umap'; import css from 'plain-tag'; @@ -170,7 +170,7 @@ const define = (tagName, definition) => { return MicroElement; }; -export {define, render, html, svg, css}; +export {define, render, html, svg, css, unsafe, Hole, signal, computed, effect, untracked, batch, fragment}; /* istanbul ignore else */ if (!CE.get('uce-lib')) diff --git a/index.js b/index.js index b236936..bdf5d15 100644 --- a/index.js +++ b/index.js @@ -79,11 +79,106 @@ var uce = (function (exports) { }), e && _setPrototypeOf(t, e); } - var DEBUG = true; + function _isNativeFunction(t) { + try { + return -1 !== Function.toString.call(t).indexOf("[native code]"); + } catch (n) { + return "function" == typeof t; + } + } - function _superPropBase(t, o) { - for (; !{}.hasOwnProperty.call(t, o) && null !== (t = _getPrototypeOf(t));); - return t; + function _isNativeReflectConstruct$2() { + try { + var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); + } catch (t) {} + return (_isNativeReflectConstruct$2 = function _isNativeReflectConstruct() { + return !!t; + })(); + } + + function _construct(t, e, r) { + if (_isNativeReflectConstruct$2()) return Reflect.construct.apply(null, arguments); + var o = [null]; + o.push.apply(o, e); + var p = new (t.bind.apply(t, o))(); + return r && _setPrototypeOf(p, r.prototype), p; + } + + function _wrapNativeSuper(t) { + var r = "function" == typeof Map ? new Map() : void 0; + return _wrapNativeSuper = function _wrapNativeSuper(t) { + if (null === t || !_isNativeFunction(t)) return t; + if ("function" != typeof t) throw new TypeError("Super expression must either be null or a function"); + if (void 0 !== r) { + if (r.has(t)) return r.get(t); + r.set(t, Wrapper); + } + function Wrapper() { + return _construct(t, arguments, _getPrototypeOf(this).constructor); + } + return Wrapper.prototype = Object.create(t.prototype, { + constructor: { + value: Wrapper, + enumerable: false, + writable: true, + configurable: true + } + }), _setPrototypeOf(Wrapper, t); + }, _wrapNativeSuper(t); + } + + function _arrayWithHoles(r) { + if (Array.isArray(r)) return r; + } + + function _iterableToArrayLimit(r, l) { + var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; + if (null != t) { + var e, + n, + i, + u, + a = [], + f = true, + o = false; + try { + if (i = (t = t.call(r)).next, 0 === l) { + if (Object(t) !== t) return; + f = !1; + } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); + } catch (r) { + o = true, n = r; + } finally { + try { + if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; + } finally { + if (o) throw n; + } + } + return a; + } + } + + function _arrayLikeToArray$1(r, a) { + (null == a || a > r.length) && (a = r.length); + for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; + return n; + } + + function _unsupportedIterableToArray$1(r, a) { + if (r) { + if ("string" == typeof r) return _arrayLikeToArray$1(r, a); + var t = {}.toString.call(r).slice(8, -1); + return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$1(r, a) : void 0; + } + } + + function _nonIterableRest() { + throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); + } + + function _slicedToArray(r, e) { + return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray$1(r, e) || _nonIterableRest(); } function _defineProperty(e, r, t) { @@ -95,437 +190,396 @@ var uce = (function (exports) { }) : e[r] = t, e; } - function _get$1() { - return _get$1 = "undefined" != typeof Reflect && Reflect.get ? Reflect.get.bind() : function (e, t, r) { + function _arrayWithoutHoles(r) { + if (Array.isArray(r)) return _arrayLikeToArray$1(r); + } + + function _iterableToArray(r) { + if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); + } + + function _nonIterableSpread() { + throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); + } + + function _toConsumableArray(r) { + return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray$1(r) || _nonIterableSpread(); + } + + function _superPropBase(t, o) { + for (; !{}.hasOwnProperty.call(t, o) && null !== (t = _getPrototypeOf(t));); + return t; + } + + function set(e, r, t, o) { + return set = "undefined" != typeof Reflect && Reflect.set ? Reflect.set : function (e, r, t, o) { + var f, + i = _superPropBase(e, r); + if (i) { + if ((f = Object.getOwnPropertyDescriptor(i, r)).set) return f.set.call(o, t), true; + if (!f.writable) return false; + } + if (f = Object.getOwnPropertyDescriptor(o, r)) { + if (!f.writable) return false; + f.value = t, Object.defineProperty(o, r, f); + } else _defineProperty(o, r, t); + return true; + }, set(e, r, t, o); + } + function _set(e, r, t, o, f) { + if (!set(e, r, t, o || e) && f) throw new TypeError("failed to set property"); + return t; + } + + function _get() { + return _get = "undefined" != typeof Reflect && Reflect.get ? Reflect.get.bind() : function (e, t, r) { var p = _superPropBase(e, t); if (p) { var n = Object.getOwnPropertyDescriptor(p, t); return n.get ? n.get.call(arguments.length < 3 ? e : r) : n.value; } - }, _get$1.apply(null, arguments); + }, _get.apply(null, arguments); } - var ReactiveFlags; - (function (ReactiveFlags) { - ReactiveFlags[ReactiveFlags["None"] = 0] = "None"; - ReactiveFlags[ReactiveFlags["Mutable"] = 1] = "Mutable"; - ReactiveFlags[ReactiveFlags["Watching"] = 2] = "Watching"; - ReactiveFlags[ReactiveFlags["RecursedCheck"] = 4] = "RecursedCheck"; - ReactiveFlags[ReactiveFlags["Recursed"] = 8] = "Recursed"; - ReactiveFlags[ReactiveFlags["Dirty"] = 16] = "Dirty"; - ReactiveFlags[ReactiveFlags["Pending"] = 32] = "Pending"; - })(ReactiveFlags || (ReactiveFlags = {})); - function createReactiveSystem(_ref) { - var update = _ref.update, - notify = _ref.notify, - unwatched = _ref.unwatched; - var currentVersion = 0; - return { - link: link, - unlink: unlink, - propagate: propagate, - checkDirty: checkDirty, - endTracking: endTracking, - startTracking: startTracking, - shallowPropagate: shallowPropagate - }; - function link(dep, sub) { - var prevDep = sub.depsTail; - if (prevDep !== undefined && prevDep.dep === dep) { - return; - } - var nextDep = prevDep !== undefined ? prevDep.nextDep : sub.deps; - if (nextDep !== undefined && nextDep.dep === dep) { - nextDep.version = currentVersion; - sub.depsTail = nextDep; - return; - } - var prevSub = dep.subsTail; - if (prevSub !== undefined && prevSub.version === currentVersion && prevSub.sub === sub) { - return; - } - var newLink = sub.depsTail = dep.subsTail = { - version: currentVersion, - dep: dep, - sub: sub, - prevDep: prevDep, - nextDep: nextDep, - prevSub: prevSub, - nextSub: undefined - }; - if (nextDep !== undefined) { - nextDep.prevDep = newLink; - } - if (prevDep !== undefined) { - prevDep.nextDep = newLink; - } else { - sub.deps = newLink; - } - if (prevSub !== undefined) { - prevSub.nextSub = newLink; - } else { - dep.subs = newLink; - } - } - function unlink(link) { - var sub = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : link.sub; - var dep = link.dep; - var prevDep = link.prevDep; - var nextDep = link.nextDep; - var nextSub = link.nextSub; - var prevSub = link.prevSub; - if (nextDep !== undefined) { - nextDep.prevDep = prevDep; - } else { - sub.depsTail = prevDep; - } - if (prevDep !== undefined) { - prevDep.nextDep = nextDep; - } else { - sub.deps = nextDep; - } - if (nextSub !== undefined) { - nextSub.prevSub = prevSub; - } else { - dep.subsTail = prevSub; - } - if (prevSub !== undefined) { - prevSub.nextSub = nextSub; - } else if ((dep.subs = nextSub) === undefined) { - unwatched(dep); - } - return nextDep; - } - function propagate(link) { - var next = link.nextSub; - var stack; - top: do { - var sub = link.sub; - var flags = sub.flags; - if (!(flags & 60)) { - sub.flags = flags | 32; - } else if (!(flags & 12)) { - flags = 0; - } else if (!(flags & 4)) { - sub.flags = flags & -9 | 32; - } else if (!(flags & 48) && isValidLink(link, sub)) { - sub.flags = flags | 40; - flags &= 1; - } else { - flags = 0; - } - if (flags & 2) { - notify(sub); - } - if (flags & 1) { - var subSubs = sub.subs; - if (subSubs !== undefined) { - var nextSub = (link = subSubs).nextSub; - if (nextSub !== undefined) { - stack = { - value: next, - prev: stack - }; - next = nextSub; + function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e) { t && (r = t); var _n1 = 0, F = function F() {}; return { s: F, n: function n() { return _n1 >= r.length ? { done: true } : { done: false, value: r[_n1++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = true, u = false; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = true, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; } + function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } } + function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; } + function _classPrivateFieldInitSpec(e, t, a) { _checkPrivateRedeclaration(e, t), t.set(e, a); } + function _checkPrivateRedeclaration(e, t) { if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object"); } + function _classPrivateFieldGet(s, a) { return s.get(_assertClassBrand(s, a)); } + function _classPrivateFieldSet(s, a, r) { return s.set(_assertClassBrand(s, a), r), r; } + function _assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n; throw new TypeError("Private element is not present on this object"); } + function _superPropSet(t, e, o, r, p, f) { return _set(_getPrototypeOf(t.prototype ), e, o, r, p); } + function _superPropGet(t, o, e, r) { var p = _get(_getPrototypeOf(1 & r ? t.prototype : t), o, e); return 2 & r && "function" == typeof p ? function (t) { return p.apply(e, t); } : p; } + function _callSuper$1(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct$1() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); } + function _isNativeReflectConstruct$1() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct$1 = function _isNativeReflectConstruct() { return !!t; })(); } + var e; + !function (e) { + e[e.None = 0] = "None", e[e.Mutable = 1] = "Mutable", e[e.Watching = 2] = "Watching", e[e.RecursedCheck = 4] = "RecursedCheck", e[e.Recursed = 8] = "Recursed", e[e.Dirty = 16] = "Dirty", e[e.Pending = 32] = "Pending"; + }(e || (e = {})); + var t = [], + n = [], + _ref = function (_ref2) { + var e = _ref2.update, + t = _ref2.notify, + n = _ref2.unwatched; + var s = 0; + return { + link: function link(e, t) { + var n = t.depsTail; + if (void 0 !== n && n.dep === e) return; + var i; + if (4 & t.flags && (i = void 0 !== n ? n.nextDep : t.deps, void 0 !== i && i.dep === e)) return i.version = s, void (t.depsTail = i); + var r = e.subsTail; + if (void 0 !== r && r.version === s && r.sub === t) return; + var o = t.depsTail = e.subsTail = { + version: s, + dep: e, + sub: t, + prevDep: n, + nextDep: i, + prevSub: r, + nextSub: void 0 + }; + void 0 !== i && (i.prevDep = o); + void 0 !== n ? n.nextDep = o : t.deps = o; + void 0 !== r ? r.nextSub = o : e.subs = o; + }, + unlink: i, + propagate: function propagate(e) { + var n, + s = e.nextSub; + e: for (;;) { + var _i = e.sub; + var _r = _i.flags; + if (3 & _r && (60 & _r ? 12 & _r ? 4 & _r ? 48 & _r || !o(e, _i) ? _r = 0 : (_i.flags = 40 | _r, _r &= 1) : _i.flags = -9 & _r | 32 : _r = 0 : _i.flags = 32 | _r, 2 & _r && t(_i), 1 & _r)) { + var _t = _i.subs; + if (void 0 !== _t) { + e = _t, void 0 !== _t.nextSub && (n = { + value: s, + prev: n + }, s = e.nextSub); + continue; + } } - continue; - } - } - if ((link = next) !== undefined) { - next = link.nextSub; - continue; - } - while (stack !== undefined) { - link = stack.value; - stack = stack.prev; - if (link !== undefined) { - next = link.nextSub; - continue top; - } - } - break; - } while (true); - } - function startTracking(sub) { - ++currentVersion; - sub.depsTail = undefined; - sub.flags = sub.flags & -57 | 4; - } - function endTracking(sub) { - var depsTail = sub.depsTail; - var toRemove = depsTail !== undefined ? depsTail.nextDep : sub.deps; - while (toRemove !== undefined) { - toRemove = unlink(toRemove, sub); - } - sub.flags &= -5; - } - function checkDirty(link, sub) { - var stack; - var checkDepth = 0; - var dirty = false; - top: do { - var dep = link.dep; - var flags = dep.flags; - if (sub.flags & 16) { - dirty = true; - } else if ((flags & 17) === 17) { - if (update(dep)) { - var subs = dep.subs; - if (subs.nextSub !== undefined) { - shallowPropagate(subs); + if (void 0 === (e = s)) { + for (; void 0 !== n;) if (e = n.value, n = n.prev, void 0 !== e) { + s = e.nextSub; + continue e; + } + break; } - dirty = true; - } - } else if ((flags & 33) === 33) { - if (link.nextSub !== undefined || link.prevSub !== undefined) { - stack = { - value: link, - prev: stack - }; - } - link = dep.deps; - sub = dep; - ++checkDepth; - continue; - } - if (!dirty) { - var nextDep = link.nextDep; - if (nextDep !== undefined) { - link = nextDep; - continue; - } - } - while (checkDepth--) { - var firstSub = sub.subs; - var hasMultipleSubs = firstSub.nextSub !== undefined; - if (hasMultipleSubs) { - link = stack.value; - stack = stack.prev; - } else { - link = firstSub; + s = e.nextSub; } - if (dirty) { - if (update(sub)) { - if (hasMultipleSubs) { - shallowPropagate(firstSub); + }, + checkDirty: function checkDirty(t, n) { + var s, + i = 0; + e: for (;;) { + var _o = t.dep, + _l = _o.flags; + var _a = false; + if (16 & n.flags) _a = true;else if (17 & ~_l) { + if (!(33 & ~_l)) { + void 0 === t.nextSub && void 0 === t.prevSub || (s = { + value: t, + prev: s + }), t = _o.deps, n = _o, ++i; + continue; } - sub = link.sub; - continue; + } else if (e(_o)) { + var _e2 = _o.subs; + void 0 !== _e2.nextSub && r(_e2), _a = true; } - dirty = false; - } else { - sub.flags &= -33; - } - sub = link.sub; - var _nextDep = link.nextDep; - if (_nextDep !== undefined) { - link = _nextDep; - continue top; - } - } - return dirty; - } while (true); - } - function shallowPropagate(link) { - do { - var sub = link.sub; - var flags = sub.flags; - if ((flags & 48) === 32) { - sub.flags = flags | 16; - if (flags & 2) { - notify(sub); + if (_a || void 0 === t.nextDep) { + for (; i;) { + --i; + var _o2 = n.subs, + _l2 = void 0 !== _o2.nextSub; + if (_l2 ? (t = s.value, s = s.prev) : t = _o2, _a) { + if (e(n)) { + _l2 && r(_o2), n = t.sub; + continue; + } + } else n.flags &= -33; + if (n = t.sub, void 0 !== t.nextDep) { + t = t.nextDep; + continue e; + } + _a = false; + } + return _a; + } + t = t.nextDep; } + }, + endTracking: function endTracking(e) { + var t = e.depsTail; + var n = void 0 !== t ? t.nextDep : e.deps; + for (; void 0 !== n;) n = i(n, e); + e.flags &= -5; + }, + startTracking: function startTracking(e) { + ++s, e.depsTail = void 0, e.flags = -57 & e.flags | 4; + }, + shallowPropagate: r + }; + function i(e) { + var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : e.sub; + var s = e.dep, + i = e.prevDep, + r = e.nextDep, + o = e.nextSub, + l = e.prevSub; + return void 0 !== r ? r.prevDep = i : t.depsTail = i, void 0 !== i ? i.nextDep = r : t.deps = r, void 0 !== o ? o.prevSub = l : s.subsTail = l, void 0 !== l ? l.nextSub = o : void 0 === (s.subs = o) && n(s), r; + } + function r(e) { + do { + var _n = e.sub, + _s = e.nextSub, + _i2 = _n.flags; + 32 == (48 & _i2) && (_n.flags = 16 | _i2, 2 & _i2 && t(_n)), e = _s; + } while (void 0 !== e); + } + function o(e, t) { + var n = t.depsTail; + if (void 0 !== n) { + var _s2 = t.deps; + do { + if (_s2 === e) return true; + if (_s2 === n) break; + _s2 = _s2.nextDep; + } while (void 0 !== _s2); } - } while ((link = link.nextSub) !== undefined); - } - function isValidLink(checkLink, sub) { - var link = sub.depsTail; - while (link !== undefined) { - if (link === checkLink) { - return true; - } - link = link.prevDep; + return false; } - return false; - } - } - - var pauseStack = []; - var _createReactiveSystem = createReactiveSystem({ - update: function update(signal) { - if ('getter' in signal) { - return updateComputed(signal); - } else { - return updateSignal(signal, signal.value); + }({ + update: function update(e) { + return "getter" in e ? y(e) : w(e, e.value); + }, + notify: function e(t) { + var s = t.flags; + if (!(64 & s)) { + t.flags = 64 | s; + var _i3 = t.subs; + void 0 !== _i3 ? e(_i3.sub) : n[h++] = t; } }, - notify: notify, - unwatched: function unwatched(node) { - if ('getter' in node) { - var toRemove = node.deps; - if (toRemove !== undefined) { - node.flags = 17; + unwatched: function unwatched(e) { + if ("getter" in e) { + var _t2 = e.deps; + if (void 0 !== _t2) { + e.flags = 17; do { - toRemove = unlink(toRemove, node); - } while (toRemove !== undefined); + _t2 = i(_t2, e); + } while (void 0 !== _t2); } - } else if (!('previousValue' in node)) { - effectOper.call(node); - } + } else "previousValue" in e || D.call(e); } }), - link = _createReactiveSystem.link, - unlink = _createReactiveSystem.unlink; - _createReactiveSystem.propagate; - _createReactiveSystem.checkDirty; - var endTracking = _createReactiveSystem.endTracking, - startTracking = _createReactiveSystem.startTracking; - _createReactiveSystem.shallowPropagate; - var activeSub; - var activeScope; - function setCurrentSub(sub) { - var prevSub = activeSub; - activeSub = sub; - return prevSub; + s = _ref.link, + i = _ref.unlink, + r = _ref.propagate, + o = _ref.checkDirty, + l = _ref.endTracking, + a = _ref.startTracking, + c = _ref.shallowPropagate; + var u, + d, + f = 0, + p = 0, + h = 0; + function v(e) { + var t = u; + return u = e, t; } - function setCurrentScope(scope) { - var prevScope = activeScope; - activeScope = scope; - return prevScope; + function g(e) { + var t = d; + return d = e, t; } - function pauseTracking() { - pauseStack.push(setCurrentSub(undefined)); + function b(e) { + return T.bind({ + previousValue: e, + value: e, + subs: void 0, + subsTail: void 0, + flags: 1 + }); } - function resumeTracking() { - setCurrentSub(pauseStack.pop()); + function m(e) { + return C.bind({ + value: void 0, + subs: void 0, + subsTail: void 0, + deps: void 0, + depsTail: void 0, + flags: 17, + getter: e + }); } - function effect(fn) { - var e = { - fn: fn, - subs: undefined, - subsTail: undefined, - deps: undefined, - depsTail: undefined, + function x(e) { + var t = { + fn: e, + subs: void 0, + subsTail: void 0, + deps: void 0, + depsTail: void 0, flags: 2 }; - if (activeSub !== undefined) { - link(e, activeSub); - } else if (activeScope !== undefined) { - link(e, activeScope); - } - var prev = setCurrentSub(e); - try { - e.fn(); - } finally { - setCurrentSub(prev); - } - return effectOper.bind(e); - } - function effectScope(fn) { - var e = { - deps: undefined, - depsTail: undefined, - subs: undefined, - subsTail: undefined, - flags: 0 - }; - if (activeScope !== undefined) { - link(e, activeScope); - } - var prevSub = setCurrentSub(undefined); - var prevScope = setCurrentScope(e); + void 0 !== u ? s(t, u) : void 0 !== d && s(t, d); + var n = v(t); try { - fn(); + t.fn(); } finally { - setCurrentScope(prevScope); - setCurrentSub(prevSub); + v(n); } - return effectOper.bind(e); + return D.bind(t); } - function updateComputed(c) { - var prevSub = setCurrentSub(c); - startTracking(c); + function y(e) { + var t = v(e); + a(e); try { - var oldValue = c.value; - return oldValue !== (c.value = c.getter(oldValue)); + var _t3 = e.value; + return _t3 !== (e.value = e.getter(_t3)); } finally { - setCurrentSub(prevSub); - endTracking(c); + v(t), l(e); } } - function updateSignal(s, value) { - s.flags = 1; - return s.previousValue !== (s.previousValue = value); + function w(e, t) { + return e.flags = 1, e.previousValue !== (e.previousValue = t); } - function notify(e) { - var flags = e.flags; - if (!(flags & 64)) { - e.flags = flags | 64; - var subs = e.subs; - if (subs !== undefined) { - notify(subs.sub); + function S(e, t) { + if (16 & t || 32 & t && o(e.deps, e)) { + var _t4 = v(e); + a(e); + try { + e.fn(); + } finally { + v(_t4), l(e); } + return; } - } - function effectOper() { - var dep = this.deps; - while (dep !== undefined) { - dep = unlink(dep, this); + 32 & t && (e.flags = -33 & t); + var n = e.deps; + for (; void 0 !== n;) { + var _e3 = n.dep, + _t5 = _e3.flags; + 64 & _t5 && S(_e3, _e3.flags = -65 & _t5), n = n.nextDep; } - var sub = this.subs; - if (sub !== undefined) { - unlink(sub); + } + function k() { + for (; p < h;) { + var _e4 = n[p]; + n[p++] = void 0, S(_e4, _e4.flags &= -65); } - this.flags = 0; + p = 0, h = 0; } - - /** - * @template T - * @param {function(): T} fn - * @returns {T} - */ - var untracked = function untracked(fn) { - pauseTracking(); - try { - return fn(); - } finally { - resumeTracking(); + function C() { + var e = this.flags; + if (16 & e || 32 & e && o(this.deps, this)) { + if (y(this)) { + var _e5 = this.subs; + void 0 !== _e5 && c(_e5); + } + } else 32 & e && (this.flags = -33 & e); + return void 0 !== u ? s(this, u) : void 0 !== d && s(this, d), this.value; + } + function T() { + if (!arguments.length) { + var _e6 = this.value; + if (16 & this.flags && w(this, _e6)) { + var _e7 = this.subs; + void 0 !== _e7 && c(_e7); + } + return void 0 !== u && s(this, u), _e6; } - }; - - /** - * @template T - */ - var Signal = /*#__PURE__*/function () { - /** - * @param {(value: T) => T} fn - * @param {T} value - */ - function Signal(fn, value) { - _classCallCheck(this, Signal); - this._ = fn(value); + { + var _t6 = arguments.length <= 0 ? undefined : arguments[0]; + if (this.value !== (this.value = _t6)) { + this.flags = 17; + var _e8 = this.subs; + void 0 !== _e8 && (r(_e8), f || k()); + } } - - /** @returns {T} */ - return _createClass(Signal, [{ + } + function D() { + var e = this.deps; + for (; void 0 !== e;) e = i(e, this); + var t = this.subs; + void 0 !== t && i(t), this.flags = 0; + } + var O = { + greedy: false + }, + N = function N(e) { + return new A(e); + }, + $ = function $(e) { + t.push(v(void 0)); + try { + return e(); + } finally { + v(t.pop()); + } + }; + var W = /*#__PURE__*/function () { + function W(e, t) { + _classCallCheck(this, W); + this._ = e(t); + } + return _createClass(W, [{ key: "value", get: function get() { return this._(); + }, + set: function set(e) { + this._(e); } - - /** @param {T} value */, - set: function set(value) { - this._(value); - } - - /** @returns {T} */ }, { key: "peek", value: function peek() { - return untracked(this._); + return $(this._); } - - /** @returns {T} */ }, { key: "valueOf", value: function valueOf() { @@ -533,1589 +587,861 @@ var uce = (function (exports) { } }]); }(); - - function _classPrivateFieldInitSpec(e, t, a) { _checkPrivateRedeclaration(e, t), t.set(e, a); } - function _checkPrivateRedeclaration(e, t) { if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object"); } - function _classPrivateFieldGet(s, a) { return s.get(_assertClassBrand(s, a)); } - function _classPrivateFieldSet(s, a, r) { return s.set(_assertClassBrand(s, a), r), r; } - function _assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n; throw new TypeError("Private element is not present on this object"); } - var isArray = Array.isArray; - var assign = Object.assign, - defineProperties$2 = Object.defineProperties, - entries = Object.entries, - freeze = Object.freeze; - var _data = /*#__PURE__*/new WeakMap(); - var Unsafe = /*#__PURE__*/function () { - function Unsafe(data) { - _classCallCheck(this, Unsafe); - _classPrivateFieldInitSpec(this, _data, void 0); - _classPrivateFieldSet(_data, this, data); + var A = /*#__PURE__*/function (_W) { + function A(e) { + _classCallCheck(this, A); + return _callSuper$1(this, A, [m, e]); + } + _inherits(A, _W); + return _createClass(A, [{ + key: "value", + get: function get() { + return this._(); + }, + set: function set(e) { + throw new Error("Computed values are read-only"); + } + }]); + }(W); + var E = /*#__PURE__*/function (_W2) { + function E(e) { + _classCallCheck(this, E); + return _callSuper$1(this, E, [b, [e]]); + } + _inherits(E, _W2); + return _createClass(E, [{ + key: "value", + get: function get() { + return _superPropGet(E, "value", this, 1)[0]; + }, + set: function set(e) { + _superPropSet(E, "value", [e], this, 1); + } + }, { + key: "peek", + value: function peek() { + return _superPropGet(E, "peek", this, 3)([])[0]; + } + }]); + }(W); + var M = function M(e) { + ++f; + try { + return e(); + } finally { + --f || k(); + } + }; + var R = function R(e) { + var _ref3 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : O, + _ref3$greedy = _ref3.greedy, + t = _ref3$greedy === void 0 ? false : _ref3$greedy; + return t ? new E(e) : new W(b, e); + }; + function L() { + return R.apply(null, arguments); + } + var _ = function _(e) { + R = e; + }, + j = Array.isArray, + F = Object.assign, + P = Object.defineProperties, + B = Object.entries, + J = Object.freeze; + var _e9 = /*#__PURE__*/new WeakMap(); + var V = /*#__PURE__*/function () { + function V(e) { + _classCallCheck(this, V); + _classPrivateFieldInitSpec(this, _e9, void 0); + _classPrivateFieldSet(_e9, this, e); } - return _createClass(Unsafe, [{ + return _createClass(V, [{ key: "valueOf", value: function valueOf() { - return _classPrivateFieldGet(_data, this); + return _classPrivateFieldGet(_e9, this); } }, { key: "toString", value: function toString() { - return String(_classPrivateFieldGet(_data, this)); + return String(_classPrivateFieldGet(_e9, this)); } }]); }(); - var createComment = function createComment(value) { - return document.createComment(value); - }; - /* c8 ignore stop */ - - function _callSuper$2(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct$3() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); } - function _isNativeReflectConstruct$3() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct$3 = function _isNativeReflectConstruct() { return !!t; })(); } - var ELEMENT = 1; - var ATTRIBUTE$1 = 2; - var TEXT$1 = 3; - var COMMENT$1 = 8; - var DOCUMENT_TYPE = 10; - var FRAGMENT = 11; - var COMPONENT$1 = 42; - var TEXT_ELEMENTS = new Set(['plaintext', 'script', 'style', 'textarea', 'title', 'xmp']); - var VOID_ELEMENTS = new Set(['area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'keygen', 'link', 'menuitem', 'meta', 'param', 'source', 'track', 'wbr']); - var props$1 = freeze({}); - var children = freeze([]); - var append = function append(node, child) { - if (node.children === children) node.children = []; - node.children.push(child); - child.parent = node; - return child; - }; - var prop = function prop(node, name, value) { - if (node.props === props$1) node.props = {}; - node.props[name] = value; - }; - var addJSON = function addJSON(value, comp, json) { - if (value !== comp) json.push(value); - }; - var Node = /*#__PURE__*/function () { - function Node(type) { - _classCallCheck(this, Node); - this.type = type; - this.parent = null; + var z = function z(e) { + return new V(e); + }, + H = function H(e) { + return document.createComment(e); + }, + q = 42, + G = new Set(["plaintext", "script", "style", "textarea", "title", "xmp"]), + I = new Set(["area", "base", "br", "col", "embed", "hr", "img", "input", "keygen", "link", "menuitem", "meta", "param", "source", "track", "wbr"]), + K = J({}), + Q = J([]), + U = function U(e, t) { + return e.children === Q && (e.children = []), e.children.push(t), t.parent = e, t; + }, + X = function X(e, t, n) { + e.props === K && (e.props = {}), e.props[t] = n; + }, + Y = function Y(e, t, n) { + e !== t && n.push(e); + }; + var Z = /*#__PURE__*/function () { + function Z(e) { + _classCallCheck(this, Z); + this.type = e, this.parent = null; } - return _createClass(Node, [{ + return _createClass(Z, [{ key: "toJSON", value: function toJSON() { - //@ts-ignore return [this.type, this.data]; } }]); }(); - var Comment = /*#__PURE__*/function (_Node) { - function Comment(data) { + var ee = /*#__PURE__*/function (_Z) { + function ee(e) { var _this; - _classCallCheck(this, Comment); - _this = _callSuper$2(this, Comment, [COMMENT$1]); - _this.data = data; + _classCallCheck(this, ee); + _this = _callSuper$1(this, ee, [8]), _this.data = e; return _this; } - _inherits(Comment, _Node); - return _createClass(Comment, [{ + _inherits(ee, _Z); + return _createClass(ee, [{ key: "toString", value: function toString() { return ""); } }]); - }(Node); - var DocumentType = /*#__PURE__*/function (_Node2) { - function DocumentType(data) { + }(Z); + var te = /*#__PURE__*/function (_Z2) { + function te(e) { var _this2; - _classCallCheck(this, DocumentType); - _this2 = _callSuper$2(this, DocumentType, [DOCUMENT_TYPE]); - _this2.data = data; + _classCallCheck(this, te); + _this2 = _callSuper$1(this, te, [10]), _this2.data = e; return _this2; } - _inherits(DocumentType, _Node2); - return _createClass(DocumentType, [{ + _inherits(te, _Z2); + return _createClass(te, [{ key: "toString", value: function toString() { return ""); } }]); - }(Node); - var Text = /*#__PURE__*/function (_Node3) { - function Text(data) { + }(Z); + var ne = /*#__PURE__*/function (_Z3) { + function ne(e) { var _this3; - _classCallCheck(this, Text); - _this3 = _callSuper$2(this, Text, [TEXT$1]); - _this3.data = data; + _classCallCheck(this, ne); + _this3 = _callSuper$1(this, ne, [3]), _this3.data = e; return _this3; } - _inherits(Text, _Node3); - return _createClass(Text, [{ + _inherits(ne, _Z3); + return _createClass(ne, [{ key: "toString", value: function toString() { return this.data; } }]); - }(Node); - var Component = /*#__PURE__*/function (_Node4) { - function Component() { + }(Z); + var se = /*#__PURE__*/function (_Z4) { + function se() { var _this4; - _classCallCheck(this, Component); - _this4 = _callSuper$2(this, Component, [COMPONENT$1]); - _this4.name = 'template'; - _this4.props = props$1; - _this4.children = children; + _classCallCheck(this, se); + _this4 = _callSuper$1(this, se, [q]), _this4.name = "template", _this4.props = K, _this4.children = Q; return _this4; } - _inherits(Component, _Node4); - return _createClass(Component, [{ + _inherits(se, _Z4); + return _createClass(se, [{ key: "toJSON", value: function toJSON() { - var json = [COMPONENT$1]; - addJSON(this.props, props$1, json); - addJSON(this.children, children, json); - return json; + var e = [q]; + return Y(this.props, K, e), Y(this.children, Q, e), e; } }, { key: "toString", value: function toString() { - var attrs = ''; - for (var key in this.props) { - var value = this.props[key]; - if (value != null) { - /* c8 ignore start */ - if (typeof value === 'boolean') { - if (value) attrs += " ".concat(key); - } else attrs += " ".concat(key, "=\"").concat(value, "\""); - /* c8 ignore stop */ - } + var e = ""; + for (var _t7 in this.props) { + var _n2 = this.props[_t7]; + null != _n2 && ("boolean" == typeof _n2 ? _n2 && (e += " ".concat(_t7)) : e += " ".concat(_t7, "=\"").concat(_n2, "\"")); } - return "").concat(this.children.join(''), ""); + return "").concat(this.children.join(""), ""); } }]); - }(Node); - var Element = /*#__PURE__*/function (_Node5) { - function Element(name) { + }(Z); + var ie = /*#__PURE__*/function (_Z5) { + function ie(e) { var _this5; - var xml = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; - _classCallCheck(this, Element); - _this5 = _callSuper$2(this, Element, [ELEMENT]); - _this5.name = name; - _this5.xml = xml; - _this5.props = props$1; - _this5.children = children; + var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; + _classCallCheck(this, ie); + _this5 = _callSuper$1(this, ie, [1]), _this5.name = e, _this5.xml = t, _this5.props = K, _this5.children = Q; return _this5; } - _inherits(Element, _Node5); - return _createClass(Element, [{ + _inherits(ie, _Z5); + return _createClass(ie, [{ key: "toJSON", value: function toJSON() { - var json = [ELEMENT, this.name, +this.xml]; - addJSON(this.props, props$1, json); - addJSON(this.children, children, json); - return json; + var e = [1, this.name, +this.xml]; + return Y(this.props, K, e), Y(this.children, Q, e), e; } }, { key: "toString", value: function toString() { - var xml = this.xml, - name = this.name, - props = this.props, - children = this.children; - var length = children.length; - var html = "<".concat(name); - for (var key in props) { - var value = props[key]; - if (value != null) { - if (typeof value === 'boolean') { - if (value) html += xml ? " ".concat(key, "=\"\"") : " ".concat(key); - } else html += " ".concat(key, "=\"").concat(value, "\""); - } + var e = this.xml, + t = this.name, + n = this.props, + s = this.children, + i = s.length; + var r = "<".concat(t); + for (var _t8 in n) { + var _s3 = n[_t8]; + null != _s3 && ("boolean" == typeof _s3 ? _s3 && (r += e ? " ".concat(_t8, "=\"\"") : " ".concat(_t8)) : r += " ".concat(_t8, "=\"").concat(_s3, "\"")); } - if (length) { - html += '>'; - for (var text = !xml && TEXT_ELEMENTS.has(name), i = 0; i < length; i++) html += text ? children[i].data : children[i]; - html += ""); - } else if (xml) html += ' />';else html += VOID_ELEMENTS.has(name) ? '>' : ">"); - return html; + if (i) { + r += ">"; + for (var _n3 = !e && G.has(t), _o3 = 0; _o3 < i; _o3++) r += _n3 ? s[_o3].data : s[_o3]; + r += ""); + } else r += e ? " />" : I.has(t) ? ">" : ">"); + return r; } }]); - }(Node); - var Fragment = /*#__PURE__*/function (_Node6) { - function Fragment() { + }(Z); + var re = /*#__PURE__*/function (_Z6) { + function re() { var _this6; - _classCallCheck(this, Fragment); - _this6 = _callSuper$2(this, Fragment, [FRAGMENT]); - _this6.name = '#fragment'; - _this6.children = children; + _classCallCheck(this, re); + _this6 = _callSuper$1(this, re, [11]), _this6.name = "#fragment", _this6.children = Q; return _this6; } - _inherits(Fragment, _Node6); - return _createClass(Fragment, [{ + _inherits(re, _Z6); + return _createClass(re, [{ key: "toJSON", value: function toJSON() { - var json = [FRAGMENT]; - addJSON(this.children, children, json); - return json; + var e = [11]; + return Y(this.children, Q, e), e; } }, { key: "toString", value: function toString() { - return this.children.join(''); + return this.children.join(""); } }]); - }(Node); - - function _arrayWithHoles(r) { - if (Array.isArray(r)) return r; - } - - function _iterableToArrayLimit(r, l) { - var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; - if (null != t) { - var e, - n, - i, - u, - a = [], - f = true, - o = false; - try { - if (i = (t = t.call(r)).next, 0 === l) { - if (Object(t) !== t) return; - f = !1; - } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); - } catch (r) { - o = true, n = r; - } finally { - try { - if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; - } finally { - if (o) throw n; + }(Z); + var oe = "\0", + le = "\"".concat(oe, "\""), + ae = "'".concat(oe, "'"), + ce = /\x00|<[^><\s]+/g, + ue = /([^\s/>=]+)(?:=(\x00|(?:(['"])[\s\S]*?\3)))?/g, + de = function de(e, t, n, s, i) { + return [t, n, s]; + }, + fe = function fe(e) { + var t = []; + for (; e.parent;) { + switch (e.type) { + case q: + case 1: + "template" === e.name && t.push(-1); } + t.push(e.parent.children.indexOf(e)), e = e.parent; } - return a; - } - } - - function _arrayLikeToArray$3(r, a) { - (null == a || a > r.length) && (a = r.length); - for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; - return n; - } - - function _unsupportedIterableToArray$3(r, a) { - if (r) { - if ("string" == typeof r) return _arrayLikeToArray$3(r, a); - var t = {}.toString.call(r).slice(8, -1); - return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$3(r, a) : void 0; - } - } - - function _nonIterableRest() { - throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); - } - - function _slicedToArray(r, e) { - return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray$3(r, e) || _nonIterableRest(); - } - - /* c8 ignore start */ - var asTemplate = function asTemplate(template) { - var _ref, _ref$join; - return ((_ref = (template === null || template === void 0 ? void 0 : template.raw) || template) === null || _ref === void 0 || (_ref$join = _ref.join) === null || _ref$join === void 0 ? void 0 : _ref$join.call(_ref, ',')) || 'unknown'; - }; - /* c8 ignore stop */ - - var errors = { - text: function text(template, tag, value) { - return new SyntaxError("Mixed text and interpolations found in text only <".concat(tag, "> element ").concat(JSON.stringify(String(value)), " in template ").concat(asTemplate(template))); - }, - unclosed: function unclosed(template, tag) { - return new SyntaxError("The text only <".concat(tag, "> element requires explicit closing tag in template ").concat(asTemplate(template))); + return t; }, - unclosed_element: function unclosed_element(template, tag) { - return new SyntaxError("Unclosed element <".concat(tag, "> found in template ").concat(asTemplate(template))); - }, - invalid_content: function invalid_content(template) { - return new SyntaxError("Invalid content \" found in template ".concat(asTemplate(template))); - }, - invalid_layout: function invalid_layout(template) { - return new SyntaxError("Too many closing tags found in template ".concat(asTemplate(template))); - }, - invalid_doctype: function invalid_doctype(template, value) { - return new SyntaxError("Invalid doctype: ".concat(value, " found in template ").concat(asTemplate(template))); - }, - // DOM ONLY - /* c8 ignore start */ - invalid_template: function invalid_template(template) { - return new SyntaxError("Invalid template - the amount of values does not match the amount of updates: ".concat(asTemplate(template))); - }, - invalid_path: function invalid_path(template, path) { - return new SyntaxError("Invalid path - unreachable node at the path [".concat(path.join(', '), "] found in template ").concat(asTemplate(template))); - }, - invalid_attribute: function invalid_attribute(template, kind) { - return new SyntaxError("Invalid ".concat(kind, " attribute in template definition\n").concat(asTemplate(template))); - }, - invalid_interpolation: function invalid_interpolation(template, value) { - return new SyntaxError("Invalid interpolation - expected hole or array: ".concat(String(value), " found in template ").concat(asTemplate(template))); + pe = function pe(e, t) { + do { + e = e.parent; + } while (t.has(e)); + return e; + }; + var he = function he(e, t) { + return t < 0 ? e.content : e.childNodes[t]; + }; + var ve = function ve(e, t) { + return t.reduceRight(he, e); + }; + var ge, + be = false; + var me = function me(_ref4) { + var e = _ref4.firstChild, + t = _ref4.lastChild; + var n = ge || (ge = document.createRange()); + return n.setStartAfter(e), n.setEndAfter(t), n.deleteContents(), e; }, - invalid_hole: function invalid_hole(value) { - return new SyntaxError("Invalid interpolation - expected hole: ".concat(String(value))); + xe = function xe(e, t) { + return be && 11 === e.nodeType ? 1 / t < 0 ? t ? me(e) : e.lastChild : t ? e.valueOf() : e.firstChild : e; }, - invalid_key: function invalid_key(value) { - return new SyntaxError("Invalid key attribute or position in template: ".concat(String(value))); + ye = Symbol("nodes"), + we = { + get: function get() { + return this.firstChild.parentNode; + } }, - invalid_array: function invalid_array(value) { - return new SyntaxError("Invalid array - expected html/svg but found something else: ".concat(String(value))); + Se = { + value: function value(e) { + me(this).replaceWith(e); + } }, - invalid_component: function invalid_component(value) { - return new SyntaxError("Invalid component: ".concat(String(value))); - } - }; - - function _createForOfIteratorHelper$2(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray$2(r)) || e) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: true } : { done: false, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = true, u = false; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = true, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; } - function _unsupportedIterableToArray$2(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray$2(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$2(r, a) : void 0; } } - function _arrayLikeToArray$2(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; } - var NUL = '\x00'; - var DOUBLE_QUOTED_NUL = "\"".concat(NUL, "\""); - var SINGLE_QUOTED_NUL = "'".concat(NUL, "'"); - var NEXT = /\x00|<[^><\s]+/g; - var ATTRS = /([^\s/>=]+)(?:=(\x00|(?:(['"])[\s\S]*?\3)))?/g; - - // // YAGNI: NUL char in the wild is a shenanigan - // // usage: template.map(safe).join(NUL).trim() - // const NUL_RE = /\x00/g; - // const safe = s => s.replace(NUL_RE, '�'); - - /** @typedef {import('../dom/ish.js').Node} Node */ - /** @typedef {import('../dom/ish.js').Element} Element */ - /** @typedef {import('../dom/ish.js').Component} Component */ - /** @typedef {(node: import('../dom/ish.js').Node, type: typeof ATTRIBUTE | typeof TEXT | typeof COMMENT | typeof COMPONENT, path: number[], name: string, hint: unknown) => unknown} update */ - /** @typedef {Element | Component} Container */ - - /** @type {update} */ - var defaultUpdate = function defaultUpdate(_, type, path, name, hint) { - return [type, path, name]; - }; - - /** - * @param {Node} node - * @returns {number[]} - */ - var path = function path(node) { - var insideout = []; - while (node.parent) { - switch (node.type) { - /* c8 ignore start */ - case COMPONENT$1: - // fallthrough - /* c8 ignore stop */ - case ELEMENT: - { - if (/** @type {Container} */node.name === 'template') insideout.push(-1); - break; - } + ke = { + value: function value() { + me(this).remove(); } - insideout.push(node.parent.children.indexOf(node)); - node = node.parent; - } - return insideout; - }; - - /** - * @param {Node} node - * @param {Set} ignore - * @returns {Node} - */ - var parent = function parent(node, ignore) { - do { - node = node.parent; - } while (ignore.has(node)); - return node; - }; - var parser = (function (_ref) { - var _ref$Comment = _ref.Comment, - Comment$1 = _ref$Comment === void 0 ? Comment : _ref$Comment, - _ref$DocumentType = _ref.DocumentType, - DocumentType$1 = _ref$DocumentType === void 0 ? DocumentType : _ref$DocumentType, - _ref$Text = _ref.Text, - Text$1 = _ref$Text === void 0 ? Text : _ref$Text, - _ref$Fragment = _ref.Fragment, - Fragment$1 = _ref$Fragment === void 0 ? Fragment : _ref$Fragment, - _ref$Element = _ref.Element, - Element$1 = _ref$Element === void 0 ? Element : _ref$Element, - _ref$Component = _ref.Component, - Component$1 = _ref$Component === void 0 ? Component : _ref$Component, - _ref$update = _ref.update, - update = _ref$update === void 0 ? defaultUpdate : _ref$update; - return ( - /** - * Parse a template string into a crawable JS literal tree and provide a list of updates. - * @param {TemplateStringsArray|string[]} template - * @param {unknown[]} holes - * @param {boolean} xml - * @returns {[Node, unknown[]]} - */ - function (template, holes, xml) { - if (template.some(function (chunk) { - return chunk.includes(NUL); - })) throw errors.invalid_nul(template); - var content = template.join(NUL).trim(); - if (content.replace(/(\S+)=(['"])([\S\s]+?)\2/g, function () { - return /^[^\x00]+\x00|\x00[^\x00]+$/.test(arguments.length <= 3 ? undefined : arguments[3]) ? xml = arguments.length <= 1 ? undefined : arguments[1] : arguments.length <= 0 ? undefined : arguments[0]; - }) !== content) throw errors.invalid_attribute(template, xml); - var ignore = new Set(); - var values = []; - var node = new Fragment$1(), - pos = 0, - skip = 0, - hole = 0, - resolvedPath = children; - var _iterator = _createForOfIteratorHelper$2(content.matchAll(NEXT)), - _step; - try { - for (_iterator.s(); !(_step = _iterator.n()).done;) { - var match = _step.value; - // already handled via attributes or text content nodes - if (0 < skip) { - skip--; - continue; - } - var chunk = match[0]; - var index = match.index; - - // prepend previous content, if any - if (pos < index) append(node, new Text$1(content.slice(pos, index))); - - // holes - if (chunk === NUL) { - if (node.name === 'table') { - node = append(node, new Element$1('tbody', xml)); - ignore.add(node); - } - var comment = append(node, new Comment$1('◦')); - values.push(update(comment, COMMENT$1, path(comment), '', holes[hole++])); - pos = index + 1; - } - // comments or doctype - else if (chunk.startsWith('', index + 2); - if (DEBUG && i < 0) throw errors.invalid_content(template); - if (content.slice(i - 2, i + 1) === '-->') { - if (DEBUG && i - index < 6) throw errors.invalid_comment(template); - var data = content.slice(index + 4, i - 2); - if (data[0] === '!') append(node, new Comment$1(data.slice(1).replace(/!$/, ''))); - } else { - if (DEBUG && !content.slice(index + 2, i).toLowerCase().startsWith('doctype')) throw errors.invalid_doctype(template, content.slice(index + 2, i)); - append(node, new DocumentType$1(content.slice(index + 2, i))); - } - pos = i + 1; - } - // closing tag or - else if (chunk.startsWith('', index + 2); - if (DEBUG && _i < 0) throw errors.invalid_closing(template); - if (xml && node.name === 'svg') xml = false; - node = /** @type {Container} */parent(node, ignore); - if (DEBUG && !node) throw errors.invalid_layout(template); - pos = _i + 1; - } - // opening tag or - else { - var _i2 = index + chunk.length; - var j = content.indexOf('>', _i2); - var name = chunk.slice(1); - if (DEBUG && j < 0) throw errors.unclosed_element(template, name); - var tag = name; - // <${Component} ... /> - if (name === NUL) { - tag = 'template'; - node = append(node, new Component$1()); - resolvedPath = path(node).slice(1); - //@ts-ignore - values.push(update(node, COMPONENT$1, resolvedPath, '', holes[hole++])); - } - // any other element - else { - if (!xml) { - tag = tag.toLowerCase(); - // patch automatic elements insertion with
- // or path will fail once live on the DOM - if (node.name === 'table' && (tag === 'tr' || tag === 'td')) { - node = append(node, new Element$1('tbody', xml)); - ignore.add(node); - } - if (node.name === 'tbody' && tag === 'td') { - node = append(node, new Element$1('tr', xml)); - ignore.add(node); - } - } - node = append(node, new Element$1(tag, xml ? tag !== 'svg' : false)); - resolvedPath = children; - } - - // attributes - if (_i2 < j) { - var dot = false; - var _iterator2 = _createForOfIteratorHelper$2(content.slice(_i2, j).matchAll(ATTRS)), - _step2; - try { - for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) { - var _step2$value = _slicedToArray(_step2.value, 3), - _ = _step2$value[0], - _name = _step2$value[1], - value = _step2$value[2]; - if (value === NUL || value === DOUBLE_QUOTED_NUL || value === SINGLE_QUOTED_NUL || (dot = _name.endsWith(NUL))) { - var p = resolvedPath === children ? resolvedPath = path(node) : resolvedPath; - //@ts-ignore - values.push(update(node, ATTRIBUTE$1, p, dot ? _name.slice(0, -1) : _name, holes[hole++])); - dot = false; - skip++; - } else prop(node, _name, value ? value.slice(1, -1) : true); - } - } catch (err) { - _iterator2.e(err); - } finally { - _iterator2.f(); - } - resolvedPath = children; - } - pos = j + 1; - - // to handle self-closing tags - var closed = 0 < j && content[j - 1] === '/'; - if (xml) { - if (closed) { - node = node.parent; - /* c8 ignore start unable to reproduce, still worth a guard */ - if (DEBUG && !node) throw errors.invalid_layout(template); - /* c8 ignore stop */ - } - } else if (closed || VOID_ELEMENTS.has(tag)) { - // void elements are never td or tr - node = closed ? parent(node, ignore) : node.parent; - - /* c8 ignore start unable to reproduce, still worth a guard */ - if (DEBUG && !node) throw errors.invalid_layout(); - /* c8 ignore stop */ - } - // switches to xml mode - else if (tag === 'svg') xml = true; - // text content / data elements content handling - else if (TEXT_ELEMENTS.has(tag)) { - var _index = content.indexOf(""), pos); - if (DEBUG && _index < 0) throw errors.unclosed(template, tag); - var _value = content.slice(pos, _index); - // interpolation as text - if (_value.trim() === NUL) { - skip++; - values.push(update(node, TEXT$1, path(node), '', holes[hole++])); - } else if (DEBUG && _value.includes(NUL)) throw errors.text(template, tag, _value);else append(node, new Text$1(_value)); - // text elements are never td or tr - node = node.parent; - /* c8 ignore start unable to reproduce, still worth a guard */ - if (DEBUG && !node) throw errors.invalid_layout(template); - /* c8 ignore stop */ - pos = _index + name.length + 3; - // ignore the closing tag regardless of the content - skip++; - continue; - } - } + }, + Ce = { + value: function value() { + var e = this.parentNode; + if (e === this) this[ye] === Q && (this[ye] = _toConsumableArray(this.childNodes));else { + if (e) { + var _e0 = this.firstChild, + _t9 = this.lastChild; + for (this[ye] = [_e0]; _e0 !== _t9;) this[ye].push(_e0 = _e0.nextSibling); } - } catch (err) { - _iterator.e(err); - } finally { - _iterator.f(); + this.replaceChildren.apply(this, _toConsumableArray(this[ye])); } - if (pos < content.length) append(node, new Text$1(content.slice(pos))); - - /* c8 ignore start */ - if (hole < holes.length) throw errors.invalid_template(template); - /* c8 ignore stop */ - - return [node, values]; + return this; } - ); - }); - - function _arrayWithoutHoles(r) { - if (Array.isArray(r)) return _arrayLikeToArray$3(r); - } - - function _iterableToArray(r) { - if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); - } - - function _nonIterableSpread() { - throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); - } - - function _toConsumableArray(r) { - return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray$3(r) || _nonIterableSpread(); - } - - var tree = function (node, i) { - var _node$childNodes; - return i < 0 ? node === null || node === void 0 ? void 0 : node.content : node === null || node === void 0 || (_node$childNodes = node.childNodes) === null || _node$childNodes === void 0 ? void 0 : _node$childNodes[i]; - } ; - var resolve = (function (root, path) { - return path.reduceRight(tree, root); - }); - - var checkType = false, - range; - - /** - * @param {DocumentFragment} fragment - * @returns {Node | Element} - */ - var drop = function drop(_ref) { - var firstChild = _ref.firstChild, - lastChild = _ref.lastChild; - var r = range || (range = document.createRange()); - r.setStartAfter(firstChild); - r.setEndAfter(lastChild); - r.deleteContents(); - //@ts-ignore - return firstChild; - }; - - /** - * @param {Node} node - * @param {1 | 0 | -0 | -1} operation - * @returns {Node} - */ - var diffFragment = function diffFragment(node, operation) { - return checkType && node.nodeType === 11 ? 1 / operation < 0 ? - //@ts-ignore - operation ? drop(node) : node.lastChild : - //@ts-ignore - operation ? node.valueOf() : node.firstChild : node; - }; - var nodes = Symbol('nodes'); - var parentNode = { - get: function get() { - return this.firstChild.parentNode; - } - }; - //@ts-ignore - var replaceWith = { - value: function value(node) { - drop(this).replaceWith(node); - } - }; - //@ts-ignore - var remove = { - value: function value() { - drop(this).remove(); - } - }; - var valueOf = { - value: function value() { - var parentNode = this.parentNode; - if (parentNode === this) { - if (this[nodes] === children) this[nodes] = _toConsumableArray(this.childNodes); - } else { - // TODO: verify fragments in lists don't call this twice - if (parentNode) { - var firstChild = this.firstChild, - lastChild = this.lastChild; - this[nodes] = [firstChild]; - while (firstChild !== lastChild) this[nodes].push(firstChild = firstChild.nextSibling); - } - this.replaceChildren.apply(this, _toConsumableArray(this[nodes])); - } - return this; - } - }; - - /** - * @param {DocumentFragment} fragment - * @returns {DocumentFragment} - */ - function PersistentFragment(fragment) { - var firstChild = createComment('<>'), - lastChild = createComment(''); - //@ts-ignore - fragment.replaceChildren.apply(fragment, [firstChild].concat(_toConsumableArray(fragment.childNodes), [lastChild])); - checkType = true; - return defineProperties$2(fragment, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, nodes, { + }; + function Te(e) { + var t = H("<>"), + n = H(""); + return e.replaceChildren.apply(e, [t].concat(_toConsumableArray(e.childNodes), [n])), be = true, P(e, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, ye, { writable: true, - value: children + value: Q }), "firstChild", { - value: firstChild + value: t }), "lastChild", { - value: lastChild - }), "parentNode", parentNode), "valueOf", valueOf), "replaceWith", replaceWith), "remove", remove)); + value: n + }), "parentNode", we), "valueOf", Ce), "replaceWith", Se), "remove", ke)); } - PersistentFragment.prototype = DocumentFragment.prototype; - - // @ts-check - - /** - * @param {Document} document - * @returns - */ - var creator = (function () { - var document = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : (/** @type {Document} */globalThis.document); - var tpl = document.createElement('template'), - range; - /** - * @param {string} content - * @param {boolean} [xml=false] - * @returns {DocumentFragment} - */ - return function (content) { - var xml = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; - if (xml) { - if (!range) { - range = document.createRange(); - range.selectNodeContents(document.createElementNS('http://www.w3.org/2000/svg', 'svg')); - } - return range.createContextualFragment(content); - } - tpl.innerHTML = content; - var fragment = tpl.content; - tpl = /** @type {HTMLTemplateElement} */tpl.cloneNode(false); - return fragment; - }; - }); - - // @see https://github.com/WebReflection/udomdiff - - /** - * ISC License - * - * Copyright (c) 2020, Andrea Giammarchi, @WebReflection - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH - * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, - * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM - * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE - * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ - - /** - * @param {Node[]} a The list of current/live children - * @param {Node[]} b The list of future children - * @param {(entry: Node, action: number) => Node} get - * The callback invoked per each entry related DOM operation. - * @param {Node} [before] The optional node used as anchor to insert before. - * @returns {Node[]} The same list of future children. - */ - var diff = (function (a, b, get, before) { - var parentNode = before.parentNode; - var bLength = b.length; - var aEnd = a.length; - var bEnd = bLength; - var aStart = 0; - var bStart = 0; - var map = null; - while (aStart < aEnd || bStart < bEnd) { - // append head, tail, or nodes in between: fast path - if (aEnd === aStart) { - // we could be in a situation where the rest of nodes that - // need to be added are not at the end, and in such case - // the node to `insertBefore`, if the index is more than 0 - // must be retrieved, otherwise it's gonna be the first item. - var node = bEnd < bLength ? bStart ? get(b[bStart - 1], -0).nextSibling : get(b[bEnd], 0) : before; - while (bStart < bEnd) parentNode.insertBefore(get(b[bStart++], 1), node); - } - // remove head or tail: fast path - else if (bEnd === bStart) { - while (aStart < aEnd) { - // remove the node only if it's unknown or not live - if (!map || !map.has(a[aStart])) - //@ts-ignore - get(a[aStart], -1).remove(); - aStart++; + Te.prototype = DocumentFragment.prototype; + var De = 16, + Oe = 32768, + Ne = function () { + var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : globalThis.document; + var t, + n = e.createElement("template"); + return function (s) { + var i = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; + if (i) return t || (t = e.createRange(), t.selectNodeContents(e.createElementNS("http://www.w3.org/2000/svg", "svg"))), t.createContextualFragment(s); + n.innerHTML = s; + var r = n.content; + return n = n.cloneNode(false), r; + }; + }(document), + $e = Symbol("ref"), + We = function We(e, t) { + var _iterator = _createForOfIteratorHelper(B(t)), + _step; + try { + for (_iterator.s(); !(_step = _iterator.n()).done;) { + var _step$value = _slicedToArray(_step.value, 2), + _n4 = _step$value[0], + _s4 = _step$value[1]; + var _t0 = "role" === _n4 ? _n4 : "aria-".concat(_n4.toLowerCase()); + null == _s4 ? e.removeAttribute(_t0) : e.setAttribute(_t0, _s4); } + } catch (err) { + _iterator.e(err); + } finally { + _iterator.f(); } - // same node: fast path - else if (a[aStart] === b[bStart]) { - aStart++; - bStart++; - } - // same tail: fast path - else if (a[aEnd - 1] === b[bEnd - 1]) { - aEnd--; - bEnd--; - } - // The once here single last swap "fast path" has been removed in v1.1.0 - // https://github.com/WebReflection/udomdiff/blob/single-final-swap/esm/index.js#L69-L85 - // reverse swap: also fast path - else if (a[aStart] === b[bEnd - 1] && b[bStart] === a[aEnd - 1]) { - // this is a "shrink" operation that could happen in these cases: - // [1, 2, 3, 4, 5] - // [1, 4, 3, 2, 5] - // or asymmetric too - // [1, 2, 3, 4, 5] - // [1, 2, 3, 5, 6, 4] - var _node = get(a[--aEnd], -0).nextSibling; - parentNode.insertBefore(get(b[bStart++], 1), get(a[aStart++], -0).nextSibling); - parentNode.insertBefore(get(b[--bEnd], 1), _node); - // mark the future index as identical (yeah, it's dirty, but cheap 👍) - // The main reason to do this, is that when a[aEnd] will be reached, - // the loop will likely be on the fast path, as identical to b[bEnd]. - // In the best case scenario, the next loop will skip the tail, - // but in the worst one, this node will be considered as already - // processed, bailing out pretty quickly from the map index check - a[aEnd] = b[bEnd]; - } - // map based fallback, "slow" path - else { - var _map$get; - // the map requires an O(bEnd - bStart) operation once - // to store all future nodes indexes for later purposes. - // In the worst case scenario, this is a full O(N) cost, - // and such scenario happens at least when all nodes are different, - // but also if both first and last items of the lists are different - if (!map) { - map = new Map(); - var i = bStart; - while (i < bEnd) map.set(b[i], i++); - } - var index = (_map$get = map.get(a[aStart])) !== null && _map$get !== void 0 ? _map$get : -1; - - // this node has no meaning in the future list, so it's more than safe - // to remove it, and check the next live node out instead, meaning - // that only the live list index should be forwarded - //@ts-ignore - if (index < 0) get(a[aStart++], -1).remove(); - // it's a future node, hence it needs some handling - else { - // if it's not already processed, look on demand for the next LCS - if (bStart < index && index < bEnd) { - var _i = aStart; - // counts the amount of nodes that are the same in the future - var sequence = 1; - while (++_i < aEnd && _i < bEnd && map.get(a[_i]) === index + sequence) sequence++; - // effort decision here: if the sequence is longer than replaces - // needed to reach such sequence, which would brings again this loop - // to the fast path, prepend the difference before a sequence, - // and move only the future list index forward, so that aStart - // and bStart will be aligned again, hence on the fast path. - // An example considering aStart and bStart are both 0: - // a: [1, 2, 3, 4] - // b: [7, 1, 2, 3, 6] - // this would place 7 before 1 and, from that time on, 1, 2, and 3 - // will be processed at zero cost - if (sequence > index - bStart) { - var _node2 = get(a[aStart], 0); - while (bStart < index) parentNode.insertBefore(get(b[bStart++], 1), _node2); - } - // if the effort wasn't good enough, fallback to a replace, - // moving both source and target indexes forward, hoping that some - // similar node will be found later on, to go back to the fast path - else { - // TODO: benchmark replaceWith instead - parentNode.replaceChild(get(b[bStart++], 1), get(a[aStart++], -1)); - } + }, + Ae = function Ae(e) { + return function (t, n) { + null == n ? t.removeAttribute(e) : t.setAttribute(e, n); + }; + }, + Ee = function Ee(e, t) { + e[ye] = function (e, t, n, s) { + var i = s.parentNode, + r = t.length; + var o = e.length, + l = r, + a = 0, + c = 0, + u = null; + for (; a < o || c < l;) if (o === a) { + var _e1 = l < r ? c ? n(t[c - 1], -0).nextSibling : n(t[l], 0) : s; + for (; c < l;) i.insertBefore(n(t[c++], 1), _e1); + } else if (l === c) for (; a < o;) u && u.has(e[a]) || n(e[a], -1).remove(), a++;else if (e[a] === t[c]) a++, c++;else if (e[o - 1] === t[l - 1]) o--, l--;else if (e[a] === t[l - 1] && t[c] === e[o - 1]) { + var _s5 = n(e[--o], -0).nextSibling; + i.insertBefore(n(t[c++], 1), n(e[a++], -0).nextSibling), i.insertBefore(n(t[--l], 1), _s5), e[o] = t[l]; + } else { + var _u$get; + if (!u) { + u = new Map(); + var _e10 = c; + for (; _e10 < l;) u.set(t[_e10], _e10++); } - // otherwise move the source forward, 'cause there's nothing to do - else aStart++; + var _s6 = (_u$get = u.get(e[a])) !== null && _u$get !== void 0 ? _u$get : -1; + if (_s6 < 0) n(e[a++], -1).remove();else if (c < _s6 && _s6 < l) { + var _r2 = a, + _d = 1; + for (; ++_r2 < o && _r2 < l && u.get(e[_r2]) === _s6 + _d;) _d++; + if (_d > _s6 - c) { + var _r3 = n(e[a], 0); + for (; c < _s6;) i.insertBefore(n(t[c++], 1), _r3); + } else i.replaceChild(n(t[c++], 1), n(e[a++], -1)); + } else a++; } + return t; + }(e[ye] || Q, t, xe, e); + }, + Me = new WeakMap(), + Re = function Re(e, t) { + var _e$ye; + var n = "object" == _typeof(t) ? t !== null && t !== void 0 ? t : e : function (e, t) { + var n = Me.get(e); + return n ? n.data = t : Me.set(e, n = document.createTextNode(t)), n; + }(e, t), + s = (_e$ye = e[ye]) !== null && _e$ye !== void 0 ? _e$ye : e; + n !== s && s.replaceWith(xe(e[ye] = n, 1)); + }, + Le = function Le(e, t) { + Re(e, t instanceof W ? t.value : t); + }, + _e = function _e(_ref5, t) { + var e = _ref5.dataset; + var _iterator2 = _createForOfIteratorHelper(B(t)), + _step2; + try { + for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) { + var _step2$value = _slicedToArray(_step2.value, 2), + _n5 = _step2$value[0], + _s7 = _step2$value[1]; + null == _s7 ? delete e[_n5] : e[_n5] = _s7; + } + } catch (err) { + _iterator2.e(err); + } finally { + _iterator2.f(); } - } - return b; - }); - - function _createForOfIteratorHelper$1(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray$1(r)) || e) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: true } : { done: false, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = true, u = false; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = true, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; } - function _unsupportedIterableToArray$1(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray$1(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$1(r, a) : void 0; } } - function _arrayLikeToArray$1(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; } - var ARRAY = 1 << 0; - var ARIA = 1 << 1; - var ATTRIBUTE = 1 << 2; - var COMMENT = 1 << 3; - var COMPONENT = 1 << 4; - var DATA = 1 << 5; - var DIRECT = 1 << 6; - var DOTS = 1 << 7; - var EVENT = 1 << 8; - var KEY = 1 << 9; - var PROP = 1 << 10; - var TEXT = 1 << 11; - var TOGGLE = 1 << 12; - var UNSAFE = 1 << 13; - var REF = 1 << 14; - var SIGNAL = 1 << 15; - - // COMPONENT flags - var COMPONENT_DIRECT = COMPONENT | DIRECT; - var COMPONENT_DOTS = COMPONENT | DOTS; - var COMPONENT_PROP = COMPONENT | PROP; - var EVENT_ARRAY = EVENT | ARRAY; - var COMMENT_ARRAY = COMMENT | ARRAY; - var fragment = creator(document); - var ref = Symbol('ref'); - var aria = function aria(node, values) { - var _iterator = _createForOfIteratorHelper$1(entries(values)), - _step; - try { - for (_iterator.s(); !(_step = _iterator.n()).done;) { - var _step$value = _slicedToArray(_step.value, 2), - key = _step$value[0], - value = _step$value[1]; - var name = key === 'role' ? key : "aria-".concat(key.toLowerCase()); - if (value == null) node.removeAttribute(name);else node.setAttribute(name, value); - } - } catch (err) { - _iterator.e(err); - } finally { - _iterator.f(); - } - }; - var attribute = function attribute(name) { - return function (node, value) { - if (value == null) node.removeAttribute(name);else node.setAttribute(name, value); - }; - }; - var comment_array = function comment_array(node, value) { - node[nodes] = diff(node[nodes] || children, value, diffFragment, node); - }; - var text = new WeakMap(); - var getText = function getText(ref, value) { - var node = text.get(ref); - if (node) node.data = value;else text.set(ref, node = document.createTextNode(value)); - return node; - }; - var comment_hole = function comment_hole(node, value) { - var _node$nodes; - var current = _typeof(value) === 'object' ? value !== null && value !== void 0 ? value : node : getText(node, value); - var prev = (_node$nodes = node[nodes]) !== null && _node$nodes !== void 0 ? _node$nodes : node; - if (current !== prev) prev.replaceWith(diffFragment(node[nodes] = current, 1)); - }; - var comment_unsafe = function comment_unsafe(xml) { - return function (node, value) { - var _node$ref; - var prev = (_node$ref = node[ref]) !== null && _node$ref !== void 0 ? _node$ref : node[ref] = {}; - if (prev.v !== value) { - prev.f = PersistentFragment(fragment(value, xml)); - prev.v = value; - } - comment_hole(node, prev.f); - }; - }; - var comment_signal = function comment_signal(node, value) { - comment_hole(node, value instanceof Signal ? value.value : value); - }; - var data = function data(_ref, values) { - var dataset = _ref.dataset; - var _iterator2 = _createForOfIteratorHelper$1(entries(values)), - _step2; - try { - for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) { - var _step2$value = _slicedToArray(_step2.value, 2), - key = _step2$value[0], - value = _step2$value[1]; - if (value == null) delete dataset[key];else dataset[key] = value; + }, + je = new Map(), + Fe = function Fe(e) { + var t = je.get(e); + return t || je.set(e, t = Pe(e)), t; + }, + Pe = function Pe(e) { + return function (t, n) { + t[e] = n; + }; + }, + Be = function Be(e, t) { + var _iterator3 = _createForOfIteratorHelper(B(t)), + _step3; + try { + for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) { + var _step3$value = _slicedToArray(_step3.value, 2), + _n6 = _step3$value[0], + _s8 = _step3$value[1]; + Ae(_n6)(e, _s8); + } + } catch (err) { + _iterator3.e(err); + } finally { + _iterator3.f(); } - } catch (err) { - _iterator2.e(err); - } finally { - _iterator2.f(); - } - }; - - /** @type {Map} */ - var directRefs = new Map(); - - /** - * @param {string|Symbol} name - * @returns {Function} - */ - var directFor = function directFor(name) { - var fn = directRefs.get(name); - if (!fn) directRefs.set(name, fn = direct$1(name)); - return fn; - }; - var direct$1 = function direct(name) { - return function (node, value) { - node[name] = value; + }, + Je = function Je(e, t, n) { + return n ? function (n, s) { + var i = n[t]; + i !== null && i !== void 0 && i.length && n.removeEventListener.apply(n, [e].concat(_toConsumableArray(i))), s && n.addEventListener.apply(n, [e].concat(_toConsumableArray(s))), n[t] = s; + } : function (n, s) { + var i = n[t]; + i && n.removeEventListener(e, i), s && n.addEventListener(e, s), n[t] = s; + }; + }, + Ve = function Ve(e) { + return function (t, n) { + t.toggleAttribute(e, !!n); + }; }; - }; - var dots = function dots(node, values) { - var _iterator3 = _createForOfIteratorHelper$1(entries(values)), - _step3; - try { - for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) { - var _step3$value = _slicedToArray(_step3.value, 2), - name = _step3$value[0], - value = _step3$value[1]; - attribute(name)(node, value); + var ze = false; + var He = true; + var qe = function qe(e) { + He = e; + }, + Ge = function Ge() { + return He; + }, + Ie = function Ie(e) { + return xe(e.n ? e.update(e) : e.valueOf(false), 1); + }, + Ke = function Ke(e, t) { + var n = [], + s = e.length, + i = t.length; + for (var _r4, _o4, _l3 = 0, _a2 = 0; _a2 < i; _a2++) _r4 = t[_a2], n[_a2] = _l3 < s && (_o4 = e[_l3++]).t === _r4.t ? (t[_a2] = _o4).update(_r4) : _r4.valueOf(false); + return n; + }, + Qe = function Qe(e, t, n) { + var s = R, + i = n.length; + var r = 0; + _(function (e) { + return r < i ? n[r++] : n[r++] = e instanceof W ? e : s(e); + }); + var o = Ge(); + o && qe(!o); + try { + return e(t, Ze); + } finally { + o && qe(o), _(s); } - } catch (err) { - _iterator3.e(err); - } finally { - _iterator3.f(); - } - }; - var event = function event(type, at, array) { - return array ? function (node, value) { - var prev = node[at]; - if (prev !== null && prev !== void 0 && prev.length) node.removeEventListener.apply(node, [type].concat(_toConsumableArray(prev))); - if (value) node.addEventListener.apply(node, [type].concat(_toConsumableArray(value))); - node[at] = value; - } : function (node, value) { - var prev = node[at]; - if (prev) node.removeEventListener(type, prev); - if (value) node.addEventListener(type, value); - node[at] = value; - }; - }; - var toggle = function toggle(name) { - return function (node, value) { - node.toggleAttribute(name, !!value); - }; - }; - var k = false; - var isKeyed = function isKeyed() { - var wasKeyed = k; - k = false; - return wasKeyed; - }; - var update = function update(node, type, path, name, hint) { - switch (type) { - case COMPONENT$1: - return [path, hint, COMPONENT]; - case COMMENT$1: - { - if (isArray(hint)) return [path, comment_array, COMMENT_ARRAY]; - if (hint instanceof Unsafe) return [path, comment_unsafe(node.xml), UNSAFE]; - if (hint instanceof Signal) return [path, comment_signal, COMMENT | SIGNAL]; - return [path, comment_hole, COMMENT]; - } - case TEXT$1: - return [path, directFor('textContent'), TEXT]; - case ATTRIBUTE$1: - { - var isComponent = node.type === COMPONENT$1; - switch (name.at(0)) { - case '@': - { - if (isComponent) throw errors.invalid_attribute([], name); - var array = isArray(hint); - return [path, event(name.slice(1), Symbol(name), array), array ? EVENT_ARRAY : EVENT]; - } - case '?': - if (isComponent) throw errors.invalid_attribute([], name); - return [path, toggle(name.slice(1)), TOGGLE]; - case '.': - { - return name === '...' ? [path, isComponent ? assign : dots, isComponent ? COMPONENT_DOTS : DOTS] : [path, direct$1(name.slice(1)), isComponent ? COMPONENT_DIRECT : DIRECT]; - } - default: - { - if (isComponent) return [path, direct$1(name), COMPONENT_PROP]; - if (name === 'aria') return [path, aria, ARIA]; - if (name === 'data' && !/^object$/i.test(node.name)) return [path, data, DATA]; - if (name === 'key') { - if (1 < path.length) throw errors.invalid_key(hint); - return [path, k = true, KEY]; - } - if (name === 'ref') return [path, directFor(ref), REF]; - if (name.startsWith('on')) return [path, directFor(name.toLowerCase()), DIRECT]; - return [path, attribute(name), ATTRIBUTE]; - } - } - } - } - }; - - var direct = true; - - /** @param {boolean} value */ - var _set = function _set(value) { - direct = value; - }; - - /** @returns {boolean} */ - var _get = function _get() { - return direct; - }; - - function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: true } : { done: false, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = true, u = false; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = true, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; } - function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } } - function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; } - - /** - * @param {Hole} hole - * @returns - */ - var dom = function dom(hole) { - return diffFragment(hole.n ? hole.update(hole) : hole.valueOf(false), 1); - }; - var holed = function holed(prev, current) { - var changes = [], - h = prev.length, - l = current.length; - for (var c, p, j = 0, i = 0; i < l; i++) { - c = current[i]; - changes[i] = j < h && (p = prev[j++]).t === c.t ? (current[i] = p).update(c) : c.valueOf(false); - } - return changes; - }; - - /** - * @param {Hole} hole - * @param {unknown} value - * @returns {Node} - */ - var keyed$1 = function keyed(hole, value) { - var _hole$t$2$get$update, _hole$t$2$get; - return /** @type {import('./keyed.js').Keyed} */(_hole$t$2$get$update = (_hole$t$2$get = hole.t[2].get(value)) === null || _hole$t$2$get === void 0 ? void 0 : _hole$t$2$get.update(hole)) !== null && _hole$t$2$get$update !== void 0 ? _hole$t$2$get$update : hole.valueOf(false); - }; - - /** - * - * @param {Function} Component - * @param {Object} obj - * @param {unknown[]} signals - * @returns {Hole} - */ - var component = function component(Component, obj, signals) { - signals.length; - var wasDirect = _get(); - if (wasDirect) _set(!wasDirect); - try { - return Component(obj, global); - } finally { - if (wasDirect) _set(wasDirect); - } - }; - - /** - * @param {Hole} hole - * @param {Hole} value - * @returns {Hole} - */ - var getHole = function getHole(hole, value) { - if (hole.t === value.t) { - hole.update(value); - } else { - hole.n.replaceWith(dom(value)); - hole = value; - } - return hole; - }; - var createEffect = function createEffect(node, value, obj) { - var signals = [], - entry = [COMPONENT, null, obj], - bootstrap = true, - hole; - effect(function () { - if (bootstrap) { - bootstrap = false; - hole = component(value, obj, signals); - if (!signals.length) signals = children; - if (hole) { - node.replaceWith(dom(hole)); - entry[1] = hole; - } else node.remove(); - } else { - var result = component(value, obj, signals); - if (hole) { - if (!(result instanceof Hole)) throw errors.invalid_component(value); - if (getHole(hole, /** @type {Hole} */result) === result) entry[2] = hole = result; + }, + Ue = function Ue(e, t) { + return e.t === t.t ? e.update(t) : (e.n.replaceWith(Ie(t)), e = t), e; + }, + Xe = function Xe(e, t, n) { + var s, + i = [], + r = [De, null, n], + o = true; + return x(function () { + if (o) o = false, s = Qe(t, n, i), i.length || (i = Q), s ? (e.replaceWith(Ie(s)), r[1] = s) : e.remove();else { + var _e11 = Qe(t, n, i); + s && Ue(s, _e11) === _e11 && (r[2] = s = _e11); } - } - }); - return entry; - }; - var updateRefs = function updateRefs(refs) { - var _iterator = _createForOfIteratorHelper(refs), - _step; - try { - for (_iterator.s(); !(_step = _iterator.n()).done;) { - var node = _step.value; - var value = node[ref]; - if (typeof value === 'function') value(node);else if (value instanceof Signal) value.value = node;else if (value) value.current = node; - } - } catch (err) { - _iterator.e(err); - } finally { - _iterator.f(); - } - }; - var props = Symbol(); - var global = {}; - var Hole = /*#__PURE__*/function () { - /** - * @param {[DocumentFragment, unknown[], import('./keyed.js').Keyed?]} template - * @param {unknown[]} values - */ - function Hole(template, values) { - _classCallCheck(this, Hole); - this.t = template; - this.v = values; - this.n = null; - this.k = -1; + }), r; + }, + Ye = Symbol(), + Ze = {}; + var et = /*#__PURE__*/function () { + function et(e, t) { + _classCallCheck(this, et); + this.t = e, this.v = t, this.n = null, this.k = -1; } - - /** - * @param {boolean} [direct] - * @returns {Node} - */ - return _createClass(Hole, [{ + return _createClass(et, [{ key: "valueOf", value: function valueOf() { - var direct = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _get(); + var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : Ge(); var _this$t = _slicedToArray(this.t, 3), - fragment = _this$t[0], - updates = _this$t[1], - keys = _this$t[2]; - var root = document.importNode(fragment, true); - var values = this.v; - var length = values.length; - var changes = children; - var node, prev, refs; - if (length !== updates.length) throw errors.invalid_interpolation(this.t[3], values); - if (0 < length) { - changes = updates.slice(0); - while (length--) { - var _updates$length = _slicedToArray(updates[length], 3), - path = _updates$length[0], - update = _updates$length[1], - type = _updates$length[2]; - var value = values[length]; - if (prev !== path) { - node = resolve(root, path); - prev = path; - if (!node) throw errors.invalid_path(this.t[3], path); - } - if (type & COMPONENT) { - var obj = node[props] || (node[props] = {}); - if (type === COMPONENT) { - var _obj$children; - var _iterator2 = _createForOfIteratorHelper(node.attributes), - _step2; + t = _this$t[0], + n = _this$t[1], + s = _this$t[2], + i = document.importNode(t, true), + r = this.v; + var o, + l, + a, + c = r.length, + u = Q; + if (0 < c) { + for (u = n.slice(0); c--;) { + var _n$c = _slicedToArray(n[c], 3), + _t1 = _n$c[0], + _s9 = _n$c[1], + _d2 = _n$c[2], + _f = r[c]; + if (l !== _t1 && (o = ve(i, _t1), l = _t1), _d2 & De) { + var _e12 = o[Ye] || (o[Ye] = {}); + if (_d2 === De) { + var _e12$children; + var _iterator4 = _createForOfIteratorHelper(o.attributes), + _step4; try { - for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) { - var _obj$name; - var _step2$value = _step2.value, - name = _step2$value.name, - _value = _step2$value.value; - (_obj$name = obj[name]) !== null && _obj$name !== void 0 ? _obj$name : obj[name] = _value; + for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) { + var _e12$_t; + var _step4$value = _step4.value, + _t10 = _step4$value.name, + _n7 = _step4$value.value; + (_e12$_t = _e12[_t10]) !== null && _e12$_t !== void 0 ? _e12$_t : _e12[_t10] = _n7; } } catch (err) { - _iterator2.e(err); + _iterator4.e(err); } finally { - _iterator2.f(); + _iterator4.f(); } - (_obj$children = obj.children) !== null && _obj$children !== void 0 ? _obj$children : obj.children = _toConsumableArray(node.content.childNodes); - changes[length] = createEffect(node, value, obj); - } else { - update(obj, value); - changes[length] = [type, update, obj]; - } + (_e12$children = _e12.children) !== null && _e12$children !== void 0 ? _e12$children : _e12.children = _toConsumableArray(o.content.childNodes), u[c] = Xe(o, _f, _e12); + } else _s9(_e12, _f), u[c] = [_d2, _s9, _e12]; } else { - var commit = true; - if (type & ARRAY && !isArray(value)) throw errors.invalid_interpolation(this.t[3], value); - if (!direct && type & COMMENT && !(type & SIGNAL)) { - if (type & ARRAY) { - commit = false; - if (value.length) update(node, value[0] instanceof Hole ? holed(children, value) : value); - } else if (value instanceof Hole) { - commit = false; - update(node, dom(value)); - } - } - if (commit) { - if (type === KEY) { - if (!keys) throw errors.invalid_key(value); - this.k = length; - } else { - if (type === REF) (refs !== null && refs !== void 0 ? refs : refs = new Set()).add(node); - update(node, value); - } - } - changes[length] = [type, update, value, node]; - if (direct && type & COMMENT) node.remove(); + var _t11 = true; + e || !(8 & _d2) || _d2 & Oe || (1 & _d2 ? (_t11 = false, _f.length && _s9(o, _f[0] instanceof et ? Ke(Q, _f) : _f)) : _f instanceof et && (_t11 = false, _s9(o, Ie(_f)))), _t11 && (512 === _d2 ? this.k = c : (16384 === _d2 && (a !== null && a !== void 0 ? a : a = new Set()).add(o), _s9(o, _f))), u[c] = [_d2, _s9, _f, o], e && 8 & _d2 && o.remove(); } } - if (refs) updateRefs(refs); + a && function (e) { + var _iterator5 = _createForOfIteratorHelper(e), + _step5; + try { + for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) { + var _t12 = _step5.value; + var _e13 = _t12[$e]; + "function" == typeof _e13 ? _e13(_t12) : _e13 instanceof W ? _e13.value = _t12 : _e13 && (_e13.current = _t12); + } + } catch (err) { + _iterator5.e(err); + } finally { + _iterator5.f(); + } + }(a); } - var childNodes = root.childNodes; - var size = childNodes.length; - var n = size === 1 ? childNodes[0] : size ? PersistentFragment(root) : root; - this.v = changes; - this.n = n; - if (-1 < this.k) keys.set(changes[this.k][2], n, this); - return n; + var d = i.childNodes, + f = d.length, + p = 1 === f ? d[0] : f ? Te(i) : i; + return this.v = u, this.n = p, -1 < this.k && s.set(u[this.k][2], p, this), p; } - - /** - * @param {Hole} hole - * @returns {Node} - */ }, { key: "update", - value: function update(hole) { - var key = this.k; - var changes = this.v; - var values = hole.v; - if (-1 < key && changes[key][2] !== values[key]) return keyed$1(hole, values[key]); - var length = changes.length; - while (length--) { - var entry = changes[length]; - var _entry = _slicedToArray(entry, 3), - type = _entry[0], - _update = _entry[1], - prev = _entry[2]; - if (type === KEY) continue; - var value = values[length]; - if (type & COMPONENT) { - if (type === COMPONENT) { - if (typeof value !== 'function') throw errors.invalid_component(value); - var result = value(prev, global); - if (_update) { - if (!(result instanceof Hole)) throw errors.invalid_component(value); - if (getHole(_update, /** @type {Hole} */result) === result) entry[2] = result; - } - } else _update(prev, value); + value: function update(e) { + var t = this.k, + n = this.v, + s = e.v; + if (-1 < t && n[t][2] !== s[t]) return function (e, t, _e$t$2$get$update, _e$t$2$get) { + return (_e$t$2$get$update = (_e$t$2$get = e.t[2].get(t)) === null || _e$t$2$get === void 0 ? void 0 : _e$t$2$get.update(e)) !== null && _e$t$2$get$update !== void 0 ? _e$t$2$get$update : e.valueOf(false); + }(e, s[t]); + var i = n.length; + for (; i--;) { + var _e15 = n[i], + _e14 = _slicedToArray(_e15, 3), + _t13 = _e14[0], + _r5 = _e14[1], + _o5 = _e14[2]; + if (512 === _t13) continue; + var _l4 = s[i]; + if (_t13 & De) { + if (_t13 === De) { + var _t14 = _l4(_o5, Ze); + _r5 && Ue(_r5, _t14) === _t14 && (_e15[2] = _t14); + } else _r5(_o5, _l4); } else { - var change = value; - if (type & ARRAY) { - if (!isArray(value)) throw errors.invalid_interpolation([], value); - if (type & COMMENT) { - // TODO: a smarter differ that does not require 2 loops - if (value.length) { - if (value[0] instanceof Hole) { - if (prev.length && !(prev[0] instanceof Hole)) throw errors.invalid_interpolation([], value[0]); - change = holed(prev, value); - } - } - } else if (type & EVENT && value[0] === prev[0]) continue; - } else if (type & COMMENT) { - if (type & SIGNAL) { - if (value === prev) { - _update(entry[3], change); - continue; - } - } else if (prev instanceof Hole) { - if (!(value instanceof Hole)) throw errors.invalid_interpolation([], value); - value = getHole(prev, /** @type {Hole} */value); - change = value.n; + var _n8 = _l4; + if (1 & _t13) { + if (8 & _t13) _l4.length && _l4[0] instanceof et && (_n8 = Ke(_o5, _l4));else if (256 & _t13 && _l4[0] === _o5[0]) continue; + } else if (8 & _t13) if (_t13 & Oe) { + if (_l4 === _o5) { + _r5(_e15[3], _n8); + continue; } - } - if (value !== prev) { - entry[2] = value; - _update(entry[3], change); - } + } else _o5 instanceof et && (_l4 = Ue(_o5, _l4), _n8 = _l4.n); + _l4 !== _o5 && (_e15[2] = _l4, _r5(_e15[3], _n8)); } } - return /** @type {Node} */this.n; + return this.n; } }]); }(); - - function _isNativeFunction(t) { - try { - return -1 !== Function.toString.call(t).indexOf("[native code]"); - } catch (n) { - return "function" == typeof t; - } - } - - function _isNativeReflectConstruct$2() { - try { - var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); - } catch (t) {} - return (_isNativeReflectConstruct$2 = function _isNativeReflectConstruct() { - return !!t; - })(); - } - - function _construct(t, e, r) { - if (_isNativeReflectConstruct$2()) return Reflect.construct.apply(null, arguments); - var o = [null]; - o.push.apply(o, e); - var p = new (t.bind.apply(t, o))(); - return r && _setPrototypeOf(p, r.prototype), p; - } - - function _wrapNativeSuper(t) { - var r = "function" == typeof Map ? new Map() : void 0; - return _wrapNativeSuper = function _wrapNativeSuper(t) { - if (null === t || !_isNativeFunction(t)) return t; - if ("function" != typeof t) throw new TypeError("Super expression must either be null or a function"); - if (void 0 !== r) { - if (r.has(t)) return r.get(t); - r.set(t, Wrapper); - } - function Wrapper() { - return _construct(t, arguments, _getPrototypeOf(this).constructor); - } - return Wrapper.prototype = Object.create(t.prototype, { - constructor: { - value: Wrapper, - enumerable: false, - writable: true, - configurable: true - } - }), _setPrototypeOf(Wrapper, t); - }, _wrapNativeSuper(t); - } - - function _callSuper$1(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct$1() ? Reflect.construct(o, [], _getPrototypeOf(t).constructor) : o.apply(t, e)); } - function _isNativeReflectConstruct$1() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct$1 = function _isNativeReflectConstruct() { return !!t; })(); } - function _superPropGet(t, o, e, r) { var p = _get$1(_getPrototypeOf(t.prototype ), o, e); return 2 & r && "function" == typeof p ? function (t) { return p.apply(e, t); } : p; } - var keyed = new WeakMap(); - - //@ts-ignore - var Keyed = /*#__PURE__*/function (_Map) { - function Keyed() { - var _this; - _classCallCheck(this, Keyed); - //@ts-ignore - (_this = _callSuper$1(this, Keyed))._ = new FinalizationRegistry(function (key) { - return _this["delete"](key); + var tt = new WeakMap(); + var nt = /*#__PURE__*/function (_Map) { + function nt() { + var _this7; + _classCallCheck(this, nt); + (_this7 = _callSuper$1(this, nt))._ = new FinalizationRegistry(function (e) { + return _this7["delete"](e); }); - return _this; + return _this7; } - _inherits(Keyed, _Map); - return _createClass(Keyed, [{ + _inherits(nt, _Map); + return _createClass(nt, [{ key: "get", - value: function get(key) { + value: function get(e) { var _superPropGet2; - var node = (_superPropGet2 = _superPropGet(Keyed, "get", this, 3)([key])) === null || _superPropGet2 === void 0 ? void 0 : _superPropGet2.deref(); - return node && keyed.get(node); + var t = (_superPropGet2 = _superPropGet(nt, "get", this, 3)([e])) === null || _superPropGet2 === void 0 ? void 0 : _superPropGet2.deref(); + return t && tt.get(t); } - - /** - * @param {any} key - * @param {Node} node - * @param {import('./rabbit.js').Hole} hole - */ - //@ts-ignore }, { key: "set", - value: function set(key, node, hole) { - keyed.set(node, hole); - //@ts-ignore - this._.register(node, key); - _superPropGet(Keyed, "set", this, 3)([key, new WeakRef(node)]); + value: function set(e, t, n) { + tt.set(t, n), this._.register(t, e), _superPropGet(nt, "set", this, 3)([e, new WeakRef(t)]); } }]); }(/*#__PURE__*/_wrapNativeSuper(Map)); - - //@ts-check - - - /** @typedef {globalThis.Element | globalThis.HTMLElement | globalThis.SVGSVGElement | globalThis.DocumentFragment} Container */ - - var parse$1 = parser({ - Comment: Comment, - DocumentType: DocumentType, - Text: Text, - Fragment: Fragment, - Element: Element, - Component: Component, - update: update - }); - - /** - * @param {boolean} xml - * @param {WeakMap} twm - * @returns - */ - var create$1 = function create(xml) { - var twm = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new WeakMap(); - return ( - /** - * @param {TemplateStringsArray | string[]} template - * @param {unknown[]} values - * @returns {Hole} - */ - function (template) { - var parsed = twm.get(template); - for (var _len = arguments.length, values = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { - values[_key - 1] = arguments[_key]; + var st = function (_ref6) { + var _ref6$Comment = _ref6.Comment, + e = _ref6$Comment === void 0 ? ee : _ref6$Comment, + _ref6$DocumentType = _ref6.DocumentType, + t = _ref6$DocumentType === void 0 ? te : _ref6$DocumentType, + _ref6$Text = _ref6.Text, + n = _ref6$Text === void 0 ? ne : _ref6$Text, + _ref6$Fragment = _ref6.Fragment, + s = _ref6$Fragment === void 0 ? re : _ref6$Fragment, + _ref6$Element = _ref6.Element, + i = _ref6$Element === void 0 ? ie : _ref6$Element, + _ref6$Component = _ref6.Component, + r = _ref6$Component === void 0 ? se : _ref6$Component, + _ref6$update = _ref6.update, + o = _ref6$update === void 0 ? de : _ref6$update; + return function (l, a, c) { + var u = l.join(oe).trim(), + d = new Set(), + f = []; + var p = new s(), + h = 0, + v = 0, + g = 0, + b = Q; + var _iterator6 = _createForOfIteratorHelper(u.matchAll(ce)), + _step6; + try { + for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) { + var _s0 = _step6.value; + if (0 < v) { + v--; + continue; + } + var _l5 = _s0[0], + _m = _s0.index; + if (h < _m && U(p, new n(u.slice(h, _m))), _l5 === oe) { + "table" === p.name && (p = U(p, new i("tbody", c)), d.add(p)); + var _t15 = U(p, new e("◦")); + f.push(o(_t15, 8, fe(_t15), "", a[g++])), h = _m + 1; + } else if (_l5.startsWith("", _m + 2); + if ("--\x3e" === u.slice(_n9 - 2, _n9 + 1)) { + var _t16 = u.slice(_m + 4, _n9 - 2); + "!" === _t16[0] && U(p, new e(_t16.slice(1).replace(/!$/, ""))); + } else U(p, new t(u.slice(_m + 2, _n9))); + h = _n9 + 1; + } else if (_l5.startsWith("", _m + 2); + c && "svg" === p.name && (c = !1), p = pe(p, d), h = _e16 + 1; + } else { + var _e17 = _m + _l5.length, + _t17 = u.indexOf(">", _e17), + _s1 = _l5.slice(1); + var _x = _s1; + if (_s1 === oe ? (_x = "template", p = U(p, new r()), b = fe(p).slice(1), f.push(o(p, q, b, "", a[g++]))) : (c || (_x = _x.toLowerCase(), "table" !== p.name || "tr" !== _x && "td" !== _x || (p = U(p, new i("tbody", c)), d.add(p)), "tbody" === p.name && "td" === _x && (p = U(p, new i("tr", c)), d.add(p))), p = U(p, new i(_x, !!c && "svg" !== _x)), b = Q), _e17 < _t17) { + var _n0 = !1; + var _iterator7 = _createForOfIteratorHelper(u.slice(_e17, _t17).matchAll(ue)), + _step7; + try { + for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) { + var _step7$value = _slicedToArray(_step7.value, 3), + _s10 = _step7$value[0], + _i4 = _step7$value[1], + _r6 = _step7$value[2]; + if (_r6 === oe || _r6 === le || _r6 === ae || (_n0 = _i4.endsWith(oe))) { + var _e18 = b === Q ? b = fe(p) : b; + f.push(o(p, 2, _e18, _n0 ? _i4.slice(0, -1) : _i4, a[g++])), _n0 = !1, v++; + } else X(p, _i4, !_r6 || _r6.slice(1, -1)); + } + } catch (err) { + _iterator7.e(err); + } finally { + _iterator7.f(); + } + b = Q; + } + h = _t17 + 1; + var _y = 0 < _t17 && "/" === u[_t17 - 1]; + if (c) _y && (p = p.parent);else if (_y || I.has(_x)) p = _y ? pe(p, d) : p.parent;else if ("svg" === _x) c = !0;else if (G.has(_x)) { + var _e19 = u.indexOf(""), h), + _t18 = u.slice(h, _e19); + _t18.trim() === oe ? (v++, f.push(o(p, 3, fe(p), "", a[g++]))) : U(p, new n(_t18)), p = p.parent, h = _e19 + _s1.length + 3, v++; + continue; + } + } + } + } catch (err) { + _iterator6.e(err); + } finally { + _iterator6.f(); } - if (!parsed) { - parsed = parse$1(template, values, xml); - parsed.push(isKeyed() ? new Keyed() : null); - parsed.push(template); - parsed[0] = fragment(parsed[0].toString(), xml); - twm.set(template, parsed); + return h < u.length && U(p, new n(u.slice(h))), [p, f]; + }; + }({ + Comment: ee, + DocumentType: te, + Text: ne, + Fragment: re, + Element: ie, + Component: se, + update: function update(e, t, n, s, i) { + switch (t) { + case q: + return [n, i, De]; + case 8: + return j(i) ? [n, Ee, 9] : i instanceof V ? [n, (r = e.xml, function (e, t) { + var _e$$e; + var n = (_e$$e = e[$e]) !== null && _e$$e !== void 0 ? _e$$e : e[$e] = {}; + n.v !== t && (n.f = Te(Ne(t, r)), n.v = t), Re(e, n.f); + }), 8192] : i instanceof W ? [n, Le, 32776] : [n, Re, 8]; + case 3: + return [n, Fe("textContent"), 2048]; + case 2: + { + var _t19 = e.type === q; + switch (s.at(0)) { + case "@": + { + var _e20 = j(i); + return [n, Je(s.slice(1), Symbol(s), _e20), _e20 ? 257 : 256]; + } + case "?": + return [n, Ve(s.slice(1)), 4096]; + case ".": + return "..." === s ? [n, _t19 ? F : Be, _t19 ? 144 : 128] : [n, Pe(s.slice(1)), _t19 ? 80 : 64]; + default: + return _t19 ? [n, Pe(s), 1040] : "aria" === s ? [n, We, 2] : "data" !== s || /^object$/i.test(e.name) ? "key" === s ? [n, ze = true, 512] : "ref" === s ? [n, Fe($e), 16384] : s.startsWith("on") ? [n, Fe(s.toLowerCase()), 64] : [n, Ae(s), 4] : [n, _e, 32]; + } + } } - return new Hole(parsed, values); + var r; } - ); - }; - var htmlHole = create$1(false); - var svgHole = create$1(true); - var rendered = new WeakMap(); - - /** - * @param {TemplateStringsArray | string[]} template - * @param {any[]} values - * @returns {Node | HTMLElement | Hole} - */ - function html(template) { - for (var _len2 = arguments.length, values = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { - values[_key2 - 1] = arguments[_key2]; + }), + it = function it(e) { + var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new WeakMap(); + return function (n) { + var i = t.get(n); + for (var _len = arguments.length, s = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + s[_key - 1] = arguments[_key]; + } + return i || (i = st(n, s, e), i.push(function () { + var e = ze; + return ze = false, e; + }() ? new nt() : null), i[0] = Ne(i[0].toString(), e), t.set(n, i)), new et(i, s); + }; + }, + rt = it(false), + ot = it(true), + lt = new WeakMap(); + function at(e) { + for (var _len2 = arguments.length, t = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { + t[_key2 - 1] = arguments[_key2]; } - var hole = htmlHole.apply(null, arguments); - return _get() ? hole.valueOf(true) : hole; + var n = rt.apply(null, arguments); + return Ge() ? n.valueOf(true) : n; } - - /** - * @param {TemplateStringsArray | string[]} template - * @param {any[]} values - * @returns {Node | SVGSVGElement | Hole} - */ - function svg(template) { - for (var _len3 = arguments.length, values = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) { - values[_key3 - 1] = arguments[_key3]; + function ct(e) { + for (var _len3 = arguments.length, t = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) { + t[_key3 - 1] = arguments[_key3]; } - var hole = svgHole.apply(null, arguments); - return _get() ? hole.valueOf(true) : hole; + var n = ot.apply(null, arguments); + return Ge() ? n.valueOf(true) : n; } - - /** - * @param {Container} where - * @param {Function | Node | Container} what - * @returns - */ - var render = function render(where, what) { - var known = rendered.get(where); - if (known) known[0](); - if (typeof what === 'function') { - _set(false); - var hole; - var scope = effectScope(function () { - hole = what(); + var ut = function ut(e, t) { + var n = lt.get(e); + if (n && n[0](), "function" == typeof t) { + var _i5; + qe(false); + var _r7 = function (e) { + var t = { + deps: void 0, + depsTail: void 0, + subs: void 0, + subsTail: void 0, + flags: 0 + }; + void 0 !== d && s(t, d); + var n = v(void 0), + i = g(t); + try { + e(); + } finally { + g(i), v(n); + } + return D.bind(t); + }(function () { + _i5 = t(); }); - //@ts-ignore - if (!known || known[1].t !== hole.t) { - //@ts-ignore - var d = hole.valueOf(false); - where.replaceChildren(d); - } else known[1].update(hole); - rendered.set(where, [scope, hole]); - } else { - _set(true); - rendered["delete"](where); - where.replaceChildren(what instanceof Hole ? dom(what) : diffFragment(what, 1)); - } - return where; + if (n && n[1].t === _i5.t) n[1].update(_i5);else { + var _t20 = _i5.valueOf(false); + e.replaceChildren(_t20); + } + lt.set(e, [_r7, _i5]); + } else qe(true), lt["delete"](e), e.replaceChildren(t instanceof et ? Ie(t) : xe(t, 1)); + return e; }; var umap = (function (_) { @@ -2416,17 +1742,17 @@ var uce = (function (exports) { }, { key: "render", get: function get() { - return render; + return ut; } }, { key: "html", get: function get() { - return html; + return at; } }, { key: "svg", get: function get() { - return svg; + return ct; } }, { key: "css", @@ -2439,14 +1765,22 @@ var uce = (function (exports) { this[method] = this[method].bind(this); } function content() { - return render(this, html.apply(null, arguments)); + return ut(this, at.apply(null, arguments)); } + exports.Hole = et; + exports.batch = M; + exports.computed = N; exports.css = css; exports.define = define; - exports.html = html; - exports.render = render; - exports.svg = svg; + exports.effect = x; + exports.fragment = Ne; + exports.html = at; + exports.render = ut; + exports.signal = L; + exports.svg = ct; + exports.unsafe = z; + exports.untracked = $; return exports; diff --git a/min.js b/min.js index 691b364..c8ac4da 100644 --- a/min.js +++ b/min.js @@ -1 +1 @@ -var uce=function(t){"use strict";function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},e(t)}function n(t){var n=function(t,n){if("object"!=e(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var i=r.call(t,n);if("object"!=e(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t,"string");return"symbol"==e(n)?n:n+""}function r(t,e){for(var r=0;r1&&void 0!==arguments[1]?arguments[1]:t.sub,n=t.dep,i=t.prevDep,o=t.nextDep,a=t.nextSub,u=t.prevSub;return void 0!==o?o.prevDep=i:e.depsTail=i,void 0!==i?i.nextDep=o:e.deps=o,void 0!==a?a.prevSub=u:n.subsTail=u,void 0!==u?u.nextSub=a:void 0===(n.subs=a)&&r(n),o}function a(t){do{var e=t.sub,r=e.flags;32==(48&r)&&(e.flags=16|r,2&r&&n(e))}while(void 0!==(t=t.nextSub))}function u(t,e){for(var n=e.depsTail;void 0!==n;){if(n===t)return!0;n=n.prevDep}return!1}}({update:function(t){return"getter"in t?function(t){var e=S(t);w(t);try{var n=t.value;return n!==(t.value=t.getter(n))}finally{S(e),m(t)}}(t):(e=t,n=t.value,e.flags=1,e.previousValue!==(e.previousValue=n));var e,n},notify:function t(e){var n=e.flags;if(!(64&n)){e.flags=64|n;var r=e.subs;void 0!==r&&t(r.sub)}},unwatched:function(t){if("getter"in t){var e=t.deps;if(void 0!==e){t.flags=17;do{e=y(e,t)}while(void 0!==e)}}else"previousValue"in t||O.call(t)}}),p=h.link,y=h.unlink;h.propagate,h.checkDirty;var b,g,m=h.endTracking,w=h.startTracking;function S(t){var e=b;return b=t,e}function x(t){var e=g;return g=t,e}function O(){for(var t=this.deps;void 0!==t;)t=y(t,this);var e=this.subs;void 0!==e&&y(e),this.flags=0}h.shallowPropagate;var k=function(t){d.push(S(void 0));try{return t()}finally{S(d.pop())}},A=function(){return i(function t(e,n){o(this,t),this._=e(n)},[{key:"value",get:function(){return this._()},set:function(t){this._(t)}},{key:"peek",value:function(){return k(this._)}},{key:"valueOf",value:function(){return this.value}}])}();function j(t,e,n){(function(t,e){if(e.has(t))throw new TypeError("Cannot initialize the same private elements twice on an object")})(t,e),e.set(t,n)}function E(t,e){return t.get(C(t,e))}function C(t,e,n){if("function"==typeof t?t===e:t.has(e))return arguments.length<3?e:n;throw new TypeError("Private element is not present on this object")}var T=Array.isArray,I=Object.assign,N=Object.defineProperties,D=Object.entries,P=Object.freeze,M=new WeakMap,R=function(){return i(function t(e){var n,r,i;o(this,t),j(this,M,void 0),r=this,i=e,(n=M).set(C(n,r),i)},[{key:"valueOf",value:function(){return E(M,this)}},{key:"toString",value:function(){return String(E(M,this))}}])}(),W=function(t){return document.createComment(t)};function _(t,e,n){return e=u(e),a(t,L()?Reflect.construct(e,n||[],u(t).constructor):e.apply(t,n))}function L(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(L=function(){return!!t})()}var B=42,$=new Set(["plaintext","script","style","textarea","title","xmp"]),J=new Set(["area","base","br","col","embed","hr","img","input","keygen","link","menuitem","meta","param","source","track","wbr"]),F=P({}),U=P([]),z=function(t,e){return t.children===U&&(t.children=[]),t.children.push(e),e.parent=t,e},V=function(t,e,n){t.props===F&&(t.props={}),t.props[e]=n},H=function(t,e,n){t!==e&&n.push(t)},q=function(){return i(function t(e){o(this,t),this.type=e,this.parent=null},[{key:"toJSON",value:function(){return[this.type,this.data]}}])}(),G=function(t){function e(t){var n;return o(this,e),(n=_(this,e,[8])).data=t,n}return l(e,t),i(e,[{key:"toString",value:function(){return"\x3c!--".concat(this.data,"--\x3e")}}])}(q),K=function(t){function e(t){var n;return o(this,e),(n=_(this,e,[10])).data=t,n}return l(e,t),i(e,[{key:"toString",value:function(){return"")}}])}(q),Q=function(t){function e(t){var n;return o(this,e),(n=_(this,e,[3])).data=t,n}return l(e,t),i(e,[{key:"toString",value:function(){return this.data}}])}(q),X=function(t){function e(){var t;return o(this,e),(t=_(this,e,[B])).name="template",t.props=F,t.children=U,t}return l(e,t),i(e,[{key:"toJSON",value:function(){var t=[B];return H(this.props,F,t),H(this.children,U,t),t}},{key:"toString",value:function(){var t="";for(var e in this.props){var n=this.props[e];null!=n&&("boolean"==typeof n?n&&(t+=" ".concat(e)):t+=" ".concat(e,'="').concat(n,'"'))}return"").concat(this.children.join(""),"")}}])}(q),Y=function(t){function e(t){var n,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return o(this,e),(n=_(this,e,[1])).name=t,n.xml=r,n.props=F,n.children=U,n}return l(e,t),i(e,[{key:"toJSON",value:function(){var t=[1,this.name,+this.xml];return H(this.props,F,t),H(this.children,U,t),t}},{key:"toString",value:function(){var t=this.xml,e=this.name,n=this.props,r=this.children,i=r.length,o="<".concat(e);for(var a in n){var u=n[a];null!=u&&("boolean"==typeof u?u&&(o+=t?" ".concat(a,'=""'):" ".concat(a)):o+=" ".concat(a,'="').concat(u,'"'))}if(i){o+=">";for(var c=!t&&$.has(e),l=0;l")}else o+=t?" />":J.has(e)?">":">");return o}}])}(q),Z=function(t){function e(){var t;return o(this,e),(t=_(this,e,[11])).name="#fragment",t.children=U,t}return l(e,t),i(e,[{key:"toJSON",value:function(){var t=[11];return H(this.children,U,t),t}},{key:"toString",value:function(){return this.children.join("")}}])}(q);function tt(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n element ").concat(JSON.stringify(String(n))," in template ").concat(rt(t)))},ot=function(t,e){return new SyntaxError("The text only <".concat(e,"> element requires explicit closing tag in template ").concat(rt(t)))},at=function(t,e){return new SyntaxError("Unclosed element <".concat(e,"> found in template ").concat(rt(t)))},ut=function(t){return new SyntaxError('Invalid content "=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,u=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return a=t.done,t},e:function(t){u=!0,o=t},f:function(){try{a||null==n.return||n.return()}finally{if(u)throw o}}}}function wt(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<\s]+/g,At=/([^\s/>=]+)(?:=(\x00|(?:(['"])[\s\S]*?\3)))?/g,jt=function(t,e,n,r,i){return[e,n,r]},Et=function(t){for(var e=[];t.parent;){switch(t.type){case B:case 1:"template"===t.name&&e.push(-1)}e.push(t.parent.children.indexOf(t)),t=t.parent}return e},Ct=function(t,e){do{t=t.parent}while(e.has(t));return t};function Tt(t){return function(t){if(Array.isArray(t))return tt(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||et(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var It,Nt=function(t,e){var n;return e<0?null==t?void 0:t.content:null==t||null===(n=t.childNodes)||void 0===n?void 0:n[e]},Dt=function(t,e){return e.reduceRight(Nt,t)},Pt=!1,Mt=function(t){var e=t.firstChild,n=t.lastChild,r=It||(It=document.createRange());return r.setStartAfter(e),r.setEndAfter(n),r.deleteContents(),e},Rt=function(t,e){return Pt&&11===t.nodeType?1/e<0?e?Mt(t):t.lastChild:e?t.valueOf():t.firstChild:t},Wt=Symbol("nodes"),_t={get:function(){return this.firstChild.parentNode}},Lt={value:function(t){Mt(this).replaceWith(t)}},Bt={value:function(){Mt(this).remove()}},$t={value:function(){var t=this.parentNode;if(t===this)this[Wt]===U&&(this[Wt]=Tt(this.childNodes));else{if(t){var e=this.firstChild,n=this.lastChild;for(this[Wt]=[e];e!==n;)this[Wt].push(e=e.nextSibling)}this.replaceChildren.apply(this,Tt(this[Wt]))}return this}};function Jt(t){var e=W("<>"),n=W("");return t.replaceChildren.apply(t,[e].concat(Tt(t.childNodes),[n])),Pt=!0,N(t,s(s(s(s(s(s(s({},Wt,{writable:!0,value:U}),"firstChild",{value:e}),"lastChild",{value:n}),"parentNode",_t),"valueOf",$t),"replaceWith",Lt),"remove",Bt))}Jt.prototype=DocumentFragment.prototype;function Ft(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=function(t,e){if(t){if("string"==typeof t)return Ut(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Ut(t,e):void 0}}(t))||e){n&&(t=n);var r=0,i=function(){};return{s:i,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,u=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return a=t.done,t},e:function(t){u=!0,o=t},f:function(){try{a||null==n.return||n.return()}finally{if(u)throw o}}}}function Ut(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n0&&void 0!==arguments[0]?arguments[0]:globalThis.document,n=e.createElement("template");return function(r){if(arguments.length>1&&void 0!==arguments[1]&&arguments[1])return t||(t=e.createRange()).selectNodeContents(e.createElementNS("http://www.w3.org/2000/svg","svg")),t.createContextualFragment(r);n.innerHTML=r;var i=n.content;return n=n.cloneNode(!1),i}}(document),qt=Symbol("ref"),Gt=function(t,e){var n,r=Ft(D(e));try{for(r.s();!(n=r.n()).done;){var i=nt(n.value,2),o=i[0],a=i[1],u="role"===o?o:"aria-".concat(o.toLowerCase());null==a?t.removeAttribute(u):t.setAttribute(u,a)}}catch(t){r.e(t)}finally{r.f()}},Kt=function(t){return function(e,n){null==n?e.removeAttribute(t):e.setAttribute(t,n)}},Qt=function(t,e){t[Wt]=function(t,e,n,r){for(var i=r.parentNode,o=e.length,a=t.length,u=o,c=0,l=0,f=null;cp-l)for(var g=n(t[c],0);l=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,u=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return a=t.done,t},e:function(t){u=!0,o=t},f:function(){try{a||null==n.return||n.return()}finally{if(u)throw o}}}}function ve(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n0&&void 0!==arguments[0]?arguments[0]:fe(),o=nt(this.t,3),a=o[0],u=o[1],c=o[2],l=document.importNode(a,!0),f=this.v,s=f.length,v=U;if(s!==u.length)throw yt(this.t[3],f);if(0",x+2);if(k<0)throw ut(t);if("--\x3e"===o.slice(k-2,k+1)){if(k-x<6)throw ft(t);var A=o.slice(x+4,k-2);"!"===A[0]&&z(d,new n(A.slice(1).replace(/!$/,"")))}else{if(!o.slice(x+2,k).toLowerCase().startsWith("doctype"))throw vt(t,o.slice(x+2,k));z(d,new i(o.slice(x+2,k)))}p=k+1}else if(S.startsWith("",x+2);if(j<0)throw ct(t);if(r&&"svg"===d.name&&(r=!1),!(d=Ct(d,l)))throw st(t);p=j+1}else{var E=x+S.length,C=o.indexOf(">",E),T=S.slice(1);if(C<0)throw at(t,T);var I=T;if(T===St?(I="template",d=z(d,new v),g=Et(d).slice(1),s.push(h(d,B,g,"",e[b++]))):(r||(I=I.toLowerCase(),"table"!==d.name||"tr"!==I&&"td"!==I||(d=z(d,new f("tbody",r)),l.add(d)),"tbody"===d.name&&"td"===I&&(d=z(d,new f("tr",r)),l.add(d))),d=z(d,new f(I,!!r&&"svg"!==I)),g=U),E"),p);if(F<0)throw ot(t,I);var H=o.slice(p,F);if(H.trim()===St)y++,s.push(h(d,3,Et(d),"",e[b++]));else{if(H.includes(St))throw it(t,I,H);z(d,new a(H))}if(!(d=d.parent))throw st(t);p=F+T.length+3,y++;continue}}}}}catch(t){m.e(t)}finally{m.f()}if(p1&&void 0!==arguments[1]?arguments[1]:new WeakMap;return function(n){for(var r,i=e.get(n),o=arguments.length,a=new Array(o>1?o-1:0),u=1;u1?e-1:0),r=1;r1?e-1:0),r=1;r0&&void 0!==arguments[0]?arguments[0]:{},n=t.all,r=void 0!==n&&n,i=t.shallow,o=void 0===i||i,a=t.useState,u=void 0===a?Be:a,c=t.getAttribute,l=void 0===c?function(t,e){return t.getAttribute(e)}:c;return function(t,n,i){var a=function(t,e,n,r,i,o){for(var a={},u=i!==Be,c=[n,r,u],l=_e(t),f=0;fe.length)&&(t=e.length);for(var n=0,r=Array(t);n=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,u=!0,a=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return u=e.done,e},e:function(e){a=!0,o=e},f:function(){try{u||null==n.return||n.return()}finally{if(a)throw o}}}}function S(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n1&&void 0!==arguments[1]?arguments[1]:e.sub,n=e.dep,i=e.prevDep,o=e.nextDep,u=e.nextSub,a=e.prevSub;return void 0!==o?o.prevDep=i:t.depsTail=i,void 0!==i?i.nextDep=o:t.deps=o,void 0!==u?u.prevSub=a:n.subsTail=a,void 0!==a?a.nextSub=u:void 0===(n.subs=u)&&r(n),o}function u(e){do{var t=e.sub,r=e.nextSub,i=t.flags;32==(48&i)&&(t.flags=16|i,2&i&&n(t)),e=r}while(void 0!==e)}function a(e,t){var n=t.depsTail;if(void 0!==n){var r=t.deps;do{if(r===e)return!0;if(r===n)break;r=r.nextDep}while(void 0!==r)}return!1}}({update:function(e){return"getter"in e?Q(e):X(e,e.value)},notify:function e(t){var n=t.flags;if(!(64&n)){t.flags=64|n;var r=t.subs;void 0!==r?e(r.sub):R[z++]=t}},unwatched:function(e){if("getter"in e){var t=e.deps;if(void 0!==t){e.flags=17;do{t=_(t,e)}while(void 0!==t)}}else"previousValue"in e||ne.call(e)}}),W=M.link,_=M.unlink,L=M.propagate,B=M.checkDirty,I=M.endTracking,F=M.startTracking,J=M.shallowPropagate,$=0,V=0,z=0;function H(e){var t=D;return D=e,t}function U(e){var t=P;return P=e,t}function q(e){return te.bind({previousValue:e,value:e,subs:void 0,subsTail:void 0,flags:1})}function G(e){return ee.bind({value:void 0,subs:void 0,subsTail:void 0,deps:void 0,depsTail:void 0,flags:17,getter:e})}function K(e){var t={fn:e,subs:void 0,subsTail:void 0,deps:void 0,depsTail:void 0,flags:2};void 0!==D?W(t,D):void 0!==P&&W(t,P);var n=H(t);try{t.fn()}finally{H(n)}return ne.bind(t)}function Q(e){var t=H(e);F(e);try{var n=e.value;return n!==(e.value=e.getter(n))}finally{H(t),I(e)}}function X(e,t){return e.flags=1,e.previousValue!==(e.previousValue=t)}function Y(e,t){if(16&t||32&t&&B(e.deps,e)){var n=H(e);F(e);try{e.fn()}finally{H(n),I(e)}}else{32&t&&(e.flags=-33&t);for(var r=e.deps;void 0!==r;){var i=r.dep,o=i.flags;64&o&&Y(i,i.flags=-65&o),r=r.nextDep}}}function Z(){for(;V1&&void 0!==arguments[1]?arguments[1]:re).greedy;return void 0!==t&&t?new ae(e):new oe(q,e)};var ce,fe=function(e){le=e},se=Array.isArray,ve=Object.assign,de=Object.defineProperties,pe=Object.entries,he=Object.freeze,ye=new WeakMap,be=function(){return i(function e(t){o(this,e),k(this,ye,void 0),function(e,t,n){e.set(x(e,t),n)}(ye,this,t)},[{key:"valueOf",value:function(){return O(ye,this)}},{key:"toString",value:function(){return String(O(ye,this))}}])}(),ge=function(e){return document.createComment(e)},me=42,we=new Set(["plaintext","script","style","textarea","title","xmp"]),Se=new Set(["area","base","br","col","embed","hr","img","input","keygen","link","menuitem","meta","param","source","track","wbr"]),ke=he({}),Oe=he([]),xe=function(e,t){return e.children===Oe&&(e.children=[]),e.children.push(t),t.parent=e,t},je=function(e,t,n){e.props===ke&&(e.props={}),e.props[t]=n},Ce=function(e,t,n){e!==t&&n.push(e)},Te=function(){return i(function e(t){o(this,e),this.type=t,this.parent=null},[{key:"toJSON",value:function(){return[this.type,this.data]}}])}(),Ae=function(e){function t(e){var n;return o(this,t),(n=T(this,t,[8])).data=e,n}return c(t,e),i(t,[{key:"toString",value:function(){return"\x3c!--".concat(this.data,"--\x3e")}}])}(Te),Ee=function(e){function t(e){var n;return o(this,t),(n=T(this,t,[10])).data=e,n}return c(t,e),i(t,[{key:"toString",value:function(){return"")}}])}(Te),De=function(e){function t(e){var n;return o(this,t),(n=T(this,t,[3])).data=e,n}return c(t,e),i(t,[{key:"toString",value:function(){return this.data}}])}(Te),Pe=function(e){function t(){var e;return o(this,t),(e=T(this,t,[me])).name="template",e.props=ke,e.children=Oe,e}return c(t,e),i(t,[{key:"toJSON",value:function(){var e=[me];return Ce(this.props,ke,e),Ce(this.children,Oe,e),e}},{key:"toString",value:function(){var e="";for(var t in this.props){var n=this.props[t];null!=n&&("boolean"==typeof n?n&&(e+=" ".concat(t)):e+=" ".concat(t,'="').concat(n,'"'))}return"").concat(this.children.join(""),"")}}])}(Te),Ne=function(e){function t(e){var n,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return o(this,t),(n=T(this,t,[1])).name=e,n.xml=r,n.props=ke,n.children=Oe,n}return c(t,e),i(t,[{key:"toJSON",value:function(){var e=[1,this.name,+this.xml];return Ce(this.props,ke,e),Ce(this.children,Oe,e),e}},{key:"toString",value:function(){var e=this.xml,t=this.name,n=this.props,r=this.children,i=r.length,o="<".concat(t);for(var u in n){var a=n[u];null!=a&&("boolean"==typeof a?a&&(o+=e?" ".concat(u,'=""'):" ".concat(u)):o+=" ".concat(u,'="').concat(a,'"'))}if(i){o+=">";for(var l=!e&&we.has(t),c=0;c")}else o+=e?" />":Se.has(t)?">":">");return o}}])}(Te),Re=function(e){function t(){var e;return o(this,t),(e=T(this,t,[11])).name="#fragment",e.children=Oe,e}return c(t,e),i(t,[{key:"toJSON",value:function(){var e=[11];return Ce(this.children,Oe,e),e}},{key:"toString",value:function(){return this.children.join("")}}])}(Te),Me="\0",We='"'.concat(Me,'"'),_e="'".concat(Me,"'"),Le=/\x00|<[^><\s]+/g,Be=/([^\s/>=]+)(?:=(\x00|(?:(['"])[\s\S]*?\3)))?/g,Ie=function(e,t,n,r,i){return[t,n,r]},Fe=function(e){for(var t=[];e.parent;){switch(e.type){case me:case 1:"template"===e.name&&t.push(-1)}t.push(e.parent.children.indexOf(e)),e=e.parent}return t},Je=function(e,t){do{e=e.parent}while(t.has(e));return e},$e=function(e,t){return t<0?e.content:e.childNodes[t]},Ve=function(e,t){return t.reduceRight($e,e)},ze=!1,He=function(e){var t=e.firstChild,n=e.lastChild,r=ce||(ce=document.createRange());return r.setStartAfter(t),r.setEndAfter(n),r.deleteContents(),t},Ue=function(e,t){return ze&&11===e.nodeType?1/t<0?t?He(e):e.lastChild:t?e.valueOf():e.firstChild:e},qe=Symbol("nodes"),Ge={get:function(){return this.firstChild.parentNode}},Ke={value:function(e){He(this).replaceWith(e)}},Qe={value:function(){He(this).remove()}},Xe={value:function(){var e=this.parentNode;if(e===this)this[qe]===Oe&&(this[qe]=y(this.childNodes));else{if(e){var t=this.firstChild,n=this.lastChild;for(this[qe]=[t];t!==n;)this[qe].push(t=t.nextSibling)}this.replaceChildren.apply(this,y(this[qe]))}return this}};function Ye(e){var t=ge("<>"),n=ge("");return e.replaceChildren.apply(e,[t].concat(y(e.childNodes),[n])),ze=!0,de(e,h(h(h(h(h(h(h({},qe,{writable:!0,value:Oe}),"firstChild",{value:t}),"lastChild",{value:n}),"parentNode",Ge),"valueOf",Xe),"replaceWith",Ke),"remove",Qe))}Ye.prototype=DocumentFragment.prototype;var Ze=16,et=function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:globalThis.document,n=t.createElement("template");return function(r){if(arguments.length>1&&void 0!==arguments[1]&&arguments[1])return e||(e=t.createRange()).selectNodeContents(t.createElementNS("http://www.w3.org/2000/svg","svg")),e.createContextualFragment(r);n.innerHTML=r;var i=n.content;return n=n.cloneNode(!1),i}}(document),tt=Symbol("ref"),nt=function(e,t){var n,r=w(pe(t));try{for(r.s();!(n=r.n()).done;){var i=p(n.value,2),o=i[0],u=i[1],a="role"===o?o:"aria-".concat(o.toLowerCase());null==u?e.removeAttribute(a):e.setAttribute(a,u)}}catch(e){r.e(e)}finally{r.f()}},rt=function(e){return function(t,n){null==n?t.removeAttribute(e):t.setAttribute(e,n)}},it=function(e,t){e[qe]=function(e,t,n,r){for(var i=r.parentNode,o=t.length,u=e.length,a=o,l=0,c=0,f=null;lh-c)for(var g=n(e[l],0);c0&&void 0!==arguments[0]?arguments[0]:gt(),o=p(this.t,3),u=o[0],a=o[1],l=o[2],c=document.importNode(u,!0),f=this.v,s=f.length,v=Oe;if(0",x+2);if("--\x3e"===a.slice(C-2,C+1)){var T=a.slice(x+4,C-2);"!"===T[0]&&xe(d,new n(T.slice(1).replace(/!$/,"")))}else xe(d,new i(a.slice(x+2,C)));y=C+1}else if(O.startsWith("",x+2);r&&"svg"===d.name&&(r=!1),d=Je(d,c),y=A+1}else{var E=x+O.length,D=a.indexOf(">",E),P=O.slice(1),N=P;if(P===Me?(N="template",d=xe(d,new v),m=Fe(d).slice(1),s.push(h(d,me,m,"",t[g++]))):(r||(N=N.toLowerCase(),"table"!==d.name||"tr"!==N&&"td"!==N||(d=xe(d,new f("tbody",r)),c.add(d)),"tbody"===d.name&&"td"===N&&(d=xe(d,new f("tr",r)),c.add(d))),d=xe(d,new f(N,!!r&&"svg"!==N)),m=Oe),E"),y),$=a.slice(y,J);$.trim()===Me?(b++,s.push(h(d,3,Fe(d),"",t[g++]))):xe(d,new u($)),d=d.parent,y=J+P.length+3,b++;continue}}}}}catch(e){S.e(e)}finally{S.f()}return y1&&void 0!==arguments[1]?arguments[1]:new WeakMap;return function(n){for(var r=t.get(n),i=arguments.length,o=new Array(i>1?i-1:0),u=1;u1?t-1:0),r=1;r1?t-1:0),r=1;r0&&void 0!==arguments[0]?arguments[0]:{},n=e.all,r=void 0!==n&&n,i=e.shallow,o=void 0===i||i,u=e.useState,a=void 0===u?Jt:u,l=e.getAttribute,c=void 0===l?function(e,t){return e.getAttribute(t)}:l;return function(e,n,i){var u=function(e,t,n,r,i,o){for(var u={},a=i!==Jt,l=[n,r,a],c=It(e),f=0;f{n.push(d(void 0));try{return e()}finally{d(n.pop())}};class g{constructor(e,t){this._=e(t)}get value(){return this._()}set value(e){this._(e)}peek(){return v(this._)}valueOf(){return this.value}}const{isArray:m}=Array,{assign:b,defineProperties:w,entries:y,freeze:x}=Object;class S{#e;constructor(e){this.#e=e}valueOf(){return this.#e}toString(){return String(this.#e)}}const $=e=>document.createComment(e),k=42,C=new Set(["plaintext","script","style","textarea","title","xmp"]),E=new Set(["area","base","br","col","embed","hr","img","input","keygen","link","menuitem","meta","param","source","track","wbr"]),O=x({}),T=x([]),N=(e,t)=>(e.children===T&&(e.children=[]),e.children.push(t),t.parent=e,t),D=(e,t,n)=>{e.props===O&&(e.props={}),e.props[t]=n},A=(e,t,n)=>{e!==t&&n.push(e)};class W{constructor(e){this.type=e,this.parent=null}toJSON(){return[this.type,this.data]}}class M extends W{constructor(e){super(8),this.data=e}toString(){return`\x3c!--${this.data}--\x3e`}}class L extends W{constructor(e){super(10),this.data=e}toString(){return``}}class j extends W{constructor(e){super(3),this.data=e}toString(){return this.data}}class I extends W{constructor(){super(k),this.name="template",this.props=O,this.children=T}toJSON(){const e=[k];return A(this.props,O,e),A(this.children,T,e),e}toString(){let e="";for(const t in this.props){const n=this.props[t];null!=n&&("boolean"==typeof n?n&&(e+=` ${t}`):e+=` ${t}="${n}"`)}return`${this.children.join("")}`}}class P extends W{constructor(e,t=!1){super(1),this.name=e,this.xml=t,this.props=O,this.children=T}toJSON(){const e=[1,this.name,+this.xml];return A(this.props,O,e),A(this.children,T,e),e}toString(){const{xml:e,name:t,props:n,children:s}=this,{length:i}=s;let r=`<${t}`;for(const t in n){const s=n[t];null!=s&&("boolean"==typeof s?s&&(r+=e?` ${t}=""`:` ${t}`):r+=` ${t}="${s}"`)}if(i){r+=">";for(let n=!e&&C.has(t),o=0;o`}else r+=e?" />":E.has(t)?">":`>`;return r}}class R extends W{constructor(){super(11),this.name="#fragment",this.children=T}toJSON(){const e=[11];return A(this.children,T,e),e}toString(){return this.children.join("")}}const J=e=>(e?.raw||e)?.join?.(",")||"unknown";var _=(e,t,n)=>new SyntaxError(`Mixed text and interpolations found in text only <${t}> element ${JSON.stringify(String(n))} in template ${J(e)}`),F=(e,t)=>new SyntaxError(`The text only <${t}> element requires explicit closing tag in template ${J(e)}`),B=(e,t)=>new SyntaxError(`Unclosed element <${t}> found in template ${J(e)}`),V=e=>new SyntaxError(`Invalid content "new SyntaxError(`Invalid closing tag: new SyntaxError(`Invalid content: NUL char \\x00 found in template: ${J(e)}`),U=e=>new SyntaxError(`Invalid comment: no closing --\x3e found in template ${J(e)}`),q=e=>new SyntaxError(`Too many closing tags found in template ${J(e)}`),G=(e,t)=>new SyntaxError(`Invalid doctype: ${t} found in template ${J(e)}`),K=e=>new SyntaxError(`Invalid template - the amount of values does not match the amount of updates: ${J(e)}`),Q=(e,t)=>new SyntaxError(`Invalid path - unreachable node at the path [${t.join(", ")}] found in template ${J(e)}`),X=(e,t)=>new SyntaxError(`Invalid ${t} attribute in template definition\n${J(e)}`),Y=(e,t)=>new SyntaxError(`Invalid interpolation - expected hole or array: ${String(t)} found in template ${J(e)}`),Z=e=>new SyntaxError(`Invalid key attribute or position in template: ${String(e)}`),ee=e=>new SyntaxError(`Invalid component: ${String(e)}`);const te="\0",ne=`"${te}"`,se=`'${te}'`,ie=/\x00|<[^><\s]+/g,re=/([^\s/>=]+)(?:=(\x00|(?:(['"])[\s\S]*?\3)))?/g,oe=(e,t,n,s,i)=>[t,n,s],le=e=>{const t=[];for(;e.parent;){switch(e.type){case k:case 1:"template"===e.name&&t.push(-1)}t.push(e.parent.children.indexOf(e)),e=e.parent}return t},ae=(e,t)=>{do{e=e.parent}while(t.has(e));return e};const ce=(e,t)=>t<0?e?.content:e?.childNodes?.[t];var ue=(e,t)=>t.reduceRight(ce,e);let fe,de=!1;const he=({firstChild:e,lastChild:t})=>{const n=fe||(fe=document.createRange());return n.setStartAfter(e),n.setEndAfter(t),n.deleteContents(),e},pe=(e,t)=>de&&11===e.nodeType?1/t<0?t?he(e):e.lastChild:t?e.valueOf():e.firstChild:e,ve=Symbol("nodes"),ge={get(){return this.firstChild.parentNode}},me={value(e){he(this).replaceWith(e)}},be={value(){he(this).remove()}},we={value(){const{parentNode:e}=this;if(e===this)this[ve]===T&&(this[ve]=[...this.childNodes]);else{if(e){let{firstChild:e,lastChild:t}=this;for(this[ve]=[e];e!==t;)this[ve].push(e=e.nextSibling)}this.replaceChildren(...this[ve])}return this}};function ye(e){const t=$("<>"),n=$("");return e.replaceChildren(t,...e.childNodes,n),de=!0,w(e,{[ve]:{writable:!0,value:T},firstChild:{value:t},lastChild:{value:n},parentNode:ge,valueOf:we,replaceWith:me,remove:be})}ye.prototype=DocumentFragment.prototype;const xe=16,Se=32768,$e=((e=globalThis.document)=>{let t,n=e.createElement("template");return(s,i=!1)=>{if(i)return t||(t=e.createRange(),t.selectNodeContents(e.createElementNS("http://www.w3.org/2000/svg","svg"))),t.createContextualFragment(s);n.innerHTML=s;const r=n.content;return n=n.cloneNode(!1),r}})(document),ke=Symbol("ref"),Ce=(e,t)=>{for(const[n,s]of y(t)){const t="role"===n?n:`aria-${n.toLowerCase()}`;null==s?e.removeAttribute(t):e.setAttribute(t,s)}},Ee=e=>(t,n)=>{null==n?t.removeAttribute(e):t.setAttribute(e,n)},Oe=(e,t)=>{e[ve]=((e,t,n,s)=>{const i=s.parentNode,r=t.length;let o=e.length,l=r,a=0,c=0,u=null;for(;as-c){const r=n(e[a],0);for(;c{const n="object"==typeof t?t??e:((e,t)=>{let n=Te.get(e);return n?n.data=t:Te.set(e,n=document.createTextNode(t)),n})(e,t),s=e[ve]??e;n!==s&&s.replaceWith(pe(e[ve]=n,1))},De=(e,t)=>{Ne(e,t instanceof g?t.value:t)},Ae=({dataset:e},t)=>{for(const[n,s]of y(t))null==s?delete e[n]:e[n]=s},We=new Map,Me=e=>{let t=We.get(e);return t||We.set(e,t=Le(e)),t},Le=e=>(t,n)=>{t[e]=n},je=(e,t)=>{for(const[n,s]of y(t))Ee(n)(e,s)},Ie=(e,t,n)=>n?(n,s)=>{const i=n[t];i?.length&&n.removeEventListener(e,...i),s&&n.addEventListener(e,...s),n[t]=s}:(n,s)=>{const i=n[t];i&&n.removeEventListener(e,i),s&&n.addEventListener(e,s),n[t]=s},Pe=e=>(t,n)=>{t.toggleAttribute(e,!!n)};let Re=!1;let Je=!0;const _e=e=>{Je=e},Fe=()=>Je,Be=e=>pe(e.n?e.update(e):e.valueOf(!1),1),Ve=(e,t)=>{const n=[],s=e.length,i=t.length;for(let r,o,l=0,a=0;a{n.length;const s=Fe();s&&_e(!s);try{return e(t,Ge)}finally{s&&_e(s)}},He=(e,t)=>(e.t===t.t?e.update(t):(e.n.replaceWith(Be(t)),e=t),e),Ue=(e,t,n)=>{let i,r=[],o=[xe,null,n],l=!0;return function(e){const t={fn:e,subs:void 0,subsTail:void 0,deps:void 0,depsTail:void 0,flags:2};void 0!==u?s(t,u):void 0!==f&&s(t,f);const n=d(t);try{t.fn()}finally{d(n)}p.bind(t)}(()=>{if(l)l=!1,i=ze(t,n,r),r.length||(r=T),i?(e.replaceWith(Be(i)),o[1]=i):e.remove();else{const e=ze(t,n,r);if(i){if(!(e instanceof Ke))throw ee(t);He(i,e)===e&&(o[2]=i=e)}}}),o},qe=Symbol(),Ge={};class Ke{constructor(e,t){this.t=e,this.v=t,this.n=null,this.k=-1}valueOf(e=Fe()){const[t,n,s]=this.t,i=document.importNode(t,!0),r=this.v;let o,l,a,c=r.length,u=T;if(c!==n.length)throw Y(this.t[3],r);if(0{for(const t of e){const e=t[ke];"function"==typeof e?e(t):e instanceof g?e.value=t:e&&(e.current=t)}})(a)}const{childNodes:f}=i,d=f.length,h=1===d?f[0]:d?ye(i):i;return this.v=u,this.n=h,-1e.t[2].get(t)?.update(e)??e.valueOf(!1))(e,s[t]);let{length:i}=n;for(;i--;){const e=n[i],[t,r,o]=e;if(512===t)continue;let l=s[i];if(t&xe)if(t===xe){if("function"!=typeof l)throw ee(l);const t=l(o,Ge);if(r){if(!(t instanceof Ke))throw ee(l);He(r,t)===t&&(e[2]=t)}}else r(o,l);else{let n=l;if(1&t){if(!m(l))throw Y([],l);if(8&t){if(l.length&&l[0]instanceof Ke){if(o.length&&!(o[0]instanceof Ke))throw Y([],l[0]);n=Ve(o,l)}}else if(256&t&&l[0]===o[0])continue}else if(8&t)if(t&Se){if(l===o){r(e[3],n);continue}}else if(o instanceof Ke){if(!(l instanceof Ke))throw Y([],l);l=He(o,l),n=l.n}l!==o&&(e[2]=l,r(e[3],n))}}return this.n}}const Qe=new WeakMap;class Xe extends Map{constructor(){super()._=new FinalizationRegistry(e=>this.delete(e))}get(e){const t=super.get(e)?.deref();return t&&Qe.get(t)}set(e,t,n){Qe.set(t,n),this._.register(t,e),super.set(e,new WeakRef(t))}}const Ye=(({Comment:e=M,DocumentType:t=L,Text:n=j,Fragment:s=R,Element:i=P,Component:r=I,update:o=oe})=>(l,a,c)=>{if(l.some(e=>e.includes(te)))throw H(l);const u=l.join(te).trim();if(u.replace(/(\S+)=(['"])([\S\s]+?)\2/g,(...e)=>/^[^\x00]+\x00|\x00[^\x00]+$/.test(e[3])?c=e[1]:e[0])!==u)throw X(l,c);const f=new Set,d=[];let h=new s,p=0,v=0,g=0,m=T;for(const s of u.matchAll(ie)){if(0",w+2);if(n<0)throw V(l);if("--\x3e"===u.slice(n-2,n+1)){if(n-w<6)throw U(l);const t=u.slice(w+4,n-2);"!"===t[0]&&N(h,new e(t.slice(1).replace(/!$/,"")))}else{if(!u.slice(w+2,n).toLowerCase().startsWith("doctype"))throw G(l,u.slice(w+2,n));N(h,new t(u.slice(w+2,n)))}p=n+1}else if(b.startsWith("",w+2);if(e<0)throw z(l);if(c&&"svg"===h.name&&(c=!1),h=ae(h,f),!h)throw q(l);p=e+1}else{const e=w+b.length,t=u.indexOf(">",e),s=b.slice(1);if(t<0)throw B(l,s);let y=s;if(s===te?(y="template",h=N(h,new r),m=le(h).slice(1),d.push(o(h,k,m,"",a[g++]))):(c||(y=y.toLowerCase(),"table"!==h.name||"tr"!==y&&"td"!==y||(h=N(h,new i("tbody",c)),f.add(h)),"tbody"===h.name&&"td"===y&&(h=N(h,new i("tr",c)),f.add(h))),h=N(h,new i(y,!!c&&"svg"!==y)),m=T),e`,p);if(e<0)throw F(l,y);const t=u.slice(p,e);if(t.trim()===te)v++,d.push(o(h,3,le(h),"",a[g++]));else{if(t.includes(te))throw _(l,y,t);N(h,new n(t))}if(h=h.parent,!h)throw q(l);p=e+s.length+3,v++;continue}}}if(p{switch(t){case k:return[n,i,xe];case 8:return m(i)?[n,Oe,9]:i instanceof S?[n,(r=e.xml,(e,t)=>{const n=e[ke]??(e[ke]={});n.v!==t&&(n.f=ye($e(t,r)),n.v=t),Ne(e,n.f)}),8192]:i instanceof g?[n,De,32776]:[n,Ne,8];case 3:return[n,Me("textContent"),2048];case 2:{const t=e.type===k;switch(s.at(0)){case"@":{if(t)throw X([],s);const e=m(i);return[n,Ie(s.slice(1),Symbol(s),e),e?257:256]}case"?":if(t)throw X([],s);return[n,Pe(s.slice(1)),4096];case".":return"..."===s?[n,t?b:je,t?144:128]:[n,Le(s.slice(1)),t?80:64];default:if(t)return[n,Le(s),1040];if("aria"===s)return[n,Ce,2];if("data"===s&&!/^object$/i.test(e.name))return[n,Ae,32];if("key"===s){if(1(n,...s)=>{let i=t.get(n);return i||(i=Ye(n,s,e),i.push((()=>{const e=Re;return Re=!1,e})()?new Xe:null),i.push(n),i[0]=$e(i[0].toString(),e),t.set(n,i)),new Ke(i,s)},et=Ze(!1),tt=Ze(!0),nt=new WeakMap;function st(e,...t){const n=et.apply(null,arguments);return Fe()?n.valueOf(!0):n}function it(e,...t){const n=tt.apply(null,arguments);return Fe()?n.valueOf(!0):n}const rt=(e,t)=>{const n=nt.get(e);if(n&&n[0](),"function"==typeof t){let i;_e(!1);const r=function(e){const t={deps:void 0,depsTail:void 0,subs:void 0,subsTail:void 0,flags:0};void 0!==f&&s(t,f);const n=d(void 0),i=h(t);try{e()}finally{h(i),d(n)}return p.bind(t)}(()=>{i=t()});if(n&&n[1].t===i.t)n[1].update(i);else{const t=i.valueOf(!1);e.replaceChildren(t)}nt.set(e,[r,i])}else _e(!0),nt.delete(e),e.replaceChildren(t instanceof Ke?Be(t):pe(t,1));return e};function ot(e){for(var t=e[0],n=1,s=arguments.length;n({configurable:!0,get:()=>s,set(r){(e||r!==s||t&&"object"==typeof r&&r)&&(s=r,n?i.call(this,s):i.call(this))}}),ut=()=>{};const ft=(({all:e=!1,shallow:t=!0,useState:n=ut,getAttribute:s=(e,t)=>e.getAttribute(t)}={})=>(i,r,o)=>{const l=((e,t,n,s,i,r)=>{const o={},l=i!==ut,a=[n,s,l];for(let n=at(e),s=0;s{let n=e[t],r=typeof n;return i.hasOwnProperty(t)?(n=i[t],delete i[t]):i.hasAttribute(t)&&(n=s(i,t),"number"==r?n=+n:"boolean"==r&&(n=!/^(?:false|0|)$/.test(n))),n},e,t,n,o);return lt(i,l)})({}),dt=customElements,{define:ht}=dt,{parse:pt,stringify:vt}=JSON,{create:gt,defineProperties:mt,getOwnPropertyDescriptor:bt,keys:wt}=Object,yt="element",xt=new WeakMap,St=($t=new Map([[yt,{c:HTMLElement,e:yt}]]),{get:e=>$t.get(e),set:(e,t)=>($t.set(e,t),t)});var $t;const kt=e=>document.createElement(e),Ct=e=>St.get(e)||St.set(e,{c:kt(e).constructor,e:e}),Et=(e,t)=>{const{attachShadow:n,attributeChanged:s,bound:i,connected:r,disconnected:o,formAssociated:l,handleEvent:a,init:c,observedAttributes:u,props:f,render:d,style:h}=t,p=new WeakMap,v={},g={},m=[],b=gt(null),w=(e,t,s)=>{if(!p.has(e)){p.set(e,0),mt(e,{html:{configurable:!0,value:Tt.bind(n?e.attachShadow(n):e)}});for(let t=0;t"getter"in e?w(e):S(e,e.value),notify:function e(t){const n=t.flags;if(!(64&n)){t.flags=64|n;const i=t.subs;void 0!==i?e(i.sub):s[v++]=t}},unwatched(e){if("getter"in e){let t=e.deps;if(void 0!==t){e.flags=17;do{t=r(t,e)}while(void 0!==t)}}else"previousValue"in e||D.call(e)}});let d,f,h=0,p=0,v=0;function g(e){const t=d;return d=e,t}function b(e){const t=f;return f=e,t}function m(e){return O.bind({previousValue:e,value:e,subs:void 0,subsTail:void 0,flags:1})}function y(e){return T.bind({value:void 0,subs:void 0,subsTail:void 0,deps:void 0,depsTail:void 0,flags:17,getter:e})}function x(e){const t={fn:e,subs:void 0,subsTail:void 0,deps:void 0,depsTail:void 0,flags:2};void 0!==d?i(t,d):void 0!==f&&i(t,f);const n=g(t);try{t.fn()}finally{g(n)}return D.bind(t)}function w(e){const t=g(e);c(e);try{const t=e.value;return t!==(e.value=e.getter(t))}finally{g(t),a(e)}}function S(e,t){return e.flags=1,e.previousValue!==(e.previousValue=t)}function k(e,t){if(16&t||32&t&&l(e.deps,e)){const t=g(e);c(e);try{e.fn()}finally{g(t),a(e)}return}32&t&&(e.flags=-33&t);let n=e.deps;for(;void 0!==n;){const e=n.dep,t=e.flags;64&t&&k(e,e.flags=-65&t),n=n.nextDep}}function C(){for(;p{n.push(g(void 0));try{return e()}finally{g(n.pop())}};class A{constructor(e,t){this._=e(t)}get value(){return this._()}set value(e){this._(e)}peek(){return N(this._)}valueOf(){return this.value}}class W extends A{constructor(e){super(y,e)}get value(){return this._()}set value(e){throw new Error("Computed values are read-only")}}class E extends A{constructor(e){super(m,[e])}get value(){return super.value[0]}set value(e){super.value=[e]}peek(){return super.peek()[0]}}let M=(e,{greedy:t=!1}=$)=>t?new E(e):new A(m,e);const L=e=>{M=e},{isArray:j}=Array,{assign:P,defineProperties:R,entries:_,freeze:F}=Object;class J{#e;constructor(e){this.#e=e}valueOf(){return this.#e}toString(){return String(this.#e)}}const B=e=>document.createComment(e),V=42,H=new Set(["plaintext","script","style","textarea","title","xmp"]),z=new Set(["area","base","br","col","embed","hr","img","input","keygen","link","menuitem","meta","param","source","track","wbr"]),q=F({}),G=F([]),I=(e,t)=>(e.children===G&&(e.children=[]),e.children.push(t),t.parent=e,t),K=(e,t,n)=>{e.props===q&&(e.props={}),e.props[t]=n},Q=(e,t,n)=>{e!==t&&n.push(e)};class U{constructor(e){this.type=e,this.parent=null}toJSON(){return[this.type,this.data]}}class X extends U{constructor(e){super(8),this.data=e}toString(){return`\x3c!--${this.data}--\x3e`}}class Y extends U{constructor(e){super(10),this.data=e}toString(){return``}}class Z extends U{constructor(e){super(3),this.data=e}toString(){return this.data}}class ee extends U{constructor(){super(V),this.name="template",this.props=q,this.children=G}toJSON(){const e=[V];return Q(this.props,q,e),Q(this.children,G,e),e}toString(){let e="";for(const t in this.props){const n=this.props[t];null!=n&&("boolean"==typeof n?n&&(e+=` ${t}`):e+=` ${t}="${n}"`)}return`${this.children.join("")}`}}class te extends U{constructor(e,t=!1){super(1),this.name=e,this.xml=t,this.props=q,this.children=G}toJSON(){const e=[1,this.name,+this.xml];return Q(this.props,q,e),Q(this.children,G,e),e}toString(){const{xml:e,name:t,props:n,children:s}=this,{length:i}=s;let r=`<${t}`;for(const t in n){const s=n[t];null!=s&&("boolean"==typeof s?s&&(r+=e?` ${t}=""`:` ${t}`):r+=` ${t}="${s}"`)}if(i){r+=">";for(let n=!e&&H.has(t),o=0;o`}else r+=e?" />":z.has(t)?">":`>`;return r}}class ne extends U{constructor(){super(11),this.name="#fragment",this.children=G}toJSON(){const e=[11];return Q(this.children,G,e),e}toString(){return this.children.join("")}}const se="\0",ie=`"${se}"`,re=`'${se}'`,oe=/\x00|<[^><\s]+/g,le=/([^\s/>=]+)(?:=(\x00|(?:(['"])[\s\S]*?\3)))?/g,ae=(e,t,n,s,i)=>[t,n,s],ce=e=>{const t=[];for(;e.parent;){switch(e.type){case V:case 1:"template"===e.name&&t.push(-1)}t.push(e.parent.children.indexOf(e)),e=e.parent}return t},ue=(e,t)=>{do{e=e.parent}while(t.has(e));return e},de=(e,t)=>t<0?e.content:e.childNodes[t];var fe=(e,t)=>t.reduceRight(de,e);let he,pe=!1;const ve=({firstChild:e,lastChild:t})=>{const n=he||(he=document.createRange());return n.setStartAfter(e),n.setEndAfter(t),n.deleteContents(),e},ge=(e,t)=>pe&&11===e.nodeType?1/t<0?t?ve(e):e.lastChild:t?e.valueOf():e.firstChild:e,be=Symbol("nodes"),me={get(){return this.firstChild.parentNode}},ye={value(e){ve(this).replaceWith(e)}},xe={value(){ve(this).remove()}},we={value(){const{parentNode:e}=this;if(e===this)this[be]===G&&(this[be]=[...this.childNodes]);else{if(e){let{firstChild:e,lastChild:t}=this;for(this[be]=[e];e!==t;)this[be].push(e=e.nextSibling)}this.replaceChildren(...this[be])}return this}};function Se(e){const t=B("<>"),n=B("");return e.replaceChildren(t,...e.childNodes,n),pe=!0,R(e,{[be]:{writable:!0,value:G},firstChild:{value:t},lastChild:{value:n},parentNode:me,valueOf:we,replaceWith:ye,remove:xe})}Se.prototype=DocumentFragment.prototype;const ke=16,Ce=((e=globalThis.document)=>{let t,n=e.createElement("template");return(s,i=!1)=>{if(i)return t||(t=e.createRange(),t.selectNodeContents(e.createElementNS("http://www.w3.org/2000/svg","svg"))),t.createContextualFragment(s);n.innerHTML=s;const r=n.content;return n=n.cloneNode(!1),r}})(document),Te=Symbol("ref"),Oe=(e,t)=>{for(const[n,s]of _(t)){const t="role"===n?n:`aria-${n.toLowerCase()}`;null==s?e.removeAttribute(t):e.setAttribute(t,s)}},De=e=>(t,n)=>{null==n?t.removeAttribute(e):t.setAttribute(e,n)},$e=(e,t)=>{e[be]=((e,t,n,s)=>{const i=s.parentNode,r=t.length;let o=e.length,l=r,a=0,c=0,u=null;for(;as-c){const r=n(e[a],0);for(;c{const n="object"==typeof t?t??e:((e,t)=>{let n=Ne.get(e);return n?n.data=t:Ne.set(e,n=document.createTextNode(t)),n})(e,t),s=e[be]??e;n!==s&&s.replaceWith(ge(e[be]=n,1))},We=(e,t)=>{Ae(e,t instanceof A?t.value:t)},Ee=({dataset:e},t)=>{for(const[n,s]of _(t))null==s?delete e[n]:e[n]=s},Me=new Map,Le=e=>{let t=Me.get(e);return t||Me.set(e,t=je(e)),t},je=e=>(t,n)=>{t[e]=n},Pe=(e,t)=>{for(const[n,s]of _(t))De(n)(e,s)},Re=(e,t,n)=>n?(n,s)=>{const i=n[t];i?.length&&n.removeEventListener(e,...i),s&&n.addEventListener(e,...s),n[t]=s}:(n,s)=>{const i=n[t];i&&n.removeEventListener(e,i),s&&n.addEventListener(e,s),n[t]=s},_e=e=>(t,n)=>{t.toggleAttribute(e,!!n)};let Fe=!1,Je=!0;const Be=e=>{Je=e},Ve=()=>Je,He=e=>ge(e.n?e.update(e):e.valueOf(!1),1),ze=(e,t)=>{const n=[],s=e.length,i=t.length;for(let r,o,l=0,a=0;a{const s=M,i=n.length;let r=0;L(e=>r(e.t===t.t?e.update(t):(e.n.replaceWith(He(t)),e=t),e),Ie=(e,t,n)=>{let s,i=[],r=[ke,null,n],o=!0;return x(()=>{if(o)o=!1,s=qe(t,n,i),i.length||(i=G),s?(e.replaceWith(He(s)),r[1]=s):e.remove();else{const e=qe(t,n,i);s&&Ge(s,e)===e&&(r[2]=s=e)}}),r},Ke=Symbol(),Qe={};class Ue{constructor(e,t){this.t=e,this.v=t,this.n=null,this.k=-1}valueOf(e=Ve()){const[t,n,s]=this.t,i=document.importNode(t,!0),r=this.v;let o,l,a,c=r.length,u=G;if(0{for(const t of e){const e=t[Te];"function"==typeof e?e(t):e instanceof A?e.value=t:e&&(e.current=t)}})(a)}const{childNodes:d}=i,f=d.length,h=1===f?d[0]:f?Se(i):i;return this.v=u,this.n=h,-1e.t[2].get(t)?.update(e)??e.valueOf(!1))(e,s[t]);let{length:i}=n;for(;i--;){const e=n[i],[t,r,o]=e;if(512===t)continue;let l=s[i];if(t&ke)if(t===ke){const t=l(o,Qe);r&&Ge(r,t)===t&&(e[2]=t)}else r(o,l);else{let n=l;if(1&t){if(8&t)l.length&&l[0]instanceof Ue&&(n=ze(o,l));else if(256&t&&l[0]===o[0])continue}else if(8&t)if(32768&t){if(l===o){r(e[3],n);continue}}else o instanceof Ue&&(l=Ge(o,l),n=l.n);l!==o&&(e[2]=l,r(e[3],n))}}return this.n}}const Xe=new WeakMap;class Ye extends Map{constructor(){super()._=new FinalizationRegistry(e=>this.delete(e))}get(e){const t=super.get(e)?.deref();return t&&Xe.get(t)}set(e,t,n){Xe.set(t,n),this._.register(t,e),super.set(e,new WeakRef(t))}}const Ze=(({Comment:e=X,DocumentType:t=Y,Text:n=Z,Fragment:s=ne,Element:i=te,Component:r=ee,update:o=ae})=>(l,a,c)=>{const u=l.join(se).trim(),d=new Set,f=[];let h=new s,p=0,v=0,g=0,b=G;for(const s of u.matchAll(oe)){if(0",m+2);if("--\x3e"===u.slice(n-2,n+1)){const t=u.slice(m+4,n-2);"!"===t[0]&&I(h,new e(t.slice(1).replace(/!$/,"")))}else I(h,new t(u.slice(m+2,n)));p=n+1}else if(l.startsWith("",m+2);c&&"svg"===h.name&&(c=!1),h=ue(h,d),p=e+1}else{const e=m+l.length,t=u.indexOf(">",e),s=l.slice(1);let y=s;if(s===se?(y="template",h=I(h,new r),b=ce(h).slice(1),f.push(o(h,V,b,"",a[g++]))):(c||(y=y.toLowerCase(),"table"!==h.name||"tr"!==y&&"td"!==y||(h=I(h,new i("tbody",c)),d.add(h)),"tbody"===h.name&&"td"===y&&(h=I(h,new i("tr",c)),d.add(h))),h=I(h,new i(y,!!c&&"svg"!==y)),b=G),e`,p),t=u.slice(p,e);t.trim()===se?(v++,f.push(o(h,3,ce(h),"",a[g++]))):I(h,new n(t)),h=h.parent,p=e+s.length+3,v++;continue}}}return p{switch(t){case V:return[n,i,ke];case 8:return j(i)?[n,$e,9]:i instanceof J?[n,(r=e.xml,(e,t)=>{const n=e[Te]??(e[Te]={});n.v!==t&&(n.f=Se(Ce(t,r)),n.v=t),Ae(e,n.f)}),8192]:i instanceof A?[n,We,32776]:[n,Ae,8];case 3:return[n,Le("textContent"),2048];case 2:{const t=e.type===V;switch(s.at(0)){case"@":{const e=j(i);return[n,Re(s.slice(1),Symbol(s),e),e?257:256]}case"?":return[n,_e(s.slice(1)),4096];case".":return"..."===s?[n,t?P:Pe,t?144:128]:[n,je(s.slice(1)),t?80:64];default:return t?[n,je(s),1040]:"aria"===s?[n,Oe,2]:"data"!==s||/^object$/i.test(e.name)?"key"===s?[n,Fe=!0,512]:"ref"===s?[n,Le(Te),16384]:s.startsWith("on")?[n,Le(s.toLowerCase()),64]:[n,De(s),4]:[n,Ee,32]}}}var r}}),et=(e,t=new WeakMap)=>(n,...s)=>{let i=t.get(n);return i||(i=Ze(n,s,e),i.push((()=>{const e=Fe;return Fe=!1,e})()?new Ye:null),i[0]=Ce(i[0].toString(),e),t.set(n,i)),new Ue(i,s)},tt=et(!1),nt=et(!0),st=new WeakMap;function it(e,...t){const n=tt.apply(null,arguments);return Ve()?n.valueOf(!0):n}function rt(e,...t){const n=nt.apply(null,arguments);return Ve()?n.valueOf(!0):n}const ot=(e,t)=>{const n=st.get(e);if(n&&n[0](),"function"==typeof t){let s;Be(!1);const r=function(e){const t={deps:void 0,depsTail:void 0,subs:void 0,subsTail:void 0,flags:0};void 0!==f&&i(t,f);const n=g(void 0),s=b(t);try{e()}finally{b(s),g(n)}return D.bind(t)}(()=>{s=t()});if(n&&n[1].t===s.t)n[1].update(s);else{const t=s.valueOf(!1);e.replaceChildren(t)}st.set(e,[r,s])}else Be(!0),st.delete(e),e.replaceChildren(t instanceof Ue?He(t):ge(t,1));return e};function lt(e){for(var t=e[0],n=1,s=arguments.length;n({configurable:!0,get:()=>s,set(r){(e||r!==s||t&&"object"==typeof r&&r)&&(s=r,n?i.call(this,s):i.call(this))}}),dt=()=>{};const ft=(({all:e=!1,shallow:t=!0,useState:n=dt,getAttribute:s=(e,t)=>e.getAttribute(t)}={})=>(i,r,o)=>{const l=((e,t,n,s,i,r)=>{const o={},l=i!==dt,a=[n,s,l];for(let n=ct(e),s=0;s{let n=e[t],r=typeof n;return i.hasOwnProperty(t)?(n=i[t],delete i[t]):i.hasAttribute(t)&&(n=s(i,t),"number"==r?n=+n:"boolean"==r&&(n=!/^(?:false|0|)$/.test(n))),n},e,t,n,o);return at(i,l)})({}),ht=customElements,{define:pt}=ht,{parse:vt,stringify:gt}=JSON,{create:bt,defineProperties:mt,getOwnPropertyDescriptor:yt,keys:xt}=Object,wt="element",St=new WeakMap,kt=(e=>({get:t=>e.get(t),set:(t,n)=>(e.set(t,n),n)}))(new Map([[wt,{c:HTMLElement,e:wt}]])),Ct=e=>document.createElement(e),Tt=e=>kt.get(e)||kt.set(e,{c:Ct(e).constructor,e:e}),Ot=(e,t)=>{const{attachShadow:n,attributeChanged:s,bound:i,connected:r,disconnected:o,formAssociated:l,handleEvent:a,init:c,observedAttributes:u,props:d,render:f,style:h}=t,p=new WeakMap,v={},g={},b=[],m=bt(null),y=(e,t,s)=>{if(!p.has(e)){p.set(e,0),mt(e,{html:{configurable:!0,value:$t.bind(n?e.attachShadow(n):e)}});for(let t=0;t{++h;try{return e()}finally{--h||C()}},e.computed=e=>new W(e),e.css=lt,e.define=Ot,e.effect=x,e.fragment=Ce,e.html=it,e.render=ot,e.signal=function(){return M.apply(null,arguments)},e.svg=rt,e.unsafe=e=>new J(e),e.untracked=N,e}({});