@webqit/oohtml 4.0.0 → 4.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -13,10 +13,16 @@ Building Single Page Applications? OOHTML is a special love letter! Writing Web
13
13
 
14
14
  <details><summary>Versions</summary>
15
15
 
16
- *This is documentation for `OOHTML@3`. (Looking for [`OOHTML@1`](https://github.com/webqit/oohtml/tree/v1.10.4)?)*
16
+ *This is documentation for `OOHTML@4`. (Looking for [`OOHTML@1`](https://github.com/webqit/oohtml/tree/v1.10.4)?)*
17
17
 
18
18
  </details>
19
19
 
20
+ ## Status
21
+
22
+ + Actively developed
23
+ + Working implementation via a polyfill
24
+ + Open to contributions
25
+
20
26
  ## Polyfill
21
27
 
22
28
  OOHTML is being developed as something to be used today. This implementation adheres closely to the spec and helps evolve the proposal through a practice-driven process.
@@ -30,13 +36,19 @@ OOHTML is being developed as something to be used today. This implementation adh
30
36
 
31
37
  └ This is to be placed early on in the document and should be a classic script without any `defer` or `async` directives!
32
38
 
33
- > For `@webqit/oohtml@3.1` and below, you would need an external polyfill - like the [samthor/scoped](https://github.com/samthor/scoped) polyfill - for the Scoped Styles feature:
34
- >
35
- > ```html
36
- > <head>
37
- > <script src="https://unpkg.com/style-scoped/scoped.min.js"></script>
38
- > </head>
39
- > ```
39
+ For `@webqit/oohtml@3.1` and below, you would need an external polyfill - like the [samthor/scoped](https://github.com/samthor/scoped) polyfill - for the Scoped Styles feature:
40
+
41
+ ```html
42
+ <head>
43
+ <script src="https://unpkg.com/style-scoped/scoped.min.js"></script>
44
+ </head>
45
+ ```
46
+
47
+ └ Being an integral part of OOHTML, the Observer and Quantum JS APIs are also accessible on loading the OOHTML polyfill:
48
+
49
+ ```js
50
+ const { QuantumFunction, QuantumAsyncFunction, QuantumScript, QuantumModule, QuantumAsyncScript, State, Observer } = window.webqit;
51
+ ```
40
52
 
41
53
  </details>
42
54
 
@@ -50,12 +62,18 @@ npm i @webqit/oohtml @webqit/quantum-js
50
62
  ```js
51
63
  // Import
52
64
  import * as Quantum from '@webqit/quantum-js/lite'; // Or from '@webqit/quantum-js'; See implementation notes below
53
- import init from '@webqit/oohtml';
65
+ import init from '@webqit/oohtml/src/init.js';
54
66
 
55
67
  // Initialize the lib
56
68
  init.call(window, Quantum[, options = {}]);
57
69
  ```
58
70
 
71
+ └ Being an integral part of OOHTML, the Observer API, in addition to the Quantum JS APIs, is also available from the OOHTML installation:
72
+
73
+ ```js
74
+ import * as Observer from '@webqit/observer';
75
+ ```
76
+
59
77
  └ To use the polyfill on server-side DOM instances as made possible by libraries like [jsdom](https://github.com/jsdom/jsdom), simply install and initialize the library with the DOM instance as above.
60
78
 
61
79
  └ But all things "SSR" for OOHTML are best left to the [`@webqit/oohtml-ssr`](https://github.com/webqit/oohtml-ssr) package!
@@ -92,7 +110,7 @@ If you'll be going ahead to build a real app with OOHTML, you may want to consid
92
110
 
93
111
  ```html
94
112
  <head>
95
- <meta name="scoped-js" content="script.mimeType=some-mime">
113
+ <meta name="scoped-js" content="script.mimeTypes=module|text/javascript|application/javascript|some-mime">
96
114
  <script async src="https://unpkg.com/@webqit/oohtml/dist/main.lite.js"></script>
97
115
  </head>
98
116
  <body>
@@ -211,6 +229,8 @@ OOHTML comes, not as a specific technology, but as a conceptual "framework" of f
211
229
 
212
230
  OOHTML is effectively different from Web Components (and from the related Declarative Custom Elements and Declarative Shadow DOM efforts) in its focus on "arbitrary" HTML and the DOM rather than on just the Custom Element or Shadow DOM "subset" of the language. This in turn lets us have a niftier authoring experience in Web Components as the latter actually just relies on the very HTML and DOM.
213
231
 
232
+ └ You may want to learn more in the introductory article: [Revisiting the HTML Problem Space and Introducing OOHTML](https://dev.to/oxharris/revisiting-the-html-problem-space-and-introducing-oohtml-3oh5)
233
+
214
234
  </details>
215
235
 
216
236
  ## On the Agenda
@@ -222,7 +242,7 @@ OOHTML is effectively different from Web Components (and from the related Declar
222
242
 
223
243
  ## Modular HTML
224
244
 
225
- The modern UI is best approached with a modular architecture (think UI component frameworks) wherein we are able to author the bits and pieces as self-contained objects - enabling us *encapsulate* structure, styling and logic!
245
+ The modern UI is best approached with a modular architecture (think UI component frameworks) wherein we are able to author in bits and pieces while having each piece *encapsulate* their structure, styling and logic!
226
246
 
227
247
  OOHTML makes this possible by introducing "namespacing" and style and script scoping!
228
248
 
@@ -1,6 +1,6 @@
1
- (()=>{function b(n){return!Array.isArray(n)&&typeof n=="object"&&n}function y(n){return Array.isArray(n)}function it(n,t,r=null){return y(t)?n.filter(e=>r?t.filter(i=>r(e,i)).length:t.indexOf(e)!==-1):[]}function I(n,...t){if(globalThis.webqit||(globalThis.webqit={}),globalThis.webqit.refs||Object.defineProperty(globalThis.webqit,"refs",{value:new R}),!arguments.length)return globalThis.webqit.refs;let r=globalThis.webqit.refs.get(n);r||(r=new R,globalThis.webqit.refs.set(n,r));let e,i;for(;e=t.shift();)(i=r)&&!(r=r.get(e))&&(r=new R,i.set(e,r));return r}var R=class extends Map{constructor(...t){super(...t),this.observers=new Set}set(t,r){let e=super.set(t,r);return this.fire("set",t,r,t),e}delete(t){let r=super.delete(t);return this.fire("delete",t),r}has(t){return this.fire("has",t),super.has(t)}get(t){return this.fire("get",t),super.get(t)}keyNames(){return Array.from(super.keys())}observe(t,r,e){let i={type:t,key:r,callback:e};return this.observers.add(i),()=>this.observers.delete(i)}unobserve(t,r,e){if(Array.isArray(t)||Array.isArray(r))throw new Error('The "type" and "key" arguments can only be strings.');for(let i of this.observers)!(Y([t,"*"],i.type)&&Y([r,"*"],i.key)&&i.callback===e)||this.observers.delete(i)}fire(t,r,...e){for(let i of this.observers)!(Y([t,"*"],i.type)&&Y([r,"*"],i.key))||i.callback(...e)}},Y=(n,t)=>Array.isArray(t)?it(n,t).length:n.includes(t);function L(n){return typeof n=="function"}function W(n){return n===null||n===""}function M(n){return arguments.length&&(n===void 0||typeof n>"u")}function v(n){return Array.isArray(n)||typeof n=="object"&&n||L(n)}function ot(n){return W(n)||M(n)||n===!1||n===0||v(n)&&!Object.keys(n).length}function w(n){return L(n)||n&&{}.toString.call(n)==="[object function]"}function V(n){return n instanceof Number||typeof n=="number"}function C(n){return V(n)||n!==!0&&n!==!1&&n!==null&&n!==""&&!isNaN(n*1)}function D(n){return n instanceof String||typeof n=="string"&&n!==null}function st(n){return!D(n)&&!M(n.length)}function Z(n,...t){return t.forEach(r=>{n.indexOf(r)<0&&n.push(r)}),n}function ft(e,t){t=t||Object.prototype,t=t&&!y(t)?[t]:t;for(var r=[],e=e;e&&(!t||t.indexOf(e)<0)&&e.name!=="default";)r.push(e),e=e?Object.getPrototypeOf(e):null;return r}function lt(n,t){var r=[];return ft(n,t).forEach(e=>{Z(r,...Object.getOwnPropertyNames(e))}),r}function T(n,t,r=!1,e=!1,i=!1){var o=0,s=n.shift();if((C(s)||s===!0||s===!1)&&(o=s,s=n.shift()),!n.length)throw new Error("_merge() requires two or more array/objects.");return n.forEach((f,u)=>{!v(f)&&!w(f)||(r?lt(f):Object.keys(f)).forEach(c=>{if(!!t(c,s,f,u)){var l=s[c],d=f[c];if((y(l)&&y(d)||b(l)&&b(d))&&(o===!0||o>0))s[c]=y(l)&&y(d)?[]:{},T([C(o)?o-1:o,s[c],l,d],t,r,e,i);else if(y(s)&&y(f))e?s[c]=d:s.push(d);else try{i?Object.defineProperty(s,c,Object.getOwnPropertyDescriptor(f,c)):s[c]=f[c]}catch{}}})}),s}function G(...n){return T(n,(t,r,e)=>!0,!1,!1,!1)}function A(n,t=!0){return y(n)?n:!t&&b(n)?[n]:n!==!1&&n!==0&&ot(n)?[]:st(n)?Array.prototype.slice.call(n):b(n)?Object.values(n):[n]}function U(n,t,r={},e={}){t=A(t).slice();for(var i=n;!M(i)&&!W(i)&&t.length;){var o=t.shift();if(!(r.get?r.get(i,o):v(i)?o in i:i[o])){e.exists=!1;return}i=r.get?r.get(i,o):i[o]}return e.exists=!0,i}function ut(n,t,r,e={},i={}){let o=(l,d,a)=>i.set?i.set(l,d,a):(C(t[f])&&y(l)?l.push(a):l[d]=a,!0);t=A(t);for(var s=n,f=0;f<t.length;f++)if(f<t.length-1){if(!s||!v(s)&&!w(s))return!1;var u=U(s,t[f],i);if(!v(u)){if(i.buildTree===!1)return!1;u=w(i.buildTree)?i.buildTree(f):C(t[f+1])?[]:{};var c=o(s,t[f],u);if(!c)return!1}s=u}else return o(s,t[f],r)}var X=class{constructor(t,r=!1){Object.defineProperty(this,"window",{value:t}),Object.defineProperty(this,"readCallbacks",{value:new Set}),Object.defineProperty(this,"writeCallbacks",{value:new Set}),Object.defineProperty(this,"_synthesis",{value:0,writable:!0}),!r&&this.window.requestAnimationFrame?this._loop():this._synthesis++}get synthesis(){return this._synthesis}async synthesizeWhile(t){this._synthesis++,this._fulfill();let r=await t();return this._synthesis--,r}_fulfill(){for(let t of this.readCallbacks)t(),this.readCallbacks.delete(t);for(let t of this.writeCallbacks)t(),this.writeCallbacks.delete(t)}_loop(){this.window.requestAnimationFrame(()=>{this._fulfill(),this._loop()})}onread(t,r=!1){if(r)return new Promise(e=>{this.synthesis?e(t()):this.readCallbacks.add(()=>{e(t())})});this.synthesis?Promise.resolve().then(t):this.readCallbacks.add(t)}onwrite(t,r=!1){if(r)return new Promise(e=>{this.synthesis?e(t()):this.writeCallbacks.add(()=>{e(t())})});this.synthesis?Promise.resolve().then(t):this.writeCallbacks.add(t)}cycle(t,r,e){this.onread(()=>{let i=t(e),o=s=>{s!==void 0&&this.onwrite(()=>{let f=r(s,e),u=c=>{c!==void 0&&this.cycle(t,r,c)};f instanceof Promise?f.then(u):u(f)})};i instanceof Promise?i.then(o):o(i)})}};function $t(n){return(n=n.trim())&&n.startsWith("(")&&n.endsWith(")")}function tt(n,t,r,e=!0){r=(Array.isArray(r)?r:[r]).map(s=>(s+"").replace("(",e?"(.//":"(./")).join("|");let i=[],o;try{let s=n.document.evaluate(r,t,null,n.XPathResult.ANY_TYPE);for(;o=s.iterateNext();)i.push(o)}catch{}return i}function St(n,t,r){r=(Array.isArray(r)?r:[r]).map(e=>(e+"").replace("(","(self::")).join("|");try{return n.document.evaluate(`${r}`,t,null,n.XPathResult.BOOLEAN_TYPE).booleanValue}catch{}}function z(n,t,r,e=!1){let i=t.getRootNode(),o=r.getRootNode();return i===o?t.contains(r):e&&o instanceof n.ShadowRoot?z(n,t,o.host,e):!1}function It(n,t="|"){return[...n].reduce(([r,e,i,o],s)=>!r&&e===0&&(Array.isArray(t)?t:[t]).includes(s)?[r,e,[""].concat(i)]:(!r&&["(","[","{"].includes(s)&&!i[0].endsWith("\\")&&e++,!r&&[")","]","}"].includes(s)&&!i[0].endsWith("\\")&&e--,['"',"'","`"].includes(s)&&!i[0].endsWith("\\")&&(r=r===s?null:r||s),i[0]+=s,[r,e,i]),[null,0,[""]])[2].reverse()}var E=class{constructor(t){this.content=t,this.type=typeof t=="string"?"selector":"instance",this.kind=this.type==="instance"?null:$t(t)?"xpath":"css",this.kind==="xpath"&&(this.isXpathAttr=It(t.trim().slice(1,-1),"@").length>1)}toString(){return this.content}};var k=class{constructor(t,r,e){this.context=t,this.namespace=r,this.window=t.defaultView||t.ownerDocument?.defaultView||e,this.document=this.window.document,this.webqit=this.window.webqit,Object.defineProperty(this,"#",{value:{}})}resolveArgs(t){if(w(t[0])?t=[[],...t]:b(t[0])&&!(t[0]instanceof E)&&t.length===1?t=[[],void 0,t[0]]:b(t[1])&&t.length===2?t=[A(t[0],!1),void 0,t[1]]:t[0]=A(t[0],!1),t[0].filter(r=>typeof r!="string"&&!(r instanceof E)&&!(r instanceof this.window.Node)).length)throw new Error("Argument #2 must be either a string or a Node object, or a list of those.");return t[0]=t[0].map(r=>r instanceof E?r:new E(r)),t}registry(...t){return I("realdom.realtime",this.window,this.namespace,...t)}createSignalGenerator(){return{generate(){return this.lastController?.abort(),this.lastController=new AbortController,{signal:this.lastController.signal}},disconnect(){this.lastController?.abort()}}}forEachMatchingContext(t,r,e){let{window:i}=this,o=Array.isArray(r)?r:[r],s=new Set;for(let[f,u]of this.registry(t))for(let[c,l]of u){let d=o.filter(a=>z(i,c,a.target,f==="cross-roots")?["subtree","cross-roots"].includes(f)||a.target===c:!1);if(!!d.length){Array.isArray(r)||(d=d[0]);for(let a of l)s.add([a,d,c])}}for(let[f,u,c]of s)e.call(i,f,u,c)}disconnectables(t,...r){let e={disconnect(){r.forEach(i=>i&&w(i.disconnect)&&i.disconnect()||w(i)&&i()||b(i)&&(i.disconnected=!0))}};return t&&t.addEventListener("abort",()=>e.disconnect()),e}};var q=class extends k{constructor(t,...r){super(t,"attr",...r)}get(t,r=void 0,e={}){let i=typeof t=="string"||t instanceof E;[t=[],r=void 0,e={}]=this.resolveArgs(arguments);let{context:o}=this,s=Pt(o,t);if(!r)return s;let f=e.lifecycleSignals&&this.createSignalGenerator();if(i)for(let u of s){let c=f?.generate()||{};r(u,c,o)}else{let u=f?.generate()||{};r(s,u,o)}if(e.live){f&&(e={...e,signalGenerator:f});let u=this.observe(i?t[0]:t,r,{newValue:!0,...e});return this.disconnectables(e.signal,u)}}observe(t,r,e={}){let i=typeof t=="string"||t instanceof E;if([t=[],r,e={}]=this.resolveArgs(arguments),["sync","intercept"].includes(e.timing))return this.observeSync(i?t[0]:t,r,e);if(e.timing&&e.timing!=="async")throw new Error(`Timing option "${e.timing}" invalid.`);let{context:o,window:s,webqit:f}=this;e.eventDetails&&!f.realdom.attrInterceptionHooks?.intercepting&&Et.call(s,"intercept",()=>{});let u=new s.MutationObserver(a=>{a=Tt(a).map(h=>Mt.call(s,h)),Ct.call(s,d,a,o)}),c={attributes:!0,attributeOldValue:e.oldValue,subtree:e.subtree&&!0};t.length&&(c.attributeFilter=t.map(a=>a+"")),u.observe(o,c);let l=e.signalGenerator||e.lifecycleSignals&&this.createSignalGenerator(),d={context:o,spec:t,callback:r,params:e,atomics:new Map,originalFilterIsString:i,signalGenerator:l,disconnectable:u};return this.disconnectables(e.signal,u,l)}observeSync(t,r,e={}){let i=typeof t=="string"||t instanceof E;[t,r,e={}]=this.resolveArgs(arguments);let{context:o,window:s}=this;if(e.timing&&!["sync","intercept"].includes(e.timing))throw new Error(`Timing option "${e.timing}" invalid.`);let f=e.timing==="intercept"?"intercept":"sync",u=e.subtree==="cross-roots"?"cross-roots":e.subtree?"subtree":"children";this.registry(f).size||Et.call(s,f,g=>{this.forEachMatchingContext(f,g,Ct)});let c={disconnect(){h.delete(d),h.size||a.delete(o)}},l=e.signalGenerator||e.lifecycleSignals&&this.createSignalGenerator(),d={context:o,spec:t,callback:r,params:e,atomics:new Map,originalFilterIsString:i,signalGenerator:l,disconnectable:c},a=this.registry(f,u);a.has(o)||a.set(o,new Set);let h=a.get(o);return h.add(d),this.disconnectables(e.signal,c,l)}};function Tt(n){return n.reduce((t,r,e)=>t[e-1]?.attributeName===r.attributeName||I(r.target,"internalAttrInteractions").get(r.attributeName)?t:t.concat(r),[])}function Ct(n,t){let{context:r,spec:e,callback:i,params:o,atomics:s,originalFilterIsString:f,signalGenerator:u}=n,c=e.map(a=>a+"");if(o.atomic&&!s.size?t=Pt(r,e,t):o.timing!=="async"&&e.length&&(t=t.filter(a=>c.includes(a.name))),!t.length)return;o.newValue===null&&o.oldValue===null&&o.eventDetails||(t=t.map(a=>{let h;return o.eventDetails||({event:h,...a}=a),!o.oldValue&&"oldValue"in a&&({oldValue:h,...a}=a),!o.newValue&&"value"in a?{value:h,...a}=a:o.newValue&&typeof a.value>"u"&&(a={...a,value:et(a.target,a.name,()=>a.target.getAttribute(a.name))}),a})),o.atomic&&(t.forEach(a=>s.set(a.name,a)),t=Array.from(s.entries()).map(([,a])=>a));let l=f?t[0]:t,d=u?.generate()||{};i(l,d,r)}function et(n,t,r){let e=I(n,"internalAttrInteractions").get(t);I(n,"internalAttrInteractions").set(t,!0);let i=r();return I(n,"internalAttrInteractions").set(t,e),i}function Pt(n,t,r=[]){let e={event:null,type:"attribute"};return t.length?t.map(o=>(o=o+"",r.find(s=>s.name===o)||{target:n,name:o,value:et(n,o,()=>n.getAttribute(o)),...e})):Array.from(n.attributes).map(o=>r.find(s=>s.name===o.nodeName)||{target:n,name:o.nodeName,value:et(n,o.nodeName,()=>o.nodeValue),...e})}function Mt({target:n,attributeName:t,value:r,oldValue:e}){let s=(this.webqit.realdom.attrInterceptionRecords?.get(n)||{})[t]?.[0]||"mutation";return{target:n,name:t,value:r,oldValue:e,type:"observation",event:s}}function Et(n,t){let r=this,{webqit:e,document:i,Element:o}=r;e.realdom.attrInterceptionHooks||Object.defineProperty(e.realdom,"attrInterceptionHooks",{value:new Map}),e.realdom.attrInterceptionHooks.has(n)||e.realdom.attrInterceptionHooks.set(n,new Set),e.realdom.attrInterceptionHooks.get(n).add(t);let s=()=>e.realdom.attrInterceptionHooks.get(n).delete(t);if(e.realdom.attrInterceptionHooks?.intercepting)return s;console.warn("Attr mutation APIs are now being intercepted."),e.realdom.attrInterceptionHooks.intercepting=!0,Object.defineProperty(e.realdom,"attrInterceptionRecords",{value:new Map});let f=(l,d)=>{e.realdom.attrInterceptionRecords.has(l.target)||e.realdom.attrInterceptionRecords.set(l.target,{});let a=e.realdom.attrInterceptionRecords.get(l.target);if(a[l.name]=a[l.name]||[],a[l.name].unshift(l.event),I(l.target,"internalAttrInteractions").get(l.name))return d();e.realdom.attrInterceptionHooks.get("intercept")?.forEach(g=>g([l]));let h=d();return e.realdom.attrInterceptionHooks.get("sync")?.forEach(g=>g([l])),h};new r.MutationObserver(l=>{l=l.filter(d=>!(r.webqit.realdom.attrInterceptionRecords?.get(d.target)||{})[d.attributeName]?.shift()),l=Tt(l).map(d=>Mt.call(r,d)),l.length&&(e.realdom.attrInterceptionHooks.get("intercept")?.forEach(d=>d(l)),e.realdom.attrInterceptionHooks.get("sync")?.forEach(d=>d(l)))}).observe(i,{attributes:!0,subtree:!0,attributeOldValue:!0});let c=Object.create(null);return["setAttribute","removeAttribute","toggleAttribute"].forEach(l=>{c[l]=o.prototype[l],o.prototype[l]=function(...d){let a,h=et(this,d[0],()=>this.getAttribute(d[0]));["setAttribute","toggleAttribute"].includes(l)&&(a=d[1]),l==="toggleAttribute"&&a===void 0&&(a=h===null);let g={target:this,name:d[0],value:a,oldValue:h,type:"interception",event:[this,l]};return f(g,()=>c[l].call(this,...d))}}),s}var Q=class extends k{constructor(t,...r){super(t,"tree",...r)}attr(t,r=void 0,e={}){let{context:i,window:o}=this;return new q(i,o).get(...arguments)}query(t,r=void 0,e={}){[t,r=void 0,e={}]=this.resolveArgs(arguments);let{context:i}=this,o=new Map,s=c=>(o.has(c)||o.set(c,{target:c,entrants:[],exits:[],type:"query",event:null}),o.get(c));if(!e.generation||e.generation==="entrants"){if(!t.length)[...i.children].forEach(c=>s(i).entrants.push(c));else if(t.every(c=>c.type==="selector")){let[c,l]=t.reduce(([a,h],g)=>g.kind==="xpath"?[a,h.concat(g)]:[a.concat(g),h],[[],[]]),d=[];e.subtree?(c.length&&d.push(...i.querySelectorAll(c.join(","))),l.length&&d.push(...tt(this.window,i,l))):(c.length&&d.push(...[...i.children].filter(a=>a.matches(c))),l.length&&d.push(...tt(this.window,i,l,!1))),d.forEach(a=>s(a.parentNode||i).entrants.push(a))}}if(!r)return o;let f={disconnected:!1},u=r&&e.lifecycleSignals&&this.createSignalGenerator();for(let[,c]of o){if(f.disconnected)break;let l=u?.generate()||{};r(c,l,i)}if(e.live){u&&(e={...e,signalGenerator:u});let c=this.observe(t,r,e);return this.disconnectables(e.signal,f,c)}return this.disconnectables(e.signal,f,u)}children(t,r=void 0,e={}){return[t,r=void 0,e={}]=this.resolveArgs(arguments),this.query(t,r,{...e,subtree:!1})}subtree(t,r=void 0,e={}){return[t,r=void 0,e={}]=this.resolveArgs(arguments),this.query(t,r,{...e,subtree:!0})}observe(t,r,e={}){if([t,r,e={}]=this.resolveArgs(arguments),["sync","intercept"].includes(e.timing))return this.observeSync(t,r,e);if(e.timing&&e.timing!=="async")throw new Error(`Timing option "${e.timing}" invalid.`);let{context:i,window:o,webqit:s,document:f}=this;e.eventDetails&&(s.realdom.domInterceptionRecordsAlwaysOn=!0),(f.readyState==="loading"||s.realdom.domInterceptionRecordsAlwaysOn)&&!s.realdom.domInterceptionHooks?.intercepting&&kt.call(o,"sync",()=>{});let u=new o.MutationObserver(d=>d.forEach(a=>{dt.call(o,l,Nt.call(o,a),i)}));u.observe(i,{childList:!0,subtree:e.subtree&&!0});let c=e.signalGenerator||e.lifecycleSignals&&this.createSignalGenerator(),l={context:i,spec:t,callback:r,params:e,signalGenerator:c,disconnectable:u};if(e.staticSensitivity){let d=qt.call(o,l);return this.disconnectables(e.signal,u,c,d)}return this.disconnectables(e.signal,u,c)}observeSync(t,r,e={}){[t,r,e={}]=this.resolveArgs(arguments);let{context:i,window:o}=this;if(e.timing&&!["sync","intercept"].includes(e.timing))throw new Error(`Timing option "${e.timing}" invalid.`);let s=e.timing==="intercept"?"intercept":"sync",f=e.subtree==="cross-roots"?"cross-roots":e.subtree?"subtree":"children";this.registry(s).size||kt.call(o,s,g=>{this.forEachMatchingContext(s,g,dt)});let u=new o.MutationObserver(g=>g.forEach(O=>{Array.isArray((O=Nt.call(o,O)).event)||dt.call(o,d,O,i)}));u.observe(i,{childList:!0,subtree:e.subtree&&!0});let c={disconnect(){u.disconnect(),h.delete(d),h.size||a.delete(i)}},l=e.signalGenerator||e.lifecycleSignals&&this.createSignalGenerator(),d={context:i,spec:t,callback:r,params:e,signalGenerator:l,disconnectable:c},a=this.registry(s,f);a.has(i)||a.set(i,new Set);let h=a.get(i);if(h.add(d),e.staticSensitivity){let g=qt.call(o,d);return this.disconnectables(e.signal,c,l,g)}return this.disconnectables(e.signal,c,l)}track(t,r,e={}){return e={subtree:!0,...e},this.observe(t,i=>{i.entrants.length&&r(!0,Array.isArray(t)?i.entrants:i.entrants[0]),i.exits.length&&r(!1,Array.isArray(t)?i.exits:i.exits[0])},e)}};function qt(n){let t=this,{context:r,spec:e,callback:i,params:o,signalGenerator:s}=n,f=e.filter(h=>h.kind==="css"),u=h=>h.match(/\.([\w-]+)/g)?.length?["class"]:[],c=h=>h.match(/#([\w-]+)/g)?.length?["id"]:[],l=h=>[...h.matchAll(/\[([^\=\]]+)(\=[^\]]+)?\]/g)].map(g=>g[1]).concat(u(h)).concat(c(h));if(!(n.$attrs=Array.from(new Set(f.filter(h=>(h+"").includes("[")).reduce((h,g)=>h.concat(l(g+"")),[])))).length)return;let d=new Set,a=new Set;return d.push=h=>(a.delete(h),d.add(h)),a.push=h=>(d.delete(h),a.add(h)),n.$deliveryCache={entrants:d,exits:a},new q(r,t).observe(n.$attrs,h=>{let g=new Map,O=p=>(g.has(p)||g.set(p,{target:p,entrants:[],exits:[],type:"static",event:null}),g.get(p)),m=new WeakMap,x=p=>(m.has(p)||m.set(p,f.some(_=>p.matches(_+""))),m.get(p));for(let p of h)["entrants","exits"].forEach(_=>{o.generation&&_!==o.generation||n.$deliveryCache[_].has(p.target)||(_==="entrants"?!x(p.target):x(p.target))||(n.$deliveryCache[_].push(p.target),O(p.target)[_].push(p.target),O(p.target).event=p.event)});for(let[,p]of g){let _=s?.generate()||{};i(p,_,r)}},{subtree:o.subtree,timing:o.timing,eventDetails:o.eventDetails})}function dt(n,t){let{context:r,spec:e,callback:i,params:o,signalGenerator:s,$deliveryCache:f}=n,u={...t,entrants:[],exits:[]};if(o.eventDetails||delete u.event,["entrants","exits"].forEach(l=>{if(!(o.generation&&l!==o.generation)&&(e.length?u[l]=re.call(this,e,o.subtree==="cross-roots",t[l],t.event!=="parse"):u[l]=[...t[l]],!!f))for(let d of u[l])f[l].push(d)}),!u.entrants.length&&!u.exits.length)return;let c=s?.generate()||{};i(u,c,r)}function re(n,t,r,e){r=Array.isArray(r)?r:[...r];let i=(o,s)=>{if(s.type==="selector"){let f=s.isXpathAttr?[]:o.filter(u=>s.kind==="xpath"?St(this,u,s+""):u.matches&&u.matches(s+""));if((e||s.isXpathAttr)&&(f=o.reduce((u,c)=>s.kind==="xpath"?[...u,...tt(this,c,s,e)]:c.querySelectorAll?[...u,...c.querySelectorAll(s+"")]:u,f)),f.length)return f}else if(o.includes(s.content)||e&&o.some(f=>z(this,f,s.content,t)))return[s.content]};return r.$$searchCache||(r.$$searchCache=new Map),n.reduce((o,s)=>{let f;return r.$$searchCache.has(s.content)?f=r.$$searchCache.get(s.content):(f=i(r,s)||[],s.type==="instance"&&r.$$searchCache.set(s.content,f)),o.concat(f)},[])}function Nt({target:n,addedNodes:t,removedNodes:r}){let e=this,i;return i=A(t).reduce((o,s)=>o||e.webqit.realdom.domInterceptionRecords?.get(s),null),i=A(r).reduce((o,s)=>o||e.webqit.realdom.domInterceptionRecords?.get(s),i),i=i||e.document.readyState==="loading"&&"parse"||"mutation",{target:n,entrants:t,exits:r,type:"observation",event:i}}function kt(n,t){let r=this,{webqit:e,document:i,Node:o,CharacterData:s,Element:f,HTMLElement:u,HTMLTemplateElement:c,DocumentFragment:l}=r;e.realdom.domInterceptionHooks||Object.defineProperty(e.realdom,"domInterceptionHooks",{value:new Map}),e.realdom.domInterceptionNoRecurse||Object.defineProperty(e.realdom,"domInterceptionNoRecurse",{value:new Map}),e.realdom.domInterceptionHooks.has(n)||e.realdom.domInterceptionHooks.set(n,new Set),e.realdom.domInterceptionHooks.get(n).add(t);let d=()=>e.realdom.domInterceptionHooks.get(n).delete(t);if(e.realdom.domInterceptionHooks?.intercepting)return d;console.warn("DOM mutation APIs are now being intercepted."),e.realdom.domInterceptionHooks.intercepting=!0,Object.defineProperty(e.realdom,"domInterceptionRecords",{value:new Map});let a=(m,x,p)=>{e.realdom.domInterceptionNoRecurse.set(m,x);let _=p();return e.realdom.domInterceptionNoRecurse.delete(m),_},h=(m,x)=>{m.entrants.concat(m.exits).forEach(_=>{clearTimeout(e.realdom.domInterceptionRecords.get(_)?.timeout),e.realdom.domInterceptionRecords.set(_,m.event);let $=setTimeout(()=>{e.realdom.domInterceptionRecords.delete(_)},0);Object.defineProperty(m.event,"timeout",{value:$,configurable:!0})}),e.realdom.domInterceptionHooks.get("intercept")?.forEach(_=>_(m));let p=x();return e.realdom.domInterceptionHooks.get("sync")?.forEach(_=>_(m)),p},g={characterData:Object.create(null),other:Object.create(null)};["insertBefore","insertAdjacentElement","insertAdjacentHTML","setHTML","replaceChildren","replaceWith","remove","replaceChild","removeChild","before","after","append","prepend","appendChild"].forEach(m=>{function x(...p){let _=this instanceof s?g.characterData:g.other,$=()=>_[m].call(this,...p);if(!(this instanceof s||this instanceof f||this instanceof l)||e.realdom.domInterceptionNoRecurse.get(this)===m)return $();let P=[],S=[],B=this;["insertBefore"].includes(m)?S=[p[0]]:["insertAdjacentElement","insertAdjacentHTML"].includes(m)?(S=[p[1]],["beforebegin","afterend"].includes(p[0])&&(B=this.parentNode)):["setHTML","replaceChildren"].includes(m)?(P=[...this.childNodes],S=m==="replaceChildren"?[...p]:[p[0]]):["replaceWith","remove"].includes(m)?(P=[this],S=m==="replaceWith"?[...p]:[],B=this.parentNode):["replaceChild"].includes(m)?(P=[p[1]],S=[p[0]]):["removeChild"].includes(m)?P=[...p]:(S=[...p],["before","after"].includes(m)&&(B=this.parentNode));let N=m;if(["insertAdjacentHTML","setHTML"].includes(m)){let yt=this.nodeName;if(m==="insertAdjacentHTML"&&["beforebegin","afterend"].includes(p[0])){if(!this.parentNode)return _[m].call(this,...p);yt=this.parentNode.nodeName}let J=i.createElement(yt);_.setHTML.call(J,S[0],m==="setHTML"?p[1]:{}),S=[...J.childNodes],m==="insertAdjacentHTML"?(N="insertAdjacentElement",p[1]=new l,a(p[1],"append",()=>p[1].append(...J.childNodes))):(N="replaceChildren",p=[...J.childNodes])}return h({target:B,entrants:S,exits:P,type:"interception",event:[this,m]},()=>_[N].call(this,...p))}["insertBefore","replaceChild","removeChild","appendChild"].includes(m)?(g.other[m]=o.prototype[m],o.prototype[m]=x):(["after","before","remove","replaceWith"].includes(m)&&(g.characterData[m]=s.prototype[m],s.prototype[m]=x),f.prototype[m]&&(g.other[m]=f.prototype[m],f.prototype[m]=x))});let O=Object.create(null);return["outerHTML","outerText","innerHTML","innerText","textContent","nodeValue"].forEach(m=>{let x=["textContent","nodeValue"].includes(m)?o:["outerText","innerText"].includes(m)?u:f;O[m]=Object.getOwnPropertyDescriptor(x.prototype,m),Object.defineProperty(x.prototype,m,{...O[m],set:function(p){let _=()=>O[m].set.call(this,p);if(!(this instanceof f))return _();let $=[],P=[],S=this;if(["outerHTML","outerText"].includes(m)?($=[this],S=this.parentNode):$=[...this.childNodes],["outerHTML","innerHTML"].includes(m)){let N=this.nodeName;if(m==="outerHTML"){if(!this.parentNode)return _();N=this.parentNode.nodeName}let H=i.createElement(N==="TEMPLATE"?"div":N);O[m].set.call(H,p),P=this instanceof c?[]:[...H.childNodes],m==="outerHTML"?(p=new l,a(p,"append",()=>p.append(...H.childNodes)),_=()=>a(this,"replaceWith",()=>f.prototype.replaceWith.call(this,p))):this instanceof c?_=()=>a(this.conten,"replaceChildren",()=>this.content.replaceChildren(...H.childNodes)):_=()=>a(this,"replaceChildren",()=>f.prototype.replaceChildren.call(this,...H.childNodes))}return h({target:S,entrants:P,exits:$,type:"interception",event:[this,m]},_)}})}),["append","prepend","replaceChildren"].forEach(m=>{[i,l.prototype].forEach(x=>{let p=x[m];x[m]=function(..._){if(e.realdom.domInterceptionNoRecurse.get(this)===m)return p.call(this,..._);let $=m==="replaceChildren"?[...this.childNodes]:[];return h({target:this,entrants:_,exits:$,type:"interception",event:[this,m]},()=>p.call(this,..._))}})}),d}function Ht(){ne.call(this),ie.call(this),oe.call(this)}function ne(){let n=this;n.CSS||(n.CSS={}),n.CSS.escape||(n.CSS.escape=t=>t.replace(/([\:@\~\$\&])/g,"\\$1"))}function ie(){let n=this;"isConnected"in n.Node.prototype||Object.defineProperty(n.Node.prototype,"isConnected",{get:function(){return!this.ownerDocument||!(this.ownerDocument.compareDocumentPosition(this)&this.DOCUMENT_POSITION_DISCONNECTED)}})}function oe(){let n=this;n.Element.prototype.matches||(n.Element.prototype.matches=n.Element.prototype.matchesSelector||n.Element.prototype.mozMatchesSelector||n.Element.prototype.msMatchesSelector||n.Element.prototype.oMatchesSelector||n.Element.prototype.webkitMatchesSelector||function(t){for(var r=(this.document||this.ownerDocument).querySelectorAll(t),e=r.length;--e>=0&&r.item(e)!==this;);return e>-1})}function Lt(){let n=this;if(n.webqit||(n.webqit={}),n.webqit.realdom)return n.webqit.realdom;n.webqit.realdom={},Ht.call(n),n.webqit.realdom.meta=(...r)=>se.call(n,...r),n.webqit.realdom.ready=(...r)=>pt.call(n,...r),n.webqit.realdom.realtime=(r,e="dom")=>{if(e==="dom")return new Q(r,n);if(e==="attr")return new q(r,n)};let t=new X(n);return n.webqit.realdom.schedule=(r,...e)=>t[`on${r}`](...e),n.webqit.realdom.synthesizeWhile=(...r)=>t.synthesizeWhile(...r),n.webqit.realdom}function pt(...n){let t="interactive",r;D(n[0])?(t=n[0],w(n[1])&&(r=n[1])):w(n[0])&&(r=n[0]);let e={interactive:["interactive","complete"],complete:["complete"]};if(!e[t])throw new Error(`Invalid ready-state timing: ${t}.`);let i=this;if(!r)return i.webqit.realdom.readyStatePromises||(i.webqit.realdom.readyStatePromises={interactive:new Promise(o=>pt.call(this,"interactive",o)),complete:new Promise(o=>pt.call(this,"complete",o))}),i.webqit.realdom.readyStatePromises[t];if(e[t].includes(i.document.readyState))return r(i);i.webqit.realdom.readyStateCallbacks||(i.webqit.realdom.readyStateCallbacks={interactive:[],complete:[]},i.document.addEventListener("readystatechange",()=>{let o=i.document.readyState;for(let s of i.webqit.realdom.readyStateCallbacks[o].splice(0))s(i)},!1)),i.webqit.realdom.readyStateCallbacks[t].push(r)}function se(n){let t=this,r={},e;return(e=t.document.querySelector(`meta[name="${n}"]`))&&(r=(e.content||"").split(";").filter(i=>i).reduce((i,o)=>{let s=o.split("=").map(f=>f.trim());return ut(i,s[0].split("."),s[1]==="true"?!0:s[1]==="false"?!1:C(s[1])?parseInt(s[1]):s[1]),i},{})),{get name(){return n},get content(){return e.content},json(){return JSON.parse(JSON.stringify(r))}}}function rt(n,t){return typeof n!="string"?n:n.replace(/\w\S*/g,function(r){return r.charAt(0).toUpperCase()+(typeof t!==void 0&&t?r.substr(1).toLowerCase():r.substr(1))})}var F=(...n)=>I("oohtml",...n),ce={};function Ft(n,t,r){let e=this,i=Lt.call(e);ce.window=e,e.webqitConfig||(e.webqitConfig=i.meta("webqit").json()),e.webqit||(e.webqit={}),e.webqit.oohtml||(e.webqit.oohtml={}),e.webqit.oohtml.configs||(e.webqit.oohtml.configs={});let o=n.toUpperCase().replace("-","_");if(!e.webqit.oohtml.configs[o]){e.webqit.oohtml.configs[o]={};let s=e.webqit.oohtml.configs[o];G(2,s,r,t,i.meta(n).json()),e.webqitConfig.prefix&&Object.keys(s).forEach(f=>{Object.keys(s[f]).forEach(u=>{f==="api"&&typeof s[f][u]=="string"?s[f][u]=`${e.webqitConfig.prefix}${rt(s[f][u])}`:["attr","elements"].includes(f)&&s[f][u]?.startsWith("data-")===!1&&(s[f][u]=`${e.webqitConfig.prefix}-${s[f][u]}`)})})}return{config:e.webqit.oohtml.configs[o],realdom:i,window:e}}function nt(n,t){return[...n].reduce(([r,e,i],o)=>!r&&e===0&&(Array.isArray(t)?t:[t]).includes(o)?[r,e,[""].concat(i)]:(!r&&["(","[","{"].includes(o)&&!i[0].endsWith("\\")&&e++,!r&&[")","]","}"].includes(o)&&!i[0].endsWith("\\")&&e--,['"',"'","`"].includes(o)&&!i[0].endsWith("\\")&&(r=r===o?null:r||o),i[0]+=o,[r,e,i]),[null,0,[""]])[2].reverse()}function _t(n={}){let{config:t,window:r}=Ft.call(this,"data-binding",n,{attr:{render:"render",itemIndex:"data-key"},tokens:{nodeType:"processing-instruction",tagStart:"?{",tagEnd:"}?",stateStart:"; [=",stateEnd:"]"}});({CONTEXT_API:t.CONTEXT_API,BINDINGS_API:t.BINDINGS_API,HTML_IMPORTS:t.HTML_IMPORTS}=r.webqit.oohtml.configs),t.attrSelector=`[${r.CSS.escape(t.attr.render)}]`;let e=(i,o)=>{let s=`starts-with(., "${i}")`,f=`substring(., string-length(.) - string-length("${o}") + 1) = "${o}"`;return`${s} and ${f}`};t.discreteBindingsSelector=`comment()[${e(t.tokens.tagStart,t.tokens.tagEnd)}]`,ue.call(r,t)}function ue(n){let t=this,{webqit:{realdom:r}}=t;r.realtime(t.document).subtree(`(${n.discreteBindingsSelector})`,e=>{jt.call(this,...e.exits),ae.call(this,n,...e.entrants)},{live:!0}),r.realtime(t.document).subtree(n.attrSelector,e=>{jt.call(this,...e.exits),de.call(this,n,...e.entrants)},{live:!0,timing:"sync",staticSensitivity:!0})}function Bt(n,t){let{webqit:{realdom:r,Observer:e,DOMBindingsContext:i}}=this;if(F(t).has("data-binding"))return F(t).get("data-binding");let o=Object.create(null),s=new AbortController;o.$exec__=(u,c,...l)=>{r.schedule("write",()=>u[c](...l))},o.$assign__=(u,c,l)=>{r.schedule("write",()=>u[c]=l)},e.intercept(o,{get:(u,c,l)=>{if(!(u.key in o)){let d={...i.createRequest(u.key),live:!0,signal:s.signal};t[n.CONTEXT_API.api.contexts].request(d,a=>{e.set(o,u.key,a)})}return l(o[u.key]??(u.key in globalThis?globalThis[u.key]:void 0))},has:(u,c,l)=>l(!0)});let f={scope:o,abortController:s,bindings:new Map};return F(t).set("data-binding",f),f}function jt(...n){for(let t of n){let r=t.nodeName==="#text"?t.parentNode:t,{bindings:e,abortController:i}=F(r).get("data-binding")||{};if(!e?.has(t))return;e.get(t).state.dispose(),e.get(t).signals?.forEach(o=>o.abort()),e.delete(t),e.size||(i.abort(),F(r).delete("data-binding"))}}async function ae(n,...t){let r=this,{webqit:{QuantumAsyncFunction:e}}=r,i=s=>{let f=n.tokens.tagStart.split("").map(g=>`\\${g}`).join(""),u=n.tokens.tagEnd.split("").map(g=>`\\${g}`).join(""),c=n.tokens.stateStart.split("").map(g=>g===" "?"(?:\\s+)?":`\\${g}`).join(""),l=n.tokens.stateEnd.split("").map(g=>`\\${g}`).join(""),d=`^${f}(.*?)(?:${c}(\\d+)${l}(?:\\s+)?)?${u}$`,[,a,h]=s.match(new RegExp(d));return{raw:s,expr:a,span:parseInt(h??0)}},o=t.reduce((s,f)=>{if(f.isBound)return s;let u=i(f.nodeValue),c=f;if(u.span){if(c=f.nextSibling,c?.nodeName!=="#text"||c.nodeValue.length<u.span)return s;c.nodeValue.length>u.span&&c.splitText(u.span)}else c=f.ownerDocument.createTextNode(""),f.after(c);c.isBound=!0;let l=f;return r.webqit.env!=="server"&&(l.remove(),l=null),s.concat({textNode:c,template:u,anchorNode:l})},[]);for(let{textNode:s,template:f,anchorNode:u}of o){let c=me(n,f.expr),{scope:l,bindings:d}=Bt.call(this,n,s.parentNode);Object.defineProperty(s,"$oohtml_internal_databinding_anchorNode",{value:u,configurable:!0}),d.set(s,{state:await(await c.bind(s,l)).execute()})}}var ht=new Map;function me(n,t){if(ht.has(t))return ht.get(t);let r=`let content = ((${t}) ?? '') + '';`;r+="$assign__(this, 'nodeValue', content);",r+=`if ( this.$oohtml_internal_databinding_anchorNode ) { $assign__(this.$oohtml_internal_databinding_anchorNode, 'nodeValue', "${n.tokens.tagStart}${j(t)}${n.tokens.stateStart}" + content.length + "${n.tokens.stateEnd} ${n.tokens.tagEnd}"); }`;let{webqit:{QuantumModule:e}}=this,i=new e(r);return ht.set(t,i),i}async function de(n,...t){for(let r of t){let e=pe(n,r.getAttribute(n.attr.render)),{scope:i,bindings:o}=Bt.call(this,n,r),s=[];Object.defineProperty(r,"$oohtml_internal_databinding_signals",{value:s,configurable:!0}),o.set(r,{signals:s,state:await(await e.bind(r,i)).execute()})}}var gt=new Map;function pe(n,t){if(gt.has(t))return gt.get(t);let r={},e=nt(t,";").map(s=>{let[f,u]=nt(s,":").map(h=>h.trim()),c=f[0],l=f.slice(1).trim(),d=`(${u})`,a=`(${d} ?? '')`;if(c==="&")return l.startsWith("--")?`$exec__(this.style, 'setProperty', "${j(l)}", ${a});`:`$assign__(this.style, "${j(l)}", ${a});`;if(c==="%")return`$exec__(this.classList, 'toggle', "${j(l)}", !!${d});`;if(c==="~")return l.startsWith("?")?`$exec__(this, 'toggleAttribute', "${j(l.substring(1).trim())}", !!${d});`:`$exec__(this, 'setAttribute', "${j(l)}", ${a});`;if(c==="@"){if(r[l])throw new Error(`Duplicate binding: ${f}.`);if(r[l]=!0,l==="text")return`$assign__(this, 'textContent', ${a});`;if(l==="html")return`$exec__(this, 'setHTML', ${a});`;if(l==="items"){let[h,g]=nt(u,"/");if(!g)throw new Error(`Invalid ${c}items spec: ${s}; no import specifier.`);let[O,m,x,p]=h.trim().match(/(.*?[\)\s+])(of|in)([\(\{\[\s+].*)/i)||[];if(!O)throw new Error(`Invalid ${c}items spec: ${s}.`);if(m.startsWith("(")?m=m.trim().slice(1,-1).split(",").map($=>$.trim()):m=[m],m.length>(x==="in"?3:2))throw new Error(`Invalid ${c}items spec: ${s}.`);let _=x==="in"?m[2]:m[1]||"$index__";return`
2
- let $iteratee__ = ${p};
3
- let $import__ = this.${n.HTML_IMPORTS.api.import}( ${g.trim()}, true );
1
+ (()=>{function b(n){return!Array.isArray(n)&&typeof n=="object"&&n}function y(n){return Array.isArray(n)}function it(n,t,r=null){return y(t)?n.filter(e=>r?t.filter(i=>r(e,i)).length:t.indexOf(e)!==-1):[]}function I(n,...t){if(globalThis.webqit||(globalThis.webqit={}),globalThis.webqit.refs||Object.defineProperty(globalThis.webqit,"refs",{value:new R}),!arguments.length)return globalThis.webqit.refs;let r=globalThis.webqit.refs.get(n);r||(r=new R,globalThis.webqit.refs.set(n,r));let e,i;for(;e=t.shift();)(i=r)&&!(r=r.get(e))&&(r=new R,i.set(e,r));return r}var R=class extends Map{constructor(...t){super(...t),this.observers=new Set}set(t,r){let e=super.set(t,r);return this.fire("set",t,r,t),e}delete(t){let r=super.delete(t);return this.fire("delete",t),r}has(t){return this.fire("has",t),super.has(t)}get(t){return this.fire("get",t),super.get(t)}keyNames(){return Array.from(super.keys())}observe(t,r,e){let i={type:t,key:r,callback:e};return this.observers.add(i),()=>this.observers.delete(i)}unobserve(t,r,e){if(Array.isArray(t)||Array.isArray(r))throw new Error('The "type" and "key" arguments can only be strings.');for(let i of this.observers)!(Y([t,"*"],i.type)&&Y([r,"*"],i.key)&&i.callback===e)||this.observers.delete(i)}fire(t,r,...e){for(let i of this.observers)!(Y([t,"*"],i.type)&&Y([r,"*"],i.key))||i.callback(...e)}},Y=(n,t)=>Array.isArray(t)?it(n,t).length:n.includes(t);function L(n){return typeof n=="function"}function W(n){return n===null||n===""}function M(n){return arguments.length&&(n===void 0||typeof n>"u")}function v(n){return Array.isArray(n)||typeof n=="object"&&n||L(n)}function ot(n){return W(n)||M(n)||n===!1||n===0||v(n)&&!Object.keys(n).length}function w(n){return L(n)||n&&{}.toString.call(n)==="[object function]"}function V(n){return n instanceof Number||typeof n=="number"}function C(n){return V(n)||n!==!0&&n!==!1&&n!==null&&n!==""&&!isNaN(n*1)}function D(n){return n instanceof String||typeof n=="string"&&n!==null}function st(n){return!D(n)&&!M(n.length)}function Z(n,...t){return t.forEach(r=>{n.indexOf(r)<0&&n.push(r)}),n}function ft(e,t){t=t||Object.prototype,t=t&&!y(t)?[t]:t;for(var r=[],e=e;e&&(!t||t.indexOf(e)<0)&&e.name!=="default";)r.push(e),e=e?Object.getPrototypeOf(e):null;return r}function lt(n,t){var r=[];return ft(n,t).forEach(e=>{Z(r,...Object.getOwnPropertyNames(e))}),r}function T(n,t,r=!1,e=!1,i=!1){var o=0,s=n.shift();if((C(s)||s===!0||s===!1)&&(o=s,s=n.shift()),!n.length)throw new Error("_merge() requires two or more array/objects.");return n.forEach((f,c)=>{!v(f)&&!w(f)||(r?lt(f):Object.keys(f)).forEach(u=>{if(!!t(u,s,f,c)){var l=s[u],d=f[u];if((y(l)&&y(d)||b(l)&&b(d))&&(o===!0||o>0))s[u]=y(l)&&y(d)?[]:{},T([C(o)?o-1:o,s[u],l,d],t,r,e,i);else if(y(s)&&y(f))e?s[u]=d:s.push(d);else try{i?Object.defineProperty(s,u,Object.getOwnPropertyDescriptor(f,u)):s[u]=f[u]}catch{}}})}),s}function G(...n){return T(n,(t,r,e)=>!0,!1,!1,!1)}function A(n,t=!0){return y(n)?n:!t&&b(n)?[n]:n!==!1&&n!==0&&ot(n)?[]:st(n)?Array.prototype.slice.call(n):b(n)?Object.values(n):[n]}function U(n,t,r={},e={}){t=A(t).slice();for(var i=n;!M(i)&&!W(i)&&t.length;){var o=t.shift();if(!(r.get?r.get(i,o):v(i)?o in i:i[o])){e.exists=!1;return}i=r.get?r.get(i,o):i[o]}return e.exists=!0,i}function ut(n,t,r,e={},i={}){let o=(l,d,a)=>i.set?i.set(l,d,a):(C(t[f])&&y(l)?l.push(a):l[d]=a,!0);t=A(t);for(var s=n,f=0;f<t.length;f++)if(f<t.length-1){if(!s||!v(s)&&!w(s))return!1;var c=U(s,t[f],i);if(!v(c)){if(i.buildTree===!1)return!1;c=w(i.buildTree)?i.buildTree(f):C(t[f+1])?[]:{};var u=o(s,t[f],c);if(!u)return!1}s=c}else return o(s,t[f],r)}var X=class{constructor(t,r=!1){Object.defineProperty(this,"window",{value:t}),Object.defineProperty(this,"readCallbacks",{value:new Set}),Object.defineProperty(this,"writeCallbacks",{value:new Set}),Object.defineProperty(this,"_synthesis",{value:0,writable:!0}),!r&&this.window.requestAnimationFrame?this._loop():this._synthesis++}get synthesis(){return this._synthesis}async synthesizeWhile(t){this._synthesis++,this._fulfill();let r=await t();return this._synthesis--,r}_fulfill(){for(let t of this.readCallbacks)t(),this.readCallbacks.delete(t);for(let t of this.writeCallbacks)t(),this.writeCallbacks.delete(t)}_loop(){this.window.requestAnimationFrame(()=>{this._fulfill(),this._loop()})}onread(t,r=!1){if(r)return new Promise(e=>{this.synthesis?e(t()):this.readCallbacks.add(()=>{e(t())})});this.synthesis?Promise.resolve().then(t):this.readCallbacks.add(t)}onwrite(t,r=!1){if(r)return new Promise(e=>{this.synthesis?e(t()):this.writeCallbacks.add(()=>{e(t())})});this.synthesis?Promise.resolve().then(t):this.writeCallbacks.add(t)}cycle(t,r,e){this.onread(()=>{let i=t(e),o=s=>{s!==void 0&&this.onwrite(()=>{let f=r(s,e),c=u=>{u!==void 0&&this.cycle(t,r,u)};f instanceof Promise?f.then(c):c(f)})};i instanceof Promise?i.then(o):o(i)})}};function $t(n){return(n=n.trim())&&n.startsWith("(")&&n.endsWith(")")}function tt(n,t,r,e=!0){r=(Array.isArray(r)?r:[r]).map(s=>(s+"").replace("(",e?"(.//":"(./")).join("|");let i=[],o;try{let s=n.document.evaluate(r,t,null,n.XPathResult.ANY_TYPE);for(;o=s.iterateNext();)i.push(o)}catch{}return i}function St(n,t,r){r=(Array.isArray(r)?r:[r]).map(e=>(e+"").replace("(","(self::")).join("|");try{return n.document.evaluate(`${r}`,t,null,n.XPathResult.BOOLEAN_TYPE).booleanValue}catch{}}function z(n,t,r,e=!1){let i=t.getRootNode(),o=r.getRootNode();return i===o?t.contains(r):e&&o instanceof n.ShadowRoot?z(n,t,o.host,e):!1}function It(n,t="|"){return[...n].reduce(([r,e,i,o],s)=>!r&&e===0&&(Array.isArray(t)?t:[t]).includes(s)?[r,e,[""].concat(i)]:(!r&&["(","[","{"].includes(s)&&!i[0].endsWith("\\")&&e++,!r&&[")","]","}"].includes(s)&&!i[0].endsWith("\\")&&e--,['"',"'","`"].includes(s)&&!i[0].endsWith("\\")&&(r=r===s?null:r||s),i[0]+=s,[r,e,i]),[null,0,[""]])[2].reverse()}var E=class{constructor(t){this.content=t,this.type=typeof t=="string"?"selector":"instance",this.kind=this.type==="instance"?null:$t(t)?"xpath":"css",this.kind==="xpath"&&(this.isXpathAttr=It(t.trim().slice(1,-1),"@").length>1)}toString(){return this.content}};var k=class{constructor(t,r,e){this.context=t,this.namespace=r,this.window=t.defaultView||t.ownerDocument?.defaultView||e,this.document=this.window.document,this.webqit=this.window.webqit,Object.defineProperty(this,"#",{value:{}})}resolveArgs(t){if(w(t[0])?t=[[],...t]:b(t[0])&&!(t[0]instanceof E)&&t.length===1?t=[[],void 0,t[0]]:b(t[1])&&t.length===2?t=[A(t[0],!1),void 0,t[1]]:t[0]=A(t[0],!1),t[0].filter(r=>typeof r!="string"&&!(r instanceof E)&&!(r instanceof this.window.Node)).length)throw new Error("Argument #2 must be either a string or a Node object, or a list of those.");return t[0]=t[0].map(r=>r instanceof E?r:new E(r)),t}registry(...t){return I("realdom.realtime",this.window,this.namespace,...t)}createSignalGenerator(){return{generate(){return this.lastController?.abort(),this.lastController=new AbortController,{signal:this.lastController.signal}},disconnect(){this.lastController?.abort()}}}forEachMatchingContext(t,r,e){let{window:i}=this,o=Array.isArray(r)?r:[r],s=new Set;for(let[f,c]of this.registry(t))for(let[u,l]of c){let d=o.filter(a=>z(i,u,a.target,f==="cross-roots")?["subtree","cross-roots"].includes(f)||a.target===u:!1);if(!!d.length){Array.isArray(r)||(d=d[0]);for(let a of l)s.add([a,d,u])}}for(let[f,c,u]of s)e.call(i,f,c,u)}disconnectables(t,...r){let e={disconnect(){r.forEach(i=>i&&w(i.disconnect)&&i.disconnect()||w(i)&&i()||b(i)&&(i.disconnected=!0))}};return t&&t.addEventListener("abort",()=>e.disconnect()),e}};var q=class extends k{constructor(t,...r){super(t,"attr",...r)}get(t,r=void 0,e={}){let i=typeof t=="string"||t instanceof E;[t=[],r=void 0,e={}]=this.resolveArgs(arguments);let{context:o}=this,s=Pt(o,t);if(!r)return s;let f=e.lifecycleSignals&&this.createSignalGenerator();if(i)for(let c of s){let u=f?.generate()||{};r(c,u,o)}else{let c=f?.generate()||{};r(s,c,o)}if(e.live){f&&(e={...e,signalGenerator:f});let c=this.observe(i?t[0]:t,r,{newValue:!0,...e});return this.disconnectables(e.signal,c)}}observe(t,r,e={}){let i=typeof t=="string"||t instanceof E;if([t=[],r,e={}]=this.resolveArgs(arguments),["sync","intercept"].includes(e.timing))return this.observeSync(i?t[0]:t,r,e);if(e.timing&&e.timing!=="async")throw new Error(`Timing option "${e.timing}" invalid.`);let{context:o,window:s,webqit:f}=this;e.eventDetails&&!f.realdom.attrInterceptionHooks?.intercepting&&Et.call(s,"intercept",()=>{});let c=new s.MutationObserver(a=>{a=Tt(a).map(p=>Mt.call(s,p)),Ct.call(s,d,a,o)}),u={attributes:!0,attributeOldValue:e.oldValue,subtree:e.subtree&&!0};t.length&&(u.attributeFilter=t.map(a=>a+"")),c.observe(o,u);let l=e.signalGenerator||e.lifecycleSignals&&this.createSignalGenerator(),d={context:o,spec:t,callback:r,params:e,atomics:new Map,originalFilterIsString:i,signalGenerator:l,disconnectable:c};return this.disconnectables(e.signal,c,l)}observeSync(t,r,e={}){let i=typeof t=="string"||t instanceof E;[t,r,e={}]=this.resolveArgs(arguments);let{context:o,window:s}=this;if(e.timing&&!["sync","intercept"].includes(e.timing))throw new Error(`Timing option "${e.timing}" invalid.`);let f=e.timing==="intercept"?"intercept":"sync",c=e.subtree==="cross-roots"?"cross-roots":e.subtree?"subtree":"children";this.registry(f).size||Et.call(s,f,_=>{this.forEachMatchingContext(f,_,Ct)});let u={disconnect(){p.delete(d),p.size||a.delete(o)}},l=e.signalGenerator||e.lifecycleSignals&&this.createSignalGenerator(),d={context:o,spec:t,callback:r,params:e,atomics:new Map,originalFilterIsString:i,signalGenerator:l,disconnectable:u},a=this.registry(f,c);a.has(o)||a.set(o,new Set);let p=a.get(o);return p.add(d),this.disconnectables(e.signal,u,l)}};function Tt(n){return n.reduce((t,r,e)=>t[e-1]?.attributeName===r.attributeName||I(r.target,"internalAttrInteractions").get(r.attributeName)?t:t.concat(r),[])}function Ct(n,t){let{context:r,spec:e,callback:i,params:o,atomics:s,originalFilterIsString:f,signalGenerator:c}=n,u=e.map(a=>a+"");if(o.atomic&&!s.size?t=Pt(r,e,t):o.timing!=="async"&&e.length&&(t=t.filter(a=>u.includes(a.name))),!t.length)return;o.newValue===null&&o.oldValue===null&&o.eventDetails||(t=t.map(a=>{let p;return o.eventDetails||({event:p,...a}=a),!o.oldValue&&"oldValue"in a&&({oldValue:p,...a}=a),!o.newValue&&"value"in a?{value:p,...a}=a:o.newValue&&typeof a.value>"u"&&(a={...a,value:et(a.target,a.name,()=>a.target.getAttribute(a.name))}),a})),o.atomic&&(t.forEach(a=>s.set(a.name,a)),t=Array.from(s.entries()).map(([,a])=>a));let l=f?t[0]:t,d=c?.generate()||{};i(l,d,r)}function et(n,t,r){let e=I(n,"internalAttrInteractions").get(t);I(n,"internalAttrInteractions").set(t,!0);let i=r();return I(n,"internalAttrInteractions").set(t,e),i}function Pt(n,t,r=[]){let e={event:null,type:"attribute"};return t.length?t.map(o=>(o=o+"",r.find(s=>s.name===o)||{target:n,name:o,value:et(n,o,()=>n.getAttribute(o)),...e})):Array.from(n.attributes).map(o=>r.find(s=>s.name===o.nodeName)||{target:n,name:o.nodeName,value:et(n,o.nodeName,()=>o.nodeValue),...e})}function Mt({target:n,attributeName:t,value:r,oldValue:e}){let s=(this.webqit.realdom.attrInterceptionRecords?.get(n)||{})[t]?.[0]||"mutation";return{target:n,name:t,value:r,oldValue:e,type:"observation",event:s}}function Et(n,t){let r=this,{webqit:e,document:i,Element:o}=r;e.realdom.attrInterceptionHooks||Object.defineProperty(e.realdom,"attrInterceptionHooks",{value:new Map}),e.realdom.attrInterceptionHooks.has(n)||e.realdom.attrInterceptionHooks.set(n,new Set),e.realdom.attrInterceptionHooks.get(n).add(t);let s=()=>e.realdom.attrInterceptionHooks.get(n).delete(t);if(e.realdom.attrInterceptionHooks?.intercepting)return s;console.warn("Attr mutation APIs are now being intercepted."),e.realdom.attrInterceptionHooks.intercepting=!0,Object.defineProperty(e.realdom,"attrInterceptionRecords",{value:new Map});let f=(l,d)=>{e.realdom.attrInterceptionRecords.has(l.target)||e.realdom.attrInterceptionRecords.set(l.target,{});let a=e.realdom.attrInterceptionRecords.get(l.target);if(a[l.name]=a[l.name]||[],a[l.name].unshift(l.event),I(l.target,"internalAttrInteractions").get(l.name))return d();e.realdom.attrInterceptionHooks.get("intercept")?.forEach(_=>_([l]));let p=d();return e.realdom.attrInterceptionHooks.get("sync")?.forEach(_=>_([l])),p};new r.MutationObserver(l=>{l=l.filter(d=>!(r.webqit.realdom.attrInterceptionRecords?.get(d.target)||{})[d.attributeName]?.shift()),l=Tt(l).map(d=>Mt.call(r,d)),l.length&&(e.realdom.attrInterceptionHooks.get("intercept")?.forEach(d=>d(l)),e.realdom.attrInterceptionHooks.get("sync")?.forEach(d=>d(l)))}).observe(i,{attributes:!0,subtree:!0,attributeOldValue:!0});let u=Object.create(null);return["setAttribute","removeAttribute","toggleAttribute"].forEach(l=>{u[l]=o.prototype[l],o.prototype[l]=function(...d){let a,p=et(this,d[0],()=>this.getAttribute(d[0]));["setAttribute","toggleAttribute"].includes(l)&&(a=d[1]),l==="toggleAttribute"&&a===void 0&&(a=p===null);let _={target:this,name:d[0],value:a,oldValue:p,type:"interception",event:[this,l]};return f(_,()=>u[l].call(this,...d))}}),s}var Q=class extends k{constructor(t,...r){super(t,"tree",...r)}attr(t,r=void 0,e={}){let{context:i,window:o}=this;return new q(i,o).get(...arguments)}query(t,r=void 0,e={}){[t,r=void 0,e={}]=this.resolveArgs(arguments);let{context:i}=this,o=new Map,s=u=>(o.has(u)||o.set(u,{target:u,entrants:[],exits:[],type:"query",event:null}),o.get(u));if(!e.generation||e.generation==="entrants"){if(!t.length)[...i.children].forEach(u=>s(i).entrants.push(u));else if(t.every(u=>u.type==="selector")){let[u,l]=t.reduce(([a,p],_)=>_.kind==="xpath"?[a,p.concat(_)]:[a.concat(_),p],[[],[]]),d=[];e.subtree?(u.length&&d.push(...i.querySelectorAll(u.join(","))),l.length&&d.push(...tt(this.window,i,l))):(u.length&&d.push(...[...i.children].filter(a=>a.matches(u))),l.length&&d.push(...tt(this.window,i,l,!1))),d.forEach(a=>s(a.parentNode||i).entrants.push(a))}}if(!r)return o;let f={disconnected:!1},c=r&&e.lifecycleSignals&&this.createSignalGenerator();for(let[,u]of o){if(f.disconnected)break;let l=c?.generate()||{};r(u,l,i)}if(e.live){c&&(e={...e,signalGenerator:c});let u=this.observe(t,r,e);return this.disconnectables(e.signal,f,u)}return this.disconnectables(e.signal,f,c)}children(t,r=void 0,e={}){return[t,r=void 0,e={}]=this.resolveArgs(arguments),this.query(t,r,{...e,subtree:!1})}subtree(t,r=void 0,e={}){return[t,r=void 0,e={}]=this.resolveArgs(arguments),this.query(t,r,{...e,subtree:!0})}observe(t,r,e={}){if([t,r,e={}]=this.resolveArgs(arguments),["sync","intercept"].includes(e.timing))return this.observeSync(t,r,e);if(e.timing&&e.timing!=="async")throw new Error(`Timing option "${e.timing}" invalid.`);let{context:i,window:o,webqit:s,document:f}=this;e.eventDetails&&(s.realdom.domInterceptionRecordsAlwaysOn=!0),(f.readyState==="loading"||s.realdom.domInterceptionRecordsAlwaysOn)&&!s.realdom.domInterceptionHooks?.intercepting&&kt.call(o,"sync",()=>{});let c=new o.MutationObserver(d=>d.forEach(a=>{dt.call(o,l,Nt.call(o,a),i)}));c.observe(i,{childList:!0,subtree:e.subtree&&!0});let u=e.signalGenerator||e.lifecycleSignals&&this.createSignalGenerator(),l={context:i,spec:t,callback:r,params:e,signalGenerator:u,disconnectable:c};if(e.staticSensitivity){let d=qt.call(o,l);return this.disconnectables(e.signal,c,u,d)}return this.disconnectables(e.signal,c,u)}observeSync(t,r,e={}){[t,r,e={}]=this.resolveArgs(arguments);let{context:i,window:o}=this;if(e.timing&&!["sync","intercept"].includes(e.timing))throw new Error(`Timing option "${e.timing}" invalid.`);let s=e.timing==="intercept"?"intercept":"sync",f=e.subtree==="cross-roots"?"cross-roots":e.subtree?"subtree":"children";this.registry(s).size||kt.call(o,s,_=>{this.forEachMatchingContext(s,_,dt)});let c=new o.MutationObserver(_=>_.forEach(O=>{Array.isArray((O=Nt.call(o,O)).event)||dt.call(o,d,O,i)}));c.observe(i,{childList:!0,subtree:e.subtree&&!0});let u={disconnect(){c.disconnect(),p.delete(d),p.size||a.delete(i)}},l=e.signalGenerator||e.lifecycleSignals&&this.createSignalGenerator(),d={context:i,spec:t,callback:r,params:e,signalGenerator:l,disconnectable:u},a=this.registry(s,f);a.has(i)||a.set(i,new Set);let p=a.get(i);if(p.add(d),e.staticSensitivity){let _=qt.call(o,d);return this.disconnectables(e.signal,u,l,_)}return this.disconnectables(e.signal,u,l)}track(t,r,e={}){return e={subtree:!0,...e},this.observe(t,i=>{i.entrants.length&&r(!0,Array.isArray(t)?i.entrants:i.entrants[0]),i.exits.length&&r(!1,Array.isArray(t)?i.exits:i.exits[0])},e)}};function qt(n){let t=this,{context:r,spec:e,callback:i,params:o,signalGenerator:s}=n,f=e.filter(p=>p.kind==="css"),c=p=>p.match(/\.([\w-]+)/g)?.length?["class"]:[],u=p=>p.match(/#([\w-]+)/g)?.length?["id"]:[],l=p=>[...p.matchAll(/\[([^\=\]]+)(\=[^\]]+)?\]/g)].map(_=>_[1]).concat(c(p)).concat(u(p));if(!(n.$attrs=Array.from(new Set(f.filter(p=>(p+"").includes("[")).reduce((p,_)=>p.concat(l(_+"")),[])))).length)return;let d=new Set,a=new Set;return d.push=p=>(a.delete(p),d.add(p)),a.push=p=>(d.delete(p),a.add(p)),n.$deliveryCache={entrants:d,exits:a},new q(r,t).observe(n.$attrs,p=>{let _=new Map,O=h=>(_.has(h)||_.set(h,{target:h,entrants:[],exits:[],type:"static",event:null}),_.get(h)),m=new WeakMap,x=h=>(m.has(h)||m.set(h,f.some(g=>h.matches(g+""))),m.get(h));for(let h of p)["entrants","exits"].forEach(g=>{o.generation&&g!==o.generation||n.$deliveryCache[g].has(h.target)||(g==="entrants"?!x(h.target):x(h.target))||(n.$deliveryCache[g].push(h.target),O(h.target)[g].push(h.target),O(h.target).event=h.event)});for(let[,h]of _){let g=s?.generate()||{};i(h,g,r)}},{subtree:o.subtree,timing:o.timing,eventDetails:o.eventDetails})}function dt(n,t){let{context:r,spec:e,callback:i,params:o,signalGenerator:s,$deliveryCache:f}=n,c={...t,entrants:[],exits:[]};if(o.eventDetails||delete c.event,["entrants","exits"].forEach(l=>{if(!(o.generation&&l!==o.generation)&&(e.length?c[l]=re.call(this,e,o.subtree==="cross-roots",t[l],t.event!=="parse"):c[l]=[...t[l]],!!f))for(let d of c[l])f[l].push(d)}),!c.entrants.length&&!c.exits.length)return;let u=s?.generate()||{};i(c,u,r)}function re(n,t,r,e){r=Array.isArray(r)?r:[...r];let i=(o,s)=>{if(s.type==="selector"){let f=s.isXpathAttr?[]:o.filter(c=>s.kind==="xpath"?St(this,c,s+""):c.matches&&c.matches(s+""));if((e||s.isXpathAttr)&&(f=o.reduce((c,u)=>s.kind==="xpath"?[...c,...tt(this,u,s,e)]:u.querySelectorAll?[...c,...u.querySelectorAll(s+"")]:c,f)),f.length)return f}else if(o.includes(s.content)||e&&o.some(f=>z(this,f,s.content,t)))return[s.content]};return r.$$searchCache||(r.$$searchCache=new Map),n.reduce((o,s)=>{let f;return r.$$searchCache.has(s.content)?f=r.$$searchCache.get(s.content):(f=i(r,s)||[],s.type==="instance"&&r.$$searchCache.set(s.content,f)),o.concat(f)},[])}function Nt({target:n,addedNodes:t,removedNodes:r}){let e=this,i;return i=A(t).reduce((o,s)=>o||e.webqit.realdom.domInterceptionRecords?.get(s),null),i=A(r).reduce((o,s)=>o||e.webqit.realdom.domInterceptionRecords?.get(s),i),i=i||e.document.readyState==="loading"&&"parse"||"mutation",{target:n,entrants:t,exits:r,type:"observation",event:i}}function kt(n,t){let r=this,{webqit:e,document:i,Node:o,CharacterData:s,Element:f,HTMLElement:c,HTMLTemplateElement:u,DocumentFragment:l}=r;e.realdom.domInterceptionHooks||Object.defineProperty(e.realdom,"domInterceptionHooks",{value:new Map}),e.realdom.domInterceptionNoRecurse||Object.defineProperty(e.realdom,"domInterceptionNoRecurse",{value:new Map}),e.realdom.domInterceptionHooks.has(n)||e.realdom.domInterceptionHooks.set(n,new Set),e.realdom.domInterceptionHooks.get(n).add(t);let d=()=>e.realdom.domInterceptionHooks.get(n).delete(t);if(e.realdom.domInterceptionHooks?.intercepting)return d;console.warn("DOM mutation APIs are now being intercepted."),e.realdom.domInterceptionHooks.intercepting=!0,Object.defineProperty(e.realdom,"domInterceptionRecords",{value:new Map});let a=(m,x,h)=>{e.realdom.domInterceptionNoRecurse.set(m,x);let g=h();return e.realdom.domInterceptionNoRecurse.delete(m),g},p=(m,x)=>{m.entrants.concat(m.exits).forEach(g=>{clearTimeout(e.realdom.domInterceptionRecords.get(g)?.timeout),e.realdom.domInterceptionRecords.set(g,m.event);let $=setTimeout(()=>{e.realdom.domInterceptionRecords.delete(g)},0);Object.defineProperty(m.event,"timeout",{value:$,configurable:!0})}),e.realdom.domInterceptionHooks.get("intercept")?.forEach(g=>g(m));let h=x();return e.realdom.domInterceptionHooks.get("sync")?.forEach(g=>g(m)),h},_={characterData:Object.create(null),other:Object.create(null)};["insertBefore","insertAdjacentElement","insertAdjacentHTML","setHTML","replaceChildren","replaceWith","remove","replaceChild","removeChild","before","after","append","prepend","appendChild"].forEach(m=>{function x(...h){let g=this instanceof s?_.characterData:_.other,$=()=>g[m].call(this,...h);if(!(this instanceof s||this instanceof f||this instanceof l)||e.realdom.domInterceptionNoRecurse.get(this)===m)return $();let P=[],S=[],B=this;["insertBefore"].includes(m)?S=[h[0]]:["insertAdjacentElement","insertAdjacentHTML"].includes(m)?(S=[h[1]],["beforebegin","afterend"].includes(h[0])&&(B=this.parentNode)):["setHTML","replaceChildren"].includes(m)?(P=[...this.childNodes],S=m==="replaceChildren"?[...h]:[h[0]]):["replaceWith","remove"].includes(m)?(P=[this],S=m==="replaceWith"?[...h]:[],B=this.parentNode):["replaceChild"].includes(m)?(P=[h[1]],S=[h[0]]):["removeChild"].includes(m)?P=[...h]:(S=[...h],["before","after"].includes(m)&&(B=this.parentNode));let N=m;if(["insertAdjacentHTML","setHTML"].includes(m)){let yt=this.nodeName;if(m==="insertAdjacentHTML"&&["beforebegin","afterend"].includes(h[0])){if(!this.parentNode)return g[m].call(this,...h);yt=this.parentNode.nodeName}let J=i.createElement(yt);g.setHTML.call(J,S[0],m==="setHTML"?h[1]:{}),S=[...J.childNodes],m==="insertAdjacentHTML"?(N="insertAdjacentElement",h[1]=new l,a(h[1],"append",()=>h[1].append(...J.childNodes))):(N="replaceChildren",h=[...J.childNodes])}return p({target:B,entrants:S,exits:P,type:"interception",event:[this,m]},()=>g[N].call(this,...h))}["insertBefore","replaceChild","removeChild","appendChild"].includes(m)?(_.other[m]=o.prototype[m],o.prototype[m]=x):(["after","before","remove","replaceWith"].includes(m)&&(_.characterData[m]=s.prototype[m],s.prototype[m]=x),f.prototype[m]&&(_.other[m]=f.prototype[m],f.prototype[m]=x))});let O=Object.create(null);return["outerHTML","outerText","innerHTML","innerText","textContent","nodeValue"].forEach(m=>{let x=["textContent","nodeValue"].includes(m)?o:["outerText","innerText"].includes(m)?c:f;O[m]=Object.getOwnPropertyDescriptor(x.prototype,m),Object.defineProperty(x.prototype,m,{...O[m],set:function(h){let g=()=>O[m].set.call(this,h);if(!(this instanceof f))return g();let $=[],P=[],S=this;if(["outerHTML","outerText"].includes(m)?($=[this],S=this.parentNode):$=[...this.childNodes],["outerHTML","innerHTML"].includes(m)){let N=this.nodeName;if(m==="outerHTML"){if(!this.parentNode)return g();N=this.parentNode.nodeName}let H=i.createElement(N==="TEMPLATE"?"div":N);O[m].set.call(H,h),P=this instanceof u?[]:[...H.childNodes],m==="outerHTML"?(h=new l,a(h,"append",()=>h.append(...H.childNodes)),g=()=>a(this,"replaceWith",()=>f.prototype.replaceWith.call(this,h))):this instanceof u?g=()=>a(this.conten,"replaceChildren",()=>this.content.replaceChildren(...H.childNodes)):g=()=>a(this,"replaceChildren",()=>f.prototype.replaceChildren.call(this,...H.childNodes))}return p({target:S,entrants:P,exits:$,type:"interception",event:[this,m]},g)}})}),["append","prepend","replaceChildren"].forEach(m=>{[i,l.prototype].forEach(x=>{let h=x[m];x[m]=function(...g){if(e.realdom.domInterceptionNoRecurse.get(this)===m)return h.call(this,...g);let $=m==="replaceChildren"?[...this.childNodes]:[];return p({target:this,entrants:g,exits:$,type:"interception",event:[this,m]},()=>h.call(this,...g))}})}),d}function Ht(){ne.call(this),ie.call(this),oe.call(this)}function ne(){let n=this;n.CSS||(n.CSS={}),n.CSS.escape||(n.CSS.escape=t=>t.replace(/([\:@\~\$\&])/g,"\\$1"))}function ie(){let n=this;"isConnected"in n.Node.prototype||Object.defineProperty(n.Node.prototype,"isConnected",{get:function(){return!this.ownerDocument||!(this.ownerDocument.compareDocumentPosition(this)&this.DOCUMENT_POSITION_DISCONNECTED)}})}function oe(){let n=this;n.Element.prototype.matches||(n.Element.prototype.matches=n.Element.prototype.matchesSelector||n.Element.prototype.mozMatchesSelector||n.Element.prototype.msMatchesSelector||n.Element.prototype.oMatchesSelector||n.Element.prototype.webkitMatchesSelector||function(t){for(var r=(this.document||this.ownerDocument).querySelectorAll(t),e=r.length;--e>=0&&r.item(e)!==this;);return e>-1})}function Lt(){let n=this;if(n.webqit||(n.webqit={}),n.webqit.realdom)return n.webqit.realdom;n.webqit.realdom={},Ht.call(n),n.webqit.realdom.meta=(...r)=>se.call(n,...r),n.webqit.realdom.ready=(...r)=>pt.call(n,...r),n.webqit.realdom.realtime=(r,e="dom")=>{if(e==="dom")return new Q(r,n);if(e==="attr")return new q(r,n)};let t=new X(n);return n.webqit.realdom.schedule=(r,...e)=>t[`on${r}`](...e),n.webqit.realdom.synthesizeWhile=(...r)=>t.synthesizeWhile(...r),n.webqit.realdom}function pt(...n){let t="interactive",r;D(n[0])?(t=n[0],w(n[1])&&(r=n[1])):w(n[0])&&(r=n[0]);let e={interactive:["interactive","complete"],complete:["complete"]};if(!e[t])throw new Error(`Invalid ready-state timing: ${t}.`);let i=this;if(!r)return i.webqit.realdom.readyStatePromises||(i.webqit.realdom.readyStatePromises={interactive:new Promise(o=>pt.call(this,"interactive",o)),complete:new Promise(o=>pt.call(this,"complete",o))}),i.webqit.realdom.readyStatePromises[t];if(e[t].includes(i.document.readyState))return r(i);i.webqit.realdom.readyStateCallbacks||(i.webqit.realdom.readyStateCallbacks={interactive:[],complete:[]},i.document.addEventListener("readystatechange",()=>{let o=i.document.readyState;for(let s of i.webqit.realdom.readyStateCallbacks[o].splice(0))s(i)},!1)),i.webqit.realdom.readyStateCallbacks[t].push(r)}function se(n){let t=this,r={},e;return(e=t.document.querySelector(`meta[name="${n}"]`))&&(r=(e.content||"").split(";").filter(i=>i).reduce((i,o)=>{let s=o.split("=").map(f=>f.trim());return ut(i,s[0].split("."),s[1]==="true"?!0:s[1]==="false"?!1:C(s[1])?parseInt(s[1]):s[1]),i},{})),{get name(){return n},get content(){return e.content},json(){return JSON.parse(JSON.stringify(r))}}}function rt(n,t){return typeof n!="string"?n:n.replace(/\w\S*/g,function(r){return r.charAt(0).toUpperCase()+(typeof t!==void 0&&t?r.substr(1).toLowerCase():r.substr(1))})}var j=(...n)=>I("oohtml",...n),ce={};function jt(n,t,r){let e=this,i=Lt.call(e);ce.window=e,e.webqitConfig||(e.webqitConfig=i.meta("webqit").json()),e.webqit||(e.webqit={}),e.webqit.oohtml||(e.webqit.oohtml={}),e.webqit.oohtml.configs||(e.webqit.oohtml.configs={});let o=n.toUpperCase().replace("-","_");if(!e.webqit.oohtml.configs[o]){e.webqit.oohtml.configs[o]={};let s=e.webqit.oohtml.configs[o];G(2,s,r,t,i.meta(n).json()),e.webqitConfig.prefix&&Object.keys(s).forEach(f=>{Object.keys(s[f]).forEach(c=>{f==="api"&&typeof s[f][c]=="string"?s[f][c]=`${e.webqitConfig.prefix}${rt(s[f][c])}`:["attr","elements"].includes(f)&&s[f][c]?.startsWith("data-")===!1&&(s[f][c]=`${e.webqitConfig.prefix}-${s[f][c]}`)})})}return{config:e.webqit.oohtml.configs[o],realdom:i,window:e}}function nt(n,t){return[...n].reduce(([r,e,i],o)=>!r&&e===0&&(Array.isArray(t)?t:[t]).includes(o)?[r,e,[""].concat(i)]:(!r&&["(","[","{"].includes(o)&&!i[0].endsWith("\\")&&e++,!r&&[")","]","}"].includes(o)&&!i[0].endsWith("\\")&&e--,['"',"'","`"].includes(o)&&!i[0].endsWith("\\")&&(r=r===o?null:r||o),i[0]+=o,[r,e,i]),[null,0,[""]])[2].reverse()}function _t(n={}){let{config:t,window:r}=jt.call(this,"data-binding",n,{attr:{render:"render",itemIndex:"data-key"},tokens:{nodeType:"processing-instruction",tagStart:"?{",tagEnd:"}?",stateStart:"; [=",stateEnd:"]"}});({CONTEXT_API:t.CONTEXT_API,BINDINGS_API:t.BINDINGS_API,HTML_IMPORTS:t.HTML_IMPORTS}=r.webqit.oohtml.configs),t.attrSelector=`[${r.CSS.escape(t.attr.render)}]`;let e=(i,o)=>{let s=`starts-with(., "${i}")`,f=`substring(., string-length(.) - string-length("${o}") + 1) = "${o}"`;return`${s} and ${f}`};t.discreteBindingsSelector=`comment()[${e(t.tokens.tagStart,t.tokens.tagEnd)}]`,ue.call(r,t)}function ue(n){let t=this,{webqit:{realdom:r}}=t;r.realtime(t.document).subtree(`(${n.discreteBindingsSelector})`,e=>{Ft.call(this,...e.exits),ae.call(this,n,...e.entrants)},{live:!0}),r.realtime(t.document).subtree(n.attrSelector,e=>{Ft.call(this,...e.exits),de.call(this,n,...e.entrants)},{live:!0,timing:"sync",staticSensitivity:!0})}function Bt(n,t){let{webqit:{realdom:r,Observer:e,DOMBindingsContext:i}}=this;if(j(t).has("data-binding"))return j(t).get("data-binding");let o=Object.create(null),s=new AbortController;o.$exec__=(c,u,...l)=>{r.schedule("write",()=>c[u](...l))},o.$assign__=(c,u,l)=>{r.schedule("write",()=>c[u]=l)},e.intercept(o,{get:(c,u,l)=>{if(!(c.key in o)){let d={...i.createRequest(c.key),live:!0,signal:s.signal};t[n.CONTEXT_API.api.contexts].request(d,a=>{e.set(o,c.key,a)})}return l(o[c.key]??(c.key in globalThis?globalThis[c.key]:void 0))},has:(c,u,l)=>l(!0)});let f={scope:o,abortController:s,bindings:new Map};return j(t).set("data-binding",f),f}function Ft(...n){for(let t of n){let r=t.nodeName==="#text"?t.parentNode:t,{bindings:e,abortController:i}=j(r).get("data-binding")||{};if(!e?.has(t))return;e.get(t).state.dispose(),e.get(t).signals?.forEach(o=>o.abort()),e.delete(t),e.size||(i.abort(),j(r).delete("data-binding"))}}async function ae(n,...t){let r=this,e=o=>{let s=n.tokens.tagStart.split("").map(p=>`\\${p}`).join(""),f=n.tokens.tagEnd.split("").map(p=>`\\${p}`).join(""),c=n.tokens.stateStart.split("").map(p=>p===" "?"(?:\\s+)?":`\\${p}`).join(""),u=n.tokens.stateEnd.split("").map(p=>`\\${p}`).join(""),l=`^${s}(.*?)(?:${c}(\\d+)${u}(?:\\s+)?)?${f}$`,[,d,a]=o.match(new RegExp(l));return{raw:o,expr:d,span:parseInt(a??0)}},i=t.reduce((o,s)=>{if(s.isBound)return o;let f=e(s.nodeValue),c=s;if(f.span){if(c=s.nextSibling,c?.nodeName!=="#text"||c.nodeValue.length<f.span)return o;c.nodeValue.length>f.span&&c.splitText(f.span)}else c=s.ownerDocument.createTextNode(""),s.after(c);c.isBound=!0;let u=s;return r.webqit.env!=="server"&&(u.remove(),u=null),o.concat({textNode:c,template:f,anchorNode:u})},[]);for(let{textNode:o,template:s,anchorNode:f}of i){let c=me(n,s.expr),{scope:u,bindings:l}=Bt.call(this,n,o.parentNode);Object.defineProperty(o,"$oohtml_internal_databinding_anchorNode",{value:f,configurable:!0}),l.set(o,{state:await(await c.bind(o,u)).execute()})}}var ht=new Map;function me(n,t){if(ht.has(t))return ht.get(t);let r=`let content = ((${t}) ?? '') + '';`;r+="$assign__(this, 'nodeValue', content);",r+=`if ( this.$oohtml_internal_databinding_anchorNode ) { $assign__(this.$oohtml_internal_databinding_anchorNode, 'nodeValue', "${n.tokens.tagStart}${F(t)}${n.tokens.stateStart}" + content.length + "${n.tokens.stateEnd} ${n.tokens.tagEnd}"); }`;let{webqit:{QuantumModule:e}}=this,i=new e(r);return ht.set(t,i),i}async function de(n,...t){for(let r of t){let e=pe(n,r.getAttribute(n.attr.render)),{scope:i,bindings:o}=Bt.call(this,n,r),s=[];Object.defineProperty(r,"$oohtml_internal_databinding_signals",{value:s,configurable:!0}),o.set(r,{signals:s,state:await(await e.bind(r,i)).execute()})}}var gt=new Map;function pe(n,t){if(gt.has(t))return gt.get(t);let r={},e=nt(t,";").map(s=>{let[f,c]=nt(s,":").map(p=>p.trim()),u=f[0],l=f.slice(1).trim(),d=`(${c})`,a=`(${d} ?? '')`;if(u==="&")return l.startsWith("--")?`$exec__(this.style, 'setProperty', "${F(l)}", ${a});`:`$assign__(this.style, "${F(l)}", ${a});`;if(u==="%")return`$exec__(this.classList, 'toggle', "${F(l)}", !!${d});`;if(u==="~")return l.startsWith("?")?`$exec__(this, 'toggleAttribute', "${F(l.substring(1).trim())}", !!${d});`:`$exec__(this, 'setAttribute', "${F(l)}", ${a});`;if(u==="@"){if(r[l])throw new Error(`Duplicate binding: ${f}.`);if(r[l]=!0,l==="text")return`$assign__(this, 'textContent', ${a});`;if(l==="html")return`$exec__(this, 'setHTML', ${a});`;if(l==="items"){let[p,_]=nt(c,"/");if(!_)throw new Error(`Invalid ${u}items spec: ${s}; no import specifier.`);let[O,m,x,h]=p.trim().match(/(.*?[\)\s+])(of|in)([\(\{\[\s+].*)/i)||[];if(!O)throw new Error(`Invalid ${u}items spec: ${s}.`);if(m.startsWith("(")?m=m.trim().slice(1,-1).split(",").map($=>$.trim()):m=[m],m.length>(x==="in"?3:2))throw new Error(`Invalid ${u}items spec: ${s}.`);let g=x==="in"?m[2]:m[1]||"$index__";return`
2
+ let $iteratee__ = ${h};
3
+ let $import__ = this.${n.HTML_IMPORTS.api.import}( ${_.trim()}, true );
4
4
  this.$oohtml_internal_databinding_signals?.push( $import__ );
5
5
 
6
6
  if ( $import__.value && $iteratee__ ) {
@@ -8,13 +8,13 @@
8
8
  this.querySelectorAll( '[${n.attr.itemIndex}]' ).forEach( x => {
9
9
  $existing__.set( x.getAttribute( '${n.attr.itemIndex}' ), x );
10
10
  } );
11
- ${_?`let ${_} = -1;`:""}
11
+ ${g?`let ${g} = -1;`:""}
12
12
  for ( let ${m[0]} ${x} $iteratee__ ) {
13
- ${_?`${_} ++;`:""}
13
+ ${g?`${g} ++;`:""}
14
14
  ${x==="in"&&m[1]?`let ${m[1]} = $iteratee__[ ${m[0]} ];`:""}
15
15
  const $itemBinding__ = { ${m.join(", ")} };
16
16
 
17
- const $key___ = ( ${x==="in"?m[0]:_} ) + '';
17
+ const $key___ = ( ${x==="in"?m[0]:g} ) + '';
18
18
  let $itemNode__ = $existing__.get( $key___ );
19
19
  if ( $itemNode__ ) {
20
20
  $existing__.delete( $key___ );
@@ -31,5 +31,5 @@
31
31
  $existing__.forEach( x => x.remove() );
32
32
  $existing__.clear();
33
33
  }`}}if(s.trim())throw new Error(`Invalid binding: ${s}.`)}).join(`
34
- `),{webqit:{QuantumModule:i}}=this,o=new i(e);return gt.set(t,o),o}var j=n=>n.replace(/"/g,'\\"');_t.call(window);})();
34
+ `),{webqit:{QuantumModule:i}}=this,o=new i(e);return gt.set(t,o),o}var F=n=>n.replace(/"/g,'\\"');_t.call(window);})();
35
35
  //# sourceMappingURL=data-binding.js.map