@webqit/oohtml 4.3.1 → 4.3.3

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
- (()=>{var te=Object.defineProperty;var ee=(n,t,r)=>t in n?te(n,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):n[t]=r;var ut=(n,t,r)=>(ee(n,typeof t!="symbol"?t+"":t,r),r);function w(n){return!Array.isArray(n)&&typeof n=="object"&&n}function g(n){return Array.isArray(n)}function yt(n,t,r=null){return g(t)?n.filter(e=>r?t.filter(i=>r(e,i)).length:t.indexOf(e)!==-1):[]}function S(n,...t){if(globalThis.webqit||(globalThis.webqit={}),globalThis.webqit.refs||Object.defineProperty(globalThis.webqit,"refs",{value:new J}),!arguments.length)return globalThis.webqit.refs;let r=globalThis.webqit.refs.get(n);r||(r=new J,globalThis.webqit.refs.set(n,r));let e,i;for(;e=t.shift();)(i=r)&&!(r=r.get(e))&&(r=new J,i.set(e,r));return r}var J=class extends Map{constructor(...t){super(...t),this.observers=new Set}set(t,r){let e=super.set(t,r);return this.fire("set",t,r,t),e}delete(t){let r=super.delete(t);return this.fire("delete",t),r}has(t){return this.fire("has",t),super.has(t)}get(t){return this.fire("get",t),super.get(t)}keyNames(){return Array.from(super.keys())}observe(t,r,e){let i={type:t,key:r,callback:e};return this.observers.add(i),()=>this.observers.delete(i)}unobserve(t,r,e){if(Array.isArray(t)||Array.isArray(r))throw new Error('The "type" and "key" arguments can only be strings.');for(let i of this.observers)!(at([t,"*"],i.type)&&at([r,"*"],i.key)&&i.callback===e)||this.observers.delete(i)}fire(t,r,...e){for(let i of this.observers)!(at([t,"*"],i.type)&&at([r,"*"],i.key))||i.callback(...e)}},at=(n,t)=>Array.isArray(t)?yt(n,t).length:n.includes(t);function X(n){return typeof n=="function"}function Y(n){return n===null||n===""}function N(n){return arguments.length&&(n===void 0||typeof n>"u")}function A(n){return Array.isArray(n)||typeof n=="object"&&n||X(n)}function _t(n){return Y(n)||N(n)||n===!1||n===0||A(n)&&!Object.keys(n).length}function b(n){return X(n)||n&&{}.toString.call(n)==="[object function]"}function Z(n){return n instanceof Number||typeof n=="number"}function C(n){return Z(n)||n!==!0&&n!==!1&&n!==null&&n!==""&&!isNaN(n*1)}function Q(n){return n instanceof String||typeof n=="string"&&n!==null}function bt(n){return!Q(n)&&!N(n.length)}function mt(n,...t){return t.forEach(r=>{n.indexOf(r)<0&&n.push(r)}),n}function wt(e,t){t=t||Object.prototype,t=t&&!g(t)?[t]:t;for(var r=[],e=e;e&&(!t||t.indexOf(e)<0)&&e.name!=="default";)r.push(e),e=e?Object.getPrototypeOf(e):null;return r}function xt(n,t){var r=[];return wt(n,t).forEach(e=>{mt(r,...Object.getOwnPropertyNames(e))}),r}function j(n,t,r=!1,e=!1,i=!1){var o=0,s=n.shift();if((C(s)||s===!0||s===!1)&&(o=s,s=n.shift()),!n.length)throw new Error("_merge() requires two or more array/objects.");return n.forEach((f,l)=>{!A(f)&&!b(f)||(r?xt(f):Object.keys(f)).forEach(a=>{if(!!t(a,s,f,l)){var c=s[a],m=f[a];if((g(c)&&g(m)||w(c)&&w(m))&&(o===!0||o>0))s[a]=g(c)&&g(m)?[]:{},j([C(o)?o-1:o,s[a],c,m],t,r,e,i);else if(g(s)&&g(f))e?s[a]=m:s.push(m);else try{i?Object.defineProperty(s,a,Object.getOwnPropertyDescriptor(f,a)):s[a]=f[a]}catch{}}})}),s}function K(...n){return j(n,(t,r,e)=>!0,!1,!1,!1)}function E(n,t=!0){return g(n)?n:!t&&w(n)?[n]:n!==!1&&n!==0&&_t(n)?[]:bt(n)?Array.prototype.slice.call(n):w(n)?Object.values(n):[n]}function tt(n,t,r={},e={}){t=E(t).slice();for(var i=n;!N(i)&&!Y(i)&&t.length;){var o=t.shift();if(!(r.get?r.get(i,o):A(i)?o in i:i[o])){e.exists=!1;return}i=r.get?r.get(i,o):i[o]}return e.exists=!0,i}function vt(n,t,r,e={},i={}){let o=(c,m,u)=>i.set?i.set(c,m,u):(C(t[f])&&g(c)?c.push(u):c[m]=u,!0);t=E(t);for(var s=n,f=0;f<t.length;f++)if(f<t.length-1){if(!s||!A(s)&&!b(s))return!1;var l=tt(s,t[f],i);if(!A(l)){if(i.buildTree===!1)return!1;l=b(i.buildTree)?i.buildTree(f):C(t[f+1])?[]:{};var a=o(s,t[f],l);if(!a)return!1}s=l}else return o(s,t[f],r)}var et=class{constructor(t,r=!1){Object.defineProperty(this,"window",{value:t}),Object.defineProperty(this,"readCallbacks",{value:new Set}),Object.defineProperty(this,"writeCallbacks",{value:new Set}),Object.defineProperty(this,"_synthesis",{value:0,writable:!0}),!r&&this.window.requestAnimationFrame?this._loop():this._synthesis++}get synthesis(){return this._synthesis}async synthesizeWhile(t){this._synthesis++,this._fulfill();let r=await t();return this._synthesis--,r}_fulfill(){for(let t of this.readCallbacks)t(),this.readCallbacks.delete(t);for(let t of this.writeCallbacks)t(),this.writeCallbacks.delete(t)}_loop(){this.window.requestAnimationFrame(()=>{this._fulfill(),this._loop()})}onread(t,r=!1){if(r)return new Promise(e=>{this.synthesis?e(t()):this.readCallbacks.add(()=>{e(t())})});this.synthesis?Promise.resolve().then(t):this.readCallbacks.add(t)}onwrite(t,r=!1){if(r)return new Promise(e=>{this.synthesis?e(t()):this.writeCallbacks.add(()=>{e(t())})});this.synthesis?Promise.resolve().then(t):this.writeCallbacks.add(t)}cycle(t,r,e){this.onread(()=>{let i=t(e),o=s=>{s!==void 0&&this.onwrite(()=>{let f=r(s,e),l=a=>{a!==void 0&&this.cycle(t,r,a)};f instanceof Promise?f.then(l):l(f)})};i instanceof Promise?i.then(o):o(i)})}};function Nt(n){return(n=n.trim())&&n.startsWith("(")&&n.endsWith(")")}function pt(n,t,r,e=!0){r=(Array.isArray(r)?r:[r]).map(s=>(s+"").replace("(",e?"(.//":"(./")).join("|");let i=[],o;try{let s=n.document.evaluate(r,t,null,n.XPathResult.ANY_TYPE);for(;o=s.iterateNext();)i.push(o)}catch{}return i}function Ht(n,t,r){r=(Array.isArray(r)?r:[r]).map(e=>(e+"").replace("(","(self::")).join("|");try{return n.document.evaluate(`${r}`,t,null,n.XPathResult.BOOLEAN_TYPE).booleanValue}catch{}}function rt(n,t,r,e=!1){let i=t.getRootNode(),o=r.getRootNode();return i===o?t.contains(r):e&&o instanceof n.ShadowRoot?rt(n,t,o.host,e):!1}function Dt(n,t="|"){return[...n].reduce(([r,e,i,o],s)=>!r&&e===0&&(Array.isArray(t)?t:[t]).includes(s)?[r,e,[""].concat(i)]:(!r&&["(","[","{"].includes(s)&&!i[0].endsWith("\\")&&e++,!r&&[")","]","}"].includes(s)&&!i[0].endsWith("\\")&&e--,['"',"'","`"].includes(s)&&!i[0].endsWith("\\")&&(r=r===s?null:r||s),i[0]+=s,[r,e,i]),[null,0,[""]])[2].reverse()}var T=class{constructor(t){this.content=t,this.type=typeof t=="string"?"selector":"instance",this.kind=this.type==="instance"?null:Nt(t)?"xpath":"css",this.kind==="xpath"&&(this.isXpathAttr=Dt(t.trim().slice(1,-1),"@").length>1)}toString(){return this.content}};var B=class{constructor(t,r,e){this.context=t,this.namespace=r,this.window=t.defaultView||t.ownerDocument?.defaultView||e,this.document=this.window.document,this.webqit=this.window.webqit,Object.defineProperty(this,"#",{value:{}})}resolveArgs(t){if(b(t[0])?t=[[],...t]:w(t[0])&&!(t[0]instanceof T)&&t.length===1?t=[[],void 0,t[0]]:w(t[1])&&t.length===2?t=[E(t[0],!1),void 0,t[1]]:t[0]=E(t[0],!1),t[0].filter(r=>typeof r!="string"&&!(r instanceof T)&&!(r instanceof this.window.Node)).length)throw new Error("Argument #2 must be either a string or a Node object, or a list of those.");return t[0]=t[0].map(r=>r instanceof T?r:new T(r)),t}registry(...t){return S("realdom.realtime",this.window,this.namespace,...t)}createSignalGenerator(){return{generate(){return this.lastController?.abort(),this.lastController=new AbortController,{signal:this.lastController.signal}},disconnect(){this.lastController?.abort()}}}forEachMatchingContext(t,r,e){let{window:i}=this,o=Array.isArray(r)?r:[r],s=new Set;for(let[f,l]of this.registry(t))for(let[a,c]of l){let m=o.filter(u=>rt(i,a,u.target,f==="cross-roots")?["subtree","cross-roots"].includes(f)||u.target===a:!1);if(!!m.length){Array.isArray(r)||(m=m[0]);for(let u of c)s.add([u,m,a])}}for(let[f,l,a]of[...s].reverse())e.call(i,f,l,a)}disconnectables(t,...r){let e={disconnect(){r.forEach(i=>i&&b(i.disconnect)&&i.disconnect()||b(i)&&i()||w(i)&&(i.disconnected=!0))}};return t&&t.addEventListener("abort",()=>e.disconnect()),e}};var F=class extends B{constructor(t,...r){super(t,"attr",...r)}get(t,r=void 0,e={}){let i=typeof t=="string"||t instanceof T;[t=[],r=void 0,e={}]=this.resolveArgs(arguments);let{context:o}=this,s=Wt(o,t);if(!r)return s;let f=e.lifecycleSignals&&this.createSignalGenerator();if(i)for(let l of s){let a=f?.generate()||{};r(l,a,o)}else{let l=f?.generate()||{};r(s,l,o)}if(e.live){f&&(e={...e,signalGenerator:f});let l=this.observe(i?t[0]:t,r,{newValue:!0,...e});return this.disconnectables(e.signal,l)}}observe(t,r,e={}){let i=typeof t=="string"||t instanceof T;if([t=[],r,e={}]=this.resolveArgs(arguments),["sync","intercept"].includes(e.timing))return this.observeSync(i?t[0]:t,r,e);if(e.timing&&e.timing!=="async")throw new Error(`Timing option "${e.timing}" invalid.`);let{context:o,window:s,webqit:f}=this;e.eventDetails&&!f.realdom.attrInterceptionHooks?.intercepting&&Rt.call(s,"intercept",()=>{});let l=new s.MutationObserver(u=>{u=Ft(u).map(d=>Ut.call(s,d)),$t.call(s,m,u,o)}),a={attributes:!0,attributeOldValue:e.oldValue,subtree:e.subtree&&!0};t.length&&(a.attributeFilter=t.map(u=>u+"")),l.observe(o,a);let c=e.signalGenerator||e.lifecycleSignals&&this.createSignalGenerator(),m={context:o,spec:t,callback:r,params:e,atomics:new Map,originalFilterIsString:i,signalGenerator:c,disconnectable:l};return this.disconnectables(e.signal,l,c)}observeSync(t,r,e={}){let i=typeof t=="string"||t instanceof T;[t,r,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 f=e.timing==="intercept"?"intercept":"sync",l=e.subtree==="cross-roots"?"cross-roots":e.subtree?"subtree":"children";this.registry(f).size||Rt.call(s,f,y=>{this.forEachMatchingContext(f,y,$t)});let a={disconnect(){d.delete(m),d.size||u.delete(o)}},c=e.signalGenerator||e.lifecycleSignals&&this.createSignalGenerator(),m={context:o,spec:t,callback:r,params:e,atomics:new Map,originalFilterIsString:i,signalGenerator:c,disconnectable:a},u=this.registry(f,l);u.has(o)||u.set(o,new Set);let d=u.get(o);return d.add(m),this.disconnectables(e.signal,a,c)}};function Ft(n){return n.reduce((t,r,e)=>t[e-1]?.attributeName===r.attributeName||S(r.target,"internalAttrInteractions").get(r.attributeName)?t:t.concat(r),[])}function $t(n,t){let{context:r,spec:e,callback:i,params:o,atomics:s,originalFilterIsString:f,signalGenerator:l}=n,a=e.map(u=>u+"");if(o.atomic&&!s.size?t=Wt(r,e,t):o.timing!=="async"&&e.length&&(t=t.filter(u=>a.includes(u.name))),!t.length)return;o.newValue===null&&o.oldValue===null&&o.eventDetails||(t=t.map(u=>{let d;return o.eventDetails||({event:d,...u}=u),!o.oldValue&&"oldValue"in u&&({oldValue:d,...u}=u),!o.newValue&&"value"in u?{value:d,...u}=u:o.newValue&&typeof u.value>"u"&&(u={...u,value:ht(u.target,u.name,()=>u.target.getAttribute(u.name))}),u})),o.atomic&&(t.forEach(u=>s.set(u.name,u)),t=Array.from(s.entries()).map(([,u])=>u));let c=f?t[0]:t,m=l?.generate()||{};i(c,m,r)}function ht(n,t,r){let e=S(n,"internalAttrInteractions").get(t);S(n,"internalAttrInteractions").set(t,!0);let i=r();return S(n,"internalAttrInteractions").set(t,e),i}function Wt(n,t,r=[]){let e={event:null,type:"attribute"};return t.length?t.map(o=>(o=o+"",r.find(s=>s.name===o)||{target:n,name:o,value:ht(n,o,()=>n.getAttribute(o)),...e})):Array.from(n.attributes).map(o=>r.find(s=>s.name===o.nodeName)||{target:n,name:o.nodeName,value:ht(n,o.nodeName,()=>o.nodeValue),...e})}function Ut({target:n,attributeName:t,value:r,oldValue:e}){let s=(this.webqit.realdom.attrInterceptionRecords?.get(n)||{})[t]?.[0]||"mutation";return{target:n,name:t,value:r,oldValue:e,type:"observation",event:s}}function Rt(n,t){let r=this,{webqit:e,document:i,Element:o}=r;e.realdom.attrInterceptionHooks||Object.defineProperty(e.realdom,"attrInterceptionHooks",{value:new Map}),e.realdom.attrInterceptionHooks.has(n)||e.realdom.attrInterceptionHooks.set(n,new Set),e.realdom.attrInterceptionHooks.get(n).add(t);let s=()=>e.realdom.attrInterceptionHooks.get(n).delete(t);if(e.realdom.attrInterceptionHooks?.intercepting)return s;console.warn("Attr mutation APIs are now being intercepted."),e.realdom.attrInterceptionHooks.intercepting=!0,Object.defineProperty(e.realdom,"attrInterceptionRecords",{value:new Map});let f=(c,m)=>{e.realdom.attrInterceptionRecords.has(c.target)||e.realdom.attrInterceptionRecords.set(c.target,{});let u=e.realdom.attrInterceptionRecords.get(c.target);if(u[c.name]=u[c.name]||[],u[c.name].unshift(c.event),S(c.target,"internalAttrInteractions").get(c.name))return m();e.realdom.attrInterceptionHooks.get("intercept")?.forEach(y=>y([c]));let d=m();return e.realdom.attrInterceptionHooks.get("sync")?.forEach(y=>y([c])),d};new r.MutationObserver(c=>{c=c.filter(m=>!(r.webqit.realdom.attrInterceptionRecords?.get(m.target)||{})[m.attributeName]?.shift()),c=Ft(c).map(m=>Ut.call(r,m)),c.length&&(e.realdom.attrInterceptionHooks.get("intercept")?.forEach(m=>m(c)),e.realdom.attrInterceptionHooks.get("sync")?.forEach(m=>m(c)))}).observe(i,{attributes:!0,subtree:!0,attributeOldValue:!0});let a=Object.create(null);return["setAttribute","removeAttribute","toggleAttribute"].forEach(c=>{a[c]=o.prototype[c],o.prototype[c]=function(...m){let u,d=ht(this,m[0],()=>this.getAttribute(m[0]));["setAttribute","toggleAttribute"].includes(c)&&(u=m[1]),c==="toggleAttribute"&&u===void 0&&(u=d===null);let y={target:this,name:m[0],value:u,oldValue:d,type:"interception",event:[this,c]};return f(y,()=>a[c].call(this,...m))}}),s}var nt=class extends B{constructor(t,...r){super(t,"tree",...r)}attr(t,r=void 0,e={}){let{context:i,window:o}=this;return new F(i,o).get(...arguments)}query(t,r=void 0,e={}){[t,r=void 0,e={}]=this.resolveArgs(arguments);let{context:i}=this,o=new Map,s=a=>(o.has(a)||o.set(a,{target:a,entrants:[],exits:[],type:"query",event:null}),o.get(a));if(!e.generation||e.generation==="entrants"){if(!t.length)[...i.children].forEach(a=>s(i).entrants.push(a));else if(t.every(a=>a.type==="selector")){let[a,c]=t.reduce(([u,d],y)=>y.kind==="xpath"?[u,d.concat(y)]:[u.concat(y),d],[[],[]]),m=[];e.subtree?(a.length&&m.push(...i.querySelectorAll(a.join(","))),c.length&&m.push(...pt(this.window,i,c))):(a.length&&m.push(...[...i.children].filter(u=>u.matches(a))),c.length&&m.push(...pt(this.window,i,c,!1))),m.forEach(u=>s(u.parentNode||i).entrants.push(u))}}if(!r)return o;let f={disconnected:!1},l=r&&e.lifecycleSignals&&this.createSignalGenerator();for(let[,a]of o){if(f.disconnected)break;let c=l?.generate()||{};r(a,c,i)}if(e.live){l&&(e={...e,signalGenerator:l});let a=this.observe(t,r,e);return this.disconnectables(e.signal,f,a)}return this.disconnectables(e.signal,f,l)}children(t,r=void 0,e={}){return[t,r=void 0,e={}]=this.resolveArgs(arguments),this.query(t,r,{...e,subtree:!1})}subtree(t,r=void 0,e={}){return[t,r=void 0,e={}]=this.resolveArgs(arguments),this.query(t,r,{...e,subtree:!0})}observe(t,r,e={}){if([t,r,e={}]=this.resolveArgs(arguments),["sync","intercept"].includes(e.timing))return this.observeSync(t,r,e);if(e.timing&&e.timing!=="async")throw new Error(`Timing option "${e.timing}" invalid.`);let{context:i,window:o,webqit:s,document:f}=this;e.eventDetails&&(s.realdom.domInterceptionRecordsAlwaysOn=!0),(f.readyState==="loading"||s.realdom.domInterceptionRecordsAlwaysOn)&&!s.realdom.domInterceptionHooks?.intercepting&&Gt.call(o,"sync",()=>{});let l=new o.MutationObserver(m=>m.forEach(u=>{St.call(o,c,Bt.call(o,u),i)}));l.observe(i,{childList:!0,subtree:e.subtree&&!0});let a=e.signalGenerator||e.lifecycleSignals&&this.createSignalGenerator(),c={context:i,spec:t,callback:r,params:e,signalGenerator:a,disconnectable:l};if(e.staticSensitivity){let m=Vt.call(o,c);return this.disconnectables(e.signal,l,a,m)}return this.disconnectables(e.signal,l,a)}observeSync(t,r,e={}){[t,r,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",f=e.subtree==="cross-roots"?"cross-roots":e.subtree?"subtree":"children";this.registry(s).size||Gt.call(o,s,y=>{this.forEachMatchingContext(s,y,St)});let l=new o.MutationObserver(y=>y.forEach(x=>{Array.isArray((x=Bt.call(o,x)).event)||St.call(o,m,x,i)}));l.observe(i,{childList:!0,subtree:e.subtree&&!0});let a={disconnect(){l.disconnect(),d.delete(m),d.size||u.delete(i)}},c=e.signalGenerator||e.lifecycleSignals&&this.createSignalGenerator(),m={context:i,spec:t,callback:r,params:e,signalGenerator:c,disconnectable:a},u=this.registry(s,f);u.has(i)||u.set(i,new Set);let d=u.get(i);if(d.add(m),e.staticSensitivity){let y=Vt.call(o,m);return this.disconnectables(e.signal,a,c,y)}return this.disconnectables(e.signal,a,c)}track(t,r,e={}){return e={subtree:!0,...e},this.observe(t,i=>{i.entrants.length&&r(!0,Array.isArray(t)?i.entrants:i.entrants[0]),i.exits.length&&r(!1,Array.isArray(t)?i.exits:i.exits[0])},e)}};function Vt(n){let t=this,{context:r,spec:e,callback:i,params:o,signalGenerator:s}=n,f=e.filter(d=>d.kind==="css"),l=d=>d.match(/\.([\w-]+)/g)?.length?["class"]:[],a=d=>d.match(/#([\w-]+)/g)?.length?["id"]:[],c=d=>[...d.matchAll(/\[([^\=\]]+)(\=[^\]]+)?\]/g)].map(y=>y[1]).concat(l(d)).concat(a(d));if(!(n.$attrs=Array.from(new Set(f.filter(d=>(d+"").includes("[")).reduce((d,y)=>d.concat(c(y+"")),[])))).length)return;let m=new Set,u=new Set;return m.push=d=>(u.delete(d),m.add(d)),u.push=d=>(m.delete(d),u.add(d)),n.$deliveryCache={entrants:m,exits:u},new F(r,t).observe(n.$attrs,d=>{let y=new Map,x=_=>(y.has(_)||y.set(_,{target:_,entrants:[],exits:[],type:"static",event:null}),y.get(_)),lt=new WeakMap,p=_=>(lt.has(_)||lt.set(_,f.some(v=>_.matches(v+""))),lt.get(_));for(let _ of d)["entrants","exits"].forEach(v=>{o.generation&&v!==o.generation||n.$deliveryCache[v].has(_.target)||(v==="entrants"?!p(_.target):p(_.target))||(n.$deliveryCache[v].push(_.target),x(_.target)[v].push(_.target),x(_.target).event=_.event)});for(let[,_]of y){let v=s?.generate()||{};i(_,v,r)}},{subtree:o.subtree,timing:o.timing,eventDetails:o.eventDetails})}function St(n,t){let{context:r,spec:e,callback:i,params:o,signalGenerator:s,$deliveryCache:f}=n,l={...t,entrants:[],exits:[]};if(o.eventDetails||delete l.event,["entrants","exits"].forEach(c=>{if(!(o.generation&&c!==o.generation)&&(e.length?l[c]=ge.call(this,e,o.subtree==="cross-roots",t[c],t.event!=="parse"):l[c]=[...t[c]],!!f))for(let m of l[c])f[c].push(m)}),!l.entrants.length&&!l.exits.length)return;let a=s?.generate()||{};i(l,a,r)}function ge(n,t,r,e){r=Array.isArray(r)?r:[...r];let i=(o,s)=>{if(s.type==="selector"){let f=s.isXpathAttr?[]:o.filter(l=>s.kind==="xpath"?Ht(this,l,s+""):l.matches&&l.matches(s+""));if((e||s.isXpathAttr)&&(f=o.reduce((l,a)=>s.kind==="xpath"?[...l,...pt(this,a,s,e)]:a.querySelectorAll?[...l,...a.querySelectorAll(s+"")]:l,f)),f.length)return f}else if(o.includes(s.content)||e&&o.some(f=>rt(this,f,s.content,t)))return[s.content]};return r.$$searchCache||(r.$$searchCache=new Map),n.reduce((o,s)=>{let f;return r.$$searchCache.has(s.content)?f=r.$$searchCache.get(s.content):(f=i(r,s)||[],s.type==="instance"&&r.$$searchCache.set(s.content,f)),o.concat(f)},[])}function Bt({target:n,addedNodes:t,removedNodes:r}){let e=this,i;return i=E(t).reduce((o,s)=>o||e.webqit.realdom.domInterceptionRecords?.get(s),null),i=E(r).reduce((o,s)=>o||e.webqit.realdom.domInterceptionRecords?.get(s),i),i=i||e.document.readyState==="loading"&&"parse"||"mutation",{target:n,entrants:t,exits:r,type:"observation",event:i}}function Gt(n,t){let r=this,{webqit:e,document:i,Node:o,CharacterData:s,Element:f,HTMLElement:l,HTMLTemplateElement:a,DocumentFragment:c}=r;e.realdom.domInterceptionHooks||Object.defineProperty(e.realdom,"domInterceptionHooks",{value:new Map}),e.realdom.domInterceptionNoRecurse||Object.defineProperty(e.realdom,"domInterceptionNoRecurse",{value:new Map}),e.realdom.domInterceptionHooks.has(n)||e.realdom.domInterceptionHooks.set(n,new Set),e.realdom.domInterceptionHooks.get(n).add(t);let m=()=>e.realdom.domInterceptionHooks.get(n).delete(t);if(e.realdom.domInterceptionHooks?.intercepting)return m;console.warn("DOM mutation APIs are now being intercepted."),e.realdom.domInterceptionHooks.intercepting=!0,Object.defineProperty(e.realdom,"domInterceptionRecords",{value:new Map});let u=(p,_,v)=>{e.realdom.domInterceptionNoRecurse.set(p,_);let h=v();return e.realdom.domInterceptionNoRecurse.delete(p),h},d=(p,_)=>{p.entrants.concat(p.exits).forEach(h=>{clearTimeout(e.realdom.domInterceptionRecords.get(h)?.timeout),e.realdom.domInterceptionRecords.set(h,p.event);let I=setTimeout(()=>{e.realdom.domInterceptionRecords.delete(h)},0);Object.defineProperty(p.event,"timeout",{value:I,configurable:!0})}),e.realdom.domInterceptionHooks.get("intercept")?.forEach(h=>h(p));let v=_();return e.realdom.domInterceptionHooks.get("sync")?.forEach(h=>h(p)),v},y={ShadowRoot:["innerHTML","setHTMLUnsafe"],DocumentFragment:["replaceChildren","append","prepend"],Document:["replaceChildren","append","prepend"],HTMLElement:["outerText","innerText"],Element:["append","prepend","before","after","insertAdjacentElement","insertAdjacentHTML","remove","replaceChildren","replaceWith","setHTMLUnsafe","innerHTML","outerHTML"],CharacterData:["before","after","remove","replaceWith"],Node:["insertBefore","replaceChild","removeChild","appendChild","textContent","nodeValue"]},x={ShadowRoot:Object.create(null),DocumentFragment:Object.create(null),Document:Object.create(null),HTMLElement:Object.create(null),Element:Object.create(null),CharacterData:Object.create(null),Node:Object.create(null)};return new Set(Object.values(y).reduce((p,_)=>p.concat(_),[])).forEach(p=>{Object.keys(y).forEach(h=>{if(!y[h].includes(p))return;let I=Object.getOwnPropertyDescriptor(r[h].prototype,p);!I||(Object.defineProperty(r[h].prototype,p,"value"in I?{...I,value:_}:{...I,set:v}),x[h][p]=I)});function _(...h){let I=Object.keys(x).find(M=>this instanceof r[M]&&p in x[M]),G=x[I],D=()=>G[p].value.call(this,...h);if(e.realdom.domInterceptionNoRecurse.get(this)===p)return D();let P=[],O=[],$=this;["insertBefore"].includes(p)?O=[h[0]]:["insertAdjacentElement","insertAdjacentHTML"].includes(p)?(O=[h[1]],["beforebegin","afterend"].includes(h[0])&&($=this.parentNode)):["setHTMLUnsafe","replaceChildren"].includes(p)?(P=[...this.childNodes],O=p==="replaceChildren"?[...h]:[h[0]]):["replaceWith","remove"].includes(p)?(P=[this],O=p==="replaceWith"?[...h]:[],$=this.parentNode):["replaceChild"].includes(p)?(P=[h[1]],O=[h[0]]):["removeChild"].includes(p)?P=[...h]:(O=[...h],["before","after"].includes(p)&&($=this.parentNode));let ct=p;if(["insertAdjacentHTML","setHTMLUnsafe"].includes(p)){let M=this.nodeName;if(p==="insertAdjacentHTML"&&["beforebegin","afterend"].includes(h[0])){if(!this.parentNode)return G[p].value.call(this,...h);M=this.parentNode.nodeName}let R=i.createElement(M);G.setHTMLUnsafe.value.call(R,O[0],p==="setHTMLUnsafe"?h[1]:{}),O=[...R.childNodes],p==="insertAdjacentHTML"?(ct="insertAdjacentElement",h[1]=new c,u(h[1],"append",()=>h[1].append(...R.childNodes))):(ct="replaceChildren",h=[...R.childNodes])}return d({target:$,entrants:O,exits:P,type:"interception",event:[this,p]},()=>G[ct].value.call(this,...h))}function v(h){let I=Object.keys(x).find(V=>this instanceof r[V]&&p in x[V]),G=x[I],D=()=>G[p].set.call(this,h);if(this instanceof HTMLScriptElement||e.realdom.domInterceptionNoRecurse.get(this)===p)return D();let P=[],O=[],$=this;if(["outerHTML","outerText"].includes(p)?(P=[this],$=this.parentNode):this instanceof a?($=this.content,P=[...this.content.childNodes]):P=[...this.childNodes],["outerHTML","innerHTML"].includes(p)){let V=this.nodeName;if(p==="outerHTML"){if(!this.parentNode)return D();V=this.parentNode.nodeName}let M=i.createElement(V.includes("-")?"div":V);if(u(M,p,()=>M[p]=h),O=this instanceof a?[...M.content.childNodes]:[...M.childNodes],this instanceof a&&this.hasAttribute("src")){let R=z=>z.reduce((k,L)=>L instanceof HTMLScriptElement?k.concat(L):L instanceof a?k.concat(R([L.content])):(k=k.concat(R([...L.querySelectorAll?.("template")||[]].map(Kt=>Kt.content))),k.concat(...L.querySelectorAll?.("script")||[])),[]);for(let z of R(O)){let k=i.createElement("script");[...z.attributes].forEach(L=>k.setAttribute(L.name,L.value)),k.textContent=z.textContent,u(z,"replaceWith",()=>z.replaceWith(k))}}p==="outerHTML"?(h=new c,u(h,"append",()=>h.append(...O)),D=()=>u(this,"replaceWith",()=>f.prototype.replaceWith.call(this,h))):this instanceof a?D=()=>u(this.content,"replaceChildren",()=>this.content.replaceChildren(...O)):D=()=>u(this,"replaceChildren",()=>f.prototype.replaceChildren.call(this,...O))}return d({target:$,entrants:O,exits:P,type:"interception",event:[this,p]},D)}}),m}function zt(){ye.call(this),_e.call(this),be.call(this)}function ye(){let n=this;n.CSS||(n.CSS={}),n.CSS.escape||(n.CSS.escape=t=>t.replace(/([\:@\~\$\&])/g,"\\$1"))}function _e(){let n=this;"isConnected"in n.Node.prototype||Object.defineProperty(n.Node.prototype,"isConnected",{get:function(){return!this.ownerDocument||!(this.ownerDocument.compareDocumentPosition(this)&this.DOCUMENT_POSITION_DISCONNECTED)}})}function be(){let n=this;n.Element.prototype.matches||(n.Element.prototype.matches=n.Element.prototype.matchesSelector||n.Element.prototype.mozMatchesSelector||n.Element.prototype.msMatchesSelector||n.Element.prototype.oMatchesSelector||n.Element.prototype.webkitMatchesSelector||function(t){for(var r=(this.document||this.ownerDocument).querySelectorAll(t),e=r.length;--e>=0&&r.item(e)!==this;);return e>-1})}function Xt(){let n=this;if(n.webqit||(n.webqit={}),n.webqit.realdom)return n.webqit.realdom;n.webqit.realdom={},zt.call(n),n.webqit.realdom.meta=(...r)=>we.call(n,...r),n.webqit.realdom.ready=(...r)=>Ct.call(n,...r),n.webqit.realdom.realtime=(r,e="dom")=>{if(e==="dom")return new nt(r,n);if(e==="attr")return new F(r,n)};let t=new et(n);return n.webqit.realdom.schedule=(r,...e)=>t[`on${r}`](...e),n.webqit.realdom.synthesizeWhile=(...r)=>t.synthesizeWhile(...r),n.webqit.realdom}function Ct(...n){let t="interactive",r;Q(n[0])?(t=n[0],b(n[1])&&(r=n[1])):b(n[0])&&(r=n[0]);let e={interactive:["interactive","complete"],complete:["complete"]};if(!e[t])throw new Error(`Invalid ready-state timing: ${t}.`);let i=this;if(!r)return i.webqit.realdom.readyStatePromises||(i.webqit.realdom.readyStatePromises={interactive:new Promise(o=>Ct.call(this,"interactive",o)),complete:new Promise(o=>Ct.call(this,"complete",o))}),i.webqit.realdom.readyStatePromises[t];if(e[t].includes(i.document.readyState))return r(i);i.webqit.realdom.readyStateCallbacks||(i.webqit.realdom.readyStateCallbacks={interactive:[],complete:[]},i.document.addEventListener("readystatechange",()=>{let o=i.document.readyState;for(let s of i.webqit.realdom.readyStateCallbacks[o].splice(0))s(i)},!1)),i.webqit.realdom.readyStateCallbacks[t].push(r)}function we(n){let t=this,r={},e;return(e=t.document.querySelector(`meta[name="${n}"]`))&&(r=(e.content||"").split(";").filter(i=>i).reduce((i,o)=>{let s=o.split("=").map(f=>f.trim());return vt(i,s[0].split("."),s[1]==="true"?!0:s[1]==="false"?!1:C(s[1])?parseInt(s[1]):s[1]),i},{})),{get name(){return n},get content(){return e.content},json(){return JSON.parse(JSON.stringify(r))}}}function gt(n,t){return typeof n!="string"?n:n.replace(/\w\S*/g,function(r){return r.charAt(0).toUpperCase()+(typeof t!==void 0&&t?r.substr(1).toLowerCase():r.substr(1))})}var W=(...n)=>S("oohtml",...n),q={};function Jt(n,t,r){let e=this,i=Xt.call(e);q.window=e,e.webqitConfig||(e.webqitConfig=i.meta("webqit").json()),e.webqit||(e.webqit={}),e.webqit.oohtml||(e.webqit.oohtml={}),e.webqit.oohtml.configs||(e.webqit.oohtml.configs={});let o=n.toUpperCase().replace("-","_");if(!e.webqit.oohtml.configs[o]){e.webqit.oohtml.configs[o]={};let s=e.webqit.oohtml.configs[o];K(2,s,r,t,i.meta(n).json()),e.webqitConfig.prefix&&Object.keys(s).forEach(f=>{Object.keys(s[f]).forEach(l=>{f==="api"&&typeof s[f][l]=="string"?s[f][l]=`${e.webqitConfig.prefix}${gt(s[f][l])}`:["attr","elements"].includes(f)&&s[f][l]?.startsWith("data-")===!1&&(s[f][l]=`${e.webqitConfig.prefix}-${s[f][l]}`)})})}return{config:e.webqit.oohtml.configs[o],realdom:i,window:e}}function Yt(){let{window:n}=q,{webqit:t}=n;if(t.DOMContextRequestEvent)return t.DOMContextRequestEvent;class r extends n.Event{constructor(...i){let o=i.pop();if(typeof o!="function")throw new Error("Callback must be provided.");let s=i.pop();if(!s?.kind)throw new Error('"options.kind" must be specified.');let f=["contextrequest","contextclaim"],l=i.pop()||f[0];if(!f.includes(l))throw new Error(`Invalid event type. Must be one of: ${f.join(",")}`);let{kind:a,detail:c,targetContext:m,live:u,signal:d,diff:y,...x}=s;super(l,{...x,bubbles:x.bubbles!==!1}),Object.defineProperty(this,"callback",{get:()=>o}),Object.defineProperty(this,"kind",{get:()=>a}),Object.defineProperty(this,"targetContext",{get:()=>m}),Object.defineProperty(this,"detail",{get:()=>c}),Object.defineProperty(this,"live",{get:()=>u}),Object.defineProperty(this,"signal",{get:()=>d}),Object.defineProperty(this,"diff",{get:()=>y}),Object.defineProperty(this,"options",{get:()=>x}),Object.defineProperty(this,"meta",{value:{}})}get target(){return super.target||this.meta.target}get answered(){return this.meta.answered||!1}respondWith(i){if(this.meta.answered=!0,this.diff){if("_prevValue"in this&&this._prevValue===i)return;Object.defineProperty(this,"_prevValue",{value:i,configurable:!0})}return this.callback(i)}}return t.DOMContextRequestEvent=r,r}var it=class extends AbortController{constructor(t){super(),t(r=>{let{window:{webqit:{Observer:e}}}=q;e.defineProperty(this,"value",{value:r,configurable:!0,enumerable:!0})},this)}};var ot=class extends Error{};var st=new Map,ft=class{static instance(t){return W(t).get("contexts::instance")||new this(t)}constructor(t){W(t).get("contexts::instance")?.dispose(),W(t).set("contexts::instance",this);let r={host:t,contexts:new Set};Object.defineProperty(this,"#",{get:()=>r})}get[Symbol.iterator](){return this["#"].contexts[Symbol.iterator]}get length(){return this["#"].contexts.size}find(...t){return[...this["#"].contexts].find(r=>typeof t[0]=="function"?t[0](r):r.constructor.kind===t[0]&&(t.length===1||r.detail===t[1]))}attach(t){if(!(t instanceof U))throw new TypeError("Context is not a valid DOMContext instance.");if(this.find(t.constructor.kind,t.detail))throw new ot(`Context of same kind "${t.constructor.kind}"${t.detail?` and detail "${t.detail}"`:""} already exists.`);this["#"].contexts.add(t),t.initialize(this["#"].host)}detach(t){t.dispose(this["#"].host),this["#"].contexts.delete(t)}request(...t){return new it((r,e)=>{typeof t[t.length-1]!="function"&&(t[t.length-1]?t.push(r):t[t.length-1]=r);let i;(i=t.find(l=>typeof l=="object"&&l))&&i.live&&(i.signal&&i.signal.addEventListener("abort",()=>e.abort()),t[t.indexOf(i)]={...i,signal:e.signal});let o=new(Yt())(...t);o.meta.target=this["#"].host;let s=this["#"].host.getRootNode(),f=l=>{if(l.stopImmediatePropagation(),l.meta.target=l.target,!l.answered){if(st.get(s)||st.set(s,new Set),l.type==="contextrequest"&&l.live)st.get(s).add(l);else if(l.type==="contextclaim"){let a=new Set;return st.get(s).forEach(c=>{!this["#"].host.contains(c.target)||!l.detail.matchEvent(c)||(st.get(s).delete(c),a.add(c))}),l.respondWith(a)}}};s.addEventListener(o.type,f),this["#"].host.dispatchEvent(o),s.removeEventListener(o.type,f)})}};var Tt=class{static createRequest(){return{kind:this.kind}}constructor(t=null){Object.defineProperty(this,"detail",{get:()=>t}),Object.defineProperty(this,"subscriptions",{value:new Set})}get configs(){let{window:{webqit:{oohtml:{configs:t}}}}=q;return t}get name(){return[q.window.Document,q.window.ShadowRoot].some(t=>this.host instanceof t)?1/0:this.host.getAttribute(this.configs.CONTEXT_API.attr.contextname)}subscribed(t){}handle(t){}unsubscribed(t){}matchEvent(t){return t.kind===this.constructor.kind&&(!t.targetContext||t.targetContext===this.name)}handleEvent(t){if(!(this.disposed||typeof t.respondWith!="function")){if(t.type==="contextclaim"){if(!(t.detail instanceof Tt)||t.target===this.host)return;let r=new Set;if(this.subscriptions.forEach(e=>{!t.target.contains(e.target)||!t.detail.matchEvent(e)||(this.subscriptions.delete(e),this.unsubscribed(e),r.add(e))}),r.size)return t.respondWith(r)}if(t.type==="contextrequest")return this.matchEvent(t)?(t.live&&(this.subscriptions.add(t),this.subscribed(t),t.signal?.addEventListener("abort",()=>{this.subscriptions.delete(t),this.unsubscribed(t)})),t.stopPropagation(),this.handle(t)):void 0}}initialize(t){this.host=t,this.disposed=!1,t.addEventListener("contextrequest",this),t.addEventListener("contextclaim",this);let{value:r}=ft.instance(t).request("contextclaim",{kind:this.constructor.kind,detail:this});return r?.forEach(e=>{this.subscriptions.add(e),this.subscribed(e),this.handle(e)}),this}dispose(t){return this.disposed=!0,t.removeEventListener("contextrequest",this),t.removeEventListener("contextclaim",this),this.subscriptions.forEach(r=>{this.subscriptions.delete(r),this.unsubscribed(r);let{target:e}=r;e.dispatchEvent(r)}),this}},U=Tt;ut(U,"kind");var H=class extends U{static createRequest(t=null){let r=super.createRequest();if(t?.startsWith("@")){let[e,...i]=i.slice(1).split(".").map(o=>o.trim());r.targetContext=e,r.detail=i.join(".")}else r.detail=t;return r}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:r}}}=q;t.meta.controller=r.reduce(this.bindingsObj,Array.isArray(t.detail)?t.detail:[t.detail],r.get,e=>{this.disposed||t.respondWith(e.value)},{live:t.live,signal:t.signal,descripted:!0})}unsubscribed(t){t.meta.controller?.abort()}};ut(H,"kind","bindings");function It(n={}){let{config:t,window:r}=Jt.call(this,"bindings-api",n,{attr:{bindingsreflection:"bindings"},api:{bind:"bind",bindings:"bindings"}});r.webqit.DOMBindingsContext=H,ve.call(r,t)}function Zt(n,t){let r=this,{webqit:{Observer:e,oohtml:{configs:{CONTEXT_API:i}}}}=r;if(!W(t).has("bindings")){let o=Object.create(null);W(t).set("bindings",o),e.observe(o,s=>{let f=Object.keys(o),l=t instanceof r.Document?t.documentElement:t,a=n.attr.bindingsreflection;f.length&&a&&l.setAttribute?l.setAttribute(n.attr.bindingsreflection,f.join(" ")):a&&l.setAttribute&&l.toggleAttribute(n.attr.bindingsreflection,!1);let c=t[i.api.contexts];for(let m of s)if(m.type==="delete"){let u=c.find(H.kind,m.key);u&&c.detach(u)}else c.find(H.kind,m.key)||c.attach(new H(m.key))})}return W(t).get("bindings")}function ve(n){let t=this,{webqit:{Observer:r}}=t;[t.Document.prototype,t.Element.prototype,t.ShadowRoot.prototype].forEach(e=>{let i=e===t.Document.prototype?"Document":e===t.ShadowRoot.prototype?"ShadowRoot":"Element";if(n.api.bind in e)throw new Error(`The ${i} prototype already has a "${n.api.bind}" API!`);if(n.api.bindings in e)throw new Error(`The ${i} prototype already has a "${n.api.bindings}" API!`);Object.defineProperty(e,n.api.bind,{value:function(o,s={}){return Ae.call(t,n,this,o,s)}}),Object.defineProperty(e,n.api.bindings,{get:function(){return r.proxy(Zt.call(t,n,this))}})})}function Ae(n,t,r,{merge:e,diff:i,namespace:o}={}){let s=this,{webqit:{Observer:f}}=s,l=Zt.call(this,n,t),a={diff:i,namespace:o},c=e?[]:f.ownKeys(l,a).filter(m=>!(m in r));return f.batch(l,()=>(c.length&&f.deleteProperties(l,c,a),f.set(l,r,a)),a)}It.call(window);})();
1
+ (()=>{var te=Object.defineProperty;var ee=(n,t,r)=>t in n?te(n,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):n[t]=r;var ut=(n,t,r)=>(ee(n,typeof t!="symbol"?t+"":t,r),r);function b(n){return!Array.isArray(n)&&typeof n=="object"&&n}function g(n){return Array.isArray(n)}function yt(n,t,r=null){return g(t)?n.filter(e=>r?t.filter(i=>r(e,i)).length:t.indexOf(e)!==-1):[]}function S(n,...t){if(globalThis.webqit||(globalThis.webqit={}),globalThis.webqit.refs||Object.defineProperty(globalThis.webqit,"refs",{value:new J}),!arguments.length)return globalThis.webqit.refs;let r=globalThis.webqit.refs.get(n);r||(r=new J,globalThis.webqit.refs.set(n,r));let e,i;for(;e=t.shift();)(i=r)&&!(r=r.get(e))&&(r=new J,i.set(e,r));return r}var J=class extends Map{constructor(...t){super(...t),this.observers=new Set}set(t,r){let e=super.set(t,r);return this.fire("set",t,r,t),e}delete(t){let r=super.delete(t);return this.fire("delete",t),r}has(t){return this.fire("has",t),super.has(t)}get(t){return this.fire("get",t),super.get(t)}keyNames(){return Array.from(super.keys())}observe(t,r,e){let i={type:t,key:r,callback:e};return this.observers.add(i),()=>this.observers.delete(i)}unobserve(t,r,e){if(Array.isArray(t)||Array.isArray(r))throw new Error('The "type" and "key" arguments can only be strings.');for(let i of this.observers)!(at([t,"*"],i.type)&&at([r,"*"],i.key)&&i.callback===e)||this.observers.delete(i)}fire(t,r,...e){for(let i of this.observers)!(at([t,"*"],i.type)&&at([r,"*"],i.key))||i.callback(...e)}},at=(n,t)=>Array.isArray(t)?yt(n,t).length:n.includes(t);function X(n){return typeof n=="function"}function Y(n){return n===null||n===""}function N(n){return arguments.length&&(n===void 0||typeof n>"u")}function A(n){return Array.isArray(n)||typeof n=="object"&&n||X(n)}function _t(n){return Y(n)||N(n)||n===!1||n===0||A(n)&&!Object.keys(n).length}function _(n){return X(n)||n&&{}.toString.call(n)==="[object function]"}function Z(n){return n instanceof Number||typeof n=="number"}function C(n){return Z(n)||n!==!0&&n!==!1&&n!==null&&n!==""&&!isNaN(n*1)}function Q(n){return n instanceof String||typeof n=="string"&&n!==null}function wt(n){return!Q(n)&&!N(n.length)}function mt(n,...t){return t.forEach(r=>{n.indexOf(r)<0&&n.push(r)}),n}function bt(e,t){t=t||Object.prototype,t=t&&!g(t)?[t]:t;for(var r=[],e=e;e&&(!t||t.indexOf(e)<0)&&e.name!=="default";)r.push(e),e=e?Object.getPrototypeOf(e):null;return r}function xt(n,t){var r=[];return bt(n,t).forEach(e=>{mt(r,...Object.getOwnPropertyNames(e))}),r}function j(n,t,r=!1,e=!1,i=!1){var s=0,o=n.shift();if((C(o)||o===!0||o===!1)&&(s=o,o=n.shift()),!n.length)throw new Error("_merge() requires two or more array/objects.");return n.forEach((f,l)=>{!A(f)&&!_(f)||(r?xt(f):Object.keys(f)).forEach(u=>{if(!!t(u,o,f,l)){var c=o[u],m=f[u];if((g(c)&&g(m)||b(c)&&b(m))&&(s===!0||s>0))o[u]=g(c)&&g(m)?[]:{},j([C(s)?s-1:s,o[u],c,m],t,r,e,i);else if(g(o)&&g(f))e?o[u]=m:o.push(m);else try{i?Object.defineProperty(o,u,Object.getOwnPropertyDescriptor(f,u)):o[u]=f[u]}catch{}}})}),o}function K(...n){return j(n,(t,r,e)=>!0,!1,!1,!1)}function E(n,t=!0){return g(n)?n:!t&&b(n)?[n]:n!==!1&&n!==0&&_t(n)?[]:wt(n)?Array.prototype.slice.call(n):b(n)?Object.values(n):[n]}function tt(n,t,r={},e={}){t=E(t).slice();for(var i=n;!N(i)&&!Y(i)&&t.length;){var s=t.shift();if(!(r.get?r.get(i,s):A(i)?s in i:i[s])){e.exists=!1;return}i=r.get?r.get(i,s):i[s]}return e.exists=!0,i}function vt(n,t,r,e={},i={}){let s=(c,m,a)=>i.set?i.set(c,m,a):(C(t[f])&&g(c)?c.push(a):c[m]=a,!0);t=E(t);for(var o=n,f=0;f<t.length;f++)if(f<t.length-1){if(!o||!A(o)&&!_(o))return!1;var l=tt(o,t[f],i);if(!A(l)){if(i.buildTree===!1)return!1;l=_(i.buildTree)?i.buildTree(f):C(t[f+1])?[]:{};var u=s(o,t[f],l);if(!u)return!1}o=l}else return s(o,t[f],r)}var et=class{constructor(t,r=!1){Object.defineProperty(this,"window",{value:t}),Object.defineProperty(this,"readCallbacks",{value:new Set}),Object.defineProperty(this,"writeCallbacks",{value:new Set}),Object.defineProperty(this,"_synthesis",{value:0,writable:!0}),!r&&this.window.requestAnimationFrame?this._loop():this._synthesis++}get synthesis(){return this._synthesis}async synthesizeWhile(t){this._synthesis++,this._fulfill();let r=await t();return this._synthesis--,r}_fulfill(){for(let t of this.readCallbacks)t(),this.readCallbacks.delete(t);for(let t of this.writeCallbacks)t(),this.writeCallbacks.delete(t)}_loop(){this.window.requestAnimationFrame(()=>{this._fulfill(),this._loop()})}onread(t,r=!1){if(r)return new Promise(e=>{this.synthesis?e(t()):this.readCallbacks.add(()=>{e(t())})});this.synthesis?Promise.resolve().then(t):this.readCallbacks.add(t)}onwrite(t,r=!1){if(r)return new Promise(e=>{this.synthesis?e(t()):this.writeCallbacks.add(()=>{e(t())})});this.synthesis?Promise.resolve().then(t):this.writeCallbacks.add(t)}cycle(t,r,e){this.onread(()=>{let i=t(e),s=o=>{o!==void 0&&this.onwrite(()=>{let f=r(o,e),l=u=>{u!==void 0&&this.cycle(t,r,u)};f instanceof Promise?f.then(l):l(f)})};i instanceof Promise?i.then(s):s(i)})}};function Nt(n){return(n=n.trim())&&n.startsWith("(")&&n.endsWith(")")}function pt(n,t,r,e=!0){r=(Array.isArray(r)?r:[r]).map(o=>(o+"").replace("(",e?"(.//":"(./")).join("|");let i=[],s;try{let o=n.document.evaluate(r,t,null,n.XPathResult.ANY_TYPE);for(;s=o.iterateNext();)i.push(s)}catch{}return i}function Ht(n,t,r){r=(Array.isArray(r)?r:[r]).map(e=>(e+"").replace("(","(self::")).join("|");try{return n.document.evaluate(`${r}`,t,null,n.XPathResult.BOOLEAN_TYPE).booleanValue}catch{}}function rt(n,t,r,e=!1,i=null){let s=i?.get(t)?.get(r);if(typeof s<"u")return s;let o=u=>(i?.has(t)||i?.set(t,new WeakMap),i?.get(t)?.set(r,u),u),f=t.getRootNode(),l=r.getRootNode();return f===l?o(t.contains(r)):e&&l instanceof n.ShadowRoot?o(rt(n,t,l.host,e,i)):o(!1)}function $t(n,t="|"){return[...n].reduce(([r,e,i,s],o)=>!r&&e===0&&(Array.isArray(t)?t:[t]).includes(o)?[r,e,[""].concat(i)]:(!r&&["(","[","{"].includes(o)&&!i[0].endsWith("\\")&&e++,!r&&[")","]","}"].includes(o)&&!i[0].endsWith("\\")&&e--,['"',"'","`"].includes(o)&&!i[0].endsWith("\\")&&(r=r===o?null:r||o),i[0]+=o,[r,e,i]),[null,0,[""]])[2].reverse()}var T=class{constructor(t){this.content=t,this.type=typeof t=="string"?"selector":"instance",this.kind=this.type==="instance"?null:Nt(t)?"xpath":"css",this.kind==="xpath"&&(this.isXpathAttr=$t(t.trim().slice(1,-1),"@").length>1)}toString(){return this.content}};var B=class{constructor(t,r,e){this.context=t,this.namespace=r,this.window=t.defaultView||t.ownerDocument?.defaultView||e,this.document=this.window.document,this.webqit=this.window.webqit,Object.defineProperty(this,"#",{value:{}})}resolveArgs(t){if(_(t[0])?t=[[],...t]:b(t[0])&&!(t[0]instanceof T)&&t.length===1?t=[[],void 0,t[0]]:b(t[1])&&t.length===2?t=[E(t[0],!1),void 0,t[1]]:t[0]=E(t[0],!1),t[0].filter(r=>typeof r!="string"&&!(r instanceof T)&&!(r instanceof this.window.Node)).length)throw new Error("Argument #2 must be either a string or a Node object, or a list of those.");return t[0]=t[0].map(r=>r instanceof T?r:new T(r)),t}registry(...t){return S("realdom.realtime",this.window,this.namespace,...t)}createSignalGenerator(){return{generate(){return this.lastController?.abort(),this.lastController=new AbortController,{signal:this.lastController.signal}},disconnect(){this.lastController?.abort()}}}forEachMatchingContext(t,r,e){let{window:i}=this,s=new Set,o=new WeakMap;for(let[f,l]of this.registry(t)){let u=[].concat(r).filter(m=>rt(i,f.context,m.target,f.params.subtree==="cross-roots",o));if(!u.length)continue;let c=[f,Array.isArray(r)?u:u[0]];l?s.add(c):e.call(i,...c)}for(let f of s)e.call(i,...f);s.clear()}disconnectables(t,...r){let e={disconnect(){r.forEach(i=>i&&_(i.disconnect)&&i.disconnect()||_(i)&&i()||b(i)&&(i.disconnected=!0))}};return t&&t.addEventListener("abort",()=>e.disconnect()),e}};var F=class extends B{type="attr";constructor(t,...r){super(t,"attr",...r)}get(t,r=void 0,e={}){let i=typeof t=="string"||t instanceof T;[t=[],r=void 0,e={}]=this.resolveArgs(arguments);let{context:s}=this,o=Wt(s,t);if(!r)return o;let f=e.lifecycleSignals&&this.createSignalGenerator();if(i)for(let l of o){let u=f?.generate()||{};r(l,u,s)}else{let l=f?.generate()||{};r(o,l,s)}if(e.live){f&&(e={...e,signalGenerator:f});let l=this.observe(i?t[0]:t,r,{newValue:!0,...e});return this.disconnectables(e.signal,l)}}observe(t,r,e={}){let i=typeof t=="string"||t instanceof T;if([t=[],r,e={}]=this.resolveArgs(arguments),["sync","intercept"].includes(e.timing))return this.observeSync(i?t[0]:t,r,e);if(e.timing&&e.timing!=="async")throw new Error(`Timing option "${e.timing}" invalid.`);let{context:s,window:o,webqit:f}=this;e.eventDetails&&!f.realdom.attrInterceptionHooks?.intercepting&&Rt.call(o,"intercept",()=>{});let l=new o.MutationObserver(a=>{a=Ft(a).map(p=>Ut.call(o,p)),Dt.call(o,m,a,s)}),u={attributes:!0,attributeOldValue:e.oldValue,subtree:e.subtree&&!0};t.length&&(u.attributeFilter=t.map(a=>a+"")),l.observe(s,u);let c=e.signalGenerator||e.lifecycleSignals&&this.createSignalGenerator(),m={context:s,spec:t,callback:r,params:e,atomics:new Map,originalFilterIsString:i,signalGenerator:c,disconnectable:l};return this.disconnectables(e.signal,l,c)}observeSync(t,r,e={}){let i=typeof t=="string"||t instanceof T;[t,r,e={}]=this.resolveArgs(arguments);let{context:s,window:o}=this;if(e.timing&&!["sync","intercept"].includes(e.timing))throw new Error(`Timing option "${e.timing}" invalid.`);let f=e.timing==="intercept"?"intercept":"sync";this.registry(f).size||Rt.call(o,f,a=>{this.forEachMatchingContext(f,a,Dt)});let l={disconnect(){m.delete(c)}},u=e.signalGenerator||e.lifecycleSignals&&this.createSignalGenerator(),c={context:s,spec:t,callback:r,params:e,atomics:new Map,originalFilterIsString:i,signalGenerator:u,disconnectable:l},m=this.registry(f);return m.set(c,!!c.params.deferred),this.disconnectables(e.signal,l,u)}};function Ft(n){return n.reduce((t,r,e)=>t[e-1]?.attributeName===r.attributeName||S(r.target,"internalAttrInteractions").get(r.attributeName)?t:t.concat(r),[])}function Dt(n,t){let{context:r,spec:e,callback:i,params:s,atomics:o,originalFilterIsString:f,signalGenerator:l}=n,u=e.map(a=>a+"");if(s.atomic&&!o.size?t=Wt(r,e,t):s.timing!=="async"&&e.length&&(t=t.filter(a=>u.includes(a.name))),!t.length)return;s.newValue===null&&s.oldValue===null&&s.eventDetails||(t=t.map(a=>{let p;return s.eventDetails||({event:p,...a}=a),!s.oldValue&&"oldValue"in a&&({oldValue:p,...a}=a),!s.newValue&&"value"in a?{value:p,...a}=a:s.newValue&&typeof a.value>"u"&&(a={...a,value:ht(a.target,a.name,()=>a.target.getAttribute(a.name))}),a})),s.atomic&&(t.forEach(a=>o.set(a.name,a)),t=Array.from(o.entries()).map(([,a])=>a));let c=f?t[0]:t,m=l?.generate()||{};i(c,m,r)}function ht(n,t,r){let e=S(n,"internalAttrInteractions").get(t);S(n,"internalAttrInteractions").set(t,!0);let i=r();return S(n,"internalAttrInteractions").set(t,e),i}function Wt(n,t,r=[]){let e={event:null,type:"attribute"};return t.length?t.map(s=>(s=s+"",r.find(o=>o.name===s)||{target:n,name:s,value:ht(n,s,()=>n.getAttribute(s)),...e})):Array.from(n.attributes).map(s=>r.find(o=>o.name===s.nodeName)||{target:n,name:s.nodeName,value:ht(n,s.nodeName,()=>s.nodeValue),...e})}function Ut({target:n,attributeName:t,value:r,oldValue:e}){let o=(this.webqit.realdom.attrInterceptionRecords?.get(n)||{})[t]?.[0]||"mutation";return{target:n,name:t,value:r,oldValue:e,type:"observation",event:o}}function Rt(n,t){let r=this,{webqit:e,document:i,Element:s}=r;e.realdom.attrInterceptionHooks||Object.defineProperty(e.realdom,"attrInterceptionHooks",{value:new Map}),e.realdom.attrInterceptionHooks.has(n)||e.realdom.attrInterceptionHooks.set(n,new Set),e.realdom.attrInterceptionHooks.get(n).add(t);let o=()=>e.realdom.attrInterceptionHooks.get(n).delete(t);if(e.realdom.attrInterceptionHooks?.intercepting)return o;console.warn("Attr mutation APIs are now being intercepted."),e.realdom.attrInterceptionHooks.intercepting=!0,Object.defineProperty(e.realdom,"attrInterceptionRecords",{value:new Map});let f=(c,m)=>{e.realdom.attrInterceptionRecords.has(c.target)||e.realdom.attrInterceptionRecords.set(c.target,{});let a=e.realdom.attrInterceptionRecords.get(c.target);if(a[c.name]=a[c.name]||[],a[c.name].unshift(c.event),S(c.target,"internalAttrInteractions").get(c.name))return m();e.realdom.attrInterceptionHooks.get("intercept")?.forEach(w=>w([c]));let p=m();return e.realdom.attrInterceptionHooks.get("sync")?.forEach(w=>w([c])),p};new r.MutationObserver(c=>{c=c.filter(m=>!(r.webqit.realdom.attrInterceptionRecords?.get(m.target)||{})[m.attributeName]?.shift()),c=Ft(c).map(m=>Ut.call(r,m)),c.length&&(e.realdom.attrInterceptionHooks.get("intercept")?.forEach(m=>m(c)),e.realdom.attrInterceptionHooks.get("sync")?.forEach(m=>m(c)))}).observe(i,{attributes:!0,subtree:!0,attributeOldValue:!0});let u=Object.create(null);return["setAttribute","removeAttribute","toggleAttribute"].forEach(c=>{u[c]=s.prototype[c],s.prototype[c]=function(...m){let a,p=ht(this,m[0],()=>this.getAttribute(m[0]));["setAttribute","toggleAttribute"].includes(c)&&(a=m[1]),c==="toggleAttribute"&&a===void 0&&(a=p===null);let w={target:this,name:m[0],value:a,oldValue:p,type:"interception",event:[this,c]};return f(w,()=>u[c].call(this,...m))}}),o}var nt=class extends B{constructor(t,...r){super(t,"tree",...r)}attr(t,r=void 0,e={}){let{context:i,window:s}=this;return new F(i,s).get(...arguments)}query(t,r=void 0,e={}){[t,r=void 0,e={}]=this.resolveArgs(arguments);let{context:i}=this,s=new Map,o=u=>(s.has(u)||s.set(u,{target:u,entrants:[],exits:[],type:"query",event:null}),s.get(u));if(!e.generation||e.generation==="entrants"){if(!t.length)[...i.children].forEach(u=>o(i).entrants.push(u));else if(t.every(u=>u.type==="selector")){let[u,c]=t.reduce(([a,p],w)=>w.kind==="xpath"?[a,p.concat(w)]:[a.concat(w),p],[[],[]]),m=[];e.subtree?(u.length&&m.push(...i.querySelectorAll(u.join(","))),c.length&&m.push(...pt(this.window,i,c))):(u.length&&m.push(...[...i.children].filter(a=>a.matches(u))),c.length&&m.push(...pt(this.window,i,c,!1))),m.forEach(a=>o(a.parentNode||i).entrants.push(a))}}if(!r)return s;let f={disconnected:!1},l=r&&e.lifecycleSignals&&this.createSignalGenerator();for(let[,u]of s){if(f.disconnected)break;let c=l?.generate()||{};r(u,c,i)}if(e.live){l&&(e={...e,signalGenerator:l});let u=this.observe(t,r,e);return this.disconnectables(e.signal,f,u)}return this.disconnectables(e.signal,f,l)}children(t,r=void 0,e={}){return[t,r=void 0,e={}]=this.resolveArgs(arguments),this.query(t,r,{...e,subtree:!1})}subtree(t,r=void 0,e={}){return[t,r=void 0,e={}]=this.resolveArgs(arguments),this.query(t,r,{...e,subtree:!0})}observe(t,r,e={}){if([t,r,e={}]=this.resolveArgs(arguments),["sync","intercept"].includes(e.timing))return this.observeSync(t,r,e);if(e.timing&&e.timing!=="async")throw new Error(`Timing option "${e.timing}" invalid.`);let{context:i,window:s,webqit:o,document:f}=this;e.eventDetails&&(o.realdom.domInterceptionRecordsAlwaysOn=!0),(f.readyState==="loading"||o.realdom.domInterceptionRecordsAlwaysOn)&&!o.realdom.domInterceptionHooks?.intercepting&&Bt.call(s,"sync",()=>{});let l=new s.MutationObserver(m=>m.forEach(a=>{St.call(s,c,Gt.call(s,a),i)}));l.observe(i,{childList:!0,subtree:e.subtree&&!0});let u=e.signalGenerator||e.lifecycleSignals&&this.createSignalGenerator(),c={context:i,spec:t,callback:r,params:e,signalGenerator:u,disconnectable:l};if(e.staticSensitivity){let m=Vt.call(s,c);return this.disconnectables(e.signal,l,u,m)}return this.disconnectables(e.signal,l,u)}observeSync(t,r,e={}){[t,r,e={}]=this.resolveArgs(arguments);let{context:i,window:s}=this;if(e.timing&&!["sync","intercept"].includes(e.timing))throw new Error(`Timing option "${e.timing}" invalid.`);let o=e.timing==="intercept"?"intercept":"sync";this.registry(o).size||Bt.call(s,o,a=>{this.forEachMatchingContext(o,a,St)});let f=new s.MutationObserver(a=>a.forEach(p=>{Array.isArray((p=Gt.call(s,p)).event)||St.call(s,c,p,i)}));f.observe(i,{childList:!0,subtree:e.subtree&&!0});let l={disconnect(){m.delete(c),f.disconnect()}},u=e.signalGenerator||e.lifecycleSignals&&this.createSignalGenerator(),c={context:i,spec:t,callback:r,params:e,signalGenerator:u,disconnectable:l},m=this.registry(o);if(m.set(c,!!c.params.deferred),e.staticSensitivity){let a=Vt.call(s,c);return this.disconnectables(e.signal,l,u,a)}return this.disconnectables(e.signal,l,u)}track(t,r,e={}){return e={subtree:!0,...e},this.observe(t,i=>{i.entrants.length&&r(!0,Array.isArray(t)?i.entrants:i.entrants[0]),i.exits.length&&r(!1,Array.isArray(t)?i.exits:i.exits[0])},e)}};function Vt(n){let t=this,{context:r,spec:e,callback:i,params:s,signalGenerator:o}=n,f=e.filter(p=>p.kind==="css"),l=p=>p.match(/\.([\w-]+)/g)?.length?["class"]:[],u=p=>p.match(/#([\w-]+)/g)?.length?["id"]:[],c=p=>[...p.matchAll(/\[([^\=\]]+)(\=[^\]]+)?\]/g)].map(w=>w[1]).concat(l(p)).concat(u(p));if(!(n.$attrs=Array.from(new Set(f.filter(p=>(p+"").includes("[")).reduce((p,w)=>p.concat(c(w+"")),[])))).length)return;let m=new Set,a=new Set;return m.push=p=>(a.delete(p),m.add(p)),a.push=p=>(m.delete(p),a.add(p)),n.$deliveryCache={entrants:m,exits:a},new F(r,t).observe(n.$attrs,p=>{let w=new Map,O=y=>(w.has(y)||w.set(y,{target:y,entrants:[],exits:[],type:"static",event:null}),w.get(y)),lt=new WeakMap,d=y=>(lt.has(y)||lt.set(y,f.some(v=>y.matches(v+""))),lt.get(y));for(let y of p)["entrants","exits"].forEach(v=>{s.generation&&v!==s.generation||n.$deliveryCache[v].has(y.target)||(v==="entrants"?!d(y.target):d(y.target))||(n.$deliveryCache[v].push(y.target),O(y.target)[v].push(y.target),O(y.target).event=y.event)});for(let[,y]of w){let v=o?.generate()||{};i(y,v,r)}},{subtree:s.subtree,timing:s.timing,eventDetails:s.eventDetails})}function St(n,t){let{context:r,spec:e,callback:i,params:s,signalGenerator:o,$deliveryCache:f}=n,l={...t,entrants:[],exits:[]};if(s.eventDetails||delete l.event,["entrants","exits"].forEach(c=>{if(!(s.generation&&c!==s.generation)&&(e.length?l[c]=ge.call(this,e,s.subtree==="cross-roots",t[c],t.event!=="parse"):l[c]=[...t[c]],!!f))for(let m of l[c])f[c].push(m)}),!l.entrants.length&&!l.exits.length)return;let u=o?.generate()||{};i(l,u,r)}function ge(n,t,r,e){r=Array.isArray(r)?r:[...r];let i=(s,o)=>{if(o.type==="selector"){let f=o.isXpathAttr?[]:s.filter(l=>o.kind==="xpath"?Ht(this,l,o+""):l.matches&&l.matches(o+""));if((e||o.isXpathAttr)&&(f=s.reduce((l,u)=>o.kind==="xpath"?[...l,...pt(this,u,o,e)]:u.querySelectorAll?[...l,...u.querySelectorAll(o+"")]:l,f)),f.length)return f}else if(s.includes(o.content)||e&&s.some(f=>rt(this,f,o.content,t)))return[o.content]};return r.$$searchCache||(r.$$searchCache=new Map),n.reduce((s,o)=>{let f;return r.$$searchCache.has(o.content)?f=r.$$searchCache.get(o.content):(f=i(r,o)||[],o.type==="instance"&&r.$$searchCache.set(o.content,f)),s.concat(f)},[])}function Gt({target:n,addedNodes:t,removedNodes:r}){let e=this,i;return i=E(t).reduce((s,o)=>s||e.webqit.realdom.domInterceptionRecords?.get(o),null),i=E(r).reduce((s,o)=>s||e.webqit.realdom.domInterceptionRecords?.get(o),i),i=i||e.document.readyState==="loading"&&"parse"||"mutation",{target:n,entrants:t,exits:r,type:"observation",event:i}}function Bt(n,t){let r=this,{webqit:e,document:i,Node:s,CharacterData:o,Element:f,HTMLElement:l,HTMLTemplateElement:u,DocumentFragment:c}=r;e.realdom.domInterceptionHooks||Object.defineProperty(e.realdom,"domInterceptionHooks",{value:new Map}),e.realdom.domInterceptionNoRecurse||Object.defineProperty(e.realdom,"domInterceptionNoRecurse",{value:new Map}),e.realdom.domInterceptionHooks.has(n)||e.realdom.domInterceptionHooks.set(n,new Set),e.realdom.domInterceptionHooks.get(n).add(t);let m=()=>e.realdom.domInterceptionHooks.get(n).delete(t);if(e.realdom.domInterceptionHooks?.intercepting)return m;console.warn("DOM mutation APIs are now being intercepted."),e.realdom.domInterceptionHooks.intercepting=!0,Object.defineProperty(e.realdom,"domInterceptionRecords",{value:new Map});let a=(d,y,v)=>{e.realdom.domInterceptionNoRecurse.set(d,y);let h=v();return e.realdom.domInterceptionNoRecurse.delete(d),h},p=(d,y)=>{d.entrants.concat(d.exits).forEach(h=>{clearTimeout(e.realdom.domInterceptionRecords.get(h)?.timeout),e.realdom.domInterceptionRecords.set(h,d.event);let I=setTimeout(()=>{e.realdom.domInterceptionRecords.delete(h)},0);Object.defineProperty(d.event,"timeout",{value:I,configurable:!0})}),e.realdom.domInterceptionHooks.get("intercept")?.forEach(h=>h(d));let v=y();return e.realdom.domInterceptionHooks.get("sync")?.forEach(h=>h(d)),v},w={ShadowRoot:["innerHTML","setHTMLUnsafe"],DocumentFragment:["replaceChildren","append","prepend"],Document:["replaceChildren","append","prepend"],HTMLElement:["outerText","innerText"],Element:["append","prepend","before","after","insertAdjacentElement","insertAdjacentHTML","remove","replaceChildren","replaceWith","setHTMLUnsafe","innerHTML","outerHTML"],CharacterData:["before","after","remove","replaceWith"],Node:["insertBefore","replaceChild","removeChild","appendChild","textContent","nodeValue"]},O={ShadowRoot:Object.create(null),DocumentFragment:Object.create(null),Document:Object.create(null),HTMLElement:Object.create(null),Element:Object.create(null),CharacterData:Object.create(null),Node:Object.create(null)};return new Set(Object.values(w).reduce((d,y)=>d.concat(y),[])).forEach(d=>{Object.keys(w).forEach(h=>{if(!w[h].includes(d))return;let I=Object.getOwnPropertyDescriptor(r[h].prototype,d);!I||(Object.defineProperty(r[h].prototype,d,"value"in I?{...I,value:y}:{...I,set:v}),O[h][d]=I)});function y(...h){let I=Object.keys(O).find(q=>this instanceof r[q]&&d in O[q]),z=O[I],$=()=>z[d].value.call(this,...h);if(e.realdom.domInterceptionNoRecurse.get(this)===d)return $();let M=[],x=[],D=this;["insertBefore"].includes(d)?x=[h[0]]:["insertAdjacentElement","insertAdjacentHTML"].includes(d)?(x=[h[1]],["beforebegin","afterend"].includes(h[0])&&(D=this.parentNode)):["setHTMLUnsafe","replaceChildren"].includes(d)?(M=[...this.childNodes],x=d==="replaceChildren"?[...h]:[h[0]]):["replaceWith","remove"].includes(d)?(M=[this],x=d==="replaceWith"?[...h]:[],D=this.parentNode):["replaceChild"].includes(d)?(M=[h[1]],x=[h[0]]):["removeChild"].includes(d)?M=[...h]:(x=[...h],["before","after"].includes(d)&&(D=this.parentNode));let ct=d;if(["insertAdjacentHTML","setHTMLUnsafe"].includes(d)){let q=this.nodeName;if(d==="insertAdjacentHTML"&&["beforebegin","afterend"].includes(h[0])){if(!this.parentNode)return z[d].value.call(this,...h);q=this.parentNode.nodeName}let R=i.createElement(q.includes("-")?"div":q);z.setHTMLUnsafe.value.call(R,x[0],d==="setHTMLUnsafe"?h[1]:{}),x=[...R.childNodes],d==="insertAdjacentHTML"?(ct="insertAdjacentElement",h[1]=new c,a(h[1],"append",()=>h[1].append(...R.childNodes))):(ct="replaceChildren",h=[...R.childNodes])}return p({target:D,entrants:x,exits:M,type:"interception",event:[this,d]},()=>z[ct].value.call(this,...h))}function v(h){let I=Object.keys(O).find(V=>this instanceof r[V]&&d in O[V]),z=O[I],$=()=>z[d].set.call(this,h);if(this instanceof HTMLScriptElement||e.realdom.domInterceptionNoRecurse.get(this)===d)return $();let M=[],x=[],D=this;if(["outerHTML","outerText"].includes(d)?(M=[this],D=this.parentNode):this instanceof u?(D=this.content,M=[...this.content.childNodes]):M=[...this.childNodes],["outerHTML","innerHTML"].includes(d)){let V=this.nodeName;if(d==="outerHTML"){if(!this.parentNode)return $();V=this.parentNode.nodeName}let q=i.createElement(V.includes("-")?"div":V);if(a(q,d,()=>q[d]=h),x=this instanceof u?[...q.content.childNodes]:[...q.childNodes],this instanceof u&&this.hasAttribute("src")||this instanceof ShadowRoot){let R=G=>G.reduce((k,L)=>L instanceof HTMLScriptElement?k.concat(L):L instanceof u?k.concat(R([L.content])):(k=k.concat(R([...L.querySelectorAll?.("template")||[]].map(Kt=>Kt.content))),k.concat(...L.querySelectorAll?.("script")||[])),[]);for(let G of R(x)){if(this instanceof ShadowRoot){G.setAttribute("data-handling","manual");continue}let k=i.createElement("script");[...G.attributes].forEach(L=>k.setAttribute(L.name,L.value)),k.textContent=G.textContent,a(G,"replaceWith",()=>G.replaceWith(k))}}d==="outerHTML"?(h=new c,a(h,"append",()=>h.append(...x)),$=()=>a(this,"replaceWith",()=>f.prototype.replaceWith.call(this,h))):this instanceof u?$=()=>a(this.content,"replaceChildren",()=>this.content.replaceChildren(...x)):$=()=>a(this,"replaceChildren",()=>f.prototype.replaceChildren.call(this,...x))}return p({target:D,entrants:x,exits:M,type:"interception",event:[this,d]},$)}}),m}function zt(){ye.call(this),_e.call(this),we.call(this)}function ye(){let n=this;n.CSS||(n.CSS={}),n.CSS.escape||(n.CSS.escape=t=>t.replace(/([\:@\~\$\&])/g,"\\$1"))}function _e(){let n=this;"isConnected"in n.Node.prototype||Object.defineProperty(n.Node.prototype,"isConnected",{get:function(){return!this.ownerDocument||!(this.ownerDocument.compareDocumentPosition(this)&this.DOCUMENT_POSITION_DISCONNECTED)}})}function we(){let n=this;n.Element.prototype.matches||(n.Element.prototype.matches=n.Element.prototype.matchesSelector||n.Element.prototype.mozMatchesSelector||n.Element.prototype.msMatchesSelector||n.Element.prototype.oMatchesSelector||n.Element.prototype.webkitMatchesSelector||function(t){for(var r=(this.document||this.ownerDocument).querySelectorAll(t),e=r.length;--e>=0&&r.item(e)!==this;);return e>-1})}function Xt(){let n=this;if(n.webqit||(n.webqit={}),n.webqit.realdom)return n.webqit.realdom;n.webqit.realdom={},zt.call(n),n.webqit.realdom.meta=(...r)=>be.call(n,...r),n.webqit.realdom.ready=(...r)=>Ct.call(n,...r),n.webqit.realdom.realtime=(r,e="dom")=>{if(e==="dom")return new nt(r,n);if(e==="attr")return new F(r,n)};let t=new et(n);return n.webqit.realdom.schedule=(r,...e)=>t[`on${r}`](...e),n.webqit.realdom.synthesizeWhile=(...r)=>t.synthesizeWhile(...r),n.webqit.realdom}function Ct(...n){let t="interactive",r;Q(n[0])?(t=n[0],_(n[1])&&(r=n[1])):_(n[0])&&(r=n[0]);let e={interactive:["interactive","complete"],complete:["complete"]};if(!e[t])throw new Error(`Invalid ready-state timing: ${t}.`);let i=this;if(!r)return i.webqit.realdom.readyStatePromises||(i.webqit.realdom.readyStatePromises={interactive:new Promise(s=>Ct.call(this,"interactive",s)),complete:new Promise(s=>Ct.call(this,"complete",s))}),i.webqit.realdom.readyStatePromises[t];if(e[t].includes(i.document.readyState))return r(i);i.webqit.realdom.readyStateCallbacks||(i.webqit.realdom.readyStateCallbacks={interactive:[],complete:[]},i.document.addEventListener("readystatechange",()=>{let s=i.document.readyState;for(let o of i.webqit.realdom.readyStateCallbacks[s].splice(0))o(i)},!1)),i.webqit.realdom.readyStateCallbacks[t].push(r)}function be(n){let t=this,r={},e;return(e=t.document.querySelector(`meta[name="${n}"]`))&&(r=(e.content||"").split(";").filter(i=>i).reduce((i,s)=>{let o=s.split("=").map(f=>f.trim());return vt(i,o[0].split("."),o[1]==="true"?!0:o[1]==="false"?!1:C(o[1])?parseInt(o[1]):o[1]),i},{})),{get name(){return n},get content(){return e.content},json(){return JSON.parse(JSON.stringify(r))}}}function gt(n,t){return typeof n!="string"?n:n.replace(/\w\S*/g,function(r){return r.charAt(0).toUpperCase()+(typeof t!==void 0&&t?r.substr(1).toLowerCase():r.substr(1))})}var W=(...n)=>S("oohtml",...n),P={};function Jt(n,t,r){let e=this,i=Xt.call(e);P.window=e,e.webqitConfig||(e.webqitConfig=i.meta("webqit").json()),e.webqit||(e.webqit={}),e.webqit.oohtml||(e.webqit.oohtml={}),e.webqit.oohtml.configs||(e.webqit.oohtml.configs={});let s=n.toUpperCase().replace("-","_");if(!e.webqit.oohtml.configs[s]){e.webqit.oohtml.configs[s]={};let o=e.webqit.oohtml.configs[s];K(2,o,r,t,i.meta(n).json()),e.webqitConfig.prefix&&Object.keys(o).forEach(f=>{Object.keys(o[f]).forEach(l=>{f==="api"&&typeof o[f][l]=="string"?o[f][l]=`${e.webqitConfig.prefix}${gt(o[f][l])}`:["attr","elements"].includes(f)&&o[f][l]?.startsWith("data-")===!1&&(o[f][l]=`${e.webqitConfig.prefix}-${o[f][l]}`)})})}return{config:e.webqit.oohtml.configs[s],realdom:i,window:e}}function Yt(){let{window:n}=P,{webqit:t}=n;if(t.DOMContextRequestEvent)return t.DOMContextRequestEvent;class r extends n.Event{constructor(...i){let s=i.pop();if(typeof s!="function")throw new Error("Callback must be provided.");let o=i.pop();if(!o?.kind)throw new Error('"options.kind" must be specified.');let f=["contextrequest","contextclaim"],l=i.pop()||f[0];if(!f.includes(l))throw new Error(`Invalid event type. Must be one of: ${f.join(",")}`);let{kind:u,detail:c,targetContext:m,live:a,signal:p,diff:w,...O}=o;super(l,{...O,bubbles:O.bubbles!==!1}),Object.defineProperty(this,"callback",{get:()=>s}),Object.defineProperty(this,"kind",{get:()=>u}),Object.defineProperty(this,"targetContext",{get:()=>m}),Object.defineProperty(this,"detail",{get:()=>c}),Object.defineProperty(this,"live",{get:()=>a}),Object.defineProperty(this,"signal",{get:()=>p}),Object.defineProperty(this,"diff",{get:()=>w}),Object.defineProperty(this,"options",{get:()=>O}),Object.defineProperty(this,"meta",{value:{}})}get target(){return super.target||this.meta.target}get answered(){return this.meta.answered||!1}respondWith(i){if(this.meta.answered=!0,this.diff){if("_prevValue"in this&&this._prevValue===i)return;Object.defineProperty(this,"_prevValue",{value:i,configurable:!0})}return this.callback(i)}}return t.DOMContextRequestEvent=r,r}var it=class extends AbortController{constructor(t){super(),t(r=>{let{window:{webqit:{Observer:e}}}=P;e.defineProperty(this,"value",{value:r,configurable:!0,enumerable:!0})},this)}};var ot=class extends Error{};var st=new Map,ft=class{static instance(t){return W(t).get("contexts::instance")||new this(t)}constructor(t){W(t).get("contexts::instance")?.dispose(),W(t).set("contexts::instance",this);let r={host:t,contexts:new Set};Object.defineProperty(this,"#",{get:()=>r})}get[Symbol.iterator](){return this["#"].contexts[Symbol.iterator]}get length(){return this["#"].contexts.size}find(...t){return[...this["#"].contexts].find(r=>typeof t[0]=="function"?t[0](r):r.constructor.kind===t[0]&&(t.length===1||r.detail===t[1]))}attach(t){if(!(t instanceof U))throw new TypeError("Context is not a valid DOMContext instance.");if(this.find(t.constructor.kind,t.detail))throw new ot(`Context of same kind "${t.constructor.kind}"${t.detail?` and detail "${t.detail}"`:""} already exists.`);this["#"].contexts.add(t),t.initialize(this["#"].host)}detach(t){t.dispose(this["#"].host),this["#"].contexts.delete(t)}request(...t){return new it((r,e)=>{typeof t[t.length-1]!="function"&&(t[t.length-1]?t.push(r):t[t.length-1]=r);let i;(i=t.find(l=>typeof l=="object"&&l))&&i.live&&(i.signal&&i.signal.addEventListener("abort",()=>e.abort()),t[t.indexOf(i)]={...i,signal:e.signal});let s=new(Yt())(...t);s.meta.target=this["#"].host;let o=this["#"].host.getRootNode(),f=l=>{if(l.stopImmediatePropagation(),l.meta.target=l.target,!l.answered){if(st.get(o)||st.set(o,new Set),l.type==="contextrequest"&&l.live)st.get(o).add(l);else if(l.type==="contextclaim"){let u=new Set;return st.get(o).forEach(c=>{!this["#"].host.contains(c.target)||!l.detail.matchEvent(c)||(st.get(o).delete(c),u.add(c))}),l.respondWith(u)}}};o.addEventListener(s.type,f),this["#"].host.dispatchEvent(s),o.removeEventListener(s.type,f)})}};var Tt=class{static createRequest(){return{kind:this.kind}}constructor(t=null){Object.defineProperty(this,"detail",{get:()=>t}),Object.defineProperty(this,"subscriptions",{value:new Set})}get configs(){let{window:{webqit:{oohtml:{configs:t}}}}=P;return t}get name(){return[P.window.Document,P.window.ShadowRoot].some(t=>this.host instanceof t)?1/0:this.host.getAttribute(this.configs.CONTEXT_API.attr.contextname)}subscribed(t){}handle(t){}unsubscribed(t){}matchEvent(t){return t.kind===this.constructor.kind&&(!t.targetContext||t.targetContext===this.name)}handleEvent(t){if(!(this.disposed||typeof t.respondWith!="function")){if(t.type==="contextclaim"){if(!(t.detail instanceof Tt)||t.target===this.host)return;let r=new Set;if(this.subscriptions.forEach(e=>{!t.target.contains(e.target)||!t.detail.matchEvent(e)||(this.subscriptions.delete(e),this.unsubscribed(e),r.add(e))}),r.size)return t.respondWith(r)}if(t.type==="contextrequest")return this.matchEvent(t)?(t.live&&(this.subscriptions.add(t),this.subscribed(t),t.signal?.addEventListener("abort",()=>{this.subscriptions.delete(t),this.unsubscribed(t)})),t.stopPropagation(),this.handle(t)):void 0}}initialize(t){this.host=t,this.disposed=!1,t.addEventListener("contextrequest",this),t.addEventListener("contextclaim",this);let{value:r}=ft.instance(t).request("contextclaim",{kind:this.constructor.kind,detail:this});return r?.forEach(e=>{this.subscriptions.add(e),this.subscribed(e),this.handle(e)}),this}dispose(t){return this.disposed=!0,t.removeEventListener("contextrequest",this),t.removeEventListener("contextclaim",this),this.subscriptions.forEach(r=>{this.subscriptions.delete(r),this.unsubscribed(r);let{target:e}=r;e.dispatchEvent(r)}),this}},U=Tt;ut(U,"kind");var H=class extends U{static createRequest(t=null){let r=super.createRequest();if(t?.startsWith("@")){let[e,...i]=i.slice(1).split(".").map(s=>s.trim());r.targetContext=e,r.detail=i.join(".")}else r.detail=t;return r}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:r}}}=P;t.meta.controller=r.reduce(this.bindingsObj,Array.isArray(t.detail)?t.detail:[t.detail],r.get,e=>{this.disposed||t.respondWith(e.value)},{live:t.live,signal:t.signal,descripted:!0})}unsubscribed(t){t.meta.controller?.abort()}};ut(H,"kind","bindings");function It(n={}){let{config:t,window:r}=Jt.call(this,"bindings-api",n,{attr:{bindingsreflection:"bindings"},api:{bind:"bind",bindings:"bindings"}});r.webqit.DOMBindingsContext=H,ve.call(r,t)}function Zt(n,t){let r=this,{webqit:{Observer:e,oohtml:{configs:{CONTEXT_API:i}}}}=r;if(!W(t).has("bindings")){let s=Object.create(null);W(t).set("bindings",s),e.observe(s,o=>{let f=Object.keys(s),l=t instanceof r.Document?t.documentElement:t,u=n.attr.bindingsreflection;f.length&&u&&l.setAttribute?l.setAttribute(n.attr.bindingsreflection,f.join(" ")):u&&l.setAttribute&&l.toggleAttribute(n.attr.bindingsreflection,!1);let c=t[i.api.contexts];for(let m of o)if(m.type==="delete"){let a=c.find(H.kind,m.key);a&&c.detach(a)}else c.find(H.kind,m.key)||c.attach(new H(m.key))})}return W(t).get("bindings")}function ve(n){let t=this,{webqit:{Observer:r}}=t;[t.Document.prototype,t.Element.prototype,t.ShadowRoot.prototype].forEach(e=>{let i=e===t.Document.prototype?"Document":e===t.ShadowRoot.prototype?"ShadowRoot":"Element";if(n.api.bind in e)throw new Error(`The ${i} prototype already has a "${n.api.bind}" API!`);if(n.api.bindings in e)throw new Error(`The ${i} prototype already has a "${n.api.bindings}" API!`);Object.defineProperty(e,n.api.bind,{value:function(s,o={}){return Ae.call(t,n,this,s,o)}}),Object.defineProperty(e,n.api.bindings,{get:function(){return r.proxy(Zt.call(t,n,this))}})})}function Ae(n,t,r,{merge:e,diff:i,namespace:s}={}){let o=this,{webqit:{Observer:f}}=o,l=Zt.call(this,n,t),u={diff:i,namespace:s},c=e?[]:f.ownKeys(l,u).filter(m=>!(m in r));return f.batch(l,()=>(c.length&&f.deleteProperties(l,c,u),f.set(l,r,u)),u)}It.call(window);})();
2
2
  //# sourceMappingURL=bindings-api.js.map