@kupola/kupola 1.4.4 → 1.4.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- (function(h,B){typeof exports=="object"&&typeof module<"u"?B(exports):typeof define=="function"&&define.amd?define(["exports"],B):(h=typeof globalThis<"u"?globalThis:h||self,B(h.Kupola={}))})(this,function(h){"use strict";class B{constructor(t="app"){this.scope=t,this.hooks=new Map,this.state="created",this.stateHistory=["created"],this.transitions=new Map([["created",["bootstrapped","destroyed"]],["bootstrapped",["mounted","destroyed"]],["mounted",["updated","unmounted","destroyed"]],["updated",["updated","unmounted","destroyed"]],["unmounted",["mounted","destroyed"]],["destroyed",[]]]),this.phaseStateMap={bootstrap:{from:"created",to:"bootstrapped"},mount:{from:["bootstrapped","unmounted"],to:"mounted"},update:{from:["mounted","updated"],to:"updated"},unmount:{from:["mounted","updated"],to:"unmounted"},destroy:{from:["bootstrapped","mounted","updated","unmounted"],to:"destroyed"}},this.basePhases=["bootstrap","mount","update","unmount","destroy"],this.allPhases=["error","errorBoundary"],this.basePhases.forEach(e=>{this.allPhases.push(`before${e.charAt(0).toUpperCase()+e.slice(1)}`),this.allPhases.push(e),this.allPhases.push(`after${e.charAt(0).toUpperCase()+e.slice(1)}`)}),this.allPhases.forEach(e=>{this.hooks.set(e,[])}),this.pendingHooks=new Set,this.trace=[],this.errorHandler=null,this.errorBoundary=null,this.lastError=null,this.errorCount=0,this.maxErrors=10,this._onErrorCallback=null}_validateTransition(t){const e=this.transitions.get(this.state);if(!e||!e.includes(t))throw new Error(`Invalid state transition: ${this.state} -> ${t}`);return!0}_updateState(t){this._validateTransition(t),this.state=t,this.stateHistory.push(t)}_resetResolved(t){const e=this.hooks.get(t);e&&e.forEach(s=>{s.resolved=!1})}on(t,e,s={}){if(!this.allPhases.includes(t))throw new Error(`Unknown lifecycle phase: ${t}`);const n=this.hooks.get(t);return n.push({handler:e,priority:s.priority||0,depends:s.depends||[],name:s.name||e.name||`anonymous_${n.length}`}),n.sort((r,a)=>a.priority-r.priority),()=>{const r=n.findIndex(a=>a.handler===e);r>-1&&n.splice(r,1)}}async _resolveDepends(t,e){if(!(!t||t.length===0))for(const s of t){const r=this.hooks.get(e).find(a=>a.name===s);r&&!r.resolved&&(await r.handler(),r.resolved=!0)}}async emit(t,...e){if(this.state==="destroyed"&&t!=="error")return;const s=this.hooks.get(t);if(!s||s.length===0)return;const n=`${t}-${Date.now()}-${Math.random().toString(36).substr(2,9)}`;this.pendingHooks.add(n);const r=performance.now();try{for(const l of s){await this._resolveDepends(l.depends,t);const o=performance.now();let c,d;try{c=l.handler(...e),c instanceof Promise&&await c,l.resolved=!0}catch(p){d=p,console.error(`[KupolaLifecycle] Error in ${t} hook "${l.name}":`,p),t!=="error"&&await this._handleError({phase:t,hook:l.name,error:p,args:e})}const u=performance.now()-o;this.trace.push({emitId:n,phase:t,hookName:l.name,duration:u,status:d?"error":"success",error:d?d.message:null,timestamp:Date.now()})}const a=performance.now()-r;console.debug(`[KupolaLifecycle] ${t} completed in ${a.toFixed(2)}ms (${this.scope})`)}finally{this.pendingHooks.delete(n)}}async runPhase(t,...e){if(!this.basePhases.includes(t))throw new Error(`Unknown base phase: ${t}`);const s=this.phaseStateMap[t];if(s){if(Array.isArray(s.from)){if(!s.from.includes(this.state))throw new Error(`Cannot ${t} from state ${this.state}, expected one of: ${s.from.join(", ")}`)}else if(this.state!==s.from)throw new Error(`Cannot ${t} from state ${this.state}, expected ${s.from}`)}const n=`before${t.charAt(0).toUpperCase()+t.slice(1)}`,r=`after${t.charAt(0).toUpperCase()+t.slice(1)}`;this._resetResolved(n),this._resetResolved(t),this._resetResolved(r),this.allPhases.includes(n)&&await this.emit(n,...e),await this.emit(t,...e),s&&this._updateState(s.to),this.allPhases.includes(r)&&await this.emit(r,...e)}async bootstrap(...t){await this.runPhase("bootstrap",...t)}async _waitForDOMReady(){return new Promise(t=>{if(document.readyState==="complete"||document.readyState==="interactive"){t();return}const e=()=>{document.removeEventListener("DOMContentLoaded",e),window.removeEventListener("load",e),t()};document.addEventListener("DOMContentLoaded",e),window.addEventListener("load",e)})}async mount(...t){await this.runPhase("mount",...t)}async mountWithDOMReady(...t){await this._waitForDOMReady(),await this.runPhase("mount",...t)}async update(...t){await this.runPhase("update",...t)}async unmount(...t){await this.runPhase("unmount",...t)}async destroy(...t){await this.runPhase("destroy",...t),this.hooks.forEach(e=>{e.length=0})}getPhaseHandlers(t){return this.hooks.get(t)||[]}hasHandlers(t){const e=this.hooks.get(t);return e&&e.length>0}getTrace(){return[...this.trace]}clearTrace(){this.trace=[]}getState(){return this.state}getStateHistory(){return[...this.stateHistory]}isInState(t){return this.state===t}onError(t){return this._onErrorCallback=t,this.on("error",t)}setErrorBoundary(t){return this.errorBoundary=t,this.on("errorBoundary",e=>typeof t=="function"?t(e):null)}setMaxErrors(t){this.maxErrors=t}getErrorCount(){return this.errorCount}getLastError(){return this.lastError}resetErrorCount(){this.errorCount=0,this.lastError=null}async _handleError(t){if(this.errorCount++,this.lastError=t.error,this.errorCount>=this.maxErrors){console.error(`[KupolaLifecycle] Error limit reached (${this.maxErrors}), stopping error handling`);return}if(await this.emit("error",t),typeof this._onErrorCallback=="function")try{await this._onErrorCallback(t)}catch(s){console.error("[KupolaLifecycle] Error in onError callback:",s)}const e=this.hooks.get("errorBoundary");if(e&&e.length>0)for(const s of e)try{const n=s.handler(t);if(n instanceof Promise&&await n,n==="handled"){console.debug(`[KupolaLifecycle] Error handled by errorBoundary hook "${s.name}"`);return}}catch(n){console.error(`[KupolaLifecycle] Error in errorBoundary hook "${s.name}":`,n)}console.error(`[KupolaLifecycle] Unhandled error in ${t.phase}:`,t.error)}}const Ms=new B("app");function Ts(i="app"){return new B(i)}const Is=new Set(["__proto__","prototype","constructor"]);function J(i){return Is.has(i)}function As(i){return i?i.trim():""}function zs(i){return i?i.replace(/^\s+/,""):""}function Ps(i){return i?i.replace(/\s+$/,""):""}function $s(i){return i?i.toUpperCase():""}function qs(i){return i?i.toLowerCase():""}function Bs(i){return i?i.charAt(0).toUpperCase()+i.slice(1):""}function Fs(i){return i?i.replace(/-(\w)/g,(t,e)=>e?e.toUpperCase():""):""}function Ns(i){return i?i.replace(/([A-Z])/g,"-$1").toLowerCase().replace(/^-/,""):""}function Os(i,t,e=" "){return(String(i)||"").padStart(t,e)}function Rs(i,t,e=" "){return(String(i)||"").padEnd(t,e)}function Vs(i,t,e="..."){return!i||i.length<=t?i||"":i.slice(0,t)+e}function Ks(i,t,e){return i?i.split(t).join(e):""}function Ws(i,t){return i?i.replace(/\{\{(\w+)\}\}/g,(e,s)=>t[s]!==void 0?t[s]:`{{${s}}}`):""}function Us(i,t){return(i||"").startsWith(t)}function Ys(i,t){return(i||"").endsWith(t)}function Xs(i,t){return(i||"").includes(t)}function js(i,t){return(i||"").repeat(t)}function Js(i){return(i||"").split("").reverse().join("")}function Gs(i,t){return!i||!t?0:i.split(t).length-1}function Zs(i){if(!i)return"";const t=document.createElement("div");return t.textContent=i,t.innerHTML}function Qs(i){if(!i)return"";const t=document.createElement("div");return t.innerHTML=i,t.textContent}function ti(i=8){const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";let e="";for(let s=0;s<i;s++)e+=t.charAt(Math.floor(Math.random()*t.length));return e}function ei(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,i=>{const t=Math.random()*16|0;return(i==="x"?t:t&3|8).toString(16)})}const Ot={trim:As,trimLeft:zs,trimRight:Ps,toUpperCase:$s,toLowerCase:qs,capitalize:Bs,camelize:Fs,hyphenate:Ns,padStart:Os,padEnd:Rs,truncate:Vs,replaceAll:Ks,format:Ws,startsWith:Us,endsWith:Ys,includes:Xs,repeat:js,reverse:Js,countOccurrences:Gs,escapeHtml:Zs,unescapeHtml:Qs,generateRandom:ti,generateUUID:ei};function si(i){return Array.isArray(i)}function ii(i){return!i||i.length===0}function ni(i){return i?i.length:0}function ri(i,t){return i&&i.length>0?i[0]:t}function ai(i,t){return i&&i.length>0?i[i.length-1]:t}function li(i,t,e){return i&&i[t]!==void 0?i[t]:e}function oi(i,t,e){return i?i.slice(t,e):[]}function ci(...i){return i.reduce((t,e)=>t.concat(e||[]),[])}function hi(i,t=","){return i?i.join(t):""}function di(i,t,e=0){if(!i)return-1;if(Number.isNaN(t)){for(let s=e;s<i.length;s++)if(Number.isNaN(i[s]))return s;return-1}return i.indexOf(t,e)}function ui(i,t,e){if(!i)return-1;if(Number.isNaN(t)){const s=e!==void 0?e:i.length-1;for(let n=s;n>=0;n--)if(Number.isNaN(i[n]))return n;return-1}return i.lastIndexOf(t,e)}function pi(i,t){return i?i.includes(t):!1}function fi(i,...t){return i&&i.push(...t),i}function mi(i){return i?i.pop():void 0}function gi(i){return i?i.shift():void 0}function _i(i,...t){return i&&i.unshift(...t),i}function yi(i,t){if(!i)return i;const e=Number.isNaN(t)?i.findIndex(s=>Number.isNaN(s)):i.indexOf(t);return e>-1&&i.splice(e,1),i}function vi(i,t){return!i||t<0||t>=i.length||i.splice(t,1),i}function bi(i,t,e){return i&&(i.splice(t,0,e),i)}function Ei(i){return i?i.slice().reverse():[]}function ki(i,t){return i?i.slice().sort(t):[]}function wi(i,t,e="asc"){return i?i.slice().sort((s,n)=>{const r=typeof s=="object"?s[t]:s,a=typeof n=="object"?n[t]:n;return r<a?e==="asc"?-1:1:r>a?e==="asc"?1:-1:0}):[]}function xi(i,t){return i?i.filter(t):[]}function Ci(i,t){return i?i.map(t):[]}function Si(i,t,e){return i?i.reduce(t,e):e}function Li(i,t){i&&i.forEach(t)}function Di(i,t){return i?i.every(t):!0}function Hi(i,t){return i?i.some(t):!1}function Mi(i,t){return i?i.find(t):void 0}function Ti(i,t){return i?i.findIndex(t):-1}function Ii(i,t=1){return i?i.flat(t):[]}function Rt(i){return i?i.reduce((t,e)=>Array.isArray(e)?t.concat(Rt(e)):t.concat(e),[]):[]}function Ai(i){return i?[...new Set(i)]:[]}function zi(i,t){if(!i)return[];const e=new Set;return i.filter(s=>{const n=typeof s=="object"?s[t]:s;return e.has(n)?!1:(e.add(n),!0)})}function Pi(i,t){if(!i||t<=0)return[];const e=[];for(let s=0;s<i.length;s+=t)e.push(i.slice(s,s+t));return e}function $i(i){if(!i)return[];const t=i.slice();for(let e=t.length-1;e>0;e--){const s=Math.floor(Math.random()*(e+1));[t[e],t[s]]=[t[s],t[e]]}return t}function Vt(i){return i?i.reduce((t,e)=>t+(Number(e)||0),0):0}function qi(i){return!i||i.length===0?0:Vt(i)/i.length}function Bi(i){return i&&i.length>0?Math.max(...i):-1/0}function Fi(i){return i&&i.length>0?Math.min(...i):1/0}function Ni(...i){return i.length===0?[]:i.reduce((t,e)=>t.filter(s=>e&&e.includes(s)))}function Oi(...i){return[...new Set(i.flat().filter(Boolean))]}function Ri(i,t){return i?i.filter(e=>!t||!t.includes(e)):[]}function Vi(...i){if(i.length===0)return[];const t=Math.max(...i.map(e=>e?e.length:0));return Array.from({length:t},(e,s)=>i.map(n=>n&&n[s]))}const Kt={isArray:si,isEmpty:ii,size:ni,first:ri,last:ai,get:li,slice:oi,concat:ci,join:hi,indexOf:di,lastIndexOf:ui,includes:pi,push:fi,pop:mi,shift:gi,unshift:_i,remove:yi,removeAt:vi,insert:bi,reverse:Ei,sort:ki,sortBy:wi,filter:xi,map:Ci,reduce:Si,forEach:Li,every:Di,some:Hi,find:Mi,findIndex:Ti,flat:Ii,flattenDeep:Rt,unique:Ai,uniqueBy:zi,chunk:Pi,shuffle:$i,sum:Vt,average:qi,max:Bi,min:Fi,intersection:Ni,union:Oi,difference:Ri,zip:Vi};function rt(i){return i!==null&&typeof i=="object"&&!Array.isArray(i)}function Ki(i){return!i||typeof i!="object"?!0:Object.keys(i).length===0}function Wi(i){return i?Object.keys(i):[]}function Ui(i){return i?Object.values(i):[]}function Yi(i){return i?Object.entries(i):[]}function Xi(i,t){return i?Object.prototype.hasOwnProperty.call(i,t):!1}function ji(i,t,e){if(!i)return e;const s=t.split(".");return s.some(J)?e:s.reduce((n,r)=>n&&n[r],i)??e}function Ji(i,t,e){if(!i||typeof i!="object")return i;const s=t.split(".");if(s.some(J))return i;const n=s.pop();let r=i;return s.forEach(a=>{(!r[a]||typeof r[a]!="object")&&(r[a]={}),r=r[a]}),r[n]=e,i}function Gi(i,t){return i?t.reduce((e,s)=>(i[s]!==void 0&&(e[s]=i[s]),e),{}):{}}function Zi(i,t){return i?Object.keys(i).reduce((e,s)=>(t.includes(s)||(e[s]=i[s]),e),{}):{}}function Wt(...i){return i.reduce((t,e)=>(e&&typeof e=="object"&&Object.keys(e).forEach(s=>{J(s)||(rt(e[s])&&rt(t[s])?t[s]=Wt(t[s],e[s]):t[s]=e[s])}),t),{})}function Qi(i){return i&&JSON.parse(JSON.stringify(i))}function Y(i,t=new WeakMap){if(!i||typeof i!="object")return i;if(t.has(i))return t.get(i);if(i instanceof Date)return new Date(i);if(i instanceof RegExp)return new RegExp(i);if(i instanceof Map){const s=new Map;return t.set(i,s),i.forEach((n,r)=>s.set(r,Y(n,t))),s}if(i instanceof Set){const s=new Set;return t.set(i,s),i.forEach(n=>s.add(Y(n,t))),s}if(Array.isArray(i)){const s=[];return t.set(i,s),i.forEach(n=>s.push(Y(n,t))),s}const e={};return t.set(i,e),Object.keys(i).forEach(s=>{J(s)||(e[s]=Y(i[s],t))}),e}function tn(i,t){i&&Object.keys(i).forEach(e=>t(i[e],e,i))}function en(i,t){if(!i)return{};const e={};return Object.keys(i).forEach(s=>{e[s]=t(i[s],s,i)}),e}function sn(i,t){if(!i)return{};const e={};return Object.keys(i).forEach(s=>{t(i[s],s,i)&&(e[s]=i[s])}),e}function nn(i,t,e){return i?Object.keys(i).reduce((s,n)=>t(s,i[n],n,i),e):e}function rn(i){return i?Object.keys(i).map(t=>({key:t,value:i[t]})):[]}function an(i,t,e){return i?i.reduce((s,n)=>{const r=typeof n=="object"?n[t]:n,a=e?n[e]:n;return r!==void 0&&(s[r]=a),s},{}):{}}function ln(i){return i?Object.keys(i).length:0}function on(i){if(!i)return{};const t={};return Object.keys(i).forEach(e=>{t[i[e]]=e}),t}function Ut(i,t){if(i===t)return!0;if(!i||!t||typeof i!="object"||typeof t!="object")return!1;const e=Object.keys(i),s=Object.keys(t);return e.length!==s.length?!1:e.every(n=>Ut(i[n],t[n]))}function Yt(i){return i&&(Object.freeze(i),Object.keys(i).forEach(t=>{typeof i[t]=="object"&&Yt(i[t])}),i)}function cn(i){return i&&Object.seal(i)}const Xt={isObject:rt,isEmpty:Ki,keys:Wi,values:Ui,entries:Yi,has:Xi,get:ji,set:Ji,pick:Gi,omit:Zi,merge:Wt,clone:Qi,deepClone:Y,forEach:tn,map:en,filter:sn,reduce:nn,toArray:rn,fromArray:an,size:ln,invert:on,isEqual:Ut,freeze:Yt,seal:cn};function L(i){return typeof i=="number"&&!isNaN(i)}function hn(i){return Number.isInteger(i)}function dn(i){return L(i)&&!Number.isInteger(i)}function un(i){return L(i)&&i>0}function pn(i){return L(i)&&i<0}function fn(i){return L(i)&&i===0}function mn(i,t,e){return L(i)?Math.min(Math.max(i,t),e):i}function gn(i,t=0){if(!L(i))return i;const e=Math.pow(10,t);return Math.round(i*e)/e}function _n(i){return L(i)?Math.floor(i):i}function yn(i){return L(i)?Math.ceil(i):i}function vn(i){return L(i)?Math.abs(i):i}function bn(...i){const t=i.filter(L);return t.length>0?Math.min(...t):void 0}function En(...i){const t=i.filter(L);return t.length>0?Math.max(...t):void 0}function jt(...i){return i.flat().filter(L).reduce((e,s)=>e+s,0)}function kn(...i){const t=i.flat().filter(L);return t.length>0?jt(t)/t.length:0}function Jt(i=0,t=1){return Math.random()*(t-i)+i}function wn(i,t){return Math.floor(Jt(i,t+1))}function xn(i,t=2){return L(i)?i.toFixed(t):String(i)}function Cn(i,t="CNY",e=2){return L(i)?new Intl.NumberFormat("zh-CN",{style:"currency",currency:t,minimumFractionDigits:e,maximumFractionDigits:e}).format(i):String(i)}function Sn(i,t=0){return L(i)?`${(i*100).toFixed(t)}%`:String(i)}function Ln(i,t=0){return L(i)?i.toFixed(t):String(i)}function Dn(i,t=6){return L(i)?i.toPrecision(t):String(i)}function Hn(i){return Number.isNaN(i)}function Mn(i){return Number.isFinite(i)}function Tn(i,t=10){return Number.parseInt(i,t)}function In(i){return Number.parseFloat(i)}function An(i,t=0){const e=Number(i);return isNaN(e)?t:e}function zn(i,t,e=0){return!L(i)||!L(t)||t===0?e:i/t}function Pn(...i){return i.reduce((t,e)=>!L(t)||!L(e)?0:t*e,1)}const Gt={isNumber:L,isInteger:hn,isFloat:dn,isPositive:un,isNegative:pn,isZero:fn,clamp:mn,round:gn,floor:_n,ceil:yn,abs:vn,min:bn,max:En,sum:jt,average:kn,random:Jt,randomInt:wn,format:xn,formatCurrency:Cn,formatPercent:Sn,toFixed:Ln,toPrecision:Dn,isNaN:Hn,isFinite:Mn,parseInt:Tn,parseFloat:In,toNumber:An,safeDivide:zn,safeMultiply:Pn};function G(){return Date.now()}function V(){const i=new Date;return i.setHours(0,0,0,0),i}function $n(){const i=V();return i.setDate(i.getDate()+1),i}function qn(){const i=V();return i.setDate(i.getDate()-1),i}function x(i){return i instanceof Date&&!isNaN(i.getTime())}function Zt(i){return x(i)}function Bn(i){const t=new Date(i);return Zt(t)?t:null}function Fn(i,t="YYYY-MM-DD HH:mm:ss"){if(!x(i))return"";const e=i.getFullYear(),s=String(i.getMonth()+1).padStart(2,"0"),n=String(i.getDate()).padStart(2,"0"),r=String(i.getHours()).padStart(2,"0"),a=String(i.getMinutes()).padStart(2,"0"),l=String(i.getSeconds()).padStart(2,"0"),o=String(i.getMilliseconds()).padStart(3,"0"),d=["日","一","二","三","四","五","六"][i.getDay()];return t.replace("YYYY",e).replace("MM",s).replace("DD",n).replace("HH",r).replace("mm",a).replace("ss",l).replace("SSS",o).replace("D",i.getDate()).replace("M",i.getMonth()+1).replace("H",i.getHours()).replace("m",i.getMinutes()).replace("s",i.getSeconds()).replace("W",d)}function Nn(i){return x(i)?i.toISOString():""}function On(i){return x(i)?new Date(i.toUTCString()):null}function Rn(i,t){if(!x(i))return i;const e=new Date(i);return e.setDate(e.getDate()+t),e}function Vn(i,t){if(!x(i))return i;const e=new Date(i);return e.setHours(e.getHours()+t),e}function Kn(i,t){if(!x(i))return i;const e=new Date(i);return e.setMinutes(e.getMinutes()+t),e}function Wn(i,t){if(!x(i))return i;const e=new Date(i);return e.setSeconds(e.getSeconds()+t),e}function Z(i,t){if(!x(i)||!x(t))return 0;const e=new Date(i);e.setHours(0,0,0,0);const s=new Date(t);return s.setHours(0,0,0,0),Math.floor((e.getTime()-s.getTime())/(1e3*60*60*24))}function Un(i,t){return!x(i)||!x(t)?0:Math.floor((i.getTime()-t.getTime())/(1e3*60*60))}function Yn(i,t){return!x(i)||!x(t)?0:Math.floor((i.getTime()-t.getTime())/(1e3*60))}function Xn(i,t){return!x(i)||!x(t)?0:Math.floor((i.getTime()-t.getTime())/1e3)}function jn(i){return x(i)?Z(i,V())===0:!1}function Jn(i){return x(i)?Z(i,V())===-1:!1}function Gn(i){return x(i)?Z(i,V())===1:!1}function Zn(i){return x(i)?i.getTime()>G():!1}function Qn(i){return x(i)?i.getTime()<G():!1}function tr(i){if(!x(i))return!1;const t=i.getFullYear();return t%4===0&&(t%100!==0||t%400===0)}function er(i){return x(i)?new Date(i.getFullYear(),i.getMonth()+1,0).getDate():0}function sr(i){if(!x(i))return 0;const t=new Date(i.getFullYear(),0,1),e=i.getTime()-t.getTime();return Math.ceil(e/(1e3*60*60*24*7))}function ir(i){return x(i)?Math.ceil((i.getMonth()+1)/3):0}function nr(i){if(!x(i))return i;const t=new Date(i);return t.setHours(0,0,0,0),t}function rr(i){if(!x(i))return i;const t=new Date(i);return t.setHours(23,59,59,999),t}function ar(i){return x(i)?new Date(i.getFullYear(),i.getMonth(),1):i}function lr(i){return x(i)?new Date(i.getFullYear(),i.getMonth()+1,0,23,59,59,999):i}function Qt(i,t=1){if(!x(i))return i;const e=new Date(i),s=e.getDay(),n=s>=t?s-t:s+(7-t);return e.setDate(e.getDate()-n),e.setHours(0,0,0,0),e}function or(i,t=1){if(!x(i))return i;const e=Qt(i,t),s=new Date(e);return s.setDate(s.getDate()+6),s.setHours(23,59,59,999),s}function cr(i){if(!x(i))return 0;const t=new Date;let e=t.getFullYear()-i.getFullYear();return(t.getMonth()<i.getMonth()||t.getMonth()===i.getMonth()&&t.getDate()<i.getDate())&&e--,Math.max(0,e)}function hr(i){if(!x(i))return"";const e=G()-i.getTime(),s=60*1e3,n=60*s,r=24*n,a=7*r,l=30*r,o=365*r;return e<s?"刚刚":e<n?`${Math.floor(e/s)}分钟前`:e<r?`${Math.floor(e/n)}小时前`:e<a?`${Math.floor(e/r)}天前`:e<l?`${Math.floor(e/a)}周前`:e<o?`${Math.floor(e/l)}个月前`:`${Math.floor(e/o)}年前`}const te={now:G,today:V,tomorrow:$n,yesterday:qn,isDate:x,isValid:Zt,parse:Bn,format:Fn,toISO:Nn,toUTC:On,addDays:Rn,addHours:Vn,addMinutes:Kn,addSeconds:Wn,diffDays:Z,diffHours:Un,diffMinutes:Yn,diffSeconds:Xn,isToday:jn,isYesterday:Jn,isTomorrow:Gn,isFuture:Zn,isPast:Qn,isLeapYear:tr,getDaysInMonth:er,getWeekOfYear:sr,getQuarter:ir,startOfDay:nr,endOfDay:rr,startOfMonth:ar,endOfMonth:lr,startOfWeek:Qt,endOfWeek:or,getAge:cr,fromNow:hr};function ee(i,t,e={}){let s=null,n=null,r=null,a=0;const l=e.leading||!1,o=e.trailing!==!1;function c(){i.apply(r,n)}function d(){a=Date.now(),l?(s=setTimeout(u,t),c()):s=setTimeout(u,t)}function u(){s=null,o&&n&&c(),n=null,r=null}function p(){return Math.max(0,t-(Date.now()-a))}return function(...m){n=m,r=this,a=Date.now(),s?(clearTimeout(s),s=setTimeout(u,p())):d()}}function se(i,t,e={}){let s=!1;const n=e.trailing||!1;let r=null,a=null;function l(){i.apply(a,r),r=null,a=null}return function(...o){s?n&&(r=o,a=this):(s=!0,r=o,a=this,l(),setTimeout(()=>{s=!1,n&&r&&l()},t))}}function dr(i){return/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(i||"")}function ur(i){return/^1[3-9]\d{9}$/.test(i||"")}function pr(i){return/^(https?:\/\/)?([\da-z.-]+)\.([a-z.]{2,6})([/\w.-]*)*\/?$/.test(i||"")}function ie(i){return/^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/.test(i||"")}function ne(i){return/^([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$/.test(i||"")}function fr(i){return ie(i)||ne(i)}function mr(i){return/^[1-9]\d{5}(18|19|20)\d{2}(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])\d{3}[\dXx]$/.test(i||"")}function gr(i){return/^[A-Z][0-9]{8}$|^[A-Z]{2}[0-9]{7}$/.test(i||"")}function _r(i){const t=/^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|6(?:011|5[0-9]{2})[0-9]{12}|3[47][0-9]{13})$/,e=i.replace(/\s/g,"");if(!t.test(e))return!1;let s=0,n=!1;for(let r=e.length-1;r>=0;r--){let a=parseInt(e[r],10);n&&(a*=2,a>9&&(a-=9)),s+=a,n=!n}return s%10===0}function re(i){return/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/.test(i||"")}function ae(i){const t=/^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/.exec(i||"");return t?t.slice(1).every(e=>parseInt(e)>=0&&parseInt(e)<=255):!1}function le(i){const t=/^rgba\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3}),\s*([01]|0\.\d+)\)$/.exec(i||"");if(!t)return!1;const[,e,s,n,r]=t;return parseInt(e)>=0&&parseInt(e)<=255&&parseInt(s)>=0&&parseInt(s)<=255&&parseInt(n)>=0&&parseInt(n)<=255&&parseFloat(r)>=0&&parseFloat(r)<=1}function yr(i){return re(i)||ae(i)||le(i)}function vr(i){return!isNaN(new Date(i).getTime())}function br(i){try{return JSON.parse(i),!0}catch{return!1}}function Er(i){return!i||i.trim()===""}function kr(i){return/^\s+$/.test(i||"")}function wr(i){return!isNaN(parseFloat(i))&&isFinite(i)}function xr(i){return/^-?\d+$/.test(i||"")}function Cr(i){return/^-?\d+\.\d+$/.test(i||"")}function Sr(i){const t=parseFloat(i);return!isNaN(t)&&t>0}function Lr(i){const t=parseFloat(i);return!isNaN(t)&&t<0}function Dr(i){return/^[a-zA-Z]+$/.test(i||"")}function Hr(i){return/^[a-zA-Z0-9]+$/.test(i||"")}function Mr(i){return/^[\u4e00-\u9fa5]+$/.test(i||"")}function Tr(i,t,e){const s=(i||"").length;return s>=t&&(e===void 0||s<=e)}function Ir(i,t){return(i||"").length>=t}function Ar(i,t){return(i||"").length<=t}function zr(i,t){return t instanceof RegExp?t.test(i||""):!1}function Pr(i,t){return String(i)===String(t)}function oe(i,t){return(i||"").includes(t)}function $r(i,t){return!oe(i,t)}function qr(i){return Array.isArray(i)}function Br(i,t,e){const s=i?i.length:0;return s>=t&&(e===void 0||s<=e)}function Fr(i,t){return i?i.length>=t:!1}function Nr(i,t){return i?i.length<=t:!1}function Or(i){return i!==null&&typeof i=="object"&&!Array.isArray(i)}function Rr(i,t){return!i||!t||!Array.isArray(t)?!1:t.every(e=>Object.prototype.hasOwnProperty.call(i,e))}function Vr(i,t){const e={};return Object.keys(t).forEach(s=>{const n=i[s],r=t[s],a=[];r.forEach(l=>{if(typeof l=="string"){const[o,...c]=l.split(":");at[o](n,...c)||a.push(o)}else if(typeof l=="function"){const o=l(n,i);o!==!0&&a.push(o||"validation_failed")}}),a.length>0&&(e[s]=a)}),{valid:Object.keys(e).length===0,errors:e}}const at={isEmail:dr,isPhone:ur,isURL:pr,isIPv4:ie,isIPv6:ne,isIP:fr,isIDCard:mr,isPassport:gr,isCreditCard:_r,isHexColor:re,isRGB:ae,isRGBA:le,isColor:yr,isDate:vr,isJSON:br,isEmpty:Er,isWhitespace:kr,isNumber:wr,isInteger:xr,isFloat:Cr,isPositive:Sr,isNegative:Lr,isAlpha:Dr,isAlphaNumeric:Hr,isChinese:Mr,isLength:Tr,minLength:Ir,maxLength:Ar,matches:zr,equals:Pr,contains:oe,notContains:$r,isArray:qr,arrayLength:Br,arrayMinLength:Fr,arrayMaxLength:Nr,isObject:Or,hasKeys:Rr,validate:Vr};function Kr(i){const t=i?String(i):"",e=[1732584193,4023233417,2562383102,271733878],s=[3614090360,3905402710,606105819,3250441966,4118548399,1200080426,2821735955,4249261313,1770035416,2336552879,4294925233,2304563134,1804603682,4254626195,2792965006,1236535329,4129170786,3225465664,643717713,3921069994,3593408605,38016083,3634488961,3889429448,568446438,3275163606,4107603335,1163531501,2850285829,4243563512,1735328473,2368359562,4294588738,2272392833,1839030562,4259657740,2763975236,1272893353,4139469664,3200236656,681279174,3936430074,3572445317,76029189,3654602809,3873151461,530742520,3299628645,4096336452,1126891415,2878612391,4237533241,1700485571,2399980690,4293915773,2240044497,1873313359,4264355552,2734768916,1309151649,4149444226,3174756917,718787259,3951481745],n=[[7,12,17,22],[5,9,14,20],[4,11,16,23],[6,10,15,21]];function r(u,p){return u<<p|u>>>32-p}function a(u){const p=u.length*8;for(u+="€";u.length%64!==56;)u+="\0";const m=p&4294967295,f=p>>>32&4294967295;for(let g=0;g<4;g++)u+=String.fromCharCode(m>>>8*g&255);for(let g=0;g<4;g++)u+=String.fromCharCode(f>>>8*g&255);return u}function l(u,p){const[m,f,g,v]=p,y=[];for(let D=0;D<16;D++)y[D]=u.charCodeAt(D*4)&255|(u.charCodeAt(D*4+1)&255)<<8|(u.charCodeAt(D*4+2)&255)<<16|(u.charCodeAt(D*4+3)&255)<<24;let k=m,E=f,b=g,C=v;for(let D=0;D<64;D++){let S,H;const A=Math.floor(D/16),$=D%16;A===0?(S=E&b|~E&C,H=$):A===1?(S=C&E|~C&b,H=(5*$+1)%16):A===2?(S=E^b^C,H=(3*$+5)%16):(S=b^(E|~C),H=7*$%16);const O=C;C=b,b=E,E=E+r(k+S+s[D]+y[H]&4294967295,n[A][D%4]),k=O}return[m+k&4294967295,f+E&4294967295,g+b&4294967295,v+C&4294967295]}const o=a(t);let c=[...e];for(let u=0;u<o.length;u+=64)c=l(o.substring(u,u+64),c);let d="";return c.forEach(u=>{for(let p=0;p<4;p++)d+=(u>>>8*p&255).toString(16).padStart(2,"0")}),d}function Wr(i){const t=i?String(i):"",e=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];function s(c,d){return c>>>d|c<<32-d}function n(c){const d=c.length*8;for(c+="€";c.length%64!==56;)c+="\0";const u=d&4294967295,p=d>>>32&4294967295;for(let m=0;m<4;m++)c+=String.fromCharCode(p>>>8*m&255);for(let m=0;m<4;m++)c+=String.fromCharCode(u>>>8*m&255);return c}function r(c,d){const u=[];for(let b=0;b<16;b++)u[b]=c.charCodeAt(b*4)&255|(c.charCodeAt(b*4+1)&255)<<8|(c.charCodeAt(b*4+2)&255)<<16|(c.charCodeAt(b*4+3)&255)<<24;for(let b=16;b<64;b++){const C=s(u[b-15],7)^s(u[b-15],18)^u[b-15]>>>3,D=s(u[b-2],17)^s(u[b-2],19)^u[b-2]>>>10;u[b]=u[b-16]+C+u[b-7]+D&4294967295}let[p,m,f,g,v,y,k,E]=d;for(let b=0;b<64;b++){const C=s(v,6)^s(v,11)^s(v,25),D=v&y^~v&k,S=E+C+D+e[b]+u[b]&4294967295,H=s(p,2)^s(p,13)^s(p,22),A=p&m^p&f^m&f,$=H+A&4294967295;E=k,k=y,y=v,v=g+S&4294967295,g=f,f=m,m=p,p=S+$&4294967295}return[d[0]+p&4294967295,d[1]+m&4294967295,d[2]+f&4294967295,d[3]+g&4294967295,d[4]+v&4294967295,d[5]+y&4294967295,d[6]+k&4294967295,d[7]+E&4294967295]}const a=n(t);let l=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225];for(let c=0;c<a.length;c+=64)l=r(a.substring(c,c+64),l);let o="";return l.forEach(c=>{for(let d=3;d>=0;d--)o+=(c>>>8*d&255).toString(16).padStart(2,"0")}),o}function Ur(i){const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";let e="",s=0;const n=i?i.split("").map(r=>r.charCodeAt(0)):[];for(;s<n.length;){const r=n[s++],a=n[s++]||0,l=n[s++]||0,o=r>>2,c=(r&3)<<4|a>>4,d=(a&15)<<2|l>>6,u=l&63;e+=t[o]+t[c]+(s>n.length+1?"=":t[d])+(s>n.length?"=":t[u])}return e}function Yr(i){const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";let e="",s=0;for(i=i.replace(/[^A-Za-z0-9+/=]/g,"");s<i.length;){const n=t.indexOf(i.charAt(s++)),r=t.indexOf(i.charAt(s++)),a=t.indexOf(i.charAt(s++)),l=t.indexOf(i.charAt(s++)),o=n<<2|r>>4,c=(r&15)<<4|a>>2,d=(a&3)<<6|l;e+=String.fromCharCode(o),a!==64&&(e+=String.fromCharCode(c)),l!==64&&(e+=String.fromCharCode(d))}return e}function Xr(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,i=>{const t=Math.random()*16|0;return(i==="x"?t:t&3|8).toString(16)})}const ce={md5:Kr,sha256:Wr,base64Encode:Ur,base64Decode:Yr,uuid:Xr},P=new Map;async function Q(i,t={}){const{crossOrigin:e="anonymous"}=t;return P.has(i)?P.get(i):new Promise((s,n)=>{const r=new Image;r.crossOrigin=e,r.onload=()=>{P.set(i,r),s(r)},r.onerror=()=>{n(new Error(`Failed to load image: ${i}`))},r.src=i})}async function jr(i,t={}){const{parallel:e=!0}=t;if(e)return Promise.all(i.map(n=>Q(n,t)));const s=[];for(const n of i)s.push(await Q(n,t));return s}async function he(i,t={}){const{type:e="text/javascript",async:s=!0,defer:n=!1}=t;return P.has(i)?P.get(i):new Promise((r,a)=>{const l=document.createElement("script");l.type=e,l.async=s,l.defer=n,l.onload=()=>{P.set(i,l),r(l)},l.onerror=()=>{l.remove(),a(new Error(`Failed to load script: ${i}`))},l.src=i,document.head.appendChild(l)})}async function de(i,t={}){const{media:e="all"}=t;return P.has(i)?P.get(i):new Promise((s,n)=>{const r=document.createElement("link");r.rel="stylesheet",r.href=i,r.media=e,r.onload=()=>{P.set(i,r),s(r)},r.onerror=()=>{r.remove(),n(new Error(`Failed to load stylesheet: ${i}`))},document.head.appendChild(r)})}async function Jr(i,t,e={}){const{weight:s="normal",style:n="normal"}=e,r=new FontFace(i,`url(${t})`,{weight:s,style:n});try{return await r.load(),document.fonts.add(r),r}catch{throw new Error(`Failed to load font: ${i}`)}}async function Gr(i,t="image"){switch(t){case"image":return Q(i);case"script":return he(i);case"stylesheet":case"style":return de(i);default:throw new Error(`Unsupported preload type: ${t}`)}}function Zr(i){return P.has(i)}function Qr(){P.clear()}function ta(i){P.delete(i)}const ue={loadImage:Q,loadImages:jr,loadScript:he,loadStylesheet:de,loadFont:Jr,preload:Gr,isLoaded:Zr,clearCache:Qr,clearCacheByUrl:ta},ea={string:Ot,array:Kt,object:Xt,number:Gt,date:te,debounce:ee,throttle:se,validator:at,crypto:ce,preload:ue};function sa(i){if(!i)return"";let t=String(i);const e=/<\s*(script|iframe|object|embed|applet|form|base|link|meta|style)\b[^>]*>[\s\S]*?<\s*\/\s*\1\s*>|<\s*(script|iframe|object|embed|applet|form|base|link|meta|style)\b[^>]*\/?>/gi;let s;do s=t,t=t.replace(e,"");while(t!==s);return t=t.replace(/\bon\w+\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+)/gi,""),t=t.replace(/(href|src|action|background)\s*=\s*(?:"[^"]*(?:javascript|vbscript|data)\s*:[^"]*"|'[^']*(?:javascript|vbscript|data)\s*:[^']*'|[^\s>]*(?:javascript|vbscript|data)\s*:[^\s>]*)/gi,'$1=""'),t=t.replace(/expression\s*\([^)]*\)/gi,""),t}class pe{constructor(){this.children={},this.keys=[]}}class lt{constructor(){this.root=new pe}insert(t){let e=this.root;const s=t.split(".");s.forEach((n,r)=>{e.children[n]||(e.children[n]=new pe),e=e.children[n],r===s.length-1&&e.keys.push(t)})}getSubKeys(t){let e=this.root;const s=t.split("."),n=[];for(let r=0;r<s.length;r++){const a=s[r];if(!e.children[a])break;e=e.children[a];const l=o=>{o.keys.length>0&&n.push(...o.keys),Object.values(o.children).forEach(c=>l(c))};l(e)}return[...new Set(n)]}getParentKeys(t){const e=t.split("."),s=[];for(let n=1;n<=e.length;n++){const r=e.slice(0,n).join(".");s.push(r)}return s}}const _={parent:Symbol("reactive_parent"),path:Symbol("reactive_path"),isReactive:Symbol("reactive_is_reactive")};class fe{constructor(){this.rawData={},this.data=null,this.observers={},this.elements={},this.computedProperties={},this.pathTrie=new lt,this.updateQueue=new Map,this.isProcessing=!1,this.pendingComputed=new Set,this.persistedKeys=new Map,this.snapshots=[],this.snapshotLimit=10,this._proxyCache=new WeakMap,this.createReactiveData()}createReactiveData(){const t={get:(e,s,n)=>{if(s==="__raw__")return e;const r=Reflect.get(e,s,n);return r&&typeof r=="object"&&!Array.isArray(r)?this.wrapReactive(r,s):r},set:(e,s,n,r)=>{const a=Reflect.get(e,s,r),l=Reflect.set(e,s,n,r),o=this.resolvePath(e,s);return this.notify(o,n,a),this.queueUpdate(o,n),l},deleteProperty:(e,s)=>{const n=Reflect.get(e,s,receiver),r=Reflect.deleteProperty(e,s),a=this.resolvePath(e,s);return this.notify(a,void 0,n),this.queueUpdate(a,void 0),r}};this.data=new Proxy(this.rawData,t),this.data.__parent__=null,this.data.__path__=""}wrapReactive(t,e){if(t[_.isReactive])return t;if(this._proxyCache.has(t))return this._proxyCache.get(t);const s={get:(r,a,l)=>{if(a==="__raw__")return r;if(a===_.parent||a==="__parent__")return r[_.parent];if(a===_.path||a==="__path__")return r[_.path];if(a===_.isReactive||a==="__isReactive__")return!0;const o=Reflect.get(r,a,l);return o&&typeof o=="object"&&!Array.isArray(o)?this.wrapReactive(o,`${r[_.path]}${r[_.path]?".":""}${a}`):o},set:(r,a,l,o)=>{if(a===_.parent||a===_.path||a===_.isReactive||a==="__parent__"||a==="__path__"||a==="__isReactive__")return!0;const c=Reflect.get(r,a,o),d=Reflect.set(r,a,l,o),u=`${r[_.path]}${r[_.path]?".":""}${a}`;return this.notify(u,l,c),this.queueUpdate(u,l),d},deleteProperty:(r,a)=>{if(a===_.parent||a===_.path||a===_.isReactive)return!1;const l=Reflect.get(r,a),o=Reflect.deleteProperty(r,a),c=`${r[_.path]}${r[_.path]?".":""}${a}`;return this.notify(c,void 0,l),this.queueUpdate(c,void 0),o},has:(r,a)=>a==="__raw__"||a===_.parent||a===_.path||a===_.isReactive||a==="__parent__"||a==="__path__"||a==="__isReactive__"?!0:a in r,ownKeys:r=>Reflect.ownKeys(r).filter(a=>a!==_.parent&&a!==_.path&&a!==_.isReactive),getOwnPropertyDescriptor:(r,a)=>a===_.parent||a===_.path||a===_.isReactive?{configurable:!1,enumerable:!1,writable:!1,value:r[a]}:Reflect.getOwnPropertyDescriptor(r,a)},n=new Proxy(t,s);return t[_.parent]=t,t[_.path]=e,t[_.isReactive]=!0,this._proxyCache.set(t,n),Object.keys(t).forEach(r=>{t[r]&&typeof t[r]=="object"&&!Array.isArray(t[r])&&(t[r]=this.wrapReactive(t[r],`${e}${e?".":""}${r}`))}),n}resolvePath(t,e){return t[_.path]?`${t[_.path]}.${e}`:e}queueUpdate(t,e){this.updateQueue.set(t,e),this.isProcessing||(this.isProcessing=!0,requestAnimationFrame(()=>{this.processQueue()}))}processQueue(){const t=new Set;this.updateQueue.forEach((e,s)=>{t.add(s),this.updateElementsDirect(s,e),this.pathTrie.getSubKeys(s).forEach(r=>{if(!t.has(r)){const a=this.get(r);this.updateElementsDirect(r,a),t.add(r)}})}),this.updateQueue.clear(),this.processComputed(),this.isProcessing=!1}updateElementsDirect(t,e){this.elements[t]&&this.elements[t].forEach(s=>{this.updateElement(s,e)})}processComputed(){Object.keys(this.computedProperties).forEach(e=>{this.computedProperties[e].deps.some(r=>this.updateQueue.has(r)||this.pathTrie.getSubKeys(r).some(a=>this.updateQueue.has(a)))&&this.updateComputedProperty(e)})}set(t,e,s=!1){const n=this.get(t);typeof t=="object"?(Object.assign(this.rawData,t),Object.keys(t).forEach(r=>{s||(this.notify(r,t[r],n?.[r]),this.queueUpdate(r,t[r]))})):(t.includes(".")?this.setNested(t,e):this.rawData[t]=e,s||(this.notify(t,e,n),this.queueUpdate(t,e))),s||this.processComputed()}get(t){if(t)return t.includes(".")?this.getNested(t):this.rawData[t]}getNested(t){if(t)return t.split(".").reduce((e,s)=>e?.[s],this.rawData)}setNested(t,e){const s=t.split("."),n=s.pop(),r=s.reduce((l,o)=>(l[o]||(l[o]={}),l[o]),this.rawData),a=r[n];r[n]=e,this.notify(t,e,a),this.queueUpdate(t,e)}observe(t,e){this.observers[t]||(this.observers[t]=[]),this.observers[t].push(e)}unobserve(t,e){this.observers[t]&&(this.observers[t]=this.observers[t].filter(s=>s!==e))}notify(t,e,s){this.observers[t]&&this.observers[t].forEach(n=>{try{n(e,s)}catch(r){console.error(`Observer error for ${t}:`,r)}}),this.observers["*"]?.forEach(n=>{try{n(t,e,s)}catch(r){console.error("Wildcard observer error:",r)}})}updateElement(t,e){const s=t.getAttribute("data-bind");if(!s)return;s.split("|").forEach(r=>{const a=r.split(":"),l=a[0].trim(),o=a[1]?.trim();switch(l){case"text":t.textContent!==String(e??"")&&(t.textContent=e??"");break;case"html":const c=sa(e);t.innerHTML!==c&&(t.innerHTML=c);break;case"value":t.type==="checkbox"?t.checked!==!!e&&(t.checked=!!e):t.value!==String(e??"")&&(t.value=e??"");break;case"checked":t.checked!==!!e&&(t.checked=!!e);break;case"disabled":t.disabled!==!!e&&(t.disabled=!!e);break;case"hidden":const d=e?"none":"";t.style.display!==d&&(t.style.display=d);break;case"class":o&&(e?t.classList.add(o):t.classList.remove(o));break;case"style":o&&t.style[o]!==String(e??"")&&(t.style[o]=e??"");break;case"attr":o&&t.getAttribute(o)!==String(e??"")&&t.setAttribute(o,e??"");break;case"src":t.src!==String(e??"")&&(t.src=e??"");break;case"href":t.href!==String(e??"")&&(t.href=e??"");break;case"placeholder":t.placeholder!==String(e??"")&&(t.placeholder=e??"");break}})}computed(t,e,s){this.computedProperties[t]={deps:e,callback:s},e.forEach(n=>{this.pathTrie.insert(n)}),this.updateComputedProperty(t)}updateComputedProperty(t){const e=this.computedProperties[t];if(e)try{const s=e.deps.map(r=>this.get(r)),n=e.callback(...s);this.set(t,n,!0)}catch(s){console.error(`Computed error for ${t}:`,s)}}load(t){Object.keys(t).forEach(e=>{t[e]&&typeof t[e]=="object"&&!Array.isArray(t[e])?this.rawData[e]=this.wrapReactive(t[e],e):this.rawData[e]=t[e],this.queueUpdate(e,this.rawData[e])}),this.processComputed()}reset(){this.rawData={},this.observers={},this.elements={},this.computedProperties={},this.pathTrie=new lt,this.updateQueue.clear(),this.snapshots=[],this.createReactiveData(),this.bind()}persist(t,e={}){const{storage:s="local",debounce:n=0,version:r=1,encrypt:a=!1,encryptionKey:l=null}=e,o=s==="session"?sessionStorage:localStorage;this.persistedKeys.set(t,{storage:o,debounce:n,timeout:null,version:r,encrypt:a,encryptionKey:l});const c=this.get(t);c!==void 0&&this._persistSave(t,c,o,{version:r,encrypt:a,encryptionKey:l}),this.observe(t,d=>{const u=this.persistedKeys.get(t);u&&(u.debounce>0?(u.timeout&&clearTimeout(u.timeout),u.timeout=setTimeout(()=>{this._persistSave(t,d,u.storage,{version:u.version,encrypt:u.encrypt,encryptionKey:u.encryptionKey})},u.debounce)):this._persistSave(t,d,u.storage,{version:u.version,encrypt:u.encrypt,encryptionKey:u.encryptionKey}))})}_persistSave(t,e,s,n={}){try{const{version:r=1,encrypt:a=!1,encryptionKey:l=null}=n,o={value:e,version:r,timestamp:Date.now()};let c=JSON.stringify(o);a&&l&&(c=this._encrypt(c,l)),this._ensureStorageCapacity(s),s.setItem(`kupola:${t}`,c)}catch(r){if(console.warn(`Failed to persist key ${t}:`,r),r.name==="QuotaExceededError"&&s===localStorage){console.warn(`localStorage quota exceeded, trying sessionStorage for key ${t}`);try{sessionStorage.setItem(`kupola:${t}`,JSON.stringify({value:e,version:1}))}catch(a){console.warn(`sessionStorage also failed for key ${t}:`,a)}}}}_ensureStorageCapacity(t){try{const e="kupola:__storage_test__";t.setItem(e,"test"),t.removeItem(e)}catch(e){e.name==="QuotaExceededError"&&this._cleanupOldStorage(t)}}_cleanupOldStorage(t){const e=Date.now(),s=30*24*60*60*1e3;for(let n=0;n<t.length;n++){const r=t.key(n);if(r?.startsWith("kupola:"))try{const a=JSON.parse(t.getItem(r));a.timestamp&&e-a.timestamp>s&&t.removeItem(r)}catch{t.removeItem(r)}}}_encrypt(t,e){return window.CryptoJS?window.CryptoJS.AES.encrypt(t,e).toString():(console.warn("CryptoJS not available, encryption skipped"),t)}_decrypt(t,e){if(!window.CryptoJS)return console.warn("CryptoJS not available, decryption skipped"),t;try{return window.CryptoJS.AES.decrypt(t,e).toString(window.CryptoJS.enc.Utf8)}catch(s){return console.warn("Decryption failed:",s),t}}unpersist(t){const e=this.persistedKeys.get(t);e&&(e.timeout&&clearTimeout(e.timeout),e.storage.removeItem(`kupola:${t}`),this.persistedKeys.delete(t))}loadPersisted(t={}){const e={},{encryptionKey:s=null}=t;for(let n=0;n<localStorage.length;n++){const r=localStorage.key(n);if(r?.startsWith("kupola:")){const a=r.replace("kupola:","");try{const l=localStorage.getItem(r);let o;if(s){const c=this._decrypt(l,s);o=JSON.parse(c)}else o=JSON.parse(l);if(o.version!==void 0&&o.version!==t.version){console.debug(`Skipping outdated data for ${a} (version ${o.version})`);continue}e[a]=o.value!==void 0?o.value:o}catch(l){console.warn(`Failed to load persisted key ${a}:`,l)}}}for(let n=0;n<sessionStorage.length;n++){const r=sessionStorage.key(n);if(r?.startsWith("kupola:")){const a=r.replace("kupola:","");try{const l=sessionStorage.getItem(r);let o;if(s){const c=this._decrypt(l,s);o=JSON.parse(c)}else o=JSON.parse(l);if(o.version!==void 0&&o.version!==t.version){console.debug(`Skipping outdated data for ${a} (version ${o.version})`);continue}e[a]=o.value!==void 0?o.value:o}catch{}}}return Object.keys(e).length>0&&this.load(e),e}_clone(t){if(typeof structuredClone=="function")try{return structuredClone(t)}catch(e){console.warn("structuredClone failed, falling back to JSON:",e)}return JSON.parse(JSON.stringify(t))}snapshot(){const t=this._clone(this.rawData);return this.snapshots.push(t),this.snapshots.length>this.snapshotLimit&&this.snapshots.shift(),this.snapshots.length-1}rollback(t=-1){if(this.snapshots.length===0)return!1;const e=t>=0?t:this.snapshots.length-1,s=this.snapshots[e];return s?(this.rawData=this._clone(s),this.createReactiveData(),Object.keys(this.rawData).forEach(n=>{this.queueUpdate(n,this.rawData[n])}),this.processComputed(),!0):!1}getSnapshotCount(){return this.snapshots.length}clearSnapshots(){this.snapshots=[]}serializeForm(t){const e={};return t.querySelectorAll("input, select, textarea").forEach(s=>{const n=s.getAttribute("data-bind");if(!n)return;const a=n.split(":")[1]?.trim();a&&(s.type==="checkbox"?(e[a]||(e[a]=[]),s.checked&&e[a].push(s.value)):s.type==="radio"?s.checked&&(e[a]=s.value):e[a]=s.value)}),e}fillForm(t,e){Object.keys(e).forEach(s=>{t.querySelectorAll('[data-bind*=":'+s+'"]').forEach(n=>{n.type==="checkbox"?n.checked=Array.isArray(e[s])?e[s].includes(n.value):!!e[s]:n.type==="radio"?n.checked=n.value===e[s]:n.value=e[s]??""})})}createReactive(t,e=""){if(t[_.isReactive])return t;if(this._proxyCache.has(t))return this._proxyCache.get(t);const s={get:(r,a,l)=>{if(a==="__raw__")return r;if(a===_.parent||a==="__parent__")return r[_.parent];if(a===_.path||a==="__path__")return r[_.path];if(a===_.isReactive||a==="__isReactive__")return!0;const o=Reflect.get(r,a,l);return o&&typeof o=="object"&&!Array.isArray(o)?this.wrapReactive(o,`${r[_.path]}${r[_.path]?".":""}${a}`):o},set:(r,a,l,o)=>{if(a===_.parent||a===_.path||a===_.isReactive||a==="__parent__"||a==="__path__"||a==="__isReactive__")return!0;const c=Reflect.get(r,a,o),d=Reflect.set(r,a,l,o),u=`${r[_.path]}${r[_.path]?".":""}${a}`;return this.notify(u,l,c),this.queueUpdate(u,l),d},deleteProperty:(r,a)=>{if(a===_.parent||a===_.path||a===_.isReactive)return!1;const l=Reflect.get(r,a),o=Reflect.deleteProperty(r,a),c=`${r[_.path]}${r[_.path]?".":""}${a}`;return this.notify(c,void 0,l),this.queueUpdate(c,void 0),o},has:(r,a)=>a==="__raw__"||a===_.parent||a===_.path||a===_.isReactive||a==="__parent__"||a==="__path__"||a==="__isReactive__"?!0:a in r,ownKeys:r=>Reflect.ownKeys(r).filter(a=>a!==_.parent&&a!==_.path&&a!==_.isReactive),getOwnPropertyDescriptor:(r,a)=>a===_.parent||a===_.path||a===_.isReactive?{configurable:!1,enumerable:!1,writable:!1,value:r[a]}:Reflect.getOwnPropertyDescriptor(r,a)},n=new Proxy(t,s);return t[_.parent]=t,t[_.path]=e,t[_.isReactive]=!0,this._proxyCache.set(t,n),Object.keys(t).forEach(r=>{t[r]&&typeof t[r]=="object"&&!Array.isArray(t[r])&&(t[r]=this.wrapReactive(t[r],`${e}${e?".":""}${r}`))}),n}bind(){document.querySelectorAll("[data-bind]").forEach(t=>{this._bindElement(t)}),this._mutationObserver||(this._isObserving=!1,this._mutationObserver=new MutationObserver(t=>{if(!this._isObserving){this._isObserving=!0;try{t.forEach(e=>{e.addedNodes.forEach(s=>{s.nodeType===Node.ELEMENT_NODE&&(s.querySelectorAll("[data-bind]").forEach(r=>this._bindElement(r)),s.hasAttribute&&s.hasAttribute("data-bind")&&this._bindElement(s))})})}finally{this._isObserving=!1}}}),this._mutationObserver.observe(document.body,{childList:!0,subtree:!0}))}_bindElement(t){const s=t.getAttribute("data-bind").split(":");s[0].split("|")[0].trim();const n=s[1]?.trim();if(n){if(this.pathTrie.insert(n),this.elements[n]||(this.elements[n]=[]),this.elements[n].includes(t)||this.elements[n].push(t),t.tagName==="INPUT"||t.tagName==="TEXTAREA"||t.tagName==="SELECT"){const r=t.__kupolaBindHandler;r&&t.removeEventListener("input",r);const a=()=>{const l=t.type==="checkbox"?t.checked:t.value;n.includes(".")?this.setNested(n,l):this.set(n,l)};t.__kupolaBindHandler=a,t.addEventListener("input",a)}this.rawData[n]!==void 0&&this.updateElement(t,this.rawData[n])}}destroy(){this._mutationObserver&&(this._mutationObserver.disconnect(),this._mutationObserver=null),Object.values(this.elements).forEach(t=>{t.forEach(e=>{const s=e.__kupolaBindHandler;s&&(e.removeEventListener("input",s),delete e.__kupolaBindHandler)})}),this.persistedKeys.forEach((t,e)=>{t.timeout&&clearTimeout(t.timeout)}),this.persistedKeys.clear(),this.rawData={},this.observers={},this.elements={},this.computedProperties={},this.pathTrie=new lt,this.updateQueue.clear(),this.snapshots=[]}}class ot{constructor(t,e={}){this.name=t,this._stateKey=`__store_${t}__`;const s=e.state?e.state():{};this.getters=e.getters||{},this.actions=e.actions||{},this.mutations=e.mutations||{},this.observers={},q?(q.set(this._stateKey,s),this.state=q.data?.[this._stateKey]||q.createReactive(s,this._stateKey),q.observe(this._stateKey,n=>{this.notify(n)})):this.state=s,this._bindGetters(),this._bindActions()}_bindGetters(){Object.keys(this.getters).forEach(t=>{Object.defineProperty(this,t,{get:()=>this.getters[t](this.state),enumerable:!0})})}_bindActions(){Object.keys(this.actions).forEach(t=>{this[t]=(...e)=>this.actions[t]({state:this.state,commit:this.commit.bind(this),dispatch:this.dispatch.bind(this),getters:this},...e)})}commit(t,e){const s=this.mutations[t];if(!s){console.warn(`Mutation ${t} not found in store ${this.name}`);return}s(this.state,e)}dispatch(t,e){const s=this.actions[t];if(!s){console.warn(`Action ${t} not found in store ${this.name}`);return}return s({state:this.state,commit:this.commit.bind(this),dispatch:this.dispatch.bind(this),getters:this},e)}observe(t){return this.observers["*"]||(this.observers["*"]=[]),this.observers["*"].push(t),t}unobserve(t){this.observers["*"]&&(this.observers["*"]=this.observers["*"].filter(e=>e!==t))}notify(t){this.observers["*"]&&this.observers["*"].forEach(e=>{try{e(t)}catch(s){console.error(`Observer error for store ${this.name}:`,s)}}),q&&q.set(this.name,t)}toJSON(){return{name:this.name,state:this.state,getters:Object.keys(this.getters).reduce((t,e)=>(t[e]=this[e],t),{})}}}class me{constructor(){this.stores=new Map}createStore(t,e){const s=new ot(t,e);return this.stores.set(t,s),s}getStore(t){return this.stores.get(t)}registerStore(t){t instanceof ot&&this.stores.set(t.name,t)}dispose(){this.stores.clear()}}class ge{constructor(){this.events={},this.delegatedEvents={},this.eventListeners={}}on(t,e){return this.events[t]||(this.events[t]=[]),this.events[t].push(e),e}off(t,e){this.events[t]&&(this.events[t]=this.events[t].filter(s=>s!==e))}emit(t,e){this.events[t]&&this.events[t].forEach(s=>{try{s(e)}catch(n){console.error(`Error in event handler for ${t}:`,n)}}),this.events["*"]?.forEach(s=>{try{s(t,e)}catch(n){console.error("Error in wildcard event handler:",n)}})}once(t,e){const s=n=>{e(n),this.off(t,s)};return this.on(t,s),s}delegate(t,e,s){if(!this.delegatedEvents[e]){this.delegatedEvents[e]=[];const n=r=>{this.delegatedEvents[e].forEach(({selector:a,cb:l})=>{(r.target.matches(a)||r.target.closest(a))&&l(r)})};document.addEventListener(e,n),this.eventListeners[e]=n}return this.delegatedEvents[e].push({selector:t,cb:s}),s}undelegate(t,e){if(this.delegatedEvents[e]&&(this.delegatedEvents[e]=this.delegatedEvents[e].filter(s=>s.selector!==t),this.delegatedEvents[e].length===0)){const s=this.eventListeners[e];s&&(document.removeEventListener(e,s),delete this.eventListeners[e]),delete this.delegatedEvents[e]}}destroy(){Object.entries(this.eventListeners).forEach(([t,e])=>{document.removeEventListener(t,e)}),this.events={},this.delegatedEvents={},this.eventListeners={}}}function T(i=null){const t={_value:i,_subscribers:new Set};return Object.defineProperty(t,"value",{configurable:!0,enumerable:!0,get(){return t._value},set(e){e!==t._value&&(t._value=e,t._subscribers.forEach(s=>s(e)))}}),t.subscribe=e=>(t._subscribers.add(e),{unsubscribe(){t._subscribers.delete(e)}}),t}const q=new fe,ia=new ge,ct=new me;function na(i,t){return ct.createStore(i,t)}function ra(i){return ct.getStore(i)}const _e="kupola-theme",ye="kupola-brand",K=[{id:"green",name:"翠绿",color:"#32F08C"},{id:"xionghuang",name:"雄黄",color:"#FF9900"},{id:"jianghuang",name:"姜黄",color:"#E2C027"},{id:"lanlv",name:"蓝绿",color:"#12A182"},{id:"kongquelan",name:"孔雀蓝",color:"#0EB0C9"},{id:"meiguizi",name:"玫瑰紫",color:"#BA2F7B"},{id:"shihong",name:"柿红",color:"#F2481B"},{id:"quhong",name:"紫云",color:"#B1A6CC"},{id:"shanchahong",name:"山茶红",color:"#F05A46"},{id:"zengqing",name:"曾青",color:"#535164"},{id:"roulan",name:"柔蓝",color:"#106898"}];function W(){return localStorage.getItem(_e)||"dark"}function tt(i){if(i!=="dark"&&i!=="light")return;document.documentElement.setAttribute("data-theme",i),localStorage.setItem(_e,i);const t=document.querySelector("[data-theme-toggle]");if(t){t.setAttribute("data-current-theme",i);const e=t.querySelector(".theme-icon");if(e){const s=e.src.substring(0,e.src.lastIndexOf("/")+1);e.src=i==="dark"?s+"sun.svg":s+"moon.svg"}}}function X(){return localStorage.getItem(ye)||"zengqing"}function et(i){const t=K.find(n=>n.id===i);if(!t)return;document.documentElement.setAttribute("data-brand",i),localStorage.setItem(ye,i);const e=document.querySelector("[data-brand-toggle]");if(e){e.setAttribute("data-current-brand",i);const n=e.querySelector(".brand-icon");n&&(n.style.backgroundColor=t.color);const r=e.querySelector(".brand-name");r&&(r.textContent=t.name)}document.querySelectorAll("[data-brand-btn]").forEach(n=>{n.getAttribute("data-brand-btn")===i?n.classList.add("is-active"):n.classList.remove("is-active")})}function ve(){const i=W();tt(i);const t=X();et(t);const e=document.querySelector("[data-theme-toggle]");e&&(e.onclick=function(l){l.preventDefault();const c=W()==="dark"?"light":"dark";tt(c)});let s=document.getElementById("brand-picker");s||(s=document.createElement("div"),s.id="brand-picker",s.style.position="fixed",s.style.top="64px",s.style.right="16px",s.style.zIndex="9998",s.style.display="none",s.style.padding="12px",s.style.width="200px",s.style.gridTemplateColumns="repeat(3, 1fr)",s.style.gap="6px",s.style.backgroundColor="var(--bg-base-secondary)",s.style.border="1px solid var(--border-neutral-l1)",s.style.borderRadius="8px",s.style.boxShadow="0 4px 20px rgba(0, 0, 0, 0.2)",s.style.overflow="hidden",K.forEach(l=>{const o=document.createElement("button");o.setAttribute("data-brand-btn",l.id),o.style.display="flex",o.style.justifyContent="center",o.style.alignItems="center",o.style.height="60px",o.style.backgroundColor=l.color,o.style.color=["#32F08C","#FF9900","#E2C027","#0EB0C9","#B1A6CC"].includes(l.color)?"#0C0C0D":"#FFFFFF",o.style.fontWeight="500",o.style.borderRadius="4px",o.style.border="none",o.style.cursor="pointer",o.style.margin="0",o.style.padding="0",o.textContent=l.name,s.appendChild(o)}),document.body.appendChild(s));const n=document.querySelector("[data-brand-toggle]");n&&s&&(n.onclick=function(l){l.stopPropagation(),l.preventDefault();const o=s.style.display==="none";s.style.display=o?"grid":"none",o?setTimeout(()=>{document.addEventListener("click",r,!0)},0):document.removeEventListener("click",r,!0)},s.onclick=function(l){l.stopPropagation()});function r(l){s&&n&&!s.contains(l.target)&&!n.contains(l.target)&&(s.style.display="none",document.removeEventListener("click",r,!0))}document.querySelectorAll("[data-brand-btn]").forEach(l=>{l.addEventListener("click",o=>{o.stopPropagation();const c=l.getAttribute("data-brand-btn");et(c),s&&(s.style.display="none")})})}function aa(){const i=document.createElement("button");i.setAttribute("data-theme-toggle",""),i.setAttribute("data-current-theme",W()),i.className="ds-btn ds-btn--ghost ds-btn--sm ds-btn--icon",i.style.position="fixed",i.style.top="16px",i.style.right="16px",i.style.zIndex="9999";const t=document.createElement("img");t.className="theme-icon";const e=document.getElementsByTagName("script"),s=e[e.length-1],n=s.src.substring(0,s.src.lastIndexOf("/")+1);return t.src=W()==="dark"?n+"../icons/sun.svg":n+"../icons/moon.svg",t.width=14,t.height=14,t.alt="Toggle theme",i.appendChild(t),document.body.appendChild(i),i.onclick=function(r){r.preventDefault();const l=W()==="dark"?"light":"dark";tt(l)},i}function la(){const i=document.createElement("div");i.id="brand-picker-auto",i.style.position="fixed",i.style.top="56px",i.style.right="16px",i.style.zIndex="9998",i.style.display="none",i.style.padding="12px",i.style.width="200px",i.style.gridTemplateColumns="repeat(3, 1fr)",i.style.gap="6px",i.style.backgroundColor="var(--bg-base-secondary)",i.style.border="1px solid var(--border-neutral-l1)",i.style.borderRadius="8px",i.style.boxShadow="0 4px 20px rgba(0, 0, 0, 0.2)",i.style.overflow="hidden",K.forEach(a=>{const l=document.createElement("button");l.setAttribute("data-brand-btn",a.id),l.style.display="flex",l.style.justifyContent="center",l.style.alignItems="center",l.style.height="60px",l.style.backgroundColor=a.color,l.style.color=["#32F08C","#FF9900","#E2C027","#0EB0C9","#B1A6CC"].includes(a.color)?"#0C0C0D":"#FFFFFF",l.style.fontWeight="500",l.style.borderRadius="4px",l.style.border="none",l.style.cursor="pointer",l.style.margin="0",l.style.padding="0",l.textContent=a.name,i.appendChild(l)}),document.body.appendChild(i);const t=document.createElement("button");t.setAttribute("data-brand-toggle",""),t.setAttribute("data-current-brand",X()),t.className="ds-btn ds-btn--ghost ds-btn--sm",t.style.position="fixed",t.style.top="16px",t.style.right="56px",t.style.zIndex="9999",t.style.display="flex",t.style.alignItems="center",t.style.gap="6px";const e=document.createElement("span");e.className="brand-icon",e.style.width="12px",e.style.height="12px",e.style.borderRadius="50%",e.style.backgroundColor=K.find(a=>a.id===X()).color;const s=document.createElement("span");s.className="brand-name",s.style.fontSize="11px",s.textContent=K.find(a=>a.id===X()).name,t.appendChild(e),t.appendChild(s),document.body.appendChild(t),t.onclick=function(a){a.stopPropagation(),a.preventDefault();const l=i.style.display==="none";i.style.display=l?"grid":"none",l?setTimeout(()=>{document.addEventListener("click",n,!0)},0):document.removeEventListener("click",n,!0)},i.onclick=function(a){a.stopPropagation()};function n(a){!i.contains(a.target)&&!t.contains(a.target)&&(i.style.display="none",document.removeEventListener("click",n,!0))}return i.querySelectorAll("[data-brand-btn]").forEach(a=>{a.addEventListener("click",l=>{l.stopPropagation();const o=a.getAttribute("data-brand-btn");et(o),i.style.display="none"})}),{toggleBtn:t,container:i}}class be{constructor(){this.initializers=new Map,this.cleanupFunctions=new Map,this.processedElements=new WeakSet,this._dataAttrs=["data-component"],this._cssClasses=[],this._cachedSelector=null}register(t,e,s=null,n={}){this.initializers.set(t,e),s&&this.cleanupFunctions.set(t,s),n.dataAttribute&&!this._dataAttrs.includes(n.dataAttribute)&&(this._dataAttrs.push(n.dataAttribute),this._cachedSelector=null),n.cssClass&&!this._cssClasses.includes(n.cssClass)&&(this._cssClasses.push(n.cssClass),this._cachedSelector=null)}unregister(t){this.initializers.delete(t),this.cleanupFunctions.delete(t)}has(t){return this.initializers.has(t)}get(t){return this.initializers.get(t)}_buildSelector(){if(this._cachedSelector!==null)return this._cachedSelector;const t=this._dataAttrs.map(e=>`[${e}]`);for(const e of this._cssClasses)t.push(`.${e}`);return this._cachedSelector=t.join(", "),this._cachedSelector}async initialize(t){if(this.processedElements.has(t))return;for(const s of this._dataAttrs){const n=t.getAttribute(s);if(n!==null){const r=n||s.replace("data-",""),a=this.initializers.get(r)||this.initializers.get(s.replace("data-",""));if(a){try{await a(t),this.processedElements.add(t)}catch(l){console.error(`[ComponentInitializerRegistry] Error initializing "${r}":`,l)}return}}}const e=t.className;if(typeof e=="string"){for(const s of this._cssClasses)if(e.includes(s)){const n=s.replace("ds-",""),r=this.initializers.get(n)||this.initializers.get(s);if(r){try{await r(t),this.processedElements.add(t)}catch(a){console.error(`[ComponentInitializerRegistry] Error initializing "${n}":`,a)}return}}}}cleanup(t){for(const s of this._dataAttrs){const n=t.getAttribute(s);if(n!==null){const r=n||s.replace("data-",""),a=this.cleanupFunctions.get(r)||this.cleanupFunctions.get(s.replace("data-",""));if(a){try{a(t)}catch(l){console.error(`[ComponentInitializerRegistry] Error cleaning up "${r}":`,l)}this.processedElements.delete(t);return}}}const e=t.className;if(typeof e=="string"){for(const s of this._cssClasses)if(e.includes(s)){const n=s.replace("ds-",""),r=this.cleanupFunctions.get(n)||this.cleanupFunctions.get(s);if(r){try{r(t)}catch(a){console.error(`[ComponentInitializerRegistry] Error cleaning up "${n}":`,a)}this.processedElements.delete(t);return}}}}async initializeAll(t=document){const e=this._buildSelector();if(!e)return;const s=t.querySelectorAll(e),n=[];s.forEach(r=>{this.processedElements.has(r)||n.push(this.initialize(r))}),await Promise.all(n)}}const w=new be,oa=[{attr:"data-dropdown",cls:"ds-dropdown"},{attr:"data-select",cls:"ds-select"},{attr:"data-datepicker",cls:"ds-datepicker"},{attr:"data-timepicker",cls:"ds-timepicker"},{attr:"data-slider",cls:"ds-slider"},{attr:"data-carousel",cls:"ds-carousel"},{attr:"data-drawer",cls:"ds-drawer"},{attr:"data-modal",cls:"ds-modal"},{attr:"data-dialog",cls:"ds-dialog"},{attr:"data-color-picker",cls:"ds-color-picker"},{attr:"data-calendar",cls:"ds-calendar"},{attr:"data-slide-captcha",cls:"ds-slide-captcha"},{attr:"data-heatmap",cls:"ds-heatmap"},{cls:"ds-tooltip"},{cls:"ds-tag"},{cls:"ds-statcard"},{cls:"ds-collapse"},{cls:"ds-fileupload"},{cls:"ds-notification"},{cls:"ds-message"}];for(const i of oa)i.attr&&!w._dataAttrs.includes(i.attr)&&w._dataAttrs.push(i.attr),i.cls&&!w._cssClasses.includes(i.cls)&&w._cssClasses.push(i.cls);class j{constructor(t){this.element=t,this.isMounted=!1,this.isDestroyed=!1,this.props=this._parseProps(),this.state={},this.slots=this._parseSlots(),this._eventListeners={},this._appliedMixins=[],this.lifecycle=new B,this.setupContext=null}_parseProps(){const t={};for(const e of this.element.attributes)if(e.name.startsWith("data-prop-")){const s=e.name.replace("data-prop-","");let n=e.value;try{n=JSON.parse(n)}catch{}t[s]=n}return t}_parseSlots(){const t={};return this.element.querySelectorAll("[data-slot]").forEach(s=>{const n=s.getAttribute("data-slot")||"default";t[n]=s.innerHTML.trim(),s.remove()}),!t.default&&this.element.children.length>0&&(t.default=this.element.innerHTML.trim()),t}$slot(t="default"){return this.slots[t]||""}$emit(t,e){if((this._eventListeners[t]||[]).forEach(n=>{try{n(e)}catch(r){console.error(`Error in event handler for ${t}:`,r)}}),this.element){const n=new CustomEvent(`kupola:${t}`,{detail:e,bubbles:!0,cancelable:!0});this.element.dispatchEvent(n)}}$on(t,e){return this._eventListeners[t]||(this._eventListeners[t]=[]),this._eventListeners[t].push(e),e}$off(t,e){this._eventListeners[t]&&(this._eventListeners[t]=this._eventListeners[t].filter(s=>s!==e))}async setProps(t){try{this.props={...this.props,...t},await this.lifecycle.update(),this.setupContext?._executeUpdated()}catch(e){console.error(`[KupolaComponent] Error in setProps for "${this.constructor.name}":`,e),this.lifecycle&&typeof this.lifecycle._handleError=="function"&&await this.lifecycle._handleError({phase:"update",hook:"setProps",error:e,args:[t]})}}async setState(t){try{this.state={...this.state,...t},await this.lifecycle.update(),this.setupContext?._executeUpdated()}catch(e){console.error(`[KupolaComponent] Error in setState for "${this.constructor.name}":`,e),this.lifecycle&&typeof this.lifecycle._handleError=="function"&&await this.lifecycle._handleError({phase:"update",hook:"setState",error:e,args:[t]})}}async mount(){if(!(this.isMounted||this.isDestroyed))try{if(this._bindLifecycleHooks(),await this.lifecycle.bootstrap(),typeof this.setup=="function"){const t=this.setup();t instanceof Promise&&await t}this.isMounted=!0,await this.lifecycle.mount(),this.setupContext?._executeMounted()}catch(t){if(console.error(`[KupolaComponent] Error mounting component "${this.constructor.name}":`,t),this.lifecycle&&typeof this.lifecycle._handleError=="function"&&await this.lifecycle._handleError({phase:"mount",hook:"component",error:t,args:[]}),typeof this.renderError=="function")try{this.renderError(t)}catch(e){console.error(`[KupolaComponent] Error in renderError for "${this.constructor.name}":`,e)}else this.element.innerHTML=`
1
+ (function(h,B){typeof exports=="object"&&typeof module<"u"?B(exports):typeof define=="function"&&define.amd?define(["exports"],B):(h=typeof globalThis<"u"?globalThis:h||self,B(h.Kupola={}))})(this,function(h){"use strict";class B{constructor(t="app"){this.scope=t,this.hooks=new Map,this.state="created",this.stateHistory=["created"],this.transitions=new Map([["created",["bootstrapped","destroyed"]],["bootstrapped",["mounted","destroyed"]],["mounted",["updated","unmounted","destroyed"]],["updated",["updated","unmounted","destroyed"]],["unmounted",["mounted","destroyed"]],["destroyed",[]]]),this.phaseStateMap={bootstrap:{from:"created",to:"bootstrapped"},mount:{from:["bootstrapped","unmounted"],to:"mounted"},update:{from:["mounted","updated"],to:"updated"},unmount:{from:["mounted","updated"],to:"unmounted"},destroy:{from:["bootstrapped","mounted","updated","unmounted"],to:"destroyed"}},this.basePhases=["bootstrap","mount","update","unmount","destroy"],this.allPhases=["error","errorBoundary"],this.basePhases.forEach(e=>{this.allPhases.push(`before${e.charAt(0).toUpperCase()+e.slice(1)}`),this.allPhases.push(e),this.allPhases.push(`after${e.charAt(0).toUpperCase()+e.slice(1)}`)}),this.allPhases.forEach(e=>{this.hooks.set(e,[])}),this.pendingHooks=new Set,this.trace=[],this.errorHandler=null,this.errorBoundary=null,this.lastError=null,this.errorCount=0,this.maxErrors=10,this._onErrorCallback=null}_validateTransition(t){const e=this.transitions.get(this.state);if(!e||!e.includes(t))throw new Error(`Invalid state transition: ${this.state} -> ${t}`);return!0}_updateState(t){this._validateTransition(t),this.state=t,this.stateHistory.push(t)}_resetResolved(t){const e=this.hooks.get(t);e&&e.forEach(s=>{s.resolved=!1})}on(t,e,s={}){if(!this.allPhases.includes(t))throw new Error(`Unknown lifecycle phase: ${t}`);const n=this.hooks.get(t);return n.push({handler:e,priority:s.priority||0,depends:s.depends||[],name:s.name||e.name||`anonymous_${n.length}`}),n.sort((r,a)=>a.priority-r.priority),()=>{const r=n.findIndex(a=>a.handler===e);r>-1&&n.splice(r,1)}}async _resolveDepends(t,e){if(!(!t||t.length===0))for(const s of t){const r=this.hooks.get(e).find(a=>a.name===s);r&&!r.resolved&&(await r.handler(),r.resolved=!0)}}async emit(t,...e){if(this.state==="destroyed"&&t!=="error")return;const s=this.hooks.get(t);if(!s||s.length===0)return;const n=`${t}-${Date.now()}-${Math.random().toString(36).substr(2,9)}`;this.pendingHooks.add(n);const r=performance.now();try{for(const l of s){await this._resolveDepends(l.depends,t);const o=performance.now();let c,d;try{c=l.handler(...e),c instanceof Promise&&await c,l.resolved=!0}catch(p){d=p,console.error(`[KupolaLifecycle] Error in ${t} hook "${l.name}":`,p),t!=="error"&&await this._handleError({phase:t,hook:l.name,error:p,args:e})}const u=performance.now()-o;this.trace.push({emitId:n,phase:t,hookName:l.name,duration:u,status:d?"error":"success",error:d?d.message:null,timestamp:Date.now()})}const a=performance.now()-r;console.debug(`[KupolaLifecycle] ${t} completed in ${a.toFixed(2)}ms (${this.scope})`)}finally{this.pendingHooks.delete(n)}}async runPhase(t,...e){if(!this.basePhases.includes(t))throw new Error(`Unknown base phase: ${t}`);const s=this.phaseStateMap[t];if(s){if(Array.isArray(s.from)){if(!s.from.includes(this.state))throw new Error(`Cannot ${t} from state ${this.state}, expected one of: ${s.from.join(", ")}`)}else if(this.state!==s.from)throw new Error(`Cannot ${t} from state ${this.state}, expected ${s.from}`)}const n=`before${t.charAt(0).toUpperCase()+t.slice(1)}`,r=`after${t.charAt(0).toUpperCase()+t.slice(1)}`;this._resetResolved(n),this._resetResolved(t),this._resetResolved(r),this.allPhases.includes(n)&&await this.emit(n,...e),await this.emit(t,...e),s&&this._updateState(s.to),this.allPhases.includes(r)&&await this.emit(r,...e)}async bootstrap(...t){await this.runPhase("bootstrap",...t)}async _waitForDOMReady(){return new Promise(t=>{if(document.readyState==="complete"||document.readyState==="interactive"){t();return}const e=()=>{document.removeEventListener("DOMContentLoaded",e),window.removeEventListener("load",e),t()};document.addEventListener("DOMContentLoaded",e),window.addEventListener("load",e)})}async mount(...t){await this.runPhase("mount",...t)}async mountWithDOMReady(...t){await this._waitForDOMReady(),await this.runPhase("mount",...t)}async update(...t){await this.runPhase("update",...t)}async unmount(...t){await this.runPhase("unmount",...t)}async destroy(...t){await this.runPhase("destroy",...t),this.hooks.forEach(e=>{e.length=0})}getPhaseHandlers(t){return this.hooks.get(t)||[]}hasHandlers(t){const e=this.hooks.get(t);return e&&e.length>0}getTrace(){return[...this.trace]}clearTrace(){this.trace=[]}getState(){return this.state}getStateHistory(){return[...this.stateHistory]}isInState(t){return this.state===t}onError(t){return this._onErrorCallback=t,this.on("error",t)}setErrorBoundary(t){return this.errorBoundary=t,this.on("errorBoundary",e=>typeof t=="function"?t(e):null)}setMaxErrors(t){this.maxErrors=t}getErrorCount(){return this.errorCount}getLastError(){return this.lastError}resetErrorCount(){this.errorCount=0,this.lastError=null}async _handleError(t){if(this.errorCount++,this.lastError=t.error,this.errorCount>=this.maxErrors){console.error(`[KupolaLifecycle] Error limit reached (${this.maxErrors}), stopping error handling`);return}if(await this.emit("error",t),typeof this._onErrorCallback=="function")try{await this._onErrorCallback(t)}catch(s){console.error("[KupolaLifecycle] Error in onError callback:",s)}const e=this.hooks.get("errorBoundary");if(e&&e.length>0)for(const s of e)try{const n=s.handler(t);if(n instanceof Promise&&await n,n==="handled"){console.debug(`[KupolaLifecycle] Error handled by errorBoundary hook "${s.name}"`);return}}catch(n){console.error(`[KupolaLifecycle] Error in errorBoundary hook "${s.name}":`,n)}console.error(`[KupolaLifecycle] Unhandled error in ${t.phase}:`,t.error)}}const Ms=new B("app");function Ts(i="app"){return new B(i)}const Is=new Set(["__proto__","prototype","constructor"]);function J(i){return Is.has(i)}function As(i){return i?i.trim():""}function zs(i){return i?i.replace(/^\s+/,""):""}function Ps(i){return i?i.replace(/\s+$/,""):""}function $s(i){return i?i.toUpperCase():""}function qs(i){return i?i.toLowerCase():""}function Bs(i){return i?i.charAt(0).toUpperCase()+i.slice(1):""}function Fs(i){return i?i.replace(/-(\w)/g,(t,e)=>e?e.toUpperCase():""):""}function Ns(i){return i?i.replace(/([A-Z])/g,"-$1").toLowerCase().replace(/^-/,""):""}function Os(i,t,e=" "){return(String(i)||"").padStart(t,e)}function Rs(i,t,e=" "){return(String(i)||"").padEnd(t,e)}function Vs(i,t,e="..."){return!i||i.length<=t?i||"":i.slice(0,t)+e}function Ks(i,t,e){return i?i.split(t).join(e):""}function Ws(i,t){return i?i.replace(/\{\{(\w+)\}\}/g,(e,s)=>t[s]!==void 0?t[s]:`{{${s}}}`):""}function Us(i,t){return(i||"").startsWith(t)}function Ys(i,t){return(i||"").endsWith(t)}function Xs(i,t){return(i||"").includes(t)}function js(i,t){return(i||"").repeat(t)}function Js(i){return(i||"").split("").reverse().join("")}function Gs(i,t){return!i||!t?0:i.split(t).length-1}function Zs(i){if(!i)return"";const t=document.createElement("div");return t.textContent=i,t.innerHTML}function Qs(i){if(!i)return"";const t=document.createElement("div");return t.innerHTML=i,t.textContent}function ti(i=8){const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";let e="";for(let s=0;s<i;s++)e+=t.charAt(Math.floor(Math.random()*t.length));return e}function ei(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,i=>{const t=Math.random()*16|0;return(i==="x"?t:t&3|8).toString(16)})}const Ot={trim:As,trimLeft:zs,trimRight:Ps,toUpperCase:$s,toLowerCase:qs,capitalize:Bs,camelize:Fs,hyphenate:Ns,padStart:Os,padEnd:Rs,truncate:Vs,replaceAll:Ks,format:Ws,startsWith:Us,endsWith:Ys,includes:Xs,repeat:js,reverse:Js,countOccurrences:Gs,escapeHtml:Zs,unescapeHtml:Qs,generateRandom:ti,generateUUID:ei};function si(i){return Array.isArray(i)}function ii(i){return!i||i.length===0}function ni(i){return i?i.length:0}function ri(i,t){return i&&i.length>0?i[0]:t}function ai(i,t){return i&&i.length>0?i[i.length-1]:t}function li(i,t,e){return i&&i[t]!==void 0?i[t]:e}function oi(i,t,e){return i?i.slice(t,e):[]}function ci(...i){return i.reduce((t,e)=>t.concat(e||[]),[])}function hi(i,t=","){return i?i.join(t):""}function di(i,t,e=0){if(!i)return-1;if(Number.isNaN(t)){for(let s=e;s<i.length;s++)if(Number.isNaN(i[s]))return s;return-1}return i.indexOf(t,e)}function ui(i,t,e){if(!i)return-1;if(Number.isNaN(t)){const s=e!==void 0?e:i.length-1;for(let n=s;n>=0;n--)if(Number.isNaN(i[n]))return n;return-1}return i.lastIndexOf(t,e)}function pi(i,t){return i?i.includes(t):!1}function fi(i,...t){return i&&i.push(...t),i}function mi(i){return i?i.pop():void 0}function gi(i){return i?i.shift():void 0}function _i(i,...t){return i&&i.unshift(...t),i}function yi(i,t){if(!i)return i;const e=Number.isNaN(t)?i.findIndex(s=>Number.isNaN(s)):i.indexOf(t);return e>-1&&i.splice(e,1),i}function vi(i,t){return!i||t<0||t>=i.length||i.splice(t,1),i}function bi(i,t,e){return i&&(i.splice(t,0,e),i)}function Ei(i){return i?i.slice().reverse():[]}function ki(i,t){return i?i.slice().sort(t):[]}function wi(i,t,e="asc"){return i?i.slice().sort((s,n)=>{const r=typeof s=="object"?s[t]:s,a=typeof n=="object"?n[t]:n;return r<a?e==="asc"?-1:1:r>a?e==="asc"?1:-1:0}):[]}function xi(i,t){return i?i.filter(t):[]}function Ci(i,t){return i?i.map(t):[]}function Si(i,t,e){return i?i.reduce(t,e):e}function Li(i,t){i&&i.forEach(t)}function Di(i,t){return i?i.every(t):!0}function Hi(i,t){return i?i.some(t):!1}function Mi(i,t){return i?i.find(t):void 0}function Ti(i,t){return i?i.findIndex(t):-1}function Ii(i,t=1){return i?i.flat(t):[]}function Rt(i){return i?i.reduce((t,e)=>Array.isArray(e)?t.concat(Rt(e)):t.concat(e),[]):[]}function Ai(i){return i?[...new Set(i)]:[]}function zi(i,t){if(!i)return[];const e=new Set;return i.filter(s=>{const n=typeof s=="object"?s[t]:s;return e.has(n)?!1:(e.add(n),!0)})}function Pi(i,t){if(!i||t<=0)return[];const e=[];for(let s=0;s<i.length;s+=t)e.push(i.slice(s,s+t));return e}function $i(i){if(!i)return[];const t=i.slice();for(let e=t.length-1;e>0;e--){const s=Math.floor(Math.random()*(e+1));[t[e],t[s]]=[t[s],t[e]]}return t}function Vt(i){return i?i.reduce((t,e)=>t+(Number(e)||0),0):0}function qi(i){return!i||i.length===0?0:Vt(i)/i.length}function Bi(i){return i&&i.length>0?Math.max(...i):-1/0}function Fi(i){return i&&i.length>0?Math.min(...i):1/0}function Ni(...i){return i.length===0?[]:i.reduce((t,e)=>t.filter(s=>e&&e.includes(s)))}function Oi(...i){return[...new Set(i.flat().filter(Boolean))]}function Ri(i,t){return i?i.filter(e=>!t||!t.includes(e)):[]}function Vi(...i){if(i.length===0)return[];const t=Math.max(...i.map(e=>e?e.length:0));return Array.from({length:t},(e,s)=>i.map(n=>n&&n[s]))}const Kt={isArray:si,isEmpty:ii,size:ni,first:ri,last:ai,get:li,slice:oi,concat:ci,join:hi,indexOf:di,lastIndexOf:ui,includes:pi,push:fi,pop:mi,shift:gi,unshift:_i,remove:yi,removeAt:vi,insert:bi,reverse:Ei,sort:ki,sortBy:wi,filter:xi,map:Ci,reduce:Si,forEach:Li,every:Di,some:Hi,find:Mi,findIndex:Ti,flat:Ii,flattenDeep:Rt,unique:Ai,uniqueBy:zi,chunk:Pi,shuffle:$i,sum:Vt,average:qi,max:Bi,min:Fi,intersection:Ni,union:Oi,difference:Ri,zip:Vi};function rt(i){return i!==null&&typeof i=="object"&&!Array.isArray(i)}function Ki(i){return!i||typeof i!="object"?!0:Object.keys(i).length===0}function Wi(i){return i?Object.keys(i):[]}function Ui(i){return i?Object.values(i):[]}function Yi(i){return i?Object.entries(i):[]}function Xi(i,t){return i?Object.prototype.hasOwnProperty.call(i,t):!1}function ji(i,t,e){if(!i)return e;const s=t.split(".");return s.some(J)?e:s.reduce((n,r)=>n&&n[r],i)??e}function Ji(i,t,e){if(!i||typeof i!="object")return i;const s=t.split(".");if(s.some(J))return i;const n=s.pop();let r=i;return s.forEach(a=>{(!r[a]||typeof r[a]!="object")&&(r[a]={}),r=r[a]}),r[n]=e,i}function Gi(i,t){return i?t.reduce((e,s)=>(i[s]!==void 0&&(e[s]=i[s]),e),{}):{}}function Zi(i,t){return i?Object.keys(i).reduce((e,s)=>(t.includes(s)||(e[s]=i[s]),e),{}):{}}function Wt(...i){return i.reduce((t,e)=>(e&&typeof e=="object"&&Object.keys(e).forEach(s=>{J(s)||(rt(e[s])&&rt(t[s])?t[s]=Wt(t[s],e[s]):t[s]=e[s])}),t),{})}function Qi(i){return i&&JSON.parse(JSON.stringify(i))}function Y(i,t=new WeakMap){if(!i||typeof i!="object")return i;if(t.has(i))return t.get(i);if(i instanceof Date)return new Date(i);if(i instanceof RegExp)return new RegExp(i);if(i instanceof Map){const s=new Map;return t.set(i,s),i.forEach((n,r)=>s.set(r,Y(n,t))),s}if(i instanceof Set){const s=new Set;return t.set(i,s),i.forEach(n=>s.add(Y(n,t))),s}if(Array.isArray(i)){const s=[];return t.set(i,s),i.forEach(n=>s.push(Y(n,t))),s}const e={};return t.set(i,e),Object.keys(i).forEach(s=>{J(s)||(e[s]=Y(i[s],t))}),e}function tn(i,t){i&&Object.keys(i).forEach(e=>t(i[e],e,i))}function en(i,t){if(!i)return{};const e={};return Object.keys(i).forEach(s=>{e[s]=t(i[s],s,i)}),e}function sn(i,t){if(!i)return{};const e={};return Object.keys(i).forEach(s=>{t(i[s],s,i)&&(e[s]=i[s])}),e}function nn(i,t,e){return i?Object.keys(i).reduce((s,n)=>t(s,i[n],n,i),e):e}function rn(i){return i?Object.keys(i).map(t=>({key:t,value:i[t]})):[]}function an(i,t,e){return i?i.reduce((s,n)=>{const r=typeof n=="object"?n[t]:n,a=e?n[e]:n;return r!==void 0&&(s[r]=a),s},{}):{}}function ln(i){return i?Object.keys(i).length:0}function on(i){if(!i)return{};const t={};return Object.keys(i).forEach(e=>{t[i[e]]=e}),t}function Ut(i,t){if(i===t)return!0;if(!i||!t||typeof i!="object"||typeof t!="object")return!1;const e=Object.keys(i),s=Object.keys(t);return e.length!==s.length?!1:e.every(n=>Ut(i[n],t[n]))}function Yt(i){return i&&(Object.freeze(i),Object.keys(i).forEach(t=>{typeof i[t]=="object"&&Yt(i[t])}),i)}function cn(i){return i&&Object.seal(i)}const Xt={isObject:rt,isEmpty:Ki,keys:Wi,values:Ui,entries:Yi,has:Xi,get:ji,set:Ji,pick:Gi,omit:Zi,merge:Wt,clone:Qi,deepClone:Y,forEach:tn,map:en,filter:sn,reduce:nn,toArray:rn,fromArray:an,size:ln,invert:on,isEqual:Ut,freeze:Yt,seal:cn};function L(i){return typeof i=="number"&&!isNaN(i)}function hn(i){return Number.isInteger(i)}function dn(i){return L(i)&&!Number.isInteger(i)}function un(i){return L(i)&&i>0}function pn(i){return L(i)&&i<0}function fn(i){return L(i)&&i===0}function mn(i,t,e){return L(i)?Math.min(Math.max(i,t),e):i}function gn(i,t=0){if(!L(i))return i;const e=Math.pow(10,t);return Math.round(i*e)/e}function _n(i){return L(i)?Math.floor(i):i}function yn(i){return L(i)?Math.ceil(i):i}function vn(i){return L(i)?Math.abs(i):i}function bn(...i){const t=i.filter(L);return t.length>0?Math.min(...t):void 0}function En(...i){const t=i.filter(L);return t.length>0?Math.max(...t):void 0}function jt(...i){return i.flat().filter(L).reduce((e,s)=>e+s,0)}function kn(...i){const t=i.flat().filter(L);return t.length>0?jt(t)/t.length:0}function Jt(i=0,t=1){return Math.random()*(t-i)+i}function wn(i,t){return Math.floor(Jt(i,t+1))}function xn(i,t=2){return L(i)?i.toFixed(t):String(i)}function Cn(i,t="CNY",e=2){return L(i)?new Intl.NumberFormat("zh-CN",{style:"currency",currency:t,minimumFractionDigits:e,maximumFractionDigits:e}).format(i):String(i)}function Sn(i,t=0){return L(i)?`${(i*100).toFixed(t)}%`:String(i)}function Ln(i,t=0){return L(i)?i.toFixed(t):String(i)}function Dn(i,t=6){return L(i)?i.toPrecision(t):String(i)}function Hn(i){return Number.isNaN(i)}function Mn(i){return Number.isFinite(i)}function Tn(i,t=10){return Number.parseInt(i,t)}function In(i){return Number.parseFloat(i)}function An(i,t=0){const e=Number(i);return isNaN(e)?t:e}function zn(i,t,e=0){return!L(i)||!L(t)||t===0?e:i/t}function Pn(...i){return i.reduce((t,e)=>!L(t)||!L(e)?0:t*e,1)}const Gt={isNumber:L,isInteger:hn,isFloat:dn,isPositive:un,isNegative:pn,isZero:fn,clamp:mn,round:gn,floor:_n,ceil:yn,abs:vn,min:bn,max:En,sum:jt,average:kn,random:Jt,randomInt:wn,format:xn,formatCurrency:Cn,formatPercent:Sn,toFixed:Ln,toPrecision:Dn,isNaN:Hn,isFinite:Mn,parseInt:Tn,parseFloat:In,toNumber:An,safeDivide:zn,safeMultiply:Pn};function G(){return Date.now()}function V(){const i=new Date;return i.setHours(0,0,0,0),i}function $n(){const i=V();return i.setDate(i.getDate()+1),i}function qn(){const i=V();return i.setDate(i.getDate()-1),i}function x(i){return i instanceof Date&&!isNaN(i.getTime())}function Zt(i){return x(i)}function Bn(i){const t=new Date(i);return Zt(t)?t:null}function Fn(i,t="YYYY-MM-DD HH:mm:ss"){if(!x(i))return"";const e=i.getFullYear(),s=String(i.getMonth()+1).padStart(2,"0"),n=String(i.getDate()).padStart(2,"0"),r=String(i.getHours()).padStart(2,"0"),a=String(i.getMinutes()).padStart(2,"0"),l=String(i.getSeconds()).padStart(2,"0"),o=String(i.getMilliseconds()).padStart(3,"0"),d=["日","一","二","三","四","五","六"][i.getDay()];return t.replace("YYYY",e).replace("MM",s).replace("DD",n).replace("HH",r).replace("mm",a).replace("ss",l).replace("SSS",o).replace("D",i.getDate()).replace("M",i.getMonth()+1).replace("H",i.getHours()).replace("m",i.getMinutes()).replace("s",i.getSeconds()).replace("W",d)}function Nn(i){return x(i)?i.toISOString():""}function On(i){return x(i)?new Date(i.toUTCString()):null}function Rn(i,t){if(!x(i))return i;const e=new Date(i);return e.setDate(e.getDate()+t),e}function Vn(i,t){if(!x(i))return i;const e=new Date(i);return e.setHours(e.getHours()+t),e}function Kn(i,t){if(!x(i))return i;const e=new Date(i);return e.setMinutes(e.getMinutes()+t),e}function Wn(i,t){if(!x(i))return i;const e=new Date(i);return e.setSeconds(e.getSeconds()+t),e}function Z(i,t){if(!x(i)||!x(t))return 0;const e=new Date(i);e.setHours(0,0,0,0);const s=new Date(t);return s.setHours(0,0,0,0),Math.floor((e.getTime()-s.getTime())/(1e3*60*60*24))}function Un(i,t){return!x(i)||!x(t)?0:Math.floor((i.getTime()-t.getTime())/(1e3*60*60))}function Yn(i,t){return!x(i)||!x(t)?0:Math.floor((i.getTime()-t.getTime())/(1e3*60))}function Xn(i,t){return!x(i)||!x(t)?0:Math.floor((i.getTime()-t.getTime())/1e3)}function jn(i){return x(i)?Z(i,V())===0:!1}function Jn(i){return x(i)?Z(i,V())===-1:!1}function Gn(i){return x(i)?Z(i,V())===1:!1}function Zn(i){return x(i)?i.getTime()>G():!1}function Qn(i){return x(i)?i.getTime()<G():!1}function tr(i){if(!x(i))return!1;const t=i.getFullYear();return t%4===0&&(t%100!==0||t%400===0)}function er(i){return x(i)?new Date(i.getFullYear(),i.getMonth()+1,0).getDate():0}function sr(i){if(!x(i))return 0;const t=new Date(i.getFullYear(),0,1),e=i.getTime()-t.getTime();return Math.ceil(e/(1e3*60*60*24*7))}function ir(i){return x(i)?Math.ceil((i.getMonth()+1)/3):0}function nr(i){if(!x(i))return i;const t=new Date(i);return t.setHours(0,0,0,0),t}function rr(i){if(!x(i))return i;const t=new Date(i);return t.setHours(23,59,59,999),t}function ar(i){return x(i)?new Date(i.getFullYear(),i.getMonth(),1):i}function lr(i){return x(i)?new Date(i.getFullYear(),i.getMonth()+1,0,23,59,59,999):i}function Qt(i,t=1){if(!x(i))return i;const e=new Date(i),s=e.getDay(),n=s>=t?s-t:s+(7-t);return e.setDate(e.getDate()-n),e.setHours(0,0,0,0),e}function or(i,t=1){if(!x(i))return i;const e=Qt(i,t),s=new Date(e);return s.setDate(s.getDate()+6),s.setHours(23,59,59,999),s}function cr(i){if(!x(i))return 0;const t=new Date;let e=t.getFullYear()-i.getFullYear();return(t.getMonth()<i.getMonth()||t.getMonth()===i.getMonth()&&t.getDate()<i.getDate())&&e--,Math.max(0,e)}function hr(i){if(!x(i))return"";const e=G()-i.getTime(),s=60*1e3,n=60*s,r=24*n,a=7*r,l=30*r,o=365*r;return e<s?"刚刚":e<n?`${Math.floor(e/s)}分钟前`:e<r?`${Math.floor(e/n)}小时前`:e<a?`${Math.floor(e/r)}天前`:e<l?`${Math.floor(e/a)}周前`:e<o?`${Math.floor(e/l)}个月前`:`${Math.floor(e/o)}年前`}const te={now:G,today:V,tomorrow:$n,yesterday:qn,isDate:x,isValid:Zt,parse:Bn,format:Fn,toISO:Nn,toUTC:On,addDays:Rn,addHours:Vn,addMinutes:Kn,addSeconds:Wn,diffDays:Z,diffHours:Un,diffMinutes:Yn,diffSeconds:Xn,isToday:jn,isYesterday:Jn,isTomorrow:Gn,isFuture:Zn,isPast:Qn,isLeapYear:tr,getDaysInMonth:er,getWeekOfYear:sr,getQuarter:ir,startOfDay:nr,endOfDay:rr,startOfMonth:ar,endOfMonth:lr,startOfWeek:Qt,endOfWeek:or,getAge:cr,fromNow:hr};function ee(i,t,e={}){let s=null,n=null,r=null,a=0;const l=e.leading||!1,o=e.trailing!==!1;function c(){i.apply(r,n)}function d(){a=Date.now(),l?(s=setTimeout(u,t),c()):s=setTimeout(u,t)}function u(){s=null,o&&n&&c(),n=null,r=null}function p(){return Math.max(0,t-(Date.now()-a))}return function(...m){n=m,r=this,a=Date.now(),s?(clearTimeout(s),s=setTimeout(u,p())):d()}}function se(i,t,e={}){let s=!1;const n=e.trailing||!1;let r=null,a=null;function l(){i.apply(a,r),r=null,a=null}return function(...o){s?n&&(r=o,a=this):(s=!0,r=o,a=this,l(),setTimeout(()=>{s=!1,n&&r&&l()},t))}}function dr(i){return/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(i||"")}function ur(i){return/^1[3-9]\d{9}$/.test(i||"")}function pr(i){return/^(https?:\/\/)?([\da-z.-]+)\.([a-z.]{2,6})([/\w.-]*)*\/?$/.test(i||"")}function ie(i){return/^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/.test(i||"")}function ne(i){return/^([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$/.test(i||"")}function fr(i){return ie(i)||ne(i)}function mr(i){return/^[1-9]\d{5}(18|19|20)\d{2}(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])\d{3}[\dXx]$/.test(i||"")}function gr(i){return/^[A-Z][0-9]{8}$|^[A-Z]{2}[0-9]{7}$/.test(i||"")}function _r(i){const t=/^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|6(?:011|5[0-9]{2})[0-9]{12}|3[47][0-9]{13})$/,e=i.replace(/\s/g,"");if(!t.test(e))return!1;let s=0,n=!1;for(let r=e.length-1;r>=0;r--){let a=parseInt(e[r],10);n&&(a*=2,a>9&&(a-=9)),s+=a,n=!n}return s%10===0}function re(i){return/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/.test(i||"")}function ae(i){const t=/^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/.exec(i||"");return t?t.slice(1).every(e=>parseInt(e)>=0&&parseInt(e)<=255):!1}function le(i){const t=/^rgba\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3}),\s*([01]|0\.\d+)\)$/.exec(i||"");if(!t)return!1;const[,e,s,n,r]=t;return parseInt(e)>=0&&parseInt(e)<=255&&parseInt(s)>=0&&parseInt(s)<=255&&parseInt(n)>=0&&parseInt(n)<=255&&parseFloat(r)>=0&&parseFloat(r)<=1}function yr(i){return re(i)||ae(i)||le(i)}function vr(i){return!isNaN(new Date(i).getTime())}function br(i){try{return JSON.parse(i),!0}catch{return!1}}function Er(i){return!i||i.trim()===""}function kr(i){return/^\s+$/.test(i||"")}function wr(i){return!isNaN(parseFloat(i))&&isFinite(i)}function xr(i){return/^-?\d+$/.test(i||"")}function Cr(i){return/^-?\d+\.\d+$/.test(i||"")}function Sr(i){const t=parseFloat(i);return!isNaN(t)&&t>0}function Lr(i){const t=parseFloat(i);return!isNaN(t)&&t<0}function Dr(i){return/^[a-zA-Z]+$/.test(i||"")}function Hr(i){return/^[a-zA-Z0-9]+$/.test(i||"")}function Mr(i){return/^[\u4e00-\u9fa5]+$/.test(i||"")}function Tr(i,t,e){const s=(i||"").length;return s>=t&&(e===void 0||s<=e)}function Ir(i,t){return(i||"").length>=t}function Ar(i,t){return(i||"").length<=t}function zr(i,t){return t instanceof RegExp?t.test(i||""):!1}function Pr(i,t){return String(i)===String(t)}function oe(i,t){return(i||"").includes(t)}function $r(i,t){return!oe(i,t)}function qr(i){return Array.isArray(i)}function Br(i,t,e){const s=i?i.length:0;return s>=t&&(e===void 0||s<=e)}function Fr(i,t){return i?i.length>=t:!1}function Nr(i,t){return i?i.length<=t:!1}function Or(i){return i!==null&&typeof i=="object"&&!Array.isArray(i)}function Rr(i,t){return!i||!t||!Array.isArray(t)?!1:t.every(e=>Object.prototype.hasOwnProperty.call(i,e))}function Vr(i,t){const e={};return Object.keys(t).forEach(s=>{const n=i[s],r=t[s],a=[];r.forEach(l=>{if(typeof l=="string"){const[o,...c]=l.split(":");at[o](n,...c)||a.push(o)}else if(typeof l=="function"){const o=l(n,i);o!==!0&&a.push(o||"validation_failed")}}),a.length>0&&(e[s]=a)}),{valid:Object.keys(e).length===0,errors:e}}const at={isEmail:dr,isPhone:ur,isURL:pr,isIPv4:ie,isIPv6:ne,isIP:fr,isIDCard:mr,isPassport:gr,isCreditCard:_r,isHexColor:re,isRGB:ae,isRGBA:le,isColor:yr,isDate:vr,isJSON:br,isEmpty:Er,isWhitespace:kr,isNumber:wr,isInteger:xr,isFloat:Cr,isPositive:Sr,isNegative:Lr,isAlpha:Dr,isAlphaNumeric:Hr,isChinese:Mr,isLength:Tr,minLength:Ir,maxLength:Ar,matches:zr,equals:Pr,contains:oe,notContains:$r,isArray:qr,arrayLength:Br,arrayMinLength:Fr,arrayMaxLength:Nr,isObject:Or,hasKeys:Rr,validate:Vr};function Kr(i){const t=i?String(i):"",e=[1732584193,4023233417,2562383102,271733878],s=[3614090360,3905402710,606105819,3250441966,4118548399,1200080426,2821735955,4249261313,1770035416,2336552879,4294925233,2304563134,1804603682,4254626195,2792965006,1236535329,4129170786,3225465664,643717713,3921069994,3593408605,38016083,3634488961,3889429448,568446438,3275163606,4107603335,1163531501,2850285829,4243563512,1735328473,2368359562,4294588738,2272392833,1839030562,4259657740,2763975236,1272893353,4139469664,3200236656,681279174,3936430074,3572445317,76029189,3654602809,3873151461,530742520,3299628645,4096336452,1126891415,2878612391,4237533241,1700485571,2399980690,4293915773,2240044497,1873313359,4264355552,2734768916,1309151649,4149444226,3174756917,718787259,3951481745],n=[[7,12,17,22],[5,9,14,20],[4,11,16,23],[6,10,15,21]];function r(u,p){return u<<p|u>>>32-p}function a(u){const p=u.length*8;for(u+="€";u.length%64!==56;)u+="\0";const m=p&4294967295,f=p>>>32&4294967295;for(let g=0;g<4;g++)u+=String.fromCharCode(m>>>8*g&255);for(let g=0;g<4;g++)u+=String.fromCharCode(f>>>8*g&255);return u}function l(u,p){const[m,f,g,v]=p,y=[];for(let D=0;D<16;D++)y[D]=u.charCodeAt(D*4)&255|(u.charCodeAt(D*4+1)&255)<<8|(u.charCodeAt(D*4+2)&255)<<16|(u.charCodeAt(D*4+3)&255)<<24;let k=m,E=f,b=g,C=v;for(let D=0;D<64;D++){let S,H;const A=Math.floor(D/16),$=D%16;A===0?(S=E&b|~E&C,H=$):A===1?(S=C&E|~C&b,H=(5*$+1)%16):A===2?(S=E^b^C,H=(3*$+5)%16):(S=b^(E|~C),H=7*$%16);const O=C;C=b,b=E,E=E+r(k+S+s[D]+y[H]&4294967295,n[A][D%4]),k=O}return[m+k&4294967295,f+E&4294967295,g+b&4294967295,v+C&4294967295]}const o=a(t);let c=[...e];for(let u=0;u<o.length;u+=64)c=l(o.substring(u,u+64),c);let d="";return c.forEach(u=>{for(let p=0;p<4;p++)d+=(u>>>8*p&255).toString(16).padStart(2,"0")}),d}function Wr(i){const t=i?String(i):"",e=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];function s(c,d){return c>>>d|c<<32-d}function n(c){const d=c.length*8;for(c+="€";c.length%64!==56;)c+="\0";const u=d&4294967295,p=d>>>32&4294967295;for(let m=0;m<4;m++)c+=String.fromCharCode(p>>>8*m&255);for(let m=0;m<4;m++)c+=String.fromCharCode(u>>>8*m&255);return c}function r(c,d){const u=[];for(let b=0;b<16;b++)u[b]=c.charCodeAt(b*4)&255|(c.charCodeAt(b*4+1)&255)<<8|(c.charCodeAt(b*4+2)&255)<<16|(c.charCodeAt(b*4+3)&255)<<24;for(let b=16;b<64;b++){const C=s(u[b-15],7)^s(u[b-15],18)^u[b-15]>>>3,D=s(u[b-2],17)^s(u[b-2],19)^u[b-2]>>>10;u[b]=u[b-16]+C+u[b-7]+D&4294967295}let[p,m,f,g,v,y,k,E]=d;for(let b=0;b<64;b++){const C=s(v,6)^s(v,11)^s(v,25),D=v&y^~v&k,S=E+C+D+e[b]+u[b]&4294967295,H=s(p,2)^s(p,13)^s(p,22),A=p&m^p&f^m&f,$=H+A&4294967295;E=k,k=y,y=v,v=g+S&4294967295,g=f,f=m,m=p,p=S+$&4294967295}return[d[0]+p&4294967295,d[1]+m&4294967295,d[2]+f&4294967295,d[3]+g&4294967295,d[4]+v&4294967295,d[5]+y&4294967295,d[6]+k&4294967295,d[7]+E&4294967295]}const a=n(t);let l=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225];for(let c=0;c<a.length;c+=64)l=r(a.substring(c,c+64),l);let o="";return l.forEach(c=>{for(let d=3;d>=0;d--)o+=(c>>>8*d&255).toString(16).padStart(2,"0")}),o}function Ur(i){const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";let e="",s=0;const n=i?i.split("").map(r=>r.charCodeAt(0)):[];for(;s<n.length;){const r=n[s++],a=n[s++]||0,l=n[s++]||0,o=r>>2,c=(r&3)<<4|a>>4,d=(a&15)<<2|l>>6,u=l&63;e+=t[o]+t[c]+(s>n.length+1?"=":t[d])+(s>n.length?"=":t[u])}return e}function Yr(i){const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";let e="",s=0;for(i=i.replace(/[^A-Za-z0-9+/=]/g,"");s<i.length;){const n=t.indexOf(i.charAt(s++)),r=t.indexOf(i.charAt(s++)),a=t.indexOf(i.charAt(s++)),l=t.indexOf(i.charAt(s++)),o=n<<2|r>>4,c=(r&15)<<4|a>>2,d=(a&3)<<6|l;e+=String.fromCharCode(o),a!==64&&(e+=String.fromCharCode(c)),l!==64&&(e+=String.fromCharCode(d))}return e}function Xr(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,i=>{const t=Math.random()*16|0;return(i==="x"?t:t&3|8).toString(16)})}const ce={md5:Kr,sha256:Wr,base64Encode:Ur,base64Decode:Yr,uuid:Xr},P=new Map;async function Q(i,t={}){const{crossOrigin:e="anonymous"}=t;return P.has(i)?P.get(i):new Promise((s,n)=>{const r=new Image;r.crossOrigin=e,r.onload=()=>{P.set(i,r),s(r)},r.onerror=()=>{n(new Error(`Failed to load image: ${i}`))},r.src=i})}async function jr(i,t={}){const{parallel:e=!0}=t;if(e)return Promise.all(i.map(n=>Q(n,t)));const s=[];for(const n of i)s.push(await Q(n,t));return s}async function he(i,t={}){const{type:e="text/javascript",async:s=!0,defer:n=!1}=t;return P.has(i)?P.get(i):new Promise((r,a)=>{const l=document.createElement("script");l.type=e,l.async=s,l.defer=n,l.onload=()=>{P.set(i,l),r(l)},l.onerror=()=>{l.remove(),a(new Error(`Failed to load script: ${i}`))},l.src=i,document.head.appendChild(l)})}async function de(i,t={}){const{media:e="all"}=t;return P.has(i)?P.get(i):new Promise((s,n)=>{const r=document.createElement("link");r.rel="stylesheet",r.href=i,r.media=e,r.onload=()=>{P.set(i,r),s(r)},r.onerror=()=>{r.remove(),n(new Error(`Failed to load stylesheet: ${i}`))},document.head.appendChild(r)})}async function Jr(i,t,e={}){const{weight:s="normal",style:n="normal"}=e,r=new FontFace(i,`url(${t})`,{weight:s,style:n});try{return await r.load(),document.fonts.add(r),r}catch{throw new Error(`Failed to load font: ${i}`)}}async function Gr(i,t="image"){switch(t){case"image":return Q(i);case"script":return he(i);case"stylesheet":case"style":return de(i);default:throw new Error(`Unsupported preload type: ${t}`)}}function Zr(i){return P.has(i)}function Qr(){P.clear()}function ta(i){P.delete(i)}const ue={loadImage:Q,loadImages:jr,loadScript:he,loadStylesheet:de,loadFont:Jr,preload:Gr,isLoaded:Zr,clearCache:Qr,clearCacheByUrl:ta},ea={string:Ot,array:Kt,object:Xt,number:Gt,date:te,debounce:ee,throttle:se,validator:at,crypto:ce,preload:ue};function sa(i){if(!i)return"";let t=String(i);const e=/<\s*(script|iframe|object|embed|applet|form|base|link|meta|style)\b[^>]*>[\s\S]*?<\s*\/\s*\1\s*>|<\s*(script|iframe|object|embed|applet|form|base|link|meta|style)\b[^>]*\/?>/gi;let s;do s=t,t=t.replace(e,"");while(t!==s);return t=t.replace(/\bon\w+\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+)/gi,""),t=t.replace(/(href|src|action|background)\s*=\s*(?:"[^"]*(?:javascript|vbscript|data)\s*:[^"]*"|'[^']*(?:javascript|vbscript|data)\s*:[^']*'|[^\s>]*(?:javascript|vbscript|data)\s*:[^\s>]*)/gi,'$1=""'),t=t.replace(/expression\s*\([^)]*\)/gi,""),t}class pe{constructor(){this.children={},this.keys=[]}}class lt{constructor(){this.root=new pe}insert(t){let e=this.root;const s=t.split(".");s.forEach((n,r)=>{e.children[n]||(e.children[n]=new pe),e=e.children[n],r===s.length-1&&e.keys.push(t)})}getSubKeys(t){let e=this.root;const s=t.split("."),n=[];for(let r=0;r<s.length;r++){const a=s[r];if(!e.children[a])break;e=e.children[a];const l=o=>{o.keys.length>0&&n.push(...o.keys),Object.values(o.children).forEach(c=>l(c))};l(e)}return[...new Set(n)]}getParentKeys(t){const e=t.split("."),s=[];for(let n=1;n<=e.length;n++){const r=e.slice(0,n).join(".");s.push(r)}return s}}const _={parent:Symbol("reactive_parent"),path:Symbol("reactive_path"),isReactive:Symbol("reactive_is_reactive")};class fe{constructor(){this.rawData={},this.data=null,this.observers={},this.elements={},this.computedProperties={},this.pathTrie=new lt,this.updateQueue=new Map,this.isProcessing=!1,this.pendingComputed=new Set,this.persistedKeys=new Map,this.snapshots=[],this.snapshotLimit=10,this._proxyCache=new WeakMap,this.createReactiveData()}createReactiveData(){const t={get:(e,s,n)=>{if(s==="__raw__")return e;const r=Reflect.get(e,s,n);return r&&typeof r=="object"&&!Array.isArray(r)?this.wrapReactive(r,s):r},set:(e,s,n,r)=>{const a=Reflect.get(e,s,r),l=Reflect.set(e,s,n,r),o=this.resolvePath(e,s);return this.notify(o,n,a),this.queueUpdate(o,n),l},deleteProperty:(e,s)=>{const n=Reflect.get(e,s,receiver),r=Reflect.deleteProperty(e,s),a=this.resolvePath(e,s);return this.notify(a,void 0,n),this.queueUpdate(a,void 0),r}};this.data=new Proxy(this.rawData,t),this.data.__parent__=null,this.data.__path__=""}wrapReactive(t,e){if(t[_.isReactive])return t;if(this._proxyCache.has(t))return this._proxyCache.get(t);const s={get:(r,a,l)=>{if(a==="__raw__")return r;if(a===_.parent||a==="__parent__")return r[_.parent];if(a===_.path||a==="__path__")return r[_.path];if(a===_.isReactive||a==="__isReactive__")return!0;const o=Reflect.get(r,a,l);return o&&typeof o=="object"&&!Array.isArray(o)?this.wrapReactive(o,`${r[_.path]}${r[_.path]?".":""}${a}`):o},set:(r,a,l,o)=>{if(a===_.parent||a===_.path||a===_.isReactive||a==="__parent__"||a==="__path__"||a==="__isReactive__")return!0;const c=Reflect.get(r,a,o),d=Reflect.set(r,a,l,o),u=`${r[_.path]}${r[_.path]?".":""}${a}`;return this.notify(u,l,c),this.queueUpdate(u,l),d},deleteProperty:(r,a)=>{if(a===_.parent||a===_.path||a===_.isReactive)return!1;const l=Reflect.get(r,a),o=Reflect.deleteProperty(r,a),c=`${r[_.path]}${r[_.path]?".":""}${a}`;return this.notify(c,void 0,l),this.queueUpdate(c,void 0),o},has:(r,a)=>a==="__raw__"||a===_.parent||a===_.path||a===_.isReactive||a==="__parent__"||a==="__path__"||a==="__isReactive__"?!0:a in r,ownKeys:r=>Reflect.ownKeys(r).filter(a=>a!==_.parent&&a!==_.path&&a!==_.isReactive),getOwnPropertyDescriptor:(r,a)=>a===_.parent||a===_.path||a===_.isReactive?{configurable:!1,enumerable:!1,writable:!1,value:r[a]}:Reflect.getOwnPropertyDescriptor(r,a)},n=new Proxy(t,s);return t[_.parent]=t,t[_.path]=e,t[_.isReactive]=!0,this._proxyCache.set(t,n),Object.keys(t).forEach(r=>{t[r]&&typeof t[r]=="object"&&!Array.isArray(t[r])&&(t[r]=this.wrapReactive(t[r],`${e}${e?".":""}${r}`))}),n}resolvePath(t,e){return t[_.path]?`${t[_.path]}.${e}`:e}queueUpdate(t,e){this.updateQueue.set(t,e),this.isProcessing||(this.isProcessing=!0,requestAnimationFrame(()=>{this.processQueue()}))}processQueue(){const t=new Set;this.updateQueue.forEach((e,s)=>{t.add(s),this.updateElementsDirect(s,e),this.pathTrie.getSubKeys(s).forEach(r=>{if(!t.has(r)){const a=this.get(r);this.updateElementsDirect(r,a),t.add(r)}})}),this.updateQueue.clear(),this.processComputed(),this.isProcessing=!1}updateElementsDirect(t,e){this.elements[t]&&this.elements[t].forEach(s=>{this.updateElement(s,e)})}processComputed(){Object.keys(this.computedProperties).forEach(e=>{this.computedProperties[e].deps.some(r=>this.updateQueue.has(r)||this.pathTrie.getSubKeys(r).some(a=>this.updateQueue.has(a)))&&this.updateComputedProperty(e)})}set(t,e,s=!1){const n=this.get(t);typeof t=="object"?(Object.assign(this.rawData,t),Object.keys(t).forEach(r=>{s||(this.notify(r,t[r],n?.[r]),this.queueUpdate(r,t[r]))})):(t.includes(".")?this.setNested(t,e):this.rawData[t]=e,s||(this.notify(t,e,n),this.queueUpdate(t,e))),s||this.processComputed()}get(t){if(t)return t.includes(".")?this.getNested(t):this.rawData[t]}getNested(t){if(t)return t.split(".").reduce((e,s)=>e?.[s],this.rawData)}setNested(t,e){const s=t.split("."),n=s.pop(),r=s.reduce((l,o)=>(l[o]||(l[o]={}),l[o]),this.rawData),a=r[n];r[n]=e,this.notify(t,e,a),this.queueUpdate(t,e)}observe(t,e){this.observers[t]||(this.observers[t]=[]),this.observers[t].push(e)}unobserve(t,e){this.observers[t]&&(this.observers[t]=this.observers[t].filter(s=>s!==e))}notify(t,e,s){this.observers[t]&&this.observers[t].forEach(n=>{try{n(e,s)}catch(r){console.error(`Observer error for ${t}:`,r)}}),this.observers["*"]?.forEach(n=>{try{n(t,e,s)}catch(r){console.error("Wildcard observer error:",r)}})}updateElement(t,e){const s=t.getAttribute("data-bind");if(!s)return;s.split("|").forEach(r=>{const a=r.split(":"),l=a[0].trim(),o=a[1]?.trim();switch(l){case"text":t.textContent!==String(e??"")&&(t.textContent=e??"");break;case"html":const c=sa(e);t.innerHTML!==c&&(t.innerHTML=c);break;case"value":t.type==="checkbox"?t.checked!==!!e&&(t.checked=!!e):t.value!==String(e??"")&&(t.value=e??"");break;case"checked":t.checked!==!!e&&(t.checked=!!e);break;case"disabled":t.disabled!==!!e&&(t.disabled=!!e);break;case"hidden":const d=e?"none":"";t.style.display!==d&&(t.style.display=d);break;case"class":o&&(e?t.classList.add(o):t.classList.remove(o));break;case"style":o&&t.style[o]!==String(e??"")&&(t.style[o]=e??"");break;case"attr":o&&t.getAttribute(o)!==String(e??"")&&t.setAttribute(o,e??"");break;case"src":t.src!==String(e??"")&&(t.src=e??"");break;case"href":t.href!==String(e??"")&&(t.href=e??"");break;case"placeholder":t.placeholder!==String(e??"")&&(t.placeholder=e??"");break}})}computed(t,e,s){this.computedProperties[t]={deps:e,callback:s},e.forEach(n=>{this.pathTrie.insert(n)}),this.updateComputedProperty(t)}updateComputedProperty(t){const e=this.computedProperties[t];if(e)try{const s=e.deps.map(r=>this.get(r)),n=e.callback(...s);this.set(t,n,!0)}catch(s){console.error(`Computed error for ${t}:`,s)}}load(t){Object.keys(t).forEach(e=>{t[e]&&typeof t[e]=="object"&&!Array.isArray(t[e])?this.rawData[e]=this.wrapReactive(t[e],e):this.rawData[e]=t[e],this.queueUpdate(e,this.rawData[e])}),this.processComputed()}reset(){this.rawData={},this.observers={},this.elements={},this.computedProperties={},this.pathTrie=new lt,this.updateQueue.clear(),this.snapshots=[],this.createReactiveData(),this.bind()}persist(t,e={}){const{storage:s="local",debounce:n=0,version:r=1,encrypt:a=!1,encryptionKey:l=null}=e,o=s==="session"?sessionStorage:localStorage;this.persistedKeys.set(t,{storage:o,debounce:n,timeout:null,version:r,encrypt:a,encryptionKey:l});const c=this.get(t);c!==void 0&&this._persistSave(t,c,o,{version:r,encrypt:a,encryptionKey:l}),this.observe(t,d=>{const u=this.persistedKeys.get(t);u&&(u.debounce>0?(u.timeout&&clearTimeout(u.timeout),u.timeout=setTimeout(()=>{this._persistSave(t,d,u.storage,{version:u.version,encrypt:u.encrypt,encryptionKey:u.encryptionKey})},u.debounce)):this._persistSave(t,d,u.storage,{version:u.version,encrypt:u.encrypt,encryptionKey:u.encryptionKey}))})}_persistSave(t,e,s,n={}){try{const{version:r=1,encrypt:a=!1,encryptionKey:l=null}=n,o={value:e,version:r,timestamp:Date.now()};let c=JSON.stringify(o);a&&l&&(c=this._encrypt(c,l)),this._ensureStorageCapacity(s),s.setItem(`kupola:${t}`,c)}catch(r){if(console.warn(`Failed to persist key ${t}:`,r),r.name==="QuotaExceededError"&&s===localStorage){console.warn(`localStorage quota exceeded, trying sessionStorage for key ${t}`);try{sessionStorage.setItem(`kupola:${t}`,JSON.stringify({value:e,version:1}))}catch(a){console.warn(`sessionStorage also failed for key ${t}:`,a)}}}}_ensureStorageCapacity(t){try{const e="kupola:__storage_test__";t.setItem(e,"test"),t.removeItem(e)}catch(e){e.name==="QuotaExceededError"&&this._cleanupOldStorage(t)}}_cleanupOldStorage(t){const e=Date.now(),s=30*24*60*60*1e3;for(let n=0;n<t.length;n++){const r=t.key(n);if(r?.startsWith("kupola:"))try{const a=JSON.parse(t.getItem(r));a.timestamp&&e-a.timestamp>s&&t.removeItem(r)}catch{t.removeItem(r)}}}_encrypt(t,e){return window.CryptoJS?window.CryptoJS.AES.encrypt(t,e).toString():(console.warn("CryptoJS not available, encryption skipped"),t)}_decrypt(t,e){if(!window.CryptoJS)return console.warn("CryptoJS not available, decryption skipped"),t;try{return window.CryptoJS.AES.decrypt(t,e).toString(window.CryptoJS.enc.Utf8)}catch(s){return console.warn("Decryption failed:",s),t}}unpersist(t){const e=this.persistedKeys.get(t);e&&(e.timeout&&clearTimeout(e.timeout),e.storage.removeItem(`kupola:${t}`),this.persistedKeys.delete(t))}loadPersisted(t={}){const e={},{encryptionKey:s=null}=t;for(let n=0;n<localStorage.length;n++){const r=localStorage.key(n);if(r?.startsWith("kupola:")){const a=r.replace("kupola:","");try{const l=localStorage.getItem(r);let o;if(s){const c=this._decrypt(l,s);o=JSON.parse(c)}else o=JSON.parse(l);if(o.version!==void 0&&o.version!==t.version){console.debug(`Skipping outdated data for ${a} (version ${o.version})`);continue}e[a]=o.value!==void 0?o.value:o}catch(l){console.warn(`Failed to load persisted key ${a}:`,l)}}}for(let n=0;n<sessionStorage.length;n++){const r=sessionStorage.key(n);if(r?.startsWith("kupola:")){const a=r.replace("kupola:","");try{const l=sessionStorage.getItem(r);let o;if(s){const c=this._decrypt(l,s);o=JSON.parse(c)}else o=JSON.parse(l);if(o.version!==void 0&&o.version!==t.version){console.debug(`Skipping outdated data for ${a} (version ${o.version})`);continue}e[a]=o.value!==void 0?o.value:o}catch{}}}return Object.keys(e).length>0&&this.load(e),e}_clone(t){if(typeof structuredClone=="function")try{return structuredClone(t)}catch(e){console.warn("structuredClone failed, falling back to JSON:",e)}return JSON.parse(JSON.stringify(t))}snapshot(){const t=this._clone(this.rawData);return this.snapshots.push(t),this.snapshots.length>this.snapshotLimit&&this.snapshots.shift(),this.snapshots.length-1}rollback(t=-1){if(this.snapshots.length===0)return!1;const e=t>=0?t:this.snapshots.length-1,s=this.snapshots[e];return s?(this.rawData=this._clone(s),this.createReactiveData(),Object.keys(this.rawData).forEach(n=>{this.queueUpdate(n,this.rawData[n])}),this.processComputed(),!0):!1}getSnapshotCount(){return this.snapshots.length}clearSnapshots(){this.snapshots=[]}serializeForm(t){const e={};return t.querySelectorAll("input, select, textarea").forEach(s=>{const n=s.getAttribute("data-bind");if(!n)return;const a=n.split(":")[1]?.trim();a&&(s.type==="checkbox"?(e[a]||(e[a]=[]),s.checked&&e[a].push(s.value)):s.type==="radio"?s.checked&&(e[a]=s.value):e[a]=s.value)}),e}fillForm(t,e){Object.keys(e).forEach(s=>{t.querySelectorAll('[data-bind*=":'+s+'"]').forEach(n=>{n.type==="checkbox"?n.checked=Array.isArray(e[s])?e[s].includes(n.value):!!e[s]:n.type==="radio"?n.checked=n.value===e[s]:n.value=e[s]??""})})}createReactive(t,e=""){if(t[_.isReactive])return t;if(this._proxyCache.has(t))return this._proxyCache.get(t);const s={get:(r,a,l)=>{if(a==="__raw__")return r;if(a===_.parent||a==="__parent__")return r[_.parent];if(a===_.path||a==="__path__")return r[_.path];if(a===_.isReactive||a==="__isReactive__")return!0;const o=Reflect.get(r,a,l);return o&&typeof o=="object"&&!Array.isArray(o)?this.wrapReactive(o,`${r[_.path]}${r[_.path]?".":""}${a}`):o},set:(r,a,l,o)=>{if(a===_.parent||a===_.path||a===_.isReactive||a==="__parent__"||a==="__path__"||a==="__isReactive__")return!0;const c=Reflect.get(r,a,o),d=Reflect.set(r,a,l,o),u=`${r[_.path]}${r[_.path]?".":""}${a}`;return this.notify(u,l,c),this.queueUpdate(u,l),d},deleteProperty:(r,a)=>{if(a===_.parent||a===_.path||a===_.isReactive)return!1;const l=Reflect.get(r,a),o=Reflect.deleteProperty(r,a),c=`${r[_.path]}${r[_.path]?".":""}${a}`;return this.notify(c,void 0,l),this.queueUpdate(c,void 0),o},has:(r,a)=>a==="__raw__"||a===_.parent||a===_.path||a===_.isReactive||a==="__parent__"||a==="__path__"||a==="__isReactive__"?!0:a in r,ownKeys:r=>Reflect.ownKeys(r).filter(a=>a!==_.parent&&a!==_.path&&a!==_.isReactive),getOwnPropertyDescriptor:(r,a)=>a===_.parent||a===_.path||a===_.isReactive?{configurable:!1,enumerable:!1,writable:!1,value:r[a]}:Reflect.getOwnPropertyDescriptor(r,a)},n=new Proxy(t,s);return t[_.parent]=t,t[_.path]=e,t[_.isReactive]=!0,this._proxyCache.set(t,n),Object.keys(t).forEach(r=>{t[r]&&typeof t[r]=="object"&&!Array.isArray(t[r])&&(t[r]=this.wrapReactive(t[r],`${e}${e?".":""}${r}`))}),n}bind(){document.querySelectorAll("[data-bind]").forEach(t=>{this._bindElement(t)}),this._mutationObserver||(this._isObserving=!1,this._mutationObserver=new MutationObserver(t=>{if(!this._isObserving){this._isObserving=!0;try{t.forEach(e=>{e.addedNodes.forEach(s=>{s.nodeType===Node.ELEMENT_NODE&&(s.querySelectorAll("[data-bind]").forEach(r=>this._bindElement(r)),s.hasAttribute&&s.hasAttribute("data-bind")&&this._bindElement(s))})})}finally{this._isObserving=!1}}}),this._mutationObserver.observe(document.body,{childList:!0,subtree:!0}))}_bindElement(t){const s=t.getAttribute("data-bind").split(":");s[0].split("|")[0].trim();const n=s[1]?.trim();if(n){if(this.pathTrie.insert(n),this.elements[n]||(this.elements[n]=[]),this.elements[n].includes(t)||this.elements[n].push(t),t.tagName==="INPUT"||t.tagName==="TEXTAREA"||t.tagName==="SELECT"){const r=t.__kupolaBindHandler;r&&t.removeEventListener("input",r);const a=()=>{const l=t.type==="checkbox"?t.checked:t.value;n.includes(".")?this.setNested(n,l):this.set(n,l)};t.__kupolaBindHandler=a,t.addEventListener("input",a)}this.rawData[n]!==void 0&&this.updateElement(t,this.rawData[n])}}destroy(){this._mutationObserver&&(this._mutationObserver.disconnect(),this._mutationObserver=null),Object.values(this.elements).forEach(t=>{t.forEach(e=>{const s=e.__kupolaBindHandler;s&&(e.removeEventListener("input",s),delete e.__kupolaBindHandler)})}),this.persistedKeys.forEach((t,e)=>{t.timeout&&clearTimeout(t.timeout)}),this.persistedKeys.clear(),this.rawData={},this.observers={},this.elements={},this.computedProperties={},this.pathTrie=new lt,this.updateQueue.clear(),this.snapshots=[]}}class ot{constructor(t,e={}){this.name=t,this._stateKey=`__store_${t}__`;const s=e.state?e.state():{};this.getters=e.getters||{},this.actions=e.actions||{},this.mutations=e.mutations||{},this.observers={},q?(q.set(this._stateKey,s),this.state=q.data?.[this._stateKey]||q.createReactive(s,this._stateKey),q.observe(this._stateKey,n=>{this.notify(n)})):this.state=s,this._bindGetters(),this._bindActions()}_bindGetters(){Object.keys(this.getters).forEach(t=>{Object.defineProperty(this,t,{get:()=>this.getters[t](this.state),enumerable:!0})})}_bindActions(){Object.keys(this.actions).forEach(t=>{this[t]=(...e)=>this.actions[t]({state:this.state,commit:this.commit.bind(this),dispatch:this.dispatch.bind(this),getters:this},...e)})}commit(t,e){const s=this.mutations[t];if(!s){console.warn(`Mutation ${t} not found in store ${this.name}`);return}s(this.state,e)}dispatch(t,e){const s=this.actions[t];if(!s){console.warn(`Action ${t} not found in store ${this.name}`);return}return s({state:this.state,commit:this.commit.bind(this),dispatch:this.dispatch.bind(this),getters:this},e)}observe(t){return this.observers["*"]||(this.observers["*"]=[]),this.observers["*"].push(t),t}unobserve(t){this.observers["*"]&&(this.observers["*"]=this.observers["*"].filter(e=>e!==t))}notify(t){this.observers["*"]&&this.observers["*"].forEach(e=>{try{e(t)}catch(s){console.error(`Observer error for store ${this.name}:`,s)}}),q&&q.set(this.name,t)}toJSON(){return{name:this.name,state:this.state,getters:Object.keys(this.getters).reduce((t,e)=>(t[e]=this[e],t),{})}}}class me{constructor(){this.stores=new Map}createStore(t,e){const s=new ot(t,e);return this.stores.set(t,s),s}getStore(t){return this.stores.get(t)}registerStore(t){t instanceof ot&&this.stores.set(t.name,t)}dispose(){this.stores.clear()}}class ge{constructor(){this.events={},this.delegatedEvents={},this.eventListeners={}}on(t,e){return this.events[t]||(this.events[t]=[]),this.events[t].push(e),e}off(t,e){this.events[t]&&(this.events[t]=this.events[t].filter(s=>s!==e))}emit(t,e){this.events[t]&&this.events[t].forEach(s=>{try{s(e)}catch(n){console.error(`Error in event handler for ${t}:`,n)}}),this.events["*"]?.forEach(s=>{try{s(t,e)}catch(n){console.error("Error in wildcard event handler:",n)}})}once(t,e){const s=n=>{e(n),this.off(t,s)};return this.on(t,s),s}delegate(t,e,s){if(!this.delegatedEvents[e]){this.delegatedEvents[e]=[];const n=r=>{this.delegatedEvents[e].forEach(({selector:a,cb:l})=>{(r.target.matches(a)||r.target.closest(a))&&l(r)})};document.addEventListener(e,n),this.eventListeners[e]=n}return this.delegatedEvents[e].push({selector:t,cb:s}),s}undelegate(t,e){if(this.delegatedEvents[e]&&(this.delegatedEvents[e]=this.delegatedEvents[e].filter(s=>s.selector!==t),this.delegatedEvents[e].length===0)){const s=this.eventListeners[e];s&&(document.removeEventListener(e,s),delete this.eventListeners[e]),delete this.delegatedEvents[e]}}destroy(){Object.entries(this.eventListeners).forEach(([t,e])=>{document.removeEventListener(t,e)}),this.events={},this.delegatedEvents={},this.eventListeners={}}}function T(i=null){const t={_value:i,_subscribers:new Set};return Object.defineProperty(t,"value",{configurable:!0,enumerable:!0,get(){return t._value},set(e){e!==t._value&&(t._value=e,t._subscribers.forEach(s=>s(e)))}}),t.subscribe=e=>(t._subscribers.add(e),{unsubscribe(){t._subscribers.delete(e)}}),t}const q=new fe,ia=new ge,ct=new me;function na(i,t){return ct.createStore(i,t)}function ra(i){return ct.getStore(i)}const _e="kupola-theme",ye="kupola-brand",K=[{id:"green",name:"翠绿",color:"#32F08C"},{id:"xionghuang",name:"雄黄",color:"#FF9900"},{id:"jianghuang",name:"姜黄",color:"#E2C027"},{id:"lanlv",name:"蓝绿",color:"#12A182"},{id:"kongquelan",name:"孔雀蓝",color:"#0EB0C9"},{id:"meiguizi",name:"玫瑰紫",color:"#BA2F7B"},{id:"shihong",name:"柿红",color:"#F2481B"},{id:"quhong",name:"紫云",color:"#B1A6CC"},{id:"shanchahong",name:"山茶红",color:"#F05A46"},{id:"zengqing",name:"曾青",color:"#535164"},{id:"roulan",name:"柔蓝",color:"#106898"}];function W(){return localStorage.getItem(_e)||"dark"}function tt(i){if(i!=="dark"&&i!=="light")return;document.documentElement.setAttribute("data-theme",i),localStorage.setItem(_e,i);const t=document.querySelector("[data-theme-toggle]");if(t){t.setAttribute("data-current-theme",i);const e=t.querySelector(".theme-icon");if(e){const s=e.src.substring(0,e.src.lastIndexOf("/")+1);e.src=i==="dark"?s+"sun.svg":s+"moon.svg"}}}function X(){return localStorage.getItem(ye)||"zengqing"}function et(i){const t=K.find(n=>n.id===i);if(!t)return;document.documentElement.setAttribute("data-brand",i),localStorage.setItem(ye,i);const e=document.querySelector("[data-brand-toggle]");if(e){e.setAttribute("data-current-brand",i);const n=e.querySelector(".brand-icon");n&&(n.style.backgroundColor=t.color);const r=e.querySelector(".brand-name");r&&(r.textContent=t.name)}document.querySelectorAll("[data-brand-btn]").forEach(n=>{n.getAttribute("data-brand-btn")===i?n.classList.add("is-active"):n.classList.remove("is-active")})}function ve(){const i=W();tt(i);const t=X();et(t);const e=document.querySelector("[data-theme-toggle]");if(e){const l=e.onclick;e.onclick=function(o){o.preventDefault();const d=W()==="dark"?"light":"dark";tt(d),typeof l=="function"&&l.call(this,o)}}let s=document.getElementById("brand-picker");s||(s=document.createElement("div"),s.id="brand-picker",s.style.position="fixed",s.style.top="64px",s.style.right="16px",s.style.zIndex="9998",s.style.display="none",s.style.padding="12px",s.style.width="200px",s.style.gridTemplateColumns="repeat(3, 1fr)",s.style.gap="6px",s.style.backgroundColor="var(--bg-base-secondary)",s.style.border="1px solid var(--border-neutral-l1)",s.style.borderRadius="8px",s.style.boxShadow="0 4px 20px rgba(0, 0, 0, 0.2)",s.style.overflow="hidden",K.forEach(l=>{const o=document.createElement("button");o.setAttribute("data-brand-btn",l.id),o.style.display="flex",o.style.justifyContent="center",o.style.alignItems="center",o.style.height="60px",o.style.backgroundColor=l.color,o.style.color=["#32F08C","#FF9900","#E2C027","#0EB0C9","#B1A6CC"].includes(l.color)?"#0C0C0D":"#FFFFFF",o.style.fontWeight="500",o.style.borderRadius="4px",o.style.border="none",o.style.cursor="pointer",o.style.margin="0",o.style.padding="0",o.textContent=l.name,s.appendChild(o)}),document.body.appendChild(s));const n=document.querySelector("[data-brand-toggle]");n&&s&&(n.onclick=function(l){l.stopPropagation(),l.preventDefault();const o=s.style.display==="none";s.style.display=o?"grid":"none",o?setTimeout(()=>{document.addEventListener("click",r,!0)},0):document.removeEventListener("click",r,!0)},s.onclick=function(l){l.stopPropagation()});function r(l){s&&n&&!s.contains(l.target)&&!n.contains(l.target)&&(s.style.display="none",document.removeEventListener("click",r,!0))}document.querySelectorAll("[data-brand-btn]").forEach(l=>{l.addEventListener("click",o=>{o.stopPropagation();const c=l.getAttribute("data-brand-btn");et(c),s&&(s.style.display="none")})})}function aa(){const i=document.createElement("button");i.setAttribute("data-theme-toggle",""),i.setAttribute("data-current-theme",W()),i.className="ds-btn ds-btn--ghost ds-btn--sm ds-btn--icon",i.style.position="fixed",i.style.top="16px",i.style.right="16px",i.style.zIndex="9999";const t=document.createElement("img");t.className="theme-icon";const e=document.getElementsByTagName("script"),s=e[e.length-1],n=s.src.substring(0,s.src.lastIndexOf("/")+1);return t.src=W()==="dark"?n+"../icons/sun.svg":n+"../icons/moon.svg",t.width=14,t.height=14,t.alt="Toggle theme",i.appendChild(t),document.body.appendChild(i),i.onclick=function(r){r.preventDefault();const l=W()==="dark"?"light":"dark";tt(l)},i}function la(){const i=document.createElement("div");i.id="brand-picker-auto",i.style.position="fixed",i.style.top="56px",i.style.right="16px",i.style.zIndex="9998",i.style.display="none",i.style.padding="12px",i.style.width="200px",i.style.gridTemplateColumns="repeat(3, 1fr)",i.style.gap="6px",i.style.backgroundColor="var(--bg-base-secondary)",i.style.border="1px solid var(--border-neutral-l1)",i.style.borderRadius="8px",i.style.boxShadow="0 4px 20px rgba(0, 0, 0, 0.2)",i.style.overflow="hidden",K.forEach(a=>{const l=document.createElement("button");l.setAttribute("data-brand-btn",a.id),l.style.display="flex",l.style.justifyContent="center",l.style.alignItems="center",l.style.height="60px",l.style.backgroundColor=a.color,l.style.color=["#32F08C","#FF9900","#E2C027","#0EB0C9","#B1A6CC"].includes(a.color)?"#0C0C0D":"#FFFFFF",l.style.fontWeight="500",l.style.borderRadius="4px",l.style.border="none",l.style.cursor="pointer",l.style.margin="0",l.style.padding="0",l.textContent=a.name,i.appendChild(l)}),document.body.appendChild(i);const t=document.createElement("button");t.setAttribute("data-brand-toggle",""),t.setAttribute("data-current-brand",X()),t.className="ds-btn ds-btn--ghost ds-btn--sm",t.style.position="fixed",t.style.top="16px",t.style.right="56px",t.style.zIndex="9999",t.style.display="flex",t.style.alignItems="center",t.style.gap="6px";const e=document.createElement("span");e.className="brand-icon",e.style.width="12px",e.style.height="12px",e.style.borderRadius="50%",e.style.backgroundColor=K.find(a=>a.id===X()).color;const s=document.createElement("span");s.className="brand-name",s.style.fontSize="11px",s.textContent=K.find(a=>a.id===X()).name,t.appendChild(e),t.appendChild(s),document.body.appendChild(t),t.onclick=function(a){a.stopPropagation(),a.preventDefault();const l=i.style.display==="none";i.style.display=l?"grid":"none",l?setTimeout(()=>{document.addEventListener("click",n,!0)},0):document.removeEventListener("click",n,!0)},i.onclick=function(a){a.stopPropagation()};function n(a){!i.contains(a.target)&&!t.contains(a.target)&&(i.style.display="none",document.removeEventListener("click",n,!0))}return i.querySelectorAll("[data-brand-btn]").forEach(a=>{a.addEventListener("click",l=>{l.stopPropagation();const o=a.getAttribute("data-brand-btn");et(o),i.style.display="none"})}),{toggleBtn:t,container:i}}class be{constructor(){this.initializers=new Map,this.cleanupFunctions=new Map,this.processedElements=new WeakSet,this._dataAttrs=["data-component"],this._cssClasses=[],this._cachedSelector=null}register(t,e,s=null,n={}){this.initializers.set(t,e),s&&this.cleanupFunctions.set(t,s),n.dataAttribute&&!this._dataAttrs.includes(n.dataAttribute)&&(this._dataAttrs.push(n.dataAttribute),this._cachedSelector=null),n.cssClass&&!this._cssClasses.includes(n.cssClass)&&(this._cssClasses.push(n.cssClass),this._cachedSelector=null)}unregister(t){this.initializers.delete(t),this.cleanupFunctions.delete(t)}has(t){return this.initializers.has(t)}get(t){return this.initializers.get(t)}_buildSelector(){if(this._cachedSelector!==null)return this._cachedSelector;const t=this._dataAttrs.map(e=>`[${e}]`);for(const e of this._cssClasses)t.push(`.${e}`);return this._cachedSelector=t.join(", "),this._cachedSelector}async initialize(t){if(this.processedElements.has(t))return;for(const s of this._dataAttrs){const n=t.getAttribute(s);if(n!==null){const r=n||s.replace("data-",""),a=this.initializers.get(r)||this.initializers.get(s.replace("data-",""));if(a){try{await a(t),this.processedElements.add(t)}catch(l){console.error(`[ComponentInitializerRegistry] Error initializing "${r}":`,l)}return}}}const e=t.className;if(typeof e=="string"){for(const s of this._cssClasses)if(e.includes(s)){const n=s.replace("ds-",""),r=this.initializers.get(n)||this.initializers.get(s);if(r){try{await r(t),this.processedElements.add(t)}catch(a){console.error(`[ComponentInitializerRegistry] Error initializing "${n}":`,a)}return}}}}cleanup(t){for(const s of this._dataAttrs){const n=t.getAttribute(s);if(n!==null){const r=n||s.replace("data-",""),a=this.cleanupFunctions.get(r)||this.cleanupFunctions.get(s.replace("data-",""));if(a){try{a(t)}catch(l){console.error(`[ComponentInitializerRegistry] Error cleaning up "${r}":`,l)}this.processedElements.delete(t);return}}}const e=t.className;if(typeof e=="string"){for(const s of this._cssClasses)if(e.includes(s)){const n=s.replace("ds-",""),r=this.cleanupFunctions.get(n)||this.cleanupFunctions.get(s);if(r){try{r(t)}catch(a){console.error(`[ComponentInitializerRegistry] Error cleaning up "${n}":`,a)}this.processedElements.delete(t);return}}}}async initializeAll(t=document){const e=this._buildSelector();if(!e)return;const s=t.querySelectorAll(e),n=[];s.forEach(r=>{this.processedElements.has(r)||n.push(this.initialize(r))}),await Promise.all(n)}}const w=new be,oa=[{attr:"data-dropdown",cls:"ds-dropdown"},{attr:"data-select",cls:"ds-select"},{attr:"data-datepicker",cls:"ds-datepicker"},{attr:"data-timepicker",cls:"ds-timepicker"},{attr:"data-slider",cls:"ds-slider"},{attr:"data-carousel",cls:"ds-carousel"},{attr:"data-drawer",cls:"ds-drawer"},{attr:"data-modal",cls:"ds-modal"},{attr:"data-dialog",cls:"ds-dialog"},{attr:"data-color-picker",cls:"ds-color-picker"},{attr:"data-calendar",cls:"ds-calendar"},{attr:"data-slide-captcha",cls:"ds-slide-captcha"},{attr:"data-heatmap",cls:"ds-heatmap"},{cls:"ds-tooltip"},{cls:"ds-tag"},{cls:"ds-statcard"},{cls:"ds-collapse"},{cls:"ds-fileupload"},{cls:"ds-notification"},{cls:"ds-message"}];for(const i of oa)i.attr&&!w._dataAttrs.includes(i.attr)&&w._dataAttrs.push(i.attr),i.cls&&!w._cssClasses.includes(i.cls)&&w._cssClasses.push(i.cls);class j{constructor(t){this.element=t,this.isMounted=!1,this.isDestroyed=!1,this.props=this._parseProps(),this.state={},this.slots=this._parseSlots(),this._eventListeners={},this._appliedMixins=[],this.lifecycle=new B,this.setupContext=null}_parseProps(){const t={};for(const e of this.element.attributes)if(e.name.startsWith("data-prop-")){const s=e.name.replace("data-prop-","");let n=e.value;try{n=JSON.parse(n)}catch{}t[s]=n}return t}_parseSlots(){const t={};return this.element.querySelectorAll("[data-slot]").forEach(s=>{const n=s.getAttribute("data-slot")||"default";t[n]=s.innerHTML.trim(),s.remove()}),!t.default&&this.element.children.length>0&&(t.default=this.element.innerHTML.trim()),t}$slot(t="default"){return this.slots[t]||""}$emit(t,e){if((this._eventListeners[t]||[]).forEach(n=>{try{n(e)}catch(r){console.error(`Error in event handler for ${t}:`,r)}}),this.element){const n=new CustomEvent(`kupola:${t}`,{detail:e,bubbles:!0,cancelable:!0});this.element.dispatchEvent(n)}}$on(t,e){return this._eventListeners[t]||(this._eventListeners[t]=[]),this._eventListeners[t].push(e),e}$off(t,e){this._eventListeners[t]&&(this._eventListeners[t]=this._eventListeners[t].filter(s=>s!==e))}async setProps(t){try{this.props={...this.props,...t},await this.lifecycle.update(),this.setupContext?._executeUpdated()}catch(e){console.error(`[KupolaComponent] Error in setProps for "${this.constructor.name}":`,e),this.lifecycle&&typeof this.lifecycle._handleError=="function"&&await this.lifecycle._handleError({phase:"update",hook:"setProps",error:e,args:[t]})}}async setState(t){try{this.state={...this.state,...t},await this.lifecycle.update(),this.setupContext?._executeUpdated()}catch(e){console.error(`[KupolaComponent] Error in setState for "${this.constructor.name}":`,e),this.lifecycle&&typeof this.lifecycle._handleError=="function"&&await this.lifecycle._handleError({phase:"update",hook:"setState",error:e,args:[t]})}}async mount(){if(!(this.isMounted||this.isDestroyed))try{if(this._bindLifecycleHooks(),await this.lifecycle.bootstrap(),typeof this.setup=="function"){const t=this.setup();t instanceof Promise&&await t}this.isMounted=!0,await this.lifecycle.mount(),this.setupContext?._executeMounted()}catch(t){if(console.error(`[KupolaComponent] Error mounting component "${this.constructor.name}":`,t),this.lifecycle&&typeof this.lifecycle._handleError=="function"&&await this.lifecycle._handleError({phase:"mount",hook:"component",error:t,args:[]}),typeof this.renderError=="function")try{this.renderError(t)}catch(e){console.error(`[KupolaComponent] Error in renderError for "${this.constructor.name}":`,e)}else this.element.innerHTML=`
2
2
  <div style="padding: 16px; background: #fee2e2; border: 1px solid #fecaca; border-radius: 8px; color: #991b1b;">
3
3
  <div style="font-weight: bold; margin-bottom: 8px;">Component Error</div>
4
4
  <div style="font-size: 12px; white-space: pre-wrap;">${t.message}</div>