@webqit/oohtml 4.1.5 → 4.1.6
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/data-binding.js +1 -1
- package/dist/data-binding.js.map +2 -2
- package/dist/main.js +1 -1
- package/dist/main.js.map +2 -2
- package/dist/main.lite.js +13 -13
- package/dist/main.lite.js.map +2 -2
- package/package.json +1 -1
- package/src/data-binding/index.js +20 -4
package/dist/main.js
CHANGED
|
@@ -16,7 +16,7 @@ ${g}
|
|
|
16
16
|
/*[ Shared style sheet ]*/
|
|
17
17
|
`}else{let m=()=>{let g=di(ce.call(t,p));or.call(this,o.sheet,g,!f&&l)};o.isConnected?m():setTimeout(()=>{m()},0)}})},{live:!0,subtree:"cross-roots",timing:"intercept",generation:"entrants"})}function ba(e,t,i,r){let s=this,n=e.textContent,a,o=i&&r?`@scope (${r}) {
|
|
18
18
|
${n.trim()}
|
|
19
|
-
}`:n.trim();try{a=new s.CSSStyleSheet,a.replaceSync(o),or.call(this,a,t,!i&&r);let u=()=>e.getRootNode().adoptedStyleSheets.push(a);e.isConnected?u():setTimeout(()=>{u()},0)}catch{let c=s.document.createElement("style");e.after(c),c.textContent=o,a=c.sheet,or.call(this,a,t,!i&&r)}return a}function or(e,t,i=null){let r=e?.cssRules.length||-1;for(let s=0;s<r;++s){let n=e.cssRules[s];n instanceof CSSImportRule||js.call(this,n,t,i)}}function js(e,t,i=null){if(e instanceof CSSStyleRule){Bs.call(this,e,t,i);return}if([window.CSSScopeRule,window.CSSMediaRule,window.CSSContainerRule,window.CSSSupportsRule,window.CSSLayerBlockRule].some(r=>r&&e instanceof r)){let r=e.cssRules.length;for(let s=0;s<r;++s)js.call(this,e.cssRules[s],t,i)}}function Bs(e,t,i=null){let r=ar.call(this,e.selectorText,t,i,1);if(e.selectorText=r,e.cssRules){let s=e.cssRules.length;for(let n=0;n<s;++n)Bs.call(this,e.cssRules[n],t)}}function cr({advanced:e={},...t}){let{config:i,window:r}=it.call(this,"scoped-js",t,{script:{retention:"retain",mimeTypes:"module|text/javascript|application/javascript",timing:"auto"},api:{scripts:"scripts"},advanced:ai(e)});i.scriptSelector=(Array.isArray(i.script.mimeTypes)?i.script.mimeTypes:i.script.mimeTypes.split("|")).concat("").reduce((s,n)=>{let a=n?`[type="${r.CSS.escape(n)}"]`:":not([type])";return s.concat(`script${a}`)},[]).join(","),r.webqit.oohtml.Script={compileCache:[new Map,new Map],execute:va.bind(r,i)},wa.call(r,i),Sa.call(r,i)}function wa(e){let t=this,i=new Map;if(e.api.scripts in t.Element.prototype)throw new Error(`The "Element" class already has a "${e.api.scripts}" property!`);Object.defineProperty(t.Element.prototype,e.api.scripts,{get:function(){return i.has(this)||i.set(this,[]),i.get(this)}}),Object.defineProperties(t.HTMLScriptElement.prototype,{scoped:{configurable:!0,get(){return this.hasAttribute("scoped")},set(r){this.toggleAttribute("scoped",r)}},quantum:{configurable:!0,get(){return this.hasAttribute("quantum")},set(r){this.toggleAttribute("quantum",r)}}})}async function va(e,t){let i=this,{realdom:r}=i.webqit,s=hi(t);if(!s)throw new Error("Argument must be a valid exec hash.");let{script:n,compiledScript:a,thisContext:o}=s;e.script.retention==="dispose"?n.remove():e.script.retention==="dispose"?n.textContent='"source hidden"':n.textContent=await a.toString();let u=n.scoped?o:n.getRootNode();A(u).has("scriptEnv")||A(u).set("scriptEnv",Object.create(null));let c=(await a.bind(o,A(u).get("scriptEnv"))).execute();n.quantum&&Object.defineProperty(n,"state",{value:c}),r.realtime(i.document).observe(n,()=>{n.quantum&&c.dispose(),o instanceof i.Element&&o[e.api.scripts]?.splice(o[e.api.scripts].indexOf(n,1))},{subtree:"cross-roots",timing:"sync",generation:"exits"})}function Sa(e){let t=this,{webqit:{oohtml:i,realdom:r,QuantumScript:s,AsyncQuantumScript:n,QuantumModule:a}}=t;t.HTMLScriptElement.supports||(t.HTMLScriptElement.supports=u=>["text/javascript","application/javascript"].includes(u));let o=new WeakSet;r.realtime(t.document).query(e.scriptSelector,u=>{u.entrants.forEach(c=>{if(o.has(c))return;let l=(c._=c.textContent.trim())&&c._.startsWith("/*@oohtml*/if(false){")&&c._.endsWith("}/*@oohtml*/")?c._.slice(21,-12):c.textContent;if(!c.scoped&&!c.quantum&&!l.includes("quantum"))return;o.add(c);let f=Qt(l),p=i.Script.compileCache[c.quantum?0:1],m;if(!(m=p.get(f))){let{parserParams:x,compilerParams:w,runtimeParams:_}=e.advanced;m=new(c.type==="module"?a:s||n)(l,{exportNamespace:`#${c.id}`,fileName:`${t.document.url?.split("#")?.[0]||""}#${c.id}`,parserParams:{...x,quantumMode:c.quantum},compilerParams:w,runtimeParams:_}),p.set(f,m)}let g=c.scoped?c.parentNode||u.target:c.type==="module"?void 0:t;c.scoped&&g[e.api.scripts].push(c);let b=Qt({script:c,compiledScript:m,thisContext:g});u.type==="query"||c.type&&!t.HTMLScriptElement.supports(c.type)||e.script.timing==="manual"?i.Script.execute(b):c.textContent=`webqit.oohtml.Script.execute( '${b}' );`})},{live:!0,subtree:"cross-roots",timing:"intercept",generation:"entrants",eventDetails:!0})}function lr(e={}){let{config:t,window:i}=it.call(this,"context-api",e,{attr:{contextname:"contextname"},api:{contexts:"contexts"}});i.webqit.DOMContexts=Rt,i.webqit.DOMContext=rt,i.webqit.DOMContextRequestEvent=fi(),i.webqit.DOMContextResponse=Gt,i.webqit.DuplicateContextError=Kt,_a.call(i,t)}function _a(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 Rt.instance(this)}})})}var Pt=class extends rt{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}}}=U;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()}};K(Pt,"kind","bindings");function hr(e={}){let{config:t,window:i}=it.call(this,"bindings-api",e,{attr:{bindingsreflection:"bindings"},api:{bind:"bind",bindings:"bindings"}});i.webqit.DOMBindingsContext=Pt,Ea.call(i,t)}function Hs(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=>{let o=Object.keys(n),u=t instanceof i.Document?t.documentElement:t,c=e.attr.bindingsreflection;o.length&&c&&u.setAttribute?u.setAttribute(e.attr.bindingsreflection,o.join(" ")):c&&u.setAttribute&&u.toggleAttribute(e.attr.bindingsreflection,!1);let l=t[s.api.contexts];for(let f of a)if(f.type==="delete"){let p=l.find(Pt.kind,f.key);p&&l.detach(p)}else l.find(Pt.kind,f.key)||l.attach(new Pt(f.key))})}return A(t).get("bindings")}function Ea(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 Ca.call(t,e,this,n,a)}}),Object.defineProperty(r,e.api.bindings,{get:function(){return i.proxy(Hs.call(t,e,this))}})})}function Ca(e,t,i,{merge:r,diff:s,namespace:n}={}){let a=this,{webqit:{Observer:o}}=a,u=Hs.call(this,e,t),c={diff:s,namespace:n},l=r?[]:o.ownKeys(u,c).filter(f=>!(f in i));return o.batch(u,()=>(l.length&&o.deleteProperties(u,l,c),o.set(u,i,c)),c)}var wt=class{static instance(t){return A(t).get("defsmanager::instance")||new this(t)}constructor(t,i=null,r=0){let{window:s}=U,{webqit:{realdom:n,oohtml:{configs:a}}}=s;A(t).get("defsmanager::instance")?.dispose(),A(t).set("defsmanager::instance",this),this.host=t,this.config=a.HTML_IMPORTS,this.parent=i,this.level=r,this.defs=It(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.export(o.entrants,!0),this.export(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.`)}export(t,i){let{window:r}=U,{webqit:{Observer:s}}=r,n,a=this.defs["#"]||[];s.batch(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 wt(o,this.host,this.level+1):(a.push(o),n=!0),c&&(this.validateDefId(c),s.set(this.defs,(!u&&"#"||"")+c,o))):(u&&c?wt.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}}}=U,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}=U;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}}}=U,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=It(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("#")||wt.instance(i).dispose()})}};var Ot=class extends rt{static createRequest(t=null){let i=super.createRequest();if(t?.startsWith("/"))i.detail=t,i.targetContext=1/0;else if(t?.startsWith("@")){let[r,...s]=s.slice(1).split(/(?<=\w)(?=\/|#)/).map(n=>n.trim());i.targetContext=r,i.detail=s.join("")}else i.detail=t;return i}get localModules(){return It(this.host)}handle(t){let{window:{webqit:{Observer:i}}}=U;if(t.meta.controller?.abort(),(t.detail||"").trim()==="/")return t.respondWith(this.localModules);let r=(t.detail||"").split(/\/|(?<=\w)(?=#)/g).map(n=>n.trim()).filter(n=>n);if(!r.length)return t.respondWith();r=r.join(`/${this.configs.HTML_IMPORTS.api.defs}/`)?.split("/")||[];let s={live:t.live,signal:t.signal,descripted:!0};t.meta.controller=i.reduce(this.localModules,r,i.get,(n,{signal:a}={})=>{let o=Array.isArray(n)?n:n.value,u=Array.isArray(n)?n.length:n.value;if(!(!u&&this.host.isConnected===!1))return u||!this.contextModules?(t._isValidLocalResult=u,t.respondWith(o)):i.reduce(this.contextModules,r,i.get,c=>(t._currentSource="context",t.respondWith(Array.isArray(c)?c:c.value)),{...s,signal:a})},{lifecycleSignals:!0,...s})}unsubscribed(t){t.meta.controller?.abort()}realtimeSources(t){this.host=t;let i=()=>{for(let n of this.subscriptions)n._isValidLocalResult||this.handle(n)},r=this.configs.HTML_IMPORTS;if(!this.host.matches||!r.attr.importscontext)return;this.refdSourceController?.disconnect();let s=this.host.ownerDocument.defaultView.webqit.realdom;this.refdSourceController=s.realtime(this.host).attr(r.attr.importscontext,(n,{signal:a})=>{if(!n.value)return this.contextModules=void 0,i();let o={...this.constructor.createRequest(n.value.trim()),live:!0,signal:a};this.host.parentNode[this.configs.CONTEXT_API.api.contexts].request(o,u=>{this.contextModules=u&&Object.getPrototypeOf(u)?It(u):u,i()})},{live:!0,timing:"sync",lifecycleSignals:!0})}initialize(t){return this.realtimeSources(t),super.initialize(t)}dispose(t){return this.refdSourceController?.disconnect(),super.dispose(t)}};K(Ot,"kind","html-imports");function Us(){let{window:e}=U,{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.importRequest=(l,f=null)=>{let p={...Ot.createRequest(c.moduleRef?.includes("#")?c.moduleRef:`${c.moduleRef}#`),live:f&&!0,signal:f};(this.el.isConnected?this.el.parentNode:c.anchorNode.parentNode)[r.CONTEXT_API.api.contexts].request(p,m=>{l((m instanceof e.HTMLTemplateElement?[...m.content.children]:Array.isArray(m)?m:m&&[m])||[])})},c.hydrate=(l,f)=>{c.moduleRef=(this.el.getAttribute(r.HTML_IMPORTS.attr.ref)||"").trim(),l.replaceWith(c.setAnchorNode(this.createAnchorNode())),c.autoRestore(()=>{f.forEach(p=>{c.slottedElements.add(p),A(p).set("slot@imports",this.el)})}),c.hydrationImportRequest=new AbortController,c.importRequest(p=>{if(c.originalsRemapped)return this.fill(p);let m=p.map((b,v)=>({el:b,fragmentDef:b.getAttribute(r.HTML_IMPORTS.attr.fragmentdef)||"",tagName:b.tagName,i:v})),g=-1;f.forEach(b=>{let v=b.tagName,x=b.getAttribute(r.HTML_IMPORTS.attr.fragmentdef)||"",w=(g++,m.find(_=>_.tagName===v&&_.fragmentDef===x&&_.i===g));!w||A(b).set("original@imports",w.el)}),c.originalsRemapped=!0},c.hydrationImportRequest.signal)},c.autoRestore=(l=null)=>{c.autoRestoreRealtime?.disconnect(),l&&l();let f=()=>{c.anchorNode?.replaceWith(this.el),c.anchorNode=null,this.el.setAttribute("data-nodecount",0)};if(!c.slottedElements.size)return f();let p=i.realtime(e.document).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=()=>{if(c.slottedElements.size)throw new Error("Illegal reinsertion into the DOM; import slot is not empty!");c.moduleRefRealtime||(c.moduleRefRealtime=i.realtime(this.el).attr(r.HTML_IMPORTS.attr.ref,(l,{signal:f})=>{c.moduleRef=l.value,c.importRequest(p=>!c.hydrationImportRequest&&this.fill(p),f)},{live:!0,timing:"sync",lifecycleSignals:!0}),c.hydrationImportRequest?.abort(),c.hydrationImportRequest=null)},c.disconnectedCallback=()=>{c.hydrationImportRequest?.abort(),c.hydrationImportRequest=null,!c.anchorNode.isConnected&&(c.moduleRefRealtime?.disconnect(),c.moduleRefRealtime=null)}}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){Array.isArray(o)&&(o=new Set(o)),this.el.setAttribute("data-nodecount",o.size),this["#"].autoRestore(()=>{if(this["#"].slottedElements.forEach(u=>{let c=A(u).get("original@imports");o.has(c)?o.delete(c):(this["#"].slottedElements.delete(u),u.remove())}),o.size){let u=this["#"].anchorNode,c=this["#"].setAnchorNode(this.createAnchorNode());(this.el.isConnected?this.el:u).replaceWith(c)}o.forEach(u=>{let c=u.cloneNode(!0);c.hasAttribute(r.HTML_IMPORTS.attr.fragmentdef)||c.toggleAttribute(r.HTML_IMPORTS.attr.fragmentdef,!0),A(c).set("original@imports",u),A(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 fr(e={}){let{config:t,window:i}=it.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(`<${t.elements.import}`,`</${t.elements.import}>`)}]`,i.webqit.HTMLImportsContext=Ot,i.webqit.HTMLImportElement=Us(),ka.call(i,t),Aa.call(i,t)}function It(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 ka(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 It(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={...Ot.createRequest(n),...u};return s[i.CONTEXT_API.api.contexts].request(c,o)}}function Aa(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=wt.instance(f);p.ownerContext=f.scoped?f.parentNode:f.getRootNode();let m=It(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=wt.instance(f),m=It(p.ownerContext);p.defId&&p.ownerContext.isConnected&&i.deleteProperty(m,p.defId),u(p.ownerContext)}else u(f)})},{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))},{live:!0,subtree:"cross-roots",timing:"sync"});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")),b=new Set,v=f;for(;(v=v.previousElementSibling)&&v.matches(e.slottedElementsSelector)&&g--;)b.add(v);n.instance(m)["#"].hydrate(f,b)})},{live:!0,subtree:"cross-roots",timing:"sync"})}function mr(e={}){let{config:t,window:i}=it.call(this,"data-binding",e,{attr:{render:"render",itemIndex:"data-key"},tokens:{nodeType:"processing-instruction",tagStart:"?{",tagEnd:"}?",stateStart:"; [=",stateEnd:"]"}});({CONTEXT_API:t.CONTEXT_API,BINDINGS_API:t.BINDINGS_API,HTML_IMPORTS:t.HTML_IMPORTS}=i.webqit.oohtml.configs),t.attrSelector=`[${i.CSS.escape(t.attr.render)}]`;let r=(s,n)=>{let a=`starts-with(., "${s}")`,o=`substring(., string-length(.) - string-length("${n}") + 1) = "${n}"`;return`${a} and ${o}`};t.discreteBindingsSelector=`comment()[${r(t.tokens.tagStart,t.tokens.tagEnd)}]`,Pa.call(i,t)}function Pa(e){let t=this,{webqit:{realdom:i}}=t;i.realtime(t.document).query(`(${e.discreteBindingsSelector})`,r=>{Ws.call(this,...r.exits),Ia.call(this,e,...r.entrants)},{live:!0,subtree:"cross-roots",timing:"sync"}),i.realtime(t.document).query(e.attrSelector,r=>{Ws.call(this,...r.exits),Ta.call(this,e,...r.entrants)},{live:!0,subtree:"cross-roots",timing:"sync",staticSensitivity:!0})}function zs(e,t){let{webqit:{realdom:i,Observer:r,DOMBindingsContext:s}}=this;if(A(t).has("data-binding"))return A(t).get("data-binding");let n=Object.create(null),a=new AbortController;n.$exec__=(u,c,...l)=>{i.schedule("write",()=>u[c](...l))},n.$assign__=(u,c,l)=>{i.schedule("write",()=>u[c]=l)},r.intercept(n,{get:(u,c,l)=>{if(!(u.key in n)){let f={...s.createRequest(u.key),live:!0,signal:a.signal};t[e.CONTEXT_API.api.contexts].request(f,p=>{r.set(n,u.key,p)})}return l(n[u.key]??(u.key in globalThis?globalThis[u.key]:void 0))},has:(u,c,l)=>l(!0)});let o={scope:n,abortController:a,bindings:new Map};return A(t).set("data-binding",o),o}function Ws(...e){for(let t of e){let i=t.nodeName==="#text"?t.parentNode:t,{bindings:r,abortController:s}=A(i).get("data-binding")||{};if(!r?.has(t))return;r.get(t).state.dispose(),r.get(t).signals?.forEach(n=>n.abort()),r.delete(t),r.size||(s.abort(),A(i).delete("data-binding"))}}async function Ia(e,...t){let i=this,r=n=>{let a=e.tokens.tagStart.split("").map(m=>`\\${m}`).join(""),o=e.tokens.tagEnd.split("").map(m=>`\\${m}`).join(""),u=e.tokens.stateStart.split("").map(m=>m===" "?"(?:\\s+)?":`\\${m}`).join(""),c=e.tokens.stateEnd.split("").map(m=>`\\${m}`).join(""),l=`^${a}(.*?)(?:${u}(\\d+)${c}(?:\\s+)?)?${o}$`,[,f,p]=n.match(new RegExp(l));return{raw:n,expr:f,span:parseInt(p??0)}},s=t.reduce((n,a)=>{if(a.isBound)return n;let o=r(a.nodeValue),u=a;if(o.span){if(u=a.nextSibling,u?.nodeName!=="#text"||u.nodeValue.length<o.span)return n;u.nodeValue.length>o.span&&u.splitText(o.span)}else u=a.ownerDocument.createTextNode(""),a.after(u);u.isBound=!0;let c=a;return i.webqit.env!=="server"&&(c.remove(),c=null),n.concat({textNode:u,template:o,anchorNode:c})},[]);for(let{textNode:n,template:a,anchorNode:o}of s){let u=Oa(e,a.expr),{scope:c,bindings:l}=zs.call(this,e,n.parentNode);Object.defineProperty(n,"$oohtml_internal_databinding_anchorNode",{value:o,configurable:!0}),l.set(n,{state:await(await u.bind(n,c)).execute()})}}var pr=new Map;function Oa(e,t){if(pr.has(t))return pr.get(t);let i=`let content = ((${t}) ?? '') + '';`;i+="$assign__(this, 'nodeValue', content);",i+=`if ( this.$oohtml_internal_databinding_anchorNode ) { $assign__(this.$oohtml_internal_databinding_anchorNode, 'nodeValue', "${e.tokens.tagStart}${le(t)}${e.tokens.stateStart}" + content.length + "${e.tokens.stateEnd} ${e.tokens.tagEnd}"); }`;let{webqit:{QuantumModule:r}}=this,s=new r(i);return pr.set(t,s),s}async function Ta(e,...t){for(let i of t){let r=Na(e,i.getAttribute(e.attr.render)),{scope:s,bindings:n}=zs.call(this,e,i),a=[];Object.defineProperty(i,"$oohtml_internal_databinding_signals",{value:a,configurable:!0}),n.set(i,{signals:a,state:await(await r.bind(i,s)).execute()})}}var dr=new Map;function Na(e,t){if(dr.has(t))return dr.get(t);let i={},r=oe(t,";").map(a=>{let[o,u]=oe(a,":").map(m=>m.trim()),c=o[0],l=o.slice(1).trim(),f=`(${u})`,p=`(${f} ?? '')`;if(c==="&")return l.startsWith("--")?`$exec__(this.style, 'setProperty', "${le(l)}", ${p});`:`$assign__(this.style, "${le(l)}", ${p});`;if(c==="%")return`$exec__(this.classList, 'toggle', "${le(l)}", !!${f});`;if(c==="~")return l.startsWith("?")?`$exec__(this, 'toggleAttribute', "${le(l.substring(1).trim())}", !!${f});`:`$exec__(this, 'setAttribute', "${le(l)}", ${p});`;if(c==="@"){if(i[l])throw new Error(`Duplicate binding: ${o}.`);if(i[l]=!0,l==="text")return`$assign__(this, 'textContent', ${p});`;if(l==="html")return`$exec__(this, 'setHTML', ${p});`;if(l==="items"){let[m,g]=oe(u,"/");if(!g)throw new Error(`Invalid ${c}items spec: ${a}; no import specifier.`);let[b,v,x,w]=m.trim().match(/(.*?[\)\s+])(of|in)([\(\{\[\s+].*)/i)||[];if(!b)throw new Error(`Invalid ${c}items spec: ${a}.`);if(v.startsWith("(")?v=v.trim().slice(1,-1).split(",").map(C=>C.trim()):v=[v],v.length>(x==="in"?3:2))throw new Error(`Invalid ${c}items spec: ${a}.`);let _=x==="in"?v[2]:v[1]||"$index__";return`
|
|
19
|
+
}`:n.trim();try{a=new s.CSSStyleSheet,a.replaceSync(o),or.call(this,a,t,!i&&r);let u=()=>e.getRootNode().adoptedStyleSheets.push(a);e.isConnected?u():setTimeout(()=>{u()},0)}catch{let c=s.document.createElement("style");e.after(c),c.textContent=o,a=c.sheet,or.call(this,a,t,!i&&r)}return a}function or(e,t,i=null){let r=e?.cssRules.length||-1;for(let s=0;s<r;++s){let n=e.cssRules[s];n instanceof CSSImportRule||js.call(this,n,t,i)}}function js(e,t,i=null){if(e instanceof CSSStyleRule){Bs.call(this,e,t,i);return}if([window.CSSScopeRule,window.CSSMediaRule,window.CSSContainerRule,window.CSSSupportsRule,window.CSSLayerBlockRule].some(r=>r&&e instanceof r)){let r=e.cssRules.length;for(let s=0;s<r;++s)js.call(this,e.cssRules[s],t,i)}}function Bs(e,t,i=null){let r=ar.call(this,e.selectorText,t,i,1);if(e.selectorText=r,e.cssRules){let s=e.cssRules.length;for(let n=0;n<s;++n)Bs.call(this,e.cssRules[n],t)}}function cr({advanced:e={},...t}){let{config:i,window:r}=it.call(this,"scoped-js",t,{script:{retention:"retain",mimeTypes:"module|text/javascript|application/javascript",timing:"auto"},api:{scripts:"scripts"},advanced:ai(e)});i.scriptSelector=(Array.isArray(i.script.mimeTypes)?i.script.mimeTypes:i.script.mimeTypes.split("|")).concat("").reduce((s,n)=>{let a=n?`[type="${r.CSS.escape(n)}"]`:":not([type])";return s.concat(`script${a}`)},[]).join(","),r.webqit.oohtml.Script={compileCache:[new Map,new Map],execute:va.bind(r,i)},wa.call(r,i),Sa.call(r,i)}function wa(e){let t=this,i=new Map;if(e.api.scripts in t.Element.prototype)throw new Error(`The "Element" class already has a "${e.api.scripts}" property!`);Object.defineProperty(t.Element.prototype,e.api.scripts,{get:function(){return i.has(this)||i.set(this,[]),i.get(this)}}),Object.defineProperties(t.HTMLScriptElement.prototype,{scoped:{configurable:!0,get(){return this.hasAttribute("scoped")},set(r){this.toggleAttribute("scoped",r)}},quantum:{configurable:!0,get(){return this.hasAttribute("quantum")},set(r){this.toggleAttribute("quantum",r)}}})}async function va(e,t){let i=this,{realdom:r}=i.webqit,s=hi(t);if(!s)throw new Error("Argument must be a valid exec hash.");let{script:n,compiledScript:a,thisContext:o}=s;e.script.retention==="dispose"?n.remove():e.script.retention==="dispose"?n.textContent='"source hidden"':n.textContent=await a.toString();let u=n.scoped?o:n.getRootNode();A(u).has("scriptEnv")||A(u).set("scriptEnv",Object.create(null));let c=(await a.bind(o,A(u).get("scriptEnv"))).execute();n.quantum&&Object.defineProperty(n,"state",{value:c}),r.realtime(i.document).observe(n,()=>{n.quantum&&c.dispose(),o instanceof i.Element&&o[e.api.scripts]?.splice(o[e.api.scripts].indexOf(n,1))},{subtree:"cross-roots",timing:"sync",generation:"exits"})}function Sa(e){let t=this,{webqit:{oohtml:i,realdom:r,QuantumScript:s,AsyncQuantumScript:n,QuantumModule:a}}=t;t.HTMLScriptElement.supports||(t.HTMLScriptElement.supports=u=>["text/javascript","application/javascript"].includes(u));let o=new WeakSet;r.realtime(t.document).query(e.scriptSelector,u=>{u.entrants.forEach(c=>{if(o.has(c))return;let l=(c._=c.textContent.trim())&&c._.startsWith("/*@oohtml*/if(false){")&&c._.endsWith("}/*@oohtml*/")?c._.slice(21,-12):c.textContent;if(!c.scoped&&!c.quantum&&!l.includes("quantum"))return;o.add(c);let f=Qt(l),p=i.Script.compileCache[c.quantum?0:1],m;if(!(m=p.get(f))){let{parserParams:x,compilerParams:w,runtimeParams:_}=e.advanced;m=new(c.type==="module"?a:s||n)(l,{exportNamespace:`#${c.id}`,fileName:`${t.document.url?.split("#")?.[0]||""}#${c.id}`,parserParams:{...x,quantumMode:c.quantum},compilerParams:w,runtimeParams:_}),p.set(f,m)}let g=c.scoped?c.parentNode||u.target:c.type==="module"?void 0:t;c.scoped&&g[e.api.scripts].push(c);let b=Qt({script:c,compiledScript:m,thisContext:g});u.type==="query"||c.type&&!t.HTMLScriptElement.supports(c.type)||e.script.timing==="manual"?i.Script.execute(b):c.textContent=`webqit.oohtml.Script.execute( '${b}' );`})},{live:!0,subtree:"cross-roots",timing:"intercept",generation:"entrants",eventDetails:!0})}function lr(e={}){let{config:t,window:i}=it.call(this,"context-api",e,{attr:{contextname:"contextname"},api:{contexts:"contexts"}});i.webqit.DOMContexts=Rt,i.webqit.DOMContext=rt,i.webqit.DOMContextRequestEvent=fi(),i.webqit.DOMContextResponse=Gt,i.webqit.DuplicateContextError=Kt,_a.call(i,t)}function _a(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 Rt.instance(this)}})})}var Pt=class extends rt{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}}}=U;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()}};K(Pt,"kind","bindings");function hr(e={}){let{config:t,window:i}=it.call(this,"bindings-api",e,{attr:{bindingsreflection:"bindings"},api:{bind:"bind",bindings:"bindings"}});i.webqit.DOMBindingsContext=Pt,Ea.call(i,t)}function Hs(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=>{let o=Object.keys(n),u=t instanceof i.Document?t.documentElement:t,c=e.attr.bindingsreflection;o.length&&c&&u.setAttribute?u.setAttribute(e.attr.bindingsreflection,o.join(" ")):c&&u.setAttribute&&u.toggleAttribute(e.attr.bindingsreflection,!1);let l=t[s.api.contexts];for(let f of a)if(f.type==="delete"){let p=l.find(Pt.kind,f.key);p&&l.detach(p)}else l.find(Pt.kind,f.key)||l.attach(new Pt(f.key))})}return A(t).get("bindings")}function Ea(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 Ca.call(t,e,this,n,a)}}),Object.defineProperty(r,e.api.bindings,{get:function(){return i.proxy(Hs.call(t,e,this))}})})}function Ca(e,t,i,{merge:r,diff:s,namespace:n}={}){let a=this,{webqit:{Observer:o}}=a,u=Hs.call(this,e,t),c={diff:s,namespace:n},l=r?[]:o.ownKeys(u,c).filter(f=>!(f in i));return o.batch(u,()=>(l.length&&o.deleteProperties(u,l,c),o.set(u,i,c)),c)}var wt=class{static instance(t){return A(t).get("defsmanager::instance")||new this(t)}constructor(t,i=null,r=0){let{window:s}=U,{webqit:{realdom:n,oohtml:{configs:a}}}=s;A(t).get("defsmanager::instance")?.dispose(),A(t).set("defsmanager::instance",this),this.host=t,this.config=a.HTML_IMPORTS,this.parent=i,this.level=r,this.defs=It(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.export(o.entrants,!0),this.export(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.`)}export(t,i){let{window:r}=U,{webqit:{Observer:s}}=r,n,a=this.defs["#"]||[];s.batch(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 wt(o,this.host,this.level+1):(a.push(o),n=!0),c&&(this.validateDefId(c),s.set(this.defs,(!u&&"#"||"")+c,o))):(u&&c?wt.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}}}=U,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}=U;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}}}=U,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=It(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("#")||wt.instance(i).dispose()})}};var Ot=class extends rt{static createRequest(t=null){let i=super.createRequest();if(t?.startsWith("/"))i.detail=t,i.targetContext=1/0;else if(t?.startsWith("@")){let[r,...s]=s.slice(1).split(/(?<=\w)(?=\/|#)/).map(n=>n.trim());i.targetContext=r,i.detail=s.join("")}else i.detail=t;return i}get localModules(){return It(this.host)}handle(t){let{window:{webqit:{Observer:i}}}=U;if(t.meta.controller?.abort(),(t.detail||"").trim()==="/")return t.respondWith(this.localModules);let r=(t.detail||"").split(/\/|(?<=\w)(?=#)/g).map(n=>n.trim()).filter(n=>n);if(!r.length)return t.respondWith();r=r.join(`/${this.configs.HTML_IMPORTS.api.defs}/`)?.split("/")||[];let s={live:t.live,signal:t.signal,descripted:!0};t.meta.controller=i.reduce(this.localModules,r,i.get,(n,{signal:a}={})=>{let o=Array.isArray(n)?n:n.value,u=Array.isArray(n)?n.length:n.value;if(!(!u&&this.host.isConnected===!1))return u||!this.contextModules?(t._isValidLocalResult=u,t.respondWith(o)):i.reduce(this.contextModules,r,i.get,c=>(t._currentSource="context",t.respondWith(Array.isArray(c)?c:c.value)),{...s,signal:a})},{lifecycleSignals:!0,...s})}unsubscribed(t){t.meta.controller?.abort()}realtimeSources(t){this.host=t;let i=()=>{for(let n of this.subscriptions)n._isValidLocalResult||this.handle(n)},r=this.configs.HTML_IMPORTS;if(!this.host.matches||!r.attr.importscontext)return;this.refdSourceController?.disconnect();let s=this.host.ownerDocument.defaultView.webqit.realdom;this.refdSourceController=s.realtime(this.host).attr(r.attr.importscontext,(n,{signal:a})=>{if(!n.value)return this.contextModules=void 0,i();let o={...this.constructor.createRequest(n.value.trim()),live:!0,signal:a};this.host.parentNode[this.configs.CONTEXT_API.api.contexts].request(o,u=>{this.contextModules=u&&Object.getPrototypeOf(u)?It(u):u,i()})},{live:!0,timing:"sync",lifecycleSignals:!0})}initialize(t){return this.realtimeSources(t),super.initialize(t)}dispose(t){return this.refdSourceController?.disconnect(),super.dispose(t)}};K(Ot,"kind","html-imports");function Us(){let{window:e}=U,{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.importRequest=(l,f=null)=>{let p={...Ot.createRequest(c.moduleRef?.includes("#")?c.moduleRef:`${c.moduleRef}#`),live:f&&!0,signal:f};(this.el.isConnected?this.el.parentNode:c.anchorNode.parentNode)[r.CONTEXT_API.api.contexts].request(p,m=>{l((m instanceof e.HTMLTemplateElement?[...m.content.children]:Array.isArray(m)?m:m&&[m])||[])})},c.hydrate=(l,f)=>{c.moduleRef=(this.el.getAttribute(r.HTML_IMPORTS.attr.ref)||"").trim(),l.replaceWith(c.setAnchorNode(this.createAnchorNode())),c.autoRestore(()=>{f.forEach(p=>{c.slottedElements.add(p),A(p).set("slot@imports",this.el)})}),c.hydrationImportRequest=new AbortController,c.importRequest(p=>{if(c.originalsRemapped)return this.fill(p);let m=p.map((b,v)=>({el:b,fragmentDef:b.getAttribute(r.HTML_IMPORTS.attr.fragmentdef)||"",tagName:b.tagName,i:v})),g=-1;f.forEach(b=>{let v=b.tagName,x=b.getAttribute(r.HTML_IMPORTS.attr.fragmentdef)||"",w=(g++,m.find(_=>_.tagName===v&&_.fragmentDef===x&&_.i===g));!w||A(b).set("original@imports",w.el)}),c.originalsRemapped=!0},c.hydrationImportRequest.signal)},c.autoRestore=(l=null)=>{c.autoRestoreRealtime?.disconnect(),l&&l();let f=()=>{c.anchorNode?.replaceWith(this.el),c.anchorNode=null,this.el.setAttribute("data-nodecount",0)};if(!c.slottedElements.size)return f();let p=i.realtime(e.document).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=()=>{if(c.slottedElements.size)throw new Error("Illegal reinsertion into the DOM; import slot is not empty!");c.moduleRefRealtime||(c.moduleRefRealtime=i.realtime(this.el).attr(r.HTML_IMPORTS.attr.ref,(l,{signal:f})=>{c.moduleRef=l.value,c.importRequest(p=>!c.hydrationImportRequest&&this.fill(p),f)},{live:!0,timing:"sync",lifecycleSignals:!0}),c.hydrationImportRequest?.abort(),c.hydrationImportRequest=null)},c.disconnectedCallback=()=>{c.hydrationImportRequest?.abort(),c.hydrationImportRequest=null,!c.anchorNode.isConnected&&(c.moduleRefRealtime?.disconnect(),c.moduleRefRealtime=null)}}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){Array.isArray(o)&&(o=new Set(o)),this.el.setAttribute("data-nodecount",o.size),this["#"].autoRestore(()=>{if(this["#"].slottedElements.forEach(u=>{let c=A(u).get("original@imports");o.has(c)?o.delete(c):(this["#"].slottedElements.delete(u),u.remove())}),o.size){let u=this["#"].anchorNode,c=this["#"].setAnchorNode(this.createAnchorNode());(this.el.isConnected?this.el:u).replaceWith(c)}o.forEach(u=>{let c=u.cloneNode(!0);c.hasAttribute(r.HTML_IMPORTS.attr.fragmentdef)||c.toggleAttribute(r.HTML_IMPORTS.attr.fragmentdef,!0),A(c).set("original@imports",u),A(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 fr(e={}){let{config:t,window:i}=it.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(`<${t.elements.import}`,`</${t.elements.import}>`)}]`,i.webqit.HTMLImportsContext=Ot,i.webqit.HTMLImportElement=Us(),ka.call(i,t),Aa.call(i,t)}function It(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 ka(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 It(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={...Ot.createRequest(n),...u};return s[i.CONTEXT_API.api.contexts].request(c,o)}}function Aa(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=wt.instance(f);p.ownerContext=f.scoped?f.parentNode:f.getRootNode();let m=It(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=wt.instance(f),m=It(p.ownerContext);p.defId&&p.ownerContext.isConnected&&i.deleteProperty(m,p.defId),u(p.ownerContext)}else u(f)})},{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))},{live:!0,subtree:"cross-roots",timing:"sync"});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")),b=new Set,v=f;for(;(v=v.previousElementSibling)&&v.matches(e.slottedElementsSelector)&&g--;)b.add(v);n.instance(m)["#"].hydrate(f,b)})},{live:!0,subtree:"cross-roots",timing:"sync"})}function mr(e={}){let{config:t,window:i}=it.call(this,"data-binding",e,{attr:{render:"render",itemIndex:"data-key"},tokens:{nodeType:"processing-instruction",tagStart:"?{",tagEnd:"}?",stateStart:"; [=",stateEnd:"]"}});({CONTEXT_API:t.CONTEXT_API,BINDINGS_API:t.BINDINGS_API,HTML_IMPORTS:t.HTML_IMPORTS}=i.webqit.oohtml.configs),t.attrSelector=`[${i.CSS.escape(t.attr.render)}]`;let r=(s,n)=>{let a=`starts-with(., "${s}")`,o=`substring(., string-length(.) - string-length("${n}") + 1) = "${n}"`;return`${a} and ${o}`};t.discreteBindingsSelector=`comment()[${r(t.tokens.tagStart,t.tokens.tagEnd)}]`,Pa.call(i,t)}function Pa(e){let t=this,{webqit:{realdom:i}}=t;i.realtime(t.document).query(`(${e.discreteBindingsSelector})`,r=>{Ws.call(this,...r.exits),Ia.call(this,e,...r.entrants)},{live:!0,subtree:"cross-roots",timing:"sync"}),i.realtime(t.document).query(e.attrSelector,r=>{Ws.call(this,...r.exits),Ta.call(this,e,...r.entrants)},{live:!0,subtree:"cross-roots",timing:"sync",staticSensitivity:!0})}function zs(e,t){let{webqit:{realdom:i,Observer:r,DOMBindingsContext:s}}=this;if(A(t).has("data-binding"))return A(t).get("data-binding");let n=Object.create(null),a=new AbortController;n.$exec__=(u,c,...l)=>{let f=()=>{try{u[c](...l)}catch(p){console.error(`${p.message} at ${p.cause}`)}};i.schedule("write",f)},n.$assign__=(u,c,l)=>{let f=()=>{try{u[c]=l}catch(p){console.error(`${p.message} at ${p.cause}`)}};i.schedule("write",f)},r.intercept(n,{get:(u,c,l)=>{if(!(u.key in n)){let f={...s.createRequest(u.key),live:!0,signal:a.signal};t[e.CONTEXT_API.api.contexts].request(f,p=>{r.set(n,u.key,p)})}return l(n[u.key]??(u.key in globalThis?globalThis[u.key]:void 0))},has:(u,c,l)=>l(!0)});let o={scope:n,abortController:a,bindings:new Map};return A(t).set("data-binding",o),o}function Ws(...e){for(let t of e){let i=t.nodeName==="#text"?t.parentNode:t,{bindings:r,abortController:s}=A(i).get("data-binding")||{};if(!r?.has(t))return;r.get(t).state.dispose(),r.get(t).signals?.forEach(n=>n.abort()),r.delete(t),r.size||(s.abort(),A(i).delete("data-binding"))}}async function Ia(e,...t){let i=this,r=n=>{let a=e.tokens.tagStart.split("").map(m=>`\\${m}`).join(""),o=e.tokens.tagEnd.split("").map(m=>`\\${m}`).join(""),u=e.tokens.stateStart.split("").map(m=>m===" "?"(?:\\s+)?":`\\${m}`).join(""),c=e.tokens.stateEnd.split("").map(m=>`\\${m}`).join(""),l=`^${a}(.*?)(?:${u}(\\d+)${c}(?:\\s+)?)?${o}$`,[,f,p]=n.match(new RegExp(l));return{raw:n,expr:f,span:parseInt(p??0)}},s=t.reduce((n,a)=>{if(a.isBound)return n;let o=r(a.nodeValue),u=a;if(o.span){if(u=a.nextSibling,u?.nodeName!=="#text"||u.nodeValue.length<o.span)return n;u.nodeValue.length>o.span&&u.splitText(o.span)}else u=a.ownerDocument.createTextNode(""),a.after(u);u.isBound=!0;let c=a;return i.webqit.env!=="server"&&(c.remove(),c=null),n.concat({textNode:u,template:o,anchorNode:c})},[]);for(let{textNode:n,template:a,anchorNode:o}of s){let u=Oa(e,a.expr),{scope:c,bindings:l}=zs.call(this,e,n.parentNode);Object.defineProperty(n,"$oohtml_internal_databinding_anchorNode",{value:o,configurable:!0});try{l.set(n,{state:await(await u.bind(n,c)).execute()})}catch(f){console.log(f)}}}var pr=new Map;function Oa(e,t){if(pr.has(t))return pr.get(t);let i=`let content = ((${t}) ?? '') + '';`;i+="$assign__(this, 'nodeValue', content);",i+=`if ( this.$oohtml_internal_databinding_anchorNode ) { $assign__(this.$oohtml_internal_databinding_anchorNode, 'nodeValue', "${e.tokens.tagStart}${le(t)}${e.tokens.stateStart}" + content.length + "${e.tokens.stateEnd} ${e.tokens.tagEnd}"); }`;let{webqit:{QuantumModule:r}}=this,s=new r(i);return pr.set(t,s),s}async function Ta(e,...t){for(let i of t){let r=Na(e,i.getAttribute(e.attr.render)),{scope:s,bindings:n}=zs.call(this,e,i),a=[];Object.defineProperty(i,"$oohtml_internal_databinding_signals",{value:a,configurable:!0});try{n.set(i,{signals:a,state:await(await r.bind(i,s)).execute()})}catch(o){console.log(o)}}}var dr=new Map;function Na(e,t){if(dr.has(t))return dr.get(t);let i={},r=oe(t,";").map(a=>{let[o,u]=oe(a,":").map(m=>m.trim()),c=o[0],l=o.slice(1).trim(),f=`(${u})`,p=`(${f} ?? '')`;if(c==="&")return l.startsWith("--")?`$exec__(this.style, 'setProperty', "${le(l)}", ${p});`:`$assign__(this.style, "${le(l)}", ${p});`;if(c==="%")return`$exec__(this.classList, 'toggle', "${le(l)}", !!${f});`;if(c==="~")return l.startsWith("?")?`$exec__(this, 'toggleAttribute', "${le(l.substring(1).trim())}", !!${f});`:`$exec__(this, 'setAttribute', "${le(l)}", ${p});`;if(c==="@"){if(i[l])throw new Error(`Duplicate binding: ${o}.`);if(i[l]=!0,l==="text")return`$assign__(this, 'textContent', ${p});`;if(l==="html")return`$exec__(this, 'setHTML', ${p});`;if(l==="items"){let[m,g]=oe(u,"/");if(!g)throw new Error(`Invalid ${c}items spec: ${a}; no import specifier.`);let[b,v,x,w]=m.trim().match(/(.*?[\)\s+])(of|in)([\(\{\[\s+].*)/i)||[];if(!b)throw new Error(`Invalid ${c}items spec: ${a}.`);if(v.startsWith("(")?v=v.trim().slice(1,-1).split(",").map(C=>C.trim()):v=[v],v.length>(x==="in"?3:2))throw new Error(`Invalid ${c}items spec: ${a}.`);let _=x==="in"?v[2]:v[1]||"$index__";return`
|
|
20
20
|
let $iteratee__ = ${w};
|
|
21
21
|
let $import__ = this.${e.HTML_IMPORTS.api.import}( ${g.trim()}, true );
|
|
22
22
|
this.$oohtml_internal_databinding_signals?.push( $import__ );
|