@webqit/oohtml 2.1.6 → 2.1.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.
@@ -1,2 +1,2 @@
1
- (()=>{function x(r){return!Array.isArray(r)&&typeof r=="object"&&r}function L(r,...t){globalThis.WebQitInternalsRegistry||(globalThis.WebQitInternalsRegistry=new Map);var n=globalThis.WebQitInternalsRegistry.get(r);if(!n){if(n=new Map,t[0]===!1)return n;globalThis.WebQitInternalsRegistry.set(r,n)}for(var e,i;e=t.shift();)if((i=n)&&!(n=n.get(e))){if(n=new Map,t[0]===!1)return n;i.set(e,n)}return n}function g(r){return Array.isArray(r)}function R(r){return typeof r=="function"}function D(r){return r===null||r===""}function S(r){return arguments.length&&(r===void 0||typeof r>"u")}function O(r){return Array.isArray(r)||typeof r=="object"&&r||R(r)}function J(r){return D(r)||S(r)||r===!1||r===0||O(r)&&!Object.keys(r).length}function w(r){return R(r)||r&&{}.toString.call(r)==="[object function]"}function N(r){return r instanceof Number||typeof r=="number"}function E(r){return N(r)||r!==!0&&r!==!1&&r!==null&&r!==""&&!isNaN(r*1)}function W(r){return r instanceof String||typeof r=="string"&&r!==null}function Q(r){return!W(r)&&!S(r.length)}function B(r,...t){return t.forEach(n=>{r.indexOf(n)<0&&r.push(n)}),r}function X(e,t){t=t||Object.prototype,t=t&&!g(t)?[t]:t;for(var n=[],e=e;e&&(!t||t.indexOf(e)<0)&&e.name!=="default";)n.push(e),e=e?Object.getPrototypeOf(e):null;return n}function Y(r,t){var n=[];return X(r,t).forEach(e=>{B(n,...Object.getOwnPropertyNames(e))}),n}function T(r,t,n=!1,e=!1,i=!1){var o=0,s=r.shift();if((E(s)||s===!0||s===!1)&&(o=s,s=r.shift()),!r.length)throw new Error("_merge() requires two or more array/objects.");return r.forEach((l,m)=>{!O(l)&&!w(l)||(n?Y(l):Object.keys(l)).forEach(u=>{if(!!t(u,s,l,m)){var f=s[u],c=l[u];if((g(f)&&g(c)||x(f)&&x(c))&&(o===!0||o>0))s[u]=g(f)&&g(c)?[]:{},T([E(o)?o-1:o,s[u],f,c],t,n,e,i);else if(g(s)&&g(l))e?s[u]=c:s.push(c);else try{i?Object.defineProperty(s,u,Object.getOwnPropertyDescriptor(l,u)):s[u]=l[u]}catch{}}})}),s}function k(...r){return T(r,(t,n,e)=>!0,!1,!1,!1)}function b(r,t=!0){return g(r)?r:!t&&x(r)?[r]:r!==!1&&r!==0&&J(r)?[]:Q(r)?Array.prototype.slice.call(r):x(r)?Object.values(r):[r]}function P(r,t,n={},e={}){t=b(t).slice();for(var i=r;!S(i)&&!D(i)&&t.length;){var o=t.shift();if(!(n.get?n.get(i,o):O(i)?o in i:i[o])){e.exists=!1;return}i=n.get?n.get(i,o):i[o]}return e.exists=!0,i}function K(r,t,n,e={},i={}){let o=(f,c,d)=>i.set?i.set(f,c,d):(E(t[l])&&g(f)?f.push(d):f[c]=d,!0);t=b(t);for(var s=r,l=0;l<t.length;l++)if(l<t.length-1){if(!s||!O(s)&&!w(s))return!1;var m=P(s,t[l],i);if(!O(m)){if(i.buildTree===!1)return!1;m=w(i.buildTree)?i.buildTree(l):E(t[l+1])?[]:{};var u=o(s,t[l],m);if(!u)return!1}s=m}else return o(s,t[l],n)}var ft=r=>class{constructor(n=!0){Object.defineProperty(this,"window",{value:r}),Object.defineProperty(this,"readCallbacks",{value:new Set}),Object.defineProperty(this,"writeCallbacks",{value:new Set}),this.async=n,this.window.requestAnimationFrame?this._run():this.async=!1}_run(){this.window.requestAnimationFrame(()=>{this.readCallbacks.forEach(n=>{n()||this.readCallbacks.delete(n)}),this.writeCallbacks.forEach(n=>{n()||this.writeCallbacks.delete(n)}),this._run()})}onread(n,e=!1){if(e)return new Promise((i,o)=>{this.async===!1?n(i,o):this.readCallbacks.add(()=>{n(i,o)})});this.async===!1?n():this.readCallbacks.add(n)}onwrite(n,e=!1){if(e)return new Promise((i,o)=>{this.async===!1?n(i,o):this.writeCallbacks.add(()=>{n(i,o)})});this.async===!1?n():this.writeCallbacks.add(n)}cycle(n,e,i){this.onread(()=>{let o=n(i),s=l=>{l!==void 0&&this.onwrite(()=>{let m=e(l,i),u=f=>{f!==void 0&&this.cycle(n,e,f)};m instanceof Promise?m.then(u):u(m)})};o instanceof Promise?o.then(s):s(o)})}};var H=class{constructor(t,n,e){this.context=t,this.namespace=n,this.window=t.defaultView||t.ownerDocument?.defaultView||e,this.document=this.window.document,this.wq=this.window.wq,Object.defineProperty(this,"#",{value:{}})}resolveArgs(t){return w(t[0])?t=[[],...t]:x(t[0])&&t.length===1?t=[[],void 0,t[0]]:x(t[1])&&t.length===2?t=[b(t[0],!1),void 0,t[1]]:t[0]=b(t[0],!1),t}registry(...t){return L(this.window,"dom.realtime",this.namespace,...t)}createSignalGenerator(){return{generate(){return this.lastController?.abort(),this.lastController=new AbortController,{signal:this.lastController.signal}},disconnect(){this.lastController?.abort()}}}forEachMatchingContext(t,n,e){let{window:i}=this,o=Array.isArray(n)?n:[n],s=new Set;for(let[l,m]of this.registry(t))for(let[u,f]of m){let c=o.filter(d=>u.contains(d.target)?l==="subtree"||d.target===u:!1);if(!!c.length){Array.isArray(n)||(c=c[0]);for(let d of f)s.add([d,c,u])}}for(let[l,m,u]of s)e.call(this,l,m,u)}disconnectables(t,...n){let e={disconnect(){n.forEach(i=>i&&w(i.disconnect)&&i.disconnect()||w(i)&&i()||x(i)&&(i.disconnected=!0))}};return t&&t.addEventListener("abort",()=>e.disconnect()),e}};var q=class extends H{constructor(t,...n){super(t,"attr",...n)}get(t,n=void 0,e={}){let i=typeof t=="string";[t=[],n=void 0,e={}]=this.resolveArgs(arguments);let{context:o}=this,s=pt(o,t),l=i?s[0]:s;if(!n)return l;let m=n&&e.lifecycleSignals&&this.createSignalGenerator(),u=m?.generate()||{};if(n(l,u,o),e.live){m&&(e={...e,signalGenerator:m});let f=this.observe(i?t[0]:t,n,{newValue:!0,...e});return this.disconnectables(e.signal,f)}}observe(t,n,e={}){let i=typeof t=="string";if([t=[],n,e={}]=this.resolveArgs(arguments),["sync","intercept"].includes(e.timing))return this.observeSync(i?t[0]:t,n,e);if(e.timing&&e.timing!=="async")throw new Error(`Timing option "${e.timing}" invalid.`);let{context:o,window:s,wq:l}=this;e.eventDetails&&!l.attrInterceptionHooks?.intercepting&&at.call(s,"intercept",()=>{});let m=new s.MutationObserver(d=>{d=mt(d).map(y=>dt.call(s,y)),lt.call(s,c,d,o)}),u={attributes:!0,attributeOldValue:e.oldValue,subtree:e.subtree};t.length&&(u.attributeFilter=t),m.observe(o,u);let f=e.signalGenerator||e.lifecycleSignals&&this.createSignalGenerator(),c={context:o,filter:t,callback:n,params:e,atomics:new Map,originalFilterIsString:i,signalGenerator:f,disconnectable:m};return this.disconnectables(e.signal,m,f)}observeSync(t,n,e={}){let i=typeof t=="string";[t,n,e={}]=this.resolveArgs(arguments);let{context:o,window:s}=this;if(e.timing&&!["sync","intercept"].includes(e.timing))throw new Error(`Timing option "${e.timing}" invalid.`);let l=e.timing==="intercept"?"intercept":"sync",m=e.subtree?"subtree":"children";this.registry(l).size||at.call(s,l,a=>{this.forEachMatchingContext(l,a,lt)});let u={disconnect(){y.delete(c),y.size||d.delete(o)}},f=e.signalGenerator||e.lifecycleSignals&&this.createSignalGenerator(),c={context:o,filter:t,callback:n,params:e,atomics:new Map,originalFilterIsString:i,signalGenerator:f,disconnectable:u},d=this.registry(l,m);d.has(o)||d.set(o,new Set);let y=d.get(o);return y.add(c),this.disconnectables(e.signal,u,f)}};function mt(r){return r.reduce((t,n,e)=>t[e-1]?.attributeName===n.attributeName?t:t.concat(n),[])}function lt(r,t){let{context:n,filter:e,callback:i,params:o,atomics:s,originalFilterIsString:l,signalGenerator:m}=r;o.atomic&&!s.size&&(t=pt(n,e,t)),o.newValue===null&&o.oldValue===null||(t=t.map(c=>{let d;return!o.oldValue&&"oldValue"in c&&({oldValue:d,...c}=c),!o.newValue&&"value"in c?{value:d,...c}=c:o.newValue&&typeof c.value>"u"&&(c={...c,value:c.target.getAttribute(c.name)}),c})),o.atomic&&(t.forEach(c=>s.set(c.name,c)),t=Array.from(s.entries()).map(([,c])=>c));let u=l?t[0]:t,f=m?.generate()||{};i(u,f,n)}function pt(r,t,n=[]){let e={event:null,type:"attribute"};return t.length?t.map(o=>n.find(s=>s.name===o)||{target:r,name:o,value:r.getAttribute(o),...e}):Array.from(r.attributes).map(o=>n.find(s=>s.name===o.nodeName)||{target:r,name:o.nodeName,value:o.nodeValue,...e})}function dt({target:r,attributeName:t,value:n,oldValue:e}){let s=(this.wq.attrInterceptionRecords?.get(r)||{})[t]||"mutation";return{target:r,name:t,value:n,oldValue:e,type:"observation",event:s}}function at(r,t){let n=this,{wq:e,document:i,Element:o}=n;e.attrInterceptionHooks||(e.attrInterceptionHooks=new Map),e.attrInterceptionHooks.has(r)||e.attrInterceptionHooks.set(r,new Set),e.attrInterceptionHooks.get(r).add(t);let s=()=>e.attrInterceptionHooks.get(r).delete(t);if(e.attrInterceptionHooks?.intercepting)return s;console.warn("Attr mutation APIs are now being intercepted."),e.attrInterceptionHooks.intercepting=!0,e.attrInterceptionRecords=new Map;let l=(f,c)=>{e.attrInterceptionRecords.has(f.target)||e.attrInterceptionRecords.set(f.target,{});let d=e.attrInterceptionRecords.get(f.target);clearTimeout(d[f.name]?.timeout),d[f.name]=f.event;let y=setTimeout(()=>{delete d[f.name]},0);Object.defineProperty(f.event,"timeout",{value:y,configurable:!0}),e.attrInterceptionHooks.get("intercept")?.forEach(h=>h([f]));let a=c();return e.attrInterceptionHooks.get("sync")?.forEach(h=>h([f])),a};new n.MutationObserver(f=>{f=mt(f).map(c=>dt.call(n,c)).filter((c,d)=>!Array.isArray(c.event)),f.length&&(e.attrInterceptionHooks.get("intercept")?.forEach(c=>c(f)),e.attrInterceptionHooks.get("sync")?.forEach(c=>c(f)))}).observe(i,{attributes:!0,subtree:!0,attributeOldValue:!0});let u=Object.create(null);return["setAttribute","removeAttribute","toggleAttribute"].forEach(f=>{u[f]=o.prototype[f],o.prototype[f]=function(...c){let d,y=this.getAttribute(c[0]);["setAttribute","toggleAttribute"].includes(f)&&(d=c[1]),f==="toggleAttribute"&&d===void 0&&(d=y===null);let a={target:this,name:c[0],value:d,oldValue:y,type:"interception",event:[this,f]};return l(a,()=>u[f].call(this,...c))}}),s}var F=class extends H{constructor(t,...n){super(t,"tree",...n)}attr(t,n=void 0,e={}){let{context:i,window:o}=this;return new q(i,o).get(...arguments)}query(t,n=void 0,e={}){[t,n=void 0,e={}]=this.resolveArgs(arguments);let{context:i}=this,o=new Map,s=u=>(o.has(u)||o.set(u,{target:u,entrants:[],exits:[],type:"query",event:null}),o.get(u));if((!e.generation||e.generation==="entrants")&&(t.length?t.every(u=>typeof u=="string")&&(t=t.join(","))&&(e.subtree?i.querySelectorAll(t):[...i.children].filter(f=>f.matches(t))).forEach(f=>s(f.parentNode||i).entrants.push(f)):[...i.children].forEach(u=>s(i).entrants.push(u))),!n)return o;let l={disconnected:!1},m=n&&e.lifecycleSignals&&this.createSignalGenerator();for(let[,u]of o){if(l.disconnected)break;let f=m?.generate()||{};n(u,f,i)}if(e.live){m&&(e={...e,signalGenerator:m});let u=this.observe(t,n,e);return this.disconnectables(e.signal,l,u)}return this.disconnectables(e.signal,l,m)}children(t,n=void 0,e={}){return[t,n=void 0,e={}]=this.resolveArgs(arguments),this.query(t,n,{...e,subtree:!1})}subtree(t,n=void 0,e={}){return[t,n=void 0,e={}]=this.resolveArgs(arguments),this.query(t,n,{...e,subtree:!0})}observe(t,n,e={}){if([t,n,e={}]=this.resolveArgs(arguments),["sync","intercept"].includes(e.timing))return this.observeSync(t,n,e);if(e.timing&&e.timing!=="async")throw new Error(`Timing option "${e.timing}" invalid.`);let{context:i,window:o,wq:s,document:l}=this;e.eventDetails&&(s.domInterceptionRecordsAlwaysOn=!0),(l.readyState==="loading"||s.domInterceptionRecordsAlwaysOn)&&!s.domInterceptionHooks?.intercepting&&yt.call(o,"sync",()=>{});let m=new o.MutationObserver(c=>c.forEach(d=>{gt.call(o,f,_t.call(o,d),i)}));m.observe(i,{childList:!0,subtree:e.subtree});let u=e.signalGenerator||e.lifecycleSignals&&this.createSignalGenerator(),f={context:i,selectors:t,callback:n,params:e,signalGenerator:u,disconnectable:m};if(e.staticSensitivity){let c=ht.call(o,f);return this.disconnectables(e.signal,m,u,c)}return this.disconnectables(e.signal,m,u)}observeSync(t,n,e={}){[t,n,e={}]=this.resolveArgs(arguments);let{context:i,window:o}=this;if(e.timing&&!["sync","intercept"].includes(e.timing))throw new Error(`Timing option "${e.timing}" invalid.`);let s=e.timing==="intercept"?"intercept":"sync",l=e.subtree?"subtree":"children";this.registry(s).size||yt.call(o,s,y=>{this.forEachMatchingContext(s,y,gt)});let m={disconnect(){d.delete(f),d.size||c.delete(i)}},u=e.signalGenerator||e.lifecycleSignals&&this.createSignalGenerator(),f={context:i,selectors:t,callback:n,params:e,signalGenerator:u,disconnectable:m},c=this.registry(s,l);c.has(i)||c.set(i,new Set);let d=c.get(i);if(d.add(f),e.staticSensitivity){let y=ht.call(o,f);return this.disconnectables(e.signal,m,u,y)}return this.disconnectables(e.signal,m,u)}};function ht(r){let t=this,{context:n,selectors:e,callback:i,params:o,signalGenerator:s}=r,l=f=>[...f.matchAll(/\[([^\=\]]+)(\=[^\]]+)?\]/g)].map(c=>c[1]);if(!(r.$attrs=e.filter(f=>typeof f=="string"&&f.includes("[")).reduce((f,c)=>f.concat(l(c)),[])).length)return;let m=new Set,u=new Set;return m.push=f=>(u.delete(f),m.add(f)),u.push=f=>(m.delete(f),u.add(f)),r.$deliveryCache={entrants:m,exits:u},new q(n,t).observe(r.$attrs,f=>{let c=new Map,d=h=>(c.has(h)||c.set(h,{target:h,entrants:[],exits:[],type:"static",event:null}),c.get(h)),y=new WeakMap,a=h=>(y.has(h)||y.set(h,e.some(p=>h.matches(p))),y.get(h));for(let h of f)["entrants","exits"].forEach(p=>{o.generation&&p!==o.generation||r.$deliveryCache[p].has(h.target)||(p==="entrants"?!a(h.target):a(h.target))||(r.$deliveryCache[p].push(h.target),d(h.target)[p].push(h.target),d(h.target).event=h.event)});for(let[,h]of c){let p=s?.generate()||{};i(h,p,n)}},{subtree:o.subtree,timing:o.timing,eventDetails:o.eventDetails})}function gt(r,t){let{context:n,selectors:e,callback:i,params:o,signalGenerator:s,$deliveryCache:l}=r,m={...t,entrants:[],exits:[]};if(["entrants","exits"].forEach(f=>{if(!(o.generation&&f!==o.generation)&&(e.length?m[f]=Ft(e,t[f],t.event!=="parse"):m[f]=[...t[f]],!!l))for(let c of m[f])l[f].push(c)}),!m.entrants.length&&!m.exits.length)return;let u=s?.generate()||{};i(m,u,n)}function Ft(r,t,n){t=Array.isArray(t)?t:[...t];let e=(i,o)=>{if(i=i.filter(s=>s.matches),typeof o=="string"){let s=i.filter(l=>l.matches(o));if(n&&(s=i.reduce((l,m)=>[...l,...m.querySelectorAll(o)],s)),s.length)return s}else if(i.includes(o)||n&&i.some(s=>s.contains(o)))return[o]};return t.$$searchCache||(t.$$searchCache=new Map),r.reduce((i,o)=>{let s;return t.$$searchCache.has(o)?s=t.$$searchCache.get(o):(s=e(t,o)||[],x(o)&&t.$$searchCache.set(o,s)),i.concat(s)},[])}function _t({target:r,addedNodes:t,removedNodes:n}){let e=this,i;return i=b(t).reduce((o,s)=>o||e.wq.domInterceptionRecords?.get(s),null),i=b(n).reduce((o,s)=>o||e.wq.domInterceptionRecords?.get(s),i),i=i||e.document.readyState==="loading"&&"parse"||"mutation",{target:r,entrants:t,exits:n,type:"observation",event:i}}function yt(r,t){let n=this,{wq:e,document:i,Node:o,Element:s,HTMLElement:l,HTMLTemplateElement:m,DocumentFragment:u}=n;e.domInterceptionHooks||(e.domInterceptionHooks=new Map),e.domInterceptionHooks.has(r)||e.domInterceptionHooks.set(r,new Set),e.domInterceptionHooks.get(r).add(t);let f=()=>e.domInterceptionHooks.get(r).delete(t);if(e.domInterceptionHooks?.intercepting)return f;console.warn("DOM mutation APIs are now being intercepted."),e.domInterceptionHooks.intercepting=!0,e.domInterceptionRecords=new Map;let c=()=>!0,d=(a,h)=>{c()?a.entrants.concat(a.exits).forEach(_=>{clearTimeout(e.domInterceptionRecords.get(_)?.timeout),e.domInterceptionRecords.set(_,a.event);let v=setTimeout(()=>{e.domInterceptionRecords.delete(_)},0);Object.defineProperty(a.event,"timeout",{value:v,configurable:!0})}):e.domInterceptionRecords.clear(),e.domInterceptionHooks.get("intercept")?.forEach(_=>_(a));let p=h();return e.domInterceptionHooks.get("sync")?.forEach(_=>_(a)),p};if(c()){let a=new n.MutationObserver(h=>h.forEach(p=>{Array.isArray((p=_t.call(n,p)).event)||(e.domInterceptionHooks.get("intercept")?.forEach(_=>_(p)),e.domInterceptionHooks.get("sync")?.forEach(_=>_(p)))}));a.observe(i,{childList:!0,subtree:!0}),i.addEventListener("readystatechange",()=>!c()&&a.disconnect())}let y=Object.create(null);return["insertBefore","insertAdjacentElement","insertAdjacentHTML","setHTML","replaceChildren","replaceWith","remove","replaceChild","removeChild","before","after","append","prepend","appendChild"].forEach(a=>{let h=["insertBefore","replaceChild","removeChild","appendChild"].includes(a)?o:s;y[a]=h.prototype[a],y[a]&&(h.prototype[a]=function(...p){let _=()=>y[a].call(this,...p);if(!(this instanceof s||this instanceof u))return _();let v=[],A=[],I=this;["insertBefore"].includes(a)?A=[p[0]]:["insertAdjacentElement","insertAdjacentHTML"].includes(a)?(A=[p[1]],["beforebegin","afterend"].includes(p[0])&&(I=this.parentNode)):["setHTML","replaceChildren"].includes(a)?(v=[...this.childNodes],A=a==="replaceChildren"?[...p]:[p[0]]):["replaceWith","remove"].includes(a)?(v=[this],A=a==="replaceWith"?[...p]:[],I=this.parentNode):["replaceChild"].includes(a)?(v=[p[1]],A=[p[0]]):["removeChild"].includes(a)?v=[...p]:(A=[...p],["before","after"].includes(a)&&(I=this.parentNode));let V=a;if(["insertAdjacentHTML","setHTML"].includes(a)){let M=this.nodeName;if(a==="insertAdjacentHTML"&&["beforebegin","afterend"].includes(p[0])){if(!this.parentNode)return y[a].call(this,...p);M=this.parentNode.nodeName}let G=i.createElement(M);y.setHTML.call(G,A[0],a==="setHTML"?p[1]:{}),A=[...G.childNodes],a==="insertAdjacentHTML"?(V="insertAdjacentElement",p[1]=new u,p[1].______isTemp=!0,p[1].append(...G.childNodes)):(V="replaceChildren",p=[...G.childNodes])}return d({target:I,entrants:A,exits:v,type:"interception",event:[this,a]},()=>y[V].call(this,...p))})}),["outerHTML","outerText","innerHTML","innerText","textContent","nodeValue"].forEach(a=>{let h=["textContent","nodeValue"].includes(a)?o:["outerText","innerText"].includes(a)?l:s;y[a]=Object.getOwnPropertyDescriptor(h.prototype,a),Object.defineProperty(h.prototype,a,{...y[a],set:function(p){let _=()=>y[a].set.call(this,p);if(!(this instanceof s))return _();let v=[],A=[],I=this;if(["outerHTML","outerText"].includes(a)?(v=[this],I=this.parentNode):v=[...this.childNodes],["outerHTML","innerHTML"].includes(a)){let j=this.nodeName;if(a==="outerHTML"){if(!this.parentNode)return _();j=this.parentNode.nodeName}let M=i.createElement(j==="TEMPLATE"?"div":j);y[a].set.call(M,p),A=this instanceof m?[]:[...M.childNodes],a==="outerHTML"?(p=new u,p.______isTemp=!0,p.append(...M.childNodes),_=()=>y.replaceWith.call(this,p)):this instanceof m?_=()=>this.content.replaceChildren(...M.childNodes):_=()=>y.replaceChildren.call(this,...M.childNodes)}return d({target:I,entrants:A,exits:v,type:"interception",event:[this,a]},_)}})}),["append","prepend","replaceChildren"].forEach(a=>{[i,u.prototype].forEach(h=>{let p=h[a];h[a]=function(..._){if(this.______isTemp)return p.call(this,..._);let v=a==="replaceChildren"?[...this.childNodes]:[];return d({target:this,entrants:_,exits:v,type:"interception",event:[this,a]},()=>p.call(this,..._))}})}),f}function xt(){Dt.call(this),Nt.call(this),kt.call(this)}function Dt(){let r=this;r.CSS||(r.CSS={}),r.CSS.escape||(r.CSS.escape=t=>t.replace(/([\:@\~\$\&])/g,"\\$1"))}function Nt(){let r=this;"isConnected"in r.Node.prototype||Object.defineProperty(r.Node.prototype,"isConnected",{get:function(){return!this.ownerDocument||!(this.ownerDocument.compareDocumentPosition(this)&this.DOCUMENT_POSITION_DISCONNECTED)}})}function kt(){let r=this;r.Element.prototype.matches||(r.Element.prototype.matches=r.Element.prototype.matchesSelector||r.Element.prototype.mozMatchesSelector||r.Element.prototype.msMatchesSelector||r.Element.prototype.oMatchesSelector||r.Element.prototype.webkitMatchesSelector||function(t){for(var n=(this.document||this.ownerDocument).querySelectorAll(t),e=n.length;--e>=0&&n.item(e)!==this;);return e>-1})}function wt(){let r=this;if(r.wq||(r.wq={}),r.wq.dom)return r.wq.dom;r.wq.dom={},xt.call(r);let t=ft(r);return r.wq.dom.Reflow=new t,r.wq.dom.DOMRealtime=F,r.wq.dom.AttrRealtime=q,r.wq.dom.realtime=(n,e="tree")=>{if(e==="tree")return new F(n,r);if(e==="attr")return new q(n,r)},r.wq.dom.ready=$t.bind(r),r.wq.dom.meta=Vt.bind(r),r.wq.dom}function $t(r){let t=this;t.document.readyState==="complete"?r(t):(t.document.domReadyCallbacks||(t.document.domReadyCallbacks=[],t.document.addEventListener("DOMContentLoaded",()=>{t.document.domReadyCallbacks.splice(0).forEach(n=>n(t))},!1)),t.document.domReadyCallbacks.push(r))}function Vt(r,t=!1){let n=this,e={content:{}};return!(e.el=n.document.querySelector(`meta[name="${r}"]`))&&t&&(e.el=n.document.createElement("meta"),e.el.setAttribute("name",r),n.document.head.append(e.el)),e.el&&(e.content=(e.el.getAttribute("content")||"").split(";").filter(i=>i).reduce((i,o)=>{let s=o.split("=").map(l=>l.trim());return K(i,s[0].split("."),s[1]==="true"?!0:s[1]==="false"?!1:E(s[1])?parseInt(s[1]):s[1]),i},{})),e.get=function(i){return JSON.parse(JSON.stringify(P(this.content,i.split("."))))},e.copy=function(){return JSON.parse(JSON.stringify(this.content))},e.copyWithDefaults=function(...i){return i.length?k(!0,{},...i.reverse().concat(this.content)):this.copy()},e}function Ot(){let r=this;return class extends r.Event{constructor(n,e,{type:i="contextrequest",...o}={}){super(i,o),Object.defineProperty(this,"request",{get:()=>n}),Object.defineProperty(this,"callback",{get:()=>e})}respondWith(n,...e){if(this.request.diff){if("previousValue"in this&&this.previousValue===n)return;this.previousValue=n}return this.callback(n,...e)}}}var z=(r,...t)=>L(r,"oohtml",...t),et=(r,t,n=1,e=!1)=>{if(n&&typeof r=="object"&&r&&typeof t=="object"&&t&&(!e||Object.keys(r).length===Object.keys(t).length)){for(let i in r)if(!et(r[i],t[i],n-1,e))return!1;return!0}return Array.isArray(r)&&Array.isArray(t)&&r.length===t.length?(t=t.slice(0).sort())&&r.slice(0).sort().every((i,o)=>i===t[o]):r===t};var C=class{static instance(t){return z(t).get("contextsmanager::instance")||new this(t)}constructor(t){z(t).get("contextsmanager::instance")?.dispose(),z(t).set("contextsmanager::instance",this);let n={host:t,contexts:new Set};Object.defineProperty(this,"#",{get:()=>n});let e=Ot.call(t.ownerDocument?.defaultView||t.defaultView);Object.defineProperty(this,"ContextRequestEvent",{get:()=>e}),this[Symbol.iterator]=function*(){yield n.contexts[Symbol.iterator]().next().value}}get length(){this["#"].contexts.size}find(t){return[...this["#"].contexts].find(t)}attach(t){this["#"].contexts.add(t),t.initialize(this["#"].host)}detach(t){t.dispose(this["#"].host),this["#"].contexts.delete(t)}ask(t,n,e={}){return this["#"].host.dispatchEvent(new this.ContextRequestEvent(t,n,{bubbles:!0,...e}))}dispose(){}};var $=class{static get params(){return{}}static attachTo(t,n,e=!1){let i,o=C.instance(t);return!e&&(i=o.find(s=>this.matchRequest(s.id,n,!0)))?i:o.attach(new this(n))}static detachFrom(t,n,e=!1){let i,o=C.instance(t);for(i of o["#"].contexts)if(!(!this.matchRequest(i.id,n,!0)||typeof e=="function"&&!e(i))&&(o.detach(i),typeof e!="function"&&!e))return i}static createId(t,n={}){let e={type:"HTMLModules",...n};return e.name||(t.getAttribute&&!(e.name=(t.getAttribute(this.params.context.attr.contextname)||"").trim())?delete e.name:t.ownerDocument||(e.name="root")),e}static createRequest(t={}){return{...t}}static matchRequest(t,n,e=!1){return e?et(t,n,1,!0):n.type===t.type&&!n.name||n.name===t.name}constructor(t){Object.defineProperty(this,"id",{get:()=>t}),Object.defineProperty(this,"subscriptions",{value:new Set})}get length(){this.subscriptions.size}handle(t){}subscribe(t){this.subscriptions.add(t),t.request.signal&&t.request.signal.addEventListener("abort",()=>{this.unsubscribe(t)})}unsubscribe(t){this.subscriptions.delete(t),t.request.controller?.abort()}handleEvent(t){if(!(this.disposed||t.target===this.host&&t.request?.superContextOnly||!t.request||typeof t.callback!="function"||!this.constructor.matchRequest(this.id,t.request)))if(t.stopPropagation(),t.type==="contextclaim"){let n=new Set;this.subscriptions.forEach(e=>{!t.target.contains(e.request.superContextOnly?e.target.parentNode:e.target)||!this.constructor.matchRequest(t.request,e.request)||(this.subscriptions.delete(e),n.add(e))}),t.respondWith(n)}else t.type==="contextrequest"&&(t.request.live&&this.subscribe(t),this.handle(t))}initialize(t){return this.host=t,this.disposed=!1,t.addEventListener("contextrequest",this),t.addEventListener("contextclaim",this),C.instance(t).ask({...this.id,superContextOnly:!0},n=>n.forEach(e=>{this.subscribe(e),this.handle(e)}),{type:"contextclaim"}),this}dispose(t){return this.disposed=!0,t.removeEventListener("contextrequest",this),t.removeEventListener("contextclaim",this),this.subscriptions.forEach(n=>{this.unsubscribe(n);let{target:e,request:i,callback:o,params:s}=n;C.instance(e).ask(i,o,s)}),this}};function rt(r={}){let t=this,n=wt.call(t);t.wq||(t.wq={}),t.wq.HTMLContextManager=C,t.wq.HTMLContext=$;let e=n.meta("oohtml").copyWithDefaults(r,{api:{context:"context"}});jt.call(this,e)}function jt(r){let t=this;if(r.api.context in t.document)throw new Error(`document already has a "${r.api.context}" property!`);if(r.api.context in t.HTMLElement.prototype)throw new Error(`The "HTMLElement" class already has a "${r.api.context}" property!`);Object.defineProperty(t.document,r.api.context,{get:function(){return C.instance(t.document)}}),Object.defineProperty(t.HTMLElement.prototype,r.api.context,{get:function(){return C.instance(this)}})}rt.call(window);})();
1
+ (()=>{function x(r){return!Array.isArray(r)&&typeof r=="object"&&r}function L(r,...t){globalThis.WebQitInternalsRegistry||(globalThis.WebQitInternalsRegistry=new Map);var n=globalThis.WebQitInternalsRegistry.get(r);if(!n){if(n=new Map,t[0]===!1)return n;globalThis.WebQitInternalsRegistry.set(r,n)}for(var e,i;e=t.shift();)if((i=n)&&!(n=n.get(e))){if(n=new Map,t[0]===!1)return n;i.set(e,n)}return n}function g(r){return Array.isArray(r)}function R(r){return typeof r=="function"}function D(r){return r===null||r===""}function S(r){return arguments.length&&(r===void 0||typeof r>"u")}function O(r){return Array.isArray(r)||typeof r=="object"&&r||R(r)}function J(r){return D(r)||S(r)||r===!1||r===0||O(r)&&!Object.keys(r).length}function w(r){return R(r)||r&&{}.toString.call(r)==="[object function]"}function N(r){return r instanceof Number||typeof r=="number"}function E(r){return N(r)||r!==!0&&r!==!1&&r!==null&&r!==""&&!isNaN(r*1)}function W(r){return r instanceof String||typeof r=="string"&&r!==null}function Q(r){return!W(r)&&!S(r.length)}function B(r,...t){return t.forEach(n=>{r.indexOf(n)<0&&r.push(n)}),r}function X(e,t){t=t||Object.prototype,t=t&&!g(t)?[t]:t;for(var n=[],e=e;e&&(!t||t.indexOf(e)<0)&&e.name!=="default";)n.push(e),e=e?Object.getPrototypeOf(e):null;return n}function Y(r,t){var n=[];return X(r,t).forEach(e=>{B(n,...Object.getOwnPropertyNames(e))}),n}function T(r,t,n=!1,e=!1,i=!1){var o=0,s=r.shift();if((E(s)||s===!0||s===!1)&&(o=s,s=r.shift()),!r.length)throw new Error("_merge() requires two or more array/objects.");return r.forEach((l,a)=>{!O(l)&&!w(l)||(n?Y(l):Object.keys(l)).forEach(u=>{if(!!t(u,s,l,a)){var f=s[u],c=l[u];if((g(f)&&g(c)||x(f)&&x(c))&&(o===!0||o>0))s[u]=g(f)&&g(c)?[]:{},T([E(o)?o-1:o,s[u],f,c],t,n,e,i);else if(g(s)&&g(l))e?s[u]=c:s.push(c);else try{i?Object.defineProperty(s,u,Object.getOwnPropertyDescriptor(l,u)):s[u]=l[u]}catch{}}})}),s}function k(...r){return T(r,(t,n,e)=>!0,!1,!1,!1)}function b(r,t=!0){return g(r)?r:!t&&x(r)?[r]:r!==!1&&r!==0&&J(r)?[]:Q(r)?Array.prototype.slice.call(r):x(r)?Object.values(r):[r]}function P(r,t,n={},e={}){t=b(t).slice();for(var i=r;!S(i)&&!D(i)&&t.length;){var o=t.shift();if(!(n.get?n.get(i,o):O(i)?o in i:i[o])){e.exists=!1;return}i=n.get?n.get(i,o):i[o]}return e.exists=!0,i}function K(r,t,n,e={},i={}){let o=(f,c,p)=>i.set?i.set(f,c,p):(E(t[l])&&g(f)?f.push(p):f[c]=p,!0);t=b(t);for(var s=r,l=0;l<t.length;l++)if(l<t.length-1){if(!s||!O(s)&&!w(s))return!1;var a=P(s,t[l],i);if(!O(a)){if(i.buildTree===!1)return!1;a=w(i.buildTree)?i.buildTree(l):E(t[l+1])?[]:{};var u=o(s,t[l],a);if(!u)return!1}s=a}else return o(s,t[l],n)}var ft=r=>class{constructor(n=!0){Object.defineProperty(this,"window",{value:r}),Object.defineProperty(this,"readCallbacks",{value:new Set}),Object.defineProperty(this,"writeCallbacks",{value:new Set}),this.async=n,this.window.requestAnimationFrame?this._run():this.async=!1}_run(){this.window.requestAnimationFrame(()=>{this.readCallbacks.forEach(n=>{n()||this.readCallbacks.delete(n)}),this.writeCallbacks.forEach(n=>{n()||this.writeCallbacks.delete(n)}),this._run()})}onread(n,e=!1){if(e)return new Promise((i,o)=>{this.async===!1?n(i,o):this.readCallbacks.add(()=>{n(i,o)})});this.async===!1?n():this.readCallbacks.add(n)}onwrite(n,e=!1){if(e)return new Promise((i,o)=>{this.async===!1?n(i,o):this.writeCallbacks.add(()=>{n(i,o)})});this.async===!1?n():this.writeCallbacks.add(n)}cycle(n,e,i){this.onread(()=>{let o=n(i),s=l=>{l!==void 0&&this.onwrite(()=>{let a=e(l,i),u=f=>{f!==void 0&&this.cycle(n,e,f)};a instanceof Promise?a.then(u):u(a)})};o instanceof Promise?o.then(s):s(o)})}};var H=class{constructor(t,n,e){this.context=t,this.namespace=n,this.window=t.defaultView||t.ownerDocument?.defaultView||e,this.document=this.window.document,this.wq=this.window.wq,Object.defineProperty(this,"#",{value:{}})}resolveArgs(t){return w(t[0])?t=[[],...t]:x(t[0])&&t.length===1?t=[[],void 0,t[0]]:x(t[1])&&t.length===2?t=[b(t[0],!1),void 0,t[1]]:t[0]=b(t[0],!1),t}registry(...t){return L(this.window,"dom.realtime",this.namespace,...t)}createSignalGenerator(){return{generate(){return this.lastController?.abort(),this.lastController=new AbortController,{signal:this.lastController.signal}},disconnect(){this.lastController?.abort()}}}forEachMatchingContext(t,n,e){let{window:i}=this,o=Array.isArray(n)?n:[n],s=new Set;for(let[l,a]of this.registry(t))for(let[u,f]of a){let c=o.filter(p=>u.contains(p.target)?l==="subtree"||p.target===u:!1);if(!!c.length){Array.isArray(n)||(c=c[0]);for(let p of f)s.add([p,c,u])}}for(let[l,a,u]of s)e.call(this,l,a,u)}disconnectables(t,...n){let e={disconnect(){n.forEach(i=>i&&w(i.disconnect)&&i.disconnect()||w(i)&&i()||x(i)&&(i.disconnected=!0))}};return t&&t.addEventListener("abort",()=>e.disconnect()),e}};var q=class extends H{constructor(t,...n){super(t,"attr",...n)}get(t,n=void 0,e={}){let i=typeof t=="string";[t=[],n=void 0,e={}]=this.resolveArgs(arguments);let{context:o}=this,s=dt(o,t),l=i?s[0]:s;if(!n)return l;let a=n&&e.lifecycleSignals&&this.createSignalGenerator(),u=a?.generate()||{};if(n(l,u,o),e.live){a&&(e={...e,signalGenerator:a});let f=this.observe(i?t[0]:t,n,{newValue:!0,...e});return this.disconnectables(e.signal,f)}}observe(t,n,e={}){let i=typeof t=="string";if([t=[],n,e={}]=this.resolveArgs(arguments),["sync","intercept"].includes(e.timing))return this.observeSync(i?t[0]:t,n,e);if(e.timing&&e.timing!=="async")throw new Error(`Timing option "${e.timing}" invalid.`);let{context:o,window:s,wq:l}=this;e.eventDetails&&!l.dom.attrInterceptionHooks?.intercepting&&mt.call(s,"intercept",()=>{});let a=new s.MutationObserver(p=>{p=at(p).map(y=>pt.call(s,y)),lt.call(s,c,p,o)}),u={attributes:!0,attributeOldValue:e.oldValue,subtree:e.subtree};t.length&&(u.attributeFilter=t),a.observe(o,u);let f=e.signalGenerator||e.lifecycleSignals&&this.createSignalGenerator(),c={context:o,filter:t,callback:n,params:e,atomics:new Map,originalFilterIsString:i,signalGenerator:f,disconnectable:a};return this.disconnectables(e.signal,a,f)}observeSync(t,n,e={}){let i=typeof t=="string";[t,n,e={}]=this.resolveArgs(arguments);let{context:o,window:s}=this;if(e.timing&&!["sync","intercept"].includes(e.timing))throw new Error(`Timing option "${e.timing}" invalid.`);let l=e.timing==="intercept"?"intercept":"sync",a=e.subtree?"subtree":"children";this.registry(l).size||mt.call(s,l,m=>{this.forEachMatchingContext(l,m,lt)});let u={disconnect(){y.delete(c),y.size||p.delete(o)}},f=e.signalGenerator||e.lifecycleSignals&&this.createSignalGenerator(),c={context:o,filter:t,callback:n,params:e,atomics:new Map,originalFilterIsString:i,signalGenerator:f,disconnectable:u},p=this.registry(l,a);p.has(o)||p.set(o,new Set);let y=p.get(o);return y.add(c),this.disconnectables(e.signal,u,f)}};function at(r){return r.reduce((t,n,e)=>t[e-1]?.attributeName===n.attributeName?t:t.concat(n),[])}function lt(r,t){let{context:n,filter:e,callback:i,params:o,atomics:s,originalFilterIsString:l,signalGenerator:a}=r;o.atomic&&!s.size&&(t=dt(n,e,t)),o.newValue===null&&o.oldValue===null||(t=t.map(c=>{let p;return!o.oldValue&&"oldValue"in c&&({oldValue:p,...c}=c),!o.newValue&&"value"in c?{value:p,...c}=c:o.newValue&&typeof c.value>"u"&&(c={...c,value:c.target.getAttribute(c.name)}),c})),o.atomic&&(t.forEach(c=>s.set(c.name,c)),t=Array.from(s.entries()).map(([,c])=>c));let u=l?t[0]:t,f=a?.generate()||{};i(u,f,n)}function dt(r,t,n=[]){let e={event:null,type:"attribute"};return t.length?t.map(o=>n.find(s=>s.name===o)||{target:r,name:o,value:r.getAttribute(o),...e}):Array.from(r.attributes).map(o=>n.find(s=>s.name===o.nodeName)||{target:r,name:o.nodeName,value:o.nodeValue,...e})}function pt({target:r,attributeName:t,value:n,oldValue:e}){let s=(this.wq.dom.attrInterceptionRecords?.get(r)||{})[t]||"mutation";return{target:r,name:t,value:n,oldValue:e,type:"observation",event:s}}function mt(r,t){let n=this,{wq:e,document:i,Element:o}=n;e.dom.attrInterceptionHooks||(e.dom.attrInterceptionHooks=new Map),e.dom.attrInterceptionHooks.has(r)||e.dom.attrInterceptionHooks.set(r,new Set),e.dom.attrInterceptionHooks.get(r).add(t);let s=()=>e.dom.attrInterceptionHooks.get(r).delete(t);if(e.dom.attrInterceptionHooks?.intercepting)return s;console.warn("Attr mutation APIs are now being intercepted."),e.dom.attrInterceptionHooks.intercepting=!0,e.dom.attrInterceptionRecords=new Map;let l=(f,c)=>{e.dom.attrInterceptionRecords.has(f.target)||e.dom.attrInterceptionRecords.set(f.target,{});let p=e.dom.attrInterceptionRecords.get(f.target);clearTimeout(p[f.name]?.timeout),p[f.name]=f.event;let y=setTimeout(()=>{delete p[f.name]},0);Object.defineProperty(f.event,"timeout",{value:y,configurable:!0}),e.dom.attrInterceptionHooks.get("intercept")?.forEach(h=>h([f]));let m=c();return e.dom.attrInterceptionHooks.get("sync")?.forEach(h=>h([f])),m};new n.MutationObserver(f=>{f=at(f).map(c=>pt.call(n,c)).filter((c,p)=>!Array.isArray(c.event)),f.length&&(e.dom.attrInterceptionHooks.get("intercept")?.forEach(c=>c(f)),e.dom.attrInterceptionHooks.get("sync")?.forEach(c=>c(f)))}).observe(i,{attributes:!0,subtree:!0,attributeOldValue:!0});let u=Object.create(null);return["setAttribute","removeAttribute","toggleAttribute"].forEach(f=>{u[f]=o.prototype[f],o.prototype[f]=function(...c){let p,y=this.getAttribute(c[0]);["setAttribute","toggleAttribute"].includes(f)&&(p=c[1]),f==="toggleAttribute"&&p===void 0&&(p=y===null);let m={target:this,name:c[0],value:p,oldValue:y,type:"interception",event:[this,f]};return l(m,()=>u[f].call(this,...c))}}),s}var F=class extends H{constructor(t,...n){super(t,"tree",...n)}attr(t,n=void 0,e={}){let{context:i,window:o}=this;return new q(i,o).get(...arguments)}query(t,n=void 0,e={}){[t,n=void 0,e={}]=this.resolveArgs(arguments);let{context:i}=this,o=new Map,s=u=>(o.has(u)||o.set(u,{target:u,entrants:[],exits:[],type:"query",event:null}),o.get(u));if((!e.generation||e.generation==="entrants")&&(t.length?t.every(u=>typeof u=="string")&&(t=t.join(","))&&(e.subtree?i.querySelectorAll(t):[...i.children].filter(f=>f.matches(t))).forEach(f=>s(f.parentNode||i).entrants.push(f)):[...i.children].forEach(u=>s(i).entrants.push(u))),!n)return o;let l={disconnected:!1},a=n&&e.lifecycleSignals&&this.createSignalGenerator();for(let[,u]of o){if(l.disconnected)break;let f=a?.generate()||{};n(u,f,i)}if(e.live){a&&(e={...e,signalGenerator:a});let u=this.observe(t,n,e);return this.disconnectables(e.signal,l,u)}return this.disconnectables(e.signal,l,a)}children(t,n=void 0,e={}){return[t,n=void 0,e={}]=this.resolveArgs(arguments),this.query(t,n,{...e,subtree:!1})}subtree(t,n=void 0,e={}){return[t,n=void 0,e={}]=this.resolveArgs(arguments),this.query(t,n,{...e,subtree:!0})}observe(t,n,e={}){if([t,n,e={}]=this.resolveArgs(arguments),["sync","intercept"].includes(e.timing))return this.observeSync(t,n,e);if(e.timing&&e.timing!=="async")throw new Error(`Timing option "${e.timing}" invalid.`);let{context:i,window:o,wq:s,document:l}=this;e.eventDetails&&(s.dom.domInterceptionRecordsAlwaysOn=!0),(l.readyState==="loading"||s.dom.domInterceptionRecordsAlwaysOn)&&!s.dom.domInterceptionHooks?.intercepting&&yt.call(o,"sync",()=>{});let a=new o.MutationObserver(c=>c.forEach(p=>{gt.call(o,f,_t.call(o,p),i)}));a.observe(i,{childList:!0,subtree:e.subtree});let u=e.signalGenerator||e.lifecycleSignals&&this.createSignalGenerator(),f={context:i,selectors:t,callback:n,params:e,signalGenerator:u,disconnectable:a};if(e.staticSensitivity){let c=ht.call(o,f);return this.disconnectables(e.signal,a,u,c)}return this.disconnectables(e.signal,a,u)}observeSync(t,n,e={}){[t,n,e={}]=this.resolveArgs(arguments);let{context:i,window:o}=this;if(e.timing&&!["sync","intercept"].includes(e.timing))throw new Error(`Timing option "${e.timing}" invalid.`);let s=e.timing==="intercept"?"intercept":"sync",l=e.subtree?"subtree":"children";this.registry(s).size||yt.call(o,s,y=>{this.forEachMatchingContext(s,y,gt)});let a={disconnect(){p.delete(f),p.size||c.delete(i)}},u=e.signalGenerator||e.lifecycleSignals&&this.createSignalGenerator(),f={context:i,selectors:t,callback:n,params:e,signalGenerator:u,disconnectable:a},c=this.registry(s,l);c.has(i)||c.set(i,new Set);let p=c.get(i);if(p.add(f),e.staticSensitivity){let y=ht.call(o,f);return this.disconnectables(e.signal,a,u,y)}return this.disconnectables(e.signal,a,u)}};function ht(r){let t=this,{context:n,selectors:e,callback:i,params:o,signalGenerator:s}=r,l=f=>[...f.matchAll(/\[([^\=\]]+)(\=[^\]]+)?\]/g)].map(c=>c[1]);if(!(r.$attrs=e.filter(f=>typeof f=="string"&&f.includes("[")).reduce((f,c)=>f.concat(l(c)),[])).length)return;let a=new Set,u=new Set;return a.push=f=>(u.delete(f),a.add(f)),u.push=f=>(a.delete(f),u.add(f)),r.$deliveryCache={entrants:a,exits:u},new q(n,t).observe(r.$attrs,f=>{let c=new Map,p=h=>(c.has(h)||c.set(h,{target:h,entrants:[],exits:[],type:"static",event:null}),c.get(h)),y=new WeakMap,m=h=>(y.has(h)||y.set(h,e.some(d=>h.matches(d))),y.get(h));for(let h of f)["entrants","exits"].forEach(d=>{o.generation&&d!==o.generation||r.$deliveryCache[d].has(h.target)||(d==="entrants"?!m(h.target):m(h.target))||(r.$deliveryCache[d].push(h.target),p(h.target)[d].push(h.target),p(h.target).event=h.event)});for(let[,h]of c){let d=s?.generate()||{};i(h,d,n)}},{subtree:o.subtree,timing:o.timing,eventDetails:o.eventDetails})}function gt(r,t){let{context:n,selectors:e,callback:i,params:o,signalGenerator:s,$deliveryCache:l}=r,a={...t,entrants:[],exits:[]};if(["entrants","exits"].forEach(f=>{if(!(o.generation&&f!==o.generation)&&(e.length?a[f]=Ft(e,t[f],t.event!=="parse"):a[f]=[...t[f]],!!l))for(let c of a[f])l[f].push(c)}),!a.entrants.length&&!a.exits.length)return;let u=s?.generate()||{};i(a,u,n)}function Ft(r,t,n){t=Array.isArray(t)?t:[...t];let e=(i,o)=>{if(i=i.filter(s=>s.matches),typeof o=="string"){let s=i.filter(l=>l.matches(o));if(n&&(s=i.reduce((l,a)=>[...l,...a.querySelectorAll(o)],s)),s.length)return s}else if(i.includes(o)||n&&i.some(s=>s.contains(o)))return[o]};return t.$$searchCache||(t.$$searchCache=new Map),r.reduce((i,o)=>{let s;return t.$$searchCache.has(o)?s=t.$$searchCache.get(o):(s=e(t,o)||[],x(o)&&t.$$searchCache.set(o,s)),i.concat(s)},[])}function _t({target:r,addedNodes:t,removedNodes:n}){let e=this,i;return i=b(t).reduce((o,s)=>o||e.wq.dom.domInterceptionRecords?.get(s),null),i=b(n).reduce((o,s)=>o||e.wq.dom.domInterceptionRecords?.get(s),i),i=i||e.document.readyState==="loading"&&"parse"||"mutation",{target:r,entrants:t,exits:n,type:"observation",event:i}}function yt(r,t){let n=this,{wq:e,document:i,Node:o,Element:s,HTMLElement:l,HTMLTemplateElement:a,DocumentFragment:u}=n;e.dom.domInterceptionHooks||(e.dom.domInterceptionHooks=new Map),e.dom.domInterceptionHooks.has(r)||e.dom.domInterceptionHooks.set(r,new Set),e.dom.domInterceptionHooks.get(r).add(t);let f=()=>e.dom.domInterceptionHooks.get(r).delete(t);if(e.dom.domInterceptionHooks?.intercepting)return f;console.warn("DOM mutation APIs are now being intercepted."),e.dom.domInterceptionHooks.intercepting=!0,e.dom.domInterceptionRecords=new Map;let c=()=>!0,p=(m,h)=>{c()?m.entrants.concat(m.exits).forEach(_=>{clearTimeout(e.dom.domInterceptionRecords.get(_)?.timeout),e.dom.domInterceptionRecords.set(_,m.event);let v=setTimeout(()=>{e.dom.domInterceptionRecords.delete(_)},0);Object.defineProperty(m.event,"timeout",{value:v,configurable:!0})}):e.dom.domInterceptionRecords.clear(),e.dom.domInterceptionHooks.get("intercept")?.forEach(_=>_(m));let d=h();return e.dom.domInterceptionHooks.get("sync")?.forEach(_=>_(m)),d};if(c()){let m=new n.MutationObserver(h=>h.forEach(d=>{Array.isArray((d=_t.call(n,d)).event)||(e.dom.domInterceptionHooks.get("intercept")?.forEach(_=>_(d)),e.dom.domInterceptionHooks.get("sync")?.forEach(_=>_(d)))}));m.observe(i,{childList:!0,subtree:!0}),i.addEventListener("readystatechange",()=>!c()&&m.disconnect())}let y=Object.create(null);return["insertBefore","insertAdjacentElement","insertAdjacentHTML","setHTML","replaceChildren","replaceWith","remove","replaceChild","removeChild","before","after","append","prepend","appendChild"].forEach(m=>{let h=["insertBefore","replaceChild","removeChild","appendChild"].includes(m)?o:s;y[m]=h.prototype[m],y[m]&&(h.prototype[m]=function(...d){let _=()=>y[m].call(this,...d);if(!(this instanceof s||this instanceof u))return _();let v=[],A=[],I=this;["insertBefore"].includes(m)?A=[d[0]]:["insertAdjacentElement","insertAdjacentHTML"].includes(m)?(A=[d[1]],["beforebegin","afterend"].includes(d[0])&&(I=this.parentNode)):["setHTML","replaceChildren"].includes(m)?(v=[...this.childNodes],A=m==="replaceChildren"?[...d]:[d[0]]):["replaceWith","remove"].includes(m)?(v=[this],A=m==="replaceWith"?[...d]:[],I=this.parentNode):["replaceChild"].includes(m)?(v=[d[1]],A=[d[0]]):["removeChild"].includes(m)?v=[...d]:(A=[...d],["before","after"].includes(m)&&(I=this.parentNode));let V=m;if(["insertAdjacentHTML","setHTML"].includes(m)){let M=this.nodeName;if(m==="insertAdjacentHTML"&&["beforebegin","afterend"].includes(d[0])){if(!this.parentNode)return y[m].call(this,...d);M=this.parentNode.nodeName}let G=i.createElement(M);y.setHTML.call(G,A[0],m==="setHTML"?d[1]:{}),A=[...G.childNodes],m==="insertAdjacentHTML"?(V="insertAdjacentElement",d[1]=new u,d[1].______isTemp=!0,d[1].append(...G.childNodes)):(V="replaceChildren",d=[...G.childNodes])}return p({target:I,entrants:A,exits:v,type:"interception",event:[this,m]},()=>y[V].call(this,...d))})}),["outerHTML","outerText","innerHTML","innerText","textContent","nodeValue"].forEach(m=>{let h=["textContent","nodeValue"].includes(m)?o:["outerText","innerText"].includes(m)?l:s;y[m]=Object.getOwnPropertyDescriptor(h.prototype,m),Object.defineProperty(h.prototype,m,{...y[m],set:function(d){let _=()=>y[m].set.call(this,d);if(!(this instanceof s))return _();let v=[],A=[],I=this;if(["outerHTML","outerText"].includes(m)?(v=[this],I=this.parentNode):v=[...this.childNodes],["outerHTML","innerHTML"].includes(m)){let j=this.nodeName;if(m==="outerHTML"){if(!this.parentNode)return _();j=this.parentNode.nodeName}let M=i.createElement(j==="TEMPLATE"?"div":j);y[m].set.call(M,d),A=this instanceof a?[]:[...M.childNodes],m==="outerHTML"?(d=new u,d.______isTemp=!0,d.append(...M.childNodes),_=()=>y.replaceWith.call(this,d)):this instanceof a?_=()=>this.content.replaceChildren(...M.childNodes):_=()=>y.replaceChildren.call(this,...M.childNodes)}return p({target:I,entrants:A,exits:v,type:"interception",event:[this,m]},_)}})}),["append","prepend","replaceChildren"].forEach(m=>{[i,u.prototype].forEach(h=>{let d=h[m];h[m]=function(..._){if(this.______isTemp)return d.call(this,..._);let v=m==="replaceChildren"?[...this.childNodes]:[];return p({target:this,entrants:_,exits:v,type:"interception",event:[this,m]},()=>d.call(this,..._))}})}),f}function xt(){Dt.call(this),Nt.call(this),kt.call(this)}function Dt(){let r=this;r.CSS||(r.CSS={}),r.CSS.escape||(r.CSS.escape=t=>t.replace(/([\:@\~\$\&])/g,"\\$1"))}function Nt(){let r=this;"isConnected"in r.Node.prototype||Object.defineProperty(r.Node.prototype,"isConnected",{get:function(){return!this.ownerDocument||!(this.ownerDocument.compareDocumentPosition(this)&this.DOCUMENT_POSITION_DISCONNECTED)}})}function kt(){let r=this;r.Element.prototype.matches||(r.Element.prototype.matches=r.Element.prototype.matchesSelector||r.Element.prototype.mozMatchesSelector||r.Element.prototype.msMatchesSelector||r.Element.prototype.oMatchesSelector||r.Element.prototype.webkitMatchesSelector||function(t){for(var n=(this.document||this.ownerDocument).querySelectorAll(t),e=n.length;--e>=0&&n.item(e)!==this;);return e>-1})}function wt(){let r=this;if(r.wq||(r.wq={}),r.wq.dom)return r.wq.dom;r.wq.dom={},xt.call(r);let t=ft(r);return r.wq.dom.Reflow=new t,r.wq.dom.DOMRealtime=F,r.wq.dom.AttrRealtime=q,r.wq.dom.realtime=(n,e="tree")=>{if(e==="tree")return new F(n,r);if(e==="attr")return new q(n,r)},r.wq.dom.ready=$t.bind(r),r.wq.dom.meta=Vt.bind(r),r.wq.dom}function $t(r){let t=this;t.document.readyState==="complete"?r(t):(t.document.domReadyCallbacks||(t.document.domReadyCallbacks=[],t.document.addEventListener("DOMContentLoaded",()=>{t.document.domReadyCallbacks.splice(0).forEach(n=>n(t))},!1)),t.document.domReadyCallbacks.push(r))}function Vt(r,t=!1){let n=this,e={content:{}};return!(e.el=n.document.querySelector(`meta[name="${r}"]`))&&t&&(e.el=n.document.createElement("meta"),e.el.setAttribute("name",r),n.document.head.append(e.el)),e.el&&(e.content=(e.el.getAttribute("content")||"").split(";").filter(i=>i).reduce((i,o)=>{let s=o.split("=").map(l=>l.trim());return K(i,s[0].split("."),s[1]==="true"?!0:s[1]==="false"?!1:E(s[1])?parseInt(s[1]):s[1]),i},{})),e.get=function(i){return JSON.parse(JSON.stringify(P(this.content,i.split("."))))},e.copy=function(){return JSON.parse(JSON.stringify(this.content))},e.copyWithDefaults=function(...i){return i.length?k(!0,{},...i.reverse().concat(this.content)):this.copy()},e}function Ot(){let r=this;return class extends r.Event{constructor(n,e,{type:i="contextrequest",...o}={}){super(i,o),Object.defineProperty(this,"request",{get:()=>n}),Object.defineProperty(this,"callback",{get:()=>e})}respondWith(n,...e){if(this.request.diff){if("previousValue"in this&&this.previousValue===n)return;this.previousValue=n}return this.callback(n,...e)}}}var z=(r,...t)=>L(r,"oohtml",...t),et=(r,t,n=1,e=!1)=>{if(n&&typeof r=="object"&&r&&typeof t=="object"&&t&&(!e||Object.keys(r).length===Object.keys(t).length)){for(let i in r)if(!et(r[i],t[i],n-1,e))return!1;return!0}return Array.isArray(r)&&Array.isArray(t)&&r.length===t.length?(t=t.slice(0).sort())&&r.slice(0).sort().every((i,o)=>i===t[o]):r===t};var C=class{static instance(t){return z(t).get("contextsmanager::instance")||new this(t)}constructor(t){z(t).get("contextsmanager::instance")?.dispose(),z(t).set("contextsmanager::instance",this);let n={host:t,contexts:new Set};Object.defineProperty(this,"#",{get:()=>n});let e=Ot.call(t.ownerDocument?.defaultView||t.defaultView);Object.defineProperty(this,"ContextRequestEvent",{get:()=>e}),this[Symbol.iterator]=function*(){yield n.contexts[Symbol.iterator]().next().value}}get length(){this["#"].contexts.size}find(t){return[...this["#"].contexts].find(t)}attach(t){this["#"].contexts.add(t),t.initialize(this["#"].host)}detach(t){t.dispose(this["#"].host),this["#"].contexts.delete(t)}ask(t,n,e={}){return this["#"].host.dispatchEvent(new this.ContextRequestEvent(t,n,{bubbles:!0,...e}))}dispose(){}};var $=class{static get params(){return{}}static attachTo(t,n,e=!1){let i,o=C.instance(t);return!e&&(i=o.find(s=>this.matchRequest(s.id,n,!0)))?i:o.attach(new this(n))}static detachFrom(t,n,e=!1){let i,o=C.instance(t);for(i of o["#"].contexts)if(!(!this.matchRequest(i.id,n,!0)||typeof e=="function"&&!e(i))&&(o.detach(i),typeof e!="function"&&!e))return i}static createId(t,n={}){let e={type:"HTMLModules",...n};return e.name||(t.getAttribute&&!(e.name=(t.getAttribute(this.params.context.attr.contextname)||"").trim())?delete e.name:t.ownerDocument||(e.name="root")),e}static createRequest(t={}){return{...t}}static matchRequest(t,n,e=!1){return e?et(t,n,1,!0):n.type===t.type&&!n.name||n.name===t.name}constructor(t){Object.defineProperty(this,"id",{get:()=>t}),Object.defineProperty(this,"subscriptions",{value:new Set})}get length(){this.subscriptions.size}handle(t){}subscribe(t){this.subscriptions.add(t),t.request.signal&&t.request.signal.addEventListener("abort",()=>{this.unsubscribe(t)})}unsubscribe(t){this.subscriptions.delete(t),t.request.controller?.abort()}handleEvent(t){if(!(this.disposed||t.target===this.host&&t.request?.superContextOnly||!t.request||typeof t.callback!="function"||!this.constructor.matchRequest(this.id,t.request)))if(t.stopPropagation(),t.type==="contextclaim"){let n=new Set;this.subscriptions.forEach(e=>{!t.target.contains(e.request.superContextOnly?e.target.parentNode:e.target)||!this.constructor.matchRequest(t.request,e.request)||(this.subscriptions.delete(e),n.add(e))}),t.respondWith(n)}else t.type==="contextrequest"&&(t.request.live&&this.subscribe(t),this.handle(t))}initialize(t){return this.host=t,this.disposed=!1,t.addEventListener("contextrequest",this),t.addEventListener("contextclaim",this),C.instance(t).ask({...this.id,superContextOnly:!0},n=>n.forEach(e=>{this.subscribe(e),this.handle(e)}),{type:"contextclaim"}),this}dispose(t){return this.disposed=!0,t.removeEventListener("contextrequest",this),t.removeEventListener("contextclaim",this),this.subscriptions.forEach(n=>{this.unsubscribe(n);let{target:e,request:i,callback:o,params:s}=n;C.instance(e).ask(i,o,s)}),this}};function rt(r={}){let t=this,n=wt.call(t);t.wq||(t.wq={}),t.wq.HTMLContextManager=C,t.wq.HTMLContext=$;let e=n.meta("oohtml").copyWithDefaults(r,{api:{context:"context"}});jt.call(this,e)}function jt(r){let t=this;if(r.api.context in t.document)throw new Error(`document already has a "${r.api.context}" property!`);if(r.api.context in t.HTMLElement.prototype)throw new Error(`The "HTMLElement" class already has a "${r.api.context}" property!`);Object.defineProperty(t.document,r.api.context,{get:function(){return C.instance(t.document)}}),Object.defineProperty(t.HTMLElement.prototype,r.api.context,{get:function(){return C.instance(this)}})}rt.call(window);})();
2
2
  //# sourceMappingURL=context-api.js.map