@bquery/bquery 1.11.1 → 1.12.0

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.
Files changed (108) hide show
  1. package/README.md +52 -33
  2. package/dist/{a11y-DgUQ8-fI.js → a11y-IV_bfLyn.js} +3 -3
  3. package/dist/{a11y-DgUQ8-fI.js.map → a11y-IV_bfLyn.js.map} +1 -1
  4. package/dist/a11y.es.mjs +1 -1
  5. package/dist/{component-D8ydhe58.js → component-BtsRbf6c.js} +7 -7
  6. package/dist/{component-D8ydhe58.js.map → component-BtsRbf6c.js.map} +1 -1
  7. package/dist/component.es.mjs +1 -1
  8. package/dist/{concurrency-BU1wPEsZ.js → concurrency-kycgAZvW.js} +3 -3
  9. package/dist/{concurrency-BU1wPEsZ.js.map → concurrency-kycgAZvW.js.map} +1 -1
  10. package/dist/concurrency.es.mjs +1 -1
  11. package/dist/{config-DhT9auRm.js → config-BP7KwiR5.js} +1 -1
  12. package/dist/{config-DhT9auRm.js.map → config-BP7KwiR5.js.map} +1 -1
  13. package/dist/constraints-Dlbx_m1b.js.map +1 -1
  14. package/dist/core-tOP6QOrY.js.map +1 -1
  15. package/dist/{core-CongXJuo.js → core-yg9rJXiR.js} +1 -1
  16. package/dist/{core-CongXJuo.js.map → core-yg9rJXiR.js.map} +1 -1
  17. package/dist/custom-directives-5DlKqvd2.js.map +1 -1
  18. package/dist/devtools-QosAqo0T.js.map +1 -1
  19. package/dist/dnd-d2OU4len.js.map +1 -1
  20. package/dist/{effect-Cc51IH91.js → effect-v8OIEmPs.js} +2 -2
  21. package/dist/{effect-Cc51IH91.js.map → effect-v8OIEmPs.js.map} +1 -1
  22. package/dist/env-PvwYHnJq.js.map +1 -1
  23. package/dist/{forms-BLx4ZzT7.js → forms-DYcdlk_h.js} +8 -8
  24. package/dist/{forms-BLx4ZzT7.js.map → forms-DYcdlk_h.js.map} +1 -1
  25. package/dist/forms.es.mjs +1 -1
  26. package/dist/full.d.ts +11 -11
  27. package/dist/full.d.ts.map +1 -1
  28. package/dist/full.es.mjs +324 -279
  29. package/dist/full.iife.js +26 -26
  30. package/dist/full.iife.js.map +1 -1
  31. package/dist/full.umd.js +26 -26
  32. package/dist/full.umd.js.map +1 -1
  33. package/dist/function-Cybd57JV.js.map +1 -1
  34. package/dist/{i18n--p7PM-9r.js → i18n-unHU1jMo.js} +3 -3
  35. package/dist/{i18n--p7PM-9r.js.map → i18n-unHU1jMo.js.map} +1 -1
  36. package/dist/i18n.es.mjs +1 -1
  37. package/dist/index.es.mjs +198 -196
  38. package/dist/match-CrZRVC4z.js.map +1 -1
  39. package/dist/{media-gjbWNq50.js → media-Chh6mA0v.js} +3 -3
  40. package/dist/{media-gjbWNq50.js.map → media-Chh6mA0v.js.map} +1 -1
  41. package/dist/media.es.mjs +1 -1
  42. package/dist/{motion-BBMso9Ir.js → motion-27Od9aFE.js} +2 -2
  43. package/dist/{motion-BBMso9Ir.js.map → motion-27Od9aFE.js.map} +1 -1
  44. package/dist/motion.es.mjs +1 -1
  45. package/dist/{mount-0A9qtcRJ.js → mount-DwUFujZ_.js} +4 -4
  46. package/dist/{mount-0A9qtcRJ.js.map → mount-DwUFujZ_.js.map} +1 -1
  47. package/dist/object-BCk-1c8T.js.map +1 -1
  48. package/dist/{platform-BPHIXbw8.js → platform-2YkFA11t.js} +4 -4
  49. package/dist/{platform-BPHIXbw8.js.map → platform-2YkFA11t.js.map} +1 -1
  50. package/dist/platform.es.mjs +2 -2
  51. package/dist/plugin-SZEirbwq.js.map +1 -1
  52. package/dist/reactive/index.d.ts +2 -2
  53. package/dist/reactive/index.d.ts.map +1 -1
  54. package/dist/reactive/signal.d.ts +7 -7
  55. package/dist/reactive/signal.d.ts.map +1 -1
  56. package/dist/reactive/websocket.d.ts +15 -3
  57. package/dist/reactive/websocket.d.ts.map +1 -1
  58. package/dist/{reactive-BAd2hfl8.js → reactive-BvPR_FYA.js} +10 -10
  59. package/dist/{reactive-BAd2hfl8.js.map → reactive-BvPR_FYA.js.map} +1 -1
  60. package/dist/reactive.es.mjs +40 -40
  61. package/dist/{readonly-C0ZwS1Tf.js → readonly-Br-6pAgj.js} +2 -2
  62. package/dist/{readonly-C0ZwS1Tf.js.map → readonly-Br-6pAgj.js.map} +1 -1
  63. package/dist/registry-jpUQHf4E.js.map +1 -1
  64. package/dist/{router-C4weu0QL.js → router-CbnWKprL.js} +7 -7
  65. package/dist/{router-C4weu0QL.js.map → router-CbnWKprL.js.map} +1 -1
  66. package/dist/router.es.mjs +1 -1
  67. package/dist/sanitize-DOMkRO9G.js.map +1 -1
  68. package/dist/server/create-server.d.ts.map +1 -1
  69. package/dist/server/types.d.ts.map +1 -1
  70. package/dist/{server-QdyKtCS1.js → server-Dwiq_F49.js} +2 -2
  71. package/dist/server-Dwiq_F49.js.map +1 -0
  72. package/dist/server.es.mjs +1 -1
  73. package/dist/ssr/context.d.ts.map +1 -1
  74. package/dist/ssr/renderer.d.ts.map +1 -1
  75. package/dist/ssr/suspense.d.ts.map +1 -1
  76. package/dist/{ssr-Bt6BQA3J.js → ssr-CqJU1Ogp.js} +8 -8
  77. package/dist/ssr-CqJU1Ogp.js.map +1 -0
  78. package/dist/ssr.es.mjs +1 -1
  79. package/dist/store/index.d.ts +1 -1
  80. package/dist/store/index.d.ts.map +1 -1
  81. package/dist/store/plugins.d.ts +38 -0
  82. package/dist/store/plugins.d.ts.map +1 -1
  83. package/dist/{store-DnXuu6Li.js → store-DzrhVQ29.js} +69 -62
  84. package/dist/store-DzrhVQ29.js.map +1 -0
  85. package/dist/store.es.mjs +13 -11
  86. package/dist/storybook.es.mjs.map +1 -1
  87. package/dist/{testing-CeMUwrRD.js → testing-ByjwS2_D.js} +3 -3
  88. package/dist/{testing-CeMUwrRD.js.map → testing-ByjwS2_D.js.map} +1 -1
  89. package/dist/testing.es.mjs +1 -1
  90. package/dist/type-guards-BMX2c0LP.js.map +1 -1
  91. package/dist/{untrack-bjWDNdyE.js → untrack-uzz3JDNK.js} +3 -3
  92. package/dist/{untrack-bjWDNdyE.js.map → untrack-uzz3JDNK.js.map} +1 -1
  93. package/dist/view.es.mjs +8 -8
  94. package/package.json +8 -7
  95. package/src/full.ts +75 -6
  96. package/src/reactive/index.ts +5 -4
  97. package/src/reactive/signal.ts +7 -6
  98. package/src/reactive/websocket.ts +15 -2
  99. package/src/server/create-server.ts +10 -5
  100. package/src/server/types.ts +1 -5
  101. package/src/ssr/context.ts +6 -2
  102. package/src/ssr/renderer.ts +5 -2
  103. package/src/ssr/suspense.ts +17 -8
  104. package/src/store/index.ts +1 -1
  105. package/src/store/plugins.ts +48 -1
  106. package/dist/server-QdyKtCS1.js.map +0 -1
  107. package/dist/ssr-Bt6BQA3J.js.map +0 -1
  108. package/dist/store-DnXuu6Li.js.map +0 -1
package/dist/full.umd.js CHANGED
@@ -1,4 +1,4 @@
1
- (function(y,$e){typeof exports=="object"&&typeof module<"u"?$e(exports):typeof define=="function"&&define.amd?define(["exports"],$e):(y=typeof globalThis<"u"?globalThis:y||self,$e(y.bQuery={}))})(this,function(y){Object.defineProperty(y,Symbol.toStringTag,{value:"Module"});var $e="bquery-sanitizer",ln=new Set(["a","abbr","address","article","aside","b","bdi","bdo","blockquote","br","button","caption","cite","code","col","colgroup","data","dd","del","details","dfn","div","dl","dt","em","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","hr","i","img","input","ins","kbd","label","legend","li","main","mark","nav","ol","optgroup","option","p","picture","pre","progress","q","rp","rt","ruby","s","samp","section","select","small","source","span","strong","sub","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","u","ul","var","wbr"]),cr=new Set(["script","iframe","frame","frameset","object","embed","applet","link","meta","style","base","template","math","svg","foreignobject","noscript"]),un=new Set(["document","window","location","top","self","parent","frames","history","navigator","screen","alert","confirm","prompt","eval","function","cookie","domain","referrer","body","head","forms","images","links","scripts","children","parentnode","firstchild","lastchild","innerhtml","outerhtml","textcontent"]),fn=new Set(["alt","class","dir","height","hidden","href","id","lang","loading","name","rel","role","src","srcset","tabindex","target","title","type","width","aria-*"]),dn=["on","formaction","xlink:","xmlns:"],lr=["javascript:","data:","vbscript:","file:"],zi=(e,t,r)=>{const n=e.toLowerCase();for(const s of dn)if(n.startsWith(s))return!1;return r&&n.startsWith("data-")||n.startsWith("aria-")?!0:t.has(n)},ji=e=>{const t=e.toLowerCase().trim();return!un.has(t)},Ui=e=>e.replace(/[\u0000-\u001F\u007F]+/g,"").replace(/[\u200B-\u200D\uFEFF\u2028\u2029]+/g,"").replace(/\\u[\da-fA-F]{4}/g,"").replace(/\s+/g,"").toLowerCase(),hn=e=>{const t=Ui(e);for(const r of lr)if(t.startsWith(r))return!1;return!0},Hi=e=>{const t=e.split(",");for(const r of t){const n=r.trim().split(/\s+/)[0];if(n&&!hn(n))return!1}return!0},Wi=e=>{try{const t=e.trim();if(t.startsWith("//"))return!0;const r=t.toLowerCase();return/^[a-z][a-z0-9+.-]*:/i.test(t)&&!r.startsWith("http://")&&!r.startsWith("https://")?!0:!r.startsWith("http://")&&!r.startsWith("https://")?!1:typeof window>"u"||!window.location?!0:new URL(t,window.location.href).origin!==window.location.origin}catch{return!0}},Fi=e=>new DOMParser().parseFromString(e,"text/html"),mn=e=>{const t=(typeof e=="string"?e:String(e??"")).trim(),r=document.createDocumentFragment();if(t.length===0)return r;if(!(t.includes("<")||t.includes(">")))return r.appendChild(document.createTextNode(t)),r;const n=Fi(t).body;if(!n)return r;for(;n.firstChild;)r.appendChild(n.firstChild);return r},At=(e,t={})=>{const{allowTags:r=[],allowAttributes:n=[],allowDataAttributes:s=!0,stripAllTags:o=!1}=t,i=new Set([...ln,...r.map(f=>f.toLowerCase())].filter(f=>!cr.has(f))),a=new Set([...fn,...n.map(f=>f.toLowerCase())]),c=mn(e);if(o)return c.textContent??"";const l=document.createTreeWalker(c,NodeFilter.SHOW_ELEMENT),u=[];for(;l.nextNode();){const f=l.currentNode,m=f.tagName.toLowerCase();if(cr.has(m)){u.push(f);continue}if(!i.has(m)){u.push(f);continue}const v=[];for(const b of Array.from(f.attributes)){const g=b.name.toLowerCase();if(!zi(g,a,s)){v.push(b.name);continue}if((g==="id"||g==="name")&&!ji(b.value)){v.push(b.name);continue}if((g==="href"||g==="src"||g==="action")&&!hn(b.value)){v.push(b.name);continue}g==="srcset"&&!Hi(b.value)&&v.push(b.name)}for(const b of v)f.removeAttribute(b);if(m==="a"){const b=f.getAttribute("href"),g=f.getAttribute("target")?.toLowerCase()==="_blank",w=b&&Wi(b);if(g||w){const S=f.getAttribute("rel"),k=new Set(S?S.split(/\s+/).filter(Boolean):[]);k.add("noopener"),k.add("noreferrer"),f.setAttribute("rel",Array.from(k).join(" "))}}}for(const f of u)f.remove();const h=f=>{const m=document.createElement("div");return m.appendChild(f.cloneNode(!0)),m.innerHTML},d=h(c),p=h(mn(d));return d!==p?c.textContent??"":p},pn=Symbol("bquery.trusted-html.brand"),ur=Symbol("bquery.trusted-html"),vn=e=>e,Bi=e=>{const t=String(e);return Object.freeze({[pn]:!0,[ur]:t,toString:()=>t})},Qi=e=>typeof e=="object"&&e!==null&&pn in e&&ur in e,Vi=e=>e[ur],yn=1024,gn=8192,bn=(e=16)=>{if(!Number.isInteger(e)||e<1)throw new RangeError("generateNonce length must be a positive integer");if(e>yn)throw new RangeError(`generateNonce length must not exceed ${yn}`);if(typeof globalThis.crypto>"u"||typeof globalThis.crypto.getRandomValues!="function")throw new Error("generateNonce requires crypto.getRandomValues (not available in this environment)");if(typeof globalThis.btoa!="function")throw new Error("generateNonce requires btoa (not available in this environment)");const t=new Uint8Array(e);globalThis.crypto.getRandomValues(t);let r="";for(let n=0;n<t.length;n+=gn){const s=t.subarray(n,Math.min(n+gn,t.length));r+=String.fromCharCode(...s)}return globalThis.btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")},Ki=e=>{if(typeof document>"u")return!1;const t=document.querySelector('meta[http-equiv="Content-Security-Policy"]');return t?(t.getAttribute("content")??"").includes(e):!1},kt=null,wn=!1,Yi=()=>typeof window<"u"&&typeof window.trustedTypes<"u",Sn=()=>{if(kt)return kt;if(wn||typeof window>"u")return null;const e=window;if(!e.trustedTypes)return null;wn=!0;try{return kt=e.trustedTypes.createPolicy($e,{createHTML:t=>At(t)}),kt}catch(t){const r=t instanceof Error?t.message:String(t);return console.warn(`bQuery: Could not create Trusted Types policy "${$e}": ${r}`),null}},Ji=e=>{const t=Sn();return t?t.createHTML(e):At(e)},ie=(e,t={})=>vn(At(e,t)),En=e=>{const t={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","`":"&#x60;"};return e.replace(/[&<>"'`]/g,r=>t[r])},Gi=e=>At(e,{stripAllTags:!0}),An=e=>Array.isArray(e)?e:[e],z=(e,t)=>{for(const r of e)t(r)},Oe=e=>{if(!e)return!1;const t=e.ownerDocument?.defaultView?.HTMLElement??globalThis.HTMLElement;return typeof t=="function"&&e instanceof t},Tt=(e,t)=>Oe(e)?t==="width"?e.clientWidth:e.clientHeight:0,Rt=(e,t,r)=>{if(!Oe(e))return 0;const n=t==="width"?e.offsetWidth:e.offsetHeight;if(!r)return n;const s=e.ownerDocument?.defaultView;if(!s||typeof s.getComputedStyle!="function")return n;const o=s.getComputedStyle(e),i=Number.parseFloat(o.getPropertyValue(t==="width"?"margin-left":"margin-top")),a=Number.parseFloat(o.getPropertyValue(t==="width"?"margin-right":"margin-bottom")),c=Number.isNaN(i)?0:i,l=Number.isNaN(a)?0:a;return n+c+l},kn=e=>ie(e),Xi=(e,t)=>{e.innerHTML=ie(t)},Tn=e=>{const t=document.createElement("template");return t.innerHTML=ie(e),t.content.firstElementChild??document.createElement("div")},Rn=(e,t,r)=>{if(typeof t=="string"){e.insertAdjacentHTML(r,ie(t));return}const n=An(t);z(r==="afterbegin"||r==="afterend"?n.slice().reverse():n,s=>{e.insertAdjacentElement(r,s)})};function Le(e){return Object.prototype.toString.call(e)==="[object Object]"}function N(e){return e==="__proto__"||e==="constructor"||e==="prototype"}function Zi(e){return typeof structuredClone=="function"?structuredClone(e):JSON.parse(JSON.stringify(e))}function Pe(...e){const t={};for(const r of e)for(const[n,s]of Object.entries(r))N(n)||(Le(s)&&Le(t[n])?t[n]=Pe(t[n],s):t[n]=s);return t}function ea(e,t){const r={};for(const n of t)n in e&&(r[n]=e[n]);return r}function ta(e,t){const r={...e};for(const n of t)delete r[n];return r}function ra(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var na=e=>{const t=e.tagName.toLowerCase();return t==="input"||t==="textarea"||t==="select"},Cn=e=>{const t=[],r=e.ownerDocument.defaultView?.Element??Element;for(const n of Array.from(e.elements)){if(!(n instanceof r)||!na(n))continue;const s=n.name;if(!(!s||n.disabled||N(s))){if(n.tagName.toLowerCase()==="input"){const o=n,i=o.type.toLowerCase();if(i==="checkbox"||i==="radio"){o.checked&&t.push([s,o.value]);continue}if(i==="file"||i==="submit"||i==="button"||i==="reset"||i==="image")continue;t.push([s,o.value]);continue}if(n.tagName.toLowerCase()==="select"){const o=n;if(o.multiple)for(const i of Array.from(o.selectedOptions))t.push([s,i.value]);else t.push([s,o.value]);continue}t.push([s,n.value])}}return t},$n=e=>{if(typeof FormData=="function")try{const t=[];for(const[r,n]of new FormData(e).entries())N(r)||typeof n!="string"||t.push([r,n]);return t.length>0?t:Cn(e)}catch{}return Cn(e)},Ne=class cn{constructor(t){this.element=t,this.delegatedHandlers=new Map}get raw(){return this.element}get node(){return this.element}addClass(...t){return this.element.classList.add(...t),this}removeClass(...t){return this.element.classList.remove(...t),this}toggleClass(t,r){return this.element.classList.toggle(t,r),this}attr(t,r){return r===void 0?this.element.getAttribute(t)??"":(this.element.setAttribute(t,r),this)}removeAttr(t){return this.element.removeAttribute(t),this}toggleAttr(t,r){const n=this.element.hasAttribute(t);return r??!n?this.element.setAttribute(t,""):this.element.removeAttribute(t),this}prop(t,r){return r===void 0?this.element[t]:(this.element[t]=r,this)}data(t,r){const n=t.replace(/[A-Z]/g,s=>`-${s.toLowerCase()}`);return r===void 0?this.element.getAttribute(`data-${n}`)??"":(this.element.setAttribute(`data-${n}`,r),this)}text(t){return t===void 0?this.element.textContent??"":(this.element.textContent=t,this)}html(t){return Xi(this.element,t),this}htmlUnsafe(t){return this.element.innerHTML=t,this}css(t,r){if(typeof t=="string"){if(r!==void 0)return this.element.style.setProperty(t,r),this;const n=this.element.ownerDocument?.defaultView;return!n||typeof n.getComputedStyle!="function"?"":n.getComputedStyle(this.element).getPropertyValue(t)}for(const[n,s]of Object.entries(t))this.element.style.setProperty(n,s);return this}append(t){return this.insertContent(t,"beforeend"),this}prepend(t){return this.insertContent(t,"afterbegin"),this}before(t){return this.insertContent(t,"beforebegin"),this}after(t){return this.insertContent(t,"afterend"),this}wrap(t){const r=typeof t=="string"?document.createElement(t):t;return this.element.parentNode?.insertBefore(r,this.element),r.appendChild(this.element),this}unwrap(){const t=this.element.parentElement;return t&&t.parentNode&&(t.parentNode.insertBefore(this.element,t),t.remove()),this}replaceWith(t){const r=typeof t=="string"?Tn(t):t;return this.element.replaceWith(r),new cn(r)}detach(){return this.remove()}index(){const t=this.element.parentElement;return t?Array.from(t.children).indexOf(this.element):-1}contents(){return Array.from(this.element.childNodes)}offsetParent(){return Oe(this.element)?this.element.offsetParent:null}position(){if(!Oe(this.element))return{top:0,left:0};const t=this.element;return{top:t.offsetTop,left:t.offsetLeft}}innerWidth(){return Tt(this.element,"width")}innerHeight(){return Tt(this.element,"height")}outerWidth(t=!1){return Rt(this.element,"width",t)}outerHeight(t=!1){return Rt(this.element,"height",t)}scrollTo(t={behavior:"smooth"}){return this.element.scrollIntoView(t),this}remove(){return this.element.remove(),this}empty(){return this.element.innerHTML="",this}clone(t=!0){return new cn(this.element.cloneNode(t))}find(t){return Array.from(this.element.querySelectorAll(t))}findOne(t){return this.element.querySelector(t)}closest(t){return this.element.closest(t)}parent(){return this.element.parentElement}children(){return Array.from(this.element.children)}siblings(){const t=this.element.parentElement;return t?Array.from(t.children).filter(r=>r!==this.element):[]}next(){return this.element.nextElementSibling}prev(){return this.element.previousElementSibling}on(t,r){return this.element.addEventListener(t,r),this}once(t,r){return this.element.addEventListener(t,r,{once:!0}),this}off(t,r){return this.element.removeEventListener(t,r),this}trigger(t,r){return this.element.dispatchEvent(new CustomEvent(t,{detail:r,bubbles:!0,cancelable:!0})),this}delegate(t,r,n){const s=`${t}:${r}`,o=i=>{const a=i.target.closest(r);a&&this.element.contains(a)&&n(i,a)};return this.delegatedHandlers.has(s)||this.delegatedHandlers.set(s,new Map),this.delegatedHandlers.get(s).set(n,o),this.element.addEventListener(t,o),this}undelegate(t,r,n){const s=`${t}:${r}`,o=this.delegatedHandlers.get(s);if(o){const i=o.get(n);i&&(this.element.removeEventListener(t,i),o.delete(n),o.size===0&&this.delegatedHandlers.delete(s))}return this}matches(t){return this.element.matches(t)}is(t){return this.matches(t)}hasClass(t){return this.element.classList.contains(t)}show(t=""){return this.element.removeAttribute("hidden"),this.element.style.display=t,this}hide(){return this.element.style.display="none",this}toggle(t){const r=this.element.style.display==="none";return t??r?this.show():this.hide()}focus(){return this.element.focus(),this}blur(){return this.element.blur(),this}val(t){const r=this.element;return t===void 0?r.value??"":(r.value=t,this)}serialize(){const t=this.element;if(t.tagName.toLowerCase()!=="form")return{};const r=Object.create(null);for(const[n,s]of $n(t))if(Object.prototype.hasOwnProperty.call(r,n)){const o=r[n];Array.isArray(o)?o.push(s):r[n]=[o,s]}else r[n]=s;return r}serializeString(){const t=this.element;if(t.tagName.toLowerCase()!=="form")return"";const r=new URLSearchParams;for(const[n,s]of $n(t))r.append(n,s);return r.toString()}rect(){return this.element.getBoundingClientRect()}offset(){const t=this.element;return{width:t.offsetWidth,height:t.offsetHeight,top:t.offsetTop,left:t.offsetLeft}}insertContent(t,r){Rn(this.element,t,r)}},Ct=class oe{constructor(t){this.elements=t,this.delegatedHandlers=new WeakMap}get length(){return this.elements.length}first(){return this.elements[0]}eq(t){const r=this.elements[t];return r?new Ne(r):void 0}firstEl(){return this.eq(0)}lastEl(){return this.eq(this.elements.length-1)}each(t){return this.elements.forEach((r,n)=>{t(new Ne(r),n)}),this}map(t){return this.elements.map(t)}filter(t){return new oe(this.elements.filter(t))}reduce(t,r){return this.elements.reduce(t,r)}toArray(){return this.elements.map(t=>new Ne(t))}addClass(...t){return z(this.elements,r=>r.classList.add(...t)),this}removeClass(...t){return z(this.elements,r=>r.classList.remove(...t)),this}toggleClass(t,r){return z(this.elements,n=>n.classList.toggle(t,r)),this}attr(t,r){return r===void 0?this.first()?.getAttribute(t)??"":(z(this.elements,n=>n.setAttribute(t,r)),this)}removeAttr(t){return z(this.elements,r=>r.removeAttribute(t)),this}toggleAttr(t,r){return z(this.elements,n=>{const s=n.hasAttribute(t);r??!s?n.setAttribute(t,""):n.removeAttribute(t)}),this}text(t){return t===void 0?this.first()?.textContent??"":(z(this.elements,r=>{r.textContent=t}),this)}html(t){if(t===void 0)return this.first()?.innerHTML??"";const r=kn(t);return z(this.elements,n=>{n.innerHTML=r}),this}htmlUnsafe(t){return z(this.elements,r=>{r.innerHTML=t}),this}append(t){return this.insertAll(t,"beforeend"),this}prepend(t){return this.insertAll(t,"afterbegin"),this}before(t){return this.insertAll(t,"beforebegin"),this}after(t){return this.insertAll(t,"afterend"),this}css(t,r){if(typeof t=="string"){if(r!==void 0)return z(this.elements,o=>{o.style.setProperty(t,r)}),this;const n=this.first();if(!n)return"";const s=n.ownerDocument?.defaultView;return!s||typeof s.getComputedStyle!="function"?"":s.getComputedStyle(n).getPropertyValue(t)}return z(this.elements,n=>{for(const[s,o]of Object.entries(t))n.style.setProperty(s,o)}),this}wrap(t){return this.elements.forEach((r,n)=>{const s=typeof t=="string"?document.createElement(t):n===0?t:t.cloneNode(!0);r.parentNode?.insertBefore(s,r),s.appendChild(r)}),this}unwrap(){const t=new Set;for(const r of this.elements)r.parentElement&&t.add(r.parentElement);return t.forEach(r=>{const n=r.parentNode;if(n){for(;r.firstChild;)n.insertBefore(r.firstChild,r);r.remove()}}),this}replaceWith(t){const r=[];return this.elements.forEach((n,s)=>{const o=typeof t=="string"?Tn(t):s===0?t:t.cloneNode(!0);n.replaceWith(o),r.push(o)}),new oe(r)}detach(){return this.remove()}index(){const t=this.first();return t?.parentElement?Array.from(t.parentElement.children).indexOf(t):-1}contents(){return Array.from(this.first()?.childNodes??[])}offsetParent(){const t=this.first();return Oe(t)?t.offsetParent:null}position(){const t=this.first();return Oe(t)?{top:t.offsetTop,left:t.offsetLeft}:{top:0,left:0}}innerWidth(){return Tt(this.first(),"width")}innerHeight(){return Tt(this.first(),"height")}outerWidth(t=!1){return Rt(this.first(),"width",t)}outerHeight(t=!1){return Rt(this.first(),"height",t)}show(t=""){return z(this.elements,r=>{r.removeAttribute("hidden"),r.style.display=t}),this}hide(){return z(this.elements,t=>{t.style.display="none"}),this}on(t,r){return z(this.elements,n=>n.addEventListener(t,r)),this}once(t,r){return z(this.elements,n=>n.addEventListener(t,r,{once:!0})),this}off(t,r){return z(this.elements,n=>n.removeEventListener(t,r)),this}trigger(t,r){return z(this.elements,n=>{n.dispatchEvent(new CustomEvent(t,{detail:r,bubbles:!0,cancelable:!0}))}),this}delegate(t,r,n){const s=`${t}:${r}`;return z(this.elements,o=>{const i=c=>{const l=c.target.closest(r);l&&o.contains(l)&&n(c,l)};this.delegatedHandlers.has(o)||this.delegatedHandlers.set(o,new Map);const a=this.delegatedHandlers.get(o);a.has(s)||a.set(s,new Map),a.get(s).set(n,i),o.addEventListener(t,i)}),this}undelegate(t,r,n){const s=`${t}:${r}`;return z(this.elements,o=>{const i=this.delegatedHandlers.get(o);if(!i)return;const a=i.get(s);if(!a)return;const c=a.get(n);c&&(o.removeEventListener(t,c),a.delete(n),a.size===0&&i.delete(s),i.size===0&&this.delegatedHandlers.delete(o))}),this}find(t){const r=new Set,n=[];for(const s of this.elements){const o=s.querySelectorAll(t);for(let i=0;i<o.length;i++)r.has(o[i])||(r.add(o[i]),n.push(o[i]))}return new oe(n)}closest(t){const r=new Set,n=[];for(const s of this.elements){const o=s.closest(t);o&&!r.has(o)&&(r.add(o),n.push(o))}return new oe(n)}parent(){const t=new Set,r=[];for(const n of this.elements){const s=n.parentElement;s&&!t.has(s)&&(t.add(s),r.push(s))}return new oe(r)}children(){const t=new Set,r=[];for(const n of this.elements)for(const s of Array.from(n.children))t.has(s)||(t.add(s),r.push(s));return new oe(r)}siblings(){const t=new Set(this.elements),r=new Set,n=[];for(const s of this.elements){const o=s.parentElement;if(o)for(const i of Array.from(o.children))!t.has(i)&&!r.has(i)&&(r.add(i),n.push(i))}return new oe(n)}next(){const t=new Set,r=[];for(const n of this.elements){const s=n.nextElementSibling;s&&!t.has(s)&&(t.add(s),r.push(s))}return new oe(r)}prev(){const t=new Set,r=[];for(const n of this.elements){const s=n.previousElementSibling;s&&!t.has(s)&&(t.add(s),r.push(s))}return new oe(r)}remove(){return z(this.elements,t=>t.remove()),this}empty(){return z(this.elements,t=>{t.innerHTML=""}),this}insertAll(t,r){if(typeof t=="string"){const s=kn(t);z(this.elements,o=>{o.insertAdjacentHTML(r,s)});return}const n=An(t);this.elements.forEach((s,o)=>{Rn(s,o===0?n:n.map(i=>i.cloneNode(!0)),r)})}},sa=e=>{if(typeof e!="string")return new Ne(e);const t=document.querySelector(e);if(!t)throw new Error(`bQuery: element not found for selector "${e}"`);return new Ne(t)},oa=e=>Array.isArray(e)?new Ct(e):e instanceof NodeList?new Ct(Array.from(e)):new Ct(Array.from(document.querySelectorAll(e)));function ia(e){return e==null?[]:Array.isArray(e)?e:[e]}function aa(e){return Array.from(new Set(e))}function ca(e,t){if(t<=0)return[];const r=[];for(let n=0;n<e.length;n+=t)r.push(e.slice(n,n+t));return r}function la(e){return e.filter(Boolean)}function ua(e){const t=[];for(const r of e)Array.isArray(r)?t.push(...r):t.push(r);return t}function fr(e,t){let r;return Object.assign((...n)=>{r!==void 0&&clearTimeout(r),r=setTimeout(()=>{r=void 0,e(...n)},t)},{cancel:()=>{r!==void 0&&(clearTimeout(r),r=void 0)}})}function On(e,t){let r=0;return Object.assign((...n)=>{const s=Date.now();s-r>=t&&(r=s,e(...n))},{cancel:()=>{r=0}})}function fa(e){let t=!1,r;return(...n)=>(t||(r=e(...n),t=!0),r)}function da(){}function ha(e="bQuery"){return`${e}_${Math.random().toString(36).slice(2,9)}`}function ma(e){return new Promise(t=>setTimeout(t,e))}function pa(e,t){try{return JSON.parse(e)}catch{return t}}function va(e){return e==null?!0:typeof e=="string"?e.trim().length===0:Array.isArray(e)?e.length===0:typeof e=="object"?Object.keys(e).length===0:!1}function ya(e,t){return Math.floor(Math.random()*(t-e+1))+e}function ga(e,t,r){return Math.min(Math.max(e,t),r)}function ba(e,t,r,n=!0){return n?e>=t&&e<=r:e>t&&e<r}function wa(e,t=0){const r=typeof e=="number"?e:Number(e);return Number.isNaN(r)?t:r}function Sa(e){return e&&e.charAt(0).toUpperCase()+e.slice(1)}function Ea(e){return e.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_]+/g,"-").toLowerCase()}function Aa(e){return e.replace(/[-_\s]+(.)?/g,(t,r)=>r?r.toUpperCase():"").replace(/^[A-Z]/,t=>t.toLowerCase())}function ka(e,t,r="…"){if(t<=0)return"";if(e.length<=t)return e;const n=Math.max(0,t-r.length);return`${e.slice(0,n)}${r}`}function Ta(e){return e.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\w\s-]/g,"").trim().replace(/[\s_-]+/g,"-").toLowerCase()}function Ra(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ca(e){return typeof Element<"u"&&e instanceof Element}function $a(e){return!!(e&&typeof e=="object"&&"elements"in e)}function Oa(e){return typeof e=="function"}function La(e){return typeof e=="string"}function Pa(e){return typeof e=="number"&&!Number.isNaN(e)}function Na(e){return typeof e=="boolean"}function Ia(e){return Array.isArray(e)}function Ma(e){return e instanceof Date}function Fe(e){return!!(e&&(e instanceof Promise||typeof e=="object"&&"then"in e&&typeof e.then=="function"))}function Da(e){return typeof e=="object"&&e!==null}var _a={clone:Zi,merge:Pe,pick:ea,omit:ta,hasOwn:ra,debounce:fr,throttle:On,once:fa,noop:da,uid:ha,isElement:Ca,isCollection:$a,isEmpty:va,isPlainObject:Le,isFunction:Oa,isString:La,isNumber:Pa,isBoolean:Na,isArray:Ia,isDate:Ma,isPromise:Fe,isObject:Da,parseJson:pa,sleep:ma,randomInt:ya,clamp:ga,inRange:ba,toNumber:wa,capitalize:Sa,toKebabCase:Ea,toCamelCase:Aa,truncate:ka,slugify:Ta,escapeRegExp:Ra,ensureArray:ia,unique:aa,chunk:ca,compact:la,flatten:ua},Ie=[],Be=0,dr=new Set,$t=new WeakMap,hr=(e,t)=>{Ie.push(e);try{return t()}finally{Ie.pop()}},Ln=()=>Ie[Ie.length-1],mr=e=>{Ie.push(void 0);try{return e()}finally{Ie.pop()}},Pn=e=>{if(Be>0){dr.add(e);return}e()},xa=()=>{for(const e of Array.from(dr)){dr.delete(e);try{e()}catch(t){console.error("bQuery reactive: Error in observer during batch flush",t)}}},qa=()=>{Be+=1},za=()=>{Be<=0||(Be-=1,Be===0&&xa())},Nn=(e,t)=>{let r=$t.get(e);r||(r=new Set,$t.set(e,r)),r.add(t)},ja=(e,t)=>{const r=$t.get(e);r&&r.delete(t)},Qe=e=>{const t=$t.get(e);if(t){for(const r of t)r.unsubscribe(e);t.clear()}},Se=e=>{qa();try{e()}finally{za()}},In={fetch:{headers:{},parseAs:"json"},cookies:{path:"/",sameSite:"Lax",secure:!1},announcer:{politeness:"polite",atomic:!0,delay:16,clearDelay:1e3},pageMeta:{},transitions:{skipOnReducedMotion:!1,classes:[],types:[]},components:{prefix:"bq"}},Ve=e=>{if(typeof Headers<"u"&&e instanceof Headers)return new Headers(e);if(Array.isArray(e))return e.map(t=>Ve(t));if(Le(e)){const t={};for(const[r,n]of Object.entries(e))t[r]=Ve(n);return t}return e},pr=Ve(In),Ua=e=>(pr=Ve(Pe(In,pr,e)),ae()),ae=()=>Ve(pr),Ke=[],Ot=e=>typeof e=="object"&&e!==null&&"_addDisposer"in e,Ha=e=>(typeof e=="object"||typeof e=="function")&&e!==null&&typeof e.then=="function",Wa=e=>{const t=typeof e.constructor=="function"?e.constructor.name:void 0;return typeof e=="function"&&(Symbol.toStringTag in e&&e[Symbol.toStringTag]==="AsyncFunction"||t==="AsyncFunction")},Ye=()=>{for(let e=Ke.length-1;e>=0;e--)if(Ke[e].active)return Ke[e]},Fa=class{constructor(){this.disposers=[],this._active=!0}get active(){return this._active}_addDisposer(e){this._active&&this.disposers.push(e)}run(e){if(!this._active)throw new Error("bQuery reactive: Cannot run in a stopped effectScope");if(Wa(e))throw new Error("bQuery reactive: effectScope.run() only supports synchronous callbacks");Ke.push(this);try{const t=e();if(Ha(t))throw this.stop(),new Error("bQuery reactive: effectScope.run() only supports synchronous callbacks");return t}finally{Ke.pop()}}stop(){if(this._active){this._active=!1;for(let e=this.disposers.length-1;e>=0;e--)try{this.disposers[e]()}catch(t){console.error("bQuery reactive: Error in scope cleanup",t)}this.disposers.length=0}}},Ba=()=>{const e=new Fa,t=Ye();return Ot(t)&&t._addDisposer(()=>e.stop()),e},Mn=()=>Ye(),Dn=e=>{const t=Ye();if(!t||!t.active||!Ot(t))throw new Error("bQuery reactive: onScopeDispose() must be called inside an active effectScope");t._addDisposer(e)},Je=class{constructor(e){this.compute=e,this.hasCachedValue=!1,this.dirty=!0,this.disposed=!1,this.subscribers=new Set,this.markDirty=()=>{if(this.disposed)return;this.dirty=!0;const t=Array.from(this.subscribers);for(const r of t)Pn(r)}}get value(){if(this.disposed)return this.hasCachedValue||(this.cachedValue=mr(()=>this.compute()),this.hasCachedValue=!0),this.cachedValue;const e=Ln();return e&&(this.subscribers.add(e),Nn(e,this)),this.dirty&&(this.dirty=!1,Qe(this.markDirty),this.cachedValue=hr(this.markDirty,this.compute),this.hasCachedValue=!0),this.cachedValue}peek(){return this.disposed?(this.hasCachedValue||(this.cachedValue=mr(()=>this.compute()),this.hasCachedValue=!0),this.cachedValue):(this.dirty&&(this.dirty=!1,Qe(this.markDirty),this.cachedValue=hr(this.markDirty,this.compute),this.hasCachedValue=!0),this.cachedValue)}unsubscribe(e){this.subscribers.delete(e)}dispose(){this.disposed=!0,this.dirty&&(this.hasCachedValue=!1),this.dirty=!1,Qe(this.markDirty),this.subscribers.clear()}},D=e=>{const t=new Je(e),r=Ye();return Ot(r)&&r._addDisposer(()=>t.dispose()),t},j=e=>{let t,r=!1;const n=Ye(),s=()=>{if(t){try{t()}catch(c){console.error("bQuery reactive: Error in effect cleanup",c)}t=void 0}},o=()=>{s(),Qe(a)},i=()=>{r||(r=!0,o())};Ot(n)&&n._addDisposer(i);const a=()=>{if(!r){s(),Qe(a);try{t=hr(a,e)}catch(c){console.error("bQuery reactive: Error in effect",c)}r&&o()}};return a(),i},Ge=class{constructor(e){this._value=e,this.subscribers=new Set}get value(){const e=Ln();return e&&(this.subscribers.add(e),Nn(e,this)),this._value}set value(e){if(Object.is(this._value,e))return;this._value=e;const t=Array.from(this.subscribers);for(const r of t)Pn(r)}peek(){return this._value}update(e){this.value=e(this._value)}dispose(){for(const e of this.subscribers)ja(e,this);this.subscribers.clear()}unsubscribe(e){this.subscribers.delete(e)}},L=e=>new Ge(e),Ee=e=>mr(e),Qa=e=>{if(e instanceof Error)return e;if(typeof e=="string")return new Error(e);try{return new Error(JSON.stringify(e))}catch{return new Error(String(e))}},Va=e=>typeof e=="function"?e():e.value,_n=(...e)=>{const t=new Headers;for(const r of e)r&&new Headers(r).forEach((n,s)=>{t.set(s,n)});return t},Ka=e=>typeof e=="string"||e instanceof Blob||e instanceof FormData||e instanceof URLSearchParams||typeof ArrayBuffer<"u"&&e instanceof ArrayBuffer||typeof ReadableStream<"u"&&e instanceof ReadableStream?!0:typeof e=="object"&&e!==null&&ArrayBuffer.isView(e),Ya=(e,t)=>e==null||Ka(e)?e:(t.has("content-type")||t.set("content-type","application/json"),JSON.stringify(e)),Ja=e=>typeof e=="function"?e():e,Ga=(e,t)=>{for(const[r,n]of Object.entries(t))if(n!=null){if(Array.isArray(n)){for(const s of n)s!=null&&e.searchParams.append(r,String(s));continue}e.searchParams.set(r,String(n))}},Xa=(e,t)=>{const r=typeof window<"u"&&/^https?:/i.test(window.location.href)?window.location.href:"http://localhost",n=t?new URL(t,r).toString():r;return e instanceof URL?new URL(e.toString(),n):new URL(e,n)},Za=async(e,t)=>{if(t==="response")return e;if(t==="text")return await e.text();if(t==="blob")return await e.blob();if(t==="arrayBuffer")return await e.arrayBuffer();if(t==="formData")return await e.formData();const r=await e.text();if(r)try{return JSON.parse(r)}catch(n){const s=e.url?` for ${e.url}`:"";throw new Error(`Failed to parse JSON response${s} (status ${e.status}): ${n instanceof Error?n.message:String(n)}`)}},vr=e=>{const t=e?.trim();return t?t.toUpperCase():void 0},ec=(e,t,r)=>{const n=t instanceof Request?vr(t.method):void 0;return e??n??(r?"POST":void 0)},tc=(e,t,r)=>e||(t instanceof Request?void 0:r),rc=e=>{const t=vr(e.method);let r;if(t!=="GET"&&t!=="HEAD"&&!e.bodyUsed)try{r=e.clone().body??void 0}catch{r=void 0}return{method:t,headers:e.headers,body:r,cache:e.cache,credentials:e.credentials,integrity:e.integrity,keepalive:e.keepalive,mode:e.mode,redirect:e.redirect,referrer:e.referrer,referrerPolicy:e.referrerPolicy,signal:e.signal}},xn=(e,t={})=>{const r=t.immediate??!0,n=L(t.defaultValue),s=L(null),o=L("idle"),i=D(()=>o.value==="pending");let a=0,c=!1,l=()=>{};const u=()=>{a+=1,n.value=t.defaultValue,s.value=null,o.value="idle"},h=()=>{c||(c=!0,a+=1,l())},d=async()=>{if(c)return n.peek();const p=++a;o.value="pending",s.value=null;try{const f=await e(),m=t.transform?t.transform(f):f;return c||p!==a?n.peek():(n.value=m,o.value="success",t.onSuccess?.(m),m)}catch(f){const m=Qa(f);return c||p!==a||(s.value=m,o.value="error",t.onError?.(m)),n.peek()}};if(t.watch?.length){let p=!1;l=j(()=>{for(const f of t.watch??[])Va(f);if(!p){p=!0,r&&Ee(()=>d());return}Ee(()=>d())})}else r&&d();return{data:n,error:s,status:o,pending:i,execute:d,refresh:d,abort:()=>{},clear:u,dispose:h}},nc=e=>e>=200&&e<300,qn=(e,t)=>e instanceof DOMException&&e.name===t,Lt=e=>qn(e,"TimeoutError"),zn=e=>qn(e,"AbortError"),sc=e=>{if(zn(e)||Lt(e)||e.code==="ABORT"||e.code==="TIMEOUT")return!1;const t=e.status;return t===void 0||t>=500},oc=e=>{if(e!=null)return typeof e=="number"?{count:e}:e},ic=(e,t)=>e==null?Math.min(1e3*2**t,3e4):typeof e=="number"?e:e(t),ac=(e,t)=>new Promise((r,n)=>{if(t?.aborted){n(t.reason??new DOMException("The operation was aborted.","AbortError"));return}let s=!1,o;const i=()=>{s||(s=!0,clearTimeout(o),t?.removeEventListener("abort",i),n(t?.reason??new DOMException("The operation was aborted.","AbortError")))};o=setTimeout(()=>{s||(s=!0,t?.removeEventListener("abort",i),r())},e),t?.addEventListener("abort",i,{once:!0})}),re=(e,t={})=>{const r=ae().fetch,n=t.parseAs??r?.parseAs??"json",s=t.fetcher??fetch,o=t.validateStatus??nc;let i=null;const a=(l,u)=>{const h=u||Lt(l)||Lt(i?.signal.reason);return Object.assign(new Error(h?`Request timeout of ${t.timeout}ms exceeded`:"Request aborted"),{code:h?"TIMEOUT":"ABORT"})},c=xn(async()=>{const l=Ja(e),u=typeof l=="string"||l instanceof URL?Xa(l,t.baseUrl??r?.baseUrl):l instanceof Request&&t.query?new URL(l.url):null;u&&t.query&&Ga(u,t.query);const h=_n(r?.headers,l instanceof Request?l.headers:void 0,t.headers),d=t.body!=null,p=vr(t.method),f=ec(p,l,d),m=f==="GET"||f==="HEAD"?f:null;if(d&&m)throw new Error(`Cannot send a request body with ${m} requests`);const v=tc(p,l,f),b=oc(t.retry),g=(b?.count??0)+1,w=new AbortController;i=w;let S,k=!1,A;t.signal&&(t.signal.aborted?w.abort(t.signal.reason):(A=()=>w.abort(t.signal?.reason),t.signal.addEventListener("abort",A,{once:!0}))),t.timeout&&t.timeout>0&&(S=setTimeout(()=>{k=!0,w.abort(new DOMException("Request timeout","TimeoutError"))},t.timeout));const E={...t,method:v,headers:h};delete E.baseUrl,delete E.query,delete E.parseAs,delete E.fetcher,delete E.defaultValue,delete E.immediate,delete E.watch,delete E.transform,delete E.onSuccess,delete E.onError,delete E.timeout,delete E.retry,delete E.validateStatus;let T=u??l;l instanceof Request&&u&&u.toString()!==l.url&&(T=new Request(u.toString(),rc(l)));const P=()=>{const $=new Headers(h);return{...E,headers:$,body:Ya(t.body,$),signal:w.signal}};if(g>1&&typeof ReadableStream<"u"&&t.body instanceof ReadableStream)throw new Error("Cannot retry requests with ReadableStream bodies");if(g>1&&typeof Request<"u"&&T instanceof Request&&T.body!==null)throw new Error("Cannot retry requests with non-replayable Request bodies");let C;try{for(let $=0;$<g;$++)try{const R=await s(T,P());if(!o(R.status))throw Object.assign(new Error(`Request failed with status ${R.status}`),{response:R,status:R.status,statusText:R.statusText});return await Za(R,n)}catch(R){const O=R instanceof Error?R:new Error(String(R));if(w.signal.aborted||zn(O)||Lt(O))throw a(w.signal.aborted?w.signal.reason:O,k);if(C=O,!(b&&(b.retryOn??sc)(O,$))||$>=g-1)throw O;await ac(ic(b.delay,$),w.signal)}throw C}finally{S!==void 0&&clearTimeout(S),t.signal&&A&&t.signal.removeEventListener("abort",A),i===w&&(i=null)}},t);return c.abort=()=>{i&&i.abort(new DOMException("Request aborted","AbortError"))},c};function cc(e={}){return(t,r={})=>{const n=e,s=Pe({},n.query??{},r.query??{});return re(t,{...n,...r,headers:_n(n.headers,r.headers),query:Object.keys(s).length>0?s:void 0})}}var ye=class extends Error{constructor(e,t,r,n){super(e),this.name="HttpError",this.config=t,this.code=r,this.response=n}};function jn(){const e=[];let t=0;return{use(r,n){const s=t++;return e.push({id:s,fulfilled:r,rejected:n}),s},eject(r){const n=e.findIndex(s=>s?.id===r);n!==-1&&(e[n]=null)},clear(){e.length=0},forEach(r){for(const n of e)n&&r(n)}}}var lc=e=>e>=200&&e<300,uc=e=>{if(e.code==="PARSE")return!1;if(e.code==="TIMEOUT"||e.code==="NETWORK")return!0;const t=e.response?.status;return t!==void 0&&t>=500},fc=e=>{if(e!=null)return typeof e=="number"?{count:e}:e},dc=(e,t)=>e==null?Math.min(1e3*2**t,3e4):typeof e=="number"?e:e(t),hc=(e,t)=>new Promise((r,n)=>{if(t?.aborted){n(t.reason??new DOMException("The operation was aborted.","AbortError"));return}let s;const o=()=>{clearTimeout(s),t?.removeEventListener("abort",o),n(t?.reason??new DOMException("The operation was aborted.","AbortError"))};s=setTimeout(()=>{t?.removeEventListener("abort",o),r()},e),t&&t.addEventListener("abort",o,{once:!0})}),Un=(...e)=>{const t=new Headers;for(const r of e)r&&new Headers(r).forEach((n,s)=>{t.set(s,n)});return t},mc=e=>typeof e=="string"||e instanceof Blob||e instanceof FormData||e instanceof URLSearchParams||typeof ArrayBuffer<"u"&&e instanceof ArrayBuffer||typeof ReadableStream<"u"&&e instanceof ReadableStream?!0:typeof e=="object"&&e!==null&&ArrayBuffer.isView(e),pc=(e,t)=>e==null||mc(e)?e:(t.has("content-type")||t.set("content-type","application/json"),JSON.stringify(e)),vc=(e,t)=>{for(const[r,n]of Object.entries(t))if(n!=null){if(Array.isArray(n)){for(const s of n)s!=null&&e.searchParams.append(r,String(s));continue}e.searchParams.set(r,String(n))}},yc=(e,t)=>{const r=typeof window<"u"&&/^https?:/i.test(window.location.href)?window.location.href:"http://localhost",n=t?new URL(t,r).toString():r;return new URL(e,n)},gc=async(e,t,r)=>{if(t==="response")return e;if(t==="text")return await e.text();if(t==="blob")return await e.blob();if(t==="arrayBuffer")return await e.arrayBuffer();if(t==="formData")return await e.formData();const n=await e.text();if(n)try{return JSON.parse(n)}catch(s){throw new ye(`Failed to parse JSON response${e.url?` for ${e.url}`:""} (status ${e.status}): ${s instanceof Error?s.message:String(s)}`,r,"PARSE",{data:n,status:e.status,statusText:e.statusText,headers:e.headers,config:r})}},bc=(e,t)=>{const r=e.body;if(!r)return e;const n=parseInt(e.headers.get("content-length")??"0",10)||0;let s=0;const o=r.getReader(),i=new ReadableStream({async pull(a){const{done:c,value:l}=await o.read();if(c){a.close();return}s+=l.byteLength,t({loaded:s,total:n,percent:n>0?Math.round(s/n*100):void 0}),a.enqueue(l)},cancel(a){o.cancel(a)}});return new Response(i,{status:e.status,statusText:e.statusText,headers:e.headers})},wc=async e=>{const t=ae().fetch,r=e.parseAs??t?.parseAs??"json",n=e.fetcher??fetch,s=e.validateStatus??lc,o=yc(e.url??"/",e.baseUrl??t?.baseUrl);e.query&&vc(o,e.query);const i=Un(t?.headers,e.headers),a=pc(e.body,i),c={};e.method&&(c.method=e.method.toUpperCase()),c.headers=i,a!=null&&(c.body=a),e.cache&&(c.cache=e.cache),e.credentials&&(c.credentials=e.credentials),e.integrity&&(c.integrity=e.integrity),e.keepalive!==void 0&&(c.keepalive=e.keepalive),e.mode&&(c.mode=e.mode),e.redirect&&(c.redirect=e.redirect),e.referrer&&(c.referrer=e.referrer),e.referrerPolicy&&(c.referrerPolicy=e.referrerPolicy);let l,u=e.signal,h;if(e.timeout&&e.timeout>0){const d=new AbortController;e.signal&&(h=()=>d.abort(e.signal?.reason),e.signal.addEventListener("abort",h,{once:!0})),l=setTimeout(()=>{d.abort(new DOMException("Request timeout","TimeoutError"))},e.timeout),u=d.signal}u&&(c.signal=u);try{let d=await n(o.toString(),c);if(e.onDownloadProgress&&(d=bc(d,e.onDownloadProgress)),!s(d.status))throw new ye(`Request failed with status ${d.status}`,e,"ERR_BAD_RESPONSE",{data:void 0,status:d.status,statusText:d.statusText,headers:d.headers,config:e});return{data:await gc(d,r,e),status:d.status,statusText:d.statusText,headers:d.headers,config:e}}catch(d){if(d instanceof ye)throw d;if(d instanceof DOMException&&(d.name==="AbortError"||d.name==="TimeoutError")){const p=d.name==="TimeoutError"||d.message==="Request timeout";throw new ye(p?`Request timeout of ${e.timeout}ms exceeded`:"Request aborted",e,p?"TIMEOUT":"ABORT")}throw new ye(d instanceof Error?d.message:String(d),e,"NETWORK")}finally{l!==void 0&&clearTimeout(l),e.signal&&h&&e.signal.removeEventListener("abort",h)}};function yr(e={}){const t=jn(),r=jn(),n=i=>{const a=Pe({},e.query??{},i.query??{});return{...e,...i,headers:Un(e.headers,i.headers),query:Object.keys(a).length>0?a:void 0}},s=async i=>{let a=i;const c=[];t.forEach(d=>c.push(d));for(const{fulfilled:d,rejected:p}of c)try{d&&(a=await d(a))}catch(f){if(p){const m=await p(f);if(Le(m))a=m;else throw f}else throw f}const l=fc(a.retry);let u;const h=(l?.count??0)+1;for(let d=0;d<h;d++)try{let p=await wc(a);const f=[];r.forEach(m=>f.push(m));for(const{fulfilled:m,rejected:v}of f)try{m&&(p=await m(p))}catch(b){if(v){const g=await v(b);if(g&&typeof g=="object"&&"data"in g)p=g;else throw b}else throw b}return p}catch(p){const f=p instanceof ye?p:new ye(p instanceof Error?p.message:String(p),a,"NETWORK");if(u=f,!(l&&(l.retryOn??uc)(f,d))||d>=h-1){const v=[];r.forEach(g=>v.push(g));let b=f;for(const{rejected:g}of v)if(g)try{const w=await g(b);if(w&&typeof w=="object"&&"data"in w)return w;w!=null&&(b=w)}catch(w){w!=null&&(b=w)}throw b instanceof Error||(b=f),b}const m=l?dc(l.delay,d):0;l?.onRetry?.(f,d+1),await hc(m,a.signal)}throw u},o=i=>s(n(i));return{request:o,get:(i,a={})=>o({...a,url:i,method:"GET"}),post:(i,a,c={})=>o({...c,url:i,method:"POST",body:a}),put:(i,a,c={})=>o({...c,url:i,method:"PUT",body:a}),patch:(i,a,c={})=>o({...c,url:i,method:"PATCH",body:a}),delete:(i,a={})=>o({...a,url:i,method:"DELETE"}),head:(i,a={})=>o({...a,url:i,method:"HEAD"}),options:(i,a={})=>o({...a,url:i,method:"OPTIONS"}),interceptors:{request:t,response:r},defaults:e}}var Sc=yr();function Ec(e={}){const{concurrency:t=6}=e;if(!Number.isInteger(t)||t<1)throw new Error("Request queue concurrency must be a positive integer");const r=[];let n=0;const s=()=>{for(;n<t&&r.length>0;){const o=r.shift();n++,Promise.resolve().then(o.execute).then(o.resolve,o.reject).finally(()=>{n--,s()})}};return{add(o){return new Promise((i,a)=>{r.push({execute:o,resolve:i,reject:a}),s()})},get pending(){return n},get size(){return r.length},clear(){const o=r.splice(0);for(const i of o)i.reject(new Error("Request queue cleared"))}}}var Ac=(e,t)=>{const r=D(e);return{get value(){return r.value},set value(n){t(n)},peek(){return r.peek()}}},kc=(e,t={})=>{const{initialPage:r=1,...n}=t,s=L(r),o=re(()=>e(s.value),{...n,watch:n.watch});return{...o,page:s,next:async()=>(s.value=s.peek()+1,o.execute()),prev:async()=>{const l=s.peek();return l>1&&(s.value=l-1),o.execute()},goTo:async l=>(s.value=Math.max(1,l),o.execute())}},Tc=(e,t)=>{const{getNextCursor:r,transform:n,initialCursor:s,immediate:o=!0,onSuccess:i,onError:a,...c}=t,l=L([]),u=L(t.defaultValue),h=L(null),d=L("idle"),p=D(()=>d.value==="pending"),f=L(s),m=D(()=>l.value.length===0||f.value!==void 0);let v=!1,b=0;const g=E=>n?n(E):E,w=async()=>{if(v)return u.peek();const E=++b;d.value="pending",h.value=null;try{const T=re(e(f.peek()),{...c,immediate:!1,watch:void 0}),P=await T.execute(),C=T.error.peek();if(T.dispose(),v||E!==b)return u.peek();if(C)return h.value=C,d.value="error",a?.(C),u.peek();if(P!==void 0){const $=P,R=[...l.peek(),$];l.value=R,f.value=r($,R);const O=g(R);return u.value=O,d.value="success",i?.(O),O}return d.value="success",u.peek()}catch(T){if(v||E!==b)return u.peek();const P=T instanceof Error?T:new Error(String(T));return h.value=P,d.value="error",a?.(P),u.peek()}},S=async()=>(l.value=[],f.value=s,u.value=t.defaultValue,h.value=null,d.value="idle",b+=1,w()),k=()=>{b+=1,l.value=[],f.value=s,u.value=t.defaultValue,h.value=null,d.value="idle"},A=()=>{v||(v=!0,b+=1)};return o&&w(),{data:u,pages:l,error:h,status:d,pending:p,hasMore:m,fetchNextPage:w,refresh:S,clear:k,dispose:A}},Rc=(e,t)=>{let r=!1,n=null;try{if(n=globalThis.localStorage,n){const i=`__bquery_test_${Math.random().toString(36).slice(2,9)}__`,a="__test__";try{n.setItem(i,a),n.getItem(i),r=!0}finally{try{n.removeItem(i)}catch{}}}}catch{r=!1}let s=t;if(r&&n)try{const i=n.getItem(e);i!==null&&(s=JSON.parse(i))}catch{}const o=L(s);return r&&n&&j(()=>{try{n.setItem(e,JSON.stringify(o.value))}catch{}}),o},Cc=(e,t)=>{const{interval:r,enabled:n=!0,pauseOnHidden:s=!0,pauseOnOffline:o=!0,immediate:i=!0,...a}=t;if(!Number.isFinite(r)||r<1)throw new Error("Polling interval must be a finite number of at least 1");const c=L(!1),l=L(!1),u=L(!1),h=typeof n=="function"?n:()=>n,d=D(()=>h()&&!c.value&&!(s&&l.value)&&!(o&&u.value)),p=re(e,{...a,immediate:i&&h()});let f,m=[];const v=()=>{b(),f=setInterval(()=>{p.execute()},r)},b=()=>{f!==void 0&&(clearInterval(f),f=void 0)},g=j(()=>{const k=d.value;Ee(()=>{k?v():b()})});if(s&&typeof document<"u"){l.value=document.hidden;const k=()=>{l.value=document.hidden};document.addEventListener("visibilitychange",k),m.push(()=>document.removeEventListener("visibilitychange",k))}if(o&&typeof window<"u"){const k=()=>{u.value=!1},A=()=>{u.value=!0};window.addEventListener("online",k),window.addEventListener("offline",A),m.push(()=>{window.removeEventListener("online",k),window.removeEventListener("offline",A)}),u.value=typeof navigator<"u"&&navigator.onLine!==void 0?!navigator.onLine:!1}const w=p.dispose;return{...p,pause:()=>{c.value=!0},resume:()=>{c.value=!1},isActive:d,dispose:()=>{b(),g();for(const k of m)k();m=[],w()}}},Hn=Symbol("bquery.readonlySignal"),Wn=e=>typeof e=="object"&&e!==null&&Object.prototype.hasOwnProperty.call(e,Hn),_=e=>Object.defineProperties({},{value:{get(){return e.value},enumerable:!0},peek:{value(){return e.peek()},enumerable:!0},[Hn]:{value:!0,enumerable:!1,configurable:!1,writable:!1}}),$c=(e,t={})=>{const{optimistic:r=!1,onMutationSuccess:n,onMutationError:s,...o}=t,i=re(e,{...o}),a=L(!1),c=D(()=>a.value);let l=!1;const u=()=>{const v=typeof e=="function"?e():e;return v instanceof URL?v.toString():v},h=()=>{const{defaultValue:v,transform:b,onSuccess:g,onError:w,...S}=o;return S},d=async(v,b,g,w)=>{if(l)return i.data.peek();const S=i.data.peek();r&&w!==void 0&&(i.data.value=w),a.value=!0,i.error.value=null;try{const k=re(u(),{...h(),method:b,body:g??void 0,immediate:!1,watch:void 0}),A=await k.execute(),E=k.error.peek();return k.dispose(),l?i.data.peek():E?(r&&w!==void 0&&(i.data.value=S),i.error.value=E,i.status.value="error",a.value=!1,s?.(E,v),i.data.peek()):(b!=="DELETE"&&A!==void 0&&(i.data.value=A),a.value=!1,i.status.value="success",n?.(A,v),A)}catch(k){if(l)return i.data.peek();r&&w!==void 0&&(i.data.value=S);const A=k instanceof Error?k:new Error(String(k));return i.error.value=A,i.status.value="error",a.value=!1,s?.(A,v),i.data.peek()}},p={fetch:()=>i.execute(),create:v=>d("create","POST",v),update:v=>{const b=i.data.peek();return d("update","PUT",v,r&&b!==void 0?{...b,...v}:void 0)},patch:v=>{const b=i.data.peek();return d("patch","PATCH",v,r&&b!==void 0?{...b,...v}:void 0)},remove:async()=>{await d("remove","DELETE"),!l&&i.error.peek()==null&&(i.data.value=void 0)}},f=i.dispose,m=()=>{l||(l=!0,f())};return{data:i.data,error:i.error,status:i.status,pending:i.pending,isMutating:c,actions:p,refresh:i.execute,clear:i.clear,dispose:m}},Oc=(e,t={})=>{const{method:r="POST",...n}=t,s=L(void 0),o=L(null),i=L("idle"),a=D(()=>i.value==="pending");return{data:s,error:o,status:i,pending:a,submit:async u=>{i.value="pending",o.value=null;try{const h=re(e,{...n,method:r,body:u,immediate:!1,watch:void 0}),d=await h.execute(),p=h.error.peek();if(h.dispose(),p){o.value=p,i.value="error";return}return s.value=d,i.value="success",d}catch(h){o.value=h instanceof Error?h:new Error(String(h)),i.value="error";return}},clear:()=>{s.value=void 0,o.value=null,i.value="idle"}}},Lc=(e,t={})=>{const r=yr({...t});let n=e;for(;n.endsWith("/");)n=n.slice(0,-1);return{list:s=>r.get(n,s),get:(s,o)=>r.get(`${n}/${encodeURIComponent(String(s))}`,o),create:(s,o)=>r.post(n,s,o),update:(s,o,i)=>r.put(`${n}/${encodeURIComponent(String(s))}`,o,i),patch:(s,o,i)=>r.patch(`${n}/${encodeURIComponent(String(s))}`,o,i),remove:(s,o)=>r.delete(`${n}/${encodeURIComponent(String(s))}`,o),http:r}},Pc=(e,t={})=>{const{getId:r=g=>g.id,optimistic:n=!1,onMutationSuccess:s,onMutationError:o,...i}=t,a=re(e,{...i}),c=L(!1),l=D(()=>c.value);let u=!1;const h=()=>{const g=typeof e=="function"?e():e;return g instanceof URL?g.toString():g},d=()=>{let g=h();for(;g.endsWith("/");)g=g.slice(0,-1);return g},p=()=>{const{defaultValue:g,transform:w,onSuccess:S,onError:k,...A}=i;return A},f=async(g,w,S,k,A,E)=>{if(!u){n&&A&&A(),c.value=!0,a.error.value=null;try{const T=re(`${d()}${S}`,{...p(),method:w,body:k??void 0,immediate:!1,watch:void 0}),P=await T.execute(),C=T.error.peek();if(T.dispose(),u)return;if(C){n&&E&&E(),a.error.value=C,a.status.value="error",c.value=!1,o?.(C,g);return}return c.value=!1,a.status.value="success",s?.(g),P}catch(T){if(u)return;n&&E&&E();const P=T instanceof Error?T:new Error(String(T));a.error.value=P,a.status.value="error",c.value=!1,o?.(P,g);return}}},m={fetch:()=>a.execute(),add:async g=>{const w=a.data.peek(),S=g,k=w?.length??0,A=await f("add","POST","",g,n?()=>{a.data.value=[...w??[],S]}:void 0,n?()=>{a.data.value=w}:void 0);if(A!==void 0&&!u){const E=a.data.peek()??[];if(n){const T=[...E];k<T.length&&T[k]===S?T[k]=A:T.push(A),a.data.value=T}else a.data.value=[...E,A]}return A},update:async(g,w)=>{const S=a.data.peek(),k=await f("update","PUT",`/${encodeURIComponent(String(g))}`,w,n&&S?()=>{a.data.value=S.map(A=>r(A)===g?{...A,...w}:A)}:void 0,n?()=>{a.data.value=S}:void 0);if(k!==void 0&&!u){const A=a.data.peek()??[];a.data.value=A.map(E=>r(E)===g?k:E)}return k},patch:async(g,w)=>{const S=a.data.peek(),k=await f("patch","PATCH",`/${encodeURIComponent(String(g))}`,w,n&&S?()=>{a.data.value=S.map(A=>r(A)===g?{...A,...w}:A)}:void 0,n?()=>{a.data.value=S}:void 0);if(k!==void 0&&!u){const A=a.data.peek()??[];a.data.value=A.map(E=>r(E)===g?k:E)}return k},remove:async g=>{const w=a.data.peek();if(await f("remove","DELETE",`/${encodeURIComponent(String(g))}`,void 0,n&&w?()=>{a.data.value=w.filter(S=>r(S)!==g)}:void 0,n?()=>{a.data.value=w}:void 0),!n&&!u&&a.error.peek()==null){const S=a.data.peek()??[];a.data.value=S.filter(k=>r(k)!==g)}}},v=a.dispose,b=()=>{u||(u=!0,v())};return{data:a.data,error:a.error,status:a.status,pending:a.pending,isMutating:l,actions:m,refresh:a.execute,clear:a.clear,dispose:b}},gr=new Map;function Nc(e,t){const r=gr.get(e);if(r)return r;const n=t().finally(()=>{gr.delete(e)});return gr.set(e,n),n}var G=e=>e instanceof Ge,ce=e=>e instanceof Je,Ic=e=>e instanceof Ge||e instanceof Je||Wn(e)?e.value:e,br=(e,t,r={})=>{const{immediate:n=!1,equals:s=Object.is}=r;let o,i=!0;return j(()=>{const a=e.value;if(i){i=!1,o=a,n&&t(a,void 0);return}s(a,o)||(t(a,o),o=a)})},Mc=(e,t,r,n={})=>{const{immediate:s=!1,equals:o=Object.is}=n,i=Number.isFinite(r)?Math.max(0,r):0;let a=!1,c,l;const u=()=>{h.cancel(),a=!1,l=void 0},h=fr(()=>{if(a){try{t(c,l)}catch(p){console.error("bQuery reactive: Error in watchDebounce callback",p)}a=!1,l=void 0}},i);s&&t(e.peek(),void 0);const d=br(e,(p,f)=>{a||(l=f),c=p,a=!0,h()},{equals:o});return Mn()&&Dn(u),()=>{d(),u()}},Dc=(e,t,r,n={})=>{const{immediate:s=!1,equals:o=Object.is}=n,i=On((c,l)=>{t(c,l)},Number.isFinite(r)?Math.max(0,r):0);s&&i(e.peek(),void 0);const a=br(e,(c,l)=>{i(c,l)},{equals:o});return()=>{a(),i.cancel()}};function Fn(e){return e===!1?!1:e===!0||e===void 0?{}:e}var _c=e=>e?e===!0?{}:e:!1,Bn=(e,t)=>{const r=t.delay??1e3,n=t.factor??2,s=t.maxDelay??3e4;return Math.min(r*n**e,s)},wr=(e,t)=>{if(typeof t=="string"||t instanceof Blob||t instanceof ArrayBuffer){e.send(t);return}if(ArrayBuffer.isView(t)){e.send(t);return}if(typeof SharedArrayBuffer<"u"&&t instanceof SharedArrayBuffer){e.send(t);return}throw new TypeError("Unsupported WebSocket payload type.")},Qn=(e,t={})=>{const{protocols:r,immediate:n=!0,historySize:s=0,onOpen:o,onMessage:i,onClose:a,onError:c,onReconnect:l}=t,u=t.serialize??(M=>JSON.stringify(M)),h=t.deserialize??(M=>{const B=M.data;if(typeof B=="string")try{return JSON.parse(B)}catch{return B}return B}),d=L("CLOSED"),p=L(void 0),f=L(null),m=L([]),v=L(0),b=L(0),g=L(0),w=D(()=>d.value==="OPEN");let S=null,k=!1,A=!1,E,T,P,C=0,$=!1,R=0;const O=[],I=Fn(t.autoReconnect),x=_c(t.heartbeat),W=()=>{if(!x)return;q();const M=x.interval??3e4,B=x.pongTimeout??1e4,J=x.message??"ping";T=setInterval(()=>{S?.readyState===WebSocket.OPEN&&(R=Date.now(),wr(S,J),P!==void 0&&clearTimeout(P),P=setTimeout(()=>{S?.close(4e3,"Heartbeat timeout")},B))},M)},q=()=>{T!==void 0&&(clearInterval(T),T=void 0),P!==void 0&&(clearTimeout(P),P=void 0)},V=()=>{P!==void 0&&(clearTimeout(P),P=void 0),R>0&&(b.value=Date.now()-R,R=0)},ve=M=>{if(k||A||!I)return;const B=I.maxAttempts??1/0;if(C>=B||I.shouldReconnect&&!I.shouldReconnect(M,C))return;const J=Bn(C,I);E=setTimeout(()=>{C++,v.value=C,$=!0,an()},J)},We=()=>{E!==void 0&&(clearTimeout(E),E=void 0)},on=()=>{if(!S||S.readyState!==WebSocket.OPEN)return;let M=0;for(;M<O.length&&S.readyState===WebSocket.OPEN;M++)wr(S,O[M]);M>0&&O.splice(0,M)},Et=()=>{const M=typeof e=="function"?e():e;return M instanceof URL?M.toString():M},an=()=>{if(!k){We(),S&&(q(),R=0,S.onopen=null,S.onmessage=null,S.onclose=null,S.onerror=null,(S.readyState===WebSocket.OPEN||S.readyState===WebSocket.CONNECTING)&&S.close(),S=null),A=!1,d.value="CONNECTING",f.value=null;try{S=new WebSocket(Et(),r)}catch{d.value="CLOSED";return}S.onopen=M=>{d.value="OPEN";const B=$,J=C;C=0,v.value=0,$=!1,on(),W(),o?.(M),B&&l?.(J)},S.onmessage=M=>{if(x){const J=x.responseMessage;(J===void 0||M.data===J)&&V()}const B=h(M);if(p.value=B,s>0){const J=[...m.peek(),B];m.value=J.length>s?J.slice(-s):J}i?.(B,M)},S.onclose=M=>{d.value="CLOSED",q(),A||(g.value=Date.now()),a?.(M),!A&&!k&&ve(M)},S.onerror=M=>{f.value=M,c?.(M)}}},_i=(M,B)=>{A=!0,We(),q(),S&&(S.readyState===WebSocket.OPEN||S.readyState===WebSocket.CONNECTING)&&(d.value="CLOSING",S.close(M,B))},Np=M=>{k||xi(u(M))},xi=M=>{k||(S?.readyState===WebSocket.OPEN?wr(S,M):O.push(M))},Ip=()=>{k||(k=!0,_i(),O.length=0,S=null)};return n&&an(),{status:d,data:p,error:f,history:m,isConnected:w,reconnectAttempts:v,latency:b,lastDisconnectedAt:g,send:Np,sendRaw:xi,open:an,close:_i,dispose:Ip}},xc=(e,t={},r={})=>{const n=r.getChannel??(u=>u.channel),s=r.wrap??((u,h)=>({channel:u,data:h})),o=new Map,i=new Map,a=Qn(e,{...t,onMessage:(u,h)=>{const d=n(u);if(d!==void 0){const p=o.get(d);p&&(p.value=u)}t.onMessage?.(u,h)}});return{subscribe:u=>{let h=o.get(u);h||(h=L(void 0),o.set(u,h)),i.set(u,(i.get(u)??0)+1);let d=!1;return{data:h,unsubscribe:()=>{if(d)return;d=!0;const p=(i.get(u)??1)-1;p<=0?(i.delete(u),o.delete(u)):i.set(u,p)}}},publish:(u,h)=>{a.send(s(u,h))},ws:a}},qc=(e,t={})=>{const{immediate:r=!0,events:n=[],eventSourceInit:s,onOpen:o,onMessage:i,onError:a}=t,c=t.deserialize??($=>{try{return JSON.parse($)}catch{return $}}),l=L("CLOSED"),u=L(void 0),h=L(void 0),d=L(null),p=D(()=>l.value==="OPEN"),f=Fn(t.autoReconnect);let m=null,v=!1,b=!1,g,w=0;const S=()=>{const $=typeof e=="function"?e():e;return $ instanceof URL?$.toString():$},k=$=>R=>{const O=c(R.data);u.value=O,h.value=$,i?.(O,R)},A=()=>{g!==void 0&&(clearTimeout(g),g=void 0)},E=()=>{if(v||b||!f)return;const $=f.maxAttempts??1/0;if(w>=$)return;const R=Bn(w,f);g=setTimeout(()=>{w++,T()},R)},T=()=>{if(!v){A(),m&&(m.close(),m=null),b=!1,l.value="CONNECTING",d.value=null;try{m=new EventSource(S(),s)}catch{l.value="CLOSED";return}m.onopen=$=>{l.value="OPEN",w=0,o?.($)},m.onerror=$=>{d.value=$,a?.($),m?.readyState===EventSource.CLOSED&&(l.value="CLOSED",!b&&!v&&E())},m.addEventListener("message",k("message"));for(const $ of n)m.addEventListener($,k($))}},P=()=>{b=!0,A(),m&&(m.close(),m=null),l.value="CLOSED"},C=()=>{v||(v=!0,P())};return r&&T(),{status:l,data:u,eventName:h,error:d,isConnected:p,open:T,close:P,dispose:C}},H=class extends Error{constructor(e,t,r){super(e),this.name="TaskWorkerError",this.code=t,r!==void 0&&(this.cause=r)}},Sr=class extends H{constructor(e="Concurrency tasks are not supported in this environment.",t){super(e,"UNSUPPORTED",t),this.name="TaskWorkerUnsupportedError"}},Ae=class extends H{constructor(e,t){super(e,"SERIALIZATION",t),this.name="TaskWorkerSerializationError"}},Pt=class extends H{constructor(e,t){super(e,"TIMEOUT",t),this.name="TaskWorkerTimeoutError"}},ge=class extends H{constructor(e="The worker task was aborted.",t){super(e,"ABORT",t),this.name="TaskWorkerAbortError"}},zc=new Set(["ABORT","BUSY","METHOD_NOT_FOUND","QUEUE_CLEARED","QUEUE_FULL","SERIALIZATION","TERMINATED","TIMEOUT","UNSUPPORTED","WORKER"]),jc=/\{\s*\[native code\]\s*\}$/u,Uc=e=>typeof e=="string"&&zc.has(e),Nt=e=>{if(!(typeof e!="number"||!Number.isFinite(e)||e<=0))return e},Xe=e=>{const t=Function.prototype.toString.call(e).trim();if(!t||jc.test(t))throw new Ae("Task handlers must be standalone user-defined functions or arrow functions.");try{if(typeof new Function(`return (${t});`)()!="function")throw new TypeError("Task handler did not revive as a function.")}catch(r){throw new Ae("Task handlers must be standalone functions that can be reconstructed in a worker context.",r)}return t},Vn=(e,t)=>{const r=new Blob([e],{type:"text/javascript"}),n=URL.createObjectURL(r);try{return new Worker(n,t?{name:t}:void 0)}finally{URL.revokeObjectURL(n)}},Kn=e=>{const t=e?.message||"Worker task failed.",r=Uc(e?.code)?e.code:"WORKER",n=r==="TIMEOUT"?new Pt(t):new H(t,r);return n.name=e?.name||n.name,e?.stack&&(n.stack=e.stack),n};function Yn(){const e=typeof globalThis.Worker=="function",t=typeof globalThis.Blob=="function",r=typeof globalThis.URL<"u"&&globalThis.URL!==null&&typeof globalThis.URL.createObjectURL=="function"&&typeof globalThis.URL.revokeObjectURL=="function";return{worker:e,blob:t,objectUrl:r,abortController:typeof globalThis.AbortController=="function",supported:e&&t&&r}}function Er(){return Yn().supported}var Jn="bq:rpc",Hc=e=>{const t=Object.keys(e);if(t.length===0)throw new Ae("RPC workers require at least one standalone method handler.");return t.map(r=>{const n=e[r];if(typeof n!="function")throw new Ae(`RPC handler "${r}" must be a standalone function.`);return[r,Xe(n)]})},Wc=e=>`'use strict';
1
+ (function(m,Le){typeof exports=="object"&&typeof module<"u"?Le(exports):typeof define=="function"&&define.amd?define(["exports"],Le):(m=typeof globalThis<"u"?globalThis:m||self,Le(m.bQuery={}))})(this,function(m){Object.defineProperty(m,Symbol.toStringTag,{value:"Module"});var Le="bquery-sanitizer",hn=new Set(["a","abbr","address","article","aside","b","bdi","bdo","blockquote","br","button","caption","cite","code","col","colgroup","data","dd","del","details","dfn","div","dl","dt","em","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","hr","i","img","input","ins","kbd","label","legend","li","main","mark","nav","ol","optgroup","option","p","picture","pre","progress","q","rp","rt","ruby","s","samp","section","select","small","source","span","strong","sub","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","u","ul","var","wbr"]),ur=new Set(["script","iframe","frame","frameset","object","embed","applet","link","meta","style","base","template","math","svg","foreignobject","noscript"]),mn=new Set(["document","window","location","top","self","parent","frames","history","navigator","screen","alert","confirm","prompt","eval","function","cookie","domain","referrer","body","head","forms","images","links","scripts","children","parentnode","firstchild","lastchild","innerhtml","outerhtml","textcontent"]),pn=new Set(["alt","class","dir","height","hidden","href","id","lang","loading","name","rel","role","src","srcset","tabindex","target","title","type","width","aria-*"]),vn=["on","formaction","xlink:","xmlns:"],fr=["javascript:","data:","vbscript:","file:"],ba=(e,t,r)=>{const n=e.toLowerCase();for(const s of vn)if(n.startsWith(s))return!1;return r&&n.startsWith("data-")||n.startsWith("aria-")?!0:t.has(n)},wa=e=>{const t=e.toLowerCase().trim();return!mn.has(t)},Sa=e=>e.replace(/[\u0000-\u001F\u007F]+/g,"").replace(/[\u200B-\u200D\uFEFF\u2028\u2029]+/g,"").replace(/\\u[\da-fA-F]{4}/g,"").replace(/\s+/g,"").toLowerCase(),yn=e=>{const t=Sa(e);for(const r of fr)if(t.startsWith(r))return!1;return!0},Ea=e=>{const t=e.split(",");for(const r of t){const n=r.trim().split(/\s+/)[0];if(n&&!yn(n))return!1}return!0},Aa=e=>{try{const t=e.trim();if(t.startsWith("//"))return!0;const r=t.toLowerCase();return/^[a-z][a-z0-9+.-]*:/i.test(t)&&!r.startsWith("http://")&&!r.startsWith("https://")?!0:!r.startsWith("http://")&&!r.startsWith("https://")?!1:typeof window>"u"||!window.location?!0:new URL(t,window.location.href).origin!==window.location.origin}catch{return!0}},ka=e=>new DOMParser().parseFromString(e,"text/html"),gn=e=>{const t=(typeof e=="string"?e:String(e??"")).trim(),r=document.createDocumentFragment();if(t.length===0)return r;if(!(t.includes("<")||t.includes(">")))return r.appendChild(document.createTextNode(t)),r;const n=ka(t).body;if(!n)return r;for(;n.firstChild;)r.appendChild(n.firstChild);return r},kt=(e,t={})=>{const{allowTags:r=[],allowAttributes:n=[],allowDataAttributes:s=!0,stripAllTags:o=!1}=t,i=new Set([...hn,...r.map(f=>f.toLowerCase())].filter(f=>!ur.has(f))),a=new Set([...pn,...n.map(f=>f.toLowerCase())]),c=gn(e);if(o)return c.textContent??"";const l=document.createTreeWalker(c,NodeFilter.SHOW_ELEMENT),u=[];for(;l.nextNode();){const f=l.currentNode,p=f.tagName.toLowerCase();if(ur.has(p)){u.push(f);continue}if(!i.has(p)){u.push(f);continue}const y=[];for(const b of Array.from(f.attributes)){const g=b.name.toLowerCase();if(!ba(g,a,s)){y.push(b.name);continue}if((g==="id"||g==="name")&&!wa(b.value)){y.push(b.name);continue}if((g==="href"||g==="src"||g==="action")&&!yn(b.value)){y.push(b.name);continue}g==="srcset"&&!Ea(b.value)&&y.push(b.name)}for(const b of y)f.removeAttribute(b);if(p==="a"){const b=f.getAttribute("href"),g=f.getAttribute("target")?.toLowerCase()==="_blank",w=b&&Aa(b);if(g||w){const S=f.getAttribute("rel"),k=new Set(S?S.split(/\s+/).filter(Boolean):[]);k.add("noopener"),k.add("noreferrer"),f.setAttribute("rel",Array.from(k).join(" "))}}}for(const f of u)f.remove();const h=f=>{const p=document.createElement("div");return p.appendChild(f.cloneNode(!0)),p.innerHTML},d=h(c),v=h(gn(d));return d!==v?c.textContent??"":v},bn=Symbol("bquery.trusted-html.brand"),dr=Symbol("bquery.trusted-html"),wn=e=>e,Ta=e=>{const t=String(e);return Object.freeze({[bn]:!0,[dr]:t,toString:()=>t})},Ca=e=>typeof e=="object"&&e!==null&&bn in e&&dr in e,Ra=e=>e[dr],Sn=1024,En=8192,An=(e=16)=>{if(!Number.isInteger(e)||e<1)throw new RangeError("generateNonce length must be a positive integer");if(e>Sn)throw new RangeError(`generateNonce length must not exceed ${Sn}`);if(typeof globalThis.crypto>"u"||typeof globalThis.crypto.getRandomValues!="function")throw new Error("generateNonce requires crypto.getRandomValues (not available in this environment)");if(typeof globalThis.btoa!="function")throw new Error("generateNonce requires btoa (not available in this environment)");const t=new Uint8Array(e);globalThis.crypto.getRandomValues(t);let r="";for(let n=0;n<t.length;n+=En){const s=t.subarray(n,Math.min(n+En,t.length));r+=String.fromCharCode(...s)}return globalThis.btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")},$a=e=>{if(typeof document>"u")return!1;const t=document.querySelector('meta[http-equiv="Content-Security-Policy"]');return t?(t.getAttribute("content")??"").includes(e):!1},Tt=null,kn=!1,Oa=()=>typeof window<"u"&&typeof window.trustedTypes<"u",Tn=()=>{if(Tt)return Tt;if(kn||typeof window>"u")return null;const e=window;if(!e.trustedTypes)return null;kn=!0;try{return Tt=e.trustedTypes.createPolicy(Le,{createHTML:t=>kt(t)}),Tt}catch(t){const r=t instanceof Error?t.message:String(t);return console.warn(`bQuery: Could not create Trusted Types policy "${Le}": ${r}`),null}},La=e=>{const t=Tn();return t?t.createHTML(e):kt(e)},ie=(e,t={})=>wn(kt(e,t)),Cn=e=>{const t={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","`":"&#x60;"};return e.replace(/[&<>"'`]/g,r=>t[r])},Pa=e=>kt(e,{stripAllTags:!0}),Rn=e=>Array.isArray(e)?e:[e],z=(e,t)=>{for(const r of e)t(r)},Pe=e=>{if(!e)return!1;const t=e.ownerDocument?.defaultView?.HTMLElement??globalThis.HTMLElement;return typeof t=="function"&&e instanceof t},Ct=(e,t)=>Pe(e)?t==="width"?e.clientWidth:e.clientHeight:0,Rt=(e,t,r)=>{if(!Pe(e))return 0;const n=t==="width"?e.offsetWidth:e.offsetHeight;if(!r)return n;const s=e.ownerDocument?.defaultView;if(!s||typeof s.getComputedStyle!="function")return n;const o=s.getComputedStyle(e),i=Number.parseFloat(o.getPropertyValue(t==="width"?"margin-left":"margin-top")),a=Number.parseFloat(o.getPropertyValue(t==="width"?"margin-right":"margin-bottom")),c=Number.isNaN(i)?0:i,l=Number.isNaN(a)?0:a;return n+c+l},$n=e=>ie(e),Na=(e,t)=>{e.innerHTML=ie(t)},On=e=>{const t=document.createElement("template");return t.innerHTML=ie(e),t.content.firstElementChild??document.createElement("div")},Ln=(e,t,r)=>{if(typeof t=="string"){e.insertAdjacentHTML(r,ie(t));return}const n=Rn(t);z(r==="afterbegin"||r==="afterend"?n.slice().reverse():n,s=>{e.insertAdjacentElement(r,s)})};function Se(e){return Object.prototype.toString.call(e)==="[object Object]"}function N(e){return e==="__proto__"||e==="constructor"||e==="prototype"}function Pn(e){return typeof structuredClone=="function"?structuredClone(e):JSON.parse(JSON.stringify(e))}function Ee(...e){const t={};for(const r of e)for(const[n,s]of Object.entries(r))N(n)||(Se(s)&&Se(t[n])?t[n]=Ee(t[n],s):t[n]=s);return t}function Nn(e,t){const r={};for(const n of t)n in e&&(r[n]=e[n]);return r}function In(e,t){const r={...e};for(const n of t)delete r[n];return r}function Mn(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var Ia=e=>{const t=e.tagName.toLowerCase();return t==="input"||t==="textarea"||t==="select"},Dn=e=>{const t=[],r=e.ownerDocument.defaultView?.Element??Element;for(const n of Array.from(e.elements)){if(!(n instanceof r)||!Ia(n))continue;const s=n.name;if(!(!s||n.disabled||N(s))){if(n.tagName.toLowerCase()==="input"){const o=n,i=o.type.toLowerCase();if(i==="checkbox"||i==="radio"){o.checked&&t.push([s,o.value]);continue}if(i==="file"||i==="submit"||i==="button"||i==="reset"||i==="image")continue;t.push([s,o.value]);continue}if(n.tagName.toLowerCase()==="select"){const o=n;if(o.multiple)for(const i of Array.from(o.selectedOptions))t.push([s,i.value]);else t.push([s,o.value]);continue}t.push([s,n.value])}}return t},_n=e=>{if(typeof FormData=="function")try{const t=[];for(const[r,n]of new FormData(e).entries())N(r)||typeof n!="string"||t.push([r,n]);return t.length>0?t:Dn(e)}catch{}return Dn(e)},Ne=class dn{constructor(t){this.element=t,this.delegatedHandlers=new Map}get raw(){return this.element}get node(){return this.element}addClass(...t){return this.element.classList.add(...t),this}removeClass(...t){return this.element.classList.remove(...t),this}toggleClass(t,r){return this.element.classList.toggle(t,r),this}attr(t,r){return r===void 0?this.element.getAttribute(t)??"":(this.element.setAttribute(t,r),this)}removeAttr(t){return this.element.removeAttribute(t),this}toggleAttr(t,r){const n=this.element.hasAttribute(t);return r??!n?this.element.setAttribute(t,""):this.element.removeAttribute(t),this}prop(t,r){return r===void 0?this.element[t]:(this.element[t]=r,this)}data(t,r){const n=t.replace(/[A-Z]/g,s=>`-${s.toLowerCase()}`);return r===void 0?this.element.getAttribute(`data-${n}`)??"":(this.element.setAttribute(`data-${n}`,r),this)}text(t){return t===void 0?this.element.textContent??"":(this.element.textContent=t,this)}html(t){return Na(this.element,t),this}htmlUnsafe(t){return this.element.innerHTML=t,this}css(t,r){if(typeof t=="string"){if(r!==void 0)return this.element.style.setProperty(t,r),this;const n=this.element.ownerDocument?.defaultView;return!n||typeof n.getComputedStyle!="function"?"":n.getComputedStyle(this.element).getPropertyValue(t)}for(const[n,s]of Object.entries(t))this.element.style.setProperty(n,s);return this}append(t){return this.insertContent(t,"beforeend"),this}prepend(t){return this.insertContent(t,"afterbegin"),this}before(t){return this.insertContent(t,"beforebegin"),this}after(t){return this.insertContent(t,"afterend"),this}wrap(t){const r=typeof t=="string"?document.createElement(t):t;return this.element.parentNode?.insertBefore(r,this.element),r.appendChild(this.element),this}unwrap(){const t=this.element.parentElement;return t&&t.parentNode&&(t.parentNode.insertBefore(this.element,t),t.remove()),this}replaceWith(t){const r=typeof t=="string"?On(t):t;return this.element.replaceWith(r),new dn(r)}detach(){return this.remove()}index(){const t=this.element.parentElement;return t?Array.from(t.children).indexOf(this.element):-1}contents(){return Array.from(this.element.childNodes)}offsetParent(){return Pe(this.element)?this.element.offsetParent:null}position(){if(!Pe(this.element))return{top:0,left:0};const t=this.element;return{top:t.offsetTop,left:t.offsetLeft}}innerWidth(){return Ct(this.element,"width")}innerHeight(){return Ct(this.element,"height")}outerWidth(t=!1){return Rt(this.element,"width",t)}outerHeight(t=!1){return Rt(this.element,"height",t)}scrollTo(t={behavior:"smooth"}){return this.element.scrollIntoView(t),this}remove(){return this.element.remove(),this}empty(){return this.element.innerHTML="",this}clone(t=!0){return new dn(this.element.cloneNode(t))}find(t){return Array.from(this.element.querySelectorAll(t))}findOne(t){return this.element.querySelector(t)}closest(t){return this.element.closest(t)}parent(){return this.element.parentElement}children(){return Array.from(this.element.children)}siblings(){const t=this.element.parentElement;return t?Array.from(t.children).filter(r=>r!==this.element):[]}next(){return this.element.nextElementSibling}prev(){return this.element.previousElementSibling}on(t,r){return this.element.addEventListener(t,r),this}once(t,r){return this.element.addEventListener(t,r,{once:!0}),this}off(t,r){return this.element.removeEventListener(t,r),this}trigger(t,r){return this.element.dispatchEvent(new CustomEvent(t,{detail:r,bubbles:!0,cancelable:!0})),this}delegate(t,r,n){const s=`${t}:${r}`,o=i=>{const a=i.target.closest(r);a&&this.element.contains(a)&&n(i,a)};return this.delegatedHandlers.has(s)||this.delegatedHandlers.set(s,new Map),this.delegatedHandlers.get(s).set(n,o),this.element.addEventListener(t,o),this}undelegate(t,r,n){const s=`${t}:${r}`,o=this.delegatedHandlers.get(s);if(o){const i=o.get(n);i&&(this.element.removeEventListener(t,i),o.delete(n),o.size===0&&this.delegatedHandlers.delete(s))}return this}matches(t){return this.element.matches(t)}is(t){return this.matches(t)}hasClass(t){return this.element.classList.contains(t)}show(t=""){return this.element.removeAttribute("hidden"),this.element.style.display=t,this}hide(){return this.element.style.display="none",this}toggle(t){const r=this.element.style.display==="none";return t??r?this.show():this.hide()}focus(){return this.element.focus(),this}blur(){return this.element.blur(),this}val(t){const r=this.element;return t===void 0?r.value??"":(r.value=t,this)}serialize(){const t=this.element;if(t.tagName.toLowerCase()!=="form")return{};const r=Object.create(null);for(const[n,s]of _n(t))if(Object.prototype.hasOwnProperty.call(r,n)){const o=r[n];Array.isArray(o)?o.push(s):r[n]=[o,s]}else r[n]=s;return r}serializeString(){const t=this.element;if(t.tagName.toLowerCase()!=="form")return"";const r=new URLSearchParams;for(const[n,s]of _n(t))r.append(n,s);return r.toString()}rect(){return this.element.getBoundingClientRect()}offset(){const t=this.element;return{width:t.offsetWidth,height:t.offsetHeight,top:t.offsetTop,left:t.offsetLeft}}insertContent(t,r){Ln(this.element,t,r)}},$t=class oe{constructor(t){this.elements=t,this.delegatedHandlers=new WeakMap}get length(){return this.elements.length}first(){return this.elements[0]}eq(t){const r=this.elements[t];return r?new Ne(r):void 0}firstEl(){return this.eq(0)}lastEl(){return this.eq(this.elements.length-1)}each(t){return this.elements.forEach((r,n)=>{t(new Ne(r),n)}),this}map(t){return this.elements.map(t)}filter(t){return new oe(this.elements.filter(t))}reduce(t,r){return this.elements.reduce(t,r)}toArray(){return this.elements.map(t=>new Ne(t))}addClass(...t){return z(this.elements,r=>r.classList.add(...t)),this}removeClass(...t){return z(this.elements,r=>r.classList.remove(...t)),this}toggleClass(t,r){return z(this.elements,n=>n.classList.toggle(t,r)),this}attr(t,r){return r===void 0?this.first()?.getAttribute(t)??"":(z(this.elements,n=>n.setAttribute(t,r)),this)}removeAttr(t){return z(this.elements,r=>r.removeAttribute(t)),this}toggleAttr(t,r){return z(this.elements,n=>{const s=n.hasAttribute(t);r??!s?n.setAttribute(t,""):n.removeAttribute(t)}),this}text(t){return t===void 0?this.first()?.textContent??"":(z(this.elements,r=>{r.textContent=t}),this)}html(t){if(t===void 0)return this.first()?.innerHTML??"";const r=$n(t);return z(this.elements,n=>{n.innerHTML=r}),this}htmlUnsafe(t){return z(this.elements,r=>{r.innerHTML=t}),this}append(t){return this.insertAll(t,"beforeend"),this}prepend(t){return this.insertAll(t,"afterbegin"),this}before(t){return this.insertAll(t,"beforebegin"),this}after(t){return this.insertAll(t,"afterend"),this}css(t,r){if(typeof t=="string"){if(r!==void 0)return z(this.elements,o=>{o.style.setProperty(t,r)}),this;const n=this.first();if(!n)return"";const s=n.ownerDocument?.defaultView;return!s||typeof s.getComputedStyle!="function"?"":s.getComputedStyle(n).getPropertyValue(t)}return z(this.elements,n=>{for(const[s,o]of Object.entries(t))n.style.setProperty(s,o)}),this}wrap(t){return this.elements.forEach((r,n)=>{const s=typeof t=="string"?document.createElement(t):n===0?t:t.cloneNode(!0);r.parentNode?.insertBefore(s,r),s.appendChild(r)}),this}unwrap(){const t=new Set;for(const r of this.elements)r.parentElement&&t.add(r.parentElement);return t.forEach(r=>{const n=r.parentNode;if(n){for(;r.firstChild;)n.insertBefore(r.firstChild,r);r.remove()}}),this}replaceWith(t){const r=[];return this.elements.forEach((n,s)=>{const o=typeof t=="string"?On(t):s===0?t:t.cloneNode(!0);n.replaceWith(o),r.push(o)}),new oe(r)}detach(){return this.remove()}index(){const t=this.first();return t?.parentElement?Array.from(t.parentElement.children).indexOf(t):-1}contents(){return Array.from(this.first()?.childNodes??[])}offsetParent(){const t=this.first();return Pe(t)?t.offsetParent:null}position(){const t=this.first();return Pe(t)?{top:t.offsetTop,left:t.offsetLeft}:{top:0,left:0}}innerWidth(){return Ct(this.first(),"width")}innerHeight(){return Ct(this.first(),"height")}outerWidth(t=!1){return Rt(this.first(),"width",t)}outerHeight(t=!1){return Rt(this.first(),"height",t)}show(t=""){return z(this.elements,r=>{r.removeAttribute("hidden"),r.style.display=t}),this}hide(){return z(this.elements,t=>{t.style.display="none"}),this}on(t,r){return z(this.elements,n=>n.addEventListener(t,r)),this}once(t,r){return z(this.elements,n=>n.addEventListener(t,r,{once:!0})),this}off(t,r){return z(this.elements,n=>n.removeEventListener(t,r)),this}trigger(t,r){return z(this.elements,n=>{n.dispatchEvent(new CustomEvent(t,{detail:r,bubbles:!0,cancelable:!0}))}),this}delegate(t,r,n){const s=`${t}:${r}`;return z(this.elements,o=>{const i=c=>{const l=c.target.closest(r);l&&o.contains(l)&&n(c,l)};this.delegatedHandlers.has(o)||this.delegatedHandlers.set(o,new Map);const a=this.delegatedHandlers.get(o);a.has(s)||a.set(s,new Map),a.get(s).set(n,i),o.addEventListener(t,i)}),this}undelegate(t,r,n){const s=`${t}:${r}`;return z(this.elements,o=>{const i=this.delegatedHandlers.get(o);if(!i)return;const a=i.get(s);if(!a)return;const c=a.get(n);c&&(o.removeEventListener(t,c),a.delete(n),a.size===0&&i.delete(s),i.size===0&&this.delegatedHandlers.delete(o))}),this}find(t){const r=new Set,n=[];for(const s of this.elements){const o=s.querySelectorAll(t);for(let i=0;i<o.length;i++)r.has(o[i])||(r.add(o[i]),n.push(o[i]))}return new oe(n)}closest(t){const r=new Set,n=[];for(const s of this.elements){const o=s.closest(t);o&&!r.has(o)&&(r.add(o),n.push(o))}return new oe(n)}parent(){const t=new Set,r=[];for(const n of this.elements){const s=n.parentElement;s&&!t.has(s)&&(t.add(s),r.push(s))}return new oe(r)}children(){const t=new Set,r=[];for(const n of this.elements)for(const s of Array.from(n.children))t.has(s)||(t.add(s),r.push(s));return new oe(r)}siblings(){const t=new Set(this.elements),r=new Set,n=[];for(const s of this.elements){const o=s.parentElement;if(o)for(const i of Array.from(o.children))!t.has(i)&&!r.has(i)&&(r.add(i),n.push(i))}return new oe(n)}next(){const t=new Set,r=[];for(const n of this.elements){const s=n.nextElementSibling;s&&!t.has(s)&&(t.add(s),r.push(s))}return new oe(r)}prev(){const t=new Set,r=[];for(const n of this.elements){const s=n.previousElementSibling;s&&!t.has(s)&&(t.add(s),r.push(s))}return new oe(r)}remove(){return z(this.elements,t=>t.remove()),this}empty(){return z(this.elements,t=>{t.innerHTML=""}),this}insertAll(t,r){if(typeof t=="string"){const s=$n(t);z(this.elements,o=>{o.insertAdjacentHTML(r,s)});return}const n=Rn(t);this.elements.forEach((s,o)=>{Ln(s,o===0?n:n.map(i=>i.cloneNode(!0)),r)})}},Ma=e=>{if(typeof e!="string")return new Ne(e);const t=document.querySelector(e);if(!t)throw new Error(`bQuery: element not found for selector "${e}"`);return new Ne(t)},Da=e=>Array.isArray(e)?new $t(e):e instanceof NodeList?new $t(Array.from(e)):new $t(Array.from(document.querySelectorAll(e)));function qn(e){return e==null?[]:Array.isArray(e)?e:[e]}function xn(e){return Array.from(new Set(e))}function zn(e,t){if(t<=0)return[];const r=[];for(let n=0;n<e.length;n+=t)r.push(e.slice(n,n+t));return r}function jn(e){return e.filter(Boolean)}function Un(e){const t=[];for(const r of e)Array.isArray(r)?t.push(...r):t.push(r);return t}function Ot(e,t){let r;return Object.assign((...n)=>{r!==void 0&&clearTimeout(r),r=setTimeout(()=>{r=void 0,e(...n)},t)},{cancel:()=>{r!==void 0&&(clearTimeout(r),r=void 0)}})}function hr(e,t){let r=0;return Object.assign((...n)=>{const s=Date.now();s-r>=t&&(r=s,e(...n))},{cancel:()=>{r=0}})}function Hn(e){let t=!1,r;return(...n)=>(t||(r=e(...n),t=!0),r)}function Wn(){}function Fn(e="bQuery"){return`${e}_${Math.random().toString(36).slice(2,9)}`}function Bn(e){return new Promise(t=>setTimeout(t,e))}function Qn(e,t){try{return JSON.parse(e)}catch{return t}}function Vn(e){return e==null?!0:typeof e=="string"?e.trim().length===0:Array.isArray(e)?e.length===0:typeof e=="object"?Object.keys(e).length===0:!1}function Kn(e,t){return Math.floor(Math.random()*(t-e+1))+e}function Yn(e,t,r){return Math.min(Math.max(e,t),r)}function Jn(e,t,r,n=!0){return n?e>=t&&e<=r:e>t&&e<r}function Gn(e,t=0){const r=typeof e=="number"?e:Number(e);return Number.isNaN(r)?t:r}function Xn(e){return e&&e.charAt(0).toUpperCase()+e.slice(1)}function Zn(e){return e.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_]+/g,"-").toLowerCase()}function es(e){return e.replace(/[-_\s]+(.)?/g,(t,r)=>r?r.toUpperCase():"").replace(/^[A-Z]/,t=>t.toLowerCase())}function ts(e,t,r="…"){if(t<=0)return"";if(e.length<=t)return e;const n=Math.max(0,t-r.length);return`${e.slice(0,n)}${r}`}function rs(e){return e.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\w\s-]/g,"").trim().replace(/[\s_-]+/g,"-").toLowerCase()}function ns(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ss(e){return typeof Element<"u"&&e instanceof Element}function os(e){return!!(e&&typeof e=="object"&&"elements"in e)}function is(e){return typeof e=="function"}function as(e){return typeof e=="string"}function cs(e){return typeof e=="number"&&!Number.isNaN(e)}function ls(e){return typeof e=="boolean"}function us(e){return Array.isArray(e)}function fs(e){return e instanceof Date}function Ie(e){return!!(e&&(e instanceof Promise||typeof e=="object"&&"then"in e&&typeof e.then=="function"))}function ds(e){return typeof e=="object"&&e!==null}var _a={clone:Pn,merge:Ee,pick:Nn,omit:In,hasOwn:Mn,debounce:Ot,throttle:hr,once:Hn,noop:Wn,uid:Fn,isElement:ss,isCollection:os,isEmpty:Vn,isPlainObject:Se,isFunction:is,isString:as,isNumber:cs,isBoolean:ls,isArray:us,isDate:fs,isPromise:Ie,isObject:ds,parseJson:Qn,sleep:Bn,randomInt:Kn,clamp:Yn,inRange:Jn,toNumber:Gn,capitalize:Xn,toKebabCase:Zn,toCamelCase:es,truncate:ts,slugify:rs,escapeRegExp:ns,ensureArray:qn,unique:xn,chunk:zn,compact:jn,flatten:Un},hs={fetch:{headers:{},parseAs:"json"},cookies:{path:"/",sameSite:"Lax",secure:!1},announcer:{politeness:"polite",atomic:!0,delay:16,clearDelay:1e3},pageMeta:{},transitions:{skipOnReducedMotion:!1,classes:[],types:[]},components:{prefix:"bq"}},Be=e=>{if(typeof Headers<"u"&&e instanceof Headers)return new Headers(e);if(Array.isArray(e))return e.map(t=>Be(t));if(Se(e)){const t={};for(const[r,n]of Object.entries(e))t[r]=Be(n);return t}return e},mr=Be(hs),qa=e=>(mr=Be(Ee(hs,mr,e)),ae()),ae=()=>Be(mr),Me=[],Qe=0,pr=new Set,Lt=new WeakMap,vr=(e,t)=>{Me.push(e);try{return t()}finally{Me.pop()}},ms=()=>Me[Me.length-1],yr=e=>{Me.push(void 0);try{return e()}finally{Me.pop()}},ps=e=>{if(Qe>0){pr.add(e);return}e()},xa=()=>{for(const e of Array.from(pr)){pr.delete(e);try{e()}catch(t){console.error("bQuery reactive: Error in observer during batch flush",t)}}},za=()=>{Qe+=1},ja=()=>{Qe<=0||(Qe-=1,Qe===0&&xa())},vs=(e,t)=>{let r=Lt.get(e);r||(r=new Set,Lt.set(e,r)),r.add(t)},Ua=(e,t)=>{const r=Lt.get(e);r&&r.delete(t)},Ve=e=>{const t=Lt.get(e);if(t){for(const r of t)r.unsubscribe(e);t.clear()}},Ke=[],Pt=e=>typeof e=="object"&&e!==null&&"_addDisposer"in e,Ha=e=>(typeof e=="object"||typeof e=="function")&&e!==null&&typeof e.then=="function",Wa=e=>{const t=typeof e.constructor=="function"?e.constructor.name:void 0;return typeof e=="function"&&(Symbol.toStringTag in e&&e[Symbol.toStringTag]==="AsyncFunction"||t==="AsyncFunction")},Ye=()=>{for(let e=Ke.length-1;e>=0;e--)if(Ke[e].active)return Ke[e]},Fa=class{constructor(){this.disposers=[],this._active=!0}get active(){return this._active}_addDisposer(e){this._active&&this.disposers.push(e)}run(e){if(!this._active)throw new Error("bQuery reactive: Cannot run in a stopped effectScope");if(Wa(e))throw new Error("bQuery reactive: effectScope.run() only supports synchronous callbacks");Ke.push(this);try{const t=e();if(Ha(t))throw this.stop(),new Error("bQuery reactive: effectScope.run() only supports synchronous callbacks");return t}finally{Ke.pop()}}stop(){if(this._active){this._active=!1;for(let e=this.disposers.length-1;e>=0;e--)try{this.disposers[e]()}catch(t){console.error("bQuery reactive: Error in scope cleanup",t)}this.disposers.length=0}}},Ba=()=>{const e=new Fa,t=Ye();return Pt(t)&&t._addDisposer(()=>e.stop()),e},ys=()=>Ye(),gs=e=>{const t=Ye();if(!t||!t.active||!Pt(t))throw new Error("bQuery reactive: onScopeDispose() must be called inside an active effectScope");t._addDisposer(e)},Je=class{constructor(e){this.compute=e,this.hasCachedValue=!1,this.dirty=!0,this.disposed=!1,this.subscribers=new Set,this.markDirty=()=>{if(this.disposed)return;this.dirty=!0;const t=Array.from(this.subscribers);for(const r of t)ps(r)}}get value(){if(this.disposed)return this.hasCachedValue||(this.cachedValue=yr(()=>this.compute()),this.hasCachedValue=!0),this.cachedValue;const e=ms();return e&&(this.subscribers.add(e),vs(e,this)),this.dirty&&(this.dirty=!1,Ve(this.markDirty),this.cachedValue=vr(this.markDirty,this.compute),this.hasCachedValue=!0),this.cachedValue}peek(){return this.disposed?(this.hasCachedValue||(this.cachedValue=yr(()=>this.compute()),this.hasCachedValue=!0),this.cachedValue):(this.dirty&&(this.dirty=!1,Ve(this.markDirty),this.cachedValue=vr(this.markDirty,this.compute),this.hasCachedValue=!0),this.cachedValue)}unsubscribe(e){this.subscribers.delete(e)}dispose(){this.disposed=!0,this.dirty&&(this.hasCachedValue=!1),this.dirty=!1,Ve(this.markDirty),this.subscribers.clear()}},D=e=>{const t=new Je(e),r=Ye();return Pt(r)&&r._addDisposer(()=>t.dispose()),t},j=e=>{let t,r=!1;const n=Ye(),s=()=>{if(t){try{t()}catch(c){console.error("bQuery reactive: Error in effect cleanup",c)}t=void 0}},o=()=>{s(),Ve(a)},i=()=>{r||(r=!0,o())};Pt(n)&&n._addDisposer(i);const a=()=>{if(!r){s(),Ve(a);try{t=vr(a,e)}catch(c){console.error("bQuery reactive: Error in effect",c)}r&&o()}};return a(),i},Ge=class{constructor(e){this._value=e,this.subscribers=new Set}get value(){const e=ms();return e&&(this.subscribers.add(e),vs(e,this)),this._value}set value(e){if(Object.is(this._value,e))return;this._value=e;const t=Array.from(this.subscribers);for(const r of t)ps(r)}peek(){return this._value}update(e){this.value=e(this._value)}dispose(){for(const e of this.subscribers)Ua(e,this);this.subscribers.clear()}unsubscribe(e){this.subscribers.delete(e)}},L=e=>new Ge(e),Ae=e=>yr(e),Qa=e=>{if(e instanceof Error)return e;if(typeof e=="string")return new Error(e);try{return new Error(JSON.stringify(e))}catch{return new Error(String(e))}},Va=e=>typeof e=="function"?e():e.value,bs=(...e)=>{const t=new Headers;for(const r of e)r&&new Headers(r).forEach((n,s)=>{t.set(s,n)});return t},Ka=e=>typeof e=="string"||e instanceof Blob||e instanceof FormData||e instanceof URLSearchParams||typeof ArrayBuffer<"u"&&e instanceof ArrayBuffer||typeof ReadableStream<"u"&&e instanceof ReadableStream?!0:typeof e=="object"&&e!==null&&ArrayBuffer.isView(e),Ya=(e,t)=>e==null||Ka(e)?e:(t.has("content-type")||t.set("content-type","application/json"),JSON.stringify(e)),Ja=e=>typeof e=="function"?e():e,Ga=(e,t)=>{for(const[r,n]of Object.entries(t))if(n!=null){if(Array.isArray(n)){for(const s of n)s!=null&&e.searchParams.append(r,String(s));continue}e.searchParams.set(r,String(n))}},Xa=(e,t)=>{const r=typeof window<"u"&&/^https?:/i.test(window.location.href)?window.location.href:"http://localhost",n=t?new URL(t,r).toString():r;return e instanceof URL?new URL(e.toString(),n):new URL(e,n)},Za=async(e,t)=>{if(t==="response")return e;if(t==="text")return await e.text();if(t==="blob")return await e.blob();if(t==="arrayBuffer")return await e.arrayBuffer();if(t==="formData")return await e.formData();const r=await e.text();if(r)try{return JSON.parse(r)}catch(n){const s=e.url?` for ${e.url}`:"";throw new Error(`Failed to parse JSON response${s} (status ${e.status}): ${n instanceof Error?n.message:String(n)}`)}},gr=e=>{const t=e?.trim();return t?t.toUpperCase():void 0},ec=(e,t,r)=>{const n=t instanceof Request?gr(t.method):void 0;return e??n??(r?"POST":void 0)},tc=(e,t,r)=>e||(t instanceof Request?void 0:r),rc=e=>{const t=gr(e.method);let r;if(t!=="GET"&&t!=="HEAD"&&!e.bodyUsed)try{r=e.clone().body??void 0}catch{r=void 0}return{method:t,headers:e.headers,body:r,cache:e.cache,credentials:e.credentials,integrity:e.integrity,keepalive:e.keepalive,mode:e.mode,redirect:e.redirect,referrer:e.referrer,referrerPolicy:e.referrerPolicy,signal:e.signal}},ws=(e,t={})=>{const r=t.immediate??!0,n=L(t.defaultValue),s=L(null),o=L("idle"),i=D(()=>o.value==="pending");let a=0,c=!1,l=()=>{};const u=()=>{a+=1,n.value=t.defaultValue,s.value=null,o.value="idle"},h=()=>{c||(c=!0,a+=1,l())},d=async()=>{if(c)return n.peek();const v=++a;o.value="pending",s.value=null;try{const f=await e(),p=t.transform?t.transform(f):f;return c||v!==a?n.peek():(n.value=p,o.value="success",t.onSuccess?.(p),p)}catch(f){const p=Qa(f);return c||v!==a||(s.value=p,o.value="error",t.onError?.(p)),n.peek()}};if(t.watch?.length){let v=!1;l=j(()=>{for(const f of t.watch??[])Va(f);if(!v){v=!0,r&&Ae(()=>d());return}Ae(()=>d())})}else r&&d();return{data:n,error:s,status:o,pending:i,execute:d,refresh:d,abort:()=>{},clear:u,dispose:h}},nc=e=>e>=200&&e<300,Ss=(e,t)=>e instanceof DOMException&&e.name===t,Nt=e=>Ss(e,"TimeoutError"),Es=e=>Ss(e,"AbortError"),sc=e=>{if(Es(e)||Nt(e)||e.code==="ABORT"||e.code==="TIMEOUT")return!1;const t=e.status;return t===void 0||t>=500},oc=e=>{if(e!=null)return typeof e=="number"?{count:e}:e},ic=(e,t)=>e==null?Math.min(1e3*2**t,3e4):typeof e=="number"?e:e(t),ac=(e,t)=>new Promise((r,n)=>{if(t?.aborted){n(t.reason??new DOMException("The operation was aborted.","AbortError"));return}let s=!1,o;const i=()=>{s||(s=!0,clearTimeout(o),t?.removeEventListener("abort",i),n(t?.reason??new DOMException("The operation was aborted.","AbortError")))};o=setTimeout(()=>{s||(s=!0,t?.removeEventListener("abort",i),r())},e),t?.addEventListener("abort",i,{once:!0})}),re=(e,t={})=>{const r=ae().fetch,n=t.parseAs??r?.parseAs??"json",s=t.fetcher??fetch,o=t.validateStatus??nc;let i=null;const a=(l,u)=>{const h=u||Nt(l)||Nt(i?.signal.reason);return Object.assign(new Error(h?`Request timeout of ${t.timeout}ms exceeded`:"Request aborted"),{code:h?"TIMEOUT":"ABORT"})},c=ws(async()=>{const l=Ja(e),u=typeof l=="string"||l instanceof URL?Xa(l,t.baseUrl??r?.baseUrl):l instanceof Request&&t.query?new URL(l.url):null;u&&t.query&&Ga(u,t.query);const h=bs(r?.headers,l instanceof Request?l.headers:void 0,t.headers),d=t.body!=null,v=gr(t.method),f=ec(v,l,d),p=f==="GET"||f==="HEAD"?f:null;if(d&&p)throw new Error(`Cannot send a request body with ${p} requests`);const y=tc(v,l,f),b=oc(t.retry),g=(b?.count??0)+1,w=new AbortController;i=w;let S,k=!1,A;t.signal&&(t.signal.aborted?w.abort(t.signal.reason):(A=()=>w.abort(t.signal?.reason),t.signal.addEventListener("abort",A,{once:!0}))),t.timeout&&t.timeout>0&&(S=setTimeout(()=>{k=!0,w.abort(new DOMException("Request timeout","TimeoutError"))},t.timeout));const E={...t,method:y,headers:h};delete E.baseUrl,delete E.query,delete E.parseAs,delete E.fetcher,delete E.defaultValue,delete E.immediate,delete E.watch,delete E.transform,delete E.onSuccess,delete E.onError,delete E.timeout,delete E.retry,delete E.validateStatus;let T=u??l;l instanceof Request&&u&&u.toString()!==l.url&&(T=new Request(u.toString(),rc(l)));const P=()=>{const $=new Headers(h);return{...E,headers:$,body:Ya(t.body,$),signal:w.signal}};if(g>1&&typeof ReadableStream<"u"&&t.body instanceof ReadableStream)throw new Error("Cannot retry requests with ReadableStream bodies");if(g>1&&typeof Request<"u"&&T instanceof Request&&T.body!==null)throw new Error("Cannot retry requests with non-replayable Request bodies");let R;try{for(let $=0;$<g;$++)try{const C=await s(T,P());if(!o(C.status))throw Object.assign(new Error(`Request failed with status ${C.status}`),{response:C,status:C.status,statusText:C.statusText});return await Za(C,n)}catch(C){const O=C instanceof Error?C:new Error(String(C));if(w.signal.aborted||Es(O)||Nt(O))throw a(w.signal.aborted?w.signal.reason:O,k);if(R=O,!(b&&(b.retryOn??sc)(O,$))||$>=g-1)throw O;await ac(ic(b.delay,$),w.signal)}throw R}finally{S!==void 0&&clearTimeout(S),t.signal&&A&&t.signal.removeEventListener("abort",A),i===w&&(i=null)}},t);return c.abort=()=>{i&&i.abort(new DOMException("Request aborted","AbortError"))},c};function cc(e={}){return(t,r={})=>{const n=e,s=Ee({},n.query??{},r.query??{});return re(t,{...n,...r,headers:bs(n.headers,r.headers),query:Object.keys(s).length>0?s:void 0})}}var ke=e=>{za();try{e()}finally{ja()}},ye=class extends Error{constructor(e,t,r,n){super(e),this.name="HttpError",this.config=t,this.code=r,this.response=n}};function As(){const e=[];let t=0;return{use(r,n){const s=t++;return e.push({id:s,fulfilled:r,rejected:n}),s},eject(r){const n=e.findIndex(s=>s?.id===r);n!==-1&&(e[n]=null)},clear(){e.length=0},forEach(r){for(const n of e)n&&r(n)}}}var lc=e=>e>=200&&e<300,uc=e=>{if(e.code==="PARSE")return!1;if(e.code==="TIMEOUT"||e.code==="NETWORK")return!0;const t=e.response?.status;return t!==void 0&&t>=500},fc=e=>{if(e!=null)return typeof e=="number"?{count:e}:e},dc=(e,t)=>e==null?Math.min(1e3*2**t,3e4):typeof e=="number"?e:e(t),hc=(e,t)=>new Promise((r,n)=>{if(t?.aborted){n(t.reason??new DOMException("The operation was aborted.","AbortError"));return}let s;const o=()=>{clearTimeout(s),t?.removeEventListener("abort",o),n(t?.reason??new DOMException("The operation was aborted.","AbortError"))};s=setTimeout(()=>{t?.removeEventListener("abort",o),r()},e),t&&t.addEventListener("abort",o,{once:!0})}),ks=(...e)=>{const t=new Headers;for(const r of e)r&&new Headers(r).forEach((n,s)=>{t.set(s,n)});return t},mc=e=>typeof e=="string"||e instanceof Blob||e instanceof FormData||e instanceof URLSearchParams||typeof ArrayBuffer<"u"&&e instanceof ArrayBuffer||typeof ReadableStream<"u"&&e instanceof ReadableStream?!0:typeof e=="object"&&e!==null&&ArrayBuffer.isView(e),pc=(e,t)=>e==null||mc(e)?e:(t.has("content-type")||t.set("content-type","application/json"),JSON.stringify(e)),vc=(e,t)=>{for(const[r,n]of Object.entries(t))if(n!=null){if(Array.isArray(n)){for(const s of n)s!=null&&e.searchParams.append(r,String(s));continue}e.searchParams.set(r,String(n))}},yc=(e,t)=>{const r=typeof window<"u"&&/^https?:/i.test(window.location.href)?window.location.href:"http://localhost",n=t?new URL(t,r).toString():r;return new URL(e,n)},gc=async(e,t,r)=>{if(t==="response")return e;if(t==="text")return await e.text();if(t==="blob")return await e.blob();if(t==="arrayBuffer")return await e.arrayBuffer();if(t==="formData")return await e.formData();const n=await e.text();if(n)try{return JSON.parse(n)}catch(s){throw new ye(`Failed to parse JSON response${e.url?` for ${e.url}`:""} (status ${e.status}): ${s instanceof Error?s.message:String(s)}`,r,"PARSE",{data:n,status:e.status,statusText:e.statusText,headers:e.headers,config:r})}},bc=(e,t)=>{const r=e.body;if(!r)return e;const n=parseInt(e.headers.get("content-length")??"0",10)||0;let s=0;const o=r.getReader(),i=new ReadableStream({async pull(a){const{done:c,value:l}=await o.read();if(c){a.close();return}s+=l.byteLength,t({loaded:s,total:n,percent:n>0?Math.round(s/n*100):void 0}),a.enqueue(l)},cancel(a){o.cancel(a)}});return new Response(i,{status:e.status,statusText:e.statusText,headers:e.headers})},wc=async e=>{const t=ae().fetch,r=e.parseAs??t?.parseAs??"json",n=e.fetcher??fetch,s=e.validateStatus??lc,o=yc(e.url??"/",e.baseUrl??t?.baseUrl);e.query&&vc(o,e.query);const i=ks(t?.headers,e.headers),a=pc(e.body,i),c={};e.method&&(c.method=e.method.toUpperCase()),c.headers=i,a!=null&&(c.body=a),e.cache&&(c.cache=e.cache),e.credentials&&(c.credentials=e.credentials),e.integrity&&(c.integrity=e.integrity),e.keepalive!==void 0&&(c.keepalive=e.keepalive),e.mode&&(c.mode=e.mode),e.redirect&&(c.redirect=e.redirect),e.referrer&&(c.referrer=e.referrer),e.referrerPolicy&&(c.referrerPolicy=e.referrerPolicy);let l,u=e.signal,h;if(e.timeout&&e.timeout>0){const d=new AbortController;e.signal&&(h=()=>d.abort(e.signal?.reason),e.signal.addEventListener("abort",h,{once:!0})),l=setTimeout(()=>{d.abort(new DOMException("Request timeout","TimeoutError"))},e.timeout),u=d.signal}u&&(c.signal=u);try{let d=await n(o.toString(),c);if(e.onDownloadProgress&&(d=bc(d,e.onDownloadProgress)),!s(d.status))throw new ye(`Request failed with status ${d.status}`,e,"ERR_BAD_RESPONSE",{data:void 0,status:d.status,statusText:d.statusText,headers:d.headers,config:e});return{data:await gc(d,r,e),status:d.status,statusText:d.statusText,headers:d.headers,config:e}}catch(d){if(d instanceof ye)throw d;if(d instanceof DOMException&&(d.name==="AbortError"||d.name==="TimeoutError")){const v=d.name==="TimeoutError"||d.message==="Request timeout";throw new ye(v?`Request timeout of ${e.timeout}ms exceeded`:"Request aborted",e,v?"TIMEOUT":"ABORT")}throw new ye(d instanceof Error?d.message:String(d),e,"NETWORK")}finally{l!==void 0&&clearTimeout(l),e.signal&&h&&e.signal.removeEventListener("abort",h)}};function br(e={}){const t=As(),r=As(),n=i=>{const a=Ee({},e.query??{},i.query??{});return{...e,...i,headers:ks(e.headers,i.headers),query:Object.keys(a).length>0?a:void 0}},s=async i=>{let a=i;const c=[];t.forEach(d=>c.push(d));for(const{fulfilled:d,rejected:v}of c)try{d&&(a=await d(a))}catch(f){if(v){const p=await v(f);if(Se(p))a=p;else throw f}else throw f}const l=fc(a.retry);let u;const h=(l?.count??0)+1;for(let d=0;d<h;d++)try{let v=await wc(a);const f=[];r.forEach(p=>f.push(p));for(const{fulfilled:p,rejected:y}of f)try{p&&(v=await p(v))}catch(b){if(y){const g=await y(b);if(g&&typeof g=="object"&&"data"in g)v=g;else throw b}else throw b}return v}catch(v){const f=v instanceof ye?v:new ye(v instanceof Error?v.message:String(v),a,"NETWORK");if(u=f,!(l&&(l.retryOn??uc)(f,d))||d>=h-1){const y=[];r.forEach(g=>y.push(g));let b=f;for(const{rejected:g}of y)if(g)try{const w=await g(b);if(w&&typeof w=="object"&&"data"in w)return w;w!=null&&(b=w)}catch(w){w!=null&&(b=w)}throw b instanceof Error||(b=f),b}const p=l?dc(l.delay,d):0;l?.onRetry?.(f,d+1),await hc(p,a.signal)}throw u},o=i=>s(n(i));return{request:o,get:(i,a={})=>o({...a,url:i,method:"GET"}),post:(i,a,c={})=>o({...c,url:i,method:"POST",body:a}),put:(i,a,c={})=>o({...c,url:i,method:"PUT",body:a}),patch:(i,a,c={})=>o({...c,url:i,method:"PATCH",body:a}),delete:(i,a={})=>o({...a,url:i,method:"DELETE"}),head:(i,a={})=>o({...a,url:i,method:"HEAD"}),options:(i,a={})=>o({...a,url:i,method:"OPTIONS"}),interceptors:{request:t,response:r},defaults:e}}var Sc=br();function Ec(e={}){const{concurrency:t=6}=e;if(!Number.isInteger(t)||t<1)throw new Error("Request queue concurrency must be a positive integer");const r=[];let n=0;const s=()=>{for(;n<t&&r.length>0;){const o=r.shift();n++,Promise.resolve().then(o.execute).then(o.resolve,o.reject).finally(()=>{n--,s()})}};return{add(o){return new Promise((i,a)=>{r.push({execute:o,resolve:i,reject:a}),s()})},get pending(){return n},get size(){return r.length},clear(){const o=r.splice(0);for(const i of o)i.reject(new Error("Request queue cleared"))}}}var Ac=(e,t)=>{const r=D(e);return{get value(){return r.value},set value(n){t(n)},peek(){return r.peek()}}},kc=(e,t={})=>{const{initialPage:r=1,...n}=t,s=L(r),o=re(()=>e(s.value),{...n,watch:n.watch});return{...o,page:s,next:async()=>(s.value=s.peek()+1,o.execute()),prev:async()=>{const l=s.peek();return l>1&&(s.value=l-1),o.execute()},goTo:async l=>(s.value=Math.max(1,l),o.execute())}},Tc=(e,t)=>{const{getNextCursor:r,transform:n,initialCursor:s,immediate:o=!0,onSuccess:i,onError:a,...c}=t,l=L([]),u=L(t.defaultValue),h=L(null),d=L("idle"),v=D(()=>d.value==="pending"),f=L(s),p=D(()=>l.value.length===0||f.value!==void 0);let y=!1,b=0;const g=E=>n?n(E):E,w=async()=>{if(y)return u.peek();const E=++b;d.value="pending",h.value=null;try{const T=re(e(f.peek()),{...c,immediate:!1,watch:void 0}),P=await T.execute(),R=T.error.peek();if(T.dispose(),y||E!==b)return u.peek();if(R)return h.value=R,d.value="error",a?.(R),u.peek();if(P!==void 0){const $=P,C=[...l.peek(),$];l.value=C,f.value=r($,C);const O=g(C);return u.value=O,d.value="success",i?.(O),O}return d.value="success",u.peek()}catch(T){if(y||E!==b)return u.peek();const P=T instanceof Error?T:new Error(String(T));return h.value=P,d.value="error",a?.(P),u.peek()}},S=async()=>(l.value=[],f.value=s,u.value=t.defaultValue,h.value=null,d.value="idle",b+=1,w()),k=()=>{b+=1,l.value=[],f.value=s,u.value=t.defaultValue,h.value=null,d.value="idle"},A=()=>{y||(y=!0,b+=1)};return o&&w(),{data:u,pages:l,error:h,status:d,pending:v,hasMore:p,fetchNextPage:w,refresh:S,clear:k,dispose:A}},Cc=(e,t)=>{let r=!1,n=null;try{if(n=globalThis.localStorage,n){const i=`__bquery_test_${Math.random().toString(36).slice(2,9)}__`,a="__test__";try{n.setItem(i,a),n.getItem(i),r=!0}finally{try{n.removeItem(i)}catch{}}}}catch{r=!1}let s=t;if(r&&n)try{const i=n.getItem(e);i!==null&&(s=JSON.parse(i))}catch{}const o=L(s);return r&&n&&j(()=>{try{n.setItem(e,JSON.stringify(o.value))}catch{}}),o},Rc=(e,t)=>{const{interval:r,enabled:n=!0,pauseOnHidden:s=!0,pauseOnOffline:o=!0,immediate:i=!0,...a}=t;if(!Number.isFinite(r)||r<1)throw new Error("Polling interval must be a finite number of at least 1");const c=L(!1),l=L(!1),u=L(!1),h=typeof n=="function"?n:()=>n,d=D(()=>h()&&!c.value&&!(s&&l.value)&&!(o&&u.value)),v=re(e,{...a,immediate:i&&h()});let f,p=[];const y=()=>{b(),f=setInterval(()=>{v.execute()},r)},b=()=>{f!==void 0&&(clearInterval(f),f=void 0)},g=j(()=>{const k=d.value;Ae(()=>{k?y():b()})});if(s&&typeof document<"u"){l.value=document.hidden;const k=()=>{l.value=document.hidden};document.addEventListener("visibilitychange",k),p.push(()=>document.removeEventListener("visibilitychange",k))}if(o&&typeof window<"u"){const k=()=>{u.value=!1},A=()=>{u.value=!0};window.addEventListener("online",k),window.addEventListener("offline",A),p.push(()=>{window.removeEventListener("online",k),window.removeEventListener("offline",A)}),u.value=typeof navigator<"u"&&navigator.onLine!==void 0?!navigator.onLine:!1}const w=v.dispose;return{...v,pause:()=>{c.value=!0},resume:()=>{c.value=!1},isActive:d,dispose:()=>{b(),g();for(const k of p)k();p=[],w()}}},Ts=Symbol("bquery.readonlySignal"),Cs=e=>typeof e=="object"&&e!==null&&Object.prototype.hasOwnProperty.call(e,Ts),_=e=>Object.defineProperties({},{value:{get(){return e.value},enumerable:!0},peek:{value(){return e.peek()},enumerable:!0},[Ts]:{value:!0,enumerable:!1,configurable:!1,writable:!1}}),$c=(e,t={})=>{const{optimistic:r=!1,onMutationSuccess:n,onMutationError:s,...o}=t,i=re(e,{...o}),a=L(!1),c=D(()=>a.value);let l=!1;const u=()=>{const y=typeof e=="function"?e():e;return y instanceof URL?y.toString():y},h=()=>{const{defaultValue:y,transform:b,onSuccess:g,onError:w,...S}=o;return S},d=async(y,b,g,w)=>{if(l)return i.data.peek();const S=i.data.peek();r&&w!==void 0&&(i.data.value=w),a.value=!0,i.error.value=null;try{const k=re(u(),{...h(),method:b,body:g??void 0,immediate:!1,watch:void 0}),A=await k.execute(),E=k.error.peek();return k.dispose(),l?i.data.peek():E?(r&&w!==void 0&&(i.data.value=S),i.error.value=E,i.status.value="error",a.value=!1,s?.(E,y),i.data.peek()):(b!=="DELETE"&&A!==void 0&&(i.data.value=A),a.value=!1,i.status.value="success",n?.(A,y),A)}catch(k){if(l)return i.data.peek();r&&w!==void 0&&(i.data.value=S);const A=k instanceof Error?k:new Error(String(k));return i.error.value=A,i.status.value="error",a.value=!1,s?.(A,y),i.data.peek()}},v={fetch:()=>i.execute(),create:y=>d("create","POST",y),update:y=>{const b=i.data.peek();return d("update","PUT",y,r&&b!==void 0?{...b,...y}:void 0)},patch:y=>{const b=i.data.peek();return d("patch","PATCH",y,r&&b!==void 0?{...b,...y}:void 0)},remove:async()=>{await d("remove","DELETE"),!l&&i.error.peek()==null&&(i.data.value=void 0)}},f=i.dispose,p=()=>{l||(l=!0,f())};return{data:i.data,error:i.error,status:i.status,pending:i.pending,isMutating:c,actions:v,refresh:i.execute,clear:i.clear,dispose:p}},Oc=(e,t={})=>{const{method:r="POST",...n}=t,s=L(void 0),o=L(null),i=L("idle"),a=D(()=>i.value==="pending");return{data:s,error:o,status:i,pending:a,submit:async u=>{i.value="pending",o.value=null;try{const h=re(e,{...n,method:r,body:u,immediate:!1,watch:void 0}),d=await h.execute(),v=h.error.peek();if(h.dispose(),v){o.value=v,i.value="error";return}return s.value=d,i.value="success",d}catch(h){o.value=h instanceof Error?h:new Error(String(h)),i.value="error";return}},clear:()=>{s.value=void 0,o.value=null,i.value="idle"}}},Lc=(e,t={})=>{const r=br({...t});let n=e;for(;n.endsWith("/");)n=n.slice(0,-1);return{list:s=>r.get(n,s),get:(s,o)=>r.get(`${n}/${encodeURIComponent(String(s))}`,o),create:(s,o)=>r.post(n,s,o),update:(s,o,i)=>r.put(`${n}/${encodeURIComponent(String(s))}`,o,i),patch:(s,o,i)=>r.patch(`${n}/${encodeURIComponent(String(s))}`,o,i),remove:(s,o)=>r.delete(`${n}/${encodeURIComponent(String(s))}`,o),http:r}},Pc=(e,t={})=>{const{getId:r=g=>g.id,optimistic:n=!1,onMutationSuccess:s,onMutationError:o,...i}=t,a=re(e,{...i}),c=L(!1),l=D(()=>c.value);let u=!1;const h=()=>{const g=typeof e=="function"?e():e;return g instanceof URL?g.toString():g},d=()=>{let g=h();for(;g.endsWith("/");)g=g.slice(0,-1);return g},v=()=>{const{defaultValue:g,transform:w,onSuccess:S,onError:k,...A}=i;return A},f=async(g,w,S,k,A,E)=>{if(!u){n&&A&&A(),c.value=!0,a.error.value=null;try{const T=re(`${d()}${S}`,{...v(),method:w,body:k??void 0,immediate:!1,watch:void 0}),P=await T.execute(),R=T.error.peek();if(T.dispose(),u)return;if(R){n&&E&&E(),a.error.value=R,a.status.value="error",c.value=!1,o?.(R,g);return}return c.value=!1,a.status.value="success",s?.(g),P}catch(T){if(u)return;n&&E&&E();const P=T instanceof Error?T:new Error(String(T));a.error.value=P,a.status.value="error",c.value=!1,o?.(P,g);return}}},p={fetch:()=>a.execute(),add:async g=>{const w=a.data.peek(),S=g,k=w?.length??0,A=await f("add","POST","",g,n?()=>{a.data.value=[...w??[],S]}:void 0,n?()=>{a.data.value=w}:void 0);if(A!==void 0&&!u){const E=a.data.peek()??[];if(n){const T=[...E];k<T.length&&T[k]===S?T[k]=A:T.push(A),a.data.value=T}else a.data.value=[...E,A]}return A},update:async(g,w)=>{const S=a.data.peek(),k=await f("update","PUT",`/${encodeURIComponent(String(g))}`,w,n&&S?()=>{a.data.value=S.map(A=>r(A)===g?{...A,...w}:A)}:void 0,n?()=>{a.data.value=S}:void 0);if(k!==void 0&&!u){const A=a.data.peek()??[];a.data.value=A.map(E=>r(E)===g?k:E)}return k},patch:async(g,w)=>{const S=a.data.peek(),k=await f("patch","PATCH",`/${encodeURIComponent(String(g))}`,w,n&&S?()=>{a.data.value=S.map(A=>r(A)===g?{...A,...w}:A)}:void 0,n?()=>{a.data.value=S}:void 0);if(k!==void 0&&!u){const A=a.data.peek()??[];a.data.value=A.map(E=>r(E)===g?k:E)}return k},remove:async g=>{const w=a.data.peek();if(await f("remove","DELETE",`/${encodeURIComponent(String(g))}`,void 0,n&&w?()=>{a.data.value=w.filter(S=>r(S)!==g)}:void 0,n?()=>{a.data.value=w}:void 0),!n&&!u&&a.error.peek()==null){const S=a.data.peek()??[];a.data.value=S.filter(k=>r(k)!==g)}}},y=a.dispose,b=()=>{u||(u=!0,y())};return{data:a.data,error:a.error,status:a.status,pending:a.pending,isMutating:l,actions:p,refresh:a.execute,clear:a.clear,dispose:b}},wr=new Map;function Nc(e,t){const r=wr.get(e);if(r)return r;const n=t().finally(()=>{wr.delete(e)});return wr.set(e,n),n}var Ic=e=>e instanceof Ge||e instanceof Je||Cs(e)?e.value:e,G=e=>e instanceof Ge,ce=e=>e instanceof Je,Sr=(e,t,r={})=>{const{immediate:n=!1,equals:s=Object.is}=r;let o,i=!0;return j(()=>{const a=e.value;if(i){i=!1,o=a,n&&t(a,void 0);return}s(a,o)||(t(a,o),o=a)})},Mc=(e,t,r,n={})=>{const{immediate:s=!1,equals:o=Object.is}=n,i=Number.isFinite(r)?Math.max(0,r):0;let a=!1,c,l;const u=()=>{h.cancel(),a=!1,l=void 0},h=Ot(()=>{if(a){try{t(c,l)}catch(v){console.error("bQuery reactive: Error in watchDebounce callback",v)}a=!1,l=void 0}},i);s&&t(e.peek(),void 0);const d=Sr(e,(v,f)=>{a||(l=f),c=v,a=!0,h()},{equals:o});return ys()&&gs(u),()=>{d(),u()}},Dc=(e,t,r,n={})=>{const{immediate:s=!1,equals:o=Object.is}=n,i=hr((c,l)=>{t(c,l)},Number.isFinite(r)?Math.max(0,r):0);s&&i(e.peek(),void 0);const a=Sr(e,(c,l)=>{i(c,l)},{equals:o});return()=>{a(),i.cancel()}};function Rs(e){return e===!1?!1:e===!0||e===void 0?{}:e}var _c=e=>e?e===!0?{}:e:!1,$s=(e,t)=>{const r=t.delay??1e3,n=t.factor??2,s=t.maxDelay??3e4;return Math.min(r*n**e,s)},Er=(e,t)=>{if(typeof t=="string"||t instanceof Blob||t instanceof ArrayBuffer){e.send(t);return}if(ArrayBuffer.isView(t)){e.send(t);return}if(typeof SharedArrayBuffer<"u"&&t instanceof SharedArrayBuffer){e.send(t);return}throw new TypeError("Unsupported WebSocket payload type.")},Os=(e,t={})=>{const{protocols:r,immediate:n=!0,historySize:s=0,onOpen:o,onMessage:i,onClose:a,onError:c,onReconnect:l}=t,u=t.serialize??(M=>JSON.stringify(M)),h=t.deserialize??(M=>{const B=M.data;if(typeof B=="string")try{return JSON.parse(B)}catch{return B}return B}),d=L("CLOSED"),v=L(void 0),f=L(null),p=L([]),y=L(0),b=L(0),g=L(0),w=D(()=>d.value==="OPEN");let S=null,k=!1,A=!1,E,T,P,R=0,$=!1,C=0;const O=[],I=Rs(t.autoReconnect),q=_c(t.heartbeat),W=()=>{if(!q)return;x();const M=q.interval??3e4,B=q.pongTimeout??1e4,J=q.message??"ping";T=setInterval(()=>{S?.readyState===WebSocket.OPEN&&(C=Date.now(),Er(S,J),P!==void 0&&clearTimeout(P),P=setTimeout(()=>{S?.close(4e3,"Heartbeat timeout")},B))},M)},x=()=>{T!==void 0&&(clearInterval(T),T=void 0),P!==void 0&&(clearTimeout(P),P=void 0)},V=()=>{P!==void 0&&(clearTimeout(P),P=void 0),C>0&&(b.value=Date.now()-C,C=0)},ve=M=>{if(k||A||!I)return;const B=I.maxAttempts??1/0;if(R>=B||I.shouldReconnect&&!I.shouldReconnect(M,R))return;const J=$s(R,I);E=setTimeout(()=>{R++,y.value=R,$=!0,fn()},J)},Fe=()=>{E!==void 0&&(clearTimeout(E),E=void 0)},un=()=>{if(!S||S.readyState!==WebSocket.OPEN)return;let M=0;for(;M<O.length&&S.readyState===WebSocket.OPEN;M++)Er(S,O[M]);M>0&&O.splice(0,M)},At=()=>{const M=typeof e=="function"?e():e;return M instanceof URL?M.toString():M},fn=()=>{if(!k){Fe(),S&&(x(),C=0,S.onopen=null,S.onmessage=null,S.onclose=null,S.onerror=null,(S.readyState===WebSocket.OPEN||S.readyState===WebSocket.CONNECTING)&&S.close(),S=null),A=!1,d.value="CONNECTING",f.value=null;try{S=new WebSocket(At(),r)}catch{d.value="CLOSED";return}S.onopen=M=>{d.value="OPEN";const B=$,J=R;R=0,y.value=0,$=!1,un(),W(),o?.(M),B&&l?.(J)},S.onmessage=M=>{if(q){const J=q.responseMessage;(J===void 0||M.data===J)&&V()}const B=h(M);if(v.value=B,s>0){const J=[...p.peek(),B];p.value=J.length>s?J.slice(-s):J}i?.(B,M)},S.onclose=M=>{d.value="CLOSED",x(),A||(g.value=Date.now()),a?.(M),!A&&!k&&ve(M)},S.onerror=M=>{f.value=M,c?.(M)}}},va=(M,B)=>{A=!0,Fe(),x(),S&&(S.readyState===WebSocket.OPEN||S.readyState===WebSocket.CONNECTING)&&(d.value="CLOSING",S.close(M,B))},Dp=M=>{k||ya(u(M))},ya=M=>{k||(S?.readyState===WebSocket.OPEN?Er(S,M):O.push(M))},_p=()=>{k||(k=!0,va(),O.length=0,S=null)};return n&&fn(),{status:d,data:v,error:f,history:p,isConnected:w,reconnectAttempts:y,latency:b,lastDisconnectedAt:g,send:Dp,sendRaw:ya,open:fn,close:va,dispose:_p}},qc=(e,t={},r={})=>{const n=r.getChannel??(u=>u.channel),s=r.wrap??((u,h)=>({channel:u,data:h})),o=new Map,i=new Map,a=Os(e,{...t,onMessage:(u,h)=>{const d=n(u);if(d!==void 0){const v=o.get(d);v&&(v.value=u)}t.onMessage?.(u,h)}});return{subscribe:u=>{let h=o.get(u);h||(h=L(void 0),o.set(u,h)),i.set(u,(i.get(u)??0)+1);let d=!1;return{data:h,unsubscribe:()=>{if(d)return;d=!0;const v=(i.get(u)??1)-1;v<=0?(i.delete(u),o.delete(u)):i.set(u,v)}}},publish:(u,h)=>{a.send(s(u,h))},ws:a}},xc=(e,t={})=>{const{immediate:r=!0,events:n=[],eventSourceInit:s,onOpen:o,onMessage:i,onError:a}=t,c=t.deserialize??($=>{try{return JSON.parse($)}catch{return $}}),l=L("CLOSED"),u=L(void 0),h=L(void 0),d=L(null),v=D(()=>l.value==="OPEN"),f=Rs(t.autoReconnect);let p=null,y=!1,b=!1,g,w=0;const S=()=>{const $=typeof e=="function"?e():e;return $ instanceof URL?$.toString():$},k=$=>C=>{const O=c(C.data);u.value=O,h.value=$,i?.(O,C)},A=()=>{g!==void 0&&(clearTimeout(g),g=void 0)},E=()=>{if(y||b||!f)return;const $=f.maxAttempts??1/0;if(w>=$)return;const C=$s(w,f);g=setTimeout(()=>{w++,T()},C)},T=()=>{if(!y){A(),p&&(p.close(),p=null),b=!1,l.value="CONNECTING",d.value=null;try{p=new EventSource(S(),s)}catch{l.value="CLOSED";return}p.onopen=$=>{l.value="OPEN",w=0,o?.($)},p.onerror=$=>{d.value=$,a?.($),p?.readyState===EventSource.CLOSED&&(l.value="CLOSED",!b&&!y&&E())},p.addEventListener("message",k("message"));for(const $ of n)p.addEventListener($,k($))}},P=()=>{b=!0,A(),p&&(p.close(),p=null),l.value="CLOSED"},R=()=>{y||(y=!0,P())};return r&&T(),{status:l,data:u,eventName:h,error:d,isConnected:v,open:T,close:P,dispose:R}},H=class extends Error{constructor(e,t,r){super(e),this.name="TaskWorkerError",this.code=t,r!==void 0&&(this.cause=r)}},Ar=class extends H{constructor(e="Concurrency tasks are not supported in this environment.",t){super(e,"UNSUPPORTED",t),this.name="TaskWorkerUnsupportedError"}},Te=class extends H{constructor(e,t){super(e,"SERIALIZATION",t),this.name="TaskWorkerSerializationError"}},It=class extends H{constructor(e,t){super(e,"TIMEOUT",t),this.name="TaskWorkerTimeoutError"}},ge=class extends H{constructor(e="The worker task was aborted.",t){super(e,"ABORT",t),this.name="TaskWorkerAbortError"}},zc=new Set(["ABORT","BUSY","METHOD_NOT_FOUND","QUEUE_CLEARED","QUEUE_FULL","SERIALIZATION","TERMINATED","TIMEOUT","UNSUPPORTED","WORKER"]),jc=/\{\s*\[native code\]\s*\}$/u,Uc=e=>typeof e=="string"&&zc.has(e),Mt=e=>{if(!(typeof e!="number"||!Number.isFinite(e)||e<=0))return e},Xe=e=>{const t=Function.prototype.toString.call(e).trim();if(!t||jc.test(t))throw new Te("Task handlers must be standalone user-defined functions or arrow functions.");try{if(typeof new Function(`return (${t});`)()!="function")throw new TypeError("Task handler did not revive as a function.")}catch(r){throw new Te("Task handlers must be standalone functions that can be reconstructed in a worker context.",r)}return t},Ls=(e,t)=>{const r=new Blob([e],{type:"text/javascript"}),n=URL.createObjectURL(r);try{return new Worker(n,t?{name:t}:void 0)}finally{URL.revokeObjectURL(n)}},Ps=e=>{const t=e?.message||"Worker task failed.",r=Uc(e?.code)?e.code:"WORKER",n=r==="TIMEOUT"?new It(t):new H(t,r);return n.name=e?.name||n.name,e?.stack&&(n.stack=e.stack),n};function Ns(){const e=typeof globalThis.Worker=="function",t=typeof globalThis.Blob=="function",r=typeof globalThis.URL<"u"&&globalThis.URL!==null&&typeof globalThis.URL.createObjectURL=="function"&&typeof globalThis.URL.revokeObjectURL=="function";return{worker:e,blob:t,objectUrl:r,abortController:typeof globalThis.AbortController=="function",supported:e&&t&&r}}function kr(){return Ns().supported}var Is="bq:rpc",Hc=e=>{const t=Object.keys(e);if(t.length===0)throw new Te("RPC workers require at least one standalone method handler.");return t.map(r=>{const n=e[r];if(typeof n!="function")throw new Te(`RPC handler "${r}" must be a standalone function.`);return[r,Xe(n)]})},Wc=e=>`'use strict';
2
2
  const serializeError = (error) => {
3
3
  if (error && typeof error === 'object') {
4
4
  return {
@@ -23,7 +23,7 @@ const hasOwn = Object.prototype.hasOwnProperty;
23
23
 
24
24
  self.onmessage = async (event) => {
25
25
  const message = event.data;
26
- if (!message || message.type !== '${Jn}') {
26
+ if (!message || message.type !== '${Is}') {
27
27
  return;
28
28
  }
29
29
 
@@ -47,7 +47,7 @@ self.onmessage = async (event) => {
47
47
  } catch (error) {
48
48
  self.postMessage({ error: serializeError(error), id: message.id, type: 'bq:error' });
49
49
  }
50
- };`;function It(e,t={}){if(!Er())throw new Sr;const r=Wc(Hc(e)),n=Nt(t.timeout);let s=!1,o=null,i=null,a=0,c;const l=()=>{i&&(i.timeoutId!==void 0&&clearTimeout(i.timeoutId),i.abortHandler&&c?.removeEventListener("abort",i.abortHandler),i=null,c=void 0)},u=()=>{o&&(o.onmessage=null,o.onerror=null,o.terminate(),o=null)},h=f=>{if(!i)return;const m=i;l(),m.reject(f)},d=()=>{if(s)throw new H("The RPC worker has already been terminated.","TERMINATED");if(o)return o;const f=Vn(r,t.name);return f.onmessage=m=>{const v=i;if(!v)return;const b=m.data;if(!(!b||b.id!==v.id)){if(l(),b.type==="bq:error"){v.reject(Kn(b.error));return}v.resolve(b.result)}},f.onerror=m=>{const v=new H(m.message||"Worker RPC execution failed.","WORKER");u(),h(v)},o=f,f},p=f=>{u(),h(f)};return{get busy(){return i!==null},get state(){return s?"terminated":i?"running":"idle"},call(f,m,v={}){if(s)return Promise.reject(new H("The RPC worker has already been terminated.","TERMINATED"));if(i)return Promise.reject(new H("This RPC worker is already processing a request. Wait for the current call to finish or create another worker.","BUSY"));if(v.signal?.aborted)return Promise.reject(new ge);const b=d(),g=Nt(v.timeout)??n,w=a++;return new Promise((S,k)=>{const A={id:w,reject:k,resolve:S};v.signal&&(A.abortHandler=()=>{p(new ge)},c=v.signal,v.signal.addEventListener("abort",A.abortHandler,{once:!0})),g!==void 0&&(A.timeoutId=setTimeout(()=>{p(new Pt(`Worker RPC call exceeded the timeout of ${g}ms.`))},g)),i=A;try{b.postMessage({id:w,method:f,payload:m,type:Jn},v.transfer??[])}catch(E){u(),h(new Ae("Failed to serialize the RPC payload or transfer list for worker execution.",E))}})},terminate(){s||(s=!0,u(),h(new H("The RPC worker was terminated.","TERMINATED")))}}}async function Fc(e,t,r,n={}){const s=It(e,n);try{return await s.call(t,r,n)}finally{s.terminate()}}var Gn="bq:run",Bc=e=>`'use strict';
50
+ };`;function Dt(e,t={}){if(!kr())throw new Ar;const r=Wc(Hc(e)),n=Mt(t.timeout);let s=!1,o=null,i=null,a=0,c;const l=()=>{i&&(i.timeoutId!==void 0&&clearTimeout(i.timeoutId),i.abortHandler&&c?.removeEventListener("abort",i.abortHandler),i=null,c=void 0)},u=()=>{o&&(o.onmessage=null,o.onerror=null,o.terminate(),o=null)},h=f=>{if(!i)return;const p=i;l(),p.reject(f)},d=()=>{if(s)throw new H("The RPC worker has already been terminated.","TERMINATED");if(o)return o;const f=Ls(r,t.name);return f.onmessage=p=>{const y=i;if(!y)return;const b=p.data;if(!(!b||b.id!==y.id)){if(l(),b.type==="bq:error"){y.reject(Ps(b.error));return}y.resolve(b.result)}},f.onerror=p=>{const y=new H(p.message||"Worker RPC execution failed.","WORKER");u(),h(y)},o=f,f},v=f=>{u(),h(f)};return{get busy(){return i!==null},get state(){return s?"terminated":i?"running":"idle"},call(f,p,y={}){if(s)return Promise.reject(new H("The RPC worker has already been terminated.","TERMINATED"));if(i)return Promise.reject(new H("This RPC worker is already processing a request. Wait for the current call to finish or create another worker.","BUSY"));if(y.signal?.aborted)return Promise.reject(new ge);const b=d(),g=Mt(y.timeout)??n,w=a++;return new Promise((S,k)=>{const A={id:w,reject:k,resolve:S};y.signal&&(A.abortHandler=()=>{v(new ge)},c=y.signal,y.signal.addEventListener("abort",A.abortHandler,{once:!0})),g!==void 0&&(A.timeoutId=setTimeout(()=>{v(new It(`Worker RPC call exceeded the timeout of ${g}ms.`))},g)),i=A;try{b.postMessage({id:w,method:f,payload:p,type:Is},y.transfer??[])}catch(E){u(),h(new Te("Failed to serialize the RPC payload or transfer list for worker execution.",E))}})},terminate(){s||(s=!0,u(),h(new H("The RPC worker was terminated.","TERMINATED")))}}}async function Fc(e,t,r,n={}){const s=Dt(e,n);try{return await s.call(t,r,n)}finally{s.terminate()}}var Ms="bq:run",Bc=e=>`'use strict';
51
51
  const serializeError = (error) => {
52
52
  if (error && typeof error === 'object') {
53
53
  return {
@@ -72,7 +72,7 @@ if (typeof handler !== 'function') {
72
72
 
73
73
  self.onmessage = async (event) => {
74
74
  const message = event.data;
75
- if (!message || message.type !== '${Gn}') {
75
+ if (!message || message.type !== '${Ms}') {
76
76
  return;
77
77
  }
78
78
 
@@ -82,13 +82,13 @@ self.onmessage = async (event) => {
82
82
  } catch (error) {
83
83
  self.postMessage({ error: serializeError(error), id: message.id, type: 'bq:error' });
84
84
  }
85
- };`;function Mt(e,t={}){if(!Er())throw new Sr;const r=Bc(Xe(e)),n=Nt(t.timeout);let s=!1,o=null,i=null,a=0;const c=()=>{i&&(i.timeoutId!==void 0&&clearTimeout(i.timeoutId),i.abortHandler&&l?.removeEventListener("abort",i.abortHandler),i=null,l=void 0)};let l;const u=()=>{o&&(o.onmessage=null,o.onerror=null,o.terminate(),o=null)},h=f=>{if(!i)return;const m=i;c(),m.reject(f)},d=()=>{if(s)throw new H("The task worker has already been terminated.","TERMINATED");if(o)return o;const f=Vn(r,t.name);return f.onmessage=m=>{const v=i;if(!v)return;const b=m.data;if(!(!b||b.id!==v.id)){if(c(),b.type==="bq:error"){v.reject(Kn(b.error));return}v.resolve(b.result)}},f.onerror=m=>{const v=new H(m.message||"Worker execution failed.","WORKER");u(),h(v)},o=f,f},p=f=>{u(),h(f)};return{get busy(){return i!==null},get state(){return s?"terminated":i?"running":"idle"},run(f,m={}){if(s)return Promise.reject(new H("The task worker has already been terminated.","TERMINATED"));if(i)return Promise.reject(new H("This task worker is already running a task. Create another worker or wait for the current task to finish.","BUSY"));if(m.signal?.aborted)return Promise.reject(new ge);const v=d(),b=Nt(m.timeout)??n,g=a++;return new Promise((w,S)=>{const k={id:g,reject:S,resolve:w};m.signal&&(k.abortHandler=()=>{p(new ge)},l=m.signal,m.signal.addEventListener("abort",k.abortHandler,{once:!0})),b!==void 0&&(k.timeoutId=setTimeout(()=>{p(new Pt(`Worker task exceeded the timeout of ${b}ms.`))},b)),i=k;try{v.postMessage({id:g,payload:f,type:Gn},m.transfer??[])}catch(A){u(),h(new Ae("Failed to serialize the task input or transfer list for worker execution.",A))}})},terminate(){s||(s=!0,u(),h(new H("The task worker was terminated.","TERMINATED")))}}}async function Xn(e,t,r={}){const n=Mt(e,r);try{return await n.run(t,r)}finally{n.terminate()}}var Qc=4,Zn=(e,t)=>{if(e===void 0)return Qc;if(!Number.isInteger(e)||e<1)throw new RangeError(`${t} concurrency must be a positive integer.`);return e},es=(e,t)=>{if(e===void 0)return Number.POSITIVE_INFINITY;if(e===Number.POSITIVE_INFINITY)return e;if(!Number.isInteger(e)||e<0)throw new RangeError(`${t} maxQueue must be a non-negative integer or Infinity.`);return e},Dt=e=>{e.abortHandler&&e.signal&&e.signal.removeEventListener("abort",e.abortHandler),e.abortHandler=void 0,e.signal=void 0},ts=({abortedWhileQueuedMessage:e,clearMessage:t,concurrency:r,createWorkers:n,queueFullMessage:s,terminatedMessage:o,workerTerminatedMessage:i,runWorker:a,maxQueue:c})=>{const l=[],u=n(r);let h=!1,d=0;const p=()=>{if(!(h||l.length===0))for(const m of u){if(l.length===0)return;if(m.busy)continue;const v=l.shift();if(v.signal?.aborted){Dt(v),v.reject(new ge(e));continue}Dt(v),d++,a(m,v.job,v.options).then(v.resolve,v.reject).finally(()=>{d--,p()})}},f=m=>{const v=l.splice(0);for(const b of v)Dt(b),b.reject(m)};return{get state(){return h?"terminated":d>0||l.length>0?"running":"idle"},get busy(){return d>0||l.length>0},concurrency:r,get pending(){return d},get size(){return l.length},enqueue(m,v={}){return h?Promise.reject(new H(i,"TERMINATED")):v.signal?.aborted?Promise.reject(new ge):new Promise((b,g)=>{const w={job:m,options:v,reject:g,resolve:b},S=u.find(k=>!k.busy);if(S){d++,a(S,m,v).then(b,g).finally(()=>{d--,p()});return}if(l.length>=c){g(new H(s,"QUEUE_FULL"));return}v.signal&&(w.signal=v.signal,w.abortHandler=()=>{const k=l.indexOf(w);k!==-1&&(l.splice(k,1),Dt(w),g(new ge(e)))},v.signal.addEventListener("abort",w.abortHandler,{once:!0})),l.push(w)})},clear(){h||l.length===0||f(new H(t,"QUEUE_CLEARED"))},terminate(){if(!h){h=!0,f(new H(o,"TERMINATED"));for(const m of u)"terminate"in m&&typeof m.terminate=="function"&&m.terminate()}}}},rs=(e,t)=>e?t===1?[e]:Array.from({length:t},(r,n)=>`${e}-${n+1}`):Array.from({length:t},()=>{});function _t(e,t={}){const{concurrency:r,maxQueue:n,...s}=t,o=ts({abortedWhileQueuedMessage:"The queued task was aborted before execution started.",clearMessage:"The task pool queue was cleared.",concurrency:Zn(r,"Task pool"),createWorkers(i){const a=[],c=rs(s.name,i);try{for(let l=0;l<i;l++)a.push(Mt(e,{...s,name:c[l]}))}catch(l){for(const u of a)u.terminate();throw l}return a},queueFullMessage:"The task pool queue is full. Increase maxQueue, wait for pending tasks, or raise pool concurrency.",terminatedMessage:"The task pool was terminated.",workerTerminatedMessage:"The task pool has already been terminated.",runWorker(i,a,c){return i.run(a,c)},maxQueue:es(n,"Task pool")});return{get state(){return o.state},get busy(){return o.busy},get concurrency(){return o.concurrency},get pending(){return o.pending},get size(){return o.size},run(i,a){return o.enqueue(i,a)},clear(){o.clear()},terminate(){o.terminate()}}}function ns(e,t={}){const{concurrency:r,maxQueue:n,...s}=t,o=ts({abortedWhileQueuedMessage:"The queued RPC call was aborted before execution started.",clearMessage:"The RPC pool queue was cleared.",concurrency:Zn(r,"RPC pool"),createWorkers(i){const a=[],c=rs(s.name,i);try{for(let l=0;l<i;l++)a.push(It(e,{...s,name:c[l]}))}catch(l){for(const u of a)u.terminate();throw l}return a},queueFullMessage:"The RPC pool queue is full. Increase maxQueue, wait for pending calls, or raise pool concurrency.",terminatedMessage:"The RPC pool was terminated.",workerTerminatedMessage:"The RPC pool has already been terminated.",runWorker(i,a,c){return i.call(a.method,a.input,c)},maxQueue:es(n,"RPC pool")});return{get state(){return o.state},get busy(){return o.busy},get concurrency(){return o.concurrency},get pending(){return o.pending},get size(){return o.size},call(i,a,c){return o.enqueue({input:a,method:i},c)},clear(){o.clear()},terminate(){o.terminate()}}}var Vc=async e=>{const t=new Function(`return (${e.handlerSource});`)();if(typeof t!="function")throw new TypeError("The serialized task handler did not revive as a function.");return await t(e.input)},Kc=async e=>{const t=new Function(`return (${e.handlerSource});`)();if(typeof t!="function")throw new TypeError("The serialized collection handler did not revive as a function.");const r=[];for(const n of e.items)r.push({index:n.index,value:await t(n.value,n.index)});return r},Yc=async e=>{const t=new Function(`return (${e.reducerSource});`)();if(typeof t!="function")throw new TypeError("The serialized reducer did not revive as a function.");let r=e.initialValue;for(let n=0;n<e.values.length;n++)r=await t(r,e.values[n],n);return r},ss=(e,t)=>{if(e===void 0)return 1;if(!Number.isInteger(e)||e<1)throw new RangeError(`${t} batchSize must be a positive integer.`);return e},os=e=>_t(Vc,e),is=e=>({handlerSource:Xe(e.handler),input:e.input}),Ze=async(e,t,r={},n)=>{if(e.length===0)return[];const s=Xe(t),{batchSize:o,signal:i,...a}=r,c=ss(o,n),l=_t(Kc,a),u=[];for(let h=0;h<e.length;h+=c){const d=Math.min(h+c,e.length),p=[];for(let f=h;f<d;f+=1)p.push({index:f,value:e[f]});u.push({items:p,handlerSource:s})}try{const h=await Promise.all(u.map(p=>l.run(p,i?{signal:i}:void 0))),d=new Array(e.length);for(const p of h)for(const f of p)d[f.index]=f.value;return d}finally{l.terminate()}};async function Jc(e,t={}){if(e.length===0)return[];const r=os(t);try{return await Promise.all(e.map(n=>r.run(is(n),n.options)))}finally{r.terminate()}}async function Gc(e,t,r={}){if(e.length===0)return[];const n=ss(t,"batchTasks"),s=os(r),o=[];try{for(let i=0;i<e.length;i+=n){const a=e.slice(i,i+n),c=await Promise.all(a.map(l=>s.run(is(l),l.options)));o.push(...c)}return o}finally{s.terminate()}}async function as(e,t,r={}){return Ze(e,t,r,"map")}async function cs(e,t,r={}){const n=await Ze(e,t,r,"filter"),s=[];for(let o=0;o<e.length;o+=1)n[o]&&(o in e?s.push(e[o]):s.length+=1);return s}async function ls(e,t,r={}){return e.length===0?!1:(await Ze(e,t,r,"some")).some(Boolean)}async function us(e,t,r={}){return e.length===0?!0:(await Ze(e,t,r,"every")).every(Boolean)}async function fs(e,t,r={}){if(e.length===0)return;const n=(await Ze(e,t,r,"find")).findIndex(Boolean);return n===-1?void 0:e[n]}async function ds(e,t,r,n={}){return e.length===0?r:Xn(Yc,{initialValue:r,reducerSource:Xe(t),values:e},n)}var et=(e,t={})=>({...e,...t}),Xc=(e,t={})=>({signal:"signal"in t?t.signal:e.signal,timeout:"timeout"in t?t.timeout:e.timeout,transfer:t.transfer}),Zc=class qi{constructor(t,r){this.valuesPromise=t,this.defaults=r}createNext(t){return new qi(this.valuesPromise.then(r=>t(r)),this.defaults)}map(t,r){const n=et(this.defaults,r);return this.createNext(s=>as(s,t,n))}filter(t,r){const n=et(this.defaults,r);return this.createNext(s=>cs(s,t,n))}toArray(){return this.valuesPromise.then(t=>t.slice())}some(t,r){const n=et(this.defaults,r);return this.valuesPromise.then(s=>ls(s,t,n))}every(t,r){const n=et(this.defaults,r);return this.valuesPromise.then(s=>us(s,t,n))}find(t,r){const n=et(this.defaults,r);return this.valuesPromise.then(s=>fs(s,t,n))}reduce(t,r,n){const s=Xc(this.defaults,n);return this.valuesPromise.then(o=>ds(o,t,r,s))}};function el(e,t={}){return new Zc(Promise.resolve(e.slice()),t)}var hs=(e,t)=>{Se(()=>{t.state.value=e.state,t.busy.value=e.busy})},ms=(e,t)=>{Se(()=>{t.state.value=e.state,t.busy.value=e.busy,t.concurrency.value=e.concurrency,t.pending.value=e.pending,t.size.value=e.size})},ps=e=>({busy:L(e.busy),state:L(e.state)}),vs=e=>({busy:L(e.busy),concurrency:L(e.concurrency),pending:L(e.pending),size:L(e.size),state:L(e.state)}),xt=(e,t)=>(t(),e.finally(()=>{t(),queueMicrotask(t)}));function tl(e,t={}){const r=Mt(e,t),n=ps(r),s=()=>{hs(r,n)};return{get busy(){return r.busy},get state(){return r.state},busy$:_(n.busy),state$:_(n.state),run(o,i={}){return xt(r.run(o,i),s)},terminate(){r.terminate(),s()}}}function rl(e,t={}){const r=It(e,t),n=ps(r),s=()=>{hs(r,n)};return{get busy(){return r.busy},get state(){return r.state},busy$:_(n.busy),state$:_(n.state),call(o,i,a={}){return xt(r.call(o,i,a),s)},terminate(){r.terminate(),s()}}}function nl(e,t={}){const r=_t(e,t),n=vs(r),s=()=>{ms(r,n)};return{get busy(){return r.busy},get concurrency(){return r.concurrency},get pending(){return r.pending},get size(){return r.size},get state(){return r.state},busy$:_(n.busy),concurrency$:_(n.concurrency),pending$:_(n.pending),size$:_(n.size),state$:_(n.state),run(o,i={}){return xt(r.run(o,i),s)},clear(){r.clear(),s()},terminate(){r.terminate(),s()}}}function sl(e,t={}){const r=ns(e,t),n=vs(r),s=()=>{ms(r,n)};return{get busy(){return r.busy},get concurrency(){return r.concurrency},get pending(){return r.pending},get size(){return r.size},get state(){return r.state},busy$:_(n.busy),concurrency$:_(n.concurrency),pending$:_(n.pending),size$:_(n.size),state$:_(n.state),call(o,i,a={}){return xt(r.call(o,i,a),s)},clear(){r.clear(),s()},terminate(){r.terminate(),s()}}}var ol=(e,t)=>{const{type:r}=t;if(r===String)return e;if(r===Number)return Number(e);if(r===Boolean){const n=e.trim().toLowerCase();return n===""||n==="true"||n==="1"?!0:n==="false"||n==="0"?!1:!!e}if(r===Object||r===Array)try{return JSON.parse(e)}catch{return e}if(typeof r=="function"){const n=r,s=r;if(t.construct===!0)return Reflect.construct(s,[e]);if(t.construct===!1)return n(e);const o=r.prototype!==void 0&&r.prototype!==null,i=(o?Object.getOwnPropertyNames(r.prototype):[]).length>1,a=o&&r.prototype.constructor!==r,c=/^class\s/.test(Function.prototype.toString.call(r));if(i||a||c)try{return Reflect.construct(s,[e])}catch{return n(e)}try{const l=n(e);if(l===void 0&&o)try{return Reflect.construct(s,[e])}catch{return l}return l}catch(l){if(l instanceof TypeError&&/cannot be invoked without 'new'|is not a function/i.test(l.message))return Reflect.construct(s,[e]);throw l}}return e},qt=()=>{try{const e=globalThis;if(typeof e.__BQUERY_DEV__=="boolean")return e.__BQUERY_DEV__;const t=e.process?.env?.NODE_ENV;if(typeof t=="string")return t!=="production";const r=e.process?.versions?.node;if(typeof r=="string"&&r.length>0)return!0;const n=e.process?.release?.name;return n==="node"||n==="io.js"}catch{return!1}},tt;function be(e){const t=tt;return tt=e,t}function ys(){const e=[];return{addDisposer(t){e.push(t)},dispose(){for(const t of e)try{t()}catch(r){qt()&&typeof console<"u"&&typeof console.error=="function"&&console.error("bQuery component: Error disposing scoped resource",r)}e.length=0}}}function il(e){const t=tt;if(!t)throw new Error("bQuery component: useSignal() must be called inside a component lifecycle hook. Avoid calling it directly from render()");const r=L(e);return t.addDisposer(()=>r.dispose()),r}function al(e){const t=tt;if(!t)throw new Error("bQuery component: useComputed() must be called inside a component lifecycle hook. Avoid calling it directly from render()");const r=D(e);return t.addDisposer(()=>r.dispose()),r}function cl(e){const t=tt;if(!t)throw new Error("bQuery component: useEffect() must be called inside a component lifecycle hook. Avoid calling it directly from render()");const r=j(e);return t.addDisposer(r),r}var ll=["slot"],ul=["part","disabled","checked","placeholder","value","rows","cols","readonly","required","maxlength","minlength","max","min","step","pattern","autocomplete","autofocus","for","multiple","selected","wrap"],gs=(e,t)=>{const r=[...ll,...t.sanitize?.allowTags??[]],n=[...ul,...t.sanitize?.allowAttributes??[]],s=Object.values(t.signals??{}),i=(l=>l===!1?!1:l==="closed"?"closed":"open")(t.shadow),a=Array.from(new Set([...Object.keys(t.props??{}),...t.observeAttributes??[]]));class c extends HTMLElement{constructor(){super(),this.state={...t.state??{}},this.props={},this.missingRequiredProps=new Set,this.hasMounted=!1,i!==!1?this.renderRootNode=this.attachShadow({mode:i}):this.renderRootNode=this,this.syncProps()}static get observedAttributes(){return a}connectedCallback(){try{if(!this.hasMounted&&this.missingRequiredProps.size>0)return;if(this.hasMounted){this.scope=ys();const u=be(this.scope);try{t.connected?.call(this)}catch(h){this.handleError(h)}finally{be(u)}this.setupSignalSubscriptions(!0);return}this.mount()}catch(u){this.handleError(u)}}mount(){if(this.hasMounted)return;const u=be(this.ensureScope());let h=!1;try{t.beforeMount?.call(this),t.connected?.call(this)}catch(d){h=!0,this.handleError(d)}finally{be(u)}if(h){this.scope?.dispose(),this.scope=void 0;return}this.render(),this.setupSignalSubscriptions(),this.hasMounted=!0}disconnectedCallback(){try{this.signalEffectCleanup?.(),this.signalEffectCleanup=void 0,this.scope?.dispose(),this.scope=void 0,t.disconnected?.call(this)}catch(u){this.handleError(u)}}attributeChangedCallback(u,h,d){try{const p=this.cloneProps();if(this.syncProps(),t.onAttributeChanged){const f=be(this.ensureScope());try{t.onAttributeChanged.call(this,u,h,d)}finally{be(f)}}this.hasMounted?this.render(!0,p,{name:u,oldValue:h,newValue:d}):this.isConnected&&this.missingRequiredProps.size===0&&this.mount()}catch(p){this.handleError(p)}}adoptedCallback(){if(!t.onAdopted)return;const u=be(this.ensureScope());try{t.onAdopted.call(this)}catch(h){this.handleError(h)}finally{be(u)}}handleError(u){t.onError?t.onError.call(this,u):console.error(`bQuery component error in <${e}>:`,u)}ensureScope(){return this.scope??(this.scope=ys())}setState(u,h){this.state[u]=h,this.render(!0,this.cloneProps(),void 0,!1)}getState(u){return this.state[u]}setupSignalSubscriptions(u=!1){if(this.signalEffectCleanup||s.length===0)return;let h=!0;this.signalEffectCleanup=j(()=>{try{for(const p of s)p.value;if(h){if(h=!1,u&&this.hasMounted&&this.isConnected){const p=this.cloneProps();Ee(()=>{this.render(!0,p,void 0,!1)})}return}if(!this.hasMounted||!this.isConnected)return;const d=this.cloneProps();Ee(()=>{this.render(!0,d,void 0,!1)})}catch(d){this.handleError(d)}})}syncProps(){const u=t.props??{};for(const[h,d]of Object.entries(u)){const p=this.getAttribute(h);let f;if(p==null?d.required&&d.default===void 0?(this.missingRequiredProps.add(h),f=void 0):f=d.default??void 0:(this.missingRequiredProps.has(h)&&this.missingRequiredProps.delete(h),f=ol(p,d)),d.validator&&f!==void 0&&!d.validator(f))throw new Error(`bQuery component: validation failed for prop "${h}" with value ${JSON.stringify(f)}`);this.props[h]=f}}cloneProps(){return{...this.props}}render(u=!1,h,d,p=!0){try{if(u&&p&&t.beforeUpdate){if(!h)throw new Error("bQuery component: previous props are required for update renders");if(t.beforeUpdate.call(this,this.props,h)===!1)return}const f=(g,w)=>{this.dispatchEvent(new CustomEvent(g,{detail:w,bubbles:!0,composed:!0}))},m=this.renderRootNode,v=ie(t.render({props:this.props,state:this.state,signals:t.signals??{},emit:f}),{allowTags:r,allowAttributes:n});let b=null;if(t.styles&&(b=m.querySelector("style[data-bquery-component-style]")),m.innerHTML=v,t.styles){const g=b??document.createElement("style");b||g.setAttribute("data-bquery-component-style",""),g.textContent=t.styles,m.prepend(g)}u&&t.updated?.call(this,d)}catch(f){this.handleError(f)}}}return c};function fl(e,t){return gs(e,t)}function Me(e,t){const r=gs(e,t);customElements.get(e)||customElements.define(e,r)}var bs=Symbol("bquery.booleanAttribute"),dl=/^[^\0-\x20"'/>=]+$/,ws=e=>{if(typeof e!="object"||e===null)return!1;const t=e;return t[bs]===!0&&typeof t.enabled=="boolean"&&typeof t.name=="string"},Ss=e=>ws(e)?e.enabled?e.name:"":String(e??""),hl={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","`":"&#x60;"},ml=e=>ws(e)?e.enabled?e.name:"":Ss(e).replace(/[&<>"'`]/g,t=>hl[t]),pl=(e,t)=>{if(!dl.test(e))throw new TypeError(`Invalid boolean attribute name: ${e}`);return Object.freeze({[bs]:!0,enabled:!!t,name:e})},De=(e,...t)=>e.reduce((r,n,s)=>`${r}${n}${Ss(t[s])}`,""),vl=(e,...t)=>{const r=n=>Qi(n)?Vi(n):ml(n);return vn(e.reduce((n,s,o)=>`${n}${s}${o<t.length?r(t[o]):""}`,""))},zt=`
85
+ };`;function _t(e,t={}){if(!kr())throw new Ar;const r=Bc(Xe(e)),n=Mt(t.timeout);let s=!1,o=null,i=null,a=0;const c=()=>{i&&(i.timeoutId!==void 0&&clearTimeout(i.timeoutId),i.abortHandler&&l?.removeEventListener("abort",i.abortHandler),i=null,l=void 0)};let l;const u=()=>{o&&(o.onmessage=null,o.onerror=null,o.terminate(),o=null)},h=f=>{if(!i)return;const p=i;c(),p.reject(f)},d=()=>{if(s)throw new H("The task worker has already been terminated.","TERMINATED");if(o)return o;const f=Ls(r,t.name);return f.onmessage=p=>{const y=i;if(!y)return;const b=p.data;if(!(!b||b.id!==y.id)){if(c(),b.type==="bq:error"){y.reject(Ps(b.error));return}y.resolve(b.result)}},f.onerror=p=>{const y=new H(p.message||"Worker execution failed.","WORKER");u(),h(y)},o=f,f},v=f=>{u(),h(f)};return{get busy(){return i!==null},get state(){return s?"terminated":i?"running":"idle"},run(f,p={}){if(s)return Promise.reject(new H("The task worker has already been terminated.","TERMINATED"));if(i)return Promise.reject(new H("This task worker is already running a task. Create another worker or wait for the current task to finish.","BUSY"));if(p.signal?.aborted)return Promise.reject(new ge);const y=d(),b=Mt(p.timeout)??n,g=a++;return new Promise((w,S)=>{const k={id:g,reject:S,resolve:w};p.signal&&(k.abortHandler=()=>{v(new ge)},l=p.signal,p.signal.addEventListener("abort",k.abortHandler,{once:!0})),b!==void 0&&(k.timeoutId=setTimeout(()=>{v(new It(`Worker task exceeded the timeout of ${b}ms.`))},b)),i=k;try{y.postMessage({id:g,payload:f,type:Ms},p.transfer??[])}catch(A){u(),h(new Te("Failed to serialize the task input or transfer list for worker execution.",A))}})},terminate(){s||(s=!0,u(),h(new H("The task worker was terminated.","TERMINATED")))}}}async function Ds(e,t,r={}){const n=_t(e,r);try{return await n.run(t,r)}finally{n.terminate()}}var Qc=4,_s=(e,t)=>{if(e===void 0)return Qc;if(!Number.isInteger(e)||e<1)throw new RangeError(`${t} concurrency must be a positive integer.`);return e},qs=(e,t)=>{if(e===void 0)return Number.POSITIVE_INFINITY;if(e===Number.POSITIVE_INFINITY)return e;if(!Number.isInteger(e)||e<0)throw new RangeError(`${t} maxQueue must be a non-negative integer or Infinity.`);return e},qt=e=>{e.abortHandler&&e.signal&&e.signal.removeEventListener("abort",e.abortHandler),e.abortHandler=void 0,e.signal=void 0},xs=({abortedWhileQueuedMessage:e,clearMessage:t,concurrency:r,createWorkers:n,queueFullMessage:s,terminatedMessage:o,workerTerminatedMessage:i,runWorker:a,maxQueue:c})=>{const l=[],u=n(r);let h=!1,d=0;const v=()=>{if(!(h||l.length===0))for(const p of u){if(l.length===0)return;if(p.busy)continue;const y=l.shift();if(y.signal?.aborted){qt(y),y.reject(new ge(e));continue}qt(y),d++,a(p,y.job,y.options).then(y.resolve,y.reject).finally(()=>{d--,v()})}},f=p=>{const y=l.splice(0);for(const b of y)qt(b),b.reject(p)};return{get state(){return h?"terminated":d>0||l.length>0?"running":"idle"},get busy(){return d>0||l.length>0},concurrency:r,get pending(){return d},get size(){return l.length},enqueue(p,y={}){return h?Promise.reject(new H(i,"TERMINATED")):y.signal?.aborted?Promise.reject(new ge):new Promise((b,g)=>{const w={job:p,options:y,reject:g,resolve:b},S=u.find(k=>!k.busy);if(S){d++,a(S,p,y).then(b,g).finally(()=>{d--,v()});return}if(l.length>=c){g(new H(s,"QUEUE_FULL"));return}y.signal&&(w.signal=y.signal,w.abortHandler=()=>{const k=l.indexOf(w);k!==-1&&(l.splice(k,1),qt(w),g(new ge(e)))},y.signal.addEventListener("abort",w.abortHandler,{once:!0})),l.push(w)})},clear(){h||l.length===0||f(new H(t,"QUEUE_CLEARED"))},terminate(){if(!h){h=!0,f(new H(o,"TERMINATED"));for(const p of u)"terminate"in p&&typeof p.terminate=="function"&&p.terminate()}}}},zs=(e,t)=>e?t===1?[e]:Array.from({length:t},(r,n)=>`${e}-${n+1}`):Array.from({length:t},()=>{});function xt(e,t={}){const{concurrency:r,maxQueue:n,...s}=t,o=xs({abortedWhileQueuedMessage:"The queued task was aborted before execution started.",clearMessage:"The task pool queue was cleared.",concurrency:_s(r,"Task pool"),createWorkers(i){const a=[],c=zs(s.name,i);try{for(let l=0;l<i;l++)a.push(_t(e,{...s,name:c[l]}))}catch(l){for(const u of a)u.terminate();throw l}return a},queueFullMessage:"The task pool queue is full. Increase maxQueue, wait for pending tasks, or raise pool concurrency.",terminatedMessage:"The task pool was terminated.",workerTerminatedMessage:"The task pool has already been terminated.",runWorker(i,a,c){return i.run(a,c)},maxQueue:qs(n,"Task pool")});return{get state(){return o.state},get busy(){return o.busy},get concurrency(){return o.concurrency},get pending(){return o.pending},get size(){return o.size},run(i,a){return o.enqueue(i,a)},clear(){o.clear()},terminate(){o.terminate()}}}function js(e,t={}){const{concurrency:r,maxQueue:n,...s}=t,o=xs({abortedWhileQueuedMessage:"The queued RPC call was aborted before execution started.",clearMessage:"The RPC pool queue was cleared.",concurrency:_s(r,"RPC pool"),createWorkers(i){const a=[],c=zs(s.name,i);try{for(let l=0;l<i;l++)a.push(Dt(e,{...s,name:c[l]}))}catch(l){for(const u of a)u.terminate();throw l}return a},queueFullMessage:"The RPC pool queue is full. Increase maxQueue, wait for pending calls, or raise pool concurrency.",terminatedMessage:"The RPC pool was terminated.",workerTerminatedMessage:"The RPC pool has already been terminated.",runWorker(i,a,c){return i.call(a.method,a.input,c)},maxQueue:qs(n,"RPC pool")});return{get state(){return o.state},get busy(){return o.busy},get concurrency(){return o.concurrency},get pending(){return o.pending},get size(){return o.size},call(i,a,c){return o.enqueue({input:a,method:i},c)},clear(){o.clear()},terminate(){o.terminate()}}}var Vc=async e=>{const t=new Function(`return (${e.handlerSource});`)();if(typeof t!="function")throw new TypeError("The serialized task handler did not revive as a function.");return await t(e.input)},Kc=async e=>{const t=new Function(`return (${e.handlerSource});`)();if(typeof t!="function")throw new TypeError("The serialized collection handler did not revive as a function.");const r=[];for(const n of e.items)r.push({index:n.index,value:await t(n.value,n.index)});return r},Yc=async e=>{const t=new Function(`return (${e.reducerSource});`)();if(typeof t!="function")throw new TypeError("The serialized reducer did not revive as a function.");let r=e.initialValue;for(let n=0;n<e.values.length;n++)r=await t(r,e.values[n],n);return r},Us=(e,t)=>{if(e===void 0)return 1;if(!Number.isInteger(e)||e<1)throw new RangeError(`${t} batchSize must be a positive integer.`);return e},Hs=e=>xt(Vc,e),Ws=e=>({handlerSource:Xe(e.handler),input:e.input}),Ze=async(e,t,r={},n)=>{if(e.length===0)return[];const s=Xe(t),{batchSize:o,signal:i,...a}=r,c=Us(o,n),l=xt(Kc,a),u=[];for(let h=0;h<e.length;h+=c){const d=Math.min(h+c,e.length),v=[];for(let f=h;f<d;f+=1)v.push({index:f,value:e[f]});u.push({items:v,handlerSource:s})}try{const h=await Promise.all(u.map(v=>l.run(v,i?{signal:i}:void 0))),d=new Array(e.length);for(const v of h)for(const f of v)d[f.index]=f.value;return d}finally{l.terminate()}};async function Jc(e,t={}){if(e.length===0)return[];const r=Hs(t);try{return await Promise.all(e.map(n=>r.run(Ws(n),n.options)))}finally{r.terminate()}}async function Gc(e,t,r={}){if(e.length===0)return[];const n=Us(t,"batchTasks"),s=Hs(r),o=[];try{for(let i=0;i<e.length;i+=n){const a=e.slice(i,i+n),c=await Promise.all(a.map(l=>s.run(Ws(l),l.options)));o.push(...c)}return o}finally{s.terminate()}}async function Fs(e,t,r={}){return Ze(e,t,r,"map")}async function Bs(e,t,r={}){const n=await Ze(e,t,r,"filter"),s=[];for(let o=0;o<e.length;o+=1)n[o]&&(o in e?s.push(e[o]):s.length+=1);return s}async function Qs(e,t,r={}){return e.length===0?!1:(await Ze(e,t,r,"some")).some(Boolean)}async function Vs(e,t,r={}){return e.length===0?!0:(await Ze(e,t,r,"every")).every(Boolean)}async function Ks(e,t,r={}){if(e.length===0)return;const n=(await Ze(e,t,r,"find")).findIndex(Boolean);return n===-1?void 0:e[n]}async function Ys(e,t,r,n={}){return e.length===0?r:Ds(Yc,{initialValue:r,reducerSource:Xe(t),values:e},n)}var et=(e,t={})=>({...e,...t}),Xc=(e,t={})=>({signal:"signal"in t?t.signal:e.signal,timeout:"timeout"in t?t.timeout:e.timeout,transfer:t.transfer}),Zc=class ga{constructor(t,r){this.valuesPromise=t,this.defaults=r}createNext(t){return new ga(this.valuesPromise.then(r=>t(r)),this.defaults)}map(t,r){const n=et(this.defaults,r);return this.createNext(s=>Fs(s,t,n))}filter(t,r){const n=et(this.defaults,r);return this.createNext(s=>Bs(s,t,n))}toArray(){return this.valuesPromise.then(t=>t.slice())}some(t,r){const n=et(this.defaults,r);return this.valuesPromise.then(s=>Qs(s,t,n))}every(t,r){const n=et(this.defaults,r);return this.valuesPromise.then(s=>Vs(s,t,n))}find(t,r){const n=et(this.defaults,r);return this.valuesPromise.then(s=>Ks(s,t,n))}reduce(t,r,n){const s=Xc(this.defaults,n);return this.valuesPromise.then(o=>Ys(o,t,r,s))}};function el(e,t={}){return new Zc(Promise.resolve(e.slice()),t)}var Js=(e,t)=>{ke(()=>{t.state.value=e.state,t.busy.value=e.busy})},Gs=(e,t)=>{ke(()=>{t.state.value=e.state,t.busy.value=e.busy,t.concurrency.value=e.concurrency,t.pending.value=e.pending,t.size.value=e.size})},Xs=e=>({busy:L(e.busy),state:L(e.state)}),Zs=e=>({busy:L(e.busy),concurrency:L(e.concurrency),pending:L(e.pending),size:L(e.size),state:L(e.state)}),zt=(e,t)=>(t(),e.finally(()=>{t(),queueMicrotask(t)}));function tl(e,t={}){const r=_t(e,t),n=Xs(r),s=()=>{Js(r,n)};return{get busy(){return r.busy},get state(){return r.state},busy$:_(n.busy),state$:_(n.state),run(o,i={}){return zt(r.run(o,i),s)},terminate(){r.terminate(),s()}}}function rl(e,t={}){const r=Dt(e,t),n=Xs(r),s=()=>{Js(r,n)};return{get busy(){return r.busy},get state(){return r.state},busy$:_(n.busy),state$:_(n.state),call(o,i,a={}){return zt(r.call(o,i,a),s)},terminate(){r.terminate(),s()}}}function nl(e,t={}){const r=xt(e,t),n=Zs(r),s=()=>{Gs(r,n)};return{get busy(){return r.busy},get concurrency(){return r.concurrency},get pending(){return r.pending},get size(){return r.size},get state(){return r.state},busy$:_(n.busy),concurrency$:_(n.concurrency),pending$:_(n.pending),size$:_(n.size),state$:_(n.state),run(o,i={}){return zt(r.run(o,i),s)},clear(){r.clear(),s()},terminate(){r.terminate(),s()}}}function sl(e,t={}){const r=js(e,t),n=Zs(r),s=()=>{Gs(r,n)};return{get busy(){return r.busy},get concurrency(){return r.concurrency},get pending(){return r.pending},get size(){return r.size},get state(){return r.state},busy$:_(n.busy),concurrency$:_(n.concurrency),pending$:_(n.pending),size$:_(n.size),state$:_(n.state),call(o,i,a={}){return zt(r.call(o,i,a),s)},clear(){r.clear(),s()},terminate(){r.terminate(),s()}}}var ol=(e,t)=>{const{type:r}=t;if(r===String)return e;if(r===Number)return Number(e);if(r===Boolean){const n=e.trim().toLowerCase();return n===""||n==="true"||n==="1"?!0:n==="false"||n==="0"?!1:!!e}if(r===Object||r===Array)try{return JSON.parse(e)}catch{return e}if(typeof r=="function"){const n=r,s=r;if(t.construct===!0)return Reflect.construct(s,[e]);if(t.construct===!1)return n(e);const o=r.prototype!==void 0&&r.prototype!==null,i=(o?Object.getOwnPropertyNames(r.prototype):[]).length>1,a=o&&r.prototype.constructor!==r,c=/^class\s/.test(Function.prototype.toString.call(r));if(i||a||c)try{return Reflect.construct(s,[e])}catch{return n(e)}try{const l=n(e);if(l===void 0&&o)try{return Reflect.construct(s,[e])}catch{return l}return l}catch(l){if(l instanceof TypeError&&/cannot be invoked without 'new'|is not a function/i.test(l.message))return Reflect.construct(s,[e]);throw l}}return e},jt=()=>{try{const e=globalThis;if(typeof e.__BQUERY_DEV__=="boolean")return e.__BQUERY_DEV__;const t=e.process?.env?.NODE_ENV;if(typeof t=="string")return t!=="production";const r=e.process?.versions?.node;if(typeof r=="string"&&r.length>0)return!0;const n=e.process?.release?.name;return n==="node"||n==="io.js"}catch{return!1}},tt;function be(e){const t=tt;return tt=e,t}function eo(){const e=[];return{addDisposer(t){e.push(t)},dispose(){for(const t of e)try{t()}catch(r){jt()&&typeof console<"u"&&typeof console.error=="function"&&console.error("bQuery component: Error disposing scoped resource",r)}e.length=0}}}function il(e){const t=tt;if(!t)throw new Error("bQuery component: useSignal() must be called inside a component lifecycle hook. Avoid calling it directly from render()");const r=L(e);return t.addDisposer(()=>r.dispose()),r}function al(e){const t=tt;if(!t)throw new Error("bQuery component: useComputed() must be called inside a component lifecycle hook. Avoid calling it directly from render()");const r=D(e);return t.addDisposer(()=>r.dispose()),r}function cl(e){const t=tt;if(!t)throw new Error("bQuery component: useEffect() must be called inside a component lifecycle hook. Avoid calling it directly from render()");const r=j(e);return t.addDisposer(r),r}var ll=["slot"],ul=["part","disabled","checked","placeholder","value","rows","cols","readonly","required","maxlength","minlength","max","min","step","pattern","autocomplete","autofocus","for","multiple","selected","wrap"],to=(e,t)=>{const r=[...ll,...t.sanitize?.allowTags??[]],n=[...ul,...t.sanitize?.allowAttributes??[]],s=Object.values(t.signals??{}),i=(l=>l===!1?!1:l==="closed"?"closed":"open")(t.shadow),a=Array.from(new Set([...Object.keys(t.props??{}),...t.observeAttributes??[]]));class c extends HTMLElement{constructor(){super(),this.state={...t.state??{}},this.props={},this.missingRequiredProps=new Set,this.hasMounted=!1,i!==!1?this.renderRootNode=this.attachShadow({mode:i}):this.renderRootNode=this,this.syncProps()}static get observedAttributes(){return a}connectedCallback(){try{if(!this.hasMounted&&this.missingRequiredProps.size>0)return;if(this.hasMounted){this.scope=eo();const u=be(this.scope);try{t.connected?.call(this)}catch(h){this.handleError(h)}finally{be(u)}this.setupSignalSubscriptions(!0);return}this.mount()}catch(u){this.handleError(u)}}mount(){if(this.hasMounted)return;const u=be(this.ensureScope());let h=!1;try{t.beforeMount?.call(this),t.connected?.call(this)}catch(d){h=!0,this.handleError(d)}finally{be(u)}if(h){this.scope?.dispose(),this.scope=void 0;return}this.render(),this.setupSignalSubscriptions(),this.hasMounted=!0}disconnectedCallback(){try{this.signalEffectCleanup?.(),this.signalEffectCleanup=void 0,this.scope?.dispose(),this.scope=void 0,t.disconnected?.call(this)}catch(u){this.handleError(u)}}attributeChangedCallback(u,h,d){try{const v=this.cloneProps();if(this.syncProps(),t.onAttributeChanged){const f=be(this.ensureScope());try{t.onAttributeChanged.call(this,u,h,d)}finally{be(f)}}this.hasMounted?this.render(!0,v,{name:u,oldValue:h,newValue:d}):this.isConnected&&this.missingRequiredProps.size===0&&this.mount()}catch(v){this.handleError(v)}}adoptedCallback(){if(!t.onAdopted)return;const u=be(this.ensureScope());try{t.onAdopted.call(this)}catch(h){this.handleError(h)}finally{be(u)}}handleError(u){t.onError?t.onError.call(this,u):console.error(`bQuery component error in <${e}>:`,u)}ensureScope(){return this.scope??(this.scope=eo())}setState(u,h){this.state[u]=h,this.render(!0,this.cloneProps(),void 0,!1)}getState(u){return this.state[u]}setupSignalSubscriptions(u=!1){if(this.signalEffectCleanup||s.length===0)return;let h=!0;this.signalEffectCleanup=j(()=>{try{for(const v of s)v.value;if(h){if(h=!1,u&&this.hasMounted&&this.isConnected){const v=this.cloneProps();Ae(()=>{this.render(!0,v,void 0,!1)})}return}if(!this.hasMounted||!this.isConnected)return;const d=this.cloneProps();Ae(()=>{this.render(!0,d,void 0,!1)})}catch(d){this.handleError(d)}})}syncProps(){const u=t.props??{};for(const[h,d]of Object.entries(u)){const v=this.getAttribute(h);let f;if(v==null?d.required&&d.default===void 0?(this.missingRequiredProps.add(h),f=void 0):f=d.default??void 0:(this.missingRequiredProps.has(h)&&this.missingRequiredProps.delete(h),f=ol(v,d)),d.validator&&f!==void 0&&!d.validator(f))throw new Error(`bQuery component: validation failed for prop "${h}" with value ${JSON.stringify(f)}`);this.props[h]=f}}cloneProps(){return{...this.props}}render(u=!1,h,d,v=!0){try{if(u&&v&&t.beforeUpdate){if(!h)throw new Error("bQuery component: previous props are required for update renders");if(t.beforeUpdate.call(this,this.props,h)===!1)return}const f=(g,w)=>{this.dispatchEvent(new CustomEvent(g,{detail:w,bubbles:!0,composed:!0}))},p=this.renderRootNode,y=ie(t.render({props:this.props,state:this.state,signals:t.signals??{},emit:f}),{allowTags:r,allowAttributes:n});let b=null;if(t.styles&&(b=p.querySelector("style[data-bquery-component-style]")),p.innerHTML=y,t.styles){const g=b??document.createElement("style");b||g.setAttribute("data-bquery-component-style",""),g.textContent=t.styles,p.prepend(g)}u&&t.updated?.call(this,d)}catch(f){this.handleError(f)}}}return c};function fl(e,t){return to(e,t)}function De(e,t){const r=to(e,t);customElements.get(e)||customElements.define(e,r)}var ro=Symbol("bquery.booleanAttribute"),dl=/^[^\0-\x20"'/>=]+$/,no=e=>{if(typeof e!="object"||e===null)return!1;const t=e;return t[ro]===!0&&typeof t.enabled=="boolean"&&typeof t.name=="string"},so=e=>no(e)?e.enabled?e.name:"":String(e??""),hl={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","`":"&#x60;"},ml=e=>no(e)?e.enabled?e.name:"":so(e).replace(/[&<>"'`]/g,t=>hl[t]),pl=(e,t)=>{if(!dl.test(e))throw new TypeError(`Invalid boolean attribute name: ${e}`);return Object.freeze({[ro]:!0,enabled:!!t,name:e})},_e=(e,...t)=>e.reduce((r,n,s)=>`${r}${n}${so(t[s])}`,""),vl=(e,...t)=>{const r=n=>Ca(n)?Ra(n):ml(n);return wn(e.reduce((n,s,o)=>`${n}${s}${o<t.length?r(t[o]):""}`,""))},Ut=`
86
86
  :host {
87
87
  color: inherit;
88
88
  font: inherit;
89
89
  }
90
- `,Es=`
91
- ${zt}
90
+ `,oo=`
91
+ ${Ut}
92
92
  .field {
93
93
  display: inline-flex;
94
94
  flex-direction: column;
@@ -122,8 +122,8 @@ self.onmessage = async (event) => {
122
122
  color: #94a3b8;
123
123
  cursor: not-allowed;
124
124
  }
125
- `,F=e=>En(e),Ar=new WeakMap,kr=(e,t)=>Ar.get(e)?.[t],Tr=(e,t,r)=>{const n=Ar.get(e)??{};n[t]=r,Ar.set(e,n)},yl=(e,t,r)=>{if(r.label!==t.label||r.type!==t.type||r.placeholder!==t.placeholder||r.name!==t.name||r.disabled!==t.disabled)return!1;const n=e.shadowRoot;if(!n||(n.querySelector(".label")?.textContent??"")!==t.label)return!1;const s=n.querySelector("input.control");return!s||s.type!==t.type||s.placeholder!==t.placeholder||s.name!==t.name||s.disabled!==t.disabled?!1:(s.value!==t.value&&(s.value=t.value),!0)},gl=(e,t,r)=>{if(r.label!==t.label||r.placeholder!==t.placeholder||r.name!==t.name||r.rows!==t.rows||r.disabled!==t.disabled)return!1;const n=e.shadowRoot;if(!n||(n.querySelector(".label")?.textContent??"")!==t.label)return!1;const s=n.querySelector("textarea.control");return!s||s.placeholder!==t.placeholder||s.name!==t.name||Number(s.rows)!==t.rows||s.disabled!==t.disabled?!1:(s.value!==t.value&&(s.value=t.value),!0)},bl=e=>["<textarea",' part="control"',' class="control"',` placeholder="${F(e.placeholder)}"`,` name="${F(e.name)}"`,` rows="${e.rows}"`,e.disabled?" disabled":"",`>${F(e.value)}</textarea>`].join(""),wl=(e={})=>{const t=e.prefix??ae().components?.prefix??"bq",r={button:`${t}-button`,card:`${t}-card`,input:`${t}-input`,textarea:`${t}-textarea`,checkbox:`${t}-checkbox`};return Me(r.button,{props:{label:{type:String,default:""},variant:{type:String,default:"primary"},size:{type:String,default:"md"},type:{type:String,default:"button"},disabled:{type:Boolean,default:!1}},styles:`
126
- ${zt}
125
+ `,F=e=>Cn(e),Tr=new WeakMap,Cr=(e,t)=>Tr.get(e)?.[t],Rr=(e,t,r)=>{const n=Tr.get(e)??{};n[t]=r,Tr.set(e,n)},yl=(e,t,r)=>{if(r.label!==t.label||r.type!==t.type||r.placeholder!==t.placeholder||r.name!==t.name||r.disabled!==t.disabled)return!1;const n=e.shadowRoot;if(!n||(n.querySelector(".label")?.textContent??"")!==t.label)return!1;const s=n.querySelector("input.control");return!s||s.type!==t.type||s.placeholder!==t.placeholder||s.name!==t.name||s.disabled!==t.disabled?!1:(s.value!==t.value&&(s.value=t.value),!0)},gl=(e,t,r)=>{if(r.label!==t.label||r.placeholder!==t.placeholder||r.name!==t.name||r.rows!==t.rows||r.disabled!==t.disabled)return!1;const n=e.shadowRoot;if(!n||(n.querySelector(".label")?.textContent??"")!==t.label)return!1;const s=n.querySelector("textarea.control");return!s||s.placeholder!==t.placeholder||s.name!==t.name||Number(s.rows)!==t.rows||s.disabled!==t.disabled?!1:(s.value!==t.value&&(s.value=t.value),!0)},bl=e=>["<textarea",' part="control"',' class="control"',` placeholder="${F(e.placeholder)}"`,` name="${F(e.name)}"`,` rows="${e.rows}"`,e.disabled?" disabled":"",`>${F(e.value)}</textarea>`].join(""),wl=(e={})=>{const t=e.prefix??ae().components?.prefix??"bq",r={button:`${t}-button`,card:`${t}-card`,input:`${t}-input`,textarea:`${t}-textarea`,checkbox:`${t}-checkbox`};return De(r.button,{props:{label:{type:String,default:""},variant:{type:String,default:"primary"},size:{type:String,default:"md"},type:{type:String,default:"button"},disabled:{type:Boolean,default:!1}},styles:`
126
+ ${Ut}
127
127
  button {
128
128
  appearance: none;
129
129
  border: 0;
@@ -160,7 +160,7 @@ self.onmessage = async (event) => {
160
160
  cursor: not-allowed;
161
161
  opacity: 0.6;
162
162
  }
163
- `,render:({props:n})=>De`
163
+ `,render:({props:n})=>_e`
164
164
  <button
165
165
  part="button"
166
166
  type="${F(n.type)}"
@@ -170,8 +170,8 @@ self.onmessage = async (event) => {
170
170
  >
171
171
  <slot>${F(n.label)}</slot>
172
172
  </button>
173
- `}),Me(r.card,{props:{title:{type:String,default:""},footer:{type:String,default:""},elevated:{type:Boolean,default:!0}},styles:`
174
- ${zt}
173
+ `}),De(r.card,{props:{title:{type:String,default:""},footer:{type:String,default:""},elevated:{type:Boolean,default:!0}},styles:`
174
+ ${Ut}
175
175
  article {
176
176
  background: #fff;
177
177
  border: 1px solid #e2e8f0;
@@ -195,13 +195,13 @@ self.onmessage = async (event) => {
195
195
  footer {
196
196
  margin-top: 0.75rem;
197
197
  }
198
- `,render:({props:n})=>De`
198
+ `,render:({props:n})=>_e`
199
199
  <article part="card" data-elevated="${String(n.elevated)}">
200
200
  ${n.title?`<header part="header">${F(n.title)}</header>`:""}
201
201
  <section part="body"><slot></slot></section>
202
202
  ${n.footer?`<footer part="footer">${F(n.footer)}</footer>`:""}
203
203
  </article>
204
- `}),Me(r.input,{props:{label:{type:String,default:""},type:{type:String,default:"text"},value:{type:String,default:""},placeholder:{type:String,default:""},name:{type:String,default:""},disabled:{type:Boolean,default:!1}},styles:Es,beforeUpdate(n,s){return!yl(this,n,s)},connected(){const n=s=>{const o=s.target;o?.matches("input")&&(s.stopPropagation(),this.setAttribute("value",o.value),this.dispatchEvent(new CustomEvent("input",{detail:{value:o.value},bubbles:!0,composed:!0})))};Tr(this,"__bqueryInputHandler",n),this.shadowRoot?.addEventListener("input",n)},disconnected(){const n=kr(this,"__bqueryInputHandler");n&&this.shadowRoot?.removeEventListener("input",n)},render:({props:n})=>De`
204
+ `}),De(r.input,{props:{label:{type:String,default:""},type:{type:String,default:"text"},value:{type:String,default:""},placeholder:{type:String,default:""},name:{type:String,default:""},disabled:{type:Boolean,default:!1}},styles:oo,beforeUpdate(n,s){return!yl(this,n,s)},connected(){const n=s=>{const o=s.target;o?.matches("input")&&(s.stopPropagation(),this.setAttribute("value",o.value),this.dispatchEvent(new CustomEvent("input",{detail:{value:o.value},bubbles:!0,composed:!0})))};Rr(this,"__bqueryInputHandler",n),this.shadowRoot?.addEventListener("input",n)},disconnected(){const n=Cr(this,"__bqueryInputHandler");n&&this.shadowRoot?.removeEventListener("input",n)},render:({props:n})=>_e`
205
205
  <label part="field" class="field">
206
206
  ${n.label?`<span part="label" class="label">${F(n.label)}</span>`:""}
207
207
  <input
@@ -214,18 +214,18 @@ self.onmessage = async (event) => {
214
214
  ${n.disabled?"disabled":""}
215
215
  />
216
216
  </label>
217
- `}),Me(r.textarea,{props:{label:{type:String,default:""},value:{type:String,default:""},placeholder:{type:String,default:""},name:{type:String,default:""},rows:{type:Number,default:4},disabled:{type:Boolean,default:!1}},styles:`${Es}
217
+ `}),De(r.textarea,{props:{label:{type:String,default:""},value:{type:String,default:""},placeholder:{type:String,default:""},name:{type:String,default:""},rows:{type:Number,default:4},disabled:{type:Boolean,default:!1}},styles:`${oo}
218
218
  textarea.control {
219
219
  min-height: 6rem;
220
220
  resize: vertical;
221
221
  }
222
- `,beforeUpdate(n,s){return!gl(this,n,s)},connected(){const n=s=>{const o=s.target;o?.matches("textarea")&&(s.stopPropagation(),this.setAttribute("value",o.value),this.dispatchEvent(new CustomEvent("input",{detail:{value:o.value},bubbles:!0,composed:!0})))};Tr(this,"__bqueryTextareaHandler",n),this.shadowRoot?.addEventListener("input",n)},disconnected(){const n=kr(this,"__bqueryTextareaHandler");n&&this.shadowRoot?.removeEventListener("input",n)},render:({props:n})=>De`
222
+ `,beforeUpdate(n,s){return!gl(this,n,s)},connected(){const n=s=>{const o=s.target;o?.matches("textarea")&&(s.stopPropagation(),this.setAttribute("value",o.value),this.dispatchEvent(new CustomEvent("input",{detail:{value:o.value},bubbles:!0,composed:!0})))};Rr(this,"__bqueryTextareaHandler",n),this.shadowRoot?.addEventListener("input",n)},disconnected(){const n=Cr(this,"__bqueryTextareaHandler");n&&this.shadowRoot?.removeEventListener("input",n)},render:({props:n})=>_e`
223
223
  <label part="field" class="field">
224
224
  ${n.label?`<span part="label" class="label">${F(n.label)}</span>`:""}
225
225
  ${bl(n)}
226
226
  </label>
227
- `}),Me(r.checkbox,{props:{label:{type:String,default:""},checked:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1}},styles:`
228
- ${zt}
227
+ `}),De(r.checkbox,{props:{label:{type:String,default:""},checked:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1}},styles:`
228
+ ${Ut}
229
229
  label {
230
230
  align-items: center;
231
231
  color: #0f172a;
@@ -241,7 +241,7 @@ self.onmessage = async (event) => {
241
241
  input:disabled {
242
242
  cursor: not-allowed;
243
243
  }
244
- `,connected(){const n=s=>{const o=s.target;o?.matches('input[type="checkbox"]')&&(s.stopPropagation(),o.checked?this.setAttribute("checked","true"):this.removeAttribute("checked"),this.dispatchEvent(new CustomEvent("change",{detail:{checked:o.checked},bubbles:!0,composed:!0})))};Tr(this,"__bqueryCheckboxHandler",n),this.shadowRoot?.addEventListener("change",n)},disconnected(){const n=kr(this,"__bqueryCheckboxHandler");n&&this.shadowRoot?.removeEventListener("change",n)},render:({props:n})=>De`
244
+ `,connected(){const n=s=>{const o=s.target;o?.matches('input[type="checkbox"]')&&(s.stopPropagation(),o.checked?this.setAttribute("checked","true"):this.removeAttribute("checked"),this.dispatchEvent(new CustomEvent("change",{detail:{checked:o.checked},bubbles:!0,composed:!0})))};Rr(this,"__bqueryCheckboxHandler",n),this.shadowRoot?.addEventListener("change",n)},disconnected(){const n=Cr(this,"__bqueryCheckboxHandler");n&&this.shadowRoot?.removeEventListener("change",n)},render:({props:n})=>_e`
245
245
  <label part="label">
246
246
  <input
247
247
  part="control"
@@ -251,12 +251,12 @@ self.onmessage = async (event) => {
251
251
  />
252
252
  <span part="text"><slot>${F(n.label)}</slot></span>
253
253
  </label>
254
- `}),r},Rr=null,le=()=>Rr!==null?Rr:typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches,Sl=e=>{Rr=e},As=e=>typeof e=="string"||typeof e=="number",ks=e=>e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`),_e=(e,t)=>{const r=e.style;if(Array.isArray(t)){const n=t[t.length-1];if(!n)return;for(const[s,o]of Object.entries(n))if(!(s==="offset"||s==="easing"||s==="composite")&&As(o)){const i=s.startsWith("--")?s:ks(s);r.setProperty(i,String(o))}return}for(const[n,s]of Object.entries(t)){if(n==="offset"||n==="easing"||n==="composite")continue;const o=Array.isArray(s)?s[s.length-1]:s;if(As(o)){const i=n.startsWith("--")?n:ks(n);r.setProperty(i,String(o))}}},jt=(e,t)=>{const{keyframes:r,options:n,commitStyles:s=!0,respectReducedMotion:o=!0,onFinish:i}=t;if(o&&le())return s&&_e(e,r),i?.(),Promise.resolve();const a=e;return typeof a.animate!="function"?(s&&_e(e,r),i?.(),Promise.resolve()):new Promise(c=>{const l=a.animate(r,n);let u=!1;const h=()=>{u||(u=!0,s&&(typeof l.commitStyles=="function"?l.commitStyles():_e(e,r)),l.cancel(),i?.(),c())};l.onfinish=h,l.finished&&l.finished.then(h).catch(h)})},ue=e=>Math.min(1,Math.max(0,e)),Ts=e=>ue(e),Rs=e=>ue(e*e),Cs=e=>ue(1-(1-e)*(1-e)),$s=e=>ue(e<.5?2*e*e:1-Math.pow(-2*e+2,2)/2),Os=e=>ue(e*e*e),Ls=e=>ue(1-Math.pow(1-e,3)),Ps=e=>ue(e<.5?4*e*e*e:1-Math.pow(-2*e+2,3)/2),Ns=e=>ue(1+(1.70158+1)*Math.pow(e-1,3)+1.70158*Math.pow(e-1,2)),Is=e=>ue(e===1?1:1-Math.pow(2,-10*e)),El={linear:Ts,easeInQuad:Rs,easeOutQuad:Cs,easeInOutQuad:$s,easeInCubic:Os,easeOutCubic:Ls,easeInOutCubic:Ps,easeOutBack:Ns,easeOutExpo:Is},Cr=e=>{const t=e.getBoundingClientRect();return{top:t.top,left:t.left,width:t.width,height:t.height}},$r=(e,t,r={})=>{const{duration:n=300,easing:s="ease-out",onComplete:o}=r,i=Cr(e);if(i.width===0||i.height===0)return o?.(),Promise.resolve();const a=t.left-i.left,c=t.top-i.top,l=t.width/i.width,u=t.height/i.height;if(a===0&&c===0&&l===1&&u===1)return o?.(),Promise.resolve();const h=e;return typeof h.animate!="function"?(o?.(),Promise.resolve()):(h.style.transform=`translate(${a}px, ${c}px) scale(${l}, ${u})`,h.style.transformOrigin="top left",h.offsetHeight,new Promise(d=>{const p=h.animate([{transform:`translate(${a}px, ${c}px) scale(${l}, ${u})`},{transform:"translate(0, 0) scale(1, 1)"}],{duration:n,easing:s,fill:"forwards"});let f=!1;const m=()=>{f||(f=!0,h.style.transform="",h.style.transformOrigin="",o?.(),d())};p.onfinish=m,p.finished&&p.finished.then(m).catch(m)}))},Al=async(e,t,r={})=>{await Ms(e,t,r)},Ms=async(e,t,r={})=>{const{stagger:n,...s}=r,o=new Map;for(const c of e)o.set(c,Cr(c));t();const i=e.length,a=e.map((c,l)=>{const u=o.get(c);if(!u)return Promise.resolve();const h=n?n(l,i):0;return h>0?new Promise(d=>setTimeout(d,h)).then(()=>$r(c,u,s)):$r(c,u,s)});await Promise.all(a)},kl={fadeIn:(e=0,t=1)=>[{opacity:e},{opacity:t}],fadeOut:(e=1,t=0)=>[{opacity:e},{opacity:t}],slideInUp:(e=16)=>[{opacity:0,transform:`translateY(${e}px)`},{opacity:1,transform:"translateY(0)"}],slideInDown:(e=16)=>[{opacity:0,transform:`translateY(-${e}px)`},{opacity:1,transform:"translateY(0)"}],slideInLeft:(e=16)=>[{opacity:0,transform:`translateX(${e}px)`},{opacity:1,transform:"translateX(0)"}],slideInRight:(e=16)=>[{opacity:0,transform:`translateX(-${e}px)`},{opacity:1,transform:"translateX(0)"}],scaleIn:(e=.95,t=1)=>[{opacity:0,transform:`scale(${e})`},{opacity:1,transform:`scale(${t})`}],scaleOut:(e=1,t=.95)=>[{opacity:1,transform:`scale(${e})`},{opacity:0,transform:`scale(${t})`}],pop:(e=.9,t=1.02,r=1)=>[{opacity:0,transform:`scale(${e})`},{opacity:1,transform:`scale(${t})`,offset:.6},{opacity:1,transform:`scale(${r})`}],rotateIn:(e=6)=>[{opacity:0,transform:`rotate(${e}deg) scale(0.98)`},{opacity:1,transform:"rotate(0deg) scale(1)"}]},Tl=(e,t,r={})=>{const{duration:n=300,easing:s="ease",respectReducedMotion:o=!0,onComplete:i}=r,a=e,c=t;if(typeof window>"u"||typeof document>"u"||typeof a.getBoundingClientRect!="function"||typeof c.getBoundingClientRect!="function"||typeof a.style>"u"||typeof c.style>"u")return i?.(),Promise.resolve();const l=e.getBoundingClientRect(),u=c.style.display,h=c.style.visibility,d=c.style.transform,p=c.style.opacity,f=typeof getComputedStyle=="function"?getComputedStyle(c).display:u||"block",m=f==="none"?"block":u||f||"block",v=()=>{c.style.transform=d,c.style.opacity=p};c.style.visibility="hidden",c.style.display=m;const b=t.getBoundingClientRect();if(c.style.visibility=h,a.style.display="none",f==="none"?c.style.display=m:u==="none"?c.style.display="":c.style.display=u,o&&le())return v(),i?.(),Promise.resolve();const g=l.left-b.left,w=l.top-b.top,S=l.width/(b.width||1),k=l.height/(b.height||1);if(g===0&&w===0&&S===1&&k===1)return v(),i?.(),Promise.resolve();const A=[{transform:`translate(${g}px, ${w}px) scale(${S}, ${k})`,opacity:"0.5"},{transform:"translate(0, 0) scale(1, 1)",opacity:"1"}];return typeof c.animate!="function"?(v(),i?.(),Promise.resolve()):new Promise(E=>{const T=c.animate(A,{duration:n,easing:s,fill:"forwards"});let P=!1;const C=()=>{P||(P=!0,v(),T.cancel(),i?.(),E())};T.onfinish=C,T.finished&&T.finished.then(C).catch(C)})},Rl=(e,t={})=>{if(typeof window>"u"||typeof window.addEventListener!="function"||typeof window.removeEventListener!="function"||typeof requestAnimationFrame!="function"||typeof cancelAnimationFrame!="function")return()=>{};const{speed:r=.5,direction:n="vertical",respectReducedMotion:s=!0}=t,o=e,i=o.style.transform;if(s&&le())return()=>{};let a=!1,c=!1,l=null;const u=()=>{c||(c=!0,window.removeEventListener("scroll",d),l!==null&&(cancelAnimationFrame(l),l=null),a=!1,o.style.transform=i)},h=()=>{if(c)return;if(s&&le()){u();return}const p=window.scrollY,f=window.scrollX;let m=0,v=0;(n==="vertical"||n==="both")&&(v=p*r),(n==="horizontal"||n==="both")&&(m=f*r);const b=`translate3d(${m}px, ${v}px, 0)`;o.style.transform=i?`${i} ${b}`:b},d=()=>{if(!c){if(s&&le()){u();return}a||(a=!0,l=requestAnimationFrame(()=>{l=null,h(),a=!1}))}};return h(),window.addEventListener("scroll",d,{passive:!0}),u},Cl=e=>typeof Element<"u"&&e instanceof Element?[e]:Array.from(e),$l=(e,t)=>{const r=Cl(e);if(!r.length)return()=>{};const{root:n=null,rootMargin:s,threshold:o,once:i=!0,onEnter:a,...c}=t;if(typeof IntersectionObserver>"u")return r.forEach(u=>{a?.(u),jt(u,c)}),()=>{};const l=new IntersectionObserver(u=>{u.forEach(h=>{if(!h.isIntersecting)return;const d=h.target;a?.(d),jt(d,c),i&&l.unobserve(d)})},{root:n,rootMargin:s,threshold:o});return r.forEach(u=>l.observe(u)),()=>l.disconnect()},Ol={stiffness:100,damping:10,mass:1,precision:.01},Ll=(e,t={})=>{const{stiffness:r,damping:n,mass:s,precision:o}={...Ol,...t};let i=e,a=0,c=e,l=null,u=null,h=null;const d=new Set,p=()=>{for(const m of d)m(i)},f=m=>{const v=h!==null?(m-h)/1e3:.016666666666666666,b=Math.min(v,1/30);h=m;const g=i-c,w=(-r*g+-n*a)/s;if(a+=w*b,i+=a*b,p(),Math.abs(a)<o&&Math.abs(g)<o){i=c,a=0,l=null,p(),u?.(),u=null;return}l=requestAnimationFrame(f)};return{to(m){return c=m,l!==null&&cancelAnimationFrame(l),u?.(),h=null,new Promise(v=>{u=v,l=requestAnimationFrame(f)})},current(){return i},stop(){l!==null&&(cancelAnimationFrame(l),l=null),a=0,h=null,u?.(),u=null},onChange(m){return d.add(m),()=>d.delete(m)}}},Pl={gentle:{stiffness:80,damping:15},snappy:{stiffness:200,damping:20},bouncy:{stiffness:300,damping:8},stiff:{stiffness:400,damping:30}},Nl=(e,t={})=>{const{start:r=0,from:n="start",easing:s}=t;return(o,i=0)=>{const a=typeof n=="number"?n:n==="center"?(i-1)/2:n==="end"?i-1:0,c=Math.abs(o-a),l=i>1?Math.max(a,i-1-a):1,u=l===0?0:c/l;return r+(s?s(u)*l:c)*e}},Or=e=>{if(typeof e=="number")return e;if(typeof e=="string"){const t=e.trim();if(t.endsWith("ms")){const n=Number.parseFloat(t.slice(0,-2));return Number.isFinite(n)?n:0}if(t.endsWith("s")){const n=Number.parseFloat(t.slice(0,-1));return Number.isFinite(n)?n*1e3:0}const r=Number.parseFloat(t);return Number.isFinite(r)?r:0}return 0},Il=(e,t)=>{if(typeof e=="number")return e;if(typeof e=="string"){const r=/^([+-])=(\d+(?:\.\d+)?)$/.exec(e);if(r){const n=Number.parseFloat(r[2]);return Number.isFinite(n)?r[1]==="+"?t+n:t-n:t}}return t},Ml=e=>{const t=Or(e?.duration),r=Or(e?.endDelay),n=e?.iterations??1;return n===1/0?Number.MAX_SAFE_INTEGER:t*Math.max(0,n)+r},Ds=e=>{let t=0;return e.map(r=>{const n=Il(r.at,t),s=Or(r.options?.delay),o=Math.max(0,n+s),i=Ml(r.options),a=o+i;return t=Math.max(t,a),{step:r,start:o,end:a,duration:i}})},Dl=async(e,t={})=>{const{stagger:r,onFinish:n}=t,s=e.length;for(let o=0;o<e.length;o+=1){const i=e[o],a=r?r(o,s):0;a>0&&await new Promise(c=>setTimeout(c,a)),await jt(i.target,i)}n?.()},_l=(e=[],t={})=>{const r=[...e],n=new Set;let s=[],o=0,i=!1,a=!1;const{commitStyles:c=!0,respectReducedMotion:l=!0,onFinish:u}=t,h=()=>{if(!a){if(a=!0,c)for(const p of s){const{animation:f,step:m}=p;typeof f.commitStyles=="function"?f.commitStyles():_e(m.target,m.keyframes),f.cancel()}n.forEach(p=>p()),u?.()}},d=()=>{s.forEach(({animation:f})=>f.cancel()),s=[],a=!1;const p=Ds(r);if(o=p.length?Math.max(...p.map(f=>f.end)):0,l&&le()){c&&p.forEach(({step:f})=>_e(f.target,f.keyframes)),i=!0;return}if(p.some(({step:f})=>typeof f.target.animate!="function")){c&&p.forEach(({step:f})=>_e(f.target,f.keyframes)),i=!0;return}i=!1,s=p.map(({step:f,start:m})=>{const{delay:v,...b}=f.options??{};return{animation:f.target.animate(f.keyframes,{...b,delay:m,fill:b.fill??"both"}),step:f,start:m}})};return{add(p){r.push(p)},duration(){if(!r.length)return 0;if(!s.length){const p=Ds(r);return Math.max(...p.map(f=>f.end))}return o},async play(){if(d(),i||s.length===0){h();return}const p=s.map(f=>f.animation.finished.catch(()=>{}));await Promise.all(p),h()},pause(){i||s.forEach(({animation:p})=>p.pause())},resume(){i||s.forEach(({animation:p})=>p.play())},stop(){s.forEach(({animation:p})=>p.cancel()),s=[],i=!1},seek(p){i||s.forEach(({animation:f})=>{f.currentTime=p})},onFinish(p){return n.add(p),()=>n.delete(p)}}},_s=e=>(e??[]).map(t=>t.trim()).filter(t=>t.length>0),xl=async e=>{const t=ae().transitions,r=typeof e=="function"?{update:e,classes:t?.classes,types:t?.types,skipOnReducedMotion:t?.skipOnReducedMotion}:{...e,classes:e.classes??t?.classes,types:e.types??t?.types,skipOnReducedMotion:e.skipOnReducedMotion??t?.skipOnReducedMotion},n=r.update;if(typeof document>"u"){await n();return}const s=document,o=document.documentElement,i=_s(r.classes),a=_s(r.types);if(!s.startViewTransition||r.skipOnReducedMotion&&le()){await n(),r.onFinish?.();return}i.forEach(c=>o.classList.add(c));try{const c=s.startViewTransition(()=>n()),l=c.types;if(l)for(const u of a)l.add(u);await c.ready,r.onReady?.(),await c.finished,r.onFinish?.()}finally{i.forEach(c=>o.classList.remove(c))}},ql=(e,t,r={})=>{const{speed:n=50,delay:s=0,cursor:o=!1,cursorChar:i="|",loop:a=!1,loopDelay:c=1e3,respectReducedMotion:l=!0,onComplete:u}=r;if(typeof document>"u")return{stop:()=>{},done:Promise.resolve()};const h=e;let d=!1,p=null,f=null,m=null,v=null;const b=()=>{if(!o)return;f=document.createElement("span"),f.setAttribute("aria-hidden","true"),f.textContent=i,h.appendChild(f);let S=!0;m=setInterval(()=>{f&&(S=!S,f.style.opacity=S?"1":"0")},530)},g=()=>{m!==null&&(clearInterval(m),m=null),f&&f.parentNode&&(f.parentNode.removeChild(f),f=null)},w=()=>{d||(d=!0,p!==null&&(clearTimeout(p),p=null),g(),v?.(),v=null)};return l&&le()?(h.textContent=t,u?.(),{stop:()=>{},done:Promise.resolve()}):{stop:w,done:new Promise(S=>{v=S;const k=()=>{let A=0;h.textContent="",b();const E=document.createTextNode("");f?h.insertBefore(E,f):h.appendChild(E);const T=()=>{d||(A<t.length?(E.data=t.slice(0,A+1),A++,p=setTimeout(T,n)):(u?.(),a&&!d?p=setTimeout(()=>{d||(g(),k())},c):(g(),S(),v=null)))};p=setTimeout(T,s)};k()})}},zl=class{constructor(e){this.bucketName=e,this.dbPromise=null,this.storeName="blobs"}openDB(){if(this.dbPromise)return this.dbPromise;const e=`bquery-bucket-${this.bucketName}`;return this.dbPromise=new Promise((t,r)=>{const n=indexedDB.open(e,1);n.onupgradeneeded=()=>{const s=n.result;s.objectStoreNames.contains(this.storeName)||s.createObjectStore(this.storeName)},n.onsuccess=()=>t(n.result),n.onerror=()=>r(n.error)}),this.dbPromise}async withStore(e,t){const r=await this.openDB();return new Promise((n,s)=>{const o=t(r.transaction(this.storeName,e).objectStore(this.storeName));o.onsuccess=()=>n(o.result),o.onerror=()=>s(o.error)})}async put(e,t){await this.withStore("readwrite",r=>r.put(t,e))}async get(e){return await this.withStore("readonly",t=>t.get(e))??null}async remove(e){await this.withStore("readwrite",t=>t.delete(e))}async keys(){return(await this.withStore("readonly",e=>e.getAllKeys())).map(e=>String(e))}},jl={async open(e){return new zl(e)}},Ul=class{constructor(e){this.cache=e}async add(e){await this.cache.add(e)}async addAll(e){await this.cache.addAll(e)}async put(e,t){await this.cache.put(e,t)}async match(e){return this.cache.match(e)}async remove(e){return this.cache.delete(e)}async keys(){return(await this.cache.keys()).map(e=>e.url)}},Hl={isSupported(){return"caches"in window},async open(e){if(!this.isSupported())throw new Error("bQuery: Cache Storage API not supported");return new Ul(await caches.open(e))},async delete(e){return this.isSupported()?caches.delete(e):!1},async keys(){return this.isSupported()?caches.keys():[]}},Wl=e=>{if(typeof document>"u")return null;const t=`${encodeURIComponent(e)}=`,r=document.cookie?document.cookie.split(";"):[];for(const n of r){const s=n.trim();if(s.startsWith(t)){const o=s.slice(t.length);try{return decodeURIComponent(o)}catch{return o}}}return null},Fl=e=>{const t=e.trim();return t.startsWith("{")||t.startsWith("[")||t.startsWith('"')},Bl=(e,t)=>{if(typeof document>"u")return;const r=[`${encodeURIComponent(e)}=`,"Expires=Thu, 01 Jan 1970 00:00:00 GMT"];t.path&&r.push(`Path=${t.path}`),t.domain&&r.push(`Domain=${t.domain}`),t.sameSite&&r.push(`SameSite=${t.sameSite}`),t.secure&&r.push("Secure"),document.cookie=r.join("; ")},Ql=(e,t,r)=>{if(typeof document>"u")return;const n=r.serialize?r.serialize(t):typeof t=="string"?t:JSON.stringify(t),s=[`${encodeURIComponent(e)}=${encodeURIComponent(n)}`];r.path&&s.push(`Path=${r.path}`),r.domain&&s.push(`Domain=${r.domain}`),typeof r.maxAge=="number"&&s.push(`Max-Age=${r.maxAge}`),r.expires&&s.push(`Expires=${r.expires.toUTCString()}`),r.sameSite&&s.push(`SameSite=${r.sameSite}`),r.secure&&s.push("Secure"),document.cookie=s.join("; ")},Vl=(e,t={})=>{const r=ae().cookies,n={path:r?.path??"/",sameSite:r?.sameSite??"Lax",secure:r?.secure??!1,watch:!0,...t};n.sameSite==="None"&&(n.secure=!0);const s=Wl(e);let o=n.defaultValue??null;if(s!==null)try{o=n.deserialize?n.deserialize(s):Fl(s)?JSON.parse(s):s??o}catch(c){console.warn(`bQuery: Failed to deserialize cookie "${e}", using raw string value`,c),o=s??o}const i=L(o);if(typeof document>"u"||n.watch===!1)return i;let a=!1;return j(()=>{const c=i.value;if(!a){a=!0;return}if(c==null){Bl(e,n);return}Ql(e,c,n)}),i},Kl={isSupported(){return"Notification"in window},getPermission(){return this.isSupported()?Notification.permission:"denied"},async requestPermission(){return this.isSupported()?Notification.permission==="granted"?"granted":Notification.permission==="denied"?"denied":Notification.requestPermission():"denied"},send(e,t){return this.isSupported()?Notification.permission!=="granted"?(console.warn("bQuery: Notification permission not granted"),null):new Notification(e,t):(console.warn("bQuery: Notifications not supported in this browser"),null)}},Yl=["position:absolute","width:1px","height:1px","padding:0","margin:-1px","overflow:hidden","clip:rect(0, 0, 0, 0)","white-space:nowrap","border:0"].join(";"),Jl=(e={})=>{const t=ae().announcer,r={politeness:t?.politeness??"polite",atomic:t?.atomic??!0,delay:t?.delay??16,clearDelay:t?.clearDelay??1e3,...e},n=L("");if(typeof document>"u")return{element:null,message:n,announce(m){n.value=m},clear(){n.value=""},destroy(){n.value=""}};const s=r.id?document.getElementById(r.id):null,o=s??document.createElement("div"),i=!s;if(r.id&&(o.id=r.id),r.className&&(o.className=r.className),o.setAttribute("aria-live",r.politeness),o.setAttribute("aria-atomic",String(r.atomic)),o.setAttribute("role",r.politeness==="assertive"?"alert":"status"),o.setAttribute("data-bquery-announcer","true"),o.getAttribute("style")||o.setAttribute("style",Yl),i){const m=r.container??document.body??document.documentElement;if(!m)return{element:null,message:n,announce(v){n.value=v},clear(){n.value=""},destroy(){n.value=""}};m.appendChild(o)}const a=j(()=>{o.textContent=n.value});let c,l,u=!1;const h=()=>{c&&(clearTimeout(c),c=void 0),l&&(clearTimeout(l),l=void 0)};return{element:o,message:n,announce:(m,v={})=>{if(u)return;const b=v.politeness??r.politeness,g=v.delay??r.delay,w=v.clearDelay??r.clearDelay;h(),o.setAttribute("aria-live",b),o.setAttribute("role",b==="assertive"?"alert":"status"),n.value="",c=setTimeout(()=>{u||(n.value=m,w>0&&(l=setTimeout(()=>{u||(n.value="")},w)))},g)},clear:()=>{u||(h(),n.value="")},destroy:()=>{u||(u=!0,h(),n.value="",a(),i&&o.remove())}}},xs=(e,t)=>{const r=new Map;for(const[n,s]of Object.entries(t))r.set(n,e.getAttribute(n)),e.setAttribute(n,s);return()=>{for(const[n,s]of r.entries())s==null?e.removeAttribute(n):e.setAttribute(n,s)}},qs=(e,t)=>{const r=document.createElement(e);r.setAttribute("data-bquery-page-meta","true");for(const[n,s]of Object.entries(t))s!==void 0&&r.setAttribute(n,s);return r},Gl=e=>{if(typeof document>"u")return()=>{};const t=ae().pageMeta,r=e.title?t?.titleTemplate?t.titleTemplate(e.title):e.title:void 0,n=[],s=[],o=document.title;r!==void 0&&(document.title=r);const i=[...e.meta??[]];e.description&&i.unshift({name:"description",content:e.description});for(const a of i){const c=qs("meta",{name:a.name,property:a.property,"http-equiv":a.httpEquiv,content:a.content});document.head.appendChild(c),n.push(c)}for(const a of e.link??[]){const c=qs("link",{rel:a.rel,href:a.href,type:a.type,media:a.media,crossorigin:a.crossOrigin});document.head.appendChild(c),n.push(c)}return e.htmlAttributes&&s.push(xs(document.documentElement,e.htmlAttributes)),e.bodyAttributes&&document.body&&s.push(xs(document.body,e.bodyAttributes)),()=>{document.title=o;for(const a of s.reverse())a();for(const a of n)a.remove()}},zs=class{constructor(e){this.storage=e}async get(e){const t=this.storage.getItem(e);if(t===null)return null;try{return JSON.parse(t)}catch{return t}}async set(e,t){const r=typeof t=="string"?t:JSON.stringify(t);this.storage.setItem(e,r)}async remove(e){this.storage.removeItem(e)}async clear(){this.storage.clear()}async keys(){const e=[];for(let t=0;t<this.storage.length;t++){const r=this.storage.key(t);r!==null&&e.push(r)}return e}},Xl=class extends zs{constructor(){super(localStorage)}},Zl=class extends zs{constructor(){super(sessionStorage)}},eu=class{constructor(e){this.options=e,this.dbPromise=null}openDB(){return this.dbPromise?this.dbPromise:(this.dbPromise=new Promise((e,t)=>{const r=indexedDB.open(this.options.name,this.options.version??1);r.onupgradeneeded=()=>{const n=r.result;n.objectStoreNames.contains(this.options.store)||n.createObjectStore(this.options.store)},r.onsuccess=()=>e(r.result),r.onerror=()=>t(r.error)}),this.dbPromise)}async withStore(e,t){const r=await this.openDB();return new Promise((n,s)=>{const o=t(r.transaction(this.options.store,e).objectStore(this.options.store));o.onsuccess=()=>n(o.result),o.onerror=()=>s(o.error)})}async get(e){return await this.withStore("readonly",t=>t.get(e))??null}async set(e,t){await this.withStore("readwrite",r=>r.put(t,e))}async remove(e){await this.withStore("readwrite",t=>t.delete(e))}async clear(){await this.withStore("readwrite",e=>e.clear())}async keys(){return(await this.withStore("readonly",e=>e.getAllKeys())).map(e=>String(e))}},tu={local(){return new Xl},session(){return new Zl},indexedDB(e){return new eu(e)}},js=null,fe=L({path:"",params:{},query:{},matched:null,hash:""}),Us=D(()=>fe.value),rt=L(0),Ut=L(!1),ru=_(Ut),Hs=()=>{rt.value===0&&(Ut.value=!0),rt.value+=1},Ws=()=>{const e=Math.max(0,rt.value-1);rt.value=e,e===0&&(Ut.value=!1)},nu=()=>{rt.value=0,Ut.value=!1},ke=()=>js,Fs=e=>{js=e},nt=async(e,t={})=>{const r=ke();if(!r)throw new Error("bQuery router: No router initialized. Call createRouter() first.");await r[t.replace?"replace":"push"](e)},su=()=>{const e=ke();e?e.back():history.back()},ou=()=>{const e=ke();e?e.forward():history.forward()},iu="active",au=e=>e.split(/\s+/).map(t=>t.trim()).filter(t=>t.length>0),cu=typeof HTMLElement<"u"?HTMLElement:class{},Bs=class extends cu{constructor(...e){super(...e),this._cleanup=null,this._trackedActiveClasses=new Map,this._handleClick=t=>{t instanceof MouseEvent&&(t.defaultPrevented||t.button===0&&(t.ctrlKey||t.metaKey||t.shiftKey||t.altKey||(t.preventDefault(),this._navigate())))},this._handleKeydown=t=>{t instanceof KeyboardEvent&&t.key==="Enter"&&(t.preventDefault(),this._navigate())}}static get observedAttributes(){return["to","replace","exact","active-class"]}get to(){const e=this.getAttribute("to");return e==null||e.trim()===""?"/":e}set to(e){this.setAttribute("to",e)}get replace(){return this.hasAttribute("replace")}set replace(e){e?this.setAttribute("replace",""):this.removeAttribute("replace")}get exact(){return this.hasAttribute("exact")}set exact(e){e?this.setAttribute("exact",""):this.removeAttribute("exact")}get activeClass(){return this.getAttribute("active-class")??iu}set activeClass(e){this.setAttribute("active-class",e)}connectedCallback(){this.getAttribute("role")||this.setAttribute("role","link"),this.hasAttribute("tabindex")||this.setAttribute("tabindex","0"),this.addEventListener("click",this._handleClick),this.addEventListener("keydown",this._handleKeydown),this._setupActiveTracking()}disconnectedCallback(){this.removeEventListener("click",this._handleClick),this.removeEventListener("keydown",this._handleKeydown),this._cleanup&&(this._cleanup(),this._cleanup=null),this._clearTrackedActiveClasses()}attributeChangedCallback(e,t,r){(e==="to"||e==="exact"||e==="active-class")&&this.isConnected&&this._setupActiveTracking()}_setupActiveTracking(){this._cleanup&&(this._cleanup(),this._cleanup=null),this._clearTrackedActiveClasses();const e=this.to,t=this.exact,r=au(this.activeClass);this._trackedActiveClasses=new Map(r.map(n=>[n,this.classList.contains(n)])),this._cleanup=j(()=>{const n=fe.value.path,s=t?n===e:e==="/"?n==="/":n===e||n.startsWith(e.endsWith("/")?e:e+"/");for(const o of r){const i=this._trackedActiveClasses.get(o)??!1;this.classList.toggle(o,s||i)}s?this.setAttribute("aria-current","page"):this.removeAttribute("aria-current")})}_clearTrackedActiveClasses(){for(const[e,t]of this._trackedActiveClasses)this.classList.toggle(e,t);this._trackedActiveClasses.clear()}_navigate(){const e=this.to;e&&ke()&&nt(e,{replace:this.replace}).catch(t=>{console.error("bq-link: Navigation failed:",t)})}},lu=()=>{typeof HTMLElement<"u"&&typeof customElements<"u"&&!customElements.get("bq-link")&&customElements.define("bq-link",Bs)},uu=(e,t={})=>r=>{r.preventDefault(),nt(e,t).catch(n=>{console.error("Navigation failed:",n)})},fu=e=>{const t=e??(typeof document<"u"?document.body:null);if(!t)return()=>{};const r=n=>{if(!(n instanceof MouseEvent)||n.defaultPrevented||n.button!==0||n.ctrlKey||n.metaKey||n.shiftKey||n.altKey||typeof Element>"u"||!(n.target instanceof Element))return;const s=n.target.closest("a");if(!s||!(s instanceof(s.ownerDocument.defaultView?.HTMLAnchorElement??HTMLAnchorElement))||s.target||s.hasAttribute("download")||typeof window>"u"||s.origin!==window.location.origin)return;const o=ke();if(!o){n.preventDefault(),nt(s.pathname+s.search+s.hash).catch(l=>{console.error("Navigation failed:",l)});return}const i=o.base,a=o.hash;let c;if(a&&s.hash&&s.hash.startsWith("#/"))c=s.hash.slice(1);else{let l=s.pathname;i&&i!=="/"&&l.startsWith(i)&&(l=l.slice(i.length)||"/"),c=l+s.search+s.hash}n.preventDefault(),nt(c).catch(l=>{console.error("Navigation failed:",l)})};return t.addEventListener("click",r),()=>t.removeEventListener("click",r)},Qs=e=>{const t={};return new URLSearchParams(e).forEach((r,n)=>{if(N(n))return;const s=t[n];s===void 0?t[n]=r:Array.isArray(s)?s.push(r):t[n]=[s,r]}),t},du=128,Vs=new Map,Ks=new Map,Ys=(e,t,r)=>{if(e.has(t)&&e.delete(t),e.set(t,r),e.size<=du)return;const n=e.keys().next().value;n!==void 0&&e.delete(n)},hu=e=>{const t=[];let r=!1;for(let n=0;n<e.length;n++){const s=e[n];if(s==="\\"&&n+1<e.length){n++;continue}if(s==="["&&!r){r=!0;continue}if(s==="]"&&r){r=!1;continue}if(!r){if(s==="("){t.push(!1);continue}if(s===")"){const o=t.pop()??!1,i=e[n+1];if(o&&(i==="+"||i==="*"||i==="?"||i==="{"))return!0;o&&t.length>0&&(t[t.length-1]=!0);continue}if(t.length>0){if(s==="?"&&n>0&&e[n-1]==="(")continue;(s==="+"||s==="*"||s==="?"||s==="{")&&(t[t.length-1]=!0)}}}return!1},mu=e=>{let t="",r=!1;for(let n=0;n<e.length;n++){const s=e[n];if(s==="\\"&&n+1<e.length){if(!r&&e[n+1]>="1"&&e[n+1]<="9")throw new Error(`bQuery router: Route constraints cannot use backreferences: "${e}".`);if(!r&&e[n+1]==="k"&&e[n+2]==="<")throw new Error(`bQuery router: Route constraints cannot use backreferences: "${e}".`);t+=s+e[n+1],n++;continue}if(s==="["&&!r){r=!0,t+=s;continue}if(s==="]"&&r){r=!1,t+=s;continue}if(!r&&s==="("){if(n+1<e.length&&e[n+1]==="?"){if(e[n+2]==="<"){if(e[n+3]==="="||e[n+3]==="!"){t+="(";continue}const o=e.indexOf(">",n+3);if(o===-1)throw new Error(`bQuery router: Invalid route constraint named capture group: "${e}".`);t+="(?:",n=o;continue}t+="(";continue}t+="(?:";continue}t+=s}return t},Lr=e=>{const t=Vs.get(e);if(t!==void 0)return t;const r=mu(e);return Ys(Vs,e,r),r},Js=e=>{const t=Lr(e),r=Ks.get(t);if(r)return r;if(hu(t))throw new Error(`bQuery router: Route constraint contains a potentially catastrophic (ReDoS) pattern. Nested quantifiers are not allowed: "${e}".`);try{const n=new RegExp(`^(?:${t})$`);return Ys(Ks,t,n),n}catch(n){throw n instanceof SyntaxError?new Error(`bQuery router: Invalid route constraint regex "${e}": ${n.message}`):n}},st=e=>e!==void 0&&(e>="a"&&e<="z"||e>="A"&&e<="Z"||e==="_"),Gs=e=>st(e)||e!==void 0&&e>="0"&&e<="9",Xs=(e,t)=>{let r=1,n="",s=t+1,o=!1;for(;s<e.length;){const i=e[s];if(i==="\\"&&s+1<e.length){n+=i+e[s+1],s+=2;continue}if(i==="["&&!o)o=!0;else if(i==="]"&&o)o=!1;else if(!o&&i==="(")r++;else if(!o&&i===")"&&(r--,r===0))return{constraint:n,endIndex:s+1};n+=i,s++}return null},pu=(e,t)=>{const r=Xs(e,t);if(!r)throw new Error(`bQuery router: Invalid route param constraint syntax in path "${e}" at index ${t}.`);return r},Zs=new Set,eo=(e,t)=>{if(e[t]!==":"||!st(e[t+1]))return null;let r=t+2;for(;r<e.length&&Gs(e[r]);)r++;let n=r,s;if(e[r]==="("){const o=pu(e,r);s=o.constraint,n=o.endIndex}return{name:e.slice(t+1,r),constraint:s,nextIndex:n}},vu=e=>{if(!Zs.has(e)){for(let t=0;t<e.length;){if(e[t]===":"&&st(e[t+1])){const r=eo(e,t);r?.constraint&&Lr(r.constraint),t=r?.nextIndex??t+1;continue}t++}Zs.add(e)}},yu=(e,t)=>{const r=e.indexOf("/",t);return r===-1?e.length:r},to=(e,t)=>{let r=t;for(;r<e.length&&!(e[r]==="*"||e[r]===":"&&st(e[r+1]));)r++;return e.slice(t,r)},ro=(e,t,r,n)=>{const s=[];let o=t;for(;o<=r;){const i=e.indexOf(n,o);if(i===-1||i>r)break;s.push(i),o=i+1}return s.reverse()},gu=(e,t)=>{const r=new Map,n=(s,o)=>{const i=`${s}:${o}`;if(r.has(i))return r.get(i)??null;if(s===e.length){const u=o===t.length?{}:null;return r.set(i,u),u}const a=e[s];if(a==="*"){if(s===e.length-1){const p={};return r.set(i,p),p}const u=to(e,s+1),h=u.length>0?ro(t,o,t.length,u):null,d=(h?p=>{for(const f of h){const m=p(f);if(m)return m}return null}:p=>{for(let f=t.length;f>=o;f--){const m=p(f);if(m)return m}return null})(p=>{const f=n(s+1,p);return f?(r.set(i,f),f):null});return d||(r.set(i,null),null)}const c=eo(e,s);if(c){const u=c.constraint?Js(c.constraint):void 0,h=c.constraint?t.length:yu(t,o),d=to(e,c.nextIndex),p=d.length>0?ro(t,o,h,d):null,f=(p?m=>{for(const v of p){if(v<=o)continue;const b=m(v);if(b)return b}return null}:m=>{for(let v=h;v>o;v--){const b=m(v);if(b)return b}return null})(m=>{const v=t.slice(o,m);if(u&&!u.test(v))return null;const b=n(c.nextIndex,m);if(b){const g={[c.name]:v,...b};return r.set(i,g),g}return null});return f||(r.set(i,null),null)}if(o>=t.length||a!==t[o])return r.set(i,null),null;const l=n(s+1,o+1);return r.set(i,l),l};return n(0,0)},no=(e,t)=>{for(const r of t){vu(r.path);const n=gu(r.path,e);if(n)return{matched:r,params:n}}return null},Ht=(e,t,r,n)=>{const s=no(e,n);return{path:e,params:s?.params??{},query:Qs(t),matched:s?.matched??null,hash:r.replace(/^#/,"")}},so=(e,t="")=>{const r=[];for(const n of e){const s=n.path==="*"?"*":`${t}${n.path}`.replace(/\/+/g,"/");r.push({...n,path:s}),n.children&&r.push(...so(n.children,s))}return r},bu=(e,t={})=>{const r=ke();if(!r)throw new Error("bQuery router: No router initialized.");const n=r.routes.find(o=>o.name===e);if(!n)throw new Error(`bQuery router: Route "${e}" not found.`);let s="";for(let o=0;o<n.path.length;){if(n.path[o]===":"&&st(n.path[o+1])){let i=o+2;for(;i<n.path.length&&Gs(n.path[i]);)i++;let a=i,c=null;if(n.path[i]==="("){const h=Xs(n.path,i);if(!h)throw new Error(`bQuery router: Invalid constraint syntax in path "${n.path}" for route "${e}".`);c=h.constraint,a=h.endIndex}const l=n.path.slice(o+1,i),u=t[l];if(u===void 0)throw new Error(`bQuery router: Missing required param "${l}" for route "${e}".`);if(c&&!Js(c).test(u))throw new Error(`bQuery router: Param "${l}" with value "${u}" does not satisfy the route constraint "${c}" for route "${e}".`);s+=encodeURIComponent(u),o=a;continue}s+=n.path[o],o++}return s},wu=(e,t=!1)=>{const r=fe.value.path;return t?r===e:r.startsWith(e)},Su=(e,t=!1)=>D(()=>{const r=fe.value.path;return t?r===e:r.startsWith(e)}),Eu=100,Au=e=>{const t={};for(const[r,n]of Object.entries(e))N(r)||(t[r]=n);return t},ku=e=>{const t=ke();t&&t.destroy();const{routes:r,base:n="",hash:s=!1,scrollRestoration:o=!1}=e,i=[],a=[],c=so(r),l=new Map;let u="0",h=0,d=null;if(o&&typeof history<"u"&&"scrollRestoration"in history){d=history.scrollRestoration,history.scrollRestoration!=="manual"&&(history.scrollRestoration="manual");const E=history.state&&typeof history.state=="object"?history.state:{};if(typeof E.__bqScrollKey!="string"){const T=s?window.location.hash||"#/":`${window.location.pathname}${window.location.search}${window.location.hash}`;history.replaceState({...E,__bqScrollKey:u},"",T)}}const p=()=>history.state&&history.state.__bqScrollKey||u,f=()=>`${Date.now()}-${h++}`,m=(E=p())=>{if(o)for(l.has(E)&&l.delete(E),l.set(E,{x:window.scrollX,y:window.scrollY});l.size>Eu;){const T=l.keys().next().value;if(T===void 0)break;l.delete(T)}},v=(E=p())=>{if(!o)return;const T=l.get(E);T?window.scrollTo(T.x,T.y):window.scrollTo(0,0)},b=()=>{const E=history.state&&typeof history.state=="object"?{...history.state}:{};return o&&(E.__bqScrollKey=u),E},g=()=>{if(s){const[T,P=""]=(window.location.hash.slice(1)||"/").split("#"),[C,$=""]=T.split("?");return{pathname:C,search:$?`?${$}`:"",hash:P?`#${P}`:""}}let E=window.location.pathname;return n&&(E===n||E.startsWith(n+"/"))&&(E=E.slice(n.length)||"/"),{pathname:E,search:window.location.search,hash:window.location.hash}},w=()=>{const{pathname:E,search:T,hash:P}=g();fe.value=Ht(E,T,P,c)},S=async(E,T,P=new Set)=>{Hs();try{const{pathname:C,search:$,hash:R}=g(),O=Ht(C,$,R,c),I=new URL(E,window.location.origin),x=`${I.pathname}${I.search}${I.hash}`;if(P.has(x))throw new Error(`bQuery router: redirect loop detected for path "${x}"`);P.add(x);const W=Ht(I.pathname,I.search,I.hash,c);if(W.matched?.redirectTo){await S(W.matched.redirectTo,T,P);return}if(W.matched?.beforeEnter&&await W.matched.beforeEnter(W,O)===!1)return;for(const Et of i)if(await Et(W,O)===!1)return;m();const q=o?p():void 0,V=T==="replaceState"&&q?q:f(),ve=s?`#${E}`:`${n}${E}`,We=o&&history.state&&typeof history.state=="object"?Au(history.state):{},on=o?{...We,__bqScrollKey:V}:{};history[T](on,"",ve),u=V,w(),o&&T==="pushState"&&window.scrollTo(0,0);for(const Et of a)Et(fe.value,O)}finally{Ws()}},k=async E=>{Hs();try{const{pathname:T,search:P,hash:C}=g(),$=fe.value,R=Ht(T,P,C,c);if(R.matched?.redirectTo){await S(R.matched.redirectTo,"replaceState");return}if(R.matched?.beforeEnter&&await R.matched.beforeEnter(R,$)===!1){const O=new URLSearchParams(Object.entries($.query).flatMap(([q,V])=>Array.isArray(V)?V.map(ve=>[q,ve]):[[q,V]])).toString(),I=O?`?${O}`:"",x=$.hash?`#${$.hash}`:"",W=s?`#${$.path}${I}${x}`:`${n}${$.path}${I}${x}`;history.replaceState(b(),"",W);return}for(const O of i)if(await O(R,$)===!1){const I=new URLSearchParams(Object.entries($.query).flatMap(([V,ve])=>Array.isArray(ve)?ve.map(We=>[V,We]):[[V,ve]])).toString(),x=I?`?${I}`:"",W=$.hash?`#${$.hash}`:"",q=s?`#${$.path}${x}${W}`:`${n}${$.path}${x}${W}`;history.replaceState(b(),"",q);return}m(u),u=E.state?.__bqScrollKey??p(),w(),v(u);for(const O of a)O(fe.value,$)}finally{Ws()}};window.addEventListener("popstate",k),w();const A={push:E=>S(E,"pushState"),replace:E=>S(E,"replaceState"),back:()=>history.back(),forward:()=>history.forward(),go:E=>history.go(E),beforeEach:E=>(i.push(E),()=>{const T=i.indexOf(E);T>-1&&i.splice(T,1)}),afterEach:E=>(a.push(E),()=>{const T=a.indexOf(E);T>-1&&a.splice(T,1)}),currentRoute:Us,routes:c,base:n,hash:s,destroy:()=>{window.removeEventListener("popstate",k),i.length=0,a.length=0,l.clear(),d!==null&&typeof history<"u"&&"scrollRestoration"in history&&(history.scrollRestoration=d),nu(),Fs(null)}};return Fs(A),A},xe=D(()=>fe.value),Tu={route:xe,path:D(()=>xe.value.path),params:D(()=>xe.value.params),query:D(()=>xe.value.query),hash:D(()=>xe.value.hash),matched:D(()=>xe.value.matched)},Ru=()=>Tu,Cu=()=>{if(!(typeof window>"u"))return window.__BQUERY_DEVTOOLS__||(window.__BQUERY_DEVTOOLS__={stores:new Map}),window.__BQUERY_DEVTOOLS__},$u=(e,t)=>{const r=Cu();r&&(r.stores.set(e,t),r.onStoreCreated?.(e,t))},Ou=e=>{typeof window>"u"||!window.__BQUERY_DEVTOOLS__||window.__BQUERY_DEVTOOLS__.stores.delete(e)},Lu=(e,t)=>{typeof window>"u"||window.__BQUERY_DEVTOOLS__?.onStateChange?.(e,t)},oo=[],Pu=e=>{oo.push(e)},Nu=(e,t)=>{for(const r of oo){const n=r({store:e,options:t});n&&Object.assign(e,n)}},ot=new Map,io=e=>ot.has(e),Iu=(e,t)=>{ot.set(e,t)},we=e=>ot.get(e),Wt=()=>Array.from(ot.keys()),Mu=e=>{ot.delete(e),Ou(e)},ao=e=>e!==null&&typeof e=="object"&&Object.getPrototypeOf(e)===Object.prototype,Te=e=>{if(e===null||typeof e!="object")return e;if(Array.isArray(e))return e.map(Te);if(e instanceof Date)return new Date(e.getTime());if(e instanceof Map)return new Map(Array.from(e.entries()).map(([r,n])=>[r,Te(n)]));if(e instanceof Set)return new Set(Array.from(e).map(Te));const t={};for(const r of Object.keys(e))t[r]=Te(e[r]);return t},qe=(e,t)=>{if(e===t)return!0;if(e===null||t===null||typeof e!="object"||typeof t!="object")return!1;if(e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime();if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const[s,o]of e.entries())if(!t.has(s)||!qe(o,t.get(s)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const s of e.values()){let o=!1;for(const i of t.values())if(qe(s,i)){o=!0;break}if(!o)return!1}return!0}if(Array.isArray(e)&&Array.isArray(t))return e.length!==t.length?!1:e.every((s,o)=>qe(s,t[o]));if(Array.isArray(e)!==Array.isArray(t))return!1;const r=Object.keys(e),n=Object.keys(t);return r.length!==n.length?!1:r.every(s=>qe(e[s],t[s]))},Du=(e,t,r)=>{const n=[];for(const s of Object.keys(t)){const o=e[s],i=t[s];r.get(s)===i&&ao(o)&&ao(i)&&!qe(o,i)&&n.push(s)}return n},it=()=>qt(),Pr=e=>{const{id:t,state:r,getters:n={},actions:s={}}=e;if(io(t))return console.warn(`bQuery store: Store "${t}" already exists. Returning existing instance.`),we(t);const o=r(),i=new Map;for(const g of Object.keys(o))i.set(g,L(o[g]));const a=[],c=[],l=(g,w,S)=>{!it()||typeof console>"u"||typeof console.error!="function"||console.error(`[bQuery store "${t}"] Error in $onAction ${g} for action "${w}"`,S)},u=new WeakSet,h=(g,w)=>{!it()||typeof console>"u"||typeof console.warn!="function"||u.has(g)||(u.add(g),console.warn(`[bQuery store "${t}"] Async $onAction listener detected for action "${w}". If it awaits, register after()/onError() before the first await; late registrations will not affect the current action.`))},d=(g,w,S,k)=>{try{const A=S();Fe(A)&&(g==="listener"&&k&&h(k,w),A.catch(E=>{l(g,w,E)}))}catch(A){l(g,w,A)}},p=()=>Ee(()=>({...m})),f=()=>{const g=typeof window<"u"&&typeof window.__BQUERY_DEVTOOLS__?.onStateChange=="function";if(a.length===0&&!g)return;const w=p();for(const S of a)S(w);Lu(t,w)},m=new Proxy({},{get:(g,w)=>{const S=w;if(i.has(S))return i.get(S).value},ownKeys:()=>Array.from(i.keys()),getOwnPropertyDescriptor:(g,w)=>{if(i.has(w))return{enumerable:!0,configurable:!0}},has:(g,w)=>i.has(w)}),v=new Map,b={};for(const g of Object.keys(o))Object.defineProperty(b,g,{get:()=>i.get(g).value,set:w=>{i.get(g).value=w,f()},enumerable:!0,configurable:!1});for(const g of Object.keys(n)){const w=n[g],S=D(()=>w(m,new Proxy({},{get:(k,A)=>{const E=A;if(v.has(E))return v.get(E).value}})));v.set(g,S),Object.defineProperty(b,g,{get:()=>S.value,enumerable:!0,configurable:!1})}for(const g of Object.keys(s)){const w=s[g],S=g;b[S]=function(...k){const A=new Proxy(b,{get:(R,O)=>typeof O=="string"&&i.has(O)?i.get(O).value:R[O],set:(R,O,I)=>typeof O=="string"&&i.has(O)?(i.get(O).value=I,f(),!0):Reflect.set(R,O,I)});if(c.length===0)return w.apply(A,k);const E=[],T=[],P=[...c],C={name:S,store:b,args:k,after:R=>{E.push(O=>R(O))},onError:R=>{T.push(R)}};for(const R of P)d("listener",S,()=>R(C),R);let $;try{$=w.apply(A,k)}catch(R){for(const O of T)d("onError",S,()=>O(R));throw R}if(Fe($))return $.then(R=>{for(const O of E)d("after",S,()=>O(R));return R},R=>{for(const O of T)d("onError",S,()=>O(R));throw R});for(const R of E)d("after",S,()=>R($));return $}}return Object.defineProperties(b,{$id:{value:t,writable:!1,enumerable:!1},$reset:{value:()=>{const g=r();Se(()=>{for(const[w,S]of i)S.value=g[w]}),f()},writable:!1,enumerable:!1},$subscribe:{value:g=>(a.push(g),()=>{const w=a.indexOf(g);w>-1&&a.splice(w,1)}),writable:!1,enumerable:!1},$onAction:{value:g=>(c.push(g),()=>{const w=c.indexOf(g);w>-1&&c.splice(w,1)}),writable:!1,enumerable:!1},$patch:{value:g=>{Se(()=>{if(typeof g=="function"){const w=it(),S=w?Te(p()):null,k=w?new Map(Array.from(i.entries()).map(([E,T])=>[E,T.value])):null,A=p();if(g(A),w&&S&&k){const E=Du(S,A,k);E.length>0&&console.warn(`[bQuery store "${t}"] Nested mutation detected in $patch() for keys: ${E.map(String).join(", ")}.
254
+ `}),r},$r=null,le=()=>$r!==null?$r:typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches,Sl=e=>{$r=e},io=e=>typeof e=="string"||typeof e=="number",ao=e=>e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`),qe=(e,t)=>{const r=e.style;if(Array.isArray(t)){const n=t[t.length-1];if(!n)return;for(const[s,o]of Object.entries(n))if(!(s==="offset"||s==="easing"||s==="composite")&&io(o)){const i=s.startsWith("--")?s:ao(s);r.setProperty(i,String(o))}return}for(const[n,s]of Object.entries(t)){if(n==="offset"||n==="easing"||n==="composite")continue;const o=Array.isArray(s)?s[s.length-1]:s;if(io(o)){const i=n.startsWith("--")?n:ao(n);r.setProperty(i,String(o))}}},Ht=(e,t)=>{const{keyframes:r,options:n,commitStyles:s=!0,respectReducedMotion:o=!0,onFinish:i}=t;if(o&&le())return s&&qe(e,r),i?.(),Promise.resolve();const a=e;return typeof a.animate!="function"?(s&&qe(e,r),i?.(),Promise.resolve()):new Promise(c=>{const l=a.animate(r,n);let u=!1;const h=()=>{u||(u=!0,s&&(typeof l.commitStyles=="function"?l.commitStyles():qe(e,r)),l.cancel(),i?.(),c())};l.onfinish=h,l.finished&&l.finished.then(h).catch(h)})},ue=e=>Math.min(1,Math.max(0,e)),co=e=>ue(e),lo=e=>ue(e*e),uo=e=>ue(1-(1-e)*(1-e)),fo=e=>ue(e<.5?2*e*e:1-Math.pow(-2*e+2,2)/2),ho=e=>ue(e*e*e),mo=e=>ue(1-Math.pow(1-e,3)),po=e=>ue(e<.5?4*e*e*e:1-Math.pow(-2*e+2,3)/2),vo=e=>ue(1+(1.70158+1)*Math.pow(e-1,3)+1.70158*Math.pow(e-1,2)),yo=e=>ue(e===1?1:1-Math.pow(2,-10*e)),El={linear:co,easeInQuad:lo,easeOutQuad:uo,easeInOutQuad:fo,easeInCubic:ho,easeOutCubic:mo,easeInOutCubic:po,easeOutBack:vo,easeOutExpo:yo},Or=e=>{const t=e.getBoundingClientRect();return{top:t.top,left:t.left,width:t.width,height:t.height}},Lr=(e,t,r={})=>{const{duration:n=300,easing:s="ease-out",onComplete:o}=r,i=Or(e);if(i.width===0||i.height===0)return o?.(),Promise.resolve();const a=t.left-i.left,c=t.top-i.top,l=t.width/i.width,u=t.height/i.height;if(a===0&&c===0&&l===1&&u===1)return o?.(),Promise.resolve();const h=e;return typeof h.animate!="function"?(o?.(),Promise.resolve()):(h.style.transform=`translate(${a}px, ${c}px) scale(${l}, ${u})`,h.style.transformOrigin="top left",h.offsetHeight,new Promise(d=>{const v=h.animate([{transform:`translate(${a}px, ${c}px) scale(${l}, ${u})`},{transform:"translate(0, 0) scale(1, 1)"}],{duration:n,easing:s,fill:"forwards"});let f=!1;const p=()=>{f||(f=!0,h.style.transform="",h.style.transformOrigin="",o?.(),d())};v.onfinish=p,v.finished&&v.finished.then(p).catch(p)}))},Al=async(e,t,r={})=>{await go(e,t,r)},go=async(e,t,r={})=>{const{stagger:n,...s}=r,o=new Map;for(const c of e)o.set(c,Or(c));t();const i=e.length,a=e.map((c,l)=>{const u=o.get(c);if(!u)return Promise.resolve();const h=n?n(l,i):0;return h>0?new Promise(d=>setTimeout(d,h)).then(()=>Lr(c,u,s)):Lr(c,u,s)});await Promise.all(a)},kl={fadeIn:(e=0,t=1)=>[{opacity:e},{opacity:t}],fadeOut:(e=1,t=0)=>[{opacity:e},{opacity:t}],slideInUp:(e=16)=>[{opacity:0,transform:`translateY(${e}px)`},{opacity:1,transform:"translateY(0)"}],slideInDown:(e=16)=>[{opacity:0,transform:`translateY(-${e}px)`},{opacity:1,transform:"translateY(0)"}],slideInLeft:(e=16)=>[{opacity:0,transform:`translateX(${e}px)`},{opacity:1,transform:"translateX(0)"}],slideInRight:(e=16)=>[{opacity:0,transform:`translateX(-${e}px)`},{opacity:1,transform:"translateX(0)"}],scaleIn:(e=.95,t=1)=>[{opacity:0,transform:`scale(${e})`},{opacity:1,transform:`scale(${t})`}],scaleOut:(e=1,t=.95)=>[{opacity:1,transform:`scale(${e})`},{opacity:0,transform:`scale(${t})`}],pop:(e=.9,t=1.02,r=1)=>[{opacity:0,transform:`scale(${e})`},{opacity:1,transform:`scale(${t})`,offset:.6},{opacity:1,transform:`scale(${r})`}],rotateIn:(e=6)=>[{opacity:0,transform:`rotate(${e}deg) scale(0.98)`},{opacity:1,transform:"rotate(0deg) scale(1)"}]},Tl=(e,t,r={})=>{const{duration:n=300,easing:s="ease",respectReducedMotion:o=!0,onComplete:i}=r,a=e,c=t;if(typeof window>"u"||typeof document>"u"||typeof a.getBoundingClientRect!="function"||typeof c.getBoundingClientRect!="function"||typeof a.style>"u"||typeof c.style>"u")return i?.(),Promise.resolve();const l=e.getBoundingClientRect(),u=c.style.display,h=c.style.visibility,d=c.style.transform,v=c.style.opacity,f=typeof getComputedStyle=="function"?getComputedStyle(c).display:u||"block",p=f==="none"?"block":u||f||"block",y=()=>{c.style.transform=d,c.style.opacity=v};c.style.visibility="hidden",c.style.display=p;const b=t.getBoundingClientRect();if(c.style.visibility=h,a.style.display="none",f==="none"?c.style.display=p:u==="none"?c.style.display="":c.style.display=u,o&&le())return y(),i?.(),Promise.resolve();const g=l.left-b.left,w=l.top-b.top,S=l.width/(b.width||1),k=l.height/(b.height||1);if(g===0&&w===0&&S===1&&k===1)return y(),i?.(),Promise.resolve();const A=[{transform:`translate(${g}px, ${w}px) scale(${S}, ${k})`,opacity:"0.5"},{transform:"translate(0, 0) scale(1, 1)",opacity:"1"}];return typeof c.animate!="function"?(y(),i?.(),Promise.resolve()):new Promise(E=>{const T=c.animate(A,{duration:n,easing:s,fill:"forwards"});let P=!1;const R=()=>{P||(P=!0,y(),T.cancel(),i?.(),E())};T.onfinish=R,T.finished&&T.finished.then(R).catch(R)})},Cl=(e,t={})=>{if(typeof window>"u"||typeof window.addEventListener!="function"||typeof window.removeEventListener!="function"||typeof requestAnimationFrame!="function"||typeof cancelAnimationFrame!="function")return()=>{};const{speed:r=.5,direction:n="vertical",respectReducedMotion:s=!0}=t,o=e,i=o.style.transform;if(s&&le())return()=>{};let a=!1,c=!1,l=null;const u=()=>{c||(c=!0,window.removeEventListener("scroll",d),l!==null&&(cancelAnimationFrame(l),l=null),a=!1,o.style.transform=i)},h=()=>{if(c)return;if(s&&le()){u();return}const v=window.scrollY,f=window.scrollX;let p=0,y=0;(n==="vertical"||n==="both")&&(y=v*r),(n==="horizontal"||n==="both")&&(p=f*r);const b=`translate3d(${p}px, ${y}px, 0)`;o.style.transform=i?`${i} ${b}`:b},d=()=>{if(!c){if(s&&le()){u();return}a||(a=!0,l=requestAnimationFrame(()=>{l=null,h(),a=!1}))}};return h(),window.addEventListener("scroll",d,{passive:!0}),u},Rl=e=>typeof Element<"u"&&e instanceof Element?[e]:Array.from(e),$l=(e,t)=>{const r=Rl(e);if(!r.length)return()=>{};const{root:n=null,rootMargin:s,threshold:o,once:i=!0,onEnter:a,...c}=t;if(typeof IntersectionObserver>"u")return r.forEach(u=>{a?.(u),Ht(u,c)}),()=>{};const l=new IntersectionObserver(u=>{u.forEach(h=>{if(!h.isIntersecting)return;const d=h.target;a?.(d),Ht(d,c),i&&l.unobserve(d)})},{root:n,rootMargin:s,threshold:o});return r.forEach(u=>l.observe(u)),()=>l.disconnect()},Ol={stiffness:100,damping:10,mass:1,precision:.01},Ll=(e,t={})=>{const{stiffness:r,damping:n,mass:s,precision:o}={...Ol,...t};let i=e,a=0,c=e,l=null,u=null,h=null;const d=new Set,v=()=>{for(const p of d)p(i)},f=p=>{const y=h!==null?(p-h)/1e3:.016666666666666666,b=Math.min(y,1/30);h=p;const g=i-c,w=(-r*g+-n*a)/s;if(a+=w*b,i+=a*b,v(),Math.abs(a)<o&&Math.abs(g)<o){i=c,a=0,l=null,v(),u?.(),u=null;return}l=requestAnimationFrame(f)};return{to(p){return c=p,l!==null&&cancelAnimationFrame(l),u?.(),h=null,new Promise(y=>{u=y,l=requestAnimationFrame(f)})},current(){return i},stop(){l!==null&&(cancelAnimationFrame(l),l=null),a=0,h=null,u?.(),u=null},onChange(p){return d.add(p),()=>d.delete(p)}}},Pl={gentle:{stiffness:80,damping:15},snappy:{stiffness:200,damping:20},bouncy:{stiffness:300,damping:8},stiff:{stiffness:400,damping:30}},Nl=(e,t={})=>{const{start:r=0,from:n="start",easing:s}=t;return(o,i=0)=>{const a=typeof n=="number"?n:n==="center"?(i-1)/2:n==="end"?i-1:0,c=Math.abs(o-a),l=i>1?Math.max(a,i-1-a):1,u=l===0?0:c/l;return r+(s?s(u)*l:c)*e}},Pr=e=>{if(typeof e=="number")return e;if(typeof e=="string"){const t=e.trim();if(t.endsWith("ms")){const n=Number.parseFloat(t.slice(0,-2));return Number.isFinite(n)?n:0}if(t.endsWith("s")){const n=Number.parseFloat(t.slice(0,-1));return Number.isFinite(n)?n*1e3:0}const r=Number.parseFloat(t);return Number.isFinite(r)?r:0}return 0},Il=(e,t)=>{if(typeof e=="number")return e;if(typeof e=="string"){const r=/^([+-])=(\d+(?:\.\d+)?)$/.exec(e);if(r){const n=Number.parseFloat(r[2]);return Number.isFinite(n)?r[1]==="+"?t+n:t-n:t}}return t},Ml=e=>{const t=Pr(e?.duration),r=Pr(e?.endDelay),n=e?.iterations??1;return n===1/0?Number.MAX_SAFE_INTEGER:t*Math.max(0,n)+r},bo=e=>{let t=0;return e.map(r=>{const n=Il(r.at,t),s=Pr(r.options?.delay),o=Math.max(0,n+s),i=Ml(r.options),a=o+i;return t=Math.max(t,a),{step:r,start:o,end:a,duration:i}})},Dl=async(e,t={})=>{const{stagger:r,onFinish:n}=t,s=e.length;for(let o=0;o<e.length;o+=1){const i=e[o],a=r?r(o,s):0;a>0&&await new Promise(c=>setTimeout(c,a)),await Ht(i.target,i)}n?.()},_l=(e=[],t={})=>{const r=[...e],n=new Set;let s=[],o=0,i=!1,a=!1;const{commitStyles:c=!0,respectReducedMotion:l=!0,onFinish:u}=t,h=()=>{if(!a){if(a=!0,c)for(const v of s){const{animation:f,step:p}=v;typeof f.commitStyles=="function"?f.commitStyles():qe(p.target,p.keyframes),f.cancel()}n.forEach(v=>v()),u?.()}},d=()=>{s.forEach(({animation:f})=>f.cancel()),s=[],a=!1;const v=bo(r);if(o=v.length?Math.max(...v.map(f=>f.end)):0,l&&le()){c&&v.forEach(({step:f})=>qe(f.target,f.keyframes)),i=!0;return}if(v.some(({step:f})=>typeof f.target.animate!="function")){c&&v.forEach(({step:f})=>qe(f.target,f.keyframes)),i=!0;return}i=!1,s=v.map(({step:f,start:p})=>{const{delay:y,...b}=f.options??{};return{animation:f.target.animate(f.keyframes,{...b,delay:p,fill:b.fill??"both"}),step:f,start:p}})};return{add(v){r.push(v)},duration(){if(!r.length)return 0;if(!s.length){const v=bo(r);return Math.max(...v.map(f=>f.end))}return o},async play(){if(d(),i||s.length===0){h();return}const v=s.map(f=>f.animation.finished.catch(()=>{}));await Promise.all(v),h()},pause(){i||s.forEach(({animation:v})=>v.pause())},resume(){i||s.forEach(({animation:v})=>v.play())},stop(){s.forEach(({animation:v})=>v.cancel()),s=[],i=!1},seek(v){i||s.forEach(({animation:f})=>{f.currentTime=v})},onFinish(v){return n.add(v),()=>n.delete(v)}}},wo=e=>(e??[]).map(t=>t.trim()).filter(t=>t.length>0),ql=async e=>{const t=ae().transitions,r=typeof e=="function"?{update:e,classes:t?.classes,types:t?.types,skipOnReducedMotion:t?.skipOnReducedMotion}:{...e,classes:e.classes??t?.classes,types:e.types??t?.types,skipOnReducedMotion:e.skipOnReducedMotion??t?.skipOnReducedMotion},n=r.update;if(typeof document>"u"){await n();return}const s=document,o=document.documentElement,i=wo(r.classes),a=wo(r.types);if(!s.startViewTransition||r.skipOnReducedMotion&&le()){await n(),r.onFinish?.();return}i.forEach(c=>o.classList.add(c));try{const c=s.startViewTransition(()=>n()),l=c.types;if(l)for(const u of a)l.add(u);await c.ready,r.onReady?.(),await c.finished,r.onFinish?.()}finally{i.forEach(c=>o.classList.remove(c))}},xl=(e,t,r={})=>{const{speed:n=50,delay:s=0,cursor:o=!1,cursorChar:i="|",loop:a=!1,loopDelay:c=1e3,respectReducedMotion:l=!0,onComplete:u}=r;if(typeof document>"u")return{stop:()=>{},done:Promise.resolve()};const h=e;let d=!1,v=null,f=null,p=null,y=null;const b=()=>{if(!o)return;f=document.createElement("span"),f.setAttribute("aria-hidden","true"),f.textContent=i,h.appendChild(f);let S=!0;p=setInterval(()=>{f&&(S=!S,f.style.opacity=S?"1":"0")},530)},g=()=>{p!==null&&(clearInterval(p),p=null),f&&f.parentNode&&(f.parentNode.removeChild(f),f=null)},w=()=>{d||(d=!0,v!==null&&(clearTimeout(v),v=null),g(),y?.(),y=null)};return l&&le()?(h.textContent=t,u?.(),{stop:()=>{},done:Promise.resolve()}):{stop:w,done:new Promise(S=>{y=S;const k=()=>{let A=0;h.textContent="",b();const E=document.createTextNode("");f?h.insertBefore(E,f):h.appendChild(E);const T=()=>{d||(A<t.length?(E.data=t.slice(0,A+1),A++,v=setTimeout(T,n)):(u?.(),a&&!d?v=setTimeout(()=>{d||(g(),k())},c):(g(),S(),y=null)))};v=setTimeout(T,s)};k()})}},zl=class{constructor(e){this.bucketName=e,this.dbPromise=null,this.storeName="blobs"}openDB(){if(this.dbPromise)return this.dbPromise;const e=`bquery-bucket-${this.bucketName}`;return this.dbPromise=new Promise((t,r)=>{const n=indexedDB.open(e,1);n.onupgradeneeded=()=>{const s=n.result;s.objectStoreNames.contains(this.storeName)||s.createObjectStore(this.storeName)},n.onsuccess=()=>t(n.result),n.onerror=()=>r(n.error)}),this.dbPromise}async withStore(e,t){const r=await this.openDB();return new Promise((n,s)=>{const o=t(r.transaction(this.storeName,e).objectStore(this.storeName));o.onsuccess=()=>n(o.result),o.onerror=()=>s(o.error)})}async put(e,t){await this.withStore("readwrite",r=>r.put(t,e))}async get(e){return await this.withStore("readonly",t=>t.get(e))??null}async remove(e){await this.withStore("readwrite",t=>t.delete(e))}async keys(){return(await this.withStore("readonly",e=>e.getAllKeys())).map(e=>String(e))}},jl={async open(e){return new zl(e)}},Ul=class{constructor(e){this.cache=e}async add(e){await this.cache.add(e)}async addAll(e){await this.cache.addAll(e)}async put(e,t){await this.cache.put(e,t)}async match(e){return this.cache.match(e)}async remove(e){return this.cache.delete(e)}async keys(){return(await this.cache.keys()).map(e=>e.url)}},Hl={isSupported(){return"caches"in window},async open(e){if(!this.isSupported())throw new Error("bQuery: Cache Storage API not supported");return new Ul(await caches.open(e))},async delete(e){return this.isSupported()?caches.delete(e):!1},async keys(){return this.isSupported()?caches.keys():[]}},Wl=e=>{if(typeof document>"u")return null;const t=`${encodeURIComponent(e)}=`,r=document.cookie?document.cookie.split(";"):[];for(const n of r){const s=n.trim();if(s.startsWith(t)){const o=s.slice(t.length);try{return decodeURIComponent(o)}catch{return o}}}return null},Fl=e=>{const t=e.trim();return t.startsWith("{")||t.startsWith("[")||t.startsWith('"')},Bl=(e,t)=>{if(typeof document>"u")return;const r=[`${encodeURIComponent(e)}=`,"Expires=Thu, 01 Jan 1970 00:00:00 GMT"];t.path&&r.push(`Path=${t.path}`),t.domain&&r.push(`Domain=${t.domain}`),t.sameSite&&r.push(`SameSite=${t.sameSite}`),t.secure&&r.push("Secure"),document.cookie=r.join("; ")},Ql=(e,t,r)=>{if(typeof document>"u")return;const n=r.serialize?r.serialize(t):typeof t=="string"?t:JSON.stringify(t),s=[`${encodeURIComponent(e)}=${encodeURIComponent(n)}`];r.path&&s.push(`Path=${r.path}`),r.domain&&s.push(`Domain=${r.domain}`),typeof r.maxAge=="number"&&s.push(`Max-Age=${r.maxAge}`),r.expires&&s.push(`Expires=${r.expires.toUTCString()}`),r.sameSite&&s.push(`SameSite=${r.sameSite}`),r.secure&&s.push("Secure"),document.cookie=s.join("; ")},Vl=(e,t={})=>{const r=ae().cookies,n={path:r?.path??"/",sameSite:r?.sameSite??"Lax",secure:r?.secure??!1,watch:!0,...t};n.sameSite==="None"&&(n.secure=!0);const s=Wl(e);let o=n.defaultValue??null;if(s!==null)try{o=n.deserialize?n.deserialize(s):Fl(s)?JSON.parse(s):s??o}catch(c){console.warn(`bQuery: Failed to deserialize cookie "${e}", using raw string value`,c),o=s??o}const i=L(o);if(typeof document>"u"||n.watch===!1)return i;let a=!1;return j(()=>{const c=i.value;if(!a){a=!0;return}if(c==null){Bl(e,n);return}Ql(e,c,n)}),i},Kl={isSupported(){return"Notification"in window},getPermission(){return this.isSupported()?Notification.permission:"denied"},async requestPermission(){return this.isSupported()?Notification.permission==="granted"?"granted":Notification.permission==="denied"?"denied":Notification.requestPermission():"denied"},send(e,t){return this.isSupported()?Notification.permission!=="granted"?(console.warn("bQuery: Notification permission not granted"),null):new Notification(e,t):(console.warn("bQuery: Notifications not supported in this browser"),null)}},Yl=["position:absolute","width:1px","height:1px","padding:0","margin:-1px","overflow:hidden","clip:rect(0, 0, 0, 0)","white-space:nowrap","border:0"].join(";"),Jl=(e={})=>{const t=ae().announcer,r={politeness:t?.politeness??"polite",atomic:t?.atomic??!0,delay:t?.delay??16,clearDelay:t?.clearDelay??1e3,...e},n=L("");if(typeof document>"u")return{element:null,message:n,announce(p){n.value=p},clear(){n.value=""},destroy(){n.value=""}};const s=r.id?document.getElementById(r.id):null,o=s??document.createElement("div"),i=!s;if(r.id&&(o.id=r.id),r.className&&(o.className=r.className),o.setAttribute("aria-live",r.politeness),o.setAttribute("aria-atomic",String(r.atomic)),o.setAttribute("role",r.politeness==="assertive"?"alert":"status"),o.setAttribute("data-bquery-announcer","true"),o.getAttribute("style")||o.setAttribute("style",Yl),i){const p=r.container??document.body??document.documentElement;if(!p)return{element:null,message:n,announce(y){n.value=y},clear(){n.value=""},destroy(){n.value=""}};p.appendChild(o)}const a=j(()=>{o.textContent=n.value});let c,l,u=!1;const h=()=>{c&&(clearTimeout(c),c=void 0),l&&(clearTimeout(l),l=void 0)};return{element:o,message:n,announce:(p,y={})=>{if(u)return;const b=y.politeness??r.politeness,g=y.delay??r.delay,w=y.clearDelay??r.clearDelay;h(),o.setAttribute("aria-live",b),o.setAttribute("role",b==="assertive"?"alert":"status"),n.value="",c=setTimeout(()=>{u||(n.value=p,w>0&&(l=setTimeout(()=>{u||(n.value="")},w)))},g)},clear:()=>{u||(h(),n.value="")},destroy:()=>{u||(u=!0,h(),n.value="",a(),i&&o.remove())}}},So=(e,t)=>{const r=new Map;for(const[n,s]of Object.entries(t))r.set(n,e.getAttribute(n)),e.setAttribute(n,s);return()=>{for(const[n,s]of r.entries())s==null?e.removeAttribute(n):e.setAttribute(n,s)}},Eo=(e,t)=>{const r=document.createElement(e);r.setAttribute("data-bquery-page-meta","true");for(const[n,s]of Object.entries(t))s!==void 0&&r.setAttribute(n,s);return r},Gl=e=>{if(typeof document>"u")return()=>{};const t=ae().pageMeta,r=e.title?t?.titleTemplate?t.titleTemplate(e.title):e.title:void 0,n=[],s=[],o=document.title;r!==void 0&&(document.title=r);const i=[...e.meta??[]];e.description&&i.unshift({name:"description",content:e.description});for(const a of i){const c=Eo("meta",{name:a.name,property:a.property,"http-equiv":a.httpEquiv,content:a.content});document.head.appendChild(c),n.push(c)}for(const a of e.link??[]){const c=Eo("link",{rel:a.rel,href:a.href,type:a.type,media:a.media,crossorigin:a.crossOrigin});document.head.appendChild(c),n.push(c)}return e.htmlAttributes&&s.push(So(document.documentElement,e.htmlAttributes)),e.bodyAttributes&&document.body&&s.push(So(document.body,e.bodyAttributes)),()=>{document.title=o;for(const a of s.reverse())a();for(const a of n)a.remove()}},Ao=class{constructor(e){this.storage=e}async get(e){const t=this.storage.getItem(e);if(t===null)return null;try{return JSON.parse(t)}catch{return t}}async set(e,t){const r=typeof t=="string"?t:JSON.stringify(t);this.storage.setItem(e,r)}async remove(e){this.storage.removeItem(e)}async clear(){this.storage.clear()}async keys(){const e=[];for(let t=0;t<this.storage.length;t++){const r=this.storage.key(t);r!==null&&e.push(r)}return e}},Xl=class extends Ao{constructor(){super(localStorage)}},Zl=class extends Ao{constructor(){super(sessionStorage)}},eu=class{constructor(e){this.options=e,this.dbPromise=null}openDB(){return this.dbPromise?this.dbPromise:(this.dbPromise=new Promise((e,t)=>{const r=indexedDB.open(this.options.name,this.options.version??1);r.onupgradeneeded=()=>{const n=r.result;n.objectStoreNames.contains(this.options.store)||n.createObjectStore(this.options.store)},r.onsuccess=()=>e(r.result),r.onerror=()=>t(r.error)}),this.dbPromise)}async withStore(e,t){const r=await this.openDB();return new Promise((n,s)=>{const o=t(r.transaction(this.options.store,e).objectStore(this.options.store));o.onsuccess=()=>n(o.result),o.onerror=()=>s(o.error)})}async get(e){return await this.withStore("readonly",t=>t.get(e))??null}async set(e,t){await this.withStore("readwrite",r=>r.put(t,e))}async remove(e){await this.withStore("readwrite",t=>t.delete(e))}async clear(){await this.withStore("readwrite",e=>e.clear())}async keys(){return(await this.withStore("readonly",e=>e.getAllKeys())).map(e=>String(e))}},tu={local(){return new Xl},session(){return new Zl},indexedDB(e){return new eu(e)}},ko=null,fe=L({path:"",params:{},query:{},matched:null,hash:""}),To=D(()=>fe.value),rt=L(0),Wt=L(!1),ru=_(Wt),Co=()=>{rt.value===0&&(Wt.value=!0),rt.value+=1},Ro=()=>{const e=Math.max(0,rt.value-1);rt.value=e,e===0&&(Wt.value=!1)},nu=()=>{rt.value=0,Wt.value=!1},Ce=()=>ko,$o=e=>{ko=e},nt=async(e,t={})=>{const r=Ce();if(!r)throw new Error("bQuery router: No router initialized. Call createRouter() first.");await r[t.replace?"replace":"push"](e)},su=()=>{const e=Ce();e?e.back():history.back()},ou=()=>{const e=Ce();e?e.forward():history.forward()},iu="active",au=e=>e.split(/\s+/).map(t=>t.trim()).filter(t=>t.length>0),cu=typeof HTMLElement<"u"?HTMLElement:class{},Oo=class extends cu{constructor(...e){super(...e),this._cleanup=null,this._trackedActiveClasses=new Map,this._handleClick=t=>{t instanceof MouseEvent&&(t.defaultPrevented||t.button===0&&(t.ctrlKey||t.metaKey||t.shiftKey||t.altKey||(t.preventDefault(),this._navigate())))},this._handleKeydown=t=>{t instanceof KeyboardEvent&&t.key==="Enter"&&(t.preventDefault(),this._navigate())}}static get observedAttributes(){return["to","replace","exact","active-class"]}get to(){const e=this.getAttribute("to");return e==null||e.trim()===""?"/":e}set to(e){this.setAttribute("to",e)}get replace(){return this.hasAttribute("replace")}set replace(e){e?this.setAttribute("replace",""):this.removeAttribute("replace")}get exact(){return this.hasAttribute("exact")}set exact(e){e?this.setAttribute("exact",""):this.removeAttribute("exact")}get activeClass(){return this.getAttribute("active-class")??iu}set activeClass(e){this.setAttribute("active-class",e)}connectedCallback(){this.getAttribute("role")||this.setAttribute("role","link"),this.hasAttribute("tabindex")||this.setAttribute("tabindex","0"),this.addEventListener("click",this._handleClick),this.addEventListener("keydown",this._handleKeydown),this._setupActiveTracking()}disconnectedCallback(){this.removeEventListener("click",this._handleClick),this.removeEventListener("keydown",this._handleKeydown),this._cleanup&&(this._cleanup(),this._cleanup=null),this._clearTrackedActiveClasses()}attributeChangedCallback(e,t,r){(e==="to"||e==="exact"||e==="active-class")&&this.isConnected&&this._setupActiveTracking()}_setupActiveTracking(){this._cleanup&&(this._cleanup(),this._cleanup=null),this._clearTrackedActiveClasses();const e=this.to,t=this.exact,r=au(this.activeClass);this._trackedActiveClasses=new Map(r.map(n=>[n,this.classList.contains(n)])),this._cleanup=j(()=>{const n=fe.value.path,s=t?n===e:e==="/"?n==="/":n===e||n.startsWith(e.endsWith("/")?e:e+"/");for(const o of r){const i=this._trackedActiveClasses.get(o)??!1;this.classList.toggle(o,s||i)}s?this.setAttribute("aria-current","page"):this.removeAttribute("aria-current")})}_clearTrackedActiveClasses(){for(const[e,t]of this._trackedActiveClasses)this.classList.toggle(e,t);this._trackedActiveClasses.clear()}_navigate(){const e=this.to;e&&Ce()&&nt(e,{replace:this.replace}).catch(t=>{console.error("bq-link: Navigation failed:",t)})}},lu=()=>{typeof HTMLElement<"u"&&typeof customElements<"u"&&!customElements.get("bq-link")&&customElements.define("bq-link",Oo)},uu=(e,t={})=>r=>{r.preventDefault(),nt(e,t).catch(n=>{console.error("Navigation failed:",n)})},fu=e=>{const t=e??(typeof document<"u"?document.body:null);if(!t)return()=>{};const r=n=>{if(!(n instanceof MouseEvent)||n.defaultPrevented||n.button!==0||n.ctrlKey||n.metaKey||n.shiftKey||n.altKey||typeof Element>"u"||!(n.target instanceof Element))return;const s=n.target.closest("a");if(!s||!(s instanceof(s.ownerDocument.defaultView?.HTMLAnchorElement??HTMLAnchorElement))||s.target||s.hasAttribute("download")||typeof window>"u"||s.origin!==window.location.origin)return;const o=Ce();if(!o){n.preventDefault(),nt(s.pathname+s.search+s.hash).catch(l=>{console.error("Navigation failed:",l)});return}const i=o.base,a=o.hash;let c;if(a&&s.hash&&s.hash.startsWith("#/"))c=s.hash.slice(1);else{let l=s.pathname;i&&i!=="/"&&l.startsWith(i)&&(l=l.slice(i.length)||"/"),c=l+s.search+s.hash}n.preventDefault(),nt(c).catch(l=>{console.error("Navigation failed:",l)})};return t.addEventListener("click",r),()=>t.removeEventListener("click",r)},Lo=e=>{const t={};return new URLSearchParams(e).forEach((r,n)=>{if(N(n))return;const s=t[n];s===void 0?t[n]=r:Array.isArray(s)?s.push(r):t[n]=[s,r]}),t},du=128,Po=new Map,No=new Map,Io=(e,t,r)=>{if(e.has(t)&&e.delete(t),e.set(t,r),e.size<=du)return;const n=e.keys().next().value;n!==void 0&&e.delete(n)},hu=e=>{const t=[];let r=!1;for(let n=0;n<e.length;n++){const s=e[n];if(s==="\\"&&n+1<e.length){n++;continue}if(s==="["&&!r){r=!0;continue}if(s==="]"&&r){r=!1;continue}if(!r){if(s==="("){t.push(!1);continue}if(s===")"){const o=t.pop()??!1,i=e[n+1];if(o&&(i==="+"||i==="*"||i==="?"||i==="{"))return!0;o&&t.length>0&&(t[t.length-1]=!0);continue}if(t.length>0){if(s==="?"&&n>0&&e[n-1]==="(")continue;(s==="+"||s==="*"||s==="?"||s==="{")&&(t[t.length-1]=!0)}}}return!1},mu=e=>{let t="",r=!1;for(let n=0;n<e.length;n++){const s=e[n];if(s==="\\"&&n+1<e.length){if(!r&&e[n+1]>="1"&&e[n+1]<="9")throw new Error(`bQuery router: Route constraints cannot use backreferences: "${e}".`);if(!r&&e[n+1]==="k"&&e[n+2]==="<")throw new Error(`bQuery router: Route constraints cannot use backreferences: "${e}".`);t+=s+e[n+1],n++;continue}if(s==="["&&!r){r=!0,t+=s;continue}if(s==="]"&&r){r=!1,t+=s;continue}if(!r&&s==="("){if(n+1<e.length&&e[n+1]==="?"){if(e[n+2]==="<"){if(e[n+3]==="="||e[n+3]==="!"){t+="(";continue}const o=e.indexOf(">",n+3);if(o===-1)throw new Error(`bQuery router: Invalid route constraint named capture group: "${e}".`);t+="(?:",n=o;continue}t+="(";continue}t+="(?:";continue}t+=s}return t},Nr=e=>{const t=Po.get(e);if(t!==void 0)return t;const r=mu(e);return Io(Po,e,r),r},Mo=e=>{const t=Nr(e),r=No.get(t);if(r)return r;if(hu(t))throw new Error(`bQuery router: Route constraint contains a potentially catastrophic (ReDoS) pattern. Nested quantifiers are not allowed: "${e}".`);try{const n=new RegExp(`^(?:${t})$`);return Io(No,t,n),n}catch(n){throw n instanceof SyntaxError?new Error(`bQuery router: Invalid route constraint regex "${e}": ${n.message}`):n}},st=e=>e!==void 0&&(e>="a"&&e<="z"||e>="A"&&e<="Z"||e==="_"),Do=e=>st(e)||e!==void 0&&e>="0"&&e<="9",_o=(e,t)=>{let r=1,n="",s=t+1,o=!1;for(;s<e.length;){const i=e[s];if(i==="\\"&&s+1<e.length){n+=i+e[s+1],s+=2;continue}if(i==="["&&!o)o=!0;else if(i==="]"&&o)o=!1;else if(!o&&i==="(")r++;else if(!o&&i===")"&&(r--,r===0))return{constraint:n,endIndex:s+1};n+=i,s++}return null},pu=(e,t)=>{const r=_o(e,t);if(!r)throw new Error(`bQuery router: Invalid route param constraint syntax in path "${e}" at index ${t}.`);return r},qo=new Set,xo=(e,t)=>{if(e[t]!==":"||!st(e[t+1]))return null;let r=t+2;for(;r<e.length&&Do(e[r]);)r++;let n=r,s;if(e[r]==="("){const o=pu(e,r);s=o.constraint,n=o.endIndex}return{name:e.slice(t+1,r),constraint:s,nextIndex:n}},vu=e=>{if(!qo.has(e)){for(let t=0;t<e.length;){if(e[t]===":"&&st(e[t+1])){const r=xo(e,t);r?.constraint&&Nr(r.constraint),t=r?.nextIndex??t+1;continue}t++}qo.add(e)}},yu=(e,t)=>{const r=e.indexOf("/",t);return r===-1?e.length:r},zo=(e,t)=>{let r=t;for(;r<e.length&&!(e[r]==="*"||e[r]===":"&&st(e[r+1]));)r++;return e.slice(t,r)},jo=(e,t,r,n)=>{const s=[];let o=t;for(;o<=r;){const i=e.indexOf(n,o);if(i===-1||i>r)break;s.push(i),o=i+1}return s.reverse()},gu=(e,t)=>{const r=new Map,n=(s,o)=>{const i=`${s}:${o}`;if(r.has(i))return r.get(i)??null;if(s===e.length){const u=o===t.length?{}:null;return r.set(i,u),u}const a=e[s];if(a==="*"){if(s===e.length-1){const v={};return r.set(i,v),v}const u=zo(e,s+1),h=u.length>0?jo(t,o,t.length,u):null,d=(h?v=>{for(const f of h){const p=v(f);if(p)return p}return null}:v=>{for(let f=t.length;f>=o;f--){const p=v(f);if(p)return p}return null})(v=>{const f=n(s+1,v);return f?(r.set(i,f),f):null});return d||(r.set(i,null),null)}const c=xo(e,s);if(c){const u=c.constraint?Mo(c.constraint):void 0,h=c.constraint?t.length:yu(t,o),d=zo(e,c.nextIndex),v=d.length>0?jo(t,o,h,d):null,f=(v?p=>{for(const y of v){if(y<=o)continue;const b=p(y);if(b)return b}return null}:p=>{for(let y=h;y>o;y--){const b=p(y);if(b)return b}return null})(p=>{const y=t.slice(o,p);if(u&&!u.test(y))return null;const b=n(c.nextIndex,p);if(b){const g={[c.name]:y,...b};return r.set(i,g),g}return null});return f||(r.set(i,null),null)}if(o>=t.length||a!==t[o])return r.set(i,null),null;const l=n(s+1,o+1);return r.set(i,l),l};return n(0,0)},Uo=(e,t)=>{for(const r of t){vu(r.path);const n=gu(r.path,e);if(n)return{matched:r,params:n}}return null},Ft=(e,t,r,n)=>{const s=Uo(e,n);return{path:e,params:s?.params??{},query:Lo(t),matched:s?.matched??null,hash:r.replace(/^#/,"")}},Ho=(e,t="")=>{const r=[];for(const n of e){const s=n.path==="*"?"*":`${t}${n.path}`.replace(/\/+/g,"/");r.push({...n,path:s}),n.children&&r.push(...Ho(n.children,s))}return r},bu=(e,t={})=>{const r=Ce();if(!r)throw new Error("bQuery router: No router initialized.");const n=r.routes.find(o=>o.name===e);if(!n)throw new Error(`bQuery router: Route "${e}" not found.`);let s="";for(let o=0;o<n.path.length;){if(n.path[o]===":"&&st(n.path[o+1])){let i=o+2;for(;i<n.path.length&&Do(n.path[i]);)i++;let a=i,c=null;if(n.path[i]==="("){const h=_o(n.path,i);if(!h)throw new Error(`bQuery router: Invalid constraint syntax in path "${n.path}" for route "${e}".`);c=h.constraint,a=h.endIndex}const l=n.path.slice(o+1,i),u=t[l];if(u===void 0)throw new Error(`bQuery router: Missing required param "${l}" for route "${e}".`);if(c&&!Mo(c).test(u))throw new Error(`bQuery router: Param "${l}" with value "${u}" does not satisfy the route constraint "${c}" for route "${e}".`);s+=encodeURIComponent(u),o=a;continue}s+=n.path[o],o++}return s},wu=(e,t=!1)=>{const r=fe.value.path;return t?r===e:r.startsWith(e)},Su=(e,t=!1)=>D(()=>{const r=fe.value.path;return t?r===e:r.startsWith(e)}),Eu=100,Au=e=>{const t={};for(const[r,n]of Object.entries(e))N(r)||(t[r]=n);return t},ku=e=>{const t=Ce();t&&t.destroy();const{routes:r,base:n="",hash:s=!1,scrollRestoration:o=!1}=e,i=[],a=[],c=Ho(r),l=new Map;let u="0",h=0,d=null;if(o&&typeof history<"u"&&"scrollRestoration"in history){d=history.scrollRestoration,history.scrollRestoration!=="manual"&&(history.scrollRestoration="manual");const E=history.state&&typeof history.state=="object"?history.state:{};if(typeof E.__bqScrollKey!="string"){const T=s?window.location.hash||"#/":`${window.location.pathname}${window.location.search}${window.location.hash}`;history.replaceState({...E,__bqScrollKey:u},"",T)}}const v=()=>history.state&&history.state.__bqScrollKey||u,f=()=>`${Date.now()}-${h++}`,p=(E=v())=>{if(o)for(l.has(E)&&l.delete(E),l.set(E,{x:window.scrollX,y:window.scrollY});l.size>Eu;){const T=l.keys().next().value;if(T===void 0)break;l.delete(T)}},y=(E=v())=>{if(!o)return;const T=l.get(E);T?window.scrollTo(T.x,T.y):window.scrollTo(0,0)},b=()=>{const E=history.state&&typeof history.state=="object"?{...history.state}:{};return o&&(E.__bqScrollKey=u),E},g=()=>{if(s){const[T,P=""]=(window.location.hash.slice(1)||"/").split("#"),[R,$=""]=T.split("?");return{pathname:R,search:$?`?${$}`:"",hash:P?`#${P}`:""}}let E=window.location.pathname;return n&&(E===n||E.startsWith(n+"/"))&&(E=E.slice(n.length)||"/"),{pathname:E,search:window.location.search,hash:window.location.hash}},w=()=>{const{pathname:E,search:T,hash:P}=g();fe.value=Ft(E,T,P,c)},S=async(E,T,P=new Set)=>{Co();try{const{pathname:R,search:$,hash:C}=g(),O=Ft(R,$,C,c),I=new URL(E,window.location.origin),q=`${I.pathname}${I.search}${I.hash}`;if(P.has(q))throw new Error(`bQuery router: redirect loop detected for path "${q}"`);P.add(q);const W=Ft(I.pathname,I.search,I.hash,c);if(W.matched?.redirectTo){await S(W.matched.redirectTo,T,P);return}if(W.matched?.beforeEnter&&await W.matched.beforeEnter(W,O)===!1)return;for(const At of i)if(await At(W,O)===!1)return;p();const x=o?v():void 0,V=T==="replaceState"&&x?x:f(),ve=s?`#${E}`:`${n}${E}`,Fe=o&&history.state&&typeof history.state=="object"?Au(history.state):{},un=o?{...Fe,__bqScrollKey:V}:{};history[T](un,"",ve),u=V,w(),o&&T==="pushState"&&window.scrollTo(0,0);for(const At of a)At(fe.value,O)}finally{Ro()}},k=async E=>{Co();try{const{pathname:T,search:P,hash:R}=g(),$=fe.value,C=Ft(T,P,R,c);if(C.matched?.redirectTo){await S(C.matched.redirectTo,"replaceState");return}if(C.matched?.beforeEnter&&await C.matched.beforeEnter(C,$)===!1){const O=new URLSearchParams(Object.entries($.query).flatMap(([x,V])=>Array.isArray(V)?V.map(ve=>[x,ve]):[[x,V]])).toString(),I=O?`?${O}`:"",q=$.hash?`#${$.hash}`:"",W=s?`#${$.path}${I}${q}`:`${n}${$.path}${I}${q}`;history.replaceState(b(),"",W);return}for(const O of i)if(await O(C,$)===!1){const I=new URLSearchParams(Object.entries($.query).flatMap(([V,ve])=>Array.isArray(ve)?ve.map(Fe=>[V,Fe]):[[V,ve]])).toString(),q=I?`?${I}`:"",W=$.hash?`#${$.hash}`:"",x=s?`#${$.path}${q}${W}`:`${n}${$.path}${q}${W}`;history.replaceState(b(),"",x);return}p(u),u=E.state?.__bqScrollKey??v(),w(),y(u);for(const O of a)O(fe.value,$)}finally{Ro()}};window.addEventListener("popstate",k),w();const A={push:E=>S(E,"pushState"),replace:E=>S(E,"replaceState"),back:()=>history.back(),forward:()=>history.forward(),go:E=>history.go(E),beforeEach:E=>(i.push(E),()=>{const T=i.indexOf(E);T>-1&&i.splice(T,1)}),afterEach:E=>(a.push(E),()=>{const T=a.indexOf(E);T>-1&&a.splice(T,1)}),currentRoute:To,routes:c,base:n,hash:s,destroy:()=>{window.removeEventListener("popstate",k),i.length=0,a.length=0,l.clear(),d!==null&&typeof history<"u"&&"scrollRestoration"in history&&(history.scrollRestoration=d),nu(),$o(null)}};return $o(A),A},xe=D(()=>fe.value),Tu={route:xe,path:D(()=>xe.value.path),params:D(()=>xe.value.params),query:D(()=>xe.value.query),hash:D(()=>xe.value.hash),matched:D(()=>xe.value.matched)},Cu=()=>Tu,Ru=()=>{if(!(typeof window>"u"))return window.__BQUERY_DEVTOOLS__||(window.__BQUERY_DEVTOOLS__={stores:new Map}),window.__BQUERY_DEVTOOLS__},$u=(e,t)=>{const r=Ru();r&&(r.stores.set(e,t),r.onStoreCreated?.(e,t))},Ou=e=>{typeof window>"u"||!window.__BQUERY_DEVTOOLS__||window.__BQUERY_DEVTOOLS__.stores.delete(e)},Lu=(e,t)=>{typeof window>"u"||window.__BQUERY_DEVTOOLS__?.onStateChange?.(e,t)},ot=[],Pu=e=>{ot.push(e)},Nu=e=>{const t=ot.indexOf(e);return t===-1?!1:(ot.splice(t,1),!0)},Iu=()=>{ot.length=0},Mu=(e,t)=>{for(const r of[...ot]){const n=r({store:e,options:t});n&&Object.assign(e,n)}},it=new Map,Wo=e=>it.has(e),Du=(e,t)=>{it.set(e,t)},we=e=>it.get(e),Bt=()=>Array.from(it.keys()),_u=e=>{it.delete(e),Ou(e)},Fo=e=>e!==null&&typeof e=="object"&&Object.getPrototypeOf(e)===Object.prototype,Re=e=>{if(e===null||typeof e!="object")return e;if(Array.isArray(e))return e.map(Re);if(e instanceof Date)return new Date(e.getTime());if(e instanceof Map)return new Map(Array.from(e.entries()).map(([r,n])=>[r,Re(n)]));if(e instanceof Set)return new Set(Array.from(e).map(Re));const t={};for(const r of Object.keys(e))t[r]=Re(e[r]);return t},ze=(e,t)=>{if(e===t)return!0;if(e===null||t===null||typeof e!="object"||typeof t!="object")return!1;if(e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime();if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const[s,o]of e.entries())if(!t.has(s)||!ze(o,t.get(s)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const s of e.values()){let o=!1;for(const i of t.values())if(ze(s,i)){o=!0;break}if(!o)return!1}return!0}if(Array.isArray(e)&&Array.isArray(t))return e.length!==t.length?!1:e.every((s,o)=>ze(s,t[o]));if(Array.isArray(e)!==Array.isArray(t))return!1;const r=Object.keys(e),n=Object.keys(t);return r.length!==n.length?!1:r.every(s=>ze(e[s],t[s]))},qu=(e,t,r)=>{const n=[];for(const s of Object.keys(t)){const o=e[s],i=t[s];r.get(s)===i&&Fo(o)&&Fo(i)&&!ze(o,i)&&n.push(s)}return n},at=()=>jt(),Ir=e=>{const{id:t,state:r,getters:n={},actions:s={}}=e;if(Wo(t))return console.warn(`bQuery store: Store "${t}" already exists. Returning existing instance.`),we(t);const o=r(),i=new Map;for(const g of Object.keys(o))i.set(g,L(o[g]));const a=[],c=[],l=(g,w,S)=>{!at()||typeof console>"u"||typeof console.error!="function"||console.error(`[bQuery store "${t}"] Error in $onAction ${g} for action "${w}"`,S)},u=new WeakSet,h=(g,w)=>{!at()||typeof console>"u"||typeof console.warn!="function"||u.has(g)||(u.add(g),console.warn(`[bQuery store "${t}"] Async $onAction listener detected for action "${w}". If it awaits, register after()/onError() before the first await; late registrations will not affect the current action.`))},d=(g,w,S,k)=>{try{const A=S();Ie(A)&&(g==="listener"&&k&&h(k,w),A.catch(E=>{l(g,w,E)}))}catch(A){l(g,w,A)}},v=()=>Ae(()=>({...p})),f=()=>{const g=typeof window<"u"&&typeof window.__BQUERY_DEVTOOLS__?.onStateChange=="function";if(a.length===0&&!g)return;const w=v();for(const S of a)S(w);Lu(t,w)},p=new Proxy({},{get:(g,w)=>{const S=w;if(i.has(S))return i.get(S).value},ownKeys:()=>Array.from(i.keys()),getOwnPropertyDescriptor:(g,w)=>{if(i.has(w))return{enumerable:!0,configurable:!0}},has:(g,w)=>i.has(w)}),y=new Map,b={};for(const g of Object.keys(o))Object.defineProperty(b,g,{get:()=>i.get(g).value,set:w=>{i.get(g).value=w,f()},enumerable:!0,configurable:!1});for(const g of Object.keys(n)){const w=n[g],S=D(()=>w(p,new Proxy({},{get:(k,A)=>{const E=A;if(y.has(E))return y.get(E).value}})));y.set(g,S),Object.defineProperty(b,g,{get:()=>S.value,enumerable:!0,configurable:!1})}for(const g of Object.keys(s)){const w=s[g],S=g;b[S]=function(...k){const A=new Proxy(b,{get:(C,O)=>typeof O=="string"&&i.has(O)?i.get(O).value:C[O],set:(C,O,I)=>typeof O=="string"&&i.has(O)?(i.get(O).value=I,f(),!0):Reflect.set(C,O,I)});if(c.length===0)return w.apply(A,k);const E=[],T=[],P=[...c],R={name:S,store:b,args:k,after:C=>{E.push(O=>C(O))},onError:C=>{T.push(C)}};for(const C of P)d("listener",S,()=>C(R),C);let $;try{$=w.apply(A,k)}catch(C){for(const O of T)d("onError",S,()=>O(C));throw C}if(Ie($))return $.then(C=>{for(const O of E)d("after",S,()=>O(C));return C},C=>{for(const O of T)d("onError",S,()=>O(C));throw C});for(const C of E)d("after",S,()=>C($));return $}}return Object.defineProperties(b,{$id:{value:t,writable:!1,enumerable:!1},$reset:{value:()=>{const g=r();ke(()=>{for(const[w,S]of i)S.value=g[w]}),f()},writable:!1,enumerable:!1},$subscribe:{value:g=>(a.push(g),()=>{const w=a.indexOf(g);w>-1&&a.splice(w,1)}),writable:!1,enumerable:!1},$onAction:{value:g=>(c.push(g),()=>{const w=c.indexOf(g);w>-1&&c.splice(w,1)}),writable:!1,enumerable:!1},$patch:{value:g=>{ke(()=>{if(typeof g=="function"){const w=at(),S=w?Re(v()):null,k=w?new Map(Array.from(i.entries()).map(([E,T])=>[E,T.value])):null,A=v();if(g(A),w&&S&&k){const E=qu(S,A,k);E.length>0&&console.warn(`[bQuery store "${t}"] Nested mutation detected in $patch() for keys: ${E.map(String).join(", ")}.
255
255
  Nested object mutations do not trigger reactive updates because the store uses shallow reactivity.
256
256
  To fix this, either:
257
257
  1. Replace the entire object: state.user = { ...state.user, name: "New" }
258
258
  2. Use $patchDeep() for automatic deep cloning
259
- See: https://bquery.dev/guide/store#deep-reactivity`)}for(const[E,T]of Object.entries(A))i.has(E)&&(i.get(E).value=T)}else for(const[w,S]of Object.entries(g))i.has(w)&&(i.get(w).value=S)}),f()},writable:!1,enumerable:!1},$patchDeep:{value:g=>{Se(()=>{if(typeof g=="function"){const w=Te(p());g(w);for(const[S,k]of Object.entries(w))i.has(S)&&(i.get(S).value=k)}else for(const[w,S]of Object.entries(g))i.has(w)&&(i.get(w).value=Te(S))}),f()},writable:!1,enumerable:!1},$state:{get:()=>p(),enumerable:!1}}),Iu(t,b),Nu(b,e),$u(t,b),b},_u=(e,t)=>()=>io(e)?we(e):Pr({id:e,...t}),xu=(e,t)=>{const r={};for(const n of t)Object.defineProperty(r,n,{get:()=>e[n],enumerable:!0});return r},qu=(e,t)=>{const r={};for(const n of t)Object.defineProperty(r,n,{get:()=>e[n],enumerable:!0});return r},zu=(e,t)=>{const r={};for(const n of t)r[n]=(...s)=>e[n](...s);return r},ju="__version",Uu={serialize:e=>JSON.stringify(e),deserialize:e=>JSON.parse(e)},co=e=>{if(typeof e!="object"||e===null||Array.isArray(e))return!1;const t=Object.getPrototypeOf(e);return t===null||Object.getPrototypeOf(t)===null},Hu=(e,t)=>{const r={...e};for(const[n,s]of Object.entries(t))N(n)||Object.prototype.hasOwnProperty.call(e,n)&&(r[n]=s);return r},Wu=()=>{try{return globalThis.localStorage}catch{return}},Fu=(e,t)=>{const r=typeof t=="string"?{key:t}:t??{},n=r.key??`bquery-store-${e.id}`,s=r.storage??Wu(),o=r.serializer??Uu,i=r.version,a=r.migrate,c=n+ju;let l=s!==void 0&&i!==void 0,u=!1,h=!1;const d=m=>{if(!s||i===void 0)return!1;try{return s.setItem(c,String(i)),!0}catch(v){return m&&it()&&typeof console<"u"&&typeof console.warn=="function"&&console.warn(m,v),!1}},p=e.state,f=Pr({...e,state:()=>{const m=p();if(!s)return m;try{const v=s.getItem(n);if(!v)return m;const b=o.deserialize(v);if(!co(b))return m;let g=b;if(i!==void 0&&a){const w=s.getItem(c),S=w!==null?Number(w):0,k=Number.isFinite(S)?S:0;if(k!==i){l=!1,u=!0;const A=a(g,k);if(!co(A))return m;g=A;let E=!1;try{s.setItem(n,o.serialize(g)),E=!0,h=!0}catch(T){it()&&typeof console<"u"&&typeof console.warn=="function"&&console.warn(`[bQuery store "${e.id}"] Failed to persist migrated state:`,T)}E&&d(`[bQuery store "${e.id}"] Failed to persist migrated version:`)&&(u=!1)}else l=!1}return Hu(m,g)}catch{return m}}});return l&&s?d():u&&h&&d(`[bQuery store "${e.id}"] Failed to persist migrated version after store creation:`)&&(u=!1),f.$subscribe(m=>{if(s)try{s.setItem(n,o.serialize(m)),u&&d(`[bQuery store "${e.id}"] Failed to persist migrated version after a successful state write:`)&&(u=!1)}catch{}}),f},Bu=(e,t,r,n={})=>{const s=n.equals??(n.deep?qe:Object.is);let o=t(e.$state);return n.immediate&&r(o,void 0),e.$subscribe(i=>{const a=t(i);if(!s(a,o)){const c=o;o=a,r(a,c)}})},lo=500,uo=class{constructor(e){this.cache=new Map,this.maxSize=e}get(e){const t=this.cache.get(e);return t!==void 0&&(this.cache.delete(e),this.cache.set(e,t)),t}set(e,t){if(this.cache.has(e))this.cache.delete(e);else if(this.cache.size>=this.maxSize){const r=this.cache.keys().next().value;r!==void 0&&this.cache.delete(r)}this.cache.set(e,t)}clear(){this.cache.clear()}get size(){return this.cache.size}},fo=new uo(lo),ho=new uo(lo),Qu=e=>new Proxy(e,{get(t,r){if(typeof r!="string")return Reflect.get(t,r);const n=t[r];return G(n)||ce(n)?n.value:n},has(t,r){return typeof r!="string"?Reflect.has(t,r):r in t}}),Q=(e,t)=>{try{const r=Qu(t);let n=fo.get(e);return n||(n=new Function("$ctx",`with($ctx) { return (${e}); }`),fo.set(e,n)),n(r)}catch(r){console.error(`bQuery view: Error evaluating "${e}"`,r);return}},Ft=(e,t)=>{try{let r=ho.get(e);return r||(r=new Function("$ctx",`with($ctx) { return (${e}); }`),ho.set(e,r)),r(t)}catch(r){console.error(`bQuery view: Error evaluating "${e}"`,r);return}},Nr=e=>{const t={},r=e.trim().replace(/^\{|\}$/g,"").trim();if(!r)return t;const n=[];let s="",o=0,i=null;for(let a=0;a<r.length;a++){const c=r[a];if(c==='"'||c==="'"||c==="`"){let l=0,u=a-1;for(;u>=0&&r[u]==="\\";)l++,u--;l%2===0&&(i===null?i=c:i===c&&(i=null)),s+=c;continue}if(i!==null){s+=c;continue}c==="("||c==="["||c==="{"?(o++,s+=c):c===")"||c==="]"||c==="}"?(o--,s+=c):c===","&&o===0?(n.push(s.trim()),s=""):s+=c}s.trim()&&n.push(s.trim());for(const a of n){let c=-1,l=0,u=null;for(let h=0;h<a.length;h++){const d=a[h];if(d==='"'||d==="'"||d==="`"){let p=0,f=h-1;for(;f>=0&&a[f]==="\\";)p++,f--;p%2===0&&(u===null?u=d:u===d&&(u=null));continue}if(u===null){if(d==="("||d==="["||d==="{")l++;else if(d===")"||d==="]"||d==="}")l--;else if(d===":"&&l===0){c=h;break}}}if(c>-1){const h=a.slice(0,c).trim().replace(/^['"]|['"]$/g,"");if(N(h))continue;t[h]=a.slice(c+1).trim()}}return t},Vu=e=>e.replace(/([A-Z])/g,"-$1").toLowerCase(),Ku=e=>{const t=e.trim(),r=t.toLowerCase();return r.startsWith("aria-")?r:`aria-${Vu(/^aria[A-Z]/.test(t)?t.slice(4):t).replace(/^-/,"")}`},Yu=e=>e==null||e==="",Ju=(e,t,r,n)=>{let s=new Set;const o=j(()=>{const i=new Set,a=Object.create(null);if(t.trimStart().startsWith("{")){const c=Nr(t);for(const[l,u]of Object.entries(c))a[l]=Q(u,r)}else{const c=Q(t,r);if(c&&typeof c=="object"&&!Array.isArray(c))for(const[l,u]of Object.entries(c))N(l)||(a[l]=u)}for(const[c,l]of Object.entries(a)){const u=Ku(c);if(Yu(l)){e.removeAttribute(u);continue}e.setAttribute(u,l===!0?"true":String(l)),i.add(u)}for(const c of s)i.has(c)||e.removeAttribute(c);s=i});n.push(o)},Gu=e=>(t,r,n,s)=>{const o=j(()=>{const i=Q(r,n);i==null||i===!1?t.removeAttribute(e):i===!0?t.setAttribute(e,""):t.setAttribute(e,String(i))});s.push(o)},Xu=(e,t,r,n)=>{let s=new Set;const o=j(()=>{const i=new Set;if(t.trimStart().startsWith("{")){const a=Nr(t);for(const[c,l]of Object.entries(a)){const u=Q(l,r);e.classList.toggle(c,!!u),i.add(c)}}else if(/^\s*\[/.test(t)){const a=Q(t,r);if(Array.isArray(a))for(const c of a)c&&(e.classList.add(c),i.add(c))}else{const a=Q(t,r);typeof a=="string"?a.split(/\s+/).forEach(c=>{c&&(e.classList.add(c),i.add(c))}):Array.isArray(a)&&a.forEach(c=>{c&&(e.classList.add(c),i.add(c))})}for(const a of s)i.has(a)||e.classList.remove(a);s=i});n.push(o)},Zu=e=>{if(G(e)||ce(e))return String(e.value??"");if(e&&typeof e=="object"&&"error"in e){const t=e.error;return G(t)||ce(t)?String(t.value??""):String(t??"")}return String(e??"")},ef=(e,t,r,n)=>{const s=e,o=!s.hasAttribute("aria-hidden");s.hasAttribute("role")||s.setAttribute("role","alert"),s.hasAttribute("aria-live")||s.setAttribute("aria-live","assertive");const i=j(()=>{const a=Zu(Q(t,r)).trim(),c=a.length>0;s.textContent=a,s.hidden=!c,o&&(c?s.removeAttribute("aria-hidden"):s.setAttribute("aria-hidden","true"))});n.push(i)},tf=(e,t,r,n,s,o)=>{if(!r)return t;const i={...o,[n]:e};return s&&(i[s]=t),Q(r,i)},rf=e=>{const{prefix:t,processElement:r,processChildren:n}=e;return(s,o,i,a)=>{const c=s.parentNode;if(!c)return;const l=o.match(/^\(?(\w+)(?:\s*,\s*(\w+))?\)?\s+in\s+(\S.*)$/);if(!l){console.error(`bQuery view: Invalid bq-for expression "${o}"`);return}const[,u,h,d]=l,p=s.getAttribute(":key")||s.getAttribute(`${t}-key`),f=s.cloneNode(!0);f.removeAttribute(`${t}-for`),f.removeAttribute(":key"),f.removeAttribute(`${t}-key`);const m=document.createComment(`bq-for: ${o}`);c.replaceChild(m,s);let v=new Map,b=[];const g=(A,E,T)=>{const P=f.cloneNode(!0),C=[],$=L(A),R=h?L(E):null,O={...i,[u]:$};return h&&R&&(O[h]=R),r(P,O,t,C),n(P,O,t,C),{key:T,element:P,cleanups:C,item:A,index:E,itemSignal:$,indexSignal:R}},w=A=>{for(const E of A.cleanups)E();A.element.remove()},S=(A,E,T)=>{Object.is(A.item,E)||(A.item=E,A.itemSignal.value=E),A.index!==T&&(A.index=T,A.indexSignal&&(A.indexSignal.value=T))},k=j(()=>{const A=Q(d,i);if(!Array.isArray(A)){for(const O of v.values())w(O);v.clear(),b=[];return}const E=[],T=new Map,P=new Set;A.forEach((O,I)=>{let x=tf(O,I,p,u,h,i);P.has(x)&&(console.warn(`bq-for: Duplicate key "${String(x)}" detected at index ${I}. Falling back to index-based key for this item. Ensure :key expressions produce unique values for each item.`),x={__bqDuplicateKey:x,__bqIndex:I}),P.add(x),E.push(x),T.set(x,{item:O,index:I})});const C=[];for(const O of b)T.has(O)||C.push(O);for(const O of C){const I=v.get(O);I&&(w(I),v.delete(O))}const $=new Map;let R=m;for(let O=0;O<E.length;O++){const I=E[O],{item:x,index:W}=T.get(I);let q=v.get(I);q?(S(q,x,W),$.set(I,q),R.nextSibling!==q.element&&R.after(q.element),R=q.element):(q=g(x,W,I),$.set(I,q),R.after(q.element),R=q.element)}v=$,b=E});a.push(()=>{k();for(const A of v.values())for(const E of A.cleanups)E();v.clear()})}},nf=e=>(t,r,n,s)=>{const o=j(()=>{const i=Q(r,n),a=String(i??"");t.innerHTML=e?ie(a):a});s.push(o)},sf=(e,t,r,n)=>{const s=document.createComment(`bq-if: ${t}`);let o=!0;const i=j(()=>{const a=Q(t,r);a&&!o?(s.replaceWith(e),o=!0):!a&&o&&(e.replaceWith(s),o=!1)});n.push(i)},of=(e,t,r,n)=>{const s=e,o=Ft(t,r);if(!G(o)){console.warn(`bQuery view: bq-model requires a signal, got "${t}"`);return}const i=o,a=s.type==="checkbox",c=s.type==="radio",l=()=>{a?s.checked=!!i.value:c?s.checked=i.value===s.value:s.value=String(i.value??"")},u=j(()=>{l()});n.push(u);const h=s.tagName==="SELECT"?"change":"input",d=()=>{a?i.value=s.checked:c?s.checked&&(i.value=s.value):i.value=s.value};s.addEventListener(h,d),n.push(()=>s.removeEventListener(h,d))},af=e=>(t,r,n,s)=>{const o=i=>{const a={...n,$event:i,$el:t};if(!r.includes("(")){const c=Ft(r,a);if(typeof c=="function"){c(i);return}return}Ft(r,a)};t.addEventListener(e,o),s.push(()=>t.removeEventListener(e,o))};function cf(e){const t=Object.getOwnPropertyDescriptor(e,"value");return t?"value"in t?t.writable===!0:typeof t.set=="function":!1}var lf=(e,t,r,n)=>{const s=Ft(t,r);G(s)?(s.value=e,n.push(()=>{s.value=null})):typeof s=="object"&&s!==null&&cf(s)&&(s.value=e,n.push(()=>{s.value=null}))},uf=(e,t,r,n)=>{const s=e;let o=s.style.display;if(!o||o==="none"){const a=s.ownerDocument.defaultView?.getComputedStyle(s).display??"";o=a!=="none"?a:""}const i=j(()=>{const a=Q(t,r);s.style.display=a?o:"none"});n.push(i)},ff=(e,t,r,n)=>{const s=e;let o=new Set;const i=j(()=>{const a=new Set;if(t.trimStart().startsWith("{")){const c=Nr(t);for(const[l,u]of Object.entries(c)){const h=Q(u,r),d=l.replace(/([A-Z])/g,"-$1").toLowerCase();s.style.setProperty(d,String(h??"")),a.add(d)}}else{const c=Q(t,r);if(c&&typeof c=="object")for(const[l,u]of Object.entries(c)){const h=l.replace(/([A-Z])/g,"-$1").toLowerCase();s.style.setProperty(h,String(u??"")),a.add(h)}}for(const c of o)a.has(c)||s.style.removeProperty(c);o=a});n.push(i)},df=(e,t,r,n)=>{const s=j(()=>{const o=Q(t,r);e.textContent=String(o??"")});n.push(s)},Ir=null,hf=e=>{Ir=e},mf=e=>Ir?Ir(e):void 0,Bt=(e,t,r,n,s)=>{const o=Array.from(e.attributes);for(const i of o){const{name:a,value:c}=i;if(!a.startsWith(`${r}-`))continue;const l=a.slice(r.length+1);if(l==="for"){s.for(e,c,t,n);return}if(l==="text")s.text(e,c,t,n);else if(l==="error")s.error(e,c,t,n);else if(l==="aria")s.aria(e,c,t,n);else if(l==="html")s.html(e,c,t,n);else if(l==="if")s.if(e,c,t,n);else if(l==="show")s.show(e,c,t,n);else if(l==="class")s.class(e,c,t,n);else if(l==="style")s.style(e,c,t,n);else if(l==="model")s.model(e,c,t,n);else if(l==="ref")s.ref(e,c,t,n);else if(l.startsWith("bind:")){const u=l.slice(5);s.bind(u)(e,c,t,n)}else if(l.startsWith("on:")){const u=l.slice(3);s.on(u)(e,c,t,n)}else{const u=mf(l);u?u(e,c,t,n):qt()&&typeof console<"u"&&typeof console.warn=="function"&&console.warn(`[bQuery][view] Unknown directive "${a}" (parsed as "${l}") on <${e.tagName.toLowerCase()}>. This may be a typo or a missing custom directive registration.`)}}},Mr=(e,t,r,n,s)=>{const o=Array.from(e.children);for(const i of o)i.hasAttribute(`${r}-for`)?Bt(i,t,r,n,s):(Bt(i,t,r,n,s),Mr(i,t,r,n,s))},Dr=(e,t,r={})=>{const{prefix:n="bq",sanitize:s=!0}=r,o=typeof e=="string"?document.querySelector(e):e;if(!o)throw new Error(`bQuery view: Element "${e}" not found.`);if(o.hasAttribute(`${n}-for`))throw new Error(`bQuery view: Cannot mount on element with ${n}-for directive. Wrap the ${n}-for element in a container instead.`);const i=[],a={text:df,error:ef,aria:Ju,html:nf(s),if:sf,show:uf,class:Xu,style:ff,model:of,ref:lf,for:rf({prefix:n,processElement:(l,u,h,d)=>Bt(l,u,h,d,a),processChildren:(l,u,h,d)=>Mr(l,u,h,d,a)}),bind:Gu,on:af};return((l,u,h)=>{const d=l.hasAttribute(`${n}-for`);Bt(l,u,n,h,a),d||Mr(l,u,n,h,a)})(o,t,i),{el:o,context:t,update:l=>{Object.assign(t,l)},destroy:()=>{for(const l of i)l();i.length=0}}},pf=(e,t={})=>r=>{const n=document.createElement("div");n.innerHTML=e.trim();const s=n.firstElementChild;if(!s)throw new Error("bQuery view: Template must contain a single root element.");if(n.childElementCount>1)throw new Error(`bQuery view: Template must contain exactly one root element, found ${n.childElementCount}.`);const{prefix:o="bq"}=t;if(s.hasAttribute(`${o}-for`)||s.hasAttribute(`${o}-if`)){const i=s.hasAttribute(`${o}-for`)?"for":"if";throw new Error(`bQuery view: Template root element cannot have ${o}-${i} directive. Wrap the ${o}-${i} element in a container instead.`)}return Dr(s,r,t)},vf=e=>e===!0||e===void 0,yf=async(e,t)=>{const r=e(t),n=Fe(r)?await r:r;return vf(n)?void 0:n},gf=e=>{const t=e.initialValue,r=L(t),n=L(""),s=L(!1),o=D(()=>!Object.is(r.value,t));return{value:r,error:n,isDirty:o,isTouched:s,isPristine:D(()=>!o.value),touch:()=>{s.value=!0},reset:()=>{r.value=t,n.value="",s.value=!1}}},mo=async(e,t)=>{if(!t||t.length===0)return e.error.value="","";for(const r of t){const n=await yf(r,e.value.value);if(n)return e.error.value=n,n}return e.error.value="",""},bf=e=>{const t=Object.entries(e.fields),r={},n={};for(const[f,m]of t){const v=gf(m);r[f]=v,n[f]=v.error}const s=L(!1),o=D(()=>{for(const f of Object.keys(r))if(r[f].error.value!=="")return!1;return!0}),i=D(()=>{for(const f of Object.keys(r))if(r[f].isDirty.value)return!0;return!1}),a=async f=>{const m=r[f],v=e.fields[f];!m||!v||await mo(m,v.validators)},c=async()=>{let f=!1;for(const[m,v]of t){const b=r[m];await mo(b,v.validators)&&(f=!0)}if(e.crossValidators&&e.crossValidators.length>0){const m=h();for(const v of e.crossValidators){const b=await v(m);if(b){for(const[g,w]of Object.entries(b))if(w){const S=r[g];S&&(S.error.value===""&&(S.error.value=w),f=!0)}}}}return!f},l=async()=>{if(!s.value){s.value=!0;try{if(!await c())return;e.onSubmit&&await e.onSubmit(h())}finally{s.value=!1}}},u=()=>{for(const f of Object.keys(r))r[f].reset()},h=()=>{const f={};for(const m of Object.keys(r))f[m]=r[m].value.value;return f};return{fields:r,errors:n,isValid:o,isDirty:i,isSubmitting:s,handleSubmit:l,validateField:a,validate:c,reset:u,getValues:h,setValues:f=>{for(const[m,v]of Object.entries(f)){if(N(m)||!Object.prototype.hasOwnProperty.call(r,m))continue;const b=r[m];b&&(b.value.value=v)}},setErrors:f=>{for(const[m,v]of Object.entries(f)){if(N(m)||!Object.prototype.hasOwnProperty.call(r,m))continue;const b=r[m];b&&(b.error.value=v??"")}}}},wf=e=>e===!0||e===void 0,Sf=async(e,t)=>{const r=e(t),n=Fe(r)?await r:r;return wf(n)?void 0:n},Ef=(e,t={})=>{let r;Af(e)?r=e:r=L(Wn(e)||kf(e)?e.peek():e);const n=r.peek(),s=L(t.initialError??""),o=L(!1),i=L(!1),a=D(()=>!Object.is(r.value,n)),c=D(()=>!a.value),l=D(()=>s.value===""),u=t.validateOn??"manual",h=Math.max(0,t.debounceMs??0);let d=0,p=!1,f=!1,m=!1,v;const b=A=>{console.error("bQuery forms: Error in scheduled field validation",A)},g=async()=>{const A=++d,E=t.validators;if(!E||E.length===0)return s.value="",i.value=!1,!0;i.value=!0;try{const T=r.peek();for(const P of E){const C=await Sf(P,T);if(A!==d)return s.peek()==="";if(C)return s.value=C,!1}return A===d&&(s.value=""),!0}finally{A===d&&(i.value=!1)}},w=fr(()=>{g().catch(b)},h),S=()=>{if(!m){if(h>0){w();return}g().catch(b)}};return(u==="change"||u==="both")&&(v=j(()=>{if(r.value,!p){p=!0;return}if(f){f=!1;return}S()})),{value:r,error:s,isDirty:a,isTouched:o,isPristine:c,isValid:l,isValidating:i,touch:()=>{o.value=!0,(u==="blur"||u==="both")&&S()},reset:()=>{d+=1,w.cancel(),Object.is(r.peek(),n)||(f=!0),r.value=n,s.value=t.initialError??"",o.value=!1,i.value=!1},validate:async()=>(w.cancel(),g()),destroy:()=>{m||(m=!0,d+=1,w.cancel(),v?.(),v=void 0,a.dispose(),c.dispose(),l.dispose(),i.value=!1)}}},Af=e=>e instanceof Ge,kf=e=>e instanceof Je,Tf=(e="This field is required")=>t=>t==null||typeof t=="string"&&t.trim()===""||Array.isArray(t)&&t.length===0?e:!0,Rf=(e,t)=>{const r=t??`Must be at least ${e} characters`;return n=>(typeof n=="string"?n:String(n??"")).length>=e?!0:r},Cf=(e,t)=>{const r=t??`Must be at most ${e} characters`;return n=>(typeof n=="string"?n:String(n??"")).length<=e?!0:r},$f=(e,t="Invalid format")=>{const r=e.global||e.sticky?new RegExp(e.source,e.flags.replace(/[gy]/g,"")):e;return n=>{const s=typeof n=="string"?n:String(n??"");return r.lastIndex=0,r.test(s)?!0:t}},Of=(e="Invalid email address")=>{const t=/^[^\s@]+@[^\s@]+\.[^\s@]+$/;return r=>{const n=typeof r=="string"?r:String(r??"");return n===""||t.test(n)?!0:e}},Lf=(e="Invalid URL")=>t=>{const r=typeof t=="string"?t:String(t??"");if(r==="")return!0;try{return new URL(r),!0}catch{return e}},Pf=(e,t)=>{const r=t??`Must be at least ${e}`;return n=>n==null||typeof n=="string"&&n.trim()===""||(typeof n=="number"?n:Number(n))>=e?!0:r},Nf=(e,t)=>{const r=t??`Must be at most ${e}`;return n=>n==null||typeof n=="string"&&n.trim()===""||(typeof n=="number"?n:Number(n))<=e?!0:r},If=(e,t)=>r=>e(r)?!0:t,Mf=(e,t)=>async r=>await e(r)?!0:t,Df=(e,t="Fields do not match")=>r=>Object.is(r,e.value)?!0:t,po=(e,t,r)=>{const{locale:n,...s}=r??{};try{return new Intl.NumberFormat(t,s).format(e)}catch{return String(e)}},vo=(e,t,r)=>{const{locale:n,...s}=r??{},o=typeof e=="number"?new Date(e):e;try{return new Intl.DateTimeFormat(t,s).format(o)}catch{return o.toLocaleString()}},yo=(e,t)=>{const r=t.split(".");let n=e;for(const s of r){if(typeof n=="string"||n[s]===void 0)return;n=n[s]}return typeof n=="string"?n:void 0},_f=(e,t)=>e.replace(/\{(\w+)\}/g,(r,n)=>n in t?String(t[n]):r),xf=(e,t)=>{if(!e.includes("|")||!("count"in t))return e;const r=Number(t.count),n=e.split("|").map(s=>s.trim());return n.length===3?r===0?n[0]:r===1?n[1]:n[2]:n.length===2?r===1?n[0]:n[1]:r===0&&n.length>0?n[0]:r===1&&n.length>1?n[1]:n[n.length-1]},go=(e,t,r,n)=>{let s;return e&&(s=yo(e,t)),s===void 0&&n&&(s=yo(n,t)),s===void 0?t:_f(xf(s,r),r)},bo=(e,t)=>{const r=Pe(e,t),n=s=>{if(Array.isArray(s))return s.map(i=>n(i));if(!Le(s))return s;const o=Object.create(null);for(const[i,a]of Object.entries(s))N(i)||(o[i]=n(a));return o};return n(r)},qf=e=>{const{locale:t,messages:r,fallbackLocale:n}=e,s=g=>bo(Object.create(null),g),o=Object.create(null);for(const[g,w]of Object.entries(r))N(g)||(o[g]=s(w));const i=L(t),a=new Map,c=new Set(Object.keys(o));return{$locale:i,t:(g,w={})=>{const S=o[i.value];return go(S,g,w,n?o[n]:void 0)},tc:(g,w={})=>D(()=>{const S=o[i.value];return go(S,g,w,n?o[n]:void 0)}),loadLocale:(g,w)=>{N(g)||a.set(g,w)},ensureLocale:async g=>{if(N(g)||c.has(g))return;const w=a.get(g);if(!w)throw new Error(`bQuery i18n: No messages or loader registered for locale "${g}".`);const S=await w();o[g]=s(S.default??S),c.add(g)},n:(g,w)=>po(g,w?.locale??i.value,w),d:(g,w)=>vo(g,w?.locale??i.value,w),getMessages:g=>{if(!N(g))return o[g]},mergeMessages:(g,w)=>{N(g)||(o[g]||(o[g]=Object.create(null),c.add(g)),o[g]=bo(o[g],s(w)))},availableLocales:()=>{const g=new Set([...c,...a.keys()]);return Array.from(g).sort()}}},Qt=new Map,at=new Map,zf=50,jf=e=>{const t=Qt.get(e);if(t&&t.isConnected)return t;const r=document.createElement("div");return r.setAttribute("aria-live",e),r.setAttribute("aria-atomic","true"),r.setAttribute("role",e==="assertive"?"alert":"status"),Object.assign(r.style,{position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",border:"0"}),document.body.appendChild(r),Qt.set(e,r),r},Uf=(e,t="polite")=>{if(!e||typeof document>"u"||!document.body)return;const r=jf(t),n=at.get(t);n!==void 0&&clearTimeout(n),r.textContent="";const s=setTimeout(()=>{at.delete(t),r.isConnected&&(r.textContent=e)},zf);at.set(t,s)},Hf=()=>{for(const e of at.values())clearTimeout(e);at.clear();for(const[,e]of Qt)e.remove();Qt.clear()},ne=(e,t,r,n)=>({severity:e,message:t,element:r,rule:n}),Wf=e=>{const t=[],r=e.querySelectorAll("img");for(const n of r)n.hasAttribute("alt")?n.getAttribute("alt")===""&&!n.hasAttribute("role")&&t.push(ne("info",'Image has empty alt text. Consider adding role="presentation" if decorative.',n,"img-decorative")):t.push(ne("error",'Image is missing an alt attribute. Add alt="" for decorative images or a descriptive alt text.',n,"img-alt"));return t},Ff=e=>{const t=[],r=e.querySelectorAll("input, select, textarea");for(const n of r){const s=n.getAttribute("type");if(s==="hidden"||s==="submit"||s==="button"||s==="reset")continue;const o=n.getAttribute("id"),i=o?!!e.querySelector(`label[for="${o}"]`):!1,a=n.hasAttribute("aria-label")||n.hasAttribute("aria-labelledby"),c=n.hasAttribute("title"),l=n.closest("label")!==null;!i&&!a&&!c&&!l&&t.push(ne("error",'Form input is missing a label. Add a <label for="id">, aria-label, or aria-labelledby attribute.',n,"input-label"))}return t},Bf=e=>{const t=[],r=e.querySelectorAll("button");for(const s of r){const o=(s.textContent??"").trim().length>0,i=s.hasAttribute("aria-label")||s.hasAttribute("aria-labelledby"),a=s.hasAttribute("title");!o&&!i&&!a&&t.push(ne("error","Button has no accessible name. Add text content, aria-label, or title.",s,"button-name"))}const n=e.querySelectorAll("a[href]");for(const s of n){const o=(s.textContent??"").trim().length>0,i=s.hasAttribute("aria-label")||s.hasAttribute("aria-labelledby"),a=s.hasAttribute("title"),c=s.querySelector("img[alt]")!==null;!o&&!i&&!a&&!c&&t.push(ne("error","Link has no accessible name. Add text content, aria-label, or title.",s,"link-name"))}return t},Qf=e=>{const t=[],r=e.querySelectorAll("h1, h2, h3, h4, h5, h6");let n=0;for(const s of r){const o=parseInt(s.tagName.charAt(1),10);n>0&&o>n+1&&t.push(ne("warning",`Heading level skipped: <${s.tagName.toLowerCase()}> follows <h${n}>. Don't skip heading levels.`,s,"heading-order")),(s.textContent??"").trim().length===0&&t.push(ne("warning","Heading element is empty.",s,"heading-empty")),n=o}return t},Vf=e=>{const t=[],r=e.querySelectorAll("[aria-labelledby]");for(const s of r){const o=(s.getAttribute("aria-labelledby")??"").split(/\s+/);for(const i of o)i&&!document.getElementById(i)&&t.push(ne("error",`aria-labelledby references "${i}" which does not exist in the document.`,s,"aria-labelledby-ref"))}const n=e.querySelectorAll("[aria-describedby]");for(const s of n){const o=(s.getAttribute("aria-describedby")??"").split(/\s+/);for(const i of o)i&&!document.getElementById(i)&&t.push(ne("error",`aria-describedby references "${i}" which does not exist in the document.`,s,"aria-describedby-ref"))}return t},Kf=e=>{const t=[];return(e===document.body||e===document.documentElement)&&(e.querySelector("main")||e.querySelector('[role="main"]')||t.push(ne("warning",'Page is missing a <main> landmark. Add <main> or role="main" to the primary content area.',e,"landmark-main"))),t},Yf=e=>{if(typeof document>"u"||!document.body)return{findings:[],errors:0,warnings:0,passed:!0};const t=e??document.body,r=[...Wf(t),...Ff(t),...Bf(t),...Qf(t),...Vf(t),...Kf(t)],n=r.filter(s=>s.severity==="error").length;return{findings:r,errors:n,warnings:r.filter(s=>s.severity==="warning").length,passed:n===0}},wo=(e,t)=>{if(typeof e.addEventListener=="function")return e.addEventListener("change",t),()=>{e.removeEventListener("change",t)};const r=e;if(typeof r.addListener=="function")return r.addListener(t),()=>{r.removeListener?.(t)}},So=(e,t)=>{let r=t;const n=e;return Object.defineProperty(n,"destroy",{configurable:!0,enumerable:!1,value:()=>{const s=r;r=()=>{},s()}}),n},Jf=()=>{const e=L("light");let t=()=>{e.dispose()};if(typeof window<"u"&&typeof window.matchMedia=="function")try{const r=window.matchMedia("(prefers-color-scheme: dark)");e.value=r.matches?"dark":"light";const s=wo(r,o=>{e.value=o.matches?"dark":"light"});s&&(t=()=>{s(),e.dispose()})}catch{}return So(_(e),t)},Gf=()=>{const e=L("no-preference");let t=()=>{e.dispose()};if(typeof window<"u"&&typeof window.matchMedia=="function"){let r,n,s;const o=()=>{!r||!n||!s||(r.matches?e.value="more":n.matches?e.value="less":s.matches?e.value="custom":e.value="no-preference")};try{r=window.matchMedia("(prefers-contrast: more)"),n=window.matchMedia("(prefers-contrast: less)"),s=window.matchMedia("(prefers-contrast: custom)"),o();const i=[r,n,s].map(a=>wo(a,()=>{o()})).filter(a=>a!==void 0);i.length>0&&(t=()=>{for(const a of i)a();e.dispose()})}catch{}}return So(_(e),t)},Xf=(e,t,r={})=>{const{wrap:n=!0,orientation:s="vertical",onActivate:o}=r;let i=0;const a=new Map,c=()=>Array.from(e.querySelectorAll(t)),l=f=>{for(const m of f)a.has(m)||a.set(m,m.getAttribute("tabindex"))},u=f=>{const m=c();if(m.length===0)return;l(m);const v=Math.max(0,Math.min(f,m.length-1));for(let b=0;b<m.length;b++)m[b].setAttribute("tabindex",b===v?"0":"-1");i=v,m[v].focus(),o?.(m[v],v)},h=f=>{if(f==="Home"||f==="End")return!0;switch(s){case"horizontal":return f==="ArrowLeft"||f==="ArrowRight";case"vertical":return f==="ArrowUp"||f==="ArrowDown";case"both":return f==="ArrowLeft"||f==="ArrowRight"||f==="ArrowUp"||f==="ArrowDown";default:return!1}},d=f=>{if(!h(f.key))return;const m=c();if(m.length===0)return;f.preventDefault();let v=i;switch(f.key){case"ArrowDown":case"ArrowRight":v=i+1,v>=m.length&&(v=n?0:m.length-1);break;case"ArrowUp":case"ArrowLeft":v=i-1,v<0&&(v=n?m.length-1:0);break;case"Home":v=0;break;case"End":v=m.length-1;break}u(v)},p=c();l(p);for(let f=0;f<p.length;f++)p[f].setAttribute("tabindex",f===0?"0":"-1");return e.addEventListener("keydown",d),{destroy:()=>{e.removeEventListener("keydown",d);for(const[f,m]of a)m===null?f.removeAttribute("tabindex"):f.setAttribute("tabindex",m);a.clear()},focusItem:f=>{u(f)},activeIndex:()=>i}},_r=`
259
+ See: https://bquery.dev/guide/store#deep-reactivity`)}for(const[E,T]of Object.entries(A))i.has(E)&&(i.get(E).value=T)}else for(const[w,S]of Object.entries(g))i.has(w)&&(i.get(w).value=S)}),f()},writable:!1,enumerable:!1},$patchDeep:{value:g=>{ke(()=>{if(typeof g=="function"){const w=Re(v());g(w);for(const[S,k]of Object.entries(w))i.has(S)&&(i.get(S).value=k)}else for(const[w,S]of Object.entries(g))i.has(w)&&(i.get(w).value=Re(S))}),f()},writable:!1,enumerable:!1},$state:{get:()=>v(),enumerable:!1}}),Du(t,b),Mu(b,e),$u(t,b),b},xu=(e,t)=>()=>Wo(e)?we(e):Ir({id:e,...t}),zu=(e,t)=>{const r={};for(const n of t)Object.defineProperty(r,n,{get:()=>e[n],enumerable:!0});return r},ju=(e,t)=>{const r={};for(const n of t)Object.defineProperty(r,n,{get:()=>e[n],enumerable:!0});return r},Uu=(e,t)=>{const r={};for(const n of t)r[n]=(...s)=>e[n](...s);return r},Hu="__version",Wu={serialize:e=>JSON.stringify(e),deserialize:e=>JSON.parse(e)},Bo=e=>{if(typeof e!="object"||e===null||Array.isArray(e))return!1;const t=Object.getPrototypeOf(e);return t===null||Object.getPrototypeOf(t)===null},Fu=(e,t)=>{const r={...e};for(const[n,s]of Object.entries(t))N(n)||Object.prototype.hasOwnProperty.call(e,n)&&(r[n]=s);return r},Bu=()=>{try{return globalThis.localStorage}catch{return}},Qu=(e,t)=>{const r=typeof t=="string"?{key:t}:t??{},n=r.key??`bquery-store-${e.id}`,s=r.storage??Bu(),o=r.serializer??Wu,i=r.version,a=r.migrate,c=n+Hu;let l=s!==void 0&&i!==void 0,u=!1,h=!1;const d=p=>{if(!s||i===void 0)return!1;try{return s.setItem(c,String(i)),!0}catch(y){return p&&at()&&typeof console<"u"&&typeof console.warn=="function"&&console.warn(p,y),!1}},v=e.state,f=Ir({...e,state:()=>{const p=v();if(!s)return p;try{const y=s.getItem(n);if(!y)return p;const b=o.deserialize(y);if(!Bo(b))return p;let g=b;if(i!==void 0&&a){const w=s.getItem(c),S=w!==null?Number(w):0,k=Number.isFinite(S)?S:0;if(k!==i){l=!1,u=!0;const A=a(g,k);if(!Bo(A))return p;g=A;let E=!1;try{s.setItem(n,o.serialize(g)),E=!0,h=!0}catch(T){at()&&typeof console<"u"&&typeof console.warn=="function"&&console.warn(`[bQuery store "${e.id}"] Failed to persist migrated state:`,T)}E&&d(`[bQuery store "${e.id}"] Failed to persist migrated version:`)&&(u=!1)}else l=!1}return Fu(p,g)}catch{return p}}});return l&&s?d():u&&h&&d(`[bQuery store "${e.id}"] Failed to persist migrated version after store creation:`)&&(u=!1),f.$subscribe(p=>{if(s)try{s.setItem(n,o.serialize(p)),u&&d(`[bQuery store "${e.id}"] Failed to persist migrated version after a successful state write:`)&&(u=!1)}catch{}}),f},Vu=(e,t,r,n={})=>{const s=n.equals??(n.deep?ze:Object.is);let o=t(e.$state);return n.immediate&&r(o,void 0),e.$subscribe(i=>{const a=t(i);if(!s(a,o)){const c=o;o=a,r(a,c)}})},Qo=500,Vo=class{constructor(e){this.cache=new Map,this.maxSize=e}get(e){const t=this.cache.get(e);return t!==void 0&&(this.cache.delete(e),this.cache.set(e,t)),t}set(e,t){if(this.cache.has(e))this.cache.delete(e);else if(this.cache.size>=this.maxSize){const r=this.cache.keys().next().value;r!==void 0&&this.cache.delete(r)}this.cache.set(e,t)}clear(){this.cache.clear()}get size(){return this.cache.size}},Mr=new Vo(Qo),Dr=new Vo(Qo),Ku=()=>{Mr.clear(),Dr.clear()},Yu=e=>new Proxy(e,{get(t,r){if(typeof r!="string")return Reflect.get(t,r);const n=t[r];return G(n)||ce(n)?n.value:n},has(t,r){return typeof r!="string"?Reflect.has(t,r):r in t}}),Q=(e,t)=>{try{const r=Yu(t);let n=Mr.get(e);return n||(n=new Function("$ctx",`with($ctx) { return (${e}); }`),Mr.set(e,n)),n(r)}catch(r){console.error(`bQuery view: Error evaluating "${e}"`,r);return}},Qt=(e,t)=>{try{let r=Dr.get(e);return r||(r=new Function("$ctx",`with($ctx) { return (${e}); }`),Dr.set(e,r)),r(t)}catch(r){console.error(`bQuery view: Error evaluating "${e}"`,r);return}},_r=e=>{const t={},r=e.trim().replace(/^\{|\}$/g,"").trim();if(!r)return t;const n=[];let s="",o=0,i=null;for(let a=0;a<r.length;a++){const c=r[a];if(c==='"'||c==="'"||c==="`"){let l=0,u=a-1;for(;u>=0&&r[u]==="\\";)l++,u--;l%2===0&&(i===null?i=c:i===c&&(i=null)),s+=c;continue}if(i!==null){s+=c;continue}c==="("||c==="["||c==="{"?(o++,s+=c):c===")"||c==="]"||c==="}"?(o--,s+=c):c===","&&o===0?(n.push(s.trim()),s=""):s+=c}s.trim()&&n.push(s.trim());for(const a of n){let c=-1,l=0,u=null;for(let h=0;h<a.length;h++){const d=a[h];if(d==='"'||d==="'"||d==="`"){let v=0,f=h-1;for(;f>=0&&a[f]==="\\";)v++,f--;v%2===0&&(u===null?u=d:u===d&&(u=null));continue}if(u===null){if(d==="("||d==="["||d==="{")l++;else if(d===")"||d==="]"||d==="}")l--;else if(d===":"&&l===0){c=h;break}}}if(c>-1){const h=a.slice(0,c).trim().replace(/^['"]|['"]$/g,"");if(N(h))continue;t[h]=a.slice(c+1).trim()}}return t},Ju=e=>e.replace(/([A-Z])/g,"-$1").toLowerCase(),Gu=e=>{const t=e.trim(),r=t.toLowerCase();return r.startsWith("aria-")?r:`aria-${Ju(/^aria[A-Z]/.test(t)?t.slice(4):t).replace(/^-/,"")}`},Xu=e=>e==null||e==="",Zu=(e,t,r,n)=>{let s=new Set;const o=j(()=>{const i=new Set,a=Object.create(null);if(t.trimStart().startsWith("{")){const c=_r(t);for(const[l,u]of Object.entries(c))a[l]=Q(u,r)}else{const c=Q(t,r);if(c&&typeof c=="object"&&!Array.isArray(c))for(const[l,u]of Object.entries(c))N(l)||(a[l]=u)}for(const[c,l]of Object.entries(a)){const u=Gu(c);if(Xu(l)){e.removeAttribute(u);continue}e.setAttribute(u,l===!0?"true":String(l)),i.add(u)}for(const c of s)i.has(c)||e.removeAttribute(c);s=i});n.push(o)},ef=e=>(t,r,n,s)=>{const o=j(()=>{const i=Q(r,n);i==null||i===!1?t.removeAttribute(e):i===!0?t.setAttribute(e,""):t.setAttribute(e,String(i))});s.push(o)},tf=(e,t,r,n)=>{let s=new Set;const o=j(()=>{const i=new Set;if(t.trimStart().startsWith("{")){const a=_r(t);for(const[c,l]of Object.entries(a)){const u=Q(l,r);e.classList.toggle(c,!!u),i.add(c)}}else if(/^\s*\[/.test(t)){const a=Q(t,r);if(Array.isArray(a))for(const c of a)c&&(e.classList.add(c),i.add(c))}else{const a=Q(t,r);typeof a=="string"?a.split(/\s+/).forEach(c=>{c&&(e.classList.add(c),i.add(c))}):Array.isArray(a)&&a.forEach(c=>{c&&(e.classList.add(c),i.add(c))})}for(const a of s)i.has(a)||e.classList.remove(a);s=i});n.push(o)},rf=e=>{if(G(e)||ce(e))return String(e.value??"");if(e&&typeof e=="object"&&"error"in e){const t=e.error;return G(t)||ce(t)?String(t.value??""):String(t??"")}return String(e??"")},nf=(e,t,r,n)=>{const s=e,o=!s.hasAttribute("aria-hidden");s.hasAttribute("role")||s.setAttribute("role","alert"),s.hasAttribute("aria-live")||s.setAttribute("aria-live","assertive");const i=j(()=>{const a=rf(Q(t,r)).trim(),c=a.length>0;s.textContent=a,s.hidden=!c,o&&(c?s.removeAttribute("aria-hidden"):s.setAttribute("aria-hidden","true"))});n.push(i)},sf=(e,t,r,n,s,o)=>{if(!r)return t;const i={...o,[n]:e};return s&&(i[s]=t),Q(r,i)},of=e=>{const{prefix:t,processElement:r,processChildren:n}=e;return(s,o,i,a)=>{const c=s.parentNode;if(!c)return;const l=o.match(/^\(?(\w+)(?:\s*,\s*(\w+))?\)?\s+in\s+(\S.*)$/);if(!l){console.error(`bQuery view: Invalid bq-for expression "${o}"`);return}const[,u,h,d]=l,v=s.getAttribute(":key")||s.getAttribute(`${t}-key`),f=s.cloneNode(!0);f.removeAttribute(`${t}-for`),f.removeAttribute(":key"),f.removeAttribute(`${t}-key`);const p=document.createComment(`bq-for: ${o}`);c.replaceChild(p,s);let y=new Map,b=[];const g=(A,E,T)=>{const P=f.cloneNode(!0),R=[],$=L(A),C=h?L(E):null,O={...i,[u]:$};return h&&C&&(O[h]=C),r(P,O,t,R),n(P,O,t,R),{key:T,element:P,cleanups:R,item:A,index:E,itemSignal:$,indexSignal:C}},w=A=>{for(const E of A.cleanups)E();A.element.remove()},S=(A,E,T)=>{Object.is(A.item,E)||(A.item=E,A.itemSignal.value=E),A.index!==T&&(A.index=T,A.indexSignal&&(A.indexSignal.value=T))},k=j(()=>{const A=Q(d,i);if(!Array.isArray(A)){for(const O of y.values())w(O);y.clear(),b=[];return}const E=[],T=new Map,P=new Set;A.forEach((O,I)=>{let q=sf(O,I,v,u,h,i);P.has(q)&&(console.warn(`bq-for: Duplicate key "${String(q)}" detected at index ${I}. Falling back to index-based key for this item. Ensure :key expressions produce unique values for each item.`),q={__bqDuplicateKey:q,__bqIndex:I}),P.add(q),E.push(q),T.set(q,{item:O,index:I})});const R=[];for(const O of b)T.has(O)||R.push(O);for(const O of R){const I=y.get(O);I&&(w(I),y.delete(O))}const $=new Map;let C=p;for(let O=0;O<E.length;O++){const I=E[O],{item:q,index:W}=T.get(I);let x=y.get(I);x?(S(x,q,W),$.set(I,x),C.nextSibling!==x.element&&C.after(x.element),C=x.element):(x=g(q,W,I),$.set(I,x),C.after(x.element),C=x.element)}y=$,b=E});a.push(()=>{k();for(const A of y.values())for(const E of A.cleanups)E();y.clear()})}},af=e=>(t,r,n,s)=>{const o=j(()=>{const i=Q(r,n),a=String(i??"");t.innerHTML=e?ie(a):a});s.push(o)},cf=(e,t,r,n)=>{const s=document.createComment(`bq-if: ${t}`);let o=!0;const i=j(()=>{const a=Q(t,r);a&&!o?(s.replaceWith(e),o=!0):!a&&o&&(e.replaceWith(s),o=!1)});n.push(i)},lf=(e,t,r,n)=>{const s=e,o=Qt(t,r);if(!G(o)){console.warn(`bQuery view: bq-model requires a signal, got "${t}"`);return}const i=o,a=s.type==="checkbox",c=s.type==="radio",l=()=>{a?s.checked=!!i.value:c?s.checked=i.value===s.value:s.value=String(i.value??"")},u=j(()=>{l()});n.push(u);const h=s.tagName==="SELECT"?"change":"input",d=()=>{a?i.value=s.checked:c?s.checked&&(i.value=s.value):i.value=s.value};s.addEventListener(h,d),n.push(()=>s.removeEventListener(h,d))},uf=e=>(t,r,n,s)=>{const o=i=>{const a={...n,$event:i,$el:t};if(!r.includes("(")){const c=Qt(r,a);if(typeof c=="function"){c(i);return}return}Qt(r,a)};t.addEventListener(e,o),s.push(()=>t.removeEventListener(e,o))};function ff(e){const t=Object.getOwnPropertyDescriptor(e,"value");return t?"value"in t?t.writable===!0:typeof t.set=="function":!1}var df=(e,t,r,n)=>{const s=Qt(t,r);G(s)?(s.value=e,n.push(()=>{s.value=null})):typeof s=="object"&&s!==null&&ff(s)&&(s.value=e,n.push(()=>{s.value=null}))},hf=(e,t,r,n)=>{const s=e;let o=s.style.display;if(!o||o==="none"){const a=s.ownerDocument.defaultView?.getComputedStyle(s).display??"";o=a!=="none"?a:""}const i=j(()=>{const a=Q(t,r);s.style.display=a?o:"none"});n.push(i)},mf=(e,t,r,n)=>{const s=e;let o=new Set;const i=j(()=>{const a=new Set;if(t.trimStart().startsWith("{")){const c=_r(t);for(const[l,u]of Object.entries(c)){const h=Q(u,r),d=l.replace(/([A-Z])/g,"-$1").toLowerCase();s.style.setProperty(d,String(h??"")),a.add(d)}}else{const c=Q(t,r);if(c&&typeof c=="object")for(const[l,u]of Object.entries(c)){const h=l.replace(/([A-Z])/g,"-$1").toLowerCase();s.style.setProperty(h,String(u??"")),a.add(h)}}for(const c of o)a.has(c)||s.style.removeProperty(c);o=a});n.push(i)},pf=(e,t,r,n)=>{const s=j(()=>{const o=Q(t,r);e.textContent=String(o??"")});n.push(s)},qr=null,vf=e=>{qr=e},yf=e=>qr?qr(e):void 0,Vt=(e,t,r,n,s)=>{const o=Array.from(e.attributes);for(const i of o){const{name:a,value:c}=i;if(!a.startsWith(`${r}-`))continue;const l=a.slice(r.length+1);if(l==="for"){s.for(e,c,t,n);return}if(l==="text")s.text(e,c,t,n);else if(l==="error")s.error(e,c,t,n);else if(l==="aria")s.aria(e,c,t,n);else if(l==="html")s.html(e,c,t,n);else if(l==="if")s.if(e,c,t,n);else if(l==="show")s.show(e,c,t,n);else if(l==="class")s.class(e,c,t,n);else if(l==="style")s.style(e,c,t,n);else if(l==="model")s.model(e,c,t,n);else if(l==="ref")s.ref(e,c,t,n);else if(l.startsWith("bind:")){const u=l.slice(5);s.bind(u)(e,c,t,n)}else if(l.startsWith("on:")){const u=l.slice(3);s.on(u)(e,c,t,n)}else{const u=yf(l);u?u(e,c,t,n):jt()&&typeof console<"u"&&typeof console.warn=="function"&&console.warn(`[bQuery][view] Unknown directive "${a}" (parsed as "${l}") on <${e.tagName.toLowerCase()}>. This may be a typo or a missing custom directive registration.`)}}},xr=(e,t,r,n,s)=>{const o=Array.from(e.children);for(const i of o)i.hasAttribute(`${r}-for`)?Vt(i,t,r,n,s):(Vt(i,t,r,n,s),xr(i,t,r,n,s))},zr=(e,t,r={})=>{const{prefix:n="bq",sanitize:s=!0}=r,o=typeof e=="string"?document.querySelector(e):e;if(!o)throw new Error(`bQuery view: Element "${e}" not found.`);if(o.hasAttribute(`${n}-for`))throw new Error(`bQuery view: Cannot mount on element with ${n}-for directive. Wrap the ${n}-for element in a container instead.`);const i=[],a={text:pf,error:nf,aria:Zu,html:af(s),if:cf,show:hf,class:tf,style:mf,model:lf,ref:df,for:of({prefix:n,processElement:(l,u,h,d)=>Vt(l,u,h,d,a),processChildren:(l,u,h,d)=>xr(l,u,h,d,a)}),bind:ef,on:uf};return((l,u,h)=>{const d=l.hasAttribute(`${n}-for`);Vt(l,u,n,h,a),d||xr(l,u,n,h,a)})(o,t,i),{el:o,context:t,update:l=>{Object.assign(t,l)},destroy:()=>{for(const l of i)l();i.length=0}}},gf=(e,t={})=>r=>{const n=document.createElement("div");n.innerHTML=e.trim();const s=n.firstElementChild;if(!s)throw new Error("bQuery view: Template must contain a single root element.");if(n.childElementCount>1)throw new Error(`bQuery view: Template must contain exactly one root element, found ${n.childElementCount}.`);const{prefix:o="bq"}=t;if(s.hasAttribute(`${o}-for`)||s.hasAttribute(`${o}-if`)){const i=s.hasAttribute(`${o}-for`)?"for":"if";throw new Error(`bQuery view: Template root element cannot have ${o}-${i} directive. Wrap the ${o}-${i} element in a container instead.`)}return zr(s,r,t)},bf=e=>e===!0||e===void 0,wf=async(e,t)=>{const r=e(t),n=Ie(r)?await r:r;return bf(n)?void 0:n},Sf=e=>{const t=e.initialValue,r=L(t),n=L(""),s=L(!1),o=D(()=>!Object.is(r.value,t));return{value:r,error:n,isDirty:o,isTouched:s,isPristine:D(()=>!o.value),touch:()=>{s.value=!0},reset:()=>{r.value=t,n.value="",s.value=!1}}},Ko=async(e,t)=>{if(!t||t.length===0)return e.error.value="","";for(const r of t){const n=await wf(r,e.value.value);if(n)return e.error.value=n,n}return e.error.value="",""},Ef=e=>{const t=Object.entries(e.fields),r={},n={};for(const[f,p]of t){const y=Sf(p);r[f]=y,n[f]=y.error}const s=L(!1),o=D(()=>{for(const f of Object.keys(r))if(r[f].error.value!=="")return!1;return!0}),i=D(()=>{for(const f of Object.keys(r))if(r[f].isDirty.value)return!0;return!1}),a=async f=>{const p=r[f],y=e.fields[f];!p||!y||await Ko(p,y.validators)},c=async()=>{let f=!1;for(const[p,y]of t){const b=r[p];await Ko(b,y.validators)&&(f=!0)}if(e.crossValidators&&e.crossValidators.length>0){const p=h();for(const y of e.crossValidators){const b=await y(p);if(b){for(const[g,w]of Object.entries(b))if(w){const S=r[g];S&&(S.error.value===""&&(S.error.value=w),f=!0)}}}}return!f},l=async()=>{if(!s.value){s.value=!0;try{if(!await c())return;e.onSubmit&&await e.onSubmit(h())}finally{s.value=!1}}},u=()=>{for(const f of Object.keys(r))r[f].reset()},h=()=>{const f={};for(const p of Object.keys(r))f[p]=r[p].value.value;return f};return{fields:r,errors:n,isValid:o,isDirty:i,isSubmitting:s,handleSubmit:l,validateField:a,validate:c,reset:u,getValues:h,setValues:f=>{for(const[p,y]of Object.entries(f)){if(N(p)||!Object.prototype.hasOwnProperty.call(r,p))continue;const b=r[p];b&&(b.value.value=y)}},setErrors:f=>{for(const[p,y]of Object.entries(f)){if(N(p)||!Object.prototype.hasOwnProperty.call(r,p))continue;const b=r[p];b&&(b.error.value=y??"")}}}},Af=e=>e===!0||e===void 0,kf=async(e,t)=>{const r=e(t),n=Ie(r)?await r:r;return Af(n)?void 0:n},Tf=(e,t={})=>{let r;Cf(e)?r=e:r=L(Cs(e)||Rf(e)?e.peek():e);const n=r.peek(),s=L(t.initialError??""),o=L(!1),i=L(!1),a=D(()=>!Object.is(r.value,n)),c=D(()=>!a.value),l=D(()=>s.value===""),u=t.validateOn??"manual",h=Math.max(0,t.debounceMs??0);let d=0,v=!1,f=!1,p=!1,y;const b=A=>{console.error("bQuery forms: Error in scheduled field validation",A)},g=async()=>{const A=++d,E=t.validators;if(!E||E.length===0)return s.value="",i.value=!1,!0;i.value=!0;try{const T=r.peek();for(const P of E){const R=await kf(P,T);if(A!==d)return s.peek()==="";if(R)return s.value=R,!1}return A===d&&(s.value=""),!0}finally{A===d&&(i.value=!1)}},w=Ot(()=>{g().catch(b)},h),S=()=>{if(!p){if(h>0){w();return}g().catch(b)}};return(u==="change"||u==="both")&&(y=j(()=>{if(r.value,!v){v=!0;return}if(f){f=!1;return}S()})),{value:r,error:s,isDirty:a,isTouched:o,isPristine:c,isValid:l,isValidating:i,touch:()=>{o.value=!0,(u==="blur"||u==="both")&&S()},reset:()=>{d+=1,w.cancel(),Object.is(r.peek(),n)||(f=!0),r.value=n,s.value=t.initialError??"",o.value=!1,i.value=!1},validate:async()=>(w.cancel(),g()),destroy:()=>{p||(p=!0,d+=1,w.cancel(),y?.(),y=void 0,a.dispose(),c.dispose(),l.dispose(),i.value=!1)}}},Cf=e=>e instanceof Ge,Rf=e=>e instanceof Je,$f=(e="This field is required")=>t=>t==null||typeof t=="string"&&t.trim()===""||Array.isArray(t)&&t.length===0?e:!0,Of=(e,t)=>{const r=t??`Must be at least ${e} characters`;return n=>(typeof n=="string"?n:String(n??"")).length>=e?!0:r},Lf=(e,t)=>{const r=t??`Must be at most ${e} characters`;return n=>(typeof n=="string"?n:String(n??"")).length<=e?!0:r},Pf=(e,t="Invalid format")=>{const r=e.global||e.sticky?new RegExp(e.source,e.flags.replace(/[gy]/g,"")):e;return n=>{const s=typeof n=="string"?n:String(n??"");return r.lastIndex=0,r.test(s)?!0:t}},Nf=(e="Invalid email address")=>{const t=/^[^\s@]+@[^\s@]+\.[^\s@]+$/;return r=>{const n=typeof r=="string"?r:String(r??"");return n===""||t.test(n)?!0:e}},If=(e="Invalid URL")=>t=>{const r=typeof t=="string"?t:String(t??"");if(r==="")return!0;try{return new URL(r),!0}catch{return e}},Mf=(e,t)=>{const r=t??`Must be at least ${e}`;return n=>n==null||typeof n=="string"&&n.trim()===""||(typeof n=="number"?n:Number(n))>=e?!0:r},Df=(e,t)=>{const r=t??`Must be at most ${e}`;return n=>n==null||typeof n=="string"&&n.trim()===""||(typeof n=="number"?n:Number(n))<=e?!0:r},_f=(e,t)=>r=>e(r)?!0:t,qf=(e,t)=>async r=>await e(r)?!0:t,xf=(e,t="Fields do not match")=>r=>Object.is(r,e.value)?!0:t,Yo=(e,t,r)=>{const{locale:n,...s}=r??{};try{return new Intl.NumberFormat(t,s).format(e)}catch{return String(e)}},Jo=(e,t,r)=>{const{locale:n,...s}=r??{},o=typeof e=="number"?new Date(e):e;try{return new Intl.DateTimeFormat(t,s).format(o)}catch{return o.toLocaleString()}},Go=(e,t)=>{const r=t.split(".");let n=e;for(const s of r){if(typeof n=="string"||n[s]===void 0)return;n=n[s]}return typeof n=="string"?n:void 0},zf=(e,t)=>e.replace(/\{(\w+)\}/g,(r,n)=>n in t?String(t[n]):r),jf=(e,t)=>{if(!e.includes("|")||!("count"in t))return e;const r=Number(t.count),n=e.split("|").map(s=>s.trim());return n.length===3?r===0?n[0]:r===1?n[1]:n[2]:n.length===2?r===1?n[0]:n[1]:r===0&&n.length>0?n[0]:r===1&&n.length>1?n[1]:n[n.length-1]},Xo=(e,t,r,n)=>{let s;return e&&(s=Go(e,t)),s===void 0&&n&&(s=Go(n,t)),s===void 0?t:zf(jf(s,r),r)},Zo=(e,t)=>{const r=Ee(e,t),n=s=>{if(Array.isArray(s))return s.map(i=>n(i));if(!Se(s))return s;const o=Object.create(null);for(const[i,a]of Object.entries(s))N(i)||(o[i]=n(a));return o};return n(r)},Uf=e=>{const{locale:t,messages:r,fallbackLocale:n}=e,s=g=>Zo(Object.create(null),g),o=Object.create(null);for(const[g,w]of Object.entries(r))N(g)||(o[g]=s(w));const i=L(t),a=new Map,c=new Set(Object.keys(o));return{$locale:i,t:(g,w={})=>{const S=o[i.value];return Xo(S,g,w,n?o[n]:void 0)},tc:(g,w={})=>D(()=>{const S=o[i.value];return Xo(S,g,w,n?o[n]:void 0)}),loadLocale:(g,w)=>{N(g)||a.set(g,w)},ensureLocale:async g=>{if(N(g)||c.has(g))return;const w=a.get(g);if(!w)throw new Error(`bQuery i18n: No messages or loader registered for locale "${g}".`);const S=await w();o[g]=s(S.default??S),c.add(g)},n:(g,w)=>Yo(g,w?.locale??i.value,w),d:(g,w)=>Jo(g,w?.locale??i.value,w),getMessages:g=>{if(!N(g))return o[g]},mergeMessages:(g,w)=>{N(g)||(o[g]||(o[g]=Object.create(null),c.add(g)),o[g]=Zo(o[g],s(w)))},availableLocales:()=>{const g=new Set([...c,...a.keys()]);return Array.from(g).sort()}}},Kt=new Map,ct=new Map,Hf=50,Wf=e=>{const t=Kt.get(e);if(t&&t.isConnected)return t;const r=document.createElement("div");return r.setAttribute("aria-live",e),r.setAttribute("aria-atomic","true"),r.setAttribute("role",e==="assertive"?"alert":"status"),Object.assign(r.style,{position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",border:"0"}),document.body.appendChild(r),Kt.set(e,r),r},Ff=(e,t="polite")=>{if(!e||typeof document>"u"||!document.body)return;const r=Wf(t),n=ct.get(t);n!==void 0&&clearTimeout(n),r.textContent="";const s=setTimeout(()=>{ct.delete(t),r.isConnected&&(r.textContent=e)},Hf);ct.set(t,s)},Bf=()=>{for(const e of ct.values())clearTimeout(e);ct.clear();for(const[,e]of Kt)e.remove();Kt.clear()},ne=(e,t,r,n)=>({severity:e,message:t,element:r,rule:n}),Qf=e=>{const t=[],r=e.querySelectorAll("img");for(const n of r)n.hasAttribute("alt")?n.getAttribute("alt")===""&&!n.hasAttribute("role")&&t.push(ne("info",'Image has empty alt text. Consider adding role="presentation" if decorative.',n,"img-decorative")):t.push(ne("error",'Image is missing an alt attribute. Add alt="" for decorative images or a descriptive alt text.',n,"img-alt"));return t},Vf=e=>{const t=[],r=e.querySelectorAll("input, select, textarea");for(const n of r){const s=n.getAttribute("type");if(s==="hidden"||s==="submit"||s==="button"||s==="reset")continue;const o=n.getAttribute("id"),i=o?!!e.querySelector(`label[for="${o}"]`):!1,a=n.hasAttribute("aria-label")||n.hasAttribute("aria-labelledby"),c=n.hasAttribute("title"),l=n.closest("label")!==null;!i&&!a&&!c&&!l&&t.push(ne("error",'Form input is missing a label. Add a <label for="id">, aria-label, or aria-labelledby attribute.',n,"input-label"))}return t},Kf=e=>{const t=[],r=e.querySelectorAll("button");for(const s of r){const o=(s.textContent??"").trim().length>0,i=s.hasAttribute("aria-label")||s.hasAttribute("aria-labelledby"),a=s.hasAttribute("title");!o&&!i&&!a&&t.push(ne("error","Button has no accessible name. Add text content, aria-label, or title.",s,"button-name"))}const n=e.querySelectorAll("a[href]");for(const s of n){const o=(s.textContent??"").trim().length>0,i=s.hasAttribute("aria-label")||s.hasAttribute("aria-labelledby"),a=s.hasAttribute("title"),c=s.querySelector("img[alt]")!==null;!o&&!i&&!a&&!c&&t.push(ne("error","Link has no accessible name. Add text content, aria-label, or title.",s,"link-name"))}return t},Yf=e=>{const t=[],r=e.querySelectorAll("h1, h2, h3, h4, h5, h6");let n=0;for(const s of r){const o=parseInt(s.tagName.charAt(1),10);n>0&&o>n+1&&t.push(ne("warning",`Heading level skipped: <${s.tagName.toLowerCase()}> follows <h${n}>. Don't skip heading levels.`,s,"heading-order")),(s.textContent??"").trim().length===0&&t.push(ne("warning","Heading element is empty.",s,"heading-empty")),n=o}return t},Jf=e=>{const t=[],r=e.querySelectorAll("[aria-labelledby]");for(const s of r){const o=(s.getAttribute("aria-labelledby")??"").split(/\s+/);for(const i of o)i&&!document.getElementById(i)&&t.push(ne("error",`aria-labelledby references "${i}" which does not exist in the document.`,s,"aria-labelledby-ref"))}const n=e.querySelectorAll("[aria-describedby]");for(const s of n){const o=(s.getAttribute("aria-describedby")??"").split(/\s+/);for(const i of o)i&&!document.getElementById(i)&&t.push(ne("error",`aria-describedby references "${i}" which does not exist in the document.`,s,"aria-describedby-ref"))}return t},Gf=e=>{const t=[];return(e===document.body||e===document.documentElement)&&(e.querySelector("main")||e.querySelector('[role="main"]')||t.push(ne("warning",'Page is missing a <main> landmark. Add <main> or role="main" to the primary content area.',e,"landmark-main"))),t},Xf=e=>{if(typeof document>"u"||!document.body)return{findings:[],errors:0,warnings:0,passed:!0};const t=e??document.body,r=[...Qf(t),...Vf(t),...Kf(t),...Yf(t),...Jf(t),...Gf(t)],n=r.filter(s=>s.severity==="error").length;return{findings:r,errors:n,warnings:r.filter(s=>s.severity==="warning").length,passed:n===0}},ei=(e,t)=>{if(typeof e.addEventListener=="function")return e.addEventListener("change",t),()=>{e.removeEventListener("change",t)};const r=e;if(typeof r.addListener=="function")return r.addListener(t),()=>{r.removeListener?.(t)}},ti=(e,t)=>{let r=t;const n=e;return Object.defineProperty(n,"destroy",{configurable:!0,enumerable:!1,value:()=>{const s=r;r=()=>{},s()}}),n},Zf=()=>{const e=L("light");let t=()=>{e.dispose()};if(typeof window<"u"&&typeof window.matchMedia=="function")try{const r=window.matchMedia("(prefers-color-scheme: dark)");e.value=r.matches?"dark":"light";const s=ei(r,o=>{e.value=o.matches?"dark":"light"});s&&(t=()=>{s(),e.dispose()})}catch{}return ti(_(e),t)},ed=()=>{const e=L("no-preference");let t=()=>{e.dispose()};if(typeof window<"u"&&typeof window.matchMedia=="function"){let r,n,s;const o=()=>{!r||!n||!s||(r.matches?e.value="more":n.matches?e.value="less":s.matches?e.value="custom":e.value="no-preference")};try{r=window.matchMedia("(prefers-contrast: more)"),n=window.matchMedia("(prefers-contrast: less)"),s=window.matchMedia("(prefers-contrast: custom)"),o();const i=[r,n,s].map(a=>ei(a,()=>{o()})).filter(a=>a!==void 0);i.length>0&&(t=()=>{for(const a of i)a();e.dispose()})}catch{}}return ti(_(e),t)},td=(e,t,r={})=>{const{wrap:n=!0,orientation:s="vertical",onActivate:o}=r;let i=0;const a=new Map,c=()=>Array.from(e.querySelectorAll(t)),l=f=>{for(const p of f)a.has(p)||a.set(p,p.getAttribute("tabindex"))},u=f=>{const p=c();if(p.length===0)return;l(p);const y=Math.max(0,Math.min(f,p.length-1));for(let b=0;b<p.length;b++)p[b].setAttribute("tabindex",b===y?"0":"-1");i=y,p[y].focus(),o?.(p[y],y)},h=f=>{if(f==="Home"||f==="End")return!0;switch(s){case"horizontal":return f==="ArrowLeft"||f==="ArrowRight";case"vertical":return f==="ArrowUp"||f==="ArrowDown";case"both":return f==="ArrowLeft"||f==="ArrowRight"||f==="ArrowUp"||f==="ArrowDown";default:return!1}},d=f=>{if(!h(f.key))return;const p=c();if(p.length===0)return;f.preventDefault();let y=i;switch(f.key){case"ArrowDown":case"ArrowRight":y=i+1,y>=p.length&&(y=n?0:p.length-1);break;case"ArrowUp":case"ArrowLeft":y=i-1,y<0&&(y=n?p.length-1:0);break;case"Home":y=0;break;case"End":y=p.length-1;break}u(y)},v=c();l(v);for(let f=0;f<v.length;f++)v[f].setAttribute("tabindex",f===0?"0":"-1");return e.addEventListener("keydown",d),{destroy:()=>{e.removeEventListener("keydown",d);for(const[f,p]of a)p===null?f.removeAttribute("tabindex"):f.setAttribute("tabindex",p);a.clear()},focusItem:f=>{u(f)},activeIndex:()=>i}},jr=`
260
260
  position: absolute;
261
261
  top: -9999px;
262
262
  left: -9999px;
@@ -269,13 +269,13 @@ See: https://bquery.dev/guide/store#deep-reactivity`)}for(const[E,T]of Object.en
269
269
  border-radius: 0 0 4px 0;
270
270
  outline: 2px solid #4A90D9;
271
271
  outline-offset: 2px;
272
- `,Zf=`
272
+ `,rd=`
273
273
  top: 0;
274
274
  left: 0;
275
- `,Eo=0,ze=new Map,ed=()=>typeof document>"u"?!1:typeof document.createElement=="function"&&typeof document.querySelector=="function"&&typeof document.getElementById=="function"&&document.body!==null&&document.body!==void 0,td=()=>({destroy:()=>{},element:null}),rd=(e,t={})=>{if(!ed())return td();const{text:r="Skip to main content",className:n="bq-skip-link"}=t;let s,o;const i=m=>{try{return document.querySelector(m)}catch{return null}},a=()=>{if(!s)return;const m=ze.get(s),v=(m?.count??0)-1;v<=0?(ze.delete(s),m?.target.isConnected&&m.target.id===s&&m.target.removeAttribute("id")):ze.set(s,{count:v,target:m.target}),s=void 0},c=()=>{if(!o)return;const{target:m,hadTabIndex:v,previousTabIndex:b}=o;m.isConnected&&(v?m.setAttribute("tabindex",b??""):m.removeAttribute("tabindex")),o=void 0},l=m=>{if(o?.target!==m){if(c(),m.hasAttribute("tabindex")){o={target:m,hadTabIndex:!0,previousTabIndex:m.getAttribute("tabindex")};return}m.tabIndex===-1&&(o={target:m,hadTabIndex:!1,previousTabIndex:null},m.setAttribute("tabindex","-1"))}},u=(m,v)=>{if(s===v)return;a();const b=ze.get(v);ze.set(v,{count:(b?.count??0)+1,target:m}),s=v},h=()=>{if(e.startsWith("#")){const v=e.slice(1),b=v?document.getElementById(v):null;return b||i(e)}const m=document.getElementById(e);return m||i(e)},d=m=>{if(m.id)return ze.get(m.id)?.target===m&&u(m,m.id),m.id;let v;do Eo+=1,v=`bq-skip-target-${Eo}`;while(document.getElementById(v)!==null);return m.id=v,u(m,v),v},p=document.createElement("a"),f=h();return p.href=e.startsWith("#")?e:f?`#${d(f)}`:`#${e}`,p.textContent=r,p.className=n,p.setAttribute("style",_r),p.addEventListener("focus",()=>{p.setAttribute("style",_r+Zf)}),p.addEventListener("blur",()=>{p.setAttribute("style",_r)}),p.addEventListener("click",m=>{m.preventDefault();const v=h();v&&(p.href=`#${d(v)}`,l(v),v.focus())}),document.body.firstChild?document.body.insertBefore(p,document.body.firstChild):document.body.appendChild(p),{destroy:()=>{c(),a(),p.remove()},element:p}},nd=["a[href]","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])",'[tabindex]:not([tabindex="-1"])','[contenteditable="true"]',"details > summary","audio[controls]","video[controls]"].join(", "),xr=e=>Array.from(e.querySelectorAll(nd)).filter(t=>!t.hasAttribute("disabled")&&t.tabIndex!==-1&&t.getClientRects().length>0),Ao=(e,t)=>e?typeof e=="string"?t.querySelector(e):e:null,sd=(e,t={})=>{const{escapeDeactivates:r=!0,onEscape:n,initialFocus:s,returnFocus:o}=t;if(typeof document>"u"||typeof document.addEventListener!="function"||typeof document.removeEventListener!="function"){let h=!1;return{get active(){return h},release:()=>{h=!1}}}const i=document.activeElement;let a=!0;const c=h=>{if(!a)return;if(h.key==="Escape"&&r){h.preventDefault(),u.release(),n?.();return}if(h.key!=="Tab")return;const d=xr(e);if(d.length===0){h.preventDefault();return}const p=d[0],f=d[d.length-1];h.shiftKey?(document.activeElement===p||!e.contains(document.activeElement))&&(h.preventDefault(),f.focus()):(document.activeElement===f||!e.contains(document.activeElement))&&(h.preventDefault(),p.focus())};document.addEventListener("keydown",c,!0);const l=Ao(s,e);if(l)l.focus();else{const h=xr(e);h.length>0&&h[0].focus()}const u={get active(){return a},release:()=>{if(!a)return;a=!1,document.removeEventListener("keydown",c,!0);const h=Ao(o,document.body);h?h.focus():i&&i.focus&&i.focus()}};return u},od=e=>{e.release()},ct=new Map,ko=()=>{const e=Array.from(ct.values());return e[e.length-1]},id=(e,t)=>{if(typeof t=="object")return t;let r=null;if(t==="parent"?r=e.parentElement:r=document.querySelector(t),!r)return null;const n=r.getBoundingClientRect(),s=e.getBoundingClientRect(),o=parseFloat(e.style.left||"0"),i=parseFloat(e.style.top||"0"),a=Number.isNaN(o)?0:o,c=Number.isNaN(i)?0:i;return{left:n.left-s.left+a,top:n.top-s.top+c,right:n.right-s.right+a+(n.width-s.width),bottom:n.bottom-s.bottom+c+(n.height-s.height)}},ad=(e,t)=>t?{x:Math.max(t.left,Math.min(t.right,e.x)),y:Math.max(t.top,Math.min(t.bottom,e.y))}:e,cd=(e,t={})=>{const{axis:r="both",bounds:n,handle:s,ghost:o=!1,ghostClass:i="bq-drag-ghost",draggingClass:a="bq-dragging",onDragStart:c,onDrag:l,onDragEnd:u}=t;let h=!t.disabled,d=!1,p={x:0,y:0},f={x:0,y:0},m={x:0,y:0},v=null,b=null;const g=e.style.touchAction,w=e.style.userSelect,S=C=>({element:e,position:{...f},delta:{x:f.x-m.x,y:f.y-m.y},event:C}),k=()=>{const C=e.cloneNode(!0),$=e.getBoundingClientRect();return C.classList.add(i),C.style.position="fixed",C.style.left=`${$.left}px`,C.style.top=`${$.top}px`,C.style.width=`${$.width}px`,C.style.height=`${$.height}px`,C.style.pointerEvents="none",C.style.zIndex="999999",C.style.opacity="0.7",C.style.margin="0",document.body.appendChild(C),C},A=()=>{v&&(v.remove(),v=null),b=null},E=C=>{if(h&&!(s&&!C.target.closest(s))){if(C.preventDefault(),d=!0,p={x:C.clientX,y:C.clientY},m={...f},e.classList.add(a),e.setPointerCapture(C.pointerId),o){const $=e.getBoundingClientRect();b={x:$.left,y:$.top},v=k()}ct.set(e,{element:e,position:f}),c?.(S(C))}},T=C=>{if(!d)return;C.preventDefault(),m={...f};let $=f.x+(C.clientX-p.x),R=f.y+(C.clientY-p.y);p={x:C.clientX,y:C.clientY},r==="x"&&(R=f.y),r==="y"&&($=f.x);let O={x:$,y:R};if(n){const I=id(e,n);O=ad(O,I)}if(f=O,ct.set(e,{element:e,position:f}),o&&v){const I=b??{x:e.getBoundingClientRect().left,y:e.getBoundingClientRect().top};v.style.left=`${I.x+f.x}px`,v.style.top=`${I.y+f.y}px`}else e.style.transform=`translate(${f.x}px, ${f.y}px)`;l?.(S(C))},P=C=>{if(d){d=!1,e.classList.remove(a);try{typeof e.releasePointerCapture=="function"&&(typeof e.hasPointerCapture!="function"||e.hasPointerCapture(C.pointerId))&&e.releasePointerCapture(C.pointerId)}catch{}finally{A(),ct.delete(e),u?.(S(C))}}};return e.addEventListener("pointerdown",E),e.addEventListener("pointermove",T),e.addEventListener("pointerup",P),e.addEventListener("pointercancel",P),e.style.touchAction="none",e.style.userSelect="none",{destroy:()=>{e.removeEventListener("pointerdown",E),e.removeEventListener("pointermove",T),e.removeEventListener("pointerup",P),e.removeEventListener("pointercancel",P),A(),ct.delete(e),e.style.touchAction=g,e.style.userSelect=w,e.classList.remove(a)},disable:()=>{h=!1},enable:()=>{h=!0},get enabled(){return h}}},ld={passive:!0},lt=new Set,ut=null,de=null,To=()=>Array.from(lt),ud=()=>typeof document<"u"&&typeof document.addEventListener=="function"&&typeof document.removeEventListener=="function"&&typeof requestAnimationFrame=="function"&&typeof cancelAnimationFrame=="function",fd=e=>{for(const t of To())t.handlePointerMove(e)},dd=()=>{de=null;const e=ut;ut=null,e&&fd(e)},Ro=e=>{ut=e,de===null&&(de=requestAnimationFrame(dd))},Co=e=>{de!==null&&(cancelAnimationFrame(de),de=null,ut=null);for(const t of To())t.handlePointerUp(e)},hd=e=>{lt.size===0&&(document.addEventListener("pointermove",Ro,ld),document.addEventListener("pointerup",Co)),lt.add(e)},md=e=>{lt.delete(e),lt.size===0&&(document.removeEventListener("pointermove",Ro),document.removeEventListener("pointerup",Co),de!==null&&(cancelAnimationFrame(de),de=null),ut=null)},$o=(e,t)=>t?typeof t=="string"?e.matches(t):t(e):!0,pd=(e,t={})=>{const{overClass:r="bq-drop-over",accept:n,onDragEnter:s,onDragOver:o,onDragLeave:i,onDrop:a}=t;if(!ud())return{destroy:()=>{}};let c=!1,l=null;const u=(b,g)=>({zone:e,dragged:b,event:g}),h=b=>{const g=e.getBoundingClientRect();return b.clientX>=g.left&&b.clientX<=g.right&&b.clientY>=g.top&&b.clientY<=g.bottom},d=()=>ko()?.element??l,p=(b,g=l)=>{c&&(c=!1,e.classList.remove(r),g&&i?.(u(g,b)),l=null)},v={handlePointerMove:b=>{const g=ko()?.element??null,w=h(b);if(!(g!==null&&g!==e&&$o(g,n))||!w){p(b,g??l);return}c?o?.(u(g,b)):(c=!0,l=g,e.classList.add(r),s?.(u(g,b)))},handlePointerUp:b=>{const g=d(),w=h(b),S=g!==null&&g!==e&&$o(g,n);w&&S&&g&&a?.(u(g,b)),c&&(c=!1,e.classList.remove(r)),l=null}};return hd(v),{destroy:()=>{md(v),e.classList.remove(r),l=null}}},Oo=(e,t)=>Array.from(e.querySelectorAll(t)),vd=(e,t,r,n)=>{let s=null;for(let o=0;o<e.length;o++){const i=e[o];if(i===n)continue;const a=i.getBoundingClientRect(),c=t-(r==="y"?a.top+a.height/2:a.left+a.width/2);(s===null||c<0&&c>s.distance||s.distance>=0&&c<0&&Math.abs(c)<Math.abs(s.distance))&&c<0&&(s={element:i,index:o,distance:c})}return s?{element:s.element,index:s.index}:null},yd=(e,t={})=>{const{items:r=":scope > *",axis:n="y",handle:s,placeholderClass:o="bq-sort-placeholder",sortingClass:i="bq-sorting",animationDuration:a=200,onSortStart:c,onSortMove:l,onSortEnd:u}=t;let h=!t.disabled,d=!1,p=null,f=null,m=-1,v=0,b=0,g=0,w=0;const S=(P,C,$)=>({container:e,item:P,oldIndex:C,newIndex:$}),k=P=>{if(!h)return;const C=P.target,$=Oo(e,r);let R=null;for(const I of $)if(I.contains(C)){R=I;break}if(!R||s&&!C.closest(s))return;P.preventDefault(),d=!0,p=R,m=$.indexOf(R),v=P.clientY,b=P.clientX;const O=R.getBoundingClientRect();g=O.top,w=O.left,f=document.createElement("div"),f.classList.add(o),f.style.width=`${O.width}px`,f.style.height=`${O.height}px`,f.style.boxSizing="border-box",R.classList.add(i),R.style.position="fixed",R.style.width=`${O.width}px`,R.style.height=`${O.height}px`,R.style.left=`${O.left}px`,R.style.top=`${O.top}px`,R.style.zIndex="999999",R.style.pointerEvents="none",R.style.margin="0",R.parentNode?.insertBefore(f,R),e.setPointerCapture(P.pointerId),c?.(S(R,m,m))},A=P=>{if(!d||!p||!f)return;P.preventDefault();const C=P.clientX-b,$=P.clientY-v;n==="y"?p.style.top=`${g+$}px`:p.style.left=`${w+C}px`;const R=vd(Oo(e,r),n==="y"?P.clientY:P.clientX,n,p);R?e.insertBefore(f,R.element):e.appendChild(f);const O=Array.from(e.children).indexOf(f);l?.(S(p,m,O))},E=P=>{if(!d||!p||!f)return;d=!1;const C=p,$=Array.from(e.children).indexOf(f),R=f.getBoundingClientRect(),O=C.getBoundingClientRect();if(a>0){const I=R.left-O.left,x=R.top-O.top;C.style.transition=`transform ${a}ms ease`,C.style.transform=`translate(${I}px, ${x}px)`;let W=!1,q=null;const V=()=>{W||(W=!0,q!==null&&(window.clearTimeout(q),q=null),T(),u?.(S(C,m,$)))};q=window.setTimeout(()=>{V()},a+50),C.addEventListener("transitionend",V,{once:!0})}else T(),u?.(S(C,m,$));e.releasePointerCapture(P.pointerId)},T=()=>{!p||!f||(f.parentNode?.insertBefore(p,f),f.remove(),f=null,p.classList.remove(i),p.style.position="",p.style.width="",p.style.height="",p.style.left="",p.style.top="",p.style.zIndex="",p.style.pointerEvents="",p.style.margin="",p.style.transition="",p.style.transform="",p=null)};return e.addEventListener("pointerdown",k),e.addEventListener("pointermove",A),e.addEventListener("pointerup",E),e.addEventListener("pointercancel",E),e.style.touchAction="none",{destroy:()=>{e.removeEventListener("pointerdown",k),e.removeEventListener("pointermove",A),e.removeEventListener("pointerup",E),e.removeEventListener("pointercancel",E),e.style.touchAction="",d&&T()},disable:()=>{h=!1},enable:()=>{h=!0},get enabled(){return h}}},gd=e=>{const t=L(!1);let r;if(typeof window<"u"&&typeof window.matchMedia=="function")try{const o=window.matchMedia(e);t.value=o.matches;const i=a=>{t.value=a.matches};if(typeof o.addEventListener=="function")o.addEventListener("change",i),r=()=>{o.removeEventListener("change",i)};else if(typeof o.addListener=="function"){const a=o;a.addListener(i),r=()=>{a.removeListener(i)}}}catch{}const n=_(t);let s=!1;return Object.defineProperty(n,"destroy",{enumerable:!1,configurable:!0,value(){s||(s=!0,r?.(),t.dispose())}}),n},bd=e=>{const t={},r=[];for(const o of Object.keys(e)){const i=e[o],a=L(!1);let c;if(typeof window<"u"&&typeof window.matchMedia=="function")try{const h=window.matchMedia(`(min-width: ${i}px)`);a.value=h.matches;const d=p=>{a.value=p.matches};if(typeof h.addEventListener=="function")h.addEventListener("change",d),c=()=>{h.removeEventListener("change",d)};else{const p=h;typeof p.addListener=="function"&&(p.addListener(d),c=()=>{p.removeListener?.(d)})}}catch{}const l=_(a);let u=!1;Object.defineProperty(l,"destroy",{enumerable:!1,configurable:!0,value(){u||(u=!0,c?.(),a.dispose())}}),r.push(l.destroy),t[o]=l}let n=!1;const s=Object.defineProperty(t,"destroyAll",{enumerable:!1,configurable:!0,value(){n||(n=!0,r.forEach(o=>{o()}))}});return Object.prototype.hasOwnProperty.call(t,"destroy")||Object.defineProperty(s,"destroy",{enumerable:!1,configurable:!0,value:s.destroyAll}),s},Lo=(e,t)=>t>=e?"portrait":"landscape",wd=()=>{const e=L({width:typeof window<"u"?window.innerWidth:0,height:typeof window<"u"?window.innerHeight:0,orientation:typeof window<"u"?Lo(window.innerWidth,window.innerHeight):"portrait"});let t;if(typeof window<"u"){const s=()=>{e.value={width:window.innerWidth,height:window.innerHeight,orientation:Lo(window.innerWidth,window.innerHeight)}};window.addEventListener("resize",s),t=()=>{window.removeEventListener("resize",s)}}const r=_(e);let n=!1;return Object.defineProperty(r,"destroy",{enumerable:!1,configurable:!0,value:()=>{n||(n=!0,t?.(),e.dispose())}}),r},Po=()=>{const e=typeof navigator<"u"&&navigator.onLine!==void 0?navigator.onLine:!0,t=(typeof navigator<"u"?navigator:void 0)?.connection;return{online:e,effectiveType:t?.effectiveType??"unknown",downlink:t?.downlink??0,rtt:t?.rtt??0}},Sd=()=>{const e=L(Po());let t;if(typeof window<"u"){const s=()=>{e.value=Po()};window.addEventListener("online",s),window.addEventListener("offline",s);const o=typeof navigator<"u"?navigator:void 0;o?.connection&&typeof o.connection.addEventListener=="function"&&o.connection.addEventListener("change",s),t=()=>{window.removeEventListener("online",s),window.removeEventListener("offline",s),o?.connection&&typeof o.connection.removeEventListener=="function"&&o.connection.removeEventListener("change",s)}}const r=_(e);let n=!1;return Object.defineProperty(r,"destroy",{value(){n||(n=!0,t?.(),e.dispose())},enumerable:!1,configurable:!0}),r},Ed={supported:!1,charging:!1,chargingTime:0,dischargingTime:0,level:1},Ad=()=>{const e=L({...Ed});let t,r=!1;typeof navigator<"u"&&"getBattery"in navigator&&typeof navigator.getBattery=="function"&&navigator.getBattery().then(s=>{if(r)return;const o=()=>{e.value={supported:!0,charging:s.charging,chargingTime:s.chargingTime,dischargingTime:s.dischargingTime,level:s.level}};o(),s.addEventListener("chargingchange",o),s.addEventListener("chargingtimechange",o),s.addEventListener("dischargingtimechange",o),s.addEventListener("levelchange",o),t=()=>{s.removeEventListener("chargingchange",o),s.removeEventListener("chargingtimechange",o),s.removeEventListener("dischargingtimechange",o),s.removeEventListener("levelchange",o)}}).catch(()=>{});const n=_(e);return Object.defineProperty(n,"destroy",{enumerable:!1,configurable:!0,value(){r||(r=!0,t?.(),e.dispose())}}),n},No={supported:!1,loading:!1,latitude:null,longitude:null,accuracy:null,altitude:null,altitudeAccuracy:null,heading:null,speed:null,timestamp:null,error:null},kd=(e={})=>{const{enableHighAccuracy:t=!1,maximumAge:r=0,timeout:n=1/0,watch:s=!1}=e,o=L({...No});let i;if(typeof navigator<"u"&&"geolocation"in navigator){o.value={...No,supported:!0,loading:!0};const l={enableHighAccuracy:t,maximumAge:r,timeout:n===1/0?void 0:n},u=d=>{o.value={supported:!0,loading:!1,latitude:d.coords.latitude,longitude:d.coords.longitude,accuracy:d.coords.accuracy,altitude:d.coords.altitude,altitudeAccuracy:d.coords.altitudeAccuracy,heading:d.coords.heading,speed:d.coords.speed,timestamp:d.timestamp,error:null}},h=d=>{o.value={...o.value,loading:!1,error:d.message}};if(s){const d=navigator.geolocation.watchPosition(u,h,l);i=()=>{navigator.geolocation.clearWatch(d)}}else navigator.geolocation.getCurrentPosition(u,h,l)}const a=_(o);let c=!1;return Object.defineProperty(a,"destroy",{enumerable:!1,configurable:!0,value(){c||(c=!0,i?.(),o.dispose())}}),a},Td={acceleration:{x:null,y:null,z:null},accelerationIncludingGravity:{x:null,y:null,z:null},rotationRate:{alpha:null,beta:null,gamma:null},interval:0},Rd={alpha:null,beta:null,gamma:null,absolute:!1},Cd=()=>{const e=L({...Td});let t;if(typeof window<"u"){const s=o=>{e.value={acceleration:{x:o.acceleration?.x??null,y:o.acceleration?.y??null,z:o.acceleration?.z??null},accelerationIncludingGravity:{x:o.accelerationIncludingGravity?.x??null,y:o.accelerationIncludingGravity?.y??null,z:o.accelerationIncludingGravity?.z??null},rotationRate:{alpha:o.rotationRate?.alpha??null,beta:o.rotationRate?.beta??null,gamma:o.rotationRate?.gamma??null},interval:o.interval??0}};window.addEventListener("devicemotion",s),t=()=>{window.removeEventListener("devicemotion",s)}}const r=_(e);let n=!1;return Object.defineProperty(r,"destroy",{enumerable:!1,configurable:!0,value(){n||(n=!0,t?.(),e.dispose())}}),r},$d=()=>{const e=L({...Rd});let t;if(typeof window<"u"){const s=o=>{e.value={alpha:o.alpha??null,beta:o.beta??null,gamma:o.gamma??null,absolute:o.absolute??!1}};window.addEventListener("deviceorientation",s),t=()=>{window.removeEventListener("deviceorientation",s)}}const r=_(e);let n=!1;return Object.defineProperty(r,"destroy",{enumerable:!1,configurable:!0,value(){n||(n=!0,t?.(),e.dispose())}}),r},Io="bQuery media: Clipboard API is unavailable. Use a secure context (HTTPS or localhost) and ensure clipboard permissions or user-activation requirements are met.",Od={read:async()=>{if(typeof navigator>"u"||!navigator.clipboard||typeof navigator.clipboard.readText!="function")throw new Error(Io);return navigator.clipboard.readText()},write:async e=>{if(typeof navigator>"u"||!navigator.clipboard||typeof navigator.clipboard.writeText!="function")throw new Error(Io);return navigator.clipboard.writeText(e)}},Ld=(e,t)=>{let r;t==="border-box"?r=e.borderBoxSize:t==="device-pixel-content-box"?r=e.devicePixelContentBoxSize:r=e.contentBoxSize;const n=Array.isArray(r)?r[0]:r;return n&&typeof n.inlineSize=="number"&&typeof n.blockSize=="number"?{width:n.inlineSize,height:n.blockSize}:{width:e.contentRect.width,height:e.contentRect.height}},Pd=(e,t)=>{const r=L({isIntersecting:!1,intersectionRatio:0,entry:null});let n,s=!1;if(typeof window<"u"&&typeof IntersectionObserver<"u")try{if(n=new IntersectionObserver(i=>{if(s)return;const a=i[i.length-1];a&&(r.value={isIntersecting:a.isIntersecting,intersectionRatio:a.intersectionRatio,entry:a})},{root:t?.root??null,rootMargin:t?.rootMargin??"0px",threshold:t?.threshold??0}),e){const i=Array.isArray(e)?e:[e];for(const a of i)n.observe(a)}}catch{n&&n.disconnect(),n=void 0}const o=_(r);return Object.defineProperties(o,{observe:{enumerable:!1,configurable:!0,value(i){if(!s)try{n?.observe(i)}catch{}}},unobserve:{enumerable:!1,configurable:!0,value(i){s||n?.unobserve(i)}},destroy:{enumerable:!1,configurable:!0,value(){s||(s=!0,n?.disconnect(),n=void 0,r.dispose())}}}),o},Nd=(e,t)=>{const r=L({width:0,height:0,entry:null});let n,s=!1;const o=t?.box??"content-box",i=t?.box?{box:t.box}:void 0;if(typeof window<"u"&&typeof ResizeObserver<"u")try{if(n=new ResizeObserver(c=>{if(s)return;const l=c[c.length-1];if(l){const{width:u,height:h}=Ld(l,o);r.value={width:u,height:h,entry:l}}}),e){const c=Array.isArray(e)?e:[e];for(const l of c)n.observe(l,i)}}catch{n&&n.disconnect(),n=void 0}const a=_(r);return Object.defineProperties(a,{observe:{enumerable:!1,configurable:!0,value(c){if(!s)try{n?.observe(c,i)}catch{}}},unobserve:{enumerable:!1,configurable:!0,value(c){s||n?.unobserve(c)}},destroy:{enumerable:!1,configurable:!0,value(){s||(s=!0,n?.disconnect(),n=void 0,r.dispose())}}}),a},Id=(e,t)=>{const r=L({mutations:[],count:0});let n,s=!1,o=0;const i={attributes:t?.attributes??!0,childList:t?.childList??!1,characterData:t?.characterData??!1,subtree:t?.subtree??!1,attributeOldValue:t?.attributeOldValue??!1,characterDataOldValue:t?.characterDataOldValue??!1,...t&&t.attributeFilter!==void 0?{attributeFilter:t.attributeFilter}:{}};if(!i.attributes&&!i.childList&&!i.characterData&&(i.attributes=!0),i.attributes||(i.attributeOldValue=!1,delete i.attributeFilter),i.characterData||(i.characterDataOldValue=!1),typeof window<"u"&&typeof MutationObserver<"u")try{n=new MutationObserver(c=>{s||(o+=1,r.value={mutations:c,count:o})}),e&&n.observe(e,i)}catch{n&&n.disconnect(),n=void 0}const a=_(r);return Object.defineProperties(a,{observe:{enumerable:!1,configurable:!0,value(c){if(!s)try{n?.observe(c,i)}catch{}}},takeRecords:{enumerable:!1,configurable:!0,value(){return n?.takeRecords()??[]}},destroy:{enumerable:!1,configurable:!0,value(){s||(s=!0,n?.disconnect(),n=void 0,r.dispose())}}}),a},ft=new Set,he=new Map,qr=()=>{hf(e=>he.get(e))};qr();var Mo=e=>{he.clear();for(const[t,r]of e)he.set(t,r)},Md=e=>({directive(t,r){if(typeof t!="string"||t.length===0)throw new Error("bQuery plugin directive: name must be a non-empty string");if(t.startsWith("bq-")){const n=t.slice(3);throw new Error(`bQuery plugin directive: name "${t}" must be provided without the "bq-" prefix`+(n?` (use "${n}")`:""))}if(typeof r!="function")throw new Error(`bQuery plugin directive: handler for "${t}" must be a function`);if(he.has(t))throw new Error(`bQuery plugin directive: a directive named "${t}" is already registered`);he.set(t,r)},component(t,r,n){if(typeof t!="string"||t.length===0)throw new Error("bQuery plugin component: tagName must be a non-empty string");if(!t.includes("-"))throw new Error(`bQuery plugin component: tagName "${t}" must be a valid custom element name containing a hyphen`);if(typeof r!="function")throw new Error(`bQuery plugin component: constructor for "${t}" must be a function`);if(typeof customElements>"u"){typeof console<"u"&&typeof console.warn=="function"&&console.warn(`[bQuery] plugin component "${t}" was not registered because customElements is not available in this environment.`);return}!customElements.get(t)&&!e.some(s=>s.tagName===t)&&e.push({tagName:t,constructor:r,options:n})}}),Dd=(e,t)=>{if(qr(),!e||typeof e!="object")throw new Error("bQuery plugin: use() expects a plugin object with { name, install }");if(typeof e.name!="string"||e.name.length===0)throw new Error('bQuery plugin: plugin must have a non-empty "name" property');if(typeof e.install!="function")throw new Error(`bQuery plugin: plugin "${e.name}" must have an "install" function`);if(ft.has(e.name))return;const r=[],n=Md(r),s=new Map(he);try{e.install(n,t)}catch(o){throw Mo(s),o}try{for(const o of r)customElements.get(o.tagName)||customElements.define(o.tagName,o.constructor,o.options)}catch(o){throw Mo(s),o}ft.add(e.name)},_d=e=>ft.has(e),xd=()=>[...ft],qd=e=>he.get(e),zd=()=>[...he.entries()].map(([e,t])=>({name:e,handler:t})),jd=()=>{ft.clear(),he.clear(),qr()},dt=!1,zr={},Re=[],Vt=new Map,Do=0,Ud=(e,t)=>{dt=e,zr=t??{},e||(Re.length=0,Vt.clear(),Do=0)},Hd=()=>dt,Wd=(e,t,r)=>{if(dt){if(typeof e!="string"||e.length===0)throw new Error("bQuery devtools: trackSignal() requires a non-empty label");Vt.set(e,{peek:t,subscriberCount:r})}},Fd=e=>{Vt.delete(e)},Bd=()=>`signal_${Do++}`,_o=()=>{const e=[];for(const[t,r]of Vt)e.push({label:t,value:r.peek(),subscriberCount:r.subscriberCount()});return e},xo=()=>{try{return Wt().map(e=>{const t=we(e),r={};if(t&&typeof t=="object"&&"$state"in t){const n=t.$state;n&&typeof n=="object"&&Object.assign(r,n)}return{id:e,state:r}})}catch{return[]}},qo=()=>{if(typeof document>"u")return[];const e=[],t=new Set,r=document.querySelectorAll("*");for(let n=0;n<r.length;n++){const s=r[n].tagName.toLowerCase();if(s.includes("-")&&!t.has(s)&&typeof customElements<"u"&&customElements.get(s)){t.add(s);const o=document.querySelectorAll(s);e.push({tagName:s,instanceCount:o.length})}}return e},Qd=(e,t)=>{if(!dt)return;const r={timestamp:Date.now(),type:e,detail:t};Re.push(r),zr.logToConsole&&console.log(`[bq:devtools] ${e} — ${t}`)},Vd=()=>Re,Kd=()=>{Re.length=0},Yd=()=>({enabled:dt,options:{...zr},timeline:[...Re]}),Jd=()=>{const e=_o();if(e.length===0){console.log("[bq:devtools] No tracked signals.");return}console.table(e)},Gd=()=>{const e=xo();if(e.length===0){console.log("[bq:devtools] No stores registered.");return}console.table(e.map(t=>({id:t.id,state:JSON.stringify(t.state)})))},Xd=()=>{const e=qo();if(e.length===0){console.log("[bq:devtools] No custom elements found.");return}console.table(e)},Zd=e=>{const t=typeof e=="number"&&e>0?Re.slice(-e):Re;if(t.length===0){console.log("[bq:devtools] Timeline is empty.");return}console.table(t.map(r=>({time:new Date(r.timestamp).toISOString(),type:r.type,detail:r.detail})))},zo=e=>e!==void 0&&(e>="a"&&e<="z"||e>="A"&&e<="Z"||e>="0"&&e<="9"||e==="_"),eh=(e,t)=>{let r=1,n="",s=t+1;for(;s<e.length;){const o=e[s];if(o==="\\"&&s+1<e.length){n+=o+e[s+1],s+=2;continue}if(o==="(")r++;else if(o===")"&&(r--,r===0))return{constraint:n,endIndex:s+1};n+=o,s++}return null},jo=new Map,th=e=>{const t=Lr(e),r=jo.get(t);if(r)return r;const n=new RegExp(`^(?:${t})$`);return jo.set(t,n),n};function rh(e,t={}){if(!e||!e.includes("-"))throw new Error(`bQuery testing: "${e}" is not a valid custom element tag name (must contain a hyphen)`);const{props:r,slots:n,container:s=document.body}=t,o=document.createElement(e);if(r)for(const[a,c]of Object.entries(r))c!=null&&o.setAttribute(a,String(c));if(n)if(typeof n=="string")o.innerHTML=n;else{const a=[];for(const[c,l]of Object.entries(n))if(c==="default")a.push(l);else{const u=c.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;");a.push(`<div slot="${u}">${l}</div>`)}o.innerHTML=a.join("")}return s.appendChild(o),{el:o,unmount:()=>{o.parentNode&&o.parentNode.removeChild(o)}}}function Uo(){Se(()=>{})}function nh(e){const t=L(e);return Object.defineProperty(t,"initialValue",{value:e,writable:!1,enumerable:!0}),t.set=function(r){t.value=r},t.reset=function(){t.value=e},t}function sh(e,t){let r=e;t&&r.startsWith(t)&&(r=r.slice(t.length)||"/");let n="";const s=r.indexOf("#");s>=0&&(n=r.slice(s+1),r=r.slice(0,s));const o={},i=r.indexOf("?");if(i>=0){const a=r.slice(i+1);r=r.slice(0,i);for(const c of a.split("&")){const l=c.indexOf("="),u=l>=0?decodeURIComponent(c.slice(0,l)):decodeURIComponent(c),h=l>=0?decodeURIComponent(c.slice(l+1)):"",d=o[u];d!==void 0?Array.isArray(d)?d.push(h):o[u]=[d,h]:o[u]=h}}return{path:r||"/",query:o,hash:n}}function oh(e,t){for(const r of t){const n=ih(r.path,e);if(n)return{matched:r,params:n}}return{matched:null,params:{}}}function ih(e,t){if(e==="*")return{};const r=new Map,n=(o,i)=>{const a=o.indexOf("/",i);return a===-1?o.length:a},s=(o,i)=>{const a=`${o}:${i}`;if(r.has(a))return r.get(a)??null;if(o===e.length){const u=i===t.length?{}:null;return r.set(a,u),u}const c=e[o];if(c==="*"){for(let u=t.length;u>=i;u--){const h=s(o+1,u);if(h)return r.set(a,h),h}return r.set(a,null),null}if(c===":"&&zo(e[o+1])){let u=o+2;for(;u<e.length&&zo(e[u]);)u++;const h=e.slice(o+1,u);let d=u,p,f=!1;if(e[u]==="("){const v=eh(e,u);v&&(p=v.constraint,d=v.endIndex)}e[d]==="*"&&(f=!0,d++);const m=f||p?t.length:n(t,i);for(let v=m;v>i;v--){const b=t.slice(i,v);if(p&&!th(p).test(b))continue;const g=s(d,v);if(g){const w={[h]:b,...g};return r.set(a,w),w}}return r.set(a,null),null}if(i>=t.length||c!==t[i])return r.set(a,null),null;const l=s(o+1,i+1);return r.set(a,l),l};return s(0,0)}function ah(e={}){const t=e.routes??[{path:"*",component:()=>null}],r=e.base??"",n=e.initialPath??"/",s=i=>{const{path:a,query:c,hash:l}=sh(i,r),{matched:u,params:h}=oh(a,t);return{path:a,params:h,query:c,matched:u,hash:l}},o=L(s(n));return{push(i){o.value=s(i)},replace(i){o.value=s(i)},get currentRoute(){return o},get routes(){return t},destroy(){o.dispose()}}}function ch(e,t,r={}){if(!e)throw new Error("bQuery testing: fireEvent requires a valid element");if(!t)throw new Error("bQuery testing: fireEvent requires an event name");const{bubbles:n=!0,cancelable:s=!0,composed:o=!0,detail:i}=r;let a;i!==void 0?a=new CustomEvent(t,{bubbles:n,cancelable:s,composed:o,detail:i}):a=new Event(t,{bubbles:n,cancelable:s,composed:o});const c=e.dispatchEvent(a);return Uo(),c}async function lh(e,t={}){if(typeof e!="function")throw new Error("bQuery testing: waitFor requires a predicate function");const{timeout:r=1e3,interval:n=10}=t,s=Date.now();for(;;){try{if(await e())return}catch{}if(Date.now()-s>=r)throw new Error(`bQuery testing: waitFor timed out after ${r}ms — predicate never returned true`);await new Promise(o=>setTimeout(o,n))}}var Ho=(e,t,r={})=>{const{hydrate:n=!0,...s}=r;if(!n)throw new Error("bQuery ssr: hydrateMount() requires { hydrate: true } when options are provided.");return Dr(e,t,s)},me={backend:"auto",documentImpl:null},uh=e=>{e.backend!==void 0&&(me.backend=e.backend),e.documentImpl!==void 0&&(me.documentImpl=e.documentImpl)},fh=()=>({backend:me.backend,documentImpl:me.documentImpl}),dh=()=>me.backend==="pure"?"pure":me.backend==="dom"||me.documentImpl||typeof globalThis.DOMParser=="function"?"dom":"pure",hh=()=>me.documentImpl?me.documentImpl.DOMParser:typeof globalThis.DOMParser=="function"?globalThis.DOMParser:null,jr=e=>{let t=5381;for(let r=0;r<e.length;r++)t=(t<<5)+t+e.charCodeAt(r)|0;return(t>>>0).toString(36)},Kt="data-bq-h",mh=(e,t,r)=>{const n=[];for(const s of e)s!=="data-bq-h"&&(s.startsWith(`${r}-`)||s.startsWith(":"))&&n.push(`${s}=${t[s]??""}`);return n.join("|")},Wo=(e,t)=>{const r=[];for(const n of Array.from(e.attributes))n.name!=="data-bq-h"&&(n.name.startsWith(`${t}-`)||n.name.startsWith(":"))&&r.push(`${n.name}=${n.value}`);return r.join("|")},ph=e=>G(e)||ce(e)?e.value:e,vh=["===","!==","==","!=","<=",">=","&&","||","??","?."],yh="+-*/%<>!?:,.()[]",Fo=e=>e>="a"&&e<="z"||e>="A"&&e<="Z"||e==="_"||e==="$",gh=e=>Fo(e)||e>="0"&&e<="9",Ur=e=>e>="0"&&e<="9",bh=e=>{const t=[],r=e.length;let n=0;for(;n<r;){const s=e[n];if(s===" "||s===" "||s===`
275
+ `,ri=0,je=new Map,nd=()=>typeof document>"u"?!1:typeof document.createElement=="function"&&typeof document.querySelector=="function"&&typeof document.getElementById=="function"&&document.body!==null&&document.body!==void 0,sd=()=>({destroy:()=>{},element:null}),od=(e,t={})=>{if(!nd())return sd();const{text:r="Skip to main content",className:n="bq-skip-link"}=t;let s,o;const i=p=>{try{return document.querySelector(p)}catch{return null}},a=()=>{if(!s)return;const p=je.get(s),y=(p?.count??0)-1;y<=0?(je.delete(s),p?.target.isConnected&&p.target.id===s&&p.target.removeAttribute("id")):je.set(s,{count:y,target:p.target}),s=void 0},c=()=>{if(!o)return;const{target:p,hadTabIndex:y,previousTabIndex:b}=o;p.isConnected&&(y?p.setAttribute("tabindex",b??""):p.removeAttribute("tabindex")),o=void 0},l=p=>{if(o?.target!==p){if(c(),p.hasAttribute("tabindex")){o={target:p,hadTabIndex:!0,previousTabIndex:p.getAttribute("tabindex")};return}p.tabIndex===-1&&(o={target:p,hadTabIndex:!1,previousTabIndex:null},p.setAttribute("tabindex","-1"))}},u=(p,y)=>{if(s===y)return;a();const b=je.get(y);je.set(y,{count:(b?.count??0)+1,target:p}),s=y},h=()=>{if(e.startsWith("#")){const y=e.slice(1),b=y?document.getElementById(y):null;return b||i(e)}const p=document.getElementById(e);return p||i(e)},d=p=>{if(p.id)return je.get(p.id)?.target===p&&u(p,p.id),p.id;let y;do ri+=1,y=`bq-skip-target-${ri}`;while(document.getElementById(y)!==null);return p.id=y,u(p,y),y},v=document.createElement("a"),f=h();return v.href=e.startsWith("#")?e:f?`#${d(f)}`:`#${e}`,v.textContent=r,v.className=n,v.setAttribute("style",jr),v.addEventListener("focus",()=>{v.setAttribute("style",jr+rd)}),v.addEventListener("blur",()=>{v.setAttribute("style",jr)}),v.addEventListener("click",p=>{p.preventDefault();const y=h();y&&(v.href=`#${d(y)}`,l(y),y.focus())}),document.body.firstChild?document.body.insertBefore(v,document.body.firstChild):document.body.appendChild(v),{destroy:()=>{c(),a(),v.remove()},element:v}},id=["a[href]","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])",'[tabindex]:not([tabindex="-1"])','[contenteditable="true"]',"details > summary","audio[controls]","video[controls]"].join(", "),Ur=e=>Array.from(e.querySelectorAll(id)).filter(t=>!t.hasAttribute("disabled")&&t.tabIndex!==-1&&t.getClientRects().length>0),ni=(e,t)=>e?typeof e=="string"?t.querySelector(e):e:null,ad=(e,t={})=>{const{escapeDeactivates:r=!0,onEscape:n,initialFocus:s,returnFocus:o}=t;if(typeof document>"u"||typeof document.addEventListener!="function"||typeof document.removeEventListener!="function"){let h=!1;return{get active(){return h},release:()=>{h=!1}}}const i=document.activeElement;let a=!0;const c=h=>{if(!a)return;if(h.key==="Escape"&&r){h.preventDefault(),u.release(),n?.();return}if(h.key!=="Tab")return;const d=Ur(e);if(d.length===0){h.preventDefault();return}const v=d[0],f=d[d.length-1];h.shiftKey?(document.activeElement===v||!e.contains(document.activeElement))&&(h.preventDefault(),f.focus()):(document.activeElement===f||!e.contains(document.activeElement))&&(h.preventDefault(),v.focus())};document.addEventListener("keydown",c,!0);const l=ni(s,e);if(l)l.focus();else{const h=Ur(e);h.length>0&&h[0].focus()}const u={get active(){return a},release:()=>{if(!a)return;a=!1,document.removeEventListener("keydown",c,!0);const h=ni(o,document.body);h?h.focus():i&&i.focus&&i.focus()}};return u},cd=e=>{e.release()},lt=new Map,si=()=>{const e=Array.from(lt.values());return e[e.length-1]},ld=(e,t)=>{if(typeof t=="object")return t;let r=null;if(t==="parent"?r=e.parentElement:r=document.querySelector(t),!r)return null;const n=r.getBoundingClientRect(),s=e.getBoundingClientRect(),o=parseFloat(e.style.left||"0"),i=parseFloat(e.style.top||"0"),a=Number.isNaN(o)?0:o,c=Number.isNaN(i)?0:i;return{left:n.left-s.left+a,top:n.top-s.top+c,right:n.right-s.right+a+(n.width-s.width),bottom:n.bottom-s.bottom+c+(n.height-s.height)}},ud=(e,t)=>t?{x:Math.max(t.left,Math.min(t.right,e.x)),y:Math.max(t.top,Math.min(t.bottom,e.y))}:e,fd=(e,t={})=>{const{axis:r="both",bounds:n,handle:s,ghost:o=!1,ghostClass:i="bq-drag-ghost",draggingClass:a="bq-dragging",onDragStart:c,onDrag:l,onDragEnd:u}=t;let h=!t.disabled,d=!1,v={x:0,y:0},f={x:0,y:0},p={x:0,y:0},y=null,b=null;const g=e.style.touchAction,w=e.style.userSelect,S=R=>({element:e,position:{...f},delta:{x:f.x-p.x,y:f.y-p.y},event:R}),k=()=>{const R=e.cloneNode(!0),$=e.getBoundingClientRect();return R.classList.add(i),R.style.position="fixed",R.style.left=`${$.left}px`,R.style.top=`${$.top}px`,R.style.width=`${$.width}px`,R.style.height=`${$.height}px`,R.style.pointerEvents="none",R.style.zIndex="999999",R.style.opacity="0.7",R.style.margin="0",document.body.appendChild(R),R},A=()=>{y&&(y.remove(),y=null),b=null},E=R=>{if(h&&!(s&&!R.target.closest(s))){if(R.preventDefault(),d=!0,v={x:R.clientX,y:R.clientY},p={...f},e.classList.add(a),e.setPointerCapture(R.pointerId),o){const $=e.getBoundingClientRect();b={x:$.left,y:$.top},y=k()}lt.set(e,{element:e,position:f}),c?.(S(R))}},T=R=>{if(!d)return;R.preventDefault(),p={...f};let $=f.x+(R.clientX-v.x),C=f.y+(R.clientY-v.y);v={x:R.clientX,y:R.clientY},r==="x"&&(C=f.y),r==="y"&&($=f.x);let O={x:$,y:C};if(n){const I=ld(e,n);O=ud(O,I)}if(f=O,lt.set(e,{element:e,position:f}),o&&y){const I=b??{x:e.getBoundingClientRect().left,y:e.getBoundingClientRect().top};y.style.left=`${I.x+f.x}px`,y.style.top=`${I.y+f.y}px`}else e.style.transform=`translate(${f.x}px, ${f.y}px)`;l?.(S(R))},P=R=>{if(d){d=!1,e.classList.remove(a);try{typeof e.releasePointerCapture=="function"&&(typeof e.hasPointerCapture!="function"||e.hasPointerCapture(R.pointerId))&&e.releasePointerCapture(R.pointerId)}catch{}finally{A(),lt.delete(e),u?.(S(R))}}};return e.addEventListener("pointerdown",E),e.addEventListener("pointermove",T),e.addEventListener("pointerup",P),e.addEventListener("pointercancel",P),e.style.touchAction="none",e.style.userSelect="none",{destroy:()=>{e.removeEventListener("pointerdown",E),e.removeEventListener("pointermove",T),e.removeEventListener("pointerup",P),e.removeEventListener("pointercancel",P),A(),lt.delete(e),e.style.touchAction=g,e.style.userSelect=w,e.classList.remove(a)},disable:()=>{h=!1},enable:()=>{h=!0},get enabled(){return h}}},dd={passive:!0},ut=new Set,ft=null,de=null,oi=()=>Array.from(ut),hd=()=>typeof document<"u"&&typeof document.addEventListener=="function"&&typeof document.removeEventListener=="function"&&typeof requestAnimationFrame=="function"&&typeof cancelAnimationFrame=="function",md=e=>{for(const t of oi())t.handlePointerMove(e)},pd=()=>{de=null;const e=ft;ft=null,e&&md(e)},ii=e=>{ft=e,de===null&&(de=requestAnimationFrame(pd))},ai=e=>{de!==null&&(cancelAnimationFrame(de),de=null,ft=null);for(const t of oi())t.handlePointerUp(e)},vd=e=>{ut.size===0&&(document.addEventListener("pointermove",ii,dd),document.addEventListener("pointerup",ai)),ut.add(e)},yd=e=>{ut.delete(e),ut.size===0&&(document.removeEventListener("pointermove",ii),document.removeEventListener("pointerup",ai),de!==null&&(cancelAnimationFrame(de),de=null),ft=null)},ci=(e,t)=>t?typeof t=="string"?e.matches(t):t(e):!0,gd=(e,t={})=>{const{overClass:r="bq-drop-over",accept:n,onDragEnter:s,onDragOver:o,onDragLeave:i,onDrop:a}=t;if(!hd())return{destroy:()=>{}};let c=!1,l=null;const u=(b,g)=>({zone:e,dragged:b,event:g}),h=b=>{const g=e.getBoundingClientRect();return b.clientX>=g.left&&b.clientX<=g.right&&b.clientY>=g.top&&b.clientY<=g.bottom},d=()=>si()?.element??l,v=(b,g=l)=>{c&&(c=!1,e.classList.remove(r),g&&i?.(u(g,b)),l=null)},y={handlePointerMove:b=>{const g=si()?.element??null,w=h(b);if(!(g!==null&&g!==e&&ci(g,n))||!w){v(b,g??l);return}c?o?.(u(g,b)):(c=!0,l=g,e.classList.add(r),s?.(u(g,b)))},handlePointerUp:b=>{const g=d(),w=h(b),S=g!==null&&g!==e&&ci(g,n);w&&S&&g&&a?.(u(g,b)),c&&(c=!1,e.classList.remove(r)),l=null}};return vd(y),{destroy:()=>{yd(y),e.classList.remove(r),l=null}}},li=(e,t)=>Array.from(e.querySelectorAll(t)),bd=(e,t,r,n)=>{let s=null;for(let o=0;o<e.length;o++){const i=e[o];if(i===n)continue;const a=i.getBoundingClientRect(),c=t-(r==="y"?a.top+a.height/2:a.left+a.width/2);(s===null||c<0&&c>s.distance||s.distance>=0&&c<0&&Math.abs(c)<Math.abs(s.distance))&&c<0&&(s={element:i,index:o,distance:c})}return s?{element:s.element,index:s.index}:null},wd=(e,t={})=>{const{items:r=":scope > *",axis:n="y",handle:s,placeholderClass:o="bq-sort-placeholder",sortingClass:i="bq-sorting",animationDuration:a=200,onSortStart:c,onSortMove:l,onSortEnd:u}=t;let h=!t.disabled,d=!1,v=null,f=null,p=-1,y=0,b=0,g=0,w=0;const S=(P,R,$)=>({container:e,item:P,oldIndex:R,newIndex:$}),k=P=>{if(!h)return;const R=P.target,$=li(e,r);let C=null;for(const I of $)if(I.contains(R)){C=I;break}if(!C||s&&!R.closest(s))return;P.preventDefault(),d=!0,v=C,p=$.indexOf(C),y=P.clientY,b=P.clientX;const O=C.getBoundingClientRect();g=O.top,w=O.left,f=document.createElement("div"),f.classList.add(o),f.style.width=`${O.width}px`,f.style.height=`${O.height}px`,f.style.boxSizing="border-box",C.classList.add(i),C.style.position="fixed",C.style.width=`${O.width}px`,C.style.height=`${O.height}px`,C.style.left=`${O.left}px`,C.style.top=`${O.top}px`,C.style.zIndex="999999",C.style.pointerEvents="none",C.style.margin="0",C.parentNode?.insertBefore(f,C),e.setPointerCapture(P.pointerId),c?.(S(C,p,p))},A=P=>{if(!d||!v||!f)return;P.preventDefault();const R=P.clientX-b,$=P.clientY-y;n==="y"?v.style.top=`${g+$}px`:v.style.left=`${w+R}px`;const C=bd(li(e,r),n==="y"?P.clientY:P.clientX,n,v);C?e.insertBefore(f,C.element):e.appendChild(f);const O=Array.from(e.children).indexOf(f);l?.(S(v,p,O))},E=P=>{if(!d||!v||!f)return;d=!1;const R=v,$=Array.from(e.children).indexOf(f),C=f.getBoundingClientRect(),O=R.getBoundingClientRect();if(a>0){const I=C.left-O.left,q=C.top-O.top;R.style.transition=`transform ${a}ms ease`,R.style.transform=`translate(${I}px, ${q}px)`;let W=!1,x=null;const V=()=>{W||(W=!0,x!==null&&(window.clearTimeout(x),x=null),T(),u?.(S(R,p,$)))};x=window.setTimeout(()=>{V()},a+50),R.addEventListener("transitionend",V,{once:!0})}else T(),u?.(S(R,p,$));e.releasePointerCapture(P.pointerId)},T=()=>{!v||!f||(f.parentNode?.insertBefore(v,f),f.remove(),f=null,v.classList.remove(i),v.style.position="",v.style.width="",v.style.height="",v.style.left="",v.style.top="",v.style.zIndex="",v.style.pointerEvents="",v.style.margin="",v.style.transition="",v.style.transform="",v=null)};return e.addEventListener("pointerdown",k),e.addEventListener("pointermove",A),e.addEventListener("pointerup",E),e.addEventListener("pointercancel",E),e.style.touchAction="none",{destroy:()=>{e.removeEventListener("pointerdown",k),e.removeEventListener("pointermove",A),e.removeEventListener("pointerup",E),e.removeEventListener("pointercancel",E),e.style.touchAction="",d&&T()},disable:()=>{h=!1},enable:()=>{h=!0},get enabled(){return h}}},Sd=e=>{const t=L(!1);let r;if(typeof window<"u"&&typeof window.matchMedia=="function")try{const o=window.matchMedia(e);t.value=o.matches;const i=a=>{t.value=a.matches};if(typeof o.addEventListener=="function")o.addEventListener("change",i),r=()=>{o.removeEventListener("change",i)};else if(typeof o.addListener=="function"){const a=o;a.addListener(i),r=()=>{a.removeListener(i)}}}catch{}const n=_(t);let s=!1;return Object.defineProperty(n,"destroy",{enumerable:!1,configurable:!0,value(){s||(s=!0,r?.(),t.dispose())}}),n},Ed=e=>{const t={},r=[];for(const o of Object.keys(e)){const i=e[o],a=L(!1);let c;if(typeof window<"u"&&typeof window.matchMedia=="function")try{const h=window.matchMedia(`(min-width: ${i}px)`);a.value=h.matches;const d=v=>{a.value=v.matches};if(typeof h.addEventListener=="function")h.addEventListener("change",d),c=()=>{h.removeEventListener("change",d)};else{const v=h;typeof v.addListener=="function"&&(v.addListener(d),c=()=>{v.removeListener?.(d)})}}catch{}const l=_(a);let u=!1;Object.defineProperty(l,"destroy",{enumerable:!1,configurable:!0,value(){u||(u=!0,c?.(),a.dispose())}}),r.push(l.destroy),t[o]=l}let n=!1;const s=Object.defineProperty(t,"destroyAll",{enumerable:!1,configurable:!0,value(){n||(n=!0,r.forEach(o=>{o()}))}});return Object.prototype.hasOwnProperty.call(t,"destroy")||Object.defineProperty(s,"destroy",{enumerable:!1,configurable:!0,value:s.destroyAll}),s},ui=(e,t)=>t>=e?"portrait":"landscape",Ad=()=>{const e=L({width:typeof window<"u"?window.innerWidth:0,height:typeof window<"u"?window.innerHeight:0,orientation:typeof window<"u"?ui(window.innerWidth,window.innerHeight):"portrait"});let t;if(typeof window<"u"){const s=()=>{e.value={width:window.innerWidth,height:window.innerHeight,orientation:ui(window.innerWidth,window.innerHeight)}};window.addEventListener("resize",s),t=()=>{window.removeEventListener("resize",s)}}const r=_(e);let n=!1;return Object.defineProperty(r,"destroy",{enumerable:!1,configurable:!0,value:()=>{n||(n=!0,t?.(),e.dispose())}}),r},fi=()=>{const e=typeof navigator<"u"&&navigator.onLine!==void 0?navigator.onLine:!0,t=(typeof navigator<"u"?navigator:void 0)?.connection;return{online:e,effectiveType:t?.effectiveType??"unknown",downlink:t?.downlink??0,rtt:t?.rtt??0}},kd=()=>{const e=L(fi());let t;if(typeof window<"u"){const s=()=>{e.value=fi()};window.addEventListener("online",s),window.addEventListener("offline",s);const o=typeof navigator<"u"?navigator:void 0;o?.connection&&typeof o.connection.addEventListener=="function"&&o.connection.addEventListener("change",s),t=()=>{window.removeEventListener("online",s),window.removeEventListener("offline",s),o?.connection&&typeof o.connection.removeEventListener=="function"&&o.connection.removeEventListener("change",s)}}const r=_(e);let n=!1;return Object.defineProperty(r,"destroy",{value(){n||(n=!0,t?.(),e.dispose())},enumerable:!1,configurable:!0}),r},Td={supported:!1,charging:!1,chargingTime:0,dischargingTime:0,level:1},Cd=()=>{const e=L({...Td});let t,r=!1;typeof navigator<"u"&&"getBattery"in navigator&&typeof navigator.getBattery=="function"&&navigator.getBattery().then(s=>{if(r)return;const o=()=>{e.value={supported:!0,charging:s.charging,chargingTime:s.chargingTime,dischargingTime:s.dischargingTime,level:s.level}};o(),s.addEventListener("chargingchange",o),s.addEventListener("chargingtimechange",o),s.addEventListener("dischargingtimechange",o),s.addEventListener("levelchange",o),t=()=>{s.removeEventListener("chargingchange",o),s.removeEventListener("chargingtimechange",o),s.removeEventListener("dischargingtimechange",o),s.removeEventListener("levelchange",o)}}).catch(()=>{});const n=_(e);return Object.defineProperty(n,"destroy",{enumerable:!1,configurable:!0,value(){r||(r=!0,t?.(),e.dispose())}}),n},di={supported:!1,loading:!1,latitude:null,longitude:null,accuracy:null,altitude:null,altitudeAccuracy:null,heading:null,speed:null,timestamp:null,error:null},Rd=(e={})=>{const{enableHighAccuracy:t=!1,maximumAge:r=0,timeout:n=1/0,watch:s=!1}=e,o=L({...di});let i;if(typeof navigator<"u"&&"geolocation"in navigator){o.value={...di,supported:!0,loading:!0};const l={enableHighAccuracy:t,maximumAge:r,timeout:n===1/0?void 0:n},u=d=>{o.value={supported:!0,loading:!1,latitude:d.coords.latitude,longitude:d.coords.longitude,accuracy:d.coords.accuracy,altitude:d.coords.altitude,altitudeAccuracy:d.coords.altitudeAccuracy,heading:d.coords.heading,speed:d.coords.speed,timestamp:d.timestamp,error:null}},h=d=>{o.value={...o.value,loading:!1,error:d.message}};if(s){const d=navigator.geolocation.watchPosition(u,h,l);i=()=>{navigator.geolocation.clearWatch(d)}}else navigator.geolocation.getCurrentPosition(u,h,l)}const a=_(o);let c=!1;return Object.defineProperty(a,"destroy",{enumerable:!1,configurable:!0,value(){c||(c=!0,i?.(),o.dispose())}}),a},$d={acceleration:{x:null,y:null,z:null},accelerationIncludingGravity:{x:null,y:null,z:null},rotationRate:{alpha:null,beta:null,gamma:null},interval:0},Od={alpha:null,beta:null,gamma:null,absolute:!1},Ld=()=>{const e=L({...$d});let t;if(typeof window<"u"){const s=o=>{e.value={acceleration:{x:o.acceleration?.x??null,y:o.acceleration?.y??null,z:o.acceleration?.z??null},accelerationIncludingGravity:{x:o.accelerationIncludingGravity?.x??null,y:o.accelerationIncludingGravity?.y??null,z:o.accelerationIncludingGravity?.z??null},rotationRate:{alpha:o.rotationRate?.alpha??null,beta:o.rotationRate?.beta??null,gamma:o.rotationRate?.gamma??null},interval:o.interval??0}};window.addEventListener("devicemotion",s),t=()=>{window.removeEventListener("devicemotion",s)}}const r=_(e);let n=!1;return Object.defineProperty(r,"destroy",{enumerable:!1,configurable:!0,value(){n||(n=!0,t?.(),e.dispose())}}),r},Pd=()=>{const e=L({...Od});let t;if(typeof window<"u"){const s=o=>{e.value={alpha:o.alpha??null,beta:o.beta??null,gamma:o.gamma??null,absolute:o.absolute??!1}};window.addEventListener("deviceorientation",s),t=()=>{window.removeEventListener("deviceorientation",s)}}const r=_(e);let n=!1;return Object.defineProperty(r,"destroy",{enumerable:!1,configurable:!0,value(){n||(n=!0,t?.(),e.dispose())}}),r},hi="bQuery media: Clipboard API is unavailable. Use a secure context (HTTPS or localhost) and ensure clipboard permissions or user-activation requirements are met.",Nd={read:async()=>{if(typeof navigator>"u"||!navigator.clipboard||typeof navigator.clipboard.readText!="function")throw new Error(hi);return navigator.clipboard.readText()},write:async e=>{if(typeof navigator>"u"||!navigator.clipboard||typeof navigator.clipboard.writeText!="function")throw new Error(hi);return navigator.clipboard.writeText(e)}},Id=(e,t)=>{let r;t==="border-box"?r=e.borderBoxSize:t==="device-pixel-content-box"?r=e.devicePixelContentBoxSize:r=e.contentBoxSize;const n=Array.isArray(r)?r[0]:r;return n&&typeof n.inlineSize=="number"&&typeof n.blockSize=="number"?{width:n.inlineSize,height:n.blockSize}:{width:e.contentRect.width,height:e.contentRect.height}},Md=(e,t)=>{const r=L({isIntersecting:!1,intersectionRatio:0,entry:null});let n,s=!1;if(typeof window<"u"&&typeof IntersectionObserver<"u")try{if(n=new IntersectionObserver(i=>{if(s)return;const a=i[i.length-1];a&&(r.value={isIntersecting:a.isIntersecting,intersectionRatio:a.intersectionRatio,entry:a})},{root:t?.root??null,rootMargin:t?.rootMargin??"0px",threshold:t?.threshold??0}),e){const i=Array.isArray(e)?e:[e];for(const a of i)n.observe(a)}}catch{n&&n.disconnect(),n=void 0}const o=_(r);return Object.defineProperties(o,{observe:{enumerable:!1,configurable:!0,value(i){if(!s)try{n?.observe(i)}catch{}}},unobserve:{enumerable:!1,configurable:!0,value(i){s||n?.unobserve(i)}},destroy:{enumerable:!1,configurable:!0,value(){s||(s=!0,n?.disconnect(),n=void 0,r.dispose())}}}),o},Dd=(e,t)=>{const r=L({width:0,height:0,entry:null});let n,s=!1;const o=t?.box??"content-box",i=t?.box?{box:t.box}:void 0;if(typeof window<"u"&&typeof ResizeObserver<"u")try{if(n=new ResizeObserver(c=>{if(s)return;const l=c[c.length-1];if(l){const{width:u,height:h}=Id(l,o);r.value={width:u,height:h,entry:l}}}),e){const c=Array.isArray(e)?e:[e];for(const l of c)n.observe(l,i)}}catch{n&&n.disconnect(),n=void 0}const a=_(r);return Object.defineProperties(a,{observe:{enumerable:!1,configurable:!0,value(c){if(!s)try{n?.observe(c,i)}catch{}}},unobserve:{enumerable:!1,configurable:!0,value(c){s||n?.unobserve(c)}},destroy:{enumerable:!1,configurable:!0,value(){s||(s=!0,n?.disconnect(),n=void 0,r.dispose())}}}),a},_d=(e,t)=>{const r=L({mutations:[],count:0});let n,s=!1,o=0;const i={attributes:t?.attributes??!0,childList:t?.childList??!1,characterData:t?.characterData??!1,subtree:t?.subtree??!1,attributeOldValue:t?.attributeOldValue??!1,characterDataOldValue:t?.characterDataOldValue??!1,...t&&t.attributeFilter!==void 0?{attributeFilter:t.attributeFilter}:{}};if(!i.attributes&&!i.childList&&!i.characterData&&(i.attributes=!0),i.attributes||(i.attributeOldValue=!1,delete i.attributeFilter),i.characterData||(i.characterDataOldValue=!1),typeof window<"u"&&typeof MutationObserver<"u")try{n=new MutationObserver(c=>{s||(o+=1,r.value={mutations:c,count:o})}),e&&n.observe(e,i)}catch{n&&n.disconnect(),n=void 0}const a=_(r);return Object.defineProperties(a,{observe:{enumerable:!1,configurable:!0,value(c){if(!s)try{n?.observe(c,i)}catch{}}},takeRecords:{enumerable:!1,configurable:!0,value(){return n?.takeRecords()??[]}},destroy:{enumerable:!1,configurable:!0,value(){s||(s=!0,n?.disconnect(),n=void 0,r.dispose())}}}),a},dt=new Set,he=new Map,Hr=()=>{vf(e=>he.get(e))};Hr();var mi=e=>{he.clear();for(const[t,r]of e)he.set(t,r)},qd=e=>({directive(t,r){if(typeof t!="string"||t.length===0)throw new Error("bQuery plugin directive: name must be a non-empty string");if(t.startsWith("bq-")){const n=t.slice(3);throw new Error(`bQuery plugin directive: name "${t}" must be provided without the "bq-" prefix`+(n?` (use "${n}")`:""))}if(typeof r!="function")throw new Error(`bQuery plugin directive: handler for "${t}" must be a function`);if(he.has(t))throw new Error(`bQuery plugin directive: a directive named "${t}" is already registered`);he.set(t,r)},component(t,r,n){if(typeof t!="string"||t.length===0)throw new Error("bQuery plugin component: tagName must be a non-empty string");if(!t.includes("-"))throw new Error(`bQuery plugin component: tagName "${t}" must be a valid custom element name containing a hyphen`);if(typeof r!="function")throw new Error(`bQuery plugin component: constructor for "${t}" must be a function`);if(typeof customElements>"u"){typeof console<"u"&&typeof console.warn=="function"&&console.warn(`[bQuery] plugin component "${t}" was not registered because customElements is not available in this environment.`);return}!customElements.get(t)&&!e.some(s=>s.tagName===t)&&e.push({tagName:t,constructor:r,options:n})}}),xd=(e,t)=>{if(Hr(),!e||typeof e!="object")throw new Error("bQuery plugin: use() expects a plugin object with { name, install }");if(typeof e.name!="string"||e.name.length===0)throw new Error('bQuery plugin: plugin must have a non-empty "name" property');if(typeof e.install!="function")throw new Error(`bQuery plugin: plugin "${e.name}" must have an "install" function`);if(dt.has(e.name))return;const r=[],n=qd(r),s=new Map(he);try{e.install(n,t)}catch(o){throw mi(s),o}try{for(const o of r)customElements.get(o.tagName)||customElements.define(o.tagName,o.constructor,o.options)}catch(o){throw mi(s),o}dt.add(e.name)},zd=e=>dt.has(e),jd=()=>[...dt],Ud=e=>he.get(e),Hd=()=>[...he.entries()].map(([e,t])=>({name:e,handler:t})),Wd=()=>{dt.clear(),he.clear(),Hr()},ht=!1,Wr={},$e=[],Yt=new Map,pi=0,Fd=(e,t)=>{ht=e,Wr=t??{},e||($e.length=0,Yt.clear(),pi=0)},Bd=()=>ht,Qd=(e,t,r)=>{if(ht){if(typeof e!="string"||e.length===0)throw new Error("bQuery devtools: trackSignal() requires a non-empty label");Yt.set(e,{peek:t,subscriberCount:r})}},Vd=e=>{Yt.delete(e)},Kd=()=>`signal_${pi++}`,vi=()=>{const e=[];for(const[t,r]of Yt)e.push({label:t,value:r.peek(),subscriberCount:r.subscriberCount()});return e},yi=()=>{try{return Bt().map(e=>{const t=we(e),r={};if(t&&typeof t=="object"&&"$state"in t){const n=t.$state;n&&typeof n=="object"&&Object.assign(r,n)}return{id:e,state:r}})}catch{return[]}},gi=()=>{if(typeof document>"u")return[];const e=[],t=new Set,r=document.querySelectorAll("*");for(let n=0;n<r.length;n++){const s=r[n].tagName.toLowerCase();if(s.includes("-")&&!t.has(s)&&typeof customElements<"u"&&customElements.get(s)){t.add(s);const o=document.querySelectorAll(s);e.push({tagName:s,instanceCount:o.length})}}return e},Yd=(e,t)=>{if(!ht)return;const r={timestamp:Date.now(),type:e,detail:t};$e.push(r),Wr.logToConsole&&console.log(`[bq:devtools] ${e} — ${t}`)},Jd=()=>$e,Gd=()=>{$e.length=0},Xd=()=>({enabled:ht,options:{...Wr},timeline:[...$e]}),Zd=()=>{const e=vi();if(e.length===0){console.log("[bq:devtools] No tracked signals.");return}console.table(e)},eh=()=>{const e=yi();if(e.length===0){console.log("[bq:devtools] No stores registered.");return}console.table(e.map(t=>({id:t.id,state:JSON.stringify(t.state)})))},th=()=>{const e=gi();if(e.length===0){console.log("[bq:devtools] No custom elements found.");return}console.table(e)},rh=e=>{const t=typeof e=="number"&&e>0?$e.slice(-e):$e;if(t.length===0){console.log("[bq:devtools] Timeline is empty.");return}console.table(t.map(r=>({time:new Date(r.timestamp).toISOString(),type:r.type,detail:r.detail})))},bi=e=>e!==void 0&&(e>="a"&&e<="z"||e>="A"&&e<="Z"||e>="0"&&e<="9"||e==="_"),nh=(e,t)=>{let r=1,n="",s=t+1;for(;s<e.length;){const o=e[s];if(o==="\\"&&s+1<e.length){n+=o+e[s+1],s+=2;continue}if(o==="(")r++;else if(o===")"&&(r--,r===0))return{constraint:n,endIndex:s+1};n+=o,s++}return null},wi=new Map,sh=e=>{const t=Nr(e),r=wi.get(t);if(r)return r;const n=new RegExp(`^(?:${t})$`);return wi.set(t,n),n};function oh(e,t={}){if(!e||!e.includes("-"))throw new Error(`bQuery testing: "${e}" is not a valid custom element tag name (must contain a hyphen)`);const{props:r,slots:n,container:s=document.body}=t,o=document.createElement(e);if(r)for(const[a,c]of Object.entries(r))c!=null&&o.setAttribute(a,String(c));if(n)if(typeof n=="string")o.innerHTML=n;else{const a=[];for(const[c,l]of Object.entries(n))if(c==="default")a.push(l);else{const u=c.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;");a.push(`<div slot="${u}">${l}</div>`)}o.innerHTML=a.join("")}return s.appendChild(o),{el:o,unmount:()=>{o.parentNode&&o.parentNode.removeChild(o)}}}function Si(){ke(()=>{})}function ih(e){const t=L(e);return Object.defineProperty(t,"initialValue",{value:e,writable:!1,enumerable:!0}),t.set=function(r){t.value=r},t.reset=function(){t.value=e},t}function ah(e,t){let r=e;t&&r.startsWith(t)&&(r=r.slice(t.length)||"/");let n="";const s=r.indexOf("#");s>=0&&(n=r.slice(s+1),r=r.slice(0,s));const o={},i=r.indexOf("?");if(i>=0){const a=r.slice(i+1);r=r.slice(0,i);for(const c of a.split("&")){const l=c.indexOf("="),u=l>=0?decodeURIComponent(c.slice(0,l)):decodeURIComponent(c),h=l>=0?decodeURIComponent(c.slice(l+1)):"",d=o[u];d!==void 0?Array.isArray(d)?d.push(h):o[u]=[d,h]:o[u]=h}}return{path:r||"/",query:o,hash:n}}function ch(e,t){for(const r of t){const n=lh(r.path,e);if(n)return{matched:r,params:n}}return{matched:null,params:{}}}function lh(e,t){if(e==="*")return{};const r=new Map,n=(o,i)=>{const a=o.indexOf("/",i);return a===-1?o.length:a},s=(o,i)=>{const a=`${o}:${i}`;if(r.has(a))return r.get(a)??null;if(o===e.length){const u=i===t.length?{}:null;return r.set(a,u),u}const c=e[o];if(c==="*"){for(let u=t.length;u>=i;u--){const h=s(o+1,u);if(h)return r.set(a,h),h}return r.set(a,null),null}if(c===":"&&bi(e[o+1])){let u=o+2;for(;u<e.length&&bi(e[u]);)u++;const h=e.slice(o+1,u);let d=u,v,f=!1;if(e[u]==="("){const y=nh(e,u);y&&(v=y.constraint,d=y.endIndex)}e[d]==="*"&&(f=!0,d++);const p=f||v?t.length:n(t,i);for(let y=p;y>i;y--){const b=t.slice(i,y);if(v&&!sh(v).test(b))continue;const g=s(d,y);if(g){const w={[h]:b,...g};return r.set(a,w),w}}return r.set(a,null),null}if(i>=t.length||c!==t[i])return r.set(a,null),null;const l=s(o+1,i+1);return r.set(a,l),l};return s(0,0)}function uh(e={}){const t=e.routes??[{path:"*",component:()=>null}],r=e.base??"",n=e.initialPath??"/",s=i=>{const{path:a,query:c,hash:l}=ah(i,r),{matched:u,params:h}=ch(a,t);return{path:a,params:h,query:c,matched:u,hash:l}},o=L(s(n));return{push(i){o.value=s(i)},replace(i){o.value=s(i)},get currentRoute(){return o},get routes(){return t},destroy(){o.dispose()}}}function fh(e,t,r={}){if(!e)throw new Error("bQuery testing: fireEvent requires a valid element");if(!t)throw new Error("bQuery testing: fireEvent requires an event name");const{bubbles:n=!0,cancelable:s=!0,composed:o=!0,detail:i}=r;let a;i!==void 0?a=new CustomEvent(t,{bubbles:n,cancelable:s,composed:o,detail:i}):a=new Event(t,{bubbles:n,cancelable:s,composed:o});const c=e.dispatchEvent(a);return Si(),c}async function dh(e,t={}){if(typeof e!="function")throw new Error("bQuery testing: waitFor requires a predicate function");const{timeout:r=1e3,interval:n=10}=t,s=Date.now();for(;;){try{if(await e())return}catch{}if(Date.now()-s>=r)throw new Error(`bQuery testing: waitFor timed out after ${r}ms — predicate never returned true`);await new Promise(o=>setTimeout(o,n))}}var Ei=(e,t,r={})=>{const{hydrate:n=!0,...s}=r;if(!n)throw new Error("bQuery ssr: hydrateMount() requires { hydrate: true } when options are provided.");return zr(e,t,s)},me={backend:"auto",documentImpl:null},hh=e=>{e.backend!==void 0&&(me.backend=e.backend),e.documentImpl!==void 0&&(me.documentImpl=e.documentImpl)},mh=()=>({backend:me.backend,documentImpl:me.documentImpl}),ph=()=>me.backend==="pure"?"pure":me.backend==="dom"||me.documentImpl||typeof globalThis.DOMParser=="function"?"dom":"pure",vh=()=>me.documentImpl?me.documentImpl.DOMParser:typeof globalThis.DOMParser=="function"?globalThis.DOMParser:null,Fr=e=>{let t=5381;for(let r=0;r<e.length;r++)t=(t<<5)+t+e.charCodeAt(r)|0;return(t>>>0).toString(36)},Jt="data-bq-h",yh=(e,t,r)=>{const n=[];for(const s of e)s!=="data-bq-h"&&(s.startsWith(`${r}-`)||s.startsWith(":"))&&n.push(`${s}=${t[s]??""}`);return n.join("|")},Ai=(e,t)=>{const r=[];for(const n of Array.from(e.attributes))n.name!=="data-bq-h"&&(n.name.startsWith(`${t}-`)||n.name.startsWith(":"))&&r.push(`${n.name}=${n.value}`);return r.join("|")},gh=e=>G(e)||ce(e)?e.value:e,bh=["===","!==","==","!=","<=",">=","&&","||","??","?."],wh="+-*/%<>!?:,.()[]",ki=e=>e>="a"&&e<="z"||e>="A"&&e<="Z"||e==="_"||e==="$",Sh=e=>ki(e)||e>="0"&&e<="9",Br=e=>e>="0"&&e<="9",Eh=e=>{const t=[],r=e.length;let n=0;for(;n<r;){const s=e[n];if(s===" "||s===" "||s===`
276
276
  `||s==="\r"){n++;continue}if(s==='"'||s==="'"){const i=s,a=n;n++;let c="";for(;n<r&&e[n]!==i;){if(e[n]==="\\"&&n+1<r){const l=e[n+1];l==="n"?c+=`
277
- `:l==="t"?c+=" ":l==="r"?c+="\r":l==="\\"?c+="\\":l===i?c+=i:c+=l,n+=2;continue}c+=e[n],n++}if(n>=r)throw new Error("Unterminated string literal in SSR expression");n++,t.push({kind:"string",value:c,start:a});continue}if(Ur(s)||s==="."&&n+1<r&&Ur(e[n+1])){const i=n;for(;n<r&&(Ur(e[n])||e[n]===".");)n++;t.push({kind:"number",value:e.slice(i,n),start:i});continue}if(Fo(s)){const i=n;for(;n<r&&gh(e[n]);)n++;t.push({kind:"ident",value:e.slice(i,n),start:i});continue}let o=!1;for(const i of vh)if(e.startsWith(i,n)){t.push({kind:"punct",value:i,start:n}),n+=i.length,o=!0;break}if(!o){if(yh.includes(s)){t.push({kind:"punct",value:s,start:n}),n++;continue}throw new Error(`Unexpected character "${s}" in SSR expression`)}}return t.push({kind:"eof",value:"",start:r}),t},Y=e=>e.tokens[e.pos],je=e=>e.tokens[e.pos++],K=(e,t)=>{const r=Y(e);if(r.kind!=="punct"||r.value!==t)throw new Error(`Expected "${t}" in SSR expression, got "${r.value}"`);e.pos++},Yt=(e,t)=>{const r=Y(e);return r.kind==="punct"&&r.value===t?(e.pos++,!0):!1},Jt=(e,t,r)=>{K(e,t);const n=[t];for(;n.length>0;){const s=je(e);if(!s||s.kind==="eof")throw new Error(`Unterminated "${t}${r}" group in SSR expression`);if(s.kind==="punct"){if(s.value==="("||s.value==="["){n.push(s.value);continue}if(s.value===")"||s.value==="]"){const o=n[n.length-1],i=o==="("?")":"]";if(s.value!==i)throw new Error(`Mismatched "${o}${i}" group in SSR expression`);n.pop()}}}},Hr=e=>{const t=Y(e);if(t.kind==="punct"&&t.value==="["){Jt(e,"[","]");return}if(t.kind==="punct"&&t.value==="("){Jt(e,"(",")");return}if(t.kind==="ident"){e.pos++;return}throw new Error("Invalid optional chain in SSR expression")},wh=e=>{for(;;){const t=Y(e);if(t.kind!=="punct")break;if(t.value==="."){if(e.pos++,je(e).kind!=="ident")throw new Error('Expected identifier after "."');continue}if(t.value==="["){Jt(e,"[","]");continue}if(t.value==="("){Jt(e,"(",")");continue}if(t.value==="?."){e.pos++,Hr(e);continue}break}},Sh=e=>{const t=je(e);if(!t||t.kind==="eof")throw new Error("Unexpected end of SSR expression");if(!(t.kind==="number"||t.kind==="string"||t.kind==="ident")){if(t.kind==="punct"&&t.value==="("){X(e,0),K(e,")");return}throw new Error(`Unexpected token "${t.value}" in SSR expression`)}},Eh=e=>{if(K(e,"("),!Yt(e,")")){for(;;)if(X(e,0),!Yt(e,",")){K(e,")");break}}},Ah=e=>{for(Sh(e);;){const t=Y(e);if(t.kind!=="punct")break;if(t.value==="."){if(e.pos++,je(e).kind!=="ident")throw new Error('Expected identifier after "."');continue}if(t.value==="?."){e.pos++,Hr(e);continue}if(t.value==="["){e.pos++,X(e,0),K(e,"]");continue}if(t.value==="("){Eh(e);continue}break}},Wr=e=>{const t=Y(e);if(t.kind==="punct"&&(t.value==="!"||t.value==="-"||t.value==="+")){e.pos++,Wr(e);return}if(t.kind==="ident"&&t.value==="typeof"){e.pos++,Wr(e);return}Ah(e)},X=(e,t=0)=>{for(Wr(e);;){const r=Y(e);if(r.kind!=="punct")break;if(r.value==="?"&&t<=0){e.pos++,X(e,0),K(e,":"),X(e,0);continue}const n=Bo[r.value];if(n===void 0||n<t)break;e.pos++,X(e,n+1)}},kh=(e,t)=>{if(t==="true")return!0;if(t==="false")return!1;if(t==="null")return null;if(t!=="undefined"&&!N(t))return ph(e.context[t])},Gt=(e,t)=>{if(e!=null&&!(typeof t=="string"&&N(t)))return e[t]},Bo={"||":1,"??":1,"&&":2,"==":3,"!=":3,"===":3,"!==":3,"<":4,"<=":4,">":4,">=":4,"+":5,"-":5,"*":6,"/":6,"%":6},Z=(e,t=0)=>{let r=ht(e);for(;;){const n=Y(e);if(n.kind!=="punct")break;if(n.value==="?"&&t<=0){if(e.pos++,r){const i=Z(e,0);K(e,":"),X(e,0),r=i}else X(e,0),K(e,":"),r=Z(e,0);continue}const s=Bo[n.value];if(s===void 0||s<t)break;if(e.pos++,n.value==="&&"){r?r=Z(e,s+1):X(e,s+1);continue}if(n.value==="||"){r?X(e,s+1):r=Z(e,s+1);continue}if(n.value==="??"){r!=null?X(e,s+1):r=Z(e,s+1);continue}const o=Z(e,s+1);r=Th(n.value,r,o)}return r},Th=(e,t,r)=>{switch(e){case"||":return t||r;case"&&":return t&&r;case"??":return t??r;case"==":return t==r;case"!=":return t!=r;case"===":return t===r;case"!==":return t!==r;case"<":return t<r;case"<=":return t<=r;case">":return t>r;case">=":return t>=r;case"+":return typeof t=="string"||typeof r=="string"?String(t??"")+String(r??""):t+r;case"-":return t-r;case"*":return t*r;case"/":return t/r;case"%":return t%r;default:throw new Error(`Unsupported binary operator "${e}"`)}},ht=e=>{const t=Y(e);if(t.kind==="punct"){if(t.value==="!")return e.pos++,!ht(e);if(t.value==="-")return e.pos++,-ht(e);if(t.value==="+")return e.pos++,+ht(e)}return t.kind==="ident"&&t.value==="typeof"?(e.pos++,typeof ht(e)):Rh(e)},Rh=e=>{let t=Ch(e),r;for(;;){const n=Y(e);if(n.kind!=="punct")break;if(n.value==="."){e.pos++;const s=je(e);if(s.kind!=="ident")throw new Error('Expected identifier after "."');r=t,t=Gt(t,s.value);continue}if(n.value==="?."){if(e.pos++,t==null){Hr(e),wh(e),t=void 0,r=void 0;continue}const s=Y(e);if(s.kind==="punct"&&s.value==="["){e.pos++;const o=t,i=Z(e,0);K(e,"]"),r=o,t=Gt(t,i)}else if(s.kind==="punct"&&s.value==="(")t=Qo(e,t,r),r=void 0;else if(s.kind==="ident")e.pos++,r=t,t=Gt(t,s.value);else throw new Error("Invalid optional chain in SSR expression");continue}if(n.value==="["){e.pos++;const s=t,o=Z(e,0);K(e,"]"),r=s,t=Gt(t,o);continue}if(n.value==="("){t=Qo(e,t,r),r=void 0;continue}break}return t},Qo=(e,t,r)=>{K(e,"(");const n=[];if(!Yt(e,")")){for(;;)if(n.push(Z(e,0)),!Yt(e,",")){K(e,")");break}}if(typeof t=="function")return t.apply(r,n)},Ch=e=>{const t=je(e);if(t.kind==="number")return Number(t.value);if(t.kind==="string")return t.value;if(t.kind==="ident")return kh(e,t.value);if(t.kind==="punct"&&t.value==="("){const r=Z(e,0);return K(e,")"),r}throw new Error(`Unexpected token "${t.value}" in SSR expression`)},pe=(e,t)=>{const r=e.trim();if(r!=="")try{const n={tokens:bh(r),pos:0,context:t},s=Z(n,0);return Y(n).kind!=="eof"?void 0:s}catch{return}},$h=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),Oh=new Set(["script","style","textarea","title"]),Lh={amp:"&",lt:"<",gt:">",quot:'"',apos:"'",nbsp:" "},Fr=e=>e.indexOf("&")===-1?e:e.replace(/&(#x?[0-9a-fA-F]+|[a-zA-Z]+);/g,(t,r)=>{if(r[0]==="#"){const n=r[1]==="x"||r[1]==="X",s=parseInt(r.slice(n?2:1),n?16:10);if(Number.isFinite(s))try{return String.fromCodePoint(s)}catch{return t}return t}return Lh[r.toLowerCase()]??t}),mt=e=>e===" "||e===" "||e===`
278
- `||e==="\r"||e==="\f",Xt=e=>{for(;e.pos<e.src.length&&mt(e.src[e.pos]);)e.pos++},Ph=(e,t)=>{const r=e.pos,n=e.src.indexOf(t,r);return n===-1?(e.pos=e.src.length,e.src.slice(r)):(e.pos=n,e.src.slice(r,n))},Vo=e=>{const t=e.pos;for(;e.pos<e.src.length;){const r=e.src[e.pos];if(mt(r)||r===">"||r==="/")break;e.pos++}return e.src.slice(t,e.pos).toLowerCase()},Nh=e=>{const t=e.pos;for(;e.pos<e.src.length;){const r=e.src[e.pos];if(mt(r)||r==="="||r===">"||r==="/")break;e.pos++}return e.src.slice(t,e.pos)},Ih=e=>{const t=e.src[e.pos];if(t==='"'||t==="'"){const n=t;e.pos++;const s=e.pos;for(;e.pos<e.src.length&&e.src[e.pos]!==n;)e.pos++;const o=e.src.slice(s,e.pos);return e.pos<e.src.length&&e.pos++,Fr(o)}const r=e.pos;for(;e.pos<e.src.length;){const n=e.src[e.pos];if(mt(n)||n===">"||n==="/"&&e.src[e.pos+1]===">")break;e.pos++}return Fr(e.src.slice(r,e.pos))},Mh=e=>{const t=Object.create(null),r=[];let n=!1;for(;e.pos<e.src.length;){Xt(e);const s=e.src[e.pos];if(s===">"){e.pos++;break}if(s==="/"){if(e.pos++,Xt(e),e.src[e.pos]===">"){n=!0,e.pos++;break}continue}if(e.pos>=e.src.length)break;const o=Nh(e);if(!o){for(;e.pos<e.src.length;){const c=e.src[e.pos];if(mt(c)||c===">"||c==="/")break;e.pos++}continue}const i=o.toLowerCase();Xt(e);let a="";e.src[e.pos]==="="&&(e.pos++,Xt(e),a=Ih(e)),i in t||r.push(i),t[i]=a}return{attributes:t,order:r,selfClose:n}},Zt=e=>{const t={src:e,pos:0},r={type:"fragment",children:[]},n=[r],s=()=>n[n.length-1];for(;t.pos<t.src.length;){if(t.src[t.pos]==="<"){if(t.src.startsWith("<!--",t.pos)){t.pos+=4;const i=t.src.indexOf("-->",t.pos),a=i===-1?t.src.slice(t.pos):t.src.slice(t.pos,i);t.pos=i===-1?t.src.length:i+3,s().children.push({type:"comment",value:a});continue}if(t.src.startsWith("<!",t.pos)||t.src.startsWith("<?",t.pos)){const i=t.src.indexOf(">",t.pos);t.pos=i===-1?t.src.length:i+1;continue}if(t.src[t.pos+1]==="/"){t.pos+=2;const i=Vo(t),a=t.src.indexOf(">",t.pos);t.pos=a===-1?t.src.length:a+1;for(let c=n.length-1;c>0;c--){const l=n[c];if(l.type==="element"&&l.tag===i){n.length=c;break}}continue}if(t.pos+1<t.src.length&&/[a-zA-Z]/.test(t.src[t.pos+1])){t.pos++;const i=Vo(t),{attributes:a,order:c,selfClose:l}=Mh(t),u=$h.has(i),h={type:"element",tag:i,attributes:a,attributeOrder:c,children:[],void:u,raw:Oh.has(i)};if(s().children.push(h),u||l)continue;if(h.raw){const d=`</${i}`,p=t.pos,f=t.src.toLowerCase().indexOf(d,p),m=f===-1?t.src.slice(p):t.src.slice(p,f);if(m&&h.children.push({type:"text",value:m}),f===-1)t.pos=t.src.length;else{t.pos=f;const v=t.src.indexOf(">",t.pos);t.pos=v===-1?t.src.length:v+1}continue}n.push(h);continue}s().children.push({type:"text",value:"<"}),t.pos++;continue}const o=Ph(t,"<");o&&s().children.push({type:"text",value:Fr(o)})}return r},Dh=e=>e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),_h=e=>e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;"),pt=e=>{if(e.type==="text")return Dh(e.value);if(e.type==="comment")return`<!--${e.value}-->`;if(e.type==="fragment"){let s="";for(const o of e.children)s+=pt(o);return s}const t=e;let r="";for(const s of t.attributeOrder){const o=t.attributes[s];r+=` ${s}="${_h(o)}"`}if(t.void)return`<${t.tag}${r}>`;let n="";if(t.raw)for(const s of t.children)s.type==="text"&&(n+=s.value);else for(const s of t.children)n+=pt(s);return`<${t.tag}${r}>${n}</${t.tag}>`},Br=e=>e.type==="element"?{type:"element",tag:e.tag,attributes:{...e.attributes},attributeOrder:[...e.attributeOrder],children:e.children.map(Br),void:e.void,raw:e.raw}:e.type==="fragment"?{type:"fragment",children:e.children.map(Br)}:e.type==="text"?{type:"text",value:e.value}:{type:"comment",value:e.value},xh=e=>{const t=e.toLowerCase();return t==="href"||t==="src"||t==="xlink:href"||t==="formaction"||t==="action"||t==="poster"||t==="background"||t==="cite"||t==="data"},qh=e=>e.trim().replace(/[\u0000-\u001F\u007F]+/g,"").replace(/[\u200B-\u200D\uFEFF\u2028\u2029]+/g,"").replace(/\\u[\da-fA-F]{4}/g,"").replace(/\s+/g,"").toLowerCase(),Ko=e=>{const t=qh(e);return lr.some(r=>t.startsWith(r))},zh=/^[a-zA-Z][a-zA-Z0-9+.-]*:/,jh=/\s+/,Uh=e=>{const t=e.toLowerCase();for(const r of dn)if(t.startsWith(r))return!1;return t.startsWith("data-")||t.startsWith("aria-")?!0:fn.has(t)},Hh=e=>!un.has(e.toLowerCase().trim()),Wh=e=>{try{const t=e.trim();if(t.startsWith("//"))return!0;const r=t.toLowerCase();return!r.startsWith("http://")&&!r.startsWith("https://")?!!zh.test(t):typeof window>"u"||!window.location?!0:new URL(t,window.location.href).origin!==window.location.origin}catch{return!0}},er=(e,t)=>{if(!t)return;const r=e.attributes.class,n=r?`${r} ${t}`:t;"class"in e.attributes||e.attributeOrder.push("class"),e.attributes.class=n},Yo=(e,t)=>{let r=e.attributes.style??"";for(const[n,s]of Object.entries(t)){if(s==null||s===!1)continue;const o=n.replace(/([A-Z])/g,"-$1").toLowerCase();r&&!r.endsWith(";")&&(r+="; "),r+=`${o}: ${String(s)};`}"style"in e.attributes||e.attributeOrder.push("style"),e.attributes.style=r},ee=(e,t)=>{if(t in e.attributes){delete e.attributes[t];const r=e.attributeOrder.indexOf(t);r!==-1&&e.attributeOrder.splice(r,1)}},tr=(e,t,r)=>{t in e.attributes||e.attributeOrder.push(t),e.attributes[t]=r},Fh=(e,t)=>mh(e.attributeOrder,e.attributes,t),Bh=e=>{const t=e.match(/^\(?(\w+)(?:\s*,\s*(\w+))?\)?\s+in\s+(\S.*)$/);return t?{itemName:t[1],indexName:t[2]||void 0,listExpr:t[3].trim()}:null},Qr=(e,t)=>{if(e.type!=="element"){if(e.type==="fragment")for(const r of e.children)Qr(r,t);return}for(const r of[...e.attributeOrder])(r.startsWith(`${t}-`)||r.startsWith(":"))&&ee(e,r);for(const r of e.children)Qr(r,t)},Qh=(e,t)=>{e.children=[{type:"text",value:t}]},Vh=(e,t)=>{e.children=Zt(t).children},Jo=e=>{const t=r=>{if(r.type==="fragment")return r.children=r.children.flatMap(n=>{const s=t(n);return s?[s]:[]}),r;if(r.type!=="element")return r;if(cr.has(r.tag)||!ln.has(r.tag))return null;for(const n of[...r.attributeOrder]){const s=r.attributes[n],o=n.toLowerCase();if(!Uh(o)){ee(r,n);continue}if((o==="id"||o==="name")&&!Hh(s)){ee(r,n);continue}if((o==="href"||o==="src")&&Ko(s)){ee(r,n);continue}}if(r.tag==="a"){const n=r.attributes.href,s=r.attributes.target?.toLowerCase()==="_blank",o=n?Wh(n):!1;if(s||o){const i=new Set((r.attributes.rel??"").trim().split(jh).filter(Boolean));i.add("noopener"),i.add("noreferrer"),tr(r,"rel",Array.from(i).join(" "))}}return r.children=r.children.flatMap(n=>{const s=t(n);return s?[s]:[]}),r};return pt(t(Zt(e))??{type:"fragment",children:[]})},Go=(e,t,r)=>{const n=[];for(const s of e.children){if(s.type!=="element"){n.push(s);continue}const o=Xo(s,t,r);if(o!==null)if(Array.isArray(o))for(const i of o)n.push(i);else n.push(o)}e.children=n},Xo=(e,t,r)=>{const{prefix:n}=r,s=e.attributes[`${n}-for`];if(s!==void 0){const d=Bh(s);if(d||ee(e,`${n}-for`),d){const p=pe(d.listExpr,t);if(!Array.isArray(p))return null;const f=[];for(let m=0;m<p.length;m++){const v=Br(e);ee(v,`${n}-for`),ee(v,`${n}-key`),ee(v,":key");const b={...t,[d.itemName]:p[m]};d.indexName&&(b[d.indexName]=m);const g=Xo(v,b,r);g!==null&&(Array.isArray(g)?f.push(...g):f.push(g))}return f}}const o=r.annotateHydration?Fh(e,n):"",i=e.attributes[`${n}-if`];if(i!==void 0&&!pe(i,t))return null;const a=e.attributes[`${n}-show`];a!==void 0&&(pe(a,t)||Yo(e,{display:"none"}));const c=e.attributes[`${n}-text`];if(c!==void 0){const d=pe(c,t);Qh(e,String(d??""))}const l=e.attributes[`${n}-html`];if(l!==void 0){const d=pe(l,t);Vh(e,Jo(String(d??"")))}const u=e.attributes[`${n}-class`];if(u!==void 0){const d=u.trim();if(d.startsWith("{")){const p=d.slice(1,-1).split(",");for(const f of p){const m=f.indexOf(":");if(m<0)continue;const v=f.slice(0,m).trim().replace(/^['"]|['"]$/g,"");pe(f.slice(m+1),t)&&er(e,v)}}else{const p=pe(u,t);if(typeof p=="string")for(const f of p.split(/\s+/).filter(Boolean))er(e,f);else if(Array.isArray(p))for(const f of p)typeof f=="string"&&f&&er(e,f);else if(p&&typeof p=="object")for(const[f,m]of Object.entries(p))m&&er(e,f)}}const h=e.attributes[`${n}-style`];if(h!==void 0){const d=pe(h,t);d&&typeof d=="object"&&Yo(e,d)}for(const d of[...e.attributeOrder]){if(!d.startsWith(`${n}-bind:`))continue;const p=d.slice(`${n}-bind:`.length),f=pe(e.attributes[d],t);f===!1||f==null?ee(e,p):f===!0?tr(e,p,""):tr(e,p,String(f))}for(const d of[...e.attributeOrder]){const p=d.toLowerCase();if(p.startsWith("on")){ee(e,d);continue}xh(p)&&Ko(e.attributes[d]??"")&&ee(e,d)}return e.tag==="script"?null:(Go(e,t,r),o&&tr(e,Kt,jr(o)),e)},Kh=(e,t,r={})=>{const n={prefix:r.prefix??"bq",stripDirectives:r.stripDirectives??!1,annotateHydration:r.annotateHydration??!1},s=Zt(e);return Go(s,t,n),n.stripDirectives&&Qr(s,n.prefix),pt(s)},Ue=e=>e.replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/\//g,"\\u002f").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029"),vt=e=>e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),rr=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),Vr=e=>{const t={};for(const[r,n]of Object.entries(e))N(r)||(t[r]=n);return t},yt=(e={})=>{const{scriptId:t="__BQUERY_STORE_STATE__",globalKey:r="__BQUERY_INITIAL_STATE__",storeIds:n,serialize:s=JSON.stringify}=e;if(N(r))throw new Error(`serializeStoreState: invalid globalKey "${r}" - prototype-pollution keys are not allowed.`);if(N(t))throw new Error(`serializeStoreState: invalid scriptId "${t}" - prototype-pollution keys are not allowed.`);const o=n??Wt(),i=Object.create(null);for(const u of o){if(N(u))continue;const h=we(u);h&&(i[u]=Vr(h.$state))}const a=s(i);if(typeof a!="string")throw new Error("serializeStoreState: custom serialize function must return a string.");if(s!==JSON.stringify){let u;try{u=JSON.parse(a)}catch{throw new Error("serializeStoreState: custom serialize function returned invalid JSON.")}if(!rr(u))throw new Error("serializeStoreState: custom serialize function must return a JSON object string.")}const c=Ue(a),l=Ue(JSON.stringify(r));return{stateJson:a,scriptTag:`<script id="${vt(t)}">window[${l}]=${c}<\/script>`}},Yh=(e="__BQUERY_INITIAL_STATE__",t="__BQUERY_STORE_STATE__")=>{if(N(e))throw new Error(`deserializeStoreState: invalid globalKey "${e}" - prototype-pollution keys are not allowed.`);if(N(t))throw new Error(`deserializeStoreState: invalid scriptId "${t}" - prototype-pollution keys are not allowed.`);if(typeof window>"u")return{};const r=window[e];if(!r)return{};try{delete window[e]}catch{window[e]=void 0}if(typeof document<"u"&&typeof document.getElementById=="function"){const s=document.getElementById(t);s&&s.remove()}if(!rr(r))return{};for(const s of Object.values(r))if(!rr(s))return{};const n=Object.create(null);for(const[s,o]of Object.entries(r))N(s)||!rr(o)||(n[s]=Vr(o));return n},Zo=(e,t)=>{const r=we(e);r&&typeof r.$patch=="function"&&r.$patch(Vr(t))},Jh=e=>{for(const[t,r]of Object.entries(e))Zo(t,r)},Gh=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),Xh=3,Zh=1,ei=e=>e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),em=e=>ei(e).replace(/"/g,"&quot;"),tm=e=>{const t=e.toLowerCase();return t==="href"||t==="src"||t==="xlink:href"||t==="formaction"||t==="action"||t==="poster"||t==="background"||t==="cite"||t==="data"},rm=e=>e.trim().replace(/[\u0000-\u001F\u007F]+/g,"").replace(/[\u200B-\u200D\uFEFF\u2028\u2029]+/g,"").replace(/\\u[\da-fA-F]{4}/g,"").replace(/\s+/g,"").toLowerCase(),nm=e=>{const t=rm(e);return lr.some(r=>t.startsWith(r))},ti=e=>{if(e.nodeType===Xh)return ei(e.textContent??"");if(e.nodeType!==Zh)return"";const t=e,r=t.tagName.toLowerCase();if(r==="script")return"";let n="";for(const o of t.attributes){const i=o.name.toLowerCase();i.startsWith("on")||tm(i)&&nm(o.value)||(n+=` ${o.name}="${em(o.value)}"`)}if(Gh.has(r))return`<${r}${n}>`;let s="";for(const o of t.childNodes)s+=ti(o);return`<${r}${n}>${s}</${r}>`},ri=e=>G(e)||ce(e)?e.value:e,se=(e,t)=>{const r=e.trim();if(r.startsWith("!"))return!se(r.slice(1).trim(),t);if(r.startsWith("'")&&r.endsWith("'")||r.startsWith('"')&&r.endsWith('"'))return r.slice(1,-1);if(/^-?\d+(\.\d+)?$/.test(r))return Number(r);if(r==="true")return!0;if(r==="false")return!1;if(r==="null")return null;if(r!=="undefined"){if(/^[\w$]+(?:\.[\w$]+)*$/.test(r)){const n=r.split(".");let s=t;for(const o of n){if(s==null)return;s===t?s=ri(s[o]):s=s[o]}return s}try{const n=Object.keys(t),s=n.map(o=>ri(t[o]));return new Function(...n,`return (${r});`)(...s)}catch{return}}},sm=e=>{const t=e.match(/^\(?(\w+)(?:\s*,\s*(\w+))?\)?\s+in\s+(\S.*)$/);return t?{itemName:t[1],indexName:t[2]||void 0,listExpr:t[3].trim()}:null},Kr=(e,t,r,n=!1)=>{const s=e.getAttribute(`${r}-for`),o=s!==null?sm(s):null;s!==null&&!o&&e.removeAttribute(`${r}-for`);const i=n?Wo(e,r):"";if(s!==null&&o){const f=se(o.listExpr,t);if(e.parentNode){const m=e.parentNode;if(!Array.isArray(f))return m.removeChild(e),!0;for(let v=0;v<f.length;v++){const b=f[v],g=e.cloneNode(!0);g.removeAttribute(`${r}-for`),g.removeAttribute(":key"),g.removeAttribute(`${r}-key`);const w={...t,[o.itemName]:b};o.indexName&&(w[o.indexName]=v),Kr(g,w,r,n)&&(Yr(g,w,r,n),m.insertBefore(g,e))}return m.removeChild(e),!0}}const a=e.getAttribute(`${r}-if`);if(a!==null&&!se(a,t))return!1;const c=e.getAttribute(`${r}-show`);if(c!==null&&!se(c,t)){const f=e;f.style?f.style.display="none":e.setAttribute("style","display: none;")}const l=e.getAttribute(`${r}-text`);if(l!==null){const f=se(l,t);e.textContent=String(f??"")}const u=e.getAttribute(`${r}-html`);if(u!==null){const f=se(u,t);e.innerHTML=Jo(String(f??""))}const h=e.getAttribute(`${r}-class`);if(h!==null){const f=h.trim();if(f.startsWith("{")){const m=f.slice(1,-1).trim().split(",");for(const v of m){const b=v.indexOf(":");if(b>-1){const g=v.slice(0,b).trim().replace(/^['"]|['"]$/g,"");se(v.slice(b+1).trim(),t)&&e.classList.add(g)}}}else{const m=se(h,t);typeof m=="string"?m.split(/\s+/).filter(Boolean).forEach(v=>e.classList.add(v)):Array.isArray(m)&&m.filter(Boolean).forEach(v=>e.classList.add(v))}}const d=e.getAttribute(`${r}-style`);if(d!==null){const f=se(d,t);if(f&&typeof f=="object"){const m=e;for(const[v,b]of Object.entries(f)){const g=v.replace(/([A-Z])/g,"-$1").toLowerCase();m.style.setProperty(g,String(b))}}}const p=Array.from(e.attributes);for(const f of p)if(f.name.startsWith(`${r}-bind:`)){const m=f.name.slice(`${r}-bind:`.length),v=se(f.value,t);v===!1||v===null||v===void 0?e.removeAttribute(m):v===!0?e.setAttribute(m,""):e.setAttribute(m,String(v))}return i&&e.setAttribute(Kt,jr(i)),!0},Yr=(e,t,r,n=!1)=>{const s=Array.from(e.children);for(const o of s){let i=!1;if(o.hasAttribute(`${r}-for`)){const a=Kr(o,t,r,n);if(i=!0,!a){o.remove();continue}if(o.parentNode!==e)continue}if(!i&&!Kr(o,t,r,n)){o.remove();continue}Yr(o,t,r,n)}},ni=(e,t)=>{const r=Array.from(e.attributes);for(const n of r)(n.name.startsWith(`${t}-`)||n.name.startsWith(":")||n.name===":key")&&e.removeAttribute(n.name);for(const n of Array.from(e.children))ni(n,t)},gt=(e,t,r={})=>{const{prefix:n="bq",stripDirectives:s=!1,includeStoreState:o=!1,annotateHydration:i=!1}=r;if(!e||typeof e!="string")throw new Error("bQuery SSR: template must be a non-empty string.");const a=e.trim();if(dh()==="pure"){const p=Kh(a,t,{prefix:n,stripDirectives:s,annotateHydration:i});let f;return o&&(f=yt({storeIds:Array.isArray(o)?o:void 0}).stateJson),{html:p,storeState:f}}const c=hh();if(!c)throw new Error("bQuery SSR: DOMParser is not available in this environment. Provide a DOMParser-compatible implementation before calling renderToString().");const l=new c().parseFromString(a,"text/html"),u=l.body||l.documentElement;if(!u)throw new Error("bQuery SSR: Failed to parse template.");if(Yr(u,t,n,i),s)for(const p of Array.from(u.children))ni(p,n);let h="";for(const p of u.childNodes)h+=ti(p);let d;return o&&(d=yt({storeIds:Array.isArray(o)?o:void 0}).stateJson),{html:h,storeState:d}},si=()=>typeof globalThis<"u"?globalThis:{},nr=()=>{const e=si();if(typeof e.Bun?.version=="string")return"bun";if(typeof e.Deno?.version?.deno=="string")return"deno";const t=e.navigator;return typeof t?.userAgent=="string"&&t.userAgent.toLowerCase().includes("cloudflare-workers")?"workerd":typeof e.process?.versions?.node=="string"?"node":typeof e.window<"u"&&typeof e.document<"u"?"browser":"unknown"},om=()=>{const e=nr();return e==="bun"||e==="deno"||e==="node"||e==="workerd"},im=()=>nr()==="browser",am=()=>{const e=si(),t=e.crypto;return{fetchApi:typeof e.Request=="function"&&typeof e.Response=="function"&&typeof e.fetch=="function",webStreams:typeof e.ReadableStream=="function",textEncoder:typeof e.TextEncoder=="function",subtleCrypto:typeof t?.subtle=="object"&&t?.subtle!==null,randomUuid:typeof t?.randomUUID=="function",domParser:typeof e.DOMParser=="function"}},bt=Symbol.for("bquery.ssr.defer"),cm=e=>(Object.defineProperty(e,bt,{value:!0,enumerable:!1,configurable:!0}),e),lm=(e,t)=>{const r=e instanceof Promise?e:Promise.resolve(e);return{[bt]:!0,promise:r,fallback:t}},um=e=>typeof e=="object"&&e!==null&&e[bt]===!0,fm=async(e,t)=>{const r=Object.create(null),n=Object.entries(e);await Promise.all(n.map(async([s,o])=>{if(!N(s)){if(G(o)||ce(o)){r[s]=o;return}if(um(o)){try{r[s]=await o.promise}catch(i){t.reportError(i),r[s]=o.fallback}return}if(o&&typeof o.then=="function"){try{r[s]=await o}catch(i){t.reportError(i),r[s]=void 0}return}if(typeof o=="function"&&o[bt]){try{r[s]=await Promise.resolve(o(t))}catch(i){t.reportError(i),r[s]=void 0}return}r[s]=o}}));for(const[s,o]of Object.entries(e))!N(s)&&!Object.prototype.hasOwnProperty.call(r,s)&&(G(o)||ce(o))&&(r[s]=o);return r},U=e=>e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),dm=e=>e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),hm=e=>e.replace(/<\/(script)/gi,"<\\/$1").replace(/<!--/g,"<\\!--").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029"),oi=()=>{const e={title:null,titleTemplate:null,meta:[],link:[],script:[]};return{add:s=>{typeof s.title=="string"&&(e.title=s.title),typeof s.titleTemplate=="string"&&(e.titleTemplate=s.titleTemplate),Array.isArray(s.meta)&&e.meta.push(...s.meta),Array.isArray(s.link)&&e.link.push(...s.link),Array.isArray(s.script)&&e.script.push(...s.script)},state:()=>({...e,meta:[...e.meta],link:[...e.link],script:[...e.script]}),render:(s={})=>{let o="";if(e.title!==null){const i=e.titleTemplate?e.titleTemplate.replace(/%s/g,e.title):e.title;o+=`<title>${dm(i)}</title>`}for(const i of e.meta){let a="";for(const[c,l]of Object.entries(i))l!=null&&(N(c)||(a+=` ${c==="httpEquiv"?"http-equiv":c}="${U(String(l))}"`));o+=`<meta${a}>`}for(const i of e.link){let a=` rel="${U(i.rel)}" href="${U(i.href)}"`;i.as&&(a+=` as="${U(i.as)}"`),i.type&&(a+=` type="${U(i.type)}"`),i.crossorigin&&(a+=` crossorigin="${U(i.crossorigin)}"`),i.media&&(a+=` media="${U(i.media)}"`),i.integrity&&(a+=` integrity="${U(i.integrity)}"`),(i.nonce??s.nonce)&&(a+=` nonce="${U(i.nonce??s.nonce)}"`),o+=`<link${a}>`}for(const i of e.script){let a="";i.src&&(a+=` src="${U(i.src)}"`),i.type?a+=` type="${U(i.type)}"`:i.module&&(a+=' type="module"'),i.defer&&(a+=" defer"),i.async&&(a+=" async"),i.crossorigin&&(a+=` crossorigin="${U(i.crossorigin)}"`),i.integrity&&(a+=` integrity="${U(i.integrity)}"`);const c=i.nonce??s.nonce;c&&(a+=` nonce="${U(c)}"`),o+=`<script${a}>${i.body?hm(i.body):""}<\/script>`}return o},reset:()=>{e.title=null,e.titleTemplate=null,e.meta=[],e.link=[],e.script=[]}}},ii=()=>{const e=[];return{preload(t,r={}){e.push({href:t,rel:"preload",...r})},module(t,r={}){e.push({href:t,rel:"modulepreload",...r})},style(t,r={}){e.push({href:t,rel:"stylesheet",...r})},list:()=>[...e],render(t={}){let r="";for(const n of e){let s=` rel="${U(n.rel)}" href="${U(n.href)}"`;n.as&&(s+=` as="${U(n.as)}"`),n.type&&(s+=` type="${U(n.type)}"`),n.crossorigin&&(s+=` crossorigin="${U(n.crossorigin)}"`),n.integrity&&(s+=` integrity="${U(n.integrity)}"`),t.nonce&&(s+=` nonce="${U(t.nonce)}"`),r+=`<link${s}>`}return r},reset(){e.length=0}}},mm=e=>{const t=Object.create(null);if(!e)return t;for(const r of e.split(/;\s*/)){const n=r.indexOf("=");if(n===-1)continue;const s=r.slice(0,n).trim(),o=r.slice(n+1).trim();if(!(!s||N(s)))try{t[s]=decodeURIComponent(o)}catch{t[s]=o}}return t},pm=e=>{if(!e)return"en";const t=e.split(",").map(r=>{const[n,...s]=r.trim().split(";"),o=s.find(a=>a.trim().startsWith("q=")),i=o?Number.parseFloat(o.split("=")[1]):1;return{tag:n.trim(),q:Number.isFinite(i)?i:0}}).filter(r=>r.tag);return t.length?(t.sort((r,n)=>n.q-r.q),t[0].tag):"en"},vm=()=>{try{return bn()}catch{return""}},ai=()=>{const e=new Map,t={append(r,n){const s=String(r).toLowerCase(),o=e.get(s);o?o.push(String(n)):e.set(s,[String(n)])},delete(r){e.delete(String(r).toLowerCase())},get(r){const n=e.get(String(r).toLowerCase());return n?n.join(", "):null},has(r){return e.has(String(r).toLowerCase())},set(r,n){e.set(String(r).toLowerCase(),[String(n)])},forEach(r,n){for(const[s,o]of e)r.call(n,o.join(", "),s,t)},*entries(){for(const[r,n]of e)yield[r,n.join(", ")]},[Symbol.iterator](){return t.entries()}};return t},ci=()=>({aborted:!1,onabort:null,reason:void 0,addEventListener(){},removeEventListener(){},dispatchEvent(){return!1},throwIfAborted(){}}),ym=e=>typeof e=="object"&&e!==null&&typeof e.get=="function",gm=e=>typeof e=="object"&&e!==null&&typeof e.aborted=="boolean",li=()=>typeof Headers=="function"?new Headers:ai(),wt=(e={})=>{const t=e.url instanceof URL?e.url.toString():typeof e.url=="string"?new URL(e.url,"http://localhost/").toString():"http://localhost/",r=e.request??(typeof Request=="function"?new Request(t):{url:t,headers:ai(),signal:ci()}),n=e.url??r.url,s=n instanceof URL?n:new URL(String(n),"http://localhost/"),o=ym(r.headers)?r.headers:li();return{request:r,url:s,headers:o,cookies:mm(o.get("cookie")??""),userAgent:e.userAgent??o.get("user-agent")??"",locale:e.locale??pm(o.get("accept-language")),signal:e.signal??(gm(r.signal)?r.signal:ci()),nonce:e.nonce??vm(),mode:e.mode??"string",head:oi(),assets:ii(),status:200,responseHeaders:li(),reportError(i){e.onError?.(i)}}},bm=e=>e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),wm=e=>e===" "||e===`
279
- `||e===" "||e==="\r"||e==="\f",Sm=(e,t)=>{if(e.slice(0,7).toLowerCase()!=="<script")return e;const r=e[7];return r!==">"&&!wm(r)?e:`<script nonce="${bm(t)}"${e.slice(7)}`},Em=(e,t)=>{if(!t)return e;const r=e.toLowerCase().indexOf("</head>");return r===-1?e:e.slice(0,r)+t+e.slice(r)},Am=(e,t)=>{if(!t)return e;const r=e.toLowerCase().lastIndexOf("</body>");return r===-1?e:e.slice(0,r)+t+e.slice(r)},Jr=async(e,t,r={})=>{const n=r.context??wt({mode:"string"});if(n.signal.aborted)throw new DOMException("SSR render aborted","AbortError");const s=await fm(t,n);if(n.signal.aborted)throw new DOMException("SSR render aborted","AbortError");let{html:o,storeState:i}=gt(e,s,{prefix:r.prefix,stripDirectives:r.stripDirectives,includeStoreState:!1,annotateHydration:r.annotateHydration});const a=n.head.render({nonce:n.nonce}),c=n.assets.render({nonce:n.nonce});let l="";if(r.includeStoreState){const u=yt({storeIds:Array.isArray(r.includeStoreState)?r.includeStoreState:void 0,scriptId:r.storeScriptId,globalKey:r.storeGlobalKey});i=u.stateJson,l=u.scriptTag,n.nonce&&(l=Sm(l,n.nonce))}return r.injectHead!==!1&&(o=Em(o,a+c),o=Am(o,l)),{html:o,storeState:i,context:n,headHtml:a,assetsHtml:c,storeScriptTag:l}},ui=()=>{if(typeof TextEncoder>"u")throw new Error("bQuery SSR: TextEncoder is not available in this runtime.");return new TextEncoder},km=(e,t,r={})=>{if(typeof ReadableStream>"u")throw new Error("bQuery SSR: ReadableStream is not available in this runtime.");const n=ui(),s=r.context??wt({...r,mode:"stream"}),o={...r,context:s};return new ReadableStream({async start(i){const a=()=>{try{i.error(new DOMException("SSR stream aborted","AbortError"))}catch{}};if(s.signal.aborted){a();return}s.signal.addEventListener("abort",a,{once:!0});try{const c=await Jr(e,t,o);i.enqueue(n.encode(c.html)),i.close()}catch(c){s.signal.removeEventListener("abort",a);try{i.error(c)}catch{}}finally{s.signal.removeEventListener("abort",a)}}})},Tm=async e=>{const t=globalThis.crypto?.subtle;if(!t)return null;try{const r=await t.digest("SHA-1",ui().encode(e)),n=new Uint8Array(r);let s="";for(const o of n)s+=o.toString(16).padStart(2,"0");return`W/"${s.slice(0,27)}"`}catch{return null}},Rm=async(e,t,r={})=>{const n=r.context??wt({...r,mode:"string"}),s=await Jr(e,t,{...r,context:n}),o=r.status??n.status??200,i=new Headers(r.headers);for(const[a,c]of n.responseHeaders)i.append(a,c);if(i.has("content-type")||i.set("content-type",r.contentType??"text/html; charset=utf-8"),r.cacheControl&&i.set("cache-control",r.cacheControl),r.etag){const a=await Tm(s.html);if(a){i.set("etag",a);const c=n.headers.get("if-none-match");if(c&&c===a)return new Response(null,{status:304,headers:i})}}return new Response(s.html,{status:o,headers:i})},Gr=e=>{if(typeof e!="string")return e;if(typeof document>"u")return null;try{return document.querySelector(e)}catch{return null}},St=(e,t,r)=>{const n=Gr(e);return n?Ho(n,t,r):null},te=()=>{},Cm=e=>{if(typeof window>"u")return e(),te;const t=window.requestIdleCallback;if(typeof t=="function"){const n=t(e);return()=>{const s=window.cancelIdleCallback;typeof s=="function"&&s(n)}}const r=setTimeout(e,1);return()=>clearTimeout(r)},sr=e=>{let t=!1,r=te,n=te;const s=new Promise((a,c)=>{r=a,n=c});let o=te;return{handle:{ready:s,cancel(){t||(t=!0,o(),r(null))}},arm:a=>{o=e(()=>{if(!t)try{const c=a();r(c)}catch(c){n(c)}})}}},$m=(e,t,r={})=>{const{rootMargin:n,threshold:s,...o}=r,{handle:i,arm:a}=sr(c=>{const l=Gr(e);if(!l||typeof IntersectionObserver>"u")return c(),te;const u=new IntersectionObserver(h=>{for(const d of h)if(d.isIntersecting){u.disconnect(),c();return}},{rootMargin:n??"0px",threshold:s??0});return u.observe(l),()=>u.disconnect()});return a(()=>St(e,t,o)),i},Om=(e,t,r={})=>{const{handle:n,arm:s}=sr(o=>Cm(o));return s(()=>St(e,t,r)),n},Lm=(e,t,r={})=>{const n=r.events??["pointerdown","click","keydown","touchstart","focusin"],{events:s,...o}=r,{handle:i,arm:a}=sr(c=>{const l=Gr(e);if(!l)return c(),te;const u=()=>{h(),c()},h=()=>{for(const d of n)l.removeEventListener(d,u,!0)};for(const d of n)l.addEventListener(d,u,{once:!0,capture:!0});return h});return a(()=>St(e,t,o)),i},Pm=(e,t,r,n={})=>{const{handle:s,arm:o}=sr(i=>{if(typeof window>"u"||typeof window.matchMedia!="function")return i(),te;const a=window.matchMedia(r);if(a.matches)return i(),te;let c=te;const l=h=>{h.matches&&(c(),i())};if(typeof a.addEventListener=="function")return a.addEventListener("change",l),c=()=>a.removeEventListener("change",l),c;const u=a;return typeof u.addListener=="function"&&typeof u.removeListener=="function"?(u.addListener(l),c=()=>u.removeListener(l),c):(i(),te)});return o(()=>St(e,t,n)),s},Nm=(e,t,r={})=>St(e,t,r),Im=(e,t={})=>{const r=t.prefix??"bq",n=t.warn??qt(),s=t.onMismatch,o=[];if(!e||typeof e.querySelectorAll!="function")return o;const i=[];typeof e.getAttribute=="function"&&e.getAttribute("data-bq-h")!==null&&i.push(e);for(const a of Array.from(e.querySelectorAll(`[${Kt}]`)))i.push(a);for(const a of i){const c=a.getAttribute("data-bq-h")??"",l=Wo(a,r),u=jr(l);if(u!==c){const h={element:a,expected:c,actual:u,signature:l};o.push(h),s?.(h),n&&console.warn(`[bQuery SSR] Hydration mismatch on <${a.tagName.toLowerCase()}>: server="${c}" client="${u}" signature="${l}".`,a)}}return o},Mm=e=>typeof e=="object"&&e!==null&&e[bt]===!0,Dm=e=>G(e)||ce(e),_m=/^[A-Za-z][\w-]*$/,xm=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)+$/,fi=(e,t)=>typeof e!="string"||!_m.test(e)?t:e,qm=(e,t)=>typeof e!="string"||!xm.test(e)?t:e,zm=e=>{const t=e.replace(/-s$/,"-r");return t===e&&e.endsWith("-r")?`${e}-template`:t===e?`${e}-r`:t},jm=(e,t)=>{const r={},n=[];let s=0;for(const[o,i]of Object.entries(e)){if(Dm(i)){r[o]=i;continue}if(Mm(i)){const a=`${t}-${s++}`;n.push({id:a,key:o,promise:i.promise}),r[o]=i.fallback;continue}if(i&&typeof i.then=="function"){const a=`${t}-${s++}`;n.push({id:a,key:o,promise:i}),r[o]=void 0;continue}r[o]=i}return{syncContext:r,slots:n}},Xr=e=>e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),or=e=>Xr(e).replace(/"/g,"&quot;"),Um=e=>e.replace(/<\/(script)/gi,"<\\/$1").replace(/<!--/g,"<\\!--").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029"),Hm=Um('(()=>{var c=document.currentScript;if(!c)return;var slotId=c.getAttribute("data-bq-slot");var templateId=c.getAttribute("data-bq-template");if(!slotId||!templateId)return;var s=document.getElementById(slotId);var t=document.getElementById(templateId);if(!s||!t)return;var f=t.content?t.content.cloneNode(true):t;while(s.firstChild)s.removeChild(s.firstChild);s.appendChild(f);t.parentNode&&t.parentNode.removeChild(t);s.parentNode&&s.replaceWith(...s.childNodes);})();'),Wm=(e,t,r)=>`<script${r?` nonce="${or(r)}"`:""} data-bq-slot="${or(e)}" data-bq-template="${or(t)}">${Hm}<\/script>`,Fm=(e,t,r,n,s,o)=>{const i=t[`__suspense_${n}`];return typeof i=="string"?gt(i,{...r,[n]:s},{prefix:o.prefix,stripDirectives:o.stripDirectives,annotateHydration:o.annotateHydration}).html:s==null?"":Xr(typeof s=="string"?s:String(s))},Bm=(e,t)=>{if(!(t in e.attributes))return;delete e.attributes[t];const r=e.attributeOrder.indexOf(t);r!==-1&&e.attributeOrder.splice(r,1)},di=(e,t,r=[])=>({type:"element",tag:e,attributes:{id:t},attributeOrder:["id"],children:r,void:!1,raw:!1}),hi=(e,t)=>{for(const r of e)r.type==="element"&&(t(r),hi(r.children,t))},mi=(e,t)=>{for(const r of e){if(r.type!=="element")continue;if(r.tag===t)return r;const n=mi(r.children,t);if(n)return n}return null},Qm=(e,t,r,n)=>{const s=qm(n.slotTag,"bq-slot"),o=Zt(e),i=new Map(r.map(l=>[l.key,l])),a=new Set;hi(o.children,l=>{const u=l.attributes["data-bq-defer"];if(!u)return;Bm(l,"data-bq-defer");const h=i.get(u);if(!h||a.has(h.id))return;const d=l.children;l.children=[di(s,h.id,d)],a.add(h.id)});const c=mi(o.children,"body")?.children??o.children;for(const l of r)a.has(l.id)||c.push(di(s,l.id));return pt(o)},Vm=e=>e!==void 0&&/\s/.test(e),Km=e=>e===void 0||e==="="||e===">"||e==="/"||/\s/.test(e),Ym=e=>{let t="",r=0,n=!1,s="",o=!1,i=!1,a=!0;const c="bq-defer";for(;r<e.length;){const l=e[r];if(!n){l==="<"&&(n=!0,o=!1,i=!1,a=!0),t+=l,r++;continue}if(s){t+=l,l===s&&(s=""),r++;continue}if(l==='"'||l==="'"){s=l,t+=l,r++;continue}if(l===">"){n=!1,t+=l,r++;continue}if(!o){if(t+=l,r++,!i){if(/\s/.test(l))continue;i=!0,(l==="/"||l==="!"||l==="?")&&(a=!1);continue}a&&/\s/.test(l)&&(o=!0);continue}if(a&&e.startsWith(c,r)&&Vm(e[r-1])&&Km(e[r+8])){t+="data-bq-defer",r+=8;continue}t+=l,r++}return t},Jm=()=>{if(typeof TextEncoder>"u")throw new Error("bQuery SSR: TextEncoder is not available in this runtime.");return new TextEncoder},Gm=(e,t,r={})=>{if(typeof ReadableStream>"u")throw new Error("bQuery SSR: ReadableStream is not available in this runtime.");const n=Jm(),s=r.context??wt({...r,mode:"stream"}),o=fi(r.slotIdPrefix??"bq-s","bq-s"),i=fi(zm(o),"bq-r");return new ReadableStream({async start(a){const c=()=>{try{a.error(new DOMException("SSR stream aborted","AbortError"))}catch{}};if(s.signal.aborted){c();return}s.signal.addEventListener("abort",c,{once:!0});try{const{syncContext:l,slots:u}=jm(t,o),h=gt(Ym(e),l,{prefix:r.prefix,stripDirectives:r.stripDirectives,annotateHydration:r.annotateHydration}).html,d=Qm(h,l,u,r);a.enqueue(n.encode(d));const p=[],f=[];let m=u.length;const v=g=>{const w=f.shift();if(w){w(g);return}p.push(g)};for(const[g,w]of u.entries())w.promise.then(S=>({index:g,slot:w,ok:!0,value:S}),S=>({index:g,slot:w,ok:!1,error:S})).then(v);const b=async()=>{const g=p.shift();return g||new Promise(w=>{f.push(w)})};for(;m>0;){if(s.signal.aborted)return;const g=await b();m--;const{slot:w}=g,S=`${i}-${w.id.split("-").pop()}`;let k;g.ok?k=Fm(e,t,l,w.key,g.value,r):(s.reportError(g.error),k="");const A=`<template id="${or(S)}">${k}</template>`,E=Wm(w.id,S,s.nonce);a.enqueue(n.encode(A+E))}a.close()}catch(l){try{a.error(l)}catch{}}finally{s.signal.removeEventListener("abort",c)}}})},Xm=e=>{if(!e||!e.meta)return;const t=e.meta.loader;return typeof t=="function"?t:void 0},pi=e=>{const t=typeof e.url=="string"?new URL(e.url,"http://localhost/"):e.url,r=e.base??"";let n=t.pathname;r&&(n===r?n="/":n.startsWith(`${r}/`)&&(n=n.slice(r.length)||"/"));const s=no(n,e.routes),o={path:n,params:s?.params??{},query:Qs(t.search),matched:s?.matched??null,hash:t.hash.replace(/^#/,"")},i=s!==null,a=s?.matched??null,c=!!a&&"redirectTo"in a&&typeof a.redirectTo=="string";return{route:o,matched:i,isRedirect:c,redirectTo:c?a.redirectTo:void 0}},vi=async(e,t)=>{const r=Xm(e.matched);if(r)try{return await r({route:e,ctx:t})}catch(n){t.reportError(n);return}},Zm=async e=>{const t=pi({url:e.url,routes:e.routes,base:e.base}),r=t.matched?await vi(t.route,e.ctx):void 0;return{route:t.route,matched:t.matched,isRedirect:t.isRedirect,redirectTo:t.redirectTo,data:r,bindings:{route:t.route,params:t.route.params,query:t.route.query,data:r}}},Zr=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),yi=e=>{const t={};for(const[r,n]of Object.entries(e))N(r)||(t[r]=n);return t},ep=e=>{const{version:t,storeIds:r,scriptId:n="__BQUERY_STORE_SNAPSHOT__",globalKey:s="__BQUERY_STORE_SNAPSHOT__",nonce:o}=e;if(typeof t!="string"||t.length===0)throw new Error("serializeStoreSnapshot: `version` is required and must be a non-empty string.");if(N(n)||N(s))throw new Error("serializeStoreSnapshot: invalid scriptId/globalKey.");const i=r??Wt(),a=Object.create(null);for(const d of i){if(N(d))continue;const p=we(d);p&&(a[d]=yi(p.$state))}const c={version:t,state:a},l=JSON.stringify(c),u=Ue(l),h=Ue(JSON.stringify(s));return{snapshot:c,json:l,scriptTag:`<script id="${vt(n)}"${o?` nonce="${vt(o)}"`:""}>window[${h}]=${u}<\/script>`}},gi=e=>{if(!Zr(e))return!1;const t=e.version,r=e.state;return typeof t=="string"&&Zr(r)},tp=(e,t={})=>{if(!gi(e))return t.strict&&console.warn("[bQuery SSR] hydrateStoreSnapshot: snapshot has invalid shape."),{applied:!1,reason:"invalid-shape",appliedIds:[],unknownIds:[]};if(typeof t.expectedVersion=="string"&&t.expectedVersion!==e.version)return t.strict&&console.warn(`[bQuery SSR] hydrateStoreSnapshot: version mismatch — server="${e.version}" client="${t.expectedVersion}". Skipping.`),{applied:!1,reason:"version-mismatch",appliedIds:[],unknownIds:[]};const r=[],n=[];for(const[s,o]of Object.entries(e.state)){if(N(s)||!Zr(o))continue;const i=we(s);if(!i||typeof i.$patch!="function"){n.push(s),t.strict&&console.warn(`[bQuery SSR] hydrateStoreSnapshot: store "${s}" is not registered; skipping.`);continue}i.$patch(yi(o)),r.push(s)}return{applied:r.length>0,appliedIds:r,unknownIds:n}},rp=(e="__BQUERY_STORE_SNAPSHOT__",t="__BQUERY_STORE_SNAPSHOT__")=>{if(N(e)||N(t)||typeof window>"u")return null;const r=window[e];try{delete window[e]}catch{window[e]=void 0}if(typeof document<"u"&&typeof document.getElementById=="function"){const n=document.getElementById(t);n&&n.remove()}return gi(r)?r:null},bi=e=>{const t=Object.create(null);for(const[r,n]of Object.entries(e))N(r)||(t[r]=n);return t},np=(e={})=>{const t=Object.create(null);if(e.initial)for(const[r,n]of Object.entries(e.initial))N(r)||(t[r]=n);return{set(r,n){N(r)||(t[r]=n)},get(r){return t[r]},entries(){return bi(t)},render(r={}){const n=r.scriptId??"__BQUERY_RESUME__",s=r.globalKey??"__BQUERY_RESUME__";if(N(n)||N(s))return"";const o=Ue(JSON.stringify(t)),i=Ue(JSON.stringify(s));return`<script id="${vt(n)}"${r.nonce?` nonce="${vt(r.nonce)}"`:""}>window[${i}]=${o}<\/script>`}}},sp=(e="__BQUERY_RESUME__",t="__BQUERY_RESUME__")=>{const r={get:()=>{},hasSnapshot:!1,entries:()=>({})};if(N(e)||N(t)||typeof window>"u")return r;const n=window[e];try{delete window[e]}catch{window[e]=void 0}if(typeof document<"u"&&typeof document.getElementById=="function"){const o=document.getElementById(t);o&&o.remove()}if(!n||typeof n!="object")return r;const s=n;return{hasSnapshot:!0,get(o){if(!N(o))return s[o]},entries(){return bi(s)}}},wi=e=>e,Si=e=>async t=>Promise.resolve(e(t)),Ei=e=>async t=>Promise.resolve(e(t)),op=e=>e!=="GET"&&e!=="HEAD",en=class extends Error{constructor(e){super(e),this.name="NodeRequestLimitError"}},ir=(e,t)=>{const r=e[t];return Array.isArray(r)?r[0]:r},ip=e=>{const t=ir(e.headers,"content-length");if(!t)return null;const r=Number.parseInt(t,10);return Number.isSafeInteger(r)&&r>=0?r:null},ap=(e,t)=>new Promise((r,n)=>{const s=[];let o=0,i=!1;const a=l=>{i||(i=!0,s.length=0,o=0,e.destroy?.(l instanceof Error?l:void 0),n(l))},c=ip(e);if(t!==void 0&&c!==null&&c>t){a(new en(`Request body exceeds ${t} bytes.`));return}e.on("data",l=>{if(i)return;const u=typeof l=="string"?new TextEncoder().encode(l):l;if(o+=u.byteLength,t!==void 0&&o>t){a(new en(`Request body exceeds ${t} bytes.`));return}s.push(u)}),e.on("end",()=>{if(i)return;i=!0;const l=new ArrayBuffer(o),u=new Uint8Array(l);let h=0;for(const d of s)u.set(d,h),h+=d.byteLength;r(l)}),e.on("error",a)}),cp=(e,t)=>{const r=`${t}://localhost`,n=ir(e.headers,"host")||"localhost";try{return new URL(e.url??"/",`${t}://${n}`)}catch{try{return new URL(e.url??"/",r)}catch{return new URL("/",r)}}},lp=async(e,t={})=>{const r=typeof ir(e.headers,"x-forwarded-proto")=="string"?ir(e.headers,"x-forwarded-proto").split(",")[0].trim().toLowerCase():"",n=cp(e,r==="http"||r==="https"?r:"http"),s=new Headers;for(const[a,c]of Object.entries(e.headers))if(c!==void 0)if(Array.isArray(c))for(const l of c)s.append(a,l);else s.append(a,c);const o=(e.method??"GET").toUpperCase(),i={method:o,headers:s};return op(o)&&(i.body=await ap(e,t.maxBodyBytes)),new Request(n.toString(),i)},up=e=>{const t=e.getSetCookie?.();if(Array.isArray(t)&&t.length>0)return t;const r=e.get("set-cookie");return r?[r]:[]},fp=e=>new Promise((t,r)=>{const n=typeof e.once=="function"?e.once.bind(e):void 0,s=typeof e.on=="function"?e.on.bind(e):void 0,o=n??s;if(!o){t();return}o("drain",()=>t()),o("error",i=>{r(i instanceof Error?i:new Error("Node response stream errored while draining."))})}),Ai=async(e,t)=>{t.statusCode=e.status;const r=up(e.headers);if(r.length>0&&t.setHeader("set-cookie",r.length===1?r[0]:r),e.headers.forEach((s,o)=>{o.toLowerCase()!=="set-cookie"&&t.setHeader(o,s)}),!e.body){t.end();return}const n=e.body.getReader();for(;;){const{value:s,done:o}=await n.read();if(o)break;s&&!t.write(s)&&await fp(t)}t.end()},ki=(e,t={})=>async(r,n)=>{let s;try{s=await lp(r,t)}catch(o){if(o instanceof en){await Ai(new Response(o.message,{status:413}),n);return}throw o}await Ai(await Promise.resolve(e(s)),n)},dp=e=>{switch(nr()){case"node":return ki(e);case"bun":return Si(e);case"deno":return Ei(e);default:return wi(e)}},hp="http://localhost",mp={"<":"\\u003C",">":"\\u003E","&":"\\u0026","\u2028":"\\u2028","\u2029":"\\u2029"},pp=/[<>&\u2028\u2029]/g,vp=null,Ti="x-bquery-websocket-passthrough",yp=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),ar=()=>Object.create(null),tn=e=>{if(!e)throw new Error(`route path must be a non-empty string; received ${String(e)}`);if(e==="*"||e==="/*")return"/*";const t=e.startsWith("/")?e:`/${e}`;return t.length>1&&t.endsWith("/")?t.slice(0,-1):t},Ri=e=>{const t=tn(e);if(t==="/*")return{path:t,paramNames:[],pattern:/^\/.*$/};const r=t.split("/").filter(Boolean);if(r.length===0)return{path:t,paramNames:[],pattern:/^\/$/};const n=[];let s="^";for(const[o,i]of r.entries()){if(s+="/",i==="*"){if(o!==r.length-1)throw new Error(`invalid route path: "*" must be the final segment in "${t}"`);s+=".*";break}if(i.startsWith(":")){const a=i.slice(1);if(!/^[A-Za-z_$][\w$]*$/.test(a))throw new Error(`invalid route param name: ${a} - must start with a letter, $, or _ and contain only word characters`);if(N(a))throw new Error(`invalid route param name: ${a} - reserved for object safety`);n.push(a),s+="([^/]+)";continue}s+=yp(i)}return s+="/?$",{path:t,paramNames:n,pattern:new RegExp(s)}},gp=e=>{if(typeof e>"u")return vp;const t=Array.isArray(e)?e:[e];if(t.length===0)throw new Error("route method must be specified - received empty array");const r=new Set(t.map(n=>n.trim().toUpperCase()).filter(Boolean));if(r.size===0)throw new Error(`route method must include at least one non-empty method string; received ${JSON.stringify(e)}`);return r},Ci=e=>{const t=ar();for(const[r,n]of e.searchParams.entries()){if(N(r))continue;const s=t[r];typeof s>"u"?t[r]=n:Array.isArray(s)?s.push(n):t[r]=[s,n]}return t},$i=(e,t)=>e instanceof URL?new URL(e.toString()):new URL(e,t),Oi=(e,t)=>{if(e instanceof Request)return e;if(typeof e=="string"||e instanceof URL)return new Request($i(e,t).toString());const{url:r,method:n="GET",headers:s,body:o=null}=e;return new Request($i(r,t).toString(),{method:n,headers:s,body:o})},bp=e=>typeof e>"u"?[]:[...new Set((Array.isArray(e)?e:[e]).map(t=>t.trim()).filter(Boolean))],wp=e=>{const t=e.data;if(typeof t=="string")try{return JSON.parse(t)}catch{return t}return t},Sp=e=>e.replace(pp,t=>mp[t]),He=e=>new Headers(e),rn=(e,t)=>(e.has("content-type")||e.set("content-type",t),e),Ce=(e,t={})=>{const{headers:r,...n}=t;return new Response(e,{...n,headers:He(r)})},Li=(e,t={})=>{const r=rn(He(t.headers),"text/plain; charset=utf-8");return Ce(e,{...t,headers:r})},nn=(e,t={})=>{const{trusted:r=!1,...n}=t,s=rn(He(n.headers),"text/html; charset=utf-8");return Ce(r?e:ie(e),{...n,headers:s})},Pi=(e,t={})=>{const r=rn(He(t.headers),"application/json; charset=utf-8");let n;try{n=JSON.stringify(e)??"null"}catch{n="null"}return Ce(Sp(n),{...t,headers:r})},Ni=(e,t=302)=>Ce(null,{headers:He({location:e.toString()}),status:t}),Ii=(e,t,r={})=>{const{includeStoreState:n=!1,status:s=200,headers:o,...i}=r,a=gt(e,t,{...i,includeStoreState:!1}),c=n?yt({storeIds:Array.isArray(n)?n:void 0}).scriptTag:"";return nn(`${a.html}${c}`,{headers:o,status:s,trusted:!0})},sn=e=>{if(e.method.toUpperCase()!=="GET")return!1;const t=e.headers.get("upgrade");if(typeof t!="string"||t.trim().toLowerCase()!=="websocket")return!1;const r=e.headers.get("connection");if(typeof r!="string"||!r.split(",").some(s=>s.trim().toLowerCase()==="upgrade")||e.headers.get("sec-websocket-version")?.trim()!=="13")return!1;const n=e.headers.get("sec-websocket-key")?.trim();return typeof n=="string"&&/^[A-Za-z0-9+/]{22}==$/.test(n)},Ep=e=>{if(typeof e!="object"||e===null||e instanceof Response)return!1;const t=e;return typeof t.open=="function"&&typeof t.message=="function"&&typeof t.close=="function"&&typeof t.error=="function"},Ap=()=>{const e=new WeakMap;return t=>{const r=e.get(t);if(r)return r;const n={get protocol(){return t.protocol},get readyState(){return t.readyState},get url(){return t.url},send(s){t.send(s)},sendJson(s){const o=JSON.stringify(s);if(typeof o!="string")throw new TypeError("socket.sendJson() does not support undefined values");t.send(o)},close(s,o){t.close(s,o)}};return e.set(t,n),n}},kp=(e,t)=>{const r=Ap(),n=t.deserialize??wp;return{context:e,protocols:bp(t.protocols),headers:t.headers,async open(s){t.onOpen&&await t.onOpen(r(s),e)},async message(s,o){t.onMessage&&await t.onMessage(n(o),r(s),e,o)},async close(s,o){t.onClose&&await t.onClose(o,r(s),e)},async error(s,o){t.onError&&await t.onError(o,r(s),e)}}},Tp=()=>Ce(null,{headers:He({[Ti]:"1"}),status:204}),Rp=e=>e.headers.get(Ti)==="1",Cp=(e,t,r)=>{if(e.methods&&!e.methods.has(t))return null;const n=e.pattern.exec(r);if(!n)return null;const s=ar();for(const[o,i]of e.paramNames.entries())try{s[i]=decodeURIComponent(n[o+1]??"")}catch(a){if(a instanceof URIError)return null;throw a}return s},Mi=(e,t,r,n)=>{for(const s of e){const o=Cp(s,t,r);if(o)return n.params=o,s}return null},$p=async(e,t,r)=>{const n=async s=>{const o=t[s];if(!o)return r();let i=!1;return await o(e,async()=>{if(i)throw new Error("middleware next() called multiple times - if a middleware calls next(), it may only do so once");return i=!0,await n(s+1)})};return await n(0)},Op=async(e,t,r)=>{const n=async s=>{const o=t[s];if(!o)return r();let i=!1;return await o(e,async()=>{if(i)throw new Error("middleware next() called multiple times - if a middleware calls next(), it may only do so once");return i=!0,await n(s+1)})};return await n(0)},Lp=e=>async(t,r)=>{let n=null,s=null;const o=await e(t,async()=>(n=await r(),n instanceof Response?(s=n,n):Tp()));return s?o:o instanceof Response&&Rp(o)?n:o},Di=e=>{const t=Ri(e.path);return{handler:e.handler,methods:gp(e.method),middlewares:e.middlewares??[],paramNames:t.paramNames,path:t.path,pattern:t.pattern}},Pp=(e={})=>{const t=e.baseUrl??hp,r=[...e.middlewares??[]],n=[],s=[],o=e.notFound??(u=>u.text("Not Found",{status:404})),i=e.onError??((u,h)=>u instanceof Response?u:h.text("Internal Server Error",{status:500})),a=(u,h,d,p)=>(n.push(Di({handler:d,method:u,middlewares:p,path:h})),l),c=(u,h,d)=>{const p=Ri(u);return s.push({handler:h,methods:new Set(["GET"]),middlewares:d??[],paramNames:p.paramNames,path:p.path,pattern:p.pattern}),l},l={use(u){return r.push(u),l},add(u){return n.push(Di(u)),l},get(u,h,d){return a("GET",u,h,d)},post(u,h,d){return a("POST",u,h,d)},put(u,h,d){return a("PUT",u,h,d)},patch(u,h,d){return a("PATCH",u,h,d)},delete(u,h,d){return a("DELETE",u,h,d)},all(u,h,d){return a(void 0,u,h,d)},ws(u,h,d){return c(u,h,d)},async handle(u){const h=Oi(u,t),d=new URL(h.url),p=h.method.toUpperCase(),f=tn(d.pathname||"/"),m=Ci(d),v={request:h,url:d,method:p,path:f,params:ar(),query:m,state:{},response:Ce,text:Li,html:nn,json:Pi,redirect:Ni,render:Ii,isWebSocketRequest:sn(h)};try{const b=Mi(n,p,f,v);return b?await $p(v,[...r,...b.middlewares,async g=>await b.handler(g)],async()=>await o(v)):await o(v)}catch(b){return await i(b,v)}},async handleWebSocket(u){const h=Oi(u,t),d=new URL(h.url),p=h.method.toUpperCase(),f=tn(d.pathname||"/"),m=Ci(d),v={request:h,url:d,method:p,path:f,params:ar(),query:m,state:{},response:Ce,text:Li,html:nn,json:Pi,redirect:Ni,render:Ii,isWebSocketRequest:sn(h)};if(!v.isWebSocketRequest)return null;try{const b=Mi(s,p,f,v);return b?await Op(v,[...r.map(Lp),...b.middlewares],async()=>kp(v,typeof b.handler=="function"?await b.handler(v):b.handler)):null}catch(b){return await i(b,v)}}};return l};y.$=sa,y.$$=oa,y.BQueryCollection=Ct,y.BQueryElement=Ne,y.BqLinkElement=Bs,y.Computed=Je,y.HYDRATION_HASH_ATTR=Kt,y.HttpError=ye,y.Signal=Ge,y.TaskWorkerAbortError=ge,y.TaskWorkerError=H,y.TaskWorkerSerializationError=Ae,y.TaskWorkerTimeoutError=Pt,y.TaskWorkerUnsupportedError=Sr,y.animate=jt,y.announceToScreenReader=Uf,y.auditA11y=Yf,y.back=su,y.batch=Se,y.batchTasks=Gc,y.bool=pl,y.breakpoints=bd,y.buckets=jl,y.cache=Hl,y.callWorkerMethod=Fc,y.capturePosition=Cr,y.clearAnnouncements=Hf,y.clearTimeline=Kd,y.clipboard=Od,y.component=Me,y.computed=D,y.configureSSR=uh,y.createAssetManager=ii,y.createBunHandler=Si,y.createDenoHandler=Ei,y.createForm=bf,y.createHeadManager=oi,y.createHttp=yr,y.createI18n=qf,y.createNodeHandler=ki,y.createPersistedStore=Fu,y.createReactiveRpcPool=sl,y.createReactiveRpcWorker=rl,y.createReactiveTaskPool=nl,y.createReactiveTaskWorker=tl,y.createRequestQueue=Ec,y.createRestClient=Lc,y.createResumableState=np,y.createRouter=ku,y.createRpcPool=ns,y.createRpcWorker=It,y.createSSRContext=wt,y.createSSRHandler=dp,y.createSSRRouterContext=Zm,y.createServer=Pp,y.createStore=Pr,y.createTaskPool=_t,y.createTaskWorker=Mt,y.createTemplate=pf,y.createTrustedHtml=Ji,y.createUseFetch=cc,y.createWebHandler=wi,y.currentRoute=Us,y.custom=If,y.customAsync=Mf,y.deduplicateRequest=Nc,y.defer=lm,y.defineBqueryConfig=Ua,y.defineComponent=fl,y.defineLoader=cm,y.definePageMeta=Gl,y.defineStore=_u,y.deserializeStoreState=Yh,y.destroyStore=Mu,y.detectRuntime=nr,y.draggable=cd,y.droppable=pd,y.easeInCubic=Os,y.easeInOutCubic=Ps,y.easeInOutQuad=$s,y.easeInQuad=Rs,y.easeOutBack=Ns,y.easeOutCubic=Ls,y.easeOutExpo=Is,y.easeOutQuad=Cs,y.easingPresets=El,y.effect=j,y.effectScope=Ba,y.email=Of,y.enableDevtools=Ud,y.escapeHtml=En,y.every=us,y.filter=cs,y.find=fs,y.fireEvent=ch,y.flip=$r,y.flipElements=Ms,y.flipList=Al,y.flushEffects=Uo,y.formatDate=vo,y.formatNumber=po,y.forward=ou,y.generateNonce=bn,y.generateSignalLabel=Bd,y.getBqueryConfig=ae,y.getConcurrencySupport=Yn,y.getCurrentScope=Mn,y.getCustomDirective=qd,y.getCustomDirectives=zd,y.getDevtoolsState=Yd,y.getFocusableElements=xr,y.getInstalledPlugins=xd,y.getSSRConfig=fh,y.getSSRRuntimeFeatures=am,y.getStore=we,y.getTimeline=Vd,y.getTrustedTypesPolicy=Sn,y.hasCSPDirective=Ki,y.html=De,y.http=Sc,y.hydrateIsland=Nm,y.hydrateMount=Ho,y.hydrateOnIdle=Om,y.hydrateOnInteraction=Lm,y.hydrateOnMedia=Pm,y.hydrateOnVisible=$m,y.hydrateStore=Zo,y.hydrateStoreSnapshot=tp,y.hydrateStores=Jh,y.inspectComponents=qo,y.inspectSignals=_o,y.inspectStores=xo,y.interceptLinks=fu,y.isActive=wu,y.isActiveSignal=Su,y.isBrowserRuntime=im,y.isComputed=ce,y.isConcurrencySupported=Er,y.isDevtoolsEnabled=Hd,y.isInstalled=_d,y.isNavigating=ru,y.isServerRuntime=om,y.isServerWebSocketSession=Ep,y.isSignal=G,y.isTrustedTypesSupported=Yi,y.isWebSocketRequest=sn,y.keyframePresets=kl,y.linear=Ts,y.link=uu,y.linkedSignal=Ac,y.listStores=Wt,y.logComponents=Xd,y.logSignals=Jd,y.logStores=Gd,y.logTimeline=Zd,y.map=as,y.mapActions=zu,y.mapGetters=qu,y.mapState=xu,y.matchField=Df,y.max=Nf,y.maxLength=Cf,y.mediaQuery=gd,y.min=Pf,y.minLength=Rf,y.mockRouter=ah,y.mockSignal=nh,y.morphElement=Tl,y.mount=Dr,y.navigate=nt,y.notifications=Kl,y.onScopeDispose=Dn,y.parallax=Rl,y.parallel=Jc,y.pattern=$f,y.persistedSignal=Rc,y.pipeline=el,y.prefersColorScheme=Jf,y.prefersContrast=Gf,y.prefersReducedMotion=le,y.readStoreSnapshot=rp,y.readonly=_,y.recordEvent=Qd,y.reduce=ds,y.registerBqLink=lu,y.registerDefaultComponents=wl,y.registerPlugin=Pu,y.releaseFocus=od,y.renderComponent=rh,y.renderToResponse=Rm,y.renderToStream=km,y.renderToStreamSuspense=Gm,y.renderToString=gt,y.renderToStringAsync=Jr,y.required=Tf,y.resetPlugins=jd,y.resolve=bu,y.resolveSSRRoute=pi,y.resumeState=sp,y.rovingTabIndex=Xf,y.runRouteLoaders=vi,y.runTask=Xn,y.safeHtml=vl,y.sanitize=ie,y.sanitizeHtml=ie,y.scrollAnimate=$l,y.sequence=Dl,y.serializeStoreSnapshot=ep,y.serializeStoreState=yt,y.setReducedMotion=Sl,y.signal=L,y.skipLink=rd,y.some=ls,y.sortable=yd,y.spring=Ll,y.springPresets=Pl,y.stagger=Nl,y.storage=tu,y.stripTags=Gi,y.timeline=_l,y.toValue=Ic,y.trackSignal=Wd,y.transition=xl,y.trapFocus=sd,y.trusted=Bi,y.typewriter=ql,y.untrack=Ee,y.untrackSignal=Fd,y.url=Lf,y.use=Dd,y.useAnnouncer=Jl,y.useAsyncData=xn,y.useBattery=Ad,y.useComputed=al,y.useCookie=Vl,y.useDeviceMotion=Cd,y.useDeviceOrientation=$d,y.useEffect=cl,y.useEventSource=qc,y.useFetch=re,y.useFormField=Ef,y.useGeolocation=kd,y.useInfiniteFetch=Tc,y.useIntersectionObserver=Pd,y.useMutationObserver=Id,y.useNetworkStatus=Sd,y.usePaginatedFetch=kc,y.usePolling=Cc,y.useResizeObserver=Nd,y.useResource=$c,y.useResourceList=Pc,y.useRoute=Ru,y.useSignal=il,y.useSubmit=Oc,y.useViewport=wd,y.useWebSocket=Qn,y.useWebSocketChannel=xc,y.utils=_a,y.verifyHydration=Im,y.waitFor=lh,y.watch=br,y.watchDebounce=Mc,y.watchStore=Bu,y.watchThrottle=Dc});
277
+ `:l==="t"?c+=" ":l==="r"?c+="\r":l==="\\"?c+="\\":l===i?c+=i:c+=l,n+=2;continue}c+=e[n],n++}if(n>=r)throw new Error("Unterminated string literal in SSR expression");n++,t.push({kind:"string",value:c,start:a});continue}if(Br(s)||s==="."&&n+1<r&&Br(e[n+1])){const i=n;for(;n<r&&(Br(e[n])||e[n]===".");)n++;t.push({kind:"number",value:e.slice(i,n),start:i});continue}if(ki(s)){const i=n;for(;n<r&&Sh(e[n]);)n++;t.push({kind:"ident",value:e.slice(i,n),start:i});continue}let o=!1;for(const i of bh)if(e.startsWith(i,n)){t.push({kind:"punct",value:i,start:n}),n+=i.length,o=!0;break}if(!o){if(wh.includes(s)){t.push({kind:"punct",value:s,start:n}),n++;continue}throw new Error(`Unexpected character "${s}" in SSR expression`)}}return t.push({kind:"eof",value:"",start:r}),t},Y=e=>e.tokens[e.pos],Ue=e=>e.tokens[e.pos++],K=(e,t)=>{const r=Y(e);if(r.kind!=="punct"||r.value!==t)throw new Error(`Expected "${t}" in SSR expression, got "${r.value}"`);e.pos++},Gt=(e,t)=>{const r=Y(e);return r.kind==="punct"&&r.value===t?(e.pos++,!0):!1},Xt=(e,t,r)=>{K(e,t);const n=[t];for(;n.length>0;){const s=Ue(e);if(!s||s.kind==="eof")throw new Error(`Unterminated "${t}${r}" group in SSR expression`);if(s.kind==="punct"){if(s.value==="("||s.value==="["){n.push(s.value);continue}if(s.value===")"||s.value==="]"){const o=n[n.length-1],i=o==="("?")":"]";if(s.value!==i)throw new Error(`Mismatched "${o}${i}" group in SSR expression`);n.pop()}}}},Qr=e=>{const t=Y(e);if(t.kind==="punct"&&t.value==="["){Xt(e,"[","]");return}if(t.kind==="punct"&&t.value==="("){Xt(e,"(",")");return}if(t.kind==="ident"){e.pos++;return}throw new Error("Invalid optional chain in SSR expression")},Ah=e=>{for(;;){const t=Y(e);if(t.kind!=="punct")break;if(t.value==="."){if(e.pos++,Ue(e).kind!=="ident")throw new Error('Expected identifier after "."');continue}if(t.value==="["){Xt(e,"[","]");continue}if(t.value==="("){Xt(e,"(",")");continue}if(t.value==="?."){e.pos++,Qr(e);continue}break}},kh=e=>{const t=Ue(e);if(!t||t.kind==="eof")throw new Error("Unexpected end of SSR expression");if(!(t.kind==="number"||t.kind==="string"||t.kind==="ident")){if(t.kind==="punct"&&t.value==="("){X(e,0),K(e,")");return}throw new Error(`Unexpected token "${t.value}" in SSR expression`)}},Th=e=>{if(K(e,"("),!Gt(e,")")){for(;;)if(X(e,0),!Gt(e,",")){K(e,")");break}}},Ch=e=>{for(kh(e);;){const t=Y(e);if(t.kind!=="punct")break;if(t.value==="."){if(e.pos++,Ue(e).kind!=="ident")throw new Error('Expected identifier after "."');continue}if(t.value==="?."){e.pos++,Qr(e);continue}if(t.value==="["){e.pos++,X(e,0),K(e,"]");continue}if(t.value==="("){Th(e);continue}break}},Vr=e=>{const t=Y(e);if(t.kind==="punct"&&(t.value==="!"||t.value==="-"||t.value==="+")){e.pos++,Vr(e);return}if(t.kind==="ident"&&t.value==="typeof"){e.pos++,Vr(e);return}Ch(e)},X=(e,t=0)=>{for(Vr(e);;){const r=Y(e);if(r.kind!=="punct")break;if(r.value==="?"&&t<=0){e.pos++,X(e,0),K(e,":"),X(e,0);continue}const n=Ti[r.value];if(n===void 0||n<t)break;e.pos++,X(e,n+1)}},Rh=(e,t)=>{if(t==="true")return!0;if(t==="false")return!1;if(t==="null")return null;if(t!=="undefined"&&!N(t))return gh(e.context[t])},Zt=(e,t)=>{if(e!=null&&!(typeof t=="string"&&N(t)))return e[t]},Ti={"||":1,"??":1,"&&":2,"==":3,"!=":3,"===":3,"!==":3,"<":4,"<=":4,">":4,">=":4,"+":5,"-":5,"*":6,"/":6,"%":6},Z=(e,t=0)=>{let r=mt(e);for(;;){const n=Y(e);if(n.kind!=="punct")break;if(n.value==="?"&&t<=0){if(e.pos++,r){const i=Z(e,0);K(e,":"),X(e,0),r=i}else X(e,0),K(e,":"),r=Z(e,0);continue}const s=Ti[n.value];if(s===void 0||s<t)break;if(e.pos++,n.value==="&&"){r?r=Z(e,s+1):X(e,s+1);continue}if(n.value==="||"){r?X(e,s+1):r=Z(e,s+1);continue}if(n.value==="??"){r!=null?X(e,s+1):r=Z(e,s+1);continue}const o=Z(e,s+1);r=$h(n.value,r,o)}return r},$h=(e,t,r)=>{switch(e){case"||":return t||r;case"&&":return t&&r;case"??":return t??r;case"==":return t==r;case"!=":return t!=r;case"===":return t===r;case"!==":return t!==r;case"<":return t<r;case"<=":return t<=r;case">":return t>r;case">=":return t>=r;case"+":return typeof t=="string"||typeof r=="string"?String(t??"")+String(r??""):t+r;case"-":return t-r;case"*":return t*r;case"/":return t/r;case"%":return t%r;default:throw new Error(`Unsupported binary operator "${e}"`)}},mt=e=>{const t=Y(e);if(t.kind==="punct"){if(t.value==="!")return e.pos++,!mt(e);if(t.value==="-")return e.pos++,-mt(e);if(t.value==="+")return e.pos++,+mt(e)}return t.kind==="ident"&&t.value==="typeof"?(e.pos++,typeof mt(e)):Oh(e)},Oh=e=>{let t=Lh(e),r;for(;;){const n=Y(e);if(n.kind!=="punct")break;if(n.value==="."){e.pos++;const s=Ue(e);if(s.kind!=="ident")throw new Error('Expected identifier after "."');r=t,t=Zt(t,s.value);continue}if(n.value==="?."){if(e.pos++,t==null){Qr(e),Ah(e),t=void 0,r=void 0;continue}const s=Y(e);if(s.kind==="punct"&&s.value==="["){e.pos++;const o=t,i=Z(e,0);K(e,"]"),r=o,t=Zt(t,i)}else if(s.kind==="punct"&&s.value==="(")t=Ci(e,t,r),r=void 0;else if(s.kind==="ident")e.pos++,r=t,t=Zt(t,s.value);else throw new Error("Invalid optional chain in SSR expression");continue}if(n.value==="["){e.pos++;const s=t,o=Z(e,0);K(e,"]"),r=s,t=Zt(t,o);continue}if(n.value==="("){t=Ci(e,t,r),r=void 0;continue}break}return t},Ci=(e,t,r)=>{K(e,"(");const n=[];if(!Gt(e,")")){for(;;)if(n.push(Z(e,0)),!Gt(e,",")){K(e,")");break}}if(typeof t=="function")return t.apply(r,n)},Lh=e=>{const t=Ue(e);if(t.kind==="number")return Number(t.value);if(t.kind==="string")return t.value;if(t.kind==="ident")return Rh(e,t.value);if(t.kind==="punct"&&t.value==="("){const r=Z(e,0);return K(e,")"),r}throw new Error(`Unexpected token "${t.value}" in SSR expression`)},pe=(e,t)=>{const r=e.trim();if(r!=="")try{const n={tokens:Eh(r),pos:0,context:t},s=Z(n,0);return Y(n).kind!=="eof"?void 0:s}catch{return}},Ph=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),Nh=new Set(["script","style","textarea","title"]),Ih={amp:"&",lt:"<",gt:">",quot:'"',apos:"'",nbsp:" "},Kr=e=>e.indexOf("&")===-1?e:e.replace(/&(#x?[0-9a-fA-F]+|[a-zA-Z]+);/g,(t,r)=>{if(r[0]==="#"){const n=r[1]==="x"||r[1]==="X",s=parseInt(r.slice(n?2:1),n?16:10);if(Number.isFinite(s))try{return String.fromCodePoint(s)}catch{return t}return t}return Ih[r.toLowerCase()]??t}),pt=e=>e===" "||e===" "||e===`
278
+ `||e==="\r"||e==="\f",er=e=>{for(;e.pos<e.src.length&&pt(e.src[e.pos]);)e.pos++},Mh=(e,t)=>{const r=e.pos,n=e.src.indexOf(t,r);return n===-1?(e.pos=e.src.length,e.src.slice(r)):(e.pos=n,e.src.slice(r,n))},Ri=e=>{const t=e.pos;for(;e.pos<e.src.length;){const r=e.src[e.pos];if(pt(r)||r===">"||r==="/")break;e.pos++}return e.src.slice(t,e.pos).toLowerCase()},Dh=e=>{const t=e.pos;for(;e.pos<e.src.length;){const r=e.src[e.pos];if(pt(r)||r==="="||r===">"||r==="/")break;e.pos++}return e.src.slice(t,e.pos)},_h=e=>{const t=e.src[e.pos];if(t==='"'||t==="'"){const n=t;e.pos++;const s=e.pos;for(;e.pos<e.src.length&&e.src[e.pos]!==n;)e.pos++;const o=e.src.slice(s,e.pos);return e.pos<e.src.length&&e.pos++,Kr(o)}const r=e.pos;for(;e.pos<e.src.length;){const n=e.src[e.pos];if(pt(n)||n===">"||n==="/"&&e.src[e.pos+1]===">")break;e.pos++}return Kr(e.src.slice(r,e.pos))},qh=e=>{const t=Object.create(null),r=[];let n=!1;for(;e.pos<e.src.length;){er(e);const s=e.src[e.pos];if(s===">"){e.pos++;break}if(s==="/"){if(e.pos++,er(e),e.src[e.pos]===">"){n=!0,e.pos++;break}continue}if(e.pos>=e.src.length)break;const o=Dh(e);if(!o){for(;e.pos<e.src.length;){const c=e.src[e.pos];if(pt(c)||c===">"||c==="/")break;e.pos++}continue}const i=o.toLowerCase();er(e);let a="";e.src[e.pos]==="="&&(e.pos++,er(e),a=_h(e)),i in t||r.push(i),t[i]=a}return{attributes:t,order:r,selfClose:n}},tr=e=>{const t={src:e,pos:0},r={type:"fragment",children:[]},n=[r],s=()=>n[n.length-1];for(;t.pos<t.src.length;){if(t.src[t.pos]==="<"){if(t.src.startsWith("<!--",t.pos)){t.pos+=4;const i=t.src.indexOf("-->",t.pos),a=i===-1?t.src.slice(t.pos):t.src.slice(t.pos,i);t.pos=i===-1?t.src.length:i+3,s().children.push({type:"comment",value:a});continue}if(t.src.startsWith("<!",t.pos)||t.src.startsWith("<?",t.pos)){const i=t.src.indexOf(">",t.pos);t.pos=i===-1?t.src.length:i+1;continue}if(t.src[t.pos+1]==="/"){t.pos+=2;const i=Ri(t),a=t.src.indexOf(">",t.pos);t.pos=a===-1?t.src.length:a+1;for(let c=n.length-1;c>0;c--){const l=n[c];if(l.type==="element"&&l.tag===i){n.length=c;break}}continue}if(t.pos+1<t.src.length&&/[a-zA-Z]/.test(t.src[t.pos+1])){t.pos++;const i=Ri(t),{attributes:a,order:c,selfClose:l}=qh(t),u=Ph.has(i),h={type:"element",tag:i,attributes:a,attributeOrder:c,children:[],void:u,raw:Nh.has(i)};if(s().children.push(h),u||l)continue;if(h.raw){const d=`</${i}`,v=t.pos,f=t.src.toLowerCase().indexOf(d,v),p=f===-1?t.src.slice(v):t.src.slice(v,f);if(p&&h.children.push({type:"text",value:p}),f===-1)t.pos=t.src.length;else{t.pos=f;const y=t.src.indexOf(">",t.pos);t.pos=y===-1?t.src.length:y+1}continue}n.push(h);continue}s().children.push({type:"text",value:"<"}),t.pos++;continue}const o=Mh(t,"<");o&&s().children.push({type:"text",value:Kr(o)})}return r},xh=e=>e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),zh=e=>e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;"),vt=e=>{if(e.type==="text")return xh(e.value);if(e.type==="comment")return`<!--${e.value}-->`;if(e.type==="fragment"){let s="";for(const o of e.children)s+=vt(o);return s}const t=e;let r="";for(const s of t.attributeOrder){const o=t.attributes[s];r+=` ${s}="${zh(o)}"`}if(t.void)return`<${t.tag}${r}>`;let n="";if(t.raw)for(const s of t.children)s.type==="text"&&(n+=s.value);else for(const s of t.children)n+=vt(s);return`<${t.tag}${r}>${n}</${t.tag}>`},Yr=e=>e.type==="element"?{type:"element",tag:e.tag,attributes:{...e.attributes},attributeOrder:[...e.attributeOrder],children:e.children.map(Yr),void:e.void,raw:e.raw}:e.type==="fragment"?{type:"fragment",children:e.children.map(Yr)}:e.type==="text"?{type:"text",value:e.value}:{type:"comment",value:e.value},jh=e=>{const t=e.toLowerCase();return t==="href"||t==="src"||t==="xlink:href"||t==="formaction"||t==="action"||t==="poster"||t==="background"||t==="cite"||t==="data"},Uh=e=>e.trim().replace(/[\u0000-\u001F\u007F]+/g,"").replace(/[\u200B-\u200D\uFEFF\u2028\u2029]+/g,"").replace(/\\u[\da-fA-F]{4}/g,"").replace(/\s+/g,"").toLowerCase(),$i=e=>{const t=Uh(e);return fr.some(r=>t.startsWith(r))},Hh=/^[a-zA-Z][a-zA-Z0-9+.-]*:/,Wh=/\s+/,Fh=e=>{const t=e.toLowerCase();for(const r of vn)if(t.startsWith(r))return!1;return t.startsWith("data-")||t.startsWith("aria-")?!0:pn.has(t)},Bh=e=>!mn.has(e.toLowerCase().trim()),Qh=e=>{try{const t=e.trim();if(t.startsWith("//"))return!0;const r=t.toLowerCase();return!r.startsWith("http://")&&!r.startsWith("https://")?!!Hh.test(t):typeof window>"u"||!window.location?!0:new URL(t,window.location.href).origin!==window.location.origin}catch{return!0}},rr=(e,t)=>{if(!t)return;const r=e.attributes.class,n=r?`${r} ${t}`:t;"class"in e.attributes||e.attributeOrder.push("class"),e.attributes.class=n},Oi=(e,t)=>{let r=e.attributes.style??"";for(const[n,s]of Object.entries(t)){if(s==null||s===!1)continue;const o=n.replace(/([A-Z])/g,"-$1").toLowerCase();r&&!r.endsWith(";")&&(r+="; "),r+=`${o}: ${String(s)};`}"style"in e.attributes||e.attributeOrder.push("style"),e.attributes.style=r},ee=(e,t)=>{if(t in e.attributes){delete e.attributes[t];const r=e.attributeOrder.indexOf(t);r!==-1&&e.attributeOrder.splice(r,1)}},nr=(e,t,r)=>{t in e.attributes||e.attributeOrder.push(t),e.attributes[t]=r},Vh=(e,t)=>yh(e.attributeOrder,e.attributes,t),Kh=e=>{const t=e.match(/^\(?(\w+)(?:\s*,\s*(\w+))?\)?\s+in\s+(\S.*)$/);return t?{itemName:t[1],indexName:t[2]||void 0,listExpr:t[3].trim()}:null},Jr=(e,t)=>{if(e.type!=="element"){if(e.type==="fragment")for(const r of e.children)Jr(r,t);return}for(const r of[...e.attributeOrder])(r.startsWith(`${t}-`)||r.startsWith(":"))&&ee(e,r);for(const r of e.children)Jr(r,t)},Yh=(e,t)=>{e.children=[{type:"text",value:t}]},Jh=(e,t)=>{e.children=tr(t).children},Li=e=>{const t=r=>{if(r.type==="fragment")return r.children=r.children.flatMap(n=>{const s=t(n);return s?[s]:[]}),r;if(r.type!=="element")return r;if(ur.has(r.tag)||!hn.has(r.tag))return null;for(const n of[...r.attributeOrder]){const s=r.attributes[n],o=n.toLowerCase();if(!Fh(o)){ee(r,n);continue}if((o==="id"||o==="name")&&!Bh(s)){ee(r,n);continue}if((o==="href"||o==="src")&&$i(s)){ee(r,n);continue}}if(r.tag==="a"){const n=r.attributes.href,s=r.attributes.target?.toLowerCase()==="_blank",o=n?Qh(n):!1;if(s||o){const i=new Set((r.attributes.rel??"").trim().split(Wh).filter(Boolean));i.add("noopener"),i.add("noreferrer"),nr(r,"rel",Array.from(i).join(" "))}}return r.children=r.children.flatMap(n=>{const s=t(n);return s?[s]:[]}),r};return vt(t(tr(e))??{type:"fragment",children:[]})},Pi=(e,t,r)=>{const n=[];for(const s of e.children){if(s.type!=="element"){n.push(s);continue}const o=Ni(s,t,r);if(o!==null)if(Array.isArray(o))for(const i of o)n.push(i);else n.push(o)}e.children=n},Ni=(e,t,r)=>{const{prefix:n}=r,s=e.attributes[`${n}-for`];if(s!==void 0){const d=Kh(s);if(d||ee(e,`${n}-for`),d){const v=pe(d.listExpr,t);if(!Array.isArray(v))return null;const f=[];for(let p=0;p<v.length;p++){const y=Yr(e);ee(y,`${n}-for`),ee(y,`${n}-key`),ee(y,":key");const b={...t,[d.itemName]:v[p]};d.indexName&&(b[d.indexName]=p);const g=Ni(y,b,r);g!==null&&(Array.isArray(g)?f.push(...g):f.push(g))}return f}}const o=r.annotateHydration?Vh(e,n):"",i=e.attributes[`${n}-if`];if(i!==void 0&&!pe(i,t))return null;const a=e.attributes[`${n}-show`];a!==void 0&&(pe(a,t)||Oi(e,{display:"none"}));const c=e.attributes[`${n}-text`];if(c!==void 0){const d=pe(c,t);Yh(e,String(d??""))}const l=e.attributes[`${n}-html`];if(l!==void 0){const d=pe(l,t);Jh(e,Li(String(d??"")))}const u=e.attributes[`${n}-class`];if(u!==void 0){const d=u.trim();if(d.startsWith("{")){const v=d.slice(1,-1).split(",");for(const f of v){const p=f.indexOf(":");if(p<0)continue;const y=f.slice(0,p).trim().replace(/^['"]|['"]$/g,"");pe(f.slice(p+1),t)&&rr(e,y)}}else{const v=pe(u,t);if(typeof v=="string")for(const f of v.split(/\s+/).filter(Boolean))rr(e,f);else if(Array.isArray(v))for(const f of v)typeof f=="string"&&f&&rr(e,f);else if(v&&typeof v=="object")for(const[f,p]of Object.entries(v))p&&rr(e,f)}}const h=e.attributes[`${n}-style`];if(h!==void 0){const d=pe(h,t);d&&typeof d=="object"&&Oi(e,d)}for(const d of[...e.attributeOrder]){if(!d.startsWith(`${n}-bind:`))continue;const v=d.slice(`${n}-bind:`.length),f=pe(e.attributes[d],t);f===!1||f==null?ee(e,v):f===!0?nr(e,v,""):nr(e,v,String(f))}for(const d of[...e.attributeOrder]){const v=d.toLowerCase();if(v.startsWith("on")){ee(e,d);continue}jh(v)&&$i(e.attributes[d]??"")&&ee(e,d)}return e.tag==="script"?null:(Pi(e,t,r),o&&nr(e,Jt,Fr(o)),e)},Gh=(e,t,r={})=>{const n={prefix:r.prefix??"bq",stripDirectives:r.stripDirectives??!1,annotateHydration:r.annotateHydration??!1},s=tr(e);return Pi(s,t,n),n.stripDirectives&&Jr(s,n.prefix),vt(s)},He=e=>e.replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/\//g,"\\u002f").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029"),yt=e=>e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),sr=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),Gr=e=>{const t={};for(const[r,n]of Object.entries(e))N(r)||(t[r]=n);return t},gt=(e={})=>{const{scriptId:t="__BQUERY_STORE_STATE__",globalKey:r="__BQUERY_INITIAL_STATE__",storeIds:n,serialize:s=JSON.stringify}=e;if(N(r))throw new Error(`serializeStoreState: invalid globalKey "${r}" - prototype-pollution keys are not allowed.`);if(N(t))throw new Error(`serializeStoreState: invalid scriptId "${t}" - prototype-pollution keys are not allowed.`);const o=n??Bt(),i=Object.create(null);for(const u of o){if(N(u))continue;const h=we(u);h&&(i[u]=Gr(h.$state))}const a=s(i);if(typeof a!="string")throw new Error("serializeStoreState: custom serialize function must return a string.");if(s!==JSON.stringify){let u;try{u=JSON.parse(a)}catch{throw new Error("serializeStoreState: custom serialize function returned invalid JSON.")}if(!sr(u))throw new Error("serializeStoreState: custom serialize function must return a JSON object string.")}const c=He(a),l=He(JSON.stringify(r));return{stateJson:a,scriptTag:`<script id="${yt(t)}">window[${l}]=${c}<\/script>`}},Xh=(e="__BQUERY_INITIAL_STATE__",t="__BQUERY_STORE_STATE__")=>{if(N(e))throw new Error(`deserializeStoreState: invalid globalKey "${e}" - prototype-pollution keys are not allowed.`);if(N(t))throw new Error(`deserializeStoreState: invalid scriptId "${t}" - prototype-pollution keys are not allowed.`);if(typeof window>"u")return{};const r=window[e];if(!r)return{};try{delete window[e]}catch{window[e]=void 0}if(typeof document<"u"&&typeof document.getElementById=="function"){const s=document.getElementById(t);s&&s.remove()}if(!sr(r))return{};for(const s of Object.values(r))if(!sr(s))return{};const n=Object.create(null);for(const[s,o]of Object.entries(r))N(s)||!sr(o)||(n[s]=Gr(o));return n},Ii=(e,t)=>{const r=we(e);r&&typeof r.$patch=="function"&&r.$patch(Gr(t))},Zh=e=>{for(const[t,r]of Object.entries(e))Ii(t,r)},em=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),tm=3,rm=1,Mi=e=>e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),nm=e=>Mi(e).replace(/"/g,"&quot;"),sm=e=>{const t=e.toLowerCase();return t==="href"||t==="src"||t==="xlink:href"||t==="formaction"||t==="action"||t==="poster"||t==="background"||t==="cite"||t==="data"},om=e=>e.trim().replace(/[\u0000-\u001F\u007F]+/g,"").replace(/[\u200B-\u200D\uFEFF\u2028\u2029]+/g,"").replace(/\\u[\da-fA-F]{4}/g,"").replace(/\s+/g,"").toLowerCase(),im=e=>{const t=om(e);return fr.some(r=>t.startsWith(r))},Di=e=>{if(e.nodeType===tm)return Mi(e.textContent??"");if(e.nodeType!==rm)return"";const t=e,r=t.tagName.toLowerCase();if(r==="script")return"";let n="";for(const o of t.attributes){const i=o.name.toLowerCase();i.startsWith("on")||sm(i)&&im(o.value)||(n+=` ${o.name}="${nm(o.value)}"`)}if(em.has(r))return`<${r}${n}>`;let s="";for(const o of t.childNodes)s+=Di(o);return`<${r}${n}>${s}</${r}>`},_i=e=>G(e)||ce(e)?e.value:e,se=(e,t)=>{const r=e.trim();if(r.startsWith("!"))return!se(r.slice(1).trim(),t);if(r.startsWith("'")&&r.endsWith("'")||r.startsWith('"')&&r.endsWith('"'))return r.slice(1,-1);if(/^-?\d+(\.\d+)?$/.test(r))return Number(r);if(r==="true")return!0;if(r==="false")return!1;if(r==="null")return null;if(r!=="undefined"){if(/^[\w$]+(?:\.[\w$]+)*$/.test(r)){const n=r.split(".");let s=t;for(const o of n){if(s==null)return;s===t?s=_i(s[o]):s=s[o]}return s}try{const n=Object.keys(t),s=n.map(o=>_i(t[o]));return new Function(...n,`return (${r});`)(...s)}catch{return}}},am=e=>{const t=e.match(/^\(?(\w+)(?:\s*,\s*(\w+))?\)?\s+in\s+(\S.*)$/);return t?{itemName:t[1],indexName:t[2]||void 0,listExpr:t[3].trim()}:null},Xr=(e,t,r,n=!1)=>{const s=e.getAttribute(`${r}-for`),o=s!==null?am(s):null;s!==null&&!o&&e.removeAttribute(`${r}-for`);const i=n?Ai(e,r):"";if(s!==null&&o){const f=se(o.listExpr,t);if(e.parentNode){const p=e.parentNode;if(!Array.isArray(f))return p.removeChild(e),!0;for(let y=0;y<f.length;y++){const b=f[y],g=e.cloneNode(!0);g.removeAttribute(`${r}-for`),g.removeAttribute(":key"),g.removeAttribute(`${r}-key`);const w={...t,[o.itemName]:b};o.indexName&&(w[o.indexName]=y),Xr(g,w,r,n)&&(Zr(g,w,r,n),p.insertBefore(g,e))}return p.removeChild(e),!0}}const a=e.getAttribute(`${r}-if`);if(a!==null&&!se(a,t))return!1;const c=e.getAttribute(`${r}-show`);if(c!==null&&!se(c,t)){const f=e;f.style?f.style.display="none":e.setAttribute("style","display: none;")}const l=e.getAttribute(`${r}-text`);if(l!==null){const f=se(l,t);e.textContent=String(f??"")}const u=e.getAttribute(`${r}-html`);if(u!==null){const f=se(u,t);e.innerHTML=Li(String(f??""))}const h=e.getAttribute(`${r}-class`);if(h!==null){const f=h.trim();if(f.startsWith("{")){const p=f.slice(1,-1).trim().split(",");for(const y of p){const b=y.indexOf(":");if(b>-1){const g=y.slice(0,b).trim().replace(/^['"]|['"]$/g,"");se(y.slice(b+1).trim(),t)&&e.classList.add(g)}}}else{const p=se(h,t);typeof p=="string"?p.split(/\s+/).filter(Boolean).forEach(y=>e.classList.add(y)):Array.isArray(p)&&p.filter(Boolean).forEach(y=>e.classList.add(y))}}const d=e.getAttribute(`${r}-style`);if(d!==null){const f=se(d,t);if(f&&typeof f=="object"){const p=e;for(const[y,b]of Object.entries(f)){const g=y.replace(/([A-Z])/g,"-$1").toLowerCase();p.style.setProperty(g,String(b))}}}const v=Array.from(e.attributes);for(const f of v)if(f.name.startsWith(`${r}-bind:`)){const p=f.name.slice(`${r}-bind:`.length),y=se(f.value,t);y===!1||y===null||y===void 0?e.removeAttribute(p):y===!0?e.setAttribute(p,""):e.setAttribute(p,String(y))}return i&&e.setAttribute(Jt,Fr(i)),!0},Zr=(e,t,r,n=!1)=>{const s=Array.from(e.children);for(const o of s){let i=!1;if(o.hasAttribute(`${r}-for`)){const a=Xr(o,t,r,n);if(i=!0,!a){o.remove();continue}if(o.parentNode!==e)continue}if(!i&&!Xr(o,t,r,n)){o.remove();continue}Zr(o,t,r,n)}},qi=(e,t)=>{const r=Array.from(e.attributes);for(const n of r)(n.name.startsWith(`${t}-`)||n.name.startsWith(":")||n.name===":key")&&e.removeAttribute(n.name);for(const n of Array.from(e.children))qi(n,t)},bt=(e,t,r={})=>{const{prefix:n="bq",stripDirectives:s=!1,includeStoreState:o=!1,annotateHydration:i=!1}=r;if(!e||typeof e!="string")throw new Error("bQuery SSR: template must be a non-empty string.");const a=e.trim();if(ph()==="pure"){const v=Gh(a,t,{prefix:n,stripDirectives:s,annotateHydration:i});let f;return o&&(f=gt({storeIds:Array.isArray(o)?o:void 0}).stateJson),{html:v,storeState:f}}const c=vh();if(!c)throw new Error("bQuery SSR: DOMParser is not available in this environment. Provide a DOMParser-compatible implementation before calling renderToString().");const l=new c().parseFromString(a,"text/html"),u=l.body||l.documentElement;if(!u)throw new Error("bQuery SSR: Failed to parse template.");if(Zr(u,t,n,i),s)for(const v of Array.from(u.children))qi(v,n);let h="";for(const v of u.childNodes)h+=Di(v);let d;return o&&(d=gt({storeIds:Array.isArray(o)?o:void 0}).stateJson),{html:h,storeState:d}},xi=()=>typeof globalThis<"u"?globalThis:{},or=()=>{const e=xi();if(typeof e.Bun?.version=="string")return"bun";if(typeof e.Deno?.version?.deno=="string")return"deno";const t=e.navigator;return typeof t?.userAgent=="string"&&t.userAgent.toLowerCase().includes("cloudflare-workers")?"workerd":typeof e.process?.versions?.node=="string"?"node":typeof e.window<"u"&&typeof e.document<"u"?"browser":"unknown"},cm=()=>{const e=or();return e==="bun"||e==="deno"||e==="node"||e==="workerd"},lm=()=>or()==="browser",um=()=>{const e=xi(),t=e.crypto;return{fetchApi:typeof e.Request=="function"&&typeof e.Response=="function"&&typeof e.fetch=="function",webStreams:typeof e.ReadableStream=="function",textEncoder:typeof e.TextEncoder=="function",subtleCrypto:typeof t?.subtle=="object"&&t?.subtle!==null,randomUuid:typeof t?.randomUUID=="function",domParser:typeof e.DOMParser=="function"}},wt=Symbol.for("bquery.ssr.defer"),fm=e=>(Object.defineProperty(e,wt,{value:!0,enumerable:!1,configurable:!0}),e),dm=(e,t)=>{const r=e instanceof Promise?e:Promise.resolve(e);return{[wt]:!0,promise:r,fallback:t}},hm=e=>typeof e=="object"&&e!==null&&e[wt]===!0,mm=async(e,t)=>{const r=Object.create(null),n=Object.entries(e);await Promise.all(n.map(async([s,o])=>{if(!N(s)){if(G(o)||ce(o)){r[s]=o;return}if(hm(o)){try{r[s]=await o.promise}catch(i){t.reportError(i),r[s]=o.fallback}return}if(o&&typeof o.then=="function"){try{r[s]=await o}catch(i){t.reportError(i),r[s]=void 0}return}if(typeof o=="function"&&o[wt]){try{r[s]=await Promise.resolve(o(t))}catch(i){t.reportError(i),r[s]=void 0}return}r[s]=o}}));for(const[s,o]of Object.entries(e))!N(s)&&!Object.prototype.hasOwnProperty.call(r,s)&&(G(o)||ce(o))&&(r[s]=o);return r},U=e=>e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),pm=e=>e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),vm=e=>e.replace(/<\/(script)/gi,"<\\/$1").replace(/<!--/g,"<\\!--").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029"),zi=()=>{const e={title:null,titleTemplate:null,meta:[],link:[],script:[]};return{add:s=>{typeof s.title=="string"&&(e.title=s.title),typeof s.titleTemplate=="string"&&(e.titleTemplate=s.titleTemplate),Array.isArray(s.meta)&&e.meta.push(...s.meta),Array.isArray(s.link)&&e.link.push(...s.link),Array.isArray(s.script)&&e.script.push(...s.script)},state:()=>({...e,meta:[...e.meta],link:[...e.link],script:[...e.script]}),render:(s={})=>{let o="";if(e.title!==null){const i=e.titleTemplate?e.titleTemplate.replace(/%s/g,e.title):e.title;o+=`<title>${pm(i)}</title>`}for(const i of e.meta){let a="";for(const[c,l]of Object.entries(i))l!=null&&(N(c)||(a+=` ${c==="httpEquiv"?"http-equiv":c}="${U(String(l))}"`));o+=`<meta${a}>`}for(const i of e.link){let a=` rel="${U(i.rel)}" href="${U(i.href)}"`;i.as&&(a+=` as="${U(i.as)}"`),i.type&&(a+=` type="${U(i.type)}"`),i.crossorigin&&(a+=` crossorigin="${U(i.crossorigin)}"`),i.media&&(a+=` media="${U(i.media)}"`),i.integrity&&(a+=` integrity="${U(i.integrity)}"`),(i.nonce??s.nonce)&&(a+=` nonce="${U(i.nonce??s.nonce)}"`),o+=`<link${a}>`}for(const i of e.script){let a="";i.src&&(a+=` src="${U(i.src)}"`),i.type?a+=` type="${U(i.type)}"`:i.module&&(a+=' type="module"'),i.defer&&(a+=" defer"),i.async&&(a+=" async"),i.crossorigin&&(a+=` crossorigin="${U(i.crossorigin)}"`),i.integrity&&(a+=` integrity="${U(i.integrity)}"`);const c=i.nonce??s.nonce;c&&(a+=` nonce="${U(c)}"`),o+=`<script${a}>${i.body?vm(i.body):""}<\/script>`}return o},reset:()=>{e.title=null,e.titleTemplate=null,e.meta=[],e.link=[],e.script=[]}}},ji=()=>{const e=[];return{preload(t,r={}){e.push({href:t,rel:"preload",...r})},module(t,r={}){e.push({href:t,rel:"modulepreload",...r})},style(t,r={}){e.push({href:t,rel:"stylesheet",...r})},list:()=>[...e],render(t={}){let r="";for(const n of e){let s=` rel="${U(n.rel)}" href="${U(n.href)}"`;n.as&&(s+=` as="${U(n.as)}"`),n.type&&(s+=` type="${U(n.type)}"`),n.crossorigin&&(s+=` crossorigin="${U(n.crossorigin)}"`),n.integrity&&(s+=` integrity="${U(n.integrity)}"`),t.nonce&&(s+=` nonce="${U(t.nonce)}"`),r+=`<link${s}>`}return r},reset(){e.length=0}}},ym=e=>{const t=Object.create(null);if(!e)return t;for(const r of e.split(/;\s*/)){const n=r.indexOf("=");if(n===-1)continue;const s=r.slice(0,n).trim(),o=r.slice(n+1).trim();if(!(!s||N(s)))try{t[s]=decodeURIComponent(o)}catch{t[s]=o}}return t},gm=e=>{if(!e)return"en";const t=e.split(",").map(r=>{const[n,...s]=r.trim().split(";"),o=s.find(a=>a.trim().startsWith("q=")),i=o?Number.parseFloat(o.split("=")[1]):1;return{tag:n.trim(),q:Number.isFinite(i)?i:0}}).filter(r=>r.tag);return t.length?(t.sort((r,n)=>n.q-r.q),t[0].tag):"en"},bm=()=>{try{return An()}catch{return""}},Ui=()=>{const e=new Map,t={append(r,n){const s=String(r).toLowerCase(),o=e.get(s);o?o.push(String(n)):e.set(s,[String(n)])},delete(r){e.delete(String(r).toLowerCase())},get(r){const n=e.get(String(r).toLowerCase());return n?n.join(", "):null},has(r){return e.has(String(r).toLowerCase())},set(r,n){e.set(String(r).toLowerCase(),[String(n)])},forEach(r,n){for(const[s,o]of e)r.call(n,o.join(", "),s,t)},*entries(){for(const[r,n]of e)yield[r,n.join(", ")]},[Symbol.iterator](){return t.entries()}};return t},Hi=()=>({aborted:!1,onabort:null,reason:void 0,addEventListener(){},removeEventListener(){},dispatchEvent(){return!1},throwIfAborted(){}}),wm=e=>typeof e=="object"&&e!==null&&typeof e.get=="function",Sm=e=>typeof e=="object"&&e!==null&&typeof e.aborted=="boolean",Wi=()=>typeof Headers=="function"?new Headers:Ui(),St=(e={})=>{const t=e.url instanceof URL?e.url.toString():typeof e.url=="string"?new URL(e.url,"http://localhost/").toString():"http://localhost/",r=e.request??(typeof Request=="function"?new Request(t):{url:t,headers:Ui(),signal:Hi()}),n=e.url??r.url,s=n instanceof URL?n:new URL(String(n),"http://localhost/"),o=wm(r.headers)?r.headers:Wi();return{request:r,url:s,headers:o,cookies:ym(o.get("cookie")??""),userAgent:e.userAgent??o.get("user-agent")??"",locale:e.locale??gm(o.get("accept-language")),signal:e.signal??(Sm(r.signal)?r.signal:Hi()),nonce:e.nonce??bm(),mode:e.mode??"string",head:zi(),assets:ji(),status:200,responseHeaders:Wi(),reportError(i){e.onError?.(i)}}},Em=e=>e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),Am=e=>e===" "||e===`
279
+ `||e===" "||e==="\r"||e==="\f",km=(e,t)=>{if(e.slice(0,7).toLowerCase()!=="<script")return e;const r=e[7];return r!==">"&&!Am(r)?e:`<script nonce="${Em(t)}"${e.slice(7)}`},Tm=(e,t)=>{if(!t)return e;const r=e.toLowerCase().indexOf("</head>");return r===-1?e:e.slice(0,r)+t+e.slice(r)},Cm=(e,t)=>{if(!t)return e;const r=e.toLowerCase().lastIndexOf("</body>");return r===-1?e:e.slice(0,r)+t+e.slice(r)},en=async(e,t,r={})=>{const n=r.context??St({mode:"string"});if(n.signal.aborted)throw new DOMException("SSR render aborted","AbortError");const s=await mm(t,n);if(n.signal.aborted)throw new DOMException("SSR render aborted","AbortError");let{html:o,storeState:i}=bt(e,s,{prefix:r.prefix,stripDirectives:r.stripDirectives,includeStoreState:!1,annotateHydration:r.annotateHydration});const a=n.head.render({nonce:n.nonce}),c=n.assets.render({nonce:n.nonce});let l="";if(r.includeStoreState){const u=gt({storeIds:Array.isArray(r.includeStoreState)?r.includeStoreState:void 0,scriptId:r.storeScriptId,globalKey:r.storeGlobalKey});i=u.stateJson,l=u.scriptTag,n.nonce&&(l=km(l,n.nonce))}return r.injectHead!==!1&&(o=Tm(o,a+c),o=Cm(o,l)),{html:o,storeState:i,context:n,headHtml:a,assetsHtml:c,storeScriptTag:l}},Fi=()=>{if(typeof TextEncoder>"u")throw new Error("bQuery SSR: TextEncoder is not available in this runtime.");return new TextEncoder},Rm=(e,t,r={})=>{if(typeof ReadableStream>"u")throw new Error("bQuery SSR: ReadableStream is not available in this runtime.");const n=Fi(),s=r.context??St({...r,mode:"stream"}),o={...r,context:s};return new ReadableStream({async start(i){const a=()=>{try{i.error(new DOMException("SSR stream aborted","AbortError"))}catch{}};if(s.signal.aborted){a();return}s.signal.addEventListener("abort",a,{once:!0});try{const c=await en(e,t,o);i.enqueue(n.encode(c.html)),i.close()}catch(c){s.signal.removeEventListener("abort",a);try{i.error(c)}catch{}}finally{s.signal.removeEventListener("abort",a)}}})},$m=async e=>{const t=globalThis.crypto?.subtle;if(!t)return null;try{const r=await t.digest("SHA-1",Fi().encode(e)),n=new Uint8Array(r);let s="";for(const o of n)s+=o.toString(16).padStart(2,"0");return`W/"${s.slice(0,27)}"`}catch{return null}},Om=async(e,t,r={})=>{const n=r.context??St({...r,mode:"string"}),s=await en(e,t,{...r,context:n}),o=r.status??n.status??200,i=new Headers(r.headers);for(const[a,c]of n.responseHeaders)i.append(a,c);if(i.has("content-type")||i.set("content-type",r.contentType??"text/html; charset=utf-8"),r.cacheControl&&i.set("cache-control",r.cacheControl),r.etag){const a=await $m(s.html);if(a){i.set("etag",a);const c=n.headers.get("if-none-match");if(c&&c===a)return new Response(null,{status:304,headers:i})}}return new Response(s.html,{status:o,headers:i})},tn=e=>{if(typeof e!="string")return e;if(typeof document>"u")return null;try{return document.querySelector(e)}catch{return null}},Et=(e,t,r)=>{const n=tn(e);return n?Ei(n,t,r):null},te=()=>{},Lm=e=>{if(typeof window>"u")return e(),te;const t=window.requestIdleCallback;if(typeof t=="function"){const n=t(e);return()=>{const s=window.cancelIdleCallback;typeof s=="function"&&s(n)}}const r=setTimeout(e,1);return()=>clearTimeout(r)},ir=e=>{let t=!1,r=te,n=te;const s=new Promise((a,c)=>{r=a,n=c});let o=te;return{handle:{ready:s,cancel(){t||(t=!0,o(),r(null))}},arm:a=>{o=e(()=>{if(!t)try{const c=a();r(c)}catch(c){n(c)}})}}},Pm=(e,t,r={})=>{const{rootMargin:n,threshold:s,...o}=r,{handle:i,arm:a}=ir(c=>{const l=tn(e);if(!l||typeof IntersectionObserver>"u")return c(),te;const u=new IntersectionObserver(h=>{for(const d of h)if(d.isIntersecting){u.disconnect(),c();return}},{rootMargin:n??"0px",threshold:s??0});return u.observe(l),()=>u.disconnect()});return a(()=>Et(e,t,o)),i},Nm=(e,t,r={})=>{const{handle:n,arm:s}=ir(o=>Lm(o));return s(()=>Et(e,t,r)),n},Im=(e,t,r={})=>{const n=r.events??["pointerdown","click","keydown","touchstart","focusin"],{events:s,...o}=r,{handle:i,arm:a}=ir(c=>{const l=tn(e);if(!l)return c(),te;const u=()=>{h(),c()},h=()=>{for(const d of n)l.removeEventListener(d,u,!0)};for(const d of n)l.addEventListener(d,u,{once:!0,capture:!0});return h});return a(()=>Et(e,t,o)),i},Mm=(e,t,r,n={})=>{const{handle:s,arm:o}=ir(i=>{if(typeof window>"u"||typeof window.matchMedia!="function")return i(),te;const a=window.matchMedia(r);if(a.matches)return i(),te;let c=te;const l=h=>{h.matches&&(c(),i())};if(typeof a.addEventListener=="function")return a.addEventListener("change",l),c=()=>a.removeEventListener("change",l),c;const u=a;return typeof u.addListener=="function"&&typeof u.removeListener=="function"?(u.addListener(l),c=()=>u.removeListener(l),c):(i(),te)});return o(()=>Et(e,t,n)),s},Dm=(e,t,r={})=>Et(e,t,r),_m=(e,t={})=>{const r=t.prefix??"bq",n=t.warn??jt(),s=t.onMismatch,o=[];if(!e||typeof e.querySelectorAll!="function")return o;const i=[];typeof e.getAttribute=="function"&&e.getAttribute("data-bq-h")!==null&&i.push(e);for(const a of Array.from(e.querySelectorAll(`[${Jt}]`)))i.push(a);for(const a of i){const c=a.getAttribute("data-bq-h")??"",l=Ai(a,r),u=Fr(l);if(u!==c){const h={element:a,expected:c,actual:u,signature:l};o.push(h),s?.(h),n&&console.warn(`[bQuery SSR] Hydration mismatch on <${a.tagName.toLowerCase()}>: server="${c}" client="${u}" signature="${l}".`,a)}}return o},qm=e=>typeof e=="object"&&e!==null&&e[wt]===!0,xm=e=>G(e)||ce(e),zm=/^[A-Za-z][\w-]*$/,jm=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)+$/,Bi=(e,t)=>typeof e!="string"||!zm.test(e)?t:e,Um=(e,t)=>typeof e!="string"||!jm.test(e)?t:e,Hm=e=>{const t=e.replace(/-s$/,"-r");return t===e&&e.endsWith("-r")?`${e}-template`:t===e?`${e}-r`:t},Wm=(e,t)=>{const r={},n=[];let s=0;for(const[o,i]of Object.entries(e)){if(xm(i)){r[o]=i;continue}if(qm(i)){const a=`${t}-${s++}`;n.push({id:a,key:o,promise:i.promise}),r[o]=i.fallback;continue}if(i&&typeof i.then=="function"){const a=`${t}-${s++}`;n.push({id:a,key:o,promise:i}),r[o]=void 0;continue}r[o]=i}return{syncContext:r,slots:n}},rn=e=>e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),ar=e=>rn(e).replace(/"/g,"&quot;"),Fm=e=>e.replace(/<\/(script)/gi,"<\\/$1").replace(/<!--/g,"<\\!--").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029"),Bm=Fm('(()=>{var c=document.currentScript;if(!c)return;var slotId=c.getAttribute("data-bq-slot");var templateId=c.getAttribute("data-bq-template");if(!slotId||!templateId)return;var s=document.getElementById(slotId);var t=document.getElementById(templateId);if(!s||!t)return;var f=t.content?t.content.cloneNode(true):t;while(s.firstChild)s.removeChild(s.firstChild);s.appendChild(f);t.parentNode&&t.parentNode.removeChild(t);s.parentNode&&s.replaceWith(...s.childNodes);})();'),Qm=(e,t,r)=>`<script${r?` nonce="${ar(r)}"`:""} data-bq-slot="${ar(e)}" data-bq-template="${ar(t)}">${Bm}<\/script>`,Vm=(e,t,r,n,s,o)=>{const i=t[`__suspense_${n}`];return typeof i=="string"?bt(i,{...r,[n]:s},{prefix:o.prefix,stripDirectives:o.stripDirectives,annotateHydration:o.annotateHydration}).html:s==null?"":rn(typeof s=="string"?s:String(s))},Km=(e,t)=>{if(!(t in e.attributes))return;delete e.attributes[t];const r=e.attributeOrder.indexOf(t);r!==-1&&e.attributeOrder.splice(r,1)},Qi=(e,t,r=[])=>({type:"element",tag:e,attributes:{id:t},attributeOrder:["id"],children:r,void:!1,raw:!1}),Vi=(e,t)=>{for(const r of e)r.type==="element"&&(t(r),Vi(r.children,t))},Ki=(e,t)=>{for(const r of e){if(r.type!=="element")continue;if(r.tag===t)return r;const n=Ki(r.children,t);if(n)return n}return null},Ym=(e,t,r,n)=>{const s=Um(n.slotTag,"bq-slot"),o=tr(e),i=new Map(r.map(l=>[l.key,l])),a=new Set;Vi(o.children,l=>{const u=l.attributes["data-bq-defer"];if(!u)return;Km(l,"data-bq-defer");const h=i.get(u);if(!h||a.has(h.id))return;const d=l.children;l.children=[Qi(s,h.id,d)],a.add(h.id)});const c=Ki(o.children,"body")?.children??o.children;for(const l of r)a.has(l.id)||c.push(Qi(s,l.id));return vt(o)},Jm=e=>e!==void 0&&/\s/.test(e),Gm=e=>e===void 0||e==="="||e===">"||e==="/"||/\s/.test(e),Xm=e=>{let t="",r=0,n=!1,s="",o=!1,i=!1,a=!0;const c="bq-defer";for(;r<e.length;){const l=e[r];if(!n){l==="<"&&(n=!0,o=!1,i=!1,a=!0),t+=l,r++;continue}if(s){t+=l,l===s&&(s=""),r++;continue}if(l==='"'||l==="'"){s=l,t+=l,r++;continue}if(l===">"){n=!1,t+=l,r++;continue}if(!o){if(t+=l,r++,!i){if(/\s/.test(l))continue;i=!0,(l==="/"||l==="!"||l==="?")&&(a=!1);continue}a&&/\s/.test(l)&&(o=!0);continue}if(a&&e.startsWith(c,r)&&Jm(e[r-1])&&Gm(e[r+8])){t+="data-bq-defer",r+=8;continue}t+=l,r++}return t},Zm=()=>{if(typeof TextEncoder>"u")throw new Error("bQuery SSR: TextEncoder is not available in this runtime.");return new TextEncoder},ep=(e,t,r={})=>{if(typeof ReadableStream>"u")throw new Error("bQuery SSR: ReadableStream is not available in this runtime.");const n=Zm(),s=r.context??St({...r,mode:"stream"}),o=Bi(r.slotIdPrefix??"bq-s","bq-s"),i=Bi(Hm(o),"bq-r");return new ReadableStream({async start(a){const c=()=>{try{a.error(new DOMException("SSR stream aborted","AbortError"))}catch{}};if(s.signal.aborted){c();return}s.signal.addEventListener("abort",c,{once:!0});try{const{syncContext:l,slots:u}=Wm(t,o),h=bt(Xm(e),l,{prefix:r.prefix,stripDirectives:r.stripDirectives,annotateHydration:r.annotateHydration}).html,d=Ym(h,l,u,r);a.enqueue(n.encode(d));const v=[],f=[];let p=u.length;const y=g=>{const w=f.shift();if(w){w(g);return}v.push(g)};for(const[g,w]of u.entries())w.promise.then(S=>({index:g,slot:w,ok:!0,value:S}),S=>({index:g,slot:w,ok:!1,error:S})).then(y);const b=async()=>{const g=v.shift();return g||new Promise(w=>{f.push(w)})};for(;p>0;){if(s.signal.aborted)return;const g=await b();p--;const{slot:w}=g,S=`${i}-${w.id.split("-").pop()}`;let k;g.ok?k=Vm(e,t,l,w.key,g.value,r):(s.reportError(g.error),k="");const A=`<template id="${ar(S)}">${k}</template>`,E=Qm(w.id,S,s.nonce);a.enqueue(n.encode(A+E))}a.close()}catch(l){try{a.error(l)}catch{}}finally{s.signal.removeEventListener("abort",c)}}})},tp=e=>{if(!e||!e.meta)return;const t=e.meta.loader;return typeof t=="function"?t:void 0},Yi=e=>{const t=typeof e.url=="string"?new URL(e.url,"http://localhost/"):e.url,r=e.base??"";let n=t.pathname;r&&(n===r?n="/":n.startsWith(`${r}/`)&&(n=n.slice(r.length)||"/"));const s=Uo(n,e.routes),o={path:n,params:s?.params??{},query:Lo(t.search),matched:s?.matched??null,hash:t.hash.replace(/^#/,"")},i=s!==null,a=s?.matched??null,c=!!a&&"redirectTo"in a&&typeof a.redirectTo=="string";return{route:o,matched:i,isRedirect:c,redirectTo:c?a.redirectTo:void 0}},Ji=async(e,t)=>{const r=tp(e.matched);if(r)try{return await r({route:e,ctx:t})}catch(n){t.reportError(n);return}},rp=async e=>{const t=Yi({url:e.url,routes:e.routes,base:e.base}),r=t.matched?await Ji(t.route,e.ctx):void 0;return{route:t.route,matched:t.matched,isRedirect:t.isRedirect,redirectTo:t.redirectTo,data:r,bindings:{route:t.route,params:t.route.params,query:t.route.query,data:r}}},nn=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),Gi=e=>{const t={};for(const[r,n]of Object.entries(e))N(r)||(t[r]=n);return t},np=e=>{const{version:t,storeIds:r,scriptId:n="__BQUERY_STORE_SNAPSHOT__",globalKey:s="__BQUERY_STORE_SNAPSHOT__",nonce:o}=e;if(typeof t!="string"||t.length===0)throw new Error("serializeStoreSnapshot: `version` is required and must be a non-empty string.");if(N(n)||N(s))throw new Error("serializeStoreSnapshot: invalid scriptId/globalKey.");const i=r??Bt(),a=Object.create(null);for(const d of i){if(N(d))continue;const v=we(d);v&&(a[d]=Gi(v.$state))}const c={version:t,state:a},l=JSON.stringify(c),u=He(l),h=He(JSON.stringify(s));return{snapshot:c,json:l,scriptTag:`<script id="${yt(n)}"${o?` nonce="${yt(o)}"`:""}>window[${h}]=${u}<\/script>`}},Xi=e=>{if(!nn(e))return!1;const t=e.version,r=e.state;return typeof t=="string"&&nn(r)},sp=(e,t={})=>{if(!Xi(e))return t.strict&&console.warn("[bQuery SSR] hydrateStoreSnapshot: snapshot has invalid shape."),{applied:!1,reason:"invalid-shape",appliedIds:[],unknownIds:[]};if(typeof t.expectedVersion=="string"&&t.expectedVersion!==e.version)return t.strict&&console.warn(`[bQuery SSR] hydrateStoreSnapshot: version mismatch — server="${e.version}" client="${t.expectedVersion}". Skipping.`),{applied:!1,reason:"version-mismatch",appliedIds:[],unknownIds:[]};const r=[],n=[];for(const[s,o]of Object.entries(e.state)){if(N(s)||!nn(o))continue;const i=we(s);if(!i||typeof i.$patch!="function"){n.push(s),t.strict&&console.warn(`[bQuery SSR] hydrateStoreSnapshot: store "${s}" is not registered; skipping.`);continue}i.$patch(Gi(o)),r.push(s)}return{applied:r.length>0,appliedIds:r,unknownIds:n}},op=(e="__BQUERY_STORE_SNAPSHOT__",t="__BQUERY_STORE_SNAPSHOT__")=>{if(N(e)||N(t)||typeof window>"u")return null;const r=window[e];try{delete window[e]}catch{window[e]=void 0}if(typeof document<"u"&&typeof document.getElementById=="function"){const n=document.getElementById(t);n&&n.remove()}return Xi(r)?r:null},Zi=e=>{const t=Object.create(null);for(const[r,n]of Object.entries(e))N(r)||(t[r]=n);return t},ip=(e={})=>{const t=Object.create(null);if(e.initial)for(const[r,n]of Object.entries(e.initial))N(r)||(t[r]=n);return{set(r,n){N(r)||(t[r]=n)},get(r){return t[r]},entries(){return Zi(t)},render(r={}){const n=r.scriptId??"__BQUERY_RESUME__",s=r.globalKey??"__BQUERY_RESUME__";if(N(n)||N(s))return"";const o=He(JSON.stringify(t)),i=He(JSON.stringify(s));return`<script id="${yt(n)}"${r.nonce?` nonce="${yt(r.nonce)}"`:""}>window[${i}]=${o}<\/script>`}}},ap=(e="__BQUERY_RESUME__",t="__BQUERY_RESUME__")=>{const r={get:()=>{},hasSnapshot:!1,entries:()=>({})};if(N(e)||N(t)||typeof window>"u")return r;const n=window[e];try{delete window[e]}catch{window[e]=void 0}if(typeof document<"u"&&typeof document.getElementById=="function"){const o=document.getElementById(t);o&&o.remove()}if(!n||typeof n!="object")return r;const s=n;return{hasSnapshot:!0,get(o){if(!N(o))return s[o]},entries(){return Zi(s)}}},ea=e=>e,ta=e=>async t=>Promise.resolve(e(t)),ra=e=>async t=>Promise.resolve(e(t)),cp=e=>e!=="GET"&&e!=="HEAD",sn=class extends Error{constructor(e){super(e),this.name="NodeRequestLimitError"}},cr=(e,t)=>{const r=e[t];return Array.isArray(r)?r[0]:r},lp=e=>{const t=cr(e.headers,"content-length");if(!t)return null;const r=Number.parseInt(t,10);return Number.isSafeInteger(r)&&r>=0?r:null},up=(e,t)=>new Promise((r,n)=>{const s=[];let o=0,i=!1;const a=l=>{i||(i=!0,s.length=0,o=0,e.destroy?.(l instanceof Error?l:void 0),n(l))},c=lp(e);if(t!==void 0&&c!==null&&c>t){a(new sn(`Request body exceeds ${t} bytes.`));return}e.on("data",l=>{if(i)return;const u=typeof l=="string"?new TextEncoder().encode(l):l;if(o+=u.byteLength,t!==void 0&&o>t){a(new sn(`Request body exceeds ${t} bytes.`));return}s.push(u)}),e.on("end",()=>{if(i)return;i=!0;const l=new ArrayBuffer(o),u=new Uint8Array(l);let h=0;for(const d of s)u.set(d,h),h+=d.byteLength;r(l)}),e.on("error",a)}),fp=(e,t)=>{const r=`${t}://localhost`,n=cr(e.headers,"host")||"localhost";try{return new URL(e.url??"/",`${t}://${n}`)}catch{try{return new URL(e.url??"/",r)}catch{return new URL("/",r)}}},dp=async(e,t={})=>{const r=typeof cr(e.headers,"x-forwarded-proto")=="string"?cr(e.headers,"x-forwarded-proto").split(",")[0].trim().toLowerCase():"",n=fp(e,r==="http"||r==="https"?r:"http"),s=new Headers;for(const[a,c]of Object.entries(e.headers))if(c!==void 0)if(Array.isArray(c))for(const l of c)s.append(a,l);else s.append(a,c);const o=(e.method??"GET").toUpperCase(),i={method:o,headers:s};return cp(o)&&(i.body=await up(e,t.maxBodyBytes)),new Request(n.toString(),i)},hp=e=>{const t=e.getSetCookie?.();if(Array.isArray(t)&&t.length>0)return t;const r=e.get("set-cookie");return r?[r]:[]},mp=e=>new Promise((t,r)=>{const n=typeof e.once=="function"?e.once.bind(e):void 0,s=typeof e.on=="function"?e.on.bind(e):void 0,o=n??s;if(!o){t();return}o("drain",()=>t()),o("error",i=>{r(i instanceof Error?i:new Error("Node response stream errored while draining."))})}),na=async(e,t)=>{t.statusCode=e.status;const r=hp(e.headers);if(r.length>0&&t.setHeader("set-cookie",r.length===1?r[0]:r),e.headers.forEach((s,o)=>{o.toLowerCase()!=="set-cookie"&&t.setHeader(o,s)}),!e.body){t.end();return}const n=e.body.getReader();for(;;){const{value:s,done:o}=await n.read();if(o)break;s&&!t.write(s)&&await mp(t)}t.end()},sa=(e,t={})=>async(r,n)=>{let s;try{s=await dp(r,t)}catch(o){if(o instanceof sn){await na(new Response(o.message,{status:413}),n);return}throw o}await na(await Promise.resolve(e(s)),n)},pp=e=>{switch(or()){case"node":return sa(e);case"bun":return ta(e);case"deno":return ra(e);default:return ea(e)}},vp="http://localhost",yp={"<":"\\u003C",">":"\\u003E","&":"\\u0026","\u2028":"\\u2028","\u2029":"\\u2029"},gp=/[<>&\u2028\u2029]/g,bp=null,oa="x-bquery-websocket-passthrough",wp=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),lr=()=>Object.create(null),on=e=>{if(!e)throw new Error(`route path must be a non-empty string; received ${String(e)}`);if(e==="*"||e==="/*")return"/*";const t=e.startsWith("/")?e:`/${e}`;return t.length>1&&t.endsWith("/")?t.slice(0,-1):t},ia=e=>{const t=on(e);if(t==="/*")return{path:t,paramNames:[],pattern:/^\/.*$/};const r=t.split("/").filter(Boolean);if(r.length===0)return{path:t,paramNames:[],pattern:/^\/$/};const n=[];let s="^";for(const[o,i]of r.entries()){if(s+="/",i==="*"){if(o!==r.length-1)throw new Error(`invalid route path: "*" must be the final segment in "${t}"`);s+=".*";break}if(i.startsWith(":")){const a=i.slice(1);if(!/^[A-Za-z_$][\w$]*$/.test(a))throw new Error(`invalid route param name: ${a} - must start with a letter, $, or _ and contain only word characters`);if(N(a))throw new Error(`invalid route param name: ${a} - reserved for object safety`);n.push(a),s+="([^/]+)";continue}s+=wp(i)}return s+="/?$",{path:t,paramNames:n,pattern:new RegExp(s)}},Sp=e=>{if(typeof e>"u")return bp;const t=Array.isArray(e)?e:[e];if(t.length===0)throw new Error("route method must be specified - received empty array");const r=new Set(t.map(n=>n.trim().toUpperCase()).filter(Boolean));if(r.size===0)throw new Error(`route method must include at least one non-empty method string; received ${JSON.stringify(e)}`);return r},aa=e=>{const t=lr();for(const[r,n]of e.searchParams.entries()){if(N(r))continue;const s=t[r];typeof s>"u"?t[r]=n:Array.isArray(s)?s.push(n):t[r]=[s,n]}return t},ca=(e,t)=>e instanceof URL?new URL(e.toString()):new URL(e,t),la=(e,t)=>{if(e instanceof Request)return e;if(typeof e=="string"||e instanceof URL)return new Request(ca(e,t).toString());const{url:r,method:n="GET",headers:s,body:o=null}=e;return new Request(ca(r,t).toString(),{method:n,headers:s,body:o})},Ep=e=>typeof e>"u"?[]:[...new Set((Array.isArray(e)?e:[e]).map(t=>t.trim()).filter(Boolean))],Ap=e=>{const t=e.data;if(typeof t=="string")try{return JSON.parse(t)}catch{return t}return t},kp=e=>e.replace(gp,t=>yp[t]),We=e=>new Headers(e),an=(e,t)=>(e.has("content-type")||e.set("content-type",t),e),Oe=(e,t={})=>{const{headers:r,...n}=t;return new Response(e,{...n,headers:We(r)})},ua=(e,t={})=>{const r=an(We(t.headers),"text/plain; charset=utf-8");return Oe(e,{...t,headers:r})},cn=(e,t={})=>{const{trusted:r=!1,...n}=t,s=an(We(n.headers),"text/html; charset=utf-8");return Oe(r?e:ie(e),{...n,headers:s})},fa=(e,t={})=>{const r=an(We(t.headers),"application/json; charset=utf-8");let n;try{n=JSON.stringify(e)??"null"}catch{n="null"}return Oe(kp(n),{...t,headers:r})},da=(e,t=302)=>Oe(null,{headers:We({location:e.toString()}),status:t}),ha=(e,t,r={})=>{const{includeStoreState:n=!1,status:s=200,headers:o,...i}=r,a=bt(e,t,{...i,includeStoreState:!1}),c=n?gt({storeIds:Array.isArray(n)?n:void 0}).scriptTag:"";return cn(`${a.html}${c}`,{headers:o,status:s,trusted:!0})},ln=e=>{if(e.method.toUpperCase()!=="GET")return!1;const t=e.headers.get("upgrade");if(typeof t!="string"||t.trim().toLowerCase()!=="websocket")return!1;const r=e.headers.get("connection");if(typeof r!="string"||!r.split(",").some(s=>s.trim().toLowerCase()==="upgrade")||e.headers.get("sec-websocket-version")?.trim()!=="13")return!1;const n=e.headers.get("sec-websocket-key")?.trim();return typeof n=="string"&&/^[A-Za-z0-9+/]{22}==$/.test(n)},Tp=e=>{if(typeof e!="object"||e===null||e instanceof Response)return!1;const t=e;return typeof t.open=="function"&&typeof t.message=="function"&&typeof t.close=="function"&&typeof t.error=="function"},Cp=()=>{const e=new WeakMap;return t=>{const r=e.get(t);if(r)return r;const n={get protocol(){return t.protocol},get readyState(){return t.readyState},get url(){return t.url},send(s){t.send(s)},sendJson(s){const o=JSON.stringify(s);if(typeof o!="string")throw new TypeError("socket.sendJson() does not support undefined values");t.send(o)},close(s,o){t.close(s,o)}};return e.set(t,n),n}},Rp=(e,t)=>{const r=Cp(),n=t.deserialize??Ap;return{context:e,protocols:Ep(t.protocols),headers:t.headers,async open(s){t.onOpen&&await t.onOpen(r(s),e)},async message(s,o){t.onMessage&&await t.onMessage(n(o),r(s),e,o)},async close(s,o){t.onClose&&await t.onClose(o,r(s),e)},async error(s,o){t.onError&&await t.onError(o,r(s),e)}}},$p=()=>Oe(null,{headers:We({[oa]:"1"}),status:204}),Op=e=>e.headers.get(oa)==="1",Lp=(e,t,r)=>{if(e.methods&&!e.methods.has(t))return null;const n=e.pattern.exec(r);if(!n)return null;const s=lr();for(const[o,i]of e.paramNames.entries())try{s[i]=decodeURIComponent(n[o+1]??"")}catch(a){if(a instanceof URIError)return null;throw a}return s},ma=(e,t,r,n)=>{for(const s of e){const o=Lp(s,t,r);if(o)return n.params=o,s}return null},Pp=async(e,t,r)=>{const n=async s=>{const o=t[s];if(!o)return r();let i=!1;return await o(e,async()=>{if(i)throw new Error("middleware next() called multiple times - if a middleware calls next(), it may only do so once");return i=!0,await n(s+1)})};return await n(0)},Np=async(e,t,r)=>{const n=async s=>{const o=t[s];if(!o)return r();let i=!1;return await o(e,async()=>{if(i)throw new Error("middleware next() called multiple times - if a middleware calls next(), it may only do so once");return i=!0,await n(s+1)})};return await n(0)},Ip=e=>async(t,r)=>{let n=null,s=null;const o=await e(t,async()=>(n=await r(),n instanceof Response?(s=n,n):$p()));return s?o:o instanceof Response&&Op(o)?n:o},pa=e=>{const t=ia(e.path);return{handler:e.handler,methods:Sp(e.method),middlewares:e.middlewares??[],paramNames:t.paramNames,path:t.path,pattern:t.pattern}},Mp=(e={})=>{const t=e.baseUrl??vp,r=[...e.middlewares??[]],n=[],s=[],o=e.notFound??(u=>u.text("Not Found",{status:404})),i=e.onError??((u,h)=>u instanceof Response?u:h.text("Internal Server Error",{status:500})),a=(u,h,d,v)=>(n.push(pa({handler:d,method:u,middlewares:v,path:h})),l),c=(u,h,d)=>{const v=ia(u);return s.push({handler:h,methods:new Set(["GET"]),middlewares:d??[],paramNames:v.paramNames,path:v.path,pattern:v.pattern}),l},l={use(u){return r.push(u),l},add(u){return n.push(pa(u)),l},get(u,h,d){return a("GET",u,h,d)},post(u,h,d){return a("POST",u,h,d)},put(u,h,d){return a("PUT",u,h,d)},patch(u,h,d){return a("PATCH",u,h,d)},delete(u,h,d){return a("DELETE",u,h,d)},all(u,h,d){return a(void 0,u,h,d)},ws(u,h,d){return c(u,h,d)},async handle(u){const h=la(u,t),d=new URL(h.url),v=h.method.toUpperCase(),f=on(d.pathname||"/"),p=aa(d),y={request:h,url:d,method:v,path:f,params:lr(),query:p,state:{},response:Oe,text:ua,html:cn,json:fa,redirect:da,render:ha,isWebSocketRequest:ln(h)};try{const b=ma(n,v,f,y);return b?await Pp(y,[...r,...b.middlewares,async g=>await b.handler(g)],async()=>await o(y)):await o(y)}catch(b){return await i(b,y)}},async handleWebSocket(u){const h=la(u,t),d=new URL(h.url),v=h.method.toUpperCase(),f=on(d.pathname||"/"),p=aa(d),y={request:h,url:d,method:v,path:f,params:lr(),query:p,state:{},response:Oe,text:ua,html:cn,json:fa,redirect:da,render:ha,isWebSocketRequest:ln(h)};if(!y.isWebSocketRequest)return null;try{const b=ma(s,v,f,y);return b?await Np(y,[...r.map(Ip),...b.middlewares],async()=>Rp(y,typeof b.handler=="function"?await b.handler(y):b.handler)):null}catch(b){return await i(b,y)}}};return l};m.$=Ma,m.$$=Da,m.BQueryCollection=$t,m.BQueryElement=Ne,m.BqLinkElement=Oo,m.Computed=Je,m.HYDRATION_HASH_ATTR=Jt,m.HttpError=ye,m.Signal=Ge,m.TaskWorkerAbortError=ge,m.TaskWorkerError=H,m.TaskWorkerSerializationError=Te,m.TaskWorkerTimeoutError=It,m.TaskWorkerUnsupportedError=Ar,m.animate=Ht,m.announceToScreenReader=Ff,m.auditA11y=Xf,m.back=su,m.batch=ke,m.batchTasks=Gc,m.bool=pl,m.breakpoints=Ed,m.buckets=jl,m.cache=Hl,m.callWorkerMethod=Fc,m.capitalize=Xn,m.capturePosition=Or,m.chunk=zn,m.clamp=Yn,m.clearAnnouncements=Bf,m.clearExpressionCache=Ku,m.clearPlugins=Iu,m.clearTimeline=Gd,m.clipboard=Nd,m.clone=Pn,m.compact=jn,m.component=De,m.computed=D,m.configureSSR=hh,m.createAssetManager=ji,m.createBunHandler=ta,m.createDenoHandler=ra,m.createForm=Ef,m.createHeadManager=zi,m.createHttp=br,m.createI18n=Uf,m.createNodeHandler=sa,m.createPersistedStore=Qu,m.createReactiveRpcPool=sl,m.createReactiveRpcWorker=rl,m.createReactiveTaskPool=nl,m.createReactiveTaskWorker=tl,m.createRequestQueue=Ec,m.createRestClient=Lc,m.createResumableState=ip,m.createRouter=ku,m.createRpcPool=js,m.createRpcWorker=Dt,m.createSSRContext=St,m.createSSRHandler=pp,m.createSSRRouterContext=rp,m.createServer=Mp,m.createStore=Ir,m.createTaskPool=xt,m.createTaskWorker=_t,m.createTemplate=gf,m.createTrustedHtml=La,m.createUseFetch=cc,m.createWebHandler=ea,m.currentRoute=To,m.custom=_f,m.customAsync=qf,m.debounce=Ot,m.deduplicateRequest=Nc,m.defer=dm,m.defineBqueryConfig=qa,m.defineComponent=fl,m.defineLoader=fm,m.definePageMeta=Gl,m.defineStore=xu,m.deserializeStoreState=Xh,m.destroyStore=_u,m.detectRuntime=or,m.draggable=fd,m.droppable=gd,m.easeInCubic=ho,m.easeInOutCubic=po,m.easeInOutQuad=fo,m.easeInQuad=lo,m.easeOutBack=vo,m.easeOutCubic=mo,m.easeOutExpo=yo,m.easeOutQuad=uo,m.easingPresets=El,m.effect=j,m.effectScope=Ba,m.email=Nf,m.enableDevtools=Fd,m.ensureArray=qn,m.escapeHtml=Cn,m.escapeRegExp=ns,m.every=Vs,m.filter=Bs,m.find=Ks,m.fireEvent=fh,m.flatten=Un,m.flip=Lr,m.flipElements=go,m.flipList=Al,m.flushEffects=Si,m.formatDate=Jo,m.formatNumber=Yo,m.forward=ou,m.generateNonce=An,m.generateSignalLabel=Kd,m.getBqueryConfig=ae,m.getConcurrencySupport=Ns,m.getCurrentScope=ys,m.getCustomDirective=Ud,m.getCustomDirectives=Hd,m.getDevtoolsState=Xd,m.getFocusableElements=Ur,m.getInstalledPlugins=jd,m.getSSRConfig=mh,m.getSSRRuntimeFeatures=um,m.getStore=we,m.getTimeline=Jd,m.getTrustedTypesPolicy=Tn,m.hasCSPDirective=$a,m.hasOwn=Mn,m.html=_e,m.http=Sc,m.hydrateIsland=Dm,m.hydrateMount=Ei,m.hydrateOnIdle=Nm,m.hydrateOnInteraction=Im,m.hydrateOnMedia=Mm,m.hydrateOnVisible=Pm,m.hydrateStore=Ii,m.hydrateStoreSnapshot=sp,m.hydrateStores=Zh,m.inRange=Jn,m.inspectComponents=gi,m.inspectSignals=vi,m.inspectStores=yi,m.interceptLinks=fu,m.isActive=wu,m.isActiveSignal=Su,m.isArray=us,m.isBoolean=ls,m.isBrowserRuntime=lm,m.isCollection=os,m.isComputed=ce,m.isConcurrencySupported=kr,m.isDate=fs,m.isDevtoolsEnabled=Bd,m.isElement=ss,m.isEmpty=Vn,m.isFunction=is,m.isInstalled=zd,m.isNavigating=ru,m.isNumber=cs,m.isObject=ds,m.isPlainObject=Se,m.isPromise=Ie,m.isServerRuntime=cm,m.isServerWebSocketSession=Tp,m.isSignal=G,m.isString=as,m.isTrustedTypesSupported=Oa,m.isWebSocketRequest=ln,m.keyframePresets=kl,m.linear=co,m.link=uu,m.linkedSignal=Ac,m.listStores=Bt,m.logComponents=th,m.logSignals=Zd,m.logStores=eh,m.logTimeline=rh,m.map=Fs,m.mapActions=Uu,m.mapGetters=ju,m.mapState=zu,m.matchField=xf,m.max=Df,m.maxLength=Lf,m.mediaQuery=Sd,m.merge=Ee,m.min=Mf,m.minLength=Of,m.mockRouter=uh,m.mockSignal=ih,m.morphElement=Tl,m.mount=zr,m.navigate=nt,m.noop=Wn,m.notifications=Kl,m.omit=In,m.onScopeDispose=gs,m.once=Hn,m.parallax=Cl,m.parallel=Jc,m.parseJson=Qn,m.pattern=Pf,m.persistedSignal=Cc,m.pick=Nn,m.pipeline=el,m.prefersColorScheme=Zf,m.prefersContrast=ed,m.prefersReducedMotion=le,m.randomInt=Kn,m.readStoreSnapshot=op,m.readonly=_,m.recordEvent=Yd,m.reduce=Ys,m.registerBqLink=lu,m.registerDefaultComponents=wl,m.registerPlugin=Pu,m.releaseFocus=cd,m.renderComponent=oh,m.renderToResponse=Om,m.renderToStream=Rm,m.renderToStreamSuspense=ep,m.renderToString=bt,m.renderToStringAsync=en,m.required=$f,m.resetPlugins=Wd,m.resolve=bu,m.resolveSSRRoute=Yi,m.resumeState=ap,m.rovingTabIndex=td,m.runRouteLoaders=Ji,m.runTask=Ds,m.safeHtml=vl,m.sanitize=ie,m.sanitizeHtml=ie,m.scrollAnimate=$l,m.sequence=Dl,m.serializeStoreSnapshot=np,m.serializeStoreState=gt,m.setReducedMotion=Sl,m.signal=L,m.skipLink=od,m.sleep=Bn,m.slugify=rs,m.some=Qs,m.sortable=wd,m.spring=Ll,m.springPresets=Pl,m.stagger=Nl,m.storage=tu,m.stripTags=Pa,m.throttle=hr,m.timeline=_l,m.toCamelCase=es,m.toKebabCase=Zn,m.toNumber=Gn,m.toValue=Ic,m.trackSignal=Qd,m.transition=ql,m.trapFocus=ad,m.truncate=ts,m.trusted=Ta,m.typewriter=xl,m.uid=Fn,m.unique=xn,m.unregisterPlugin=Nu,m.untrack=Ae,m.untrackSignal=Vd,m.url=If,m.use=xd,m.useAnnouncer=Jl,m.useAsyncData=ws,m.useBattery=Cd,m.useComputed=al,m.useCookie=Vl,m.useDeviceMotion=Ld,m.useDeviceOrientation=Pd,m.useEffect=cl,m.useEventSource=xc,m.useFetch=re,m.useFormField=Tf,m.useGeolocation=Rd,m.useInfiniteFetch=Tc,m.useIntersectionObserver=Md,m.useMutationObserver=_d,m.useNetworkStatus=kd,m.usePaginatedFetch=kc,m.usePolling=Rc,m.useResizeObserver=Dd,m.useResource=$c,m.useResourceList=Pc,m.useRoute=Cu,m.useSignal=il,m.useSubmit=Oc,m.useViewport=Ad,m.useWebSocket=Os,m.useWebSocketChannel=qc,m.utils=_a,m.verifyHydration=_m,m.waitFor=dh,m.watch=Sr,m.watchDebounce=Mc,m.watchStore=Vu,m.watchThrottle=Dc});
280
280
 
281
281
  //# sourceMappingURL=full.umd.js.map