@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.js CHANGED
@@ -50,7 +50,7 @@ ${g}
50
50
  const abort${r} = () => this.removeEventListener( '${g}', handler${r} );
51
51
  this.$oohtml_internal_databinding_signals?.push( { abort: abort${r} } );
52
52
  `;if(m==="$")return`$exec__(this, '${g}', ${v});`;if(l.trim())throw new Error(`Invalid binding: ${l}.`)}).join(`
53
- `),{webqit:{QuantumModule:n}}=this,{parserParams:a,compilerParams:o,runtimeParams:u}=e.advanced,c=new n(s,{parserParams:a,compilerParams:o,runtimeParams:u});return br.set(t,c),c}var ye=e=>e.replace(/"/g,'\\"');function on(e){let t=this,{webqit:{oohtml:{configs:{DATA_BINDING:i}}}}=t;(e?.matches(i.attrSelector)?[e]:[]).concat([...e?.querySelectorAll(i.attrSelector)||[]]).forEach(r=>{an.call(t,i,r.getAttribute(i.attr.render))}),de(t,e,`(${i.discreteBindingsSelector})`).forEach(r=>{let s=sn(i,r.nodeValue);nn.call(t,i,s.expr)})}var pt=class extends st{static createRequest(t=null){let i=super.createRequest();if(t?.startsWith("@")){let[r,...s]=s.slice(1).split(".").map(n=>n.trim());i.targetContext=r,i.detail=s.join(".")}else i.detail=t;return i}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:i}}}=H;t.meta.controller=i.reduce(this.bindingsObj,Array.isArray(t.detail)?t.detail:[t.detail],i.get,r=>{this.disposed||t.respondWith(r.value)},{live:t.live,signal:t.signal,descripted:!0})}unsubscribed(t){t.meta.controller?.abort()}};G(pt,"kind","bindings");function vr(e={}){let{config:t,window:i}=rt.call(this,"bindings-api",e,{attr:{bindingsreflection:"bindings"},api:{bind:"bind",bindings:"bindings"}});i.webqit.DOMBindingsContext=pt,ja.call(i,t),Ha.call(i,t)}function Sr(e,t){let i=this,{webqit:{Observer:r,oohtml:{configs:{CONTEXT_API:s}}}}=i;if(!A(t).has("bindings")){let n=Object.create(null);A(t).set("bindings",n),r.observe(n,a=>{if(t instanceof i.Element){let o=_i(t.getAttribute(e.attr.bindingsreflection)||""),u=new Map(o);for(let c of a)c.detail?.publish!==!1&&(c.type==="delete"?o.delete(c.key):o.set(c.key,void 0));o.size&&o.size!==u.size?t.setAttribute(e.attr.bindingsreflection,`{ ${[...o.entries()].map(([c,l])=>l===void 0?c:`${c}: ${l}`).join(", ")} }`):o.size||t.toggleAttribute(e.attr.bindingsreflection,!1)}else{let o=t[s.api.contexts];for(let u of a)if(u.type==="delete"){let c=o.find(pt.kind,u.key);c&&o.detach(c)}else o.find(pt.kind,u.key)||o.attach(new pt(u.key))}})}return A(t).get("bindings")}function ja(e){let t=this,{webqit:{Observer:i}}=t;[t.Document.prototype,t.Element.prototype,t.ShadowRoot.prototype].forEach(r=>{let s=r===t.Document.prototype?"Document":r===t.ShadowRoot.prototype?"ShadowRoot":"Element";if(e.api.bind in r)throw new Error(`The ${s} prototype already has a "${e.api.bind}" API!`);if(e.api.bindings in r)throw new Error(`The ${s} prototype already has a "${e.api.bindings}" API!`);Object.defineProperty(r,e.api.bind,{value:function(n,a={}){return Ba.call(t,e,this,n,a)}}),Object.defineProperty(r,e.api.bindings,{get:function(){return i.proxy(Sr.call(t,e,this))}})})}function Ba(e,t,i,{merge:r,diff:s,publish:n,namespace:a}={}){let o=this,{webqit:{Observer:u}}=o,c=Sr.call(this,e,t),l={diff:s,namespace:a,detail:{publish:n}},f=r?[]:u.ownKeys(c,l).filter(p=>!(p in i));return u.batch(c,()=>(f.length&&u.deleteProperties(c,f,l),u.set(c,i,l)),l)}function Ha(e){let t=this,{webqit:{realdom:i,Observer:r,oohtml:{configs:s}}}=t,n=(o,u)=>{let c=o[s.CONTEXT_API.api.contexts];c.find(pt.kind,u)||c.attach(new pt(u))},a=(o,u)=>{let c,l=o[s.CONTEXT_API.api.contexts];for(;c=l.find(pt.kind,u);)l.detach(c)};i.realtime(t.document).query(`[${t.CSS.escape(e.attr.bindingsreflection)}]`,o=>{o.exits.forEach(u=>a(u)),o.entrants.forEach(u=>{let c=_i(u.getAttribute(e.attr.bindingsreflection)||""),l=[...c.entries()].filter(([f,p])=>p!==void 0);l.length&&u[e.api.bind](Object.fromEntries(l),{merge:!0,publish:!1});for(let[f]of c)n(u,f)})},{id:"bindings:dom",live:!0,subtree:"cross-roots",timing:"sync",eventDetails:!0}),i.realtime(t.document,"attr").observe(e.attr.bindingsreflection,o=>{let u=Sr.call(t,e,o.target),c=_i(o.value||""),l=_i(o.oldValue||"");for(let f of new Set([...c.keys(),...l.keys()]))l.has(f)?c.has(f)?c.get(f)!==l.get(f)&&r.set(u,f,c.get(f),{detail:{publish:!1}}):(l.get(f)!==void 0&&r.deleteProperty(u,f,{detail:{publish:!1}}),a(o.target,f)):(c.get(f)!==void 0&&r.set(u,f,c.get(f),{detail:{publish:!1}}),n(o.target,f))},{id:"bindings:attr",subtree:"cross-roots",timing:"sync",newValue:!0,oldValue:!0})}var _i=e=>(e=e.trim(),new Map($t(e.slice(1,-1),",").filter(t=>t.trim()).map(t=>$t(t,":").map(i=>i.trim()))));var St=class{static instance(t){return A(t).get("defsmanager::instance")||new this(t)}constructor(t,i=null,r=0){let{window:s}=H,{webqit:{realdom:n,oohtml:{configs:a}}}=s;A(t).get("defsmanager::instance")?.dispose(),A(t).set("defsmanager::instance",this),this.window=s,this.host=t,this.config=a.HTML_IMPORTS,this.parent=i,this.level=r,this.defs=qt(this.host),this.defId=(this.host.getAttribute(this.config.attr.def)||"").trim(),this.validateDefId(this.defId),this.realtimeA=n.realtime(this.host.content).children(o=>{this.expose(o.entrants,!0),this.expose(o.exits,!1)},{live:!0,timing:"sync"}),this.realtimeB=n.realtime(this.host).attr(["src","loading"],(...o)=>this.evaluateLoading(...o),{live:!0,atomic:!0,timing:"sync",lifecycleSignals:!0}),this.realtimeC=this.evalInheritance()}validateDefId(t){if(["@","/","*","#"].some(i=>t.includes(i)))throw new Error(`The export ID "${t}" contains an invalid character.`)}expose(t,i){let{window:r}=H,{webqit:{Observer:s}}=r,n,a=this.defs["#"]||[];t.forEach(o=>{if(o.nodeType!==1)return;let u=o.matches(this.config.templateSelector),c=(o.getAttribute(u?this.config.attr.def:this.config.attr.fragmentdef)||"").trim();i?(u&&c?new St(o,this.host,this.level+1):(a.push(o),n=!0,typeof requestIdleCallback=="function"&&requestIdleCallback(()=>{this.config.idleCompilers?.forEach(l=>l.call(this.window,o))})),c&&(this.validateDefId(c),s.set(this.defs,(!u&&"#"||"")+c,o))):(u&&c?St.instance(o).dispose():(a=a.filter(l=>l!==o),n=!0),c&&s.deleteProperty(this.defs,(!u&&"#"||"")+c))}),n&&s.set(this.defs,"#",a)}evaluateLoading([t,i],{signal:r}){let{window:{webqit:{Observer:s}}}=H,n=(t.value||"").trim();if(!n)return;let a,o=l=>{if(!l)return a;a=l.then(()=>c.remove())},u=(i.value||"").trim(),c=s.intercept(this.defs,"get",async(l,f,p)=>(u==="lazy"&&o(this.load(n,!0)),await o(),p()),{signal:r});u!=="lazy"&&o(this.load(n))}load(t){let{window:i}=H;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,s=(a,o)=>this.host.dispatchEvent(new i.CustomEvent(a,{detail:o})),n=i.fetch(t,{signal:r.signal,element:this.host}).then(a=>a.ok?a.text():Promise.reject(a.statusText)).then(a=>(this.host.innerHTML=a.trim(),s("load"),this.host)).catch(a=>(console.error(`Error fetching the bundle at "${t}": ${a.message}`),this.fetchInFlight=null,s("loaderror"),this.host));return this.fetchInFlight={src:t,request:n,controller:r},n}evalInheritance(){if(!this.parent)return[];let{window:{webqit:{Observer:t}}}=H,i=(this.host.getAttribute(this.config.attr.extends)||"").trim(),r=(this.host.getAttribute(this.config.attr.inherits)||"").trim(),s=o=>{o.forEach(u=>{t.get(this.defs,u.key)===u.oldValue&&(["get","set","def"].includes(u.type)?t[u.type.replace("get","set")](this.defs,u.key,u.value):u.type==="delete"&&t.deleteProperty(this.defs,u.key))})},n=[],a=qt(this.parent);return i&&n.push(t.reduce(a,[i,this.config.api.defs,1/0],t.get,s,{live:!0})),(r=r.split(" ").map(o=>o.trim()).filter(o=>o)).length&&n.push(t.get(a,r,s,{live:!0})),n}dispose(){this.realtimeA.disconnect(),this.realtimeB.disconnect(),this.realtimeC.forEach(t=>t instanceof Promise?t.then(i=>i.abort()):t.abort()),Object.entries(this.defs).forEach(([t,i])=>{t.startsWith("#")||St.instance(i).dispose()})}};var Ei,_t,xe,be,Lt=class extends st{constructor(){super(...arguments);we(this,Ei,{});we(this,_t,void 0);we(this,xe,void 0);we(this,be,void 0)}static createRequest(i=null){let r=super.createRequest();if(i?.startsWith("/"))r.detail=i,r.targetContext=1/0;else if(i?.startsWith("@")){let[s,...n]=i.slice(1).split(/(?<=\w)(?=\/|#)/).map(a=>a.trim());r.targetContext=s,r.detail=n.join("")}else r.detail=i;return r}get localModules(){return qt(this.host)}get inheritedModules(){return at(this,Ei)}handle(i){let{window:{webqit:{Observer:r}}}=H;i.meta.controller?.abort();let s=(i.detail||"").split(/\/|(?<=\w)(?=#)/g).map(a=>a.trim()).filter(a=>a);if(!s.length)return i.respondWith();s=s.join(`/${this.configs.HTML_IMPORTS.api.defs}/`)?.split("/").map(a=>a==="*"?1/0:a)||[];let n={live:i.live,signal:i.signal,descripted:!0};i.meta.controller=r.reduce(at(this,_t),s,r.get,a=>{if(Array.isArray(a))for(let o of a)i.respondWith(o);else i.respondWith(a.value)},n)}unsubscribed(i){i.meta.controller?.abort()}initialize(i){this.host=i;let{window:{webqit:{Observer:r}}}=H;Xe(this,_t,{...this.localModules}),at(this,xe)?.abort(),Xe(this,xe,r.observe(this.localModules,n=>{for(let a of n)a.type==="delete"?this.inheritedModules&&r.has(this.inheritedModules,a.key)?r.set(at(this,_t),a.key,r.get(this.inheritedModules,a.key)):r.deleteProperty(at(this,_t),a.key):r.set(at(this,_t),a.key,a.value)},{timing:"sync"}));let s=this.configs.HTML_IMPORTS;if(this.host.matches&&s.attr.importscontext){let n=this.host.ownerDocument.defaultView.webqit.realdom,a;at(this,be)?.disconnect(),Xe(this,be,n.realtime(this.host).attr(s.attr.importscontext,(o,{signal:u})=>{let c=(o.value||"").trim();if(c===a)return;a=c;let l={...this.constructor.createRequest(c?`${c}/*`:"*"),live:!0,signal:u,diff:!0};this.host.parentNode[this.configs.CONTEXT_API.api.contexts].request(l,f=>{f.type==="delete"?(Reflect.deleteProperty(this.inheritedModules,f.key),r.has(this.localModules,f.key)||r.deleteProperty(at(this,_t),f.key)):(Reflect.set(this.inheritedModules,f.key,f.value),r.has(this.localModules,f.key)||r.set(at(this,_t),f.key,f.value))})},{live:!0,timing:"sync",oldValue:!0,lifecycleSignals:!0}))}return super.initialize(i)}dispose(i){return at(this,xe)?.abort(),at(this,be)?.disconnect(),super.dispose(i)}};Ei=new WeakMap,_t=new WeakMap,xe=new WeakMap,be=new WeakMap,G(Lt,"kind","html-imports");function un(){let{window:e}=H,{webqit:t}=e,{realdom:i,oohtml:{configs:r}}=t;if(t.HTMLImportElement)return t.HTMLImportElement;let s=r.HTML_IMPORTS.elements.import.includes("-")?e.HTMLElement:class{};class n extends s{static instance(o){return r.HTML_IMPORTS.elements.import.includes("-")&&o instanceof this?o:A(o).get("import::instance")||new this(o)}constructor(...o){super();let u=o[0]||this;A(u).set("import::instance",this),Object.defineProperty(this,"el",{get:()=>u,configurable:!1});let c={};Object.defineProperty(this,"#",{get:()=>c,configurable:!1}),c.slottedElements=new Set,c.setAnchorNode=l=>(c.anchorNode=l,l),c.live=l=>{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=i.realtime(this.el).attr(r.HTML_IMPORTS.attr.ref,(p,{signal:m})=>{c.moduleRef=p.value;let g=c.moduleRef.includes("#")?c.moduleRef:`${c.moduleRef}#`,v={...Lt.createRequest(g),live:m&&!0,signal:m,diff:!g.endsWith("#")};f[r.CONTEXT_API.api.contexts].request(v,E=>{l((E instanceof e.HTMLTemplateElement?[...E.content.children]:Array.isArray(E)?E:E&&[E])||[])})},{live:!0,timing:"sync",lifecycleSignals:!0}),c.autoDestroyRealtime=i.realtime(e.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=(l,f)=>{l.replaceWith(c.setAnchorNode(this.createAnchorNode())),c.live(p=>{if(c.originalsRemapped)return this.fill(p);let m=p.map((g,v)=>({el:g,fragmentDef:g.getAttribute(r.HTML_IMPORTS.attr.fragmentdef)||"",tagName:g.tagName,i:v}));f.forEach((g,v)=>{let E=g.tagName,y=g.getAttribute(r.HTML_IMPORTS.attr.fragmentdef)||"",w=(v++,m.find(C=>C.tagName===E&&C.fragmentDef===y&&C.i===v));w&&A(g).set("original@imports",w.el),A(g).set("slot@imports",this.el),c.slottedElements.add(g)}),c.originalsRemapped=!0})},c.autoRestore=(l=null)=>{c.autoRestoreRealtime?.disconnect(),l&&l();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 p=i.realtime(c.anchorNode.parentNode).observe([...c.slottedElements],m=>{if(m.exits.forEach(g=>{A(g).delete("slot@imports"),c.slottedElements.delete(g)}),!c.slottedElements.size){if(p.disconnect(),!m.target.isConnected)return;f()}},{subtree:"cross-roots",timing:"sync",generation:"exits"});c.autoRestoreRealtime=p},c.connectedCallback=()=>{c.internalMutation||c.live(l=>this.fill(l))},c.disconnectedCallback=()=>{c.internalMutation||c.die()}}createAnchorNode(){if(e.webqit.env!=="server")return e.document.createTextNode("");let o=e.document.createElement("div");o.textContent=this.el.outerHTML;let u=e.document.createComment(o.innerHTML);return A(u).set("isAnchorNode",!0),u}fill(o,u){!this.el.isConnected&&(!this["#"].anchorNode||!this["#"].anchorNode.isConnected)||(Array.isArray(o)&&(o=new Set(o)),this.el.setAttribute("data-nodecount",o.size),this["#"].autoRestore(()=>{if(this["#"].slottedElements.forEach(c=>{let l=A(c).get("original@imports");o.has(l)?o.delete(l):(this["#"].slottedElements.delete(c),c.remove())}),o.size&&this.el.isConnected){let c=this["#"].setAnchorNode(this.createAnchorNode());this["#"].internalMutation=!0,this.el.replaceWith(c),this["#"].internalMutation=!1}o.forEach(c=>{let l=c.cloneNode(!0);l.hasAttribute(r.HTML_IMPORTS.attr.fragmentdef)||l.toggleAttribute(r.HTML_IMPORTS.attr.fragmentdef,!0),A(l).set("original@imports",c),A(l).set("slot@imports",this.el),this["#"].slottedElements.add(l),this["#"].anchorNode.before(l)})}))}empty(){this["#"].slottedElements.forEach(o=>o.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,n),t.HTMLImportElement=n,n}function _r(e={}){let{config:t,window:i}=rt.call(this,"html-imports",e,{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[${i.CSS.escape(t.attr.def)}]`,t.importsContextSelector=`[${i.CSS.escape(t.attr.importscontext)}]`,t.slottedElementsSelector=`[${i.CSS.escape(t.attr.fragmentdef)}]:not(template)`;let r=(s,n)=>{let a=`starts-with(., "${s}")`,o=`substring(., string-length(.) - string-length("${n}") + 1) = "${n}"`;return`${a} and ${o}`};t.anchorNodeSelector=`comment()[${r(`&lt;${t.elements.import}`,`&lt;/${t.elements.import}&gt;`)}]`,i.webqit.HTMLImportsContext=Lt,i.webqit.HTMLImportElement=un(),Ua.call(i,t),Wa.call(i,t)}function qt(e,t=!0){if(!A(e).has("defs")&&t){let i=Object.create(null);A(e).set("defs",i)}return A(e).get("defs")}function Ua(e){let t=this,{webqit:{oohtml:{configs:i}}}=t;if(e.api.def in t.HTMLTemplateElement.prototype)throw new Error(`The "HTMLTemplateElement" prototype already has a "${e.api.def}" API!`);if(e.api.defs in t.HTMLTemplateElement.prototype)throw new Error(`The "HTMLTemplateElement" prototype already has a "${e.api.defs}" API!`);Object.defineProperty(t.HTMLTemplateElement.prototype,e.api.def,{get:function(){return this.getAttribute(e.attr.def)}}),Object.defineProperty(t.HTMLTemplateElement.prototype,e.api.defs,{get:function(){return qt(this)}}),Object.defineProperty(t.HTMLTemplateElement.prototype,"scoped",{configurable:!0,get(){return this.hasAttribute("scoped")},set(s){this.toggleAttribute("scoped",s)}}),[t.Document.prototype,t.Element.prototype,t.ShadowRoot.prototype].forEach(s=>{let n=s===t.Document.prototype?"Document":s===t.ShadowRoot.prototype?"ShadowRoot":"Element";if(e.api.import in s)throw new Error(`The ${n} prototype already has a "${e.api.import}" API!`);Object.defineProperty(s,e.api.import,{value:function(a,o=!1,u=null){return r(this,...arguments)}})});function r(s,n,a=!1,o=null){let u={};typeof a=="function"?(o=a,a=!1):typeof a=="object"&&a?u={...a,...u}:u={live:a};let c={...Lt.createRequest(n),...u};return s[i.CONTEXT_API.api.contexts].request(c,o)}}function Wa(e){let t=this,{webqit:{Observer:i,realdom:r,oohtml:{configs:s},HTMLImportElement:n,HTMLImportsContext:a}}=t,o=l=>{let f=l[s.CONTEXT_API.api.contexts];f.find(a.kind)||f.attach(new a)},u=l=>{let f=l[s.CONTEXT_API.api.contexts],p=f.find(a.kind);p&&(!l.isConnected||!l.matches?.(e.importsContextSelector)&&!Object.keys(p.localModules).length)&&f.detach(p)};r.realtime(t.document).query([e.templateSelector,e.importsContextSelector],l=>{l.entrants.forEach(f=>{if(f.matches(e.templateSelector)){let p=St.instance(f);p.ownerContext=f.scoped?f.parentNode:f.getRootNode();let m=qt(p.ownerContext);p.defId&&i.set(m,p.defId,f),o(p.ownerContext)}else o(f)}),l.exits.forEach(f=>{if(f.matches(e.templateSelector)){let p=St.instance(f),m=qt(p.ownerContext);p.defId&&p.ownerContext.isConnected&&i.deleteProperty(m,p.defId),u(p.ownerContext)}else u(f)})},{id:"imports:template/importscontext",live:!0,subtree:"cross-roots",timing:"sync",staticSensitivity:!0,eventDetails:!0}),r.realtime(t.document).query(e.elements.import,l=>{l.entrants.forEach(f=>c(f,!0,l)),l.exits.forEach(f=>c(f,!1,l))},{id:"imports:import",live:!0,subtree:"cross-roots",timing:"sync",deferred:!0});function c(l,f){let p=n.instance(l);f?p["#"].connectedCallback():p["#"].disconnectedCallback()}t.webqit.env!=="server"&&r.realtime(t.document).query(`(${e.anchorNodeSelector})`,l=>{l.entrants.forEach(f=>{if(A(f).get("isAnchorNode"))return;let p=t.document.createElement("div");p.innerHTML=f.nodeValue,p.innerHTML=p.firstChild.textContent;let m=p.firstChild,g=parseInt(m.getAttribute("data-nodecount")),v=new Set,E=f;for(;(E=E.previousElementSibling)&&E.matches(e.slottedElementsSelector)&&g--;)v.add(E);n.instance(m)["#"].hydrate(f,v)})},{id:"imports:hydration",live:!0,subtree:"cross-roots",timing:"sync"})}function Er(e={}){let{config:t,window:i}=rt.call(this,"context-api",e,{attr:{contextname:"contextname"},api:{contexts:"contexts"}}),r=new Map,s=i.EventTarget.prototype.dispatchEvent;Object.defineProperty(i.EventTarget.prototype,"dispatchEvent",{value:function(...n){let a=n[0],o=this.getRootNode?.();if(["contextclaim","contextrequest"].includes(a.type)&&o){a.meta&&(a.meta.target=this);let u=l=>{if(l.stopImmediatePropagation(),l.meta&&(l.meta.target=l.target),!l.answered){if(r.get(o)||r.set(o,new Set),l.type==="contextrequest"&&l.live)r.get(o).add(l);else if(l.type==="contextclaim"){let f=new Set;return r.get(o).forEach(p=>{!l.target.contains(p.target)||!l.detail?.matchEvent?.(p)||(r.get(o).delete(p),f.add(p))}),r.get(o).size||r.delete(o),l.respondWith?.(f)}}};o.addEventListener(a.type,u);let c=s.call(this,...n);return o.removeEventListener(a.type,u),c}return s.call(this,...n)}}),i.webqit.DOMContexts=Ft,i.webqit.DOMContext=st,i.webqit.DOMContextRequestEvent=wi(),i.webqit.DOMContextResponse=te,i.webqit.DuplicateContextError=ee,za.call(i,t)}function za(e){let t=this;[t.Document.prototype,t.Element.prototype,t.ShadowRoot.prototype].forEach(i=>{let r=i===t.Document.prototype?"Document":i===t.ShadowRoot.prototype?"ShadowRoot":"Element";if(e.api.contexts in i)throw new Error(`The ${r} prototype already has a "${e.api.contexts}" API!`);Object.defineProperty(i,e.api.contexts,{get:function(){return Ft.instance(this)}})})}function kr({advanced:e={},...t}){let{config:i,window:r}=rt.call(this,"scoped-css",t,{api:{styleSheets:"styleSheets"},style:{retention:"retain",mimeTypes:"text/css",strategy:null}});i.styleSelector=(Array.isArray(i.style.mimeTypes)?i.style.mimeTypes:i.style.mimeTypes.split("|")).concat("").reduce((s,n)=>{let a=n?`[type="${r.CSS.escape(n)}"]`:":not([type])";return s.concat(`style${a}`)},[]).join(","),r.webqit.oohtml.Style={compileCache:new Map},Qa.call(r,i),Ga.call(r,i)}function Qa(e){let t=this,i=new Map;[t.Element.prototype].forEach(r=>{let s="Element";if(e.api.styleSheets in r)throw new Error(`The ${s} prototype already has a "${e.api.styleSheets}" API!`);Object.defineProperty(r,e.api.styleSheets,{get:function(){return i.has(this)||i.set(this,[]),i.get(this)}})}),Object.defineProperty(t.HTMLStyleElement.prototype,"scoped",{configurable:!0,get(){return this.hasAttribute("scoped")},set(r){this.toggleAttribute("scoped",r)}})}function Ga(e){let t=this,{webqit:{oohtml:i,realdom:r}}=t,s=Object.getOwnPropertyDescriptor(globalThis,"window")?.get?.toString().includes("[native code]")??!1;t.CSS.supports||(t.CSS.supports=()=>!1);let n=new WeakSet;r.realtime(t.document).query(e.styleSelector,a=>{a.entrants.forEach(o=>{if(n.has(o))return;n.add(o);let u=Zt(o.textContent),c=CSS.supports("selector(:has(a,b))"),l=o.scoped&&(c?`:has(> style[rand-${u}])`:`[rand-${u}]`),f=o.scoped&&t.CSSScopeRule&&!1,p=o.scoped&&o.parentNode||o.getRootNode();if(p instanceof t.Element){if(p[e.api.styleSheets].push(o),!s)return;(c?o:p).toggleAttribute(`rand-${u}`,!0)}if(!!s)if(o.scoped&&o.hasAttribute("shared")){let m;(m=i.Style.compileCache.get(u))||(m=Ka.call(t,o,null,f,l),i.Style.compileCache.set(u,m)),Object.defineProperty(o,"sheet",{value:m,configurable:!0}),o.textContent=`
53
+ `),{webqit:{QuantumModule:n}}=this,{parserParams:a,compilerParams:o,runtimeParams:u}=e.advanced,c=new n(s,{parserParams:a,compilerParams:o,runtimeParams:u});return br.set(t,c),c}var ye=e=>e.replace(/"/g,'\\"');function on(e){let t=this,{webqit:{oohtml:{configs:{DATA_BINDING:i}}}}=t;(e?.matches(i.attrSelector)?[e]:[]).concat([...e?.querySelectorAll(i.attrSelector)||[]]).forEach(r=>{an.call(t,i,r.getAttribute(i.attr.render))}),de(t,e,`(${i.discreteBindingsSelector})`).forEach(r=>{let s=sn(i,r.nodeValue);nn.call(t,i,s.expr)})}var pt=class extends st{static createRequest(t=null){let i=super.createRequest();if(t?.startsWith("@")){let[r,...s]=s.slice(1).split(".").map(n=>n.trim());i.targetContext=r,i.detail=s.join(".")}else i.detail=t;return i}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:i}}}=H;t.meta.controller=i.reduce(this.bindingsObj,Array.isArray(t.detail)?t.detail:[t.detail],i.get,r=>{this.disposed||t.respondWith(r.value)},{live:t.live,signal:t.signal,descripted:!0})}unsubscribed(t){t.meta.controller?.abort()}};G(pt,"kind","bindings");function vr(e={}){let{config:t,window:i}=rt.call(this,"bindings-api",e,{attr:{bindingsreflection:"bindings"},api:{bind:"bind",bindings:"bindings"}});i.webqit.DOMBindingsContext=pt,ja.call(i,t),Ha.call(i,t)}function Sr(e,t){let i=this,{webqit:{Observer:r,oohtml:{configs:{CONTEXT_API:s}}}}=i;if(!A(t).has("bindings")){let n=Object.create(null);A(t).set("bindings",n),r.observe(n,a=>{if(t instanceof i.Element){let o=_i(t.getAttribute(e.attr.bindingsreflection)||""),u=new Map(o);for(let c of a)c.detail?.publish!==!1&&(c.type==="delete"?o.delete(c.key):o.set(c.key,void 0));o.size&&o.size!==u.size?t.setAttribute(e.attr.bindingsreflection,`{ ${[...o.entries()].map(([c,l])=>l===void 0?c:`${c}: ${l}`).join(", ")} }`):o.size||t.toggleAttribute(e.attr.bindingsreflection,!1)}else{let o=t[s.api.contexts];for(let u of a)if(u.type==="delete"){let c=o.find(pt.kind,u.key);c&&o.detach(c)}else o.find(pt.kind,u.key)||o.attach(new pt(u.key))}})}return A(t).get("bindings")}function ja(e){let t=this,{webqit:{Observer:i}}=t;[t.Document.prototype,t.Element.prototype,t.ShadowRoot.prototype].forEach(r=>{let s=r===t.Document.prototype?"Document":r===t.ShadowRoot.prototype?"ShadowRoot":"Element";if(e.api.bind in r)throw new Error(`The ${s} prototype already has a "${e.api.bind}" API!`);if(e.api.bindings in r)throw new Error(`The ${s} prototype already has a "${e.api.bindings}" API!`);Object.defineProperty(r,e.api.bind,{value:function(n,a={}){return Ba.call(t,e,this,n,a)}}),Object.defineProperty(r,e.api.bindings,{get:function(){return i.proxy(Sr.call(t,e,this))}})})}function Ba(e,t,i,{merge:r,diff:s,publish:n,namespace:a}={}){let o=this,{webqit:{Observer:u}}=o,c=Sr.call(this,e,t),l={diff:s,namespace:a,detail:{publish:n}},f=r?[]:u.ownKeys(c,l).filter(p=>!(p in i));return u.batch(c,()=>(f.length&&u.deleteProperties(c,f,l),u.set(c,i,l)),l)}function Ha(e){let t=this,{webqit:{realdom:i,Observer:r,oohtml:{configs:s}}}=t,n=(o,u)=>{let c=o[s.CONTEXT_API.api.contexts];c.find(pt.kind,u)||c.attach(new pt(u))},a=(o,u)=>{let c,l=o[s.CONTEXT_API.api.contexts];for(;c=l.find(pt.kind,u);)l.detach(c)};i.realtime(t.document).query(`[${t.CSS.escape(e.attr.bindingsreflection)}]`,o=>{o.exits.forEach(u=>a(u)),o.entrants.forEach(u=>{let c=_i(u.getAttribute(e.attr.bindingsreflection)||""),l=[...c.entries()].filter(([f,p])=>p!==void 0);l.length&&u[e.api.bind](Object.fromEntries(l),{merge:!0,publish:!1});for(let[f]of c)n(u,f)})},{id:"bindings:dom",live:!0,subtree:"cross-roots",timing:"sync",eventDetails:!0}),i.realtime(t.document,"attr").observe(e.attr.bindingsreflection,o=>{let u=Sr.call(t,e,o.target),c=_i(o.value||""),l=_i(o.oldValue||"");for(let f of new Set([...c.keys(),...l.keys()]))l.has(f)?c.has(f)?c.get(f)!==l.get(f)&&r.set(u,f,c.get(f),{detail:{publish:!1}}):(l.get(f)!==void 0&&r.deleteProperty(u,f,{detail:{publish:!1}}),a(o.target,f)):(c.get(f)!==void 0&&r.set(u,f,c.get(f),{detail:{publish:!1}}),n(o.target,f))},{id:"bindings:attr",subtree:"cross-roots",timing:"sync",newValue:!0,oldValue:!0})}var _i=e=>(e=e.trim(),new Map($t(e.slice(1,-1),",").filter(t=>t.trim()).map(t=>$t(t,":").map(i=>i.trim()))));var St=class{static instance(t){return A(t).get("defsmanager::instance")||new this(t)}constructor(t,i=null,r=0){let{window:s}=H,{webqit:{realdom:n,oohtml:{configs:a}}}=s;A(t).get("defsmanager::instance")?.dispose(),A(t).set("defsmanager::instance",this),this.window=s,this.host=t,this.config=a.HTML_IMPORTS,this.parent=i,this.level=r,this.defs=qt(this.host),this.defId=(this.host.getAttribute(this.config.attr.def)||"").trim(),this.validateDefId(this.defId),this.realtimeA=n.realtime(this.host.content).children(o=>{this.expose(o.entrants,!0),this.expose(o.exits,!1)},{live:!0,timing:"sync"}),this.realtimeB=n.realtime(this.host).attr(["src","loading"],(...o)=>this.evaluateLoading(...o),{live:!0,atomic:!0,timing:"sync",lifecycleSignals:!0}),this.realtimeC=this.evalInheritance()}validateDefId(t){if(["@","/","*","#"].some(i=>t.includes(i)))throw new Error(`The export ID "${t}" contains an invalid character.`)}expose(t,i){let{window:r}=H,{webqit:{Observer:s}}=r,n,a=this.defs["#"]||[];t.forEach(o=>{if(o.nodeType!==1)return;let u=o.matches(this.config.templateSelector),c=(o.getAttribute(u?this.config.attr.def:this.config.attr.fragmentdef)||"").trim();i?(u&&c?new St(o,this.host,this.level+1):(a.push(o),n=!0,typeof requestIdleCallback=="function"&&requestIdleCallback(()=>{this.config.idleCompilers?.forEach(l=>l.call(this.window,o))})),c&&(this.validateDefId(c),s.set(this.defs,(!u&&"#"||"")+c,o))):(u&&c?St.instance(o).dispose():(a=a.filter(l=>l!==o),n=!0),c&&s.deleteProperty(this.defs,(!u&&"#"||"")+c))}),n&&s.set(this.defs,"#",a)}evaluateLoading([t,i],{signal:r}){let{window:{webqit:{Observer:s}}}=H,n=(t.value||"").trim();if(!n)return;let a,o=l=>{if(!l)return a;a=l.then(()=>c.remove())},u=(i.value||"").trim(),c=s.intercept(this.defs,"get",async(l,f,p)=>(u==="lazy"&&o(this.load(n,!0)),await o(),p()),{signal:r});u!=="lazy"&&o(this.load(n))}load(t){let{window:i}=H;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,s=(a,o)=>this.host.dispatchEvent(new i.CustomEvent(a,{detail:o})),n=i.fetch(t,{signal:r.signal,element:this.host}).then(a=>a.ok?a.text():Promise.reject(a.statusText)).then(a=>(this.host.innerHTML=a.trim(),s("load"),this.host)).catch(a=>(console.error(`Error fetching the bundle at "${t}": ${a.message}`),this.fetchInFlight=null,s("loaderror"),this.host));return this.fetchInFlight={src:t,request:n,controller:r},n}evalInheritance(){if(!this.parent)return[];let{window:{webqit:{Observer:t}}}=H,i=(this.host.getAttribute(this.config.attr.extends)||"").trim(),r=(this.host.getAttribute(this.config.attr.inherits)||"").trim(),s=o=>{o.forEach(u=>{t.get(this.defs,u.key)===u.oldValue&&(["get","set","def"].includes(u.type)?t[u.type.replace("get","set")](this.defs,u.key,u.value):u.type==="delete"&&t.deleteProperty(this.defs,u.key))})},n=[],a=qt(this.parent);return i&&n.push(t.reduce(a,[i,this.config.api.defs,1/0],t.get,s,{live:!0})),(r=r.split(" ").map(o=>o.trim()).filter(o=>o)).length&&n.push(t.get(a,r,s,{live:!0})),n}dispose(){this.realtimeA.disconnect(),this.realtimeB.disconnect(),this.realtimeC.forEach(t=>t instanceof Promise?t.then(i=>i.abort()):t.abort()),Object.entries(this.defs).forEach(([t,i])=>{t.startsWith("#")||St.instance(i).dispose()})}};var Ei,_t,xe,be,Lt=class extends st{constructor(){super(...arguments);we(this,Ei,{});we(this,_t,void 0);we(this,xe,void 0);we(this,be,void 0)}static createRequest(i=null){let r=super.createRequest();if(i?.startsWith("/"))r.detail=i,r.targetContext=1/0;else if(i?.startsWith("@")){let[s,...n]=i.slice(1).split(/(?<=\w)(?=\/|#)/).map(a=>a.trim());r.targetContext=s,r.detail=n.join("")}else r.detail=i;return r}get localModules(){return qt(this.host)}get inheritedModules(){return at(this,Ei)}handle(i){let{window:{webqit:{Observer:r}}}=H;i.meta.controller?.abort();let s=(i.detail||"").split(/\/|(?<=\w)(?=#)/g).map(a=>a.trim()).filter(a=>a);if(!s.length)return i.respondWith();s=s.join(`/${this.configs.HTML_IMPORTS.api.defs}/`)?.split("/").map(a=>a==="*"?1/0:a)||[];let n={live:i.live,signal:i.signal,descripted:!0};i.meta.controller=r.reduce(at(this,_t),s,r.get,a=>{if(Array.isArray(a))for(let o of a)i.respondWith(o);else i.respondWith(a.value)},n)}unsubscribed(i){i.meta.controller?.abort()}initialize(i){this.host=i;let{window:{webqit:{Observer:r}}}=H;Xe(this,_t,{...this.localModules}),at(this,xe)?.abort(),Xe(this,xe,r.observe(this.localModules,n=>{for(let a of n)a.type==="delete"?this.inheritedModules&&r.has(this.inheritedModules,a.key)?r.set(at(this,_t),a.key,r.get(this.inheritedModules,a.key)):r.deleteProperty(at(this,_t),a.key):r.set(at(this,_t),a.key,a.value)},{timing:"sync"}));let s=this.configs.HTML_IMPORTS;if(this.host.matches&&s.attr.importscontext){let n=this.host.ownerDocument.defaultView.webqit.realdom,a;at(this,be)?.disconnect(),Xe(this,be,n.realtime(this.host).attr(s.attr.importscontext,(o,{signal:u})=>{let c=(o.value||"").trim();if(c===a)return;a=c;let l={...this.constructor.createRequest(c?`${c}/*`:"*"),live:!0,signal:u,diff:!0};this.host.parentNode[this.configs.CONTEXT_API.api.contexts].request(l,f=>{f.type==="delete"?(Reflect.deleteProperty(this.inheritedModules,f.key),r.has(this.localModules,f.key)||r.deleteProperty(at(this,_t),f.key)):(Reflect.set(this.inheritedModules,f.key,f.value),r.has(this.localModules,f.key)||r.set(at(this,_t),f.key,f.value))})},{live:!0,timing:"sync",oldValue:!0,lifecycleSignals:!0}))}return super.initialize(i)}dispose(i){return at(this,xe)?.abort(),at(this,be)?.disconnect(),super.dispose(i)}};Ei=new WeakMap,_t=new WeakMap,xe=new WeakMap,be=new WeakMap,G(Lt,"kind","html-imports");function un(){let{window:e}=H,{webqit:t}=e,{realdom:i,oohtml:{configs:r}}=t;if(t.HTMLImportElement)return t.HTMLImportElement;let s=r.HTML_IMPORTS.elements.import.includes("-")?e.HTMLElement:class{};class n extends s{static instance(o){return r.HTML_IMPORTS.elements.import.includes("-")&&o instanceof this?o:A(o).get("import::instance")||new this(o)}constructor(...o){super();let u=o[0]||this;A(u).set("import::instance",this),Object.defineProperty(this,"el",{get:()=>u,configurable:!1});let c={};Object.defineProperty(this,"#",{get:()=>c,configurable:!1}),c.slottedElements=new Set,c.setAnchorNode=l=>(c.anchorNode=l,l),c.live=l=>{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=i.realtime(this.el).attr(r.HTML_IMPORTS.attr.ref,(p,{signal:m})=>{c.moduleRef=p.value;let g=c.moduleRef.includes("#")?c.moduleRef:`${c.moduleRef}#`,v={...Lt.createRequest(g),live:m&&!0,signal:m,diff:!g.endsWith("#")};f[r.CONTEXT_API.api.contexts].request(v,E=>{l((E instanceof e.HTMLTemplateElement?[...E.content.children]:Array.isArray(E)?E:E&&[E])||[])})},{live:!0,timing:"sync",lifecycleSignals:!0}),c.autoDestroyRealtime=i.realtime(e.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=(l,f)=>{l.replaceWith(c.setAnchorNode(this.createAnchorNode())),c.live(p=>{if(c.originalsRemapped)return this.fill(p);let m=p.map((g,v)=>({el:g,fragmentDef:g.getAttribute(r.HTML_IMPORTS.attr.fragmentdef)||"",tagName:g.tagName,i:v}));f.forEach((g,v)=>{let E=g.tagName,y=g.getAttribute(r.HTML_IMPORTS.attr.fragmentdef)||"",w=(v++,m.find(C=>C.tagName===E&&C.fragmentDef===y&&C.i===v));w&&A(g).set("original@imports",w.el),A(g).set("slot@imports",this.el),c.slottedElements.add(g)}),c.originalsRemapped=!0})},c.autoRestore=(l=null)=>{c.autoRestoreRealtime?.disconnect(),l&&l();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 p=i.realtime(c.anchorNode.parentNode).observe([...c.slottedElements],m=>{if(m.exits.forEach(g=>{A(g).delete("slot@imports"),c.slottedElements.delete(g)}),!c.slottedElements.size){if(p.disconnect(),!m.target.isConnected)return;f()}},{subtree:"cross-roots",timing:"sync",generation:"exits"});c.autoRestoreRealtime=p},c.connectedCallback=()=>{c.internalMutation||c.live(l=>this.fill(l))},c.disconnectedCallback=()=>{c.internalMutation||c.die()}}createAnchorNode(){if(e.webqit.env!=="server")return e.document.createTextNode("");let o=e.document.createElement("div");o.textContent=this.el.outerHTML;let u=e.document.createComment(o.innerHTML);return A(u).set("isAnchorNode",!0),u}fill(o,u){!this.el.isConnected&&(!this["#"].anchorNode||!this["#"].anchorNode.isConnected)||(Array.isArray(o)&&(o=new Set(o)),this.el.setAttribute("data-nodecount",o.size),this["#"].autoRestore(()=>{if(this["#"].slottedElements.forEach(c=>{let l=A(c).get("original@imports");o.has(l)?o.delete(l):(this["#"].slottedElements.delete(c),c.remove())}),o.size&&this.el.isConnected){let c=this["#"].setAnchorNode(this.createAnchorNode());this["#"].internalMutation=!0,this.el.replaceWith(c),this["#"].internalMutation=!1}o.forEach(c=>{let l=c.cloneNode(!0);l.hasAttribute(r.HTML_IMPORTS.attr.fragmentdef)||l.toggleAttribute(r.HTML_IMPORTS.attr.fragmentdef,!0),A(l).set("original@imports",c),A(l).set("slot@imports",this.el),this["#"].slottedElements.add(l),this["#"].anchorNode.before(l)})}))}empty(){this["#"].slottedElements.forEach(o=>o.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,n),t.HTMLImportElement=n,n}function _r(e={}){let{config:t,window:i}=rt.call(this,"html-imports",e,{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[${i.CSS.escape(t.attr.def)}]`,t.importsContextSelector=`[${i.CSS.escape(t.attr.importscontext)}]`,t.slottedElementsSelector=`[${i.CSS.escape(t.attr.fragmentdef)}]:not(template)`;let r=(s,n)=>{let a=`starts-with(., "${s}")`,o=`substring(., string-length(.) - string-length("${n}") + 1) = "${n}"`;return`${a} and ${o}`};t.anchorNodeSelector=`comment()[${r(`&lt;${t.elements.import}`,`&lt;/${t.elements.import}&gt;`)}]`,i.webqit.HTMLImportsContext=Lt,i.webqit.HTMLImportElement=un(),Ua.call(i,t),Wa.call(i,t)}function qt(e,t=!0){if(!A(e).has("defs")&&t){let i=Object.create(null);A(e).set("defs",i)}return A(e).get("defs")}function Ua(e){let t=this,{webqit:{oohtml:{configs:i}}}=t;if(e.api.def in t.HTMLTemplateElement.prototype)throw new Error(`The "HTMLTemplateElement" prototype already has a "${e.api.def}" API!`);if(e.api.defs in t.HTMLTemplateElement.prototype)throw new Error(`The "HTMLTemplateElement" prototype already has a "${e.api.defs}" API!`);Object.defineProperty(t.HTMLTemplateElement.prototype,e.api.def,{get:function(){return this.getAttribute(e.attr.def)}}),Object.defineProperty(t.HTMLTemplateElement.prototype,e.api.defs,{get:function(){return qt(this)}}),Object.defineProperty(t.HTMLTemplateElement.prototype,"scoped",{configurable:!0,get(){return this.hasAttribute("scoped")},set(s){this.toggleAttribute("scoped",s)}}),[t.Document.prototype,t.Element.prototype,t.ShadowRoot.prototype].forEach(s=>{let n=s===t.Document.prototype?"Document":s===t.ShadowRoot.prototype?"ShadowRoot":"Element";if(e.api.import in s)throw new Error(`The ${n} prototype already has a "${e.api.import}" API!`);Object.defineProperty(s,e.api.import,{value:function(a,o=!1,u=null){return r(this,...arguments)}})});function r(s,n,a=!1,o=null){let u={};typeof a=="function"?(o=a,a=!1):typeof a=="object"&&a?u={...a,...u}:u={live:a};let c={...Lt.createRequest(n),...u};return s[i.CONTEXT_API.api.contexts].request(c,o)}}function Wa(e){let t=this,{webqit:{Observer:i,realdom:r,oohtml:{configs:s},HTMLImportElement:n,HTMLImportsContext:a}}=t,o=l=>{let f=l[s.CONTEXT_API.api.contexts];f.find(a.kind)||f.attach(new a)},u=l=>{let f=l[s.CONTEXT_API.api.contexts],p=f.find(a.kind);p&&(!l.isConnected||!l.matches?.(e.importsContextSelector)&&!Object.keys(p.localModules).length)&&f.detach(p)};r.realtime(t.document).query([e.templateSelector,e.importsContextSelector],l=>{l.entrants.forEach(f=>{if(f.matches(e.templateSelector)){let p=St.instance(f);p.ownerContext=f.scoped?f.parentNode:f.getRootNode();let m=qt(p.ownerContext);p.defId&&i.set(m,p.defId,f),o(p.ownerContext)}else o(f)}),l.exits.forEach(f=>{if(f.matches(e.templateSelector)){let p=St.instance(f),m=qt(p.ownerContext);p.defId&&p.ownerContext.isConnected&&i.deleteProperty(m,p.defId),u(p.ownerContext)}else u(f)})},{id:"imports:template/importscontext",live:!0,subtree:"cross-roots",timing:"sync",staticSensitivity:!0,eventDetails:!0}),r.realtime(t.document).query(e.elements.import,l=>{l.entrants.forEach(f=>c(f,!0,l)),l.exits.forEach(f=>c(f,!1,l))},{id:"imports:import",live:!0,subtree:"cross-roots",timing:"sync",deferred:!0});function c(l,f){let p=n.instance(l);f?p["#"].connectedCallback():p["#"].disconnectedCallback()}t.webqit.env!=="server"&&r.realtime(t.document).query(`(${e.anchorNodeSelector})`,l=>{l.entrants.forEach(f=>{if(A(f).get("isAnchorNode"))return;let p=t.document.createElement("div");p.innerHTML=f.nodeValue,p.innerHTML=p.firstChild.textContent;let m=p.firstChild,g=parseInt(m.getAttribute("data-nodecount")),v=new Set,E=f;for(;(E=E.previousElementSibling)&&E.matches(e.slottedElementsSelector)&&g--;)v.add(E);n.instance(m)["#"].hydrate(f,v)})},{id:"imports:hydration",live:!0,subtree:"cross-roots",timing:"sync"})}function Er(e={}){let{config:t,window:i}=rt.call(this,"context-api",e,{elements:{roots:"root,webflo-embedded"},attr:{contextname:"contextname"},api:{contexts:"contexts"}}),r=new Map,s=i.EventTarget.prototype.dispatchEvent;Object.defineProperty(i.EventTarget.prototype,"dispatchEvent",{value:function(...n){let a=n[0],o=this?.closest?.(t.elements.roots)||this.getRootNode?.();if(["contextclaim","contextrequest"].includes(a.type)&&o){a.meta&&(a.meta.target=this);let u=l=>{if(l.stopImmediatePropagation(),l.meta&&(l.meta.target=l.target),!l.answered){if(r.get(o)||r.set(o,new Set),l.type==="contextrequest"&&l.live)r.get(o).add(l);else if(l.type==="contextclaim"){let f=new Set;return r.get(o).forEach(p=>{!l.target.contains(p.target)||!l.detail?.matchEvent?.(p)||(r.get(o).delete(p),f.add(p))}),r.get(o).size||r.delete(o),l.respondWith?.(f)}}};o.addEventListener(a.type,u);let c=s.call(this,...n);return o.removeEventListener(a.type,u),c}return s.call(this,...n)}}),i.webqit.DOMContexts=Ft,i.webqit.DOMContext=st,i.webqit.DOMContextRequestEvent=wi(),i.webqit.DOMContextResponse=te,i.webqit.DuplicateContextError=ee,za.call(i,t)}function za(e){let t=this;[t.Document.prototype,t.Element.prototype,t.ShadowRoot.prototype].forEach(i=>{let r=i===t.Document.prototype?"Document":i===t.ShadowRoot.prototype?"ShadowRoot":"Element";if(e.api.contexts in i)throw new Error(`The ${r} prototype already has a "${e.api.contexts}" API!`);Object.defineProperty(i,e.api.contexts,{get:function(){return Ft.instance(this)}})})}function kr({advanced:e={},...t}){let{config:i,window:r}=rt.call(this,"scoped-css",t,{api:{styleSheets:"styleSheets"},style:{retention:"retain",mimeTypes:"text/css",strategy:null}});i.styleSelector=(Array.isArray(i.style.mimeTypes)?i.style.mimeTypes:i.style.mimeTypes.split("|")).concat("").reduce((s,n)=>{let a=n?`[type="${r.CSS.escape(n)}"]`:":not([type])";return s.concat(`style${a}`)},[]).join(","),r.webqit.oohtml.Style={compileCache:new Map},Qa.call(r,i),Ga.call(r,i)}function Qa(e){let t=this,i=new Map;[t.Element.prototype].forEach(r=>{let s="Element";if(e.api.styleSheets in r)throw new Error(`The ${s} prototype already has a "${e.api.styleSheets}" API!`);Object.defineProperty(r,e.api.styleSheets,{get:function(){return i.has(this)||i.set(this,[]),i.get(this)}})}),Object.defineProperty(t.HTMLStyleElement.prototype,"scoped",{configurable:!0,get(){return this.hasAttribute("scoped")},set(r){this.toggleAttribute("scoped",r)}})}function Ga(e){let t=this,{webqit:{oohtml:i,realdom:r}}=t,s=Object.getOwnPropertyDescriptor(globalThis,"window")?.get?.toString().includes("[native code]")??!1;t.CSS.supports||(t.CSS.supports=()=>!1);let n=new WeakSet;r.realtime(t.document).query(e.styleSelector,a=>{a.entrants.forEach(o=>{if(n.has(o))return;n.add(o);let u=Zt(o.textContent),c=CSS.supports("selector(:has(a,b))"),l=o.scoped&&(c?`:has(> style[rand-${u}])`:`[rand-${u}]`),f=o.scoped&&t.CSSScopeRule&&!1,p=o.scoped&&o.parentNode||o.getRootNode();if(p instanceof t.Element){if(p[e.api.styleSheets].push(o),!s)return;(c?o:p).toggleAttribute(`rand-${u}`,!0)}if(!!s)if(o.scoped&&o.hasAttribute("shared")){let m;(m=i.Style.compileCache.get(u))||(m=Ka.call(t,o,null,f,l),i.Style.compileCache.set(u,m)),Object.defineProperty(o,"sheet",{value:m,configurable:!0}),o.textContent=`
54
54
  /*[ Shared style sheet ]*/
55
55
  `}else{let m=()=>{let g=Si(ge.call(t,p));Cr.call(this,o.sheet,g,!f&&l)};o.isConnected?m():setTimeout(()=>{m()},0)}})},{id:"scoped-css",live:!0,subtree:"cross-roots",timing:"intercept",generation:"entrants"})}function Ka(e,t,i,r){let s=this,n=e.textContent,a,o=i&&r?`@scope (${r}) {
56
56
  ${n.trim()}