@webqit/oohtml 4.3.10 → 4.3.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/main.lite.js CHANGED
@@ -51,7 +51,7 @@ ${m}
51
51
  const abort${r} = () => this.removeEventListener( '${m}', handler${r} );
52
52
  this.$oohtml_internal_databinding_signals?.push( { abort: abort${r} } );
53
53
  `;if(p==="$")return`$exec__(this, '${m}', ${x});`;if(u.trim())throw new Error(`Invalid binding: ${u}.`)}).join(`
54
- `),{webqit:{QuantumModule:o}}=this,{parserParams:s,compilerParams:a,runtimeParams:l}=i.advanced,c=new o(n,{parserParams:s,compilerParams:a,runtimeParams:l});return ir.set(t,c),c}var Nt=i=>i.replace(/"/g,'\\"');function Qr(i){let t=this,{webqit:{oohtml:{configs:{DATA_BINDING:e}}}}=t;(i?.matches(e.attrSelector)?[i]:[]).concat([...i?.querySelectorAll(e.attrSelector)||[]]).forEach(r=>{Gr.call(t,e,r.getAttribute(e.attr.render))}),qt(t,i,`(${e.discreteBindingsSelector})`).forEach(r=>{let n=zr(e,r.nodeValue);Ur.call(t,e,n.expr)})}var J=class extends z{static createRequest(t=null){let e=super.createRequest();if(t?.startsWith("@")){let[r,...n]=n.slice(1).split(".").map(o=>o.trim());e.targetContext=r,e.detail=n.join(".")}else e.detail=t;return e}get bindingsObj(){return this.host[this.configs.BINDINGS_API.api.bindings]}matchEvent(t){return super.matchEvent(t)&&(!t.detail||!this.detail||(Array.isArray(t.detail)?t.detail[0]===this.detail:t.detail===this.detail))}handle(t){if(t.meta.controller?.abort(),!(t.detail+"").trim())return t.respondWith(this.bindingsObj);let{window:{webqit:{Observer:e}}}=q;t.meta.controller=e.reduce(this.bindingsObj,Array.isArray(t.detail)?t.detail:[t.detail],e.get,r=>{this.disposed||t.respondWith(r.value)},{live:t.live,signal:t.signal,descripted:!0})}unsubscribed(t){t.meta.controller?.abort()}};F(J,"kind","bindings");function or(i={}){let{config:t,window:e}=B.call(this,"bindings-api",i,{attr:{bindingsreflection:"bindings"},api:{bind:"bind",bindings:"bindings"}});e.webqit.DOMBindingsContext=J,Gi.call(e,t),Xi.call(e,t)}function sr(i,t){let e=this,{webqit:{Observer:r,oohtml:{configs:{CONTEXT_API:n}}}}=e;if(!v(t).has("bindings")){let o=Object.create(null);v(t).set("bindings",o),r.observe(o,s=>{if(t instanceof e.Element){let a=Oe(t.getAttribute(i.attr.bindingsreflection)||""),l=new Map(a);for(let c of s)c.detail?.publish!==!1&&(c.type==="delete"?a.delete(c.key):a.set(c.key,void 0));a.size&&a.size!==l.size?t.setAttribute(i.attr.bindingsreflection,`{ ${[...a.entries()].map(([c,u])=>u===void 0?c:`${c}: ${u}`).join(", ")} }`):a.size||t.toggleAttribute(i.attr.bindingsreflection,!1)}else{let a=t[n.api.contexts];for(let l of s)if(l.type==="delete"){let c=a.find(J.kind,l.key);c&&a.detach(c)}else a.find(J.kind,l.key)||a.attach(new J(l.key))}})}return v(t).get("bindings")}function Gi(i){let t=this,{webqit:{Observer:e}}=t;[t.Document.prototype,t.Element.prototype,t.ShadowRoot.prototype].forEach(r=>{let n=r===t.Document.prototype?"Document":r===t.ShadowRoot.prototype?"ShadowRoot":"Element";if(i.api.bind in r)throw new Error(`The ${n} prototype already has a "${i.api.bind}" API!`);if(i.api.bindings in r)throw new Error(`The ${n} prototype already has a "${i.api.bindings}" API!`);Object.defineProperty(r,i.api.bind,{value:function(o,s={}){return Qi.call(t,i,this,o,s)}}),Object.defineProperty(r,i.api.bindings,{get:function(){return e.proxy(sr.call(t,i,this))}})})}function Qi(i,t,e,{merge:r,diff:n,publish:o,namespace:s}={}){let a=this,{webqit:{Observer:l}}=a,c=sr.call(this,i,t),u={diff:n,namespace:s,detail:{publish:o}},f=r?[]:l.ownKeys(c,u).filter(d=>!(d in e));return l.batch(c,()=>(f.length&&l.deleteProperties(c,f,u),l.set(c,e,u)),u)}function Xi(i){let t=this,{webqit:{realdom:e,Observer:r,oohtml:{configs:n}}}=t,o=(a,l)=>{let c=a[n.CONTEXT_API.api.contexts];c.find(J.kind,l)||c.attach(new J(l))},s=(a,l)=>{let c,u=a[n.CONTEXT_API.api.contexts];for(;c=u.find(J.kind,l);)u.detach(c)};e.realtime(t.document).query(`[${t.CSS.escape(i.attr.bindingsreflection)}]`,a=>{a.exits.forEach(l=>s(l)),a.entrants.forEach(l=>{let c=Oe(l.getAttribute(i.attr.bindingsreflection)||""),u=[...c.entries()].filter(([f,d])=>d!==void 0);u.length&&l[i.api.bind](Object.fromEntries(u),{merge:!0,publish:!1});for(let[f]of c)o(l,f)})},{id:"bindings:dom",live:!0,subtree:"cross-roots",timing:"sync",eventDetails:!0}),e.realtime(t.document,"attr").observe(i.attr.bindingsreflection,a=>{let l=sr.call(t,i,a.target),c=Oe(a.value||""),u=Oe(a.oldValue||"");for(let f of new Set([...c.keys(),...u.keys()]))u.has(f)?c.has(f)?c.get(f)!==u.get(f)&&r.set(l,f,c.get(f),{detail:{publish:!1}}):(u.get(f)!==void 0&&r.deleteProperty(l,f,{detail:{publish:!1}}),s(a.target,f)):(c.get(f)!==void 0&&r.set(l,f,c.get(f),{detail:{publish:!1}}),o(a.target,f))},{id:"bindings:attr",subtree:"cross-roots",timing:"sync",newValue:!0,oldValue:!0})}var Oe=i=>(i=i.trim(),new Map(ct(i.slice(1,-1),",").filter(t=>t.trim()).map(t=>ct(t,":").map(e=>e.trim()))));var et=class{static instance(t){return v(t).get("defsmanager::instance")||new this(t)}constructor(t,e=null,r=0){let{window:n}=q,{webqit:{realdom:o,oohtml:{configs:s}}}=n;v(t).get("defsmanager::instance")?.dispose(),v(t).set("defsmanager::instance",this),this.window=n,this.host=t,this.config=s.HTML_IMPORTS,this.parent=e,this.level=r,this.defs=pt(this.host),this.defId=(this.host.getAttribute(this.config.attr.def)||"").trim(),this.validateDefId(this.defId),this.realtimeA=o.realtime(this.host.content).children(a=>{this.expose(a.entrants,!0),this.expose(a.exits,!1)},{live:!0,timing:"sync"}),this.realtimeB=o.realtime(this.host).attr(["src","loading"],(...a)=>this.evaluateLoading(...a),{live:!0,atomic:!0,timing:"sync",lifecycleSignals:!0}),this.realtimeC=this.evalInheritance()}validateDefId(t){if(["@","/","*","#"].some(e=>t.includes(e)))throw new Error(`The export ID "${t}" contains an invalid character.`)}expose(t,e){let{window:r}=q,{webqit:{Observer:n}}=r,o,s=this.defs["#"]||[];t.forEach(a=>{if(a.nodeType!==1)return;let l=a.matches(this.config.templateSelector),c=(a.getAttribute(l?this.config.attr.def:this.config.attr.fragmentdef)||"").trim();e?(l&&c?new et(a,this.host,this.level+1):(s.push(a),o=!0,typeof requestIdleCallback=="function"&&requestIdleCallback(()=>{this.config.idleCompilers?.forEach(u=>u.call(this.window,a))})),c&&(this.validateDefId(c),n.set(this.defs,(!l&&"#"||"")+c,a))):(l&&c?et.instance(a).dispose():(s=s.filter(u=>u!==a),o=!0),c&&n.deleteProperty(this.defs,(!l&&"#"||"")+c))}),o&&n.set(this.defs,"#",s)}evaluateLoading([t,e],{signal:r}){let{window:{webqit:{Observer:n}}}=q,o=(t.value||"").trim();if(!o)return;let s,a=u=>{if(!u)return s;s=u.then(()=>c.remove())},l=(e.value||"").trim(),c=n.intercept(this.defs,"get",async(u,f,d)=>(l==="lazy"&&a(this.load(o,!0)),await a(),d()),{signal:r});l!=="lazy"&&a(this.load(o))}load(t){let{window:e}=q;if(this.host.content.children.length)return Promise.resolve();if(this.fetchInFlight?.src===t)return this.fetchInFlight.request;this.fetchInFlight?.controller.abort();let r=new AbortController,n=(s,a)=>this.host.dispatchEvent(new e.CustomEvent(s,{detail:a})),o=e.fetch(t,{signal:r.signal,element:this.host}).then(s=>s.ok?s.text():Promise.reject(s.statusText)).then(s=>(this.host.innerHTML=s.trim(),n("load"),this.host)).catch(s=>(console.error(`Error fetching the bundle at "${t}": ${s.message}`),this.fetchInFlight=null,n("loaderror"),this.host));return this.fetchInFlight={src:t,request:o,controller:r},o}evalInheritance(){if(!this.parent)return[];let{window:{webqit:{Observer:t}}}=q,e=(this.host.getAttribute(this.config.attr.extends)||"").trim(),r=(this.host.getAttribute(this.config.attr.inherits)||"").trim(),n=a=>{a.forEach(l=>{t.get(this.defs,l.key)===l.oldValue&&(["get","set","def"].includes(l.type)?t[l.type.replace("get","set")](this.defs,l.key,l.value):l.type==="delete"&&t.deleteProperty(this.defs,l.key))})},o=[],s=pt(this.parent);return e&&o.push(t.reduce(s,[e,this.config.api.defs,1/0],t.get,n,{live:!0})),(r=r.split(" ").map(a=>a.trim()).filter(a=>a)).length&&o.push(t.get(s,r,n,{live:!0})),o}dispose(){this.realtimeA.disconnect(),this.realtimeB.disconnect(),this.realtimeC.forEach(t=>t instanceof Promise?t.then(e=>e.abort()):t.abort()),Object.entries(this.defs).forEach(([t,e])=>{t.startsWith("#")||et.instance(e).dispose()})}};var Se,rt,Dt,Lt,lt=class extends z{constructor(){super(...arguments);Ht(this,Se,{});Ht(this,rt,void 0);Ht(this,Dt,void 0);Ht(this,Lt,void 0)}static createRequest(e=null){let r=super.createRequest();if(e?.startsWith("/"))r.detail=e,r.targetContext=1/0;else if(e?.startsWith("@")){let[n,...o]=e.slice(1).split(/(?<=\w)(?=\/|#)/).map(s=>s.trim());r.targetContext=n,r.detail=o.join("")}else r.detail=e;return r}get localModules(){return pt(this.host)}get inheritedModules(){return G(this,Se)}handle(e){let{window:{webqit:{Observer:r}}}=q;e.meta.controller?.abort();let n=(e.detail||"").split(/\/|(?<=\w)(?=#)/g).map(s=>s.trim()).filter(s=>s);if(!n.length)return e.respondWith();n=n.join(`/${this.configs.HTML_IMPORTS.api.defs}/`)?.split("/").map(s=>s==="*"?1/0:s)||[];let o={live:e.live,signal:e.signal,descripted:!0};e.meta.controller=r.reduce(G(this,rt),n,r.get,s=>{if(Array.isArray(s))for(let a of s)e.respondWith(a);else e.respondWith(s.value)},o)}unsubscribed(e){e.meta.controller?.abort()}initialize(e){this.host=e;let{window:{webqit:{Observer:r}}}=q;oe(this,rt,{...this.localModules}),G(this,Dt)?.abort(),oe(this,Dt,r.observe(this.localModules,o=>{for(let s of o)s.type==="delete"?this.inheritedModules&&r.has(this.inheritedModules,s.key)?r.set(G(this,rt),s.key,r.get(this.inheritedModules,s.key)):r.deleteProperty(G(this,rt),s.key):r.set(G(this,rt),s.key,s.value)},{timing:"sync"}));let n=this.configs.HTML_IMPORTS;if(this.host.matches&&n.attr.importscontext){let o=this.host.ownerDocument.defaultView.webqit.realdom,s;G(this,Lt)?.disconnect(),oe(this,Lt,o.realtime(this.host).attr(n.attr.importscontext,(a,{signal:l})=>{let c=(a.value||"").trim();if(c===s)return;s=c;let u={...this.constructor.createRequest(c?`${c}/*`:"*"),live:!0,signal:l,diff:!0};this.host.parentNode[this.configs.CONTEXT_API.api.contexts].request(u,f=>{f.type==="delete"?(Reflect.deleteProperty(this.inheritedModules,f.key),r.has(this.localModules,f.key)||r.deleteProperty(G(this,rt),f.key)):(Reflect.set(this.inheritedModules,f.key,f.value),r.has(this.localModules,f.key)||r.set(G(this,rt),f.key,f.value))})},{live:!0,timing:"sync",oldValue:!0,lifecycleSignals:!0}))}return super.initialize(e)}dispose(e){return G(this,Dt)?.abort(),G(this,Lt)?.disconnect(),super.dispose(e)}};Se=new WeakMap,rt=new WeakMap,Dt=new WeakMap,Lt=new WeakMap,F(lt,"kind","html-imports");function Xr(){let{window:i}=q,{webqit:t}=i,{realdom:e,oohtml:{configs:r}}=t;if(t.HTMLImportElement)return t.HTMLImportElement;let n=r.HTML_IMPORTS.elements.import.includes("-")?i.HTMLElement:class{};class o extends n{static instance(a){return r.HTML_IMPORTS.elements.import.includes("-")&&a instanceof this?a:v(a).get("import::instance")||new this(a)}constructor(...a){super();let l=a[0]||this;v(l).set("import::instance",this),Object.defineProperty(this,"el",{get:()=>l,configurable:!1});let c={};Object.defineProperty(this,"#",{get:()=>c,configurable:!1}),c.slottedElements=new Set,c.setAnchorNode=u=>(c.anchorNode=u,u),c.live=u=>{if(c.liveImportsRealtime)throw new Error("Import element already in live mode.");let f=this.el.isConnected?this.el.parentNode:c.anchorNode.parentNode;c.liveImportsRealtime=e.realtime(this.el).attr(r.HTML_IMPORTS.attr.ref,(d,{signal:p})=>{c.moduleRef=d.value;let m=c.moduleRef.includes("#")?c.moduleRef:`${c.moduleRef}#`,x={...lt.createRequest(m),live:p&&!0,signal:p,diff:!m.endsWith("#")};f[r.CONTEXT_API.api.contexts].request(x,S=>{u((S instanceof i.HTMLTemplateElement?[...S.content.children]:Array.isArray(S)?S:S&&[S])||[])})},{live:!0,timing:"sync",lifecycleSignals:!0}),c.autoDestroyRealtime=e.realtime(i.document).track(f,()=>{c.die()},{subtree:"cross-roots",timing:"sync",generation:"exits"})},c.die=()=>{c.autoDestroyRealtime?.disconnect(),c.liveImportsRealtime?.disconnect(),c.liveImportsRealtime=null},c.hydrate=(u,f)=>{u.replaceWith(c.setAnchorNode(this.createAnchorNode())),c.live(d=>{if(c.originalsRemapped)return this.fill(d);let p=d.map((m,x)=>({el:m,fragmentDef:m.getAttribute(r.HTML_IMPORTS.attr.fragmentdef)||"",tagName:m.tagName,i:x}));f.forEach((m,x)=>{let S=m.tagName,g=m.getAttribute(r.HTML_IMPORTS.attr.fragmentdef)||"",_=(x++,p.find(O=>O.tagName===S&&O.fragmentDef===g&&O.i===x));_&&v(m).set("original@imports",_.el),v(m).set("slot@imports",this.el),c.slottedElements.add(m)}),c.originalsRemapped=!0})},c.autoRestore=(u=null)=>{c.autoRestoreRealtime?.disconnect(),u&&u();let f=()=>{this.el.isConnected||(this.el.setAttribute("data-nodecount",0),c.internalMutation=!0,c.anchorNode.replaceWith(this.el),c.internalMutation=!1,c.setAnchorNode(null))};if(!c.slottedElements.size)return f();let d=e.realtime(c.anchorNode.parentNode).observe([...c.slottedElements],p=>{if(p.exits.forEach(m=>{v(m).delete("slot@imports"),c.slottedElements.delete(m)}),!c.slottedElements.size){if(d.disconnect(),!p.target.isConnected)return;f()}},{subtree:"cross-roots",timing:"sync",generation:"exits"});c.autoRestoreRealtime=d},c.connectedCallback=()=>{c.internalMutation||c.live(u=>this.fill(u))},c.disconnectedCallback=()=>{c.internalMutation||c.die()}}createAnchorNode(){if(i.webqit.env!=="server")return i.document.createTextNode("");let a=i.document.createElement("div");a.textContent=this.el.outerHTML;let l=i.document.createComment(a.innerHTML);return v(l).set("isAnchorNode",!0),l}fill(a,l){!this.el.isConnected&&(!this["#"].anchorNode||!this["#"].anchorNode.isConnected)||(Array.isArray(a)&&(a=new Set(a)),this.el.setAttribute("data-nodecount",a.size),this["#"].autoRestore(()=>{if(this["#"].slottedElements.forEach(c=>{let u=v(c).get("original@imports");a.has(u)?a.delete(u):(this["#"].slottedElements.delete(c),c.remove())}),a.size&&this.el.isConnected){let c=this["#"].setAnchorNode(this.createAnchorNode());this["#"].internalMutation=!0,this.el.replaceWith(c),this["#"].internalMutation=!1}a.forEach(c=>{let u=c.cloneNode(!0);u.hasAttribute(r.HTML_IMPORTS.attr.fragmentdef)||u.toggleAttribute(r.HTML_IMPORTS.attr.fragmentdef,!0),v(u).set("original@imports",c),v(u).set("slot@imports",this.el),this["#"].slottedElements.add(u),this["#"].anchorNode.before(u)})}))}empty(){this["#"].slottedElements.forEach(a=>a.remove())}get anchorNode(){return this["#"].anchorNode}get moduleRef(){return this["#"].moduleRef}get slottedElements(){return this["#"].slottedElements}}return r.HTML_IMPORTS.elements.import.includes("-")&&customElements.define(r.HTML_IMPORTS.elements.import,o),t.HTMLImportElement=o,o}function ar(i={}){let{config:t,window:e}=B.call(this,"html-imports",i,{elements:{import:"import"},attr:{def:"def",extends:"extends",inherits:"inherits",ref:"ref",importscontext:"importscontext"},api:{def:"def",defs:"defs",import:"import"}});t.attr.fragmentdef||(t.attr.fragmentdef=t.attr.def),t.templateSelector=`template[${e.CSS.escape(t.attr.def)}]`,t.importsContextSelector=`[${e.CSS.escape(t.attr.importscontext)}]`,t.slottedElementsSelector=`[${e.CSS.escape(t.attr.fragmentdef)}]:not(template)`;let r=(n,o)=>{let s=`starts-with(., "${n}")`,a=`substring(., string-length(.) - string-length("${o}") + 1) = "${o}"`;return`${s} and ${a}`};t.anchorNodeSelector=`comment()[${r(`&lt;${t.elements.import}`,`&lt;/${t.elements.import}&gt;`)}]`,e.webqit.HTMLImportsContext=lt,e.webqit.HTMLImportElement=Xr(),Ji.call(e,t),Yi.call(e,t)}function pt(i,t=!0){if(!v(i).has("defs")&&t){let e=Object.create(null);v(i).set("defs",e)}return v(i).get("defs")}function Ji(i){let t=this,{webqit:{oohtml:{configs:e}}}=t;if(i.api.def in t.HTMLTemplateElement.prototype)throw new Error(`The "HTMLTemplateElement" prototype already has a "${i.api.def}" API!`);if(i.api.defs in t.HTMLTemplateElement.prototype)throw new Error(`The "HTMLTemplateElement" prototype already has a "${i.api.defs}" API!`);Object.defineProperty(t.HTMLTemplateElement.prototype,i.api.def,{get:function(){return this.getAttribute(i.attr.def)}}),Object.defineProperty(t.HTMLTemplateElement.prototype,i.api.defs,{get:function(){return pt(this)}}),Object.defineProperty(t.HTMLTemplateElement.prototype,"scoped",{configurable:!0,get(){return this.hasAttribute("scoped")},set(n){this.toggleAttribute("scoped",n)}}),[t.Document.prototype,t.Element.prototype,t.ShadowRoot.prototype].forEach(n=>{let o=n===t.Document.prototype?"Document":n===t.ShadowRoot.prototype?"ShadowRoot":"Element";if(i.api.import in n)throw new Error(`The ${o} prototype already has a "${i.api.import}" API!`);Object.defineProperty(n,i.api.import,{value:function(s,a=!1,l=null){return r(this,...arguments)}})});function r(n,o,s=!1,a=null){let l={};typeof s=="function"?(a=s,s=!1):typeof s=="object"&&s?l={...s,...l}:l={live:s};let c={...lt.createRequest(o),...l};return n[e.CONTEXT_API.api.contexts].request(c,a)}}function Yi(i){let t=this,{webqit:{Observer:e,realdom:r,oohtml:{configs:n},HTMLImportElement:o,HTMLImportsContext:s}}=t,a=u=>{let f=u[n.CONTEXT_API.api.contexts];f.find(s.kind)||f.attach(new s)},l=u=>{let f=u[n.CONTEXT_API.api.contexts],d=f.find(s.kind);d&&(!u.isConnected||!u.matches?.(i.importsContextSelector)&&!Object.keys(d.localModules).length)&&f.detach(d)};r.realtime(t.document).query([i.templateSelector,i.importsContextSelector],u=>{u.entrants.forEach(f=>{if(f.matches(i.templateSelector)){let d=et.instance(f);d.ownerContext=f.scoped?f.parentNode:f.getRootNode();let p=pt(d.ownerContext);d.defId&&e.set(p,d.defId,f),a(d.ownerContext)}else a(f)}),u.exits.forEach(f=>{if(f.matches(i.templateSelector)){let d=et.instance(f),p=pt(d.ownerContext);d.defId&&d.ownerContext.isConnected&&e.deleteProperty(p,d.defId),l(d.ownerContext)}else l(f)})},{id:"imports:template/importscontext",live:!0,subtree:"cross-roots",timing:"sync",staticSensitivity:!0,eventDetails:!0}),r.realtime(t.document).query(i.elements.import,u=>{u.entrants.forEach(f=>c(f,!0,u)),u.exits.forEach(f=>c(f,!1,u))},{id:"imports:import",live:!0,subtree:"cross-roots",timing:"sync",deferred:!0});function c(u,f){let d=o.instance(u);f?d["#"].connectedCallback():d["#"].disconnectedCallback()}t.webqit.env!=="server"&&r.realtime(t.document).query(`(${i.anchorNodeSelector})`,u=>{u.entrants.forEach(f=>{if(v(f).get("isAnchorNode"))return;let d=t.document.createElement("div");d.innerHTML=f.nodeValue,d.innerHTML=d.firstChild.textContent;let p=d.firstChild,m=parseInt(p.getAttribute("data-nodecount")),x=new Set,S=f;for(;(S=S.previousElementSibling)&&S.matches(i.slottedElementsSelector)&&m--;)x.add(S);o.instance(p)["#"].hydrate(f,x)})},{id:"imports:hydration",live:!0,subtree:"cross-roots",timing:"sync"})}function cr(i={}){let{config:t,window:e}=B.call(this,"context-api",i,{attr:{contextname:"contextname"},api:{contexts:"contexts"}}),r=new Map,n=e.EventTarget.prototype.dispatchEvent;Object.defineProperty(e.EventTarget.prototype,"dispatchEvent",{value:function(...o){let s=o[0],a=this.getRootNode?.();if(["contextclaim","contextrequest"].includes(s.type)&&a){s.meta&&(s.meta.target=this);let l=u=>{if(u.stopImmediatePropagation(),u.meta&&(u.meta.target=u.target),!u.answered){if(r.get(a)||r.set(a,new Set),u.type==="contextrequest"&&u.live)r.get(a).add(u);else if(u.type==="contextclaim"){let f=new Set;return r.get(a).forEach(d=>{!u.target.contains(d.target)||!u.detail?.matchEvent?.(d)||(r.get(a).delete(d),f.add(d))}),r.get(a).size||r.delete(a),u.respondWith?.(f)}}};a.addEventListener(s.type,l);let c=n.call(this,...o);return a.removeEventListener(s.type,l),c}return n.call(this,...o)}}),e.webqit.DOMContexts=dt,e.webqit.DOMContext=z,e.webqit.DOMContextRequestEvent=xe(),e.webqit.DOMContextResponse=$t,e.webqit.DuplicateContextError=Et,Zi.call(e,t)}function Zi(i){let t=this;[t.Document.prototype,t.Element.prototype,t.ShadowRoot.prototype].forEach(e=>{let r=e===t.Document.prototype?"Document":e===t.ShadowRoot.prototype?"ShadowRoot":"Element";if(i.api.contexts in e)throw new Error(`The ${r} prototype already has a "${i.api.contexts}" API!`);Object.defineProperty(e,i.api.contexts,{get:function(){return dt.instance(this)}})})}function ur({advanced:i={},...t}){let{config:e,window:r}=B.call(this,"scoped-css",t,{api:{styleSheets:"styleSheets"},style:{retention:"retain",mimeTypes:"text/css",strategy:null}});e.styleSelector=(Array.isArray(e.style.mimeTypes)?e.style.mimeTypes:e.style.mimeTypes.split("|")).concat("").reduce((n,o)=>{let s=o?`[type="${r.CSS.escape(o)}"]`:":not([type])";return n.concat(`style${s}`)},[]).join(","),r.webqit.oohtml.Style={compileCache:new Map},Ki.call(r,e),tn.call(r,e)}function Ki(i){let t=this,e=new Map;[t.Element.prototype].forEach(r=>{let n="Element";if(i.api.styleSheets in r)throw new Error(`The ${n} prototype already has a "${i.api.styleSheets}" API!`);Object.defineProperty(r,i.api.styleSheets,{get:function(){return e.has(this)||e.set(this,[]),e.get(this)}})}),Object.defineProperty(t.HTMLStyleElement.prototype,"scoped",{configurable:!0,get(){return this.hasAttribute("scoped")},set(r){this.toggleAttribute("scoped",r)}})}function tn(i){let t=this,{webqit:{oohtml:e,realdom:r}}=t,n=Object.getOwnPropertyDescriptor(globalThis,"window")?.get?.toString().includes("[native code]")??!1;t.CSS.supports||(t.CSS.supports=()=>!1);let o=new WeakSet;r.realtime(t.document).query(i.styleSelector,s=>{s.entrants.forEach(a=>{if(o.has(a))return;o.add(a);let l=St(a.textContent),c=CSS.supports("selector(:has(a,b))"),u=a.scoped&&(c?`:has(> style[rand-${l}])`:`[rand-${l}]`),f=a.scoped&&t.CSSScopeRule&&!1,d=a.scoped&&a.parentNode||a.getRootNode();if(d instanceof t.Element){if(d[i.api.styleSheets].push(a),!n)return;(c?a:d).toggleAttribute(`rand-${l}`,!0)}if(!!n)if(a.scoped&&a.hasAttribute("shared")){let p;(p=e.Style.compileCache.get(l))||(p=en.call(t,a,null,f,u),e.Style.compileCache.set(l,p)),Object.defineProperty(a,"sheet",{value:p,configurable:!0}),a.textContent=`
54
+ `),{webqit:{QuantumModule:o}}=this,{parserParams:s,compilerParams:a,runtimeParams:l}=i.advanced,c=new o(n,{parserParams:s,compilerParams:a,runtimeParams:l});return ir.set(t,c),c}var Nt=i=>i.replace(/"/g,'\\"');function Qr(i){let t=this,{webqit:{oohtml:{configs:{DATA_BINDING:e}}}}=t;(i?.matches(e.attrSelector)?[i]:[]).concat([...i?.querySelectorAll(e.attrSelector)||[]]).forEach(r=>{Gr.call(t,e,r.getAttribute(e.attr.render))}),qt(t,i,`(${e.discreteBindingsSelector})`).forEach(r=>{let n=zr(e,r.nodeValue);Ur.call(t,e,n.expr)})}var J=class extends z{static createRequest(t=null){let e=super.createRequest();if(t?.startsWith("@")){let[r,...n]=n.slice(1).split(".").map(o=>o.trim());e.targetContext=r,e.detail=n.join(".")}else e.detail=t;return e}get bindingsObj(){return this.host[this.configs.BINDINGS_API.api.bindings]}matchEvent(t){return super.matchEvent(t)&&(!t.detail||!this.detail||(Array.isArray(t.detail)?t.detail[0]===this.detail:t.detail===this.detail))}handle(t){if(t.meta.controller?.abort(),!(t.detail+"").trim())return t.respondWith(this.bindingsObj);let{window:{webqit:{Observer:e}}}=q;t.meta.controller=e.reduce(this.bindingsObj,Array.isArray(t.detail)?t.detail:[t.detail],e.get,r=>{this.disposed||t.respondWith(r.value)},{live:t.live,signal:t.signal,descripted:!0})}unsubscribed(t){t.meta.controller?.abort()}};F(J,"kind","bindings");function or(i={}){let{config:t,window:e}=B.call(this,"bindings-api",i,{attr:{bindingsreflection:"bindings"},api:{bind:"bind",bindings:"bindings"}});e.webqit.DOMBindingsContext=J,Gi.call(e,t),Xi.call(e,t)}function sr(i,t){let e=this,{webqit:{Observer:r,oohtml:{configs:{CONTEXT_API:n}}}}=e;if(!v(t).has("bindings")){let o=Object.create(null);v(t).set("bindings",o),r.observe(o,s=>{if(t instanceof e.Element){let a=Oe(t.getAttribute(i.attr.bindingsreflection)||""),l=new Map(a);for(let c of s)c.detail?.publish!==!1&&(c.type==="delete"?a.delete(c.key):a.set(c.key,void 0));a.size&&a.size!==l.size?t.setAttribute(i.attr.bindingsreflection,`{ ${[...a.entries()].map(([c,u])=>u===void 0?c:`${c}: ${u}`).join(", ")} }`):a.size||t.toggleAttribute(i.attr.bindingsreflection,!1)}else{let a=t[n.api.contexts];for(let l of s)if(l.type==="delete"){let c=a.find(J.kind,l.key);c&&a.detach(c)}else a.find(J.kind,l.key)||a.attach(new J(l.key))}})}return v(t).get("bindings")}function Gi(i){let t=this,{webqit:{Observer:e}}=t;[t.Document.prototype,t.Element.prototype,t.ShadowRoot.prototype].forEach(r=>{let n=r===t.Document.prototype?"Document":r===t.ShadowRoot.prototype?"ShadowRoot":"Element";if(i.api.bind in r)throw new Error(`The ${n} prototype already has a "${i.api.bind}" API!`);if(i.api.bindings in r)throw new Error(`The ${n} prototype already has a "${i.api.bindings}" API!`);Object.defineProperty(r,i.api.bind,{value:function(o,s={}){return Qi.call(t,i,this,o,s)}}),Object.defineProperty(r,i.api.bindings,{get:function(){return e.proxy(sr.call(t,i,this))}})})}function Qi(i,t,e,{merge:r,diff:n,publish:o,namespace:s}={}){let a=this,{webqit:{Observer:l}}=a,c=sr.call(this,i,t),u={diff:n,namespace:s,detail:{publish:o}},f=r?[]:l.ownKeys(c,u).filter(d=>!(d in e));return l.batch(c,()=>(f.length&&l.deleteProperties(c,f,u),l.set(c,e,u)),u)}function Xi(i){let t=this,{webqit:{realdom:e,Observer:r,oohtml:{configs:n}}}=t,o=(a,l)=>{let c=a[n.CONTEXT_API.api.contexts];c.find(J.kind,l)||c.attach(new J(l))},s=(a,l)=>{let c,u=a[n.CONTEXT_API.api.contexts];for(;c=u.find(J.kind,l);)u.detach(c)};e.realtime(t.document).query(`[${t.CSS.escape(i.attr.bindingsreflection)}]`,a=>{a.exits.forEach(l=>s(l)),a.entrants.forEach(l=>{let c=Oe(l.getAttribute(i.attr.bindingsreflection)||""),u=[...c.entries()].filter(([f,d])=>d!==void 0);u.length&&l[i.api.bind](Object.fromEntries(u),{merge:!0,publish:!1});for(let[f]of c)o(l,f)})},{id:"bindings:dom",live:!0,subtree:"cross-roots",timing:"sync",eventDetails:!0}),e.realtime(t.document,"attr").observe(i.attr.bindingsreflection,a=>{let l=sr.call(t,i,a.target),c=Oe(a.value||""),u=Oe(a.oldValue||"");for(let f of new Set([...c.keys(),...u.keys()]))u.has(f)?c.has(f)?c.get(f)!==u.get(f)&&r.set(l,f,c.get(f),{detail:{publish:!1}}):(u.get(f)!==void 0&&r.deleteProperty(l,f,{detail:{publish:!1}}),s(a.target,f)):(c.get(f)!==void 0&&r.set(l,f,c.get(f),{detail:{publish:!1}}),o(a.target,f))},{id:"bindings:attr",subtree:"cross-roots",timing:"sync",newValue:!0,oldValue:!0})}var Oe=i=>(i=i.trim(),new Map(ct(i.slice(1,-1),",").filter(t=>t.trim()).map(t=>ct(t,":").map(e=>e.trim()))));var et=class{static instance(t){return v(t).get("defsmanager::instance")||new this(t)}constructor(t,e=null,r=0){let{window:n}=q,{webqit:{realdom:o,oohtml:{configs:s}}}=n;v(t).get("defsmanager::instance")?.dispose(),v(t).set("defsmanager::instance",this),this.window=n,this.host=t,this.config=s.HTML_IMPORTS,this.parent=e,this.level=r,this.defs=pt(this.host),this.defId=(this.host.getAttribute(this.config.attr.def)||"").trim(),this.validateDefId(this.defId),this.realtimeA=o.realtime(this.host.content).children(a=>{this.expose(a.entrants,!0),this.expose(a.exits,!1)},{live:!0,timing:"sync"}),this.realtimeB=o.realtime(this.host).attr(["src","loading"],(...a)=>this.evaluateLoading(...a),{live:!0,atomic:!0,timing:"sync",lifecycleSignals:!0}),this.realtimeC=this.evalInheritance()}validateDefId(t){if(["@","/","*","#"].some(e=>t.includes(e)))throw new Error(`The export ID "${t}" contains an invalid character.`)}expose(t,e){let{window:r}=q,{webqit:{Observer:n}}=r,o,s=this.defs["#"]||[];t.forEach(a=>{if(a.nodeType!==1)return;let l=a.matches(this.config.templateSelector),c=(a.getAttribute(l?this.config.attr.def:this.config.attr.fragmentdef)||"").trim();e?(l&&c?new et(a,this.host,this.level+1):(s.push(a),o=!0,typeof requestIdleCallback=="function"&&requestIdleCallback(()=>{this.config.idleCompilers?.forEach(u=>u.call(this.window,a))})),c&&(this.validateDefId(c),n.set(this.defs,(!l&&"#"||"")+c,a))):(l&&c?et.instance(a).dispose():(s=s.filter(u=>u!==a),o=!0),c&&n.deleteProperty(this.defs,(!l&&"#"||"")+c))}),o&&n.set(this.defs,"#",s)}evaluateLoading([t,e],{signal:r}){let{window:{webqit:{Observer:n}}}=q,o=(t.value||"").trim();if(!o)return;let s,a=u=>{if(!u)return s;s=u.then(()=>c.remove())},l=(e.value||"").trim(),c=n.intercept(this.defs,"get",async(u,f,d)=>(l==="lazy"&&a(this.load(o,!0)),await a(),d()),{signal:r});l!=="lazy"&&a(this.load(o))}load(t){let{window:e}=q;if(this.host.content.children.length)return Promise.resolve();if(this.fetchInFlight?.src===t)return this.fetchInFlight.request;this.fetchInFlight?.controller.abort();let r=new AbortController,n=(s,a)=>this.host.dispatchEvent(new e.CustomEvent(s,{detail:a})),o=e.fetch(t,{signal:r.signal,element:this.host}).then(s=>s.ok?s.text():Promise.reject(s.statusText)).then(s=>(this.host.innerHTML=s.trim(),n("load"),this.host)).catch(s=>(console.error(`Error fetching the bundle at "${t}": ${s.message}`),this.fetchInFlight=null,n("loaderror"),this.host));return this.fetchInFlight={src:t,request:o,controller:r},o}evalInheritance(){if(!this.parent)return[];let{window:{webqit:{Observer:t}}}=q,e=(this.host.getAttribute(this.config.attr.extends)||"").trim(),r=(this.host.getAttribute(this.config.attr.inherits)||"").trim(),n=a=>{a.forEach(l=>{t.get(this.defs,l.key)===l.oldValue&&(["get","set","def"].includes(l.type)?t[l.type.replace("get","set")](this.defs,l.key,l.value):l.type==="delete"&&t.deleteProperty(this.defs,l.key))})},o=[],s=pt(this.parent);return e&&o.push(t.reduce(s,[e,this.config.api.defs,1/0],t.get,n,{live:!0})),(r=r.split(" ").map(a=>a.trim()).filter(a=>a)).length&&o.push(t.get(s,r,n,{live:!0})),o}dispose(){this.realtimeA.disconnect(),this.realtimeB.disconnect(),this.realtimeC.forEach(t=>t instanceof Promise?t.then(e=>e.abort()):t.abort()),Object.entries(this.defs).forEach(([t,e])=>{t.startsWith("#")||et.instance(e).dispose()})}};var Se,rt,Dt,Lt,lt=class extends z{constructor(){super(...arguments);Ht(this,Se,{});Ht(this,rt,void 0);Ht(this,Dt,void 0);Ht(this,Lt,void 0)}static createRequest(e=null){let r=super.createRequest();if(e?.startsWith("/"))r.detail=e,r.targetContext=1/0;else if(e?.startsWith("@")){let[n,...o]=e.slice(1).split(/(?<=\w)(?=\/|#)/).map(s=>s.trim());r.targetContext=n,r.detail=o.join("")}else r.detail=e;return r}get localModules(){return pt(this.host)}get inheritedModules(){return G(this,Se)}handle(e){let{window:{webqit:{Observer:r}}}=q;e.meta.controller?.abort();let n=(e.detail||"").split(/\/|(?<=\w)(?=#)/g).map(s=>s.trim()).filter(s=>s);if(!n.length)return e.respondWith();n=n.join(`/${this.configs.HTML_IMPORTS.api.defs}/`)?.split("/").map(s=>s==="*"?1/0:s)||[];let o={live:e.live,signal:e.signal,descripted:!0};e.meta.controller=r.reduce(G(this,rt),n,r.get,s=>{if(Array.isArray(s))for(let a of s)e.respondWith(a);else e.respondWith(s.value)},o)}unsubscribed(e){e.meta.controller?.abort()}initialize(e){this.host=e;let{window:{webqit:{Observer:r}}}=q;oe(this,rt,{...this.localModules}),G(this,Dt)?.abort(),oe(this,Dt,r.observe(this.localModules,o=>{for(let s of o)s.type==="delete"?this.inheritedModules&&r.has(this.inheritedModules,s.key)?r.set(G(this,rt),s.key,r.get(this.inheritedModules,s.key)):r.deleteProperty(G(this,rt),s.key):r.set(G(this,rt),s.key,s.value)},{timing:"sync"}));let n=this.configs.HTML_IMPORTS;if(this.host.matches&&n.attr.importscontext){let o=this.host.ownerDocument.defaultView.webqit.realdom,s;G(this,Lt)?.disconnect(),oe(this,Lt,o.realtime(this.host).attr(n.attr.importscontext,(a,{signal:l})=>{let c=(a.value||"").trim();if(c===s)return;s=c;let u={...this.constructor.createRequest(c?`${c}/*`:"*"),live:!0,signal:l,diff:!0};this.host.parentNode[this.configs.CONTEXT_API.api.contexts].request(u,f=>{f.type==="delete"?(Reflect.deleteProperty(this.inheritedModules,f.key),r.has(this.localModules,f.key)||r.deleteProperty(G(this,rt),f.key)):(Reflect.set(this.inheritedModules,f.key,f.value),r.has(this.localModules,f.key)||r.set(G(this,rt),f.key,f.value))})},{live:!0,timing:"sync",oldValue:!0,lifecycleSignals:!0}))}return super.initialize(e)}dispose(e){return G(this,Dt)?.abort(),G(this,Lt)?.disconnect(),super.dispose(e)}};Se=new WeakMap,rt=new WeakMap,Dt=new WeakMap,Lt=new WeakMap,F(lt,"kind","html-imports");function Xr(){let{window:i}=q,{webqit:t}=i,{realdom:e,oohtml:{configs:r}}=t;if(t.HTMLImportElement)return t.HTMLImportElement;let n=r.HTML_IMPORTS.elements.import.includes("-")?i.HTMLElement:class{};class o extends n{static instance(a){return r.HTML_IMPORTS.elements.import.includes("-")&&a instanceof this?a:v(a).get("import::instance")||new this(a)}constructor(...a){super();let l=a[0]||this;v(l).set("import::instance",this),Object.defineProperty(this,"el",{get:()=>l,configurable:!1});let c={};Object.defineProperty(this,"#",{get:()=>c,configurable:!1}),c.slottedElements=new Set,c.setAnchorNode=u=>(c.anchorNode=u,u),c.live=u=>{if(c.liveImportsRealtime)throw new Error("Import element already in live mode.");let f=this.el.isConnected?this.el.parentNode:c.anchorNode.parentNode;c.liveImportsRealtime=e.realtime(this.el).attr(r.HTML_IMPORTS.attr.ref,(d,{signal:p})=>{c.moduleRef=d.value;let m=c.moduleRef.includes("#")?c.moduleRef:`${c.moduleRef}#`,x={...lt.createRequest(m),live:p&&!0,signal:p,diff:!m.endsWith("#")};f[r.CONTEXT_API.api.contexts].request(x,S=>{u((S instanceof i.HTMLTemplateElement?[...S.content.children]:Array.isArray(S)?S:S&&[S])||[])})},{live:!0,timing:"sync",lifecycleSignals:!0}),c.autoDestroyRealtime=e.realtime(i.document).track(f,()=>{c.die()},{subtree:"cross-roots",timing:"sync",generation:"exits"})},c.die=()=>{c.autoDestroyRealtime?.disconnect(),c.liveImportsRealtime?.disconnect(),c.liveImportsRealtime=null},c.hydrate=(u,f)=>{u.replaceWith(c.setAnchorNode(this.createAnchorNode())),c.live(d=>{if(c.originalsRemapped)return this.fill(d);let p=d.map((m,x)=>({el:m,fragmentDef:m.getAttribute(r.HTML_IMPORTS.attr.fragmentdef)||"",tagName:m.tagName,i:x}));f.forEach((m,x)=>{let S=m.tagName,g=m.getAttribute(r.HTML_IMPORTS.attr.fragmentdef)||"",_=(x++,p.find(O=>O.tagName===S&&O.fragmentDef===g&&O.i===x));_&&v(m).set("original@imports",_.el),v(m).set("slot@imports",this.el),c.slottedElements.add(m)}),c.originalsRemapped=!0})},c.autoRestore=(u=null)=>{c.autoRestoreRealtime?.disconnect(),u&&u();let f=()=>{this.el.isConnected||(this.el.setAttribute("data-nodecount",0),c.internalMutation=!0,c.anchorNode.replaceWith(this.el),c.internalMutation=!1,c.setAnchorNode(null))};if(!c.slottedElements.size)return f();let d=e.realtime(c.anchorNode.parentNode).observe([...c.slottedElements],p=>{if(p.exits.forEach(m=>{v(m).delete("slot@imports"),c.slottedElements.delete(m)}),!c.slottedElements.size){if(d.disconnect(),!p.target.isConnected)return;f()}},{subtree:"cross-roots",timing:"sync",generation:"exits"});c.autoRestoreRealtime=d},c.connectedCallback=()=>{c.internalMutation||c.live(u=>this.fill(u))},c.disconnectedCallback=()=>{c.internalMutation||c.die()}}createAnchorNode(){if(i.webqit.env!=="server")return i.document.createTextNode("");let a=i.document.createElement("div");a.textContent=this.el.outerHTML;let l=i.document.createComment(a.innerHTML);return v(l).set("isAnchorNode",!0),l}fill(a,l){!this.el.isConnected&&(!this["#"].anchorNode||!this["#"].anchorNode.isConnected)||(Array.isArray(a)&&(a=new Set(a)),this.el.setAttribute("data-nodecount",a.size),this["#"].autoRestore(()=>{if(this["#"].slottedElements.forEach(c=>{let u=v(c).get("original@imports");a.has(u)?a.delete(u):(this["#"].slottedElements.delete(c),c.remove())}),a.size&&this.el.isConnected){let c=this["#"].setAnchorNode(this.createAnchorNode());this["#"].internalMutation=!0,this.el.replaceWith(c),this["#"].internalMutation=!1}a.forEach(c=>{let u=c.cloneNode(!0);u.hasAttribute(r.HTML_IMPORTS.attr.fragmentdef)||u.toggleAttribute(r.HTML_IMPORTS.attr.fragmentdef,!0),v(u).set("original@imports",c),v(u).set("slot@imports",this.el),this["#"].slottedElements.add(u),this["#"].anchorNode.before(u)})}))}empty(){this["#"].slottedElements.forEach(a=>a.remove())}get anchorNode(){return this["#"].anchorNode}get moduleRef(){return this["#"].moduleRef}get slottedElements(){return this["#"].slottedElements}}return r.HTML_IMPORTS.elements.import.includes("-")&&customElements.define(r.HTML_IMPORTS.elements.import,o),t.HTMLImportElement=o,o}function ar(i={}){let{config:t,window:e}=B.call(this,"html-imports",i,{elements:{import:"import"},attr:{def:"def",extends:"extends",inherits:"inherits",ref:"ref",importscontext:"importscontext"},api:{def:"def",defs:"defs",import:"import"}});t.attr.fragmentdef||(t.attr.fragmentdef=t.attr.def),t.templateSelector=`template[${e.CSS.escape(t.attr.def)}]`,t.importsContextSelector=`[${e.CSS.escape(t.attr.importscontext)}]`,t.slottedElementsSelector=`[${e.CSS.escape(t.attr.fragmentdef)}]:not(template)`;let r=(n,o)=>{let s=`starts-with(., "${n}")`,a=`substring(., string-length(.) - string-length("${o}") + 1) = "${o}"`;return`${s} and ${a}`};t.anchorNodeSelector=`comment()[${r(`&lt;${t.elements.import}`,`&lt;/${t.elements.import}&gt;`)}]`,e.webqit.HTMLImportsContext=lt,e.webqit.HTMLImportElement=Xr(),Ji.call(e,t),Yi.call(e,t)}function pt(i,t=!0){if(!v(i).has("defs")&&t){let e=Object.create(null);v(i).set("defs",e)}return v(i).get("defs")}function Ji(i){let t=this,{webqit:{oohtml:{configs:e}}}=t;if(i.api.def in t.HTMLTemplateElement.prototype)throw new Error(`The "HTMLTemplateElement" prototype already has a "${i.api.def}" API!`);if(i.api.defs in t.HTMLTemplateElement.prototype)throw new Error(`The "HTMLTemplateElement" prototype already has a "${i.api.defs}" API!`);Object.defineProperty(t.HTMLTemplateElement.prototype,i.api.def,{get:function(){return this.getAttribute(i.attr.def)}}),Object.defineProperty(t.HTMLTemplateElement.prototype,i.api.defs,{get:function(){return pt(this)}}),Object.defineProperty(t.HTMLTemplateElement.prototype,"scoped",{configurable:!0,get(){return this.hasAttribute("scoped")},set(n){this.toggleAttribute("scoped",n)}}),[t.Document.prototype,t.Element.prototype,t.ShadowRoot.prototype].forEach(n=>{let o=n===t.Document.prototype?"Document":n===t.ShadowRoot.prototype?"ShadowRoot":"Element";if(i.api.import in n)throw new Error(`The ${o} prototype already has a "${i.api.import}" API!`);Object.defineProperty(n,i.api.import,{value:function(s,a=!1,l=null){return r(this,...arguments)}})});function r(n,o,s=!1,a=null){let l={};typeof s=="function"?(a=s,s=!1):typeof s=="object"&&s?l={...s,...l}:l={live:s};let c={...lt.createRequest(o),...l};return n[e.CONTEXT_API.api.contexts].request(c,a)}}function Yi(i){let t=this,{webqit:{Observer:e,realdom:r,oohtml:{configs:n},HTMLImportElement:o,HTMLImportsContext:s}}=t,a=u=>{let f=u[n.CONTEXT_API.api.contexts];f.find(s.kind)||f.attach(new s)},l=u=>{let f=u[n.CONTEXT_API.api.contexts],d=f.find(s.kind);d&&(!u.isConnected||!u.matches?.(i.importsContextSelector)&&!Object.keys(d.localModules).length)&&f.detach(d)};r.realtime(t.document).query([i.templateSelector,i.importsContextSelector],u=>{u.entrants.forEach(f=>{if(f.matches(i.templateSelector)){let d=et.instance(f);d.ownerContext=f.scoped?f.parentNode:f.getRootNode();let p=pt(d.ownerContext);d.defId&&e.set(p,d.defId,f),a(d.ownerContext)}else a(f)}),u.exits.forEach(f=>{if(f.matches(i.templateSelector)){let d=et.instance(f),p=pt(d.ownerContext);d.defId&&d.ownerContext.isConnected&&e.deleteProperty(p,d.defId),l(d.ownerContext)}else l(f)})},{id:"imports:template/importscontext",live:!0,subtree:"cross-roots",timing:"sync",staticSensitivity:!0,eventDetails:!0}),r.realtime(t.document).query(i.elements.import,u=>{u.entrants.forEach(f=>c(f,!0,u)),u.exits.forEach(f=>c(f,!1,u))},{id:"imports:import",live:!0,subtree:"cross-roots",timing:"sync",deferred:!0});function c(u,f){let d=o.instance(u);f?d["#"].connectedCallback():d["#"].disconnectedCallback()}t.webqit.env!=="server"&&r.realtime(t.document).query(`(${i.anchorNodeSelector})`,u=>{u.entrants.forEach(f=>{if(v(f).get("isAnchorNode"))return;let d=t.document.createElement("div");d.innerHTML=f.nodeValue,d.innerHTML=d.firstChild.textContent;let p=d.firstChild,m=parseInt(p.getAttribute("data-nodecount")),x=new Set,S=f;for(;(S=S.previousElementSibling)&&S.matches(i.slottedElementsSelector)&&m--;)x.add(S);o.instance(p)["#"].hydrate(f,x)})},{id:"imports:hydration",live:!0,subtree:"cross-roots",timing:"sync"})}function cr(i={}){let{config:t,window:e}=B.call(this,"context-api",i,{elements:{roots:"root,webflo-embedded"},attr:{contextname:"contextname"},api:{contexts:"contexts"}}),r=new Map,n=e.EventTarget.prototype.dispatchEvent;Object.defineProperty(e.EventTarget.prototype,"dispatchEvent",{value:function(...o){let s=o[0],a=this?.closest?.(t.elements.roots)||this.getRootNode?.();if(["contextclaim","contextrequest"].includes(s.type)&&a){s.meta&&(s.meta.target=this);let l=u=>{if(u.stopImmediatePropagation(),u.meta&&(u.meta.target=u.target),!u.answered){if(r.get(a)||r.set(a,new Set),u.type==="contextrequest"&&u.live)r.get(a).add(u);else if(u.type==="contextclaim"){let f=new Set;return r.get(a).forEach(d=>{!u.target.contains(d.target)||!u.detail?.matchEvent?.(d)||(r.get(a).delete(d),f.add(d))}),r.get(a).size||r.delete(a),u.respondWith?.(f)}}};a.addEventListener(s.type,l);let c=n.call(this,...o);return a.removeEventListener(s.type,l),c}return n.call(this,...o)}}),e.webqit.DOMContexts=dt,e.webqit.DOMContext=z,e.webqit.DOMContextRequestEvent=xe(),e.webqit.DOMContextResponse=$t,e.webqit.DuplicateContextError=Et,Zi.call(e,t)}function Zi(i){let t=this;[t.Document.prototype,t.Element.prototype,t.ShadowRoot.prototype].forEach(e=>{let r=e===t.Document.prototype?"Document":e===t.ShadowRoot.prototype?"ShadowRoot":"Element";if(i.api.contexts in e)throw new Error(`The ${r} prototype already has a "${i.api.contexts}" API!`);Object.defineProperty(e,i.api.contexts,{get:function(){return dt.instance(this)}})})}function ur({advanced:i={},...t}){let{config:e,window:r}=B.call(this,"scoped-css",t,{api:{styleSheets:"styleSheets"},style:{retention:"retain",mimeTypes:"text/css",strategy:null}});e.styleSelector=(Array.isArray(e.style.mimeTypes)?e.style.mimeTypes:e.style.mimeTypes.split("|")).concat("").reduce((n,o)=>{let s=o?`[type="${r.CSS.escape(o)}"]`:":not([type])";return n.concat(`style${s}`)},[]).join(","),r.webqit.oohtml.Style={compileCache:new Map},Ki.call(r,e),tn.call(r,e)}function Ki(i){let t=this,e=new Map;[t.Element.prototype].forEach(r=>{let n="Element";if(i.api.styleSheets in r)throw new Error(`The ${n} prototype already has a "${i.api.styleSheets}" API!`);Object.defineProperty(r,i.api.styleSheets,{get:function(){return e.has(this)||e.set(this,[]),e.get(this)}})}),Object.defineProperty(t.HTMLStyleElement.prototype,"scoped",{configurable:!0,get(){return this.hasAttribute("scoped")},set(r){this.toggleAttribute("scoped",r)}})}function tn(i){let t=this,{webqit:{oohtml:e,realdom:r}}=t,n=Object.getOwnPropertyDescriptor(globalThis,"window")?.get?.toString().includes("[native code]")??!1;t.CSS.supports||(t.CSS.supports=()=>!1);let o=new WeakSet;r.realtime(t.document).query(i.styleSelector,s=>{s.entrants.forEach(a=>{if(o.has(a))return;o.add(a);let l=St(a.textContent),c=CSS.supports("selector(:has(a,b))"),u=a.scoped&&(c?`:has(> style[rand-${l}])`:`[rand-${l}]`),f=a.scoped&&t.CSSScopeRule&&!1,d=a.scoped&&a.parentNode||a.getRootNode();if(d instanceof t.Element){if(d[i.api.styleSheets].push(a),!n)return;(c?a:d).toggleAttribute(`rand-${l}`,!0)}if(!!n)if(a.scoped&&a.hasAttribute("shared")){let p;(p=e.Style.compileCache.get(l))||(p=en.call(t,a,null,f,u),e.Style.compileCache.set(l,p)),Object.defineProperty(a,"sheet",{value:p,configurable:!0}),a.textContent=`
55
55
  /*[ Shared style sheet ]*/
56
56
  `}else{let p=()=>{let m=ve(jt.call(t,d));lr.call(this,a.sheet,m,!f&&u)};a.isConnected?p():setTimeout(()=>{p()},0)}})},{id:"scoped-css",live:!0,subtree:"cross-roots",timing:"intercept",generation:"entrants"})}function en(i,t,e,r){let n=this,o=i.textContent,s,a=e&&r?`@scope (${r}) {
57
57
  ${o.trim()}