@bquery/bquery 1.5.0 → 1.6.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 (106) hide show
  1. package/README.md +586 -546
  2. package/dist/component/component.d.ts +13 -5
  3. package/dist/component/component.d.ts.map +1 -1
  4. package/dist/component/html.d.ts +40 -3
  5. package/dist/component/html.d.ts.map +1 -1
  6. package/dist/component/index.d.ts +2 -2
  7. package/dist/component/index.d.ts.map +1 -1
  8. package/dist/component/library.d.ts.map +1 -1
  9. package/dist/component/types.d.ts +131 -16
  10. package/dist/component/types.d.ts.map +1 -1
  11. package/dist/component-BEQgt5hl.js +600 -0
  12. package/dist/component-BEQgt5hl.js.map +1 -0
  13. package/dist/component.es.mjs +7 -6
  14. package/dist/config-DRmZZno3.js.map +1 -1
  15. package/dist/core-BGQJVw0-.js +35 -0
  16. package/dist/core-BGQJVw0-.js.map +1 -0
  17. package/dist/{core-CK2Mfpf4.js → core-CCEabVHl.js} +2 -2
  18. package/dist/{core-CK2Mfpf4.js.map → core-CCEabVHl.js.map} +1 -1
  19. package/dist/core.es.mjs +1 -1
  20. package/dist/effect-AFRW_Plg.js +84 -0
  21. package/dist/effect-AFRW_Plg.js.map +1 -0
  22. package/dist/full.d.ts +4 -4
  23. package/dist/full.d.ts.map +1 -1
  24. package/dist/full.es.mjs +98 -94
  25. package/dist/full.iife.js +14 -14
  26. package/dist/full.iife.js.map +1 -1
  27. package/dist/full.umd.js +14 -14
  28. package/dist/full.umd.js.map +1 -1
  29. package/dist/index.es.mjs +143 -139
  30. package/dist/{motion-C5DRdPnO.js → motion-D9TcHxOF.js} +1 -1
  31. package/dist/{motion-C5DRdPnO.js.map → motion-D9TcHxOF.js.map} +1 -1
  32. package/dist/motion.es.mjs +1 -1
  33. package/dist/{platform-B7JhGBc7.js → platform-Dr9b6fsq.js} +21 -20
  34. package/dist/platform-Dr9b6fsq.js.map +1 -0
  35. package/dist/platform.es.mjs +1 -1
  36. package/dist/{reactive-BDya-ia8.js → reactive-DSkct0dO.js} +51 -50
  37. package/dist/reactive-DSkct0dO.js.map +1 -0
  38. package/dist/reactive.es.mjs +19 -17
  39. package/dist/{router-CijiICxt.js → router-CbDhl8rS.js} +3 -3
  40. package/dist/{router-CijiICxt.js.map → router-CbDhl8rS.js.map} +1 -1
  41. package/dist/router.es.mjs +1 -1
  42. package/dist/{sanitize-jyJ2ryE2.js → sanitize-Bs2dkMby.js} +94 -83
  43. package/dist/sanitize-Bs2dkMby.js.map +1 -0
  44. package/dist/security/index.d.ts +4 -2
  45. package/dist/security/index.d.ts.map +1 -1
  46. package/dist/security/sanitize.d.ts +4 -1
  47. package/dist/security/sanitize.d.ts.map +1 -1
  48. package/dist/security/trusted-html.d.ts +53 -0
  49. package/dist/security/trusted-html.d.ts.map +1 -0
  50. package/dist/security.es.mjs +10 -9
  51. package/dist/store/define-store.d.ts +1 -1
  52. package/dist/store/define-store.d.ts.map +1 -1
  53. package/dist/store/mapping.d.ts +1 -1
  54. package/dist/store/mapping.d.ts.map +1 -1
  55. package/dist/store/persisted.d.ts +1 -1
  56. package/dist/store/persisted.d.ts.map +1 -1
  57. package/dist/store/types.d.ts +2 -2
  58. package/dist/store/types.d.ts.map +1 -1
  59. package/dist/store/watch.d.ts +1 -1
  60. package/dist/store/watch.d.ts.map +1 -1
  61. package/dist/{store-CPK9E62U.js → store-BwDvI45q.js} +49 -48
  62. package/dist/{store-CPK9E62U.js.map → store-BwDvI45q.js.map} +1 -1
  63. package/dist/store.es.mjs +1 -1
  64. package/dist/storybook/index.d.ts +37 -0
  65. package/dist/storybook/index.d.ts.map +1 -0
  66. package/dist/storybook.es.mjs +151 -0
  67. package/dist/storybook.es.mjs.map +1 -0
  68. package/dist/untrack-B0rVscTc.js +7 -0
  69. package/dist/untrack-B0rVscTc.js.map +1 -0
  70. package/dist/{view-Cdi0g-qo.js → view-C70lA3vf.js} +29 -28
  71. package/dist/{view-Cdi0g-qo.js.map → view-C70lA3vf.js.map} +1 -1
  72. package/dist/view.es.mjs +9 -8
  73. package/package.json +141 -136
  74. package/src/component/component.ts +259 -54
  75. package/src/component/html.ts +153 -53
  76. package/src/component/index.ts +10 -2
  77. package/src/component/library.ts +42 -28
  78. package/src/component/types.ts +184 -19
  79. package/src/full.ts +8 -2
  80. package/src/motion/transition.ts +97 -97
  81. package/src/motion/types.ts +208 -208
  82. package/src/platform/announcer.ts +208 -208
  83. package/src/platform/config.ts +163 -163
  84. package/src/platform/cookies.ts +165 -165
  85. package/src/platform/index.ts +39 -39
  86. package/src/platform/meta.ts +168 -168
  87. package/src/reactive/async-data.ts +486 -486
  88. package/src/reactive/index.ts +37 -37
  89. package/src/reactive/signal.ts +29 -29
  90. package/src/security/constants.ts +211 -211
  91. package/src/security/index.ts +17 -10
  92. package/src/security/sanitize.ts +70 -66
  93. package/src/security/trusted-html.ts +71 -0
  94. package/src/store/define-store.ts +49 -48
  95. package/src/store/mapping.ts +74 -73
  96. package/src/store/persisted.ts +62 -61
  97. package/src/store/types.ts +92 -94
  98. package/src/store/watch.ts +53 -52
  99. package/src/storybook/index.ts +479 -0
  100. package/dist/component-CY5MVoYN.js +0 -531
  101. package/dist/component-CY5MVoYN.js.map +0 -1
  102. package/dist/core-DPdbItcq.js +0 -112
  103. package/dist/core-DPdbItcq.js.map +0 -1
  104. package/dist/platform-B7JhGBc7.js.map +0 -1
  105. package/dist/reactive-BDya-ia8.js.map +0 -1
  106. package/dist/sanitize-jyJ2ryE2.js.map +0 -1
package/dist/full.iife.js CHANGED
@@ -1,9 +1,9 @@
1
- var bQuery=(function(d){Object.defineProperty(d,Symbol.toStringTag,{value:"Module"});var _e="bquery-sanitizer",Dt=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"]),De=new Set(["script","iframe","frame","frameset","object","embed","applet","link","meta","style","base","template","math","svg","foreignobject","noscript"]),qt=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"]),jt=new Set(["alt","class","dir","height","hidden","href","id","lang","loading","name","rel","role","src","srcset","tabindex","target","title","type","width","aria-*"]),It=["on","formaction","xlink:","xmlns:"],Ht=["javascript:","data:","vbscript:","file:"],zt=(e,t,r)=>{const n=e.toLowerCase();for(const s of It)if(n.startsWith(s))return!1;return r&&n.startsWith("data-")||n.startsWith("aria-")?!0:t.has(n)},Bt=e=>{const t=e.toLowerCase().trim();return!qt.has(t)},Ft=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(),qe=e=>{const t=Ft(e);for(const r of Ht)if(t.startsWith(r))return!1;return!0},Ut=e=>{const t=e.split(",");for(const r of t){const n=r.trim().split(/\s+/)[0];if(n&&!qe(n))return!1}return!0},xt=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}},Wt=e=>new DOMParser().parseFromString(e,"text/html"),je=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=Wt(t).body;if(!n)return r;for(;n.firstChild;)r.appendChild(n.firstChild);return r},te=(e,t={})=>{const{allowTags:r=[],allowAttributes:n=[],allowDataAttributes:s=!0,stripAllTags:a=!1}=t,i=new Set([...Dt,...r.map(f=>f.toLowerCase())].filter(f=>!De.has(f))),o=new Set([...jt,...n.map(f=>f.toLowerCase())]),c=je(e);if(a)return c.textContent??"";const l=document.createTreeWalker(c,NodeFilter.SHOW_ELEMENT),h=[];for(;l.nextNode();){const f=l.currentNode,m=f.tagName.toLowerCase();if(De.has(m)){h.push(f);continue}if(!i.has(m)){h.push(f);continue}const v=[];for(const g of Array.from(f.attributes)){const b=g.name.toLowerCase();if(!zt(b,o,s)){v.push(g.name);continue}if((b==="id"||b==="name")&&!Bt(g.value)){v.push(g.name);continue}if((b==="href"||b==="src"||b==="action")&&!qe(g.value)){v.push(g.name);continue}b==="srcset"&&!Ut(g.value)&&v.push(g.name)}for(const g of v)f.removeAttribute(g);if(m==="a"){const g=f.getAttribute("href"),b=f.getAttribute("target")?.toLowerCase()==="_blank",A=g&&xt(g);if(b||A){const D=f.getAttribute("rel"),L=new Set(D?D.split(/\s+/).filter(Boolean):[]);L.add("noopener"),L.add("noreferrer"),f.setAttribute("rel",Array.from(L).join(" "))}}}for(const f of h)f.remove();const p=f=>{const m=document.createElement("div");return m.appendChild(f.cloneNode(!0)),m.innerHTML},y=p(c),u=p(je(y));return y!==u?c.textContent??"":u},Ie=1024,He=8192,Qt=(e=16)=>{if(!Number.isInteger(e)||e<1)throw new RangeError("generateNonce length must be a positive integer");if(e>Ie)throw new RangeError(`generateNonce length must not exceed ${Ie}`);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+=He){const s=t.subarray(n,Math.min(n+He,t.length));r+=String.fromCharCode(...s)}return globalThis.btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")},Vt=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},re=null,ze=!1,Kt=()=>typeof window<"u"&&typeof window.trustedTypes<"u",Be=()=>{if(re)return re;if(ze||typeof window>"u")return null;const e=window;if(!e.trustedTypes)return null;ze=!0;try{return re=e.trustedTypes.createPolicy(_e,{createHTML:t=>te(t)}),re}catch(t){const r=t instanceof Error?t.message:String(t);return console.warn(`bQuery: Could not create Trusted Types policy "${_e}": ${r}`),null}},Jt=e=>{const t=Be();return t?t.createHTML(e):te(e)},j=(e,t={})=>te(e,t),Fe=e=>{const t={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","`":"&#x60;"};return e.replace(/[&<>"'`]/g,r=>t[r])},Gt=e=>te(e,{stripAllTags:!0}),Ue=e=>Array.isArray(e)?e:[e],S=(e,t)=>{for(const r of e)t(r)},xe=e=>j(e),Yt=(e,t)=>{e.innerHTML=j(t)},We=e=>{const t=document.createElement("template");return t.innerHTML=j(e),t.content.firstElementChild??document.createElement("div")},Qe=(e,t,r)=>{if(typeof t=="string"){e.insertAdjacentHTML(r,j(t));return}const n=Ue(t);S(r==="afterbegin"||r==="afterend"?n.slice().reverse():n,s=>{e.insertAdjacentElement(r,s)})},F=class Ne{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 Yt(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"?We(t):t;return this.element.replaceWith(r),new Ne(r)}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 Ne(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}`,a=i=>{const o=i.target.closest(r);o&&this.element.contains(o)&&n(i,o)};return this.delegatedHandlers.has(s)||this.delegatedHandlers.set(s,new Map),this.delegatedHandlers.get(s).set(n,a),this.element.addEventListener(t,a),this}undelegate(t,r,n){const s=`${t}:${r}`,a=this.delegatedHandlers.get(s);if(a){const i=a.get(n);i&&(this.element.removeEventListener(t,i),a.delete(n),a.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={},n=new FormData(t);for(const[s,a]of n.entries())if(typeof a=="string")if(s in r){const i=r[s];Array.isArray(i)?i.push(a):r[s]=[i,a]}else r[s]=a;return r}serializeString(){const t=this.element;if(t.tagName.toLowerCase()!=="form")return"";const r=new FormData(t),n=new URLSearchParams;for(const[s,a]of r.entries())typeof a=="string"&&n.append(s,a);return n.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){Qe(this.element,t,r)}},ne=class ve{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 F(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 F(r),n)}),this}map(t){return this.elements.map(t)}filter(t){return new ve(this.elements.filter(t))}reduce(t,r){return this.elements.reduce(t,r)}toArray(){return this.elements.map(t=>new F(t))}addClass(...t){return S(this.elements,r=>r.classList.add(...t)),this}removeClass(...t){return S(this.elements,r=>r.classList.remove(...t)),this}toggleClass(t,r){return S(this.elements,n=>n.classList.toggle(t,r)),this}attr(t,r){return r===void 0?this.first()?.getAttribute(t)??"":(S(this.elements,n=>n.setAttribute(t,r)),this)}removeAttr(t){return S(this.elements,r=>r.removeAttribute(t)),this}toggleAttr(t,r){return S(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??"":(S(this.elements,r=>{r.textContent=t}),this)}html(t){if(t===void 0)return this.first()?.innerHTML??"";const r=xe(t);return S(this.elements,n=>{n.innerHTML=r}),this}htmlUnsafe(t){return S(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 S(this.elements,a=>{a.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 S(this.elements,n=>{for(const[s,a]of Object.entries(t))n.style.setProperty(s,a)}),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 a=typeof t=="string"?We(t):s===0?t:t.cloneNode(!0);n.replaceWith(a),r.push(a)}),new ve(r)}show(t=""){return S(this.elements,r=>{r.removeAttribute("hidden"),r.style.display=t}),this}hide(){return S(this.elements,t=>{t.style.display="none"}),this}on(t,r){return S(this.elements,n=>n.addEventListener(t,r)),this}once(t,r){return S(this.elements,n=>n.addEventListener(t,r,{once:!0})),this}off(t,r){return S(this.elements,n=>n.removeEventListener(t,r)),this}trigger(t,r){return S(this.elements,n=>{n.dispatchEvent(new CustomEvent(t,{detail:r,bubbles:!0,cancelable:!0}))}),this}delegate(t,r,n){const s=`${t}:${r}`;return S(this.elements,a=>{const i=c=>{const l=c.target.closest(r);l&&a.contains(l)&&n(c,l)};this.delegatedHandlers.has(a)||this.delegatedHandlers.set(a,new Map);const o=this.delegatedHandlers.get(a);o.has(s)||o.set(s,new Map),o.get(s).set(n,i),a.addEventListener(t,i)}),this}undelegate(t,r,n){const s=`${t}:${r}`;return S(this.elements,a=>{const i=this.delegatedHandlers.get(a);if(!i)return;const o=i.get(s);if(!o)return;const c=o.get(n);c&&(a.removeEventListener(t,c),o.delete(n),o.size===0&&i.delete(s),i.size===0&&this.delegatedHandlers.delete(a))}),this}find(t){const r=new Set,n=[];for(const s of this.elements){const a=s.querySelectorAll(t);for(let i=0;i<a.length;i++)r.has(a[i])||(r.add(a[i]),n.push(a[i]))}return new ve(n)}remove(){return S(this.elements,t=>t.remove()),this}empty(){return S(this.elements,t=>{t.innerHTML=""}),this}insertAll(t,r){if(typeof t=="string"){const s=xe(t);S(this.elements,a=>{a.insertAdjacentHTML(r,s)});return}const n=Ue(t);this.elements.forEach((s,a)=>{Qe(s,a===0?n:n.map(i=>i.cloneNode(!0)),r)})}},Zt=e=>{if(typeof e!="string")return new F(e);const t=document.querySelector(e);if(!t)throw new Error(`bQuery: element not found for selector "${e}"`);return new F(t)},Xt=e=>Array.isArray(e)?new ne(e):e instanceof NodeList?new ne(Array.from(e)):new ne(Array.from(document.querySelectorAll(e)));function er(e){return e==null?[]:Array.isArray(e)?e:[e]}function tr(e){return Array.from(new Set(e))}function rr(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 nr(e){return e.filter(Boolean)}function sr(e){const t=[];for(const r of e)Array.isArray(r)?t.push(...r):t.push(r);return t}function ar(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 ir(e,t){let r=0;return Object.assign((...n)=>{const s=Date.now();s-r>=t&&(r=s,e(...n))},{cancel:()=>{r=0}})}function or(e){let t=!1,r;return(...n)=>(t||(r=e(...n),t=!0),r)}function cr(){}function lr(e="bQuery"){return`${e}_${Math.random().toString(36).slice(2,9)}`}function ur(e){return new Promise(t=>setTimeout(t,e))}function fr(e,t){try{return JSON.parse(e)}catch{return t}}function dr(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 hr(e,t){return Math.floor(Math.random()*(t-e+1))+e}function mr(e,t,r){return Math.min(Math.max(e,t),r)}function pr(e,t,r,n=!0){return n?e>=t&&e<=r:e>t&&e<r}function yr(e,t=0){const r=typeof e=="number"?e:Number(e);return Number.isNaN(r)?t:r}function se(e){return Object.prototype.toString.call(e)==="[object Object]"}function gr(e){return e==="__proto__"||e==="constructor"||e==="prototype"}function vr(e){return typeof structuredClone=="function"?structuredClone(e):JSON.parse(JSON.stringify(e))}function ae(...e){const t={};for(const r of e)for(const[n,s]of Object.entries(r))gr(n)||(se(s)&&se(t[n])?t[n]=ae(t[n],s):t[n]=s);return t}function br(e,t){const r={};for(const n of t)n in e&&(r[n]=e[n]);return r}function wr(e,t){const r={...e};for(const n of t)delete r[n];return r}function Sr(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Ar(e){return e&&e.charAt(0).toUpperCase()+e.slice(1)}function Er(e){return e.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_]+/g,"-").toLowerCase()}function $r(e){return e.replace(/[-_\s]+(.)?/g,(t,r)=>r?r.toUpperCase():"").replace(/^[A-Z]/,t=>t.toLowerCase())}function kr(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 Cr(e){return e.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\w\s-]/g,"").trim().replace(/[\s_-]+/g,"-").toLowerCase()}function Pr(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Or(e){return typeof Element<"u"&&e instanceof Element}function Rr(e){return!!(e&&typeof e=="object"&&"elements"in e)}function Tr(e){return typeof e=="function"}function Lr(e){return typeof e=="string"}function Mr(e){return typeof e=="number"&&!Number.isNaN(e)}function Nr(e){return typeof e=="boolean"}function _r(e){return Array.isArray(e)}function Dr(e){return e instanceof Date}function qr(e){return!!(e&&(e instanceof Promise||typeof e=="object"&&"then"in e&&typeof e.then=="function"))}function jr(e){return typeof e=="object"&&e!==null}var Ir={clone:vr,merge:ae,pick:br,omit:wr,hasOwn:Sr,debounce:ar,throttle:ir,once:or,noop:cr,uid:lr,isElement:Or,isCollection:Rr,isEmpty:dr,isPlainObject:se,isFunction:Tr,isString:Lr,isNumber:Mr,isBoolean:Nr,isArray:_r,isDate:Dr,isPromise:qr,isObject:jr,parseJson:fr,sleep:ur,randomInt:hr,clamp:mr,inRange:pr,toNumber:yr,capitalize:Ar,toKebabCase:Er,toCamelCase:$r,truncate:kr,slugify:Cr,escapeRegExp:Pr,ensureArray:er,unique:tr,chunk:rr,compact:nr,flatten:sr},U=[],Y=0,be=new Set,ie=new WeakMap,we=(e,t)=>{U.push(e);try{return t()}finally{U.pop()}},Ve=()=>U[U.length-1],Hr=e=>{U.push(void 0);try{return e()}finally{U.pop()}},Ke=e=>{if(Y>0){be.add(e);return}e()},zr=()=>{for(const e of Array.from(be)){be.delete(e);try{e()}catch(t){console.error("bQuery reactive: Error in observer during batch flush",t)}}},Br=()=>{Y+=1},Fr=()=>{Y<=0||(Y-=1,Y===0&&zr())},Je=(e,t)=>{let r=ie.get(e);r||(r=new Set,ie.set(e,r)),r.add(t)},Ur=(e,t)=>{const r=ie.get(e);r&&r.delete(t)},oe=e=>{const t=ie.get(e);if(t){for(const r of t)r.unsubscribe(e);t.clear()}},ce=e=>{Br();try{e()}finally{Fr()}},Ge={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"}},Z=e=>{if(typeof Headers<"u"&&e instanceof Headers)return new Headers(e);if(Array.isArray(e))return e.map(t=>Z(t));if(se(e)){const t={};for(const[r,n]of Object.entries(e))t[r]=Z(n);return t}return e},Se=Z(Ge),xr=e=>(Se=Z(ae(Ge,Se,e)),I()),I=()=>Z(Se),Ae=class{constructor(e){this.compute=e,this.dirty=!0,this.subscribers=new Set,this.markDirty=()=>{this.dirty=!0;const t=Array.from(this.subscribers);for(const r of t)Ke(r)}}get value(){const e=Ve();return e&&(this.subscribers.add(e),Je(e,this)),this.dirty&&(this.dirty=!1,oe(this.markDirty),this.cachedValue=we(this.markDirty,this.compute)),this.cachedValue}peek(){return this.dirty&&(this.dirty=!1,oe(this.markDirty),this.cachedValue=we(this.markDirty,this.compute)),this.cachedValue}unsubscribe(e){this.subscribers.delete(e)}},x=e=>new Ae(e),C=e=>{let t,r=!1;const n=()=>{if(t){try{t()}catch(a){console.error("bQuery reactive: Error in effect cleanup",a)}t=void 0}},s=()=>{if(!r){n(),oe(s);try{t=we(s,e)}catch(a){console.error("bQuery reactive: Error in effect",a)}}};return s(),()=>{r=!0,n(),oe(s)}},Ee=class{constructor(e){this._value=e,this.subscribers=new Set}get value(){const e=Ve();return e&&(this.subscribers.add(e),Je(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)Ke(r)}peek(){return this._value}update(e){this.value=e(this._value)}dispose(){for(const e of this.subscribers)Ur(e,this);this.subscribers.clear()}unsubscribe(e){this.subscribers.delete(e)}},T=e=>new Ee(e),le=e=>Hr(e),Wr=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))}},Qr=e=>typeof e=="function"?e():e.value,Ye=(...e)=>{const t=new Headers;for(const r of e)r&&new Headers(r).forEach((n,s)=>{t.set(s,n)});return t},Vr=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),Kr=(e,t)=>e==null||Vr(e)?e:(t.has("content-type")||t.set("content-type","application/json"),JSON.stringify(e)),Jr=e=>typeof e=="function"?e():e,Gr=(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))}},Yr=(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)},Zr=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)}`)}},$e=e=>{const t=e?.trim();return t?t.toUpperCase():void 0},Xr=(e,t,r)=>{const n=t instanceof Request?$e(t.method):void 0;return e??n??(r?"POST":void 0)},en=(e,t,r)=>e||(t instanceof Request?void 0:r),tn=e=>{const t=$e(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}},Ze=(e,t={})=>{const r=t.immediate??!0,n=T(t.defaultValue),s=T(null),a=T("idle"),i=x(()=>a.value==="pending");let o=0,c=!1,l=()=>{};const h=()=>{o+=1,n.value=t.defaultValue,s.value=null,a.value="idle"},p=()=>{c||(c=!0,o+=1,l())},y=async()=>{if(c)return n.peek();const u=++o;a.value="pending",s.value=null;try{const f=await e(),m=t.transform?t.transform(f):f;return c||u!==o?n.peek():(n.value=m,a.value="success",t.onSuccess?.(m),m)}catch(f){const m=Wr(f);return c||u!==o||(s.value=m,a.value="error",t.onError?.(m)),n.peek()}};if(t.watch?.length){let u=!1;l=C(()=>{for(const f of t.watch??[])Qr(f);if(!u){u=!0,r&&le(()=>y());return}le(()=>y())})}else r&&y();return{data:n,error:s,status:a,pending:i,execute:y,refresh:y,clear:h,dispose:p}},Xe=(e,t={})=>{const r=I().fetch,n=t.parseAs??r?.parseAs??"json",s=t.fetcher??fetch;return Ze(async()=>{const a=Jr(e),i=typeof a=="string"||a instanceof URL?Yr(a,t.baseUrl??r?.baseUrl):a instanceof Request&&t.query?new URL(a.url):null;i&&t.query&&Gr(i,t.query);const o=Ye(r?.headers,a instanceof Request?a.headers:void 0,t.headers),c=t.body!=null,l=$e(t.method),h=Xr(l,a,c),p=h==="GET"||h==="HEAD"?h:null;if(c&&p)throw new Error(`Cannot send a request body with ${p} requests`);const y=en(l,a,h),u={...t,method:y,headers:o,body:Kr(t.body,o)};delete u.baseUrl,delete u.query,delete u.parseAs,delete u.fetcher,delete u.defaultValue,delete u.immediate,delete u.watch,delete u.transform,delete u.onSuccess,delete u.onError;let f=i??a;a instanceof Request&&i&&i.toString()!==a.url&&(f=new Request(i.toString(),tn(a)));const m=await s(f,u);if(!m.ok)throw Object.assign(new Error(`Request failed with status ${m.status}`),{response:m,status:m.status,statusText:m.statusText});return Zr(m,n)},t)};function rn(e={}){return(t,r={})=>{const n=e,s=ae({},n.query??{},r.query??{});return Xe(t,{...n,...r,headers:Ye(n.headers,r.headers),query:Object.keys(s).length>0?s:void 0})}}var nn=(e,t)=>{const r=x(e);return{get value(){return r.value},set value(n){t(n)},peek(){return r.peek()}}},sn=(e,t)=>{let r=!1,n=null;try{if(n=globalThis.localStorage,n){const i=`__bquery_test_${Math.random().toString(36).slice(2,9)}__`,o="__test__";try{n.setItem(i,o),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 a=T(s);return r&&n&&C(()=>{try{n.setItem(e,JSON.stringify(a.value))}catch{}}),a},an=e=>({get value(){return e.value},peek(){return e.peek()}}),ue=e=>e instanceof Ee,et=e=>e instanceof Ae,on=(e,t,r={})=>{const{immediate:n=!1,equals:s=Object.is}=r;let a,i=!0;return C(()=>{const o=e.value;if(i){i=!1,a=o,n&&t(o,void 0);return}s(o,a)||(t(o,a),a=o)})},cn=(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 a=r.prototype!==void 0&&r.prototype!==null,i=(a?Object.getOwnPropertyNames(r.prototype):[]).length>1,o=a&&r.prototype.constructor!==r,c=/^class\s/.test(Function.prototype.toString.call(r));if(i||o||c)try{return Reflect.construct(s,[e])}catch{return n(e)}try{const l=n(e);if(l===void 0&&a)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},ln=(e,t)=>{class r extends HTMLElement{constructor(){super(),this.state={...t.state??{}},this.props={},this.missingRequiredProps=new Set,this.hasMounted=!1,this.attachShadow({mode:"open"}),this.syncProps()}static get observedAttributes(){return Object.keys(t.props??{})}connectedCallback(){try{if(this.missingRequiredProps.size>0)return;this.mount()}catch(s){this.handleError(s)}}mount(){this.hasMounted||(t.beforeMount?.call(this),t.connected?.call(this),this.render(),this.hasMounted=!0)}disconnectedCallback(){try{t.disconnected?.call(this)}catch(s){this.handleError(s)}}attributeChangedCallback(s,a,i){try{this.syncProps(),this.hasMounted?this.render(!0):this.isConnected&&this.missingRequiredProps.size===0&&this.mount()}catch(o){this.handleError(o)}}handleError(s){t.onError?t.onError.call(this,s):console.error(`bQuery component error in <${e}>:`,s)}setState(s,a){this.state[s]=a,this.render(!0)}getState(s){return this.state[s]}syncProps(){const s=t.props??{};for(const[a,i]of Object.entries(s)){const o=this.getAttribute(a);let c;if(o==null?i.required&&i.default===void 0?(this.missingRequiredProps.add(a),c=void 0):c=i.default??void 0:(this.missingRequiredProps.has(a)&&this.missingRequiredProps.delete(a),c=cn(o,i)),i.validator&&c!==void 0&&!i.validator(c))throw new Error(`bQuery component: validation failed for prop "${a}" with value ${JSON.stringify(c)}`);this.props[a]=c}}render(s=!1){try{if(s&&t.beforeUpdate&&t.beforeUpdate.call(this,this.props)===!1)return;const a=(o,c)=>{this.dispatchEvent(new CustomEvent(o,{detail:c,bubbles:!0,composed:!0}))};if(!this.shadowRoot)return;const i=j(t.render({props:this.props,state:this.state,emit:a}),{allowTags:["slot"],allowAttributes:["part","disabled","checked","placeholder","value","rows","cols","readonly","required","maxlength","minlength","max","min","step","pattern","autocomplete","autofocus","for","multiple","selected","wrap"]});if(this.shadowRoot.innerHTML=i,t.styles){const o=document.createElement("style");o.textContent=t.styles,this.shadowRoot.prepend(o)}s&&t.updated?.call(this)}catch(a){this.handleError(a)}}}return r},W=(e,t)=>{const r=ln(e,t);customElements.get(e)||customElements.define(e,r)},Q=(e,...t)=>e.reduce((r,n,s)=>`${r}${n}${t[s]??""}`,""),un=(e,...t)=>{const r={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","`":"&#x60;"},n=s=>String(s??"").replace(/[&<>"'`]/g,a=>r[a]);return e.reduce((s,a,i)=>`${s}${a}${n(t[i])}`,"")},fe=`
1
+ var bQuery=(function(h){Object.defineProperty(h,Symbol.toStringTag,{value:"Module"});var De="bquery-sanitizer",zt=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"]),qe=new Set(["script","iframe","frame","frameset","object","embed","applet","link","meta","style","base","template","math","svg","foreignobject","noscript"]),Bt=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"]),Ut=new Set(["alt","class","dir","height","hidden","href","id","lang","loading","name","rel","role","src","srcset","tabindex","target","title","type","width","aria-*"]),Ft=["on","formaction","xlink:","xmlns:"],Wt=["javascript:","data:","vbscript:","file:"],Qt=(e,t,r)=>{const n=e.toLowerCase();for(const s of Ft)if(n.startsWith(s))return!1;return r&&n.startsWith("data-")||n.startsWith("aria-")?!0:t.has(n)},xt=e=>{const t=e.toLowerCase().trim();return!Bt.has(t)},Vt=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(),je=e=>{const t=Vt(e);for(const r of Wt)if(t.startsWith(r))return!1;return!0},Kt=e=>{const t=e.split(",");for(const r of t){const n=r.trim().split(/\s+/)[0];if(n&&!je(n))return!1}return!0},Jt=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}},Gt=e=>new DOMParser().parseFromString(e,"text/html"),Ie=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=Gt(t).body;if(!n)return r;for(;n.firstChild;)r.appendChild(n.firstChild);return r},re=(e,t={})=>{const{allowTags:r=[],allowAttributes:n=[],allowDataAttributes:s=!0,stripAllTags:a=!1}=t,i=new Set([...zt,...r.map(u=>u.toLowerCase())].filter(u=>!qe.has(u))),o=new Set([...Ut,...n.map(u=>u.toLowerCase())]),c=Ie(e);if(a)return c.textContent??"";const l=document.createTreeWalker(c,NodeFilter.SHOW_ELEMENT),d=[];for(;l.nextNode();){const u=l.currentNode,p=u.tagName.toLowerCase();if(qe.has(p)){d.push(u);continue}if(!i.has(p)){d.push(u);continue}const v=[];for(const g of Array.from(u.attributes)){const b=g.name.toLowerCase();if(!Qt(b,o,s)){v.push(g.name);continue}if((b==="id"||b==="name")&&!xt(g.value)){v.push(g.name);continue}if((b==="href"||b==="src"||b==="action")&&!je(g.value)){v.push(g.name);continue}b==="srcset"&&!Kt(g.value)&&v.push(g.name)}for(const g of v)u.removeAttribute(g);if(p==="a"){const g=u.getAttribute("href"),b=u.getAttribute("target")?.toLowerCase()==="_blank",E=g&&Jt(g);if(b||E){const D=u.getAttribute("rel"),P=new Set(D?D.split(/\s+/).filter(Boolean):[]);P.add("noopener"),P.add("noreferrer"),u.setAttribute("rel",Array.from(P).join(" "))}}}for(const u of d)u.remove();const m=u=>{const p=document.createElement("div");return p.appendChild(u.cloneNode(!0)),p.innerHTML},y=m(c),f=m(Ie(y));return y!==f?c.textContent??"":f},He=Symbol("bquery.trusted-html.brand"),be=Symbol("bquery.trusted-html"),ze=e=>e,Yt=e=>{const t=String(e);return Object.freeze({[He]:!0,[be]:t,toString:()=>t})},Zt=e=>typeof e=="object"&&e!==null&&He in e&&be in e,Xt=e=>e[be],Be=1024,Ue=8192,er=(e=16)=>{if(!Number.isInteger(e)||e<1)throw new RangeError("generateNonce length must be a positive integer");if(e>Be)throw new RangeError(`generateNonce length must not exceed ${Be}`);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+=Ue){const s=t.subarray(n,Math.min(n+Ue,t.length));r+=String.fromCharCode(...s)}return globalThis.btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")},tr=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},ne=null,Fe=!1,rr=()=>typeof window<"u"&&typeof window.trustedTypes<"u",We=()=>{if(ne)return ne;if(Fe||typeof window>"u")return null;const e=window;if(!e.trustedTypes)return null;Fe=!0;try{return ne=e.trustedTypes.createPolicy(De,{createHTML:t=>re(t)}),ne}catch(t){const r=t instanceof Error?t.message:String(t);return console.warn(`bQuery: Could not create Trusted Types policy "${De}": ${r}`),null}},nr=e=>{const t=We();return t?t.createHTML(e):re(e)},j=(e,t={})=>ze(re(e,t)),Qe=e=>{const t={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","`":"&#x60;"};return e.replace(/[&<>"'`]/g,r=>t[r])},sr=e=>re(e,{stripAllTags:!0}),xe=e=>Array.isArray(e)?e:[e],S=(e,t)=>{for(const r of e)t(r)},Ve=e=>j(e),ar=(e,t)=>{e.innerHTML=j(t)},Ke=e=>{const t=document.createElement("template");return t.innerHTML=j(e),t.content.firstElementChild??document.createElement("div")},Je=(e,t,r)=>{if(typeof t=="string"){e.insertAdjacentHTML(r,j(t));return}const n=xe(t);S(r==="afterbegin"||r==="afterend"?n.slice().reverse():n,s=>{e.insertAdjacentElement(r,s)})},U=class _e{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 ar(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"?Ke(t):t;return this.element.replaceWith(r),new _e(r)}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 _e(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}`,a=i=>{const o=i.target.closest(r);o&&this.element.contains(o)&&n(i,o)};return this.delegatedHandlers.has(s)||this.delegatedHandlers.set(s,new Map),this.delegatedHandlers.get(s).set(n,a),this.element.addEventListener(t,a),this}undelegate(t,r,n){const s=`${t}:${r}`,a=this.delegatedHandlers.get(s);if(a){const i=a.get(n);i&&(this.element.removeEventListener(t,i),a.delete(n),a.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={},n=new FormData(t);for(const[s,a]of n.entries())if(typeof a=="string")if(s in r){const i=r[s];Array.isArray(i)?i.push(a):r[s]=[i,a]}else r[s]=a;return r}serializeString(){const t=this.element;if(t.tagName.toLowerCase()!=="form")return"";const r=new FormData(t),n=new URLSearchParams;for(const[s,a]of r.entries())typeof a=="string"&&n.append(s,a);return n.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){Je(this.element,t,r)}},se=class ve{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 U(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 U(r),n)}),this}map(t){return this.elements.map(t)}filter(t){return new ve(this.elements.filter(t))}reduce(t,r){return this.elements.reduce(t,r)}toArray(){return this.elements.map(t=>new U(t))}addClass(...t){return S(this.elements,r=>r.classList.add(...t)),this}removeClass(...t){return S(this.elements,r=>r.classList.remove(...t)),this}toggleClass(t,r){return S(this.elements,n=>n.classList.toggle(t,r)),this}attr(t,r){return r===void 0?this.first()?.getAttribute(t)??"":(S(this.elements,n=>n.setAttribute(t,r)),this)}removeAttr(t){return S(this.elements,r=>r.removeAttribute(t)),this}toggleAttr(t,r){return S(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??"":(S(this.elements,r=>{r.textContent=t}),this)}html(t){if(t===void 0)return this.first()?.innerHTML??"";const r=Ve(t);return S(this.elements,n=>{n.innerHTML=r}),this}htmlUnsafe(t){return S(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 S(this.elements,a=>{a.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 S(this.elements,n=>{for(const[s,a]of Object.entries(t))n.style.setProperty(s,a)}),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 a=typeof t=="string"?Ke(t):s===0?t:t.cloneNode(!0);n.replaceWith(a),r.push(a)}),new ve(r)}show(t=""){return S(this.elements,r=>{r.removeAttribute("hidden"),r.style.display=t}),this}hide(){return S(this.elements,t=>{t.style.display="none"}),this}on(t,r){return S(this.elements,n=>n.addEventListener(t,r)),this}once(t,r){return S(this.elements,n=>n.addEventListener(t,r,{once:!0})),this}off(t,r){return S(this.elements,n=>n.removeEventListener(t,r)),this}trigger(t,r){return S(this.elements,n=>{n.dispatchEvent(new CustomEvent(t,{detail:r,bubbles:!0,cancelable:!0}))}),this}delegate(t,r,n){const s=`${t}:${r}`;return S(this.elements,a=>{const i=c=>{const l=c.target.closest(r);l&&a.contains(l)&&n(c,l)};this.delegatedHandlers.has(a)||this.delegatedHandlers.set(a,new Map);const o=this.delegatedHandlers.get(a);o.has(s)||o.set(s,new Map),o.get(s).set(n,i),a.addEventListener(t,i)}),this}undelegate(t,r,n){const s=`${t}:${r}`;return S(this.elements,a=>{const i=this.delegatedHandlers.get(a);if(!i)return;const o=i.get(s);if(!o)return;const c=o.get(n);c&&(a.removeEventListener(t,c),o.delete(n),o.size===0&&i.delete(s),i.size===0&&this.delegatedHandlers.delete(a))}),this}find(t){const r=new Set,n=[];for(const s of this.elements){const a=s.querySelectorAll(t);for(let i=0;i<a.length;i++)r.has(a[i])||(r.add(a[i]),n.push(a[i]))}return new ve(n)}remove(){return S(this.elements,t=>t.remove()),this}empty(){return S(this.elements,t=>{t.innerHTML=""}),this}insertAll(t,r){if(typeof t=="string"){const s=Ve(t);S(this.elements,a=>{a.insertAdjacentHTML(r,s)});return}const n=xe(t);this.elements.forEach((s,a)=>{Je(s,a===0?n:n.map(i=>i.cloneNode(!0)),r)})}},ir=e=>{if(typeof e!="string")return new U(e);const t=document.querySelector(e);if(!t)throw new Error(`bQuery: element not found for selector "${e}"`);return new U(t)},or=e=>Array.isArray(e)?new se(e):e instanceof NodeList?new se(Array.from(e)):new se(Array.from(document.querySelectorAll(e)));function cr(e){return e==null?[]:Array.isArray(e)?e:[e]}function lr(e){return Array.from(new Set(e))}function ur(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 fr(e){return e.filter(Boolean)}function dr(e){const t=[];for(const r of e)Array.isArray(r)?t.push(...r):t.push(r);return t}function hr(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 mr(e,t){let r=0;return Object.assign((...n)=>{const s=Date.now();s-r>=t&&(r=s,e(...n))},{cancel:()=>{r=0}})}function pr(e){let t=!1,r;return(...n)=>(t||(r=e(...n),t=!0),r)}function yr(){}function gr(e="bQuery"){return`${e}_${Math.random().toString(36).slice(2,9)}`}function vr(e){return new Promise(t=>setTimeout(t,e))}function br(e,t){try{return JSON.parse(e)}catch{return t}}function wr(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 Sr(e,t){return Math.floor(Math.random()*(t-e+1))+e}function Er(e,t,r){return Math.min(Math.max(e,t),r)}function Ar(e,t,r,n=!0){return n?e>=t&&e<=r:e>t&&e<r}function Cr(e,t=0){const r=typeof e=="number"?e:Number(e);return Number.isNaN(r)?t:r}function ae(e){return Object.prototype.toString.call(e)==="[object Object]"}function $r(e){return e==="__proto__"||e==="constructor"||e==="prototype"}function kr(e){return typeof structuredClone=="function"?structuredClone(e):JSON.parse(JSON.stringify(e))}function ie(...e){const t={};for(const r of e)for(const[n,s]of Object.entries(r))$r(n)||(ae(s)&&ae(t[n])?t[n]=ie(t[n],s):t[n]=s);return t}function Or(e,t){const r={};for(const n of t)n in e&&(r[n]=e[n]);return r}function Tr(e,t){const r={...e};for(const n of t)delete r[n];return r}function Rr(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Mr(e){return e&&e.charAt(0).toUpperCase()+e.slice(1)}function Pr(e){return e.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_]+/g,"-").toLowerCase()}function Lr(e){return e.replace(/[-_\s]+(.)?/g,(t,r)=>r?r.toUpperCase():"").replace(/^[A-Z]/,t=>t.toLowerCase())}function Nr(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 _r(e){return e.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\w\s-]/g,"").trim().replace(/[\s_-]+/g,"-").toLowerCase()}function Dr(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function qr(e){return typeof Element<"u"&&e instanceof Element}function jr(e){return!!(e&&typeof e=="object"&&"elements"in e)}function Ir(e){return typeof e=="function"}function Hr(e){return typeof e=="string"}function zr(e){return typeof e=="number"&&!Number.isNaN(e)}function Br(e){return typeof e=="boolean"}function Ur(e){return Array.isArray(e)}function Fr(e){return e instanceof Date}function Wr(e){return!!(e&&(e instanceof Promise||typeof e=="object"&&"then"in e&&typeof e.then=="function"))}function Qr(e){return typeof e=="object"&&e!==null}var xr={clone:kr,merge:ie,pick:Or,omit:Tr,hasOwn:Rr,debounce:hr,throttle:mr,once:pr,noop:yr,uid:gr,isElement:qr,isCollection:jr,isEmpty:wr,isPlainObject:ae,isFunction:Ir,isString:Hr,isNumber:zr,isBoolean:Br,isArray:Ur,isDate:Fr,isPromise:Wr,isObject:Qr,parseJson:br,sleep:vr,randomInt:Sr,clamp:Er,inRange:Ar,toNumber:Cr,capitalize:Mr,toKebabCase:Pr,toCamelCase:Lr,truncate:Nr,slugify:_r,escapeRegExp:Dr,ensureArray:cr,unique:lr,chunk:ur,compact:fr,flatten:dr},F=[],Z=0,we=new Set,oe=new WeakMap,Se=(e,t)=>{F.push(e);try{return t()}finally{F.pop()}},Ge=()=>F[F.length-1],Vr=e=>{F.push(void 0);try{return e()}finally{F.pop()}},Ye=e=>{if(Z>0){we.add(e);return}e()},Kr=()=>{for(const e of Array.from(we)){we.delete(e);try{e()}catch(t){console.error("bQuery reactive: Error in observer during batch flush",t)}}},Jr=()=>{Z+=1},Gr=()=>{Z<=0||(Z-=1,Z===0&&Kr())},Ze=(e,t)=>{let r=oe.get(e);r||(r=new Set,oe.set(e,r)),r.add(t)},Yr=(e,t)=>{const r=oe.get(e);r&&r.delete(t)},ce=e=>{const t=oe.get(e);if(t){for(const r of t)r.unsubscribe(e);t.clear()}},le=e=>{Jr();try{e()}finally{Gr()}},Xe={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"}},X=e=>{if(typeof Headers<"u"&&e instanceof Headers)return new Headers(e);if(Array.isArray(e))return e.map(t=>X(t));if(ae(e)){const t={};for(const[r,n]of Object.entries(e))t[r]=X(n);return t}return e},Ee=X(Xe),Zr=e=>(Ee=X(ie(Xe,Ee,e)),I()),I=()=>X(Ee),Ae=class{constructor(e){this.compute=e,this.dirty=!0,this.subscribers=new Set,this.markDirty=()=>{this.dirty=!0;const t=Array.from(this.subscribers);for(const r of t)Ye(r)}}get value(){const e=Ge();return e&&(this.subscribers.add(e),Ze(e,this)),this.dirty&&(this.dirty=!1,ce(this.markDirty),this.cachedValue=Se(this.markDirty,this.compute)),this.cachedValue}peek(){return this.dirty&&(this.dirty=!1,ce(this.markDirty),this.cachedValue=Se(this.markDirty,this.compute)),this.cachedValue}unsubscribe(e){this.subscribers.delete(e)}},W=e=>new Ae(e),$=e=>{let t,r=!1;const n=()=>{if(t){try{t()}catch(a){console.error("bQuery reactive: Error in effect cleanup",a)}t=void 0}},s=()=>{if(!r){n(),ce(s);try{t=Se(s,e)}catch(a){console.error("bQuery reactive: Error in effect",a)}}};return s(),()=>{r=!0,n(),ce(s)}},Ce=class{constructor(e){this._value=e,this.subscribers=new Set}get value(){const e=Ge();return e&&(this.subscribers.add(e),Ze(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)Ye(r)}peek(){return this._value}update(e){this.value=e(this._value)}dispose(){for(const e of this.subscribers)Yr(e,this);this.subscribers.clear()}unsubscribe(e){this.subscribers.delete(e)}},M=e=>new Ce(e),Q=e=>Vr(e),Xr=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))}},en=e=>typeof e=="function"?e():e.value,et=(...e)=>{const t=new Headers;for(const r of e)r&&new Headers(r).forEach((n,s)=>{t.set(s,n)});return t},tn=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),rn=(e,t)=>e==null||tn(e)?e:(t.has("content-type")||t.set("content-type","application/json"),JSON.stringify(e)),nn=e=>typeof e=="function"?e():e,sn=(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))}},an=(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)},on=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)}`)}},$e=e=>{const t=e?.trim();return t?t.toUpperCase():void 0},cn=(e,t,r)=>{const n=t instanceof Request?$e(t.method):void 0;return e??n??(r?"POST":void 0)},ln=(e,t,r)=>e||(t instanceof Request?void 0:r),un=e=>{const t=$e(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}},tt=(e,t={})=>{const r=t.immediate??!0,n=M(t.defaultValue),s=M(null),a=M("idle"),i=W(()=>a.value==="pending");let o=0,c=!1,l=()=>{};const d=()=>{o+=1,n.value=t.defaultValue,s.value=null,a.value="idle"},m=()=>{c||(c=!0,o+=1,l())},y=async()=>{if(c)return n.peek();const f=++o;a.value="pending",s.value=null;try{const u=await e(),p=t.transform?t.transform(u):u;return c||f!==o?n.peek():(n.value=p,a.value="success",t.onSuccess?.(p),p)}catch(u){const p=Xr(u);return c||f!==o||(s.value=p,a.value="error",t.onError?.(p)),n.peek()}};if(t.watch?.length){let f=!1;l=$(()=>{for(const u of t.watch??[])en(u);if(!f){f=!0,r&&Q(()=>y());return}Q(()=>y())})}else r&&y();return{data:n,error:s,status:a,pending:i,execute:y,refresh:y,clear:d,dispose:m}},rt=(e,t={})=>{const r=I().fetch,n=t.parseAs??r?.parseAs??"json",s=t.fetcher??fetch;return tt(async()=>{const a=nn(e),i=typeof a=="string"||a instanceof URL?an(a,t.baseUrl??r?.baseUrl):a instanceof Request&&t.query?new URL(a.url):null;i&&t.query&&sn(i,t.query);const o=et(r?.headers,a instanceof Request?a.headers:void 0,t.headers),c=t.body!=null,l=$e(t.method),d=cn(l,a,c),m=d==="GET"||d==="HEAD"?d:null;if(c&&m)throw new Error(`Cannot send a request body with ${m} requests`);const y=ln(l,a,d),f={...t,method:y,headers:o,body:rn(t.body,o)};delete f.baseUrl,delete f.query,delete f.parseAs,delete f.fetcher,delete f.defaultValue,delete f.immediate,delete f.watch,delete f.transform,delete f.onSuccess,delete f.onError;let u=i??a;a instanceof Request&&i&&i.toString()!==a.url&&(u=new Request(i.toString(),un(a)));const p=await s(u,f);if(!p.ok)throw Object.assign(new Error(`Request failed with status ${p.status}`),{response:p,status:p.status,statusText:p.statusText});return on(p,n)},t)};function fn(e={}){return(t,r={})=>{const n=e,s=ie({},n.query??{},r.query??{});return rt(t,{...n,...r,headers:et(n.headers,r.headers),query:Object.keys(s).length>0?s:void 0})}}var dn=(e,t)=>{const r=W(e);return{get value(){return r.value},set value(n){t(n)},peek(){return r.peek()}}},hn=(e,t)=>{let r=!1,n=null;try{if(n=globalThis.localStorage,n){const i=`__bquery_test_${Math.random().toString(36).slice(2,9)}__`,o="__test__";try{n.setItem(i,o),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 a=M(s);return r&&n&&$(()=>{try{n.setItem(e,JSON.stringify(a.value))}catch{}}),a},mn=e=>({get value(){return e.value},peek(){return e.peek()}}),ue=e=>e instanceof Ce,nt=e=>e instanceof Ae,pn=(e,t,r={})=>{const{immediate:n=!1,equals:s=Object.is}=r;let a,i=!0;return $(()=>{const o=e.value;if(i){i=!1,a=o,n&&t(o,void 0);return}s(o,a)||(t(o,a),a=o)})},yn=(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 a=r.prototype!==void 0&&r.prototype!==null,i=(a?Object.getOwnPropertyNames(r.prototype):[]).length>1,o=a&&r.prototype.constructor!==r,c=/^class\s/.test(Function.prototype.toString.call(r));if(i||o||c)try{return Reflect.construct(s,[e])}catch{return n(e)}try{const l=n(e);if(l===void 0&&a)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},gn=["slot"],vn=["part","disabled","checked","placeholder","value","rows","cols","readonly","required","maxlength","minlength","max","min","step","pattern","autocomplete","autofocus","for","multiple","selected","wrap"],bn=(e,t)=>{const r=[...gn,...t.sanitize?.allowTags??[]],n=[...vn,...t.sanitize?.allowAttributes??[]],s=Object.values(t.signals??{});class a extends HTMLElement{constructor(){super(),this.state={...t.state??{}},this.props={},this.missingRequiredProps=new Set,this.hasMounted=!1,this.attachShadow({mode:"open"}),this.syncProps()}static get observedAttributes(){return Object.keys(t.props??{})}connectedCallback(){try{if(!this.hasMounted&&this.missingRequiredProps.size>0)return;if(this.hasMounted){try{t.connected?.call(this)}catch(o){this.handleError(o)}this.setupSignalSubscriptions(!0);return}this.mount()}catch(o){this.handleError(o)}}mount(){this.hasMounted||(t.beforeMount?.call(this),t.connected?.call(this),this.render(),this.setupSignalSubscriptions(),this.hasMounted=!0)}disconnectedCallback(){try{this.signalEffectCleanup?.(),this.signalEffectCleanup=void 0,t.disconnected?.call(this)}catch(o){this.handleError(o)}}attributeChangedCallback(o,c,l){try{const d=this.cloneProps();this.syncProps(),this.hasMounted?this.render(!0,d,{name:o,oldValue:c,newValue:l}):this.isConnected&&this.missingRequiredProps.size===0&&this.mount()}catch(d){this.handleError(d)}}handleError(o){t.onError?t.onError.call(this,o):console.error(`bQuery component error in <${e}>:`,o)}setState(o,c){this.state[o]=c,this.render(!0,this.cloneProps(),void 0,!1)}getState(o){return this.state[o]}setupSignalSubscriptions(o=!1){if(this.signalEffectCleanup||s.length===0)return;let c=!0;this.signalEffectCleanup=$(()=>{try{for(const d of s)d.value;if(c){if(c=!1,o&&this.hasMounted&&this.isConnected){const d=this.cloneProps();Q(()=>{this.render(!0,d,void 0,!1)})}return}if(!this.hasMounted||!this.isConnected)return;const l=this.cloneProps();Q(()=>{this.render(!0,l,void 0,!1)})}catch(l){this.handleError(l)}})}syncProps(){const o=t.props??{};for(const[c,l]of Object.entries(o)){const d=this.getAttribute(c);let m;if(d==null?l.required&&l.default===void 0?(this.missingRequiredProps.add(c),m=void 0):m=l.default??void 0:(this.missingRequiredProps.has(c)&&this.missingRequiredProps.delete(c),m=yn(d,l)),l.validator&&m!==void 0&&!l.validator(m))throw new Error(`bQuery component: validation failed for prop "${c}" with value ${JSON.stringify(m)}`);this.props[c]=m}}cloneProps(){return{...this.props}}render(o=!1,c,l,d=!0){try{if(o&&d&&t.beforeUpdate){if(!c)throw new Error("bQuery component: previous props are required for update renders");if(t.beforeUpdate.call(this,this.props,c)===!1)return}const m=(u,p)=>{this.dispatchEvent(new CustomEvent(u,{detail:p,bubbles:!0,composed:!0}))};if(!this.shadowRoot)return;const y=j(t.render({props:this.props,state:this.state,signals:t.signals??{},emit:m}),{allowTags:r,allowAttributes:n});let f=null;if(t.styles&&(f=this.shadowRoot.querySelector("style[data-bquery-component-style]")),this.shadowRoot.innerHTML=y,t.styles){const u=f??document.createElement("style");f||u.setAttribute("data-bquery-component-style",""),u.textContent=t.styles,this.shadowRoot.prepend(u)}o&&t.updated?.call(this,l)}catch(m){this.handleError(m)}}}return a};function x(e,t){const r=bn(e,t);customElements.get(e)||customElements.define(e,r)}var st=Symbol("bquery.booleanAttribute"),wn=/^[^\0-\x20"'/>=]+$/,at=e=>{if(typeof e!="object"||e===null)return!1;const t=e;return t[st]===!0&&typeof t.enabled=="boolean"&&typeof t.name=="string"},it=e=>at(e)?e.enabled?e.name:"":String(e??""),Sn={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","`":"&#x60;"},En=e=>at(e)?e.enabled?e.name:"":it(e).replace(/[&<>"'`]/g,t=>Sn[t]),An=(e,t)=>{if(!wn.test(e))throw new TypeError(`Invalid boolean attribute name: ${e}`);const r={[st]:!0,enabled:!!t,name:e};return Object.freeze(r)},V=(e,...t)=>e.reduce((r,n,s)=>`${r}${n}${it(t[s])}`,""),Cn=(e,...t)=>{const r=n=>Zt(n)?Xt(n):En(n);return ze(e.reduce((n,s,a)=>`${n}${s}${a<t.length?r(t[a]):""}`,""))},fe=`
2
2
  :host {
3
3
  color: inherit;
4
4
  font: inherit;
5
5
  }
6
- `,tt=`
6
+ `,ot=`
7
7
  ${fe}
8
8
  .field {
9
9
  display: inline-flex;
@@ -38,7 +38,7 @@ var bQuery=(function(d){Object.defineProperty(d,Symbol.toStringTag,{value:"Modul
38
38
  color: #94a3b8;
39
39
  cursor: not-allowed;
40
40
  }
41
- `,k=e=>Fe(e),ke=new WeakMap,Ce=(e,t)=>ke.get(e)?.[t],Pe=(e,t,r)=>{const n=ke.get(e)??{};n[t]=r,ke.set(e,n)},rt=e=>e.shadowRoot?.querySelector(".label")?.textContent??"",fn=(e,t)=>{const r=e.shadowRoot?.querySelector("input.control");return!r||rt(e)!==t.label||(r.getAttribute("type")??"text")!==t.type||(r.getAttribute("placeholder")??"")!==t.placeholder||(r.getAttribute("name")??"")!==t.name||r.disabled!==t.disabled?!1:(r.value!==t.value&&(r.value=t.value),!0)},dn=(e,t)=>{const r=e.shadowRoot?.querySelector("textarea.control");return!r||rt(e)!==t.label||(r.getAttribute("placeholder")??"")!==t.placeholder||(r.getAttribute("name")??"")!==t.name||r.getAttribute("rows")!==String(t.rows)||r.disabled!==t.disabled?!1:(r.value!==t.value&&(r.value=t.value),!0)},hn=e=>["<textarea",' part="control"',' class="control"',` placeholder="${k(e.placeholder)}"`,` name="${k(e.name)}"`,` rows="${e.rows}"`,e.disabled?" disabled":"",`>${k(e.value)}</textarea>`].join(""),mn=(e={})=>{const t=e.prefix??I().components?.prefix??"bq",r={button:`${t}-button`,card:`${t}-card`,input:`${t}-input`,textarea:`${t}-textarea`,checkbox:`${t}-checkbox`};return W(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:`
41
+ `,k=e=>Qe(e),ke=new WeakMap,Oe=(e,t)=>ke.get(e)?.[t],Te=(e,t,r)=>{const n=ke.get(e)??{};n[t]=r,ke.set(e,n)},$n=(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?.querySelector("input.control");return n?(n.value!==t.value&&(n.value=t.value),!0):!1},kn=(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?.querySelector("textarea.control");return n?(n.value!==t.value&&(n.value=t.value),!0):!1},On=e=>["<textarea",' part="control"',' class="control"',` placeholder="${k(e.placeholder)}"`,` name="${k(e.name)}"`,` rows="${e.rows}"`,e.disabled?" disabled":"",`>${k(e.value)}</textarea>`].join(""),Tn=(e={})=>{const t=e.prefix??I().components?.prefix??"bq",r={button:`${t}-button`,card:`${t}-card`,input:`${t}-input`,textarea:`${t}-textarea`,checkbox:`${t}-checkbox`};return x(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:`
42
42
  ${fe}
43
43
  button {
44
44
  appearance: none;
@@ -76,7 +76,7 @@ var bQuery=(function(d){Object.defineProperty(d,Symbol.toStringTag,{value:"Modul
76
76
  cursor: not-allowed;
77
77
  opacity: 0.6;
78
78
  }
79
- `,render:({props:n})=>Q`
79
+ `,render:({props:n})=>V`
80
80
  <button
81
81
  part="button"
82
82
  type="${k(n.type)}"
@@ -86,7 +86,7 @@ var bQuery=(function(d){Object.defineProperty(d,Symbol.toStringTag,{value:"Modul
86
86
  >
87
87
  <slot>${k(n.label)}</slot>
88
88
  </button>
89
- `}),W(r.card,{props:{title:{type:String,default:""},footer:{type:String,default:""},elevated:{type:Boolean,default:!0}},styles:`
89
+ `}),x(r.card,{props:{title:{type:String,default:""},footer:{type:String,default:""},elevated:{type:Boolean,default:!0}},styles:`
90
90
  ${fe}
91
91
  article {
92
92
  background: #fff;
@@ -111,13 +111,13 @@ var bQuery=(function(d){Object.defineProperty(d,Symbol.toStringTag,{value:"Modul
111
111
  footer {
112
112
  margin-top: 0.75rem;
113
113
  }
114
- `,render:({props:n})=>Q`
114
+ `,render:({props:n})=>V`
115
115
  <article part="card" data-elevated="${String(n.elevated)}">
116
116
  ${n.title?`<header part="header">${k(n.title)}</header>`:""}
117
117
  <section part="body"><slot></slot></section>
118
118
  ${n.footer?`<footer part="footer">${k(n.footer)}</footer>`:""}
119
119
  </article>
120
- `}),W(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:tt,beforeUpdate(n){return!fn(this,n)},connected(){const n=s=>{const a=s.target;a?.matches("input")&&(s.stopPropagation(),this.setAttribute("value",a.value),this.dispatchEvent(new CustomEvent("input",{detail:{value:a.value},bubbles:!0,composed:!0})))};Pe(this,"__bqueryInputHandler",n),this.shadowRoot?.addEventListener("input",n)},disconnected(){const n=Ce(this,"__bqueryInputHandler");n&&this.shadowRoot?.removeEventListener("input",n)},render:({props:n})=>Q`
120
+ `}),x(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:ot,beforeUpdate(n,s){return!$n(this,n,s)},connected(){const n=s=>{const a=s.target;a?.matches("input")&&(s.stopPropagation(),this.setAttribute("value",a.value),this.dispatchEvent(new CustomEvent("input",{detail:{value:a.value},bubbles:!0,composed:!0})))};Te(this,"__bqueryInputHandler",n),this.shadowRoot?.addEventListener("input",n)},disconnected(){const n=Oe(this,"__bqueryInputHandler");n&&this.shadowRoot?.removeEventListener("input",n)},render:({props:n})=>V`
121
121
  <label part="field" class="field">
122
122
  ${n.label?`<span part="label" class="label">${k(n.label)}</span>`:""}
123
123
  <input
@@ -130,17 +130,17 @@ var bQuery=(function(d){Object.defineProperty(d,Symbol.toStringTag,{value:"Modul
130
130
  ${n.disabled?"disabled":""}
131
131
  />
132
132
  </label>
133
- `}),W(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:`${tt}
133
+ `}),x(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:`${ot}
134
134
  textarea.control {
135
135
  min-height: 6rem;
136
136
  resize: vertical;
137
137
  }
138
- `,beforeUpdate(n){return!dn(this,n)},connected(){const n=s=>{const a=s.target;a?.matches("textarea")&&(s.stopPropagation(),this.setAttribute("value",a.value),this.dispatchEvent(new CustomEvent("input",{detail:{value:a.value},bubbles:!0,composed:!0})))};Pe(this,"__bqueryTextareaHandler",n),this.shadowRoot?.addEventListener("input",n)},disconnected(){const n=Ce(this,"__bqueryTextareaHandler");n&&this.shadowRoot?.removeEventListener("input",n)},render:({props:n})=>Q`
138
+ `,beforeUpdate(n,s){return!kn(this,n,s)},connected(){const n=s=>{const a=s.target;a?.matches("textarea")&&(s.stopPropagation(),this.setAttribute("value",a.value),this.dispatchEvent(new CustomEvent("input",{detail:{value:a.value},bubbles:!0,composed:!0})))};Te(this,"__bqueryTextareaHandler",n),this.shadowRoot?.addEventListener("input",n)},disconnected(){const n=Oe(this,"__bqueryTextareaHandler");n&&this.shadowRoot?.removeEventListener("input",n)},render:({props:n})=>V`
139
139
  <label part="field" class="field">
140
140
  ${n.label?`<span part="label" class="label">${k(n.label)}</span>`:""}
141
- ${hn(n)}
141
+ ${On(n)}
142
142
  </label>
143
- `}),W(r.checkbox,{props:{label:{type:String,default:""},checked:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1}},styles:`
143
+ `}),x(r.checkbox,{props:{label:{type:String,default:""},checked:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1}},styles:`
144
144
  ${fe}
145
145
  label {
146
146
  align-items: center;
@@ -157,7 +157,7 @@ var bQuery=(function(d){Object.defineProperty(d,Symbol.toStringTag,{value:"Modul
157
157
  input:disabled {
158
158
  cursor: not-allowed;
159
159
  }
160
- `,connected(){const n=s=>{const a=s.target;a?.matches('input[type="checkbox"]')&&(s.stopPropagation(),a.checked?this.setAttribute("checked","true"):this.removeAttribute("checked"),this.dispatchEvent(new CustomEvent("change",{detail:{checked:a.checked},bubbles:!0,composed:!0})))};Pe(this,"__bqueryCheckboxHandler",n),this.shadowRoot?.addEventListener("change",n)},disconnected(){const n=Ce(this,"__bqueryCheckboxHandler");n&&this.shadowRoot?.removeEventListener("change",n)},render:({props:n})=>Q`
160
+ `,connected(){const n=s=>{const a=s.target;a?.matches('input[type="checkbox"]')&&(s.stopPropagation(),a.checked?this.setAttribute("checked","true"):this.removeAttribute("checked"),this.dispatchEvent(new CustomEvent("change",{detail:{checked:a.checked},bubbles:!0,composed:!0})))};Te(this,"__bqueryCheckboxHandler",n),this.shadowRoot?.addEventListener("change",n)},disconnected(){const n=Oe(this,"__bqueryCheckboxHandler");n&&this.shadowRoot?.removeEventListener("change",n)},render:({props:n})=>V`
161
161
  <label part="label">
162
162
  <input
163
163
  part="control"
@@ -167,11 +167,11 @@ var bQuery=(function(d){Object.defineProperty(d,Symbol.toStringTag,{value:"Modul
167
167
  />
168
168
  <span part="text"><slot>${k(n.label)}</slot></span>
169
169
  </label>
170
- `}),r},de=()=>typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches,nt=e=>typeof e=="string"||typeof e=="number",st=e=>e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`),V=(e,t)=>{const r=e.style;if(Array.isArray(t)){const n=t[t.length-1];if(!n)return;for(const[s,a]of Object.entries(n))if(!(s==="offset"||s==="easing"||s==="composite")&&nt(a)){const i=s.startsWith("--")?s:st(s);r.setProperty(i,String(a))}return}for(const[n,s]of Object.entries(t)){if(n==="offset"||n==="easing"||n==="composite")continue;const a=Array.isArray(s)?s[s.length-1]:s;if(nt(a)){const i=n.startsWith("--")?n:st(n);r.setProperty(i,String(a))}}},he=(e,t)=>{const{keyframes:r,options:n,commitStyles:s=!0,respectReducedMotion:a=!0,onFinish:i}=t;if(a&&de())return s&&V(e,r),i?.(),Promise.resolve();const o=e;return typeof o.animate!="function"?(s&&V(e,r),i?.(),Promise.resolve()):new Promise(c=>{const l=o.animate(r,n);let h=!1;const p=()=>{h||(h=!0,s&&(typeof l.commitStyles=="function"?l.commitStyles():V(e,r)),l.cancel(),i?.(),c())};l.onfinish=p,l.finished&&l.finished.then(p).catch(p)})},_=e=>Math.min(1,Math.max(0,e)),at=e=>_(e),it=e=>_(e*e),ot=e=>_(1-(1-e)*(1-e)),ct=e=>_(e<.5?2*e*e:1-Math.pow(-2*e+2,2)/2),lt=e=>_(e*e*e),ut=e=>_(1-Math.pow(1-e,3)),ft=e=>_(e<.5?4*e*e*e:1-Math.pow(-2*e+2,3)/2),dt=e=>_(1+(1.70158+1)*Math.pow(e-1,3)+1.70158*Math.pow(e-1,2)),ht=e=>_(e===1?1:1-Math.pow(2,-10*e)),pn={linear:at,easeInQuad:it,easeOutQuad:ot,easeInOutQuad:ct,easeInCubic:lt,easeOutCubic:ut,easeInOutCubic:ft,easeOutBack:dt,easeOutExpo:ht},Oe=e=>{const t=e.getBoundingClientRect();return{top:t.top,left:t.left,width:t.width,height:t.height}},Re=(e,t,r={})=>{const{duration:n=300,easing:s="ease-out",onComplete:a}=r,i=Oe(e);if(i.width===0||i.height===0)return a?.(),Promise.resolve();const o=t.left-i.left,c=t.top-i.top,l=t.width/i.width,h=t.height/i.height;if(o===0&&c===0&&l===1&&h===1)return a?.(),Promise.resolve();const p=e;return typeof p.animate!="function"?(a?.(),Promise.resolve()):(p.style.transform=`translate(${o}px, ${c}px) scale(${l}, ${h})`,p.style.transformOrigin="top left",p.offsetHeight,new Promise(y=>{const u=p.animate([{transform:`translate(${o}px, ${c}px) scale(${l}, ${h})`},{transform:"translate(0, 0) scale(1, 1)"}],{duration:n,easing:s,fill:"forwards"});let f=!1;const m=()=>{f||(f=!0,p.style.transform="",p.style.transformOrigin="",a?.(),y())};u.onfinish=m,u.finished&&u.finished.then(m).catch(m)}))},yn=async(e,t,r={})=>{await mt(e,t,r)},mt=async(e,t,r={})=>{const{stagger:n,...s}=r,a=new Map;for(const c of e)a.set(c,Oe(c));t();const i=e.length,o=e.map((c,l)=>{const h=a.get(c);if(!h)return Promise.resolve();const p=n?n(l,i):0;return p>0?new Promise(y=>setTimeout(y,p)).then(()=>Re(c,h,s)):Re(c,h,s)});await Promise.all(o)},gn={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)"}]},vn=e=>typeof Element<"u"&&e instanceof Element?[e]:Array.from(e),bn=(e,t)=>{const r=vn(e);if(!r.length)return()=>{};const{root:n=null,rootMargin:s,threshold:a,once:i=!0,onEnter:o,...c}=t;if(typeof IntersectionObserver>"u")return r.forEach(h=>{o?.(h),he(h,c)}),()=>{};const l=new IntersectionObserver(h=>{h.forEach(p=>{if(!p.isIntersecting)return;const y=p.target;o?.(y),he(y,c),i&&l.unobserve(y)})},{root:n,rootMargin:s,threshold:a});return r.forEach(h=>l.observe(h)),()=>l.disconnect()},wn={stiffness:100,damping:10,mass:1,precision:.01},Sn=(e,t={})=>{const{stiffness:r,damping:n,mass:s,precision:a}={...wn,...t};let i=e,o=0,c=e,l=null,h=null,p=null;const y=new Set,u=()=>{for(const m of y)m(i)},f=m=>{const v=p!==null?(m-p)/1e3:.016666666666666666,g=Math.min(v,1/30);p=m;const b=i-c,A=(-r*b+-n*o)/s;if(o+=A*g,i+=o*g,u(),Math.abs(o)<a&&Math.abs(b)<a){i=c,o=0,l=null,u(),h?.(),h=null;return}l=requestAnimationFrame(f)};return{to(m){return c=m,l!==null&&cancelAnimationFrame(l),h?.(),p=null,new Promise(v=>{h=v,l=requestAnimationFrame(f)})},current(){return i},stop(){l!==null&&(cancelAnimationFrame(l),l=null),o=0,p=null,h?.(),h=null},onChange(m){return y.add(m),()=>y.delete(m)}}},An={gentle:{stiffness:80,damping:15},snappy:{stiffness:200,damping:20},bouncy:{stiffness:300,damping:8},stiff:{stiffness:400,damping:30}},En=(e,t={})=>{const{start:r=0,from:n="start",easing:s}=t;return(a,i=0)=>{const o=typeof n=="number"?n:n==="center"?(i-1)/2:n==="end"?i-1:0,c=Math.abs(a-o),l=i>1?Math.max(o,i-1-o):1,h=l===0?0:c/l;return r+(s?s(h)*l:c)*e}},Te=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},$n=(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},kn=e=>{const t=Te(e?.duration),r=Te(e?.endDelay),n=e?.iterations??1;return n===1/0?Number.MAX_SAFE_INTEGER:t*Math.max(0,n)+r},pt=e=>{let t=0;return e.map(r=>{const n=$n(r.at,t),s=Te(r.options?.delay),a=Math.max(0,n+s),i=kn(r.options),o=a+i;return t=Math.max(t,o),{step:r,start:a,end:o,duration:i}})},Cn=async(e,t={})=>{const{stagger:r,onFinish:n}=t,s=e.length;for(let a=0;a<e.length;a+=1){const i=e[a],o=r?r(a,s):0;o>0&&await new Promise(c=>setTimeout(c,o)),await he(i.target,i)}n?.()},Pn=(e=[],t={})=>{const r=[...e],n=new Set;let s=[],a=0,i=!1,o=!1;const{commitStyles:c=!0,respectReducedMotion:l=!0,onFinish:h}=t,p=()=>{if(!o){if(o=!0,c)for(const u of s){const{animation:f,step:m}=u;typeof f.commitStyles=="function"?f.commitStyles():V(m.target,m.keyframes),f.cancel()}n.forEach(u=>u()),h?.()}},y=()=>{s.forEach(({animation:f})=>f.cancel()),s=[],o=!1;const u=pt(r);if(a=u.length?Math.max(...u.map(f=>f.end)):0,l&&de()){c&&u.forEach(({step:f})=>V(f.target,f.keyframes)),i=!0;return}if(u.some(({step:f})=>typeof f.target.animate!="function")){c&&u.forEach(({step:f})=>V(f.target,f.keyframes)),i=!0;return}i=!1,s=u.map(({step:f,start:m})=>{const{delay:v,...g}=f.options??{};return{animation:f.target.animate(f.keyframes,{...g,delay:m,fill:g.fill??"both"}),step:f,start:m}})};return{add(u){r.push(u)},duration(){if(!r.length)return 0;if(!s.length){const u=pt(r);return Math.max(...u.map(f=>f.end))}return a},async play(){if(y(),i||s.length===0){p();return}const u=s.map(f=>f.animation.finished.catch(()=>{}));await Promise.all(u),p()},pause(){i||s.forEach(({animation:u})=>u.pause())},resume(){i||s.forEach(({animation:u})=>u.play())},stop(){s.forEach(({animation:u})=>u.cancel()),s=[],i=!1},seek(u){i||s.forEach(({animation:f})=>{f.currentTime=u})},onFinish(u){return n.add(u),()=>n.delete(u)}}},yt=e=>(e??[]).map(t=>t.trim()).filter(t=>t.length>0),On=async e=>{const t=I().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,a=document.documentElement,i=yt(r.classes),o=yt(r.types);if(!s.startViewTransition||r.skipOnReducedMotion&&de()){await n(),r.onFinish?.();return}i.forEach(c=>a.classList.add(c));try{const c=s.startViewTransition(()=>n()),l=c.types;if(l)for(const h of o)l.add(h);await c.ready,r.onReady?.(),await c.finished,r.onFinish?.()}finally{i.forEach(c=>a.classList.remove(c))}},Rn=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 a=t(r.transaction(this.storeName,e).objectStore(this.storeName));a.onsuccess=()=>n(a.result),a.onerror=()=>s(a.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))}},Tn={async open(e){return new Rn(e)}},Ln=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)}},Mn={isSupported(){return"caches"in window},async open(e){if(!this.isSupported())throw new Error("bQuery: Cache Storage API not supported");return new Ln(await caches.open(e))},async delete(e){return this.isSupported()?caches.delete(e):!1},async keys(){return this.isSupported()?caches.keys():[]}},Nn=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 a=s.slice(t.length);try{return decodeURIComponent(a)}catch{return a}}}return null},_n=e=>{const t=e.trim();return t.startsWith("{")||t.startsWith("[")||t.startsWith('"')},Dn=(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("; ")},qn=(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("; ")},jn=(e,t={})=>{const r=I().cookies,n={path:r?.path??"/",sameSite:r?.sameSite??"Lax",secure:r?.secure??!1,watch:!0,...t};n.sameSite==="None"&&(n.secure=!0);const s=Nn(e);let a=n.defaultValue??null;if(s!==null)try{a=n.deserialize?n.deserialize(s):_n(s)?JSON.parse(s):s??a}catch(c){console.warn(`bQuery: Failed to deserialize cookie "${e}", using raw string value`,c),a=s??a}const i=T(a);if(typeof document>"u"||n.watch===!1)return i;let o=!1;return C(()=>{const c=i.value;if(!o){o=!0;return}if(c==null){Dn(e,n);return}qn(e,c,n)}),i},In={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)}},Hn=["position:absolute","width:1px","height:1px","padding:0","margin:-1px","overflow:hidden","clip:rect(0, 0, 0, 0)","white-space:nowrap","border:0"].join(";"),zn=(e={})=>{const t=I().announcer,r={politeness:t?.politeness??"polite",atomic:t?.atomic??!0,delay:t?.delay??16,clearDelay:t?.clearDelay??1e3,...e},n=T("");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,a=s??document.createElement("div"),i=!s;if(r.id&&(a.id=r.id),r.className&&(a.className=r.className),a.setAttribute("aria-live",r.politeness),a.setAttribute("aria-atomic",String(r.atomic)),a.setAttribute("role",r.politeness==="assertive"?"alert":"status"),a.setAttribute("data-bquery-announcer","true"),a.getAttribute("style")||a.setAttribute("style",Hn),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(a)}const o=C(()=>{a.textContent=n.value});let c,l,h=!1;const p=()=>{c&&(clearTimeout(c),c=void 0),l&&(clearTimeout(l),l=void 0)};return{element:a,message:n,announce:(m,v={})=>{if(h)return;const g=v.politeness??r.politeness,b=v.delay??r.delay,A=v.clearDelay??r.clearDelay;p(),a.setAttribute("aria-live",g),a.setAttribute("role",g==="assertive"?"alert":"status"),n.value="",c=setTimeout(()=>{h||(n.value=m,A>0&&(l=setTimeout(()=>{h||(n.value="")},A)))},b)},clear:()=>{h||(p(),n.value="")},destroy:()=>{h||(h=!0,p(),n.value="",o(),i&&a.remove())}}},gt=(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)}},vt=(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},Bn=e=>{if(typeof document>"u")return()=>{};const t=I().pageMeta,r=e.title?t?.titleTemplate?t.titleTemplate(e.title):e.title:void 0,n=[],s=[],a=document.title;r!==void 0&&(document.title=r);const i=[...e.meta??[]];e.description&&i.unshift({name:"description",content:e.description});for(const o of i){const c=vt("meta",{name:o.name,property:o.property,"http-equiv":o.httpEquiv,content:o.content});document.head.appendChild(c),n.push(c)}for(const o of e.link??[]){const c=vt("link",{rel:o.rel,href:o.href,type:o.type,media:o.media,crossorigin:o.crossOrigin});document.head.appendChild(c),n.push(c)}return e.htmlAttributes&&s.push(gt(document.documentElement,e.htmlAttributes)),e.bodyAttributes&&document.body&&s.push(gt(document.body,e.bodyAttributes)),()=>{document.title=a;for(const o of s.reverse())o();for(const o of n)o.remove()}},bt=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}},Fn=class extends bt{constructor(){super(localStorage)}},Un=class extends bt{constructor(){super(sessionStorage)}},xn=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 a=t(r.transaction(this.options.store,e).objectStore(this.options.store));a.onsuccess=()=>n(a.result),a.onerror=()=>s(a.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))}},Wn={local(){return new Fn},session(){return new Un},indexedDB(e){return new xn(e)}},wt=null,z=T({path:"",params:{},query:{},matched:null,hash:""}),St=x(()=>z.value),K=()=>wt,At=e=>{wt=e},me=async(e,t={})=>{const r=K();if(!r)throw new Error("bQuery router: No router initialized. Call createRouter() first.");await r[t.replace?"replace":"push"](e)},Qn=()=>{const e=K();e?e.back():history.back()},Vn=()=>{const e=K();e?e.forward():history.forward()},Kn=(e,t={})=>r=>{r.preventDefault(),me(e,t).catch(n=>{console.error("Navigation failed:",n)})},Jn=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 a=K();if(!a){n.preventDefault(),me(s.pathname+s.search+s.hash).catch(l=>{console.error("Navigation failed:",l)});return}const i=a.base,o=a.hash;let c;if(o&&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(),me(c).catch(l=>{console.error("Navigation failed:",l)})};return t.addEventListener("click",r),()=>t.removeEventListener("click",r)},Gn=e=>{const t={};return new URLSearchParams(e).forEach((r,n)=>{const s=t[n];s===void 0?t[n]=r:Array.isArray(s)?s.push(r):t[n]=[s,r]}),t},Yn=e=>{if(e==="*")return/^.*$/;const t="\0P\0",r="\0W\0";let n=e.replace(/:([a-zA-Z_][a-zA-Z0-9_]*)/g,()=>t);return n=n.replace(/\*/g,r),n=n.replace(/[\\^$.*+?()[\]{}|]/g,"\\$&"),n=n.replace(/\u0000P\u0000/g,()=>"([^/]+)"),n=n.replace(/\u0000W\u0000/g,".*"),new RegExp(`^${n}$`)},Zn=e=>{const t=e.match(/:([a-zA-Z_][a-zA-Z0-9_]*)/g);return t?t.map(r=>r.slice(1)):[]},Xn=(e,t)=>{for(const r of t){const n=Yn(r.path),s=e.match(n);if(s){const a=Zn(r.path),i={};return a.forEach((o,c)=>{i[o]=s[c+1]||""}),{matched:r,params:i}}}return null},pe=(e,t,r,n)=>{const s=Xn(e,n);return{path:e,params:s?.params??{},query:Gn(t),matched:s?.matched??null,hash:r.replace(/^#/,"")}},Et=(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(...Et(n.children,s))}return r},es=(e,t={})=>{const r=K();if(!r)throw new Error("bQuery router: No router initialized.");const n=r.routes.find(a=>a.name===e);if(!n)throw new Error(`bQuery router: Route "${e}" not found.`);let s=n.path;for(const[a,i]of Object.entries(t))s=s.replace(`:${a}`,encodeURIComponent(i));return s},ts=(e,t=!1)=>{const r=z.value.path;return t?r===e:r.startsWith(e)},rs=(e,t=!1)=>x(()=>{const r=z.value.path;return t?r===e:r.startsWith(e)}),ns=e=>{const t=K();t&&t.destroy();const{routes:r,base:n="",hash:s=!1}=e,a=[],i=[],o=Et(r),c=()=>{if(s){const[f,m=""]=(window.location.hash.slice(1)||"/").split("#"),[v,g=""]=f.split("?");return{pathname:v,search:g?`?${g}`:"",hash:m?`#${m}`:""}}let u=window.location.pathname;return n&&(u===n||u.startsWith(n+"/"))&&(u=u.slice(n.length)||"/"),{pathname:u,search:window.location.search,hash:window.location.hash}},l=()=>{const{pathname:u,search:f,hash:m}=c();z.value=pe(u,f,m,o)},h=async(u,f)=>{const{pathname:m,search:v,hash:g}=c(),b=pe(m,v,g,o),A=new URL(u,window.location.origin),D=pe(A.pathname,A.search,A.hash,o);for(const w of a)if(await w(D,b)===!1)return;const L=s?`#${u}`:`${n}${u}`;history[f]({},"",L),l();for(const w of i)w(z.value,b)},p=async()=>{const{pathname:u,search:f,hash:m}=c(),v=z.value,g=pe(u,f,m,o);for(const b of a)if(await b(g,v)===!1){const A=new URLSearchParams(Object.entries(v.query).flatMap(([E,P])=>Array.isArray(P)?P.map(H=>[E,H]):[[E,P]])).toString(),D=A?`?${A}`:"",L=v.hash?`#${v.hash}`:"",w=s?`#${v.path}${D}${L}`:`${n}${v.path}${D}${L}`;history.replaceState({},"",w);return}l();for(const b of i)b(z.value,v)};window.addEventListener("popstate",p),l();const y={push:u=>h(u,"pushState"),replace:u=>h(u,"replaceState"),back:()=>history.back(),forward:()=>history.forward(),go:u=>history.go(u),beforeEach:u=>(a.push(u),()=>{const f=a.indexOf(u);f>-1&&a.splice(f,1)}),afterEach:u=>(i.push(u),()=>{const f=i.indexOf(u);f>-1&&i.splice(f,1)}),currentRoute:St,routes:o,base:n,hash:s,destroy:()=>{window.removeEventListener("popstate",p),a.length=0,i.length=0,At(null)}};return At(y),y},ss=()=>{if(!(typeof window>"u"))return window.__BQUERY_DEVTOOLS__||(window.__BQUERY_DEVTOOLS__={stores:new Map}),window.__BQUERY_DEVTOOLS__},as=(e,t)=>{const r=ss();r&&(r.stores.set(e,t),r.onStoreCreated?.(e,t))},is=e=>{typeof window>"u"||!window.__BQUERY_DEVTOOLS__||window.__BQUERY_DEVTOOLS__.stores.delete(e)},os=(e,t)=>{typeof window>"u"||window.__BQUERY_DEVTOOLS__?.onStateChange?.(e,t)},$t=[],cs=e=>{$t.push(e)},ls=(e,t)=>{for(const r of $t){const n=r({store:e,options:t});n&&Object.assign(e,n)}},X=new Map,us=e=>X.has(e),fs=(e,t)=>{X.set(e,t)},kt=e=>X.get(e),ds=()=>Array.from(X.keys()),hs=e=>{X.delete(e),is(e)},Ct=e=>e!==null&&typeof e=="object"&&Object.getPrototypeOf(e)===Object.prototype,B=e=>{if(e===null||typeof e!="object")return e;if(Array.isArray(e))return e.map(B);if(e instanceof Date)return new Date(e.getTime());if(e instanceof Map)return new Map(Array.from(e.entries()).map(([r,n])=>[r,B(n)]));if(e instanceof Set)return new Set(Array.from(e).map(B));const t={};for(const r of Object.keys(e))t[r]=B(e[r]);return t},ee=(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,a]of e.entries())if(!t.has(s)||!ee(a,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 a=!1;for(const i of t.values())if(ee(s,i)){a=!0;break}if(!a)return!1}return!0}if(Array.isArray(e)&&Array.isArray(t))return e.length!==t.length?!1:e.every((s,a)=>ee(s,t[a]));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=>ee(e[s],t[s]))},ms=(e,t,r)=>{const n=[];for(const s of Object.keys(t)){const a=e[s],i=t[s];r.get(s)===i&&Ct(a)&&Ct(i)&&!ee(a,i)&&n.push(s)}return n},Le=(()=>{try{const e=globalThis.process;return!(typeof e<"u"&&e.env?.NODE_ENV==="production")}catch{return!0}})(),Pt=e=>{const{id:t,state:r,getters:n={},actions:s={}}=e;if(us(t))return console.warn(`bQuery store: Store "${t}" already exists. Returning existing instance.`),kt(t);const a=r(),i=new Map;for(const u of Object.keys(a))i.set(u,T(a[u]));const o=[],c=()=>le(()=>({...h})),l=()=>{const u=typeof window<"u"&&typeof window.__BQUERY_DEVTOOLS__?.onStateChange=="function";if(o.length===0&&!u)return;const f=c();for(const m of o)m(f);os(t,f)},h=new Proxy({},{get:(u,f)=>{const m=f;if(i.has(m))return i.get(m).value},ownKeys:()=>Array.from(i.keys()),getOwnPropertyDescriptor:(u,f)=>{if(i.has(f))return{enumerable:!0,configurable:!0}},has:(u,f)=>i.has(f)}),p=new Map,y={};for(const u of Object.keys(a))Object.defineProperty(y,u,{get:()=>i.get(u).value,set:f=>{i.get(u).value=f,l()},enumerable:!0,configurable:!1});for(const u of Object.keys(n)){const f=n[u],m=x(()=>f(h,new Proxy({},{get:(v,g)=>{const b=g;if(p.has(b))return p.get(b).value}})));p.set(u,m),Object.defineProperty(y,u,{get:()=>m.value,enumerable:!0,configurable:!1})}for(const u of Object.keys(s)){const f=s[u];y[u]=function(...m){const v=new Proxy(y,{get:(g,b)=>typeof b=="string"&&i.has(b)?i.get(b).value:g[b],set:(g,b,A)=>typeof b=="string"&&i.has(b)?(i.get(b).value=A,l(),!0):Reflect.set(g,b,A)});return f.apply(v,m)}}return Object.defineProperties(y,{$id:{value:t,writable:!1,enumerable:!1},$reset:{value:()=>{const u=r();ce(()=>{for(const[f,m]of i)m.value=u[f]}),l()},writable:!1,enumerable:!1},$subscribe:{value:u=>(o.push(u),()=>{const f=o.indexOf(u);f>-1&&o.splice(f,1)}),writable:!1,enumerable:!1},$patch:{value:u=>{ce(()=>{if(typeof u=="function"){const f=Le?B(c()):null,m=Le?new Map(Array.from(i.entries()).map(([g,b])=>[g,b.value])):null,v=c();if(u(v),Le&&f&&m){const g=ms(f,v,m);g.length>0&&console.warn(`[bQuery store "${t}"] Nested mutation detected in $patch() for keys: ${g.map(String).join(", ")}.
170
+ `}),r},de=()=>typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches,ct=e=>typeof e=="string"||typeof e=="number",lt=e=>e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`),K=(e,t)=>{const r=e.style;if(Array.isArray(t)){const n=t[t.length-1];if(!n)return;for(const[s,a]of Object.entries(n))if(!(s==="offset"||s==="easing"||s==="composite")&&ct(a)){const i=s.startsWith("--")?s:lt(s);r.setProperty(i,String(a))}return}for(const[n,s]of Object.entries(t)){if(n==="offset"||n==="easing"||n==="composite")continue;const a=Array.isArray(s)?s[s.length-1]:s;if(ct(a)){const i=n.startsWith("--")?n:lt(n);r.setProperty(i,String(a))}}},he=(e,t)=>{const{keyframes:r,options:n,commitStyles:s=!0,respectReducedMotion:a=!0,onFinish:i}=t;if(a&&de())return s&&K(e,r),i?.(),Promise.resolve();const o=e;return typeof o.animate!="function"?(s&&K(e,r),i?.(),Promise.resolve()):new Promise(c=>{const l=o.animate(r,n);let d=!1;const m=()=>{d||(d=!0,s&&(typeof l.commitStyles=="function"?l.commitStyles():K(e,r)),l.cancel(),i?.(),c())};l.onfinish=m,l.finished&&l.finished.then(m).catch(m)})},_=e=>Math.min(1,Math.max(0,e)),ut=e=>_(e),ft=e=>_(e*e),dt=e=>_(1-(1-e)*(1-e)),ht=e=>_(e<.5?2*e*e:1-Math.pow(-2*e+2,2)/2),mt=e=>_(e*e*e),pt=e=>_(1-Math.pow(1-e,3)),yt=e=>_(e<.5?4*e*e*e:1-Math.pow(-2*e+2,3)/2),gt=e=>_(1+(1.70158+1)*Math.pow(e-1,3)+1.70158*Math.pow(e-1,2)),vt=e=>_(e===1?1:1-Math.pow(2,-10*e)),Rn={linear:ut,easeInQuad:ft,easeOutQuad:dt,easeInOutQuad:ht,easeInCubic:mt,easeOutCubic:pt,easeInOutCubic:yt,easeOutBack:gt,easeOutExpo:vt},Re=e=>{const t=e.getBoundingClientRect();return{top:t.top,left:t.left,width:t.width,height:t.height}},Me=(e,t,r={})=>{const{duration:n=300,easing:s="ease-out",onComplete:a}=r,i=Re(e);if(i.width===0||i.height===0)return a?.(),Promise.resolve();const o=t.left-i.left,c=t.top-i.top,l=t.width/i.width,d=t.height/i.height;if(o===0&&c===0&&l===1&&d===1)return a?.(),Promise.resolve();const m=e;return typeof m.animate!="function"?(a?.(),Promise.resolve()):(m.style.transform=`translate(${o}px, ${c}px) scale(${l}, ${d})`,m.style.transformOrigin="top left",m.offsetHeight,new Promise(y=>{const f=m.animate([{transform:`translate(${o}px, ${c}px) scale(${l}, ${d})`},{transform:"translate(0, 0) scale(1, 1)"}],{duration:n,easing:s,fill:"forwards"});let u=!1;const p=()=>{u||(u=!0,m.style.transform="",m.style.transformOrigin="",a?.(),y())};f.onfinish=p,f.finished&&f.finished.then(p).catch(p)}))},Mn=async(e,t,r={})=>{await bt(e,t,r)},bt=async(e,t,r={})=>{const{stagger:n,...s}=r,a=new Map;for(const c of e)a.set(c,Re(c));t();const i=e.length,o=e.map((c,l)=>{const d=a.get(c);if(!d)return Promise.resolve();const m=n?n(l,i):0;return m>0?new Promise(y=>setTimeout(y,m)).then(()=>Me(c,d,s)):Me(c,d,s)});await Promise.all(o)},Pn={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)"}]},Ln=e=>typeof Element<"u"&&e instanceof Element?[e]:Array.from(e),Nn=(e,t)=>{const r=Ln(e);if(!r.length)return()=>{};const{root:n=null,rootMargin:s,threshold:a,once:i=!0,onEnter:o,...c}=t;if(typeof IntersectionObserver>"u")return r.forEach(d=>{o?.(d),he(d,c)}),()=>{};const l=new IntersectionObserver(d=>{d.forEach(m=>{if(!m.isIntersecting)return;const y=m.target;o?.(y),he(y,c),i&&l.unobserve(y)})},{root:n,rootMargin:s,threshold:a});return r.forEach(d=>l.observe(d)),()=>l.disconnect()},_n={stiffness:100,damping:10,mass:1,precision:.01},Dn=(e,t={})=>{const{stiffness:r,damping:n,mass:s,precision:a}={..._n,...t};let i=e,o=0,c=e,l=null,d=null,m=null;const y=new Set,f=()=>{for(const p of y)p(i)},u=p=>{const v=m!==null?(p-m)/1e3:.016666666666666666,g=Math.min(v,1/30);m=p;const b=i-c,E=(-r*b+-n*o)/s;if(o+=E*g,i+=o*g,f(),Math.abs(o)<a&&Math.abs(b)<a){i=c,o=0,l=null,f(),d?.(),d=null;return}l=requestAnimationFrame(u)};return{to(p){return c=p,l!==null&&cancelAnimationFrame(l),d?.(),m=null,new Promise(v=>{d=v,l=requestAnimationFrame(u)})},current(){return i},stop(){l!==null&&(cancelAnimationFrame(l),l=null),o=0,m=null,d?.(),d=null},onChange(p){return y.add(p),()=>y.delete(p)}}},qn={gentle:{stiffness:80,damping:15},snappy:{stiffness:200,damping:20},bouncy:{stiffness:300,damping:8},stiff:{stiffness:400,damping:30}},jn=(e,t={})=>{const{start:r=0,from:n="start",easing:s}=t;return(a,i=0)=>{const o=typeof n=="number"?n:n==="center"?(i-1)/2:n==="end"?i-1:0,c=Math.abs(a-o),l=i>1?Math.max(o,i-1-o):1,d=l===0?0:c/l;return r+(s?s(d)*l:c)*e}},Pe=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},In=(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},Hn=e=>{const t=Pe(e?.duration),r=Pe(e?.endDelay),n=e?.iterations??1;return n===1/0?Number.MAX_SAFE_INTEGER:t*Math.max(0,n)+r},wt=e=>{let t=0;return e.map(r=>{const n=In(r.at,t),s=Pe(r.options?.delay),a=Math.max(0,n+s),i=Hn(r.options),o=a+i;return t=Math.max(t,o),{step:r,start:a,end:o,duration:i}})},zn=async(e,t={})=>{const{stagger:r,onFinish:n}=t,s=e.length;for(let a=0;a<e.length;a+=1){const i=e[a],o=r?r(a,s):0;o>0&&await new Promise(c=>setTimeout(c,o)),await he(i.target,i)}n?.()},Bn=(e=[],t={})=>{const r=[...e],n=new Set;let s=[],a=0,i=!1,o=!1;const{commitStyles:c=!0,respectReducedMotion:l=!0,onFinish:d}=t,m=()=>{if(!o){if(o=!0,c)for(const f of s){const{animation:u,step:p}=f;typeof u.commitStyles=="function"?u.commitStyles():K(p.target,p.keyframes),u.cancel()}n.forEach(f=>f()),d?.()}},y=()=>{s.forEach(({animation:u})=>u.cancel()),s=[],o=!1;const f=wt(r);if(a=f.length?Math.max(...f.map(u=>u.end)):0,l&&de()){c&&f.forEach(({step:u})=>K(u.target,u.keyframes)),i=!0;return}if(f.some(({step:u})=>typeof u.target.animate!="function")){c&&f.forEach(({step:u})=>K(u.target,u.keyframes)),i=!0;return}i=!1,s=f.map(({step:u,start:p})=>{const{delay:v,...g}=u.options??{};return{animation:u.target.animate(u.keyframes,{...g,delay:p,fill:g.fill??"both"}),step:u,start:p}})};return{add(f){r.push(f)},duration(){if(!r.length)return 0;if(!s.length){const f=wt(r);return Math.max(...f.map(u=>u.end))}return a},async play(){if(y(),i||s.length===0){m();return}const f=s.map(u=>u.animation.finished.catch(()=>{}));await Promise.all(f),m()},pause(){i||s.forEach(({animation:f})=>f.pause())},resume(){i||s.forEach(({animation:f})=>f.play())},stop(){s.forEach(({animation:f})=>f.cancel()),s=[],i=!1},seek(f){i||s.forEach(({animation:u})=>{u.currentTime=f})},onFinish(f){return n.add(f),()=>n.delete(f)}}},St=e=>(e??[]).map(t=>t.trim()).filter(t=>t.length>0),Un=async e=>{const t=I().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,a=document.documentElement,i=St(r.classes),o=St(r.types);if(!s.startViewTransition||r.skipOnReducedMotion&&de()){await n(),r.onFinish?.();return}i.forEach(c=>a.classList.add(c));try{const c=s.startViewTransition(()=>n()),l=c.types;if(l)for(const d of o)l.add(d);await c.ready,r.onReady?.(),await c.finished,r.onFinish?.()}finally{i.forEach(c=>a.classList.remove(c))}},Fn=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 a=t(r.transaction(this.storeName,e).objectStore(this.storeName));a.onsuccess=()=>n(a.result),a.onerror=()=>s(a.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))}},Wn={async open(e){return new Fn(e)}},Qn=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)}},xn={isSupported(){return"caches"in window},async open(e){if(!this.isSupported())throw new Error("bQuery: Cache Storage API not supported");return new Qn(await caches.open(e))},async delete(e){return this.isSupported()?caches.delete(e):!1},async keys(){return this.isSupported()?caches.keys():[]}},Vn=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 a=s.slice(t.length);try{return decodeURIComponent(a)}catch{return a}}}return null},Kn=e=>{const t=e.trim();return t.startsWith("{")||t.startsWith("[")||t.startsWith('"')},Jn=(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("; ")},Gn=(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("; ")},Yn=(e,t={})=>{const r=I().cookies,n={path:r?.path??"/",sameSite:r?.sameSite??"Lax",secure:r?.secure??!1,watch:!0,...t};n.sameSite==="None"&&(n.secure=!0);const s=Vn(e);let a=n.defaultValue??null;if(s!==null)try{a=n.deserialize?n.deserialize(s):Kn(s)?JSON.parse(s):s??a}catch(c){console.warn(`bQuery: Failed to deserialize cookie "${e}", using raw string value`,c),a=s??a}const i=M(a);if(typeof document>"u"||n.watch===!1)return i;let o=!1;return $(()=>{const c=i.value;if(!o){o=!0;return}if(c==null){Jn(e,n);return}Gn(e,c,n)}),i},Zn={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)}},Xn=["position:absolute","width:1px","height:1px","padding:0","margin:-1px","overflow:hidden","clip:rect(0, 0, 0, 0)","white-space:nowrap","border:0"].join(";"),es=(e={})=>{const t=I().announcer,r={politeness:t?.politeness??"polite",atomic:t?.atomic??!0,delay:t?.delay??16,clearDelay:t?.clearDelay??1e3,...e},n=M("");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,a=s??document.createElement("div"),i=!s;if(r.id&&(a.id=r.id),r.className&&(a.className=r.className),a.setAttribute("aria-live",r.politeness),a.setAttribute("aria-atomic",String(r.atomic)),a.setAttribute("role",r.politeness==="assertive"?"alert":"status"),a.setAttribute("data-bquery-announcer","true"),a.getAttribute("style")||a.setAttribute("style",Xn),i){const p=r.container??document.body??document.documentElement;if(!p)return{element:null,message:n,announce(v){n.value=v},clear(){n.value=""},destroy(){n.value=""}};p.appendChild(a)}const o=$(()=>{a.textContent=n.value});let c,l,d=!1;const m=()=>{c&&(clearTimeout(c),c=void 0),l&&(clearTimeout(l),l=void 0)};return{element:a,message:n,announce:(p,v={})=>{if(d)return;const g=v.politeness??r.politeness,b=v.delay??r.delay,E=v.clearDelay??r.clearDelay;m(),a.setAttribute("aria-live",g),a.setAttribute("role",g==="assertive"?"alert":"status"),n.value="",c=setTimeout(()=>{d||(n.value=p,E>0&&(l=setTimeout(()=>{d||(n.value="")},E)))},b)},clear:()=>{d||(m(),n.value="")},destroy:()=>{d||(d=!0,m(),n.value="",o(),i&&a.remove())}}},Et=(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)}},At=(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},ts=e=>{if(typeof document>"u")return()=>{};const t=I().pageMeta,r=e.title?t?.titleTemplate?t.titleTemplate(e.title):e.title:void 0,n=[],s=[],a=document.title;r!==void 0&&(document.title=r);const i=[...e.meta??[]];e.description&&i.unshift({name:"description",content:e.description});for(const o of i){const c=At("meta",{name:o.name,property:o.property,"http-equiv":o.httpEquiv,content:o.content});document.head.appendChild(c),n.push(c)}for(const o of e.link??[]){const c=At("link",{rel:o.rel,href:o.href,type:o.type,media:o.media,crossorigin:o.crossOrigin});document.head.appendChild(c),n.push(c)}return e.htmlAttributes&&s.push(Et(document.documentElement,e.htmlAttributes)),e.bodyAttributes&&document.body&&s.push(Et(document.body,e.bodyAttributes)),()=>{document.title=a;for(const o of s.reverse())o();for(const o of n)o.remove()}},Ct=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}},rs=class extends Ct{constructor(){super(localStorage)}},ns=class extends Ct{constructor(){super(sessionStorage)}},ss=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 a=t(r.transaction(this.options.store,e).objectStore(this.options.store));a.onsuccess=()=>n(a.result),a.onerror=()=>s(a.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))}},as={local(){return new rs},session(){return new ns},indexedDB(e){return new ss(e)}},$t=null,z=M({path:"",params:{},query:{},matched:null,hash:""}),kt=W(()=>z.value),J=()=>$t,Ot=e=>{$t=e},me=async(e,t={})=>{const r=J();if(!r)throw new Error("bQuery router: No router initialized. Call createRouter() first.");await r[t.replace?"replace":"push"](e)},is=()=>{const e=J();e?e.back():history.back()},os=()=>{const e=J();e?e.forward():history.forward()},cs=(e,t={})=>r=>{r.preventDefault(),me(e,t).catch(n=>{console.error("Navigation failed:",n)})},ls=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 a=J();if(!a){n.preventDefault(),me(s.pathname+s.search+s.hash).catch(l=>{console.error("Navigation failed:",l)});return}const i=a.base,o=a.hash;let c;if(o&&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(),me(c).catch(l=>{console.error("Navigation failed:",l)})};return t.addEventListener("click",r),()=>t.removeEventListener("click",r)},us=e=>{const t={};return new URLSearchParams(e).forEach((r,n)=>{const s=t[n];s===void 0?t[n]=r:Array.isArray(s)?s.push(r):t[n]=[s,r]}),t},fs=e=>{if(e==="*")return/^.*$/;const t="\0P\0",r="\0W\0";let n=e.replace(/:([a-zA-Z_][a-zA-Z0-9_]*)/g,()=>t);return n=n.replace(/\*/g,r),n=n.replace(/[\\^$.*+?()[\]{}|]/g,"\\$&"),n=n.replace(/\u0000P\u0000/g,()=>"([^/]+)"),n=n.replace(/\u0000W\u0000/g,".*"),new RegExp(`^${n}$`)},ds=e=>{const t=e.match(/:([a-zA-Z_][a-zA-Z0-9_]*)/g);return t?t.map(r=>r.slice(1)):[]},hs=(e,t)=>{for(const r of t){const n=fs(r.path),s=e.match(n);if(s){const a=ds(r.path),i={};return a.forEach((o,c)=>{i[o]=s[c+1]||""}),{matched:r,params:i}}}return null},pe=(e,t,r,n)=>{const s=hs(e,n);return{path:e,params:s?.params??{},query:us(t),matched:s?.matched??null,hash:r.replace(/^#/,"")}},Tt=(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(...Tt(n.children,s))}return r},ms=(e,t={})=>{const r=J();if(!r)throw new Error("bQuery router: No router initialized.");const n=r.routes.find(a=>a.name===e);if(!n)throw new Error(`bQuery router: Route "${e}" not found.`);let s=n.path;for(const[a,i]of Object.entries(t))s=s.replace(`:${a}`,encodeURIComponent(i));return s},ps=(e,t=!1)=>{const r=z.value.path;return t?r===e:r.startsWith(e)},ys=(e,t=!1)=>W(()=>{const r=z.value.path;return t?r===e:r.startsWith(e)}),gs=e=>{const t=J();t&&t.destroy();const{routes:r,base:n="",hash:s=!1}=e,a=[],i=[],o=Tt(r),c=()=>{if(s){const[u,p=""]=(window.location.hash.slice(1)||"/").split("#"),[v,g=""]=u.split("?");return{pathname:v,search:g?`?${g}`:"",hash:p?`#${p}`:""}}let f=window.location.pathname;return n&&(f===n||f.startsWith(n+"/"))&&(f=f.slice(n.length)||"/"),{pathname:f,search:window.location.search,hash:window.location.hash}},l=()=>{const{pathname:f,search:u,hash:p}=c();z.value=pe(f,u,p,o)},d=async(f,u)=>{const{pathname:p,search:v,hash:g}=c(),b=pe(p,v,g,o),E=new URL(f,window.location.origin),D=pe(E.pathname,E.search,E.hash,o);for(const w of a)if(await w(D,b)===!1)return;const P=s?`#${f}`:`${n}${f}`;history[u]({},"",P),l();for(const w of i)w(z.value,b)},m=async()=>{const{pathname:f,search:u,hash:p}=c(),v=z.value,g=pe(f,u,p,o);for(const b of a)if(await b(g,v)===!1){const E=new URLSearchParams(Object.entries(v.query).flatMap(([A,O])=>Array.isArray(O)?O.map(H=>[A,H]):[[A,O]])).toString(),D=E?`?${E}`:"",P=v.hash?`#${v.hash}`:"",w=s?`#${v.path}${D}${P}`:`${n}${v.path}${D}${P}`;history.replaceState({},"",w);return}l();for(const b of i)b(z.value,v)};window.addEventListener("popstate",m),l();const y={push:f=>d(f,"pushState"),replace:f=>d(f,"replaceState"),back:()=>history.back(),forward:()=>history.forward(),go:f=>history.go(f),beforeEach:f=>(a.push(f),()=>{const u=a.indexOf(f);u>-1&&a.splice(u,1)}),afterEach:f=>(i.push(f),()=>{const u=i.indexOf(f);u>-1&&i.splice(u,1)}),currentRoute:kt,routes:o,base:n,hash:s,destroy:()=>{window.removeEventListener("popstate",m),a.length=0,i.length=0,Ot(null)}};return Ot(y),y},vs=()=>{if(!(typeof window>"u"))return window.__BQUERY_DEVTOOLS__||(window.__BQUERY_DEVTOOLS__={stores:new Map}),window.__BQUERY_DEVTOOLS__},bs=(e,t)=>{const r=vs();r&&(r.stores.set(e,t),r.onStoreCreated?.(e,t))},ws=e=>{typeof window>"u"||!window.__BQUERY_DEVTOOLS__||window.__BQUERY_DEVTOOLS__.stores.delete(e)},Ss=(e,t)=>{typeof window>"u"||window.__BQUERY_DEVTOOLS__?.onStateChange?.(e,t)},Rt=[],Es=e=>{Rt.push(e)},As=(e,t)=>{for(const r of Rt){const n=r({store:e,options:t});n&&Object.assign(e,n)}},ee=new Map,Cs=e=>ee.has(e),$s=(e,t)=>{ee.set(e,t)},Mt=e=>ee.get(e),ks=()=>Array.from(ee.keys()),Os=e=>{ee.delete(e),ws(e)},Pt=e=>e!==null&&typeof e=="object"&&Object.getPrototypeOf(e)===Object.prototype,B=e=>{if(e===null||typeof e!="object")return e;if(Array.isArray(e))return e.map(B);if(e instanceof Date)return new Date(e.getTime());if(e instanceof Map)return new Map(Array.from(e.entries()).map(([r,n])=>[r,B(n)]));if(e instanceof Set)return new Set(Array.from(e).map(B));const t={};for(const r of Object.keys(e))t[r]=B(e[r]);return t},te=(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,a]of e.entries())if(!t.has(s)||!te(a,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 a=!1;for(const i of t.values())if(te(s,i)){a=!0;break}if(!a)return!1}return!0}if(Array.isArray(e)&&Array.isArray(t))return e.length!==t.length?!1:e.every((s,a)=>te(s,t[a]));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=>te(e[s],t[s]))},Ts=(e,t,r)=>{const n=[];for(const s of Object.keys(t)){const a=e[s],i=t[s];r.get(s)===i&&Pt(a)&&Pt(i)&&!te(a,i)&&n.push(s)}return n},Le=(()=>{try{const e=globalThis.process;return!(typeof e<"u"&&e.env?.NODE_ENV==="production")}catch{return!0}})(),Lt=e=>{const{id:t,state:r,getters:n={},actions:s={}}=e;if(Cs(t))return console.warn(`bQuery store: Store "${t}" already exists. Returning existing instance.`),Mt(t);const a=r(),i=new Map;for(const f of Object.keys(a))i.set(f,M(a[f]));const o=[],c=()=>Q(()=>({...d})),l=()=>{const f=typeof window<"u"&&typeof window.__BQUERY_DEVTOOLS__?.onStateChange=="function";if(o.length===0&&!f)return;const u=c();for(const p of o)p(u);Ss(t,u)},d=new Proxy({},{get:(f,u)=>{const p=u;if(i.has(p))return i.get(p).value},ownKeys:()=>Array.from(i.keys()),getOwnPropertyDescriptor:(f,u)=>{if(i.has(u))return{enumerable:!0,configurable:!0}},has:(f,u)=>i.has(u)}),m=new Map,y={};for(const f of Object.keys(a))Object.defineProperty(y,f,{get:()=>i.get(f).value,set:u=>{i.get(f).value=u,l()},enumerable:!0,configurable:!1});for(const f of Object.keys(n)){const u=n[f],p=W(()=>u(d,new Proxy({},{get:(v,g)=>{const b=g;if(m.has(b))return m.get(b).value}})));m.set(f,p),Object.defineProperty(y,f,{get:()=>p.value,enumerable:!0,configurable:!1})}for(const f of Object.keys(s)){const u=s[f];y[f]=function(...p){const v=new Proxy(y,{get:(g,b)=>typeof b=="string"&&i.has(b)?i.get(b).value:g[b],set:(g,b,E)=>typeof b=="string"&&i.has(b)?(i.get(b).value=E,l(),!0):Reflect.set(g,b,E)});return u.apply(v,p)}}return Object.defineProperties(y,{$id:{value:t,writable:!1,enumerable:!1},$reset:{value:()=>{const f=r();le(()=>{for(const[u,p]of i)p.value=f[u]}),l()},writable:!1,enumerable:!1},$subscribe:{value:f=>(o.push(f),()=>{const u=o.indexOf(f);u>-1&&o.splice(u,1)}),writable:!1,enumerable:!1},$patch:{value:f=>{le(()=>{if(typeof f=="function"){const u=Le?B(c()):null,p=Le?new Map(Array.from(i.entries()).map(([g,b])=>[g,b.value])):null,v=c();if(f(v),Le&&u&&p){const g=Ts(u,v,p);g.length>0&&console.warn(`[bQuery store "${t}"] Nested mutation detected in $patch() for keys: ${g.map(String).join(", ")}.
171
171
  Nested object mutations do not trigger reactive updates because the store uses shallow reactivity.
172
172
  To fix this, either:
173
173
  1. Replace the entire object: state.user = { ...state.user, name: "New" }
174
174
  2. Use $patchDeep() for automatic deep cloning
175
- See: https://bquery.dev/guide/store#deep-reactivity`)}for(const[g,b]of Object.entries(v))i.has(g)&&(i.get(g).value=b)}else for(const[f,m]of Object.entries(u))i.has(f)&&(i.get(f).value=m)}),l()},writable:!1,enumerable:!1},$patchDeep:{value:u=>{ce(()=>{if(typeof u=="function"){const f=B(c());u(f);for(const[m,v]of Object.entries(f))i.has(m)&&(i.get(m).value=v)}else for(const[f,m]of Object.entries(u))i.has(f)&&(i.get(f).value=B(m))}),l()},writable:!1,enumerable:!1},$state:{get:()=>c(),enumerable:!1}}),fs(t,y),ls(y,e),as(t,y),y},ps=(e,t)=>{const r={};for(const n of t)Object.defineProperty(r,n,{get:()=>e[n],enumerable:!0});return r},ys=(e,t)=>{const r={};for(const n of t)r[n]=(...s)=>e[n](...s);return r},gs=(e,t)=>{const r=t??`bquery-store-${e.id}`,n=e.state,s=Pt({...e,state:()=>{const a=n();if(typeof window<"u")try{const i=localStorage.getItem(r);if(i)return{...a,...JSON.parse(i)}}catch{}return a}});return s.$subscribe(a=>{if(typeof window<"u")try{localStorage.setItem(r,JSON.stringify(a))}catch{}}),s},Ot=500,Rt=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}},Tt=new Rt(Ot),Lt=new Rt(Ot),vs=e=>new Proxy(e,{get(t,r){if(typeof r!="string")return Reflect.get(t,r);const n=t[r];return ue(n)||et(n)?n.value:n},has(t,r){return typeof r!="string"?Reflect.has(t,r):r in t}}),R=(e,t)=>{try{const r=vs(t);let n=Tt.get(e);return n||(n=new Function("$ctx",`with($ctx) { return (${e}); }`),Tt.set(e,n)),n(r)}catch(r){console.error(`bQuery view: Error evaluating "${e}"`,r);return}},ye=(e,t)=>{try{let r=Lt.get(e);return r||(r=new Function("$ctx",`with($ctx) { return (${e}); }`),Lt.set(e,r)),r(t)}catch(r){console.error(`bQuery view: Error evaluating "${e}"`,r);return}},Mt=e=>{const t={},r=e.trim().replace(/^\{|\}$/g,"").trim();if(!r)return t;const n=[];let s="",a=0,i=null;for(let o=0;o<r.length;o++){const c=r[o];if(c==='"'||c==="'"||c==="`"){let l=0,h=o-1;for(;h>=0&&r[h]==="\\";)l++,h--;l%2===0&&(i===null?i=c:i===c&&(i=null)),s+=c;continue}if(i!==null){s+=c;continue}c==="("||c==="["||c==="{"?(a++,s+=c):c===")"||c==="]"||c==="}"?(a--,s+=c):c===","&&a===0?(n.push(s.trim()),s=""):s+=c}s.trim()&&n.push(s.trim());for(const o of n){let c=-1,l=0,h=null;for(let p=0;p<o.length;p++){const y=o[p];if(y==='"'||y==="'"||y==="`"){let u=0,f=p-1;for(;f>=0&&o[f]==="\\";)u++,f--;u%2===0&&(h===null?h=y:h===y&&(h=null));continue}if(h===null){if(y==="("||y==="["||y==="{")l++;else if(y===")"||y==="]"||y==="}")l--;else if(y===":"&&l===0){c=p;break}}}if(c>-1){const p=o.slice(0,c).trim().replace(/^['"]|['"]$/g,"");t[p]=o.slice(c+1).trim()}}return t},bs=e=>(t,r,n,s)=>{const a=C(()=>{const i=R(r,n);i==null||i===!1?t.removeAttribute(e):i===!0?t.setAttribute(e,""):t.setAttribute(e,String(i))});s.push(a)},ws=(e,t,r,n)=>{let s=new Set;const a=C(()=>{const i=new Set;if(t.trimStart().startsWith("{")){const o=Mt(t);for(const[c,l]of Object.entries(o)){const h=R(l,r);e.classList.toggle(c,!!h),i.add(c)}}else if(/^\s*\[/.test(t)){const o=R(t,r);if(Array.isArray(o))for(const c of o)c&&(e.classList.add(c),i.add(c))}else{const o=R(t,r);typeof o=="string"?o.split(/\s+/).forEach(c=>{c&&(e.classList.add(c),i.add(c))}):Array.isArray(o)&&o.forEach(c=>{c&&(e.classList.add(c),i.add(c))})}for(const o of s)i.has(o)||e.classList.remove(o);s=i});n.push(a)},Ss=(e,t,r,n,s,a)=>{if(!r)return t;const i={...a,[n]:e};return s&&(i[s]=t),R(r,i)},As=e=>{const{prefix:t,processElement:r,processChildren:n}=e;return(s,a,i,o)=>{const c=s.parentNode;if(!c)return;const l=a.match(/^\(?(\w+)(?:\s*,\s*(\w+))?\)?\s+in\s+(\S.*)$/);if(!l){console.error(`bQuery view: Invalid bq-for expression "${a}"`);return}const[,h,p,y]=l,u=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: ${a}`);c.replaceChild(m,s);let v=new Map,g=[];const b=(w,E,P)=>{const H=f.cloneNode(!0),J=[],G=T(w),q=p?T(E):null,$={...i,[h]:G};return p&&q&&($[p]=q),r(H,$,t,J),n(H,$,t,J),{key:P,element:H,cleanups:J,item:w,index:E,itemSignal:G,indexSignal:q}},A=w=>{for(const E of w.cleanups)E();w.element.remove()},D=(w,E,P)=>{Object.is(w.item,E)||(w.item=E,w.itemSignal.value=E),w.index!==P&&(w.index=P,w.indexSignal&&(w.indexSignal.value=P))},L=C(()=>{const w=R(y,i);if(!Array.isArray(w)){for(const $ of v.values())A($);v.clear(),g=[];return}const E=[],P=new Map,H=new Set;w.forEach(($,O)=>{let M=Ss($,O,u,h,p,i);H.has(M)&&(console.warn(`bq-for: Duplicate key "${String(M)}" detected at index ${O}. Falling back to index-based key for this item. Ensure :key expressions produce unique values for each item.`),M={__bqDuplicateKey:M,__bqIndex:O}),H.add(M),E.push(M),P.set(M,{item:$,index:O})});const J=[];for(const $ of g)P.has($)||J.push($);for(const $ of J){const O=v.get($);O&&(A(O),v.delete($))}const G=new Map;let q=m;for(let $=0;$<E.length;$++){const O=E[$],{item:M,index:_t}=P.get(O);let N=v.get(O);N?(D(N,M,_t),G.set(O,N),q.nextSibling!==N.element&&q.after(N.element),q=N.element):(N=b(M,_t,O),G.set(O,N),q.after(N.element),q=N.element)}v=G,g=E});o.push(()=>{L();for(const w of v.values())for(const E of w.cleanups)E();v.clear()})}},Es=e=>(t,r,n,s)=>{const a=C(()=>{const i=R(r,n),o=String(i??"");t.innerHTML=e?j(o):o});s.push(a)},$s=(e,t,r,n)=>{const s=document.createComment(`bq-if: ${t}`);let a=!0;const i=C(()=>{const o=R(t,r);o&&!a?(s.replaceWith(e),a=!0):!o&&a&&(e.replaceWith(s),a=!1)});n.push(i)},ks=(e,t,r,n)=>{const s=e,a=ye(t,r);if(!ue(a)){console.warn(`bQuery view: bq-model requires a signal, got "${t}"`);return}const i=a,o=s.type==="checkbox",c=s.type==="radio",l=()=>{o?s.checked=!!i.value:c?s.checked=i.value===s.value:s.value=String(i.value??"")},h=C(()=>{l()});n.push(h);const p=s.tagName==="SELECT"?"change":"input",y=()=>{o?i.value=s.checked:c?s.checked&&(i.value=s.value):i.value=s.value};s.addEventListener(p,y),n.push(()=>s.removeEventListener(p,y))},Cs=e=>(t,r,n,s)=>{const a=i=>{const o={...n,$event:i,$el:t};if(!r.includes("(")){const c=ye(r,o);if(typeof c=="function"){c(i);return}return}ye(r,o)};t.addEventListener(e,a),s.push(()=>t.removeEventListener(e,a))};function Ps(e){const t=Object.getOwnPropertyDescriptor(e,"value");return t?"value"in t?t.writable===!0:typeof t.set=="function":!1}var Os=(e,t,r,n)=>{const s=ye(t,r);ue(s)?(s.value=e,n.push(()=>{s.value=null})):typeof s=="object"&&s!==null&&Ps(s)&&(s.value=e,n.push(()=>{s.value=null}))},Rs=(e,t,r,n)=>{const s=e;let a=s.style.display;if(!a||a==="none"){const o=s.ownerDocument.defaultView?.getComputedStyle(s).display??"";a=o!=="none"?o:""}const i=C(()=>{const o=R(t,r);s.style.display=o?a:"none"});n.push(i)},Ts=(e,t,r,n)=>{const s=e;let a=new Set;const i=C(()=>{const o=new Set;if(t.trimStart().startsWith("{")){const c=Mt(t);for(const[l,h]of Object.entries(c)){const p=R(h,r),y=l.replace(/([A-Z])/g,"-$1").toLowerCase();s.style.setProperty(y,String(p??"")),o.add(y)}}else{const c=R(t,r);if(c&&typeof c=="object")for(const[l,h]of Object.entries(c)){const p=l.replace(/([A-Z])/g,"-$1").toLowerCase();s.style.setProperty(p,String(h??"")),o.add(p)}}for(const c of a)o.has(c)||s.style.removeProperty(c);a=o});n.push(i)},Ls=(e,t,r,n)=>{const s=C(()=>{const a=R(t,r);e.textContent=String(a??"")});n.push(s)},ge=(e,t,r,n,s)=>{const a=Array.from(e.attributes);for(const i of a){const{name:o,value:c}=i;if(!o.startsWith(`${r}-`))continue;const l=o.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==="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 h=l.slice(5);s.bind(h)(e,c,t,n)}else if(l.startsWith("on:")){const h=l.slice(3);s.on(h)(e,c,t,n)}}},Me=(e,t,r,n,s)=>{const a=Array.from(e.children);for(const i of a)i.hasAttribute(`${r}-for`)?ge(i,t,r,n,s):(ge(i,t,r,n,s),Me(i,t,r,n,s))},Nt=(e,t,r={})=>{const{prefix:n="bq",sanitize:s=!0}=r,a=typeof e=="string"?document.querySelector(e):e;if(!a)throw new Error(`bQuery view: Element "${e}" not found.`);if(a.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=[],o={text:Ls,html:Es(s),if:$s,show:Rs,class:ws,style:Ts,model:ks,ref:Os,for:As({prefix:n,processElement:(l,h,p,y)=>ge(l,h,p,y,o),processChildren:(l,h,p,y)=>Me(l,h,p,y,o)}),bind:bs,on:Cs};return((l,h,p)=>{const y=l.hasAttribute(`${n}-for`);ge(l,h,n,p,o),y||Me(l,h,n,p,o)})(a,t,i),{el:a,context:t,update:l=>{Object.assign(t,l)},destroy:()=>{for(const l of i)l();i.length=0}}},Ms=(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:a="bq"}=t;if(s.hasAttribute(`${a}-for`)||s.hasAttribute(`${a}-if`)){const i=s.hasAttribute(`${a}-for`)?"for":"if";throw new Error(`bQuery view: Template root element cannot have ${a}-${i} directive. Wrap the ${a}-${i} element in a container instead.`)}return Nt(s,r,t)};return d.$=Zt,d.$$=Xt,d.BQueryCollection=ne,d.BQueryElement=F,d.Computed=Ae,d.Signal=Ee,d.animate=he,d.back=Qn,d.batch=ce,d.buckets=Tn,d.cache=Mn,d.capturePosition=Oe,d.component=W,d.computed=x,d.createPersistedStore=gs,d.createRouter=ns,d.createStore=Pt,d.createTemplate=Ms,d.createTrustedHtml=Jt,d.createUseFetch=rn,d.currentRoute=St,d.defineBqueryConfig=xr,d.definePageMeta=Bn,d.destroyStore=hs,d.easeInCubic=lt,d.easeInOutCubic=ft,d.easeInOutQuad=ct,d.easeInQuad=it,d.easeOutBack=dt,d.easeOutCubic=ut,d.easeOutExpo=ht,d.easeOutQuad=ot,d.easingPresets=pn,d.effect=C,d.escapeHtml=Fe,d.flip=Re,d.flipElements=mt,d.flipList=yn,d.forward=Vn,d.generateNonce=Qt,d.getBqueryConfig=I,d.getStore=kt,d.getTrustedTypesPolicy=Be,d.hasCSPDirective=Vt,d.html=Q,d.interceptLinks=Jn,d.isActive=ts,d.isActiveSignal=rs,d.isComputed=et,d.isSignal=ue,d.isTrustedTypesSupported=Kt,d.keyframePresets=gn,d.linear=at,d.link=Kn,d.linkedSignal=nn,d.listStores=ds,d.mapActions=ys,d.mapState=ps,d.mount=Nt,d.navigate=me,d.notifications=In,d.persistedSignal=sn,d.prefersReducedMotion=de,d.readonly=an,d.registerDefaultComponents=mn,d.registerPlugin=cs,d.resolve=es,d.safeHtml=un,d.sanitize=j,d.sanitizeHtml=j,d.scrollAnimate=bn,d.sequence=Cn,d.signal=T,d.spring=Sn,d.springPresets=An,d.stagger=En,d.storage=Wn,d.stripTags=Gt,d.timeline=Pn,d.transition=On,d.untrack=le,d.useAnnouncer=zn,d.useAsyncData=Ze,d.useCookie=jn,d.useFetch=Xe,d.utils=Ir,d.watch=on,d})({});
175
+ See: https://bquery.dev/guide/store#deep-reactivity`)}for(const[g,b]of Object.entries(v))i.has(g)&&(i.get(g).value=b)}else for(const[u,p]of Object.entries(f))i.has(u)&&(i.get(u).value=p)}),l()},writable:!1,enumerable:!1},$patchDeep:{value:f=>{le(()=>{if(typeof f=="function"){const u=B(c());f(u);for(const[p,v]of Object.entries(u))i.has(p)&&(i.get(p).value=v)}else for(const[u,p]of Object.entries(f))i.has(u)&&(i.get(u).value=B(p))}),l()},writable:!1,enumerable:!1},$state:{get:()=>c(),enumerable:!1}}),$s(t,y),As(y,e),bs(t,y),y},Rs=(e,t)=>{const r={};for(const n of t)Object.defineProperty(r,n,{get:()=>e[n],enumerable:!0});return r},Ms=(e,t)=>{const r={};for(const n of t)r[n]=(...s)=>e[n](...s);return r},Ps=(e,t)=>{const r=t??`bquery-store-${e.id}`,n=e.state,s=Lt({...e,state:()=>{const a=n();if(typeof window<"u")try{const i=localStorage.getItem(r);if(i)return{...a,...JSON.parse(i)}}catch{}return a}});return s.$subscribe(a=>{if(typeof window<"u")try{localStorage.setItem(r,JSON.stringify(a))}catch{}}),s},Nt=500,_t=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}},Dt=new _t(Nt),qt=new _t(Nt),Ls=e=>new Proxy(e,{get(t,r){if(typeof r!="string")return Reflect.get(t,r);const n=t[r];return ue(n)||nt(n)?n.value:n},has(t,r){return typeof r!="string"?Reflect.has(t,r):r in t}}),R=(e,t)=>{try{const r=Ls(t);let n=Dt.get(e);return n||(n=new Function("$ctx",`with($ctx) { return (${e}); }`),Dt.set(e,n)),n(r)}catch(r){console.error(`bQuery view: Error evaluating "${e}"`,r);return}},ye=(e,t)=>{try{let r=qt.get(e);return r||(r=new Function("$ctx",`with($ctx) { return (${e}); }`),qt.set(e,r)),r(t)}catch(r){console.error(`bQuery view: Error evaluating "${e}"`,r);return}},jt=e=>{const t={},r=e.trim().replace(/^\{|\}$/g,"").trim();if(!r)return t;const n=[];let s="",a=0,i=null;for(let o=0;o<r.length;o++){const c=r[o];if(c==='"'||c==="'"||c==="`"){let l=0,d=o-1;for(;d>=0&&r[d]==="\\";)l++,d--;l%2===0&&(i===null?i=c:i===c&&(i=null)),s+=c;continue}if(i!==null){s+=c;continue}c==="("||c==="["||c==="{"?(a++,s+=c):c===")"||c==="]"||c==="}"?(a--,s+=c):c===","&&a===0?(n.push(s.trim()),s=""):s+=c}s.trim()&&n.push(s.trim());for(const o of n){let c=-1,l=0,d=null;for(let m=0;m<o.length;m++){const y=o[m];if(y==='"'||y==="'"||y==="`"){let f=0,u=m-1;for(;u>=0&&o[u]==="\\";)f++,u--;f%2===0&&(d===null?d=y:d===y&&(d=null));continue}if(d===null){if(y==="("||y==="["||y==="{")l++;else if(y===")"||y==="]"||y==="}")l--;else if(y===":"&&l===0){c=m;break}}}if(c>-1){const m=o.slice(0,c).trim().replace(/^['"]|['"]$/g,"");t[m]=o.slice(c+1).trim()}}return t},Ns=e=>(t,r,n,s)=>{const a=$(()=>{const i=R(r,n);i==null||i===!1?t.removeAttribute(e):i===!0?t.setAttribute(e,""):t.setAttribute(e,String(i))});s.push(a)},_s=(e,t,r,n)=>{let s=new Set;const a=$(()=>{const i=new Set;if(t.trimStart().startsWith("{")){const o=jt(t);for(const[c,l]of Object.entries(o)){const d=R(l,r);e.classList.toggle(c,!!d),i.add(c)}}else if(/^\s*\[/.test(t)){const o=R(t,r);if(Array.isArray(o))for(const c of o)c&&(e.classList.add(c),i.add(c))}else{const o=R(t,r);typeof o=="string"?o.split(/\s+/).forEach(c=>{c&&(e.classList.add(c),i.add(c))}):Array.isArray(o)&&o.forEach(c=>{c&&(e.classList.add(c),i.add(c))})}for(const o of s)i.has(o)||e.classList.remove(o);s=i});n.push(a)},Ds=(e,t,r,n,s,a)=>{if(!r)return t;const i={...a,[n]:e};return s&&(i[s]=t),R(r,i)},qs=e=>{const{prefix:t,processElement:r,processChildren:n}=e;return(s,a,i,o)=>{const c=s.parentNode;if(!c)return;const l=a.match(/^\(?(\w+)(?:\s*,\s*(\w+))?\)?\s+in\s+(\S.*)$/);if(!l){console.error(`bQuery view: Invalid bq-for expression "${a}"`);return}const[,d,m,y]=l,f=s.getAttribute(":key")||s.getAttribute(`${t}-key`),u=s.cloneNode(!0);u.removeAttribute(`${t}-for`),u.removeAttribute(":key"),u.removeAttribute(`${t}-key`);const p=document.createComment(`bq-for: ${a}`);c.replaceChild(p,s);let v=new Map,g=[];const b=(w,A,O)=>{const H=u.cloneNode(!0),G=[],Y=M(w),q=m?M(A):null,C={...i,[d]:Y};return m&&q&&(C[m]=q),r(H,C,t,G),n(H,C,t,G),{key:O,element:H,cleanups:G,item:w,index:A,itemSignal:Y,indexSignal:q}},E=w=>{for(const A of w.cleanups)A();w.element.remove()},D=(w,A,O)=>{Object.is(w.item,A)||(w.item=A,w.itemSignal.value=A),w.index!==O&&(w.index=O,w.indexSignal&&(w.indexSignal.value=O))},P=$(()=>{const w=R(y,i);if(!Array.isArray(w)){for(const C of v.values())E(C);v.clear(),g=[];return}const A=[],O=new Map,H=new Set;w.forEach((C,T)=>{let L=Ds(C,T,f,d,m,i);H.has(L)&&(console.warn(`bq-for: Duplicate key "${String(L)}" detected at index ${T}. Falling back to index-based key for this item. Ensure :key expressions produce unique values for each item.`),L={__bqDuplicateKey:L,__bqIndex:T}),H.add(L),A.push(L),O.set(L,{item:C,index:T})});const G=[];for(const C of g)O.has(C)||G.push(C);for(const C of G){const T=v.get(C);T&&(E(T),v.delete(C))}const Y=new Map;let q=p;for(let C=0;C<A.length;C++){const T=A[C],{item:L,index:Ht}=O.get(T);let N=v.get(T);N?(D(N,L,Ht),Y.set(T,N),q.nextSibling!==N.element&&q.after(N.element),q=N.element):(N=b(L,Ht,T),Y.set(T,N),q.after(N.element),q=N.element)}v=Y,g=A});o.push(()=>{P();for(const w of v.values())for(const A of w.cleanups)A();v.clear()})}},js=e=>(t,r,n,s)=>{const a=$(()=>{const i=R(r,n),o=String(i??"");t.innerHTML=e?j(o):o});s.push(a)},Is=(e,t,r,n)=>{const s=document.createComment(`bq-if: ${t}`);let a=!0;const i=$(()=>{const o=R(t,r);o&&!a?(s.replaceWith(e),a=!0):!o&&a&&(e.replaceWith(s),a=!1)});n.push(i)},Hs=(e,t,r,n)=>{const s=e,a=ye(t,r);if(!ue(a)){console.warn(`bQuery view: bq-model requires a signal, got "${t}"`);return}const i=a,o=s.type==="checkbox",c=s.type==="radio",l=()=>{o?s.checked=!!i.value:c?s.checked=i.value===s.value:s.value=String(i.value??"")},d=$(()=>{l()});n.push(d);const m=s.tagName==="SELECT"?"change":"input",y=()=>{o?i.value=s.checked:c?s.checked&&(i.value=s.value):i.value=s.value};s.addEventListener(m,y),n.push(()=>s.removeEventListener(m,y))},zs=e=>(t,r,n,s)=>{const a=i=>{const o={...n,$event:i,$el:t};if(!r.includes("(")){const c=ye(r,o);if(typeof c=="function"){c(i);return}return}ye(r,o)};t.addEventListener(e,a),s.push(()=>t.removeEventListener(e,a))};function Bs(e){const t=Object.getOwnPropertyDescriptor(e,"value");return t?"value"in t?t.writable===!0:typeof t.set=="function":!1}var Us=(e,t,r,n)=>{const s=ye(t,r);ue(s)?(s.value=e,n.push(()=>{s.value=null})):typeof s=="object"&&s!==null&&Bs(s)&&(s.value=e,n.push(()=>{s.value=null}))},Fs=(e,t,r,n)=>{const s=e;let a=s.style.display;if(!a||a==="none"){const o=s.ownerDocument.defaultView?.getComputedStyle(s).display??"";a=o!=="none"?o:""}const i=$(()=>{const o=R(t,r);s.style.display=o?a:"none"});n.push(i)},Ws=(e,t,r,n)=>{const s=e;let a=new Set;const i=$(()=>{const o=new Set;if(t.trimStart().startsWith("{")){const c=jt(t);for(const[l,d]of Object.entries(c)){const m=R(d,r),y=l.replace(/([A-Z])/g,"-$1").toLowerCase();s.style.setProperty(y,String(m??"")),o.add(y)}}else{const c=R(t,r);if(c&&typeof c=="object")for(const[l,d]of Object.entries(c)){const m=l.replace(/([A-Z])/g,"-$1").toLowerCase();s.style.setProperty(m,String(d??"")),o.add(m)}}for(const c of a)o.has(c)||s.style.removeProperty(c);a=o});n.push(i)},Qs=(e,t,r,n)=>{const s=$(()=>{const a=R(t,r);e.textContent=String(a??"")});n.push(s)},ge=(e,t,r,n,s)=>{const a=Array.from(e.attributes);for(const i of a){const{name:o,value:c}=i;if(!o.startsWith(`${r}-`))continue;const l=o.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==="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 d=l.slice(5);s.bind(d)(e,c,t,n)}else if(l.startsWith("on:")){const d=l.slice(3);s.on(d)(e,c,t,n)}}},Ne=(e,t,r,n,s)=>{const a=Array.from(e.children);for(const i of a)i.hasAttribute(`${r}-for`)?ge(i,t,r,n,s):(ge(i,t,r,n,s),Ne(i,t,r,n,s))},It=(e,t,r={})=>{const{prefix:n="bq",sanitize:s=!0}=r,a=typeof e=="string"?document.querySelector(e):e;if(!a)throw new Error(`bQuery view: Element "${e}" not found.`);if(a.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=[],o={text:Qs,html:js(s),if:Is,show:Fs,class:_s,style:Ws,model:Hs,ref:Us,for:qs({prefix:n,processElement:(l,d,m,y)=>ge(l,d,m,y,o),processChildren:(l,d,m,y)=>Ne(l,d,m,y,o)}),bind:Ns,on:zs};return((l,d,m)=>{const y=l.hasAttribute(`${n}-for`);ge(l,d,n,m,o),y||Ne(l,d,n,m,o)})(a,t,i),{el:a,context:t,update:l=>{Object.assign(t,l)},destroy:()=>{for(const l of i)l();i.length=0}}},xs=(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:a="bq"}=t;if(s.hasAttribute(`${a}-for`)||s.hasAttribute(`${a}-if`)){const i=s.hasAttribute(`${a}-for`)?"for":"if";throw new Error(`bQuery view: Template root element cannot have ${a}-${i} directive. Wrap the ${a}-${i} element in a container instead.`)}return It(s,r,t)};return h.$=ir,h.$$=or,h.BQueryCollection=se,h.BQueryElement=U,h.Computed=Ae,h.Signal=Ce,h.animate=he,h.back=is,h.batch=le,h.bool=An,h.buckets=Wn,h.cache=xn,h.capturePosition=Re,h.component=x,h.computed=W,h.createPersistedStore=Ps,h.createRouter=gs,h.createStore=Lt,h.createTemplate=xs,h.createTrustedHtml=nr,h.createUseFetch=fn,h.currentRoute=kt,h.defineBqueryConfig=Zr,h.definePageMeta=ts,h.destroyStore=Os,h.easeInCubic=mt,h.easeInOutCubic=yt,h.easeInOutQuad=ht,h.easeInQuad=ft,h.easeOutBack=gt,h.easeOutCubic=pt,h.easeOutExpo=vt,h.easeOutQuad=dt,h.easingPresets=Rn,h.effect=$,h.escapeHtml=Qe,h.flip=Me,h.flipElements=bt,h.flipList=Mn,h.forward=os,h.generateNonce=er,h.getBqueryConfig=I,h.getStore=Mt,h.getTrustedTypesPolicy=We,h.hasCSPDirective=tr,h.html=V,h.interceptLinks=ls,h.isActive=ps,h.isActiveSignal=ys,h.isComputed=nt,h.isSignal=ue,h.isTrustedTypesSupported=rr,h.keyframePresets=Pn,h.linear=ut,h.link=cs,h.linkedSignal=dn,h.listStores=ks,h.mapActions=Ms,h.mapState=Rs,h.mount=It,h.navigate=me,h.notifications=Zn,h.persistedSignal=hn,h.prefersReducedMotion=de,h.readonly=mn,h.registerDefaultComponents=Tn,h.registerPlugin=Es,h.resolve=ms,h.safeHtml=Cn,h.sanitize=j,h.sanitizeHtml=j,h.scrollAnimate=Nn,h.sequence=zn,h.signal=M,h.spring=Dn,h.springPresets=qn,h.stagger=jn,h.storage=as,h.stripTags=sr,h.timeline=Bn,h.transition=Un,h.trusted=Yt,h.untrack=Q,h.useAnnouncer=es,h.useAsyncData=tt,h.useCookie=Yn,h.useFetch=rt,h.utils=xr,h.watch=pn,h})({});
176
176
 
177
177
  //# sourceMappingURL=full.iife.js.map