yvee 0.0.9 → 0.0.10
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/dist/index.d.ts +83 -40
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -259,7 +259,7 @@ declare class __ {
|
|
|
259
259
|
static randArray<T>(arr?: T[], length?: number, unique?: boolean): T[];
|
|
260
260
|
static randomAZ: () => string;
|
|
261
261
|
static makeID: (length: number) => string;
|
|
262
|
-
static class(a: obj$1<any>, ...classes: string[]): void;
|
|
262
|
+
static class(a: obj$1<any>, ...classes: (string | undefined | boolean)[]): void;
|
|
263
263
|
static get O(): {
|
|
264
264
|
vals: {
|
|
265
265
|
<T>(o: {
|
|
@@ -288,10 +288,27 @@ declare class __ {
|
|
|
288
288
|
};
|
|
289
289
|
static get is(): typeof is;
|
|
290
290
|
static get return(): typeof returner;
|
|
291
|
+
static isHREF(pt: string, hpt: string): boolean;
|
|
291
292
|
static sleep: (ms?: number) => Promise<unknown>;
|
|
292
293
|
static get screen(): "xs" | "sm" | "smd" | "md" | "lg" | "xl" | "xxl" | undefined;
|
|
293
294
|
bytes(bytes: number): string;
|
|
294
295
|
static format(val: any): Formatteer;
|
|
296
|
+
static compareObjects: <T extends object>(oldObj: T, newObj: T | any) => {
|
|
297
|
+
added: Record<string, any>;
|
|
298
|
+
removed: Record<string, any>;
|
|
299
|
+
modified: Record<string, {
|
|
300
|
+
old: any;
|
|
301
|
+
new: any;
|
|
302
|
+
}>;
|
|
303
|
+
};
|
|
304
|
+
static isObjectUdpated: (changes: {
|
|
305
|
+
added: Record<string, any>;
|
|
306
|
+
removed: Record<string, any>;
|
|
307
|
+
modified: Record<string, {
|
|
308
|
+
old: any;
|
|
309
|
+
new: any;
|
|
310
|
+
}>;
|
|
311
|
+
}) => boolean;
|
|
295
312
|
}
|
|
296
313
|
declare class returner {
|
|
297
314
|
static arr<T = string>(val?: any): T[];
|
|
@@ -972,8 +989,8 @@ declare class Dom {
|
|
|
972
989
|
ctx: ctx[];
|
|
973
990
|
constructor(tag: string, attr: attr, ctx: ctx[]);
|
|
974
991
|
}
|
|
975
|
-
declare function dom(tag: string | ((attr: attr, ...ctx: ctx[]) => Dom), attr?: attr | null, ...ctx: ctx[]): Dom
|
|
976
|
-
declare const frag: (attr: attr, ...ctx: Dom[]) => Dom
|
|
992
|
+
declare function dom$1(tag: string | ((attr: attr, ...ctx: ctx[]) => maybePromise<Dom>), attr?: attr | null, ...ctx: ctx[]): Promise<Dom>;
|
|
993
|
+
declare const frag: (attr: attr, ...ctx: Dom[]) => Promise<Dom>;
|
|
977
994
|
declare global {
|
|
978
995
|
type events<T extends Elements = HTMLElement> = {
|
|
979
996
|
[P in keyof GlobalEventHandlersEventMap]?: (this: T, e: GlobalEventHandlersEventMap[P]) => void;
|
|
@@ -982,10 +999,10 @@ declare global {
|
|
|
982
999
|
type dom = Dom;
|
|
983
1000
|
type ctx<T = DVal | dom> = T | Stateful<T> | ctx[];
|
|
984
1001
|
type obj<T> = Record<string, T>;
|
|
985
|
-
type DomFN<T = {}> = (a: attr & T, ...D: ctx[]) => dom
|
|
1002
|
+
type DomFN<T = {}> = (a: attr & T, ...D: ctx[]) => maybePromise<dom>;
|
|
986
1003
|
type attr = EAttr;
|
|
987
1004
|
namespace JSX {
|
|
988
|
-
type Element = dom
|
|
1005
|
+
type Element = maybePromise<dom>;
|
|
989
1006
|
interface IntrinsicElements extends ElementAttributes, SVGAttributes {
|
|
990
1007
|
}
|
|
991
1008
|
}
|
|
@@ -999,10 +1016,11 @@ declare class doc<T extends docObj = obj<obj<any>>> extends head {
|
|
|
999
1016
|
path: string;
|
|
1000
1017
|
data: T["data"];
|
|
1001
1018
|
args: T["args"];
|
|
1002
|
-
importArgs: any[];
|
|
1019
|
+
importArgs: any[] | (() => any[]);
|
|
1003
1020
|
fetch?(): maybePromise<obj<any>>;
|
|
1004
1021
|
head?(): maybePromise<void>;
|
|
1005
1022
|
body?(): maybePromise<any>;
|
|
1023
|
+
static A: (a: aAttr, ...ctx: ctx[]) => Promise<Dom>;
|
|
1006
1024
|
}
|
|
1007
1025
|
|
|
1008
1026
|
type ExtraState = Record<string, unknown>;
|
|
@@ -1013,7 +1031,7 @@ type ChangeHandler<S extends ExtraState> = (path: string, state: HistoryData<S>)
|
|
|
1013
1031
|
declare class PathHistory<S extends ExtraState = ExtraState> {
|
|
1014
1032
|
private onChange?;
|
|
1015
1033
|
private popListener?;
|
|
1016
|
-
constructor(path?: Stateful<string>, onChange?: ChangeHandler<S>);
|
|
1034
|
+
constructor(path?: Stateful<string>, isDev?: boolean, onChange?: ChangeHandler<S>);
|
|
1017
1035
|
/** Current path (pathname + search + hash) */
|
|
1018
1036
|
path(): string;
|
|
1019
1037
|
/** Current state object */
|
|
@@ -1028,7 +1046,6 @@ declare class PathHistory<S extends ExtraState = ExtraState> {
|
|
|
1028
1046
|
destroy(): void;
|
|
1029
1047
|
private resolve;
|
|
1030
1048
|
private samePath;
|
|
1031
|
-
private assertClient;
|
|
1032
1049
|
}
|
|
1033
1050
|
|
|
1034
1051
|
interface contentObj {
|
|
@@ -1039,7 +1056,11 @@ declare class content<T extends contentObj = obj<obj<string>>> {
|
|
|
1039
1056
|
path: string;
|
|
1040
1057
|
data: T["data"];
|
|
1041
1058
|
args: T["args"];
|
|
1059
|
+
importArgs: any[] | (() => any[]);
|
|
1042
1060
|
body?(): maybePromise<any>;
|
|
1061
|
+
static Button: (a: buttonAttr & {
|
|
1062
|
+
tab?: string | string[];
|
|
1063
|
+
}, ...ctx: ctx[]) => Promise<Dom>;
|
|
1043
1064
|
}
|
|
1044
1065
|
|
|
1045
1066
|
declare class websocket<T = Record<string, any>> {
|
|
@@ -1090,7 +1111,7 @@ declare class Stormy extends MainStorage<ClientPath> {
|
|
|
1090
1111
|
wss: Storage<SocketPath>;
|
|
1091
1112
|
setRoute(path: string, _doc: typeof doc<{}>): void;
|
|
1092
1113
|
getRoute(path: string, error?: number): doc<{}>;
|
|
1093
|
-
setWss(path: string): void;
|
|
1114
|
+
setWss(path: string, _wss: typeof websocket): void;
|
|
1094
1115
|
getWss(path: string): [SocketPath | undefined, Record<string, string>];
|
|
1095
1116
|
setError(code: number, _doc: typeof doc<{}>): void;
|
|
1096
1117
|
getError(code?: number): [ClientPath | undefined, Record<string, string>];
|
|
@@ -1102,67 +1123,89 @@ declare class miniStormy extends MainStorage<TabPath> {
|
|
|
1102
1123
|
getRoute(path: string, error?: number): content<{}>;
|
|
1103
1124
|
setWss(path: string): void;
|
|
1104
1125
|
getWss(path: string): void;
|
|
1105
|
-
setError(code: number, _doc: typeof
|
|
1126
|
+
setError(code: number, _doc: typeof content<{}>): void;
|
|
1106
1127
|
getError(code?: number): [TabPath | undefined, Record<string, string>];
|
|
1107
1128
|
}
|
|
1108
1129
|
|
|
1109
|
-
declare class
|
|
1130
|
+
declare class minElements$1 extends htmlHead {
|
|
1131
|
+
id: string;
|
|
1132
|
+
data: obj<any>;
|
|
1133
|
+
path: Stateful<string>;
|
|
1134
|
+
protected _root: Stateful<any[]>;
|
|
1135
|
+
constructor();
|
|
1136
|
+
A(a: aAttr, ...ctx: ctx[]): Promise<Dom>;
|
|
1137
|
+
protected _main?: (root: Stateful<any[]>) => maybePromise<dom>;
|
|
1138
|
+
protected getMain(_class?: string | string[]): Promise<Dom>;
|
|
1139
|
+
}
|
|
1140
|
+
|
|
1141
|
+
declare class Router extends minElements$1 {
|
|
1142
|
+
protected pushHistory: boolean;
|
|
1110
1143
|
storage: Stormy;
|
|
1111
1144
|
protected base: string;
|
|
1112
|
-
constructor(base?: string, index?: string);
|
|
1145
|
+
constructor(base?: string, index?: string, pushHistory?: boolean);
|
|
1146
|
+
/** --------------------
|
|
1147
|
+
* string | int | float | file | uuid
|
|
1148
|
+
* - /url/\<string:hell>
|
|
1149
|
+
*/
|
|
1113
1150
|
route<Q extends typeof doc<{}>>(path: string): (f: Q) => Q;
|
|
1151
|
+
error<Q extends typeof doc<{}>>(...codes: number[]): (f: Q) => Q;
|
|
1152
|
+
/** --------------------
|
|
1153
|
+
* string | int | float | file | uuid
|
|
1154
|
+
* - /url/\<string:hell>
|
|
1155
|
+
*/
|
|
1156
|
+
wss<Q extends typeof websocket>(path: string): (f: Q) => Q;
|
|
1114
1157
|
}
|
|
1115
1158
|
|
|
1116
1159
|
interface mtab {
|
|
1117
|
-
tab
|
|
1160
|
+
tab?: string | string[];
|
|
1118
1161
|
}
|
|
1119
|
-
declare class minElements
|
|
1162
|
+
declare class minElements {
|
|
1120
1163
|
id: string;
|
|
1121
1164
|
path: Stateful<string>;
|
|
1122
|
-
_root: Stateful<any[]>;
|
|
1123
|
-
|
|
1124
|
-
|
|
1165
|
+
protected _root: Stateful<any[]>;
|
|
1166
|
+
Button(a: buttonAttr & mtab, ...ctx: ctx[]): Promise<Dom>;
|
|
1167
|
+
}
|
|
1168
|
+
interface _Tabs {
|
|
1169
|
+
path?: Stateful<string>;
|
|
1125
1170
|
}
|
|
1126
|
-
declare class Tabs extends minElements
|
|
1171
|
+
declare class Tabs extends minElements {
|
|
1127
1172
|
storage: miniStormy;
|
|
1128
|
-
|
|
1173
|
+
private hasLoaded;
|
|
1174
|
+
constructor({ path }?: _Tabs);
|
|
1129
1175
|
tab<Q extends typeof content<{}>>(path: string): (f: Q) => Q;
|
|
1130
|
-
|
|
1176
|
+
Main(a: attr & {
|
|
1177
|
+
tab?: string;
|
|
1178
|
+
data?: obj<any>;
|
|
1179
|
+
}): Promise<Dom>;
|
|
1180
|
+
load(tab: string, data?: obj<any>): Promise<void>;
|
|
1131
1181
|
}
|
|
1132
1182
|
|
|
1133
1183
|
interface renderConfig {
|
|
1134
1184
|
class?: string | string[];
|
|
1135
1185
|
id?: string;
|
|
1136
1186
|
data?: any;
|
|
1137
|
-
isDev?: boolean;
|
|
1138
|
-
}
|
|
1139
|
-
interface _Yvee {
|
|
1140
|
-
base?: string;
|
|
1141
|
-
index?: string;
|
|
1142
|
-
history?: boolean;
|
|
1143
|
-
}
|
|
1144
|
-
declare class minElements extends Router {
|
|
1145
|
-
protected pushHistory: boolean;
|
|
1146
|
-
id: string;
|
|
1147
|
-
data: obj<any>;
|
|
1148
|
-
path: Stateful<string>;
|
|
1149
|
-
protected _root: Stateful<any[]>;
|
|
1150
|
-
constructor(base?: string, index?: string, pushHistory?: boolean);
|
|
1151
|
-
Main(a: attr): Dom;
|
|
1152
|
-
A(a: aAttr, ...ctx: ctx[]): Dom;
|
|
1153
1187
|
}
|
|
1154
1188
|
interface serverRender {
|
|
1155
1189
|
path: string;
|
|
1156
1190
|
error?: number;
|
|
1157
1191
|
data?: Record<string, any>;
|
|
1158
1192
|
}
|
|
1159
|
-
|
|
1193
|
+
interface _Yvee {
|
|
1194
|
+
base?: string;
|
|
1195
|
+
index?: string;
|
|
1196
|
+
history?: boolean;
|
|
1197
|
+
isDev?: boolean;
|
|
1198
|
+
}
|
|
1199
|
+
declare class Yvee extends Router {
|
|
1160
1200
|
yvee: Yvee;
|
|
1161
|
-
|
|
1201
|
+
private isDev;
|
|
1202
|
+
history: PathHistory;
|
|
1203
|
+
constructor({ base, history, index, isDev }?: _Yvee);
|
|
1204
|
+
Main(main?: (root: Stateful<any[]>) => maybePromise<dom>): void;
|
|
1162
1205
|
render(x?: renderConfig): Promise<(() => void) | (({ path, data, error }: serverRender) => Promise<string>)>;
|
|
1163
1206
|
private init;
|
|
1164
1207
|
}
|
|
1165
|
-
declare const Routes: (fn: (route: Yvee["route"]) =>
|
|
1208
|
+
declare const Routes: <T>(fn: (route: Yvee["route"]) => T) => (route: Yvee["route"]) => T;
|
|
1166
1209
|
|
|
1167
|
-
export { $, IfClient, Meta, PathHistory, QState, Ref, Routes, State, StateHook, Stateful, Tabs, Time, Yvee, __, addCSS, content, cssLoader, doc, dom, frag, log, socket, useRef, websocket };
|
|
1210
|
+
export { $, IfClient, Meta, PathHistory, QState, Ref, Routes, State, StateHook, Stateful, Tabs, Time, Yvee, __, addCSS, content, cssLoader, doc, dom$1 as dom, frag, log, socket, useRef, websocket };
|
|
1168
1211
|
export type { $E, Elements, _$, aAttr, headAttr, maybePromise, serverRender };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var Sn=Object.defineProperty;var Mn=(t,n)=>{for(var r in n)Sn(t,r,{get:n[r],enumerable:!0,configurable:!0,set:(o)=>n[r]=()=>o})};var L=function(t,n,r,o){var i=arguments.length,f=i<3?n:o===null?o=Object.getOwnPropertyDescriptor(n,r):o,u;if(typeof Reflect==="object"&&typeof Reflect.decorate==="function")f=Reflect.decorate(t,n,r,o);else for(var m=t.length-1;m>=0;m--)if(u=t[m])f=(i<3?u(f):i>3?u(n,r,f):u(n,r))||f;return i>3&&f&&Object.defineProperty(n,r,f),f};var g=(t,n)=>{if(typeof Reflect==="object"&&typeof Reflect.metadata==="function")return Reflect.metadata(t,n)};var Et={};Mn(Et,{isWindow:()=>$t,isUndefined:()=>Un,isStr:()=>V,isPromise:()=>Rn,isPlainObject:()=>X,isObject:()=>qn,isObj:()=>Y,isNumber:()=>K,isNum:()=>yt,isNull:()=>ot,isNotWindow:()=>$,isNotNull:()=>Qn,isModule:()=>et,isInt:()=>Ht,isFN:()=>E,isDefined:()=>Xn,isClassOrId:()=>Fn,isBool:()=>P,isAsync:()=>Zn,isArraybuff:()=>An,isArr:()=>x});var E=(t)=>typeof t==="function",Zn=(t)=>t.constructor.name==="AsyncFunction",Rn=(t)=>!!t&&typeof t.then==="function",K=(t)=>{return!isNaN(parseFloat(t))&&isFinite(t)},qn=(t)=>{return t&&typeof t==="object"&&!Array.isArray(t)},X=(t)=>{return typeof t==="object"&&t!==null&&Object.getPrototypeOf(t)===Object.prototype&&!Array.isArray(t)},et=(t)=>{return t&&typeof t==="object"&&t[Symbol.toStringTag]==="Module"},An=(t)=>{return t instanceof Uint8Array||t instanceof ArrayBuffer||typeof t==="string"},Fn=(t)=>{return t.startsWith(".")||t.startsWith("#")},P=(t)=>typeof t==="boolean",V=(t)=>typeof t==="string",x=(t)=>Array.isArray(t),Y=(t)=>typeof t==="object",yt=(t)=>typeof t==="number",ot=(t)=>t===null,Qn=(t)=>t===null,Un=(t)=>typeof t==="undefined",Xn=(t)=>typeof t!=="undefined",Ht=(t)=>{return Number.isInteger(Number(t))},$t=typeof window!=="undefined",$=typeof window==="undefined";var Bn=(t)=>{if($)return;return t()};function Pt(t,n){b(n).forEach(([r,o])=>{Vt(t,r,{value:o,writable:!1,configurable:!1,enumerable:!0})})}var lt=(t)=>{return x(t)?t:[t]};class J{static set i(t){console.info(...lt(t))}static set e(t){console.error(...lt(t))}static set w(t){console.warn(...lt(t))}}class D{_c=0;_id="";constructor(t){if(this._c=0,this._id=t??B(5),t?.includes("-")){let[n,r]=[t.split("-").slice(0,-1).join("-"),t.split("-").slice(-1)[0]];this._id=n,this._c=K(r)?parseInt(r):0}}get id(){return this._id+"-"+this._c}get mid(){return this._id+"-"+ ++this._c}}var Cn=(t)=>Array.from({length:t},(n,r)=>r),dt="ABCDEFGHIJKLMNOPQRSTUVWXYZ",Ot="abcdefghijklmnopqrstuvwxyz";var S=(t)=>JSON.stringify(t),Nt=(t)=>{return JSON.parse(t)};var q=(t)=>{if(t.startsWith("webkit"))t="-"+t;return t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()},B=(t)=>{let n=dt+Ot,r=Cn(10).join("");return Array.from({length:t},(o,i)=>n+(i?r:"")).reduce((o,i)=>{return o+=i.charAt(Math.floor(Math.random()*i.length))},"")},wn=(t=6,n)=>{if(!n)return Math.floor(Math.random()*t);return Math.round(Math.random()*(n-t)+t)},_t=()=>{let t=[...dt,...Ot],n=wn(0,t.length);return t[n]};class T extends Map{obj(t){t&&b(t).forEach(([n,r])=>this.set(n,r))}map(t){t.forEach((n,r)=>{if(n instanceof T)this.set(r,n);else if(x(n)){if(this.lacks(r))this.set(r,[]);this.get(r).push(...n)}else if(Y(n))this.ass(r,n);else this.set(r,n)})}ass(t,n){if(!this.has(t))this.set(t,{});h(this.get(t),n)}lacks(t){return!this.has(t)}init(t,n){return this.has(t)?this.get(t):this.set(t,n).get(t)}}var{values:M,keys:j,entries:b}=Object;var{defineProperty:Vt,assign:h}=Object,at=(t,n)=>Object.hasOwn(t,n),C=(t)=>{return Object.keys(t).length},it=(t,n)=>{if(!n.has(t))n.set(t,new T);return n.get(t)},d=(t,n)=>{if(!n.has(t))n.set(t,[]);return n.get(t)},Dt=(t,n)=>{let r={added:{},removed:{},modified:{}},o=j(t),i=j(n);for(let f of i){let u=t[f],m=n[f];if(!(f in t))r.added[f]=m;else if(x(u)&&x(m)){if(S(u)!==S(m))r.modified[f]={old:u,new:m}}else if(Y(u)&&Y(m)&&!ot(u)&&!ot(m)){let s=Dt(u,m);if(C(s.added)||C(s.removed)||C(s.modified))r.modified[f]={old:u,new:m}}else if(u!==m)r.modified[f]={old:u,new:m}}for(let f of o)if(!(f in n))r.removed[f]=t[f];return r};function kt(t,n){if(t.size!==n.size)return!1;for(let r of t)if(!n.has(r))return!1;return!0}var vt=(t)=>{return M(t).some((n)=>{return C(n)})};var Z=(t,n,r)=>{let o=r.value;return{configurable:!0,get(){if(this===t.constructor.prototype)return o;let i=o.bind(this);return Object.defineProperty(this,n,{value:i,configurable:!0,writable:!0}),i}}};var G=(t,n)=>{return{name:t,content:n}},Gn=(t,n)=>{return{property:t,content:n}},Jn=(t,n)=>{return{"http-equiv":t,content:n}};class O{metas=[];constructor(t){t&&this.metas.push(G("description",t))}author(t){return this.meta=G("author",t),this}charset(t){return this.meta={charset:t},this}keywords(...t){return this.meta=G("keywords",t.join(", ")),this}viewport(t){let n=b(t).map(([r,o])=>[q(r),String(o)].join("="));return this.meta=G("viewport",n.join(", ")),this}httpEquiv(t){return b(t).forEach(([n,r])=>{this.meta=Jn(q(n),String(r))}),this}robots(...t){return this.meta=G("robots",t.join(", ")),this}themeColor(t){return this.meta=G("theme-color",t),this}openGraph(t){return b(t).forEach(([n,r])=>{this.meta=Gn("og:"+n,String(r))}),this}twitter(t){return b(t).forEach(([n,r])=>{this.meta=G("twitter:"+n,String(r))}),this}push(t){this.metas.unshift(...t)}set meta(t){this.metas.push(t)}}class Yt{}var jn=["charset","name","property","http-equiv"],tn=(t,n,r=!1,o={})=>{n.forEach((i)=>{for(let f of jn)if(f in i){let u=i[f];if(r)h(i,{x:!0});else if(!("x"in i))h(i,o);t[`${f}_${f==="charset"?"":u}`]=i}})},zn=(t,n,r=!1,o={})=>{n.forEach((i)=>{if("href"in i){let f=i.href;if(r)h(i,{x:!0});else if(!("x"in i))h(i,o);t[`${f}`]=i}})};class nn{_head;idm;mark;push;constructor({initial:t,mark:n,push:r}={}){this._head=new T(t),this.mark=n||!1,this.push=r||{}}set head(t){b(t).forEach(([n,r])=>{if(n==="title"||n==="base"){if(r!==void 0){if(n=="base"){if(this.mark)h(r[0]||{},{x:!0})}this._head.set(n,r)}return}if(r instanceof O)return tn(this._head.init("meta",{}),r.metas,this.mark,this.push);if(!x(r))return;switch(n){case"meta":return tn(this._head.init("meta",{}),r,this.mark,this.push);case"link":return zn(this._head.init("link",{}),r,this.mark,this.push);case"script":if(r.length){this._head.init(n,[]);let o=r.map((i)=>{if(!i.yid&&this.idm)i.yid="sc"+this.idm.mid;if(this.mark)h(i,{x:!0});else if(!("x"in i))h(i,this.push);return i});this._head.get(n).push(...o)}return}})}get head(){return this._head}set id(t){this.idm=new D(t)}}var Lt=(t)=>{return b(t??{}).reduce((n,[r,o])=>{return n.push(P(o)&&o?r:`${r}="${o}"`),n},[""]).join(" ")},rn=(t)=>{let n=new Set;if(!t)return"";let r=[...t].reduce((o,[i,f])=>{if(i==="meta"||i==="link")f=M(f);if(V(f)){if(i==="title")n.add(`<${i}>${f}</${i}>`);else o.add(`<${i}>${f}</${i}>`);return o}if(!x(f))return o;if(i==="base"){let m=f.slice(-1);if(m)return n.add(`<${i}${Lt(m[0])}>`),o}return f.map((m)=>{if(i==="script"){let s={...m},e="";if("importmap"in s)s.type="importmap",e=JSON.stringify(s.importmap),delete s.importmap;else if("body"in s)e=s.body,delete s.body;return`<${i}${Lt(s)}>${e}</${i}>`}return`<${i}${Lt(m)}>`}).forEach((m)=>{if(m.includes('type="module"'))n.add(m);else if(m.includes("<meta"))n.add(m);else o.add(m)}),o},new Set);return[...n,...r].join("")};class N{lang="en";htmlHead;head;constructor({mark:t,push:n}={}){this.htmlHead=new T,this.head=(r={})=>{let o=new nn({initial:this.htmlHead,mark:t,push:n}),{link:i,script:f,meta:u,title:m,description:s,css:e,js:y}=r;if(s)o.head={meta:[{name:"description",content:s}]};if(pn(o,{css:e,js:y}),"base"in r)o.head={base:r.base};o.head={script:f,title:m,meta:u,link:i},this.htmlHead=o.head}}}var pn=(t,n)=>{let{css:r,js:o}=n;if(r){let f=(x(r)?r:[r]).map((u)=>({rel:"preload stylesheet",href:u,as:"style"}));t.head={link:[...f]}}if(o){let f=(x(o)?o:[o]).map((u)=>({src:u}));t.head={script:[...f]}}};var St=async(t)=>{if($)return;return new Promise((n,r)=>{let o=document.createElement("link");if(t.rel!=="stylesheet")t.rel="stylesheet",t.as="style";b(t).forEach(([i,f])=>{o.setAttribute(i,f)}),o.onload=()=>n(o),o.onerror=()=>r(new Error("Failed to load CSS")),document.head.appendChild(o)})};var on=(t)=>{if($)return;return new Promise((n,r)=>{let o=document.createElement("script"),i="";if("importmap"in t)t.type="importmap",i=JSON.stringify(t.importmap),delete t.importmap;else if("body"in t)i=t.body,delete t.body;if(i)o.textContent=i;b(t).forEach(([f,u])=>{o.setAttribute(f,u)}),o.onload=()=>n(o),o.onerror=()=>r(new Error("Failed to load Script")),document.head.appendChild(o),requestAnimationFrame(()=>n("Script executed"))})},Wn=()=>{let n=document.querySelector("#d-css")?.sheet;if(n)return n;let r=document.createElement("style");return r.id="d-css",document.head.appendChild(r),r.sheet},cn=(t,n)=>{for(let r=0;r<t.cssRules.length;r++)if(t.cssRules[r].selectorText===n)return!0;return!1},In=(t)=>Object.entries(t).map(([n,r])=>`${q(n)}: ${r};`).join(" ");function Kn(t,n={}){if($)return;let r=Wn();if(!r)return;if(!cn(r,t))r.insertRule(`${t} { ${In(n)} }`,r.cssRules.length)}var fn=(t,n=!1)=>{if(K(t))return[+t,Ht(t)?"int":"float"];if(n&&/\.\w+$/.test(t))return[t,"file"];if(t==="/")return[t,"-"];if(t.length===36&&t.match(/\-/g)?.length===4)return[t,"uuid"];return[t,"string"]},ft=(t)=>{let n=t.startsWith("/")?t:"/"+t,r=n.match(/(?<=\/)[^/].*?(?=\/|$)/g)??["/"],[o,i]=r.reduce(([f,u],m)=>{if(m.includes("<")){let s=m.match(/(?<=<)[^/].*?(?=>|$)/g);if(s?.length){let[e,y]=s[0].split(":");if(e)f.push(e),u.push(y||"_")}}else f.push(m===">"?"/":m);return[f,u]},[[],[]]);if(n.endsWith("/")&&n.length>1)o.push("/");return{parsed:o,args:i}};class ut{storage;constructor(){this.storage=new T}cache(t,n){if(this.storage.lacks(t))this.storage.set(t,n());return this.storage.get(t)}}var Pn=["int","float","file","uuid","string"];class z{_storage;CC;constructor(){this._storage=new T,this.CC=new ut}set(t){let{parsed:n,path:r}=t,o=S(n);if(!this._storage.get(o))this._storage.set(o,t);else throw`path: ${r} already used.`}get(t){let{parsed:n}=this.CC.cache(t,()=>ft(t)),r={},o=this._storage.get(S(n));if(!o&&t!=="/")for(let i of this._storage.keys()){let f=[],u=Nt(i);if(n.length===u.length){let m=u.map((y,w)=>{let F=fn(n[w],n.length-1===w);if(y===F[0])return F[0];if(Pn.includes(F[1]))return f.push(F[0]),F[1];return y}),s=S(m);if(this._storage.has(s)){o=this._storage.get(s),o?.args.forEach((y,w)=>{r[y]=f[w]});break}}}return[o,r]}keys(){return this._storage.keys()}}class mt{path="";parsed=[];args=[];constructor(t){Pt(this,{path:t,...ft(t)})}}class Mt{date;constructor(t){this.date=t?new Date(t):new Date}delta(t=null,n=!1){let r=Mt.delta(this.date.getTime(),t);return n?new Date(r):r}timed(t){if(!t)return this.date;return[["year","FullYear"],["month","Month"],["day","Date"],["hour","Hours"],["minute","Minutes"],["second","Seconds"]].reduce((r,[o,i])=>{let f=t[o];return f?new Date(r[`set${i}`](r[`get${i}`]()+f)):r},new Date(this.date))}static delta(t,n=null){return n?n-t:t-Date.now()}static local(t){return new Date(t).toLocaleString()}static get now(){return Date.now()}}class Zt{static rand(t=6,n){if(n)return Math.floor(Math.random()*(n-t+1)+t);return Math.floor(Math.random()*t)+1-1}static fill(t,n=null){return Array(t).fill(n)}static new({dom:t,id:n,inner:r}){let o=document.createElement(t);if(n)o.id=n;if(r)o.innerHTML=r;return o}static randFrom(t){if(Array.isArray(t)){let n=t.length,r=this.rand(0,n-1);return t[r]}else if(typeof t=="object"){let n=j(t),r=n.length,o=this.rand(0,r-1);return n[o]}}static randArray(t=[],n=1,r=!1){let o=[],i=r?new Set:null;while((r?i.size:o.length)<n){let f=t[Zt.rand(0,t.length-1)];r?i.add(f):o.push(f)}return r?[...i]:o}static randomAZ=_t;static makeID=B;static class(t,...n){let r=n;if(t?.class)r.push(...x(t.class)?t.class:[t.class]);t.class=n}static get O(){return{vals:M,keys:j,items:b,has:at,ass:h,len:(t={})=>j(t).length}}static get is(){return Et}static get return(){return un}static sleep=(t=1000)=>new Promise((n)=>setTimeout(n,t));static get screen(){let{innerWidth:t}=window,n={xs:t<=480,sm:t>=480,smd:t>=624,md:t>=768,lg:t>=1024,xl:t>=1280,xxl:t>=1536},r=b(n).reverse();for(let o=0;o<r.length;o++){let[i,f]=r[o];if(f)return i}return}bytes(t){if(t===0)return"0 Bytes";let n=1024,r=["Bytes","KB","MB","GB"],o=Math.floor(Math.log(t)/Math.log(n));return parseFloat((t/Math.pow(n,o)).toFixed(2))+" "+r[o]}static format(t){return new mn(t)}}class un{static arr(t){return t?x(t)?t:[t]:[]}static num(t,n=0){let r=parseFloat(t);return isNaN(r)?n:r}static str(t){return String(t)}static arr2obj(t,n=!1){return t.reduce((r,o,i)=>{if(n)r[o]=i;else r[i]=o;return r},{})}}class mn{val;constructor(t){this.val=t}get px(){return`${this.val}px`}get rem(){return`${this.val}rem`}get pr(){return`${this.val}%`}}async function p(t,n,{id:r="stateHook",init:o}={}){let i=[],f=()=>n.map((m)=>m.value),u=async()=>{await t(...f())};if(n.forEach((m)=>{i.push(m.hook(u)(r))}),o)await u();return()=>{i.forEach((m)=>m())}}var sn=(t)=>{t.forEach((n)=>n())};var Vn=(t,n)=>{for(let[r,o]of t){let i=W(r);if(!i){t.delete(r);continue}o.forEach((f)=>{f.call(i,n)})}};class A extends EventTarget{options;deep;verify;hooks=new T;states=new T;_value;listening=!1;end;constructor(t,n={},r=!0,o=!0){super();this.options=n;this.deep=r;this.verify=o;this._value=t}get value(){return this._value}set value(t){if(!this.verify){this._value=t,this.dispatchEvent(new CustomEvent("updated",{detail:this._value}));return}if(!this.deep){if(this._value===t)return;this._value=t,this.dispatchEvent(new CustomEvent("updated",{detail:this._value}));return}if(X(this._value)||x(this._value)){let n=Dt(this._value,t);if(!vt(n))return}else if(this._value instanceof Set){if(!kt(this._value,t))return}else if(this._value===t)return;this._value=t,this.dispatchEvent(new CustomEvent("updated",{detail:this._value}))}get listen(){let t=(n)=>{if(sn(this.hooks),Vn(this.states,n.detail),!this.states.size&&!this.hooks.size)this.end?.()};if(!this.listening)this.addEventListener("updated",t,this.options),this.listening=!0;return()=>{this.listening&&this.removeEventListener("updated",t,this.options),this.end=void 0,this.listening=!1}}call(t,n){return(r)=>{if(it(r,this.states).set(n,t),!$&&!this.listening)this.end=this.listen;return()=>{if(this.states.has(r))this.states.get(r)?.delete(n)}}}hook(t){return(n)=>{if(this.hooks.set(n,t),!$&&!this.listening)this.end=this.listen;return()=>{if(this.hooks.has(n))this.hooks.delete(n)}}}}function R(t,n={}){return new A(t,n,!0)}function dn(t,n=!1){return new A(t,{},!1,n)}class Rt{e;opt;constructor(t){this.e=t;this.opt={duration:500,easing:"ease-in-out",fill:"forwards"}}animate(t,n={}){return this.e.animate(t,n)}get slide(){let t=({x:n=0,y:r=0},o={})=>{h(this.opt,o);let i=[[n,r],[0,0]].map(([f,u])=>({transform:`translateX(${f}rem) translateY(${u}rem)`}));return this.e.animate(i,this.opt),this};return{left:(n={})=>{return t({x:-2},n)},right:(n={})=>{return t({x:2},n)},up:(n={})=>{return t({y:2},n)},down:(n={})=>{return t({y:-2},n)}}}fade(t={}){h(this.opt,t);let n=[0,1].map((r)=>({opacity:r}));return this.e.animate(n,this.opt),this}shake(t="Y",n={}){h(this.opt,n);let r=[0,5,-5,5,0].map((o)=>({transform:`translate${t}(${o}px)`}));return this.e.animate(r,this.opt),this}color(t=[],n={}){h(this.opt,n);let r=Array.isArray(t)?t.map((o)=>({color:o})):{color:t};return this.e.animate(r,this.opt),this}bg(t=[],n={}){h(this.opt,n);let r=Array.isArray(t)?t.map((o)=>({backgroundColor:o})):{backgroundColor:t};return this.e.animate(r,this.opt),this}bounce(t=1,n={}){h(this.opt,n);let r=[0.5,t,1].map((o)=>({transform:`scale(${o})`}));return this.e.animate(r),this}}var _=(t)=>{if(x(t))return t.filter((n)=>n!==void 0).join(" ");else if(Y(t)){if(X(t))return S(t)}else if(E(t))return _(t());else if(t!==void 0&&t!==null)return P(t)?t?"":"false":String(t);return""};function On(t,n){switch(n??t){case"style":return function(r){this.style.setProperty(t,r)};default:return function(r){this.setAttribute(t,r)}}}class qt{attr;constructor(t={}){this.attr=t}get(t,n=this.attr,r){let o=(i,f)=>{if(x(f))t.attr_push(i,_(f),r);else if(f instanceof A){let u=r?`${r}_${i}`:i;t.states.push(f.call(On(i,r),u)),o(i,f.value)}else if(Y(f)){if(X(f)&&!r)this.get(t,f,i)}else t.attr_push(i,_(f),r)};b(n).forEach(([i,f])=>{if(i==="ref"){if(f instanceof a)t.events.obj({element(){f.element=this}})}else if(["on"].includes(i))Y(n.on)&&t.events.obj(n.on);else{if(f===void 0)return;o(i,f)}})}unload(t){let n=void 0;if(t in this.attr)n=this.attr[t],delete this.attr[t];return n}}var Nn=["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"],_n=(t)=>Nn.includes(t);function an(t){return String(t).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}var st=(t,n)=>{if(x(t))return t.map((r)=>st(r,n)).join("");else if(t instanceof c){let{ctx:r,oz:o}=Qt(t,n.IDM);return n.OZ.push(o),r}else if(Y(t))return S(t);else if(E(t))return st(t(),n);else if(t!==void 0&&t!==null)return an(t);return""},ht=(t,n)=>{let r=new D(n),o=new k(r.id,r);return{ctx:st(t,o),catt:o}};function kn(t){let n=this.id;if(n){let{ctx:r,catt:o}=ht(t,n);if(this.innerHTML!==r)this.innerHTML=r,Q.RPS(o.OZ)}}var At=(t,n,r,o=[])=>{if(x(t))t.forEach((i)=>{At(i,t.length,r,o)});else if(t instanceof A)if(n>1)At(l("div",{},t),n,r,o);else{let i=t.value,f=i instanceof c?"dom":"ctx",{ctx:u,catt:m}=ht(i,r.xid+"-0");r.xid=m.xid,o.push(u),r.OZ.push(m.OZ),r.states.push(t.call(kn,f))}else o.push(st(t,r))};class Ft{tag;ctx;closing;constructor(t="",n){this.tag=t;this.ctx=n;let r=_n(t);this.closing=r?"":`</${t}>`}process(t,n=this.ctx,r=[]){return n.forEach((o)=>{At(o,n.length,t,r)}),r.join("")}get(t){let n=this.process(t);if(!this.tag)return n;if(t.events.size||t.states.length)t.id=t.xid;return`<${this.tag}${t.attr}>${n}${this.closing}`}}class Bt{e;query;constructor(t,n){this.e=t;this.query=n}get a(){return new Rt(this)}get all(){if(this.query){let t=document.querySelectorAll(this.query);if(t.length)return Array.from(t).map((n)=>n)}return[]}get attr(){let t=this.e;return{has:(n)=>{return t.hasAttribute(n)},get:(n)=>{return t.getAttribute(n)},del:(n)=>{return t.removeAttribute(n),this},set:(n)=>{for(let r in n){let o=n[r];if(n[r]!==void 0)t.setAttribute(r,_(o))}return this}}}get children(){return Array.from(this.e.children).map((t)=>H(t))}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 t=this.e.offsetParent;if(t)return new U(t);return}get parent(){let t=this.e.parentElement;if(t)return new U(t);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 t=this.e.style,n=this;return{set:(r,o=0)=>{let i=t,f=()=>{b(r).forEach(([u,m])=>{if(u in i){if(i[u]!==m)i[u]=m}else if(m!==null)t.setProperty(u,String(m))})};if(E(o))n.on("transitionend",o);if(yt(o))setTimeout(f,o);else f();return n},get:(r)=>{let o=q(String(r));return t.getPropertyValue(o)},del:(...r)=>{r.forEach((o)=>{let i=q(String(o));t.removeProperty(i)})}}}get submit(){let t=this.e;if("submit"in t)return t.submit();return!1}get tag(){return this.e.tagName.toLowerCase()}get value(){return this.e.value??""}get unload(){return()=>{this.e.remove()}}set append(t){let{ctx:n,oz:r}=Ut(t,Xt(this.id));this.e.insertAdjacentHTML("beforeend",n),Q.RPS(r)}set appendfirst(t){let{ctx:n,oz:r}=Ut(t,Xt(this.id));this.e.insertAdjacentHTML("afterbegin",n),Q.RPS(r)}set inner(t){let{ctx:n,oz:r}=Ut(t,Xt(this.id));this.e.innerHTML=n,Q.RPS(r)}set disabled(t){let n=this.e;if("disabled"in n)n.disabled=t}set id(t){this.e.id=t}set value(t){let n=this.e;n.value=t}}var Ut=(t,n)=>{let{ctx:r,catt:o}=ht(t,n);return{ctx:r,oz:o.OZ}},Xt=(t)=>t?`${t}-0`:t;class U extends Bt{constructor(t,n){super(t,n)}add(...t){return this.e.classList.add(...t.map((n)=>n.replace(/[^\w-]/,""))),()=>{this.e.classList.remove(...t.map((n)=>n.replace(/[^\w-]/,"")))}}remove(...t){return this.e.classList.remove(...t.map((n)=>n.replace(/[^\w-]/,""))),this}toggle(t,n){let r=typeof t!="string"?t.apply(this):t;return this.e.classList.toggle(r,n)}hasNode(t){return this.e.contains(t)}has(...t){let n=this.e.classList;return t.every((r)=>n.contains(r))}insert(t){return{HTML:(...n)=>{return n.forEach((r)=>{this.e.insertAdjacentHTML(t,r)}),this},element:(...n)=>{return n.forEach((r)=>{this.e.insertAdjacentElement(t,r)}),this},text:function(...n){return n.forEach((r)=>{this.e.insertAdjacentText(t,r)}),this}}}is(t){let n=this.e.classList,r=this.e.tagName.toLocaleLowerCase(),o=!0,i=!0;if(t.dom)i=t.dom==r?!0:!1;if(t.class)if(Array.isArray(t.class))t.class.forEach((f)=>{o=o?n.contains(f):!1});else o=o?n.contains(t.class):!1;return o&&i}on(t,n,r=!1){let o=!1;if(t.indexOf("touch")>-1)o=!0;return this.e.addEventListener(t,n,{capture:r,passive:o}),this}remove_on(t,n,r=!1){return this.e.removeEventListener(t,n,r),this}timed(t,n=250){return setTimeout(()=>t(this),n),this}animate(t,n,r){let o={duration:300,easing:"ease",fill:"forwards"};if(E(n))r=n;else h(o,n);let i=this.e.animate(t,o);if(r)i.finished.then(r);return this}}var v=new T,W=(t)=>{if($)return;let n=v.get(t);if(n?.isConnected)return n;v.delete(t);let r=document.getElementById(t);if(!r)return;return v.set(t,r),r};function hn(){let t=[];for(let[n,r]of v)if(!r.isConnected)t.push(n),v.delete(n);return t}function H(t,n){let r=n?n:document;if(V(t)){let o=r.querySelector(t);if(o)return new U(o,t);return}else if(X(t)){let[[o,i]]=b(t),u=`${o==="id"?"#":"."}${i}`,m=r.querySelector(u);if(m)return new U(m,u);return}else return new U(t)}class a{state=new A(void 0);constructor(){}get element(){return this.state.value?.e}set element(t){if(t)this.state.value=new U(t);else this.state.value=void 0}get $(){return this.state.value}}var vn=()=>{return new a};var tr=(t,n,r)=>{return t.addEventListener(n,r),()=>{t.removeEventListener(n,r)}},tt={};class gt{events=new T;states=new T;windowEvents=new T;resetST=new T;resetEV=new T;get keys(){return[...new Set([...this.states.keys(),...this.events.keys()])]}set(t){let{id:n,events:r,states:o}=t;if(n){if(r.size)this.events.set(n,r);if(o.length)this.states.set(n,o)}return this}push(t){return t.events.forEach((n,r)=>{n.forEach((o,i)=>{it(r,this.events).set(i,o)})}),t.states.forEach((n,r)=>{d(r,this.states).push(...n)}),this}get stage(){return this.events.forEach((t,n)=>{this.events.delete(n);let r=W(n);if(!r){this.events.delete(n);return}t.forEach((o,i)=>{switch(i){case"ready":case"element":o.apply(r,[r]);break;case"resize":case"beforeunload":case"popstate":case"winscroll":case"winload":case"winfocus":case"winblur":let f=i.replace(/^win/,"");this.windowEvents.init(f,new T).set(n,o);break;case"state":let[u,m,s]=o.apply(r,[r]),e=x(m)?m:[m];if(!e.length)break;let y=()=>e.map((F)=>F.value),w=()=>u(...y());if(s)w();e.forEach((F)=>d(n,this.resetST).push(F.call(w,n+"_state")(n)));break;default:d(n,this.resetEV).push(tr(r,i,o))}})}),this.processWindowEvents,this.states.forEach((t,n)=>{this.states.delete(n),t.forEach((r)=>{d(n,this.resetST).push(r(n))})}),this}get processWindowEvents(){let t=(n,r)=>{let o=0,i=!1,f=(m)=>{if(o=window.scrollY,!i)window.requestAnimationFrame(()=>{r.forEach((s,e)=>{let y=W(e);if(y)s.call(y,m);else this.windowEvents.get(n)?.delete(e)}),i=!1}),i=!0},u=(m)=>{r.forEach((s,e)=>{let y=W(e);if(y)s.call(y,m);else this.windowEvents.get(n)?.delete(e)})};return window.addEventListener(n,n==="scroll"?f:u),()=>{window.removeEventListener(n,n==="scroll"?f:u)}};return this.windowEvents.forEach((n,r)=>{if(n.size){if(!tt[r])tt[r]=t(r,n)}else if(tt[r])tt[r](),delete tt[r]}),this}reset(t){return t.forEach((n)=>{this.windowEvents.forEach((r,o)=>{if(r.has(n))r.delete(n)}),this.resetEV.get(n)?.forEach((r)=>{r()}),this.resetST.get(n)?.forEach((r)=>{r()}),this.resetST.delete(n),this.resetEV.delete(n)}),this}RPS(t){if(t){let n=hn();this.reset(n);let r=t.keys;if(r.length)this.reset(r).push(t).stage}return this}}var Q=new gt;class k{xid;IDM;map=new T;states=[];events=new T;OZ;constructor(t,n=new D,r){this.xid=t;this.IDM=n;this.OZ=r??new gt}attr_push(t,n,r){let o=r??t;if(!this.map.has(o))this.map.set(o,[]);let i=r?`${q(t)}:${n};`:n;this.map.get(o).push(i)}get attr(){let t=[""];return this.map.forEach((n,r)=>{let o=n.join("");t.push(o?`${r}="${o}"`:r)}),t.join(" ")}set id(t){if(!this.map.has("id"))this.map.set("id",[t])}get id(){return this.map.get("id")?.join("")}}async function gn(t,n,r){let o=new D(n),i=l("main",{class:r},t);return Qt(i,o)}function Qt(t,n=new D){let{tag:r,attr:o,ctx:i}=t,f=n instanceof D?n:new D(n),u=f.mid,m=new k(u,f),s=new qt(o),e=new Ft(r,i);return s.get(m),{ctx:e.get(m),oz:m.OZ.set(m),id:m.id}}class c{tag;attr;ctx;constructor(t,n,r){this.tag=t;this.attr=n;this.ctx=r}}function l(t,n={},...r){if(E(t))return t(n??{},...r);return new c(t,n??{},r)}var nr=(t,...n)=>new c("",{},n);async function xn(t={},n){let r=H("link[rt]")?.all.map((o)=>()=>o.remove())||[];if(t&&C(t))for(let o of M(t)){if(o.x)continue;try{await St(o)}catch(i){J.e=["link error",{error:"Huntr @ link"}]}}return r}var rr=["charset","name","property","http-equiv"];async function Tn(t){let n={};if(H("meta")?.all.forEach((r)=>{let o=r.attributes;for(let i of rr)if(i in o){let f=o[i].value;n[`${i}_${i==="charset"?"":f}`]=r}}),t)b(t).forEach(([r,o])=>{if(r in n)H(n[r]).attr.set(o),delete n[r];else{let i=H(document.createElement("meta"));i.attr.set(o),document.head.append(i.e)}});return M(n).map((r)=>H(r).unload)}async function bn(t,n=!1){let r=H("script[rt]")?.all.map((o)=>()=>o.remove())||[];if(t&&C(t))for(let o of M(t)){if(o.x)continue;try{await on(o)}catch(i){J.e=["script error",{error:"Huntr @ script"}]}}return r}class nt extends Yt{path="";data={};args={};importArgs=[]}async function en(t,n=!1){if(!n&&t.fetch)h(t.data,await t.fetch());return await t.head?.(),[wt(await t.body?.(),t.importArgs),or.call(this,t)]}function wt(t,n=[]){let r=t||"";if(et(t)){let o=t.default;r=E(o)?o.apply({},n):o}return x(r)?r:[r]}function or(t){let n=new N({push:{rt:this.id}});return n.htmlHead=structuredClone(this.htmlHead),n.head(t),n.htmlHead}async function yn(t,n){document.title=t.get("title")||"",Ct(await xn(t.get("link"),n)),Ct(await bn(t.get("script")));let r=await Tn(t.get("meta"));Ct(r)}var Ct=(t)=>{t.forEach((n)=>n())};class xt{onChange;popListener;constructor(t=R(""),n){this.assertClient(),this.onChange=n,this.onChange?.(this.path(),history.state??{path:this.path()}),this.popListener=(r)=>{let o=r.state??{path:this.path()};t.value=o?.path||t.value,this.onChange?.(this.path(),o)},window.addEventListener("popstate",this.popListener)}path(){this.assertClient();let{pathname:t,search:n,hash:r}=window.location;return`${t}${n}${r}`}state(){return this.assertClient(),window.history.state??{path:this.path()}}navigate(t,n,r=""){this.assertClient();let o=this.resolve(t),i=this.path();if(this.samePath(i,o))return;let f={...n,path:o};window.history.pushState(f,r,o),this.onChange?.(this.path(),f)}replace(t,n,r=""){this.assertClient();let o=this.resolve(t),i=this.path();if(this.samePath(i,o))return;let f={...n,path:o};window.history.replaceState(f,r,o),this.onChange?.(this.path(),f)}back(){this.assertClient(),window.history.back()}forward(){this.assertClient(),window.history.forward()}destroy(){if(this.popListener)window.removeEventListener("popstate",this.popListener),this.popListener=void 0}resolve(t){let n=new URL(t,window.location.origin);return`${n.pathname}${n.search}${n.hash}`}samePath(t,n){return t===n}assertClient(){if(typeof window==="undefined"||typeof window.history==="undefined")throw new Error("BrowserPathHistory must be used in a client/browser environment.")}}class Gt{lang;head="";constructor(t,n){if(this.lang=t,n)this.head=rn(n)}body(t,n,r){return[`<!DOCTYPE html><html lang="${this.lang}">`,`<head>${this.head}</head>`,`<body id="${n}"${r?" "+r:""}>${t}</body>`,"</html>"].join("")}}class rt{path="";data={};args={}}class Jt extends mt{cls;constructor(t,n){super(t);this.cls=n}}class Tt extends Jt{}class jt{storage=new z;error=new z}class zt extends jt{wss=new z;setRoute(t,n){this.storage.set(new Tt(t,n))}getRoute(t,n){let[r,o]=this.storage.get(t);if(!r){let[f=new Tt(t,Hn)]=this.getError(n),u=new f.cls;return u.args=o,h(u,{args:o})}let i=new r.cls;return h(i,{args:o})}setWss(t){}getWss(t){return this.wss.get(t)}setError(t,n){this.error.set(new Tt(t.toString(),n))}getError(t=404){return this.error.get(t.toString())}}class bt extends Jt{}class pt extends jt{setRoute(t,n){this.storage.set(new bt(t,n))}getRoute(t,n){let[r,o]=this.storage.get(t);if(!r){let[f=new bt(t,$n)]=this.getError(n),u=new f.cls;return u.args=o,h(u,{args:o})}let i=new r.cls;return h(i,{args:o})}setWss(t){}getWss(t){}setError(t,n){this.error.set(new bt(t.toString(),n))}getError(t=404){return this.error.get(t.toString())}}class Hn extends nt{body(){return l("div",{},this.path+" not found...")}}class $n extends rt{body(){return l("div",{},`${this.path} not found...`)}}class Wt extends N{storage=new zt;base;constructor(t="/",n=""){super({mark:!0});this.base=t?t.startsWith("/")?t:`/${t}`:"";let r=this.base;this.head({script:[{type:"module",src:"./index.js"}],...{base:[{href:r==="/"?r:`${r}/`,target:"_blank"}]},meta:[{charset:"utf-8"},{name:"viewport",content:"width=device-width, initial-scale=1.0"}]})}route(t){return(n)=>{return this.storage.setRoute(t,n),n}}}L([Z,g("design:type",Function),g("design:paramtypes",[String]),g("design:returntype",void 0)],Wt.prototype,"route",null);class En{id=B(5);path=R("");_root=R([]);Main(t){return l("main",{},this._root)}Button(t,...n){let r=this.path,{on:o,...i}=t,f={...o||{},click(u){u.preventDefault();let s=H(this).attr.get("tab");if(!s)return;r.value=s}};return l("button",{on:f,...i},...n)}}L([Z,g("design:type",Function),g("design:paramtypes",[typeof attr==="undefined"?Object:attr]),g("design:returntype",void 0)],En.prototype,"Main",null),L([Z,g("design:type",Function),g("design:paramtypes",[Object,Object]),g("design:returntype",void 0)],En.prototype,"Button",null);class ct extends En{storage=new pt;constructor(){super()}tab(t){return(n)=>{return this.storage.setRoute(t,n),n}}async load(t,n={}){this.path.value=this.path.value||t,await p(async(r)=>{this._root.value=await ir.call(this,r,n)},[this.path],{id:this.id,init:!0})}}L([Z,g("design:type",Function),g("design:paramtypes",[String]),g("design:returntype",void 0)],ct.prototype,"tab",null),L([Z,g("design:type",Function),g("design:paramtypes",[String,typeof obj==="undefined"?Object:obj]),g("design:returntype",Promise)],ct.prototype,"load",null);async function ir(t,n={},r=!1,o){let i=this.storage.getRoute(t,o);return h(i,{path:t,data:n}),wt(await i.body?.())}class It{path;args;route="/";isConnected=R(!1);data={};constructor(t,n={}){this.path=t;this.args=n;this.data=n}open(t){}message(t){}close(t){}error(t){}get connect(){if(this.ws&&this.ws.readyState<=1)return this;return this.ws=new WebSocket(this.path),this.ws.onopen=async(t)=>{this.isConnected.value=!0,await this.open.call(this,t)},this.ws.onmessage=async(t)=>{await this.message.call(this,t)},this.ws.onclose=async(t)=>{this.isConnected.value=!1,await this.close.call(this,t)},this.ws.onerror=async(t)=>{this.isConnected.value=this.ws.readyState<=1,await this.error.call(this,t)},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(t){if(this.isConnected.value)this.ws.send(t);else throw new Error(`websocket path ${this.path} not connected`)}}var I=new T;class Kt{yvee;constructor(t){this.yvee=t}async load(t){if($)return;if(!I.has(t)){let[r,o]=this.yvee.storage.getWss(t);if(!r)return;let{cls:i,path:f}=r,u=new i(f,o).connect;return I.set(t,u),u}let n=I.get(t);return n.reconnect,n}unload(t){if($)return;if(I.has(t)){let n=I.get(t);if(!n)return;n.disconnect,I.delete(t)}}}class Dn extends Wt{pushHistory;id;data;path;_root;constructor(t="/",n="",r=!1){super(t,n);this.pushHistory=r;this.id=B(6),this.path=R("/"),this._root=R([]),this.data={}}Main(t){return l("main",{},this._root)}A(t,...n){let{on:r,...o}=t,i=this.path,f={...r||{},click(u){u.preventDefault();let m=H(this).path;i.value=m}};return l("a",{on:f,...o},...n)}}L([Z,g("design:type",Function),g("design:paramtypes",[typeof attr==="undefined"?Object:attr]),g("design:returntype",void 0)],Dn.prototype,"Main",null),L([Z,g("design:type",Function),g("design:paramtypes",[typeof aAttr==="undefined"?Object:aAttr,Object]),g("design:returntype",void 0)],Dn.prototype,"A",null);class Ln extends Dn{constructor({base:t,history:n,index:r}={}){super(t,r,n);let o=this;h(this,{get yvee(){return o}})}async render(t={}){let{id:n,data:r,class:o,isDev:i=!1}=t;if($t){let f=window.location.pathname;if(i)f=f.replace(/\/+$/g,"");this.path.value=f;let u=document.body.id;this.id=u;let[m,s]=await ln.call(this,this.path.value,o);return Q.push(s.oz),requestAnimationFrame(()=>{Q.stage,this.init(r)}),()=>{}}return async({path:f,data:u={},error:m=0})=>{if(n)this.id=n;this.path.value=f;let[s,e]=await ln.call(this,this.path.value,o,m,u,!0);return new Gt(this.lang,s).body(e.ctx,this.id)}}async init(t={}){let n=this.id,r=new xt(this.path);p(async(o)=>{let[i,f]=await Yn.call(this,o,t);await yn(f,n),this._root.value=i,this.pushHistory&&r.navigate(o)},[this.path],{id:n})}}L([Z,g("design:type",Function),g("design:paramtypes",[typeof renderConfig==="undefined"?Object:renderConfig]),g("design:returntype",Promise)],Ln.prototype,"render",null);async function Yn(t,n={},r=!1,o){let i=this.storage.getRoute(t,o);return h(i,{path:t,data:n}),await en.call(this,i,r)}async function ln(t,n,r,o={},i=!1){let[f,u]=await Yn.call(this,t,o,i,r);this._root.value=f;let m=await gn(this._root,this.id,n);return[u,m]}var fr=(t)=>{return(n)=>{t(n)}};export{It as websocket,vn as useRef,Kt as socket,J as log,nr as frag,l as dom,nt as doc,St as cssLoader,rt as content,Kn as addCSS,Zt as __,Ln as Yvee,Mt as Time,ct as Tabs,A as Stateful,p as StateHook,R as State,fr as Routes,a as Ref,dn as QState,xt as PathHistory,O as Meta,Bn as IfClient,H as $};
|
|
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 $};
|