@webqit/oohtml 4.5.7 → 4.5.8

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 @@ ${m}
50
50
  const abort${r} = () => this.removeEventListener( '${m}', handler${r} );
51
51
  this.$oohtml_internal_databinding_signals?.push( { abort: abort${r} } );
52
52
  `;if(g==="$")return`$exec__(this, '${m}', ${S});`;if(c.trim())throw new Error(`Invalid binding: ${c}.`)}).join(`
53
- `),{webqit:{QuantumModule:n}}=this,{parserParams:a,compilerParams:o,runtimeParams:l}=e.advanced,u=new n(s,{parserParams:a,compilerParams:o,runtimeParams:l});return br.set(t,u),u}var we=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))}),ye(t,e,`(${i.discreteBindingsSelector})`).forEach(r=>{let s=sn(i,r.nodeValue);nn.call(t,i,s.expr)})}var dt=class extends nt{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}}}=B;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(dt,"kind","bindings");function vr(e={}){let{config:t,window:i}=st.call(this,"bindings-api",e,{attr:{bindingsreflection:"bindings"},api:{bind:"bind",bindings:"bindings"}});i.webqit.DOMBindingsContext=dt,Ua.call(i,t),za.call(i,t)}function Sr(e,t){let i=this,{webqit:{Observer:r,oohtml:{configs:{CONTEXT_API:s}}}}=i;if(!k(t).has("bindings")){let n=Object.create(null);k(t).set("bindings",n),r.observe(n,a=>{if(t instanceof i.Element){let o=wi(t.getAttribute(e.attr.bindingsreflection)||""),l=new Map(o);for(let u of a)u.detail?.publish!==!1&&(u.type==="delete"?o.delete(u.key):o.set(u.key,void 0));o.size&&o.size!==l.size?t.setAttribute(e.attr.bindingsreflection,`{ ${[...o.entries()].map(([u,c])=>c===void 0?u:`${u}: ${c}`).join(", ")} }`):o.size||t.toggleAttribute(e.attr.bindingsreflection,!1)}else{let o=t[s.api.contexts];for(let l of a)if(l.type==="delete"){let u=o.find(dt.kind,l.key);u&&o.detach(u)}else o.find(dt.kind,l.key)||o.attach(new dt(l.key))}})}return k(t).get("bindings")}function Ua(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 Wa.call(t,e,this,n,a)}}),Object.defineProperty(r,e.api.bindings,{get:function(){return i.proxy(Sr.call(t,e,this))}})})}function Wa(e,t,i,{merge:r,diff:s,publish:n,namespace:a}={}){let o=this,{webqit:{Observer:l}}=o,u=Sr.call(this,e,t),c={diff:s,namespace:a,detail:{publish:n}},f=r?[]:Object.keys(u).filter(p=>!(p in i));return l.batch(u,()=>(f.length&&l.deleteProperties(u,f,c),l.set(u,i,c)),c)}function za(e){let t=this,{webqit:{realdom:i,Observer:r,oohtml:{configs:s}}}=t,n=(o,l)=>{let u=o[s.CONTEXT_API.api.contexts];u.find(dt.kind,l)||u.attach(new dt(l))},a=(o,l)=>{let u,c=o[s.CONTEXT_API.api.contexts];for(;u=c.find(dt.kind,l);)c.detach(u)};i.realtime(t.document).query(`[${t.CSS.escape(e.attr.bindingsreflection)}]`,o=>{o.exits.forEach(l=>a(l)),o.entrants.forEach(l=>{let u=wi(l.getAttribute(e.attr.bindingsreflection)||""),c=[...u.entries()].filter(([f,p])=>p!==void 0);c.length&&l[e.api.bind](Object.fromEntries(c),{merge:!0,publish:!1});for(let[f]of u)n(l,f)})},{id:"bindings:dom",live:!0,subtree:"cross-roots",timing:"sync",eventDetails:!0}),i.realtime(t.document,"attr").observe(e.attr.bindingsreflection,o=>{let l=Sr.call(t,e,o.target),u=wi(o.value||""),c=wi(o.oldValue||"");for(let f of new Set([...u.keys(),...c.keys()]))c.has(f)?u.has(f)?u.get(f)!==c.get(f)&&r.set(l,f,u.get(f),{detail:{publish:!1}}):(c.get(f)!==void 0&&r.deleteProperty(l,f,{detail:{publish:!1}}),a(o.target,f)):(u.get(f)!==void 0&&r.set(l,f,u.get(f),{detail:{publish:!1}}),n(o.target,f))},{id:"bindings:attr",subtree:"cross-roots",timing:"sync",newValue:!0,oldValue:!0})}var wi=e=>(e=e.trim(),new Map(Lt(e.slice(1,-1),",").filter(t=>t.trim()).map(t=>Lt(t,":").map(i=>i.trim()))));var _t=class{static instance(t){return k(t).get("defsmanager::instance")||new this(t)}constructor(t,i=null,r=0){let{window:s}=B,{webqit:{realdom:n,oohtml:{configs:a}}}=s;k(t).get("defsmanager::instance")?.dispose(),k(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}=B,{webqit:{Observer:s}}=r,n,a=this.defs["#"]||[];t.forEach(o=>{if(o.nodeType!==1)return;let l=o.matches(this.config.templateSelector),u=(o.getAttribute(l?this.config.attr.def:this.config.attr.fragmentdef)||"").trim();i?(l&&u?new _t(o,this.host,this.level+1):(a.push(o),n=!0,typeof requestIdleCallback=="function"&&requestIdleCallback(()=>{this.config.idleCompilers?.forEach(c=>c.call(this.window,o))})),u&&(this.validateDefId(u),s.set(this.defs,(!l&&"#"||"")+u,o))):(l&&u?_t.instance(o).dispose():(a=a.filter(c=>c!==o),n=!0),u&&s.deleteProperty(this.defs,(!l&&"#"||"")+u))}),n&&s.set(this.defs,"#",a)}evaluateLoading([t,i],{signal:r}){let{window:{webqit:{Observer:s}}}=B,n=(t.value||"").trim();if(!n)return;let a,o=c=>{if(!c)return a;a=c.then(()=>u.remove())},l=(i.value||"").trim(),u=s.intercept(this.defs,"get",async(c,f,p)=>(l==="lazy"&&o(this.load(n,!0)),await o(),p()),{signal:r});l!=="lazy"&&o(this.load(n))}load(t){let{window:i}=B;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}}}=B,i=(this.host.getAttribute(this.config.attr.extends)||"").trim(),r=(this.host.getAttribute(this.config.attr.inherits)||"").trim().split(" ").map(o=>o.trim()).filter(o=>o),s=o=>{o.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))})},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.length&&n.push(t.get(a,r.includes("*")?1/0: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("#")||_t.instance(i).dispose()})}};var jt,ot,ve,Se,Rt=class extends nt{constructor(){super(...arguments);_e(this,jt,{});_e(this,ot,void 0);_e(this,ve,void 0);_e(this,Se,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 J(this,jt)}handle(i){let{window:{webqit:{Observer:r}}}=B;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(J(this,ot),s,r.get,a=>{if(Array.isArray(a)){if(!a.length){i.respondWith();return}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}}}=B,s=()=>{for(let a of new Set([...Object.keys(this.localModules),...Object.keys(this.inheritedModules),...Object.keys(J(this,ot))]))if(!r.has(this.localModules,a)&&!r.has(this.inheritedModules,a))r.deleteProperty(J(this,ot),a);else if(a==="#"&&r.has(this.localModules,a)&&r.has(this.inheritedModules,a))r.set(J(this,ot),a,[...r.get(this.localModules,a),...r.get(this.inheritedModules,a)]);else{let o=r.get(this.localModules,a)||r.get(this.inheritedModules,a);r.get(J(this,ot),a)!==o&&r.set(J(this,ot),a,o)}};se(this,ot,{...this.localModules}),J(this,ve)?.abort(),se(this,ve,r.observe(this.localModules,()=>s("local"),{timing:"sync"}));let n=this.configs.HTML_IMPORTS;if(this.host.matches&&n.attr.importscontext){let a=this.host.ownerDocument.defaultView.webqit.realdom,o;J(this,Se)?.disconnect(),se(this,Se,a.realtime(this.host).attr(n.attr.importscontext,(l,{signal:u})=>{let c=(l.value||"").trim();if(c===o)return;o=c,se(this,jt,{});let f={...this.constructor.createRequest(c?`${c}/*`:"*"),live:!0,signal:u,diff:!0};this.host.parentNode[this.configs.CONTEXT_API.api.contexts].request(f,p=>{p?p.type==="delete"?(delete J(this,jt)[p.key],Reflect.has(this.localModules,p.key)||r.deleteProperty(J(this,ot),p.key)):(J(this,jt)[p.key]=p.value,!Reflect.has(this.localModules,p.key)&&Reflect.get(J(this,ot),p.key)!==p.value&&r.set(J(this,ot),p.key,p.value)):(se(this,jt,{}),s("inherited"))}),s("inherited")},{live:!0,timing:"sync",oldValue:!0,lifecycleSignals:!0}))}return super.initialize(i)}dispose(i){return J(this,ve)?.abort(),J(this,Se)?.disconnect(),super.dispose(i)}};jt=new WeakMap,ot=new WeakMap,ve=new WeakMap,Se=new WeakMap,G(Rt,"kind","html-imports");function un(){let{window:e}=B,{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:k(o).get("import::instance")||new this(o)}constructor(...o){super();let l=o[0]||this;k(l).set("import::instance",this),Object.defineProperty(this,"el",{get:()=>l,configurable:!1});let u={};Object.defineProperty(this,"#",{get:()=>u,configurable:!1}),u.slottedElements=new Set,u.setAnchorNode=c=>(u.anchorNode=c,c),u.live=c=>{if(u.liveImportsRealtime)throw new Error("Import element already in live mode.");let f=this.el.isConnected?this.el.parentNode:u.anchorNode.parentNode;u.liveImportsRealtime=i.realtime(this.el).attr(r.HTML_IMPORTS.attr.ref,(p,{signal:g})=>{u.moduleRef=p.value;let m=u.moduleRef.includes("#")?u.moduleRef:`${u.moduleRef}#`,S={...Rt.createRequest(m),live:g&&!0,signal:g,diff:!m.endsWith("#")};f[r.CONTEXT_API.api.contexts].request(S,E=>{c((E instanceof e.HTMLTemplateElement?[...E.content.children]:Array.isArray(E)?E:E&&[E])||[])})},{live:!0,timing:"sync",lifecycleSignals:!0}),u.autoDestroyRealtime=i.realtime(e.document).track(f,()=>{u.die()},{subtree:"cross-roots",timing:"sync",generation:"exits"})},u.die=()=>{u.autoDestroyRealtime?.disconnect(),u.liveImportsRealtime?.disconnect(),u.liveImportsRealtime=null},u.hydrate=(c,f)=>{c.replaceWith(u.setAnchorNode(this.createAnchorNode())),u.live(p=>{if(u.originalsRemapped)return this.fill(p);let g=p.map((m,S)=>({el:m,fragmentDef:m.getAttribute(r.HTML_IMPORTS.attr.fragmentdef)||"",tagName:m.tagName,i:S}));f.forEach((m,S)=>{let E=m.tagName,y=m.getAttribute(r.HTML_IMPORTS.attr.fragmentdef)||"",b=(S++,g.find(w=>w.tagName===E&&w.fragmentDef===y&&w.i===S));b&&k(m).set("original@imports",b.el),k(m).set("slot@imports",this.el),u.slottedElements.add(m)}),u.originalsRemapped=!0})},u.autoRestore=(c=null)=>{u.autoRestoreRealtime?.disconnect(),c&&c();let f=()=>{this.el.isConnected||(this.el.setAttribute("data-nodecount",0),u.internalMutation=!0,u.anchorNode.replaceWith(this.el),u.internalMutation=!1,u.setAnchorNode(null))};if(!u.slottedElements.size)return f();let p=i.realtime(u.anchorNode.parentNode).observe([...u.slottedElements],g=>{if(g.exits.forEach(m=>{k(m).delete("slot@imports"),u.slottedElements.delete(m)}),!u.slottedElements.size){if(p.disconnect(),!g.target.isConnected)return;f()}},{subtree:"cross-roots",timing:"sync",generation:"exits"});u.autoRestoreRealtime=p},u.connectedCallback=()=>{u.internalMutation||u.live(c=>this.fill(c))},u.disconnectedCallback=()=>{u.internalMutation||u.die()}}createAnchorNode(){if(e.webqit.env!=="server")return e.document.createTextNode("");let o=e.document.createElement("div");o.textContent=this.el.outerHTML;let l=e.document.createComment(o.innerHTML);return k(l).set("isAnchorNode",!0),l}fill(o,l){!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(u=>{let c=k(u).get("original@imports");o.has(c)?o.delete(c):(this["#"].slottedElements.delete(u),u.remove())}),o.size&&this.el.isConnected){let u=this["#"].setAnchorNode(this.createAnchorNode());this["#"].internalMutation=!0,this.el.replaceWith(u),this["#"].internalMutation=!1}o.forEach(u=>{let c=u.cloneNode(!0);c.hasAttribute(r.HTML_IMPORTS.attr.fragmentdef)||c.toggleAttribute(r.HTML_IMPORTS.attr.fragmentdef,!0),k(c).set("original@imports",u),k(c).set("slot@imports",this.el),this["#"].slottedElements.add(c),this["#"].anchorNode.before(c)})}))}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}=st.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=Rt,i.webqit.HTMLImportElement=un(),Qa.call(i,t),Ga.call(i,t)}function qt(e,t=!0){if(!k(e).has("defs")&&t){let i=Object.create(null);k(e).set("defs",i)}return k(e).get("defs")}function Qa(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,l=null){return r(this,...arguments)}})});function r(s,n,a=!1,o=null){let l={};typeof a=="function"?(o=a,a=!1):typeof a=="object"&&a?l={...a,...l}:l={live:a};let u={...Rt.createRequest(n),...l};return s[i.CONTEXT_API.api.contexts].request(u,o)}}function Ga(e){let t=this,{webqit:{Observer:i,realdom:r,oohtml:{configs:s},HTMLImportElement:n,HTMLImportsContext:a}}=t,o=c=>{let f=c[s.CONTEXT_API.api.contexts];f.find(a.kind)||f.attach(new a)},l=c=>{let f=c[s.CONTEXT_API.api.contexts],p=f.find(a.kind);p&&(!c.isConnected||!c.matches?.(e.importsContextSelector)&&!Object.keys(p.localModules).length)&&f.detach(p)};r.realtime(t.document).query([e.templateSelector,e.importsContextSelector],c=>{c.entrants.forEach(f=>{if(f.matches(e.templateSelector)){let p=_t.instance(f);p.ownerContext=f.scoped?f.parentNode:f.getRootNode();let g=qt(p.ownerContext);p.defId&&i.set(g,p.defId,f),o(p.ownerContext)}else o(f)}),c.exits.forEach(f=>{if(f.matches(e.templateSelector)){let p=_t.instance(f),g=qt(p.ownerContext);p.defId&&p.ownerContext.isConnected&&i.deleteProperty(g,p.defId),l(p.ownerContext)}else l(f)})},{id:"imports:template/importscontext",live:!0,subtree:"cross-roots",timing:"sync",staticSensitivity:!0,eventDetails:!0}),r.realtime(t.document).query(e.elements.import,c=>{c.entrants.forEach(f=>u(f,!0,c)),c.exits.forEach(f=>u(f,!1,c))},{id:"imports:import",live:!0,subtree:"cross-roots",timing:"sync",deferred:!0});function u(c,f){let p=n.instance(c);f?p["#"].connectedCallback():p["#"].disconnectedCallback()}t.webqit.env!=="server"&&r.realtime(t.document).query(`(${e.anchorNodeSelector})`,c=>{c.entrants.forEach(f=>{if(k(f).get("isAnchorNode"))return;let p=t.document.createElement("div");p.innerHTML=f.nodeValue,p.innerHTML=p.firstChild.textContent;let g=p.firstChild,m=parseInt(g.getAttribute("data-nodecount")),S=new Set,E=f;for(;(E=E.previousElementSibling)&&E.matches(e.slottedElementsSelector)&&m--;)S.add(E);n.instance(g)["#"].hydrate(f,S)})},{id:"imports:hydration",live:!0,subtree:"cross-roots",timing:"sync"})}function Er(e={}){let{config:t,window:i}=st.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 l=c=>{if(c.stopImmediatePropagation(),c.meta&&(c.meta.target=c.target),!c.answered){if(r.get(o)||r.set(o,new Set),c.type==="contextrequest"&&c.live)r.get(o).add(c);else if(c.type==="contextclaim"){let f=new Set;return r.get(o).forEach(p=>{!c.target.contains(p.target)||!c.detail?.matchEvent?.(p)||(r.get(o).delete(p),f.add(p))}),r.get(o).size||r.delete(o),c.respondWith?.(f)}}};o.addEventListener(a.type,l);let u=s.call(this,...n);return o.removeEventListener(a.type,l),u}return s.call(this,...n)}}),i.webqit.DOMContexts=Ft,i.webqit.DOMContext=nt,i.webqit.DOMContextRequestEvent=yi(),i.webqit.DOMContextResponse=ie,i.webqit.DuplicateContextError=re,Xa.call(i,t)}function Xa(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}=st.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},Ka.call(r,i),Ya.call(r,i)}function Ka(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 Ya(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 l=ee(o.textContent),u=CSS.supports("selector(:has(a,b))"),c=o.scoped&&(u?`:has(> style[rand-${l}])`:`[rand-${l}]`),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;(u?o:p).toggleAttribute(`rand-${l}`,!0)}if(!!s)if(o.scoped&&o.hasAttribute("shared")){let g;(g=i.Style.compileCache.get(l))||(g=Ja.call(t,o,null,f,c),i.Style.compileCache.set(l,g)),Object.defineProperty(o,"sheet",{value:g,configurable:!0}),o.textContent=`
53
+ `),{webqit:{QuantumModule:n}}=this,{parserParams:a,compilerParams:o,runtimeParams:l}=e.advanced,u=new n(s,{parserParams:a,compilerParams:o,runtimeParams:l});return br.set(t,u),u}var we=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))}),ye(t,e,`(${i.discreteBindingsSelector})`).forEach(r=>{let s=sn(i,r.nodeValue);nn.call(t,i,s.expr)})}var dt=class extends nt{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}}}=B;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(dt,"kind","bindings");function vr(e={}){let{config:t,window:i}=st.call(this,"bindings-api",e,{attr:{bindingsreflection:"bindings"},api:{bind:"bind",bindings:"bindings"}});i.webqit.DOMBindingsContext=dt,Ua.call(i,t),za.call(i,t)}function Sr(e,t){let i=this,{webqit:{Observer:r,oohtml:{configs:{CONTEXT_API:s}}}}=i;if(!k(t).has("bindings")){let n=Object.create(null);k(t).set("bindings",n),r.observe(n,a=>{if(t instanceof i.Element){let o=wi(t.getAttribute(e.attr.bindingsreflection)||""),l=new Map(o);for(let u of a)u.detail?.publish!==!1&&(u.type==="delete"?o.delete(u.key):o.set(u.key,void 0));o.size&&o.size!==l.size?t.setAttribute(e.attr.bindingsreflection,`{ ${[...o.entries()].map(([u,c])=>c===void 0?u:`${u}: ${c}`).join(", ")} }`):o.size||t.toggleAttribute(e.attr.bindingsreflection,!1)}else{let o=t[s.api.contexts];for(let l of a)if(l.type==="delete"){let u=o.find(dt.kind,l.key);u&&o.detach(u)}else o.find(dt.kind,l.key)||o.attach(new dt(l.key))}})}return k(t).get("bindings")}function Ua(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 Wa.call(t,e,this,n,a)}}),Object.defineProperty(r,e.api.bindings,{get:function(){return i.proxy(Sr.call(t,e,this))}})})}function Wa(e,t,i,{merge:r,diff:s,publish:n,namespace:a}={}){let o=this,{webqit:{Observer:l}}=o,u=Sr.call(this,e,t),c={diff:s,namespace:a,detail:{publish:n}},f=r?[]:Object.keys(u).filter(p=>!(p in i));return l.batch(u,()=>(f.length&&l.deleteProperties(u,f,c),l.set(u,i,c)),c)}function za(e){let t=this,{webqit:{realdom:i,Observer:r,oohtml:{configs:s}}}=t,n=(o,l)=>{let u=o[s.CONTEXT_API.api.contexts];u.find(dt.kind,l)||u.attach(new dt(l))},a=(o,l)=>{let u,c=o[s.CONTEXT_API.api.contexts];for(;u=c.find(dt.kind,l);)c.detach(u)};i.realtime(t.document).query(`[${t.CSS.escape(e.attr.bindingsreflection)}]`,o=>{o.exits.forEach(l=>a(l)),o.entrants.forEach(l=>{let u=wi(l.getAttribute(e.attr.bindingsreflection)||""),c=[...u.entries()].filter(([f,p])=>p!==void 0);c.length&&l[e.api.bind](Object.fromEntries(c),{merge:!0,publish:!1});for(let[f]of u)n(l,f)})},{id:"bindings:dom",live:!0,subtree:"cross-roots",timing:"sync",eventDetails:!0}),i.realtime(t.document,"attr").observe(e.attr.bindingsreflection,o=>{let l=Sr.call(t,e,o.target),u=wi(o.value||""),c=wi(o.oldValue||"");for(let f of new Set([...u.keys(),...c.keys()]))c.has(f)?u.has(f)?u.get(f)!==c.get(f)&&r.set(l,f,u.get(f),{detail:{publish:!1}}):(c.get(f)!==void 0&&r.deleteProperty(l,f,{detail:{publish:!1}}),a(o.target,f)):(u.get(f)!==void 0&&r.set(l,f,u.get(f),{detail:{publish:!1}}),n(o.target,f))},{id:"bindings:attr",subtree:"cross-roots",timing:"sync",newValue:!0,oldValue:!0})}var wi=e=>(e=e.trim(),new Map(Lt(e.slice(1,-1),",").filter(t=>t.trim()).map(t=>Lt(t,":").map(i=>i.trim()))));var _t=class{static instance(t){return k(t).get("defsmanager::instance")||new this(t)}constructor(t,i=null,r=0){let{window:s}=B,{webqit:{realdom:n,oohtml:{configs:a}}}=s;k(t).get("defsmanager::instance")?.dispose(),k(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}=B,{webqit:{Observer:s}}=r,n,a=this.defs["#"]||[];t.forEach(o=>{if(!o||o.nodeType!==1)return;let l=o.matches(this.config.templateSelector),u=(o.getAttribute(l?this.config.attr.def:this.config.attr.fragmentdef)||"").trim();i?(l&&u?new _t(o,this.host,this.level+1):(a.push(o),n=!0,typeof requestIdleCallback=="function"&&requestIdleCallback(()=>{this.config.idleCompilers?.forEach(c=>c.call(this.window,o))})),u&&(this.validateDefId(u),s.set(this.defs,(!l&&"#"||"")+u,o))):(l&&u?_t.instance(o).dispose():(a=a.filter(c=>c!==o),n=!0),u&&s.deleteProperty(this.defs,(!l&&"#"||"")+u))}),n&&s.set(this.defs,"#",a)}evaluateLoading([t,i],{signal:r}){let{window:{webqit:{Observer:s}}}=B,n=(t.value||"").trim();if(!n)return;let a,o=c=>{if(!c)return a;a=c.then(()=>u.remove())},l=(i.value||"").trim(),u=s.intercept(this.defs,"get",async(c,f,p)=>(l==="lazy"&&o(this.load(n,!0)),await o(),p()),{signal:r});l!=="lazy"&&o(this.load(n))}#t=new Set;#e;load(t){let{window:i}=B;if(this.#t.has(t)||(this.#t.add(t),this.#t.size===1&&this.host.content.children.length))return Promise.resolve();this.#e?.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.#e=null,s("loaderror"),this.host));return this.#e={request:n,controller:r},n}evalInheritance(){if(!this.parent)return[];let{window:{webqit:{Observer:t}}}=B,i=(this.host.getAttribute(this.config.attr.extends)||"").trim(),r=(this.host.getAttribute(this.config.attr.inherits)||"").trim().split(" ").map(o=>o.trim()).filter(o=>o),s=o=>{o.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))})},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.length&&n.push(t.get(a,r.includes("*")?1/0: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("#")||_t.instance(i).dispose()})}};var jt,ot,ve,Se,Rt=class extends nt{constructor(){super(...arguments);_e(this,jt,{});_e(this,ot,void 0);_e(this,ve,void 0);_e(this,Se,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 J(this,jt)}handle(i){let{window:{webqit:{Observer:r}}}=B;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(J(this,ot),s,r.get,a=>{if(Array.isArray(a)){if(!a.length){i.respondWith();return}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}}}=B,s=()=>{for(let a of new Set([...Object.keys(this.localModules),...Object.keys(this.inheritedModules),...Object.keys(J(this,ot))]))if(!r.has(this.localModules,a)&&!r.has(this.inheritedModules,a))r.deleteProperty(J(this,ot),a);else if(a==="#"&&r.has(this.localModules,a)&&r.has(this.inheritedModules,a))r.set(J(this,ot),a,[...r.get(this.localModules,a),...r.get(this.inheritedModules,a)]);else{let o=r.get(this.localModules,a)||r.get(this.inheritedModules,a);r.get(J(this,ot),a)!==o&&r.set(J(this,ot),a,o)}};se(this,ot,{...this.localModules}),J(this,ve)?.abort(),se(this,ve,r.observe(this.localModules,()=>s("local"),{timing:"sync"}));let n=this.configs.HTML_IMPORTS;if(this.host.matches&&n.attr.importscontext){let a=this.host.ownerDocument.defaultView.webqit.realdom,o;J(this,Se)?.disconnect(),se(this,Se,a.realtime(this.host).attr(n.attr.importscontext,(l,{signal:u})=>{let c=(l.value||"").trim();if(c===o)return;o=c,se(this,jt,{});let f={...this.constructor.createRequest(c?`${c}/*`:"*"),live:!0,signal:u,diff:!0};this.host.parentNode[this.configs.CONTEXT_API.api.contexts].request(f,p=>{p?p.type==="delete"?(delete J(this,jt)[p.key],Reflect.has(this.localModules,p.key)||r.deleteProperty(J(this,ot),p.key)):(J(this,jt)[p.key]=p.value,!Reflect.has(this.localModules,p.key)&&Reflect.get(J(this,ot),p.key)!==p.value&&r.set(J(this,ot),p.key,p.value)):(se(this,jt,{}),s("inherited"))}),s("inherited")},{live:!0,timing:"sync",oldValue:!0,lifecycleSignals:!0}))}return super.initialize(i)}dispose(i){return J(this,ve)?.abort(),J(this,Se)?.disconnect(),super.dispose(i)}};jt=new WeakMap,ot=new WeakMap,ve=new WeakMap,Se=new WeakMap,G(Rt,"kind","html-imports");function un(){let{window:e}=B,{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:k(o).get("import::instance")||new this(o)}constructor(...o){super();let l=o[0]||this;k(l).set("import::instance",this),Object.defineProperty(this,"el",{get:()=>l,configurable:!1});let u={};Object.defineProperty(this,"#",{get:()=>u,configurable:!1}),u.slottedElements=new Set,u.setAnchorNode=c=>(u.anchorNode=c,c),u.live=c=>{if(u.liveImportsRealtime)throw new Error("Import element already in live mode.");let f=this.el.isConnected?this.el.parentNode:u.anchorNode.parentNode;u.liveImportsRealtime=i.realtime(this.el).attr(r.HTML_IMPORTS.attr.ref,(p,{signal:g})=>{u.moduleRef=p.value;let m=u.moduleRef.includes("#")?u.moduleRef:`${u.moduleRef}#`,S={...Rt.createRequest(m),live:g&&!0,signal:g,diff:!m.endsWith("#")};f[r.CONTEXT_API.api.contexts].request(S,E=>{c((E instanceof e.HTMLTemplateElement?[...E.content.children]:Array.isArray(E)?E:E&&[E])||[])})},{live:!0,timing:"sync",lifecycleSignals:!0}),u.autoDestroyRealtime=i.realtime(e.document).track(f,()=>{u.die()},{subtree:"cross-roots",timing:"sync",generation:"exits"})},u.die=()=>{u.autoDestroyRealtime?.disconnect(),u.liveImportsRealtime?.disconnect(),u.liveImportsRealtime=null},u.hydrate=(c,f)=>{c.replaceWith(u.setAnchorNode(this.createAnchorNode())),u.live(p=>{if(u.originalsRemapped)return this.fill(p);let g=p.map((m,S)=>({el:m,fragmentDef:m.getAttribute(r.HTML_IMPORTS.attr.fragmentdef)||"",tagName:m.tagName,i:S}));f.forEach((m,S)=>{let E=m.tagName,y=m.getAttribute(r.HTML_IMPORTS.attr.fragmentdef)||"",b=(S++,g.find(w=>w.tagName===E&&w.fragmentDef===y&&w.i===S));b&&k(m).set("original@imports",b.el),k(m).set("slot@imports",this.el),u.slottedElements.add(m)}),u.originalsRemapped=!0})},u.autoRestore=(c=null)=>{u.autoRestoreRealtime?.disconnect(),c&&c();let f=()=>{this.el.isConnected||(this.el.setAttribute("data-nodecount",0),u.internalMutation=!0,u.anchorNode.replaceWith(this.el),u.internalMutation=!1,u.setAnchorNode(null))};if(!u.slottedElements.size)return f();let p=i.realtime(u.anchorNode.parentNode).observe([...u.slottedElements],g=>{if(g.exits.forEach(m=>{k(m).delete("slot@imports"),u.slottedElements.delete(m)}),!u.slottedElements.size){if(p.disconnect(),!g.target.isConnected)return;f()}},{subtree:"cross-roots",timing:"sync",generation:"exits"});u.autoRestoreRealtime=p},u.connectedCallback=()=>{u.internalMutation||u.live(c=>this.fill(c))},u.disconnectedCallback=()=>{u.internalMutation||u.die()}}createAnchorNode(){if(e.webqit.env!=="server")return e.document.createTextNode("");let o=e.document.createElement("div");o.textContent=this.el.outerHTML;let l=e.document.createComment(o.innerHTML);return k(l).set("isAnchorNode",!0),l}fill(o,l){!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(u=>{let c=k(u).get("original@imports");o.has(c)?o.delete(c):(this["#"].slottedElements.delete(u),u.remove())}),o.size&&this.el.isConnected){let u=this["#"].setAnchorNode(this.createAnchorNode());this["#"].internalMutation=!0,this.el.replaceWith(u),this["#"].internalMutation=!1}o.forEach(u=>{let c=u.cloneNode(!0);c.hasAttribute(r.HTML_IMPORTS.attr.fragmentdef)||c.toggleAttribute(r.HTML_IMPORTS.attr.fragmentdef,!0),k(c).set("original@imports",u),k(c).set("slot@imports",this.el),this["#"].slottedElements.add(c),this["#"].anchorNode.before(c)})}))}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}=st.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=Rt,i.webqit.HTMLImportElement=un(),Qa.call(i,t),Ga.call(i,t)}function qt(e,t=!0){if(!k(e).has("defs")&&t){let i=Object.create(null);k(e).set("defs",i)}return k(e).get("defs")}function Qa(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,l=null){return r(this,...arguments)}})});function r(s,n,a=!1,o=null){let l={};typeof a=="function"?(o=a,a=!1):typeof a=="object"&&a?l={...a,...l}:l={live:a};let u={...Rt.createRequest(n),...l};return s[i.CONTEXT_API.api.contexts].request(u,o)}}function Ga(e){let t=this,{webqit:{Observer:i,realdom:r,oohtml:{configs:s},HTMLImportElement:n,HTMLImportsContext:a}}=t,o=c=>{let f=c[s.CONTEXT_API.api.contexts];f.find(a.kind)||f.attach(new a)},l=c=>{let f=c[s.CONTEXT_API.api.contexts],p=f.find(a.kind);p&&(!c.isConnected||!c.matches?.(e.importsContextSelector)&&!Object.keys(p.localModules).length)&&f.detach(p)};r.realtime(t.document).query([e.templateSelector,e.importsContextSelector],c=>{c.entrants.forEach(f=>{if(f.matches(e.templateSelector)){let p=_t.instance(f);p.ownerContext=f.scoped?f.parentNode:f.getRootNode();let g=qt(p.ownerContext);p.defId&&i.set(g,p.defId,f),o(p.ownerContext)}else o(f)}),c.exits.forEach(f=>{if(f.matches(e.templateSelector)){let p=_t.instance(f),g=qt(p.ownerContext);p.defId&&p.ownerContext.isConnected&&i.deleteProperty(g,p.defId),l(p.ownerContext)}else l(f)})},{id:"imports:template/importscontext",live:!0,subtree:"cross-roots",timing:"sync",staticSensitivity:!0,eventDetails:!0}),r.realtime(t.document).query(e.elements.import,c=>{c.entrants.forEach(f=>u(f,!0,c)),c.exits.forEach(f=>u(f,!1,c))},{id:"imports:import",live:!0,subtree:"cross-roots",timing:"sync",deferred:!0});function u(c,f){let p=n.instance(c);f?p["#"].connectedCallback():p["#"].disconnectedCallback()}t.webqit.env!=="server"&&r.realtime(t.document).query(`(${e.anchorNodeSelector})`,c=>{c.entrants.forEach(f=>{if(k(f).get("isAnchorNode"))return;let p=t.document.createElement("div");p.innerHTML=f.nodeValue,p.innerHTML=p.firstChild.textContent;let g=p.firstChild,m=parseInt(g.getAttribute("data-nodecount")),S=new Set,E=f;for(;(E=E.previousElementSibling)&&E.matches(e.slottedElementsSelector)&&m--;)S.add(E);n.instance(g)["#"].hydrate(f,S)})},{id:"imports:hydration",live:!0,subtree:"cross-roots",timing:"sync"})}function Er(e={}){let{config:t,window:i}=st.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 l=c=>{if(c.stopImmediatePropagation(),c.meta&&(c.meta.target=c.target),!c.answered){if(r.get(o)||r.set(o,new Set),c.type==="contextrequest"&&c.live)r.get(o).add(c);else if(c.type==="contextclaim"){let f=new Set;return r.get(o).forEach(p=>{!c.target.contains(p.target)||!c.detail?.matchEvent?.(p)||(r.get(o).delete(p),f.add(p))}),r.get(o).size||r.delete(o),c.respondWith?.(f)}}};o.addEventListener(a.type,l);let u=s.call(this,...n);return o.removeEventListener(a.type,l),u}return s.call(this,...n)}}),i.webqit.DOMContexts=Ft,i.webqit.DOMContext=nt,i.webqit.DOMContextRequestEvent=yi(),i.webqit.DOMContextResponse=ie,i.webqit.DuplicateContextError=re,Xa.call(i,t)}function Xa(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}=st.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},Ka.call(r,i),Ya.call(r,i)}function Ka(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 Ya(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 l=ee(o.textContent),u=CSS.supports("selector(:has(a,b))"),c=o.scoped&&(u?`:has(> style[rand-${l}])`:`[rand-${l}]`),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;(u?o:p).toggleAttribute(`rand-${l}`,!0)}if(!!s)if(o.scoped&&o.hasAttribute("shared")){let g;(g=i.Style.compileCache.get(l))||(g=Ja.call(t,o,null,f,c),i.Style.compileCache.set(l,g)),Object.defineProperty(o,"sheet",{value:g,configurable:!0}),o.textContent=`
54
54
  /*[ Shared style sheet ]*/
55
55
  `}else{let g=()=>{let m=bi(be.call(t,p));Cr.call(this,o.sheet,m,!f&&c)};o.isConnected?g():setTimeout(()=>{g()},0)}})},{id:"scoped-css",live:!0,subtree:"cross-roots",timing:"intercept",generation:"entrants"})}function Ja(e,t,i,r){let s=this,n=e.textContent,a,o=i&&r?`@scope (${r}) {
56
56
  ${n.trim()}