@kupola/kupola 1.6.3 → 1.6.4

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,9 +1,9 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class it{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 o of s){await this._resolveDepends(o.depends,t);const l=performance.now();let c,h;try{c=o.handler(...e),c instanceof Promise&&await c,o.resolved=!0}catch(u){h=u,console.error(`[KupolaLifecycle] Error in ${t} hook "${o.name}":`,u),t!=="error"&&await this._handleError({phase:t,hook:o.name,error:u,args:e})}const d=performance.now()-l;this.trace.push({emitId:n,phase:t,hookName:o.name,duration:d,status:h?"error":"success",error:h?h.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 Xs=new it("app");function js(i="app"){return new it(i)}const Js=new Set(["__proto__","prototype","constructor"]);function nt(i){return Js.has(i)}function Zs(i){return i?i.trim():""}function Gs(i){return i?i.replace(/^\s+/,""):""}function Qs(i){return i?i.replace(/\s+$/,""):""}function ti(i){return i?i.toUpperCase():""}function ei(i){return i?i.toLowerCase():""}function si(i){return i?i.charAt(0).toUpperCase()+i.slice(1):""}function ii(i){return i?i.replace(/-(\w)/g,(t,e)=>e?e.toUpperCase():""):""}function ni(i){return i?i.replace(/([A-Z])/g,"-$1").toLowerCase().replace(/^-/,""):""}function ri(i,t,e=" "){return(String(i)||"").padStart(t,e)}function ai(i,t,e=" "){return(String(i)||"").padEnd(t,e)}function oi(i,t,e="..."){return!i||i.length<=t?i||"":i.slice(0,t)+e}function li(i,t,e){return i?i.split(t).join(e):""}function ci(i,t){return i?i.replace(/\{\{(\w+)\}\}/g,(e,s)=>t[s]!==void 0?t[s]:`{{${s}}}`):""}function hi(i,t){return(i||"").startsWith(t)}function di(i,t){return(i||"").endsWith(t)}function ui(i,t){return(i||"").includes(t)}function pi(i,t){return(i||"").repeat(t)}function fi(i){return(i||"").split("").reverse().join("")}function mi(i,t){return!i||!t?0:i.split(t).length-1}function gi(i){if(!i)return"";const t=document.createElement("div");return t.textContent=i,t.innerHTML}function _i(i){if(!i)return"";const t=document.createElement("div");return t.innerHTML=i,t.textContent}function yi(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 vi(){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 ie={trim:Zs,trimLeft:Gs,trimRight:Qs,toUpperCase:ti,toLowerCase:ei,capitalize:si,camelize:ii,hyphenate:ni,padStart:ri,padEnd:ai,truncate:oi,replaceAll:li,format:ci,startsWith:hi,endsWith:di,includes:ui,repeat:pi,reverse:fi,countOccurrences:mi,escapeHtml:gi,unescapeHtml:_i,generateRandom:yi,generateUUID:vi};function bi(i){return Array.isArray(i)}function xi(i){return!i||i.length===0}function Ei(i){return i?i.length:0}function ki(i,t){return i&&i.length>0?i[0]:t}function wi(i,t){return i&&i.length>0?i[i.length-1]:t}function Ci(i,t,e){return i&&i[t]!==void 0?i[t]:e}function Si(i,t,e){return i?i.slice(t,e):[]}function Li(...i){return i.reduce((t,e)=>t.concat(e||[]),[])}function Di(i,t=","){return i?i.join(t):""}function Hi(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 Mi(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 Ti(i,t){return i?i.includes(t):!1}function Ii(i,...t){return i&&i.push(...t),i}function Ai(i){return i?i.pop():void 0}function zi(i){return i?i.shift():void 0}function Pi(i,...t){return i&&i.unshift(...t),i}function $i(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 Bi(i,t){return!i||t<0||t>=i.length||i.splice(t,1),i}function qi(i,t,e){return i&&(i.splice(t,0,e),i)}function Oi(i){return i?i.slice().reverse():[]}function Fi(i,t){return i?i.slice().sort(t):[]}function Ni(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 Ri(i,t){return i?i.filter(t):[]}function Vi(i,t){return i?i.map(t):[]}function Ki(i,t,e){return i?i.reduce(t,e):e}function Wi(i,t){i&&i.forEach(t)}function Ui(i,t){return i?i.every(t):!0}function Yi(i,t){return i?i.some(t):!1}function Xi(i,t){return i?i.find(t):void 0}function ji(i,t){return i?i.findIndex(t):-1}function Ji(i,t=1){return i?i.flat(t):[]}function ne(i){return i?i.reduce((t,e)=>Array.isArray(e)?t.concat(ne(e)):t.concat(e),[]):[]}function Zi(i){return i?[...new Set(i)]:[]}function Gi(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 Qi(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 tn(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 re(i){return i?i.reduce((t,e)=>t+(Number(e)||0),0):0}function en(i){return!i||i.length===0?0:re(i)/i.length}function sn(i){return i&&i.length>0?Math.max(...i):-1/0}function nn(i){return i&&i.length>0?Math.min(...i):1/0}function rn(...i){return i.length===0?[]:i.reduce((t,e)=>t.filter(s=>e&&e.includes(s)))}function an(...i){return[...new Set(i.flat().filter(Boolean))]}function on(i,t){return i?i.filter(e=>!t||!t.includes(e)):[]}function ln(...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 ae={isArray:bi,isEmpty:xi,size:Ei,first:ki,last:wi,get:Ci,slice:Si,concat:Li,join:Di,indexOf:Hi,lastIndexOf:Mi,includes:Ti,push:Ii,pop:Ai,shift:zi,unshift:Pi,remove:$i,removeAt:Bi,insert:qi,reverse:Oi,sort:Fi,sortBy:Ni,filter:Ri,map:Vi,reduce:Ki,forEach:Wi,every:Ui,some:Yi,find:Xi,findIndex:ji,flat:Ji,flattenDeep:ne,unique:Zi,uniqueBy:Gi,chunk:Qi,shuffle:tn,sum:re,average:en,max:sn,min:nn,intersection:rn,union:an,difference:on,zip:ln};function ht(i){return i!==null&&typeof i=="object"&&!Array.isArray(i)}function cn(i){return!i||typeof i!="object"?!0:Object.keys(i).length===0}function hn(i){return i?Object.keys(i):[]}function dn(i){return i?Object.values(i):[]}function un(i){return i?Object.entries(i):[]}function pn(i,t){return i?Object.prototype.hasOwnProperty.call(i,t):!1}function fn(i,t,e){if(!i)return e;const s=t.split(".");return s.some(nt)?e:s.reduce((n,r)=>n&&n[r],i)??e}function mn(i,t,e){if(!i||typeof i!="object")return i;const s=t.split(".");if(s.some(nt))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 gn(i,t){return i?t.reduce((e,s)=>(i[s]!==void 0&&(e[s]=i[s]),e),{}):{}}function _n(i,t){return i?Object.keys(i).reduce((e,s)=>(t.includes(s)||(e[s]=i[s]),e),{}):{}}function oe(...i){return i.reduce((t,e)=>(e&&typeof e=="object"&&Object.keys(e).forEach(s=>{nt(s)||(ht(e[s])&&ht(t[s])?t[s]=oe(t[s],e[s]):t[s]=e[s])}),t),{})}function yn(i){return i&&JSON.parse(JSON.stringify(i))}function X(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,X(n,t))),s}if(i instanceof Set){const s=new Set;return t.set(i,s),i.forEach(n=>s.add(X(n,t))),s}if(Array.isArray(i)){const s=[];return t.set(i,s),i.forEach(n=>s.push(X(n,t))),s}const e={};return t.set(i,e),Object.keys(i).forEach(s=>{nt(s)||(e[s]=X(i[s],t))}),e}function vn(i,t){i&&Object.keys(i).forEach(e=>t(i[e],e,i))}function bn(i,t){if(!i)return{};const e={};return Object.keys(i).forEach(s=>{e[s]=t(i[s],s,i)}),e}function xn(i,t){if(!i)return{};const e={};return Object.keys(i).forEach(s=>{t(i[s],s,i)&&(e[s]=i[s])}),e}function En(i,t,e){return i?Object.keys(i).reduce((s,n)=>t(s,i[n],n,i),e):e}function kn(i){return i?Object.keys(i).map(t=>({key:t,value:i[t]})):[]}function wn(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 Cn(i){return i?Object.keys(i).length:0}function Sn(i){if(!i)return{};const t={};return Object.keys(i).forEach(e=>{t[i[e]]=e}),t}function le(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=>le(i[n],t[n]))}function ce(i){return i&&(Object.freeze(i),Object.keys(i).forEach(t=>{typeof i[t]=="object"&&ce(i[t])}),i)}function Ln(i){return i&&Object.seal(i)}const he={isObject:ht,isEmpty:cn,keys:hn,values:dn,entries:un,has:pn,get:fn,set:mn,pick:gn,omit:_n,merge:oe,clone:yn,deepClone:X,forEach:vn,map:bn,filter:xn,reduce:En,toArray:kn,fromArray:wn,size:Cn,invert:Sn,isEqual:le,freeze:ce,seal:Ln};function L(i){return typeof i=="number"&&!isNaN(i)}function Dn(i){return Number.isInteger(i)}function Hn(i){return L(i)&&!Number.isInteger(i)}function Mn(i){return L(i)&&i>0}function Tn(i){return L(i)&&i<0}function In(i){return L(i)&&i===0}function An(i,t,e){return L(i)?Math.min(Math.max(i,t),e):i}function zn(i,t=0){if(!L(i))return i;const e=Math.pow(10,t);return Math.round(i*e)/e}function Pn(i){return L(i)?Math.floor(i):i}function $n(i){return L(i)?Math.ceil(i):i}function Bn(i){return L(i)?Math.abs(i):i}function qn(...i){const t=i.filter(L);return t.length>0?Math.min(...t):void 0}function On(...i){const t=i.filter(L);return t.length>0?Math.max(...t):void 0}function de(...i){return i.flat().filter(L).reduce((e,s)=>e+s,0)}function Fn(...i){const t=i.flat().filter(L);return t.length>0?de(t)/t.length:0}function ue(i=0,t=1){return Math.random()*(t-i)+i}function Nn(i,t){return Math.floor(ue(i,t+1))}function Rn(i,t=2){return L(i)?i.toFixed(t):String(i)}function Vn(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 Kn(i,t=0){return L(i)?`${(i*100).toFixed(t)}%`:String(i)}function Wn(i,t=0){return L(i)?i.toFixed(t):String(i)}function Un(i,t=6){return L(i)?i.toPrecision(t):String(i)}function Yn(i){return Number.isNaN(i)}function Xn(i){return Number.isFinite(i)}function jn(i,t=10){return Number.parseInt(i,t)}function Jn(i){return Number.parseFloat(i)}function Zn(i,t=0){const e=Number(i);return isNaN(e)?t:e}function Gn(i,t,e=0){return!L(i)||!L(t)||t===0?e:i/t}function Qn(...i){return i.reduce((t,e)=>!L(t)||!L(e)?0:t*e,1)}const pe={isNumber:L,isInteger:Dn,isFloat:Hn,isPositive:Mn,isNegative:Tn,isZero:In,clamp:An,round:zn,floor:Pn,ceil:$n,abs:Bn,min:qn,max:On,sum:de,average:Fn,random:ue,randomInt:Nn,format:Rn,formatCurrency:Vn,formatPercent:Kn,toFixed:Wn,toPrecision:Un,isNaN:Yn,isFinite:Xn,parseInt:jn,parseFloat:Jn,toNumber:Zn,safeDivide:Gn,safeMultiply:Qn};function rt(){return Date.now()}function W(){const i=new Date;return i.setHours(0,0,0,0),i}function tr(){const i=W();return i.setDate(i.getDate()+1),i}function er(){const i=W();return i.setDate(i.getDate()-1),i}function k(i){return i instanceof Date&&!isNaN(i.getTime())}function fe(i){return k(i)}function sr(i){const t=new Date(i);return fe(t)?t:null}function ir(i,t="YYYY-MM-DD HH:mm:ss"){if(!k(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"),o=String(i.getSeconds()).padStart(2,"0"),l=String(i.getMilliseconds()).padStart(3,"0"),h=["日","一","二","三","四","五","六"][i.getDay()];return t.replace("YYYY",e).replace("MM",s).replace("DD",n).replace("HH",r).replace("mm",a).replace("ss",o).replace("SSS",l).replace("D",i.getDate()).replace("M",i.getMonth()+1).replace("H",i.getHours()).replace("m",i.getMinutes()).replace("s",i.getSeconds()).replace("W",h)}function nr(i){return k(i)?i.toISOString():""}function rr(i){return k(i)?new Date(i.toUTCString()):null}function ar(i,t){if(!k(i))return i;const e=new Date(i);return e.setDate(e.getDate()+t),e}function or(i,t){if(!k(i))return i;const e=new Date(i);return e.setHours(e.getHours()+t),e}function lr(i,t){if(!k(i))return i;const e=new Date(i);return e.setMinutes(e.getMinutes()+t),e}function cr(i,t){if(!k(i))return i;const e=new Date(i);return e.setSeconds(e.getSeconds()+t),e}function at(i,t){if(!k(i)||!k(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 hr(i,t){return!k(i)||!k(t)?0:Math.floor((i.getTime()-t.getTime())/(1e3*60*60))}function dr(i,t){return!k(i)||!k(t)?0:Math.floor((i.getTime()-t.getTime())/(1e3*60))}function ur(i,t){return!k(i)||!k(t)?0:Math.floor((i.getTime()-t.getTime())/1e3)}function pr(i){return k(i)?at(i,W())===0:!1}function fr(i){return k(i)?at(i,W())===-1:!1}function mr(i){return k(i)?at(i,W())===1:!1}function gr(i){return k(i)?i.getTime()>rt():!1}function _r(i){return k(i)?i.getTime()<rt():!1}function yr(i){if(!k(i))return!1;const t=i.getFullYear();return t%4===0&&(t%100!==0||t%400===0)}function vr(i){return k(i)?new Date(i.getFullYear(),i.getMonth()+1,0).getDate():0}function br(i){if(!k(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 xr(i){return k(i)?Math.ceil((i.getMonth()+1)/3):0}function Er(i){if(!k(i))return i;const t=new Date(i);return t.setHours(0,0,0,0),t}function kr(i){if(!k(i))return i;const t=new Date(i);return t.setHours(23,59,59,999),t}function wr(i){return k(i)?new Date(i.getFullYear(),i.getMonth(),1):i}function Cr(i){return k(i)?new Date(i.getFullYear(),i.getMonth()+1,0,23,59,59,999):i}function me(i,t=1){if(!k(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 Sr(i,t=1){if(!k(i))return i;const e=me(i,t),s=new Date(e);return s.setDate(s.getDate()+6),s.setHours(23,59,59,999),s}function Lr(i){if(!k(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 Dr(i){if(!k(i))return"";const e=rt()-i.getTime(),s=60*1e3,n=60*s,r=24*n,a=7*r,o=30*r,l=365*r;return e<s?"刚刚":e<n?`${Math.floor(e/s)}分钟前`:e<r?`${Math.floor(e/n)}小时前`:e<a?`${Math.floor(e/r)}天前`:e<o?`${Math.floor(e/a)}周前`:e<l?`${Math.floor(e/o)}个月前`:`${Math.floor(e/l)}年前`}const ge={now:rt,today:W,tomorrow:tr,yesterday:er,isDate:k,isValid:fe,parse:sr,format:ir,toISO:nr,toUTC:rr,addDays:ar,addHours:or,addMinutes:lr,addSeconds:cr,diffDays:at,diffHours:hr,diffMinutes:dr,diffSeconds:ur,isToday:pr,isYesterday:fr,isTomorrow:mr,isFuture:gr,isPast:_r,isLeapYear:yr,getDaysInMonth:vr,getWeekOfYear:br,getQuarter:xr,startOfDay:Er,endOfDay:kr,startOfMonth:wr,endOfMonth:Cr,startOfWeek:me,endOfWeek:Sr,getAge:Lr,fromNow:Dr};function _e(i,t,e={}){let s=null,n=null,r=null,a=0;const o=e.leading||!1,l=e.trailing!==!1;function c(){i.apply(r,n)}function h(){a=Date.now(),o?(s=setTimeout(d,t),c()):s=setTimeout(d,t)}function d(){s=null,l&&n&&c(),n=null,r=null}function u(){return Math.max(0,t-(Date.now()-a))}return function(...f){n=f,r=this,a=Date.now(),s?(clearTimeout(s),s=setTimeout(d,u())):h()}}function ye(i,t,e={}){let s=!1;const n=e.trailing||!1;let r=null,a=null;function o(){i.apply(a,r),r=null,a=null}return function(...l){s?n&&(r=l,a=this):(s=!0,r=l,a=this,o(),setTimeout(()=>{s=!1,n&&r&&o()},t))}}function Hr(i){return/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(i||"")}function Mr(i){return/^1[3-9]\d{9}$/.test(i||"")}function Tr(i){return/^(https?:\/\/)?([\da-z.-]+)\.([a-z.]{2,6})([/\w.-]*)*\/?$/.test(i||"")}function ve(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 be(i){return/^([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$/.test(i||"")}function Ir(i){return ve(i)||be(i)}function Ar(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 zr(i){return/^[A-Z][0-9]{8}$|^[A-Z]{2}[0-9]{7}$/.test(i||"")}function Pr(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 xe(i){return/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/.test(i||"")}function Ee(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 ke(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 $r(i){return xe(i)||Ee(i)||ke(i)}function Br(i){return!isNaN(new Date(i).getTime())}function qr(i){try{return JSON.parse(i),!0}catch{return!1}}function Or(i){return!i||i.trim()===""}function Fr(i){return/^\s+$/.test(i||"")}function Nr(i){return!isNaN(parseFloat(i))&&isFinite(i)}function Rr(i){return/^-?\d+$/.test(i||"")}function Vr(i){return/^-?\d+\.\d+$/.test(i||"")}function Kr(i){const t=parseFloat(i);return!isNaN(t)&&t>0}function Wr(i){const t=parseFloat(i);return!isNaN(t)&&t<0}function Ur(i){return/^[a-zA-Z]+$/.test(i||"")}function Yr(i){return/^[a-zA-Z0-9]+$/.test(i||"")}function Xr(i){return/^[\u4e00-\u9fa5]+$/.test(i||"")}function jr(i,t,e){const s=(i||"").length;return s>=t&&(e===void 0||s<=e)}function Jr(i,t){return(i||"").length>=t}function Zr(i,t){return(i||"").length<=t}function Gr(i,t){return t instanceof RegExp?t.test(i||""):!1}function Qr(i,t){return String(i)===String(t)}function we(i,t){return(i||"").includes(t)}function ta(i,t){return!we(i,t)}function ea(i){return Array.isArray(i)}function sa(i,t,e){const s=i?i.length:0;return s>=t&&(e===void 0||s<=e)}function ia(i,t){return i?i.length>=t:!1}function na(i,t){return i?i.length<=t:!1}function ra(i){return i!==null&&typeof i=="object"&&!Array.isArray(i)}function aa(i,t){return!i||!t||!Array.isArray(t)?!1:t.every(e=>Object.prototype.hasOwnProperty.call(i,e))}function oa(i,t){const e={};return Object.keys(t).forEach(s=>{const n=i[s],r=t[s],a=[];r.forEach(o=>{if(typeof o=="string"){const[l,...c]=o.split(":");ft[l](n,...c)||a.push(l)}else if(typeof o=="function"){const l=o(n,i);l!==!0&&a.push(l||"validation_failed")}}),a.length>0&&(e[s]=a)}),{valid:Object.keys(e).length===0,errors:e}}const ft={isEmail:Hr,isPhone:Mr,isURL:Tr,isIPv4:ve,isIPv6:be,isIP:Ir,isIDCard:Ar,isPassport:zr,isCreditCard:Pr,isHexColor:xe,isRGB:Ee,isRGBA:ke,isColor:$r,isDate:Br,isJSON:qr,isEmpty:Or,isWhitespace:Fr,isNumber:Nr,isInteger:Rr,isFloat:Vr,isPositive:Kr,isNegative:Wr,isAlpha:Ur,isAlphaNumeric:Yr,isChinese:Xr,isLength:jr,minLength:Jr,maxLength:Zr,matches:Gr,equals:Qr,contains:we,notContains:ta,isArray:ea,arrayLength:sa,arrayMinLength:ia,arrayMaxLength:na,isObject:ra,hasKeys:aa,validate:oa};function la(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(d,u){return d<<u|d>>>32-u}function a(d){const u=d.length*8;for(d+="€";d.length%64!==56;)d+="\0";const f=u&4294967295,p=u>>>32&4294967295;for(let m=0;m<4;m++)d+=String.fromCharCode(f>>>8*m&255);for(let m=0;m<4;m++)d+=String.fromCharCode(p>>>8*m&255);return d}function o(d,u){const[f,p,m,y]=u,_=[];for(let S=0;S<16;S++)_[S]=d.charCodeAt(S*4)&255|(d.charCodeAt(S*4+1)&255)<<8|(d.charCodeAt(S*4+2)&255)<<16|(d.charCodeAt(S*4+3)&255)<<24;let b=f,x=p,v=m,C=y;for(let S=0;S<64;S++){let w,A;const z=Math.floor(S/16),D=S%16;z===0?(w=x&v|~x&C,A=D):z===1?(w=C&x|~C&v,A=(5*D+1)%16):z===2?(w=x^v^C,A=(3*D+5)%16):(w=v^(x|~C),A=7*D%16);const B=C;C=v,v=x,x=x+r(b+w+s[S]+_[A]&4294967295,n[z][S%4]),b=B}return[f+b&4294967295,p+x&4294967295,m+v&4294967295,y+C&4294967295]}const l=a(t);let c=[...e];for(let d=0;d<l.length;d+=64)c=o(l.substring(d,d+64),c);let h="";return c.forEach(d=>{for(let u=0;u<4;u++)h+=(d>>>8*u&255).toString(16).padStart(2,"0")}),h}function ca(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,h){return c>>>h|c<<32-h}function n(c){const h=c.length*8;for(c+="€";c.length%64!==56;)c+="\0";const d=h&4294967295,u=h>>>32&4294967295;for(let f=0;f<4;f++)c+=String.fromCharCode(u>>>8*f&255);for(let f=0;f<4;f++)c+=String.fromCharCode(d>>>8*f&255);return c}function r(c,h){const d=[];for(let v=0;v<16;v++)d[v]=c.charCodeAt(v*4)&255|(c.charCodeAt(v*4+1)&255)<<8|(c.charCodeAt(v*4+2)&255)<<16|(c.charCodeAt(v*4+3)&255)<<24;for(let v=16;v<64;v++){const C=s(d[v-15],7)^s(d[v-15],18)^d[v-15]>>>3,S=s(d[v-2],17)^s(d[v-2],19)^d[v-2]>>>10;d[v]=d[v-16]+C+d[v-7]+S&4294967295}let[u,f,p,m,y,_,b,x]=h;for(let v=0;v<64;v++){const C=s(y,6)^s(y,11)^s(y,25),S=y&_^~y&b,w=x+C+S+e[v]+d[v]&4294967295,A=s(u,2)^s(u,13)^s(u,22),z=u&f^u&p^f&p,D=A+z&4294967295;x=b,b=_,_=y,y=m+w&4294967295,m=p,p=f,f=u,u=w+D&4294967295}return[h[0]+u&4294967295,h[1]+f&4294967295,h[2]+p&4294967295,h[3]+m&4294967295,h[4]+y&4294967295,h[5]+_&4294967295,h[6]+b&4294967295,h[7]+x&4294967295]}const a=n(t);let o=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225];for(let c=0;c<a.length;c+=64)o=r(a.substring(c,c+64),o);let l="";return o.forEach(c=>{for(let h=3;h>=0;h--)l+=(c>>>8*h&255).toString(16).padStart(2,"0")}),l}function ha(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,o=n[s++]||0,l=r>>2,c=(r&3)<<4|a>>4,h=(a&15)<<2|o>>6,d=o&63;e+=t[l]+t[c]+(s>n.length+1?"=":t[h])+(s>n.length?"=":t[d])}return e}function da(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++)),o=t.indexOf(i.charAt(s++)),l=n<<2|r>>4,c=(r&15)<<4|a>>2,h=(a&3)<<6|o;e+=String.fromCharCode(l),a!==64&&(e+=String.fromCharCode(c)),o!==64&&(e+=String.fromCharCode(h))}return e}function ua(){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:la,sha256:ca,base64Encode:ha,base64Decode:da,uuid:ua},$=new Map;async function G(i,t={}){const{crossOrigin:e="anonymous"}=t;return $.has(i)?$.get(i):new Promise((s,n)=>{const r=new Image;r.crossOrigin=e,r.onload=()=>{$.set(i,r),s(r)},r.onerror=()=>{n(new Error(`Failed to load image: ${i}`))},r.src=i})}async function pa(i,t={}){const{parallel:e=!0}=t;if(e)return Promise.all(i.map(n=>G(n,t)));const s=[];for(const n of i)s.push(await G(n,t));return s}async function Se(i,t={}){const{type:e="text/javascript",async:s=!0,defer:n=!1}=t;return $.has(i)?$.get(i):new Promise((r,a)=>{const o=document.createElement("script");o.type=e,o.async=s,o.defer=n,o.onload=()=>{$.set(i,o),r(o)},o.onerror=()=>{o.remove(),a(new Error(`Failed to load script: ${i}`))},o.src=i,document.head.appendChild(o)})}async function Le(i,t={}){const{media:e="all"}=t;return $.has(i)?$.get(i):new Promise((s,n)=>{const r=document.createElement("link");r.rel="stylesheet",r.href=i,r.media=e,r.onload=()=>{$.set(i,r),s(r)},r.onerror=()=>{r.remove(),n(new Error(`Failed to load stylesheet: ${i}`))},document.head.appendChild(r)})}async function fa(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 ma(i,t="image"){switch(t){case"image":return G(i);case"script":return Se(i);case"stylesheet":case"style":return Le(i);default:throw new Error(`Unsupported preload type: ${t}`)}}function ga(i){return $.has(i)}function _a(){$.clear()}function ya(i){$.delete(i)}const De={loadImage:G,loadImages:pa,loadScript:Se,loadStylesheet:Le,loadFont:fa,preload:ma,isLoaded:ga,clearCache:_a,clearCacheByUrl:ya},va={string:ie,array:ae,object:he,number:pe,date:ge,debounce:_e,throttle:ye,validator:ft,crypto:Ce,preload:De};function ba(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 jt{constructor(){this.children={},this.keys=[]}}class ct{constructor(){this.root=new jt}insert(t){let e=this.root;const s=t.split(".");s.forEach((n,r)=>{e.children[n]||(e.children[n]=new jt),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 o=l=>{l.keys.length>0&&n.push(...l.keys),Object.values(l.children).forEach(c=>o(c))};o(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 g={parent:Symbol("reactive_parent"),path:Symbol("reactive_path"),isReactive:Symbol("reactive_is_reactive")};class He{constructor(){this.rawData={},this.data=null,this.observers={},this.elements={},this.computedProperties={},this.pathTrie=new ct,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),o=Reflect.set(e,s,n,r),l=this.resolvePath(e,s);return this.notify(l,n,a),this.queueUpdate(l,n),o},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[g.isReactive])return t;if(this._proxyCache.has(t))return this._proxyCache.get(t);const s={get:(r,a,o)=>{if(a==="__raw__")return r;if(a===g.parent||a==="__parent__")return r[g.parent];if(a===g.path||a==="__path__")return r[g.path];if(a===g.isReactive||a==="__isReactive__")return!0;const l=Reflect.get(r,a,o);return l&&typeof l=="object"&&!Array.isArray(l)?this.wrapReactive(l,`${r[g.path]}${r[g.path]?".":""}${a}`):l},set:(r,a,o,l)=>{if(a===g.parent||a===g.path||a===g.isReactive||a==="__parent__"||a==="__path__"||a==="__isReactive__")return!0;const c=Reflect.get(r,a,l),h=Reflect.set(r,a,o,l),d=`${r[g.path]}${r[g.path]?".":""}${a}`;return this.notify(d,o,c),this.queueUpdate(d,o),h},deleteProperty:(r,a)=>{if(a===g.parent||a===g.path||a===g.isReactive)return!1;const o=Reflect.get(r,a),l=Reflect.deleteProperty(r,a),c=`${r[g.path]}${r[g.path]?".":""}${a}`;return this.notify(c,void 0,o),this.queueUpdate(c,void 0),l},has:(r,a)=>a==="__raw__"||a===g.parent||a===g.path||a===g.isReactive||a==="__parent__"||a==="__path__"||a==="__isReactive__"?!0:a in r,ownKeys:r=>Reflect.ownKeys(r).filter(a=>a!==g.parent&&a!==g.path&&a!==g.isReactive),getOwnPropertyDescriptor:(r,a)=>a===g.parent||a===g.path||a===g.isReactive?{configurable:!1,enumerable:!1,writable:!1,value:r[a]}:Reflect.getOwnPropertyDescriptor(r,a)},n=new Proxy(t,s);return t[g.parent]=t,t[g.path]=e,t[g.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[g.path]?`${t[g.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((o,l)=>(o[l]||(o[l]={}),o[l]),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(":"),o=a[0].trim(),l=a[1]?.trim();switch(o){case"text":t.textContent!==String(e??"")&&(t.textContent=e??"");break;case"html":const c=ba(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 h=e?"none":"";t.style.display!==h&&(t.style.display=h);break;case"class":l&&(e?t.classList.add(l):t.classList.remove(l));break;case"style":l&&t.style[l]!==String(e??"")&&(t.style[l]=e??"");break;case"attr":l&&t.getAttribute(l)!==String(e??"")&&t.setAttribute(l,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 ct,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:o=null}=e,l=s==="session"?sessionStorage:localStorage;this.persistedKeys.set(t,{storage:l,debounce:n,timeout:null,version:r,encrypt:a,encryptionKey:o});const c=this.get(t);c!==void 0&&this._persistSave(t,c,l,{version:r,encrypt:a,encryptionKey:o}),this.observe(t,h=>{const d=this.persistedKeys.get(t);d&&(d.debounce>0?(d.timeout&&clearTimeout(d.timeout),d.timeout=setTimeout(()=>{this._persistSave(t,h,d.storage,{version:d.version,encrypt:d.encrypt,encryptionKey:d.encryptionKey})},d.debounce)):this._persistSave(t,h,d.storage,{version:d.version,encrypt:d.encrypt,encryptionKey:d.encryptionKey}))})}_persistSave(t,e,s,n={}){try{const{version:r=1,encrypt:a=!1,encryptionKey:o=null}=n,l={value:e,version:r,timestamp:Date.now()};let c=JSON.stringify(l);a&&o&&(c=this._encrypt(c,o)),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 o=localStorage.getItem(r);let l;if(s){const c=this._decrypt(o,s);l=JSON.parse(c)}else l=JSON.parse(o);if(l.version!==void 0&&l.version!==t.version){console.debug(`Skipping outdated data for ${a} (version ${l.version})`);continue}e[a]=l.value!==void 0?l.value:l}catch(o){console.warn(`Failed to load persisted key ${a}:`,o)}}}for(let n=0;n<sessionStorage.length;n++){const r=sessionStorage.key(n);if(r?.startsWith("kupola:")){const a=r.replace("kupola:","");try{const o=sessionStorage.getItem(r);let l;if(s){const c=this._decrypt(o,s);l=JSON.parse(c)}else l=JSON.parse(o);if(l.version!==void 0&&l.version!==t.version){console.debug(`Skipping outdated data for ${a} (version ${l.version})`);continue}e[a]=l.value!==void 0?l.value:l}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[g.isReactive])return t;if(this._proxyCache.has(t))return this._proxyCache.get(t);const s={get:(r,a,o)=>{if(a==="__raw__")return r;if(a===g.parent||a==="__parent__")return r[g.parent];if(a===g.path||a==="__path__")return r[g.path];if(a===g.isReactive||a==="__isReactive__")return!0;const l=Reflect.get(r,a,o);return l&&typeof l=="object"&&!Array.isArray(l)?this.wrapReactive(l,`${r[g.path]}${r[g.path]?".":""}${a}`):l},set:(r,a,o,l)=>{if(a===g.parent||a===g.path||a===g.isReactive||a==="__parent__"||a==="__path__"||a==="__isReactive__")return!0;const c=Reflect.get(r,a,l),h=Reflect.set(r,a,o,l),d=`${r[g.path]}${r[g.path]?".":""}${a}`;return this.notify(d,o,c),this.queueUpdate(d,o),h},deleteProperty:(r,a)=>{if(a===g.parent||a===g.path||a===g.isReactive)return!1;const o=Reflect.get(r,a),l=Reflect.deleteProperty(r,a),c=`${r[g.path]}${r[g.path]?".":""}${a}`;return this.notify(c,void 0,o),this.queueUpdate(c,void 0),l},has:(r,a)=>a==="__raw__"||a===g.parent||a===g.path||a===g.isReactive||a==="__parent__"||a==="__path__"||a==="__isReactive__"?!0:a in r,ownKeys:r=>Reflect.ownKeys(r).filter(a=>a!==g.parent&&a!==g.path&&a!==g.isReactive),getOwnPropertyDescriptor:(r,a)=>a===g.parent||a===g.path||a===g.isReactive?{configurable:!1,enumerable:!1,writable:!1,value:r[a]}:Reflect.getOwnPropertyDescriptor(r,a)},n=new Proxy(t,s);return t[g.parent]=t,t[g.path]=e,t[g.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 o=t.type==="checkbox"?t.checked:t.value;n.includes(".")?this.setNested(n,o):this.set(n,o)};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 ct,this.updateQueue.clear(),this.snapshots=[]}}class dt{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 dt(t,e);return this.stores.set(t,s),s}getStore(t){return this.stores.get(t)}registerStore(t){t instanceof dt&&this.stores.set(t.name,t)}dispose(){this.stores.clear()}}class Te{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:o})=>{(r.target.matches(a)||r.target.closest(a))&&o(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 He,xa=new Te,mt=new Me;function Ea(i,t){return mt.createStore(i,t)}function ka(i){return mt.getStore(i)}const M={paths:{icons:"/icons/",base:"/"},theme:{default:"dark",brand:"zengqing"},i18n:{locale:"zh-CN",fallbackLocale:"en-US"},http:{baseURL:"",timeout:1e4,headers:{},withCredentials:!1},zIndex:{modal:1e3,dropdown:2e3,tooltip:2100,popover:2200,datepicker:2300,message:3e3,notification:3100,loading:5e3},ui:{defaultSize:"md",modal:{backdropClick:!0},dropdown:{closeOnClick:!0},datepicker:{weekStart:1},tooltip:{delay:300}},performance:{lazyLoad:!1,debounceDelay:200,throttleDelay:100,animationEnabled:!0},security:{xssProtection:!0,sanitizeHtml:{enabled:!0,allowedTags:["b","i","u","em","strong","a","br","p","span","div","img"],allowedAttributes:{a:["href","target","rel"],img:["src","alt","width","height"],span:["class","style"],div:["class","style"]}},maskData:{enabled:!0,patterns:{phone:{regex:"^(\\d{3})\\d{4}(\\d{4})$",replace:"$1****$2"},email:{regex:"^(.)(.*)(@.*)$",replace:"$1***$3"},idCard:{regex:"^(\\d{6})\\d{8}(\\d{4})$",replace:"$1********$2"},bankCard:{regex:"^(\\d{4})\\d{8}(\\d{4})$",replace:"$1 **** **** $2"}}},secureId:{length:16,charset:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"}},message:{duration:3e3,position:"top-right",maxCount:5},notification:{duration:4500,position:"top-right"},validation:{defaultRules:[],showErrors:!0,trigger:"blur"},components:{autoInit:!0,silentErrors:!1}};function wa(i){qe(M,i)}function ot(i){return i?La(M,i):M}function gt(){return M.paths.base+M.paths.icons.replace(/^\//,"")}function Ca(){return M.paths.base}function Ie(){return M.theme.default}function Ae(){return M.theme.brand}function Sa(){return M.http}function U(){return M.ui}function Y(){return M.zIndex}function Z(){return M.security}function ze(){return M.performance}function Pe(){return M.message}function $e(){return M.notification}function Be(){return M.validation}function qe(i,t){for(const e in t)t[e]instanceof Object&&e in i&&i[e]instanceof Object?qe(i[e],t[e]):i[e]=t[e];return i}function La(i,t){return t.split(".").reduce((e,s)=>(e&&e[s])!==void 0?e[s]:void 0,i)}const Oe="kupola-theme",Fe="kupola-brand",V=[{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 N(){return localStorage.getItem(Oe)||Ie()}function Q(i){if(i!=="dark"&&i!=="light")return;document.documentElement.setAttribute("data-theme",i),localStorage.setItem(Oe,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 j(){return localStorage.getItem(Fe)||Ae()}function tt(i){const t=V.find(n=>n.id===i);if(!t)return;document.documentElement.setAttribute("data-brand",i),localStorage.setItem(Fe,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 Jt(i){const t=i.querySelector(".theme-icon");if(t){const e=N(),s=gt();t.src=e==="dark"?s+"sun.svg":s+"moon.svg"}}function Ne(){const i=N();Q(i);const t=j();tt(t);const e=document.querySelector("[data-theme-toggle]");if(e){Jt(e);const o=e.onclick;e.onclick=function(l){l.preventDefault();const h=N()==="dark"?"light":"dark";Q(h),Jt(e),typeof o=="function"&&o.call(this,l)}}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",V.forEach(o=>{const l=document.createElement("button");l.setAttribute("data-brand-btn",o.id),l.style.display="flex",l.style.justifyContent="center",l.style.alignItems="center",l.style.height="60px",l.style.backgroundColor=o.color,l.style.color=["#32F08C","#FF9900","#E2C027","#0EB0C9","#B1A6CC"].includes(o.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=o.name,s.appendChild(l)}),document.body.appendChild(s));const n=document.querySelector("[data-brand-toggle]");n&&s&&(n.onclick=function(o){o.stopPropagation(),o.preventDefault();const l=s.style.display==="none";s.style.display=l?"grid":"none",l?setTimeout(()=>{document.addEventListener("click",r,!0)},0):document.removeEventListener("click",r,!0)},s.onclick=function(o){o.stopPropagation()});function r(o){s&&n&&!s.contains(o.target)&&!n.contains(o.target)&&(s.style.display="none",document.removeEventListener("click",r,!0))}document.querySelectorAll("[data-brand-btn]").forEach(o=>{o.addEventListener("click",l=>{l.stopPropagation();const c=o.getAttribute("data-brand-btn");tt(c),s&&(s.style.display="none")})})}function Da(){const i=document.createElement("button");i.setAttribute("data-theme-toggle",""),i.setAttribute("data-current-theme",N()),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=gt();return t.src=N()==="dark"?e+"sun.svg":e+"moon.svg",t.width=14,t.height=14,t.alt="Toggle theme",i.appendChild(t),document.body.appendChild(i),i.onclick=function(s){s.preventDefault();const r=N()==="dark"?"light":"dark";Q(r)},i}function Ha(){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",V.forEach(a=>{const o=document.createElement("button");o.setAttribute("data-brand-btn",a.id),o.style.display="flex",o.style.justifyContent="center",o.style.alignItems="center",o.style.height="60px",o.style.backgroundColor=a.color,o.style.color=["#32F08C","#FF9900","#E2C027","#0EB0C9","#B1A6CC"].includes(a.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=a.name,i.appendChild(o)}),document.body.appendChild(i);const t=document.createElement("button");t.setAttribute("data-brand-toggle",""),t.setAttribute("data-current-brand",j()),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=V.find(a=>a.id===j()).color;const s=document.createElement("span");s.className="brand-name",s.style.fontSize="11px",s.textContent=V.find(a=>a.id===j()).name,t.appendChild(e),t.appendChild(s),document.body.appendChild(t),t.onclick=function(a){a.stopPropagation(),a.preventDefault();const o=i.style.display==="none";i.style.display=o?"grid":"none",o?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",o=>{o.stopPropagation();const l=a.getAttribute("data-brand-btn");tt(l),i.style.display="none"})}),{toggleBtn:t,container:i}}function Ma(i,t={}){const s=Z()?.sanitizeHtml||{};if(!s.enabled&&!t.force)return i;const n=t.allowedTags||s.allowedTags||[],r=t.allowedAttributes||s.allowedAttributes||{};if(typeof i!="string")return i;const o=new DOMParser().parseFromString(i,"text/html");return o.body.querySelectorAll("*").forEach(c=>{const h=c.tagName.toLowerCase();if(!n.includes(h)){c.remove();return}Array.from(c.attributes).forEach(d=>{const u=d.name.toLowerCase();(r[h]||[]).includes(u)||c.removeAttribute(d.name)})}),o.body.innerHTML}function Ta(i){if(typeof i!="string")return i;const t=document.createElement("div");return t.textContent=i,t.innerHTML}function Ia(i){return typeof i!="string"?i:new DOMParser().parseFromString(i,"text/html").body.textContent||""}function Aa(i,t,e={}){const n=Z()?.maskData||{};if(!n.enabled&&!e.force||i==null)return i;const a=(e.patterns||n.patterns||{})[t];if(!a)return i;const o=typeof a.regex=="string"?new RegExp(a.regex):a.regex;return String(i).replace(o,a.replace)}function za(i,t){const s=Z()?.secureId||{},n=i||s.length||16,r=s.charset||"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";if(typeof crypto>"u"||!crypto.getRandomValues){let l="";for(let c=0;c<n;c++)l+=r[Math.floor(Math.random()*r.length)];return t?`${t}_${l}`:l}const a=new Uint32Array(n);crypto.getRandomValues(a);let o="";for(let l=0;l<n;l++)o+=r[a[l]%r.length];return t?`${t}_${o}`:o}class Re{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(o){console.error(`[ComponentInitializerRegistry] Error initializing "${r}":`,o)}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(o){console.error(`[ComponentInitializerRegistry] Error cleaning up "${r}":`,o)}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 E=new Re,Pa=[{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 Pa)i.attr&&!E._dataAttrs.includes(i.attr)&&E._dataAttrs.push(i.attr),i.cls&&!E._cssClasses.includes(i.cls)&&E._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 it,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
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class it{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 o of s){await this._resolveDepends(o.depends,t);const l=performance.now();let c,h;try{c=o.handler(...e),c instanceof Promise&&await c,o.resolved=!0}catch(u){h=u,console.error(`[KupolaLifecycle] Error in ${t} hook "${o.name}":`,u),t!=="error"&&await this._handleError({phase:t,hook:o.name,error:u,args:e})}const d=performance.now()-l;this.trace.push({emitId:n,phase:t,hookName:o.name,duration:d,status:h?"error":"success",error:h?h.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 Xs=new it("app");function js(i="app"){return new it(i)}const Js=new Set(["__proto__","prototype","constructor"]);function nt(i){return Js.has(i)}function Zs(i){return i?i.trim():""}function Gs(i){return i?i.replace(/^\s+/,""):""}function Qs(i){return i?i.replace(/\s+$/,""):""}function ti(i){return i?i.toUpperCase():""}function ei(i){return i?i.toLowerCase():""}function si(i){return i?i.charAt(0).toUpperCase()+i.slice(1):""}function ii(i){return i?i.replace(/-(\w)/g,(t,e)=>e?e.toUpperCase():""):""}function ni(i){return i?i.replace(/([A-Z])/g,"-$1").toLowerCase().replace(/^-/,""):""}function ri(i,t,e=" "){return(String(i)||"").padStart(t,e)}function ai(i,t,e=" "){return(String(i)||"").padEnd(t,e)}function oi(i,t,e="..."){return!i||i.length<=t?i||"":i.slice(0,t)+e}function li(i,t,e){return i?i.split(t).join(e):""}function ci(i,t){return i?i.replace(/\{\{(\w+)\}\}/g,(e,s)=>t[s]!==void 0?t[s]:`{{${s}}}`):""}function hi(i,t){return(i||"").startsWith(t)}function di(i,t){return(i||"").endsWith(t)}function ui(i,t){return(i||"").includes(t)}function pi(i,t){return(i||"").repeat(t)}function fi(i){return(i||"").split("").reverse().join("")}function mi(i,t){return!i||!t?0:i.split(t).length-1}function gi(i){if(!i)return"";const t=document.createElement("div");return t.textContent=i,t.innerHTML}function _i(i){if(!i)return"";const t=document.createElement("div");return t.innerHTML=i,t.textContent}function yi(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 vi(){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 ie={trim:Zs,trimLeft:Gs,trimRight:Qs,toUpperCase:ti,toLowerCase:ei,capitalize:si,camelize:ii,hyphenate:ni,padStart:ri,padEnd:ai,truncate:oi,replaceAll:li,format:ci,startsWith:hi,endsWith:di,includes:ui,repeat:pi,reverse:fi,countOccurrences:mi,escapeHtml:gi,unescapeHtml:_i,generateRandom:yi,generateUUID:vi};function bi(i){return Array.isArray(i)}function xi(i){return!i||i.length===0}function Ei(i){return i?i.length:0}function ki(i,t){return i&&i.length>0?i[0]:t}function wi(i,t){return i&&i.length>0?i[i.length-1]:t}function Ci(i,t,e){return i&&i[t]!==void 0?i[t]:e}function Si(i,t,e){return i?i.slice(t,e):[]}function Li(...i){return i.reduce((t,e)=>t.concat(e||[]),[])}function Di(i,t=","){return i?i.join(t):""}function Hi(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 Mi(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 Ti(i,t){return i?i.includes(t):!1}function Ii(i,...t){return i&&i.push(...t),i}function Ai(i){return i?i.pop():void 0}function zi(i){return i?i.shift():void 0}function Pi(i,...t){return i&&i.unshift(...t),i}function $i(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 Bi(i,t){return!i||t<0||t>=i.length||i.splice(t,1),i}function qi(i,t,e){return i&&(i.splice(t,0,e),i)}function Oi(i){return i?i.slice().reverse():[]}function Fi(i,t){return i?i.slice().sort(t):[]}function Ni(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 Ri(i,t){return i?i.filter(t):[]}function Vi(i,t){return i?i.map(t):[]}function Ki(i,t,e){return i?i.reduce(t,e):e}function Wi(i,t){i&&i.forEach(t)}function Ui(i,t){return i?i.every(t):!0}function Yi(i,t){return i?i.some(t):!1}function Xi(i,t){return i?i.find(t):void 0}function ji(i,t){return i?i.findIndex(t):-1}function Ji(i,t=1){return i?i.flat(t):[]}function ne(i){return i?i.reduce((t,e)=>Array.isArray(e)?t.concat(ne(e)):t.concat(e),[]):[]}function Zi(i){return i?[...new Set(i)]:[]}function Gi(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 Qi(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 tn(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 re(i){return i?i.reduce((t,e)=>t+(Number(e)||0),0):0}function en(i){return!i||i.length===0?0:re(i)/i.length}function sn(i){return i&&i.length>0?Math.max(...i):-1/0}function nn(i){return i&&i.length>0?Math.min(...i):1/0}function rn(...i){return i.length===0?[]:i.reduce((t,e)=>t.filter(s=>e&&e.includes(s)))}function an(...i){return[...new Set(i.flat().filter(Boolean))]}function on(i,t){return i?i.filter(e=>!t||!t.includes(e)):[]}function ln(...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 ae={isArray:bi,isEmpty:xi,size:Ei,first:ki,last:wi,get:Ci,slice:Si,concat:Li,join:Di,indexOf:Hi,lastIndexOf:Mi,includes:Ti,push:Ii,pop:Ai,shift:zi,unshift:Pi,remove:$i,removeAt:Bi,insert:qi,reverse:Oi,sort:Fi,sortBy:Ni,filter:Ri,map:Vi,reduce:Ki,forEach:Wi,every:Ui,some:Yi,find:Xi,findIndex:ji,flat:Ji,flattenDeep:ne,unique:Zi,uniqueBy:Gi,chunk:Qi,shuffle:tn,sum:re,average:en,max:sn,min:nn,intersection:rn,union:an,difference:on,zip:ln};function ht(i){return i!==null&&typeof i=="object"&&!Array.isArray(i)}function cn(i){return!i||typeof i!="object"?!0:Object.keys(i).length===0}function hn(i){return i?Object.keys(i):[]}function dn(i){return i?Object.values(i):[]}function un(i){return i?Object.entries(i):[]}function pn(i,t){return i?Object.prototype.hasOwnProperty.call(i,t):!1}function fn(i,t,e){if(!i)return e;const s=t.split(".");return s.some(nt)?e:s.reduce((n,r)=>n&&n[r],i)??e}function mn(i,t,e){if(!i||typeof i!="object")return i;const s=t.split(".");if(s.some(nt))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 gn(i,t){return i?t.reduce((e,s)=>(i[s]!==void 0&&(e[s]=i[s]),e),{}):{}}function _n(i,t){return i?Object.keys(i).reduce((e,s)=>(t.includes(s)||(e[s]=i[s]),e),{}):{}}function oe(...i){return i.reduce((t,e)=>(e&&typeof e=="object"&&Object.keys(e).forEach(s=>{nt(s)||(ht(e[s])&&ht(t[s])?t[s]=oe(t[s],e[s]):t[s]=e[s])}),t),{})}function yn(i){return i&&JSON.parse(JSON.stringify(i))}function X(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,X(n,t))),s}if(i instanceof Set){const s=new Set;return t.set(i,s),i.forEach(n=>s.add(X(n,t))),s}if(Array.isArray(i)){const s=[];return t.set(i,s),i.forEach(n=>s.push(X(n,t))),s}const e={};return t.set(i,e),Object.keys(i).forEach(s=>{nt(s)||(e[s]=X(i[s],t))}),e}function vn(i,t){i&&Object.keys(i).forEach(e=>t(i[e],e,i))}function bn(i,t){if(!i)return{};const e={};return Object.keys(i).forEach(s=>{e[s]=t(i[s],s,i)}),e}function xn(i,t){if(!i)return{};const e={};return Object.keys(i).forEach(s=>{t(i[s],s,i)&&(e[s]=i[s])}),e}function En(i,t,e){return i?Object.keys(i).reduce((s,n)=>t(s,i[n],n,i),e):e}function kn(i){return i?Object.keys(i).map(t=>({key:t,value:i[t]})):[]}function wn(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 Cn(i){return i?Object.keys(i).length:0}function Sn(i){if(!i)return{};const t={};return Object.keys(i).forEach(e=>{t[i[e]]=e}),t}function le(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=>le(i[n],t[n]))}function ce(i){return i&&(Object.freeze(i),Object.keys(i).forEach(t=>{typeof i[t]=="object"&&ce(i[t])}),i)}function Ln(i){return i&&Object.seal(i)}const he={isObject:ht,isEmpty:cn,keys:hn,values:dn,entries:un,has:pn,get:fn,set:mn,pick:gn,omit:_n,merge:oe,clone:yn,deepClone:X,forEach:vn,map:bn,filter:xn,reduce:En,toArray:kn,fromArray:wn,size:Cn,invert:Sn,isEqual:le,freeze:ce,seal:Ln};function L(i){return typeof i=="number"&&!isNaN(i)}function Dn(i){return Number.isInteger(i)}function Hn(i){return L(i)&&!Number.isInteger(i)}function Mn(i){return L(i)&&i>0}function Tn(i){return L(i)&&i<0}function In(i){return L(i)&&i===0}function An(i,t,e){return L(i)?Math.min(Math.max(i,t),e):i}function zn(i,t=0){if(!L(i))return i;const e=Math.pow(10,t);return Math.round(i*e)/e}function Pn(i){return L(i)?Math.floor(i):i}function $n(i){return L(i)?Math.ceil(i):i}function Bn(i){return L(i)?Math.abs(i):i}function qn(...i){const t=i.filter(L);return t.length>0?Math.min(...t):void 0}function On(...i){const t=i.filter(L);return t.length>0?Math.max(...t):void 0}function de(...i){return i.flat().filter(L).reduce((e,s)=>e+s,0)}function Fn(...i){const t=i.flat().filter(L);return t.length>0?de(t)/t.length:0}function ue(i=0,t=1){return Math.random()*(t-i)+i}function Nn(i,t){return Math.floor(ue(i,t+1))}function Rn(i,t=2){return L(i)?i.toFixed(t):String(i)}function Vn(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 Kn(i,t=0){return L(i)?`${(i*100).toFixed(t)}%`:String(i)}function Wn(i,t=0){return L(i)?i.toFixed(t):String(i)}function Un(i,t=6){return L(i)?i.toPrecision(t):String(i)}function Yn(i){return Number.isNaN(i)}function Xn(i){return Number.isFinite(i)}function jn(i,t=10){return Number.parseInt(i,t)}function Jn(i){return Number.parseFloat(i)}function Zn(i,t=0){const e=Number(i);return isNaN(e)?t:e}function Gn(i,t,e=0){return!L(i)||!L(t)||t===0?e:i/t}function Qn(...i){return i.reduce((t,e)=>!L(t)||!L(e)?0:t*e,1)}const pe={isNumber:L,isInteger:Dn,isFloat:Hn,isPositive:Mn,isNegative:Tn,isZero:In,clamp:An,round:zn,floor:Pn,ceil:$n,abs:Bn,min:qn,max:On,sum:de,average:Fn,random:ue,randomInt:Nn,format:Rn,formatCurrency:Vn,formatPercent:Kn,toFixed:Wn,toPrecision:Un,isNaN:Yn,isFinite:Xn,parseInt:jn,parseFloat:Jn,toNumber:Zn,safeDivide:Gn,safeMultiply:Qn};function rt(){return Date.now()}function W(){const i=new Date;return i.setHours(0,0,0,0),i}function tr(){const i=W();return i.setDate(i.getDate()+1),i}function er(){const i=W();return i.setDate(i.getDate()-1),i}function k(i){return i instanceof Date&&!isNaN(i.getTime())}function fe(i){return k(i)}function sr(i){const t=new Date(i);return fe(t)?t:null}function ir(i,t="YYYY-MM-DD HH:mm:ss"){if(!k(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"),o=String(i.getSeconds()).padStart(2,"0"),l=String(i.getMilliseconds()).padStart(3,"0"),h=["日","一","二","三","四","五","六"][i.getDay()];return t.replace("YYYY",e).replace("MM",s).replace("DD",n).replace("HH",r).replace("mm",a).replace("ss",o).replace("SSS",l).replace("D",i.getDate()).replace("M",i.getMonth()+1).replace("H",i.getHours()).replace("m",i.getMinutes()).replace("s",i.getSeconds()).replace("W",h)}function nr(i){return k(i)?i.toISOString():""}function rr(i){return k(i)?new Date(i.toUTCString()):null}function ar(i,t){if(!k(i))return i;const e=new Date(i);return e.setDate(e.getDate()+t),e}function or(i,t){if(!k(i))return i;const e=new Date(i);return e.setHours(e.getHours()+t),e}function lr(i,t){if(!k(i))return i;const e=new Date(i);return e.setMinutes(e.getMinutes()+t),e}function cr(i,t){if(!k(i))return i;const e=new Date(i);return e.setSeconds(e.getSeconds()+t),e}function at(i,t){if(!k(i)||!k(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 hr(i,t){return!k(i)||!k(t)?0:Math.floor((i.getTime()-t.getTime())/(1e3*60*60))}function dr(i,t){return!k(i)||!k(t)?0:Math.floor((i.getTime()-t.getTime())/(1e3*60))}function ur(i,t){return!k(i)||!k(t)?0:Math.floor((i.getTime()-t.getTime())/1e3)}function pr(i){return k(i)?at(i,W())===0:!1}function fr(i){return k(i)?at(i,W())===-1:!1}function mr(i){return k(i)?at(i,W())===1:!1}function gr(i){return k(i)?i.getTime()>rt():!1}function _r(i){return k(i)?i.getTime()<rt():!1}function yr(i){if(!k(i))return!1;const t=i.getFullYear();return t%4===0&&(t%100!==0||t%400===0)}function vr(i){return k(i)?new Date(i.getFullYear(),i.getMonth()+1,0).getDate():0}function br(i){if(!k(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 xr(i){return k(i)?Math.ceil((i.getMonth()+1)/3):0}function Er(i){if(!k(i))return i;const t=new Date(i);return t.setHours(0,0,0,0),t}function kr(i){if(!k(i))return i;const t=new Date(i);return t.setHours(23,59,59,999),t}function wr(i){return k(i)?new Date(i.getFullYear(),i.getMonth(),1):i}function Cr(i){return k(i)?new Date(i.getFullYear(),i.getMonth()+1,0,23,59,59,999):i}function me(i,t=1){if(!k(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 Sr(i,t=1){if(!k(i))return i;const e=me(i,t),s=new Date(e);return s.setDate(s.getDate()+6),s.setHours(23,59,59,999),s}function Lr(i){if(!k(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 Dr(i){if(!k(i))return"";const e=rt()-i.getTime(),s=60*1e3,n=60*s,r=24*n,a=7*r,o=30*r,l=365*r;return e<s?"刚刚":e<n?`${Math.floor(e/s)}分钟前`:e<r?`${Math.floor(e/n)}小时前`:e<a?`${Math.floor(e/r)}天前`:e<o?`${Math.floor(e/a)}周前`:e<l?`${Math.floor(e/o)}个月前`:`${Math.floor(e/l)}年前`}const ge={now:rt,today:W,tomorrow:tr,yesterday:er,isDate:k,isValid:fe,parse:sr,format:ir,toISO:nr,toUTC:rr,addDays:ar,addHours:or,addMinutes:lr,addSeconds:cr,diffDays:at,diffHours:hr,diffMinutes:dr,diffSeconds:ur,isToday:pr,isYesterday:fr,isTomorrow:mr,isFuture:gr,isPast:_r,isLeapYear:yr,getDaysInMonth:vr,getWeekOfYear:br,getQuarter:xr,startOfDay:Er,endOfDay:kr,startOfMonth:wr,endOfMonth:Cr,startOfWeek:me,endOfWeek:Sr,getAge:Lr,fromNow:Dr};function _e(i,t,e={}){let s=null,n=null,r=null,a=0;const o=e.leading||!1,l=e.trailing!==!1;function c(){i.apply(r,n)}function h(){a=Date.now(),o?(s=setTimeout(d,t),c()):s=setTimeout(d,t)}function d(){s=null,l&&n&&c(),n=null,r=null}function u(){return Math.max(0,t-(Date.now()-a))}return function(...f){n=f,r=this,a=Date.now(),s?(clearTimeout(s),s=setTimeout(d,u())):h()}}function ye(i,t,e={}){let s=!1;const n=e.trailing||!1;let r=null,a=null;function o(){i.apply(a,r),r=null,a=null}return function(...l){s?n&&(r=l,a=this):(s=!0,r=l,a=this,o(),setTimeout(()=>{s=!1,n&&r&&o()},t))}}function Hr(i){return/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(i||"")}function Mr(i){return/^1[3-9]\d{9}$/.test(i||"")}function Tr(i){return/^(https?:\/\/)?([\da-z.-]+)\.([a-z.]{2,6})([/\w.-]*)*\/?$/.test(i||"")}function ve(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 be(i){return/^([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$/.test(i||"")}function Ir(i){return ve(i)||be(i)}function Ar(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 zr(i){return/^[A-Z][0-9]{8}$|^[A-Z]{2}[0-9]{7}$/.test(i||"")}function Pr(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 xe(i){return/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/.test(i||"")}function Ee(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 ke(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 $r(i){return xe(i)||Ee(i)||ke(i)}function Br(i){return!isNaN(new Date(i).getTime())}function qr(i){try{return JSON.parse(i),!0}catch{return!1}}function Or(i){return!i||i.trim()===""}function Fr(i){return/^\s+$/.test(i||"")}function Nr(i){return!isNaN(parseFloat(i))&&isFinite(i)}function Rr(i){return/^-?\d+$/.test(i||"")}function Vr(i){return/^-?\d+\.\d+$/.test(i||"")}function Kr(i){const t=parseFloat(i);return!isNaN(t)&&t>0}function Wr(i){const t=parseFloat(i);return!isNaN(t)&&t<0}function Ur(i){return/^[a-zA-Z]+$/.test(i||"")}function Yr(i){return/^[a-zA-Z0-9]+$/.test(i||"")}function Xr(i){return/^[\u4e00-\u9fa5]+$/.test(i||"")}function jr(i,t,e){const s=(i||"").length;return s>=t&&(e===void 0||s<=e)}function Jr(i,t){return(i||"").length>=t}function Zr(i,t){return(i||"").length<=t}function Gr(i,t){return t instanceof RegExp?t.test(i||""):!1}function Qr(i,t){return String(i)===String(t)}function we(i,t){return(i||"").includes(t)}function ta(i,t){return!we(i,t)}function ea(i){return Array.isArray(i)}function sa(i,t,e){const s=i?i.length:0;return s>=t&&(e===void 0||s<=e)}function ia(i,t){return i?i.length>=t:!1}function na(i,t){return i?i.length<=t:!1}function ra(i){return i!==null&&typeof i=="object"&&!Array.isArray(i)}function aa(i,t){return!i||!t||!Array.isArray(t)?!1:t.every(e=>Object.prototype.hasOwnProperty.call(i,e))}function oa(i,t){const e={};return Object.keys(t).forEach(s=>{const n=i[s],r=t[s],a=[];r.forEach(o=>{if(typeof o=="string"){const[l,...c]=o.split(":");ft[l](n,...c)||a.push(l)}else if(typeof o=="function"){const l=o(n,i);l!==!0&&a.push(l||"validation_failed")}}),a.length>0&&(e[s]=a)}),{valid:Object.keys(e).length===0,errors:e}}const ft={isEmail:Hr,isPhone:Mr,isURL:Tr,isIPv4:ve,isIPv6:be,isIP:Ir,isIDCard:Ar,isPassport:zr,isCreditCard:Pr,isHexColor:xe,isRGB:Ee,isRGBA:ke,isColor:$r,isDate:Br,isJSON:qr,isEmpty:Or,isWhitespace:Fr,isNumber:Nr,isInteger:Rr,isFloat:Vr,isPositive:Kr,isNegative:Wr,isAlpha:Ur,isAlphaNumeric:Yr,isChinese:Xr,isLength:jr,minLength:Jr,maxLength:Zr,matches:Gr,equals:Qr,contains:we,notContains:ta,isArray:ea,arrayLength:sa,arrayMinLength:ia,arrayMaxLength:na,isObject:ra,hasKeys:aa,validate:oa};function la(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(d,u){return d<<u|d>>>32-u}function a(d){const u=d.length*8;for(d+="€";d.length%64!==56;)d+="\0";const f=u&4294967295,p=u>>>32&4294967295;for(let m=0;m<4;m++)d+=String.fromCharCode(f>>>8*m&255);for(let m=0;m<4;m++)d+=String.fromCharCode(p>>>8*m&255);return d}function o(d,u){const[f,p,m,y]=u,_=[];for(let S=0;S<16;S++)_[S]=d.charCodeAt(S*4)&255|(d.charCodeAt(S*4+1)&255)<<8|(d.charCodeAt(S*4+2)&255)<<16|(d.charCodeAt(S*4+3)&255)<<24;let b=f,x=p,v=m,C=y;for(let S=0;S<64;S++){let w,A;const z=Math.floor(S/16),D=S%16;z===0?(w=x&v|~x&C,A=D):z===1?(w=C&x|~C&v,A=(5*D+1)%16):z===2?(w=x^v^C,A=(3*D+5)%16):(w=v^(x|~C),A=7*D%16);const B=C;C=v,v=x,x=x+r(b+w+s[S]+_[A]&4294967295,n[z][S%4]),b=B}return[f+b&4294967295,p+x&4294967295,m+v&4294967295,y+C&4294967295]}const l=a(t);let c=[...e];for(let d=0;d<l.length;d+=64)c=o(l.substring(d,d+64),c);let h="";return c.forEach(d=>{for(let u=0;u<4;u++)h+=(d>>>8*u&255).toString(16).padStart(2,"0")}),h}function ca(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,h){return c>>>h|c<<32-h}function n(c){const h=c.length*8;for(c+="€";c.length%64!==56;)c+="\0";const d=h&4294967295,u=h>>>32&4294967295;for(let f=0;f<4;f++)c+=String.fromCharCode(u>>>8*f&255);for(let f=0;f<4;f++)c+=String.fromCharCode(d>>>8*f&255);return c}function r(c,h){const d=[];for(let v=0;v<16;v++)d[v]=c.charCodeAt(v*4)&255|(c.charCodeAt(v*4+1)&255)<<8|(c.charCodeAt(v*4+2)&255)<<16|(c.charCodeAt(v*4+3)&255)<<24;for(let v=16;v<64;v++){const C=s(d[v-15],7)^s(d[v-15],18)^d[v-15]>>>3,S=s(d[v-2],17)^s(d[v-2],19)^d[v-2]>>>10;d[v]=d[v-16]+C+d[v-7]+S&4294967295}let[u,f,p,m,y,_,b,x]=h;for(let v=0;v<64;v++){const C=s(y,6)^s(y,11)^s(y,25),S=y&_^~y&b,w=x+C+S+e[v]+d[v]&4294967295,A=s(u,2)^s(u,13)^s(u,22),z=u&f^u&p^f&p,D=A+z&4294967295;x=b,b=_,_=y,y=m+w&4294967295,m=p,p=f,f=u,u=w+D&4294967295}return[h[0]+u&4294967295,h[1]+f&4294967295,h[2]+p&4294967295,h[3]+m&4294967295,h[4]+y&4294967295,h[5]+_&4294967295,h[6]+b&4294967295,h[7]+x&4294967295]}const a=n(t);let o=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225];for(let c=0;c<a.length;c+=64)o=r(a.substring(c,c+64),o);let l="";return o.forEach(c=>{for(let h=3;h>=0;h--)l+=(c>>>8*h&255).toString(16).padStart(2,"0")}),l}function ha(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,o=n[s++]||0,l=r>>2,c=(r&3)<<4|a>>4,h=(a&15)<<2|o>>6,d=o&63;e+=t[l]+t[c]+(s>n.length+1?"=":t[h])+(s>n.length?"=":t[d])}return e}function da(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++)),o=t.indexOf(i.charAt(s++)),l=n<<2|r>>4,c=(r&15)<<4|a>>2,h=(a&3)<<6|o;e+=String.fromCharCode(l),a!==64&&(e+=String.fromCharCode(c)),o!==64&&(e+=String.fromCharCode(h))}return e}function ua(){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:la,sha256:ca,base64Encode:ha,base64Decode:da,uuid:ua},$=new Map;async function G(i,t={}){const{crossOrigin:e="anonymous"}=t;return $.has(i)?$.get(i):new Promise((s,n)=>{const r=new Image;r.crossOrigin=e,r.onload=()=>{$.set(i,r),s(r)},r.onerror=()=>{n(new Error(`Failed to load image: ${i}`))},r.src=i})}async function pa(i,t={}){const{parallel:e=!0}=t;if(e)return Promise.all(i.map(n=>G(n,t)));const s=[];for(const n of i)s.push(await G(n,t));return s}async function Se(i,t={}){const{type:e="text/javascript",async:s=!0,defer:n=!1}=t;return $.has(i)?$.get(i):new Promise((r,a)=>{const o=document.createElement("script");o.type=e,o.async=s,o.defer=n,o.onload=()=>{$.set(i,o),r(o)},o.onerror=()=>{o.remove(),a(new Error(`Failed to load script: ${i}`))},o.src=i,document.head.appendChild(o)})}async function Le(i,t={}){const{media:e="all"}=t;return $.has(i)?$.get(i):new Promise((s,n)=>{const r=document.createElement("link");r.rel="stylesheet",r.href=i,r.media=e,r.onload=()=>{$.set(i,r),s(r)},r.onerror=()=>{r.remove(),n(new Error(`Failed to load stylesheet: ${i}`))},document.head.appendChild(r)})}async function fa(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 ma(i,t="image"){switch(t){case"image":return G(i);case"script":return Se(i);case"stylesheet":case"style":return Le(i);default:throw new Error(`Unsupported preload type: ${t}`)}}function ga(i){return $.has(i)}function _a(){$.clear()}function ya(i){$.delete(i)}const De={loadImage:G,loadImages:pa,loadScript:Se,loadStylesheet:Le,loadFont:fa,preload:ma,isLoaded:ga,clearCache:_a,clearCacheByUrl:ya},va={string:ie,array:ae,object:he,number:pe,date:ge,debounce:_e,throttle:ye,validator:ft,crypto:Ce,preload:De};function ba(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 jt{constructor(){this.children={},this.keys=[]}}class ct{constructor(){this.root=new jt}insert(t){let e=this.root;const s=t.split(".");s.forEach((n,r)=>{e.children[n]||(e.children[n]=new jt),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 o=l=>{l.keys.length>0&&n.push(...l.keys),Object.values(l.children).forEach(c=>o(c))};o(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 g={parent:Symbol("reactive_parent"),path:Symbol("reactive_path"),isReactive:Symbol("reactive_is_reactive")};class He{constructor(){this.rawData={},this.data=null,this.observers={},this.elements={},this.computedProperties={},this.pathTrie=new ct,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),o=Reflect.set(e,s,n,r),l=this.resolvePath(e,s);return this.notify(l,n,a),this.queueUpdate(l,n),o},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[g.isReactive])return t;if(this._proxyCache.has(t))return this._proxyCache.get(t);const s={get:(r,a,o)=>{if(a==="__raw__")return r;if(a===g.parent||a==="__parent__")return r[g.parent];if(a===g.path||a==="__path__")return r[g.path];if(a===g.isReactive||a==="__isReactive__")return!0;const l=Reflect.get(r,a,o);return l&&typeof l=="object"&&!Array.isArray(l)?this.wrapReactive(l,`${r[g.path]}${r[g.path]?".":""}${a}`):l},set:(r,a,o,l)=>{if(a===g.parent||a===g.path||a===g.isReactive||a==="__parent__"||a==="__path__"||a==="__isReactive__")return!0;const c=Reflect.get(r,a,l),h=Reflect.set(r,a,o,l),d=`${r[g.path]}${r[g.path]?".":""}${a}`;return this.notify(d,o,c),this.queueUpdate(d,o),h},deleteProperty:(r,a)=>{if(a===g.parent||a===g.path||a===g.isReactive)return!1;const o=Reflect.get(r,a),l=Reflect.deleteProperty(r,a),c=`${r[g.path]}${r[g.path]?".":""}${a}`;return this.notify(c,void 0,o),this.queueUpdate(c,void 0),l},has:(r,a)=>a==="__raw__"||a===g.parent||a===g.path||a===g.isReactive||a==="__parent__"||a==="__path__"||a==="__isReactive__"?!0:a in r,ownKeys:r=>Reflect.ownKeys(r).filter(a=>a!==g.parent&&a!==g.path&&a!==g.isReactive),getOwnPropertyDescriptor:(r,a)=>a===g.parent||a===g.path||a===g.isReactive?{configurable:!1,enumerable:!1,writable:!1,value:r[a]}:Reflect.getOwnPropertyDescriptor(r,a)},n=new Proxy(t,s);return t[g.parent]=t,t[g.path]=e,t[g.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[g.path]?`${t[g.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((o,l)=>(o[l]||(o[l]={}),o[l]),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(":"),o=a[0].trim(),l=a[1]?.trim();switch(o){case"text":t.textContent!==String(e??"")&&(t.textContent=e??"");break;case"html":const c=ba(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 h=e?"none":"";t.style.display!==h&&(t.style.display=h);break;case"class":l&&(e?t.classList.add(l):t.classList.remove(l));break;case"style":l&&t.style[l]!==String(e??"")&&(t.style[l]=e??"");break;case"attr":l&&t.getAttribute(l)!==String(e??"")&&t.setAttribute(l,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 ct,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:o=null}=e,l=s==="session"?sessionStorage:localStorage;this.persistedKeys.set(t,{storage:l,debounce:n,timeout:null,version:r,encrypt:a,encryptionKey:o});const c=this.get(t);c!==void 0&&this._persistSave(t,c,l,{version:r,encrypt:a,encryptionKey:o}),this.observe(t,h=>{const d=this.persistedKeys.get(t);d&&(d.debounce>0?(d.timeout&&clearTimeout(d.timeout),d.timeout=setTimeout(()=>{this._persistSave(t,h,d.storage,{version:d.version,encrypt:d.encrypt,encryptionKey:d.encryptionKey})},d.debounce)):this._persistSave(t,h,d.storage,{version:d.version,encrypt:d.encrypt,encryptionKey:d.encryptionKey}))})}_persistSave(t,e,s,n={}){try{const{version:r=1,encrypt:a=!1,encryptionKey:o=null}=n,l={value:e,version:r,timestamp:Date.now()};let c=JSON.stringify(l);a&&o&&(c=this._encrypt(c,o)),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 o=localStorage.getItem(r);let l;if(s){const c=this._decrypt(o,s);l=JSON.parse(c)}else l=JSON.parse(o);if(l.version!==void 0&&l.version!==t.version){console.debug(`Skipping outdated data for ${a} (version ${l.version})`);continue}e[a]=l.value!==void 0?l.value:l}catch(o){console.warn(`Failed to load persisted key ${a}:`,o)}}}for(let n=0;n<sessionStorage.length;n++){const r=sessionStorage.key(n);if(r?.startsWith("kupola:")){const a=r.replace("kupola:","");try{const o=sessionStorage.getItem(r);let l;if(s){const c=this._decrypt(o,s);l=JSON.parse(c)}else l=JSON.parse(o);if(l.version!==void 0&&l.version!==t.version){console.debug(`Skipping outdated data for ${a} (version ${l.version})`);continue}e[a]=l.value!==void 0?l.value:l}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[g.isReactive])return t;if(this._proxyCache.has(t))return this._proxyCache.get(t);const s={get:(r,a,o)=>{if(a==="__raw__")return r;if(a===g.parent||a==="__parent__")return r[g.parent];if(a===g.path||a==="__path__")return r[g.path];if(a===g.isReactive||a==="__isReactive__")return!0;const l=Reflect.get(r,a,o);return l&&typeof l=="object"&&!Array.isArray(l)?this.wrapReactive(l,`${r[g.path]}${r[g.path]?".":""}${a}`):l},set:(r,a,o,l)=>{if(a===g.parent||a===g.path||a===g.isReactive||a==="__parent__"||a==="__path__"||a==="__isReactive__")return!0;const c=Reflect.get(r,a,l),h=Reflect.set(r,a,o,l),d=`${r[g.path]}${r[g.path]?".":""}${a}`;return this.notify(d,o,c),this.queueUpdate(d,o),h},deleteProperty:(r,a)=>{if(a===g.parent||a===g.path||a===g.isReactive)return!1;const o=Reflect.get(r,a),l=Reflect.deleteProperty(r,a),c=`${r[g.path]}${r[g.path]?".":""}${a}`;return this.notify(c,void 0,o),this.queueUpdate(c,void 0),l},has:(r,a)=>a==="__raw__"||a===g.parent||a===g.path||a===g.isReactive||a==="__parent__"||a==="__path__"||a==="__isReactive__"?!0:a in r,ownKeys:r=>Reflect.ownKeys(r).filter(a=>a!==g.parent&&a!==g.path&&a!==g.isReactive),getOwnPropertyDescriptor:(r,a)=>a===g.parent||a===g.path||a===g.isReactive?{configurable:!1,enumerable:!1,writable:!1,value:r[a]}:Reflect.getOwnPropertyDescriptor(r,a)},n=new Proxy(t,s);return t[g.parent]=t,t[g.path]=e,t[g.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 o=t.type==="checkbox"?t.checked:t.value;n.includes(".")?this.setNested(n,o):this.set(n,o)};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 ct,this.updateQueue.clear(),this.snapshots=[]}}class dt{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 dt(t,e);return this.stores.set(t,s),s}getStore(t){return this.stores.get(t)}registerStore(t){t instanceof dt&&this.stores.set(t.name,t)}dispose(){this.stores.clear()}}class Te{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:o})=>{(r.target.matches(a)||r.target.closest(a))&&o(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 He,xa=new Te,mt=new Me;function Ea(i,t){return mt.createStore(i,t)}function ka(i){return mt.getStore(i)}const M={paths:{icons:"/icons/",base:"/"},theme:{default:"dark",brand:"zengqing"},i18n:{locale:"zh-CN",fallbackLocale:"en-US"},http:{baseURL:"",timeout:1e4,headers:{},withCredentials:!1},zIndex:{modal:1e3,dropdown:2e3,tooltip:2100,popover:2200,datepicker:2300,message:3e3,notification:3100,loading:5e3},ui:{defaultSize:"md",modal:{backdropClick:!0},dropdown:{closeOnClick:!0},datepicker:{weekStart:1},tooltip:{delay:300}},performance:{lazyLoad:!1,debounceDelay:200,throttleDelay:100,animationEnabled:!0},security:{xssProtection:!0,sanitizeHtml:{enabled:!0,allowedTags:["b","i","u","em","strong","a","br","p","span","div","img"],allowedAttributes:{a:["href","target","rel"],img:["src","alt","width","height"],span:["class","style"],div:["class","style"]}},maskData:{enabled:!0,patterns:{phone:{regex:"^(\\d{3})\\d{4}(\\d{4})$",replace:"$1****$2"},email:{regex:"^(.)(.*)(@.*)$",replace:"$1***$3"},idCard:{regex:"^(\\d{6})\\d{8}(\\d{4})$",replace:"$1********$2"},bankCard:{regex:"^(\\d{4})\\d{8}(\\d{4})$",replace:"$1 **** **** $2"}}},secureId:{length:16,charset:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"}},message:{duration:3e3,position:"top-right",maxCount:5},notification:{duration:4500,position:"top-right"},validation:{defaultRules:[],showErrors:!0,trigger:"blur"},components:{autoInit:!0,silentErrors:!1}};function wa(i){qe(M,i)}function ot(i){return i?La(M,i):M}function gt(){return M.paths.base+M.paths.icons.replace(/^\//,"")}function Ca(){return M.paths.base}function Ie(){return M.theme.default}function Ae(){return M.theme.brand}function Sa(){return M.http}function U(){return M.ui}function Y(){return M.zIndex}function Z(){return M.security}function ze(){return M.performance}function Pe(){return M.message}function $e(){return M.notification}function Be(){return M.validation}function qe(i,t){for(const e in t)t[e]instanceof Object&&e in i&&i[e]instanceof Object?qe(i[e],t[e]):i[e]=t[e];return i}function La(i,t){return t.split(".").reduce((e,s)=>(e&&e[s])!==void 0?e[s]:void 0,i)}const Oe="kupola-theme",Fe="kupola-brand",V=[{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 N(){return localStorage.getItem(Oe)||Ie()}function Q(i){if(i!=="dark"&&i!=="light")return;document.documentElement.setAttribute("data-theme",i),localStorage.setItem(Oe,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 j(){return localStorage.getItem(Fe)||Ae()}function tt(i){const t=V.find(n=>n.id===i);if(!t)return;document.documentElement.setAttribute("data-brand",i),localStorage.setItem(Fe,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 Jt(i){const t=i.querySelector(".theme-icon");if(t){const e=N(),s=gt();t.src=e==="dark"?s+"sun.svg":s+"moon.svg"}}function Ne(){const i=N();Q(i);const t=j();tt(t);const e=document.querySelector("[data-theme-toggle]");if(e){Jt(e);const o=e.onclick;e.onclick=function(l){l.preventDefault();const h=N()==="dark"?"light":"dark";Q(h),Jt(e),typeof o=="function"&&o.call(this,l)}}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",V.forEach(o=>{const l=document.createElement("button");l.setAttribute("data-brand-btn",o.id),l.style.display="flex",l.style.justifyContent="center",l.style.alignItems="center",l.style.height="60px",l.style.backgroundColor=o.color,l.style.color=["#32F08C","#FF9900","#E2C027","#0EB0C9","#B1A6CC"].includes(o.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=o.name,s.appendChild(l)}),document.body.appendChild(s));const n=document.querySelector("[data-brand-toggle]");n&&s&&(n.onclick=function(o){o.stopPropagation(),o.preventDefault();const l=s.style.display==="none";s.style.display=l?"grid":"none",l?setTimeout(()=>{document.addEventListener("click",r,!0)},0):document.removeEventListener("click",r,!0)},s.onclick=function(o){o.stopPropagation()});function r(o){s&&n&&!s.contains(o.target)&&!n.contains(o.target)&&(s.style.display="none",document.removeEventListener("click",r,!0))}document.querySelectorAll("[data-brand-btn]").forEach(o=>{o.addEventListener("click",l=>{l.stopPropagation();const c=o.getAttribute("data-brand-btn");tt(c),s&&(s.style.display="none")})})}function Da(){const i=document.createElement("button");i.setAttribute("data-theme-toggle",""),i.setAttribute("data-current-theme",N()),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=gt();return t.src=N()==="dark"?e+"sun.svg":e+"moon.svg",t.width=14,t.height=14,t.alt="Toggle theme",i.appendChild(t),document.body.appendChild(i),i.onclick=function(s){s.preventDefault();const r=N()==="dark"?"light":"dark";Q(r)},i}function Ha(){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",V.forEach(a=>{const o=document.createElement("button");o.setAttribute("data-brand-btn",a.id),o.style.display="flex",o.style.justifyContent="center",o.style.alignItems="center",o.style.height="60px",o.style.backgroundColor=a.color,o.style.color=["#32F08C","#FF9900","#E2C027","#0EB0C9","#B1A6CC"].includes(a.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=a.name,i.appendChild(o)}),document.body.appendChild(i);const t=document.createElement("button");t.setAttribute("data-brand-toggle",""),t.setAttribute("data-current-brand",j()),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=V.find(a=>a.id===j()).color;const s=document.createElement("span");s.className="brand-name",s.style.fontSize="11px",s.textContent=V.find(a=>a.id===j()).name,t.appendChild(e),t.appendChild(s),document.body.appendChild(t),t.onclick=function(a){a.stopPropagation(),a.preventDefault();const o=i.style.display==="none";i.style.display=o?"grid":"none",o?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",o=>{o.stopPropagation();const l=a.getAttribute("data-brand-btn");tt(l),i.style.display="none"})}),{toggleBtn:t,container:i}}function Ma(i,t={}){const s=Z()?.sanitizeHtml||{};if(!s.enabled&&!t.force)return i;const n=t.allowedTags||s.allowedTags||[],r=t.allowedAttributes||s.allowedAttributes||{};if(typeof i!="string")return i;const o=new DOMParser().parseFromString(i,"text/html");return o.body.querySelectorAll("*").forEach(c=>{const h=c.tagName.toLowerCase();if(!n.includes(h)){c.remove();return}Array.from(c.attributes).forEach(d=>{const u=d.name.toLowerCase();(r[h]||[]).includes(u)||c.removeAttribute(d.name)})}),o.body.innerHTML}function Ta(i){if(typeof i!="string")return i;const t=document.createElement("div");return t.textContent=i,t.innerHTML}function Ia(i){return typeof i!="string"?i:new DOMParser().parseFromString(i,"text/html").body.textContent||""}function Aa(i,t,e={}){const n=Z()?.maskData||{};if(!n.enabled&&!e.force||i==null)return i;const a=(e.patterns||n.patterns||{})[t];if(!a)return i;const o=typeof a.regex=="string"?new RegExp(a.regex):a.regex;return String(i).replace(o,a.replace)}function za(i,t){const s=Z()?.secureId||{},n=i||s.length||16,r=s.charset||"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";if(typeof crypto>"u"||!crypto.getRandomValues){let l="";for(let c=0;c<n;c++)l+=r[Math.floor(Math.random()*r.length)];return t?`${t}_${l}`:l}const a=new Uint32Array(n);crypto.getRandomValues(a);let o="";for(let l=0;l<n;l++)o+=r[a[l]%r.length];return t?`${t}_${o}`:o}class Re{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(o){console.error(`[ComponentInitializerRegistry] Error initializing "${r}":`,o)}return}}}const e=t.className;if(typeof e=="string"){for(const s of this._cssClasses)if(new RegExp(`(^|\\s)${s}(\\s|$)`).test(e)){const r=s.replace("ds-",""),a=this.initializers.get(r)||this.initializers.get(s);if(a){try{await a(t),this.processedElements.add(t)}catch(o){console.error(`[ComponentInitializerRegistry] Error initializing "${r}":`,o)}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(o){console.error(`[ComponentInitializerRegistry] Error cleaning up "${r}":`,o)}this.processedElements.delete(t);return}}}const e=t.className;if(typeof e=="string"){for(const s of this._cssClasses)if(new RegExp(`(^|\\s)${s}(\\s|$)`).test(e)){const r=s.replace("ds-",""),a=this.cleanupFunctions.get(r)||this.cleanupFunctions.get(s);if(a){try{a(t)}catch(o){console.error(`[ComponentInitializerRegistry] Error cleaning up "${r}":`,o)}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 E=new Re,Pa=[{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 Pa)i.attr&&!E._dataAttrs.includes(i.attr)&&E._dataAttrs.push(i.attr),i.cls&&!E._cssClasses.includes(i.cls)&&E._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 it,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>
5
5
  </div>
6
- `}}_bindLifecycleHooks(){if(this._hooksBound)return;const t={beforeMount:"beforeMount",render:["mount","update"],afterMount:"afterMount",updated:"afterUpdate",beforeUnmount:"beforeUnmount",afterUnmount:"afterUnmount",renderError:"errorBoundary"};let e=Object.getPrototypeOf(this);const s=new Set;for(;e&&e.constructor!==Object&&e.constructor!==J;){for(const[n,r]of Object.entries(t))s.has(n)||e.hasOwnProperty(n)&&(Array.isArray(r)?r.forEach(a=>{n==="render"&&this.lifecycle.on(a,()=>this.render?.())}):n==="renderError"?this.lifecycle.on(r,a=>(this.renderError(a.error),"handled")):this.lifecycle.on(r,()=>this[n]?.()),s.add(n));e=Object.getPrototypeOf(e)}this._hooksBound=!0}async unmount(){if(!(!this.isMounted||this.isDestroyed))try{this.setupContext?._executeUnmounted(),await this.lifecycle.unmount(),this.isMounted=!1,this.isDestroyed=!0,await this.lifecycle.destroy()}catch(t){console.error(`[KupolaComponent] Error unmounting component "${this.constructor.name}":`,t),this.lifecycle&&typeof this.lifecycle._handleError=="function"&&await this.lifecycle._handleError({phase:"unmount",hook:"component",error:t,args:[]}),this.isMounted=!1,this.isDestroyed=!0}}beforeMount(){}afterMount(){}beforeUnmount(){}afterUnmount(){}render(){}renderError(t){}updated(){}setup(){}}function ut(i,t){Object.keys(t).forEach(e=>{if(e!=="constructor")if(typeof t[e]=="function"){const s=i.prototype[e];s?i.prototype[e]=function(...n){return t[e].apply(this,n),s.apply(this,n)}:i.prototype[e]=t[e]}else i.prototype[e]=t[e]})}class Ve{constructor(){this.components=new Map,this.lazyComponents=new Map,this.loadedComponents=new Map,this.instances=new Map,this.observer=null,this.mixins=new Map,this.loadingPromises=new Map}register(t,e){if(!(e.prototype instanceof J))throw new Error(`Component ${t} must extend KupolaComponent`);this.components.set(t,e)}registerLazy(t,e){this.lazyComponents.set(t,e)}unregister(t){this.components.delete(t),this.lazyComponents.delete(t),this.loadedComponents.delete(t),this.loadingPromises.delete(t)}get(t){return this.components.get(t)||this.loadedComponents.get(t)}async getAsync(t){const e=this.components.get(t)||this.loadedComponents.get(t);if(e)return e;if(this.loadingPromises.has(t))return this.loadingPromises.get(t);const s=this.lazyComponents.get(t);if(!s)throw new Error(`Component ${t} not found`);const n=(async()=>{try{const r=await s(),a=r.default||r;if(!(a.prototype instanceof J))throw new Error(`Component ${t} must extend KupolaComponent`);return this.loadedComponents.set(t,a),a}catch(r){throw this.loadingPromises.delete(t),r}})();return this.loadingPromises.set(t,n),n}defineMixin(t,e){this.mixins.set(t,e)}useMixin(t,...e){e.forEach(s=>{const n=this.mixins.get(s);n&&ut(t,n)})}async bootstrap(t=document){await this._upgradeElements(t),this._startObserver(t)}async _upgradeElements(t){const e=t.querySelectorAll("[data-component]"),s=[];e.forEach(n=>{s.push(this._upgradeElement(n))}),await Promise.all(s)}async _upgradeElement(t){if(!(t.__kupolaInstance||t.__kupolaUpgrading)){t.__kupolaUpgrading=!0;try{const e=t.getAttribute("data-component");if(e){const o=E.get(e);if(o)try{await o(t);return}catch(l){console.warn(`[KupolaComponentRegistry] Initializer for "${e}" failed, trying component class:`,l)}}let s=this.components.get(e);if(!s){try{s=await this.getAsync(e)}catch(o){console.error(`Failed to load component ${e}:`,o);return}if(!t.isConnected)return}const n=t.getAttribute("data-mixins"),r=s;n&&n.split(",").forEach(o=>{const l=this.mixins.get(o.trim());l&&ut(r,l)});const a=new r(t);t.__kupolaInstance=a,this.instances.set(t,a),a.mount()}finally{t.__kupolaUpgrading=!1}}}_startObserver(t){this.observer||(this.observer=new MutationObserver(e=>{e.forEach(s=>{s.addedNodes.forEach(n=>{if(n.nodeType===Node.ELEMENT_NODE){n.hasAttribute("data-component")&&this._upgradeElement(n).catch(a=>console.error(a)),this._upgradeElements(n).catch(a=>console.error(a)),E.initialize(n).catch(()=>{});const r=E._buildSelector();r&&n.querySelectorAll?.(r).forEach(a=>{E.initialize(a).catch(()=>{})})}}),s.removedNodes.forEach(n=>{if(n.nodeType===Node.ELEMENT_NODE){const r=this.instances.get(n);r&&(r.unmount(),this.instances.delete(n)),n.querySelectorAll("[data-component]").forEach(a=>{const o=this.instances.get(a);o&&(o.unmount(),this.instances.delete(a))}),E.cleanup(n),n.querySelectorAll?.("*").forEach(a=>{E.cleanup(a)})}})})}),this.observer.observe(t,{childList:!0,subtree:!0}))}destroy(){this.observer&&(this.observer.disconnect(),this.observer=null),this.instances.forEach(t=>{t.unmount()}),this.instances.clear(),this.components.clear(),this.mixins.clear()}}exports.kupolaRegistry=null;typeof window<"u"&&(exports.kupolaRegistry=new Ve);function $a(){if(Z().xssProtection&&typeof document<"u"){let t=document.querySelector('meta[http-equiv="X-XSS-Protection"]');t||(t=document.createElement("meta"),t.setAttribute("http-equiv","X-XSS-Protection"),t.setAttribute("content","1; mode=block"),document.head.insertBefore(t,document.head.firstChild)),t=document.querySelector('meta[http-equiv="X-Content-Type-Options"]'),t||(t=document.createElement("meta"),t.setAttribute("http-equiv","X-Content-Type-Options"),t.setAttribute("content","nosniff"),document.head.insertBefore(t,document.head.firstChild)),t=document.querySelector('meta[http-equiv="X-Frame-Options"]'),t||(t=document.createElement("meta"),t.setAttribute("http-equiv","X-Frame-Options"),t.setAttribute("content","SAMEORIGIN"),document.head.insertBefore(t,document.head.firstChild))}}async function pt(){if(typeof window<"u"){$a();const i=ot();q.loadPersisted(),q.bind(),Ne(),i.components?.autoInit!==!1&&(await E.initializeAll(),exports.kupolaRegistry&&await exports.kupolaRegistry.bootstrap())}}typeof document<"u"&&document.readyState==="loading"?document.addEventListener("DOMContentLoaded",pt):typeof window<"u"&&setTimeout(pt,0);function Ba(i,t){exports.kupolaRegistry&&exports.kupolaRegistry.register(i,t)}function qa(i,t){exports.kupolaRegistry&&exports.kupolaRegistry.registerLazy(i,t)}function Oa(i){return exports.kupolaRegistry?exports.kupolaRegistry.bootstrap(i):Promise.resolve()}function Fa(i,t){exports.kupolaRegistry&&exports.kupolaRegistry.defineMixin(i,t)}function Na(i,...t){exports.kupolaRegistry&&exports.kupolaRegistry.useMixin(i,...t)}function Ra(i,t){if(!t||typeof t!="object")throw new Error(`defineComponent("${i}"): options must be an object`);t.componentClass?exports.kupolaRegistry&&exports.kupolaRegistry.register(i,t.componentClass):t.lazy&&exports.kupolaRegistry&&exports.kupolaRegistry.registerLazy(i,t.lazy),t.init?E.register(i,t.init,t.cleanup||null,{dataAttribute:t.dataAttribute,cssClass:t.cssClass}):(t.dataAttribute||t.cssClass)&&E.register(i,()=>{},null,{dataAttribute:t.dataAttribute,cssClass:t.cssClass})}class _t{constructor(t={}){const e=ot();this.locales=t.locales||{},this.currentLocale=t.defaultLocale||e.i18n?.locale||"zh-CN",this.fallbackLocale=t.fallbackLocale||e.i18n?.fallbackLocale||"en-US",this.delimiter=t.delimiter||".",this.missingHandler=t.missingHandler||(s=>(console.warn(`Missing translation: ${s}`),s)),this._initFromDOM()}_initFromDOM(){document.querySelectorAll('script[type="application/json"][data-kupola-i18n]').forEach(s=>{const n=s.dataset.kupolaI18n;if(n)try{const r=JSON.parse(s.textContent);this.addLocale(n,r)}catch(r){console.error("Failed to parse i18n data:",r)}});const e=document.documentElement.lang;e&&this.locales[e]&&(this.currentLocale=e)}addLocale(t,e){this.locales[t]||(this.locales[t]={}),this._mergeDeep(this.locales[t],e)}_mergeDeep(t,e){for(const s of Object.keys(e))e[s]instanceof Object&&s in t?this._mergeDeep(t[s],e[s]):t[s]=e[s]}setLocale(t){return this.locales[t]?(this.currentLocale=t,document.documentElement.lang=t,this._emitChange(),!0):!1}getLocale(){return this.currentLocale}t(t,e={}){let s=this._getTranslation(t,this.currentLocale);return s||(s=this._getTranslation(t,this.fallbackLocale)),s?this._interpolate(s,e):this.missingHandler(t)}_getTranslation(t,e){if(!this.locales[e])return null;const s=t.split(this.delimiter);let n=this.locales[e];for(const r of s)if(n&&typeof n=="object"&&r in n)n=n[r];else return null;return typeof n=="string"?n:null}_interpolate(t,e){return t.replace(/\{(\w+)\}/g,(s,n)=>e[n]!==void 0?e[n]:s)}n(t,e,s={}){const n=this.t(t,{...s,count:e});if(!n)return n;const r=n.split("|");return r.length===1?n.replace("{count}",e):r.length===2?e===1?r[0]:r[1]:r.length>=3?e===0?r[0]:e===1?r[1]:r[2]:n}_emitChange(){const t=new CustomEvent("kupola:i18n:change",{detail:{locale:this.currentLocale},bubbles:!0});document.dispatchEvent(t)}async loadLocale(t,e){try{const n=await(await fetch(e)).json();return this.addLocale(t,n),!0}catch(s){return console.error("Failed to load locale:",s),!1}}getAvailableLocales(){return Object.keys(this.locales)}hasLocale(t){return!!this.locales[t]}formatDate(t,e={}){const s=e.locale||this.currentLocale,n=typeof t=="string"?new Date(t):t;return new Intl.DateTimeFormat(s,e).format(n)}formatNumber(t,e={}){const s=e.locale||this.currentLocale;return new Intl.NumberFormat(s,e).format(t)}formatCurrency(t,e,s={}){const n=s.locale||this.currentLocale;return new Intl.NumberFormat(n,{style:"currency",currency:e,...s}).format(t)}formatRelativeTime(t,e,s={}){const n=s.locale||this.currentLocale;return new Intl.RelativeTimeFormat(n,s).format(t,e)}}const F=new _t;function Va(i){return new _t(i)}function Ka(i,t={}){return F.t(i,t)}function Wa(i,t,e={}){return F.n(i,t,e)}function Ua(i){return F.setLocale(i)}function Ya(){return F.getLocale()}function Xa(i,t={}){return F.formatDate(i,t)}function ja(i,t={}){return F.formatNumber(i,t)}function Ja(i,t,e={}){return F.formatCurrency(i,t,e)}class Ke{constructor(){this._listeners=new Map,this._scopeListeners=new Map}on(t,e,s,n={}){const{scope:r=null,once:a=!1,passive:o=!1,capture:l=!1}=n,c=this._generateId(),h={id:c,target:t,eventName:e,handler:s,scope:r,once:a,wrappedHandler:null};h.wrappedHandler=u=>{a&&this.offById(c),s.call(t,u)};const d=this._getEventKey(t,e);return this._listeners.has(d)||this._listeners.set(d,[]),this._listeners.get(d).push(h),r&&(this._scopeListeners.has(r)||this._scopeListeners.set(r,[]),this._scopeListeners.get(r).push(c)),t.addEventListener(e,h.wrappedHandler,{passive:o,capture:l}),{unsubscribe:()=>this.offById(c)}}once(t,e,s,n={}){return this.on(t,e,s,{...n,once:!0})}off(t,e,s){const n=this._getEventKey(t,e);if(!this._listeners.has(n))return;const r=this._listeners.get(n),a=r.filter(o=>o.handler!==s);r.forEach(o=>{o.handler===s&&(t.removeEventListener(e,o.wrappedHandler),this._removeFromScope(o))}),a.length===0?this._listeners.delete(n):this._listeners.set(n,a)}offById(t){for(const[e,s]of this._listeners){const n=s.findIndex(r=>r.id===t);if(n!==-1){const r=s[n];return r.target.removeEventListener(r.eventName,r.wrappedHandler),s.splice(n,1),s.length===0&&this._listeners.delete(e),this._removeFromScope(r),!0}}return!1}offByScope(t){if(!this._scopeListeners.has(t))return;this._scopeListeners.get(t).forEach(s=>{this.offById(s)}),this._scopeListeners.delete(t)}offAll(t,e=null){if(e){const s=this._getEventKey(t,e);if(!this._listeners.has(s))return;this._listeners.get(s).forEach(r=>{t.removeEventListener(e,r.wrappedHandler),this._removeFromScope(r)}),this._listeners.delete(s)}else for(const[s,n]of this._listeners){const[r]=s.split(":");this._getTargetId(t)===r&&(n.forEach(a=>{t.removeEventListener(a.eventName,a.wrappedHandler),this._removeFromScope(a)}),this._listeners.delete(s))}}emit(t,e,s={}){const n=new CustomEvent(e,{detail:s,bubbles:!0,cancelable:!0});return t.dispatchEvent(n),n}emitGlobal(t,e={}){return this.emit(document,t,e)}emitToScope(t,e,s={}){if(!this._scopeListeners.has(t))return;const n=this._scopeListeners.get(t),r=new Set;for(const[a,o]of this._listeners)o.forEach(l=>{n.includes(l.id)&&r.add(l.target)});r.forEach(a=>{this.emit(a,e,s)})}getListenerCount(t,e=null){if(e){const r=this._getEventKey(t,e);return this._listeners.has(r)?this._listeners.get(r).length:0}let s=0;const n=this._getTargetId(t);for(const[r,a]of this._listeners){const[o]=r.split(":");o===n&&(s+=a.length)}return s}getScopeListenerCount(t){return this._scopeListeners.has(t)?this._scopeListeners.get(t).length:0}hasListeners(t,e=null){return this.getListenerCount(t,e)>0}_getEventKey(t,e){return`${this._getTargetId(t)}:${e}`}_getTargetId(t){return t===document?"document":t===window?"window":t===document.body?"body":(t._kupolaId||(t._kupolaId=this._generateId()),t._kupolaId)}_generateId(){return`ge-${Math.random().toString(36).substr(2,9)}-${Date.now()}`}_removeFromScope(t){if(!t.scope||!this._scopeListeners.has(t.scope))return;const e=this._scopeListeners.get(t.scope),s=e.indexOf(t.id);s!==-1&&(e.splice(s,1),e.length===0&&this._scopeListeners.delete(t.scope))}destroy(){for(const[t,e]of this._listeners)e.forEach(s=>{s.target.removeEventListener(s.eventName,s.wrappedHandler)});this._listeners.clear(),this._scopeListeners.clear()}}const H=new Ke;function Za(i,t,e,s){return H.on(i,t,e,s)}function Ga(i,t,e,s){return H.once(i,t,e,s)}function Qa(i,t,e){H.off(i,t,e)}function to(i,t,e){return H.emit(i,t,e)}function eo(i,t){return H.emitGlobal(i,t)}function so(i){H.offByScope(i)}function io(i,t){H.offAll(i,t)}function no(i,t){return H.getListenerCount(i,t)}class We{constructor(t,e={}){this.element=t,this.trigger=t.querySelector(".ds-dropdown__trigger"),this.menu=t.querySelector(".ds-dropdown__menu"),this.triggerText=this.trigger?this.trigger.querySelector("span"):null,this.scope=`dropdown-${Math.random().toString(36).substr(2,9)}`;const s=U();this.triggerMode=e.trigger||t.getAttribute("data-dropdown-trigger")||"click",this.hoverDelay=e.hoverDelay||parseInt(t.getAttribute("data-dropdown-hover-delay"))||150,this.disabled=e.disabled||t.hasAttribute("data-dropdown-disabled"),this.keyboardNav=e.keyboardNav!==!1,this.autoPosition=e.autoPosition!==!1,this.closeOnClick=e.closeOnClick!==void 0?e.closeOnClick:s.dropdown?.closeOnClick!==void 0?s.dropdown.closeOnClick:!0,this.appendToBody=e.appendToBody!==!1,this.onSelect=e.onSelect||null,this.onShow=e.onShow||null,this.onHide=e.onHide||null,this.isOpen=!1,this.focusIndex=-1,this._hoverTimer=null,this._hoverLeaveTimer=null,this._originalParent=null,this._originalPosition=null,this._triggerClickHandler=null,this._documentClickHandler=null,this._documentClickListener=null,this._itemClickHandler=null,this._keydownHandler=null,this._mouseenterHandler=null,this._mouseleaveHandler=null,this._triggerMouseenterHandler=null,this._triggerMouseleaveHandler=null,this._triggerKeydownHandler=null}init(){!this.trigger||!this.menu||this.element.__kupolaInitialized||(this._itemClickHandler=t=>{t.stopPropagation();const e=t.currentTarget;e.classList.contains("is-disabled")||e.classList.contains("ds-dropdown__divider")||(this.menu.querySelectorAll(".ds-dropdown__item").forEach(s=>s.classList.remove("is-selected")),e.classList.add("is-selected"),this.triggerText&&!e.hasAttribute("data-no-update-trigger")&&(this.triggerText.textContent=e.textContent.trim()),this.element.setAttribute("data-value",e.getAttribute("data-value")||""),this.onSelect&&this.onSelect({item:e,value:e.getAttribute("data-value"),text:e.textContent.trim()}),this.closeOnClick&&(this.hideMenu(),this.trigger.focus()))},this._bindMenuItems(),this._triggerClickHandler=t=>{t.stopPropagation(),!this.disabled&&this.toggleMenu()},this._triggerMouseenterHandler=()=>{this.disabled||this.triggerMode!=="hover"||(clearTimeout(this._hoverLeaveTimer),this._hoverTimer=setTimeout(()=>this.showMenu(),this.hoverDelay))},this._triggerMouseleaveHandler=()=>{this.triggerMode==="hover"&&(clearTimeout(this._hoverTimer),this._hoverLeaveTimer=setTimeout(()=>this.hideMenu(),this.hoverDelay))},this._mouseenterHandler=()=>{this.disabled||this.triggerMode!=="hover"||clearTimeout(this._hoverLeaveTimer)},this._mouseleaveHandler=()=>{this.triggerMode==="hover"&&(this._hoverLeaveTimer=setTimeout(()=>this.hideMenu(),this.hoverDelay))},this._keydownHandler=t=>{if(!this.isOpen||this.disabled)return;const e=this._getNavigableItems();if(e.length)switch(t.key){case"ArrowDown":t.preventDefault(),this.focusIndex=Math.min(this.focusIndex+1,e.length-1),this._focusItem(e);break;case"ArrowUp":t.preventDefault(),this.focusIndex=Math.max(this.focusIndex-1,0),this._focusItem(e);break;case"Enter":case" ":t.preventDefault(),this.focusIndex>=0&&e[this.focusIndex]&&e[this.focusIndex].click();break;case"Escape":t.preventDefault(),this.hideMenu(),this.trigger.focus();break;case"Home":t.preventDefault(),this.focusIndex=0,this._focusItem(e);break;case"End":t.preventDefault(),this.focusIndex=e.length-1,this._focusItem(e);break}},this.triggerMode==="hover"?(this.trigger.addEventListener("mouseenter",this._triggerMouseenterHandler),this.trigger.addEventListener("mouseleave",this._triggerMouseleaveHandler),this.menu.addEventListener("mouseenter",this._mouseenterHandler),this.menu.addEventListener("mouseleave",this._mouseleaveHandler)):this.trigger.addEventListener("click",this._triggerClickHandler),this._triggerKeydownHandler=t=>{this.disabled||(t.key==="Enter"||t.key===" "||t.key==="ArrowDown")&&(t.preventDefault(),this.showMenu())},this.trigger.addEventListener("keydown",this._triggerKeydownHandler),document.addEventListener("keydown",this._keydownHandler),this._documentClickHandler=t=>{if(!this.isOpen)return;const e=this.element.contains(t.target),s=this.menu&&this.menu.contains(t.target);!e&&!s&&this.hideMenu()},this._documentClickListener=H.on(document,"click",this._documentClickHandler,{scope:this.scope}),this.menu.style.display="none",this.element.__kupolaInitialized=!0)}_bindMenuItems(){this.menu.querySelectorAll(".ds-dropdown__item").forEach(t=>{t._dropdownItemClickHandler=e=>this._itemClickHandler(e),t.addEventListener("click",t._dropdownItemClickHandler)})}_getNavigableItems(){return Array.from(this.menu.querySelectorAll(".ds-dropdown__item")).filter(t=>!t.classList.contains("is-disabled")&&!t.classList.contains("ds-dropdown__divider"))}_focusItem(t){t.forEach(e=>e.classList.remove("is-focused")),t[this.focusIndex]&&(t[this.focusIndex].classList.add("is-focused"),t[this.focusIndex].scrollIntoView({block:"nearest"}))}_calculatePosition(){if(!this.autoPosition)return;const t=this.element.getBoundingClientRect(),e=this.menu.getBoundingClientRect(),s=window.innerHeight,n=window.innerWidth;if(this.menu.classList.remove("ds-dropdown--top","ds-dropdown--right","ds-dropdown--dropup"),this.appendToBody){this.menu.style.width=`${Math.max(t.width,e.width)}px`;const r=s-t.bottom,a=t.top;r<e.height&&a>r?(this.menu.style.top=`${t.top-e.height-4}px`,this.menu.style.bottom="auto"):(this.menu.style.top=`${t.bottom+4}px`,this.menu.style.bottom="auto"),t.left+e.width>n?(this.menu.style.left=`${t.right-Math.max(t.width,e.width)}px`,this.menu.style.right="auto"):(this.menu.style.left=`${t.left}px`,this.menu.style.right="auto")}else{const r=s-t.bottom,a=t.top;r<e.height&&a>r?(this.menu.classList.add("ds-dropdown--dropup"),this.menu.style.top="auto",this.menu.style.bottom="100%",this.menu.style.marginBottom="4px"):(this.menu.style.top="100%",this.menu.style.bottom="auto",this.menu.style.marginBottom="0"),t.left+e.width>n?(this.menu.style.left="auto",this.menu.style.right="0"):(this.menu.style.left="0",this.menu.style.right="auto")}}showMenu(){this.disabled||this.isOpen||(this.isOpen=!0,this.focusIndex=-1,this.element.classList.add("is-open"),this.appendToBody&&(this._appendMenuToBody(),this._addScrollListener()),this.menu.style.display="block",this._calculatePosition(),this.onShow&&this.onShow(),this.element.dispatchEvent(new CustomEvent("kupola:dropdown-show",{bubbles:!0})))}hideMenu(){this.isOpen&&(this.isOpen=!1,this.menu.style.display="none",this.element.classList.remove("is-open"),this.appendToBody&&(this._restoreMenuFromBody(),this._removeScrollListener()),this.menu.querySelectorAll(".ds-dropdown__item").forEach(t=>t.classList.remove("is-focused")),this.onHide&&this.onHide(),this.element.dispatchEvent(new CustomEvent("kupola:dropdown-hide",{bubbles:!0})))}_appendMenuToBody(){if(!this.menu)return;this._originalParent=this.menu.parentNode,this._originalPosition=this.menu.style.position,this._originalTop=this.menu.style.top,this._originalLeft=this.menu.style.left,this._originalRight=this.menu.style.right,this._originalBottom=this.menu.style.bottom,this._originalMarginBottom=this.menu.style.marginBottom,this._originalWidth=this.menu.style.width,this._originalTransform=this.menu.style.transform,this._originalZIndex=this.menu.style.zIndex;const t=Y().dropdown;this.menu.style.position="fixed",this.menu.style.zIndex=t,this.menu.style.transform="translateZ(0)",document.body.appendChild(this.menu)}_restoreMenuFromBody(){!this.menu||!this._originalParent||(this._originalParent.appendChild(this.menu),this.menu.style.position=this._originalPosition||"",this.menu.style.top=this._originalTop||"",this.menu.style.left=this._originalLeft||"",this.menu.style.right=this._originalRight||"",this.menu.style.bottom=this._originalBottom||"",this.menu.style.marginBottom=this._originalMarginBottom||"",this.menu.style.width=this._originalWidth||"",this.menu.style.zIndex=this._originalZIndex||"",this.menu.style.transform=this._originalTransform||"",this._originalParent=null)}_addScrollListener(){this._scrollHandler=()=>{this.hideMenu()},window.addEventListener("scroll",this._scrollHandler,!0)}_removeScrollListener(){this._scrollHandler&&(window.removeEventListener("scroll",this._scrollHandler,!0),this._scrollHandler=null)}toggleMenu(){this.isOpen?this.hideMenu():this.showMenu()}enable(){this.disabled=!1,this.element.removeAttribute("data-dropdown-disabled")}disable(){this.disabled=!0,this.element.setAttribute("data-dropdown-disabled",""),this.hideMenu()}setItems(t){this.menu.querySelectorAll(".ds-dropdown__item").forEach(e=>{e._dropdownItemClickHandler&&e.removeEventListener("click",e._dropdownItemClickHandler)}),this.menu.innerHTML="",t.forEach(e=>{if(e.type==="divider"){const s=document.createElement("div");s.className="ds-dropdown__divider",this.menu.appendChild(s)}else{const s=document.createElement("div");s.className="ds-dropdown__item"+(e.disabled?" is-disabled":"")+(e.active?" is-selected":""),s.textContent=e.text||e.label||"",e.value!==void 0&&s.setAttribute("data-value",e.value),e.icon&&(s.innerHTML=e.icon+s.innerHTML),e.disabled&&s.classList.add("is-disabled"),s._dropdownItemClickHandler=n=>this._itemClickHandler(n),s.addEventListener("click",s._dropdownItemClickHandler),this.menu.appendChild(s)}})}destroy(){this.element.__kupolaInitialized&&(clearTimeout(this._hoverTimer),clearTimeout(this._hoverLeaveTimer),this.trigger&&(this._triggerClickHandler&&this.trigger.removeEventListener("click",this._triggerClickHandler),this._triggerMouseenterHandler&&this.trigger.removeEventListener("mouseenter",this._triggerMouseenterHandler),this._triggerMouseleaveHandler&&this.trigger.removeEventListener("mouseleave",this._triggerMouseleaveHandler),this._triggerKeydownHandler&&this.trigger.removeEventListener("keydown",this._triggerKeydownHandler)),this.menu&&(this.menu.querySelectorAll(".ds-dropdown__item").forEach(t=>{t._dropdownItemClickHandler&&t.removeEventListener("click",t._dropdownItemClickHandler)}),this._mouseenterHandler&&this.menu.removeEventListener("mouseenter",this._mouseenterHandler),this._mouseleaveHandler&&this.menu.removeEventListener("mouseleave",this._mouseleaveHandler)),this._keydownHandler&&document.removeEventListener("keydown",this._keydownHandler),this._documentClickListener&&this._documentClickListener.unsubscribe?this._documentClickListener.unsubscribe():this._documentClickHandler&&document.removeEventListener("click",this._documentClickHandler),this.appendToBody&&this._originalParent&&this._restoreMenuFromBody(),this._documentClickHandler=null,this._documentClickListener=null,this._triggerClickHandler=null,this._itemClickHandler=null,this._keydownHandler=null,this._mouseenterHandler=null,this._mouseleaveHandler=null,this._triggerMouseenterHandler=null,this._triggerMouseleaveHandler=null,this._triggerKeydownHandler=null,this.element.__kupolaInitialized=!1)}}function yt(i,t){const e=new We(i,t);e.init(),i._kupolaDropdown=e}function ro(i=document){i.querySelectorAll(".ds-dropdown").forEach(t=>{yt(t)})}function vt(i){i._kupolaDropdown&&(i._kupolaDropdown.destroy(),i._kupolaDropdown=null)}function ao(){document.querySelectorAll(".ds-dropdown").forEach(i=>{vt(i)})}E.register("dropdown",yt,vt);class Ue{constructor(t,e={}){this.element=t,this.trigger=t.querySelector(".ds-select__trigger"),this.valueEl=t.querySelector(".ds-select__value")||t.querySelector(".ds-select__trigger span"),this.optionsEl=t.querySelector(".ds-select__options")||t.querySelector(".ds-select__menu"),this.nativeSelect=t.querySelector("select"),this.icon=t.querySelector(".ds-select__icon"),this.scope=`select-${Math.random().toString(36).substr(2,9)}`,this.multiple=e.multiple||t.hasAttribute("data-select-multiple"),this.searchable=e.searchable||t.hasAttribute("data-select-search"),this.clearable=e.clearable||t.hasAttribute("data-select-clear"),this.placeholder=e.placeholder||t.getAttribute("data-select-placeholder")||"",this.disabled=e.disabled||t.hasAttribute("data-select-disabled"),this.maxSelection=e.maxSelection||parseInt(t.getAttribute("data-select-max"))||1/0,this.remoteMethod=e.remoteMethod||null,this.onChange=e.onChange||null,this.appendToBody=e.appendToBody!==!1,this.isOpen=!1,this.selectedValues=new Set,this.allOptions=[],this.filteredOptions=[],this.focusIndex=-1,this.searchInput=null,this.clearBtn=null,this.tagsWrap=null,this._originalParent=null,this._originalPosition=null,this._triggerClickHandler=null,this._documentClickHandler=null,this._documentClickListener=null,this._optionClickHandler=null,this._keydownHandler=null}init(){!this.trigger||!this.optionsEl||this.element.__kupolaInitialized||(this._collectOptions(),this.searchable&&this._createSearchInput(),this.clearable&&this._createClearButton(),this.multiple&&this._createTagsWrap(),this.placeholder&&this.valueEl&&(this.valueEl.setAttribute("data-placeholder",this.placeholder),this.selectedValues.size||(this.valueEl.classList.add("ds-select__value--placeholder"),this.valueEl.textContent=this.placeholder)),this._optionClickHandler=t=>{t.stopPropagation();const e=t.currentTarget;if(e.classList.contains("is-disabled"))return;const s=e.getAttribute("data-value");this.multiple?this._toggleMultiOption(s,e):this._selectSingleOption(s,e)},this._bindOptionClicks(),this._triggerClickHandler=t=>{t.stopPropagation(),!this.disabled&&this.toggleOptions()},this.trigger.addEventListener("click",this._triggerClickHandler),this._keydownHandler=t=>{if(!this.isOpen||this.disabled)return;const e=this._getVisibleOptions();if(e.length)switch(t.key){case"ArrowDown":t.preventDefault(),this.focusIndex=Math.min(this.focusIndex+1,e.length-1),this._focusOption(e);break;case"ArrowUp":t.preventDefault(),this.focusIndex=Math.max(this.focusIndex-1,0),this._focusOption(e);break;case"Enter":t.preventDefault(),this.focusIndex>=0&&e[this.focusIndex]&&e[this.focusIndex].click();break;case"Escape":t.preventDefault(),this.hideOptions(),this.trigger.focus();break}},document.addEventListener("keydown",this._keydownHandler),this._documentClickHandler=t=>{if(!this.isOpen)return;const e=this.element.contains(t.target),s=this.optionsEl&&this.optionsEl.contains(t.target);!e&&!s&&this.hideOptions()},this._documentClickListener=H.on(document,"click",this._documentClickHandler,{scope:this.scope}),this._restoreSelectedState(),this.optionsEl.style.display="none",this.element.__kupolaInitialized=!0)}_collectOptions(){this.allOptions=[],this.optionsEl.querySelectorAll(".ds-select__option, .ds-select__item").forEach(t=>{this.allOptions.push({el:t,value:t.getAttribute("data-value"),text:t.textContent.trim(),group:t.closest(".ds-select__group")?.getAttribute("data-group")||"",disabled:t.classList.contains("is-disabled")})}),this.filteredOptions=[...this.allOptions]}_createSearchInput(){this.searchInput=document.createElement("input"),this.searchInput.className="ds-select__search",this.searchInput.type="text",this.searchInput.placeholder="Search...",this.searchInput.setAttribute("autocomplete","off"),this.searchInput.addEventListener("input",()=>this._handleSearch()),this.searchInput.addEventListener("click",t=>t.stopPropagation()),this.optionsEl.insertBefore(this.searchInput,this.optionsEl.firstChild)}_createClearButton(){this.clearBtn=document.createElement("button"),this.clearBtn.className="ds-select__clear",this.clearBtn.type="button",this.clearBtn.innerHTML='<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>',this.clearBtn.style.display="none",this.clearBtn.addEventListener("click",e=>{e.stopPropagation(),this.clear()});const t=this.trigger.querySelector(".ds-select__value")||this.trigger;t.parentNode.insertBefore(this.clearBtn,t.nextSibling)}_createTagsWrap(){this.tagsWrap=document.createElement("div"),this.tagsWrap.className="ds-select__tags";const t=this.valueEl||this.trigger;t.parentNode.insertBefore(this.tagsWrap,t.nextSibling)}_handleSearch(){const t=this.searchInput.value.toLowerCase().trim();if(this.remoteMethod){this.remoteMethod(t,e=>{this._renderRemoteOptions(e)});return}this.filteredOptions=this.allOptions.filter(e=>e.text.toLowerCase().includes(t)),this.allOptions.forEach(e=>{const s=this.filteredOptions.includes(e);e.el.style.display=s?"":"none"}),this.optionsEl.querySelectorAll(".ds-select__group-title").forEach(e=>{const s=e.getAttribute("data-group"),n=this.filteredOptions.some(r=>r.group===s);e.style.display=n?"":"none"}),this.focusIndex=-1}_renderRemoteOptions(t){this.optionsEl.querySelectorAll(".ds-select__option, .ds-select__item").forEach(e=>{e._selectOptionClickHandler&&e.removeEventListener("click",e._selectOptionClickHandler),e.remove()}),t.forEach(e=>{const s=document.createElement("div");s.className="ds-select__option",s.setAttribute("data-value",e.value),s.textContent=e.text||e.label,e.disabled&&s.classList.add("is-disabled"),this.selectedValues.has(e.value)&&s.classList.add("is-selected"),s._selectOptionClickHandler=n=>this._optionClickHandler(n),s.addEventListener("click",s._selectOptionClickHandler),this.optionsEl.appendChild(s)}),this.allOptions=t.map(e=>({el:this.optionsEl.querySelector(`[data-value="${e.value}"]`),value:e.value,text:e.text||e.label,group:"",disabled:!!e.disabled})),this.filteredOptions=[...this.allOptions]}_selectSingleOption(t,e){this.optionsEl.querySelectorAll(".ds-select__option, .ds-select__item").forEach(s=>s.classList.remove("is-selected")),e.classList.add("is-selected"),this.selectedValues.clear(),this.selectedValues.add(t),this.updateValue(e.textContent.trim()),this._syncNativeSelect(),this.hideOptions(),this._updateClearBtn(),this._fireChange()}_toggleMultiOption(t,e){if(this.selectedValues.has(t))this.selectedValues.delete(t),e.classList.remove("is-selected");else{if(this.selectedValues.size>=this.maxSelection)return;this.selectedValues.add(t),e.classList.add("is-selected")}this._updateTags(),this._updateValueDisplay(),this._syncNativeSelect(),this._updateClearBtn(),this._fireChange()}_updateTags(){this.tagsWrap&&(this.tagsWrap.innerHTML="",this.selectedValues.forEach(t=>{const e=this.allOptions.find(r=>r.value===t);if(!e)return;const s=document.createElement("span");s.className="ds-select__tag",s.textContent=e.text;const n=document.createElement("button");n.className="ds-select__tag-close",n.type="button",n.innerHTML='<svg width="10" height="10" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>',n.addEventListener("click",r=>{r.stopPropagation(),this.selectedValues.delete(t);const a=this.optionsEl.querySelector(`[data-value="${t}"]`);a&&a.classList.remove("is-selected"),this._updateTags(),this._updateValueDisplay(),this._syncNativeSelect(),this._updateClearBtn(),this._fireChange()}),s.appendChild(n),this.tagsWrap.appendChild(s)}))}_updateValueDisplay(){if(this.valueEl)if(this.multiple){const t=this.selectedValues.size;t===0?(this.valueEl.textContent=this.placeholder||"",this.valueEl.classList.add("ds-select__value--placeholder")):(this.valueEl.textContent=`Selected ${t}`,this.valueEl.classList.remove("ds-select__value--placeholder")),this.tagsWrap&&(this.valueEl.style.display=t>0?"none":"")}else this.selectedValues.size===0&&(this.valueEl.textContent=this.placeholder||"",this.valueEl.classList.add("ds-select__value--placeholder"))}_updateClearBtn(){this.clearBtn&&(this.clearBtn.style.display=this.selectedValues.size>0?"":"none")}_syncNativeSelect(){this.nativeSelect&&(this.multiple?Array.from(this.nativeSelect.options).forEach(t=>{t.selected=this.selectedValues.has(t.value)}):this.nativeSelect.value=Array.from(this.selectedValues)[0]||"")}_fireChange(){this.nativeSelect&&this.nativeSelect.dispatchEvent(new Event("change",{bubbles:!0}));const t=this.multiple?Array.from(this.selectedValues):Array.from(this.selectedValues)[0];this.onChange&&this.onChange({values:t,selectedOptions:this.getSelectedOptions()}),this.element.dispatchEvent(new CustomEvent("kupola:select-change",{detail:{values:t,selectedOptions:this.getSelectedOptions()},bubbles:!0}))}_restoreSelectedState(){if(this.nativeSelect){if(this.multiple)Array.from(this.nativeSelect.selectedOptions).forEach(t=>{this.selectedValues.add(t.value);const e=this.optionsEl.querySelector(`[data-value="${t.value}"]`);e&&e.classList.add("is-selected")}),this._updateTags(),this._updateValueDisplay();else if(this.nativeSelect.value){this.selectedValues.add(this.nativeSelect.value);const t=this.optionsEl.querySelector(`[data-value="${this.nativeSelect.value}"]`);t&&(t.classList.add("is-selected"),this.updateValue(t.textContent.trim()))}}this._updateClearBtn()}_bindOptionClicks(){this.optionsEl.querySelectorAll(".ds-select__option, .ds-select__item").forEach(t=>{t._selectOptionClickHandler=e=>this._optionClickHandler(e),t.addEventListener("click",t._selectOptionClickHandler)})}_getVisibleOptions(){return Array.from(this.optionsEl.querySelectorAll(".ds-select__option, .ds-select__item")).filter(t=>t.style.display!=="none"&&!t.classList.contains("is-disabled"))}_focusOption(t){t.forEach(e=>e.classList.remove("is-focused")),t[this.focusIndex]&&(t[this.focusIndex].classList.add("is-focused"),t[this.focusIndex].scrollIntoView({block:"nearest"}))}updateValue(t){this.valueEl&&(this.valueEl.textContent=t||this.valueEl.textContent,this.valueEl.classList.remove("ds-select__value--placeholder"))}showOptions(){this.disabled||this.isOpen||(this.isOpen=!0,this.element.classList.add("is-open"),this.icon&&(this.icon.style.transform="rotate(180deg)"),this.focusIndex=-1,this.appendToBody&&(this._appendOptionsToBody(),this._addScrollListener()),this.optionsEl.style.display="block",this._calculateOptionsPosition(),this.searchInput&&setTimeout(()=>this.searchInput.focus(),50))}hideOptions(){this.isOpen&&(this.isOpen=!1,this.optionsEl.style.display="none",this.icon&&(this.icon.style.transform="rotate(0deg)"),this.element.classList.remove("is-open"),this.appendToBody&&(this._restoreOptionsFromBody(),this._removeScrollListener()),this.searchInput&&(this.searchInput.value="",this._handleSearch()),this.optionsEl.querySelectorAll(".ds-select__option, .ds-select__item").forEach(t=>t.classList.remove("is-focused")))}_addScrollListener(){this._scrollHandler=()=>{this.hideOptions()},window.addEventListener("scroll",this._scrollHandler,!0)}_removeScrollListener(){this._scrollHandler&&(window.removeEventListener("scroll",this._scrollHandler,!0),this._scrollHandler=null)}_appendOptionsToBody(){if(!this.optionsEl)return;this._originalParent=this.optionsEl.parentNode,this._originalPosition=this.optionsEl.style.position,this._originalTop=this.optionsEl.style.top,this._originalLeft=this.optionsEl.style.left,this._originalRight=this.optionsEl.style.right,this._originalWidth=this.optionsEl.style.width,this._originalTransform=this.optionsEl.style.transform,this._originalZIndex=this.optionsEl.style.zIndex;const t=Y().dropdown;this.optionsEl.style.position="fixed",this.optionsEl.style.zIndex=t,this.optionsEl.style.transform="translateZ(0)",document.body.appendChild(this.optionsEl)}_restoreOptionsFromBody(){!this.optionsEl||!this._originalParent||(this._originalParent.appendChild(this.optionsEl),this.optionsEl.style.position=this._originalPosition||"",this.optionsEl.style.top=this._originalTop||"",this.optionsEl.style.left=this._originalLeft||"",this.optionsEl.style.right=this._originalRight||"",this.optionsEl.style.width=this._originalWidth||"",this.optionsEl.style.zIndex=this._originalZIndex||"",this.optionsEl.style.transform=this._originalTransform||"",this._originalParent=null)}_calculateOptionsPosition(){if(!this.appendToBody||!this.optionsEl)return;const t=this.element.getBoundingClientRect(),e=this.optionsEl.getBoundingClientRect(),s=window.innerHeight,n=window.innerWidth;this.optionsEl.style.width=`${Math.max(t.width,e.width)}px`;const r=s-t.bottom,a=t.top;r<e.height&&a>r?this.optionsEl.style.top=`${t.top-e.height-4}px`:this.optionsEl.style.top=`${t.bottom+4}px`,t.left+e.width>n?this.optionsEl.style.left=`${t.right-Math.max(t.width,e.width)}px`:this.optionsEl.style.left=`${t.left}px`}toggleOptions(){this.isOpen?this.hideOptions():this.showOptions()}clear(){this.selectedValues.clear(),this.optionsEl.querySelectorAll(".ds-select__option, .ds-select__item").forEach(t=>t.classList.remove("is-selected")),this._updateTags(),this._updateValueDisplay(),this._syncNativeSelect(),this._updateClearBtn(),this._fireChange()}getSelectedOptions(){return Array.from(this.selectedValues).map(t=>{const e=this.allOptions.find(s=>s.value===t);return e?{value:e.value,text:e.text}:{value:t,text:""}})}getValue(){return this.multiple?Array.from(this.selectedValues):Array.from(this.selectedValues)[0]||""}setValue(t){this.multiple&&Array.isArray(t)?(this.selectedValues.clear(),t.forEach(e=>this.selectedValues.add(e)),this.optionsEl.querySelectorAll(".ds-select__option, .ds-select__item").forEach(e=>{e.classList.toggle("is-selected",this.selectedValues.has(e.getAttribute("data-value")))}),this._updateTags(),this._updateValueDisplay()):(this.selectedValues.clear(),this.selectedValues.add(t),this.optionsEl.querySelectorAll(".ds-select__option, .ds-select__item").forEach(e=>{const s=e.getAttribute("data-value")===t;e.classList.toggle("is-selected",s),s&&this.updateValue(e.textContent.trim())})),this._syncNativeSelect(),this._updateClearBtn()}enable(){this.disabled=!1,this.element.removeAttribute("data-select-disabled")}disable(){this.disabled=!0,this.element.setAttribute("data-select-disabled",""),this.hideOptions()}destroy(){this.element.__kupolaInitialized&&(this.trigger&&this._triggerClickHandler&&this.trigger.removeEventListener("click",this._triggerClickHandler),this.optionsEl&&this.optionsEl.querySelectorAll(".ds-select__option, .ds-select__item").forEach(t=>{t._selectOptionClickHandler&&t.removeEventListener("click",t._selectOptionClickHandler)}),this._keydownHandler&&document.removeEventListener("keydown",this._keydownHandler),this._documentClickListener&&this._documentClickListener.unsubscribe?this._documentClickListener.unsubscribe():this._documentClickHandler&&document.removeEventListener("click",this._documentClickHandler),this.searchInput&&this.searchInput.remove(),this.clearBtn&&this.clearBtn.remove(),this.tagsWrap&&this.tagsWrap.remove(),this.appendToBody&&this._originalParent&&this._restoreOptionsFromBody(),this._documentClickHandler=null,this._documentClickListener=null,this._triggerClickHandler=null,this._optionClickHandler=null,this._keydownHandler=null,this.element.__kupolaInitialized=!1)}}function bt(i,t){const e=new Ue(i,t);e.init(),i._kupolaSelect=e}function oo(i=document){i.querySelectorAll(".ds-select").forEach(t=>{bt(t)})}function Ye(i){i._kupolaSelect&&(i._kupolaSelect.destroy(),i._kupolaSelect=null)}E.register("select",bt,Ye);class Xe{constructor(t,e={}){this.element=t,this.input=t.querySelector("input"),this.endInput=t.querySelector(".ds-datepicker__end-input"),this.icon=t.querySelector(".ds-datepicker__icon"),this.calendarEl=t.querySelector(".ds-datepicker__calendar"),this.scope=`datepicker-${Math.random().toString(36).substr(2,9)}`;const s=U(),n=s.datepicker?.weekStart!==void 0?s.datepicker.weekStart:1;this.format=e.format||t.getAttribute("data-datepicker-format")||"YYYY-MM-DD",this.range=e.range||t.hasAttribute("data-datepicker-range"),this.minDate=e.minDate||t.getAttribute("data-datepicker-min")||null,this.maxDate=e.maxDate||t.getAttribute("data-datepicker-max")||null,this.disabledDate=e.disabledDate||null,this.weekStart=e.weekStart!==void 0?e.weekStart:parseInt(t.getAttribute("data-datepicker-week-start"))||n,this.appendToBody=e.appendToBody!==!1,this.placeholder=e.placeholder||t.getAttribute("data-datepicker-placeholder")||"",this.showToday=e.showToday!==!1,this.showWeekNumber=e.showWeekNumber||t.hasAttribute("data-datepicker-week-number"),this.onChange=e.onChange||null,this.months=e.months||["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],this.weekDays=e.weekDays||["Su","Mo","Tu","We","Th","Fr","Sa"],this.todayText=e.todayText||"Today",this.clearText=e.clearText||"Clear",this.currentDate=new Date,this.viewMode="days",this.selectedDate=null,this.rangeStart=null,this.rangeEnd=null,this.isSelectingEnd=!1,this._iconClickHandler=null,this._inputClickHandler=null,this._endInputClickHandler=null,this._documentClickHandler=null,this._originalParent=null,this._documentClickListener=null,this._resizeHandler=null,this._resizeListener=null,this._keydownHandler=null}init(){if(this.calendarEl&&!this.element.__kupolaInitialized){if(this.input&&this.input.value)if(this.range){const t=this.input.value.split(" ~ ");t.length===2&&(this.rangeStart=this._parseDate(t[0].trim()),this.rangeEnd=this._parseDate(t[1].trim()),this.currentDate=new Date(this.rangeStart))}else this.selectedDate=this._parseDate(this.input.value),this.currentDate=new Date(this.selectedDate);this.placeholder&&this.input&&(this.input.placeholder=this.placeholder),this._iconClickHandler=t=>this.toggleCalendar(t),this._inputClickHandler=t=>this.toggleCalendar(t),this.icon&&this.icon.addEventListener("click",this._iconClickHandler),this.input&&this.input.addEventListener("click",this._inputClickHandler),this.endInput&&(this._endInputClickHandler=t=>{this.isSelectingEnd=!0,this.toggleCalendar(t)},this.endInput.addEventListener("click",this._endInputClickHandler)),this._documentClickListener=H.on(document,"click",t=>this.hideCalendar(t),{scope:this.scope}),this._resizeListener=H.on(window,"resize",()=>this.resizeHandler(),{scope:this.scope}),this._keydownHandler=t=>{t.key==="Escape"&&this.calendarEl.style.display==="block"&&this.hideCalendar(t)},document.addEventListener("keydown",this._keydownHandler),this.element.__kupolaInitialized=!0,this._renderCalendar()}}_parseDate(t){if(!t)return null;const e=t.split("-");return e.length===3?new Date(parseInt(e[0]),parseInt(e[1])-1,parseInt(e[2])):null}_formatDate(t){if(!t)return"";const e=t.getFullYear(),s=String(t.getMonth()+1).padStart(2,"0"),n=String(t.getDate()).padStart(2,"0");return this.format.replace("YYYY",e).replace("MM",s).replace("DD",n)}_isDateDisabled(t){if(this.minDate){const e=typeof this.minDate=="string"?this._parseDate(this.minDate):this.minDate;if(t<e)return!0}if(this.maxDate){const e=typeof this.maxDate=="string"?this._parseDate(this.maxDate):this.maxDate;if(t>e)return!0}return this.disabledDate?this.disabledDate(t):!1}_isToday(t){const e=new Date;return t.getFullYear()===e.getFullYear()&&t.getMonth()===e.getMonth()&&t.getDate()===e.getDate()}_isSameDay(t,e){return!t||!e?!1:t.getFullYear()===e.getFullYear()&&t.getMonth()===e.getMonth()&&t.getDate()===e.getDate()}_isInRange(t){if(!this.range||!this.rangeStart||!this.rangeEnd)return!1;const e=t.getTime(),s=Math.min(this.rangeStart.getTime(),this.rangeEnd.getTime()),n=Math.max(this.rangeStart.getTime(),this.rangeEnd.getTime());return e>=s&&e<=n}calculatePosition(){const t=this.element.getBoundingClientRect(),e=this.calendarEl.getBoundingClientRect(),n=window.innerHeight-t.bottom,r=t.top,a=e.height||320;this.appendToBody?(this.calendarEl.style.left=`${t.left}px`,n>=a?(this.calendarEl.style.top=`${t.bottom+4}px`,this.calendarEl.style.bottom="auto"):r>=a?(this.calendarEl.style.top=`${t.top-a-4}px`,this.calendarEl.style.bottom="auto"):(this.calendarEl.style.top=`${t.bottom+4}px`,this.calendarEl.style.bottom="auto")):n>=a?(this.calendarEl.style.top="calc(100% + 4px)",this.calendarEl.style.bottom="auto"):r>=a?(this.calendarEl.style.top="auto",this.calendarEl.style.bottom="calc(100% + 4px)"):(this.calendarEl.style.top="calc(100% + 4px)",this.calendarEl.style.bottom="auto")}toggleCalendar(t){t.preventDefault(),t.stopPropagation();const e=this.calendarEl.style.display==="block";document.querySelectorAll(".ds-datepicker__calendar").forEach(s=>{s!==this.calendarEl&&(s.style.display="none",s.setAttribute("hidden",""))}),e||(this.appendToBody&&(this._appendCalendarToBody(),this._addScrollListener()),this.calendarEl.style.display="block",this.calendarEl.removeAttribute("hidden"),this.calculatePosition())}hideCalendar(t){!this.element.contains(t.target)&&!this.calendarEl.contains(t.target)&&(this.calendarEl.style.display="none",this.calendarEl.setAttribute("hidden",""),this.viewMode="days",this.appendToBody&&(this._restoreCalendarFromBody(),this._removeScrollListener()))}_addScrollListener(){this._scrollHandler=()=>{this.hideCalendar({target:document})},window.addEventListener("scroll",this._scrollHandler,!0)}_removeScrollListener(){this._scrollHandler&&(window.removeEventListener("scroll",this._scrollHandler,!0),this._scrollHandler=null)}_appendCalendarToBody(){if(!this.calendarEl)return;this._originalParent=this.calendarEl.parentNode,this._originalPosition=this.calendarEl.style.position,this._originalTop=this.calendarEl.style.top,this._originalLeft=this.calendarEl.style.left,this._originalWidth=this.calendarEl.style.width,this._originalTransform=this.calendarEl.style.transform,this._originalZIndex=this.calendarEl.style.zIndex;const t=Y().datepicker;this.calendarEl.style.position="fixed",this.calendarEl.style.zIndex=t,this.calendarEl.style.transform="translateZ(0)",document.body.appendChild(this.calendarEl)}_restoreCalendarFromBody(){!this.calendarEl||!this._originalParent||(this._originalParent.appendChild(this.calendarEl),this.calendarEl.style.position=this._originalPosition||"",this.calendarEl.style.top=this._originalTop||"",this.calendarEl.style.left=this._originalLeft||"",this.calendarEl.style.width=this._originalWidth||"",this.calendarEl.style.zIndex=this._originalZIndex||"",this.calendarEl.style.transform=this._originalTransform||"",this._originalParent=null)}resizeHandler(){this.calendarEl.style.display==="block"&&this.calculatePosition()}_renderCalendar(){const t=this.calendarEl;if(!t)return;if(t.querySelectorAll(".ds-datepicker__day").forEach(p=>{p._dayClickHandler&&p.removeEventListener("click",p._dayClickHandler)}),this.viewMode==="years"){this._renderYearsView();return}if(this.viewMode==="months"){this._renderMonthsView();return}const e=this.currentDate.getFullYear(),s=this.currentDate.getMonth();t.innerHTML="";const n=document.createElement("div");n.className="ds-datepicker__header";const r=document.createElement("button");r.className="ds-datepicker__nav ds-datepicker__nav--prev",r.type="button",r.innerHTML='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="15 18 9 12 15 6"/></svg>',r.addEventListener("click",p=>{p.stopPropagation(),this._prevMonth()});const a=document.createElement("button");a.className="ds-datepicker__title",a.type="button",a.textContent=`${e} ${this.months[s]}`,a.addEventListener("click",p=>{p.stopPropagation(),this.viewMode="months",this._renderCalendar()});const o=document.createElement("button");o.className="ds-datepicker__nav ds-datepicker__nav--next",o.type="button",o.innerHTML='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="9 18 15 12 9 6"/></svg>',o.addEventListener("click",p=>{p.stopPropagation(),this._nextMonth()}),n.appendChild(r),n.appendChild(a),n.appendChild(o),t.appendChild(n);const l=document.createElement("div");l.className="ds-datepicker__weekdays",[...this.weekDays.slice(this.weekStart),...this.weekDays.slice(0,this.weekStart)].forEach(p=>{const m=document.createElement("span");m.className="ds-datepicker__weekday",m.textContent=p,l.appendChild(m)}),t.appendChild(l);const h=document.createElement("div");h.className="ds-datepicker__days";const d=new Date(e,s,1).getDay(),u=new Date(e,s+1,0).getDate(),f=(d-this.weekStart+7)%7;for(let p=0;p<f;p++){const m=document.createElement("span");m.className="ds-datepicker__day ds-datepicker__day--empty",h.appendChild(m)}for(let p=1;p<=u;p++){const m=new Date(e,s,p),y=document.createElement("button");y.className="ds-datepicker__day",y.type="button",y.textContent=p,this._formatDate(m),this._isToday(m)&&y.classList.add("is-today"),this.range?((this._isSameDay(m,this.rangeStart)||this._isSameDay(m,this.rangeEnd))&&y.classList.add("is-selected"),this._isInRange(m)&&y.classList.add("is-in-range")):this._isSameDay(m,this.selectedDate)&&y.classList.add("is-selected"),this._isDateDisabled(m)&&(y.classList.add("is-disabled"),y.disabled=!0);const _=()=>this._selectDate(m);y.addEventListener("click",_),y._dayClickHandler=_,h.appendChild(y)}if(t.appendChild(h),this.showToday){const p=document.createElement("div");p.className="ds-datepicker__footer";const m=document.createElement("button");m.className="ds-datepicker__today-btn",m.type="button",m.textContent=this.todayText,m.addEventListener("click",_=>{_.stopPropagation(),this._goToToday()});const y=document.createElement("button");y.className="ds-datepicker__clear-btn",y.type="button",y.textContent=this.clearText,y.addEventListener("click",_=>{_.stopPropagation(),this._clearDate()}),p.appendChild(m),p.appendChild(y),t.appendChild(p)}}_renderYearsView(){const t=this.calendarEl;t.innerHTML="";const e=this.currentDate.getFullYear(),s=e-6,n=document.createElement("div");n.className="ds-datepicker__header";const r=document.createElement("button");r.className="ds-datepicker__nav ds-datepicker__nav--prev",r.type="button",r.innerHTML='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="15 18 9 12 15 6"/></svg>',r.addEventListener("click",c=>{c.stopPropagation(),this.currentDate.setFullYear(this.currentDate.getFullYear()-12),this._renderCalendar()});const a=document.createElement("button");a.className="ds-datepicker__title",a.type="button",a.textContent=`${s} - ${s+11}`,a.addEventListener("click",c=>{c.stopPropagation()});const o=document.createElement("button");o.className="ds-datepicker__nav ds-datepicker__nav--next",o.type="button",o.innerHTML='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="9 18 15 12 9 6"/></svg>',o.addEventListener("click",c=>{c.stopPropagation(),this.currentDate.setFullYear(this.currentDate.getFullYear()+12),this._renderCalendar()}),n.appendChild(r),n.appendChild(a),n.appendChild(o),t.appendChild(n);const l=document.createElement("div");l.className="ds-datepicker__years-grid";for(let c=0;c<12;c++){const h=s+c,d=document.createElement("button");d.className="ds-datepicker__year-cell",d.type="button",d.textContent=h,h===e&&d.classList.add("is-selected"),d.addEventListener("click",u=>{u.stopPropagation(),this.currentDate.setFullYear(h),this.viewMode="months",this._renderCalendar()}),l.appendChild(d)}t.appendChild(l)}_renderMonthsView(){const t=this.calendarEl;t.innerHTML="";const e=this.currentDate.getFullYear(),s=document.createElement("div");s.className="ds-datepicker__header";const n=document.createElement("button");n.className="ds-datepicker__nav ds-datepicker__nav--prev",n.type="button",n.innerHTML='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="15 18 9 12 15 6"/></svg>',n.addEventListener("click",l=>{l.stopPropagation(),this.currentDate.setFullYear(this.currentDate.getFullYear()-1),this._renderCalendar()});const r=document.createElement("button");r.className="ds-datepicker__title",r.type="button",r.textContent=e,r.addEventListener("click",l=>{l.stopPropagation(),this.viewMode="years",this._renderCalendar()});const a=document.createElement("button");a.className="ds-datepicker__nav ds-datepicker__nav--next",a.type="button",a.innerHTML='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="9 18 15 12 9 6"/></svg>',a.addEventListener("click",l=>{l.stopPropagation(),this.currentDate.setFullYear(this.currentDate.getFullYear()+1),this._renderCalendar()}),s.appendChild(n),s.appendChild(r),s.appendChild(a),t.appendChild(s);const o=document.createElement("div");o.className="ds-datepicker__months-grid",this.months.forEach((l,c)=>{const h=document.createElement("button");h.className="ds-datepicker__month-cell",h.type="button",h.textContent=l,c===this.currentDate.getMonth()&&h.classList.add("is-selected"),h.addEventListener("click",d=>{d.stopPropagation(),this.currentDate.setMonth(c),this.viewMode="days",this._renderCalendar()}),o.appendChild(h)}),t.appendChild(o)}_selectDate(t){if(!this._isDateDisabled(t)){if(this.range)if(!this.isSelectingEnd||!this.rangeStart)this.rangeStart=t,this.rangeEnd=null,this.isSelectingEnd=!0;else{this.rangeEnd=t,this.rangeEnd<this.rangeStart&&([this.rangeStart,this.rangeEnd]=[this.rangeEnd,this.rangeStart]),this.isSelectingEnd=!1,this.input&&(this.input.value=this._formatDate(this.rangeStart)),this.endInput&&(this.endInput.value=this._formatDate(this.rangeEnd)),this.calendarEl.style.display="none",this.calendarEl.setAttribute("hidden",""),this._fireChange();return}else{this.selectedDate=t,this.input&&(this.input.value=this._formatDate(t)),this.calendarEl.style.display="none",this.calendarEl.setAttribute("hidden",""),this._fireChange();return}this._renderCalendar()}}_fireChange(){this.input&&this.input.dispatchEvent(new Event("change",{bubbles:!0})),this.onChange&&(this.range?this.onChange({start:this.rangeStart,end:this.rangeEnd,startStr:this._formatDate(this.rangeStart),endStr:this._formatDate(this.rangeEnd)}):this.onChange({date:this.selectedDate,dateStr:this._formatDate(this.selectedDate)})),this.element.dispatchEvent(new CustomEvent("kupola:datepicker-change",{detail:{date:this.selectedDate,dateStr:this._formatDate(this.selectedDate),rangeStart:this.rangeStart,rangeEnd:this.rangeEnd},bubbles:!0}))}_prevMonth(){this.currentDate.setMonth(this.currentDate.getMonth()-1),this._renderCalendar()}_nextMonth(){this.currentDate.setMonth(this.currentDate.getMonth()+1),this._renderCalendar()}_goToToday(){const t=new Date;this.currentDate=new Date(t),this._isDateDisabled(t)?this._renderCalendar():this._selectDate(t)}_clearDate(){this.selectedDate=null,this.rangeStart=null,this.rangeEnd=null,this.isSelectingEnd=!1,this.input&&(this.input.value=""),this.endInput&&(this.endInput.value=""),this.calendarEl.style.display="none",this.calendarEl.setAttribute("hidden",""),this._fireChange()}setDate(t){const e=typeof t=="string"?this._parseDate(t):t;e&&(this.selectedDate=e,this.currentDate=new Date(e),this.input&&(this.input.value=this._formatDate(e)),this._renderCalendar())}getDate(){return this.selectedDate}setRange(t,e){this.rangeStart=typeof t=="string"?this._parseDate(t):t,this.rangeEnd=typeof e=="string"?this._parseDate(e):e,this.input&&(this.input.value=this._formatDate(this.rangeStart)),this.endInput&&(this.endInput.value=this._formatDate(this.rangeEnd)),this._renderCalendar()}destroy(){this.element.__kupolaInitialized&&(this.icon&&this._iconClickHandler&&this.icon.removeEventListener("click",this._iconClickHandler),this.input&&this._inputClickHandler&&this.input.removeEventListener("click",this._inputClickHandler),this.endInput&&this._endInputClickHandler&&this.endInput.removeEventListener("click",this._endInputClickHandler),this._keydownHandler&&document.removeEventListener("keydown",this._keydownHandler),this._documentClickListener&&this._documentClickListener.unsubscribe?this._documentClickListener.unsubscribe():this._documentClickHandler&&document.removeEventListener("click",this._documentClickHandler),this._resizeListener&&this._resizeListener.unsubscribe?this._resizeListener.unsubscribe():this._resizeHandler&&window.removeEventListener("resize",this._resizeHandler),this.calendarEl&&this.calendarEl.querySelectorAll(".ds-datepicker__day").forEach(t=>{t._dayClickHandler&&t.removeEventListener("click",t._dayClickHandler)}),this.appendToBody&&this._originalParent&&this._restoreCalendarFromBody(),this._documentClickHandler=null,this._resizeHandler=null,this._documentClickListener=null,this._resizeListener=null,this._iconClickHandler=null,this._inputClickHandler=null,this._endInputClickHandler=null,this._keydownHandler=null,this.element.__kupolaInitialized=!1)}}function xt(i,t){const e=new Xe(i,t);e.init(),i._kupolaDatepicker=e}function lo(i=document){i.querySelectorAll(".ds-datepicker").forEach(t=>{xt(t)})}function je(i){i._kupolaDatepicker&&(i._kupolaDatepicker.destroy(),i._kupolaDatepicker=null)}E.register("datepicker",xt,je);class Je{constructor(t,e={}){this.element=t,this.input=t.querySelector("input"),this.inputWrap=t.querySelector(".ds-timepicker__input-wrap"),this.panelEl=null,this.scope=`timepicker-${Math.random().toString(36).substr(2,9)}`,this.showSeconds=e.showSeconds||t.hasAttribute("data-timepicker-seconds"),this.use12Hour=e.use12Hour||t.hasAttribute("data-timepicker-12h"),this.hourStep=e.hourStep||parseInt(t.getAttribute("data-timepicker-hour-step"))||1,this.minuteStep=e.minuteStep||parseInt(t.getAttribute("data-timepicker-minute-step"))||5,this.secondStep=e.secondStep||parseInt(t.getAttribute("data-timepicker-second-step"))||5,this.minTime=e.minTime||t.getAttribute("data-timepicker-min")||null,this.maxTime=e.maxTime||t.getAttribute("data-timepicker-max")||null,this.disabledTime=e.disabledTime||null,this.placeholder=e.placeholder||t.getAttribute("data-timepicker-placeholder")||"",this.clearable=e.clearable||t.hasAttribute("data-timepicker-clear"),this.onChange=e.onChange||null,this.selectedHour=12,this.selectedMinute=0,this.selectedSecond=0,this.isPM=!1,this._inputWrapClickHandler=null,this._documentClickHandler=null,this._documentClickListener=null,this._resizeHandler=null,this._resizeListener=null,this._keydownHandler=null}init(){this.element.__kupolaInitialized||(this.placeholder&&this.input&&(this.input.placeholder=this.placeholder),this.input&&this.input.value&&this._parseInputValue(),this._inputWrapClickHandler=t=>{t.stopPropagation(),this.panelEl&&this.panelEl.style.display==="block"?this.hideTimepicker():this.showTimepicker()},this.inputWrap.addEventListener("click",this._inputWrapClickHandler),this._documentClickListener=H.on(document,"click",t=>this.hideTimepicker(t),{scope:this.scope}),this._resizeListener=H.on(window,"resize",()=>this.resizeHandler(),{scope:this.scope}),this._keydownHandler=t=>{t.key==="Escape"&&this.panelEl&&this.panelEl.style.display==="block"&&this.hideTimepicker()},document.addEventListener("keydown",this._keydownHandler),this.element.__kupolaInitialized=!0)}_parseInputValue(){const t=this.input.value.trim();if(!t)return;const e=t.match(/^(\d{1,2}):(\d{2})(?::(\d{2}))?\s*(AM|PM|am|pm)$/i);if(e){this.selectedHour=parseInt(e[1])%12,e[4].toUpperCase()==="PM"&&(this.selectedHour+=12),this.selectedMinute=parseInt(e[2]),this.selectedSecond=e[3]?parseInt(e[3]):0;return}const s=t.split(":");s.length>=2&&(this.selectedHour=parseInt(s[0])||0,this.selectedMinute=parseInt(s[1])||0,this.selectedSecond=s[2]&&parseInt(s[2])||0)}_isTimeDisabled(t,e,s){if(this.disabledTime)return this.disabledTime(t,e,s);const n=t*3600+e*60+s;if(this.minTime){const r=this.minTime.split(":"),a=parseInt(r[0])*3600+parseInt(r[1])*60+(parseInt(r[2])||0);if(n<a)return!0}if(this.maxTime){const r=this.maxTime.split(":"),a=parseInt(r[0])*3600+parseInt(r[1])*60+(parseInt(r[2])||0);if(n>a)return!0}return!1}_formatTime(){let t=this.selectedHour,e=this.selectedMinute,s=this.selectedSecond;if(this.use12Hour){const n=t>=12?"PM":"AM";return t=t%12||12,this.showSeconds?`${t}:${String(e).padStart(2,"0")}:${String(s).padStart(2,"0")} ${n}`:`${t}:${String(e).padStart(2,"0")} ${n}`}return this.showSeconds?`${String(t).padStart(2,"0")}:${String(e).padStart(2,"0")}:${String(s).padStart(2,"0")}`:`${String(t).padStart(2,"0")}:${String(e).padStart(2,"0")}`}calculatePosition(){if(!this.panelEl)return;const t=this.element.getBoundingClientRect(),e=this.panelEl.getBoundingClientRect(),n=window.innerHeight-t.bottom,r=t.top,a=e.height||320;n>=a?(this.panelEl.style.top="calc(100% + 4px)",this.panelEl.style.bottom="auto"):r>=a?(this.panelEl.style.top="auto",this.panelEl.style.bottom="calc(100% + 4px)"):(this.panelEl.style.top="calc(100% + 4px)",this.panelEl.style.bottom="auto")}showTimepicker(){if(this.panelEl){this.panelEl.style.display="block",this._syncPanelSelection(),this.calculatePosition();return}this.panelEl=document.createElement("div"),this.panelEl.className="ds-timepicker__panel";let t="";if(t+=`<div class="ds-timepicker__section">
6
+ `}}_bindLifecycleHooks(){if(this._hooksBound)return;const t={beforeMount:"beforeMount",render:["mount","update"],afterMount:"afterMount",updated:"afterUpdate",beforeUnmount:"beforeUnmount",afterUnmount:"afterUnmount",renderError:"errorBoundary"};let e=Object.getPrototypeOf(this);const s=new Set;for(;e&&e.constructor!==Object&&e.constructor!==J;){for(const[n,r]of Object.entries(t))s.has(n)||e.hasOwnProperty(n)&&(Array.isArray(r)?r.forEach(a=>{n==="render"&&this.lifecycle.on(a,()=>this.render?.())}):n==="renderError"?this.lifecycle.on(r,a=>(this.renderError(a.error),"handled")):this.lifecycle.on(r,()=>this[n]?.()),s.add(n));e=Object.getPrototypeOf(e)}this._hooksBound=!0}async unmount(){if(!(!this.isMounted||this.isDestroyed))try{this.setupContext?._executeUnmounted(),await this.lifecycle.unmount(),this.isMounted=!1,this.isDestroyed=!0,await this.lifecycle.destroy()}catch(t){console.error(`[KupolaComponent] Error unmounting component "${this.constructor.name}":`,t),this.lifecycle&&typeof this.lifecycle._handleError=="function"&&await this.lifecycle._handleError({phase:"unmount",hook:"component",error:t,args:[]}),this.isMounted=!1,this.isDestroyed=!0}}beforeMount(){}afterMount(){}beforeUnmount(){}afterUnmount(){}render(){}renderError(t){}updated(){}setup(){}}function ut(i,t){Object.keys(t).forEach(e=>{if(e!=="constructor")if(typeof t[e]=="function"){const s=i.prototype[e];s?i.prototype[e]=function(...n){return t[e].apply(this,n),s.apply(this,n)}:i.prototype[e]=t[e]}else i.prototype[e]=t[e]})}class Ve{constructor(){this.components=new Map,this.lazyComponents=new Map,this.loadedComponents=new Map,this.instances=new Map,this.observer=null,this.mixins=new Map,this.loadingPromises=new Map}register(t,e){if(!(e.prototype instanceof J))throw new Error(`Component ${t} must extend KupolaComponent`);this.components.set(t,e)}registerLazy(t,e){this.lazyComponents.set(t,e)}unregister(t){this.components.delete(t),this.lazyComponents.delete(t),this.loadedComponents.delete(t),this.loadingPromises.delete(t)}get(t){return this.components.get(t)||this.loadedComponents.get(t)}async getAsync(t){const e=this.components.get(t)||this.loadedComponents.get(t);if(e)return e;if(this.loadingPromises.has(t))return this.loadingPromises.get(t);const s=this.lazyComponents.get(t);if(!s)throw new Error(`Component ${t} not found`);const n=(async()=>{try{const r=await s(),a=r.default||r;if(!(a.prototype instanceof J))throw new Error(`Component ${t} must extend KupolaComponent`);return this.loadedComponents.set(t,a),a}catch(r){throw this.loadingPromises.delete(t),r}})();return this.loadingPromises.set(t,n),n}defineMixin(t,e){this.mixins.set(t,e)}useMixin(t,...e){e.forEach(s=>{const n=this.mixins.get(s);n&&ut(t,n)})}async bootstrap(t=document){await this._upgradeElements(t),this._startObserver(t)}async _upgradeElements(t){const e=t.querySelectorAll("[data-component]"),s=[];e.forEach(n=>{s.push(this._upgradeElement(n))}),await Promise.all(s)}async _upgradeElement(t){if(!(t.__kupolaInstance||t.__kupolaUpgrading)){t.__kupolaUpgrading=!0;try{const e=t.getAttribute("data-component");if(e){const o=E.get(e);if(o)try{await o(t);return}catch(l){console.warn(`[KupolaComponentRegistry] Initializer for "${e}" failed, trying component class:`,l)}}let s=this.components.get(e);if(!s){try{s=await this.getAsync(e)}catch(o){console.error(`Failed to load component ${e}:`,o);return}if(!t.isConnected)return}const n=t.getAttribute("data-mixins"),r=s;n&&n.split(",").forEach(o=>{const l=this.mixins.get(o.trim());l&&ut(r,l)});const a=new r(t);t.__kupolaInstance=a,this.instances.set(t,a),a.mount()}finally{t.__kupolaUpgrading=!1}}}_startObserver(t){this.observer||(this.observer=new MutationObserver(e=>{e.forEach(s=>{s.addedNodes.forEach(n=>{if(n.nodeType===Node.ELEMENT_NODE){n.hasAttribute("data-component")&&this._upgradeElement(n).catch(a=>console.error(a)),this._upgradeElements(n).catch(a=>console.error(a)),E.initialize(n).catch(()=>{});const r=E._buildSelector();r&&n.querySelectorAll?.(r).forEach(a=>{E.initialize(a).catch(()=>{})})}}),s.removedNodes.forEach(n=>{if(n.nodeType===Node.ELEMENT_NODE){const r=this.instances.get(n);r&&(r.unmount(),this.instances.delete(n)),n.querySelectorAll("[data-component]").forEach(a=>{const o=this.instances.get(a);o&&(o.unmount(),this.instances.delete(a))}),E.cleanup(n),n.querySelectorAll?.("*").forEach(a=>{E.cleanup(a)})}})})}),this.observer.observe(t,{childList:!0,subtree:!0}))}destroy(){this.observer&&(this.observer.disconnect(),this.observer=null),this.instances.forEach(t=>{t.unmount()}),this.instances.clear(),this.components.clear(),this.mixins.clear()}}exports.kupolaRegistry=null;typeof window<"u"&&(exports.kupolaRegistry=new Ve);function $a(){if(Z().xssProtection&&typeof document<"u"){let t=document.querySelector('meta[http-equiv="X-XSS-Protection"]');t||(t=document.createElement("meta"),t.setAttribute("http-equiv","X-XSS-Protection"),t.setAttribute("content","1; mode=block"),document.head.insertBefore(t,document.head.firstChild)),t=document.querySelector('meta[http-equiv="X-Content-Type-Options"]'),t||(t=document.createElement("meta"),t.setAttribute("http-equiv","X-Content-Type-Options"),t.setAttribute("content","nosniff"),document.head.insertBefore(t,document.head.firstChild)),t=document.querySelector('meta[http-equiv="X-Frame-Options"]'),t||(t=document.createElement("meta"),t.setAttribute("http-equiv","X-Frame-Options"),t.setAttribute("content","SAMEORIGIN"),document.head.insertBefore(t,document.head.firstChild))}}async function pt(){if(typeof window<"u"){$a();const i=ot();q.loadPersisted(),q.bind(),Ne(),i.components?.autoInit!==!1&&(await E.initializeAll(),exports.kupolaRegistry&&await exports.kupolaRegistry.bootstrap())}}typeof document<"u"&&document.readyState==="loading"?document.addEventListener("DOMContentLoaded",pt):typeof window<"u"&&setTimeout(pt,0);function Ba(i,t){exports.kupolaRegistry&&exports.kupolaRegistry.register(i,t)}function qa(i,t){exports.kupolaRegistry&&exports.kupolaRegistry.registerLazy(i,t)}function Oa(i){return exports.kupolaRegistry?exports.kupolaRegistry.bootstrap(i):Promise.resolve()}function Fa(i,t){exports.kupolaRegistry&&exports.kupolaRegistry.defineMixin(i,t)}function Na(i,...t){exports.kupolaRegistry&&exports.kupolaRegistry.useMixin(i,...t)}function Ra(i,t){if(!t||typeof t!="object")throw new Error(`defineComponent("${i}"): options must be an object`);t.componentClass?exports.kupolaRegistry&&exports.kupolaRegistry.register(i,t.componentClass):t.lazy&&exports.kupolaRegistry&&exports.kupolaRegistry.registerLazy(i,t.lazy),t.init?E.register(i,t.init,t.cleanup||null,{dataAttribute:t.dataAttribute,cssClass:t.cssClass}):(t.dataAttribute||t.cssClass)&&E.register(i,()=>{},null,{dataAttribute:t.dataAttribute,cssClass:t.cssClass})}class _t{constructor(t={}){const e=ot();this.locales=t.locales||{},this.currentLocale=t.defaultLocale||e.i18n?.locale||"zh-CN",this.fallbackLocale=t.fallbackLocale||e.i18n?.fallbackLocale||"en-US",this.delimiter=t.delimiter||".",this.missingHandler=t.missingHandler||(s=>(console.warn(`Missing translation: ${s}`),s)),this._initFromDOM()}_initFromDOM(){document.querySelectorAll('script[type="application/json"][data-kupola-i18n]').forEach(s=>{const n=s.dataset.kupolaI18n;if(n)try{const r=JSON.parse(s.textContent);this.addLocale(n,r)}catch(r){console.error("Failed to parse i18n data:",r)}});const e=document.documentElement.lang;e&&this.locales[e]&&(this.currentLocale=e)}addLocale(t,e){this.locales[t]||(this.locales[t]={}),this._mergeDeep(this.locales[t],e)}_mergeDeep(t,e){for(const s of Object.keys(e))e[s]instanceof Object&&s in t?this._mergeDeep(t[s],e[s]):t[s]=e[s]}setLocale(t){return this.locales[t]?(this.currentLocale=t,document.documentElement.lang=t,this._emitChange(),!0):!1}getLocale(){return this.currentLocale}t(t,e={}){let s=this._getTranslation(t,this.currentLocale);return s||(s=this._getTranslation(t,this.fallbackLocale)),s?this._interpolate(s,e):this.missingHandler(t)}_getTranslation(t,e){if(!this.locales[e])return null;const s=t.split(this.delimiter);let n=this.locales[e];for(const r of s)if(n&&typeof n=="object"&&r in n)n=n[r];else return null;return typeof n=="string"?n:null}_interpolate(t,e){return t.replace(/\{(\w+)\}/g,(s,n)=>e[n]!==void 0?e[n]:s)}n(t,e,s={}){const n=this.t(t,{...s,count:e});if(!n)return n;const r=n.split("|");return r.length===1?n.replace("{count}",e):r.length===2?e===1?r[0]:r[1]:r.length>=3?e===0?r[0]:e===1?r[1]:r[2]:n}_emitChange(){const t=new CustomEvent("kupola:i18n:change",{detail:{locale:this.currentLocale},bubbles:!0});document.dispatchEvent(t)}async loadLocale(t,e){try{const n=await(await fetch(e)).json();return this.addLocale(t,n),!0}catch(s){return console.error("Failed to load locale:",s),!1}}getAvailableLocales(){return Object.keys(this.locales)}hasLocale(t){return!!this.locales[t]}formatDate(t,e={}){const s=e.locale||this.currentLocale,n=typeof t=="string"?new Date(t):t;return new Intl.DateTimeFormat(s,e).format(n)}formatNumber(t,e={}){const s=e.locale||this.currentLocale;return new Intl.NumberFormat(s,e).format(t)}formatCurrency(t,e,s={}){const n=s.locale||this.currentLocale;return new Intl.NumberFormat(n,{style:"currency",currency:e,...s}).format(t)}formatRelativeTime(t,e,s={}){const n=s.locale||this.currentLocale;return new Intl.RelativeTimeFormat(n,s).format(t,e)}}const F=new _t;function Va(i){return new _t(i)}function Ka(i,t={}){return F.t(i,t)}function Wa(i,t,e={}){return F.n(i,t,e)}function Ua(i){return F.setLocale(i)}function Ya(){return F.getLocale()}function Xa(i,t={}){return F.formatDate(i,t)}function ja(i,t={}){return F.formatNumber(i,t)}function Ja(i,t,e={}){return F.formatCurrency(i,t,e)}class Ke{constructor(){this._listeners=new Map,this._scopeListeners=new Map}on(t,e,s,n={}){const{scope:r=null,once:a=!1,passive:o=!1,capture:l=!1}=n,c=this._generateId(),h={id:c,target:t,eventName:e,handler:s,scope:r,once:a,wrappedHandler:null};h.wrappedHandler=u=>{a&&this.offById(c),s.call(t,u)};const d=this._getEventKey(t,e);return this._listeners.has(d)||this._listeners.set(d,[]),this._listeners.get(d).push(h),r&&(this._scopeListeners.has(r)||this._scopeListeners.set(r,[]),this._scopeListeners.get(r).push(c)),t.addEventListener(e,h.wrappedHandler,{passive:o,capture:l}),{unsubscribe:()=>this.offById(c)}}once(t,e,s,n={}){return this.on(t,e,s,{...n,once:!0})}off(t,e,s){const n=this._getEventKey(t,e);if(!this._listeners.has(n))return;const r=this._listeners.get(n),a=r.filter(o=>o.handler!==s);r.forEach(o=>{o.handler===s&&(t.removeEventListener(e,o.wrappedHandler),this._removeFromScope(o))}),a.length===0?this._listeners.delete(n):this._listeners.set(n,a)}offById(t){for(const[e,s]of this._listeners){const n=s.findIndex(r=>r.id===t);if(n!==-1){const r=s[n];return r.target.removeEventListener(r.eventName,r.wrappedHandler),s.splice(n,1),s.length===0&&this._listeners.delete(e),this._removeFromScope(r),!0}}return!1}offByScope(t){if(!this._scopeListeners.has(t))return;this._scopeListeners.get(t).forEach(s=>{this.offById(s)}),this._scopeListeners.delete(t)}offAll(t,e=null){if(e){const s=this._getEventKey(t,e);if(!this._listeners.has(s))return;this._listeners.get(s).forEach(r=>{t.removeEventListener(e,r.wrappedHandler),this._removeFromScope(r)}),this._listeners.delete(s)}else for(const[s,n]of this._listeners){const[r]=s.split(":");this._getTargetId(t)===r&&(n.forEach(a=>{t.removeEventListener(a.eventName,a.wrappedHandler),this._removeFromScope(a)}),this._listeners.delete(s))}}emit(t,e,s={}){const n=new CustomEvent(e,{detail:s,bubbles:!0,cancelable:!0});return t.dispatchEvent(n),n}emitGlobal(t,e={}){return this.emit(document,t,e)}emitToScope(t,e,s={}){if(!this._scopeListeners.has(t))return;const n=this._scopeListeners.get(t),r=new Set;for(const[a,o]of this._listeners)o.forEach(l=>{n.includes(l.id)&&r.add(l.target)});r.forEach(a=>{this.emit(a,e,s)})}getListenerCount(t,e=null){if(e){const r=this._getEventKey(t,e);return this._listeners.has(r)?this._listeners.get(r).length:0}let s=0;const n=this._getTargetId(t);for(const[r,a]of this._listeners){const[o]=r.split(":");o===n&&(s+=a.length)}return s}getScopeListenerCount(t){return this._scopeListeners.has(t)?this._scopeListeners.get(t).length:0}hasListeners(t,e=null){return this.getListenerCount(t,e)>0}_getEventKey(t,e){return`${this._getTargetId(t)}:${e}`}_getTargetId(t){return t===document?"document":t===window?"window":t===document.body?"body":(t._kupolaId||(t._kupolaId=this._generateId()),t._kupolaId)}_generateId(){return`ge-${Math.random().toString(36).substr(2,9)}-${Date.now()}`}_removeFromScope(t){if(!t.scope||!this._scopeListeners.has(t.scope))return;const e=this._scopeListeners.get(t.scope),s=e.indexOf(t.id);s!==-1&&(e.splice(s,1),e.length===0&&this._scopeListeners.delete(t.scope))}destroy(){for(const[t,e]of this._listeners)e.forEach(s=>{s.target.removeEventListener(s.eventName,s.wrappedHandler)});this._listeners.clear(),this._scopeListeners.clear()}}const H=new Ke;function Za(i,t,e,s){return H.on(i,t,e,s)}function Ga(i,t,e,s){return H.once(i,t,e,s)}function Qa(i,t,e){H.off(i,t,e)}function to(i,t,e){return H.emit(i,t,e)}function eo(i,t){return H.emitGlobal(i,t)}function so(i){H.offByScope(i)}function io(i,t){H.offAll(i,t)}function no(i,t){return H.getListenerCount(i,t)}class We{constructor(t,e={}){this.element=t,this.trigger=t.querySelector(".ds-dropdown__trigger"),this.menu=t.querySelector(".ds-dropdown__menu"),this.triggerText=this.trigger?this.trigger.querySelector("span"):null,this.scope=`dropdown-${Math.random().toString(36).substr(2,9)}`;const s=U();this.triggerMode=e.trigger||t.getAttribute("data-dropdown-trigger")||"click",this.hoverDelay=e.hoverDelay||parseInt(t.getAttribute("data-dropdown-hover-delay"))||150,this.disabled=e.disabled||t.hasAttribute("data-dropdown-disabled"),this.keyboardNav=e.keyboardNav!==!1,this.autoPosition=e.autoPosition!==!1,this.closeOnClick=e.closeOnClick!==void 0?e.closeOnClick:s.dropdown?.closeOnClick!==void 0?s.dropdown.closeOnClick:!0,this.appendToBody=e.appendToBody!==!1,this.onSelect=e.onSelect||null,this.onShow=e.onShow||null,this.onHide=e.onHide||null,this.isOpen=!1,this.focusIndex=-1,this._hoverTimer=null,this._hoverLeaveTimer=null,this._originalParent=null,this._originalPosition=null,this._triggerClickHandler=null,this._documentClickHandler=null,this._documentClickListener=null,this._itemClickHandler=null,this._keydownHandler=null,this._mouseenterHandler=null,this._mouseleaveHandler=null,this._triggerMouseenterHandler=null,this._triggerMouseleaveHandler=null,this._triggerKeydownHandler=null}init(){!this.trigger||!this.menu||this.element.__kupolaInitialized||(this._itemClickHandler=t=>{t.stopPropagation();const e=t.currentTarget;e.classList.contains("is-disabled")||e.classList.contains("ds-dropdown__divider")||(this.menu.querySelectorAll(".ds-dropdown__item").forEach(s=>s.classList.remove("is-selected")),e.classList.add("is-selected"),this.triggerText&&!e.hasAttribute("data-no-update-trigger")&&(this.triggerText.textContent=e.textContent.trim()),this.element.setAttribute("data-value",e.getAttribute("data-value")||""),this.onSelect&&this.onSelect({item:e,value:e.getAttribute("data-value"),text:e.textContent.trim()}),this.closeOnClick!==!1&&(this.hideMenu(),this.trigger&&this.trigger.focus()))},this._bindMenuItems(),this._triggerClickHandler=t=>{t.stopPropagation(),!this.disabled&&this.toggleMenu()},this._triggerMouseenterHandler=()=>{this.disabled||this.triggerMode!=="hover"||(clearTimeout(this._hoverLeaveTimer),this._hoverTimer=setTimeout(()=>this.showMenu(),this.hoverDelay))},this._triggerMouseleaveHandler=()=>{this.triggerMode==="hover"&&(clearTimeout(this._hoverTimer),this._hoverLeaveTimer=setTimeout(()=>this.hideMenu(),this.hoverDelay))},this._mouseenterHandler=()=>{this.disabled||this.triggerMode!=="hover"||clearTimeout(this._hoverLeaveTimer)},this._mouseleaveHandler=()=>{this.triggerMode==="hover"&&(this._hoverLeaveTimer=setTimeout(()=>this.hideMenu(),this.hoverDelay))},this._keydownHandler=t=>{if(!this.isOpen||this.disabled)return;const e=this._getNavigableItems();if(e.length)switch(t.key){case"ArrowDown":t.preventDefault(),this.focusIndex=Math.min(this.focusIndex+1,e.length-1),this._focusItem(e);break;case"ArrowUp":t.preventDefault(),this.focusIndex=Math.max(this.focusIndex-1,0),this._focusItem(e);break;case"Enter":case" ":t.preventDefault(),this.focusIndex>=0&&e[this.focusIndex]&&e[this.focusIndex].click();break;case"Escape":t.preventDefault(),this.hideMenu(),this.trigger.focus();break;case"Home":t.preventDefault(),this.focusIndex=0,this._focusItem(e);break;case"End":t.preventDefault(),this.focusIndex=e.length-1,this._focusItem(e);break}},this.triggerMode==="hover"?(this.trigger.addEventListener("mouseenter",this._triggerMouseenterHandler),this.trigger.addEventListener("mouseleave",this._triggerMouseleaveHandler),this.menu.addEventListener("mouseenter",this._mouseenterHandler),this.menu.addEventListener("mouseleave",this._mouseleaveHandler)):this.trigger.addEventListener("click",this._triggerClickHandler),this._triggerKeydownHandler=t=>{this.disabled||(t.key==="Enter"||t.key===" "||t.key==="ArrowDown")&&(t.preventDefault(),this.showMenu())},this.trigger.addEventListener("keydown",this._triggerKeydownHandler),document.addEventListener("keydown",this._keydownHandler),this._documentClickHandler=t=>{if(!this.isOpen)return;const e=this.element.contains(t.target),s=this.menu&&this.menu.contains(t.target);!e&&!s&&this.hideMenu()},this._documentClickListener=H.on(document,"click",this._documentClickHandler,{scope:this.scope}),this.menu.style.display="none",this.element.__kupolaInitialized=!0)}_bindMenuItems(){this.menu.querySelectorAll(".ds-dropdown__item").forEach(t=>{t._dropdownItemClickHandler=e=>this._itemClickHandler(e),t.addEventListener("click",t._dropdownItemClickHandler)})}_getNavigableItems(){return Array.from(this.menu.querySelectorAll(".ds-dropdown__item")).filter(t=>!t.classList.contains("is-disabled")&&!t.classList.contains("ds-dropdown__divider"))}_focusItem(t){t.forEach(e=>e.classList.remove("is-focused")),t[this.focusIndex]&&(t[this.focusIndex].classList.add("is-focused"),t[this.focusIndex].scrollIntoView({block:"nearest"}))}_calculatePosition(){if(!this.autoPosition)return;const t=this.element.getBoundingClientRect(),e=window.innerHeight,s=window.innerWidth;if(this.menu.classList.remove("ds-dropdown--top","ds-dropdown--right","ds-dropdown--dropup"),this.appendToBody){this.menu.style.width=`${t.width}px`;const n=this.menu.getBoundingClientRect(),r=e-t.bottom,a=t.top;r<n.height&&a>r?(this.menu.style.top=`${t.top-n.height-4}px`,this.menu.style.bottom="auto"):(this.menu.style.top=`${t.bottom+4}px`,this.menu.style.bottom="auto"),t.left+n.width>s?(this.menu.style.left=`${t.right-n.width}px`,this.menu.style.right="auto"):(this.menu.style.left=`${t.left}px`,this.menu.style.right="auto")}else{const n=e-t.bottom,r=t.top;n<menuRect.height&&r>n?(this.menu.classList.add("ds-dropdown--dropup"),this.menu.style.top="auto",this.menu.style.bottom="100%",this.menu.style.marginBottom="4px"):(this.menu.style.top="100%",this.menu.style.bottom="auto",this.menu.style.marginBottom="0"),t.left+menuRect.width>s?(this.menu.style.left="auto",this.menu.style.right="0"):(this.menu.style.left="0",this.menu.style.right="auto")}}showMenu(){this.disabled||this.isOpen||(this.isOpen=!0,this.focusIndex=-1,this.element.classList.add("is-open"),this.appendToBody&&(this._appendMenuToBody(),this._addScrollListener()),this.menu.style.display="block",this._calculatePosition(),this.onShow&&this.onShow(),this.element.dispatchEvent(new CustomEvent("kupola:dropdown-show",{bubbles:!0})))}hideMenu(){this.isOpen&&(this.isOpen=!1,this.menu.style.display="none",this.element.classList.remove("is-open"),this.appendToBody&&(this._restoreMenuFromBody(),this._removeScrollListener()),this.menu.querySelectorAll(".ds-dropdown__item").forEach(t=>t.classList.remove("is-focused")),this.onHide&&this.onHide(),this.element.dispatchEvent(new CustomEvent("kupola:dropdown-hide",{bubbles:!0})))}_appendMenuToBody(){if(!this.menu)return;this._originalParent=this.menu.parentNode,this._originalPosition=this.menu.style.position,this._originalTop=this.menu.style.top,this._originalLeft=this.menu.style.left,this._originalRight=this.menu.style.right,this._originalBottom=this.menu.style.bottom,this._originalMarginBottom=this.menu.style.marginBottom,this._originalWidth=this.menu.style.width,this._originalTransform=this.menu.style.transform,this._originalZIndex=this.menu.style.zIndex,this._originalDisplay=this.menu.style.display;const t=this.element.getBoundingClientRect(),e=Y().dropdown;this.menu.style.position="fixed",this.menu.style.width=`${t.width}px`,this.menu.style.zIndex=e,this.menu.style.transform="translateZ(0)",document.body.appendChild(this.menu)}_restoreMenuFromBody(){!this.menu||!this._originalParent||(this._originalParent.appendChild(this.menu),this.menu.style.position=this._originalPosition||"",this.menu.style.top=this._originalTop||"",this.menu.style.left=this._originalLeft||"",this.menu.style.right=this._originalRight||"",this.menu.style.bottom=this._originalBottom||"",this.menu.style.marginBottom=this._originalMarginBottom||"",this.menu.style.width=this._originalWidth||"",this.menu.style.zIndex=this._originalZIndex||"",this.menu.style.transform=this._originalTransform||"",this.menu.style.display=this._originalDisplay||"",this._originalParent=null,console.log("[Dropdown] Menu restored from body"))}_addScrollListener(){this._scrollHandler=()=>{this.hideMenu()},window.addEventListener("scroll",this._scrollHandler,!0)}_removeScrollListener(){this._scrollHandler&&(window.removeEventListener("scroll",this._scrollHandler,!0),this._scrollHandler=null)}toggleMenu(){this.isOpen?this.hideMenu():this.showMenu()}enable(){this.disabled=!1,this.element.removeAttribute("data-dropdown-disabled")}disable(){this.disabled=!0,this.element.setAttribute("data-dropdown-disabled",""),this.hideMenu()}setItems(t){this._itemClickHandler||(this._itemClickHandler=e=>{e.stopPropagation();const s=e.currentTarget;s.classList.contains("is-disabled")||s.classList.contains("ds-dropdown__divider")||(this.menu.querySelectorAll(".ds-dropdown__item").forEach(n=>n.classList.remove("is-selected")),s.classList.add("is-selected"),this.triggerText&&!s.hasAttribute("data-no-update-trigger")&&(this.triggerText.textContent=s.textContent.trim()),this.element.setAttribute("data-value",s.getAttribute("data-value")||""),this.onSelect&&this.onSelect({item:s,value:s.getAttribute("data-value"),text:s.textContent.trim()}),this.closeOnClick!==!1&&(this.hideMenu(),this.trigger&&this.trigger.focus()))}),this.menu.querySelectorAll(".ds-dropdown__item").forEach(e=>{e._dropdownItemClickHandler&&e.removeEventListener("click",e._dropdownItemClickHandler)}),this.menu.innerHTML="",t.forEach((e,s)=>{if(e.type==="divider"){const n=document.createElement("div");n.className="ds-dropdown__divider",this.menu.appendChild(n)}else{const n=document.createElement("div");n.className="ds-dropdown__item"+(e.disabled?" is-disabled":"")+(e.active?" is-selected":""),n.textContent=e.text||e.label||"",e.value!==void 0&&n.setAttribute("data-value",e.value),e.icon&&(n.innerHTML=e.icon+n.innerHTML),e.disabled&&n.classList.add("is-disabled"),n._dropdownItemClickHandler=r=>this._itemClickHandler(r),n.addEventListener("click",n._dropdownItemClickHandler),this.menu.appendChild(n)}})}destroy(){this.element.__kupolaInitialized&&(clearTimeout(this._hoverTimer),clearTimeout(this._hoverLeaveTimer),this.trigger&&(this._triggerClickHandler&&this.trigger.removeEventListener("click",this._triggerClickHandler),this._triggerMouseenterHandler&&this.trigger.removeEventListener("mouseenter",this._triggerMouseenterHandler),this._triggerMouseleaveHandler&&this.trigger.removeEventListener("mouseleave",this._triggerMouseleaveHandler),this._triggerKeydownHandler&&this.trigger.removeEventListener("keydown",this._triggerKeydownHandler)),this.menu&&(this.menu.querySelectorAll(".ds-dropdown__item").forEach(t=>{t._dropdownItemClickHandler&&t.removeEventListener("click",t._dropdownItemClickHandler)}),this._mouseenterHandler&&this.menu.removeEventListener("mouseenter",this._mouseenterHandler),this._mouseleaveHandler&&this.menu.removeEventListener("mouseleave",this._mouseleaveHandler)),this._keydownHandler&&document.removeEventListener("keydown",this._keydownHandler),this._documentClickListener&&this._documentClickListener.unsubscribe?this._documentClickListener.unsubscribe():this._documentClickHandler&&document.removeEventListener("click",this._documentClickHandler),this.appendToBody&&this._originalParent&&this._restoreMenuFromBody(),this._documentClickHandler=null,this._documentClickListener=null,this._triggerClickHandler=null,this._itemClickHandler=null,this._keydownHandler=null,this._mouseenterHandler=null,this._mouseleaveHandler=null,this._triggerMouseenterHandler=null,this._triggerMouseleaveHandler=null,this._triggerKeydownHandler=null,this.element.__kupolaInitialized=!1)}}function yt(i,t){i._kupolaDropdown&&i._kupolaDropdown.destroy();const e=new We(i,t);e.init(),i._kupolaDropdown=e}function ro(i=document){i.querySelectorAll(".ds-dropdown").forEach(t=>{yt(t)})}function vt(i){i._kupolaDropdown&&(i._kupolaDropdown.destroy(),i._kupolaDropdown=null)}function ao(){document.querySelectorAll(".ds-dropdown").forEach(i=>{vt(i)})}E.register("dropdown",yt,vt);class Ue{constructor(t,e={}){this.element=t,this.trigger=t.querySelector(".ds-select__trigger"),this.valueEl=t.querySelector(".ds-select__value")||t.querySelector(".ds-select__trigger span"),this.optionsEl=t.querySelector(".ds-select__options")||t.querySelector(".ds-select__menu"),this.nativeSelect=t.querySelector("select"),this.icon=t.querySelector(".ds-select__icon"),this.scope=`select-${Math.random().toString(36).substr(2,9)}`,this.multiple=e.multiple||t.hasAttribute("data-select-multiple"),this.searchable=e.searchable||t.hasAttribute("data-select-search"),this.clearable=e.clearable||t.hasAttribute("data-select-clear"),this.placeholder=e.placeholder||t.getAttribute("data-select-placeholder")||"",this.disabled=e.disabled||t.hasAttribute("data-select-disabled"),this.maxSelection=e.maxSelection||parseInt(t.getAttribute("data-select-max"))||1/0,this.remoteMethod=e.remoteMethod||null,this.onChange=e.onChange||null,this.appendToBody=e.appendToBody!==!1,this.isOpen=!1,this.selectedValues=new Set,this.allOptions=[],this.filteredOptions=[],this.focusIndex=-1,this.searchInput=null,this.clearBtn=null,this.tagsWrap=null,this._originalParent=null,this._originalPosition=null,this._triggerClickHandler=null,this._documentClickHandler=null,this._documentClickListener=null,this._optionClickHandler=null,this._keydownHandler=null}init(){!this.trigger||!this.optionsEl||this.element.__kupolaInitialized||(this._collectOptions(),this.searchable&&this._createSearchInput(),this.clearable&&this._createClearButton(),this.multiple&&this._createTagsWrap(),this.placeholder&&this.valueEl&&(this.valueEl.setAttribute("data-placeholder",this.placeholder),this.selectedValues.size||(this.valueEl.classList.add("ds-select__value--placeholder"),this.valueEl.textContent=this.placeholder)),this._optionClickHandler=t=>{t.stopPropagation();const e=t.currentTarget;if(e.classList.contains("is-disabled"))return;const s=e.getAttribute("data-value");this.multiple?this._toggleMultiOption(s,e):this._selectSingleOption(s,e)},this._bindOptionClicks(),this._triggerClickHandler=t=>{t.stopPropagation(),!this.disabled&&this.toggleOptions()},this.trigger.addEventListener("click",this._triggerClickHandler),this._keydownHandler=t=>{if(!this.isOpen||this.disabled)return;const e=this._getVisibleOptions();if(e.length)switch(t.key){case"ArrowDown":t.preventDefault(),this.focusIndex=Math.min(this.focusIndex+1,e.length-1),this._focusOption(e);break;case"ArrowUp":t.preventDefault(),this.focusIndex=Math.max(this.focusIndex-1,0),this._focusOption(e);break;case"Enter":t.preventDefault(),this.focusIndex>=0&&e[this.focusIndex]&&e[this.focusIndex].click();break;case"Escape":t.preventDefault(),this.hideOptions(),this.trigger.focus();break}},document.addEventListener("keydown",this._keydownHandler),this._documentClickHandler=t=>{if(!this.isOpen)return;const e=this.element.contains(t.target),s=this.optionsEl&&this.optionsEl.contains(t.target);!e&&!s&&this.hideOptions()},this._documentClickListener=H.on(document,"click",this._documentClickHandler,{scope:this.scope}),this._restoreSelectedState(),this.optionsEl.style.display="none",this.element.__kupolaInitialized=!0)}_collectOptions(){this.allOptions=[],this.optionsEl.querySelectorAll(".ds-select__option, .ds-select__item").forEach(t=>{this.allOptions.push({el:t,value:t.getAttribute("data-value"),text:t.textContent.trim(),group:t.closest(".ds-select__group")?.getAttribute("data-group")||"",disabled:t.classList.contains("is-disabled")})}),this.filteredOptions=[...this.allOptions]}_createSearchInput(){this.searchInput=document.createElement("input"),this.searchInput.className="ds-select__search",this.searchInput.type="text",this.searchInput.placeholder="Search...",this.searchInput.setAttribute("autocomplete","off"),this.searchInput.addEventListener("input",()=>this._handleSearch()),this.searchInput.addEventListener("click",t=>t.stopPropagation()),this.optionsEl.insertBefore(this.searchInput,this.optionsEl.firstChild)}_createClearButton(){this.clearBtn=document.createElement("button"),this.clearBtn.className="ds-select__clear",this.clearBtn.type="button",this.clearBtn.innerHTML='<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>',this.clearBtn.style.display="none",this.clearBtn.addEventListener("click",e=>{e.stopPropagation(),this.clear()});const t=this.trigger.querySelector(".ds-select__value")||this.trigger;t.parentNode.insertBefore(this.clearBtn,t.nextSibling)}_createTagsWrap(){this.tagsWrap=document.createElement("div"),this.tagsWrap.className="ds-select__tags";const t=this.valueEl||this.trigger;t.parentNode.insertBefore(this.tagsWrap,t.nextSibling)}_handleSearch(){const t=this.searchInput.value.toLowerCase().trim();if(this.remoteMethod){this.remoteMethod(t,e=>{this._renderRemoteOptions(e)});return}this.filteredOptions=this.allOptions.filter(e=>e.text.toLowerCase().includes(t)),this.allOptions.forEach(e=>{const s=this.filteredOptions.includes(e);e.el.style.display=s?"":"none"}),this.optionsEl.querySelectorAll(".ds-select__group-title").forEach(e=>{const s=e.getAttribute("data-group"),n=this.filteredOptions.some(r=>r.group===s);e.style.display=n?"":"none"}),this.focusIndex=-1}_renderRemoteOptions(t){this._optionClickHandler||(this._optionClickHandler=e=>{e.stopPropagation();const s=e.currentTarget;if(s.classList.contains("is-disabled"))return;const n=s.getAttribute("data-value");this.multiple?this._toggleMultiOption(n,s):this._selectSingleOption(n,s)}),this.optionsEl.querySelectorAll(".ds-select__option, .ds-select__item").forEach(e=>{e._selectOptionClickHandler&&e.removeEventListener("click",e._selectOptionClickHandler),e.remove()}),t.forEach(e=>{const s=document.createElement("div");s.className="ds-select__option",s.setAttribute("data-value",e.value),s.textContent=e.text||e.label,e.disabled&&s.classList.add("is-disabled"),this.selectedValues.has(e.value)&&s.classList.add("is-selected"),s._selectOptionClickHandler=n=>this._optionClickHandler(n),s.addEventListener("click",s._selectOptionClickHandler),this.optionsEl.appendChild(s)}),this.allOptions=t.map(e=>({el:this.optionsEl.querySelector(`[data-value="${e.value}"]`),value:e.value,text:e.text||e.label,group:"",disabled:!!e.disabled})),this.filteredOptions=[...this.allOptions]}_selectSingleOption(t,e){this.optionsEl.querySelectorAll(".ds-select__option, .ds-select__item").forEach(s=>s.classList.remove("is-selected")),e.classList.add("is-selected"),this.selectedValues.clear(),this.selectedValues.add(t),this.updateValue(e.textContent.trim()),this._syncNativeSelect(),this.hideOptions(),this._updateClearBtn(),this._fireChange()}_toggleMultiOption(t,e){if(this.selectedValues.has(t))this.selectedValues.delete(t),e.classList.remove("is-selected");else{if(this.selectedValues.size>=this.maxSelection)return;this.selectedValues.add(t),e.classList.add("is-selected")}this._updateTags(),this._updateValueDisplay(),this._syncNativeSelect(),this._updateClearBtn(),this._fireChange()}_updateTags(){this.tagsWrap&&(this.tagsWrap.innerHTML="",this.selectedValues.forEach(t=>{const e=this.allOptions.find(r=>r.value===t);if(!e)return;const s=document.createElement("span");s.className="ds-select__tag",s.textContent=e.text;const n=document.createElement("button");n.className="ds-select__tag-close",n.type="button",n.innerHTML='<svg width="10" height="10" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>',n.addEventListener("click",r=>{r.stopPropagation(),this.selectedValues.delete(t);const a=this.optionsEl.querySelector(`[data-value="${t}"]`);a&&a.classList.remove("is-selected"),this._updateTags(),this._updateValueDisplay(),this._syncNativeSelect(),this._updateClearBtn(),this._fireChange()}),s.appendChild(n),this.tagsWrap.appendChild(s)}))}_updateValueDisplay(){if(this.valueEl)if(this.multiple){const t=this.selectedValues.size;t===0?(this.valueEl.textContent=this.placeholder||"",this.valueEl.classList.add("ds-select__value--placeholder")):(this.valueEl.textContent=`Selected ${t}`,this.valueEl.classList.remove("ds-select__value--placeholder")),this.tagsWrap&&(this.valueEl.style.display=t>0?"none":"")}else this.selectedValues.size===0&&(this.valueEl.textContent=this.placeholder||"",this.valueEl.classList.add("ds-select__value--placeholder"))}_updateClearBtn(){this.clearBtn&&(this.clearBtn.style.display=this.selectedValues.size>0?"":"none")}_syncNativeSelect(){this.nativeSelect&&(this.multiple?Array.from(this.nativeSelect.options).forEach(t=>{t.selected=this.selectedValues.has(t.value)}):this.nativeSelect.value=Array.from(this.selectedValues)[0]||"")}_fireChange(){this.nativeSelect&&this.nativeSelect.dispatchEvent(new Event("change",{bubbles:!0}));const t=this.multiple?Array.from(this.selectedValues):Array.from(this.selectedValues)[0];this.onChange&&this.onChange({values:t,selectedOptions:this.getSelectedOptions()}),this.element.dispatchEvent(new CustomEvent("kupola:select-change",{detail:{values:t,selectedOptions:this.getSelectedOptions()},bubbles:!0}))}_restoreSelectedState(){if(this.nativeSelect){if(this.multiple)Array.from(this.nativeSelect.selectedOptions).forEach(t=>{this.selectedValues.add(t.value);const e=this.optionsEl.querySelector(`[data-value="${t.value}"]`);e&&e.classList.add("is-selected")}),this._updateTags(),this._updateValueDisplay();else if(this.nativeSelect.value){this.selectedValues.add(this.nativeSelect.value);const t=this.optionsEl.querySelector(`[data-value="${this.nativeSelect.value}"]`);t&&(t.classList.add("is-selected"),this.updateValue(t.textContent.trim()))}}this._updateClearBtn()}_bindOptionClicks(){this.optionsEl.querySelectorAll(".ds-select__option, .ds-select__item").forEach(t=>{t._selectOptionClickHandler=e=>this._optionClickHandler(e),t.addEventListener("click",t._selectOptionClickHandler)})}_getVisibleOptions(){return Array.from(this.optionsEl.querySelectorAll(".ds-select__option, .ds-select__item")).filter(t=>t.style.display!=="none"&&!t.classList.contains("is-disabled"))}_focusOption(t){t.forEach(e=>e.classList.remove("is-focused")),t[this.focusIndex]&&(t[this.focusIndex].classList.add("is-focused"),t[this.focusIndex].scrollIntoView({block:"nearest"}))}updateValue(t){this.valueEl&&(this.valueEl.textContent=t||this.valueEl.textContent,this.valueEl.classList.remove("ds-select__value--placeholder"))}showOptions(){this.disabled||this.isOpen||(this.isOpen=!0,this.element.classList.add("is-open"),this.icon&&(this.icon.style.transform="rotate(180deg)"),this.focusIndex=-1,this.appendToBody&&(this._appendOptionsToBody(),this._addScrollListener()),this.optionsEl.style.display="block",this._calculateOptionsPosition(),this.searchInput&&setTimeout(()=>this.searchInput.focus(),50))}hideOptions(){this.isOpen&&(this.isOpen=!1,this.optionsEl.style.display="none",this.icon&&(this.icon.style.transform="rotate(0deg)"),this.element.classList.remove("is-open"),this.appendToBody&&(this._restoreOptionsFromBody(),this._removeScrollListener()),this.searchInput&&(this.searchInput.value="",this._handleSearch()),this.optionsEl.querySelectorAll(".ds-select__option, .ds-select__item").forEach(t=>t.classList.remove("is-focused")))}_addScrollListener(){this._scrollHandler=()=>{this.hideOptions()},window.addEventListener("scroll",this._scrollHandler,!0)}_removeScrollListener(){this._scrollHandler&&(window.removeEventListener("scroll",this._scrollHandler,!0),this._scrollHandler=null)}_appendOptionsToBody(){if(!this.optionsEl)return;this._originalParent=this.optionsEl.parentNode,this._originalPosition=this.optionsEl.style.position,this._originalTop=this.optionsEl.style.top,this._originalLeft=this.optionsEl.style.left,this._originalRight=this.optionsEl.style.right,this._originalWidth=this.optionsEl.style.width,this._originalTransform=this.optionsEl.style.transform,this._originalZIndex=this.optionsEl.style.zIndex;const t=this.element.getBoundingClientRect(),e=Y().dropdown;this.optionsEl.style.position="fixed",this.optionsEl.style.width=`${t.width}px`,this.optionsEl.style.zIndex=e,this.optionsEl.style.transform="translateZ(0)",document.body.appendChild(this.optionsEl)}_restoreOptionsFromBody(){!this.optionsEl||!this._originalParent||(this._originalParent.appendChild(this.optionsEl),this.optionsEl.style.position=this._originalPosition||"",this.optionsEl.style.top=this._originalTop||"",this.optionsEl.style.left=this._originalLeft||"",this.optionsEl.style.right=this._originalRight||"",this.optionsEl.style.width=this._originalWidth||"",this.optionsEl.style.zIndex=this._originalZIndex||"",this.optionsEl.style.transform=this._originalTransform||"",this._originalParent=null)}_calculateOptionsPosition(){if(!this.appendToBody||!this.optionsEl)return;const t=this.element.getBoundingClientRect(),e=window.innerHeight,s=window.innerWidth;this.optionsEl.style.width=`${t.width}px`;const n=this.optionsEl.getBoundingClientRect(),r=e-t.bottom,a=t.top;r<n.height&&a>r?this.optionsEl.style.top=`${t.top-n.height-4}px`:this.optionsEl.style.top=`${t.bottom+4}px`,t.left+n.width>s?this.optionsEl.style.left=`${t.right-n.width}px`:this.optionsEl.style.left=`${t.left}px`}toggleOptions(){this.isOpen?this.hideOptions():this.showOptions()}clear(){this.selectedValues.clear(),this.optionsEl.querySelectorAll(".ds-select__option, .ds-select__item").forEach(t=>t.classList.remove("is-selected")),this._updateTags(),this._updateValueDisplay(),this._syncNativeSelect(),this._updateClearBtn(),this._fireChange()}getSelectedOptions(){return Array.from(this.selectedValues).map(t=>{const e=this.allOptions.find(s=>s.value===t);return e?{value:e.value,text:e.text}:{value:t,text:""}})}getValue(){return this.multiple?Array.from(this.selectedValues):Array.from(this.selectedValues)[0]||""}setValue(t){this.multiple&&Array.isArray(t)?(this.selectedValues.clear(),t.forEach(e=>this.selectedValues.add(e)),this.optionsEl.querySelectorAll(".ds-select__option, .ds-select__item").forEach(e=>{e.classList.toggle("is-selected",this.selectedValues.has(e.getAttribute("data-value")))}),this._updateTags(),this._updateValueDisplay()):(this.selectedValues.clear(),this.selectedValues.add(t),this.optionsEl.querySelectorAll(".ds-select__option, .ds-select__item").forEach(e=>{const s=e.getAttribute("data-value")===t;e.classList.toggle("is-selected",s),s&&this.updateValue(e.textContent.trim())})),this._syncNativeSelect(),this._updateClearBtn()}enable(){this.disabled=!1,this.element.removeAttribute("data-select-disabled")}disable(){this.disabled=!0,this.element.setAttribute("data-select-disabled",""),this.hideOptions()}destroy(){this.element.__kupolaInitialized&&(this.trigger&&this._triggerClickHandler&&this.trigger.removeEventListener("click",this._triggerClickHandler),this.optionsEl&&this.optionsEl.querySelectorAll(".ds-select__option, .ds-select__item").forEach(t=>{t._selectOptionClickHandler&&t.removeEventListener("click",t._selectOptionClickHandler)}),this._keydownHandler&&document.removeEventListener("keydown",this._keydownHandler),this._documentClickListener&&this._documentClickListener.unsubscribe?this._documentClickListener.unsubscribe():this._documentClickHandler&&document.removeEventListener("click",this._documentClickHandler),this.searchInput&&this.searchInput.remove(),this.clearBtn&&this.clearBtn.remove(),this.tagsWrap&&this.tagsWrap.remove(),this.appendToBody&&this._originalParent&&this._restoreOptionsFromBody(),this._documentClickHandler=null,this._documentClickListener=null,this._triggerClickHandler=null,this._optionClickHandler=null,this._keydownHandler=null,this.element.__kupolaInitialized=!1)}}function bt(i,t){const e=new Ue(i,t);e.init(),i._kupolaSelect=e}function oo(i=document){i.querySelectorAll(".ds-select").forEach(t=>{bt(t)})}function Ye(i){i._kupolaSelect&&(i._kupolaSelect.destroy(),i._kupolaSelect=null)}E.register("select",bt,Ye);class Xe{constructor(t,e={}){this.element=t,this.input=t.querySelector("input"),this.endInput=t.querySelector(".ds-datepicker__end-input"),this.icon=t.querySelector(".ds-datepicker__icon"),this.calendarEl=t.querySelector(".ds-datepicker__calendar"),this.scope=`datepicker-${Math.random().toString(36).substr(2,9)}`;const s=U(),n=s.datepicker?.weekStart!==void 0?s.datepicker.weekStart:1;this.format=e.format||t.getAttribute("data-datepicker-format")||"YYYY-MM-DD",this.range=e.range||t.hasAttribute("data-datepicker-range"),this.minDate=e.minDate||t.getAttribute("data-datepicker-min")||null,this.maxDate=e.maxDate||t.getAttribute("data-datepicker-max")||null,this.disabledDate=e.disabledDate||null,this.weekStart=e.weekStart!==void 0?e.weekStart:parseInt(t.getAttribute("data-datepicker-week-start"))||n,this.appendToBody=e.appendToBody!==!1,this.placeholder=e.placeholder||t.getAttribute("data-datepicker-placeholder")||"",this.showToday=e.showToday!==!1,this.showWeekNumber=e.showWeekNumber||t.hasAttribute("data-datepicker-week-number"),this.onChange=e.onChange||null,this.months=e.months||["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],this.weekDays=e.weekDays||["Su","Mo","Tu","We","Th","Fr","Sa"],this.todayText=e.todayText||"Today",this.clearText=e.clearText||"Clear",this.currentDate=new Date,this.viewMode="days",this.selectedDate=null,this.rangeStart=null,this.rangeEnd=null,this.isSelectingEnd=!1,this._iconClickHandler=null,this._inputClickHandler=null,this._endInputClickHandler=null,this._documentClickHandler=null,this._originalParent=null,this._documentClickListener=null,this._resizeHandler=null,this._resizeListener=null,this._keydownHandler=null}init(){if(this.calendarEl&&!this.element.__kupolaInitialized){if(this.input&&this.input.value)if(this.range){const t=this.input.value.split(" ~ ");t.length===2&&(this.rangeStart=this._parseDate(t[0].trim()),this.rangeEnd=this._parseDate(t[1].trim()),this.currentDate=new Date(this.rangeStart))}else this.selectedDate=this._parseDate(this.input.value),this.currentDate=new Date(this.selectedDate);this.placeholder&&this.input&&(this.input.placeholder=this.placeholder),this._iconClickHandler=t=>this.toggleCalendar(t),this._inputClickHandler=t=>this.toggleCalendar(t),this.icon&&this.icon.addEventListener("click",this._iconClickHandler),this.input&&this.input.addEventListener("click",this._inputClickHandler),this.endInput&&(this._endInputClickHandler=t=>{this.isSelectingEnd=!0,this.toggleCalendar(t)},this.endInput.addEventListener("click",this._endInputClickHandler)),this._documentClickListener=H.on(document,"click",t=>this.hideCalendar(t),{scope:this.scope}),this._resizeListener=H.on(window,"resize",()=>this.resizeHandler(),{scope:this.scope}),this._keydownHandler=t=>{t.key==="Escape"&&this.calendarEl.style.display==="block"&&this.hideCalendar(t)},document.addEventListener("keydown",this._keydownHandler),this.element.__kupolaInitialized=!0,this._renderCalendar()}}_parseDate(t){if(!t)return null;const e=t.split("-");return e.length===3?new Date(parseInt(e[0]),parseInt(e[1])-1,parseInt(e[2])):null}_formatDate(t){if(!t)return"";const e=t.getFullYear(),s=String(t.getMonth()+1).padStart(2,"0"),n=String(t.getDate()).padStart(2,"0");return this.format.replace("YYYY",e).replace("MM",s).replace("DD",n)}_isDateDisabled(t){if(this.minDate){const e=typeof this.minDate=="string"?this._parseDate(this.minDate):this.minDate;if(t<e)return!0}if(this.maxDate){const e=typeof this.maxDate=="string"?this._parseDate(this.maxDate):this.maxDate;if(t>e)return!0}return this.disabledDate?this.disabledDate(t):!1}_isToday(t){const e=new Date;return t.getFullYear()===e.getFullYear()&&t.getMonth()===e.getMonth()&&t.getDate()===e.getDate()}_isSameDay(t,e){return!t||!e?!1:t.getFullYear()===e.getFullYear()&&t.getMonth()===e.getMonth()&&t.getDate()===e.getDate()}_isInRange(t){if(!this.range||!this.rangeStart||!this.rangeEnd)return!1;const e=t.getTime(),s=Math.min(this.rangeStart.getTime(),this.rangeEnd.getTime()),n=Math.max(this.rangeStart.getTime(),this.rangeEnd.getTime());return e>=s&&e<=n}calculatePosition(){const t=this.element.getBoundingClientRect(),e=this.calendarEl.getBoundingClientRect(),n=window.innerHeight-t.bottom,r=t.top,a=e.height||320;this.appendToBody?(this.calendarEl.style.left=`${t.left}px`,n>=a?(this.calendarEl.style.top=`${t.bottom+4}px`,this.calendarEl.style.bottom="auto"):r>=a?(this.calendarEl.style.top=`${t.top-a-4}px`,this.calendarEl.style.bottom="auto"):(this.calendarEl.style.top=`${t.bottom+4}px`,this.calendarEl.style.bottom="auto")):n>=a?(this.calendarEl.style.top="calc(100% + 4px)",this.calendarEl.style.bottom="auto"):r>=a?(this.calendarEl.style.top="auto",this.calendarEl.style.bottom="calc(100% + 4px)"):(this.calendarEl.style.top="calc(100% + 4px)",this.calendarEl.style.bottom="auto")}toggleCalendar(t){t.preventDefault(),t.stopPropagation();const e=this.calendarEl.style.display==="block";document.querySelectorAll(".ds-datepicker__calendar").forEach(s=>{s!==this.calendarEl&&(s.style.display="none",s.setAttribute("hidden",""))}),e||(this.appendToBody&&(this._appendCalendarToBody(),this._addScrollListener()),this.calendarEl.style.display="block",this.calendarEl.removeAttribute("hidden"),this.calculatePosition())}hideCalendar(t){!this.element.contains(t.target)&&!this.calendarEl.contains(t.target)&&(this.calendarEl.style.display="none",this.calendarEl.setAttribute("hidden",""),this.viewMode="days",this.appendToBody&&(this._restoreCalendarFromBody(),this._removeScrollListener()))}_addScrollListener(){this._scrollHandler=()=>{this.hideCalendar({target:document})},window.addEventListener("scroll",this._scrollHandler,!0)}_removeScrollListener(){this._scrollHandler&&(window.removeEventListener("scroll",this._scrollHandler,!0),this._scrollHandler=null)}_appendCalendarToBody(){if(!this.calendarEl)return;this._originalParent=this.calendarEl.parentNode,this._originalPosition=this.calendarEl.style.position,this._originalTop=this.calendarEl.style.top,this._originalLeft=this.calendarEl.style.left,this._originalWidth=this.calendarEl.style.width,this._originalTransform=this.calendarEl.style.transform,this._originalZIndex=this.calendarEl.style.zIndex;const t=Y().datepicker;this.calendarEl.style.position="fixed",this.calendarEl.style.zIndex=t,this.calendarEl.style.transform="translateZ(0)",document.body.appendChild(this.calendarEl)}_restoreCalendarFromBody(){!this.calendarEl||!this._originalParent||(this._originalParent.appendChild(this.calendarEl),this.calendarEl.style.position=this._originalPosition||"",this.calendarEl.style.top=this._originalTop||"",this.calendarEl.style.left=this._originalLeft||"",this.calendarEl.style.width=this._originalWidth||"",this.calendarEl.style.zIndex=this._originalZIndex||"",this.calendarEl.style.transform=this._originalTransform||"",this._originalParent=null)}resizeHandler(){this.calendarEl.style.display==="block"&&this.calculatePosition()}_renderCalendar(){const t=this.calendarEl;if(!t)return;if(t.querySelectorAll(".ds-datepicker__day").forEach(p=>{p._dayClickHandler&&p.removeEventListener("click",p._dayClickHandler)}),this.viewMode==="years"){this._renderYearsView();return}if(this.viewMode==="months"){this._renderMonthsView();return}const e=this.currentDate.getFullYear(),s=this.currentDate.getMonth();t.innerHTML="";const n=document.createElement("div");n.className="ds-datepicker__header";const r=document.createElement("button");r.className="ds-datepicker__nav ds-datepicker__nav--prev",r.type="button",r.innerHTML='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="15 18 9 12 15 6"/></svg>',r.addEventListener("click",p=>{p.stopPropagation(),this._prevMonth()});const a=document.createElement("button");a.className="ds-datepicker__title",a.type="button",a.textContent=`${e} ${this.months[s]}`,a.addEventListener("click",p=>{p.stopPropagation(),this.viewMode="months",this._renderCalendar()});const o=document.createElement("button");o.className="ds-datepicker__nav ds-datepicker__nav--next",o.type="button",o.innerHTML='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="9 18 15 12 9 6"/></svg>',o.addEventListener("click",p=>{p.stopPropagation(),this._nextMonth()}),n.appendChild(r),n.appendChild(a),n.appendChild(o),t.appendChild(n);const l=document.createElement("div");l.className="ds-datepicker__weekdays",[...this.weekDays.slice(this.weekStart),...this.weekDays.slice(0,this.weekStart)].forEach(p=>{const m=document.createElement("span");m.className="ds-datepicker__weekday",m.textContent=p,l.appendChild(m)}),t.appendChild(l);const h=document.createElement("div");h.className="ds-datepicker__days";const d=new Date(e,s,1).getDay(),u=new Date(e,s+1,0).getDate(),f=(d-this.weekStart+7)%7;for(let p=0;p<f;p++){const m=document.createElement("span");m.className="ds-datepicker__day ds-datepicker__day--empty",h.appendChild(m)}for(let p=1;p<=u;p++){const m=new Date(e,s,p),y=document.createElement("button");y.className="ds-datepicker__day",y.type="button",y.textContent=p,this._formatDate(m),this._isToday(m)&&y.classList.add("is-today"),this.range?((this._isSameDay(m,this.rangeStart)||this._isSameDay(m,this.rangeEnd))&&y.classList.add("is-selected"),this._isInRange(m)&&y.classList.add("is-in-range")):this._isSameDay(m,this.selectedDate)&&y.classList.add("is-selected"),this._isDateDisabled(m)&&(y.classList.add("is-disabled"),y.disabled=!0);const _=()=>this._selectDate(m);y.addEventListener("click",_),y._dayClickHandler=_,h.appendChild(y)}if(t.appendChild(h),this.showToday){const p=document.createElement("div");p.className="ds-datepicker__footer";const m=document.createElement("button");m.className="ds-datepicker__today-btn",m.type="button",m.textContent=this.todayText,m.addEventListener("click",_=>{_.stopPropagation(),this._goToToday()});const y=document.createElement("button");y.className="ds-datepicker__clear-btn",y.type="button",y.textContent=this.clearText,y.addEventListener("click",_=>{_.stopPropagation(),this._clearDate()}),p.appendChild(m),p.appendChild(y),t.appendChild(p)}}_renderYearsView(){const t=this.calendarEl;t.innerHTML="";const e=this.currentDate.getFullYear(),s=e-6,n=document.createElement("div");n.className="ds-datepicker__header";const r=document.createElement("button");r.className="ds-datepicker__nav ds-datepicker__nav--prev",r.type="button",r.innerHTML='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="15 18 9 12 15 6"/></svg>',r.addEventListener("click",c=>{c.stopPropagation(),this.currentDate.setFullYear(this.currentDate.getFullYear()-12),this._renderCalendar()});const a=document.createElement("button");a.className="ds-datepicker__title",a.type="button",a.textContent=`${s} - ${s+11}`,a.addEventListener("click",c=>{c.stopPropagation()});const o=document.createElement("button");o.className="ds-datepicker__nav ds-datepicker__nav--next",o.type="button",o.innerHTML='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="9 18 15 12 9 6"/></svg>',o.addEventListener("click",c=>{c.stopPropagation(),this.currentDate.setFullYear(this.currentDate.getFullYear()+12),this._renderCalendar()}),n.appendChild(r),n.appendChild(a),n.appendChild(o),t.appendChild(n);const l=document.createElement("div");l.className="ds-datepicker__years-grid";for(let c=0;c<12;c++){const h=s+c,d=document.createElement("button");d.className="ds-datepicker__year-cell",d.type="button",d.textContent=h,h===e&&d.classList.add("is-selected"),d.addEventListener("click",u=>{u.stopPropagation(),this.currentDate.setFullYear(h),this.viewMode="months",this._renderCalendar()}),l.appendChild(d)}t.appendChild(l)}_renderMonthsView(){const t=this.calendarEl;t.innerHTML="";const e=this.currentDate.getFullYear(),s=document.createElement("div");s.className="ds-datepicker__header";const n=document.createElement("button");n.className="ds-datepicker__nav ds-datepicker__nav--prev",n.type="button",n.innerHTML='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="15 18 9 12 15 6"/></svg>',n.addEventListener("click",l=>{l.stopPropagation(),this.currentDate.setFullYear(this.currentDate.getFullYear()-1),this._renderCalendar()});const r=document.createElement("button");r.className="ds-datepicker__title",r.type="button",r.textContent=e,r.addEventListener("click",l=>{l.stopPropagation(),this.viewMode="years",this._renderCalendar()});const a=document.createElement("button");a.className="ds-datepicker__nav ds-datepicker__nav--next",a.type="button",a.innerHTML='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="9 18 15 12 9 6"/></svg>',a.addEventListener("click",l=>{l.stopPropagation(),this.currentDate.setFullYear(this.currentDate.getFullYear()+1),this._renderCalendar()}),s.appendChild(n),s.appendChild(r),s.appendChild(a),t.appendChild(s);const o=document.createElement("div");o.className="ds-datepicker__months-grid",this.months.forEach((l,c)=>{const h=document.createElement("button");h.className="ds-datepicker__month-cell",h.type="button",h.textContent=l,c===this.currentDate.getMonth()&&h.classList.add("is-selected"),h.addEventListener("click",d=>{d.stopPropagation(),this.currentDate.setMonth(c),this.viewMode="days",this._renderCalendar()}),o.appendChild(h)}),t.appendChild(o)}_selectDate(t){if(!this._isDateDisabled(t)){if(this.range)if(!this.isSelectingEnd||!this.rangeStart)this.rangeStart=t,this.rangeEnd=null,this.isSelectingEnd=!0;else{this.rangeEnd=t,this.rangeEnd<this.rangeStart&&([this.rangeStart,this.rangeEnd]=[this.rangeEnd,this.rangeStart]),this.isSelectingEnd=!1,this.input&&(this.input.value=this._formatDate(this.rangeStart)),this.endInput&&(this.endInput.value=this._formatDate(this.rangeEnd)),this.calendarEl.style.display="none",this.calendarEl.setAttribute("hidden",""),this._fireChange();return}else{this.selectedDate=t,this.input&&(this.input.value=this._formatDate(t)),this.calendarEl.style.display="none",this.calendarEl.setAttribute("hidden",""),this._fireChange();return}this._renderCalendar()}}_fireChange(){this.input&&this.input.dispatchEvent(new Event("change",{bubbles:!0})),this.onChange&&(this.range?this.onChange({start:this.rangeStart,end:this.rangeEnd,startStr:this._formatDate(this.rangeStart),endStr:this._formatDate(this.rangeEnd)}):this.onChange({date:this.selectedDate,dateStr:this._formatDate(this.selectedDate)})),this.element.dispatchEvent(new CustomEvent("kupola:datepicker-change",{detail:{date:this.selectedDate,dateStr:this._formatDate(this.selectedDate),rangeStart:this.rangeStart,rangeEnd:this.rangeEnd},bubbles:!0}))}_prevMonth(){this.currentDate.setMonth(this.currentDate.getMonth()-1),this._renderCalendar()}_nextMonth(){this.currentDate.setMonth(this.currentDate.getMonth()+1),this._renderCalendar()}_goToToday(){const t=new Date;this.currentDate=new Date(t),this._isDateDisabled(t)?this._renderCalendar():this._selectDate(t)}_clearDate(){this.selectedDate=null,this.rangeStart=null,this.rangeEnd=null,this.isSelectingEnd=!1,this.input&&(this.input.value=""),this.endInput&&(this.endInput.value=""),this.calendarEl.style.display="none",this.calendarEl.setAttribute("hidden",""),this._fireChange()}setDate(t){const e=typeof t=="string"?this._parseDate(t):t;e&&(this.selectedDate=e,this.currentDate=new Date(e),this.input&&(this.input.value=this._formatDate(e)),this._renderCalendar())}getDate(){return this.selectedDate}setRange(t,e){this.rangeStart=typeof t=="string"?this._parseDate(t):t,this.rangeEnd=typeof e=="string"?this._parseDate(e):e,this.input&&(this.input.value=this._formatDate(this.rangeStart)),this.endInput&&(this.endInput.value=this._formatDate(this.rangeEnd)),this._renderCalendar()}destroy(){this.element.__kupolaInitialized&&(this.icon&&this._iconClickHandler&&this.icon.removeEventListener("click",this._iconClickHandler),this.input&&this._inputClickHandler&&this.input.removeEventListener("click",this._inputClickHandler),this.endInput&&this._endInputClickHandler&&this.endInput.removeEventListener("click",this._endInputClickHandler),this._keydownHandler&&document.removeEventListener("keydown",this._keydownHandler),this._documentClickListener&&this._documentClickListener.unsubscribe?this._documentClickListener.unsubscribe():this._documentClickHandler&&document.removeEventListener("click",this._documentClickHandler),this._resizeListener&&this._resizeListener.unsubscribe?this._resizeListener.unsubscribe():this._resizeHandler&&window.removeEventListener("resize",this._resizeHandler),this.calendarEl&&this.calendarEl.querySelectorAll(".ds-datepicker__day").forEach(t=>{t._dayClickHandler&&t.removeEventListener("click",t._dayClickHandler)}),this.appendToBody&&this._originalParent&&this._restoreCalendarFromBody(),this._documentClickHandler=null,this._resizeHandler=null,this._documentClickListener=null,this._resizeListener=null,this._iconClickHandler=null,this._inputClickHandler=null,this._endInputClickHandler=null,this._keydownHandler=null,this.element.__kupolaInitialized=!1)}}function xt(i,t){const e=new Xe(i,t);e.init(),i._kupolaDatepicker=e}function lo(i=document){i.querySelectorAll(".ds-datepicker").forEach(t=>{xt(t)})}function je(i){i._kupolaDatepicker&&(i._kupolaDatepicker.destroy(),i._kupolaDatepicker=null)}E.register("datepicker",xt,je);class Je{constructor(t,e={}){this.element=t,this.input=t.querySelector("input"),this.inputWrap=t.querySelector(".ds-timepicker__input-wrap"),this.panelEl=null,this.scope=`timepicker-${Math.random().toString(36).substr(2,9)}`,this.showSeconds=e.showSeconds||t.hasAttribute("data-timepicker-seconds"),this.use12Hour=e.use12Hour||t.hasAttribute("data-timepicker-12h"),this.hourStep=e.hourStep||parseInt(t.getAttribute("data-timepicker-hour-step"))||1,this.minuteStep=e.minuteStep||parseInt(t.getAttribute("data-timepicker-minute-step"))||5,this.secondStep=e.secondStep||parseInt(t.getAttribute("data-timepicker-second-step"))||5,this.minTime=e.minTime||t.getAttribute("data-timepicker-min")||null,this.maxTime=e.maxTime||t.getAttribute("data-timepicker-max")||null,this.disabledTime=e.disabledTime||null,this.placeholder=e.placeholder||t.getAttribute("data-timepicker-placeholder")||"",this.clearable=e.clearable||t.hasAttribute("data-timepicker-clear"),this.onChange=e.onChange||null,this.selectedHour=12,this.selectedMinute=0,this.selectedSecond=0,this.isPM=!1,this._inputWrapClickHandler=null,this._documentClickHandler=null,this._documentClickListener=null,this._resizeHandler=null,this._resizeListener=null,this._keydownHandler=null}init(){this.element.__kupolaInitialized||(this.placeholder&&this.input&&(this.input.placeholder=this.placeholder),this.input&&this.input.value&&this._parseInputValue(),this._inputWrapClickHandler=t=>{t.stopPropagation(),this.panelEl&&this.panelEl.style.display==="block"?this.hideTimepicker():this.showTimepicker()},this.inputWrap.addEventListener("click",this._inputWrapClickHandler),this._documentClickListener=H.on(document,"click",t=>this.hideTimepicker(t),{scope:this.scope}),this._resizeListener=H.on(window,"resize",()=>this.resizeHandler(),{scope:this.scope}),this._keydownHandler=t=>{t.key==="Escape"&&this.panelEl&&this.panelEl.style.display==="block"&&this.hideTimepicker()},document.addEventListener("keydown",this._keydownHandler),this.element.__kupolaInitialized=!0)}_parseInputValue(){const t=this.input.value.trim();if(!t)return;const e=t.match(/^(\d{1,2}):(\d{2})(?::(\d{2}))?\s*(AM|PM|am|pm)$/i);if(e){this.selectedHour=parseInt(e[1])%12,e[4].toUpperCase()==="PM"&&(this.selectedHour+=12),this.selectedMinute=parseInt(e[2]),this.selectedSecond=e[3]?parseInt(e[3]):0;return}const s=t.split(":");s.length>=2&&(this.selectedHour=parseInt(s[0])||0,this.selectedMinute=parseInt(s[1])||0,this.selectedSecond=s[2]&&parseInt(s[2])||0)}_isTimeDisabled(t,e,s){if(this.disabledTime)return this.disabledTime(t,e,s);const n=t*3600+e*60+s;if(this.minTime){const r=this.minTime.split(":"),a=parseInt(r[0])*3600+parseInt(r[1])*60+(parseInt(r[2])||0);if(n<a)return!0}if(this.maxTime){const r=this.maxTime.split(":"),a=parseInt(r[0])*3600+parseInt(r[1])*60+(parseInt(r[2])||0);if(n>a)return!0}return!1}_formatTime(){let t=this.selectedHour,e=this.selectedMinute,s=this.selectedSecond;if(this.use12Hour){const n=t>=12?"PM":"AM";return t=t%12||12,this.showSeconds?`${t}:${String(e).padStart(2,"0")}:${String(s).padStart(2,"0")} ${n}`:`${t}:${String(e).padStart(2,"0")} ${n}`}return this.showSeconds?`${String(t).padStart(2,"0")}:${String(e).padStart(2,"0")}:${String(s).padStart(2,"0")}`:`${String(t).padStart(2,"0")}:${String(e).padStart(2,"0")}`}calculatePosition(){if(!this.panelEl)return;const t=this.element.getBoundingClientRect(),e=this.panelEl.getBoundingClientRect(),n=window.innerHeight-t.bottom,r=t.top,a=e.height||320;n>=a?(this.panelEl.style.top="calc(100% + 4px)",this.panelEl.style.bottom="auto"):r>=a?(this.panelEl.style.top="auto",this.panelEl.style.bottom="calc(100% + 4px)"):(this.panelEl.style.top="calc(100% + 4px)",this.panelEl.style.bottom="auto")}showTimepicker(){if(this.panelEl){this.panelEl.style.display="block",this._syncPanelSelection(),this.calculatePosition();return}this.panelEl=document.createElement("div"),this.panelEl.className="ds-timepicker__panel";let t="";if(t+=`<div class="ds-timepicker__section">
7
7
  <div class="ds-timepicker__section-label">Hour</div>
8
8
  <div class="ds-timepicker__grid ds-timepicker__grid--hour" data-type="hour"></div>
9
9
  </div>`,t+=`<div class="ds-timepicker__section">