yvee 0.0.10 → 0.1.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.
- package/LICENSE +1 -1
- package/README.md +131 -0
- package/dist/assets.d.ts +290 -0
- package/dist/index.d.ts +1128 -785
- package/dist/index.js +3 -1
- package/package.json +34 -13
- package/readme.md +0 -3
package/dist/index.js
CHANGED
|
@@ -1 +1,3 @@
|
|
|
1
|
-
var Mn=Object.defineProperty;var Xn=(o,n)=>{for(var i in n)Mn(o,i,{get:n[i],enumerable:!0,configurable:!0,set:(t)=>n[i]=()=>t})};var B=function(o,n,i,t){var r=arguments.length,f=r<3?n:t===null?t=Object.getOwnPropertyDescriptor(n,i):t,m;if(typeof Reflect==="object"&&typeof Reflect.decorate==="function")f=Reflect.decorate(o,n,i,t);else for(var u=o.length-1;u>=0;u--)if(m=o[u])f=(r<3?m(f):r>3?m(n,i,f):m(n,i))||f;return r>3&&f&&Object.defineProperty(n,i,f),f};var g=(o,n)=>{if(typeof Reflect==="object"&&typeof Reflect.metadata==="function")return Reflect.metadata(o,n)};var Zo={};Xn(Zo,{isWindow:()=>c,isUndefined:()=>Wn,isStr:()=>p,isPromise:()=>Jn,isPlainObject:()=>j,isObject:()=>Fn,isObj:()=>R,isNumber:()=>_,isNum:()=>Uo,isNull:()=>fo,isNotWindow:()=>U,isNotNull:()=>En,isModule:()=>Lo,isInt:()=>Bo,isFN:()=>L,isDefined:()=>Sn,isClassOrId:()=>jn,isBool:()=>N,isAsync:()=>qn,isArraybuff:()=>Qn,isArr:()=>b});var L=(o)=>typeof o==="function",qn=(o)=>o.constructor.name==="AsyncFunction",Jn=(o)=>!!o&&typeof o.then==="function",_=(o)=>{return!isNaN(parseFloat(o))&&isFinite(o)},Fn=(o)=>{return o&&typeof o==="object"&&!Array.isArray(o)},j=(o)=>{return typeof o==="object"&&o!==null&&Object.getPrototypeOf(o)===Object.prototype&&!Array.isArray(o)},Lo=(o)=>{return o&&typeof o==="object"&&o[Symbol.toStringTag]==="Module"},Qn=(o)=>{return o instanceof Uint8Array||o instanceof ArrayBuffer||typeof o==="string"},jn=(o)=>{return o.startsWith(".")||o.startsWith("#")},N=(o)=>typeof o==="boolean",p=(o)=>typeof o==="string",b=(o)=>Array.isArray(o),R=(o)=>typeof o==="object",Uo=(o)=>typeof o==="number",fo=(o)=>o===null,En=(o)=>o===null,Wn=(o)=>typeof o==="undefined",Sn=(o)=>typeof o!=="undefined",Bo=(o)=>{return Number.isInteger(Number(o))},c=typeof window!=="undefined",U=typeof window==="undefined";var zn=(o)=>{if(U)return;return o()};function lo(o,n){$(n).forEach(([i,t])=>{ao(o,i,{value:t,writable:!1,configurable:!1,enumerable:!0})})}var Ao=(o)=>{return b(o)?o:[o]};class I{static set i(o){console.info(...Ao(o))}static set e(o){console.error(...Ao(o))}static set w(o){console.warn(...Ao(o))}}class A{_c=0;_id="";constructor(o){if(this._c=0,this._id=o??E(5),o?.includes("-")){let[n,i]=[o.split("-").slice(0,-1).join("-"),o.split("-").slice(-1)[0]];this._id=n,this._c=_(i)?parseInt(i):0}}get id(){return this._id+"-"+this._c}get mid(){return this._id+"-"+ ++this._c}}var In=(o)=>Array.from({length:o},(n,i)=>i),ko="ABCDEFGHIJKLMNOPQRSTUVWXYZ",eo="abcdefghijklmnopqrstuvwxyz";var w=(o)=>JSON.stringify(o),vo=(o)=>{return JSON.parse(o)};var X=(o)=>{if(o.startsWith("webkit"))o="-"+o;return o.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()},E=(o)=>{let n=ko+eo,i=In(10).join("");return Array.from({length:o},(t,r)=>n+(r?i:"")).reduce((t,r)=>{return t+=r.charAt(Math.floor(Math.random()*r.length))},"")},Kn=(o=6,n)=>{if(!n)return Math.floor(Math.random()*o);return Math.round(Math.random()*(n-o)+o)},on=()=>{let o=[...ko,...eo],n=Kn(0,o.length);return o[n]};class y extends Map{obj(o){o&&$(o).forEach(([n,i])=>this.set(n,i))}map(o){o.forEach((n,i)=>{if(n instanceof y)this.set(i,n);else if(b(n)){if(this.lacks(i))this.set(i,[]);this.get(i).push(...n)}else if(R(n))this.ass(i,n);else this.set(i,n)})}ass(o,n){if(!this.has(o))this.set(o,{});T(this.get(o),n)}lacks(o){return!this.has(o)}init(o,n){return this.has(o)?this.get(o):this.set(o,n).get(o)}}var{values:G,keys:K,entries:$}=Object;var{defineProperty:ao,assign:T}=Object,nn=(o,n)=>Object.hasOwn(o,n),W=(o)=>{return Object.keys(o).length},uo=(o,n)=>{if(!n.has(o))n.set(o,new y);return n.get(o)},l=(o,n)=>{if(!n.has(o))n.set(o,[]);return n.get(o)},d=(o,n)=>{let i={added:{},removed:{},modified:{}},t=K(o),r=K(n);for(let f of r){let m=o[f],u=n[f];if(!(f in o))i.added[f]=u;else if(b(m)&&b(u)){if(w(m)!==w(u))i.modified[f]={old:m,new:u}}else if(R(m)&&R(u)&&!fo(m)&&!fo(u)){let x=d(m,u);if(W(x.added)||W(x.removed)||W(x.modified))i.modified[f]={old:m,new:u}}else if(m!==u)i.modified[f]={old:m,new:u}}for(let f of t)if(!(f in n))i.removed[f]=o[f];return i};function tn(o,n){if(o.size!==n.size)return!1;for(let i of o)if(!n.has(i))return!1;return!0}var mo=(o)=>{return G(o).some((n)=>{return W(n)})};var Z=(o,n,i)=>{let t=i.value;return{configurable:!0,get(){if(this===o.constructor.prototype)return t;let r=t.bind(this);return Object.defineProperty(this,n,{value:r,configurable:!0,writable:!0}),r}}};var z=(o,n)=>{return{name:o,content:n}},sn=(o,n)=>{return{property:o,content:n}},Cn=(o,n)=>{return{"http-equiv":o,content:n}};class a{metas=[];constructor(o){o&&this.metas.push(z("description",o))}author(o){return this.meta=z("author",o),this}charset(o){return this.meta={charset:o},this}keywords(...o){return this.meta=z("keywords",o.join(", ")),this}viewport(o){let n=$(o).map(([i,t])=>[X(i),String(t)].join("="));return this.meta=z("viewport",n.join(", ")),this}httpEquiv(o){return $(o).forEach(([n,i])=>{this.meta=Cn(X(n),String(i))}),this}robots(...o){return this.meta=z("robots",o.join(", ")),this}themeColor(o){return this.meta=z("theme-color",o),this}openGraph(o){return $(o).forEach(([n,i])=>{this.meta=sn("og:"+n,String(i))}),this}twitter(o){return $(o).forEach(([n,i])=>{this.meta=z("twitter:"+n,String(i))}),this}push(o){this.metas.unshift(...o)}set meta(o){this.metas.push(o)}}class wo{}var Pn=["charset","name","property","http-equiv"],rn=(o,n,i=!1,t={})=>{n.forEach((r)=>{for(let f of Pn)if(f in r){let m=r[f];if(i)T(r,{x:!0});else if(!("x"in r))T(r,t);o[`${f}_${f==="charset"?"":m}`]=r}})},Vn=(o,n,i=!1,t={})=>{n.forEach((r)=>{if("href"in r){let f=r.href;if(i)T(r,{x:!0});else if(!("x"in r))T(r,t);o[`${f}`]=r}})};class fn{_head;idm;mark;push;constructor({initial:o,mark:n,push:i}={}){this._head=new y(o),this.mark=n||!1,this.push=i||{}}set head(o){$(o).forEach(([n,i])=>{if(n==="title"||n==="base"){if(i!==void 0){if(n=="base"){if(this.mark)T(i[0]||{},{x:!0})}this._head.set(n,i)}return}if(i instanceof a)return rn(this._head.init("meta",{}),i.metas,this.mark,this.push);if(!b(i))return;switch(n){case"meta":return rn(this._head.init("meta",{}),i,this.mark,this.push);case"link":return Vn(this._head.init("link",{}),i,this.mark,this.push);case"script":if(i.length){this._head.init(n,[]);let t=i.map((r)=>{if(!r.yid&&this.idm)r.yid="sc"+this.idm.mid;if(this.mark)T(r,{x:!0});else if(!("x"in r))T(r,this.push);return r});this._head.get(n).push(...t)}return}})}get head(){return this._head}set id(o){this.idm=new A(o)}}var Ro=(o)=>{return $(o??{}).reduce((n,[i,t])=>{return n.push(N(t)&&t?i:`${i}="${t}"`),n},[""]).join(" ")},un=(o)=>{let n=new Set;if(!o)return"";let i=[...o].reduce((t,[r,f])=>{if(r==="meta"||r==="link")f=G(f);if(p(f)){if(r==="title")n.add(`<${r}>${f}</${r}>`);else t.add(`<${r}>${f}</${r}>`);return t}if(!b(f))return t;if(r==="base"){let u=f.slice(-1);if(u)return n.add(`<${r}${Ro(u[0])}>`),t}return f.map((u)=>{if(r==="script"){let x={...u},h="";if("importmap"in x)x.type="importmap",h=JSON.stringify(x.importmap),delete x.importmap;else if("body"in x)h=x.body,delete x.body;return`<${r}${Ro(x)}>${h}</${r}>`}return`<${r}${Ro(u)}>`}).forEach((u)=>{if(u.includes('type="module"'))n.add(u);else if(u.includes("<meta"))n.add(u);else t.add(u)}),t},new Set);return[...n,...i].join("")};class k{lang="en";htmlHead;head;constructor({mark:o,push:n}={}){this.htmlHead=new y,this.head=(i={})=>{let t=new fn({initial:this.htmlHead,mark:o,push:n}),{link:r,script:f,meta:m,title:u,description:x,css:h,js:H}=i;if(x)t.head={meta:[{name:"description",content:x}]};if(On(t,{css:h,js:H}),"base"in i)t.head={base:i.base};t.head={script:f,title:u,meta:m,link:r},this.htmlHead=t.head}}}var On=(o,n)=>{let{css:i,js:t}=n;if(i){let f=(b(i)?i:[i]).map((m)=>({rel:"preload stylesheet",href:m,as:"style"}));o.head={link:[...f]}}if(t){let f=(b(t)?t:[t]).map((m)=>({src:m}));o.head={script:[...f]}}};var Go=async(o)=>{if(U)return;return new Promise((n,i)=>{let t=document.createElement("link");if(o.rel!=="stylesheet")o.rel="stylesheet",o.as="style";$(o).forEach(([r,f])=>{t.setAttribute(r,f)}),t.onload=()=>n(t),t.onerror=()=>i(new Error("Failed to load CSS")),document.head.appendChild(t)})};var mn=(o)=>{if(U)return;return new Promise((n,i)=>{let t=document.createElement("script"),r="";if("importmap"in o)o.type="importmap",r=JSON.stringify(o.importmap),delete o.importmap;else if("body"in o)r=o.body,delete o.body;if(r)t.textContent=r;$(o).forEach(([f,m])=>{t.setAttribute(f,m)}),t.onload=()=>n(t),t.onerror=()=>i(new Error("Failed to load Script")),document.head.appendChild(t),requestAnimationFrame(()=>n("Script executed"))})},_n=()=>{let n=document.querySelector("#d-css")?.sheet;if(n)return n;let i=document.createElement("style");return i.id="d-css",document.head.appendChild(i),i.sheet},Nn=(o,n)=>{for(let i=0;i<o.cssRules.length;i++)if(o.cssRules[i].selectorText===n)return!0;return!1},pn=(o)=>Object.entries(o).map(([n,i])=>`${X(n)}: ${i};`).join(" ");function cn(o,n={}){if(U)return;let i=_n();if(!i)return;if(!Nn(i,o))i.insertRule(`${o} { ${pn(n)} }`,i.cssRules.length)}var xn=(o,n=!1)=>{if(_(o))return[+o,Bo(o)?"int":"float"];if(n&&/\.\w+$/.test(o))return[o,"file"];if(o==="/")return[o,"-"];if(o.length===36&&o.match(/\-/g)?.length===4)return[o,"uuid"];return[o,"string"]},xo=(o)=>{let n=o.startsWith("/")?o:"/"+o,i=n.match(/(?<=\/)[^/].*?(?=\/|$)/g)??["/"],[t,r]=i.reduce(([f,m],u)=>{if(u.includes("<")){let x=u.match(/(?<=<)[^/].*?(?=>|$)/g);if(x?.length){let[h,H]=x[0].split(":");if(h)f.push(h),m.push(H||"_")}}else f.push(u===">"?"/":u);return[f,m]},[[],[]]);if(n.endsWith("/")&&n.length>1)t.push("/");return{parsed:t,args:r}};class go{storage;constructor(){this.storage=new y}cache(o,n){if(this.storage.lacks(o))this.storage.set(o,n());return this.storage.get(o)}}var ln=["int","float","file","uuid","string"];class s{_storage;CC;constructor(){this._storage=new y,this.CC=new go}set(o){let{parsed:n,path:i}=o,t=w(n);if(!this._storage.get(t))this._storage.set(t,o);else throw`path: ${i} already used.`}get(o){let{parsed:n}=this.CC.cache(o,()=>xo(o)),i={},t=this._storage.get(w(n));if(!t&&o!=="/")for(let r of this._storage.keys()){let f=[],m=vo(r);if(n.length===m.length){let u=m.map((H,S)=>{let J=xn(n[S],n.length-1===S);if(H===J[0])return J[0];if(ln.includes(J[1]))return f.push(J[0]),J[1];return H}),x=w(u);if(this._storage.has(x)){t=this._storage.get(x),t?.args.forEach((H,S)=>{i[H]=f[S]});break}}}return[t,i]}keys(){return this._storage.keys()}}class To{path="";parsed=[];args=[];constructor(o){lo(this,{path:o,...xo(o)})}}class Mo{date;constructor(o){this.date=o?new Date(o):new Date}delta(o=null,n=!1){let i=Mo.delta(this.date.getTime(),o);return n?new Date(i):i}timed(o){if(!o)return this.date;return[["year","FullYear"],["month","Month"],["day","Date"],["hour","Hours"],["minute","Minutes"],["second","Seconds"]].reduce((i,[t,r])=>{let f=o[t];return f?new Date(i[`set${r}`](i[`get${r}`]()+f)):i},new Date(this.date))}static delta(o,n=null){return n?n-o:o-Date.now()}static local(o){return new Date(o).toLocaleString()}static get now(){return Date.now()}}class Xo{static rand(o=6,n){if(n)return Math.floor(Math.random()*(n-o+1)+o);return Math.floor(Math.random()*o)+1-1}static fill(o,n=null){return Array(o).fill(n)}static new({dom:o,id:n,inner:i}){let t=document.createElement(o);if(n)t.id=n;if(i)t.innerHTML=i;return t}static randFrom(o){if(Array.isArray(o)){let n=o.length,i=this.rand(0,n-1);return o[i]}else if(typeof o=="object"){let n=K(o),i=n.length,t=this.rand(0,i-1);return n[t]}}static randArray(o=[],n=1,i=!1){let t=[],r=i?new Set:null;while((i?r.size:t.length)<n){let f=o[Xo.rand(0,o.length-1)];i?r.add(f):t.push(f)}return i?[...r]:t}static randomAZ=on;static makeID=E;static class(o,...n){let i=n.filter(Boolean);if(o?.class)i.push(...b(o.class)?o.class:[o.class]);if(i.length)o.class=i}static get O(){return{vals:G,keys:K,items:$,has:nn,ass:T,len:(o={})=>K(o).length}}static get is(){return Zo}static get return(){return gn}static isHREF(o,n){return o===n?!0:o.startsWith(n)&&n!=="/"?!0:!1}static sleep=(o=1000)=>new Promise((n)=>setTimeout(n,o));static get screen(){let{innerWidth:o}=window,n={xs:o<=480,sm:o>=480,smd:o>=624,md:o>=768,lg:o>=1024,xl:o>=1280,xxl:o>=1536},i=$(n).reverse();for(let t=0;t<i.length;t++){let[r,f]=i[t];if(f)return r}return}bytes(o){if(o===0)return"0 Bytes";let n=1024,i=["Bytes","KB","MB","GB"],t=Math.floor(Math.log(o)/Math.log(n));return parseFloat((o/Math.pow(n,t)).toFixed(2))+" "+i[t]}static format(o){return new Tn(o)}static compareObjects=d;static isObjectUdpated=mo}class gn{static arr(o){return o?b(o)?o:[o]:[]}static num(o,n=0){let i=parseFloat(o);return isNaN(i)?n:i}static str(o){return String(o)}static arr2obj(o,n=!1){return o.reduce((i,t,r)=>{if(n)i[t]=r;else i[r]=t;return i},{})}}class Tn{val;constructor(o){this.val=o}get px(){return`${this.val}px`}get rem(){return`${this.val}rem`}get pr(){return`${this.val}%`}}async function C(o,n,{id:i="stateHook",init:t}={}){let r=[],f=()=>n.map((u)=>u.value),m=async()=>{await o(...f())};if(n.forEach((u)=>{r.push(u.hook(m)(i))}),t)await m();return()=>{r.forEach((u)=>u())}}var bn=(o)=>{o.forEach((n)=>n())};var dn=(o,n)=>{for(let[i,t]of o){let r=P(i);if(!r){o.delete(i);continue}t.forEach((f)=>{f.call(r,n)})}};class q extends EventTarget{options;deep;verify;hooks=new y;states=new y;_value;listening=!1;end;constructor(o,n={},i=!0,t=!0){super();this.options=n;this.deep=i;this.verify=t;this._value=o}get value(){return this._value}set value(o){if(!this.verify){this._value=o,this.dispatchEvent(new CustomEvent("updated",{detail:this._value}));return}if(!this.deep){if(this._value===o)return;this._value=o,this.dispatchEvent(new CustomEvent("updated",{detail:this._value}));return}if(j(this._value)||b(this._value)){let n=d(this._value,o);if(!mo(n))return}else if(this._value instanceof Set){if(!tn(this._value,o))return}else if(this._value===o)return;this._value=o,this.dispatchEvent(new CustomEvent("updated",{detail:this._value}))}get listen(){let o=(n)=>{if(bn(this.hooks),dn(this.states,n.detail),!this.states.size&&!this.hooks.size)this.end?.()};if(!this.listening)this.addEventListener("updated",o,this.options),this.listening=!0;return()=>{this.listening&&this.removeEventListener("updated",o,this.options),this.end=void 0,this.listening=!1}}call(o,n){return(i)=>{if(uo(i,this.states).set(n,o),!U&&!this.listening)this.end=this.listen;return()=>{if(this.states.has(i))this.states.get(i)?.delete(n)}}}hook(o){return(n)=>{if(this.hooks.set(n,o),!U&&!this.listening)this.end=this.listen;return()=>{if(this.hooks.has(n))this.hooks.delete(n)}}}}function M(o,n={}){return new q(o,n,!0)}function an(o,n=!1){return new q(o,{},!1,n)}class qo{e;opt;constructor(o){this.e=o;this.opt={duration:500,easing:"ease-in-out",fill:"forwards"}}animate(o,n={}){return this.e.animate(o,n)}get slide(){let o=({x:n=0,y:i=0},t={})=>{T(this.opt,t);let r=[[n,i],[0,0]].map(([f,m])=>({transform:`translateX(${f}rem) translateY(${m}rem)`}));return this.e.animate(r,this.opt),this};return{left:(n={})=>{return o({x:-2},n)},right:(n={})=>{return o({x:2},n)},up:(n={})=>{return o({y:2},n)},down:(n={})=>{return o({y:-2},n)}}}fade(o={}){T(this.opt,o);let n=[0,1].map((i)=>({opacity:i}));return this.e.animate(n,this.opt),this}shake(o="Y",n={}){T(this.opt,n);let i=[0,5,-5,5,0].map((t)=>({transform:`translate${o}(${t}px)`}));return this.e.animate(i,this.opt),this}color(o=[],n={}){T(this.opt,n);let i=Array.isArray(o)?o.map((t)=>({color:t})):{color:o};return this.e.animate(i,this.opt),this}bg(o=[],n={}){T(this.opt,n);let i=Array.isArray(o)?o.map((t)=>({backgroundColor:t})):{backgroundColor:o};return this.e.animate(i,this.opt),this}bounce(o=1,n={}){T(this.opt,n);let i=[0.5,o,1].map((t)=>({transform:`scale(${t})`}));return this.e.animate(i),this}}var e=(o)=>{if(b(o))return o.filter((n)=>n!==void 0).join(" ");else if(R(o)){if(j(o))return w(o)}else if(L(o))return e(o());else if(o!==void 0&&o!==null)return N(o)?o?"":"false":String(o);return""};function kn(o,n){switch(n??o){case"style":return function(i){this.style.setProperty(o,i)};default:return function(i){this.setAttribute(o,i)}}}class Jo{attr;constructor(o={}){this.attr=o}get(o,n=this.attr,i){let t=(r,f)=>{if(b(f))o.attr_push(r,e(f),i);else if(f instanceof q){let m=i?`${i}_${r}`:r;o.states.push(f.call(kn(r,i),m)),t(r,f.value)}else if(R(f)){if(j(f)&&!i)this.get(o,f,r)}else o.attr_push(r,e(f),i)};$(n).forEach(([r,f])=>{if(r==="ref"){if(f instanceof v)o.events.obj({element(){f.element=this}})}else if(["on"].includes(r))R(n.on)&&o.events.obj(n.on);else{if(f===void 0)return;t(r,f)}})}unload(o){let n=void 0;if(o in this.attr)n=this.attr[o],delete this.attr[o];return n}}var en=["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"],vn=(o)=>en.includes(o);function oi(o){return String(o).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}var bo=async(o,n)=>{if(o=await Promise.resolve(o),b(o)){let i=[];for(let t of o)i.push(await bo(t,n));return i.join("")}else if(o instanceof V){let{ctx:i,oz:t}=await jo(o,n.IDM);return n.OZ.push(t),i}else if(R(o))return w(o);else if(L(o))return await bo(o(),n);else if(o!==void 0&&o!==null)return oi(o);return""},yo=async(o,n)=>{let i=new A(n),t=new oo(i.id,i);return{ctx:await bo(o,t),catt:t}};async function ni(o){let n=this.id;if(n){let{ctx:i,catt:t}=await yo(o,n);if(this.innerHTML!==i)this.innerHTML=i,F.RPS(t.OZ)}}var Fo=async(o,n,i,t=[])=>{if(b(o))for(let r of o)await Fo(r,o.length,i,t);else if(o instanceof q)if(n>1)await Fo(await Y("div",{},o),n,i,t);else{let r=o.value,f=r instanceof V?"dom":"ctx",{ctx:m,catt:u}=await yo(r,i.xid+"-0");i.xid=u.xid,t.push(m),i.OZ.push(u.OZ),i.states.push(o.call(ni,f))}else t.push(await bo(o,i))};class Qo{tag;ctx;closing;constructor(o="",n){this.tag=o;this.ctx=n;let i=vn(o);this.closing=i?"":`</${o}>`}async process(o,n=this.ctx,i=[]){for(let t of n)await Fo(await Promise.resolve(t),n.length,o,i);return i.join("")}async get(o){let n=await this.process(o);if(!this.tag)return n;if(o.events.size||o.states.length)o.id=o.xid;return`<${this.tag}${o.attr}>${n}${this.closing}`}}class So{e;query;constructor(o,n){this.e=o;this.query=n}get a(){return new qo(this)}get all(){if(this.query){let o=document.querySelectorAll(this.query);if(o.length)return Array.from(o).map((n)=>n)}return[]}get attr(){let o=this.e;return{has:(n)=>{return o.hasAttribute(n)},get:(n)=>{return o.getAttribute(n)},del:(n)=>{return o.removeAttribute(n),this},set:(n)=>{for(let i in n){let t=n[i];if(n[i]!==void 0)o.setAttribute(i,e(t))}return this}}}get children(){return Array.from(this.e.children).map((o)=>D(o))}get click(){return this.e.click(),this}get delete(){return this.e.remove(),this}get disabled(){return this.e.disabled??!1}get focus(){return this.e.focus(),this}get href(){return this.e?.href??""}get id(){return this.e.id}get inner(){return this.e.innerHTML}get offsetParent(){let o=this.e.offsetParent;if(o)return new Q(o);return}get parent(){let o=this.e.parentElement;if(o)return new Q(o);return}get hash(){return this.e?.hash??""}get path(){return this.e?.pathname??""}get rect(){return this.e.getBoundingClientRect()}get remove_element(){return this.e.remove(),this}get style(){let o=this.e.style,n=this;return{set:(i,t=0)=>{let r=o,f=()=>{$(i).forEach(([m,u])=>{if(m in r){if(r[m]!==u)r[m]=u}else if(u!==null)o.setProperty(m,String(u))})};if(L(t))n.on("transitionend",t);if(Uo(t))setTimeout(f,t);else f();return n},get:(i)=>{let t=X(String(i));return o.getPropertyValue(t)},del:(...i)=>{i.forEach((t)=>{let r=X(String(t));o.removeProperty(r)})}}}get submit(){let o=this.e;if("submit"in o)return o.submit();return!1}get tag(){return this.e.tagName.toLowerCase()}get value(){return this.e.value??""}get unload(){return()=>{this.e.remove()}}set append(o){Eo(o,Wo(this.id)).then((n)=>{let{ctx:i,catt:t}=n;this.e.insertAdjacentHTML("beforeend",i),F.RPS(t.OZ)})}set appendfirst(o){Eo(o,Wo(this.id)).then((n)=>{let{ctx:i,catt:t}=n;this.e.insertAdjacentHTML("afterbegin",i),F.RPS(t.OZ)})}set inner(o){Eo(o,Wo(this.id)).then((n)=>{let{ctx:i,catt:t}=n;this.e.innerHTML=i,F.RPS(t.OZ)})}set disabled(o){let n=this.e;if("disabled"in n)n.disabled=o}set id(o){this.e.id=o}set value(o){let n=this.e;n.value=o}}var Eo=(o,n)=>{return yo(o,n)},Wo=(o)=>o?`${o}-0`:o;class Q extends So{constructor(o,n){super(o,n)}add(...o){return this.e.classList.add(...o.map((n)=>n.replace(/[^\w-]/,""))),()=>{this.e.classList.remove(...o.map((n)=>n.replace(/[^\w-]/,"")))}}remove(...o){return this.e.classList.remove(...o.map((n)=>n.replace(/[^\w-]/,""))),this}toggle(o,n){let i=typeof o!="string"?o.apply(this):o;return this.e.classList.toggle(i,n)}hasNode(o){return this.e.contains(o)}has(...o){let n=this.e.classList;return o.every((i)=>n.contains(i))}insert(o){return{HTML:(...n)=>{return n.forEach((i)=>{this.e.insertAdjacentHTML(o,i)}),this},element:(...n)=>{return n.forEach((i)=>{this.e.insertAdjacentElement(o,i)}),this},text:function(...n){return n.forEach((i)=>{this.e.insertAdjacentText(o,i)}),this}}}is(o){let n=this.e.classList,i=this.e.tagName.toLocaleLowerCase(),t=!0,r=!0;if(o.dom)r=o.dom==i?!0:!1;if(o.class)if(Array.isArray(o.class))o.class.forEach((f)=>{t=t?n.contains(f):!1});else t=t?n.contains(o.class):!1;return t&&r}on(o,n,i=!1){let t=!1;if(o.indexOf("touch")>-1)t=!0;return this.e.addEventListener(o,n,{capture:i,passive:t}),this}remove_on(o,n,i=!1){return this.e.removeEventListener(o,n,i),this}timed(o,n=250){return setTimeout(()=>o(this),n),this}animate(o,n,i){let t={duration:300,easing:"ease",fill:"forwards"};if(L(n))i=n;else T(t,n);let r=this.e.animate(o,t);if(i)r.finished.then(i);return this}}var no=new y,P=(o)=>{if(U)return;let n=no.get(o);if(n?.isConnected)return n;no.delete(o);let i=document.getElementById(o);if(!i)return;return no.set(o,i),i};function yn(){let o=[];for(let[n,i]of no)if(!i.isConnected)o.push(n),no.delete(n);return o}function D(o,n){let i=n?n:document;if(p(o)){let t=i.querySelector(o);if(t)return new Q(t,o);return}else if(j(o)){let[[t,r]]=$(o),m=`${t==="id"?"#":"."}${r}`,u=i.querySelector(m);if(u)return new Q(u,m);return}else return new Q(o)}class v{state=new q(void 0);constructor(){}get element(){return this.state.value?.e}set element(o){if(o)this.state.value=new Q(o);else this.state.value=void 0}get $(){return this.state.value}}var ii=()=>{return new v};var ti=(o,n,i)=>{return o.addEventListener(n,i),()=>{o.removeEventListener(n,i)}},io={};class $o{events=new y;states=new y;windowEvents=new y;resetST=new y;resetEV=new y;get keys(){return[...new Set([...this.states.keys(),...this.events.keys()])]}set(o){let{id:n,events:i,states:t}=o;if(n){if(i.size)this.events.set(n,i);if(t.length)this.states.set(n,t)}return this}push(o){return o.events.forEach((n,i)=>{n.forEach((t,r)=>{uo(i,this.events).set(r,t)})}),o.states.forEach((n,i)=>{l(i,this.states).push(...n)}),this}get stage(){return this.events.forEach((o,n)=>{this.events.delete(n);let i=P(n);if(!i){this.events.delete(n);return}o.forEach((t,r)=>{switch(r){case"ready":case"element":t.apply(i,[i]);break;case"resize":case"beforeunload":case"popstate":case"winscroll":case"winload":case"winfocus":case"winblur":let f=r.replace(/^win/,"");this.windowEvents.init(f,new y).set(n,t);break;case"state":let[m,u,x]=t.apply(i,[i]),h=b(u)?u:[u];if(!h.length)break;let H=()=>h.map((J)=>J.value),S=()=>m(...H());if(x)S();h.forEach((J)=>l(n,this.resetST).push(J.call(S,n+"_state")(n)));break;default:l(n,this.resetEV).push(ti(i,r,t))}})}),this.processWindowEvents,this.states.forEach((o,n)=>{this.states.delete(n),o.forEach((i)=>{l(n,this.resetST).push(i(n))})}),this}get processWindowEvents(){let o=(n,i)=>{let t=0,r=!1,f=(u)=>{if(t=window.scrollY,!r)window.requestAnimationFrame(()=>{i.forEach((x,h)=>{let H=P(h);if(H)x.call(H,u);else this.windowEvents.get(n)?.delete(h)}),r=!1}),r=!0},m=(u)=>{i.forEach((x,h)=>{let H=P(h);if(H)x.call(H,u);else this.windowEvents.get(n)?.delete(h)})};return window.addEventListener(n,n==="scroll"?f:m),()=>{window.removeEventListener(n,n==="scroll"?f:m)}};return this.windowEvents.forEach((n,i)=>{if(n.size){if(!io[i])io[i]=o(i,n)}else if(io[i])io[i](),delete io[i]}),this}reset(o){return o.forEach((n)=>{this.windowEvents.forEach((i,t)=>{if(i.has(n))i.delete(n)}),this.resetEV.get(n)?.forEach((i)=>{i()}),this.resetST.get(n)?.forEach((i)=>{i()}),this.resetST.delete(n),this.resetEV.delete(n)}),this}RPS(o){if(o){let n=yn();this.reset(n);let i=o.keys;if(i.length)this.reset(i).push(o).stage}return this}}var F=new $o;class oo{xid;IDM;map=new y;states=[];events=new y;OZ;constructor(o,n=new A,i){this.xid=o;this.IDM=n;this.OZ=i??new $o}attr_push(o,n,i){let t=i??o;if(!this.map.has(t))this.map.set(t,[]);let r=i?`${X(o)}:${n};`:n;this.map.get(t).push(r)}get attr(){let o=[""];return this.map.forEach((n,i)=>{let t=n.join("");o.push(t?`${i}="${t}"`:i)}),o.join(" ")}set id(o){if(!this.map.has("id"))this.map.set("id",[o])}get id(){return this.map.get("id")?.join("")}}async function $n(o,n){return await jo(o,new A(n))}async function jo(o,n=new A){let{tag:i,attr:t,ctx:r}=o,f=n instanceof A?n:new A(n),m=f.mid,u=new oo(m,f),x=new Jo(t),h=new Qo(i,r);return x.get(u),{ctx:await h.get(u),oz:u.OZ.set(u),id:u.id}}class V{tag;attr;ctx;constructor(o,n,i){this.tag=o;this.attr=n;this.ctx=i}}async function Y(o,n={},...i){if(L(o))return await o(n??{},...i);return new V(o,n??{},i)}var ri=async(o,...n)=>new V("",{},n);async function hn(o={},n){let i=D("link[rt]")?.all.map((t)=>()=>t.remove())||[];if(o&&W(o))for(let t of G(o)){if(t.x)continue;try{await Go(t)}catch(r){I.e=["link error",{error:"Huntr @ link"}]}}return i}var fi=["charset","name","property","http-equiv"];async function Hn(o){let n={};if(D("meta")?.all.forEach((i)=>{let t=i.attributes;for(let r of fi)if(r in t){let f=t[r].value;n[`${r}_${r==="charset"?"":f}`]=i}}),o)$(o).forEach(([i,t])=>{if(i in n)D(n[i]).attr.set(t),delete n[i];else{let r=D(document.createElement("meta"));r.attr.set(t),document.head.append(r.e)}});return G(n).map((i)=>D(i).unload)}async function Yn(o,n=!1){let i=D("script[rt]")?.all.map((t)=>()=>t.remove())||[];if(o&&W(o))for(let t of G(o)){if(t.x)continue;try{await mn(t)}catch(r){I.e=["script error",{error:"Huntr @ script"}]}}return i}class to extends wo{path="";data={};args={};importArgs=[];static A=(o,...n)=>{return Y("a",o||{},...n)}}async function Dn(o,n=!1){if(!n&&o.fetch)T(o.data,await o.fetch());return[await Io(await o.body?.(),o.importArgs),ui.call(this,o)]}async function Io(o,n=[]){let i=o||"";if(Lo(o)){let t=o.default,r=L(n)?n():n;i=L(t)?await t.apply({},r):t}return b(i)?i:[i]}function ui(o){let n=new k({push:{rt:this.id}});return n.htmlHead=structuredClone(this.htmlHead),n.head(o),n.htmlHead}async function Ln(o,n){document.title=o.get("title")||"",zo(await hn(o.get("link"),n)),zo(await Yn(o.get("script")));let i=await Hn(o.get("meta"));zo(i)}var zo=(o)=>{o.forEach((n)=>n())};class ho{onChange;popListener;constructor(o=M(""),n=!1,i){if(this.onChange=i,this.onChange?.(this.path(),history.state??{path:this.path()}),this.popListener=(t)=>{let r=t.state??{path:this.path()},f=r?.path;if(n&&f)f=f==="/"?f:f.replace(/\/+$/g,"");o.value=f||o.value,this.onChange?.(this.path(),r)},c)window.addEventListener("popstate",this.popListener)}path(){let{pathname:o,search:n,hash:i}=window.location;return`${o}${n}${i}`}state(){return window.history.state??{path:this.path()}}navigate(o,n,i=""){let t=this.resolve(o),r=this.path();if(this.samePath(r,t))return;let f={...n,path:t};window.history.pushState(f,i,t),this.onChange?.(this.path(),f)}replace(o,n,i=""){let t=this.resolve(o),r=this.path();if(this.samePath(r,t))return;let f={...n,path:t};window.history.replaceState(f,i,t),this.onChange?.(this.path(),f)}back(){window.history.back()}forward(){window.history.forward()}destroy(){if(this.popListener)window.removeEventListener("popstate",this.popListener),this.popListener=void 0}resolve(o){let n=new URL(o,window.location.origin);return`${n.pathname}${n.search}${n.hash}`}samePath(o,n){return o===n}}class Ko{lang;head="";constructor(o,n){if(this.lang=o,n)this.head=un(n)}body(o,n,i){return[`<!DOCTYPE html><html lang="${this.lang}">`,`<head>${this.head}</head>`,`<body id="${n}"${i?" "+i:""}>${o}</body>`,"</html>"].join("")}}class ro{path="";data={};args={};importArgs=[];static Button=(o,...n)=>{return Y("button",o||{},...n)}}class Do extends To{cls;constructor(o,n){super(o);this.cls=n}}class Ho extends Do{}class Un extends Do{}class so{storage=new s;error=new s}class Co extends so{wss=new s;setRoute(o,n){this.storage.set(new Ho(o,n))}getRoute(o,n){let[i,t]=this.storage.get(o);if(!i){let[f=new Ho(o,Bn)]=this.getError(n),m=new f.cls;return m.args=t,T(m,{args:t})}let r=new i.cls;return T(r,{args:t})}setWss(o,n){this.wss.set(new Un(o,n))}getWss(o){return this.wss.get(o)}setError(o,n){this.error.set(new Ho(o.toString(),n))}getError(o=404){return this.error.get(o.toString())}}class Yo extends Do{}class Po extends so{setRoute(o,n){this.storage.set(new Yo(o,n))}getRoute(o,n){let[i,t]=this.storage.get(o);if(!i){let[f=new Yo(o,Zn)]=this.getError(n),m=new f.cls;return m.args=t,T(m,{args:t})}let r=new i.cls;return T(r,{args:t})}setWss(o){}getWss(o){}setError(o,n){this.error.set(new Yo(o.toString(),n))}getError(o=404){return this.error.get(o.toString())}}class Bn extends to{body(){return Y("div",{},this.path+" not found...")}}class Zn extends ro{body(){return Y("div",{},`${this.path} not found...`)}}class Vo extends k{id;data;path;_root;constructor(){super({mark:!0});this.id=E(6),this.path=M("/"),this._root=M([]),this.data={}}A(o,...n){let{on:i,...t}=o,r=this.path,f={...i||{},click(m){m.preventDefault();let u=D(this).path;r.value=u}};return Y("a",{on:f,...t},...n)}_main;async getMain(o){return await Y("main",{...o&&{class:o}},await this._main?.(this._root)||this._root)}}B([Z,g("design:type",Function),g("design:paramtypes",[typeof aAttr==="undefined"?Object:aAttr,Object]),g("design:returntype",void 0)],Vo.prototype,"A",null);class Oo extends Vo{pushHistory;storage=new Co;base;constructor(o="/",n="",i=!1){super();this.pushHistory=i;this.base=o?o.startsWith("/")?o:`/${o}`:"";let t=this.base;this.head({script:[{type:"module",src:"./index.js"}],...{base:[{href:t==="/"?t:`${t}/`,target:"_blank"}]},meta:[{charset:"utf-8"},{name:"viewport",content:"width=device-width, initial-scale=1.0"}]})}route(o){return(n)=>{return n.A=(i,...t)=>{if(i.href&&b(i.href))i.href=_o(o,i.href);else if(!i.href)i.href=o;return this.A(i,...t)},this.storage.setRoute(o,n),n}}error(...o){return(n)=>{if(o.length)o.forEach((i)=>{this.storage.setError(i,n)});return n}}wss(o){return(n)=>{return this.storage.setWss(o,n),n}}}B([Z,g("design:type",Function),g("design:paramtypes",[String]),g("design:returntype",void 0)],Oo.prototype,"route",null),B([Z,g("design:type",Function),g("design:paramtypes",[Object]),g("design:returntype",void 0)],Oo.prototype,"error",null),B([Z,g("design:type",Function),g("design:paramtypes",[String]),g("design:returntype",void 0)],Oo.prototype,"wss",null);function _o(o,n){let i=0;return o.replace(/<[^>]+>/g,()=>n[i++])}class An{id=E(5);path=M("");_root=M([]);Button(o,...n){let i=this.path,{on:t,...r}=o,f={...t||{},click(m){m.preventDefault();let x=D(this).attr.get("tab");if(!x)return;i.value=x}};return Y("button",{on:f,...r},...n)}}B([Z,g("design:type",Function),g("design:paramtypes",[Object,Object]),g("design:returntype",void 0)],An.prototype,"Button",null);class No extends An{storage=new Po;hasLoaded=!1;constructor({path:o}={}){super();if(o)this.path=o}tab(o){return(n)=>{return n.Button=(i,...t)=>{if(i.tab&&b(i.tab))i.tab=_o(o,i.tab);else if(!i.tab)i.tab=o;return this.Button(i,...t)},this.storage.setRoute(o,n),n}}Main(o){let{tab:n,data:i={},...t}=o;if(n)this.load(n,i);return Y("main",{...t},this._root)}async load(o,n={}){this.path.value=this.path.value||o,await C(async(i)=>{this._root.value=await mi.call(this,i,n)},[this.path],{id:this.id,init:!0})}}B([Z,g("design:type",Function),g("design:paramtypes",[String]),g("design:returntype",void 0)],No.prototype,"tab",null),B([Z,g("design:type",Function),g("design:paramtypes",[Object]),g("design:returntype",void 0)],No.prototype,"Main",null),B([Z,g("design:type",Function),g("design:paramtypes",[String,typeof obj==="undefined"?Object:obj]),g("design:returntype",Promise)],No.prototype,"load",null);async function mi(o,n={},i){let t=this.storage.getRoute(o,i);return T(t,{path:o,data:n}),Io(await t.body?.(),t.importArgs)}class po{path;args;route="/";isConnected=M(!1);data={};constructor(o,n={}){this.path=o;this.args=n;this.data=n}open(o){}message(o){}close(o){}error(o){}get connect(){if(this.ws&&this.ws.readyState<=1)return this;return this.ws=new WebSocket(this.path),this.ws.onopen=async(o)=>{this.isConnected.value=!0,await this.open.call(this,o)},this.ws.onmessage=async(o)=>{await this.message.call(this,o)},this.ws.onclose=async(o)=>{this.isConnected.value=!1,await this.close.call(this,o)},this.ws.onerror=async(o)=>{this.isConnected.value=this.ws.readyState<=1,await this.error.call(this,o)},this}get reconnect(){if(this.state>=2)this.connect;return this}get disconnect(){if(this.state<=1)this.ws.close();return this}get state(){return this.ws?.readyState??3}set send(o){if(this.isConnected.value)this.ws.send(o);else throw new Error(`websocket path ${this.path} not connected`)}}var O=new y;class co{yvee;constructor(o){this.yvee=o}async load(o){if(U)return;if(!O.has(o)){let[i,t]=this.yvee.storage.getWss(o);if(!i)return;let{cls:r,path:f}=i,m=new r(f,t).connect;return O.set(o,m),m}let n=O.get(o);return n.reconnect,n}unload(o){if(U)return;if(O.has(o)){let n=O.get(o);if(!n)return;n.disconnect,O.delete(o)}}}class wn extends Oo{isDev;history;constructor({base:o,history:n,index:i,isDev:t=!1}={}){super(o,i,n);let r=this;this.isDev=t,this.history=new ho(this.path,this.isDev),T(this,{get yvee(){return r}})}Main(o){this._main=o}async render(o={}){let{id:n,data:i,class:t}=o;if(c){let r=window.location.pathname;if(this.isDev)r=r.replace(/\/+$/g,"");this.path.value=r;let f=document.body.id;this.id=f;let[m,u]=await Rn.call(this,this.path.value,t);return F.push(u.oz),requestAnimationFrame(()=>{F.stage,this.init(i)}),()=>{}}return async({path:r,data:f={},error:m=0})=>{if(n)this.id=n;this.path.value=r;let[u,x]=await Rn.call(this,this.path.value,t,m,f,!0);return new Ko(this.lang,u).body(x.ctx,this.id)}}async init(o={}){let n=this.id;C(async(i)=>{let[t,r]=await Gn.call(this,i,o);await Ln(r,n),this._root.value=t,this.pushHistory&&this.history.navigate(i)},[this.path],{id:n})}}B([Z,g("design:type",Function),g("design:paramtypes",[Function]),g("design:returntype",void 0)],wn.prototype,"Main",null),B([Z,g("design:type",Function),g("design:paramtypes",[typeof renderConfig==="undefined"?Object:renderConfig]),g("design:returntype",Promise)],wn.prototype,"render",null);async function Gn(o,n={},i=!1,t){let r=this.storage.getRoute(o,t);return T(r,{path:o,data:n}),await Dn.call(this,r,i)}async function Rn(o,n,i,t={},r=!1){let[f,m]=await Gn.call(this,o,t,r,i);this._root.value=f;let u=await this.getMain(n),x=await $n(await this.getMain(n),this.id);return[m,x]}var xi=(o)=>{return(n)=>{return o(n)}};export{po as websocket,ii as useRef,co as socket,I as log,ri as frag,Y as dom,to as doc,Go as cssLoader,ro as content,cn as addCSS,Xo as __,wn as Yvee,Mo as Time,No as Tabs,q as Stateful,C as StateHook,M as State,xi as Routes,v as Ref,an as QState,ho as PathHistory,a as Meta,zn as IfClient,D as $};
|
|
1
|
+
// @bun
|
|
2
|
+
var ye=(e)=>typeof e==="function",pt=(e)=>typeof e==="number"&&!Number.isNaN(e),N=Object.assign,ft=(e)=>Object.entries(e),He=(e)=>{if(e.startsWith("webkit"))e=`-${e}`;return e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()},ir=new Set(["allowfullscreen","async","autofocus","autoplay","checked","controls","default","defer","disabled","formnovalidate","hidden","inert","ismap","itemscope","loop","multiple","muted","nomodule","novalidate","open","playsinline","readonly","required","reversed","selected"]),ht=(e)=>ir.has(e.toLowerCase()),$e=(e)=>{if(Array.isArray(e))return e.filter((t)=>t!==void 0).join(" ");if(typeof e==="function")return $e(e());if(e===void 0||e===null)return"";if(typeof e==="boolean")return e?"":"false";if(typeof e==="object")try{return JSON.stringify(e)??""}catch{return String(e)}return String(e)},mt=(e)=>typeof e==="object"&&e!==null&&("value"in e);var R=(e)=>String(e).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'");function P(e,t){if(!/^[A-Za-z_:][A-Za-z0-9:._-]*$/.test(e))throw TypeError(`Invalid attribute name: ${e}`);let r=e.toLowerCase();if(r.startsWith("on")||r==="srcdoc")throw TypeError(`Executable attribute is not supported: ${e}`);if(t===!1||t==null)return;let n=String(t);if(r==="srcset"||r==="imagesrcset"){if(/data:/i.test(n))throw TypeError("Data URLs are not supported in srcset.");for(let o of n.split(","))yt(o.trim().split(/\s+/)[0]??"",r)}else if(["href","src","action","formaction","poster","cite","background","xlink:href","data"].includes(r))yt(n,r)}function yt(e,t){let r=e.replace(/[\u0000-\u0020\u007f]/g,""),n=/^([a-z][a-z0-9+.-]*):/i.exec(r)?.[1]?.toLowerCase();if(!n||["http","https"].includes(n))return;if((t==="href"||t==="xlink:href")&&["mailto","tel"].includes(n))return;if(t==="src"&&/^data:image\/(?:png|gif|jpeg|webp|avif);base64,[a-z0-9+/=]*$/i.test(r))return;throw TypeError(`Unsupported URL scheme in ${t}: ${n}`)}function F(e,t){let r=String(t??"");if(new RegExp(`</${e}(?:[\\t\\n\\f\\r />]|$)`,"i").test(r)||e==="script"&&/<!--|<script[\t\n\f\r />]/i.test(r))throw TypeError(`Unsafe inline ${e} content; use an external file or serializePayload for JSON.`);return r}function gt(e){let t=JSON.stringify(e,(r,n)=>{if(typeof n==="bigint"||typeof n==="function"||typeof n==="symbol"||n===void 0||typeof n==="number"&&!Number.isFinite(n))throw TypeError("Bootstrap payload must contain JSON-serializable values.");return n});if(t===void 0)throw TypeError("Bootstrap payload must be JSON-serializable.");return t.replace(/[<>&\u2028\u2029]/g,(r)=>`\\u${r.charCodeAt(0).toString(16).padStart(4,"0")}`)}function ge(e,t){return`<script type="application/json" id="${R(t.id)}"${t.nonce===void 0?"":` nonce="${R(t.nonce)}"`}>${gt(e)}</script>`}class je{e;opt;constructor(e){this.e=e;this.opt={duration:500,easing:"ease-in-out",fill:"forwards"}}animate(e,t={}){return this.e.e.animate(e,{...this.opt,...t})}get slide(){let e=({x:t=0,y:r=0},n={})=>{N(this.opt,n);let o=[[t,r],[0,0]].map(([s,i])=>({transform:`translateX(${s}rem) translateY(${i}rem)`}));return this.e.animate(o,this.opt),this};return{left:(t={})=>e({x:-2},t),right:(t={})=>e({x:2},t),up:(t={})=>e({y:2},t),down:(t={})=>e({y:-2},t)}}fade(e={}){N(this.opt,e);let t=[0,1].map((r)=>({opacity:r}));return this.e.animate(t,this.opt),this}shake(e="Y",t={}){N(this.opt,t);let r=[0,5,-5,5,0].map((n)=>({transform:`translate${e}(${n}px)`}));return this.e.animate(r,this.opt),this}color(e=[],t={}){N(this.opt,t);let r=Array.isArray(e)?e.map((n)=>({color:n})):{color:e};return this.e.animate(r,this.opt),this}bg(e=[],t={}){N(this.opt,t);let r=Array.isArray(e)?e.map((n)=>({backgroundColor:n})):{backgroundColor:e};return this.e.animate(r,this.opt),this}bounce(e=1,t={}){N(this.opt,t);let r=[0.5,e,1].map((n)=>({transform:`scale(${n})`}));return this.e.animate(r,this.opt),this}}var te,wt=(e)=>(te=e,()=>{if(te===e)te=void 0}),vt=async(e,t)=>{if(te)return te(e,t);return{html:(e==null?"":String(e)).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}};class Ue{e;_query;constructor(e,t){this.e=e;this._query=t}get a(){return new je(this)}get all(){if(this._query){let e=document.querySelectorAll(this._query);if(e.length)return Array.from(e).map((t)=>t)}return[]}get attr(){let e=this.e;return{has:(t)=>e.hasAttribute(t),get:(t)=>e.getAttribute(t),del:(t)=>(e.removeAttribute(t),this),set:(t)=>{for(let[r,n]of Object.entries(t)){if(n===void 0)continue;let o=$e(n);if(P(r,o),ht(r)&&typeof n==="boolean")e.toggleAttribute(r,n);else e.setAttribute(r,o)}return this}}}get children(){return Array.from(this.e.children).map((e)=>new D(e))}get click(){return this.e.click(),this}get delete(){return this.e.remove(),this}get disabled(){return"disabled"in this.e?Boolean(this.e.disabled):!1}get focus(){return this.e.focus(),this}get href(){return this.e?.href??""}get id(){return this.e.id}get inner(){return this.e.innerHTML}get offsetParent(){let e=this.e.offsetParent;if(e)return new D(e);return}get parent(){let e=this.e.parentElement;if(e)return new D(e);return}get hash(){return this.e?.hash??""}get path(){return this.e?.pathname??""}get rect(){return this.e.getBoundingClientRect()}get remove_element(){return this.e.remove(),this}get style(){let e=this.e.style,t=this;return{set:(r,n=0)=>{let o=e,s=()=>{ft(r).forEach(([i,a])=>{if(a===void 0)return;let l=mt(a)?a.value:a;if(i in o){if(o[String(i)]!==l)o[String(i)]=l}else if(l!==null)e.setProperty(String(i),String(l));else e.removeProperty(String(i))})};if(ye(n))t.e.addEventListener("transitionend",n,{once:!0});if(pt(n))setTimeout(s,n);else s();return t},get:(r)=>{let n=He(String(r));return e.getPropertyValue(n)},del:(...r)=>(r.forEach((n)=>{let o=He(String(n));e.removeProperty(o)}),t)}}get submit(){if(!(this.e instanceof HTMLFormElement))return!1;return this.e.requestSubmit(),!0}get tag(){return this.e.tagName.toLowerCase()}get value(){return"value"in this.e?this.e.value??"":""}get unload(){return()=>{this.e.remove()}}async updateContent(e,t){let r=await vt(e,ar(this.id));if(t==="inner")this.e.innerHTML=r.html;else this.e.insertAdjacentHTML(t,r.html);await r.commit?.()}set append(e){this.updateContent(e,"beforeend")}set appendfirst(e){this.updateContent(e,"afterbegin")}set inner(e){this.updateContent(e,"inner")}set disabled(e){let t=this.e;if("disabled"in t)t.disabled=e}set id(e){this.e.id=e}set value(e){if("value"in this.e)this.e.value=e}}var ar=(e)=>e?`${e}-0`:e;class D extends Ue{add(...e){let t=e.flatMap((r)=>r.trim().split(/\s+/)).filter(Boolean);if(t.length)this.e.classList.add(...t);return()=>{if(t.length)this.e.classList.remove(...t)}}remove(...e){let t=e.flatMap((r)=>r.trim().split(/\s+/)).filter(Boolean);if(t.length)this.e.classList.remove(...t);return this}toggle(e,t){let r=typeof e!="string"?e.apply(this):e;return this.e.classList.toggle(r,t)}toggled(e,t){if(e)this.add(t);else this.remove(t);return this}clear(){return this.e.classList.remove(...Array.from(this.e.classList)),this}hasNode(e){return this.e.contains(e)}has(...e){let t=this.e.classList;return e.every((r)=>t.contains(r))}insert(e){return{HTML:(...t)=>(t.forEach((r)=>{this.e.insertAdjacentHTML(e,r)}),this),element:(...t)=>(t.forEach((r)=>{this.e.insertAdjacentElement(e,r)}),this),text:(...t)=>(t.forEach((r)=>{this.e.insertAdjacentText(e,r)}),this)}}is(e){let t=this.e.classList,r=this.e.tagName.toLocaleLowerCase(),n=!e.dom||e.dom.toLowerCase()===r,o=Array.isArray(e.class)?e.class:e.class?[e.class]:[];return n&&o.every((s)=>t.contains(s))}on(e,t,r=!1){let n=!1;if(e.indexOf("touch")>-1)n=!0;return this.e.addEventListener(e,t,{capture:r,passive:n}),this}remove_on(e,t,r=!1){return this.e.removeEventListener(e,t,r),this}timed(e,t=250){return setTimeout(()=>e(this),t),this}animate(e,t,r){let n={duration:300,easing:"ease",fill:"forwards"};if(ye(t))r=t;else N(n,t);let o=this.e.animate(e,n);if(r)o.finished.then(r);return this}query(e){return this.e.querySelector(e)}queryAll(e){let t=this.e.querySelectorAll(e);if(t.length)return Array.from(t).map((r)=>r);return[]}newChild(e,t={}){let r=document.createElement(e);return this.e.appendChild(r),Object.assign(r,t),new D(r)}newChildNS(e,t={}){let r=document.createElementNS("http://www.w3.org/2000/svg",e);return this.e.appendChild(r),Object.assign(r,t),new D(r)}get(e){return this.e[e]}}var re=new Map,bt=(e)=>{if(e===null||typeof e!=="object")return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null},I=(e)=>{if(typeof document>"u")return;let t=re.get(e);if(t?.isConnected&&t.id===e)return t;re.delete(e);let r=document.getElementById(e);if(!r)return;return re.set(e,r),r};function Tt(){let e=[];for(let[t,r]of re)if(!r.isConnected||r.id!==t)e.push(t),re.delete(t);return e}function dn(e,t){if(typeof e!=="string"&&!bt(e))return new D(e);if(typeof document>"u")return;let r=t??document,n=(o)=>{let s=r.querySelector(o);return s?new D(s,o):void 0};if(typeof e==="string")return n(e);if(bt(e)){let o=e,s=[];if(o.id)s.push(`#${CSS.escape(o.id)}`);if(o.class){let a=o.class.trim().split(/\s+/).filter(Boolean).map((l)=>`.${CSS.escape(l)}`);s.push(...a)}if(!s.length)return;let i=s.join("");return n(i)}return}function ln(e,t,r){return e?t:r}class xt extends EventTarget{current;constructor(e){super();this.current=e}get value(){return this.current}get clone(){if(typeof Element<"u"&&this.current instanceof Element)return this.current;return structuredClone(this.current)}set value(e){if(Object.is(this.current,e))return;this.current=e,this.dispatchEvent(new CustomEvent("updated",{detail:e}))}}class we{state=new xt(void 0);get element(){return this.state.value}set element(e){this.state.value=e}get $(){return this.state.value}}var gn=()=>new we;var Ne=0,Ge=new Set;function St(e){if(Ne)Ge.add(e);else e()}function dr(e){Ne++;try{let t=e();if(t&&typeof t.then==="function")throw Promise.resolve(t).catch(()=>{}),TypeError("batch callbacks must be synchronous.");return t}finally{if(--Ne===0){let t=[...Ge];Ge.clear();for(let r of t)r()}}}var qe=(e)=>typeof e==="boolean",H=(e)=>Array.isArray(e),j=(e)=>typeof e==="function",_=(e)=>e!==null&&typeof e==="object",Y=(e)=>_(e)&&(Object.getPrototypeOf(e)===Object.prototype||Object.getPrototypeOf(e)===null);class x extends Map{obj(e){if(e)Object.entries(e).forEach(([t,r])=>this.set(t,r));return this}init(e,t){if(!this.has(e))this.set(e,t);return this.get(e)}}var ve=(e,t)=>{if(!t.has(e))t.set(e,new x);return t.get(e)},W=(e,t)=>{if(!t.has(e))t.set(e,[]);return t.get(e)},Et=(e)=>Object.entries(e),ne=(e)=>JSON.stringify(e),kt=(e)=>{if(e.startsWith("webkit"))e=`-${e}`;return e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()},Rt=(e)=>Array.from({length:e},(n,o)=>{let s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"+(o?"0123456789":"");return s.charAt(Math.floor(Math.random()*s.length))}).join("");var Be=0;async function oe(e,t,{id:r=`stateHook:${++Be}`,init:n,signal:o,scope:s}={}){o?.throwIfAborted(),s?.signal.throwIfAborted();let i=[],a=()=>t.map((d)=>d.value),l=async()=>{await e(...a())};for(let d of t)i.push(await d.hook(l)(r));let c=()=>{i.splice(0).forEach((d)=>d()),o?.removeEventListener("abort",c)};o?.addEventListener("abort",c,{once:!0}),s?.defer(c);try{if(n)await l()}catch(d){throw c(),d}if(o?.aborted||s?.disposed)c();return c}async function cr(e,t,{id:r=`stateLoad:${++Be}`,init:n,signal:o,scope:s}={}){o?.throwIfAborted(),s?.signal.throwIfAborted();let i=[],a=()=>t.map((d)=>d.value),l=async()=>{await e(...a())};for(let d of t)i.push(d.loaded(l)(r));let c=()=>{i.splice(0).forEach((d)=>d()),o?.removeEventListener("abort",c)};o?.addEventListener("abort",c,{once:!0}),s?.defer(c);try{if(n)await l()}catch(d){throw c(),d}if(o?.aborted||s?.disposed)c();return c}function lr(e,t,r=!1){return[e,t,r,!1]}function ur(e,t,r=!1){return[e,t,r,!0]}async function pr(e,t,r={}){r.signal?.throwIfAborted(),r.scope?.signal.throwIfAborted();let n,o,s=[],i=!1,a=()=>{i=!0,n?.abort(),o?.(),s.splice(0).forEach((d)=>d()),r.signal?.removeEventListener("abort",a)},l=async(d)=>{if(i)return;n?.abort(),o?.();let u=new AbortController;n=u;let f=()=>u.abort();if(d.signal.addEventListener("abort",f,{once:!0}),o=()=>d.signal.removeEventListener("abort",f),d.signal.aborted)f();try{await e({signal:u.signal,isCurrent:()=>!u.signal.aborted&&d.isCurrent()},...t.map((p)=>p.value))}catch(p){throw u.abort(),o?.(),p}},c=r.id??`stateEffect:${++Be}`;r.signal?.addEventListener("abort",a,{once:!0}),r.scope?.defer(a);try{for(let d of t)s.push(await d.hook(l)(c));if(r.init){let d=new AbortController;await l({signal:d.signal,isCurrent:()=>!i})}if(r.signal?.aborted||r.scope?.disposed)a()}catch(d){throw a(),d}return a}function fr(e,t){if(Object.is(e,t))return!0;let r=Array.isArray(e)&&Array.isArray(t);if(!r&&!(Y(e)&&Y(t)))return!1;if(Object.getPrototypeOf(e)!==Object.getPrototypeOf(t))return!1;if(r&&e.length!==t.length)return!1;let n=(a)=>Reflect.ownKeys(a).filter((l)=>Object.prototype.propertyIsEnumerable.call(a,l)),o=e,s=t,i=n(o);return i.length===n(s).length&&i.every((a)=>Object.prototype.propertyIsEnumerable.call(s,a)&&Object.is(Reflect.get(o,a),Reflect.get(s,a)))}class A extends EventTarget{options;hooks=new x;loads=new x;states=new x;_value;listening=!1;controller=new AbortController;pending=new Set;failures=[];emit=()=>{this.controller.abort(),this.controller=new AbortController,this.dispatchEvent(new CustomEvent("updated",{detail:this._value}))};end;constructor(e,t={}){super();this.options=t;this._value=e}get value(){return this._value}get clone(){return structuredClone(this._value)}set value(e){let t=this.options.equals??Object.is;if(t!==!1&&t(this._value,e))return;this._value=e,this.dispatch()}async flush(){while(this.pending.size)await Promise.all([...this.pending]);let e=this.failures.splice(0);if(e.length===1)throw e[0];if(e.length)throw AggregateError(e,"State updates failed.")}report(e){this.failures.push(e);let t=new CustomEvent("error",{detail:e,cancelable:!0});this.dispatchEvent(t);try{if(this.options.onError)this.options.onError(e);else if(!t.defaultPrevented)console.error("Yvee state update failed",e)}catch(r){console.error("Yvee state error handler failed",r)}}async update(e,t){let r=[],n=async(o)=>{try{await o()}catch(s){if(t.isCurrent())r.push(s)}};for(let[o,s]of[...this.hooks.entries()]){if(!t.isCurrent())return;if(this.hooks.get(o)!==s)continue;await n(()=>s(t))}for(let[o,s]of this.states){let i=I(o);if(!i||!s.size){this.states.delete(o);continue}for(let[a,l]of[...s.entries()]){if(!t.isCurrent())return;let c=()=>t.isCurrent()&&this.states.get(o)?.get(a)===l&&I(o)===i;if(!c())continue;await n(()=>l.call(i,e,{signal:t.signal,isCurrent:c}))}}if(!t.isCurrent())return;if(!r.length){for(let[o,s]of[...this.loads.entries()]){if(!t.isCurrent())return;if(this.loads.get(o)===s)await n(s)}if(t.isCurrent())this.dispatchEvent(new CustomEvent("loaded",{detail:e}))}if(r.length===1)throw r[0];if(r.length)throw AggregateError(r,"State subscribers failed.")}listen(){if(this.options.signal?.aborted)return()=>{};if(!this.listening){let e=(r)=>{let n=this.controller,o={signal:n.signal,isCurrent:()=>!n.signal.aborted},s,i=new Promise((c)=>{let d=()=>c();n.signal.addEventListener("abort",d,{once:!0}),s=()=>n.signal.removeEventListener("abort",d)}),a=this.update(r.detail,o).catch((c)=>{if(o.isCurrent())this.report(c)}),l=Promise.race([a,i]).finally(()=>{s(),this.pending.delete(l),this.stopListeningWhenUnused()});this.pending.add(l)},t=()=>this.end?.();this.options.signal?.addEventListener("abort",t,{once:!0}),this.addEventListener("updated",e,this.options),this.listening=!0,this.end=()=>{this.removeEventListener("updated",e,this.options),this.options.signal?.removeEventListener("abort",t),this.controller.abort(),this.listening=!1,this.end=void 0}}return this.end}stopListeningWhenUnused(){if(!this.states.size&&!this.hooks.size&&!this.loads.size)this.end?.()}call(e,t){return async(r)=>(ve(r,this.states).set(t,e),this.listen(),()=>{let n=this.states.get(r);if(n?.get(t)===e)n.delete(t);if(n&&!n.size)this.states.delete(r);this.stopListeningWhenUnused()})}hook(e){return async(t)=>(this.hooks.set(t,e),this.listen(),()=>{if(this.hooks.get(t)===e)this.hooks.delete(t);this.stopListeningWhenUnused()})}loaded(e){return(t)=>(this.loads.set(t,e),this.listen(),()=>{if(this.loads.get(t)===e)this.loads.delete(t);this.stopListeningWhenUnused()})}dispatch(){St(this.emit)}}class Ct extends A{constructor(e,t={}){super(new Set(e),t)}add(e){if(this._value.has(e))return;this._value.add(e),this.dispatch()}delete(e){if(!this._value.has(e))return;this._value.delete(e),this.dispatch()}has(e){return this._value.has(e)}clear(){if(!this._value.size)return;this._value.clear(),this.dispatch()}}class Lt extends A{constructor(e,t={}){super(e,t)}set(e,t){let r=this._value[e];if(!Object.hasOwn(this._value,e)||!Object.is(r,t))this._value[e]=t,this.dispatch()}delete(e){if(Object.hasOwn(this._value,e))delete this._value[e],this.dispatch()}entries(){return Object.entries(this._value)}}function Z(e,t={}){return new A(e,t)}function Ln(e,t={}){return new Ct(e,t)}function Pn(e,t={}){return new Lt(e,t)}function An(e,t=!1){return Z(e,{equals:t?Object.is:!1})}function Ke(){return new Map}var Pt=Ke();function se(e,t=Pt){let r=Object.entries(e);for(let[o,s]of r){if(!o.trim())throw TypeError("Scope names must not be empty.");if(t.has(o))throw Error(`Scope already registered: ${o}`);if(s===null||typeof s!=="object"||Array.isArray(s)||![Object.prototype,null].includes(Object.getPrototypeOf(s)))throw TypeError(`Scope must be a plain object: ${o}`)}let n=r.map(([o,s])=>[o,Object.seal({...s})]);for(let[o,s]of n)t.set(o,s)}function Q(e,t=Pt){let r=t.get(e);if(!r)throw Error(`Scope is not registered: ${e}`);return r}class At{constructor(){}static create(e){let t=Ke();return se(e,t),{use:(r)=>Q(r,t)}}static register(e){return se(e),{use:(t)=>Q(t)}}static use(e){return Q(e)}}var hr=At;class Ot{static register(e){return se(e),{use:(t)=>Mt.use(t)}}static use(e){return new Proxy({},{get(t,r){return(n,o)=>{if(o.kind!=="field")throw TypeError("Field scope can only decorate class fields.");return function(){let s=Q(e);if(!Object.hasOwn(s,r))throw Error(`Scope field is not registered: ${e}.${String(r)}`);return Reflect.get(s,r)}}}})}}var Mt=Ot;class Dt{state;dev;constructor(e,t){Object.seal(e);for(let r in e){let n=e[r];if(typeof n==="object"&&n!==null)Object.seal(n)}this.state=e,this.dev=t?.dev??!1}get __(){return this.state}bind(e){for(let[t,r]of Object.entries(e)){let n=t;if(this.state[n]!=null){if(this.dev)console.warn(`[Stored] ${String(n)} already bound`);continue}if(this.state[n]=r,this.dev)console.log(`[Stored] bound ${String(n)}`)}}set(e,t,r){let n=this.state[e];if(typeof n!=="object"||n===null)throw Error(`${String(e)} is not an object`);if(n[t]=r,this.dev)console.log(`[Stored] updated ${String(e)}.${String(t)} \u2192`,r)}fn(e){return()=>e(this.state)}safe(e){let t=this.state[e];if(t==null)throw Error(`${String(e)} not bound`);return t}}var Ve=new Map,be=new Map,ie=new Map;class It{url;stream;handlers=new Map;closed=!1;constructor(e,t=!1){this.url=e;let r=Ve.get(e);if(r&&r.withCredentials!==t)throw TypeError(`Event stream ${e} is already open with different credentials settings.`);if(!r){if(typeof EventSource>"u")throw Error("EventSource is not available in this environment.");r=new EventSource(e,{withCredentials:t}),Ve.set(e,r),be.set(e,new Map)}this.stream=r;let n=ie.get(e);if(!n)n=new Set,ie.set(e,n);n.add(this)}on(e){let t=be.get(this.url);for(let[r,n]of Object.entries(e)){if(this.closed)break;let o=this.handlers.get(r);if(!o)o=new Set,this.handlers.set(r,o);if(o.has(n))continue;o.add(n);let s=t.get(r);if(!s)s=new Set,t.set(r,s);if(!s.has(n))s.add(n),this.stream.addEventListener(r,n)}return this}off(e,t){let r=be.get(this.url);if(!r)return this;let n=e?[e]:[...this.handlers.keys()];for(let o of n){let s=this.handlers.get(o);if(!s)continue;let i=t?s.has(t)?[t]:[]:[...s],a=r.get(o);for(let l of i)if(s.delete(l),![...ie.get(this.url)??[]].some((d)=>d!==this&&d.handlers.get(o)?.has(l)))this.stream.removeEventListener(o,l),a?.delete(l);if(!s.size)this.handlers.delete(o);if(a&&!a.size)r.delete(o)}return this}close(){if(this.closed)return;this.off(),this.closed=!0;let e=ie.get(this.url);if(e?.delete(this),!e?.size)this.stream.close(),ie.delete(this.url),be.delete(this.url),Ve.delete(this.url)}}function Vn(e,t=!0){return new It(e,t)}class G{type;primaryKey=!1;required=!1;isUnique=!1;indexed=!1;autoIncrement=!1;hasDefault=!1;defaultValue;constructor(e){this.type=e}get primary(){return this.primaryKey=!0,this}get notNull(){return this.required=!0,this}get index(){return this.indexed=!0,this}get unique(){return this.indexed=!0,this.isUnique=!0,this}get defaultNow(){if(this.type!=="date")throw TypeError("defaultNow requires a timestamp column.");return this.default(()=>new Date)}default(e){return this.hasDefault=!0,this.defaultValue=e,this}value(){return typeof this.defaultValue==="function"?this.defaultValue():structuredClone(this.defaultValue)}validate(e,t){if(t===void 0||t===null){if(this.required||this.primaryKey&&!this.autoIncrement)throw TypeError(`Column '${e}' is required.`);return}if(!(this.type==="json"||this.type==="text"&&typeof t==="string"||this.type==="boolean"&&typeof t==="boolean"||this.type==="number"&&typeof t==="number"&&Number.isFinite(t)||this.type==="integer"&&typeof t==="number"&&Number.isSafeInteger(t)||this.type==="date"&&t instanceof Date&&Number.isFinite(t.getTime())))throw TypeError(`Column '${e}' must be ${this.type}.`)}}var mr={text:()=>new G("text"),int:()=>new G("integer"),number:()=>new G("number"),boolean:()=>new G("boolean"),timestamp:()=>new G("date"),json:()=>new G("json"),serial:()=>{let e=new G("integer");return e.autoIncrement=!0,e}};class Ht{table;definitions;keyPath;autoIncrement;constructor(e,t){this.table=e;this.definitions=t;if(!e)throw TypeError("An object store name is required.");let r=this.entries().filter(([,s])=>s.primaryKey);if(r.length!==1)throw TypeError(`Store '${e}' requires exactly one primary column.`);let[n,o]=r[0];this.keyPath=n,this.autoIncrement=o.autoIncrement;for(let[s,i]of this.entries()){if(!/^[A-Za-z_$][\w$]*$/.test(s))throw TypeError(`Invalid field name '${s}'.`);if(i.autoIncrement&&!i.primaryKey)throw TypeError(`Serial column '${s}' must be the primary key.`);if((i.primaryKey||i.indexed)&&!["text","integer","number","date"].includes(i.type))throw TypeError(`Column '${s}' cannot be an IndexedDB key or index.`)}}entries(){return Object.entries(this.definitions)}prepare(e){let t={...e};for(let[r,n]of this.entries()){if(t[r]===void 0&&n.hasDefault)t[r]=n.value();if(n.autoIncrement&&t[r]===void 0){delete t[r];continue}n.validate(r,t[r])}return t}upgrade(e,t){let r=e.objectStoreNames.contains(this.table)?t.objectStore(this.table):e.createObjectStore(this.table,{keyPath:this.keyPath,autoIncrement:this.autoIncrement});if(r.keyPath!==this.keyPath||r.autoIncrement!==this.autoIncrement)throw Error(`Changing the primary key of '${this.table}' requires an explicit data migration.`);for(let[n,o]of this.entries()){if(!o.indexed||o.primaryKey)continue;if(r.indexNames.contains(n)){let s=r.index(n);if(s.keyPath===n&&s.unique===o.isUnique&&!s.multiEntry)continue;r.deleteIndex(n)}r.createIndex(n,n,{unique:o.isUnique})}}}function z(e,t,r,n){return new Promise((o,s)=>{let i=e.transaction(t,r),a,l;i.oncomplete=()=>o(a),i.onabort=()=>s(l??i.error??Error("IndexedDB transaction aborted."));let c=(d)=>{l=d,i.abort()};try{n(i.objectStore(t),(d)=>{a=d},c)}catch(d){c(d)}})}class Te{db;schema;constructor(e,t){this.db=e;this.schema=t}insert(e){let t=this.schema.prepare(e);return z(this.db,this.schema.table,"readwrite",(r,n)=>{r.add(t).onsuccess=(o)=>n(o.target.result)})}put(e){let t=this.schema.prepare(e);return z(this.db,this.schema.table,"readwrite",(r,n)=>{let o=r.put(t);o.onsuccess=()=>n(o.result)})}find(e){return z(this.db,this.schema.table,"readonly",(t,r)=>{let n=t.get(e);n.onsuccess=()=>r(n.result)})}findAll(e,t){return this.readAll(void 0,e,t)}findByIndex(e,t,r){return this.readAll(e,t,r)}readAll(e,t,r){if(r!==void 0&&(!Number.isInteger(r)||r<1||r>4294967295))throw RangeError("Limit must be an integer between 1 and 4294967295.");return z(this.db,this.schema.table,"readonly",(n,o)=>{let s=(e===void 0?n:n.index(e)).getAll(t,r);s.onsuccess=()=>o(s.result)})}update(e,t){if(Object.hasOwn(t,this.schema.keyPath))throw TypeError("Updates cannot change the primary key.");return z(this.db,this.schema.table,"readwrite",(r,n,o)=>{let s=r.get(e);s.onsuccess=()=>{if(s.result===void 0){n(void 0);return}try{let i=this.schema.prepare({...s.result,...t});r.put(i).onsuccess=()=>n(i)}catch(i){o(i)}}})}count(e){return z(this.db,this.schema.table,"readonly",(t,r)=>{let n=t.count(e);n.onsuccess=()=>r(n.result)})}delete(e){return z(this.db,this.schema.table,"readwrite",(t,r)=>{t.delete(e).onsuccess=()=>r(void 0)})}clear(){return z(this.db,this.schema.table,"readwrite",(e,t)=>{e.clear().onsuccess=()=>t(void 0)})}}class Fe{connection;schemas;constructor(e,t){this.connection=e;this.schemas=t}static open(e,t,r,n={}){if(!e||!Number.isSafeInteger(t)||t<1)return Promise.reject(TypeError("A database name and positive integer version are required."));if(new Set(r.map((s)=>s.table)).size!==r.length)return Promise.reject(TypeError("Object store names must be unique."));let o=n.factory??globalThis.indexedDB;if(!o)return Promise.reject(Error("IndexedDB is unavailable in this environment."));return new Promise((s,i)=>{let a=o.open(e,t),l;a.onblocked=(c)=>n.onBlocked?.(c),a.onerror=()=>i(l??a.error),a.onupgradeneeded=(c)=>{let d=a.transaction;try{for(let u of r)u.upgrade(a.result,d);n.upgrade?.(a.result,d,c.oldVersion,c.newVersion)}catch(u){l=u,d.abort()}},a.onsuccess=()=>{let c=a.result;c.onversionchange=()=>c.close();try{for(let d of r){let f=c.transaction(d.table,"readonly").objectStore(d.table);if(f.keyPath!==d.keyPath||f.autoIncrement!==d.autoIncrement)throw Error(`Schema '${d.table}' changed; increase the database version.`);for(let[p,w]of d.entries()){if(!w.indexed||w.primaryKey)continue;if(!f.indexNames.contains(p)||f.index(p).unique!==w.isUnique||f.index(p).keyPath!==p||f.index(p).multiEntry)throw Error(`Index '${d.table}.${p}' changed; increase the database version.`)}}s(new Fe(c,new Set(r)))}catch(d){c.close(),i(d)}}})}repository(e){if(!this.schemas.has(e))throw Error(`Schema '${e.table}' was not registered when opening this database.`);return new Te(this.connection,e)}close(){this.connection.close()}}async function oo(e,t,r={}){r.signal?.throwIfAborted(),r.scope?.signal.throwIfAborted();let n=()=>{let c=t(...e.map((d)=>d.value));if(c!=null&&typeof c.then==="function")throw Promise.resolve(c).catch(()=>{}),TypeError("Derived calculations must be synchronous; use StateEffect for async work.");return c},o=new A(n(),r),s=o.flush.bind(o),i=!1,a=await oe(async()=>{if(!i)o.value=n();await s()},e,r);o.flush=async()=>{await Promise.all(e.map((c)=>c.flush())),await s()};let l=()=>{i=!0,a()};return r.scope?.defer(l),Object.defineProperty(o,"dispose",{value:l}),o}class O{controller=new AbortController;cleanups=new Set;get signal(){return this.controller.signal}get disposed(){return this.signal.aborted}defer(e){let t=!0,r=()=>{if(!t)return;t=!1,this.cleanups.delete(r),e()};if(this.disposed)r();else this.cleanups.add(r);return r}own(e){return this.defer(()=>{if("dispose"in e)e.dispose();else e.close()}),e}listen(e,t,r,n){if(this.disposed)return()=>{};return e.addEventListener(t,r,n),this.defer(()=>e.removeEventListener(t,r,n))}timeout(e,t){if(this.disposed)return()=>{};let r=setTimeout(()=>{if(n(),!this.disposed)e()},t),n=this.defer(()=>clearTimeout(r));return n}dispose(){if(this.disposed)return;this.controller.abort();let e=[];for(let t of[...this.cleanups].reverse())try{t()}catch(r){e.push(r)}if(e.length)throw AggregateError(e,"Resource cleanup failed.")}}class C{tag;attr;ctx;constructor(e,t,r){this.tag=e;this.attr=t;this.ctx=r;if(e&&!/^[A-Za-z][A-Za-z0-9._:-]*$/.test(e))throw TypeError(`Invalid DOM tag name: ${e}`)}}async function q(e,t={},...r){if(j(e))return await e(t??{},...r);return new C(e,t??{},r)}var wo=async(e,...t)=>new C("",{},t);class S{nonce;counter;baseId;constructor(e,t=0,r){this.nonce=r;this.baseId=e||Rt(4),this.counter=Number.isSafeInteger(t)&&t>=0?t:0}static fromId(e,t){let r=/^(.*)-(\d+)$/.exec(e);if(!r||!r[1])return new S(e,0,t);return new S(r[1],Number(r[2]),t)}get id(){return`${this.baseId}-${this.counter}`}get nextId(){return`${this.baseId}-${this.counter++}`}get childId(){return S.fromId(`${this.nextId}-0`,this.nonce)}append(e="h"){return S.fromId(`${e}${this.id}`,this.nonce)}}var yr=(e,t,r)=>(e.addEventListener(t,r),()=>{e.removeEventListener(t,r)}),ae={},de={};class ee{tokens=new Map;events=new x;states=new x;windowEvents=new x;documentEvents=new x;resetST=new x;resetEV=new x;get keys(){return[...new Set([...this.states.keys(),...this.events.keys()])]}set(e){let{id:t,events:r,states:n}=e;if(t){if(r.size)this.events.set(t,r);if(n.length)this.states.set(t,n)}return this}push(e){return e.events.forEach((t,r)=>{t.forEach((n,o)=>{ve(r,this.events).set(o,n)})}),e.states.forEach((t,r)=>{W(r,this.states).push(...t)}),this}async stage(e=()=>!0){for(let[t,r]of[...this.events.entries()]){if(!e())return this;this.events.delete(t);let n=I(t);if(!n)continue;let o={};this.tokens.set(t,o);let s=()=>e()&&this.tokens.get(t)===o&&I(t)===n,i=(c)=>{if(s())W(t,this.resetEV).push(c);else c()},a=r.get("ready");if(a){let c=await a.apply(n,[n]);if(j(c))i(c)}if(!s())return this;let l=0;for(let[c,d]of r.entries()){if(!s())return this;switch(c){case"ready":break;case"element":{let p=await d.apply(n,[n]);if(j(p))i(p)}break;case"states":case"state":let u=await d.apply(n,[n]);if(!s())return this;let f=H(u[0])?u:u[0]?[u]:[];if(!f.length)break;for(let p of f){let[w,g,v,b]=p;if(!g||g.length===0)continue;let y=H(g)?g:[g];if(!y.length)break;let m=()=>y.map((E)=>E.value),h=()=>w(...m());if(v)await h();if(!s())return this;if(b){for(let E of y)W(t,this.resetST).push(E.loaded(h)(`${t}_loaded${l++}`));continue}for(let E of y)W(t,this.resetST).push(await E.call(h,`${t}_state${l}`)(t));l++}break;case"paste":if(c.startsWith("doc")){let p=c.replace(/^doc/,"");this.documentEvents.init(p,new x).set(t,d)}else this.documentEvents.init(c,new x).set(t,d);break;case"resize":case"beforeunload":case"popstate":this.windowEvents.init(c,new x).set(t,d);break;default:if(c.startsWith("win")){let p=c.replace(/^win/,"");this.windowEvents.init(p,new x).set(t,d)}else W(t,this.resetEV).push(yr(n,c,d))}}}this.processWindowEvents,this.processDocumentEvents;for(let[t,r]of[...this.states.entries()]){if(!e())return this;if(this.states.delete(t),!I(t))continue;let n=this.tokens.get(t)??{};this.tokens.set(t,n);for(let o of r){let s=await o(t);if(!e()||this.tokens.get(t)!==n)return s(),this;W(t,this.resetST).push(s)}}return this}get processWindowEvents(){let e=(t,r)=>{let n=!1,o=(i)=>{if(!n)window.requestAnimationFrame(()=>{r.forEach((a,l)=>{let c=I(l);if(c)a.call(c,i);else this.windowEvents.get(t)?.delete(l)}),n=!1}),n=!0},s=(i)=>{r.forEach((a,l)=>{let c=I(l);if(c)a.call(c,i);else this.windowEvents.get(t)?.delete(l)})};return window.addEventListener(t,t==="scroll"?o:s),()=>{window.removeEventListener(t,t==="scroll"?o:s)}};return this.windowEvents.forEach((t,r)=>{if(t.size){if(!ae[r])ae[r]=e(r,t)}else if(ae[r])ae[r](),delete ae[r]}),this}get processDocumentEvents(){let e=(t,r)=>{let n=!1,o=(i)=>{if(!n)window.requestAnimationFrame(()=>{r.forEach((a,l)=>{let c=I(l);if(c)a.call(c,i);else this.documentEvents.get(t)?.delete(l)}),n=!1}),n=!0},s=(i)=>{r.forEach((a,l)=>{let c=I(l);if(c)a.call(c,i);else this.documentEvents.get(t)?.delete(l)})};return document.addEventListener(t,t==="scroll"?o:s),()=>{document.removeEventListener(t,t==="scroll"?o:s)}};return this.documentEvents.forEach((t,r)=>{if(t.size){if(!de[r])de[r]=e(r,t)}else if(de[r])de[r](),delete de[r]}),this}reset(e){let t=[];if(e.forEach((r)=>{this.tokens.delete(r),this.events.delete(r),this.states.delete(r),this.windowEvents.forEach((n,o)=>{if(n.has(r))n.delete(r)}),this.documentEvents.forEach((n,o)=>{if(n.has(r))n.delete(r)});for(let n of[...this.resetEV.get(r)??[],...this.resetST.get(r)??[]])try{n()}catch(o){t.push(o)}this.resetST.delete(r),this.resetEV.delete(r)}),this.processWindowEvents,this.processDocumentEvents,t.length)throw AggregateError(t,"One or more OZ element cleanups failed.");return this}resetScope(e){let t=new Set([...this.tokens.keys(),...this.events.keys(),...this.states.keys(),...this.resetEV.keys(),...this.resetST.keys()]);for(let n of[...this.windowEvents.values(),...this.documentEvents.values()])for(let o of n.keys())t.add(o);let r=[...t].filter((n)=>n===e||n.startsWith(`${e}-`));return this.reset(r),this}async RPS(e,t=()=>!0){if(!t())return this;let r=Tt();if(this.reset(r),e){let n=e.keys;if(n.length)await this.reset(n).push(e).stage(t)}return this.processWindowEvents,this.processDocumentEvents,this}}var M=new ee;class ce{xid;IDM;map=new x;states=[];events=new x;OZ;internalId;constructor(e,t=new S,r){this.xid=e;this.IDM=t;this.OZ=r??new ee}attr_push(e,t,r){let n=r??e;if(P(n,void 0),r==="style"&&!/^(?:--[A-Za-z0-9_-]+|-?[A-Za-z][A-Za-z0-9-]*)$/.test(e))return;if(!this.map.has(n))this.map.set(n,[]);let o=r?`${kt(e)}:${t};`:t;this.map.get(n).push(o)}get attr(){let e=[""];return this.map.forEach((t,r)=>{let n=t.join("");e.push(n?`${r}="${n}"`:r)}),e.join(" ")}set id(e){if(!this.map.has("id"))this.internalId=e,this.map.set("id",[R(e)])}get id(){return this.internalId??this.map.get("id")?.join("")}setId(e){this.internalId=e}}var Ye,jt=(e)=>{Ye=e},gr=["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"],$t=(e)=>gr.includes(e.toLowerCase()),xe=async(e,t)=>{let r=await Promise.resolve(e);if(H(r)){let n=[];for(let o of r)n.push(await xe(o,t));return n.join("")}else if(r instanceof C){if(!Ye)throw Error("The DOM renderer has not been initialized.");let{ctx:n,oz:o}=await Ye(r,t.IDM);return t.OZ.push(o),n}else if(_(r)){if(r instanceof Set)return R([...r].join(" "));return R(ne(r))}else if(j(r))return await xe(r(),t);else if(r!==void 0&&r!==null)return R(r);return""},Se=async(e,t,r)=>{let n=t?S.fromId(t,r):new S(void 0,0,r),o=new ce(n.id,n);return{ctx:await xe(e,o),catt:o}};async function wr(e,t,r){let n=this.id;if(n){let{ctx:o,catt:s}=await Se(e,n,t);if(r&&!r.isCurrent())return!1;if(this.innerHTML!==o)return this.innerHTML=o,await M.RPS(s.OZ,r?.isCurrent),!0}return!1}var ze=async(e,t,r,n=[])=>{if(H(e))for(let o of e)await ze(o,e.length,r,n);else if(e instanceof A)if(t>1)await ze(await q("div",{},e),t,r,n);else{let o=e.value,s=o instanceof C?"dom":"ctx",{ctx:i,catt:a}=await Se(o,r.xid+"-0",r.IDM.nonce);r.xid=a.xid,n.push(i),r.OZ.push(a.OZ),r.states.push(e.call(function(l,c){return wr.call(this,l,r.IDM.nonce,c)},s))}else n.push(await xe(e,r))};class _e{tag;ctx;closing;constructor(e="",t){this.tag=e;this.ctx=t;let r=$t(e);this.closing=r?"":`</${e}>`}async process(e,t=this.ctx,r=[]){for(let n of t)await ze(await Promise.resolve(n),t.length,e,r);return r.join("")}async get(e){let t=e.xid,r,n=this.tag.toLowerCase();if(n==="script"||n==="style"){let o=async(s)=>{let i=await s;if(Array.isArray(i))return(await Promise.all(i.map(o))).join("");if(typeof i==="function")return o(i());if(i==null)return"";if(typeof i!=="string"&&typeof i!=="number")throw TypeError("Inline script/style children must be static text.");return String(i)};r=F(n,await o(this.ctx))}else r=await this.process(e);if(!this.tag)return r;if(e.events.size||e.states.length)e.id=t;if($t(this.tag)){if(r)throw TypeError(`<${this.tag}> cannot contain child content.`);return`<${this.tag}${e.attr}>`}return`<${this.tag}${e.attr}>${r}${this.closing}`}}var vr=new Set(["allowfullscreen","async","autofocus","autoplay","checked","controls","default","defer","disabled","formnovalidate","hidden","inert","ismap","itemscope","loop","multiple","muted","nomodule","novalidate","open","playsinline","readonly","required","reversed","selected"]),We=(e)=>vr.has(e.toLowerCase()),le=(e)=>{if(H(e))return R(e.filter((t)=>t!==void 0).join(" "));if(Y(e))return R(ne(e));if(j(e))return le(e());if(e===void 0||e===null)return"";return qe(e)?e?"":"false":R(String(e))},J=(e)=>{if(H(e))return e.filter((t)=>t!==void 0).join(" ");if(Y(e))return ne(e);if(j(e))return J(e());if(e===void 0||e===null)return"";return qe(e)?e?"":"false":String(e)};var br=(e)=>/^[A-Za-z_:][A-Za-z0-9:._-]*$/.test(e),Tr=(e)=>/^(?:--[A-Za-z0-9_-]+|-?[A-Za-z][A-Za-z0-9-]*)$/.test(e);function xr(e,t){switch(t??e){case"style":return function(r){this.style.setProperty(e,J(r))};default:return function(r){if(We(e)&&(typeof r==="boolean"||r==null)){this.toggleAttribute(e,r===!0);return}let n=J(r);P(e,n),this.setAttribute(e,n)}}}class Ze{attr;constructor(e={}){this.attr=e}get(e,t=this.attr,r){let n=(o,s)=>{if(r!=="style"&&We(o)&&(s===!1||s===null))return;if(r!=="style"&&!(s instanceof A)&&!_(s))P(o,J(s));if(H(s)){if(!r)P(o,J(s));e.attr_push(o,le(s),r)}else if(s instanceof A){let i=r?`${r}_${o}`:o;e.states.push(s.call(xr(o,r),i)),n(o,s.value)}else if(_(s)){if(Y(s)&&!r)this.get(e,s,o)}else e.attr_push(o,le(s),r)};Et(t).forEach(([o,s])=>{let i=String(o);if(!(r==="style"?Tr(i):br(i)))return;if(i==="id"&&s!==void 0)e.setId(J(s instanceof A?s.value:s));if(i==="ref"){if(s instanceof we)e.events.obj({element(){s.element=this}})}else if(["on"].includes(i))_(t.on)&&e.events.obj(t.on);else{if(s===void 0)return;n(i,s)}})}unload(e){let t;if(e in this.attr)t=this.attr[e],delete this.attr[e];return t}}async function X(e,t=new S){let{tag:r,attr:n,ctx:o}=await Promise.resolve(e),s=t instanceof S?t:S.fromId(t),i=s.nextId,a=new ce(i,s),l=["script","style"].includes(r.toLowerCase())&&s.nonce!==void 0?{...n,nonce:s.nonce}:n,c=new Ze(l),d=new _e(r,o);return c.get(a),{ctx:await d.get(a),oz:a.OZ.set(a),id:a.id}}jt(X);wt(async(e,t)=>{let{ctx:r,catt:n}=await Se(e,t);return{html:r,commit:()=>M.RPS(n.OZ).then(()=>{return})}});function k(e){if(e===void 0)return[];return Array.isArray(e)?e:[e]}function U(e,t){return{...e,...t,base:[...k(e.base),...k(t.base)],meta:[...k(e.meta),...k(t.meta)],link:[...k(e.link),...k(t.link)],script:[...k(e.script),...k(t.script)],css:[...k(e.css),...k(t.css)],js:[...k(e.js),...k(t.js)],elements:[...k(e.elements),...k(t.elements)]}}function ue(e){if(e instanceof C)return{elements:[e]};if(typeof e==="string")return{style:e};return e??{}}class pe{values={};head(e){let t=ue(e);if(t.title!==void 0)this.values.title=t.title;let r=[this.values.style,t.style].filter(Boolean).join(`
|
|
3
|
+
`);if(r)this.values.style=r;if(t.description!==void 0)this.values.description=t.description;for(let n of["base","meta","link","script","css","js","elements"]){let o=t[n];if(o===void 0)continue;let s=this.values[n],i=s===void 0?[]:Array.isArray(s)?s:[s],a=Array.isArray(o)?o:[o];this.values[n]=[...i,...a]}}}async function fe(e,t,r,n){let o=new S(r,0,n),s=new ee,i=[],a;for(let l of e){let c=await Je(l,t),d=await X(c,o);i.push(d.ctx),s.push(d.oz),a=d.id??a}return{ctx:i.join(""),oz:s,id:a}}async function Je(e,t){let r=await Promise.resolve(e);if(Array.isArray(r)){let s=[];for(let i of r)s.push(await Je(i,t));return s}if(!(r instanceof C))return r;let n=[];for(let s of r.ctx)n.push(await Je(s,t));let o=r.tag?{...r.attr,"data-yv":t}:r.attr;return new C(r.tag,o,n)}function Xe(e){let t=new Set;return{ready:Promise.all(e.map((n)=>new Promise((o)=>{let s=!1,i=()=>{if(s)return;s=!0,t.delete(i),window.clearTimeout(a),n.removeEventListener("load",i),n.removeEventListener("error",i),o()},a=window.setTimeout(i,8000);t.add(i),n.addEventListener("load",i,{once:!0}),n.addEventListener("error",i,{once:!0})}))).then(()=>{return}),cancel(){for(let n of[...t])n()}}}function Ee(e,t,r={}){if(typeof document>"u")return Object.assign(()=>{},{ready:Promise.resolve(),async activate(){},cancel(){}});let n=document.title,o=e.title??"",s=[],i,a,l=[],c=!r.deferTitle,d=!1,u=!1,f=Xe([]);if(c&&e.title!==void 0)document.title=o,d=!0;let p=(b,y)=>{if(b==="script"&&typeof y.src==="string"){let h=new URL(y.src,document.baseURI).href,E=String(y.type??"").toLowerCase();if(Array.from(document.head.querySelectorAll("script[src]")).find((ut)=>ut.src===h&&ut.type.toLowerCase()===E))return}let m=document.createElement(b);for(let[h,E]of Object.entries(y)){if(h==="body"||E===void 0)continue;if(P(h,E),typeof E==="boolean")m.toggleAttribute(h,E);else m.setAttribute(h,String(E))}if((b==="script"||b==="style")&&r.nonce!==void 0)m.setAttribute("nonce",r.nonce);if(m.dataset.yv=t,b==="script"&&y.body)m.textContent=F("script",y.body);if(document.head.append(m),s.push(m),b==="link"&&String(y.rel??"").toLowerCase()==="stylesheet")l.push(m)},w=r.idSeed??`${t}:h`,g=(async()=>{if(!r.keepExisting)ke(t);let b=e.base?.at(-1);if(b)document.head.querySelectorAll("base").forEach((h)=>h.remove()),p("base",b);if(e.description)p("meta",{name:"description",content:e.description});for(let h of e.meta??[])p("meta",h);for(let h of e.link??[])p("link",h);let y=k(e.css);for(let h of y)p("link",{rel:"stylesheet",href:h});for(let h of e.script??[])p("script",h);let m=k(e.js);for(let h of m)p("script",{src:h});if(e.style){let h=document.createElement("style");if(h.textContent=F("style",e.style),r.nonce!==void 0)h.setAttribute("nonce",r.nonce);h.dataset.yv=t,document.head.append(h),s.push(h)}if(e.elements?.length){if(a=await fe(e.elements,t,w,r.nonce),u)return;let h=document.createElement("template");h.innerHTML=a.ctx;let E=Array.from(h.content.children);for(let V of E){if(V instanceof HTMLTitleElement){if(i=V,r.deferTitle)continue;d=!0}document.head.append(V),s.push(V)}l.push(...E.filter((V)=>V instanceof HTMLLinkElement&&V.rel.toLowerCase()==="stylesheet"))}if(f=Xe(l),await f.ready,c&&a)await M.RPS(a.oz,()=>!u&&c)})(),v=()=>{if(u)return;u=!0;try{if(f.cancel(),c&&a)M.resetScope(w)}finally{let b=i?.textContent??o,y=d&&document.title===b;if(s.forEach((m)=>m.remove()),i?.remove(),y)document.title=n}};return v.ready=g.catch((b)=>{throw v(),b}),v.activate=async()=>{if(u||c)return;if(n=document.title,c=!0,i)document.head.querySelectorAll("title").forEach((b)=>{if(b!==i)b.remove()}),document.head.append(i),s.push(i),d=!0;else if(e.title!==void 0)document.title=o,d=!0;if(a)await M.RPS(a.oz,()=>!u&&c)},v.cancel=()=>f.cancel(),v}function ke(e){if(typeof document>"u")return;document.head.querySelectorAll("[data-yv]").forEach((t)=>{if(t.getAttribute("data-yv")!==e)return;if(t instanceof HTMLScriptElement&&t.hasAttribute("src"))return;t.remove()})}var Qe=new WeakMap,Ut=(e)=>(...t)=>e(...t),Nt=(...e)=>(t)=>(Qe.set(t,[...e,...Qe.get(t)??[]]),t),Re=(e)=>Qe.get(e)??[];async function Ce(e,t){for(let r of e){t.signal.throwIfAborted();let n=await r(t);if(t.signal.throwIfAborted(),n&&n.kind!=="allow")return n}return{kind:"allow"}}function et(e,t={kind:"stop"}){return async(r)=>await e(r)?{kind:"allow"}:typeof t==="function"?t(r):t}function Gt(...e){return async(t)=>{for(let r of e){t.signal.throwIfAborted();let n=await r(t);if(t.signal.throwIfAborted(),n&&n.kind!=="allow")return n}return{kind:"allow"}}}function qt(e,t){return async(r)=>await e(r)?t(r):{kind:"allow"}}function Bt(e,t={kind:"stop"}){return et(async(r)=>{for(let[n,o]of Object.entries(e)){let s=r.params[n];if(s===void 0||!await o(s,r))return!1}return!0},t)}class Le{resources=new O;url={path:"/",search:"",hash:"",params:new URLSearchParams};path="/";params={};data={};error;status=200}class he extends Le{body(){return q("main",{role:"status"},"Page not found: ",this.path)}}class me extends Le{status=500;body(){return q("main",{role:"alert"},"This page could not be loaded.")}}async function Pe({app:e,routes:t,globalGuards:r,errors:n,error:o,url:s,data:i,signal:a}){let l=t.find(s.path),c=l?.entry.controller,d=o??(c?void 0:404),u=n.get(d??404)??(d===404?he:me),f=d===void 0&&c?new c:new u;if(d!==void 0)f.status=d;Kt(f,s,l?.params,i),Ft(f,a);try{let p=await Ce([...r,...Re(f.constructor)],{app:e,page:f,url:s,params:f.params,data:f.data,signal:a});if(p.kind!=="allow")return f.resources.dispose(),p;return{...await Vt(f,s,a),url:s,dispose:()=>f.resources.dispose()}}catch(p){if(f.resources.dispose(),a.aborted)throw a.reason??p;return kr({app:e,errors:n,globalGuards:r,url:s,data:i,failure:p,signal:a,original:f})}}function Kt(e,t,r,n){e.url=t,e.path=t.path,e.params=r??{},e.data=Object.assign(Object.create(null),e.data,n)}async function Vt(e,t,r){if(r.aborted)throw r.reason??Error("Page load aborted.");if(e.fetch){let l=await e.fetch({url:t,params:e.params,data:e.data,signal:e.resources.signal,resources:e.resources});Object.assign(e.data,l)}if(r.aborted)throw r.reason??Error("Page load aborted.");let n=await e.body?.();if(r.aborted)throw r.reason??Error("Page load aborted.");let{bodyValue:o,moduleHead:s}=await Sr(n,e);r.throwIfAborted();let i=await e.head?.();r.throwIfAborted();let a=U(ue(s),ue(i));return{kind:"ready",status:e.status,head:a,body:Array.isArray(o)?o:[o??""]}}async function Sr(e,t){if(!Er(e))return{bodyValue:e,moduleHead:void 0};let r=typeof e.head==="function"?await e.head({page:t}):await e.head;return{bodyValue:typeof e.default==="function"?await e.default({page:t}):await e.default,moduleHead:r}}function Er(e){return typeof e==="object"&&e!==null&&"default"in e}async function kr({app:e,errors:t,globalGuards:r,url:n,data:o,failure:s,signal:i,original:a}){let l=s instanceof Response&&s.status>=400?s.status:500,c=t.get(l)??(l===404?he:me);if(a.constructor===c)throw s;let d=new c;Kt(d,n,a.params,o),d.error=s,d.status=l,Ft(d,i);try{let u=await Ce([...r,...Re(d.constructor)],{app:e,page:d,url:n,params:d.params,data:d.data,signal:i});if(u.kind!=="allow")return d.resources.dispose(),u;return{...await Vt(d,n,i),url:n,failure:s,dispose:()=>d.resources.dispose()}}catch(u){if(d.resources.dispose(),i.aborted)throw i.reason??u;throw AggregateError([s,u],"Yvee error page failed to render.")}}function Ft(e,t){let r=()=>{try{e.resources.dispose()}catch(n){console.error("Yvee aborted page cleanup failed",n)}};if(t.aborted)r();else t.addEventListener("abort",r,{once:!0}),e.resources.defer(()=>t.removeEventListener("abort",r))}async function Yt({element:e,id:t,className:r,root:n,layout:o,hydrate:s=!0,nonce:i,isCurrent:a}){let l=o?await o(n):n,c=l instanceof C?l:q("main",{class:r},l),d=await X(c,new S(e.id||t,0,i));if(a&&!a())return;let u=document.createElement("template");if(u.innerHTML=d.ctx,!s||e.innerHTML!==u.innerHTML)e.innerHTML=d.ctx;await M.RPS(d.oz,a)}var B=(e)=>{let t=e.split(/[?#]/,1)[0]||"/",n=(t.startsWith("/")?t:`/${t}`).replace(/\/{2,}/g,"/");return n.length>1?n.replace(/\/+$/,""):"/"},L=(e)=>{let t=typeof window>"u"?"http://localhost":window.location.href,r=e instanceof URL?e:new URL(e,t);return{path:B(r.pathname),search:r.search,hash:r.hash,params:r.searchParams}},T=(e)=>`${e.path}${e.search}${e.hash}`;class tt{options;previousScrollRestoration;handlePop=(e)=>this.options.onPop(L(location.href),e.state);handleClick=(e)=>{if(!this.isEligibleClick(e))return;let t=e.target.closest("a");if(!t)return;let r=this.options.root?.();if(r&&t.closest("[data-app]")!==r)return;let n=new URL(t.href,location.href);if(n.origin!==location.origin||!this.isWithinBase(n.pathname))return;e.preventDefault(),this.options.navigate(`${n.pathname}${n.search}${n.hash}`)};constructor(e){this.options=e}start(){if(this.options.history!==!1)this.previousScrollRestoration=history.scrollRestoration,history.scrollRestoration="manual",window.addEventListener("popstate",this.handlePop);document.addEventListener("click",this.handleClick)}stop(){if(typeof window<"u")window.removeEventListener("popstate",this.handlePop);if(typeof document<"u")document.removeEventListener("click",this.handleClick);if(this.previousScrollRestoration!==void 0)history.scrollRestoration=this.previousScrollRestoration,this.previousScrollRestoration=void 0}isEligibleClick(e){if(e.defaultPrevented||e.button!==0)return!1;if(e.metaKey||e.ctrlKey||e.shiftKey||e.altKey)return!1;if(!(e.target instanceof Element))return!1;let t=e.target.closest("a");return Boolean(t&&!t.target&&!t.hasAttribute("download"))}isWithinBase(e){let t=this.options.base==="/"?"/":`${this.options.base.replace(/\/$/,"")}/`;return t==="/"||e===t.slice(0,-1)||e.startsWith(t)}}class nt{options;displayedEntry;nextEntryId=0;scrollPositions=new Map;constructor(e){this.options=e}pop(e,t){this.captureDisplayedScroll();let r=T(e),n=this.scrollPositions.get(this.entryKey(t)??"")??zt(t)??this.scrollPositions.get(r);if(n)this.rememberScroll(r,n);return n}initialize(e){this.trackDisplayedEntry(),this.rememberScroll(T(e),zt(history.state)??rt())}getScroll(e){return this.scrollPositions.get(e)}beginTransition(){this.displayedEntry=void 0}reset(){this.displayedEntry=void 0,this.scrollPositions.clear()}restoreAddress(e){if(this.options.enabled&&location.protocol!=="file:")history.replaceState(history.state,"",T(e))}write(e,t,r=!1,n){if(!this.options.enabled||location.protocol==="file:")return;let o=r?"replaceState":"pushState",s=n??(r?rt():{x:0,y:0});history[o]({...t,path:T(e),scroll:s,yveeScrollEntry:this.newEntryKey()},"",T(e))}newEntryKey(){return`yv:${this.options.id}:${Date.now()}:${++this.nextEntryId}`}entryKey(e){if(e&&typeof e==="object"&&"yveeScrollEntry"in e&&typeof e.yveeScrollEntry==="string")return e.yveeScrollEntry;return}trackDisplayedEntry(){let e=this.options.enabled&&location.protocol!=="file:",t=e?this.entryKey(history.state):void 0;if(this.displayedEntry=t??this.newEntryKey(),e&&!t)history.replaceState({...history.state,yveeScrollEntry:this.displayedEntry},"")}captureDisplayedScroll(){let e=this.options.currentURL();if(!e||!this.displayedEntry)return;let t=rt();return this.rememberScroll(this.displayedEntry,t),this.rememberScroll(T(e),t),this.displayedEntry=void 0,t}saveCurrentScroll(){let e=this.captureDisplayedScroll();if(!e||!this.options.enabled||location.protocol==="file:")return;history.replaceState({...history.state,path:T(this.options.currentURL()),scroll:e},"")}rememberScroll(e,t){if(this.scrollPositions.delete(e),this.scrollPositions.set(e,t),this.scrollPositions.size>100){let r=this.scrollPositions.keys().next().value;if(r)this.scrollPositions.delete(r)}}replaceAddressIfNeeded(e){if(!this.options.enabled||location.protocol==="file:")return;if(T(e)===`${location.pathname}${location.search}${location.hash}`)return;history.replaceState(history.state,"",T(e))}}function rt(){return{x:window.scrollX,y:window.scrollY}}function zt(e){if(!e||typeof e!=="object"||!("scroll"in e))return;let t=e.scroll;if(!t||typeof t!=="object"||!("x"in t)||!("y"in t))return;if(typeof t.x!=="number"||typeof t.y!=="number")return;return{x:t.x,y:t.y}}class ot{options;constructor(e){this.options=e}async restoreScroll(e,t,r){let n=e??this.options.history.getScroll(T(r));await new Promise((o)=>requestAnimationFrame(()=>requestAnimationFrame(()=>{if(this.options.isCurrent(t))_t(()=>{if(n)window.scrollTo(n.x,n.y);else window.scrollTo(0,0)}),this.options.history.trackDisplayedEntry();o()})))}async scrollToRoute(e,t){if(await new Promise((r)=>requestAnimationFrame(()=>r())),!this.options.isCurrent(t))return;if(e.hash){let r=document.getElementById(decodeURIComponent(e.hash.slice(1)));if(r){_t(()=>r.scrollIntoView()),this.options.history.trackDisplayedEntry();return}}await this.restoreScroll(void 0,t,e)}}function _t(e){if(!window.matchMedia?.("(prefers-reduced-motion: reduce)").matches){e();return}let t=document.documentElement,r=t.style.scrollBehavior;t.style.scrollBehavior="auto";try{e()}finally{t.style.scrollBehavior=r}}class st{id;element;status;constructor(e,t){this.id=e;this.element=t}dispose(){this.status?.remove(),this.status=void 0}mount(){let e=document.createElement("div");e.dataset.yveeRouteStatus=this.id,e.setAttribute("role","status"),e.setAttribute("aria-live","polite"),e.setAttribute("aria-atomic","true"),Object.assign(e.style,{position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",border:"0"}),document.body.append(e),this.status=e}commit(e,t){let r=this.element();if(!t()||!r)return;let n=e.hash?document.getElementById(decodeURIComponent(e.hash.slice(1))):null,o=n&&(r===n||r.contains(n))?n:(r.matches("[data-yvee-focus]")?r:null)??r.querySelector("[data-yvee-focus]")??(r.matches("h1")?r:null)??r.querySelector("h1")??(r.tagName==="BODY"?null:r);if(o){let i=!o.hasAttribute("tabindex");if(i)o.setAttribute("tabindex","-1");if(o.focus({preventScroll:!0}),i){if(document.activeElement===o)o.addEventListener("blur",()=>{if(o.getAttribute("tabindex")==="-1")o.removeAttribute("tabindex")},{once:!0});else if(o.getAttribute("tabindex")==="-1")o.removeAttribute("tabindex")}}let s=this.status;if(!s)return;s.textContent="",requestAnimationFrame(()=>{if(t()&&s.isConnected)s.textContent=document.title||o?.textContent?.trim()||e.path})}}class it{options;active;nonce;pending=new Set;committedHead;committedBody;constructor(e){this.options=e}remember(e,t){this.committedBody=e,this.committedHead=t}reset(){this.committedHead=void 0,this.committedBody=void 0}async setBody(e,t){this.options.root.value=e;try{await this.options.root.flush()}catch(r){if(this.options.isCurrent(t)&&this.committedBody){this.options.root.value=this.committedBody;try{await this.options.root.flush()}catch(n){throw AggregateError([r,n],"Route commit and rollback failed.")}}throw r}}async activate(e,t){this.active?.();try{await e.activate()}catch(r){if(this.options.isCurrent(t)){e();try{if(this.committedBody)this.options.root.value=this.committedBody,await this.options.root.flush();if(this.committedHead){let n=this.stage(this.committedHead,t);await n.ready,await n.activate(),this.active=n,this.releasePending(n)}}catch(n){throw AggregateError([r,n],"Head commit and rollback failed.")}}throw r}}releasePending(e){this.pending.delete(e)}releaseActive(){let e=this.active;this.active=void 0,e?.()}discardPending(){let e=[...this.pending];this.pending.clear();let t=[];for(let r of e)try{r()}catch(n){t.push(n)}if(t.length)throw AggregateError(t,"Pending head cleanup failed.")}stage(e,t){let r=Ee(e,`${this.options.id}-r${t}`,{keepExisting:!0,deferTitle:!0,idSeed:`${this.options.id}:h`,...this.nonce===void 0?{}:{nonce:this.nonce}});return this.pending.add(r),r}}class Ae{options;navigation;history;scroll;accessibility;view;nonce;element;mounted=!1;ignoreURLHook=!1;revision=0;mountEpoch=0;redirects=0;stopPage;pendingPages=new Set;currentURL;pendingNavigation;stopURL;activeLoad;constructor(e){this.options=e;this.history=new nt({id:e.id,enabled:e.useHistory,currentURL:()=>this.currentURL}),this.scroll=new ot({history:this.history,isCurrent:(t)=>this.mounted&&t===this.revision}),this.accessibility=new st(e.id,()=>this.element),this.view=new it({id:e.id,root:e.root,isCurrent:(t)=>this.mounted&&t===this.revision}),this.navigation=new tt({base:e.base,history:e.useHistory,root:()=>this.element,onPop:(t,r)=>{let n=this.history.pop(t,r);this.pendingNavigation=void 0,this.updateURL(t),this.transition(t,!0,n)},navigate:(t)=>this.navigate(t)})}async mount(e={}){this.unmount();let t=this.revision;try{return await this.mountAtRevision(e,t)}catch(r){if(t===this.revision)this.unmount(),this.options.onError?.(r,this.initialURL());throw r}}async mountAtRevision(e,t){this.options.onMount?.(),this.nonce=e.nonce,this.view.nonce=e.nonce;let r=this.mountEpoch,n=()=>{if(r===this.mountEpoch)this.unmount()};if(this.element=e.id?document.getElementById(e.id)??void 0:document.body,!this.element)throw Error(`Yvee mount element not found: ${e.id}`);if(!document.body.id)document.body.id=e.id??this.options.id;this.element.dataset.app=this.options.id,this.mounted=!0,this.options.onLoading(!0);let o=await this.resolveInitialPage(this.initialURL());if(!this.mounted||t!==this.revision){if(o.kind==="ready")o.dispose?.();return n}if(o.kind==="ready"){if(o.dispose)this.pendingPages.add(o.dispose);if(o.failure!==void 0)this.options.onError?.(o.failure,o.url);this.options.url.value=o.url,this.options.root.value=o.body;let s=this.view.stage(U(this.options.getHead(),o.head),t);if(this.view.active=s,await s.ready,!this.mounted||t!==this.revision)return s(),n;ke("root"),await s.activate(),this.view.releasePending(s);let i=this.options.getLayout();if(await Yt({element:this.element,id:this.options.id,root:this.options.root,isCurrent:()=>this.mounted&&t===this.revision,...this.nonce===void 0?{}:{nonce:this.nonce},...e.className?{className:e.className}:{},...e.hydrate===void 0?{}:{hydrate:e.hydrate},...i?{layout:i}:{}}),!this.mounted||t!==this.revision)return n;if(this.accessibility.mount(),this.stopPage=o.dispose,o.dispose)this.pendingPages.delete(o.dispose);this.view.remember(o.body,U(this.options.getHead(),o.head)),this.currentURL=o.url,this.history.initialize(o.url)}if(this.options.onLoading(!1),await this.watchURL(),!this.mounted||t!==this.revision)return n;return this.navigation.start(),n}navigate(e,t,r=!1){let n=typeof e==="string"?L(e):L(`${e.path}${e.search}${e.hash}`);if(T(n)===T(this.options.url.value))return;if(!this.mounted){this.options.url.value=n;return}this.history.saveCurrentScroll();let o=T(n),s=r||n.hash?void 0:this.history.getScroll(o);if(this.history.write(n,t,r,s),this.options.useHistory&&location.protocol!=="file:")this.pendingNavigation={key:o,replace:r,...s?{scroll:s}:{}};this.options.url.value=n}back(){if(typeof history<"u")history.back()}forward(){if(typeof history<"u")history.forward()}async resolveInitialPage(e){let t=e,r=new AbortController;this.activeLoad=r;try{let n=Number(document.body.dataset.error);delete document.body.dataset.error;let o=await this.options.load(e,r.signal,n>=400&&n<=599?n:void 0),s=0;while(o.kind==="redirect"){if(++s>10)throw Error("Yvee redirect limit exceeded.");e=L(o.to),o=await this.options.load(e,r.signal)}if(T(e)!==T(t))this.history.write(e,void 0,!0);return o}finally{if(this.activeLoad===r)this.activeLoad=void 0}}async transition(e,t=!1,r){let n=this.revision+1;try{await this.runTransition(e,t,r)}catch(o){if(!this.mounted||n!==this.revision)return;let s=[o];try{this.view.discardPending()}catch(i){s.push(i)}try{this.discardPendingPages()}catch(i){s.push(i)}if(this.options.onLoading(!1),this.options.onError?.(s.length===1?o:AggregateError(s,"Transition cleanup failed."),e),this.currentURL)this.cancelNavigation(e,t)}}async runTransition(e,t=!1,r){let n=++this.revision;this.history.beginTransition(),this.view.discardPending(),this.discardPendingPages(),this.activeLoad?.abort();let o=new AbortController;this.activeLoad=o,this.options.onLoading(!0);let s;try{s=await this.options.load(e,o.signal)}catch(c){if(this.activeLoad!==o||!this.mounted)return;if(this.activeLoad=void 0,this.options.onLoading(!1),this.options.onError?.(c,e),this.currentURL)this.cancelNavigation(e,t);return}if(!this.mounted||n!==this.revision||o.signal.aborted){if(s.kind==="ready")s.dispose?.();return}if(this.activeLoad=void 0,s.kind==="stop"){if(this.options.onLoading(!1),this.currentURL)this.cancelNavigation(e,t);return}if(s.kind==="redirect"){this.options.onLoading(!1),this.followRedirect(s);return}if(s.dispose)this.pendingPages.add(s.dispose);if(this.redirects=0,s.failure!==void 0)this.options.onError?.(s.failure,s.url);let i=this.view.stage(U(this.options.getHead(),s.head),n);if(await i.ready,!this.mounted||n!==this.revision||o.signal.aborted){i();return}if(await this.view.setBody(s.body,n),!this.mounted||n!==this.revision||o.signal.aborted){i();return}let a=this.pendingNavigation?.key===T(e)?this.pendingNavigation.scroll:void 0;if(await this.view.activate(i,n),!this.mounted||n!==this.revision){i();return}this.view.active=i,this.view.releasePending(i),this.clearPendingNavigation(e);let l=this.stopPage;if(this.stopPage=s.dispose,s.dispose)this.pendingPages.delete(s.dispose);try{l?.()}catch(c){this.options.onError?.(c,s.url)}if(this.view.remember(s.body,U(this.options.getHead(),s.head)),this.currentURL=s.url,!this.options.useHistory){this.accessibility.commit(s.url,()=>this.mounted&&n===this.revision),this.options.onLoading(!1);return}if(t)await this.scroll.restoreScroll(r,n,s.url);else if(this.history.replaceAddressIfNeeded(s.url),a&&!s.url.hash)await this.scroll.restoreScroll(a,n,s.url);else await this.scroll.scrollToRoute(s.url,n);if(this.mounted&&n===this.revision)this.accessibility.commit(s.url,()=>this.mounted&&n===this.revision),this.options.onLoading(!1)}async watchURL(){this.stopURL=await oe(async(e)=>{if(!this.mounted||this.ignoreURLHook)return;await this.transition(e)},[this.options.url],{id:`${this.options.id}_url`})}followRedirect(e){if(++this.redirects>10)throw Error("Yvee redirect limit exceeded.");this.navigate(e.to,void 0,e.replace??!0)}cancelNavigation(e,t){let r=this.pendingNavigation;if(this.pendingNavigation=void 0,!t&&r?.key===T(e)&&!r.replace&&this.options.useHistory&&location.protocol!=="file:"){this.updateURL(this.currentURL),history.back();return}this.restoreURL(this.currentURL)}clearPendingNavigation(e){if(this.pendingNavigation?.key===T(e))this.pendingNavigation=void 0}restoreURL(e){this.history.restoreAddress(e),this.updateURL(e),this.history.trackDisplayedEntry()}updateURL(e){this.ignoreURLHook=!0;try{this.options.url.value=e}finally{this.ignoreURLHook=!1}}initialURL(){return L(location.protocol==="file:"?"/":location.href)}dispose(){this.unmount()}discardPendingPages(){let e=[...this.pendingPages];this.pendingPages.clear();let t=[];for(let r of e)try{r()}catch(n){t.push(n)}if(t.length)throw AggregateError(t,"Pending page cleanup failed.")}unmount(){this.mountEpoch++,this.mounted=!1,this.revision++;let e=this.stopURL;this.stopURL=void 0;let t=this.stopPage;this.stopPage=void 0;let r=this.activeLoad;this.activeLoad=void 0;let n=[],o=(s)=>{try{s()}catch(i){n.push(i)}};if(o(()=>r?.abort()),o(()=>e?.()),o(()=>this.view.releaseActive()),o(()=>this.view.discardPending()),o(()=>this.discardPendingPages()),o(()=>this.navigation.stop()),o(()=>{if(this.element?.id)M.resetScope(this.element.id)}),o(()=>t?.()),o(()=>this.accessibility.dispose()),this.element?.dataset.app===this.options.id)delete this.element.dataset.app;if(o(()=>this.options.onUnmount()),this.options.onLoading(!1),this.currentURL=void 0,this.view.reset(),this.pendingNavigation=void 0,this.history.reset(),n.length)throw AggregateError(n,"App disposal failed.")}}var Wt=new WeakMap;function Rr(e){if(!Number.isInteger(e)||e<400||e>599)throw RangeError("Expected an HTTP error status between 400 and 599.");return(t)=>(Wt.set(t,e),t)}var Zt=(e)=>Wt.get(e),at=new WeakMap,Jt=(e,t)=>(r)=>{let n=at.get(r)??[];return at.set(r,[...n,{path:e,transport:t}]),r},Xt=(e="/")=>Jt(e,"page"),Cr=Xt,Lr=(e="/")=>Jt(e,"socket"),Qt=(e)=>at.get(e)??[];function Pr(e,t){let r=B(t),n=B(e),i=B(`${r==="/"?"":r}/${n==="/"?"":n}`),a=[];if(i==="/")return{path:i,expression:/^\/?$/,names:a};let c=i.slice(1).split("/").map((d)=>{if(!d.startsWith(":"))return d.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");let u=d.slice(1);if(!/^[A-Za-z_][A-Za-z0-9_]*$/.test(u)||a.includes(u))throw TypeError(`Invalid route parameter: ${d}`);return a.push(u),"([^/]+)"}).join("/");return{path:i,expression:new RegExp(`^/${c}/?$`),names:a}}class Oe{base;entries=[];constructor(e="/"){this.base=e}add(e,t,r="page"){let n=Pr(e,this.base);if(this.entries.some((i)=>i.path===n.path&&i.transport===r))throw Error(`Route already registered: ${n.path}`);let s={...n,controller:t,transport:r};return this.entries.push(s),s}find(e,t="page"){let r=B(e);for(let n of this.entries){if(n.transport!==t)continue;let o=n.expression.exec(r);if(!o)continue;let s={};return n.names.forEach((i,a)=>{s[i]=decodeURIComponent(o[a+1]??"")}),{entry:n,params:s}}return}all(e){return this.entries.filter((t)=>!e||t.transport===e)}}var Ar=(e,t)=>{let r=0;return e.replace(/:([A-Za-z_][A-Za-z0-9_]*)/g,(n,o)=>{let s=Array.isArray(t)?t[r++]:t[o];return encodeURIComponent(String(s??""))})};function dt(e,t=new WeakMap){if(e===null||typeof e!=="object"){if(typeof e==="function"||typeof e==="symbol")throw TypeError("SSR data must be plain data; use dataFactory for request-owned services.");return e}let r=t.get(e);if(r)return r;let n=Object.getPrototypeOf(e);if(!Array.isArray(e)&&n!==Object.prototype&&n!==null)throw TypeError("SSR data must be plain data; use dataFactory for request-owned services.");let o=Array.isArray(e)?[]:Object.create(n);t.set(e,o);for(let s of Reflect.ownKeys(e)){if(Array.isArray(e)&&s==="length")continue;let i=Object.getOwnPropertyDescriptor(e,s);if(!("value"in i))throw TypeError("SSR data must not contain accessors.");Object.defineProperty(o,s,{value:dt(i.value,t),enumerable:i.enumerable??!1,configurable:!0,writable:!0})}if(Array.isArray(e))o.length=e.length;return Object.freeze(o)}function tr(e,t={}){let r=t.id??e.id,n=async(o)=>{let{url:s,data:i,error:a,nonce:l}=o,c=jr(s),d=o.signal??new AbortController().signal,u=[],f,p=!1;try{d.throwIfAborted();let w=i??t.data??e.data,g=t.dataFactory?await t.dataFactory({...o,signal:d,onDispose:(E)=>{u.push(E)}}):dt(w);d.throwIfAborted();let v=await Or(e,c,g,a,d);if(v.kind==="stop")throw Error(`Yvee server rendering was stopped by a guard for ${c.path}`);if(v.dispose)u.push(v.dispose);let b=U(e.defaults,v.head),y=await Mr(v.body,e.layout,t.class,r,l),m=v.status,h=await Dr(y,b,r,m,l,g,t.dataFactory?w:void 0);return d.throwIfAborted(),{html:h,status:m}}catch(w){throw f=w,p=!0,w}finally{let w=[];for(let g of u.reverse())try{await g()}catch(v){w.push(v)}if(w.length)throw AggregateError(p?[f,...w]:w,"SSR request cleanup failed.")}};return Object.assign(async(o)=>(await n(o)).html,{withStatus:n})}async function Or(e,t,r,n,o){let s=t;for(let i=0;i<=10;i++){let a=await Pe({app:e.app,routes:e.routes,globalGuards:e.guards,errors:e.errors,...n===void 0?{}:{error:n},url:s,data:r,signal:o});if(a.kind!=="redirect")return a;if(i===10)throw Error("Yvee redirect limit exceeded during server rendering.");n=void 0,s=L(a.to)}throw Error("Yvee redirect limit exceeded during server rendering.")}async function Mr(e,t,r,n,o){let s=Z(e),i=t?await t(s):s,a=i instanceof C?i:q("main",{class:r},i);return(await X(a,new S(n,0,o))).ctx}async function Dr(e,t,r,n,o,s,i){return["<!doctype html>",'<html lang="en">',`<head>${await Hr(t,"root",o)}${Ir(s,o,i)}</head>`,`<body id="${rr(r)}"${n>=400?` data-error="${Number(n)}"`:""}>${e}</body>`,"</html>"].join("")}function Ir(e,t,r){let n={id:"ssr",...t===void 0?{}:{nonce:t}};try{return ge(e,n)}catch(o){if(r===void 0||!(o instanceof TypeError))throw o;try{return ge(r,n)}catch(s){if(!(s instanceof TypeError))throw s;return""}}}async function Hr(e,t,r){let n=[],o=e.base?.at(-1);if(o)n.push(`<base${K(o,t)}>`);if(e.description)n.push(`<meta${K({name:"description",content:e.description},t)}>`);for(let s of e.meta??[])n.push(`<meta${K(s,t)}>`);for(let s of e.script??[]){let{body:i,...a}=s;n.push(`<script${K({...a,...r===void 0?{}:{nonce:r}},t)}>${F("script",i)}</script>`)}for(let s of er(e.js))n.push(`<script${K({src:s,...r===void 0?{}:{nonce:r}},t)}></script>`);if(e.title)n.push(`<title${K({},t)}>${$r(e.title)}</title>`);if(e.style)n.push(`<style${K({...r===void 0?{}:{nonce:r}},t)}>${F("style",e.style)}</style>`);for(let s of e.link??[])n.push(`<link${K(s,t)}>`);for(let s of er(e.css))n.push(`<link${K({rel:"stylesheet",href:s},t)}>`);if(e.elements?.length)n.push((await fe(e.elements,t,`${t}:h`,r)).ctx);return n.join("")}function K(e,t){let r={...e,"data-yv":t};return Object.entries(r).map(([n,o])=>{if(P(n,o),o===!1)return"";if(o===!0)return` ${n}`;return` ${n}="${rr(o)}"`}).join("")}var rr=R,$r=R;function er(e){if(e===void 0)return[];return Array.isArray(e)?e:[e]}function jr(e){if(typeof e==="string"||e instanceof URL)return L(e);return L(`${e.path}${e.search}${e.hash}`)}class nr{connection;path="/";params={};open(e){}message(e){}close(e){}error(e){}messageError(e,t,r){console.error(`Yvee socket ${t} failed`,e)}sendJson(e){if(this.connection?.readyState===WebSocket.OPEN)this.connection.send(JSON.stringify(e))}onMessage(e,t={}){let r=this.message.bind(this);return this.message=async(n)=>{let o=(i,a)=>{if(t.onError)t.onError(i,a,n);else this.messageError(i,a,n)};try{await r(n)}catch(i){o(i,"handler")}let s;try{if(typeof n.data!=="string")throw TypeError("Expected a JSON text frame.");s=JSON.parse(n.data)}catch(i){o(i,"parse");return}try{if(t.validate&&!t.validate(s))throw TypeError("Socket payload validation failed.")}catch(i){o(i,"validation");return}try{await e(s,n)}catch(i){o(i,"handler")}},this}}class Me{app;connections=new Map;constructor(e){this.app=e}load(e,t={}){if(t.signal?.throwIfAborted(),typeof WebSocket>"u")throw Error("WebSocket is not available in this environment.");let r=typeof location>"u"?"http://localhost":location.href,n=new URL(e,r);if(n.protocol==="https:")n.protocol="wss:";else if(n.protocol==="http:")n.protocol="ws:";else if(!["ws:","wss:"].includes(n.protocol))throw TypeError("Unsupported WebSocket protocol.");let o=this.app.routes.find(n.pathname,"socket");if(!o)throw Error(`No WebSocket route matches ${e}`);let s=this.connections.get(e);if(s)return s.controller;let i=t.retry?.attempts??0,a=t.retry?.delay??250,l=t.retry?.maxDelay??30000;if(!Number.isSafeInteger(i)||i<0||!Number.isFinite(a)||a<0||!Number.isFinite(l)||l<a)throw RangeError("Invalid WebSocket retry policy.");let d=new o.entry.controller;d.path=e,d.params=o.params;let u=new O;if(this.connections.set(e,{controller:d,scope:u}),u.defer(()=>{if(this.connections.get(e)?.controller===d)this.connections.delete(e)}),t.signal)u.listen(t.signal,"abort",()=>this.unload(e),{once:!0});let f=0,p=(g)=>console.error("Yvee socket callback failed",g),w=()=>{if(u.disposed)return;let g=new WebSocket(n);d.connection=g;let v=new O,b=u.defer(()=>v.dispose());v.defer(()=>{if(g.readyState<WebSocket.CLOSING)g.close()}),v.listen(g,"open",(y)=>{try{Promise.resolve(d.open(y)).catch(p)}catch(m){p(m)}}),v.listen(g,"message",(y)=>{try{Promise.resolve(d.message(y)).catch(p)}catch(m){p(m)}}),v.listen(g,"error",(y)=>{try{Promise.resolve(d.error(y)).catch(p)}catch(m){p(m)}}),v.listen(g,"close",(y)=>{b();try{Promise.resolve(d.close(y)).catch(p)}catch(m){p(m)}if(u.disposed)return;if(f<i)u.timeout(()=>{try{w()}catch(m){p(m),u.dispose()}},Math.min(l,a*2**f++));else u.dispose()})};try{w()}catch(g){throw u.dispose(),g}return d}unload(e){this.connections.get(e)?.scope.dispose()}closeAll(){let e=[];for(let{scope:t}of[...this.connections.values()])try{t.dispose()}catch(r){e.push(r)}if(e.length)throw AggregateError(e,"Socket cleanup failed.")}}class or extends pe{id;routes;url;loading;socket;history;data={};resources=new O;root;pageErrors=new Map;globalGuards=[];client;layout;onError;constructor(e={}){super();let t=B(e.base??"/"),r=e.history??!0;this.id=e.id??Math.random().toString(36).slice(2,9),this.url=Z(L("/")),this.loading=Z(!1),this.root=Z([],{onError(){}}),this.routes=new Oe(t),this.socket=new Me(this),this.head({base:[{href:t==="/"?"/":`${t}/`}],meta:[{charset:"utf-8"},{name:"viewport",content:"width=device-width, initial-scale=1.0"}],script:[{type:"module",src:Nr(e.client??".")}],...e.index?{js:e.index}:{}}),this.client=new Ae({id:this.id,base:t,useHistory:r,url:this.url,root:this.root,load:(n,o,s)=>this.load(n,o,s),getHead:()=>this.values,getLayout:()=>this.layout,onLoading:(n)=>{this.loading.value=n},onError:(n,o)=>{if(this.onError)this.onError(n,o);else console.error("Yvee page transition failed",n)},onMount:()=>{if(this.resources.disposed)this.resources=new O},onUnmount:()=>{let n=[];try{this.resources.dispose()}catch(o){n.push(o)}try{this.socket.closeAll()}catch(o){n.push(o)}if(n.length)throw AggregateError(n,"Owned app resources failed to close.")}}),this.history={navigate:(n,o)=>this.client.navigate(n,o),replace:(n,o)=>this.client.navigate(n,o,!0),back:()=>this.client.back(),forward:()=>this.client.forward()}}Main(e){return this.layout=e,this}use(...e){return this.globalGuards.push(...e),this}head(e){return super.head(e),this}route(e){return(t)=>(this.routes.add(e,t),t)}error(e,t){return this.pageErrors.set(e,t),this}register(...e){for(let t of e){let r=Zt(t);if(r!==void 0)this.error(r,t);for(let n of Qt(t))this.routes.add(n.path,t,n.transport)}return this}listRoutes(e){return this.routes.all(e)}listPaths(){return[...new Set(this.routes.all("page").map(({path:e})=>e.split("/").map((t)=>t.startsWith(":")?t.slice(1):t).join("/")))]}renderHTML(e,t={}){return this.server()({...t,url:e})}render(e={}){let t=typeof document<"u";this.data=e.data??(t?Ur():void 0)??{};let r=this.server({...e.id?{id:e.id}:{},...e.class?{class:e.class}:{},data:this.data}),n=t?this.client.mount({...e.id?{id:e.id}:{},...e.class?{className:e.class}:{},...e.hydrate===void 0?{}:{hydrate:e.hydrate},...e.nonce===void 0?{}:{nonce:e.nonce}}).then(()=>{document.body.dataset.yveeReady="true"}):Promise.resolve(()=>{});n.catch(()=>{});let o=Object.assign((s)=>r(s),{withStatus:r.withStatus});return Object.assign(o,{then:n.then.bind(n),catch:n.catch.bind(n),finally:n.finally.bind(n)})}dispose(){this.client.dispose()}server(e={}){return tr({id:this.id,defaults:this.values,routes:this.routes,errors:this.pageErrors,guards:this.globalGuards,data:this.data,...this.layout?{layout:this.layout}:{},app:this},e)}load(e,t,r){return Pe({app:this,routes:this.routes,globalGuards:this.globalGuards,errors:this.pageErrors,url:e,data:this.data,...r===void 0?{}:{error:r},signal:t})}}function Ur(){let e=document.getElementById("ssr");if(!e?.textContent)return;try{let t=JSON.parse(e.textContent);if(typeof t==="object"&&t!==null&&!Array.isArray(t))return t;throw TypeError("Yvee SSR payload must be a JSON object.")}catch(t){console.error("Could not read Yvee SSR payload",t);return}}function Nr(e){let t=e.startsWith("/")||e.startsWith(".")?e:`/${e}`;return/\.js(?:[?#]|$)/i.test(t)?t:`${t.replace(/\/+$/,"")}/index.js`}class ct{store;base;schema;key;constructor(e,t,r){this.store=e;this.base=t;this.schema=r;if(!Number.isSafeInteger(r.version)||r.version<1)throw TypeError("Storage versions must be positive integers.");this.key=`${t}:v${r.version}`}get(){if(this.store.has(this.key))return this.check(this.store.get(this.key).value);for(let e=this.schema.version-1;e>=1;e--){let t=`${this.base}:v${e}`;if(!this.store.has(t))continue;let r=this.store.get(t).value;for(let o=e+1;o<=this.schema.version;o++){let s=this.schema.migrations?.[o];if(!s)throw Error(`Missing storage migration to version ${o}.`);r=s(r)}let n=this.check(r);return this.store.set(this.key,n),n}return this.check(this.schema.fallback())}set(e){return this.store.set(this.key,this.check(e)),this}remove(){return this.store.remove(this.key),this}watch(e,t){return this.store.watch(this.key,e,t)}check(e){if(!this.schema.validate(e))throw TypeError(`Invalid stored value for '${this.key}'.`);return e}}class De{storeName;key;current;constructor(e,t,r){this.storeName=e;this.key=t;this.current=r}get value(){return this.current}set value(e){this.current=e}set(e){return this.current=e,this}save(){if(typeof window<"u")this.storage().setItem(this.key,JSON.stringify(this.current));return this}remove(){if(typeof window<"u")this.storage().removeItem(this.key);return this}as={str:()=>String(this.current??""),int:()=>Number.parseInt(String(this.current),10),float:()=>Number.parseFloat(String(this.current)),bool:()=>this.current===!0||this.current==="true"||this.current===1,json:()=>this.current};storage(){return this.storeName==="localStorage"?window.localStorage:window.sessionStorage}}class Ie{storeName;constructor(e){this.storeName=e}versioned(e,t){return new ct(this,e,t)}watch(e,t,{signal:r,scope:n}={}){if(typeof window>"u"||r?.aborted||n?.disposed)return()=>{};let o=window,s=this.storage();s.getItem(e);let i=(l)=>{if(l.storageArea===s&&(l.key===e||l.key===null))t({key:l.key,oldValue:l.oldValue,newValue:l.newValue})},a=()=>{o.removeEventListener("storage",i),r?.removeEventListener("abort",a)};return o.addEventListener("storage",i),r?.addEventListener("abort",a,{once:!0}),n?n.defer(a):a}get(e,t){let r;if(typeof window<"u")try{let n=this.storage().getItem(e);if(n!==null)r=JSON.parse(n)}catch{r=void 0}return new De(this.storeName,e,r===void 0?t:r)}set(e,t){return new De(this.storeName,e,t).save()}remove(e){if(typeof window<"u")this.storage().removeItem(e);return this}has(e){return typeof window<"u"&&this.storage().getItem(e)!==null}storage(){return this.storeName==="localStorage"?window.localStorage:window.sessionStorage}}var Gr=new Ie("localStorage"),qr=new Ie("sessionStorage");class lt extends Error{response;constructor(e){super(`HTTP ${e.status} ${e.statusText}`);this.response=e;this.name="HTTPError"}}function sr(e,t){return t?.throwIfAborted(),new Promise((r,n)=>{let o=()=>{clearTimeout(s),n(t?.reason)},s=setTimeout(()=>{t?.removeEventListener("abort",o),r()},e);t?.addEventListener("abort",o,{once:!0})})}async function Br(e,t){let{validate:r,retry:n,fetch:o=globalThis.fetch,...s}=t,i=s.signal===void 0?e instanceof Request?e.signal:void 0:s.signal,a=(s.method??(e instanceof Request?e.method:"GET")).toUpperCase(),l=n?.attempts??0,c=n?.delayMs??100;if(!Number.isInteger(l)||l<0||l>5||!Number.isFinite(c)||c<0)throw TypeError("Retries require 0\u20135 additional attempts and a finite nonnegative delay.");if(l&&(!["GET","HEAD","OPTIONS"].includes(a)||s.body!=null||e instanceof Request&&e.body!==null))throw TypeError("Only bodyless GET, HEAD and OPTIONS requests may retry.");for(let d=0;;d++){i?.throwIfAborted();let u;try{u=await o(e,s)}catch(p){if(i?.throwIfAborted(),d>=l||!(p instanceof TypeError))throw p;await sr(c,i);continue}if(i?.throwIfAborted(),!u.ok){let p=new lt(u);if(d>=l||![408,429,500,502,503,504].includes(u.status))throw p;await u.body?.cancel(),await sr(c,i);continue}let f=await u.json();if(i?.throwIfAborted(),!r(f))throw TypeError("Response JSON failed validation.");return f}}function Kr(e,t={},r={}){if(r.signal?.throwIfAborted(),typeof EventSource>"u")throw Error("EventSource is not available in this environment.");let n=new EventSource(e,{withCredentials:r.withCredentials??!1}),o=new O,s=n.close.bind(n);o.defer(s),n.close=()=>o.dispose();for(let[i,a]of Object.entries(t))if(a)o.listen(n,i,a);if(r.signal)o.listen(r.signal,"abort",()=>n.close(),{once:!0});return n}export{dn as $,Ze as ATTR,Ie as BrowserStore,G as Column,C as DOM,Te as DbRepository,oo as Derived,O as DisposalScope,D as Elem,It as EventStream,me as FailurePage,Mt as Field,lt as HTTPError,pe as HeadDefaults,Tt as IDNotConnected,Fe as IndexedDatabase,he as MissingPage,Le as Page,An as QState,Pn as RecState,Lt as RecStateful,we as Ref,xt as RefState,Oe as RouteBook,Ht as Schema,hr as Scope,Ln as SetState,Ct as SetStateful,nr as SocketController,Me as SocketHub,Z as State,pr as StateEffect,oe as StateHook,cr as StateLoaded,A as Stateful,Dt as Stored,De as StoredValue,ln as Toggled,ct as VersionedValue,or as Yvee,Gt as allGuards,Ee as applyHead,le as attr_value,dr as batch,Ut as createGuard,q as dom,Rr as error,Vn as eventStream,Kr as eventStreams,wo as frag,I as getElementById,lr as hook,Ar as interpolate,ur as loaded,Gr as local,B as normalizePath,Xt as page,Bt as paramsGuard,vt as renderContent,X as renderDom,ge as renderJSONScript,Br as requestJSON,et as requireGuard,Cr as route,gt as serializePayload,qr as session,wt as setContentRenderer,fr as shallowEqual,Lr as socketRoute,mr as t,L as toURL,Nt as use,gn as useRef,qt as whenGuard};
|
package/package.json
CHANGED
|
@@ -1,21 +1,39 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yvee",
|
|
3
|
-
"version": "0.0
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "TypeScript UI framework with reactive state, a TSX renderer, client-side routing with guards, server-side rendering, and browser storage and network helpers.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"typescript",
|
|
7
|
+
"ui",
|
|
8
|
+
"framework",
|
|
9
|
+
"reactive",
|
|
10
|
+
"tsx",
|
|
11
|
+
"ssr",
|
|
12
|
+
"routing",
|
|
13
|
+
"spa",
|
|
14
|
+
"indexeddb",
|
|
15
|
+
"websockets"
|
|
16
|
+
],
|
|
5
17
|
"author": "Marky <markjotep@gmail.com>",
|
|
6
18
|
"license": "MIT",
|
|
7
19
|
"main": "dist/index.js",
|
|
8
20
|
"types": "dist/index.d.ts",
|
|
21
|
+
"exports": {
|
|
22
|
+
".": {
|
|
23
|
+
"types": "./dist/index.d.ts",
|
|
24
|
+
"default": "./dist/index.js"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"sideEffects": false,
|
|
9
28
|
"files": [
|
|
10
29
|
"dist"
|
|
11
30
|
],
|
|
12
31
|
"scripts": {
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"build": "rm -r ./types ; tsc && bun build ./src/index.ts --outdir ./dist --minify --packages external --target browser && rollup -c ./util/rollup.config.js"
|
|
32
|
+
"init": "bun update && mkdir -p ./src ./dist ./types && { [ ! -f ./src/index.ts ] && touch ./src/index.ts; }",
|
|
33
|
+
"test": "bun test",
|
|
34
|
+
"test:browser": "playwright test",
|
|
35
|
+
"test:types": "tsc --noEmit -p tsconfig.consumer.json",
|
|
36
|
+
"demo": "bun run test/yvee-bun/server.ts"
|
|
19
37
|
},
|
|
20
38
|
"repository": {
|
|
21
39
|
"type": "git",
|
|
@@ -27,12 +45,15 @@
|
|
|
27
45
|
"homepage": "https://github.com/MARKjotep/yvee#readme",
|
|
28
46
|
"dependencies": {},
|
|
29
47
|
"devDependencies": {
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
"
|
|
48
|
+
"@axe-core/playwright": "^4.14.0",
|
|
49
|
+
"@ohmyqt/oven": "link:@ohmyqt/oven",
|
|
50
|
+
"@ohmyqt/u": "link:@ohmyqt/u",
|
|
51
|
+
"@playwright/test": "^1.65.1",
|
|
52
|
+
"@types/bun": "^1.4.4",
|
|
53
|
+
"fake-indexeddb": "^6.2.8",
|
|
54
|
+
"typescript": "5.9.3"
|
|
35
55
|
},
|
|
56
|
+
"peerDependencies": {},
|
|
36
57
|
"directories": {
|
|
37
58
|
"test": "test"
|
|
38
59
|
},
|
package/readme.md
DELETED