@webqit/oohtml 4.3.3 → 4.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/main.lite.js
CHANGED
|
@@ -51,7 +51,7 @@ ${g}
|
|
|
51
51
|
const abort${r} = () => this.removeEventListener( '${f}', handler${r} );
|
|
52
52
|
this.$oohtml_internal_databinding_signals?.push( { abort: abort${r} } );
|
|
53
53
|
`;if(u==="$")return`$exec__(this, '${f}', ${d});`;if(a.trim())throw new Error(`Invalid binding: ${a}.`)}).join(`
|
|
54
|
-
`),{webqit:{QuantumModule:o}}=this,s=new o(i);return Je.set(t,s),s}var jt=n=>n.replace(/"/g,'\\"');function Lr(n){let t=this,{webqit:{oohtml:{configs:{DATA_BINDING:e}}}}=t;(n?.matches(e.attrSelector)?[n]:[]).concat([...n?.querySelectorAll(e.attrSelector)||[]]).forEach(r=>{Dr.call(t,e,r.getAttribute(e.attr.render))}),Tt(t,n,`(${e.discreteBindingsSelector})`).forEach(r=>{let i=kr(e,r.nodeValue);Nr.call(t,e,i.expr)})}var ot=class extends U{static createRequest(t=null){let e=super.createRequest();if(t?.startsWith("@")){let[r,...i]=i.slice(1).split(".").map(o=>o.trim());e.targetContext=r,e.detail=i.join(".")}else e.detail=t;return e}get bindingsObj(){return this.host[this.configs.BINDINGS_API.api.bindings]}matchEvent(t){return super.matchEvent(t)&&(!t.detail||!this.detail||(Array.isArray(t.detail)?t.detail[0]===this.detail:t.detail===this.detail))}handle(t){if(t.meta.controller?.abort(),!(t.detail+"").trim())return t.respondWith(this.bindingsObj);let{window:{webqit:{Observer:e}}}=R;t.meta.controller=e.reduce(this.bindingsObj,Array.isArray(t.detail)?t.detail:[t.detail],e.get,r=>{this.disposed||t.respondWith(r.value)},{live:t.live,signal:t.signal,descripted:!0})}unsubscribed(t){t.meta.controller?.abort()}};F(ot,"kind","bindings");function Ze(n={}){let{config:t,window:e}=B.call(this,"bindings-api",n,{attr:{bindingsreflection:"bindings"},api:{bind:"bind",bindings:"bindings"}});e.webqit.DOMBindingsContext=ot,Hn.call(e,t)}function Hr(n,t){let e=this,{webqit:{Observer:r,oohtml:{configs:{CONTEXT_API:i}}}}=e;if(!v(t).has("bindings")){let o=Object.create(null);v(t).set("bindings",o),r.observe(o,s=>{let a=Object.keys(o),l=t instanceof e.Document?t.documentElement:t,c=n.attr.bindingsreflection;a.length&&c&&l.setAttribute?l.setAttribute(n.attr.bindingsreflection,a.join(" ")):c&&l.setAttribute&&l.toggleAttribute(n.attr.bindingsreflection,!1);let u=t[i.api.contexts];for(let f of s)if(f.type==="delete"){let d=u.find(ot.kind,f.key);d&&u.detach(d)}else u.find(ot.kind,f.key)||u.attach(new ot(f.key))})}return v(t).get("bindings")}function Hn(n){let t=this,{webqit:{Observer:e}}=t;[t.Document.prototype,t.Element.prototype,t.ShadowRoot.prototype].forEach(r=>{let i=r===t.Document.prototype?"Document":r===t.ShadowRoot.prototype?"ShadowRoot":"Element";if(n.api.bind in r)throw new Error(`The ${i} prototype already has a "${n.api.bind}" API!`);if(n.api.bindings in r)throw new Error(`The ${i} prototype already has a "${n.api.bindings}" API!`);Object.defineProperty(r,n.api.bind,{value:function(o,s={}){return Fn.call(t,n,this,o,s)}}),Object.defineProperty(r,n.api.bindings,{get:function(){return e.proxy(Hr.call(t,n,this))}})})}function Fn(n,t,e,{merge:r,diff:i,namespace:o}={}){let s=this,{webqit:{Observer:a}}=s,l=Hr.call(this,n,t),c={diff:i,namespace:o},u=r?[]:a.ownKeys(l,c).filter(f=>!(f in e));return a.batch(l,()=>(u.length&&a.deleteProperties(l,u,c),a.set(l,e,c)),c)}var K=class{static instance(t){return v(t).get("defsmanager::instance")||new this(t)}constructor(t,e=null,r=0){let{window:i}=R,{webqit:{realdom:o,oohtml:{configs:s}}}=i;v(t).get("defsmanager::instance")?.dispose(),v(t).set("defsmanager::instance",this),this.window=i,this.host=t,this.config=s.HTML_IMPORTS,this.parent=e,this.level=r,this.defs=st(this.host),this.defId=(this.host.getAttribute(this.config.attr.def)||"").trim(),this.validateDefId(this.defId),this.realtimeA=o.realtime(this.host.content).children(a=>{this.expose(a.entrants,!0),this.expose(a.exits,!1)},{live:!0,timing:"sync"}),this.realtimeB=o.realtime(this.host).attr(["src","loading"],(...a)=>this.evaluateLoading(...a),{live:!0,atomic:!0,timing:"sync",lifecycleSignals:!0}),this.realtimeC=this.evalInheritance()}validateDefId(t){if(["@","/","*","#"].some(e=>t.includes(e)))throw new Error(`The export ID "${t}" contains an invalid character.`)}expose(t,e){let{window:r}=R,{webqit:{Observer:i}}=r,o,s=this.defs["#"]||[];t.forEach(a=>{if(a.nodeType!==1)return;let l=a.matches(this.config.templateSelector),c=(a.getAttribute(l?this.config.attr.def:this.config.attr.fragmentdef)||"").trim();e?(l&&c?new K(a,this.host,this.level+1):(s.push(a),o=!0,typeof requestIdleCallback=="function"&&requestIdleCallback(()=>{this.config.idleCompilers?.forEach(u=>u.call(this.window,a))})),c&&(this.validateDefId(c),i.set(this.defs,(!l&&"#"||"")+c,a))):(l&&c?K.instance(a).dispose():(s=s.filter(u=>u!==a),o=!0),c&&i.deleteProperty(this.defs,(!l&&"#"||"")+c))}),o&&i.set(this.defs,"#",s)}evaluateLoading([t,e],{signal:r}){let{window:{webqit:{Observer:i}}}=R,o=(t.value||"").trim();if(!o)return;let s,a=u=>{if(!u)return s;s=u.then(()=>c.remove())},l=(e.value||"").trim(),c=i.intercept(this.defs,"get",async(u,f,d)=>(l==="lazy"&&a(this.load(o,!0)),await a(),d()),{signal:r});l!=="lazy"&&a(this.load(o))}load(t){let{window:e}=R;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,i=(s,a)=>this.host.dispatchEvent(new e.CustomEvent(s,{detail:a})),o=e.fetch(t,{signal:r.signal,element:this.host}).then(s=>s.ok?s.text():Promise.reject(s.statusText)).then(s=>(this.host.innerHTML=s.trim(),i("load"),this.host)).catch(s=>(console.error(`Error fetching the bundle at "${t}": ${s.message}`),this.fetchInFlight=null,i("loaderror"),this.host));return this.fetchInFlight={src:t,request:o,controller:r},o}evalInheritance(){if(!this.parent)return[];let{window:{webqit:{Observer:t}}}=R,e=(this.host.getAttribute(this.config.attr.extends)||"").trim(),r=(this.host.getAttribute(this.config.attr.inherits)||"").trim(),i=a=>{a.forEach(l=>{t.get(this.defs,l.key)===l.oldValue&&(["get","set","def"].includes(l.type)?t[l.type.replace("get","set")](this.defs,l.key,l.value):l.type==="delete"&&t.deleteProperty(this.defs,l.key))})},o=[],s=st(this.parent);return e&&o.push(t.reduce(s,[e,this.config.api.defs,1/0],t.get,i,{live:!0})),(r=r.split(" ").map(a=>a.trim()).filter(a=>a)).length&&o.push(t.get(s,r,i,{live:!0})),o}dispose(){this.realtimeA.disconnect(),this.realtimeB.disconnect(),this.realtimeC.forEach(t=>t instanceof Promise?t.then(e=>e.abort()):t.abort()),Object.entries(this.defs).forEach(([t,e])=>{t.startsWith("#")||K.instance(e).dispose()})}};var at=class extends U{static createRequest(t=null){let e=super.createRequest();if(t?.startsWith("/"))e.detail=t,e.targetContext=1/0;else if(t?.startsWith("@")){let[r,...i]=i.slice(1).split(/(?<=\w)(?=\/|#)/).map(o=>o.trim());e.targetContext=r,e.detail=i.join("")}else e.detail=t;return e}get localModules(){return st(this.host)}handle(t){let{window:{webqit:{Observer:e}}}=R;if(t.meta.controller?.abort(),(t.detail||"").trim()==="/")return t.respondWith(this.localModules);let r=(t.detail||"").split(/\/|(?<=\w)(?=#)/g).map(o=>o.trim()).filter(o=>o);if(!r.length)return t.respondWith();r=r.join(`/${this.configs.HTML_IMPORTS.api.defs}/`)?.split("/")||[];let i={live:t.live,signal:t.signal,descripted:!0};t.meta.controller=e.reduce(this.localModules,r,e.get,(o,{signal:s}={})=>{let a=Array.isArray(o)?o:o.value,l=Array.isArray(o)?o.length:o.value;if(!(!l&&this.host.isConnected===!1))return l||!this.contextModules?(t._isValidLocalResult=l,t.respondWith(a)):e.reduce(this.contextModules,r,e.get,c=>(t._currentSource="context",t.respondWith(Array.isArray(c)?c:c.value)),{...i,signal:s})},{lifecycleSignals:!0,...i})}unsubscribed(t){t.meta.controller?.abort()}realtimeSources(t){this.host=t;let e=()=>{for(let s of this.subscriptions)s._isValidLocalResult||this.handle(s)},r=this.configs.HTML_IMPORTS;if(!this.host.matches||!r.attr.importscontext)return;this.refdSourceController?.disconnect();let i=this.host.ownerDocument.defaultView.webqit.realdom,o;this.refdSourceController=i.realtime(this.host).attr(r.attr.importscontext,(s,{signal:a})=>{if(s.value===o)return;if(o=s.value,!s.value)return this.contextModules=void 0,e();let l={...this.constructor.createRequest(s.value.trim()),live:!0,signal:a,diff:!0};this.host.parentNode[this.configs.CONTEXT_API.api.contexts].request(l,c=>{this.contextModules=c&&Object.getPrototypeOf(c)?st(c):c,e()})},{live:!0,timing:"sync",lifecycleSignals:!0})}initialize(t){return this.realtimeSources(t),super.initialize(t)}dispose(t){return this.refdSourceController?.disconnect(),super.dispose(t)}};F(at,"kind","html-imports");function Fr(){let{window:n}=R,{webqit:t}=n,{realdom:e,oohtml:{configs:r}}=t;if(t.HTMLImportElement)return t.HTMLImportElement;let i=r.HTML_IMPORTS.elements.import.includes("-")?n.HTMLElement:class{};class o extends i{static instance(a){return r.HTML_IMPORTS.elements.import.includes("-")&&a instanceof this?a:v(a).get("import::instance")||new this(a)}constructor(...a){super();let l=a[0]||this;v(l).set("import::instance",this),Object.defineProperty(this,"el",{get:()=>l,configurable:!1});let c={};Object.defineProperty(this,"#",{get:()=>c,configurable:!1}),c.slottedElements=new Set,c.setAnchorNode=u=>(c.anchorNode=u,u),c.live=u=>{if(c.liveImportsRealtime)throw new Error("Import element already in live mode.");let f=this.el.isConnected?this.el.parentNode:c.anchorNode.parentNode;c.liveImportsRealtime=e.realtime(this.el).attr(r.HTML_IMPORTS.attr.ref,(d,{signal:p})=>{c.moduleRef=d.value;let g=c.moduleRef.includes("#")?c.moduleRef:`${c.moduleRef}#`,_={...at.createRequest(g),live:p&&!0,signal:p,diff:!g.endsWith("#")};f[r.CONTEXT_API.api.contexts].request(_,A=>{u((A instanceof n.HTMLTemplateElement?[...A.content.children]:Array.isArray(A)?A:A&&[A])||[])})},{live:!0,timing:"sync",lifecycleSignals:!0}),c.autoDestroyRealtime=e.realtime(n.document).track(f,()=>{this.state=null,c.die()},{subtree:"cross-roots",timing:"sync",generation:"exits"})},c.die=()=>{c.autoDestroyRealtime?.disconnect(),c.liveImportsRealtime?.disconnect(),c.liveImportsRealtime=null},c.hydrate=(u,f)=>{u.replaceWith(c.setAnchorNode(this.createAnchorNode())),c.live(d=>{if(c.originalsRemapped)return this.fill(d);let p=d.map((g,_)=>({el:g,fragmentDef:g.getAttribute(r.HTML_IMPORTS.attr.fragmentdef)||"",tagName:g.tagName,i:_}));f.forEach((g,_)=>{let A=g.tagName,m=g.getAttribute(r.HTML_IMPORTS.attr.fragmentdef)||"",y=(_++,p.find(O=>O.tagName===A&&O.fragmentDef===m&&O.i===_));y&&v(g).set("original@imports",y.el),v(g).set("slot@imports",this.el),c.slottedElements.add(g)}),c.originalsRemapped=!0})},c.autoRestore=(u=null)=>{c.autoRestoreRealtime?.disconnect(),u&&u();let f=()=>{this.el.isConnected||(this.el.setAttribute("data-nodecount",0),this.state="restored",c.anchorNode.replaceWith(this.el),c.setAnchorNode(null))};if(!c.slottedElements.size)return f();let d=e.realtime(c.anchorNode.parentNode).observe([...c.slottedElements],p=>{if(p.exits.forEach(g=>{v(g).delete("slot@imports"),c.slottedElements.delete(g)}),!c.slottedElements.size){if(d.disconnect(),!p.target.isConnected)return;f()}},{subtree:"cross-roots",timing:"sync",generation:"exits"});c.autoRestoreRealtime=d},c.connectedCallback=()=>{this.state!=="restored"&&c.live(u=>this.fill(u))},c.disconnectedCallback=()=>{this.state!=="resolved"&&c.die()}}createAnchorNode(){if(n.webqit.env!=="server")return n.document.createTextNode("");let a=n.document.createElement("div");a.textContent=this.el.outerHTML;let l=n.document.createComment(a.innerHTML);return v(l).set("isAnchorNode",!0),l}fill(a,l){!this.el.isConnected&&(!this["#"].anchorNode||!this["#"].anchorNode.isConnected)||(Array.isArray(a)&&(a=new Set(a)),this.el.setAttribute("data-nodecount",a.size),this["#"].autoRestore(()=>{if(this["#"].slottedElements.forEach(c=>{let u=v(c).get("original@imports");a.has(u)?a.delete(u):(this["#"].slottedElements.delete(c),c.remove())}),a.size&&this.el.isConnected){let c=this["#"].setAnchorNode(this.createAnchorNode());this.state="resolved",this.el.replaceWith(c)}a.forEach(c=>{let u=c.cloneNode(!0);u.hasAttribute(r.HTML_IMPORTS.attr.fragmentdef)||u.toggleAttribute(r.HTML_IMPORTS.attr.fragmentdef,!0),v(u).set("original@imports",c),v(u).set("slot@imports",this.el),this["#"].slottedElements.add(u),this["#"].anchorNode.before(u)})}))}empty(){this["#"].slottedElements.forEach(a=>a.remove())}get anchorNode(){return this["#"].anchorNode}get moduleRef(){return this["#"].moduleRef}get slottedElements(){return this["#"].slottedElements}}return r.HTML_IMPORTS.elements.import.includes("-")&&customElements.define(r.HTML_IMPORTS.elements.import,o),t.HTMLImportElement=o,o}function Ke(n={}){let{config:t,window:e}=B.call(this,"html-imports",n,{elements:{import:"import"},attr:{def:"def",extends:"extends",inherits:"inherits",ref:"ref",importscontext:"importscontext"},api:{def:"def",defs:"defs",import:"import"}});t.attr.fragmentdef||(t.attr.fragmentdef=t.attr.def),t.templateSelector=`template[${e.CSS.escape(t.attr.def)}]`,t.importsContextSelector=`[${e.CSS.escape(t.attr.importscontext)}]`,t.slottedElementsSelector=`[${e.CSS.escape(t.attr.fragmentdef)}]:not(template)`;let r=(i,o)=>{let s=`starts-with(., "${i}")`,a=`substring(., string-length(.) - string-length("${o}") + 1) = "${o}"`;return`${s} and ${a}`};t.anchorNodeSelector=`comment()[${r(`<${t.elements.import}`,`</${t.elements.import}>`)}]`,e.webqit.HTMLImportsContext=at,e.webqit.HTMLImportElement=Fr(),Wn.call(e,t),Vn.call(e,t)}function st(n,t=!0){if(!v(n).has("defs")&&t){let e=Object.create(null);v(n).set("defs",e)}return v(n).get("defs")}function Wn(n){let t=this,{webqit:{oohtml:{configs:e}}}=t;if(n.api.def in t.HTMLTemplateElement.prototype)throw new Error(`The "HTMLTemplateElement" prototype already has a "${n.api.def}" API!`);if(n.api.defs in t.HTMLTemplateElement.prototype)throw new Error(`The "HTMLTemplateElement" prototype already has a "${n.api.defs}" API!`);Object.defineProperty(t.HTMLTemplateElement.prototype,n.api.def,{get:function(){return this.getAttribute(n.attr.def)}}),Object.defineProperty(t.HTMLTemplateElement.prototype,n.api.defs,{get:function(){return st(this)}}),Object.defineProperty(t.HTMLTemplateElement.prototype,"scoped",{configurable:!0,get(){return this.hasAttribute("scoped")},set(i){this.toggleAttribute("scoped",i)}}),[t.Document.prototype,t.Element.prototype,t.ShadowRoot.prototype].forEach(i=>{let o=i===t.Document.prototype?"Document":i===t.ShadowRoot.prototype?"ShadowRoot":"Element";if(n.api.import in i)throw new Error(`The ${o} prototype already has a "${n.api.import}" API!`);Object.defineProperty(i,n.api.import,{value:function(s,a=!1,l=null){return r(this,...arguments)}})});function r(i,o,s=!1,a=null){let l={};typeof s=="function"?(a=s,s=!1):typeof s=="object"&&s?l={...s,...l}:l={live:s};let c={...at.createRequest(o),...l};return i[e.CONTEXT_API.api.contexts].request(c,a)}}function Vn(n){let t=this,{webqit:{Observer:e,realdom:r,oohtml:{configs:i},HTMLImportElement:o,HTMLImportsContext:s}}=t,a=u=>{let f=u[i.CONTEXT_API.api.contexts];f.find(s.kind)||f.attach(new s)},l=u=>{let f=u[i.CONTEXT_API.api.contexts],d=f.find(s.kind);d&&(!u.isConnected||!u.matches?.(n.importsContextSelector)&&!Object.keys(d.localModules).length)&&f.detach(d)};r.realtime(t.document).query([n.templateSelector,n.importsContextSelector],u=>{u.entrants.forEach(f=>{if(f.matches(n.templateSelector)){let d=K.instance(f);d.ownerContext=f.scoped?f.parentNode:f.getRootNode();let p=st(d.ownerContext);d.defId&&e.set(p,d.defId,f),a(d.ownerContext)}else a(f)}),u.exits.forEach(f=>{if(f.matches(n.templateSelector)){let d=K.instance(f),p=st(d.ownerContext);d.defId&&d.ownerContext.isConnected&&e.deleteProperty(p,d.defId),l(d.ownerContext)}else l(f)})},{id:"imports:template/importscontext",live:!0,subtree:"cross-roots",timing:"sync",staticSensitivity:!0,eventDetails:!0}),r.realtime(t.document).query(n.elements.import,u=>{u.entrants.forEach(f=>c(f,!0,u)),u.exits.forEach(f=>c(f,!1,u))},{id:"imports:import",live:!0,subtree:"cross-roots",timing:"sync",deferred:!0});function c(u,f){let d=o.instance(u);f?d["#"].connectedCallback():d["#"].disconnectedCallback()}t.webqit.env!=="server"&&r.realtime(t.document).query(`(${n.anchorNodeSelector})`,u=>{u.entrants.forEach(f=>{if(v(f).get("isAnchorNode"))return;let d=t.document.createElement("div");d.innerHTML=f.nodeValue,d.innerHTML=d.firstChild.textContent;let p=d.firstChild,g=parseInt(p.getAttribute("data-nodecount")),_=new Set,A=f;for(;(A=A.previousElementSibling)&&A.matches(n.slottedElementsSelector)&&g--;)_.add(A);o.instance(p)["#"].hydrate(f,_)})},{id:"imports:hydration",live:!0,subtree:"cross-roots",timing:"sync"})}function tr(n={}){let{config:t,window:e}=B.call(this,"context-api",n,{attr:{contextname:"contextname"},api:{contexts:"contexts"}});e.webqit.DOMContexts=ut,e.webqit.DOMContext=U,e.webqit.DOMContextRequestEvent=he(),e.webqit.DOMContextResponse=vt,e.webqit.DuplicateContextError=Ot,Bn.call(e,t)}function Bn(n){let t=this;[t.Document.prototype,t.Element.prototype,t.ShadowRoot.prototype].forEach(e=>{let r=e===t.Document.prototype?"Document":e===t.ShadowRoot.prototype?"ShadowRoot":"Element";if(n.api.contexts in e)throw new Error(`The ${r} prototype already has a "${n.api.contexts}" API!`);Object.defineProperty(e,n.api.contexts,{get:function(){return ut.instance(this)}})})}function rr({advanced:n={},...t}){let{config:e,window:r}=B.call(this,"scoped-css",t,{api:{styleSheets:"styleSheets"},style:{retention:"retain",mimeTypes:"text/css",strategy:null}});e.styleSelector=(Array.isArray(e.style.mimeTypes)?e.style.mimeTypes:e.style.mimeTypes.split("|")).concat("").reduce((i,o)=>{let s=o?`[type="${r.CSS.escape(o)}"]`:":not([type])";return i.concat(`style${s}`)},[]).join(","),r.webqit.oohtml.Style={compileCache:new Map},Un.call(r,e),zn.call(r,e)}function Un(n){let t=this,e=new Map;[t.Element.prototype].forEach(r=>{let i="Element";if(n.api.styleSheets in r)throw new Error(`The ${i} prototype already has a "${n.api.styleSheets}" API!`);Object.defineProperty(r,n.api.styleSheets,{get:function(){return e.has(this)||e.set(this,[]),e.get(this)}})}),Object.defineProperty(t.HTMLStyleElement.prototype,"scoped",{configurable:!0,get(){return this.hasAttribute("scoped")},set(r){this.toggleAttribute("scoped",r)}})}function zn(n){let t=this,{webqit:{oohtml:e,realdom:r}}=t,i=Object.getOwnPropertyDescriptor(globalThis,"window")?.get?.toString().includes("[native code]")??!1;t.CSS.supports||(t.CSS.supports=()=>!1);let o=new WeakSet;r.realtime(t.document).query(n.styleSelector,s=>{s.entrants.forEach(a=>{if(o.has(a))return;o.add(a);let l=_t(a.textContent),c=CSS.supports("selector(:has(a,b))"),u=a.scoped&&(c?`:has(> style[rand-${l}])`:`[rand-${l}]`),f=a.scoped&&t.CSSScopeRule&&!1,d=a.scoped&&a.parentNode||a.getRootNode();if(d instanceof t.Element){if(d[n.api.styleSheets].push(a),!i)return;(c?a:d).toggleAttribute(`rand-${l}`,!0)}if(!!i)if(a.scoped&&a.hasAttribute("shared")){let p;(p=e.Style.compileCache.get(l))||(p=Gn.call(t,a,null,f,u),e.Style.compileCache.set(l,p)),Object.defineProperty(a,"sheet",{value:p,configurable:!0}),a.textContent=`
|
|
54
|
+
`),{webqit:{QuantumModule:o}}=this,s=new o(i);return Je.set(t,s),s}var jt=n=>n.replace(/"/g,'\\"');function Lr(n){let t=this,{webqit:{oohtml:{configs:{DATA_BINDING:e}}}}=t;(n?.matches(e.attrSelector)?[n]:[]).concat([...n?.querySelectorAll(e.attrSelector)||[]]).forEach(r=>{Dr.call(t,e,r.getAttribute(e.attr.render))}),Tt(t,n,`(${e.discreteBindingsSelector})`).forEach(r=>{let i=kr(e,r.nodeValue);Nr.call(t,e,i.expr)})}var ot=class extends U{static createRequest(t=null){let e=super.createRequest();if(t?.startsWith("@")){let[r,...i]=i.slice(1).split(".").map(o=>o.trim());e.targetContext=r,e.detail=i.join(".")}else e.detail=t;return e}get bindingsObj(){return this.host[this.configs.BINDINGS_API.api.bindings]}matchEvent(t){return super.matchEvent(t)&&(!t.detail||!this.detail||(Array.isArray(t.detail)?t.detail[0]===this.detail:t.detail===this.detail))}handle(t){if(t.meta.controller?.abort(),!(t.detail+"").trim())return t.respondWith(this.bindingsObj);let{window:{webqit:{Observer:e}}}=R;t.meta.controller=e.reduce(this.bindingsObj,Array.isArray(t.detail)?t.detail:[t.detail],e.get,r=>{this.disposed||t.respondWith(r.value)},{live:t.live,signal:t.signal,descripted:!0})}unsubscribed(t){t.meta.controller?.abort()}};F(ot,"kind","bindings");function Ze(n={}){let{config:t,window:e}=B.call(this,"bindings-api",n,{attr:{bindingsreflection:"bindings"},api:{bind:"bind",bindings:"bindings"}});e.webqit.DOMBindingsContext=ot,Hn.call(e,t)}function Hr(n,t){let e=this,{webqit:{Observer:r,oohtml:{configs:{CONTEXT_API:i}}}}=e;if(!v(t).has("bindings")){let o=Object.create(null);v(t).set("bindings",o),r.observe(o,s=>{let a=Object.keys(o),l=t instanceof e.Document?t.documentElement:t,c=n.attr.bindingsreflection;a.length&&c&&l.setAttribute?l.setAttribute(n.attr.bindingsreflection,a.join(" ")):c&&l.setAttribute&&l.toggleAttribute(n.attr.bindingsreflection,!1);let u=t[i.api.contexts];for(let f of s)if(f.type==="delete"){let d=u.find(ot.kind,f.key);d&&u.detach(d)}else u.find(ot.kind,f.key)||u.attach(new ot(f.key))})}return v(t).get("bindings")}function Hn(n){let t=this,{webqit:{Observer:e}}=t;[t.Document.prototype,t.Element.prototype,t.ShadowRoot.prototype].forEach(r=>{let i=r===t.Document.prototype?"Document":r===t.ShadowRoot.prototype?"ShadowRoot":"Element";if(n.api.bind in r)throw new Error(`The ${i} prototype already has a "${n.api.bind}" API!`);if(n.api.bindings in r)throw new Error(`The ${i} prototype already has a "${n.api.bindings}" API!`);Object.defineProperty(r,n.api.bind,{value:function(o,s={}){return Fn.call(t,n,this,o,s)}}),Object.defineProperty(r,n.api.bindings,{get:function(){return e.proxy(Hr.call(t,n,this))}})})}function Fn(n,t,e,{merge:r,diff:i,namespace:o}={}){let s=this,{webqit:{Observer:a}}=s,l=Hr.call(this,n,t),c={diff:i,namespace:o},u=r?[]:a.ownKeys(l,c).filter(f=>!(f in e));return a.batch(l,()=>(u.length&&a.deleteProperties(l,u,c),a.set(l,e,c)),c)}var K=class{static instance(t){return v(t).get("defsmanager::instance")||new this(t)}constructor(t,e=null,r=0){let{window:i}=R,{webqit:{realdom:o,oohtml:{configs:s}}}=i;v(t).get("defsmanager::instance")?.dispose(),v(t).set("defsmanager::instance",this),this.window=i,this.host=t,this.config=s.HTML_IMPORTS,this.parent=e,this.level=r,this.defs=st(this.host),this.defId=(this.host.getAttribute(this.config.attr.def)||"").trim(),this.validateDefId(this.defId),this.realtimeA=o.realtime(this.host.content).children(a=>{this.expose(a.entrants,!0),this.expose(a.exits,!1)},{live:!0,timing:"sync"}),this.realtimeB=o.realtime(this.host).attr(["src","loading"],(...a)=>this.evaluateLoading(...a),{live:!0,atomic:!0,timing:"sync",lifecycleSignals:!0}),this.realtimeC=this.evalInheritance()}validateDefId(t){if(["@","/","*","#"].some(e=>t.includes(e)))throw new Error(`The export ID "${t}" contains an invalid character.`)}expose(t,e){let{window:r}=R,{webqit:{Observer:i}}=r,o,s=this.defs["#"]||[];t.forEach(a=>{if(a.nodeType!==1)return;let l=a.matches(this.config.templateSelector),c=(a.getAttribute(l?this.config.attr.def:this.config.attr.fragmentdef)||"").trim();e?(l&&c?new K(a,this.host,this.level+1):(s.push(a),o=!0,typeof requestIdleCallback=="function"&&requestIdleCallback(()=>{this.config.idleCompilers?.forEach(u=>u.call(this.window,a))})),c&&(this.validateDefId(c),i.set(this.defs,(!l&&"#"||"")+c,a))):(l&&c?K.instance(a).dispose():(s=s.filter(u=>u!==a),o=!0),c&&i.deleteProperty(this.defs,(!l&&"#"||"")+c))}),o&&i.set(this.defs,"#",s)}evaluateLoading([t,e],{signal:r}){let{window:{webqit:{Observer:i}}}=R,o=(t.value||"").trim();if(!o)return;let s,a=u=>{if(!u)return s;s=u.then(()=>c.remove())},l=(e.value||"").trim(),c=i.intercept(this.defs,"get",async(u,f,d)=>(l==="lazy"&&a(this.load(o,!0)),await a(),d()),{signal:r});l!=="lazy"&&a(this.load(o))}load(t){let{window:e}=R;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,i=(s,a)=>this.host.dispatchEvent(new e.CustomEvent(s,{detail:a})),o=e.fetch(t,{signal:r.signal,element:this.host}).then(s=>s.ok?s.text():Promise.reject(s.statusText)).then(s=>(this.host.innerHTML=s.trim(),i("load"),this.host)).catch(s=>(console.error(`Error fetching the bundle at "${t}": ${s.message}`),this.fetchInFlight=null,i("loaderror"),this.host));return this.fetchInFlight={src:t,request:o,controller:r},o}evalInheritance(){if(!this.parent)return[];let{window:{webqit:{Observer:t}}}=R,e=(this.host.getAttribute(this.config.attr.extends)||"").trim(),r=(this.host.getAttribute(this.config.attr.inherits)||"").trim(),i=a=>{a.forEach(l=>{t.get(this.defs,l.key)===l.oldValue&&(["get","set","def"].includes(l.type)?t[l.type.replace("get","set")](this.defs,l.key,l.value):l.type==="delete"&&t.deleteProperty(this.defs,l.key))})},o=[],s=st(this.parent);return e&&o.push(t.reduce(s,[e,this.config.api.defs,1/0],t.get,i,{live:!0})),(r=r.split(" ").map(a=>a.trim()).filter(a=>a)).length&&o.push(t.get(s,r,i,{live:!0})),o}dispose(){this.realtimeA.disconnect(),this.realtimeB.disconnect(),this.realtimeC.forEach(t=>t instanceof Promise?t.then(e=>e.abort()):t.abort()),Object.entries(this.defs).forEach(([t,e])=>{t.startsWith("#")||K.instance(e).dispose()})}};var at=class extends U{static createRequest(t=null){let e=super.createRequest();if(t?.startsWith("/"))e.detail=t,e.targetContext=1/0;else if(t?.startsWith("@")){let[r,...i]=i.slice(1).split(/(?<=\w)(?=\/|#)/).map(o=>o.trim());e.targetContext=r,e.detail=i.join("")}else e.detail=t;return e}get localModules(){return st(this.host)}handle(t){let{window:{webqit:{Observer:e}}}=R;if(t.meta.controller?.abort(),(t.detail||"").trim()==="/")return t.respondWith(this.localModules);let r=(t.detail||"").split(/\/|(?<=\w)(?=#)/g).map(o=>o.trim()).filter(o=>o);if(!r.length)return t.respondWith();r=r.join(`/${this.configs.HTML_IMPORTS.api.defs}/`)?.split("/")||[];let i={live:t.live,signal:t.signal,descripted:!0};t.meta.controller=e.reduce(this.localModules,r,e.get,(o,{signal:s}={})=>{let a=Array.isArray(o)?o:o.value,l=Array.isArray(o)?o.length:o.value;if(!(!l&&this.host.isConnected===!1))return l||!this.contextModules?(t._isValidLocalResult=l,t.respondWith(a)):e.reduce(this.contextModules,r,e.get,c=>(t._currentSource="context",t.respondWith(Array.isArray(c)?c:c.value)),{...i,signal:s})},{lifecycleSignals:!0,...i})}unsubscribed(t){t.meta.controller?.abort()}realtimeSources(t){this.host=t;let e=()=>{for(let s of this.subscriptions)s._isValidLocalResult||this.handle(s)},r=this.configs.HTML_IMPORTS;if(!this.host.matches||!r.attr.importscontext)return;this.refdSourceController?.disconnect();let i=this.host.ownerDocument.defaultView.webqit.realdom,o;this.refdSourceController=i.realtime(this.host).attr(r.attr.importscontext,(s,{signal:a})=>{if(s.value===o)return;if(o=s.value,!s.value)return this.contextModules=void 0,e();let l={...this.constructor.createRequest(s.value.trim()),live:!0,signal:a,diff:!0};this.host.parentNode[this.configs.CONTEXT_API.api.contexts].request(l,c=>{this.contextModules=c&&Object.getPrototypeOf(c)?st(c):c,e()})},{live:!0,timing:"sync",lifecycleSignals:!0})}initialize(t){return this.realtimeSources(t),super.initialize(t)}dispose(t){return this.refdSourceController?.disconnect(),super.dispose(t)}};F(at,"kind","html-imports");function Fr(){let{window:n}=R,{webqit:t}=n,{realdom:e,oohtml:{configs:r}}=t;if(t.HTMLImportElement)return t.HTMLImportElement;let i=r.HTML_IMPORTS.elements.import.includes("-")?n.HTMLElement:class{};class o extends i{static instance(a){return r.HTML_IMPORTS.elements.import.includes("-")&&a instanceof this?a:v(a).get("import::instance")||new this(a)}constructor(...a){super();let l=a[0]||this;v(l).set("import::instance",this),Object.defineProperty(this,"el",{get:()=>l,configurable:!1});let c={};Object.defineProperty(this,"#",{get:()=>c,configurable:!1}),c.slottedElements=new Set,c.setAnchorNode=u=>(c.anchorNode=u,u),c.live=u=>{if(c.liveImportsRealtime)throw new Error("Import element already in live mode.");let f=this.el.isConnected?this.el.parentNode:c.anchorNode.parentNode;c.liveImportsRealtime=e.realtime(this.el).attr(r.HTML_IMPORTS.attr.ref,(d,{signal:p})=>{c.moduleRef=d.value;let g=c.moduleRef.includes("#")?c.moduleRef:`${c.moduleRef}#`,_={...at.createRequest(g),live:p&&!0,signal:p,diff:!g.endsWith("#")};f[r.CONTEXT_API.api.contexts].request(_,A=>{u((A instanceof n.HTMLTemplateElement?[...A.content.children]:Array.isArray(A)?A:A&&[A])||[])})},{live:!0,timing:"sync",lifecycleSignals:!0}),c.autoDestroyRealtime=e.realtime(n.document).track(f,()=>{c.die()},{subtree:"cross-roots",timing:"sync",generation:"exits"})},c.die=()=>{c.autoDestroyRealtime?.disconnect(),c.liveImportsRealtime?.disconnect(),c.liveImportsRealtime=null},c.hydrate=(u,f)=>{u.replaceWith(c.setAnchorNode(this.createAnchorNode())),c.live(d=>{if(c.originalsRemapped)return this.fill(d);let p=d.map((g,_)=>({el:g,fragmentDef:g.getAttribute(r.HTML_IMPORTS.attr.fragmentdef)||"",tagName:g.tagName,i:_}));f.forEach((g,_)=>{let A=g.tagName,m=g.getAttribute(r.HTML_IMPORTS.attr.fragmentdef)||"",y=(_++,p.find(O=>O.tagName===A&&O.fragmentDef===m&&O.i===_));y&&v(g).set("original@imports",y.el),v(g).set("slot@imports",this.el),c.slottedElements.add(g)}),c.originalsRemapped=!0})},c.autoRestore=(u=null)=>{c.autoRestoreRealtime?.disconnect(),u&&u();let f=()=>{this.el.isConnected||(this.el.setAttribute("data-nodecount",0),c.internalMutation=!0,c.anchorNode.replaceWith(this.el),c.internalMutation=!1,c.setAnchorNode(null))};if(!c.slottedElements.size)return f();let d=e.realtime(c.anchorNode.parentNode).observe([...c.slottedElements],p=>{if(p.exits.forEach(g=>{v(g).delete("slot@imports"),c.slottedElements.delete(g)}),!c.slottedElements.size){if(d.disconnect(),!p.target.isConnected)return;f()}},{subtree:"cross-roots",timing:"sync",generation:"exits"});c.autoRestoreRealtime=d},c.connectedCallback=()=>{c.internalMutation||c.live(u=>this.fill(u))},c.disconnectedCallback=()=>{c.internalMutation||c.die()}}createAnchorNode(){if(n.webqit.env!=="server")return n.document.createTextNode("");let a=n.document.createElement("div");a.textContent=this.el.outerHTML;let l=n.document.createComment(a.innerHTML);return v(l).set("isAnchorNode",!0),l}fill(a,l){!this.el.isConnected&&(!this["#"].anchorNode||!this["#"].anchorNode.isConnected)||(Array.isArray(a)&&(a=new Set(a)),this.el.setAttribute("data-nodecount",a.size),this["#"].autoRestore(()=>{if(this["#"].slottedElements.forEach(c=>{let u=v(c).get("original@imports");a.has(u)?a.delete(u):(this["#"].slottedElements.delete(c),c.remove())}),a.size&&this.el.isConnected){let c=this["#"].setAnchorNode(this.createAnchorNode());this["#"].internalMutation=!0,this.el.replaceWith(c),this["#"].internalMutation=!1}a.forEach(c=>{let u=c.cloneNode(!0);u.hasAttribute(r.HTML_IMPORTS.attr.fragmentdef)||u.toggleAttribute(r.HTML_IMPORTS.attr.fragmentdef,!0),v(u).set("original@imports",c),v(u).set("slot@imports",this.el),this["#"].slottedElements.add(u),this["#"].anchorNode.before(u)})}))}empty(){this["#"].slottedElements.forEach(a=>a.remove())}get anchorNode(){return this["#"].anchorNode}get moduleRef(){return this["#"].moduleRef}get slottedElements(){return this["#"].slottedElements}}return r.HTML_IMPORTS.elements.import.includes("-")&&customElements.define(r.HTML_IMPORTS.elements.import,o),t.HTMLImportElement=o,o}function Ke(n={}){let{config:t,window:e}=B.call(this,"html-imports",n,{elements:{import:"import"},attr:{def:"def",extends:"extends",inherits:"inherits",ref:"ref",importscontext:"importscontext"},api:{def:"def",defs:"defs",import:"import"}});t.attr.fragmentdef||(t.attr.fragmentdef=t.attr.def),t.templateSelector=`template[${e.CSS.escape(t.attr.def)}]`,t.importsContextSelector=`[${e.CSS.escape(t.attr.importscontext)}]`,t.slottedElementsSelector=`[${e.CSS.escape(t.attr.fragmentdef)}]:not(template)`;let r=(i,o)=>{let s=`starts-with(., "${i}")`,a=`substring(., string-length(.) - string-length("${o}") + 1) = "${o}"`;return`${s} and ${a}`};t.anchorNodeSelector=`comment()[${r(`<${t.elements.import}`,`</${t.elements.import}>`)}]`,e.webqit.HTMLImportsContext=at,e.webqit.HTMLImportElement=Fr(),Wn.call(e,t),Vn.call(e,t)}function st(n,t=!0){if(!v(n).has("defs")&&t){let e=Object.create(null);v(n).set("defs",e)}return v(n).get("defs")}function Wn(n){let t=this,{webqit:{oohtml:{configs:e}}}=t;if(n.api.def in t.HTMLTemplateElement.prototype)throw new Error(`The "HTMLTemplateElement" prototype already has a "${n.api.def}" API!`);if(n.api.defs in t.HTMLTemplateElement.prototype)throw new Error(`The "HTMLTemplateElement" prototype already has a "${n.api.defs}" API!`);Object.defineProperty(t.HTMLTemplateElement.prototype,n.api.def,{get:function(){return this.getAttribute(n.attr.def)}}),Object.defineProperty(t.HTMLTemplateElement.prototype,n.api.defs,{get:function(){return st(this)}}),Object.defineProperty(t.HTMLTemplateElement.prototype,"scoped",{configurable:!0,get(){return this.hasAttribute("scoped")},set(i){this.toggleAttribute("scoped",i)}}),[t.Document.prototype,t.Element.prototype,t.ShadowRoot.prototype].forEach(i=>{let o=i===t.Document.prototype?"Document":i===t.ShadowRoot.prototype?"ShadowRoot":"Element";if(n.api.import in i)throw new Error(`The ${o} prototype already has a "${n.api.import}" API!`);Object.defineProperty(i,n.api.import,{value:function(s,a=!1,l=null){return r(this,...arguments)}})});function r(i,o,s=!1,a=null){let l={};typeof s=="function"?(a=s,s=!1):typeof s=="object"&&s?l={...s,...l}:l={live:s};let c={...at.createRequest(o),...l};return i[e.CONTEXT_API.api.contexts].request(c,a)}}function Vn(n){let t=this,{webqit:{Observer:e,realdom:r,oohtml:{configs:i},HTMLImportElement:o,HTMLImportsContext:s}}=t,a=u=>{let f=u[i.CONTEXT_API.api.contexts];f.find(s.kind)||f.attach(new s)},l=u=>{let f=u[i.CONTEXT_API.api.contexts],d=f.find(s.kind);d&&(!u.isConnected||!u.matches?.(n.importsContextSelector)&&!Object.keys(d.localModules).length)&&f.detach(d)};r.realtime(t.document).query([n.templateSelector,n.importsContextSelector],u=>{u.entrants.forEach(f=>{if(f.matches(n.templateSelector)){let d=K.instance(f);d.ownerContext=f.scoped?f.parentNode:f.getRootNode();let p=st(d.ownerContext);d.defId&&e.set(p,d.defId,f),a(d.ownerContext)}else a(f)}),u.exits.forEach(f=>{if(f.matches(n.templateSelector)){let d=K.instance(f),p=st(d.ownerContext);d.defId&&d.ownerContext.isConnected&&e.deleteProperty(p,d.defId),l(d.ownerContext)}else l(f)})},{id:"imports:template/importscontext",live:!0,subtree:"cross-roots",timing:"sync",staticSensitivity:!0,eventDetails:!0}),r.realtime(t.document).query(n.elements.import,u=>{u.entrants.forEach(f=>c(f,!0,u)),u.exits.forEach(f=>c(f,!1,u))},{id:"imports:import",live:!0,subtree:"cross-roots",timing:"sync",deferred:!0});function c(u,f){let d=o.instance(u);f?d["#"].connectedCallback():d["#"].disconnectedCallback()}t.webqit.env!=="server"&&r.realtime(t.document).query(`(${n.anchorNodeSelector})`,u=>{u.entrants.forEach(f=>{if(v(f).get("isAnchorNode"))return;let d=t.document.createElement("div");d.innerHTML=f.nodeValue,d.innerHTML=d.firstChild.textContent;let p=d.firstChild,g=parseInt(p.getAttribute("data-nodecount")),_=new Set,A=f;for(;(A=A.previousElementSibling)&&A.matches(n.slottedElementsSelector)&&g--;)_.add(A);o.instance(p)["#"].hydrate(f,_)})},{id:"imports:hydration",live:!0,subtree:"cross-roots",timing:"sync"})}function tr(n={}){let{config:t,window:e}=B.call(this,"context-api",n,{attr:{contextname:"contextname"},api:{contexts:"contexts"}});e.webqit.DOMContexts=ut,e.webqit.DOMContext=U,e.webqit.DOMContextRequestEvent=he(),e.webqit.DOMContextResponse=vt,e.webqit.DuplicateContextError=Ot,Bn.call(e,t)}function Bn(n){let t=this;[t.Document.prototype,t.Element.prototype,t.ShadowRoot.prototype].forEach(e=>{let r=e===t.Document.prototype?"Document":e===t.ShadowRoot.prototype?"ShadowRoot":"Element";if(n.api.contexts in e)throw new Error(`The ${r} prototype already has a "${n.api.contexts}" API!`);Object.defineProperty(e,n.api.contexts,{get:function(){return ut.instance(this)}})})}function rr({advanced:n={},...t}){let{config:e,window:r}=B.call(this,"scoped-css",t,{api:{styleSheets:"styleSheets"},style:{retention:"retain",mimeTypes:"text/css",strategy:null}});e.styleSelector=(Array.isArray(e.style.mimeTypes)?e.style.mimeTypes:e.style.mimeTypes.split("|")).concat("").reduce((i,o)=>{let s=o?`[type="${r.CSS.escape(o)}"]`:":not([type])";return i.concat(`style${s}`)},[]).join(","),r.webqit.oohtml.Style={compileCache:new Map},Un.call(r,e),zn.call(r,e)}function Un(n){let t=this,e=new Map;[t.Element.prototype].forEach(r=>{let i="Element";if(n.api.styleSheets in r)throw new Error(`The ${i} prototype already has a "${n.api.styleSheets}" API!`);Object.defineProperty(r,n.api.styleSheets,{get:function(){return e.has(this)||e.set(this,[]),e.get(this)}})}),Object.defineProperty(t.HTMLStyleElement.prototype,"scoped",{configurable:!0,get(){return this.hasAttribute("scoped")},set(r){this.toggleAttribute("scoped",r)}})}function zn(n){let t=this,{webqit:{oohtml:e,realdom:r}}=t,i=Object.getOwnPropertyDescriptor(globalThis,"window")?.get?.toString().includes("[native code]")??!1;t.CSS.supports||(t.CSS.supports=()=>!1);let o=new WeakSet;r.realtime(t.document).query(n.styleSelector,s=>{s.entrants.forEach(a=>{if(o.has(a))return;o.add(a);let l=_t(a.textContent),c=CSS.supports("selector(:has(a,b))"),u=a.scoped&&(c?`:has(> style[rand-${l}])`:`[rand-${l}]`),f=a.scoped&&t.CSSScopeRule&&!1,d=a.scoped&&a.parentNode||a.getRootNode();if(d instanceof t.Element){if(d[n.api.styleSheets].push(a),!i)return;(c?a:d).toggleAttribute(`rand-${l}`,!0)}if(!!i)if(a.scoped&&a.hasAttribute("shared")){let p;(p=e.Style.compileCache.get(l))||(p=Gn.call(t,a,null,f,u),e.Style.compileCache.set(l,p)),Object.defineProperty(a,"sheet",{value:p,configurable:!0}),a.textContent=`
|
|
55
55
|
/*[ Shared style sheet ]*/
|
|
56
56
|
`}else{let p=()=>{let g=ye(qt.call(t,d));er.call(this,a.sheet,g,!f&&u)};a.isConnected?p():setTimeout(()=>{p()},0)}})},{id:"scoped-css",live:!0,subtree:"cross-roots",timing:"intercept",generation:"entrants"})}function Gn(n,t,e,r){let i=this,o=n.textContent,s,a=e&&r?`@scope (${r}) {
|
|
57
57
|
${o.trim()}
|