@kupola/kupola 1.4.3 → 1.4.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.
- package/README.md +28 -3
- package/css/components-ext.css +1 -1
- package/dist/css/components-ext.css +158 -1
- package/dist/css/components.css +93 -1
- package/dist/css/kupola.css +13 -12
- package/dist/css/table.css +74 -0
- package/dist/css/theme-dark.css +5 -5
- package/dist/css/utilities.css +159 -1
- package/dist/kupola.cjs.js +214 -15600
- package/dist/kupola.cjs.js.map +1 -1
- package/dist/kupola.css +1 -1
- package/dist/kupola.esm.js +8195 -15405
- package/dist/kupola.esm.js.map +1 -1
- package/dist/kupola.min.css +1 -1
- package/dist/kupola.umd.js +214 -15606
- package/dist/kupola.umd.js.map +1 -1
- package/js/theme.js +10 -4
- package/package.json +3 -3
- package/dist/css/kupola.min.css +0 -1
- package/dist/icons.svg +0 -284
- package/dist/kupola.min.js +0 -2
- package/dist/kupola.min.js.map +0 -1
- /package/dist/css/{colors_and_type.css → colors-and-type.css} +0 -0
package/dist/kupola.min.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).Kupola={})}(this,function(t){"use strict";class e{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(t=>{this.allPhases.push(`before${t.charAt(0).toUpperCase()+t.slice(1)}`),this.allPhases.push(t),this.allPhases.push(`after${t.charAt(0).toUpperCase()+t.slice(1)}`)}),this.allPhases.forEach(t=>{this.hooks.set(t,[])}),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(t=>{t.resolved=!1})}on(t,e,s={}){if(!this.allPhases.includes(t))throw new Error(`Unknown lifecycle phase: ${t}`);const i=this.hooks.get(t);return i.push({handler:e,priority:s.priority||0,depends:s.depends||[],name:s.name||e.name||`anonymous_${i.length}`}),i.sort((t,e)=>e.priority-t.priority),()=>{const t=i.findIndex(t=>t.handler===e);t>-1&&i.splice(t,1)}}async _resolveDepends(t,e){if(t&&0!==t.length)for(const s of t){const t=this.hooks.get(e).find(t=>t.name===s);t&&!t.resolved&&(await t.handler(),t.resolved=!0)}}async emit(t,...e){if("destroyed"===this.state&&"error"!==t)return;const s=this.hooks.get(t);if(!s||0===s.length)return;const i=`${t}-${Date.now()}-${Math.random().toString(36).substr(2,9)}`;this.pendingHooks.add(i);const n=performance.now();try{for(const n of s){await this._resolveDepends(n.depends,t);const s=performance.now();let r,a;try{r=n.handler(...e),r instanceof Promise&&await r,n.resolved=!0}catch(s){a=s,console.error(`[KupolaLifecycle] Error in ${t} hook "${n.name}":`,s),"error"!==t&&await this._handleError({phase:t,hook:n.name,error:s,args:e})}const o=performance.now()-s;this.trace.push({emitId:i,phase:t,hookName:n.name,duration:o,status:a?"error":"success",error:a?a.message:null,timestamp:Date.now()})}const r=performance.now()-n;console.debug(`[KupolaLifecycle] ${t} completed in ${r.toFixed(2)}ms (${this.scope})`)}finally{this.pendingHooks.delete(i)}}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 i=`before${t.charAt(0).toUpperCase()+t.slice(1)}`,n=`after${t.charAt(0).toUpperCase()+t.slice(1)}`;this._resetResolved(i),this._resetResolved(t),this._resetResolved(n),this.allPhases.includes(i)&&await this.emit(i,...e),await this.emit(t,...e),s&&this._updateState(s.to),this.allPhases.includes(n)&&await this.emit(n,...e)}async bootstrap(...t){await this.runPhase("bootstrap",...t)}async _waitForDOMReady(){return new Promise(t=>{if("complete"===document.readyState||"interactive"===document.readyState)return void t();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(t=>{t.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=>"function"==typeof t?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)return void console.error(`[KupolaLifecycle] Error limit reached (${this.maxErrors}), stopping error handling`);if(await this.emit("error",t),"function"==typeof this._onErrorCallback)try{await this._onErrorCallback(t)}catch(t){console.error("[KupolaLifecycle] Error in onError callback:",t)}const e=this.hooks.get("errorBoundary");if(e&&e.length>0)for(const s of e)try{const e=s.handler(t);if(e instanceof Promise&&await e,"handled"===e)return void console.debug(`[KupolaLifecycle] Error handled by errorBoundary hook "${s.name}"`)}catch(t){console.error(`[KupolaLifecycle] Error in errorBoundary hook "${s.name}":`,t)}console.error(`[KupolaLifecycle] Unhandled error in ${t.phase}:`,t.error)}}const s=new e("app");const i=new Set(["__proto__","prototype","constructor"]);function n(t){return i.has(t)}const r={trim:function(t){return t?t.trim():""},trimLeft:function(t){return t?t.replace(/^\s+/,""):""},trimRight:function(t){return t?t.replace(/\s+$/,""):""},toUpperCase:function(t){return t?t.toUpperCase():""},toLowerCase:function(t){return t?t.toLowerCase():""},capitalize:function(t){return t?t.charAt(0).toUpperCase()+t.slice(1):""},camelize:function(t){return t?t.replace(/-(\w)/g,(t,e)=>e?e.toUpperCase():""):""},hyphenate:function(t){return t?t.replace(/([A-Z])/g,"-$1").toLowerCase().replace(/^-/,""):""},padStart:function(t,e,s=" "){return(String(t)||"").padStart(e,s)},padEnd:function(t,e,s=" "){return(String(t)||"").padEnd(e,s)},truncate:function(t,e,s="..."){return!t||t.length<=e?t||"":t.slice(0,e)+s},replaceAll:function(t,e,s){return t?t.split(e).join(s):""},format:function(t,e){return t?t.replace(/\{\{(\w+)\}\}/g,(t,s)=>void 0!==e[s]?e[s]:`{{${s}}}`):""},startsWith:function(t,e){return(t||"").startsWith(e)},endsWith:function(t,e){return(t||"").endsWith(e)},includes:function(t,e){return(t||"").includes(e)},repeat:function(t,e){return(t||"").repeat(e)},reverse:function(t){return(t||"").split("").reverse().join("")},countOccurrences:function(t,e){return t&&e?t.split(e).length-1:0},escapeHtml:function(t){if(!t)return"";const e=document.createElement("div");return e.textContent=t,e.innerHTML},unescapeHtml:function(t){if(!t)return"";const e=document.createElement("div");return e.innerHTML=t,e.textContent},generateRandom:function(t=8){const e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";let s="";for(let i=0;i<t;i++)s+=e.charAt(Math.floor(62*Math.random()));return s},generateUUID:function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{const e=16*Math.random()|0;return("x"===t?e:3&e|8).toString(16)})}};function a(t){return t?t.reduce((t,e)=>t+(Number(e)||0),0):0}const o={isArray:function(t){return Array.isArray(t)},isEmpty:function(t){return!t||0===t.length},size:function(t){return t?t.length:0},first:function(t,e){return t&&t.length>0?t[0]:e},last:function(t,e){return t&&t.length>0?t[t.length-1]:e},get:function(t,e,s){return t&&void 0!==t[e]?t[e]:s},slice:function(t,e,s){return t?t.slice(e,s):[]},concat:function(...t){return t.reduce((t,e)=>t.concat(e||[]),[])},join:function(t,e=","){return t?t.join(e):""},indexOf:function(t,e,s=0){if(!t)return-1;if(Number.isNaN(e)){for(let e=s;e<t.length;e++)if(Number.isNaN(t[e]))return e;return-1}return t.indexOf(e,s)},lastIndexOf:function(t,e,s){if(!t)return-1;if(Number.isNaN(e)){for(let e=void 0!==s?s:t.length-1;e>=0;e--)if(Number.isNaN(t[e]))return e;return-1}return t.lastIndexOf(e,s)},includes:function(t,e){return!!t&&t.includes(e)},push:function(t,...e){return t&&t.push(...e),t},pop:function(t){return t?t.pop():void 0},shift:function(t){return t?t.shift():void 0},unshift:function(t,...e){return t&&t.unshift(...e),t},remove:function(t,e){if(!t)return t;const s=Number.isNaN(e)?t.findIndex(t=>Number.isNaN(t)):t.indexOf(e);return s>-1&&t.splice(s,1),t},removeAt:function(t,e){return!t||e<0||e>=t.length||t.splice(e,1),t},insert:function(t,e,s){return t?(t.splice(e,0,s),t):t},reverse:function(t){return t?t.slice().reverse():[]},sort:function(t,e){return t?t.slice().sort(e):[]},sortBy:function(t,e,s="asc"){return t?t.slice().sort((t,i)=>{const n="object"==typeof t?t[e]:t,r="object"==typeof i?i[e]:i;return n<r?"asc"===s?-1:1:n>r?"asc"===s?1:-1:0}):[]},filter:function(t,e){return t?t.filter(e):[]},map:function(t,e){return t?t.map(e):[]},reduce:function(t,e,s){return t?t.reduce(e,s):s},forEach:function(t,e){t&&t.forEach(e)},every:function(t,e){return!t||t.every(e)},some:function(t,e){return!!t&&t.some(e)},find:function(t,e){return t?t.find(e):void 0},findIndex:function(t,e){return t?t.findIndex(e):-1},flat:function(t,e=1){return t?t.flat(e):[]},flattenDeep:function t(e){return e?e.reduce((e,s)=>Array.isArray(s)?e.concat(t(s)):e.concat(s),[]):[]},unique:function(t){return t?[...new Set(t)]:[]},uniqueBy:function(t,e){if(!t)return[];const s=new Set;return t.filter(t=>{const i="object"==typeof t?t[e]:t;return!s.has(i)&&(s.add(i),!0)})},chunk:function(t,e){if(!t||e<=0)return[];const s=[];for(let i=0;i<t.length;i+=e)s.push(t.slice(i,i+e));return s},shuffle:function(t){if(!t)return[];const e=t.slice();for(let t=e.length-1;t>0;t--){const s=Math.floor(Math.random()*(t+1));[e[t],e[s]]=[e[s],e[t]]}return e},sum:a,average:function(t){return t&&0!==t.length?a(t)/t.length:0},max:function(t){return t&&t.length>0?Math.max(...t):-1/0},min:function(t){return t&&t.length>0?Math.min(...t):1/0},intersection:function(...t){return 0===t.length?[]:t.reduce((t,e)=>t.filter(t=>e&&e.includes(t)))},union:function(...t){return[...new Set(t.flat().filter(Boolean))]},difference:function(t,e){return t?t.filter(t=>!e||!e.includes(t)):[]},zip:function(...t){if(0===t.length)return[];const e=Math.max(...t.map(t=>t?t.length:0));return Array.from({length:e},(e,s)=>t.map(t=>t&&t[s]))}};function l(t){return null!==t&&"object"==typeof t&&!Array.isArray(t)}const h={isObject:l,isEmpty:function(t){return!t||"object"!=typeof t||0===Object.keys(t).length},keys:function(t){return t?Object.keys(t):[]},values:function(t){return t?Object.values(t):[]},entries:function(t){return t?Object.entries(t):[]},has:function(t,e){return!!t&&Object.prototype.hasOwnProperty.call(t,e)},get:function(t,e,s){if(!t)return s;const i=e.split(".");return i.some(n)?s:i.reduce((t,e)=>t&&t[e],t)??s},set:function(t,e,s){if(!t||"object"!=typeof t)return t;const i=e.split(".");if(i.some(n))return t;const r=i.pop();let a=t;return i.forEach(t=>{a[t]&&"object"==typeof a[t]||(a[t]={}),a=a[t]}),a[r]=s,t},pick:function(t,e){return t?e.reduce((e,s)=>(void 0!==t[s]&&(e[s]=t[s]),e),{}):{}},omit:function(t,e){return t?Object.keys(t).reduce((s,i)=>(e.includes(i)||(s[i]=t[i]),s),{}):{}},merge:function t(...e){return e.reduce((e,s)=>(s&&"object"==typeof s&&Object.keys(s).forEach(i=>{n(i)||(l(s[i])&&l(e[i])?e[i]=t(e[i],s[i]):e[i]=s[i])}),e),{})},clone:function(t){return t?JSON.parse(JSON.stringify(t)):t},deepClone:function t(e,s=new WeakMap){if(!e||"object"!=typeof e)return e;if(s.has(e))return s.get(e);if(e instanceof Date)return new Date(e);if(e instanceof RegExp)return new RegExp(e);if(e instanceof Map){const i=new Map;return s.set(e,i),e.forEach((e,n)=>i.set(n,t(e,s))),i}if(e instanceof Set){const i=new Set;return s.set(e,i),e.forEach(e=>i.add(t(e,s))),i}if(Array.isArray(e)){const i=[];return s.set(e,i),e.forEach(e=>i.push(t(e,s))),i}const i={};return s.set(e,i),Object.keys(e).forEach(r=>{n(r)||(i[r]=t(e[r],s))}),i},forEach:function(t,e){t&&Object.keys(t).forEach(s=>e(t[s],s,t))},map:function(t,e){if(!t)return{};const s={};return Object.keys(t).forEach(i=>{s[i]=e(t[i],i,t)}),s},filter:function(t,e){if(!t)return{};const s={};return Object.keys(t).forEach(i=>{e(t[i],i,t)&&(s[i]=t[i])}),s},reduce:function(t,e,s){return t?Object.keys(t).reduce((s,i)=>e(s,t[i],i,t),s):s},toArray:function(t){return t?Object.keys(t).map(e=>({key:e,value:t[e]})):[]},fromArray:function(t,e,s){return t?t.reduce((t,i)=>{const n="object"==typeof i?i[e]:i,r=s?i[s]:i;return void 0!==n&&(t[n]=r),t},{}):{}},size:function(t){return t?Object.keys(t).length:0},invert:function(t){if(!t)return{};const e={};return Object.keys(t).forEach(s=>{e[t[s]]=s}),e},isEqual:function t(e,s){if(e===s)return!0;if(!e||!s||"object"!=typeof e||"object"!=typeof s)return!1;const i=Object.keys(e),n=Object.keys(s);return i.length===n.length&&i.every(i=>t(e[i],s[i]))},freeze:function t(e){return e?(Object.freeze(e),Object.keys(e).forEach(s=>{"object"==typeof e[s]&&t(e[s])}),e):e},seal:function(t){return t?Object.seal(t):t}};function c(t){return"number"==typeof t&&!isNaN(t)}function d(...t){return t.flat().filter(c).reduce((t,e)=>t+e,0)}function u(t=0,e=1){return Math.random()*(e-t)+t}const p={isNumber:c,isInteger:function(t){return Number.isInteger(t)},isFloat:function(t){return c(t)&&!Number.isInteger(t)},isPositive:function(t){return c(t)&&t>0},isNegative:function(t){return c(t)&&t<0},isZero:function(t){return c(t)&&0===t},clamp:function(t,e,s){return c(t)?Math.min(Math.max(t,e),s):t},round:function(t,e=0){if(!c(t))return t;const s=Math.pow(10,e);return Math.round(t*s)/s},floor:function(t){return c(t)?Math.floor(t):t},ceil:function(t){return c(t)?Math.ceil(t):t},abs:function(t){return c(t)?Math.abs(t):t},min:function(...t){const e=t.filter(c);return e.length>0?Math.min(...e):void 0},max:function(...t){const e=t.filter(c);return e.length>0?Math.max(...e):void 0},sum:d,average:function(...t){const e=t.flat().filter(c);return e.length>0?d(e)/e.length:0},random:u,randomInt:function(t,e){return Math.floor(u(t,e+1))},format:function(t,e=2){return c(t)?t.toFixed(e):String(t)},formatCurrency:function(t,e="CNY",s=2){return c(t)?new Intl.NumberFormat("zh-CN",{style:"currency",currency:e,minimumFractionDigits:s,maximumFractionDigits:s}).format(t):String(t)},formatPercent:function(t,e=0){return c(t)?`${(100*t).toFixed(e)}%`:String(t)},toFixed:function(t,e=0){return c(t)?t.toFixed(e):String(t)},toPrecision:function(t,e=6){return c(t)?t.toPrecision(e):String(t)},isNaN:function(t){return Number.isNaN(t)},isFinite:function(t){return Number.isFinite(t)},parseInt:function(t,e=10){return Number.parseInt(t,e)},parseFloat:function(t){return Number.parseFloat(t)},toNumber:function(t,e=0){const s=Number(t);return isNaN(s)?e:s},safeDivide:function(t,e,s=0){return c(t)&&c(e)&&0!==e?t/e:s},safeMultiply:function(...t){return t.reduce((t,e)=>c(t)&&c(e)?t*e:0,1)}};function m(){return Date.now()}function g(){const t=new Date;return t.setHours(0,0,0,0),t}function _(t){return t instanceof Date&&!isNaN(t.getTime())}function y(t){return _(t)}function f(t,e){if(!_(t)||!_(e))return 0;const s=new Date(t);s.setHours(0,0,0,0);const i=new Date(e);return i.setHours(0,0,0,0),Math.floor((s.getTime()-i.getTime())/864e5)}function v(t,e=1){if(!_(t))return t;const s=new Date(t),i=s.getDay(),n=i>=e?i-e:i+(7-e);return s.setDate(s.getDate()-n),s.setHours(0,0,0,0),s}const b={now:m,today:g,tomorrow:function(){const t=g();return t.setDate(t.getDate()+1),t},yesterday:function(){const t=g();return t.setDate(t.getDate()-1),t},isDate:_,isValid:y,parse:function(t){const e=new Date(t);return y(e)?e:null},format:function(t,e="YYYY-MM-DD HH:mm:ss"){if(!_(t))return"";const s=t.getFullYear(),i=String(t.getMonth()+1).padStart(2,"0"),n=String(t.getDate()).padStart(2,"0"),r=String(t.getHours()).padStart(2,"0"),a=String(t.getMinutes()).padStart(2,"0"),o=String(t.getSeconds()).padStart(2,"0"),l=String(t.getMilliseconds()).padStart(3,"0"),h=["日","一","二","三","四","五","六"][t.getDay()];return e.replace("YYYY",s).replace("MM",i).replace("DD",n).replace("HH",r).replace("mm",a).replace("ss",o).replace("SSS",l).replace("D",t.getDate()).replace("M",t.getMonth()+1).replace("H",t.getHours()).replace("m",t.getMinutes()).replace("s",t.getSeconds()).replace("W",h)},toISO:function(t){return _(t)?t.toISOString():""},toUTC:function(t){return _(t)?new Date(t.toUTCString()):null},addDays:function(t,e){if(!_(t))return t;const s=new Date(t);return s.setDate(s.getDate()+e),s},addHours:function(t,e){if(!_(t))return t;const s=new Date(t);return s.setHours(s.getHours()+e),s},addMinutes:function(t,e){if(!_(t))return t;const s=new Date(t);return s.setMinutes(s.getMinutes()+e),s},addSeconds:function(t,e){if(!_(t))return t;const s=new Date(t);return s.setSeconds(s.getSeconds()+e),s},diffDays:f,diffHours:function(t,e){return _(t)&&_(e)?Math.floor((t.getTime()-e.getTime())/36e5):0},diffMinutes:function(t,e){return _(t)&&_(e)?Math.floor((t.getTime()-e.getTime())/6e4):0},diffSeconds:function(t,e){return _(t)&&_(e)?Math.floor((t.getTime()-e.getTime())/1e3):0},isToday:function(t){return!!_(t)&&0===f(t,g())},isYesterday:function(t){return!!_(t)&&-1===f(t,g())},isTomorrow:function(t){return!!_(t)&&1===f(t,g())},isFuture:function(t){return!!_(t)&&t.getTime()>m()},isPast:function(t){return!!_(t)&&t.getTime()<m()},isLeapYear:function(t){if(!_(t))return!1;const e=t.getFullYear();return e%4==0&&(e%100!=0||e%400==0)},getDaysInMonth:function(t){return _(t)?new Date(t.getFullYear(),t.getMonth()+1,0).getDate():0},getWeekOfYear:function(t){if(!_(t))return 0;const e=new Date(t.getFullYear(),0,1),s=t.getTime()-e.getTime();return Math.ceil(s/6048e5)},getQuarter:function(t){return _(t)?Math.ceil((t.getMonth()+1)/3):0},startOfDay:function(t){if(!_(t))return t;const e=new Date(t);return e.setHours(0,0,0,0),e},endOfDay:function(t){if(!_(t))return t;const e=new Date(t);return e.setHours(23,59,59,999),e},startOfMonth:function(t){return _(t)?new Date(t.getFullYear(),t.getMonth(),1):t},endOfMonth:function(t){return _(t)?new Date(t.getFullYear(),t.getMonth()+1,0,23,59,59,999):t},startOfWeek:v,endOfWeek:function(t,e=1){if(!_(t))return t;const s=v(t,e),i=new Date(s);return i.setDate(i.getDate()+6),i.setHours(23,59,59,999),i},getAge:function(t){if(!_(t))return 0;const e=new Date;let s=e.getFullYear()-t.getFullYear();return(e.getMonth()<t.getMonth()||e.getMonth()===t.getMonth()&&e.getDate()<t.getDate())&&s--,Math.max(0,s)},fromNow:function(t){if(!_(t))return"";const e=m()-t.getTime(),s=6e4,i=36e5,n=24*i,r=7*n,a=30*n,o=365*n;return e<s?"刚刚":e<i?`${Math.floor(e/s)}分钟前`:e<n?`${Math.floor(e/i)}小时前`:e<r?`${Math.floor(e/n)}天前`:e<a?`${Math.floor(e/r)}周前`:e<o?`${Math.floor(e/a)}个月前`:`${Math.floor(e/o)}年前`}};function k(t,e,s={}){let i=null,n=null,r=null,a=0;const o=s.leading||!1,l=!1!==s.trailing;function h(){t.apply(r,n)}function c(){i=null,l&&n&&h(),n=null,r=null}return function(...t){n=t,r=this,a=Date.now(),i?(clearTimeout(i),i=setTimeout(c,Math.max(0,e-(Date.now()-a)))):(a=Date.now(),o?(i=setTimeout(c,e),h()):i=setTimeout(c,e))}}function E(t,e,s={}){let i=!1;const n=s.trailing||!1;let r=null,a=null;function o(){t.apply(a,r),r=null,a=null}return function(...t){i?n&&(r=t,a=this):(i=!0,r=t,a=this,o(),setTimeout(()=>{i=!1,n&&r&&o()},e))}}function w(t){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(t||"")}function x(t){return/^([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$/.test(t||"")}function C(t){return/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/.test(t||"")}function S(t){const e=/^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/.exec(t||"");return!!e&&e.slice(1).every(t=>parseInt(t)>=0&&parseInt(t)<=255)}function L(t){const e=/^rgba\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3}),\s*([01]|0\.\d+)\)$/.exec(t||"");if(!e)return!1;const[,s,i,n,r]=e;return parseInt(s)>=0&&parseInt(s)<=255&&parseInt(i)>=0&&parseInt(i)<=255&&parseInt(n)>=0&&parseInt(n)<=255&&parseFloat(r)>=0&&parseFloat(r)<=1}function D(t,e){return(t||"").includes(e)}const M={isEmail:function(t){return/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(t||"")},isPhone:function(t){return/^1[3-9]\d{9}$/.test(t||"")},isURL:function(t){return/^(https?:\/\/)?([\da-z.-]+)\.([a-z.]{2,6})([/\w.-]*)*\/?$/.test(t||"")},isIPv4:w,isIPv6:x,isIP:function(t){return w(t)||x(t)},isIDCard:function(t){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(t||"")},isPassport:function(t){return/^[A-Z][0-9]{8}$|^[A-Z]{2}[0-9]{7}$/.test(t||"")},isCreditCard:function(t){const e=t.replace(/\s/g,"");if(!/^(?: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})$/.test(e))return!1;let s=0,i=!1;for(let t=e.length-1;t>=0;t--){let n=parseInt(e[t],10);i&&(n*=2,n>9&&(n-=9)),s+=n,i=!i}return s%10==0},isHexColor:C,isRGB:S,isRGBA:L,isColor:function(t){return C(t)||S(t)||L(t)},isDate:function(t){return!isNaN(new Date(t).getTime())},isJSON:function(t){try{return JSON.parse(t),!0}catch{return!1}},isEmpty:function(t){return!t||""===t.trim()},isWhitespace:function(t){return/^\s+$/.test(t||"")},isNumber:function(t){return!isNaN(parseFloat(t))&&isFinite(t)},isInteger:function(t){return/^-?\d+$/.test(t||"")},isFloat:function(t){return/^-?\d+\.\d+$/.test(t||"")},isPositive:function(t){const e=parseFloat(t);return!isNaN(e)&&e>0},isNegative:function(t){const e=parseFloat(t);return!isNaN(e)&&e<0},isAlpha:function(t){return/^[a-zA-Z]+$/.test(t||"")},isAlphaNumeric:function(t){return/^[a-zA-Z0-9]+$/.test(t||"")},isChinese:function(t){return/^[\u4e00-\u9fa5]+$/.test(t||"")},isLength:function(t,e,s){const i=(t||"").length;return i>=e&&(void 0===s||i<=s)},minLength:function(t,e){return(t||"").length>=e},maxLength:function(t,e){return(t||"").length<=e},matches:function(t,e){return e instanceof RegExp&&e.test(t||"")},equals:function(t,e){return String(t)===String(e)},contains:D,notContains:function(t,e){return!D(t,e)},isArray:function(t){return Array.isArray(t)},arrayLength:function(t,e,s){const i=t?t.length:0;return i>=e&&(void 0===s||i<=s)},arrayMinLength:function(t,e){return!!t&&t.length>=e},arrayMaxLength:function(t,e){return!!t&&t.length<=e},isObject:function(t){return null!==t&&"object"==typeof t&&!Array.isArray(t)},hasKeys:function(t,e){return!!(t&&e&&Array.isArray(e))&&e.every(e=>Object.prototype.hasOwnProperty.call(t,e))},validate:function(t,e){const s={};return Object.keys(e).forEach(i=>{const n=t[i],r=e[i],a=[];r.forEach(e=>{if("string"==typeof e){const[t,...s]=e.split(":");M[t](n,...s)||a.push(t)}else if("function"==typeof e){const s=e(n,t);!0!==s&&a.push(s||"validation_failed")}}),a.length>0&&(s[i]=a)}),{valid:0===Object.keys(s).length,errors:s}}};const H={md5:function(t){const e=t?String(t):"",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],i=[[7,12,17,22],[5,9,14,20],[4,11,16,23],[6,10,15,21]];function n(t,e){return t<<e|t>>>32-e}function r(t,e){const[r,a,o,l]=e,h=[];for(let e=0;e<16;e++)h[e]=255&t.charCodeAt(4*e)|(255&t.charCodeAt(4*e+1))<<8|(255&t.charCodeAt(4*e+2))<<16|(255&t.charCodeAt(4*e+3))<<24;let c=r,d=a,u=o,p=l;for(let t=0;t<64;t++){let e,r;const a=Math.floor(t/16),o=t%16;0===a?(e=d&u|~d&p,r=o):1===a?(e=p&d|~p&u,r=(5*o+1)%16):2===a?(e=d^u^p,r=(3*o+5)%16):(e=u^(d|~p),r=7*o%16);const l=p;p=u,u=d,d+=n(c+e+s[t]+h[r]&4294967295,i[a][t%4]),c=l}return[r+c&4294967295,a+d&4294967295,o+u&4294967295,l+p&4294967295]}const a=function(t){const e=8*t.length;for(t+="";t.length%64!=56;)t+="\0";const s=4294967295&e,i=e>>>32&4294967295;for(let e=0;e<4;e++)t+=String.fromCharCode(s>>>8*e&255);for(let e=0;e<4;e++)t+=String.fromCharCode(i>>>8*e&255);return t}(e);let o=[1732584193,4023233417,2562383102,271733878];for(let t=0;t<a.length;t+=64)o=r(a.substring(t,t+64),o);let l="";return o.forEach(t=>{for(let e=0;e<4;e++)l+=(t>>>8*e&255).toString(16).padStart(2,"0")}),l},sha256:function(t){const e=t?String(t):"",s=[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 i(t,e){return t>>>e|t<<32-e}function n(t,e){const n=[];for(let e=0;e<16;e++)n[e]=255&t.charCodeAt(4*e)|(255&t.charCodeAt(4*e+1))<<8|(255&t.charCodeAt(4*e+2))<<16|(255&t.charCodeAt(4*e+3))<<24;for(let t=16;t<64;t++){const e=i(n[t-15],7)^i(n[t-15],18)^n[t-15]>>>3,s=i(n[t-2],17)^i(n[t-2],19)^n[t-2]>>>10;n[t]=n[t-16]+e+n[t-7]+s&4294967295}let[r,a,o,l,h,c,d,u]=e;for(let t=0;t<64;t++){const e=u+(i(h,6)^i(h,11)^i(h,25))+(h&c^~h&d)+s[t]+n[t]&4294967295,p=r&a^r&o^a&o;u=d,d=c,c=h,h=l+e&4294967295,l=o,o=a,a=r,r=e+((i(r,2)^i(r,13)^i(r,22))+p&4294967295)&4294967295}return[e[0]+r&4294967295,e[1]+a&4294967295,e[2]+o&4294967295,e[3]+l&4294967295,e[4]+h&4294967295,e[5]+c&4294967295,e[6]+d&4294967295,e[7]+u&4294967295]}const r=function(t){const e=8*t.length;for(t+="";t.length%64!=56;)t+="\0";const s=4294967295&e,i=e>>>32&4294967295;for(let e=0;e<4;e++)t+=String.fromCharCode(i>>>8*e&255);for(let e=0;e<4;e++)t+=String.fromCharCode(s>>>8*e&255);return t}(e);let a=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225];for(let t=0;t<r.length;t+=64)a=n(r.substring(t,t+64),a);let o="";return a.forEach(t=>{for(let e=3;e>=0;e--)o+=(t>>>8*e&255).toString(16).padStart(2,"0")}),o},base64Encode:function(t){const e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";let s="",i=0;const n=t?t.split("").map(t=>t.charCodeAt(0)):[];for(;i<n.length;){const t=n[i++],r=n[i++]||0,a=n[i++]||0,o=(15&r)<<2|a>>6,l=63&a;s+=e[t>>2]+e[(3&t)<<4|r>>4]+(i>n.length+1?"=":e[o])+(i>n.length?"=":e[l])}return s},base64Decode:function(t){const e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";let s="",i=0;for(t=t.replace(/[^A-Za-z0-9+/=]/g,"");i<t.length;){const n=e.indexOf(t.charAt(i++)),r=e.indexOf(t.charAt(i++)),a=e.indexOf(t.charAt(i++)),o=e.indexOf(t.charAt(i++)),l=n<<2|r>>4,h=(15&r)<<4|a>>2,c=(3&a)<<6|o;s+=String.fromCharCode(l),64!==a&&(s+=String.fromCharCode(h)),64!==o&&(s+=String.fromCharCode(c))}return s},uuid:function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{const e=16*Math.random()|0;return("x"===t?e:3&e|8).toString(16)})}},I=new Map;async function T(t,e={}){const{crossOrigin:s="anonymous"}=e;return I.has(t)?I.get(t):new Promise((e,i)=>{const n=new Image;n.crossOrigin=s,n.onload=()=>{I.set(t,n),e(n)},n.onerror=()=>{i(new Error(`Failed to load image: ${t}`))},n.src=t})}async function A(t,e={}){const{type:s="text/javascript",async:i=!0,defer:n=!1}=e;return I.has(t)?I.get(t):new Promise((e,r)=>{const a=document.createElement("script");a.type=s,a.async=i,a.defer=n,a.onload=()=>{I.set(t,a),e(a)},a.onerror=()=>{a.remove(),r(new Error(`Failed to load script: ${t}`))},a.src=t,document.head.appendChild(a)})}async function z(t,e={}){const{media:s="all"}=e;return I.has(t)?I.get(t):new Promise((e,i)=>{const n=document.createElement("link");n.rel="stylesheet",n.href=t,n.media=s,n.onload=()=>{I.set(t,n),e(n)},n.onerror=()=>{n.remove(),i(new Error(`Failed to load stylesheet: ${t}`))},document.head.appendChild(n)})}const $={loadImage:T,loadImages:async function(t,e={}){const{parallel:s=!0}=e;if(s)return Promise.all(t.map(t=>T(t,e)));const i=[];for(const s of t)i.push(await T(s,e));return i},loadScript:A,loadStylesheet:z,loadFont:async function(t,e,s={}){const{weight:i="normal",style:n="normal"}=s,r=new FontFace(t,`url(${e})`,{weight:i,style:n});try{return await r.load(),document.fonts.add(r),r}catch(e){throw new Error(`Failed to load font: ${t}`)}},preload:async function(t,e="image"){switch(e){case"image":return T(t);case"script":return A(t);case"stylesheet":case"style":return z(t);default:throw new Error(`Unsupported preload type: ${e}`)}},isLoaded:function(t){return I.has(t)},clearCache:function(){I.clear()},clearCacheByUrl:function(t){I.delete(t)}},q={string:r,array:o,object:h,number:p,date:b,debounce:k,throttle:E,validator:M,crypto:H,preload:$};class P{constructor(){this.children={},this.keys=[]}}class N{constructor(){this.root=new P}insert(t){let e=this.root;const s=t.split(".");s.forEach((i,n)=>{e.children[i]||(e.children[i]=new P),e=e.children[i],n===s.length-1&&e.keys.push(t)})}getSubKeys(t){let e=this.root;const s=t.split("."),i=[];for(let t=0;t<s.length;t++){const n=s[t];if(!e.children[n])break;e=e.children[n];const r=t=>{t.keys.length>0&&i.push(...t.keys),Object.values(t.children).forEach(t=>r(t))};r(e)}return[...new Set(i)]}getParentKeys(t){const e=t.split("."),s=[];for(let t=1;t<=e.length;t++){const i=e.slice(0,t).join(".");s.push(i)}return s}}const F=Symbol("reactive_parent"),O=Symbol("reactive_path"),B=Symbol("reactive_is_reactive");class R{constructor(){this.rawData={},this.data=null,this.observers={},this.elements={},this.computedProperties={},this.pathTrie=new N,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:(t,e,s)=>{if("__raw__"===e)return t;const i=Reflect.get(t,e,s);return i&&"object"==typeof i&&!Array.isArray(i)?this.wrapReactive(i,e):i},set:(t,e,s,i)=>{const n=Reflect.get(t,e,i),r=Reflect.set(t,e,s,i),a=this.resolvePath(t,e);return this.notify(a,s,n),this.queueUpdate(a,s),r},deleteProperty:(t,e)=>{const s=Reflect.get(t,e,receiver),i=Reflect.deleteProperty(t,e),n=this.resolvePath(t,e);return this.notify(n,void 0,s),this.queueUpdate(n,void 0),i}};this.data=new Proxy(this.rawData,t),this.data.__parent__=null,this.data.__path__=""}wrapReactive(t,e){if(t[B])return t;if(this._proxyCache.has(t))return this._proxyCache.get(t);const s=new Proxy(t,{get:(t,e,s)=>{if("__raw__"===e)return t;if(e===F||"__parent__"===e)return t[F];if(e===O||"__path__"===e)return t[O];if(e===B||"__isReactive__"===e)return!0;const i=Reflect.get(t,e,s);return i&&"object"==typeof i&&!Array.isArray(i)?this.wrapReactive(i,`${t[O]}${t[O]?".":""}${e}`):i},set:(t,e,s,i)=>{if(e===F||e===O||e===B||"__parent__"===e||"__path__"===e||"__isReactive__"===e)return!0;const n=Reflect.get(t,e,i),r=Reflect.set(t,e,s,i),a=`${t[O]}${t[O]?".":""}${e}`;return this.notify(a,s,n),this.queueUpdate(a,s),r},deleteProperty:(t,e)=>{if(e===F||e===O||e===B)return!1;const s=Reflect.get(t,e),i=Reflect.deleteProperty(t,e),n=`${t[O]}${t[O]?".":""}${e}`;return this.notify(n,void 0,s),this.queueUpdate(n,void 0),i},has:(t,e)=>"__raw__"===e||e===F||e===O||e===B||"__parent__"===e||"__path__"===e||"__isReactive__"===e||e in t,ownKeys:t=>Reflect.ownKeys(t).filter(t=>t!==F&&t!==O&&t!==B),getOwnPropertyDescriptor:(t,e)=>e===F||e===O||e===B?{configurable:!1,enumerable:!1,writable:!1,value:t[e]}:Reflect.getOwnPropertyDescriptor(t,e)});return t[F]=t,t[O]=e,t[B]=!0,this._proxyCache.set(t,s),Object.keys(t).forEach(s=>{t[s]&&"object"==typeof t[s]&&!Array.isArray(t[s])&&(t[s]=this.wrapReactive(t[s],`${e}${e?".":""}${s}`))}),s}resolvePath(t,e){return t[O]?`${t[O]}.${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(e=>{if(!t.has(e)){const s=this.get(e);this.updateElementsDirect(e,s),t.add(e)}})}),this.updateQueue.clear(),this.processComputed(),this.isProcessing=!1}updateElementsDirect(t,e){this.elements[t]&&this.elements[t].forEach(t=>{this.updateElement(t,e)})}processComputed(){Object.keys(this.computedProperties).forEach(t=>{this.computedProperties[t].deps.some(t=>this.updateQueue.has(t)||this.pathTrie.getSubKeys(t).some(t=>this.updateQueue.has(t)))&&this.updateComputedProperty(t)})}set(t,e,s=!1){const i=this.get(t);"object"==typeof t?(Object.assign(this.rawData,t),Object.keys(t).forEach(e=>{s||(this.notify(e,t[e],i?.[e]),this.queueUpdate(e,t[e]))})):(t.includes(".")?this.setNested(t,e):this.rawData[t]=e,s||(this.notify(t,e,i),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((t,e)=>t?.[e],this.rawData)}setNested(t,e){const s=t.split("."),i=s.pop(),n=s.reduce((t,e)=>(t[e]||(t[e]={}),t[e]),this.rawData),r=n[i];n[i]=e,this.notify(t,e,r),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(t=>t!==e))}notify(t,e,s){this.observers[t]&&this.observers[t].forEach(i=>{try{i(e,s)}catch(e){console.error(`Observer error for ${t}:`,e)}}),this.observers["*"]?.forEach(i=>{try{i(t,e,s)}catch(t){console.error("Wildcard observer error:",t)}})}updateElement(t,e){const s=t.getAttribute("data-bind");if(!s)return;s.split("|").forEach(s=>{const i=s.split(":"),n=i[0].trim(),r=i[1]?.trim();switch(n){case"text":t.textContent!==String(e??"")&&(t.textContent=e??"");break;case"html":const s=function(t){if(!t)return"";let e=String(t);const s=/<\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 i;do{i=e,e=e.replace(s,"")}while(e!==i);return e=e.replace(/\bon\w+\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+)/gi,""),e=e.replace(/(href|src|action|background)\s*=\s*(?:"[^"]*(?:javascript|vbscript|data)\s*:[^"]*"|'[^']*(?:javascript|vbscript|data)\s*:[^']*'|[^\s>]*(?:javascript|vbscript|data)\s*:[^\s>]*)/gi,'$1=""'),e=e.replace(/expression\s*\([^)]*\)/gi,""),e}(e);t.innerHTML!==s&&(t.innerHTML=s);break;case"value":"checkbox"===t.type?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 i=e?"none":"";t.style.display!==i&&(t.style.display=i);break;case"class":r&&(e?t.classList.add(r):t.classList.remove(r));break;case"style":r&&t.style[r]!==String(e??"")&&(t.style[r]=e??"");break;case"attr":if(r){t.getAttribute(r)!==String(e??"")&&t.setAttribute(r,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??"")}})}computed(t,e,s){this.computedProperties[t]={deps:e,callback:s},e.forEach(t=>{this.pathTrie.insert(t)}),this.updateComputedProperty(t)}updateComputedProperty(t){const e=this.computedProperties[t];if(e)try{const s=e.deps.map(t=>this.get(t)),i=e.callback(...s);this.set(t,i,!0)}catch(e){console.error(`Computed error for ${t}:`,e)}}load(t){Object.keys(t).forEach(e=>{t[e]&&"object"==typeof t[e]&&!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 N,this.updateQueue.clear(),this.snapshots=[],this.createReactiveData(),this.bind()}persist(t,e={}){const{storage:s="local",debounce:i=0,version:n=1,encrypt:r=!1,encryptionKey:a=null}=e,o="session"===s?sessionStorage:localStorage;this.persistedKeys.set(t,{storage:o,debounce:i,timeout:null,version:n,encrypt:r,encryptionKey:a});const l=this.get(t);void 0!==l&&this._persistSave(t,l,o,{version:n,encrypt:r,encryptionKey:a}),this.observe(t,e=>{const s=this.persistedKeys.get(t);s&&(s.debounce>0?(s.timeout&&clearTimeout(s.timeout),s.timeout=setTimeout(()=>{this._persistSave(t,e,s.storage,{version:s.version,encrypt:s.encrypt,encryptionKey:s.encryptionKey})},s.debounce)):this._persistSave(t,e,s.storage,{version:s.version,encrypt:s.encrypt,encryptionKey:s.encryptionKey}))})}_persistSave(t,e,s,i={}){try{const{version:n=1,encrypt:r=!1,encryptionKey:a=null}=i,o={value:e,version:n,timestamp:Date.now()};let l=JSON.stringify(o);r&&a&&(l=this._encrypt(l,a)),this._ensureStorageCapacity(s),s.setItem(`kupola:${t}`,l)}catch(i){if(console.warn(`Failed to persist key ${t}:`,i),"QuotaExceededError"===i.name&&s===localStorage){console.warn(`localStorage quota exceeded, trying sessionStorage for key ${t}`);try{sessionStorage.setItem(`kupola:${t}`,JSON.stringify({value:e,version:1}))}catch(e){console.warn(`sessionStorage also failed for key ${t}:`,e)}}}}_ensureStorageCapacity(t){try{const e="kupola:__storage_test__";t.setItem(e,"test"),t.removeItem(e)}catch(e){"QuotaExceededError"===e.name&&this._cleanupOldStorage(t)}}_cleanupOldStorage(t){const e=Date.now();for(let s=0;s<t.length;s++){const i=t.key(s);if(i?.startsWith("kupola:"))try{const s=JSON.parse(t.getItem(i));s.timestamp&&e-s.timestamp>2592e6&&t.removeItem(i)}catch(e){t.removeItem(i)}}}_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(e){return console.warn("Decryption failed:",e),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 i=0;i<localStorage.length;i++){const n=localStorage.key(i);if(n?.startsWith("kupola:")){const i=n.replace("kupola:","");try{const r=localStorage.getItem(n);let a;if(s){const t=this._decrypt(r,s);a=JSON.parse(t)}else a=JSON.parse(r);if(void 0!==a.version&&a.version!==t.version){console.debug(`Skipping outdated data for ${i} (version ${a.version})`);continue}e[i]=void 0!==a.value?a.value:a}catch(t){console.warn(`Failed to load persisted key ${i}:`,t)}}}for(let i=0;i<sessionStorage.length;i++){const n=sessionStorage.key(i);if(n?.startsWith("kupola:")){const i=n.replace("kupola:","");try{const r=sessionStorage.getItem(n);let a;if(s){const t=this._decrypt(r,s);a=JSON.parse(t)}else a=JSON.parse(r);if(void 0!==a.version&&a.version!==t.version){console.debug(`Skipping outdated data for ${i} (version ${a.version})`);continue}e[i]=void 0!==a.value?a.value:a}catch(t){}}}return Object.keys(e).length>0&&this.load(e),e}_clone(t){if("function"==typeof structuredClone)try{return structuredClone(t)}catch(t){console.warn("structuredClone failed, falling back to JSON:",t)}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(0===this.snapshots.length)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(t=>{this.queueUpdate(t,this.rawData[t])}),this.processComputed(),!0)}getSnapshotCount(){return this.snapshots.length}clearSnapshots(){this.snapshots=[]}serializeForm(t){const e={};return t.querySelectorAll("input, select, textarea").forEach(t=>{const s=t.getAttribute("data-bind");if(!s)return;const i=s.split(":"),n=i[1]?.trim();n&&("checkbox"===t.type?(e[n]||(e[n]=[]),t.checked&&e[n].push(t.value)):"radio"===t.type?t.checked&&(e[n]=t.value):e[n]=t.value)}),e}fillForm(t,e){Object.keys(e).forEach(s=>{t.querySelectorAll('[data-bind*=":'+s+'"]').forEach(t=>{"checkbox"===t.type?t.checked=Array.isArray(e[s])?e[s].includes(t.value):!!e[s]:"radio"===t.type?t.checked=t.value===e[s]:t.value=e[s]??""})})}createReactive(t,e=""){if(t[B])return t;if(this._proxyCache.has(t))return this._proxyCache.get(t);const s={get:(t,e,s)=>{if("__raw__"===e)return t;if(e===F||"__parent__"===e)return t[F];if(e===O||"__path__"===e)return t[O];if(e===B||"__isReactive__"===e)return!0;const i=Reflect.get(t,e,s);return i&&"object"==typeof i&&!Array.isArray(i)?this.wrapReactive(i,`${t[O]}${t[O]?".":""}${e}`):i},set:(t,e,s,i)=>{if(e===F||e===O||e===B||"__parent__"===e||"__path__"===e||"__isReactive__"===e)return!0;const n=Reflect.get(t,e,i),r=Reflect.set(t,e,s,i),a=`${t[O]}${t[O]?".":""}${e}`;return this.notify(a,s,n),this.queueUpdate(a,s),r},deleteProperty:(t,e)=>{if(e===F||e===O||e===B)return!1;const s=Reflect.get(t,e),i=Reflect.deleteProperty(t,e),n=`${t[O]}${t[O]?".":""}${e}`;return this.notify(n,void 0,s),this.queueUpdate(n,void 0),i},has:(t,e)=>"__raw__"===e||e===F||e===O||e===B||"__parent__"===e||"__path__"===e||"__isReactive__"===e||e in t,ownKeys:t=>Reflect.ownKeys(t).filter(t=>t!==F&&t!==O&&t!==B),getOwnPropertyDescriptor:(t,e)=>e===F||e===O||e===B?{configurable:!1,enumerable:!1,writable:!1,value:t[e]}:Reflect.getOwnPropertyDescriptor(t,e)},i=new Proxy(t,s);return t[F]=t,t[O]=e,t[B]=!0,this._proxyCache.set(t,i),Object.keys(t).forEach(s=>{t[s]&&"object"==typeof t[s]&&!Array.isArray(t[s])&&(t[s]=this.wrapReactive(t[s],`${e}${e?".":""}${s}`))}),i}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(t=>{t.addedNodes.forEach(t=>{if(t.nodeType===Node.ELEMENT_NODE){t.querySelectorAll("[data-bind]").forEach(t=>this._bindElement(t)),t.hasAttribute&&t.hasAttribute("data-bind")&&this._bindElement(t)}})})}finally{this._isObserving=!1}}}),this._mutationObserver.observe(document.body,{childList:!0,subtree:!0}))}_bindElement(t){const e=t.getAttribute("data-bind").split(":");e[0].split("|")[0].trim();const s=e[1]?.trim();if(s){if(this.pathTrie.insert(s),this.elements[s]||(this.elements[s]=[]),this.elements[s].includes(t)||this.elements[s].push(t),"INPUT"===t.tagName||"TEXTAREA"===t.tagName||"SELECT"===t.tagName){const e=t.__kupolaBindHandler;e&&t.removeEventListener("input",e);const i=()=>{const e="checkbox"===t.type?t.checked:t.value;s.includes(".")?this.setNested(s,e):this.set(s,e)};t.__kupolaBindHandler=i,t.addEventListener("input",i)}void 0!==this.rawData[s]&&this.updateElement(t,this.rawData[s])}}destroy(){this._mutationObserver&&(this._mutationObserver.disconnect(),this._mutationObserver=null),Object.values(this.elements).forEach(t=>{t.forEach(t=>{const e=t.__kupolaBindHandler;e&&(t.removeEventListener("input",e),delete t.__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 N,this.updateQueue.clear(),this.snapshots=[]}}class V{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={},U?(U.set(this._stateKey,s),this.state=U.data?.[this._stateKey]||U.createReactive(s,this._stateKey),U.observe(this._stateKey,t=>{this.notify(t)})):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];s?s(this.state,e):console.warn(`Mutation ${t} not found in store ${this.name}`)}dispatch(t,e){const s=this.actions[t];if(s)return s({state:this.state,commit:this.commit.bind(this),dispatch:this.dispatch.bind(this),getters:this},e);console.warn(`Action ${t} not found in store ${this.name}`)}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(t){console.error(`Observer error for store ${this.name}:`,t)}}),U&&U.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 K{constructor(){this.stores=new Map}createStore(t,e){const s=new V(t,e);return this.stores.set(t,s),s}getStore(t){return this.stores.get(t)}registerStore(t){t instanceof V&&this.stores.set(t.name,t)}dispose(){this.stores.clear()}}class j{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(t=>t!==e))}emit(t,e){this.events[t]&&this.events[t].forEach(s=>{try{s(e)}catch(e){console.error(`Error in event handler for ${t}:`,e)}}),this.events["*"]?.forEach(s=>{try{s(t,e)}catch(t){console.error("Error in wildcard event handler:",t)}})}once(t,e){const s=i=>{e(i),this.off(t,s)};return this.on(t,s),s}delegate(t,e,s){if(!this.delegatedEvents[e]){this.delegatedEvents[e]=[];const t=t=>{this.delegatedEvents[e].forEach(({selector:e,cb:s})=>{(t.target.matches(e)||t.target.closest(e))&&s(t)})};document.addEventListener(e,t),this.eventListeners[e]=t}return this.delegatedEvents[e].push({selector:t,cb:s}),s}undelegate(t,e){if(this.delegatedEvents[e]&&(this.delegatedEvents[e]=this.delegatedEvents[e].filter(e=>e.selector!==t),0===this.delegatedEvents[e].length)){const t=this.eventListeners[e];t&&(document.removeEventListener(e,t),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 W(t=null){const e={_value:t,_subscribers:new Set};return Object.defineProperty(e,"value",{configurable:!0,enumerable:!0,get:()=>e._value,set(t){t!==e._value&&(e._value=t,e._subscribers.forEach(e=>e(t)))}}),e.subscribe=t=>(e._subscribers.add(t),{unsubscribe(){e._subscribers.delete(t)}}),e}const U=new R,Y=new j,X=new K;const J="kupola-theme",Z="kupola-brand",G=[{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 Q(){return localStorage.getItem(J)||"dark"}function tt(t){if("dark"!==t&&"light"!==t)return;document.documentElement.setAttribute("data-theme",t),localStorage.setItem(J,t);const e=document.querySelector("[data-theme-toggle]");if(e){e.setAttribute("data-current-theme",t);const s=e.querySelector(".theme-icon");if(s){const e=s.src.substring(0,s.src.lastIndexOf("/")+1);s.src="dark"===t?e+"sun.svg":e+"moon.svg"}}}function et(){return localStorage.getItem(Z)||"zengqing"}function st(t){const e=G.find(e=>e.id===t);if(!e)return;document.documentElement.setAttribute("data-brand",t),localStorage.setItem(Z,t);const s=document.querySelector("[data-brand-toggle]");if(s){s.setAttribute("data-current-brand",t);const i=s.querySelector(".brand-icon");i&&(i.style.backgroundColor=e.color);const n=s.querySelector(".brand-name");n&&(n.textContent=e.name)}document.querySelectorAll("[data-brand-btn]").forEach(e=>{e.getAttribute("data-brand-btn")===t?e.classList.add("is-active"):e.classList.remove("is-active")})}function it(){tt(Q());st(et());const t=document.querySelector("[data-theme-toggle]");t&&t.addEventListener("click",()=>{tt("dark"===Q()?"light":"dark")});let e=document.getElementById("brand-picker");e||(e=document.createElement("div"),e.id="brand-picker",e.style.position="fixed",e.style.top="64px",e.style.right="16px",e.style.zIndex="9998",e.style.display="none",e.style.padding="12px",e.style.width="200px",e.style.gridTemplateColumns="repeat(3, 1fr)",e.style.gap="6px",e.style.backgroundColor="var(--bg-base-secondary)",e.style.border="1px solid var(--border-neutral-l1)",e.style.borderRadius="8px",e.style.boxShadow="0 4px 20px rgba(0, 0, 0, 0.2)",e.style.overflow="hidden",G.forEach(t=>{const s=document.createElement("button");s.setAttribute("data-brand-btn",t.id),s.style.display="flex",s.style.justifyContent="center",s.style.alignItems="center",s.style.height="60px",s.style.backgroundColor=t.color,s.style.color=["#32F08C","#FF9900","#E2C027","#0EB0C9","#B1A6CC"].includes(t.color)?"#0C0C0D":"#FFFFFF",s.style.fontWeight="500",s.style.borderRadius="4px",s.style.border="none",s.style.cursor="pointer",s.style.margin="0",s.style.padding="0",s.textContent=t.name,e.appendChild(s)}),document.body.appendChild(e));const s=document.querySelector("[data-brand-toggle]");function i(t){e&&s&&(e.contains(t.target)||s.contains(t.target)||(e.style.display="none",document.removeEventListener("click",i,!0)))}s&&e&&(s.onclick=function(t){t.stopPropagation(),t.preventDefault();const s="none"===e.style.display;e.style.display=s?"grid":"none",s?setTimeout(()=>{document.addEventListener("click",i,!0)},0):document.removeEventListener("click",i,!0)},e.onclick=function(t){t.stopPropagation()});document.querySelectorAll("[data-brand-btn]").forEach(t=>{t.addEventListener("click",s=>{s.stopPropagation();st(t.getAttribute("data-brand-btn")),e&&(e.style.display="none")})})}class nt{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,i={}){this.initializers.set(t,e),s&&this.cleanupFunctions.set(t,s),i.dataAttribute&&!this._dataAttrs.includes(i.dataAttribute)&&(this._dataAttrs.push(i.dataAttribute),this._cachedSelector=null),i.cssClass&&!this._cssClasses.includes(i.cssClass)&&(this._cssClasses.push(i.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(null!==this._cachedSelector)return this._cachedSelector;const t=this._dataAttrs.map(t=>`[${t}]`);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 e of this._dataAttrs){const s=t.getAttribute(e);if(null!==s){const i=s||e.replace("data-",""),n=this.initializers.get(i)||this.initializers.get(e.replace("data-",""));if(n){try{await n(t),this.processedElements.add(t)}catch(t){console.error(`[ComponentInitializerRegistry] Error initializing "${i}":`,t)}return}}}const e=t.className;if("string"==typeof e)for(const s of this._cssClasses)if(e.includes(s)){const e=s.replace("ds-",""),i=this.initializers.get(e)||this.initializers.get(s);if(i){try{await i(t),this.processedElements.add(t)}catch(t){console.error(`[ComponentInitializerRegistry] Error initializing "${e}":`,t)}return}}}cleanup(t){for(const e of this._dataAttrs){const s=t.getAttribute(e);if(null!==s){const i=s||e.replace("data-",""),n=this.cleanupFunctions.get(i)||this.cleanupFunctions.get(e.replace("data-",""));if(n){try{n(t)}catch(t){console.error(`[ComponentInitializerRegistry] Error cleaning up "${i}":`,t)}return void this.processedElements.delete(t)}}}const e=t.className;if("string"==typeof e)for(const s of this._cssClasses)if(e.includes(s)){const e=s.replace("ds-",""),i=this.cleanupFunctions.get(e)||this.cleanupFunctions.get(s);if(i){try{i(t)}catch(t){console.error(`[ComponentInitializerRegistry] Error cleaning up "${e}":`,t)}return void this.processedElements.delete(t)}}}async initializeAll(t=document){const e=this._buildSelector();if(!e)return;const s=t.querySelectorAll(e),i=[];s.forEach(t=>{this.processedElements.has(t)||i.push(this.initialize(t))}),await Promise.all(i)}}const rt=new nt,at=[{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 t of at)t.attr&&!rt._dataAttrs.includes(t.attr)&&rt._dataAttrs.push(t.attr),t.cls&&!rt._cssClasses.includes(t.cls)&&rt._cssClasses.push(t.cls);class ot{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 e,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 i=e.value;try{i=JSON.parse(i)}catch(t){}t[s]=i}return t}_parseSlots(){const t={};return this.element.querySelectorAll("[data-slot]").forEach(e=>{const s=e.getAttribute("data-slot")||"default";t[s]=e.innerHTML.trim(),e.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(s=>{try{s(e)}catch(e){console.error(`Error in event handler for ${t}:`,e)}}),this.element){const s=new CustomEvent(`kupola:${t}`,{detail:e,bubbles:!0,cancelable:!0});this.element.dispatchEvent(s)}}$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(t=>t!==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&&"function"==typeof this.lifecycle._handleError&&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&&"function"==typeof this.lifecycle._handleError&&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(),"function"==typeof this.setup){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&&"function"==typeof this.lifecycle._handleError&&await this.lifecycle._handleError({phase:"mount",hook:"component",error:t,args:[]}),"function"==typeof this.renderError)try{this.renderError(t)}catch(t){console.error(`[KupolaComponent] Error in renderError for "${this.constructor.name}":`,t)}else this.element.innerHTML=`\n <div style="padding: 16px; background: #fee2e2; border: 1px solid #fecaca; border-radius: 8px; color: #991b1b;">\n <div style="font-weight: bold; margin-bottom: 8px;">Component Error</div>\n <div style="font-size: 12px; white-space: pre-wrap;">${t.message}</div>\n </div>\n `}}_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!==ot;){for(const[i,n]of Object.entries(t))s.has(i)||e.hasOwnProperty(i)&&(Array.isArray(n)?n.forEach(t=>{"render"===i&&this.lifecycle.on(t,()=>this.render?.())}):"renderError"===i?this.lifecycle.on(n,t=>(this.renderError(t.error),"handled")):this.lifecycle.on(n,()=>this[i]?.()),s.add(i));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&&"function"==typeof this.lifecycle._handleError&&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 lt(t,e){Object.keys(e).forEach(s=>{if("constructor"!==s)if("function"==typeof e[s]){const i=t.prototype[s];t.prototype[s]=i?function(...t){return e[s].apply(this,t),i.apply(this,t)}:e[s]}else t.prototype[s]=e[s]})}class ht{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 ot))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 i=(async()=>{try{const e=await s(),i=e.default||e;if(!(i.prototype instanceof ot))throw new Error(`Component ${t} must extend KupolaComponent`);return this.loadedComponents.set(t,i),i}catch(e){throw this.loadingPromises.delete(t),e}})();return this.loadingPromises.set(t,i),i}defineMixin(t,e){this.mixins.set(t,e)}useMixin(t,...e){e.forEach(e=>{const s=this.mixins.get(e);s&<(t,s)})}async bootstrap(t=document){await this._upgradeElements(t),this._startObserver(t)}async _upgradeElements(t){const e=t.querySelectorAll("[data-component]"),s=[];e.forEach(t=>{s.push(this._upgradeElement(t))}),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 s=rt.get(e);if(s)try{return void await s(t)}catch(t){console.warn(`[KupolaComponentRegistry] Initializer for "${e}" failed, trying component class:`,t)}}let s=this.components.get(e);if(!s){try{s=await this.getAsync(e)}catch(t){return void console.error(`Failed to load component ${e}:`,t)}if(!t.isConnected)return}const i=t.getAttribute("data-mixins"),n=s;i&&i.split(",").forEach(t=>{const e=this.mixins.get(t.trim());e&<(n,e)});const r=new n(t);t.__kupolaInstance=r,this.instances.set(t,r),r.mount()}finally{t.__kupolaUpgrading=!1}}}_startObserver(t){this.observer||(this.observer=new MutationObserver(t=>{t.forEach(t=>{t.addedNodes.forEach(t=>{if(t.nodeType===Node.ELEMENT_NODE){t.hasAttribute("data-component")&&this._upgradeElement(t).catch(t=>console.error(t)),this._upgradeElements(t).catch(t=>console.error(t)),rt.initialize(t).catch(()=>{});const e=rt._buildSelector();e&&t.querySelectorAll?.(e).forEach(t=>{rt.initialize(t).catch(()=>{})})}}),t.removedNodes.forEach(t=>{if(t.nodeType===Node.ELEMENT_NODE){const e=this.instances.get(t);e&&(e.unmount(),this.instances.delete(t)),t.querySelectorAll("[data-component]").forEach(t=>{const e=this.instances.get(t);e&&(e.unmount(),this.instances.delete(t))}),rt.cleanup(t),t.querySelectorAll?.("*").forEach(t=>{rt.cleanup(t)})}})})}),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()}}async function ct(){"undefined"!=typeof window&&(U.loadPersisted(),U.bind(),it(),await rt.initializeAll(),t.kupolaRegistry&&await t.kupolaRegistry.bootstrap())}t.kupolaRegistry=null,"undefined"!=typeof window&&(t.kupolaRegistry=new ht),"undefined"!=typeof document&&"loading"===document.readyState?document.addEventListener("DOMContentLoaded",ct):"undefined"!=typeof window&&setTimeout(ct,0);class dt{constructor(t={}){this.locales=t.locales||{},this.currentLocale=t.defaultLocale||"zh-CN",this.fallbackLocale=t.fallbackLocale||"zh-CN",this.delimiter=t.delimiter||".",this.missingHandler=t.missingHandler||(t=>(console.warn(`Missing translation: ${t}`),t)),this._initFromDOM()}_initFromDOM(){document.querySelectorAll('script[type="application/json"][data-kupola-i18n]').forEach(t=>{const e=t.dataset.kupolaI18n;if(e)try{const s=JSON.parse(t.textContent);this.addLocale(e,s)}catch(t){console.error("Failed to parse i18n data:",t)}});const t=document.documentElement.lang;t&&this.locales[t]&&(this.currentLocale=t)}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)}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 i=this.locales[e];for(const t of s){if(!i||"object"!=typeof i||!(t in i))return null;i=i[t]}return"string"==typeof i?i:null}_interpolate(t,e){return t.replace(/\{(\w+)\}/g,(t,s)=>void 0!==e[s]?e[s]:t)}n(t,e,s={}){const i=this.t(t,{...s,count:e});if(!i)return i;const n=i.split("|");return 1===n.length?i.replace("{count}",e):2===n.length?1===e?n[0]:n[1]:n.length>=3?0===e?n[0]:1===e?n[1]:n[2]:i}_emitChange(){const t=new CustomEvent("kupola:i18n:change",{detail:{locale:this.currentLocale},bubbles:!0});document.dispatchEvent(t)}async loadLocale(t,e){try{const s=await fetch(e),i=await s.json();return this.addLocale(t,i),!0}catch(t){return console.error("Failed to load locale:",t),!1}}getAvailableLocales(){return Object.keys(this.locales)}hasLocale(t){return!!this.locales[t]}formatDate(t,e={}){const s=e.locale||this.currentLocale,i="string"==typeof t?new Date(t):t;return new Intl.DateTimeFormat(s,e).format(i)}formatNumber(t,e={}){const s=e.locale||this.currentLocale;return new Intl.NumberFormat(s,e).format(t)}formatCurrency(t,e,s={}){const i=s.locale||this.currentLocale;return new Intl.NumberFormat(i,{style:"currency",currency:e,...s}).format(t)}formatRelativeTime(t,e,s={}){const i=s.locale||this.currentLocale;return new Intl.RelativeTimeFormat(i,s).format(t,e)}}const ut=new dt;class pt{constructor(){this._listeners=new Map,this._scopeListeners=new Map}on(t,e,s,i={}){const{scope:n=null,once:r=!1,passive:a=!1,capture:o=!1}=i,l=this._generateId(),h={id:l,target:t,eventName:e,handler:s,scope:n,once:r,wrappedHandler:null};h.wrappedHandler=e=>{r&&this.offById(l),s.call(t,e)};const c=this._getEventKey(t,e);return this._listeners.has(c)||this._listeners.set(c,[]),this._listeners.get(c).push(h),n&&(this._scopeListeners.has(n)||this._scopeListeners.set(n,[]),this._scopeListeners.get(n).push(l)),t.addEventListener(e,h.wrappedHandler,{passive:a,capture:o}),{unsubscribe:()=>this.offById(l)}}once(t,e,s,i={}){return this.on(t,e,s,{...i,once:!0})}off(t,e,s){const i=this._getEventKey(t,e);if(!this._listeners.has(i))return;const n=this._listeners.get(i),r=n.filter(t=>t.handler!==s);n.forEach(i=>{i.handler===s&&(t.removeEventListener(e,i.wrappedHandler),this._removeFromScope(i))}),0===r.length?this._listeners.delete(i):this._listeners.set(i,r)}offById(t){for(const[e,s]of this._listeners){const i=s.findIndex(e=>e.id===t);if(-1!==i){const t=s[i];return t.target.removeEventListener(t.eventName,t.wrappedHandler),s.splice(i,1),0===s.length&&this._listeners.delete(e),this._removeFromScope(t),!0}}return!1}offByScope(t){if(!this._scopeListeners.has(t))return;this._scopeListeners.get(t).forEach(t=>{this.offById(t)}),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(s=>{t.removeEventListener(e,s.wrappedHandler),this._removeFromScope(s)}),this._listeners.delete(s)}else for(const[e,s]of this._listeners){const[i]=e.split(":");this._getTargetId(t)===i&&(s.forEach(e=>{t.removeEventListener(e.eventName,e.wrappedHandler),this._removeFromScope(e)}),this._listeners.delete(e))}}emit(t,e,s={}){const i=new CustomEvent(e,{detail:s,bubbles:!0,cancelable:!0});return t.dispatchEvent(i),i}emitGlobal(t,e={}){return this.emit(document,t,e)}emitToScope(t,e,s={}){if(!this._scopeListeners.has(t))return;const i=this._scopeListeners.get(t),n=new Set;for(const[t,e]of this._listeners)e.forEach(t=>{i.includes(t.id)&&n.add(t.target)});n.forEach(t=>{this.emit(t,e,s)})}getListenerCount(t,e=null){if(e){const s=this._getEventKey(t,e);return this._listeners.has(s)?this._listeners.get(s).length:0}let s=0;const i=this._getTargetId(t);for(const[t,e]of this._listeners){const[n]=t.split(":");n===i&&(s+=e.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);-1!==s&&(e.splice(s,1),0===e.length&&this._scopeListeners.delete(t.scope))}destroy(){for(const[t,e]of this._listeners)e.forEach(t=>{t.target.removeEventListener(t.eventName,t.wrappedHandler)});this._listeners.clear(),this._scopeListeners.clear()}}const mt=new pt;class gt{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)}`,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=!1!==e.keyboardNav,this.autoPosition=!1!==e.autoPosition,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._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=>{const e=t.currentTarget;e.classList.contains("is-disabled")||e.classList.contains("ds-dropdown__divider")||(this.triggerText&&!e.hasAttribute("data-no-update-trigger")&&(this.triggerText.textContent=e.textContent.trim()),this.onSelect&&this.onSelect({item:e,value:e.getAttribute("data-value"),text:e.textContent.trim()}),this.hideMenu(),this.trigger.focus())},this._bindMenuItems(),this._triggerClickHandler=t=>{t.stopPropagation(),this.disabled||this.toggleMenu()},this._triggerMouseenterHandler=()=>{this.disabled||"hover"!==this.triggerMode||(clearTimeout(this._hoverLeaveTimer),this._hoverTimer=setTimeout(()=>this.showMenu(),this.hoverDelay))},this._triggerMouseleaveHandler=()=>{"hover"===this.triggerMode&&(clearTimeout(this._hoverTimer),this._hoverLeaveTimer=setTimeout(()=>this.hideMenu(),this.hoverDelay))},this._mouseenterHandler=()=>{this.disabled||"hover"!==this.triggerMode||clearTimeout(this._hoverLeaveTimer)},this._mouseleaveHandler=()=>{"hover"===this.triggerMode&&(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)}},"hover"===this.triggerMode?(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||"Enter"!==t.key&&" "!==t.key&&"ArrowDown"!==t.key||(t.preventDefault(),this.showMenu())},this.trigger.addEventListener("keydown",this._triggerKeydownHandler),document.addEventListener("keydown",this._keydownHandler),this._documentClickHandler=t=>{this.element.contains(t.target)||this.hideMenu()},this._documentClickListener=mt.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.addEventListener("click",this._itemClickHandler),t._dropdownItemClickHandler=this._itemClickHandler})}_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(t=>t.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,i=window.innerWidth;this.menu.classList.remove("ds-dropdown--top","ds-dropdown--right","ds-dropdown--dropup");const n=s-t.bottom,r=t.top;n<e.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+e.width>i?(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.menu.style.display="block",this.element.classList.add("is-open"),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.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})))}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(t=>{t._dropdownItemClickHandler&&t.removeEventListener("click",t._dropdownItemClickHandler)}),this.menu.innerHTML="",t.forEach(t=>{if("divider"===t.type){const t=document.createElement("div");t.className="ds-dropdown__divider",this.menu.appendChild(t)}else{const e=document.createElement("div");e.className="ds-dropdown__item"+(t.disabled?" is-disabled":"")+(t.active?" is-selected":""),e.textContent=t.text||t.label||"",void 0!==t.value&&e.setAttribute("data-value",t.value),t.icon&&(e.innerHTML=t.icon+e.innerHTML),t.disabled&&e.classList.add("is-disabled"),this.menu.appendChild(e)}}),this._bindMenuItems()}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._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 _t(t,e){const s=new gt(t,e);s.init(),t._kupolaDropdown=s}function yt(t){t._kupolaDropdown&&(t._kupolaDropdown.destroy(),t._kupolaDropdown=null)}rt.register("dropdown",_t,yt);class ft{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.isOpen=!1,this.selectedValues=new Set,this.allOptions=[],this.filteredOptions=[],this.focusIndex=-1,this.searchInput=null,this.clearBtn=null,this.tagsWrap=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=>{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()}},document.addEventListener("keydown",this._keydownHandler),this._documentClickHandler=t=>{this.element.contains(t.target)||this.hideOptions()},this._documentClickListener=mt.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",t=>{t.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();this.remoteMethod?this.remoteMethod(t,t=>{this._renderRemoteOptions(t)}):(this.filteredOptions=this.allOptions.filter(e=>e.text.toLowerCase().includes(t)),this.allOptions.forEach(t=>{const e=this.filteredOptions.includes(t);t.el.style.display=e?"":"none"}),this.optionsEl.querySelectorAll(".ds-select__group-title").forEach(t=>{const e=t.getAttribute("data-group"),s=this.filteredOptions.some(t=>t.group===e);t.style.display=s?"":"none"}),this.focusIndex=-1)}_renderRemoteOptions(t){this.optionsEl.querySelectorAll(".ds-select__option, .ds-select__item").forEach(t=>{t._selectOptionClickHandler&&t.removeEventListener("click",t._selectOptionClickHandler),t.remove()}),t.forEach(t=>{const e=document.createElement("div");e.className="ds-select__option",e.setAttribute("data-value",t.value),e.textContent=t.text||t.label,t.disabled&&e.classList.add("is-disabled"),this.selectedValues.has(t.value)&&e.classList.add("is-selected"),e.addEventListener("click",this._optionClickHandler),e._selectOptionClickHandler=this._optionClickHandler,this.optionsEl.appendChild(e)}),this.allOptions=t.map(t=>({el:this.optionsEl.querySelector(`[data-value="${t.value}"]`),value:t.value,text:t.text||t.label,group:"",disabled:!!t.disabled})),this.filteredOptions=[...this.allOptions]}_selectSingleOption(t,e){this.optionsEl.querySelectorAll(".ds-select__option, .ds-select__item").forEach(t=>t.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(e=>e.value===t);if(!e)return;const s=document.createElement("span");s.className="ds-select__tag",s.textContent=e.text;const i=document.createElement("button");i.className="ds-select__tag-close",i.type="button",i.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>',i.addEventListener("click",e=>{e.stopPropagation(),this.selectedValues.delete(t);const s=this.optionsEl.querySelector(`[data-value="${t}"]`);s&&s.classList.remove("is-selected"),this._updateTags(),this._updateValueDisplay(),this._syncNativeSelect(),this._updateClearBtn(),this._fireChange()}),s.appendChild(i),this.tagsWrap.appendChild(s)}))}_updateValueDisplay(){if(this.valueEl)if(this.multiple){const t=this.selectedValues.size;0===t?(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 0===this.selectedValues.size&&(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.addEventListener("click",this._optionClickHandler),t._selectOptionClickHandler=this._optionClickHandler})}_getVisibleOptions(){return Array.from(this.optionsEl.querySelectorAll(".ds-select__option, .ds-select__item")).filter(t=>"none"!==t.style.display&&!t.classList.contains("is-disabled"))}_focusOption(t){t.forEach(t=>t.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.optionsEl.style.display="block",this.icon&&(this.icon.style.transform="rotate(180deg)"),this.element.classList.add("is-open"),this.focusIndex=-1,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.searchInput&&(this.searchInput.value="",this._handleSearch()),this.optionsEl.querySelectorAll(".ds-select__option, .ds-select__item").forEach(t=>t.classList.remove("is-focused")))}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(e=>e.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(t=>this.selectedValues.add(t)),this.optionsEl.querySelectorAll(".ds-select__option, .ds-select__item").forEach(t=>{t.classList.toggle("is-selected",this.selectedValues.has(t.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._documentClickHandler=null,this._documentClickListener=null,this._triggerClickHandler=null,this._optionClickHandler=null,this._keydownHandler=null,this.element.__kupolaInitialized=!1)}}function vt(t,e){const s=new ft(t,e);s.init(),t._kupolaSelect=s}function bt(t){t._kupolaSelect&&(t._kupolaSelect.destroy(),t._kupolaSelect=null)}rt.register("select",vt,bt);class kt{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)}`,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||parseInt(t.getAttribute("data-datepicker-week-start"))||0,this.placeholder=e.placeholder||t.getAttribute("data-datepicker-placeholder")||"",this.showToday=!1!==e.showToday,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._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(" ~ ");2===t.length&&(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=mt.on(document,"click",t=>this.hideCalendar(t),{scope:this.scope}),this._resizeListener=mt.on(window,"resize",()=>this.resizeHandler(),{scope:this.scope}),this._keydownHandler=t=>{"Escape"===t.key&&"block"===this.calendarEl.style.display&&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 3===e.length?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"),i=String(t.getDate()).padStart(2,"0");return this.format.replace("YYYY",e).replace("MM",s).replace("DD",i)}_isDateDisabled(t){if(this.minDate){if(t<("string"==typeof this.minDate?this._parseDate(this.minDate):this.minDate))return!0}if(this.maxDate){if(t>("string"==typeof this.maxDate?this._parseDate(this.maxDate):this.maxDate))return!0}return!!this.disabledDate&&this.disabledDate(t)}_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)&&(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()),i=Math.max(this.rangeStart.getTime(),this.rangeEnd.getTime());return e>=s&&e<=i}calculatePosition(){const t=this.element.getBoundingClientRect(),e=this.calendarEl.getBoundingClientRect(),s=window.innerHeight-t.bottom,i=t.top,n=e.height||320;s>=n?(this.calendarEl.style.top="calc(100% + 4px)",this.calendarEl.style.bottom="auto"):i>=n?(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="block"===this.calendarEl.style.display;document.querySelectorAll(".ds-datepicker__calendar").forEach(t=>{t!==this.calendarEl&&(t.style.display="none",t.setAttribute("hidden",""))}),e||(this.calendarEl.style.display="block",this.calendarEl.removeAttribute("hidden"),this.calculatePosition())}hideCalendar(t){this.element.contains(t.target)||(this.calendarEl.style.display="none",this.calendarEl.setAttribute("hidden",""),this.viewMode="days")}resizeHandler(){"block"===this.calendarEl.style.display&&this.calculatePosition()}_renderCalendar(){const t=this.calendarEl;if(!t)return;if(t.querySelectorAll(".ds-datepicker__day").forEach(t=>{t._dayClickHandler&&t.removeEventListener("click",t._dayClickHandler)}),"years"===this.viewMode)return void this._renderYearsView();if("months"===this.viewMode)return void this._renderMonthsView();const e=this.currentDate.getFullYear(),s=this.currentDate.getMonth();t.innerHTML="";const i=document.createElement("div");i.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",t=>{t.stopPropagation(),this._prevMonth()});const r=document.createElement("button");r.className="ds-datepicker__title",r.type="button",r.textContent=`${e} ${this.months[s]}`,r.addEventListener("click",t=>{t.stopPropagation(),this.viewMode="months",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",t=>{t.stopPropagation(),this._nextMonth()}),i.appendChild(n),i.appendChild(r),i.appendChild(a),t.appendChild(i);const o=document.createElement("div");o.className="ds-datepicker__weekdays";[...this.weekDays.slice(this.weekStart),...this.weekDays.slice(0,this.weekStart)].forEach(t=>{const e=document.createElement("span");e.className="ds-datepicker__weekday",e.textContent=t,o.appendChild(e)}),t.appendChild(o);const l=document.createElement("div");l.className="ds-datepicker__days";const h=new Date(e,s,1).getDay(),c=new Date(e,s+1,0).getDate(),d=(h-this.weekStart+7)%7;for(let t=0;t<d;t++){const t=document.createElement("span");t.className="ds-datepicker__day ds-datepicker__day--empty",l.appendChild(t)}for(let t=1;t<=c;t++){const i=new Date(e,s,t),n=document.createElement("button");n.className="ds-datepicker__day",n.type="button",n.textContent=t,this._formatDate(i),this._isToday(i)&&n.classList.add("is-today"),this.range?((this._isSameDay(i,this.rangeStart)||this._isSameDay(i,this.rangeEnd))&&n.classList.add("is-selected"),this._isInRange(i)&&n.classList.add("is-in-range")):this._isSameDay(i,this.selectedDate)&&n.classList.add("is-selected"),this._isDateDisabled(i)&&(n.classList.add("is-disabled"),n.disabled=!0);const r=()=>this._selectDate(i);n.addEventListener("click",r),n._dayClickHandler=r,l.appendChild(n)}if(t.appendChild(l),this.showToday){const e=document.createElement("div");e.className="ds-datepicker__footer";const s=document.createElement("button");s.className="ds-datepicker__today-btn",s.type="button",s.textContent=this.todayText,s.addEventListener("click",t=>{t.stopPropagation(),this._goToToday()});const i=document.createElement("button");i.className="ds-datepicker__clear-btn",i.type="button",i.textContent=this.clearText,i.addEventListener("click",t=>{t.stopPropagation(),this._clearDate()}),e.appendChild(s),e.appendChild(i),t.appendChild(e)}}_renderYearsView(){const t=this.calendarEl;t.innerHTML="";const e=this.currentDate.getFullYear(),s=e-6,i=document.createElement("div");i.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",t=>{t.stopPropagation(),this.currentDate.setFullYear(this.currentDate.getFullYear()-12),this._renderCalendar()});const r=document.createElement("button");r.className="ds-datepicker__title",r.type="button",r.textContent=`${s} - ${s+11}`,r.addEventListener("click",t=>{t.stopPropagation()});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",t=>{t.stopPropagation(),this.currentDate.setFullYear(this.currentDate.getFullYear()+12),this._renderCalendar()}),i.appendChild(n),i.appendChild(r),i.appendChild(a),t.appendChild(i);const o=document.createElement("div");o.className="ds-datepicker__years-grid";for(let t=0;t<12;t++){const i=s+t,n=document.createElement("button");n.className="ds-datepicker__year-cell",n.type="button",n.textContent=i,i===e&&n.classList.add("is-selected"),n.addEventListener("click",t=>{t.stopPropagation(),this.currentDate.setFullYear(i),this.viewMode="months",this._renderCalendar()}),o.appendChild(n)}t.appendChild(o)}_renderMonthsView(){const t=this.calendarEl;t.innerHTML="";const e=this.currentDate.getFullYear(),s=document.createElement("div");s.className="ds-datepicker__header";const i=document.createElement("button");i.className="ds-datepicker__nav ds-datepicker__nav--prev",i.type="button",i.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>',i.addEventListener("click",t=>{t.stopPropagation(),this.currentDate.setFullYear(this.currentDate.getFullYear()-1),this._renderCalendar()});const n=document.createElement("button");n.className="ds-datepicker__title",n.type="button",n.textContent=e,n.addEventListener("click",t=>{t.stopPropagation(),this.viewMode="years",this._renderCalendar()});const r=document.createElement("button");r.className="ds-datepicker__nav ds-datepicker__nav--next",r.type="button",r.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>',r.addEventListener("click",t=>{t.stopPropagation(),this.currentDate.setFullYear(this.currentDate.getFullYear()+1),this._renderCalendar()}),s.appendChild(i),s.appendChild(n),s.appendChild(r),t.appendChild(s);const a=document.createElement("div");a.className="ds-datepicker__months-grid",this.months.forEach((t,e)=>{const s=document.createElement("button");s.className="ds-datepicker__month-cell",s.type="button",s.textContent=t,e===this.currentDate.getMonth()&&s.classList.add("is-selected"),s.addEventListener("click",t=>{t.stopPropagation(),this.currentDate.setMonth(e),this.viewMode="days",this._renderCalendar()}),a.appendChild(s)}),t.appendChild(a)}_selectDate(t){if(!this._isDateDisabled(t)){if(!this.range)return this.selectedDate=t,this.input&&(this.input.value=this._formatDate(t)),this.calendarEl.style.display="none",this.calendarEl.setAttribute("hidden",""),void this._fireChange();if(this.isSelectingEnd&&this.rangeStart)return 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",""),void this._fireChange();this.rangeStart=t,this.rangeEnd=null,this.isSelectingEnd=!0,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="string"==typeof t?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="string"==typeof t?this._parseDate(t):t,this.rangeEnd="string"==typeof e?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._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 Et(t,e){const s=new kt(t,e);s.init(),t._kupolaDatepicker=s}function wt(t){t._kupolaDatepicker&&(t._kupolaDatepicker.destroy(),t._kupolaDatepicker=null)}rt.register("datepicker",Et,wt);class xt{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&&"block"===this.panelEl.style.display?this.hideTimepicker():this.showTimepicker()},this.inputWrap.addEventListener("click",this._inputWrapClickHandler),this._documentClickListener=mt.on(document,"click",t=>this.hideTimepicker(t),{scope:this.scope}),this._resizeListener=mt.on(window,"resize",()=>this.resizeHandler(),{scope:this.scope}),this._keydownHandler=t=>{"Escape"===t.key&&this.panelEl&&"block"===this.panelEl.style.display&&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)return this.selectedHour=parseInt(e[1])%12,"PM"===e[4].toUpperCase()&&(this.selectedHour+=12),this.selectedMinute=parseInt(e[2]),void(this.selectedSecond=e[3]?parseInt(e[3]):0);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 i=3600*t+60*e+s;if(this.minTime){const t=this.minTime.split(":");if(i<3600*parseInt(t[0])+60*parseInt(t[1])+(parseInt(t[2])||0))return!0}if(this.maxTime){const t=this.maxTime.split(":");if(i>3600*parseInt(t[0])+60*parseInt(t[1])+(parseInt(t[2])||0))return!0}return!1}_formatTime(){let t=this.selectedHour,e=this.selectedMinute,s=this.selectedSecond;if(this.use12Hour){const i=t>=12?"PM":"AM";return t=t%12||12,this.showSeconds?`${t}:${String(e).padStart(2,"0")}:${String(s).padStart(2,"0")} ${i}`:`${t}:${String(e).padStart(2,"0")} ${i}`}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(),s=window.innerHeight-t.bottom,i=t.top,n=e.height||320;s>=n?(this.panelEl.style.top="calc(100% + 4px)",this.panelEl.style.bottom="auto"):i>=n?(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)return this.panelEl.style.display="block",this._syncPanelSelection(),void this.calculatePosition();this.panelEl=document.createElement("div"),this.panelEl.className="ds-timepicker__panel";let t="";if(t+='<div class="ds-timepicker__section">\n <div class="ds-timepicker__section-label">Hour</div>\n <div class="ds-timepicker__grid ds-timepicker__grid--hour" data-type="hour"></div>\n </div>',t+='<div class="ds-timepicker__section">\n <div class="ds-timepicker__section-label">Min</div>\n <div class="ds-timepicker__grid ds-timepicker__grid--minute" data-type="minute"></div>\n </div>',this.showSeconds&&(t+='<div class="ds-timepicker__section">\n <div class="ds-timepicker__section-label">Sec</div>\n <div class="ds-timepicker__grid ds-timepicker__grid--second" data-type="second"></div>\n </div>'),this.use12Hour&&(t+='<div class="ds-timepicker__section ds-timepicker__section--ampm">\n <div class="ds-timepicker__grid ds-timepicker__grid--ampm" data-type="ampm"></div>\n </div>'),this.panelEl.innerHTML=`\n <div class="ds-timepicker__header">\n <div class="ds-timepicker__display">\n <span class="ds-timepicker__display-hour">${String(this.selectedHour).padStart(2,"0")}</span>\n <span class="ds-timepicker__separator">:</span>\n <span class="ds-timepicker__display-minute">${String(this.selectedMinute).padStart(2,"0")}</span>\n ${this.showSeconds?'<span class="ds-timepicker__separator">:</span><span class="ds-timepicker__display-second">'+String(this.selectedSecond).padStart(2,"0")+"</span>":""}\n ${this.use12Hour?'<span class="ds-timepicker__display-ampm">'+(this.selectedHour>=12?"PM":"AM")+"</span>":""}\n </div>\n </div>\n <div class="ds-timepicker__body">${t}</div>\n ${this.clearable?'<div class="ds-timepicker__footer"><button class="ds-timepicker__clear-btn" type="button">Clear</button></div>':""}\n `,this.element.appendChild(this.panelEl),this._populateHourGrid(),this._populateMinuteGrid(),this.showSeconds&&this._populateSecondGrid(),this.use12Hour&&this._populateAmPmGrid(),this.clearable){const t=this.panelEl.querySelector(".ds-timepicker__clear-btn");t&&t.addEventListener("click",t=>{t.stopPropagation(),this.input.value="",this.hideTimepicker(),this.input.dispatchEvent(new Event("change"))})}this.panelEl.addEventListener("click",t=>t.stopPropagation()),this._syncPanelSelection(),setTimeout(()=>{this.calculatePosition(),this._scrollToSelection()},0)}_populateHourGrid(){const t=this.panelEl.querySelector('[data-type="hour"]');if(!t)return;this.use12Hour;for(let e=this.use12Hour?1:0;e<(this.use12Hour?13:24);e+=this.hourStep){const s=document.createElement("button");s.type="button",s.className="ds-timepicker__item",s.textContent=String(e).padStart(2,"0"),s.dataset.value=e,s.addEventListener("click",()=>{let t=e;this.use12Hour&&(t=12===e?this.isPM?12:0:this.isPM?e+12:e),this.selectedHour=t,this._updateDisplay(),this._syncGridSelection("hour",e),this._confirmSelection()}),t.appendChild(s)}}_populateMinuteGrid(){const t=this.panelEl.querySelector('[data-type="minute"]');if(t)for(let e=0;e<60;e+=this.minuteStep){const s=document.createElement("button");s.type="button",s.className="ds-timepicker__item",s.textContent=String(e).padStart(2,"0"),s.dataset.value=e,s.addEventListener("click",()=>{this.selectedMinute=e,this._updateDisplay(),this._syncGridSelection("minute",e),this._confirmSelection()}),t.appendChild(s)}}_populateSecondGrid(){const t=this.panelEl.querySelector('[data-type="second"]');if(t)for(let e=0;e<60;e+=this.secondStep){const s=document.createElement("button");s.type="button",s.className="ds-timepicker__item",s.textContent=String(e).padStart(2,"0"),s.dataset.value=e,s.addEventListener("click",()=>{this.selectedSecond=e,this._updateDisplay(),this._syncGridSelection("second",e),this._confirmSelection()}),t.appendChild(s)}}_populateAmPmGrid(){const t=this.panelEl.querySelector('[data-type="ampm"]');t&&["AM","PM"].forEach(e=>{const s=document.createElement("button");s.type="button",s.className="ds-timepicker__item",s.textContent=e,s.dataset.value=e,s.addEventListener("click",()=>{this.isPM="PM"===e,this.isPM&&this.selectedHour<12&&(this.selectedHour+=12),!this.isPM&&this.selectedHour>=12&&(this.selectedHour-=12),this._updateDisplay(),t.querySelectorAll(".ds-timepicker__item").forEach(t=>t.classList.remove("is-selected")),s.classList.add("is-selected"),this._confirmSelection()}),t.appendChild(s)})}_updateDisplay(){if(!this.panelEl)return;const t=this.panelEl.querySelector(".ds-timepicker__display-hour"),e=this.panelEl.querySelector(".ds-timepicker__display-minute"),s=this.panelEl.querySelector(".ds-timepicker__display-second"),i=this.panelEl.querySelector(".ds-timepicker__display-ampm");if(t){const e=this.use12Hour?this.selectedHour%12||12:this.selectedHour;t.textContent=String(e).padStart(2,"0")}e&&(e.textContent=String(this.selectedMinute).padStart(2,"0")),s&&(s.textContent=String(this.selectedSecond).padStart(2,"0")),i&&(i.textContent=this.selectedHour>=12?"PM":"AM")}_syncPanelSelection(){if(!this.panelEl)return;const t=this.use12Hour?this.selectedHour%12||12:this.selectedHour;this._syncGridSelection("hour",t),this._syncGridSelection("minute",this.selectedMinute),this._syncGridSelection("second",this.selectedSecond);const e=this.panelEl.querySelector('[data-type="ampm"]');e&&e.querySelectorAll(".ds-timepicker__item").forEach(t=>{t.classList.toggle("is-selected","PM"===t.dataset.value==this.selectedHour>=12)}),this._updateDisplay()}_syncGridSelection(t,e){const s=this.panelEl.querySelector(`[data-type="${t}"]`);s&&s.querySelectorAll(".ds-timepicker__item").forEach(t=>{t.classList.toggle("is-selected",parseInt(t.dataset.value)===e)})}_scrollToSelection(){["hour","minute","second"].forEach(t=>{const e=this.panelEl.querySelector(`[data-type="${t}"]`);if(!e)return;const s=e.querySelector(".is-selected");s&&s.scrollIntoView({block:"center"})})}_confirmSelection(){this.input.value=this._formatTime()}hideTimepicker(t){this.panelEl&&"block"===this.panelEl.style.display&&(this.element.contains(t.target)||(this.panelEl.style.display="none",this.input.value=this._formatTime(),this.input.dispatchEvent(new Event("change")),this.onChange&&this.onChange({hour:this.selectedHour,minute:this.selectedMinute,second:this.selectedSecond,timeStr:this._formatTime()})))}resizeHandler(){this.panelEl&&"block"===this.panelEl.style.display&&this.calculatePosition()}setTime(t,e,s){this.selectedHour=Math.max(0,Math.min(23,t)),this.selectedMinute=Math.max(0,Math.min(59,e)),this.selectedSecond=Math.max(0,Math.min(59,s||0)),this.isPM=this.selectedHour>=12,this.input&&(this.input.value=this._formatTime()),this.panelEl&&this._syncPanelSelection()}getTime(){return{hour:this.selectedHour,minute:this.selectedMinute,second:this.selectedSecond}}destroy(){this.element.__kupolaInitialized&&(this.inputWrap&&this._inputWrapClickHandler&&this.inputWrap.removeEventListener("click",this._inputWrapClickHandler),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._keydownHandler&&document.removeEventListener("keydown",this._keydownHandler),this.panelEl&&(this.panelEl.remove(),this.panelEl=null),this._inputWrapClickHandler=null,this._documentClickHandler=null,this._documentClickListener=null,this._resizeHandler=null,this._resizeListener=null,this._keydownHandler=null,this.element.__kupolaInitialized=!1)}}function Ct(t,e){const s=new xt(t,e);s.init(),t._kupolaTimepicker=s}function St(t){t._kupolaTimepicker&&(t._kupolaTimepicker.destroy(),t._kupolaTimepicker=null)}rt.register("timepicker",Ct,St);class Lt{constructor(t,e={}){if(this.element=t,this.track=t.querySelector(".ds-slider__track"),this.fill=t.querySelector(".ds-slider__fill"),this.input=t.querySelector(".ds-slider__input"),this.valueEl=t.querySelector(".ds-slider__value"),this.range=e.range||t.hasAttribute("data-slider-range"),this.vertical=e.vertical||t.hasAttribute("data-slider-vertical"),this.disabled=e.disabled||t.hasAttribute("data-slider-disabled"),this.showTooltip=!1!==e.showTooltip,this.showMarks=e.marks||t.hasAttribute("data-slider-marks"),this.markStep=e.markStep||parseInt(t.getAttribute("data-slider-mark-step"))||10,this.tooltipFormat=e.tooltipFormat||(t=>t),this.onChange=e.onChange||null,this.onInput=e.onInput||null,this.inputEnd=t.querySelector(".ds-slider__input--end"),this.fillEnd=null,this.thumbStart=null,this.thumbEnd=null,this.tooltipStart=null,this.tooltipEnd=null,this.marksEl=null,this._listeners=[],this._isDragging=!1,this._activeThumb=null,!this.track||!this.fill)throw new Error("Slider: Missing required elements");this._build(),this._bindEvents(),this.updateSlider()}_build(){this.vertical&&this.element.classList.add("ds-slider--vertical"),this.disabled&&this.element.classList.add("is-disabled"),this.element.querySelector(".ds-slider__thumb")?this.thumbStart=this.element.querySelector(".ds-slider__thumb--start"):(this.thumbStart=document.createElement("div"),this.thumbStart.className="ds-slider__thumb ds-slider__thumb--start",this.thumbStart.setAttribute("role","slider"),this.thumbStart.setAttribute("tabindex",this.disabled?"-1":"0"),this.track.appendChild(this.thumbStart),this.showTooltip&&(this.tooltipStart=document.createElement("div"),this.tooltipStart.className="ds-slider__tooltip",this.thumbStart.appendChild(this.tooltipStart))),this.range&&(this.element.classList.add("ds-slider--range"),this.element.querySelector(".ds-slider__thumb--end")?this.thumbEnd=this.element.querySelector(".ds-slider__thumb--end"):(this.thumbEnd=document.createElement("div"),this.thumbEnd.className="ds-slider__thumb ds-slider__thumb--end",this.thumbEnd.setAttribute("role","slider"),this.thumbEnd.setAttribute("tabindex",this.disabled?"-1":"0"),this.track.appendChild(this.thumbEnd),this.showTooltip&&(this.tooltipEnd=document.createElement("div"),this.tooltipEnd.className="ds-slider__tooltip",this.thumbEnd.appendChild(this.tooltipEnd)))),this.showMarks&&this._renderMarks()}_renderMarks(){this.marksEl&&this.marksEl.remove(),this.marksEl=document.createElement("div"),this.marksEl.className="ds-slider__marks";const t=parseFloat(this.input?.min||0),e=parseFloat(this.input?.max||100);for(let s=t;s<=e;s+=this.markStep){const i=document.createElement("div");i.className="ds-slider__mark";const n=(s-t)/(e-t)*100;this.vertical?i.style.bottom=n+"%":i.style.left=n+"%";const r=document.createElement("span");r.className="ds-slider__mark-label",r.textContent=s,i.appendChild(r),this.marksEl.appendChild(i)}this.element.appendChild(this.marksEl)}_bindEvents(){if(this.input){const t=()=>this.updateSlider(),e=()=>this.updateSlider();this.input.addEventListener("input",t),this.input.addEventListener("change",e),this._listeners.push({el:this.input,event:"input",handler:t},{el:this.input,event:"change",handler:e})}if(this.inputEnd){const t=()=>this.updateSlider();this.inputEnd.addEventListener("input",t),this._listeners.push({el:this.inputEnd,event:"input",handler:t})}if(this.thumbStart&&this._bindThumbDrag(this.thumbStart,"start"),this.thumbEnd&&this._bindThumbDrag(this.thumbEnd,"end"),this.track){const t=t=>{this.disabled||this._handleTrackClick(t)};this.track.addEventListener("click",t),this._listeners.push({el:this.track,event:"click",handler:t})}if(this.thumbStart){const t=t=>this._handleKeyboard(t,"start");this.thumbStart.addEventListener("keydown",t),this._listeners.push({el:this.thumbStart,event:"keydown",handler:t})}if(this.thumbEnd){const t=t=>this._handleKeyboard(t,"end");this.thumbEnd.addEventListener("keydown",t),this._listeners.push({el:this.thumbEnd,event:"keydown",handler:t})}}_bindThumbDrag(t,e){const s=t=>{this.disabled||(t.preventDefault(),this._isDragging=!0,this._activeThumb=e,this.element.classList.add("is-dragging"),document.addEventListener("mousemove",i),document.addEventListener("mouseup",n),document.addEventListener("touchmove",i,{passive:!1}),document.addEventListener("touchend",n))},i=t=>{if(!this._isDragging)return;t.preventDefault();const s=t.touches?t.touches[0].clientX:t.clientX,i=t.touches?t.touches[0].clientY:t.clientY,n=this.track.getBoundingClientRect();let r;r=this.vertical?1-(i-n.top)/n.height:(s-n.left)/n.width,r=Math.max(0,Math.min(1,r));const a=parseFloat(this.input?.min||0),o=parseFloat(this.input?.max||100),l=parseFloat(this.input?.step||1);let h=a+r*(o-a);if(h=Math.round(h/l)*l,h=Math.max(a,Math.min(o,h)),"start"===e&&this.range&&this.inputEnd){const t=parseFloat(this.inputEnd.value);h>t&&(h=t)}if("end"===e&&this.range&&this.input){const t=parseFloat(this.input.value);h<t&&(h=t)}"start"===e&&this.input?this.input.value=h:"end"===e&&this.inputEnd&&(this.inputEnd.value=h),this.updateSlider(),this.onInput&&this.onInput({value:this.getValue(),percentage:r})},n=()=>{this._isDragging=!1,this._activeThumb=null,this.element.classList.remove("is-dragging"),document.removeEventListener("mousemove",i),document.removeEventListener("mouseup",n),document.removeEventListener("touchmove",i),document.removeEventListener("touchend",n),this.onChange&&this.onChange({value:this.getValue()}),this.element.dispatchEvent(new CustomEvent("kupola:slider-change",{detail:{value:this.getValue()},bubbles:!0}))};t.addEventListener("mousedown",s),t.addEventListener("touchstart",s,{passive:!1}),this._listeners.push({el:t,event:"mousedown",handler:s},{el:t,event:"touchstart",handler:s})}_handleTrackClick(t){if(t.target.classList.contains("ds-slider__thumb"))return;const e=this.track.getBoundingClientRect(),s=t.clientX,i=t.clientY;let n;n=this.vertical?1-(i-e.top)/e.height:(s-e.left)/e.width,n=Math.max(0,Math.min(1,n));const r=parseFloat(this.input?.min||0),a=parseFloat(this.input?.max||100),o=parseFloat(this.input?.step||1);let l=r+n*(a-r);if(l=Math.round(l/o)*o,this.range){const t=parseFloat(this.input?.value||0),e=parseFloat(this.inputEnd?.value||0);Math.abs(l-t)<=Math.abs(l-e)?this.input&&(this.input.value=Math.min(l,e)):this.inputEnd&&(this.inputEnd.value=Math.max(l,t))}else this.input&&(this.input.value=l);this.updateSlider()}_handleKeyboard(t,e){if(this.disabled)return;const s="start"===e?this.input:this.inputEnd;if(!s)return;const i=parseFloat(s.step||1),n=parseFloat(s.min||0),r=parseFloat(s.max||100);let a=parseFloat(s.value);switch(t.key){case"ArrowRight":case"ArrowUp":t.preventDefault(),a=Math.min(r,a+i);break;case"ArrowLeft":case"ArrowDown":t.preventDefault(),a=Math.max(n,a-i);break;case"Home":t.preventDefault(),a=n;break;case"End":t.preventDefault(),a=r;break;default:return}s.value=a,this.updateSlider(),this.onChange&&this.onChange({value:this.getValue()})}updateSlider(){const t=parseFloat(this.input?.min||0),e=parseFloat(this.input?.max||100);if(this.range&&this.inputEnd){const s=parseFloat(this.input?.value||0),i=parseFloat(this.inputEnd?.value||0),n=(s-t)/(e-t)*100,r=(i-t)/(e-t)*100;this.vertical?(this.fill.style.bottom=n+"%",this.fill.style.height=r-n+"%"):(this.fill.style.left=n+"%",this.fill.style.width=r-n+"%"),this.thumbStart&&(this.vertical?this.thumbStart.style.bottom=n+"%":this.thumbStart.style.left=n+"%"),this.thumbEnd&&(this.vertical?this.thumbEnd.style.bottom=r+"%":this.thumbEnd.style.left=r+"%"),this.tooltipStart&&(this.tooltipStart.textContent=this.tooltipFormat(s)),this.tooltipEnd&&(this.tooltipEnd.textContent=this.tooltipFormat(i)),this.valueEl&&(this.valueEl.textContent=`${this.tooltipFormat(s)} - ${this.tooltipFormat(i)}`),this.thumbStart&&this.thumbStart.setAttribute("aria-valuenow",s),this.thumbEnd&&this.thumbEnd.setAttribute("aria-valuenow",i)}else{const s=this.input?.value||0,i=(s-t)/(e-t)*100;this.vertical?this.fill.style.height=`${i}%`:this.fill.style.width=`${i}%`,this.thumbStart&&(this.vertical?this.thumbStart.style.bottom=i+"%":this.thumbStart.style.left=i+"%"),this.tooltipStart&&(this.tooltipStart.textContent=this.tooltipFormat(parseFloat(s))),this.valueEl&&(this.valueEl.textContent=this.tooltipFormat(parseFloat(s))),this.thumbStart&&this.thumbStart.setAttribute("aria-valuenow",s),this.element.setAttribute("aria-valuenow",s)}}destroy(){this._listeners?.forEach(({el:t,event:e,handler:s})=>{t.removeEventListener(e,s)}),this._listeners=null,this.marksEl&&this.marksEl.remove(),this.track=null,this.fill=null,this.input=null,this.inputEnd=null,this.valueEl=null,this.thumbStart=null,this.thumbEnd=null,this.tooltipStart=null,this.tooltipEnd=null,this.marksEl=null,this.element=null}setValue(t,e){this.input&&(this.input.value=t),void 0!==e&&this.inputEnd&&(this.inputEnd.value=e),this.updateSlider()}getValue(){return this.range&&this.inputEnd?[parseFloat(this.input?.value||0),parseFloat(this.inputEnd?.value||0)]:parseFloat(this.input?.value||0)}enable(){this.disabled=!1,this.element.classList.remove("is-disabled")}disable(){this.disabled=!0,this.element.classList.add("is-disabled")}}function Dt(t,e){if(!t.__kupolaInitialized)try{const s=new Lt(t,e);t.__kupolaInstance=s,t.__kupolaInitialized=!0}catch(t){console.error("[Slider] Error initializing:",t)}}function Mt(t){if(!t.__kupolaInitialized||!t.__kupolaInstance)return;t.__kupolaInstance.destroy(),t.__kupolaInstance=null,t.__kupolaInitialized=!1}rt.register("slider",Dt,Mt);class Ht{constructor(t,e={}){this.element=t,this.track=t.querySelector(".ds-carousel__track"),this.items=t.querySelectorAll(".ds-carousel__item"),this.prevBtn=t.querySelector(".ds-carousel__prev"),this.nextBtn=t.querySelector(".ds-carousel__next"),this.indicators=t.querySelectorAll(".ds-carousel__indicator"),this.autoBtn=t.querySelector(".ds-carousel__auto"),this.mode=e.mode||t.getAttribute("data-carousel-mode")||"slide",this.vertical=e.vertical||t.hasAttribute("data-carousel-vertical"),this.autoPlay=!1!==e.autoPlay,this.interval=e.interval||parseInt(t.getAttribute("data-carousel-interval"))||3e3,this.transitionDuration=e.transitionDuration||parseInt(t.getAttribute("data-carousel-duration"))||500,this.loop=!1!==e.loop,this.pauseOnHover=!1!==e.pauseOnHover,this.swipe=!1!==e.swipe,this.swipeThreshold=e.swipeThreshold||50,this.keyboardNav=e.keyboardNav||t.hasAttribute("data-carousel-keyboard"),this.onChange=e.onChange||null,this.currentIndex=0,this.totalItems=this.items.length,this.autoPlayTimer=null,this.isAutoPlaying=!1,this.isTransitioning=!1,this.touchStartX=0,this.touchStartY=0,this.touchDeltaX=0,this.touchDeltaY=0,this.isSwiping=!1,this._mouseEnterHandler=()=>{this.pauseOnHover&&this.stopAutoPlay()},this._mouseLeaveHandler=()=>{this.pauseOnHover&&this.autoPlay&&this.startAutoPlay()},this.init()}init(){this._prevClickHandler=()=>this.prev(),this._nextClickHandler=()=>this.next(),this._autoClickHandler=()=>this.toggleAutoPlay(),this._indicatorClickHandlers=[],this.prevBtn&&this.prevBtn.addEventListener("click",this._prevClickHandler),this.nextBtn&&this.nextBtn.addEventListener("click",this._nextClickHandler),this.indicators.forEach((t,e)=>{const s=()=>this.goTo(e);this._indicatorClickHandlers.push(s),t.addEventListener("click",s)}),this.autoBtn&&this.autoBtn.addEventListener("click",this._autoClickHandler),this.swipe&&(this._touchStartHandler=t=>this._handleTouchStart(t),this._touchMoveHandler=t=>this._handleTouchMove(t),this._touchEndHandler=()=>this._handleTouchEnd(),this.element.addEventListener("touchstart",this._touchStartHandler,{passive:!0}),this.element.addEventListener("touchmove",this._touchMoveHandler,{passive:!1}),this.element.addEventListener("touchend",this._touchEndHandler)),this.keyboardNav&&(this._keydownHandler=t=>{this.element.contains(document.activeElement)&&("ArrowLeft"===t.key||"ArrowUp"===t.key?(t.preventDefault(),this.prev()):"ArrowRight"!==t.key&&"ArrowDown"!==t.key||(t.preventDefault(),this.next()))},this.element.addEventListener("keydown",this._keydownHandler)),"fade"===this.mode&&this.element.classList.add("ds-carousel--fade"),this.vertical&&this.element.classList.add("ds-carousel--vertical"),this.track&&(this.track.style.transitionDuration=this.transitionDuration+"ms"),this.updateIndicators(),this.autoPlay&&this.startAutoPlay(),this.element.addEventListener("mouseenter",this._mouseEnterHandler),this.element.addEventListener("mouseleave",this._mouseLeaveHandler)}goTo(t){if(this.isTransitioning)return;if(t<0||t>=this.totalItems)return;this.isTransitioning=!0;const e=this.currentIndex;if(this.currentIndex=t,"fade"===this.mode)this.items.forEach((e,s)=>{e.style.opacity=s===t?"1":"0",e.style.zIndex=s===t?"1":"0"});else if(this.vertical){const e=100*-t;this.track.style.transform=`translateY(${e}%)`}else{const e=100*-t;this.track.style.transform=`translateX(${e}%)`}this.updateIndicators(),setTimeout(()=>{this.isTransitioning=!1},this.transitionDuration),this.onChange&&this.onChange({index:t,prevIndex:e,total:this.totalItems}),this.element.dispatchEvent(new CustomEvent("kupola:carousel-change",{detail:{index:t,prevIndex:e,total:this.totalItems},bubbles:!0}))}prev(){this.currentIndex>0?this.goTo(this.currentIndex-1):this.loop&&this.goTo(this.totalItems-1)}next(){this.currentIndex<this.totalItems-1?this.goTo(this.currentIndex+1):this.loop&&this.goTo(0)}updateIndicators(){this.indicators.forEach((t,e)=>{t.classList.toggle("is-active",e===this.currentIndex)}),this.loop||(this.prevBtn&&(this.prevBtn.disabled=0===this.currentIndex),this.nextBtn&&(this.nextBtn.disabled=this.currentIndex===this.totalItems-1))}startAutoPlay(){this.totalItems<=1||(this.stopAutoPlay(),this.isAutoPlaying=!0,this.autoBtn&&this.autoBtn.classList.add("is-active"),this.autoPlayTimer=setInterval(()=>this.next(),this.interval))}stopAutoPlay(){this.autoPlayTimer&&(clearInterval(this.autoPlayTimer),this.autoPlayTimer=null),this.isAutoPlaying=!1,this.autoBtn&&this.autoBtn.classList.remove("is-active")}toggleAutoPlay(){this.isAutoPlaying?this.stopAutoPlay():this.startAutoPlay()}_handleTouchStart(t){this.touchStartX=t.touches[0].clientX,this.touchStartY=t.touches[0].clientY,this.touchDeltaX=0,this.touchDeltaY=0,this.isSwiping=!0,this.isAutoPlaying&&(this.stopAutoPlay(),this._wasAutoPlaying=!0)}_handleTouchMove(t){if(!this.isSwiping)return;this.touchDeltaX=t.touches[0].clientX-this.touchStartX,this.touchDeltaY=t.touches[0].clientY-this.touchStartY;const e=Math.abs(this.touchDeltaX);e>Math.abs(this.touchDeltaY)&&e>10&&t.preventDefault()}_handleTouchEnd(){if(!this.isSwiping)return;this.isSwiping=!1;const t=Math.abs(this.touchDeltaX),e=Math.abs(this.touchDeltaY);t>this.swipeThreshold&&t>e&&(this.touchDeltaX>0?this.prev():this.next()),this._wasAutoPlaying&&(this.startAutoPlay(),this._wasAutoPlaying=!1)}destroy(){this.stopAutoPlay(),this.element.removeEventListener("mouseenter",this._mouseEnterHandler),this.element.removeEventListener("mouseleave",this._mouseLeaveHandler),this.prevBtn&&this._prevClickHandler&&this.prevBtn.removeEventListener("click",this._prevClickHandler),this.nextBtn&&this._nextClickHandler&&this.nextBtn.removeEventListener("click",this._nextClickHandler),this.autoBtn&&this._autoClickHandler&&this.autoBtn.removeEventListener("click",this._autoClickHandler),this.indicators.forEach((t,e)=>{const s=this._indicatorClickHandlers[e];s&&t.removeEventListener("click",s)}),this._touchStartHandler&&this.element.removeEventListener("touchstart",this._touchStartHandler),this._touchMoveHandler&&this.element.removeEventListener("touchmove",this._touchMoveHandler),this._touchEndHandler&&this.element.removeEventListener("touchend",this._touchEndHandler),this._keydownHandler&&this.element.removeEventListener("keydown",this._keydownHandler),this._prevClickHandler=null,this._nextClickHandler=null,this._autoClickHandler=null,this._indicatorClickHandlers=null}}function It(t,e){if(t.__kupolaInitialized)return;const s=new Ht(t,e);t.__kupolaInstance=s,t.__kupolaInitialized=!0}function Tt(t){if(!t.__kupolaInitialized||!t.__kupolaInstance)return;t.__kupolaInstance.destroy(),t.__kupolaInstance=null,t.__kupolaInitialized=!1}rt.register("carousel",It,Tt);class At{constructor(t,e={}){this.element=t,this.mask=t.querySelector(".ds-drawer-mask"),this.drawerEl=t.querySelector(".ds-drawer"),this.placement=e.placement||t.getAttribute("data-drawer-placement")||"right",this.width=e.width||t.getAttribute("data-drawer-width")||"400px",this.height=e.height||t.getAttribute("data-drawer-height")||"400px",this.escClose=!1!==e.escClose,this.maskClosable=!1!==e.maskClosable,this.showMask=!1!==e.showMask,this.onOpen=e.onOpen||null,this.onClose=e.onClose||null,this.onBeforeClose=e.onBeforeClose||null,this._keydownHandler=null,this._bindEvents()}_bindEvents(){const t=this.mask?.querySelector(".ds-drawer__close"),e=this.mask?.querySelector(".ds-drawer__footer .ds-btn--ghost"),s=this.mask?.querySelector(".ds-drawer__footer .ds-btn--brand");this.closeDrawer=()=>{if(this.onBeforeClose){if(!1===this.onBeforeClose())return}this.mask&&this.mask.classList.remove("is-visible"),this.drawerEl&&this.drawerEl.classList.remove("is-visible"),document.body.style.overflow="",this.onClose&&this.onClose(),this.element.dispatchEvent(new CustomEvent("kupola:drawer-close",{bubbles:!0}))},this.handleMaskClick=t=>{this.maskClosable&&t.target===this.mask&&this.closeDrawer()},this.mask&&this.mask.addEventListener("click",this.handleMaskClick),t&&t.addEventListener("click",this.closeDrawer),e&&e.addEventListener("click",this.closeDrawer),s&&s.addEventListener("click",this.closeDrawer),this.escClose&&(this._keydownHandler=t=>{"Escape"===t.key&&this.drawerEl?.classList.contains("is-visible")&&this.closeDrawer()},document.addEventListener("keydown",this._keydownHandler)),this._listeners=[{el:this.mask,event:"click",handler:this.handleMaskClick},{el:t,event:"click",handler:this.closeDrawer},{el:e,event:"click",handler:this.closeDrawer},{el:s,event:"click",handler:this.closeDrawer}].filter(t=>t.el)}_applyPlacement(){this.drawerEl&&(this.drawerEl.classList.remove("ds-drawer--right","ds-drawer--left","ds-drawer--top","ds-drawer--bottom"),this.drawerEl.classList.add(`ds-drawer--${this.placement}`),"left"===this.placement||"right"===this.placement?this.drawerEl.style.width=this.width:this.drawerEl.style.height=this.height,!this.showMask&&this.mask&&(this.mask.style.background="transparent",this.mask.style.pointerEvents="none",this.drawerEl.style.boxShadow="0 0 24px rgba(0,0,0,0.15)"))}destroy(){this._listeners?.forEach(({el:t,event:e,handler:s})=>{t.removeEventListener(e,s)}),this._keydownHandler&&document.removeEventListener("keydown",this._keydownHandler),this._listeners=null,this.mask=null,this.drawerEl=null,this.element=null}open(){this._applyPlacement(),this.mask&&this.mask.classList.add("is-visible"),this.drawerEl&&this.drawerEl.classList.add("is-visible"),document.body.style.overflow="hidden",this.onOpen&&this.onOpen(),this.element.dispatchEvent(new CustomEvent("kupola:drawer-open",{bubbles:!0}))}close(){this.closeDrawer()}isOpen(){return this.drawerEl?.classList.contains("is-visible")||!1}}function zt(t,e){if(t.__kupolaInitialized)return;const s=new At(t,e);t.__kupolaInstance=s,t.__kupolaInitialized=!0}function $t(t){if(!t.__kupolaInitialized||!t.__kupolaInstance)return;t.__kupolaInstance.destroy(),t.__kupolaInstance=null,t.__kupolaInitialized=!1}rt.register("drawer",zt,$t);class qt{constructor(t,e={}){this.element=t,this.mask=t.querySelector(".ds-modal-mask"),this.modal=t.querySelector(".ds-modal"),this.closeBtn=t.querySelector(".ds-modal__close"),this.fullscreen=e.fullscreen||t.hasAttribute("data-modal-fullscreen"),this.closableOnMask=!1!==e.closableOnMask,this.escClose=!1!==e.escClose,this.width=e.width||t.getAttribute("data-modal-width")||"",this.center=!1!==e.center,this.onBeforeOpen=e.onBeforeOpen||null,this.onBeforeClose=e.onBeforeClose||null,this.onOpened=e.onOpened||null,this.onClosed=e.onClosed||null,this._isOpen=!1,this._keydownHandler=t=>{this.escClose&&"Escape"===t.key&&this.isVisible()&&this.close()},this._closeBtnClickHandler=()=>this.close(),this._maskClickHandler=t=>{this.closableOnMask&&t.target===this.mask&&this.close()},this.init()}init(){this.closeBtn&&this.closeBtn.addEventListener("click",this._closeBtnClickHandler),this.mask&&this.mask.addEventListener("click",this._maskClickHandler),document.addEventListener("keydown",this._keydownHandler),this.fullscreen&&this.modal&&this.modal.classList.add("ds-modal--fullscreen"),this.width&&this.modal&&(this.modal.style.maxWidth=this.width)}open(){if(this.onBeforeOpen){if(!1===this.onBeforeOpen())return}this.mask&&(this.mask.classList.add("is-visible"),this.mask.classList.add("ds-modal-fade-enter"),requestAnimationFrame(()=>{this.mask.classList.add("ds-modal-fade-enter-active")})),this.modal&&(this.modal.classList.add("ds-modal-zoom-enter"),requestAnimationFrame(()=>{this.modal.classList.add("ds-modal-zoom-enter-active")})),this._isOpen||(qt._openCount=(qt._openCount||0)+1,this._isOpen=!0),document.body.style.overflow="hidden",this.onOpened&&setTimeout(()=>this.onOpened(),300),this.element.dispatchEvent(new CustomEvent("kupola:modal-open",{bubbles:!0}))}close(){if(this.onBeforeClose){if(!1===this.onBeforeClose())return}this.mask&&(this.mask.classList.remove("ds-modal-fade-enter-active"),this.mask.classList.add("ds-modal-fade-leave-active")),this.modal&&(this.modal.classList.remove("ds-modal-zoom-enter-active"),this.modal.classList.add("ds-modal-zoom-leave-active")),setTimeout(()=>{this.mask&&this.mask.classList.remove("is-visible","ds-modal-fade-enter","ds-modal-fade-leave-active"),this.modal&&this.modal.classList.remove("ds-modal-zoom-enter","ds-modal-zoom-leave-active")},300),this._isOpen&&(qt._openCount=Math.max(0,(qt._openCount||0)-1),this._isOpen=!1,0===qt._openCount&&(document.body.style.overflow="")),this.onClosed&&setTimeout(()=>this.onClosed(),300),this.element.dispatchEvent(new CustomEvent("kupola:modal-close",{bubbles:!0}))}toggleFullscreen(){this.fullscreen=!this.fullscreen,this.modal&&this.modal.classList.toggle("ds-modal--fullscreen",this.fullscreen)}isVisible(){return this.mask&&this.mask.classList.contains("is-visible")}destroy(){document.removeEventListener("keydown",this._keydownHandler),this.closeBtn&&this.closeBtn.removeEventListener("click",this._closeBtnClickHandler),this.mask&&this.mask.removeEventListener("click",this._maskClickHandler),this._isOpen&&(qt._openCount=Math.max(0,(qt._openCount||0)-1),this._isOpen=!1,0===qt._openCount&&(document.body.style.overflow=""))}}function Pt(t={}){const{title:e="",content:s="",html:i=!1,width:n="480px",fullscreen:r=!1,showCancel:a=!0,showConfirm:o=!0,confirmText:l="OK",cancelText:h="Cancel",confirmClass:c="ds-btn--brand",cancelClass:d="ds-btn--ghost",closable:u=!0,maskClosable:p=!0,onConfirm:m,onCancel:g,onOpen:_,onClose:y,footer:f=null}=t,v=document.createElement("div");v.className="ds-modal-container";let b="";null!==f&&("string"==typeof f?b=`<div class="ds-modal__footer">${f}</div>`:(o||a)&&(b=`<div class="ds-modal__footer">\n ${a?`<button class="ds-btn ${d}" data-modal-cancel>${h}</button>`:""}\n ${o?`<button class="ds-btn ${c}" data-modal-confirm>${l}</button>`:""}\n </div>`)),v.innerHTML=`\n <div class="ds-modal-mask">\n <div class="ds-modal${r?" ds-modal--fullscreen":""}" style="${r?"":"max-width: "+n}">\n <div class="ds-modal__header">\n <span class="ds-modal__title"></span>\n ${u?'<button class="ds-modal__close" aria-label="Close">\n <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">\n <path d="M18 6L6 18M6 6l12 12"/>\n </svg>\n </button>':""}\n </div>\n <div class="ds-modal__body"></div>\n ${b}\n </div>\n </div>\n `,document.body.appendChild(v);const k=new qt(v,{fullscreen:r,closableOnMask:p}),E=v.querySelector(".ds-modal__title");E&&(E.textContent=e);const w=v.querySelector(".ds-modal__body");w&&(i?w.innerHTML=s:w.textContent=s);const x=v.querySelector("[data-modal-confirm]"),C=v.querySelector("[data-modal-cancel]");let S=!1;const L=async()=>{if(m){x.disabled=!0,x.classList.add("is-loading");try{if(!1===await m())return x.disabled=!1,void x.classList.remove("is-loading")}catch(t){return x.disabled=!1,void x.classList.remove("is-loading")}}S=!0,k.close()},D=()=>{g&&g(),k.close()};x&&x.addEventListener("click",L),C&&C.addEventListener("click",D);const M=k.close.bind(k);return k.close=()=>{M(),setTimeout(()=>{x&&x.removeEventListener("click",L),C&&C.removeEventListener("click",D),k.destroy(),v.remove(),y&&y(S)},300)},k.open(),_&&setTimeout(()=>_(),50),k}function Nt(t){if(t.__kupolaInitialized)return;const e=new qt(t);t.__kupolaInstance=e,t.__kupolaInitialized=!0}function Ft(t){if(!t.__kupolaInitialized||!t.__kupolaInstance)return;t.__kupolaInstance.destroy(),t.__kupolaInstance=null,t.__kupolaInitialized=!1}qt._openCount=0,rt.register("modal",Nt,Ft);const Ot={normal:function(t){this.show({...t,type:"normal"})},success:function(t){this.show({...t,type:"success"})},error:function(t){this.show({...t,type:"error"})},warning:function(t){this.show({...t,type:"warning"})},info:function(t){this.show({...t,type:"info"})},show:function(t){const{title:e,message:s,type:i="normal",duration:n=4e3}=t,r=document.createElement("div");r.className=`ds-notification__item ds-notification__item--${i}`;r.innerHTML=`\n <div class="ds-notification__icon ds-notification__icon--${i}">${{normal:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="12" y1="16" x2="12" y2="12"/><line x1="12" y1="8" x2="12.01" y2="8"/></svg>',success:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="20 6 9 17 4 12"/></svg>',error:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="15" y1="9" x2="9" y2="15"/><line x1="9" y1="9" x2="15" y2="15"/></svg>',warning:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"/><line x1="12" y1="9" x2="12" y2="13"/><line x1="12" y1="17" x2="12.01" y2="17"/></svg>',info:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="12" y1="16" x2="12" y2="12"/><line x1="12" y1="8" x2="12.01" y2="8"/></svg>'}[i]}</div>\n <div class="ds-notification__content">\n ${e?'<div class="ds-notification__title"></div>':""}\n ${s?'<div class="ds-notification__message"></div>':""}\n </div>\n <button class="ds-notification__close">\n <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>\n </button>\n `,e&&(r.querySelector(".ds-notification__title").textContent=e),s&&(r.querySelector(".ds-notification__message").textContent=s);let a=document.querySelector(".ds-notification");a||(a=document.createElement("div"),a.className="ds-notification",document.body.appendChild(a)),a.appendChild(r),setTimeout(()=>{r.classList.add("is-visible")},10),r.querySelector(".ds-notification__close").addEventListener("click",()=>{r.classList.remove("is-visible"),r.classList.add("is-exiting"),setTimeout(()=>r.remove(),300)}),n>0&&setTimeout(()=>{r.classList.remove("is-visible"),r.classList.add("is-exiting"),setTimeout(()=>r.remove(),300)},n)}};const Bt={normal:function(t,e={}){this.show(t,"normal",e)},success:function(t,e={}){this.show(t,"success",e)},error:function(t,e={}){this.show(t,"error",e)},warning:function(t,e={}){this.show(t,"warning",e)},info:function(t,e={}){this.show(t,"info",e)},show:function(t,e="normal",s={}){const{duration:i=3e3}=s,n=document.createElement("div");n.className=`ds-message__item ds-message__item--${e}`;n.innerHTML=`\n <div class="ds-message__icon ds-message__icon--${e}">${{normal:'<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="12" y1="16" x2="12" y2="12"/><line x1="12" y1="8" x2="12.01" y2="8"/></svg>',success:'<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="20 6 9 17 4 12"/></svg>',error:'<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="15" y1="9" x2="9" y2="15"/><line x1="9" y1="9" x2="15" y2="15"/></svg>',warning:'<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"/><line x1="12" y1="9" x2="12" y2="13"/><line x1="12" y1="17" x2="12.01" y2="17"/></svg>',info:'<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="12" y1="16" x2="12" y2="12"/><line x1="12" y1="8" x2="12.01" y2="8"/></svg>'}[e]}</div>\n <div class="ds-message__content"></div>\n `,n.querySelector(".ds-message__content").textContent=t;let r=document.querySelector(".ds-message");r||(r=document.createElement("div"),r.className="ds-message",document.body.appendChild(r)),r.appendChild(n),setTimeout(()=>{n.classList.add("is-visible")},10),i>0&&setTimeout(()=>{n.classList.remove("is-visible"),n.classList.add("is-exiting"),setTimeout(()=>n.remove(),300)},i)}};function Rt(t){return t?t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"):""}class Vt{constructor(t){this.element=t,this.dropzone=t.querySelector(".ds-fileupload__dropzone"),this.input=t.querySelector(".ds-fileupload__input"),this.list=t.querySelector(".ds-fileupload__list"),this.progress=t.querySelector(".ds-fileupload__preview"),this.files=[],this.maxSize=parseInt(t.getAttribute("data-max-size"))||0,this.maxCount=parseInt(t.getAttribute("data-max-count"))||0,this._listeners=[],this.init()}init(){this.bindEvents()}bindEvents(){const t=t=>{t.target===this.input||this.input.contains(t.target)||this.input.click()},e=t=>{const e=Array.from(t.target.files);this.addFiles(e),t.target.value=""},s=t=>{t.preventDefault(),t.stopPropagation(),this.dropzone.classList.add("is-dragging")},i=t=>{t.preventDefault(),t.stopPropagation(),this.dropzone.classList.remove("is-dragging")},n=t=>{t.preventDefault(),t.stopPropagation(),this.dropzone.classList.remove("is-dragging");const e=Array.from(t.dataTransfer.files);this.addFiles(e)};this.dropzone.addEventListener("click",t),this.input.addEventListener("change",e),this.dropzone.addEventListener("dragover",s),this.dropzone.addEventListener("dragleave",i),this.dropzone.addEventListener("drop",n),this._listeners.push({el:this.dropzone,event:"click",handler:t},{el:this.input,event:"change",handler:e},{el:this.dropzone,event:"dragover",handler:s},{el:this.dropzone,event:"dragleave",handler:i},{el:this.dropzone,event:"drop",handler:n})}addFiles(t){t.forEach(t=>{this.maxCount>0&&this.files.length>=this.maxCount?this.showError(`Maximum ${this.maxCount} files allowed`):this.isValidFile(t)&&(this.files.push(t),this.renderFileItem(t),this.showPreview(t))}),this.dispatchChange()}isValidFile(t){const e=this.input.getAttribute("accept");if(e&&""!==e){const s=e.split(",").map(t=>t.trim()),i=t.type,n=t.name.toLowerCase();if(!s.some(t=>t.startsWith(".")?n.endsWith(t):!t.includes("/")||(t.endsWith("/*")?i.startsWith(t.replace("/*","")):i===t)))return this.showError(`File type not allowed: ${t.type}`),!1}return!(this.maxSize>0&&t.size>this.maxSize)||(this.showError(`File size exceeds ${this.formatSize(this.maxSize)}`),!1)}renderFileItem(t){const e=document.createElement("div");e.className="ds-fileupload__item",e.dataset.filename=t.name;const s=this.getFileIcon(t.type);e.innerHTML=`\n <div class="ds-fileupload__icon" style="width: 24px; height: 24px; border-radius: 4px;">\n ${s}\n </div>\n <span class="ds-fileupload__filename">${this.truncateFilename(Rt(t.name))}</span>\n <span class="ds-fileupload__size">${this.formatSize(t.size)}</span>\n <button class="ds-fileupload__remove" type="button" aria-label="Remove file">\n <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">\n <path d="M18 6L6 18"/>\n <path d="M6 6l12 12"/>\n </svg>\n </button>\n `;const i=e.querySelector(".ds-fileupload__remove"),n=()=>{this.removeFile(t,e)};i.addEventListener("click",n),this._listeners.push({el:i,event:"click",handler:n}),this.list||(this.list=document.createElement("div"),this.list.className="ds-fileupload__list",this.element.appendChild(this.list)),this.list.appendChild(e)}getFileIcon(t){return t.startsWith("image/")?'<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"/><circle cx="8.5" cy="8.5" r="1.5"/><polyline points="21 15 16 10 5 21"/></svg>':t.startsWith("video/")?'<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polygon points="23 7 16 12 23 17 23 7"/><rect x="1" y="5" width="15" height="14" rx="2" ry="2"/></svg>':t.startsWith("audio/")?'<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polygon points="11 5 6 9 2 9 2 15 6 15 11 19 11 5"/><path d="M19.07 4.93a10 10 0 0 1 0 14.14M15.54 8.46a5 5 0 0 1 0 7.07"/></svg>':t.includes("pdf")||t.includes("document")||t.includes("text")?'<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><polyline points="14 2 14 8 20 8"/><line x1="16" y1="13" x2="8" y2="13"/><line x1="16" y1="17" x2="8" y2="17"/><polyline points="10 9 9 9 8 9"/></svg>':t.includes("zip")||t.includes("archive")?'<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="11" width="18" height="11" rx="2" ry="2"/><path d="M16 11V7a4 4 0 0 0-8 0v4"/><polyline points="10 14 8 16 6 14"/></svg>':'<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><polyline points="14 2 14 8 20 8"/></svg>'}truncateFilename(t,e=20){if(t.length<=e)return t;const s=t.substring(t.lastIndexOf("."));return t.substring(0,t.lastIndexOf(".")).substring(0,e-s.length-3)+"..."+s}formatSize(t){if(0===t)return"0 B";const e=Math.floor(Math.log(t)/Math.log(1024));return parseFloat((t/Math.pow(1024,e)).toFixed(1))+" "+["B","KB","MB","GB"][e]}removeFile(t,e){this.files=this.files.filter(e=>e!==t),e&&e.remove(),0===this.files.length&&this.list&&(this.list.remove(),this.list=null),this.dispatchChange()}clearFiles(){this.files=[],this.list&&(this.list.remove(),this.list=null),this.preview&&(this.preview.innerHTML=""),this.clearError(),this.dispatchChange()}showError(t){this.clearError(),this.dropzone.classList.add("is-error");const e=document.createElement("div");e.className="ds-fileupload__error",e.textContent=t,e.setAttribute("role","alert"),e.setAttribute("aria-live","polite"),this.dropzone.appendChild(e),setTimeout(()=>{this.clearError()},5e3)}clearError(){this.dropzone.classList.remove("is-error");const t=this.dropzone.querySelector(".ds-fileupload__error");t&&t.remove()}showPreview(t){if(!t.type.startsWith("image/"))return;this.preview||(this.preview=document.createElement("div"),this.preview.className="ds-fileupload__preview",this.element.insertBefore(this.preview,this.list||null));const e=new FileReader;e.onload=e=>{const s=document.createElement("div");s.className="ds-fileupload__preview-item",s.innerHTML=`\n <img src="${e.target.result}" alt="${Rt(t.name)}">\n <button class="ds-fileupload__preview-remove" type="button" aria-label="Remove preview">\n <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">\n <path d="M18 6L6 18"/>\n <path d="M6 6l12 12"/>\n </svg>\n </button>\n `;const i=s.querySelector(".ds-fileupload__preview-remove"),n=()=>{this.removeFile(t,this.list?.querySelector(`[data-filename="${t.name}"]`)),s.remove(),this.preview&&0===this.preview.children.length&&(this.preview.remove(),this.preview=null)};i.addEventListener("click",n),this._listeners.push({el:i,event:"click",handler:n}),this.preview.appendChild(s)},e.readAsDataURL(t)}updateProgress(t){this.progress||(this.progress=document.createElement("div"),this.progress.className="ds-fileupload__progress",this.element.insertBefore(this.progress,this.list||null)),this.progress.style.display="block";const e=this.progress.querySelector(".ds-fileupload__progress-bar")||document.createElement("div");e.className="ds-fileupload__progress-bar",e.style.width=`${t}%`,this.progress.querySelector(".ds-fileupload__progress-bar")||this.progress.appendChild(e),t>=100&&setTimeout(()=>{this.progress&&(this.progress.remove(),this.progress=null)},500)}simulateUpload(t){this.updateProgress(0);const e=100;let s=0;Math.max(1,Math.floor(t.size/e));const i=setInterval(()=>{s++;const t=Math.min(100,Math.floor(s/e*100));this.updateProgress(t),s>=e&&(clearInterval(i),this.updateProgress(100))},Math.max(50,Math.floor(50)));return i}getFiles(){return[...this.files]}dispatchChange(){this.element.dispatchEvent(new CustomEvent("kupola:fileupload-change",{detail:{files:this.getFiles(),count:this.files.length}}))}destroy(){this._listeners.forEach(({el:t,event:e,handler:s})=>{t.removeEventListener(e,s)}),this._listeners=null,this.files=[],this.dropzone=null,this.input=null,this.list=null,this.progress=null,this.preview=null,this.element=null}}function Kt(t){if(t.__kupolaInitialized)return;const e=new Vt(t);t.__kupolaInstance=e,t.__kupolaInitialized=!0}function jt(t){if(!t.__kupolaInitialized||!t.__kupolaInstance)return;t.__kupolaInstance.destroy(),t.__kupolaInstance=null,t.__kupolaInitialized=!1}rt.register("fileupload",Kt,jt);class Wt{constructor(t,e={}){this.element=t,this.headers=[],this._listeners=[],this.accordion=e.accordion||t.hasAttribute("data-collapse-accordion"),this.animationDuration=e.animationDuration||parseInt(t.getAttribute("data-collapse-duration"))||300,this.disabledItems=e.disabledItems||[],this.defaultExpanded=e.defaultExpanded||[],this._init()}_init(){this.element.querySelectorAll(".ds-collapse__header").forEach((t,e)=>{const s=t.closest(".ds-collapse__item"),i=t.nextElementSibling;if(!s||!i||!i.classList.contains("ds-collapse__content"))return;const n=s.hasAttribute("data-collapse-disabled")||this.disabledItems.includes(e);n&&s.classList.add("is-disabled");let r=s.classList.contains("is-active");("all"===this.defaultExpanded||Array.isArray(this.defaultExpanded)&&this.defaultExpanded.includes(e))&&(r=!0),r?(s.classList.add("is-active"),i.style.height=i.scrollHeight+"px",i.style.overflow="hidden",setTimeout(()=>{s.classList.contains("is-active")&&(i.style.height="auto",i.style.overflow="visible")},this.animationDuration)):(s.classList.remove("is-active"),i.style.height="0",i.style.overflow="hidden");const a=()=>{if(n)return;const t=s.classList.contains("is-active");this.accordion&&!t&&this.headers.forEach((t,s)=>{s!==e&&t.item.classList.contains("is-active")&&this._collapseItem(t)}),t?this._collapseItem({item:s,content:i}):this._expandItem({item:s,content:i}),this.element.dispatchEvent(new CustomEvent("kupola:collapse-toggle",{detail:{index:e,expanded:!t,item:s},bubbles:!0}))};t.addEventListener("click",a),this.headers.push({header:t,item:s,content:i,clickHandler:a,isDisabled:n}),this._listeners.push({el:t,event:"click",handler:a})})}_expandItem(t){const{item:e,content:s}=t;s.style.overflow="hidden",s.style.height="0",s.offsetHeight,s.style.transition=`height ${this.animationDuration}ms ease`,s.style.height=s.scrollHeight+"px",e.classList.add("is-active");const i=()=>{s.removeEventListener("transitionend",i),e.classList.contains("is-active")&&(s.style.height="auto",s.style.overflow="visible"),s.style.transition=""};s.addEventListener("transitionend",i),this._listeners.push({el:s,event:"transitionend",handler:i})}_collapseItem(t){const{item:e,content:s}=t;s.style.overflow="hidden",s.style.height=s.scrollHeight+"px",s.offsetHeight,s.style.transition=`height ${this.animationDuration}ms ease`,s.style.height="0",e.classList.remove("is-active");const i=()=>{s.removeEventListener("transitionend",i),s.style.transition=""};s.addEventListener("transitionend",i),this._listeners.push({el:s,event:"transitionend",handler:i})}destroy(){this._listeners.forEach(({el:t,event:e,handler:s})=>{t.removeEventListener(e,s)}),this._listeners=null,this.headers=null,this.element=null}toggle(t){const e=this.headers[t];e&&!e.isDisabled&&e.clickHandler()}expand(t){const e=this.headers[t];!e||e.item.classList.contains("is-active")||e.isDisabled||(this.accordion&&this.headers.forEach((e,s)=>{s!==t&&e.item.classList.contains("is-active")&&this._collapseItem(e)}),this._expandItem(e))}collapse(t){const e=this.headers[t];e&&e.item.classList.contains("is-active")&&this._collapseItem(e)}expandAll(){this.accordion||this.headers.forEach((t,e)=>{t.item.classList.contains("is-active")||t.isDisabled||this._expandItem(t)})}collapseAll(){this.headers.forEach(t=>{t.item.classList.contains("is-active")&&this._collapseItem(t)})}getExpandedIndices(){return this.headers.map((t,e)=>t.item.classList.contains("is-active")?e:-1).filter(t=>t>=0)}disable(t){this.headers[t]&&(this.headers[t].isDisabled=!0,this.headers[t].item.classList.add("is-disabled"))}enable(t){this.headers[t]&&(this.headers[t].isDisabled=!1,this.headers[t].item.classList.remove("is-disabled"))}}function Ut(t,e){if(t.__kupolaInitialized)return;const s=new Wt(t,e);t.__kupolaInstance=s,t.__kupolaInitialized=!0}function Yt(t){if(!t.__kupolaInitialized||!t.__kupolaInstance)return;t.__kupolaInstance.destroy(),t.__kupolaInstance=null,t.__kupolaInitialized=!1}rt.register("collapse",Ut,Yt);class Xt{constructor(t,e={}){this.element=t,this.trigger=t.querySelector(".ds-color-picker__trigger"),this.panel=t.querySelector(".ds-color-picker__panel"),this.valueSpan=t.querySelector(".ds-color-picker__value"),this.customInput=t.querySelector(".ds-color-picker__input"),this.scope=`colorpicker-${Math.random().toString(36).substr(2,9)}`,this.options=e,this.value=e.value||"#007bff",this.showAlpha=!1!==e.showAlpha,this.mode=e.mode||"hex",this.previousColors=e.previousColors||this._getStoredColors(),this.previousColorsLimit=e.previousColorsLimit||12,this._triggerClickHandler=null,this._documentClickHandler=null,this._documentClickListener=null,this._colorClickHandler=null,this._inputInputHandler=null,this._alphaChangeHandler=null,this._modeChangeHandler=null,this._hueChangeHandler=null,this._saturationChangeHandler=null,this._valueChangeHandler=null,this.hue=210,this.saturation=100,this.brightness=50,this.alpha=100,this._colorStringToHSB(this.value)}_getStoredColors(){try{const t=localStorage.getItem("kupola-color-picker-previous");return t?JSON.parse(t):[]}catch{return[]}}_storeColors(){try{localStorage.setItem("kupola-color-picker-previous",JSON.stringify(this.previousColors))}catch{}}_addPreviousColor(t){const e=this.previousColors.indexOf(t);-1!==e&&this.previousColors.splice(e,1),this.previousColors.unshift(t),this.previousColors=this.previousColors.slice(0,this.previousColorsLimit),this._storeColors(),this._renderPreviousColors()}_colorStringToHSB(t){const e=t.replace(/^#/,""),s=parseInt(e.substring(0,2),16)/255,i=parseInt(e.substring(2,4),16)/255,n=parseInt(e.substring(4,6),16)/255,r=8===e.length?parseInt(e.substring(6,8),16)/255:1,a=Math.max(s,i,n),o=Math.min(s,i,n);let l=0,h=0,c=a;const d=a-o;if(h=0===a?0:d/a,a!==o)switch(a){case s:l=((i-n)/d+(i<n?6:0))/6;break;case i:l=((n-s)/d+2)/6;break;case n:l=((s-i)/d+4)/6}this.hue=Math.round(360*l),this.saturation=Math.round(100*h),this.brightness=Math.round(100*c),this.alpha=Math.round(100*r)}_HSBToColorString(t,e,s,i=1){e/=100,s/=100,i/=100;const n=e=>(e+t/60)%6,r=t=>s*(1-e*Math.max(0,Math.min(n(t),4-n(t),1))),a=Math.round(255*r(5)),o=Math.round(255*r(3)),l=Math.round(255*r(1));if("rgb"===this.mode)return i<1?`rgba(${a}, ${o}, ${l}, ${i.toFixed(2)})`:`rgb(${a}, ${o}, ${l})`;if("hsl"===this.mode)return i<1?`hsla(${t}, ${Math.round(100*e)}%, ${Math.round(100*s)}%, ${i.toFixed(2)})`:`hsl(${t}, ${Math.round(100*e)}%, ${Math.round(100*s)}%)`;const h=`#${a.toString(16).padStart(2,"0")}${o.toString(16).padStart(2,"0")}${l.toString(16).padStart(2,"0")}`;return i<1?h+Math.round(255*i).toString(16).padStart(2,"0"):h}_renderPreviousColors(){const t=this.panel.querySelector(".ds-color-picker__previous");t&&(t.innerHTML="",this.previousColors.forEach(e=>{const s=document.createElement("button");s.className="ds-color-picker__color",s.style.backgroundColor=e,s.setAttribute("data-color",e),s.addEventListener("click",this._colorClickHandler),t.appendChild(s)}))}_renderColorPanel(){const t=this.panel.querySelector(".ds-color-picker__hue"),e=this.panel.querySelector(".ds-color-picker__sv"),s=this.panel.querySelector(".ds-color-picker__alpha");t&&(t.value=this.hue,t.style.background="linear-gradient(to right, hsl(0,100%,50%), hsl(60,100%,50%), hsl(120,100%,50%), hsl(180,100%,50%), hsl(240,100%,50%), hsl(300,100%,50%), hsl(360,100%,50%))"),e&&(e.style.background=`hsl(${this.hue}, 100%, 50%)`),s&&this.showAlpha&&(s.value=this.alpha,s.style.background=`linear-gradient(to right, transparent, ${this._HSBToColorString(this.hue,this.saturation,this.brightness,1)})`)}init(){if(!this.trigger||!this.panel)return;if(this.element.__kupolaInitialized)return;this._triggerClickHandler=t=>{t.stopPropagation(),this.togglePanel()},this._colorClickHandler=t=>{const e=t.currentTarget.getAttribute("data-color");this.updateColor(e),this.hidePanel()},this._inputInputHandler=t=>{const e=t.target.value;this._isValidColor(e)&&this.updateColor(e)},this._alphaChangeHandler=t=>{this.alpha=parseInt(t.target.value),this._updateFromHSB()},this._modeChangeHandler=t=>{const e=t.currentTarget;this.mode=e.getAttribute("data-mode"),this.panel.querySelectorAll(".ds-color-picker__mode-btn").forEach(t=>t.classList.remove("is-active")),e.classList.add("is-active"),this._updateDisplay()},this._hueChangeHandler=t=>{this.hue=parseInt(t.target.value),this._renderColorPanel(),this._updateFromHSB()},this._saturationChangeHandler=t=>{const e=t.currentTarget.getBoundingClientRect(),s=t.clientX-e.left,i=t.clientY-e.top;this.saturation=Math.round(s/e.width*100),this.brightness=Math.round(100*(1-i/e.height)),this._updateFromHSB()},this._documentClickHandler=t=>{this.element.contains(t.target)||this.hidePanel()},this.trigger.addEventListener("click",this._triggerClickHandler),this.panel.querySelectorAll(".ds-color-picker__color").forEach(t=>{t.addEventListener("click",this._colorClickHandler),t._colorPickerColorHandler=this._colorClickHandler}),this.customInput&&(this.customInput.addEventListener("input",this._inputInputHandler),this.customInput._colorPickerInputHandler=this._inputInputHandler);const t=this.panel.querySelector(".ds-color-picker__hue");t&&t.addEventListener("input",this._hueChangeHandler);const e=this.panel.querySelector(".ds-color-picker__sv");e&&(e.addEventListener("click",this._saturationChangeHandler),e.addEventListener("mousemove",t=>{1===t.buttons&&this._saturationChangeHandler(t)}));const s=this.panel.querySelector(".ds-color-picker__alpha");s&&this.showAlpha&&s.addEventListener("input",this._alphaChangeHandler),this.panel.querySelectorAll(".ds-color-picker__mode-btn").forEach(t=>{t.addEventListener("click",this._modeChangeHandler),t.getAttribute("data-mode")===this.mode&&t.classList.add("is-active")}),this._documentClickListener=mt.on(document,"click",this._documentClickHandler,{scope:this.scope}),this._renderPreviousColors(),this._renderColorPanel(),this._updateDisplay(),this.element.__kupolaInitialized=!0}_isValidColor(t){const e=(new Option).style;return e.color=t,""!==e.color}_updateFromHSB(){const t=this._HSBToColorString(this.hue,this.saturation,this.brightness,this.alpha);this.value=t,this._updateDisplay(),this._addPreviousColor(t),this.element.dispatchEvent(new CustomEvent("kupola:color-picker-change",{detail:{color:this.value,hsb:{h:this.hue,s:this.saturation,b:this.brightness,a:this.alpha},mode:this.mode}}))}_updateDisplay(){this.trigger.style.backgroundColor=this.value,this.valueSpan&&(this.valueSpan.textContent=this.value.toUpperCase()),this.customInput&&(this.customInput.value=this.value),this._renderColorPanel()}togglePanel(){this.panel.classList.toggle("is-visible")}hidePanel(){this.panel.classList.remove("is-visible")}showPanel(){this.panel.classList.add("is-visible")}updateColor(t){this._isValidColor(t)&&(this.value=t,this._colorStringToHSB(t),this._updateDisplay(),this._addPreviousColor(t),this.element.dispatchEvent(new CustomEvent("kupola:color-picker-change",{detail:{color:this.value,hsb:{h:this.hue,s:this.saturation,b:this.brightness,a:this.alpha},mode:this.mode}})))}setValue(t){this.updateColor(t)}getValue(){return this.value}setMode(t){"hex"!==t&&"rgb"!==t&&"hsl"!==t||(this.mode=t,this._updateDisplay())}getMode(){return this.mode}setAlpha(t){this.alpha=Math.max(0,Math.min(100,t)),this._updateFromHSB()}getAlpha(){return this.alpha}destroy(){if(!this.element.__kupolaInitialized)return;this.trigger&&this._triggerClickHandler&&this.trigger.removeEventListener("click",this._triggerClickHandler),this.panel&&this.panel.querySelectorAll(".ds-color-picker__color").forEach(t=>{t._colorPickerColorHandler&&t.removeEventListener("click",t._colorPickerColorHandler)}),this.customInput&&this._inputInputHandler&&this.customInput.removeEventListener("input",this._inputInputHandler);const t=this.panel?.querySelector(".ds-color-picker__hue");t&&this._hueChangeHandler&&t.removeEventListener("input",this._hueChangeHandler);const e=this.panel?.querySelector(".ds-color-picker__sv");e&&this._saturationChangeHandler&&(e.removeEventListener("click",this._saturationChangeHandler),e.removeEventListener("mousemove",this._saturationChangeHandler));const s=this.panel?.querySelector(".ds-color-picker__alpha");s&&this._alphaChangeHandler&&s.removeEventListener("input",this._alphaChangeHandler),this.panel?.querySelectorAll(".ds-color-picker__mode-btn").forEach(t=>{t.removeEventListener("click",this._modeChangeHandler)}),this._documentClickListener&&this._documentClickListener.unsubscribe?this._documentClickListener.unsubscribe():this._documentClickHandler&&document.removeEventListener("click",this._documentClickHandler),this._documentClickHandler=null,this._documentClickListener=null,this._triggerClickHandler=null,this._colorClickHandler=null,this._inputInputHandler=null,this._alphaChangeHandler=null,this._modeChangeHandler=null,this._hueChangeHandler=null,this._saturationChangeHandler=null,this._valueChangeHandler=null,this.element.__kupolaInitialized=!1}}function Jt(t,e){const s=new Xt(t,e);s.init(),t._kupolaColorPicker=s}function Zt(t){t._kupolaColorPicker&&(t._kupolaColorPicker.destroy(),t._kupolaColorPicker=null)}rt.register("color-picker",Jt,Zt);class Gt{constructor(t,e={}){if(this.element=t,this.titleEl=t.querySelector(".ds-calendar__title"),this.daysEl=t.querySelector(".ds-calendar__days"),this.prevBtn=t.querySelector(".ds-calendar__nav--prev"),this.nextBtn=t.querySelector(".ds-calendar__nav--next"),this.todayBtn=t.querySelector(".ds-calendar__nav--today"),this._listeners=[],!this.titleEl||!this.daysEl)throw new Error("Calendar: Missing required elements");this.currentDate=new Date,this.selectedDate=e.selectedDate?new Date(e.selectedDate):null,this.rangeStart=e.rangeStart?new Date(e.rangeStart):null,this.rangeEnd=e.rangeEnd?new Date(e.rangeEnd):null,this.isRangeMode=e.rangeMode||t.hasAttribute("data-calendar-range"),this.viewMode=e.viewMode||t.getAttribute("data-calendar-view")||"month",this.events=e.events||[],this.i18n=e.i18n||{months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],weekdays:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortWeekdays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],today:"Today",selectRangeStart:"Select start date",selectRangeEnd:"Select end date"},this.onSelect=e.onSelect||null,this.onRangeSelect=e.onRangeSelect||null,this.onChange=e.onChange||null,this.onEventClick=e.onEventClick||null,this._init()}_init(){this.render();const t=()=>{"week"===this.viewMode?this.currentDate.setDate(this.currentDate.getDate()-7):this.currentDate.setMonth(this.currentDate.getMonth()-1),this.render(),this._emitChange()},e=()=>{"week"===this.viewMode?this.currentDate.setDate(this.currentDate.getDate()+7):this.currentDate.setMonth(this.currentDate.getMonth()+1),this.render(),this._emitChange()},s=()=>{this.currentDate=new Date,this.render(),this._emitChange()};this.prevBtn&&(this.prevBtn.addEventListener("click",t),this._listeners.push({el:this.prevBtn,event:"click",handler:t})),this.nextBtn&&(this.nextBtn.addEventListener("click",e),this._listeners.push({el:this.nextBtn,event:"click",handler:e})),this.todayBtn&&(this.todayBtn.addEventListener("click",s),this._listeners.push({el:this.todayBtn,event:"click",handler:s}))}_emitChange(){const t={date:this.currentDate,selectedDate:this.selectedDate,rangeStart:this.rangeStart,rangeEnd:this.rangeEnd,viewMode:this.viewMode};this.onChange&&this.onChange(t),this.element.dispatchEvent(new CustomEvent("kupola:calendar-change",{detail:t,bubbles:!0}))}_formatDate(t){return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}`}_isSameDay(t,e){return!(!t||!e)&&this._formatDate(t)===this._formatDate(e)}_isDateInRange(t){if(!this.rangeStart||!this.rangeEnd)return!1;const e=this._formatDate(t),s=this._formatDate(this.rangeStart),i=this._formatDate(this.rangeEnd);return e>=s&&e<=i}_isRangeStart(t){return this._isSameDay(t,this.rangeStart)}_isRangeEnd(t){return this._isSameDay(t,this.rangeEnd)}_getEventsForDate(t){const e=this._formatDate(t);return this.events.filter(t=>{const s=t.date||t.start,i=t.end;if(!s)return!1;const n="string"==typeof s?s:this._formatDate(s);if(!i)return n===e;const r="string"==typeof i?i:this._formatDate(i);return e>=n&&e<=r})}render(){const t=this.currentDate.getFullYear(),e=this.currentDate.getMonth();"week"===this.viewMode?this._renderWeekView(t,e):this._renderMonthView(t,e)}_renderMonthView(t,e){this.titleEl.textContent=`${t} ${this.i18n.months[e]}`;const s=new Date(t,e,1).getDay(),i=new Date(t,e+1,0).getDate();this.daysEl.innerHTML="";for(let t=0;t<s;t++){const t=document.createElement("span");t.className="ds-calendar__day ds-calendar__day--empty",this.daysEl.appendChild(t)}const n=new Date,r=this._formatDate(n);for(let s=1;s<=i;s++){const i=new Date(t,e,s),n=document.createElement("button");n.className="ds-calendar__day",n.textContent=s;const a=this._formatDate(i);a===r&&n.classList.add("is-today"),this._isSameDay(i,this.selectedDate)&&n.classList.add("is-selected"),this.isRangeMode&&(this._isRangeStart(i)&&n.classList.add("is-range-start"),this._isRangeEnd(i)&&n.classList.add("is-range-end"),this._isDateInRange(i)&&n.classList.add("is-in-range"));const o=this._getEventsForDate(i);if(o.length>0){n.classList.add("has-events");const t=document.createElement("span");t.className="ds-calendar__day-event",t.style.backgroundColor=o[0].color||"#007bff",n.appendChild(t)}const l=()=>{this.element.querySelectorAll(".ds-calendar__day").forEach(t=>t.classList.remove("is-selected")),n.classList.add("is-selected"),this.isRangeMode?!this.rangeStart||this.rangeEnd&&!this._isSameDay(i,this.rangeEnd)?(this.rangeStart=i,this.rangeEnd=null):this.rangeStart&&!this.rangeEnd&&(i<this.rangeStart?(this.rangeEnd=this.rangeStart,this.rangeStart=i):this.rangeEnd=i,this.onRangeSelect&&this.onRangeSelect({start:this.rangeStart,end:this.rangeEnd}),this.element.dispatchEvent(new CustomEvent("kupola:calendar-range-select",{detail:{start:this.rangeStart,end:this.rangeEnd},bubbles:!0}))):(this.selectedDate=i,this.onSelect&&this.onSelect({date:i,dateStr:a}),this.element.dispatchEvent(new CustomEvent("kupola:calendar-select",{detail:{date:i,dateStr:a},bubbles:!0}))),o.forEach(t=>{this.onEventClick&&this.onEventClick(t,i)}),this.render()};n.addEventListener("click",l),this._listeners.push({el:n,event:"click",handler:l}),this.daysEl.appendChild(n)}}_renderWeekView(t,e){const s=this.currentDate.getDay(),i=new Date(t,e,this.currentDate.getDate()-s+(0===s?-6:1)),n=i,r=new Date(i);r.setDate(i.getDate()+6),this.titleEl.textContent=`${this.i18n.shortMonths[n.getMonth()]} ${n.getDate()} - ${this.i18n.shortMonths[r.getMonth()]} ${r.getDate()} ${t}`,this.daysEl.innerHTML="";const a=new Date,o=this._formatDate(a);for(let t=0;t<7;t++){const e=new Date(i);e.setDate(i.getDate()+t);const s=document.createElement("button");s.className="ds-calendar__day ds-calendar__day--week";const n=document.createElement("span");n.className="ds-calendar__day-header",n.textContent=this.i18n.shortWeekdays[e.getDay()],s.appendChild(n);const r=document.createElement("span");r.className="ds-calendar__day-number",r.textContent=e.getDate(),s.appendChild(r);const a=this._formatDate(e);a===o&&s.classList.add("is-today"),this._isSameDay(e,this.selectedDate)&&s.classList.add("is-selected");const l=this._getEventsForDate(e);if(l.length>0){const t=document.createElement("span");t.className="ds-calendar__day-events",l.slice(0,3).forEach(e=>{const s=document.createElement("span");s.className="ds-calendar__day-event",s.style.backgroundColor=e.color||"#007bff",t.appendChild(s)}),s.appendChild(t)}const h=()=>{this.element.querySelectorAll(".ds-calendar__day").forEach(t=>t.classList.remove("is-selected")),s.classList.add("is-selected"),this.selectedDate=e,this.onSelect&&this.onSelect({date:e,dateStr:a}),this.element.dispatchEvent(new CustomEvent("kupola:calendar-select",{detail:{date:e,dateStr:a},bubbles:!0})),this.render()};s.addEventListener("click",h),this._listeners.push({el:s,event:"click",handler:h}),this.daysEl.appendChild(s)}}destroy(){this._listeners.forEach(({el:t,event:e,handler:s})=>{t.removeEventListener(e,s)}),this._listeners=null,this.titleEl=null,this.daysEl=null,this.prevBtn=null,this.nextBtn=null,this.todayBtn=null,this.element=null}setDate(t){this.currentDate=new Date(t),this.render(),this._emitChange()}getDate(){return this.currentDate}setSelectedDate(t){this.selectedDate=t?new Date(t):null,this.render()}getSelectedDate(){return this.selectedDate}setRange(t,e){this.rangeStart=t?new Date(t):null,this.rangeEnd=e?new Date(e):null,this.render(),this.onRangeSelect&&this.rangeStart&&this.rangeEnd&&this.onRangeSelect({start:this.rangeStart,end:this.rangeEnd})}getRange(){return{start:this.rangeStart,end:this.rangeEnd}}setEvents(t){this.events=t||[],this.render()}addEvent(t){this.events.push(t),this.render()}removeEvent(t){this.events=this.events.filter(e=>e.id!==t),this.render()}setViewMode(t){"month"!==t&&"week"!==t||(this.viewMode=t,this.render(),this._emitChange())}getViewMode(){return this.viewMode}setI18n(t){this.i18n={...this.i18n,...t},this.render()}prevMonth(){this.currentDate.setMonth(this.currentDate.getMonth()-1),this.render(),this._emitChange()}nextMonth(){this.currentDate.setMonth(this.currentDate.getMonth()+1),this.render(),this._emitChange()}prevWeek(){this.currentDate.setDate(this.currentDate.getDate()-7),this.render(),this._emitChange()}nextWeek(){this.currentDate.setDate(this.currentDate.getDate()+7),this.render(),this._emitChange()}goToToday(){this.currentDate=new Date,this.render(),this._emitChange()}goToDate(t){this.currentDate=new Date(t),this.render(),this._emitChange()}toggleRangeMode(){this.isRangeMode=!this.isRangeMode,this.rangeStart=null,this.rangeEnd=null,this.render(),this._emitChange()}}function Qt(t,e){if(!t.__kupolaInitialized)try{const s=new Gt(t,e);t.__kupolaInstance=s,t.__kupolaInitialized=!0}catch(t){console.error("[Calendar] Error initializing:",t)}}function te(t){if(!t.__kupolaInitialized||!t.__kupolaInstance)return;t.__kupolaInstance.destroy(),t.__kupolaInstance=null,t.__kupolaInitialized=!1}rt.register("calendar",Qt,te);class ee{constructor(t,e={}){this.element=t,this.input=t.querySelector(".ds-dynamic-tags__input"),this._listeners=[],this.maxCount=e.maxCount||parseInt(t.getAttribute("data-dynamic-tags-max"))||1/0,this.allowDuplicates=!1!==e.allowDuplicates,this.color=e.color||t.getAttribute("data-dynamic-tags-color")||"default",this.init()}init(){this.bindEvents()}bindEvents(){if(this.element.querySelectorAll(".ds-dynamic-tags__tag").forEach(t=>{const e=t.querySelector(".ds-dynamic-tags__remove");if(e){const s=e=>{e.stopPropagation(),t.remove(),this.dispatchChange()};e.addEventListener("click",s),this._listeners.push({el:e,event:"click",handler:s})}}),this.input){const t=()=>{const t=this.input.value.trim();if(!t)return;if(!this.allowDuplicates&&this.hasTag(t))return void(this.input.value="");if(this.getTags().length>=this.maxCount)return this.input.value="",void this.element.dispatchEvent(new CustomEvent("kupola:dynamic-tags-max",{detail:{maxCount:this.maxCount}}));const e=this.createTag(t);this.element.insertBefore(e,this.input),this.input.value="",this.input.focus(),this.dispatchChange()},e=e=>{"Enter"===e.key&&(e.preventDefault(),e.stopPropagation(),t())};this.input.addEventListener("keydown",e),this._listeners.push({el:this.input,event:"keydown",handler:e});const s=()=>{this.input.focus()};this.element.addEventListener("click",s),this._listeners.push({el:this.element,event:"click",handler:s})}}createTag(t){const e=document.createElement("span");e.className=`ds-dynamic-tags__tag ds-dynamic-tags__tag--${this.color}`;const s=document.createTextNode(t);e.appendChild(s);const i=document.createElement("button");i.className="ds-dynamic-tags__remove",i.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>',e.appendChild(i);const n=t=>{t.stopPropagation(),e.remove(),this.dispatchChange()};return i.addEventListener("click",n),this._listeners.push({el:i,event:"click",handler:n}),e}hasTag(t){const e=this.element.querySelectorAll(".ds-dynamic-tags__tag");for(const s of e)if(s.textContent.trim()===t)return!0;return!1}addTag(t,e){if(!t||!this.input)return;if(!this.allowDuplicates&&this.hasTag(t))return;if(this.getTags().length>=this.maxCount)return void this.element.dispatchEvent(new CustomEvent("kupola:dynamic-tags-max",{detail:{maxCount:this.maxCount}}));const s=this.createTag(t);if(e){const t=["ds-dynamic-tags__tag--default","ds-dynamic-tags__tag--primary","ds-dynamic-tags__tag--success","ds-dynamic-tags__tag--warning","ds-dynamic-tags__tag--danger","ds-dynamic-tags__tag--info"];t.forEach(t=>s.classList.remove(t)),t.includes(`ds-dynamic-tags__tag--${e}`)&&s.classList.add(`ds-dynamic-tags__tag--${e}`)}this.element.insertBefore(s,this.input),this.dispatchChange()}removeTag(t){const e=this.element.querySelectorAll(".ds-dynamic-tags__tag")[t];e&&(e.remove(),this.dispatchChange())}removeTagByValue(t){const e=this.element.querySelectorAll(".ds-dynamic-tags__tag");for(const s of e)if(s.textContent.trim()===t)return s.remove(),void this.dispatchChange()}getTags(){const t=[];return this.element.querySelectorAll(".ds-dynamic-tags__tag").forEach(e=>{t.push(e.textContent.trim())}),t}getTagsWithColor(){const t=[];return this.element.querySelectorAll(".ds-dynamic-tags__tag").forEach(e=>{const s=Array.from(e.classList).find(t=>t.startsWith("ds-dynamic-tags__tag--"))?.replace("ds-dynamic-tags__tag--","")||"default";t.push({value:e.textContent.trim(),color:s})}),t}clearTags(){this.element.querySelectorAll(".ds-dynamic-tags__tag").forEach(t=>{t.remove()}),this.dispatchChange()}setTags(t){this.clearTags(),t.forEach(t=>{"string"==typeof t?this.addTag(t):t&&"object"==typeof t&&t.value&&this.addTag(t.value,t.color)})}setMaxCount(t){this.maxCount=t,this.element.setAttribute("data-dynamic-tags-max",t)}getMaxCount(){return this.maxCount}setAllowDuplicates(t){this.allowDuplicates=t}isAllowDuplicates(){return this.allowDuplicates}setColor(t){["default","primary","success","warning","danger","info"].includes(t)&&(this.color=t,this.element.setAttribute("data-dynamic-tags-color",t))}getColor(){return this.color}dispatchChange(){this.element.dispatchEvent(new CustomEvent("kupola:dynamic-tags-change",{detail:{tags:this.getTags(),tagsWithColor:this.getTagsWithColor(),count:this.getTags().length,maxCount:this.maxCount}}))}destroy(){this._listeners.forEach(({el:t,event:e,handler:s})=>{t.removeEventListener(e,s)}),this._listeners=null,this.input=null,this.element=null}}function se(t,e){if(t.__kupolaInitialized)return;const s=new ee(t,e);t.__kupolaInstance=s,t.__kupolaInitialized=!0}function ie(t){if(!t.__kupolaInitialized||!t.__kupolaInstance)return;t.__kupolaInstance.destroy(),t.__kupolaInstance=null,t.__kupolaInitialized=!1}rt.register("dynamic-tags",se,ie);class ne{constructor(t={}){this.images=t.images||[],this.currentIndex=t.currentIndex||0,this.overlay=null,this.closeHandler=this.close.bind(this),this.keyHandler=this.handleKeydown.bind(this),this.clickHandler=this.handleOverlayClick.bind(this),this.zoom=1,this.rotation=0,this.zoomStep=t.zoomStep||.2,this.minZoom=t.minZoom||.5,this.maxZoom=t.maxZoom||3,this.init()}init(){this.createOverlay()}createOverlay(){this.overlay=document.createElement("div"),this.overlay.className="ds-image-preview-overlay",this.overlay.innerHTML='\n <button class="ds-image-preview__close" type="button" aria-label="Close preview">\n <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">\n <path d="M18 6L6 18"/>\n <path d="M6 6l12 12"/>\n </svg>\n </button>\n <div class="ds-image-preview__nav">\n <button class="ds-image-preview__nav-btn ds-image-preview__nav-btn--prev" type="button" aria-label="Previous image">\n <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">\n <polyline points="15 18 9 12 15 6"/>\n </svg>\n </button>\n <button class="ds-image-preview__nav-btn ds-image-preview__nav-btn--next" type="button" aria-label="Next image">\n <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">\n <polyline points="9 18 15 12 9 6"/>\n </svg>\n </button>\n </div>\n <div class="ds-image-preview__toolbar">\n <button class="ds-image-preview__toolbar-btn" type="button" aria-label="Zoom in" data-action="zoom-in">\n <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">\n <line x1="12" y1="5" x2="12" y2="19"/>\n <line x1="5" y1="12" x2="19" y2="12"/>\n </svg>\n </button>\n <button class="ds-image-preview__toolbar-btn" type="button" aria-label="Zoom out" data-action="zoom-out">\n <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">\n <line x1="5" y1="12" x2="19" y2="12"/>\n </svg>\n </button>\n <button class="ds-image-preview__toolbar-btn" type="button" aria-label="Reset zoom" data-action="zoom-reset">\n <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">\n <path d="M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0z"/>\n <line x1="12" y1="5" x2="12" y2="19"/>\n <line x1="5" y1="12" x2="19" y2="12"/>\n </svg>\n </button>\n <button class="ds-image-preview__toolbar-btn" type="button" aria-label="Rotate left" data-action="rotate-left">\n <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">\n <polyline points="1 4 1 10 7 10"/>\n <path d="M3.51 15a9 9 0 1 0 2.13-9.36L1 10"/>\n </svg>\n </button>\n <button class="ds-image-preview__toolbar-btn" type="button" aria-label="Rotate right" data-action="rotate-right">\n <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">\n <polyline points="23 4 23 10 17 10"/>\n <path d="M20.49 15a9 9 0 1 1-2.12-9.36L23 10"/>\n </svg>\n </button>\n </div>\n <div class="ds-image-preview__content">\n <img src="" alt="" />\n </div>\n <div class="ds-image-preview__info">\n <div class="ds-image-preview__title"></div>\n <div class="ds-image-preview__meta"></div>\n </div>\n <div class="ds-image-preview__indicators"></div>\n ',document.body.appendChild(this.overlay),this.bindEvents()}bindEvents(){const t=this.overlay.querySelector(".ds-image-preview__close"),e=this.overlay.querySelector(".ds-image-preview__nav-btn--prev"),s=this.overlay.querySelector(".ds-image-preview__nav-btn--next");this._prevHandler=()=>this.prev(),this._nextHandler=()=>this.next(),t.addEventListener("click",this.closeHandler),e.addEventListener("click",this._prevHandler),s.addEventListener("click",this._nextHandler);this.overlay.querySelectorAll(".ds-image-preview__toolbar-btn").forEach(t=>{t.addEventListener("click",e=>{const s=t.getAttribute("data-action");this.handleToolbarAction(s)})});this.overlay.querySelector(".ds-image-preview__content").addEventListener("wheel",t=>{t.preventDefault(),t.deltaY<0?this.zoomIn():this.zoomOut()},{passive:!1})}handleToolbarAction(t){switch(t){case"zoom-in":this.zoomIn();break;case"zoom-out":this.zoomOut();break;case"zoom-reset":this.resetZoom();break;case"rotate-left":this.rotate(-90);break;case"rotate-right":this.rotate(90)}}zoomIn(){this.zoom=Math.min(this.maxZoom,this.zoom+this.zoomStep),this.updateTransform()}zoomOut(){this.zoom=Math.max(this.minZoom,this.zoom-this.zoomStep),this.updateTransform()}resetZoom(){this.zoom=1,this.rotation=0,this.updateTransform()}rotate(t){this.rotation+=t,this.updateTransform()}setRotation(t){this.rotation=t,this.updateTransform()}setZoom(t){this.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,t)),this.updateTransform()}updateTransform(){const t=this.overlay.querySelector(".ds-image-preview__content img");t&&(t.style.transform=`scale(${this.zoom}) rotate(${this.rotation}deg)`)}handleKeydown(t){if(this.overlay.classList.contains("is-visible"))switch(t.key){case"Escape":this.close();break;case"ArrowLeft":this.prev();break;case"ArrowRight":this.next();break;case"+":case"=":t.preventDefault(),this.zoomIn();break;case"-":case"_":t.preventDefault(),this.zoomOut();break;case"0":t.preventDefault(),this.resetZoom();break;case"[":t.preventDefault(),this.rotate(-90);break;case"]":t.preventDefault(),this.rotate(90)}}handleOverlayClick(t){t.target===this.overlay&&this.close()}show(t,e=0){this.images=t,this.currentIndex=Math.min(Math.max(e,0),t.length-1),this.resetZoom(),this.render(),this.overlay.classList.add("is-visible"),document.addEventListener("keydown",this.keyHandler),this.overlay.addEventListener("click",this.clickHandler),document.body.style.overflow="hidden"}close(){this.overlay.classList.remove("is-visible"),document.removeEventListener("keydown",this.keyHandler),this.overlay.removeEventListener("click",this.clickHandler),document.body.style.overflow=""}prev(){this.currentIndex>0&&(this.currentIndex--,this.resetZoom(),this.render())}next(){this.currentIndex<this.images.length-1&&(this.currentIndex++,this.resetZoom(),this.render())}goTo(t){t>=0&&t<this.images.length&&(this.currentIndex=t,this.resetZoom(),this.render())}render(){const t=this.overlay.querySelector(".ds-image-preview__content img"),e=this.overlay.querySelector(".ds-image-preview__title"),s=this.overlay.querySelector(".ds-image-preview__meta"),i=this.overlay.querySelector(".ds-image-preview__indicators"),n=this.overlay.querySelector(".ds-image-preview__nav-btn--prev"),r=this.overlay.querySelector(".ds-image-preview__nav-btn--next"),a=this.images[this.currentIndex];t.src=a.src,t.alt=a.alt||"",e.textContent=a.title||"",s.textContent=a.meta||`${this.currentIndex+1} / ${this.images.length}`,n.disabled=0===this.currentIndex,r.disabled=this.currentIndex===this.images.length-1,i.innerHTML=this.images.map((t,e)=>`\n <button class="ds-image-preview__indicator${e===this.currentIndex?" is-active":""}" type="button" data-index="${e}" aria-label="Go to image ${e+1}"></button>\n `).join(""),i.querySelectorAll(".ds-image-preview__indicator").forEach(t=>{const e=()=>{this.goTo(parseInt(t.dataset.index))};t.addEventListener("click",e),t._clickHandler=e})}destroy(){this.close();const t=this.overlay?.querySelector(".ds-image-preview__indicators");t&&t.querySelectorAll(".ds-image-preview__indicator").forEach(t=>{t._clickHandler&&t.removeEventListener("click",t._clickHandler)});const e=this.overlay?.querySelector(".ds-image-preview__close"),s=this.overlay?.querySelector(".ds-image-preview__nav-btn--prev"),i=this.overlay?.querySelector(".ds-image-preview__nav-btn--next");e&&e.removeEventListener("click",this.closeHandler),s&&this._prevHandler&&s.removeEventListener("click",this._prevHandler),i&&this._nextHandler&&i.removeEventListener("click",this._nextHandler),this.overlay&&this.overlay.parentNode&&this.overlay.parentNode.removeChild(this.overlay)}}let re=null;class ae{constructor(t,e={}){this.element=t,this.closeBtn=t.querySelector(".ds-tag__close"),this.checkbox=t.querySelector(".ds-tag__checkbox"),this.editInput=t.querySelector(".ds-tag__input"),this._listeners=[],this.color=e.color||t.getAttribute("data-tag-color")||"default",this.size=e.size||t.getAttribute("data-tag-size")||"default",this.checkable=e.checkable||t.hasAttribute("data-tag-checkable"),this.checked=e.checked||t.hasAttribute("data-tag-checked"),this.editable=e.editable||t.hasAttribute("data-tag-editable"),this.maxLength=e.maxLength||parseInt(t.getAttribute("data-tag-maxlength"))||50,this.init()}init(){if(this._applyStyles(),this.closeBtn){const t=t=>{t.stopPropagation(),this.element.dispatchEvent(new CustomEvent("kupola:tag-remove",{detail:{tag:this.element,content:this.getContent()},bubbles:!0})),this.element.remove()};this.closeBtn.addEventListener("click",t),this._listeners.push({el:this.closeBtn,event:"click",handler:t})}if(this.checkable){const t=t=>{t.target!==this.checkbox&&t.target!==this.closeBtn&&this.toggleChecked()};if(this.element.addEventListener("click",t),this._listeners.push({el:this.element,event:"click",handler:t}),this.checkbox){const t=()=>{this.toggleChecked()};this.checkbox.addEventListener("change",t),this._listeners.push({el:this.checkbox,event:"change",handler:t})}}if(this.editable){const t=()=>{this.startEdit()};if(this.element.addEventListener("dblclick",t),this._listeners.push({el:this.element,event:"dblclick",handler:t}),this.editInput){const t=()=>{this.endEdit()},e=t=>{"Enter"===t.key?this.endEdit():"Escape"===t.key&&this.cancelEdit()};this.editInput.addEventListener("blur",t),this.editInput.addEventListener("keydown",e),this._listeners.push({el:this.editInput,event:"blur",handler:t}),this._listeners.push({el:this.editInput,event:"keydown",handler:e})}}}_applyStyles(){const t=["ds-tag--default","ds-tag--primary","ds-tag--success","ds-tag--warning","ds-tag--danger","ds-tag--info"],e=["ds-tag--default","ds-tag--small","ds-tag--large"];t.forEach(t=>this.element.classList.remove(t)),e.forEach(t=>this.element.classList.remove(t)),t.includes(`ds-tag--${this.color}`)&&this.element.classList.add(`ds-tag--${this.color}`),e.includes(`ds-tag--${this.size}`)&&this.element.classList.add(`ds-tag--${this.size}`),this.checkable&&this.element.classList.add("ds-tag--checkable"),this.checked&&this.element.classList.add("is-checked"),this.editable&&this.element.classList.add("ds-tag--editable")}setContent(t){this.editable&&this.editInput&&(this.editInput.value=t);const e=[];this.element.childNodes.forEach(t=>{t.nodeType===Node.TEXT_NODE&&e.push(t)}),e.forEach(t=>t.remove());const s=this.element.querySelector(".ds-tag__close"),i=this.element.querySelector(".ds-tag__checkbox"),n=this.element.querySelector(".ds-tag__input"),r=s||i||n||null;this.element.insertBefore(document.createTextNode(t),r),this.element.dispatchEvent(new CustomEvent("kupola:tag-change",{detail:{tag:this.element,content:t},bubbles:!0}))}getContent(){return this.editable&&this.editInput&&this.element.classList.contains("is-editing")?this.editInput.value:this.element.textContent.trim()}setColor(t){["default","primary","success","warning","danger","info"].includes(t)&&(this.color=t,this.element.setAttribute("data-tag-color",t),this._applyStyles())}getColor(){return this.color}setSize(t){["default","small","large"].includes(t)&&(this.size=t,this.element.setAttribute("data-tag-size",t),this._applyStyles())}getSize(){return this.size}toggleChecked(){this.checked=!this.checked,this.element.setAttribute("data-tag-checked",this.checked?"true":"false"),this._applyStyles(),this.checkbox&&(this.checkbox.checked=this.checked),this.element.dispatchEvent(new CustomEvent("kupola:tag-check",{detail:{tag:this.element,checked:this.checked,content:this.getContent()},bubbles:!0}))}setChecked(t){this.checked=t,this.element.setAttribute("data-tag-checked",t?"true":"false"),this._applyStyles(),this.checkbox&&(this.checkbox.checked=t)}isChecked(){return this.checked}startEdit(){if(!this.editable)return;const t=this.getContent();if(this.editInput)this.editInput.value=t;else{const e=document.createElement("input");e.type="text",e.className="ds-tag__input",e.value=t,e.maxLength=this.maxLength,this.editInput=e;const s=this.element.querySelector(".ds-tag__close");this.element.insertBefore(e,s);const i=()=>this.endEdit(),n=t=>{"Enter"===t.key?this.endEdit():"Escape"===t.key&&this.cancelEdit()};e.addEventListener("blur",i),e.addEventListener("keydown",n),this._listeners.push({el:e,event:"blur",handler:i}),this._listeners.push({el:e,event:"keydown",handler:n})}this.element.classList.add("is-editing"),setTimeout(()=>{this.editInput&&(this.editInput.focus(),this.editInput.select())},0)}endEdit(){if(!this.editable||!this.element.classList.contains("is-editing"))return;const t=this.editInput.value.trim();this.element.classList.remove("is-editing"),t&&t!==this.getContent()&&(this.setContent(t),this.element.dispatchEvent(new CustomEvent("kupola:tag-edit",{detail:{tag:this.element,content:t},bubbles:!0})))}cancelEdit(){this.editable&&this.element.classList.contains("is-editing")&&(this.element.classList.remove("is-editing"),this.editInput&&(this.editInput.value=this.getContent()))}setEditable(t){this.editable=t,t?this.element.setAttribute("data-tag-editable",""):this.element.removeAttribute("data-tag-editable"),this._applyStyles()}isEditable(){return this.editable}setCheckable(t){this.checkable!==t&&(this.destroy(),this.checkable=t,t?this.element.setAttribute("data-tag-checkable",""):this.element.removeAttribute("data-tag-checkable"),this.init())}isCheckable(){return this.checkable}destroy(){this._listeners.forEach(({el:t,event:e,handler:s})=>{t.removeEventListener(e,s)}),this._listeners=[],this.closeBtn=null,this.checkbox=null,this.editInput=null,this.element=null}}function oe(t,e){if(t.__kupolaInitialized)return;const s=new ae(t,e);t.__kupolaInstance=s,t.__kupolaInitialized=!0}function le(t){if(!t.__kupolaInitialized||!t.__kupolaInstance)return;t.__kupolaInstance.destroy(),t.__kupolaInstance=null,t.__kupolaInitialized=!1}rt.register("tag",oe,le);class he{constructor(t){this.element=t,this.valueElement=t.querySelector(".ds-statcard__value"),this.progressFill=t.querySelector(".ds-statcard__progress-fill"),this.animated=!1,this._observer=null,this.init()}init(){this.animateValue(),this.animateProgress(),this._observer=new IntersectionObserver(t=>{t.forEach(t=>{t.isIntersecting&&!this.animated&&(this.animateValue(),this.animateProgress(),this.animated=!0)})},{threshold:.3}),this._observer.observe(this.element)}animateValue(){if(!this.valueElement)return;const t=this.valueElement.textContent,e=t.match(/[\d.,]+/);if(!e)return;const s=parseFloat(e[0].replace(",","")),i=t.substring(0,e.index),n=t.substring(e.index+e[0].length),r=performance.now(),a=t=>{const e=t-r,o=Math.min(e/1500,1),l=1-Math.pow(1-o,3),h=0+(s-0)*l;let c;c=s>=1e6?(h/1e6).toFixed(1)+"M":s>=1e3?(h/1e3).toFixed(1)+"K":Number.isInteger(s)?Math.floor(h).toLocaleString():h.toFixed(2),this.valueElement.textContent=i+c+n,o<1&&requestAnimationFrame(a)};requestAnimationFrame(a)}animateProgress(){if(!this.progressFill)return;const t=this.progressFill.getAttribute("data-width")||"0%";this.progressFill.style.width=t}updateValue(t,e={}){if(!this.valueElement)return;const s=e.duration||800,i=this.valueElement.textContent,n=i.match(/[\d.,]+/);if(!n)return void(this.valueElement.textContent=t);const r=i.substring(0,n.index),a=i.substring(n.index+n[0].length),o=parseFloat(n[0].replace(",","")),l=parseFloat(t),h=performance.now(),c=t=>{const e=t-h,i=Math.min(e/s,1),n=1-Math.pow(1-i,3),d=o+(l-o)*n;let u;u=l>=1e6?(d/1e6).toFixed(1)+"M":l>=1e3?(d/1e3).toFixed(1)+"K":Number.isInteger(l)?Math.floor(d).toLocaleString():d.toFixed(2),this.valueElement.textContent=r+u+a,i<1&&requestAnimationFrame(c)};requestAnimationFrame(c)}updateProgress(t,e={}){if(!this.progressFill)return;const s=e.duration||600,i=parseFloat(this.progressFill.style.width||"0"),n=Math.min(Math.max(t,0),100),r=performance.now(),a=t=>{const e=t-r,o=Math.min(e/s,1),l=1-Math.pow(1-o,3),h=i+(n-i)*l;this.progressFill.style.width=h+"%",o<1&&requestAnimationFrame(a)};requestAnimationFrame(a)}setTrend(t,e){const s=this.element.querySelector(".ds-statcard__trend");if(!s)return;s.className=`ds-statcard__trend ds-statcard__trend--${t}`;const i="up"===t?'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="23 6 13.5 15.5 8.5 10.5 1 18"/></svg>':"down"===t?'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="1 18 10.5 8.5 15.5 13.5 23 6"/></svg>':'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="12 19 18 13 12 7 6 13"/></svg>';s.innerHTML=i+e}destroy(){this._observer&&(this._observer.disconnect(),this._observer=null),this.animated=!1,this.valueElement=null,this.progressFill=null,this.element=null}}function ce(t){if(t.__kupolaInitialized)return;const e=new he(t);t.__kupolaInstance=e,t.__kupolaInitialized=!0}function de(t){if(!t.__kupolaInitialized||!t.__kupolaInstance)return;t.__kupolaInstance.destroy(),t.__kupolaInstance=null,t.__kupolaInitialized=!1}rt.register("statcard",ce,de);class ue{constructor(t,e={}){this.element=t,this.data=e.data||[],this.startDate=e.startDate||this.getOneYearAgo(),this.endDate=e.endDate||new Date,this.cellSize=e.cellSize||14,this.onCellClick=e.onCellClick||null,this.tooltip=null,this.baseColor=e.color||t.getAttribute("data-color")||"#22c55e",this._listeners=[],this.init()}getOneYearAgo(){const t=new Date;return t.setFullYear(t.getFullYear()-1),t}init(){this.render(),this.createTooltip()}getDataByDate(t){const e=this.formatDate(t),s=this.data.find(t=>t.date===e);return s?s.value:0}formatDate(t){return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}`}getLevel(t,e){if(0===t)return 0;e&&0!==e||(e=Math.max(...this.data.map(t=>t.value),1));const s=t/e;return s<.2?1:s<.4?2:s<.6?3:s<.8?4:5}hexToRgb(t){const e=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);return e?{r:parseInt(e[1],16),g:parseInt(e[2],16),b:parseInt(e[3],16)}:{r:34,g:197,b:94}}getCellColor(t){const e=this.hexToRgb(this.baseColor);if(0===t)return"rgba(0, 0, 0, 0.1)";const s=[.2,.4,.6,.8,1][t-1];return`rgba(${e.r}, ${e.g}, ${e.b}, ${s})`}getWeekdayLabels(){return["","一","","三","","五",""]}getMonthLabels(){const t=["1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"],e=[];let s=-1;for(let i=new Date(this.startDate);i<=this.endDate;i.setDate(i.getDate()+1)){const n=i.getMonth(),r=i.getDate();n!==s&&1===r&&(e.push({month:n,label:t[n],offset:Math.floor((i-this.startDate)/864e5)}),s=n)}return e}getWeekCount(){let t=0;const e=new Date(this.startDate).getDay();for(let e=new Date(this.startDate);e<=this.endDate;e.setDate(e.getDate()+1))0===e.getDay()&&t++;return 0!==e&&t++,t}render(){const t=this.element.querySelector(".ds-heatmap__body");if(!t)return;t.innerHTML="";const e=[];let s=[];const i=new Date(this.startDate).getDay();for(let t=1;t<i;t++)s.push(null);for(let t=new Date(this.startDate);t<=this.endDate;t.setDate(t.getDate()+1))s.push(new Date(t)),6!==t.getDay()&&t.getTime()!==this.endDate.getTime()||(e.push(s),s=[]);const n=e.length,r=this.element.classList.contains("ds-heatmap--compact")?12:16,a=n*r,o=document.createElement("div");o.className="ds-heatmap__container";const l=document.createElement("div");l.className="ds-heatmap__labels-and-grid";const h=document.createElement("div");h.className="ds-heatmap__weekday-labels";const c=this.element.classList.contains("ds-heatmap--compact")?12:16;this.getWeekdayLabels().forEach(t=>{const e=document.createElement("div");e.className="ds-heatmap__weekday-label",e.textContent=t,e.style.height=c+"px",e.style.lineHeight=c+"px",h.appendChild(e)}),l.appendChild(h);const d=document.createElement("div");d.className="ds-heatmap__grid-container";const u=document.createElement("div");u.className="ds-heatmap__month-labels",u.style.width=a+"px";const p=this.getMonthLabels();p.forEach((t,e)=>{const s=document.createElement("div");s.className="ds-heatmap__month-label",s.textContent=t.label;const i=p[e+1];let a;a=i?Math.ceil((i.offset-t.offset)/7):n-Math.floor(t.offset/7),s.style.width=a*r+"px",u.appendChild(s)}),d.appendChild(u);const m=document.createElement("div");m.className="ds-heatmap__grid",e.forEach(t=>{const e=document.createElement("div");e.className="ds-heatmap__week-column",t.forEach(t=>{if(null===t){const t=document.createElement("div");t.className="ds-heatmap__cell",t.style.visibility="hidden",e.appendChild(t)}else{const s=this.getDataByDate(t),i=Math.max(...this.data.map(t=>t.value),1),n=this.getLevel(s,i),r=document.createElement("div");r.className="ds-heatmap__cell",r.dataset.date=this.formatDate(t),r.dataset.value=s,r.style.backgroundColor=this.getCellColor(n);const a=e=>this.showTooltip(e,t,s),o=()=>this.hideTooltip(),l=()=>{this.onCellClick&&this.onCellClick({date:this.formatDate(t),value:s})};r.addEventListener("mouseenter",a),r.addEventListener("mouseleave",o),r.addEventListener("click",l),this._listeners.push({el:r,event:"mouseenter",handler:a},{el:r,event:"mouseleave",handler:o},{el:r,event:"click",handler:l}),e.appendChild(r)}}),m.appendChild(e)}),d.appendChild(m),l.appendChild(d),o.appendChild(l),t.appendChild(o),this.renderLegend(t)}renderLegend(t){const e=document.createElement("div");e.className="ds-heatmap__legend";const s=document.createElement("span");s.className="ds-heatmap__legend-label",s.textContent="少";const i=document.createElement("div");i.className="ds-heatmap__legend-cells";for(let t=0;t<=5;t++){const e=document.createElement("div");e.className="ds-heatmap__legend-cell",e.style.backgroundColor=this.getCellColor(t),i.appendChild(e)}const n=document.createElement("span");n.className="ds-heatmap__legend-label",n.textContent="多",e.appendChild(s),e.appendChild(i),e.appendChild(n),t.appendChild(e)}createTooltip(){this.tooltip=document.createElement("div"),this.tooltip.className="ds-heatmap__tooltip",document.body.appendChild(this.tooltip)}showTooltip(t,e,s){const i=t.target.getBoundingClientRect();this.tooltip.innerHTML=`\n <div class="ds-heatmap__tooltip-date">${e.getFullYear()}年${e.getMonth()+1}月${e.getDate()}日</div>\n <div class="ds-heatmap__tooltip-value">${s} contributions</div>\n `,this.tooltip.style.left=Math.min(i.left+i.width/2-75,window.innerWidth-150-16)+"px",this.tooltip.style.top=i.top-50+"px",this.tooltip.classList.add("is-visible")}hideTooltip(){this.tooltip.classList.remove("is-visible")}updateData(t){this._listeners.forEach(({el:t,event:e,handler:s})=>{t.removeEventListener(e,s)}),this._listeners=[],this.data=t,this.render()}setDateRange(t,e){this.startDate=t,this.endDate=e,this.render()}destroy(){this._listeners.forEach(({el:t,event:e,handler:s})=>{t.removeEventListener(e,s)}),this._listeners=null,this.tooltip&&this.tooltip.parentNode&&this.tooltip.parentNode.removeChild(this.tooltip),this.tooltip=null,this.data=[],this.element=null}}function pe(t){if(t.__kupolaInitialized)return;const e=t.getAttribute("data-heatmap-data");let s=[];if(e)try{s=JSON.parse(e)}catch(t){s=ge()}else s=ge();const i=new ue(t,{data:s,onCellClick:t=>{}});t.__kupolaInstance=i,t.__kupolaInitialized=!0}function me(t){if(!t.__kupolaInitialized||!t.__kupolaInstance)return;t.__kupolaInstance.destroy(),t.__kupolaInstance=null,t.__kupolaInitialized=!1}function ge(){const t=[],e=new Date,s=new Date;s.setFullYear(s.getFullYear()-1);for(let i=new Date(s);i<=e;i.setDate(i.getDate()+1)){const e=i.getFullYear(),s=String(i.getMonth()+1).padStart(2,"0"),n=String(i.getDate()).padStart(2,"0"),r=0===i.getDay()||6===i.getDay()?20*Math.random():50*Math.random(),a=Math.floor(r);t.push({date:`${e}-${s}-${n}`,value:a>0?a:Math.floor(30*Math.random())+1})}return t}rt.register("heatmap",pe,me);class _e{constructor(t,e={}){this.element=t,this.tooltipEl=null,this.options=e,this.delay=e.delay||parseInt(t.getAttribute("data-tooltip-delay"))||0,this.hideDelay=e.hideDelay||parseInt(t.getAttribute("data-tooltip-hide-delay"))||0,this.trigger=e.trigger||t.getAttribute("data-tooltip-trigger")||"hover",this.html=e.html||t.hasAttribute("data-tooltip-html"),this.theme=e.theme||t.getAttribute("data-tooltip-theme")||"default",this.position=e.position||t.getAttribute("data-tooltip-position")||"top",this.animation=!1!==e.animation,this.mouseFollow=e.mouseFollow||t.hasAttribute("data-tooltip-mouse-follow"),this._showTooltip=null,this._hideTooltip=null,this._showTimer=null,this._hideTimer=null,this._clickHandler=null,this._focusHandler=null,this._blurHandler=null,this._mouseMoveHandler=null,this.isVisible=!1}init(){this.element.__kupolaInitialized||(this._showTooltip=()=>{this.delay>0?this._showTimer=setTimeout(()=>this.show(),this.delay):this.show()},this._hideTooltip=()=>{this._showTimer&&(clearTimeout(this._showTimer),this._showTimer=null),this.hideDelay>0?this._hideTimer=setTimeout(()=>this.hide(),this.hideDelay):this.hide()},this._clickHandler=()=>{this.isVisible?this.hide():this.show()},this._mouseMoveHandler=t=>{if(!this.isVisible||!this.mouseFollow||!this.tooltipEl)return;const e=this.tooltipEl.getBoundingClientRect();let s=t.clientX+10,i=t.clientY+10;const n=window.innerWidth,r=window.innerHeight;s+e.width>n&&(s=t.clientX-e.width-10),i+e.height>r&&(i=t.clientY-e.height-10),this.tooltipEl.style.left=`${s}px`,this.tooltipEl.style.top=`${i}px`},"hover"!==this.trigger&&"focus"!==this.trigger||(this.element.addEventListener("mouseenter",this._showTooltip),this.element.addEventListener("mouseleave",this._hideTooltip),this.mouseFollow&&this.element.addEventListener("mousemove",this._mouseMoveHandler)),"click"===this.trigger&&(this.element.addEventListener("click",this._clickHandler),document.addEventListener("click",t=>{!this.isVisible||this.element.contains(t.target)||this.tooltipEl?.contains(t.target)||this.hide()})),"focus"!==this.trigger&&"hover"!==this.trigger||(this.element.addEventListener("focus",this._showTooltip),this.element.addEventListener("blur",this._hideTooltip)),this.element.__kupolaInitialized=!0)}show(){if(this.isVisible)return;const t=this.element.getAttribute("data-tooltip");t&&(this.tooltipEl=document.createElement("div"),this.tooltipEl.className=`ds-tooltip ds-tooltip--${this.position} ds-tooltip--${this.theme}`,this.html?this.tooltipEl.innerHTML=t:this.tooltipEl.textContent=t,document.body.appendChild(this.tooltipEl),requestAnimationFrame(()=>{this.tooltipEl.classList.add("is-visible"),this.mouseFollow||this._positionTooltip(),this.isVisible=!0,this.element.dispatchEvent(new CustomEvent("kupola:tooltip-show",{detail:{tooltip:this.tooltipEl},bubbles:!0}))}))}hide(){if(!this.isVisible||!this.tooltipEl)return;this.tooltipEl.classList.remove("is-visible");const t=this.tooltipEl;setTimeout(()=>{t===this.tooltipEl&&(t.remove(),this.tooltipEl=null)},this.animation?200:0),this.isVisible=!1,this.element.dispatchEvent(new CustomEvent("kupola:tooltip-hide",{detail:{tooltip:t},bubbles:!0}))}toggle(){this.isVisible?this.hide():this.show()}_positionTooltip(){if(!this.tooltipEl)return;const t=this.element.getBoundingClientRect(),e=this.tooltipEl.getBoundingClientRect(),s=window.innerWidth,i=window.innerHeight;let n,r;switch(this.position){case"bottom":n=t.left+t.width/2-e.width/2,r=t.bottom+8;break;case"right":n=t.right+8,r=t.top+t.height/2-e.height/2;break;case"left":n=t.left-e.width-8,r=t.top+t.height/2-e.height/2;break;default:n=t.left+t.width/2-e.width/2,r=t.top-e.height-8}n<8&&(n=8),n+e.width>s&&(n=s-e.width-8),r<8&&(r=8),r+e.height>i&&(r=i-e.height-8),this.tooltipEl.style.left=`${n}px`,this.tooltipEl.style.top=`${r}px`,this.tooltipEl.style.position="fixed"}updateContent(t,e=!1){this.element.setAttribute("data-tooltip",t),e?this.element.setAttribute("data-tooltip-html",""):this.element.removeAttribute("data-tooltip-html"),this.html=e,this.isVisible&&this.tooltipEl&&(this.html?this.tooltipEl.innerHTML=t:this.tooltipEl.textContent=t,this._positionTooltip())}setPosition(t){["top","bottom","left","right"].includes(t)&&(this.position=t,this.element.setAttribute("data-tooltip-position",t),this.tooltipEl&&(this.tooltipEl.className=`ds-tooltip ds-tooltip--${this.position} ds-tooltip--${this.theme}`,this.isVisible&&this._positionTooltip()))}setTheme(t){this.theme=t,this.element.setAttribute("data-tooltip-theme",t),this.tooltipEl&&(this.tooltipEl.className=`ds-tooltip ds-tooltip--${this.position} ds-tooltip--${this.theme}`)}setDelay(t){this.delay=t,this.element.setAttribute("data-tooltip-delay",t)}setHideDelay(t){this.hideDelay=t,this.element.setAttribute("data-tooltip-hide-delay",t)}setTrigger(t){["hover","click","focus","manual"].includes(t)&&(this.destroy(),this.trigger=t,this.element.setAttribute("data-tooltip-trigger",t),this.init())}enableMouseFollow(t){this.mouseFollow=t,t?(this.element.setAttribute("data-tooltip-mouse-follow",""),this.element.addEventListener("mousemove",this._mouseMoveHandler)):(this.element.removeAttribute("data-tooltip-mouse-follow"),this.element.removeEventListener("mousemove",this._mouseMoveHandler))}destroy(){this.element.__kupolaInitialized&&(this._showTimer&&(clearTimeout(this._showTimer),this._showTimer=null),this._hideTimer&&(clearTimeout(this._hideTimer),this._hideTimer=null),"hover"!==this.trigger&&"focus"!==this.trigger||(this.element.removeEventListener("mouseenter",this._showTooltip),this.element.removeEventListener("mouseleave",this._hideTooltip)),"click"===this.trigger&&this.element.removeEventListener("click",this._clickHandler),"focus"!==this.trigger&&"hover"!==this.trigger||(this.element.removeEventListener("focus",this._showTooltip),this.element.removeEventListener("blur",this._hideTooltip)),this.mouseFollow&&this.element.removeEventListener("mousemove",this._mouseMoveHandler),this.tooltipEl&&(this.tooltipEl.remove(),this.tooltipEl=null),this.isVisible=!1,this._showTooltip=null,this._hideTooltip=null,this._clickHandler=null,this._mouseMoveHandler=null,this.element.__kupolaInitialized=!1)}}function ye(t,e){const s=new _e(t,e);s.init(),t._kupolaTooltip=s}function fe(t){t._kupolaTooltip&&(t._kupolaTooltip.destroy(),t._kupolaTooltip=null)}rt.register("tooltip",ye,fe);class ve{constructor(){this.validators={required:this.validateRequired,email:this.validateEmail,url:this.validateUrl,minLength:this.validateMinLength,maxLength:this.validateMaxLength,pattern:this.validatePattern,min:this.validateMin,max:this.validateMax,equalTo:this.validateEqualTo,phone:this.validatePhone,date:this.validateDate,number:this.validateNumber},this.customValidators={},this.asyncValidators={},this.customAsyncValidators={},this.formStates={},this.submitting=new Set}addValidator(t,e){this.customValidators[t]=e}addAsyncValidator(t,e){this.customAsyncValidators[t]=e}validate(t){const e=t.id||`form-${Math.random().toString(36).substr(2,9)}`,s={},i=t.querySelectorAll("[data-validate]");let n=!1;return i.forEach(t=>{const e=t.name||t.id,i=this.parseRules(t.getAttribute("data-validate")),r=this.getValue(t);for(const[a,o]of Object.entries(i)){const i=this.customValidators[a]||this.validators[a],l=i?.(r,o);if(!l){s[e]=this.getErrorMessage(a,o,t),this.showError(t,s[e]),n=!0;break}this.clearError(t)}}),this.formStates[e]={valid:!n,errors:s,errorCount:Object.keys(s).length},this.updateFormState(t),!n}getValue(t){if(t.classList.contains("ds-datepicker__input")||t.classList.contains("ds-timepicker__input"))return t.value.trim();if(t.closest(".ds-select")){const e=t.closest(".ds-select"),s=e.querySelector(".ds-select__value")||e.querySelector(".ds-select__trigger span");return s?s.textContent.trim():""}if(t.closest(".ds-fileupload")){const e=t.closest(".ds-fileupload").__fileUploadInstance;return e&&e.getFiles().length>0?"has-files":""}return t.value.trim()}validateInput(t){const e=this.parseRules(t.getAttribute("data-validate")),s=this.getValue(t);for(const[i,n]of Object.entries(e)){const e=this.customValidators[i]||this.validators[i],r=e?.(s,n);if(!r)return this.showError(t,this.getErrorMessage(i,n,t)),!1}return this.clearError(t),!0}validateAll(){const t=document.querySelectorAll("form[data-validation]");let e=!0;return t.forEach(t=>{this.validate(t)||(e=!1)}),e}async validateAsync(t,e={}){const s=t.id||`form-${Math.random().toString(36).substr(2,9)}`,i=e.group,n=i?t.querySelectorAll(`[data-validate][data-validate-group="${i}"]`):t.querySelectorAll("[data-validate]");let r=!1;for(const t of n){await this.validateInputAsync(t)||(r=!0)}const a={};return n.forEach(t=>{const e=t.name||t.id,s=t.parentElement.querySelector(".ds-input__error");s&&(a[e]=s.textContent)}),this.formStates[s]={valid:!r,errors:a,errorCount:Object.keys(a).length},this.updateFormState(t),!r}async validateInputAsync(t){const e=this.parseRules(t.getAttribute("data-validate")),s=this.parseRules(t.getAttribute("data-validate-async")||""),i=this.getValue(t);for(const[s,n]of Object.entries(e)){const e=this.customValidators[s]||this.validators[s],r=e?.(i,n);if(!r)return this.showError(t,this.getErrorMessage(s,n,t)),!1}for(const[e,n]of Object.entries(s)){const s=this.customAsyncValidators[e]||this.asyncValidators[e];if(s)try{if(!await s(i,n,t))return this.showError(t,this.getErrorMessage(e,n,t)),!1}catch(e){return this.showError(t,e.message||"Validation error"),!1}}return this.clearError(t),!0}async validateGroup(t,e){const s=t.querySelectorAll(`[data-validate][data-validate-group="${e}"]`);let i=!1;for(const t of s){await this.validateInputAsync(t)||(i=!0)}return!i}getGroups(t){const e=new Set;return t.querySelectorAll("[data-validate-group]").forEach(t=>{e.add(t.getAttribute("data-validate-group"))}),Array.from(e)}getFormState(t){const e=t.id||`form-${Math.random().toString(36).substr(2,9)}`;return this.formStates[e]||{valid:!0,errors:{},errorCount:0,loading:!1,submitting:!1,disabled:!1}}updateFormState(t){const e=this.getFormState(t);e.valid?(t.classList.remove("ds-form--invalid"),t.classList.add("ds-form--valid")):(t.classList.remove("ds-form--valid"),t.classList.add("ds-form--invalid")),e.loading?t.classList.add("ds-form--loading"):t.classList.remove("ds-form--loading"),e.submitting?t.classList.add("ds-form--submitting"):t.classList.remove("ds-form--submitting"),e.disabled?(t.classList.add("ds-form--disabled"),t.querySelectorAll("input, select, textarea, button").forEach(t=>t.disabled=!0)):(t.classList.remove("ds-form--disabled"),t.querySelectorAll("input, select, textarea, button").forEach(t=>{t.hasAttribute("data-permanent-disabled")||(t.disabled=!1)}));const s=t.querySelector(".ds-form__status");s&&(e.errorCount>0?(s.textContent=`${e.errorCount} ${1===e.errorCount?"error":"errors"} found`,s.classList.add("ds-form__status--error")):(s.textContent="All fields are valid",s.classList.remove("ds-form__status--error")))}setFormLoading(t,e){const s=t.id||`form-${Math.random().toString(36).substr(2,9)}`;this.formStates[s]||(this.formStates[s]={valid:!0,errors:{},errorCount:0,loading:!1,submitting:!1,disabled:!1}),this.formStates[s].loading=e,this.updateFormState(t)}setFormSubmitting(t,e){const s=t.id||`form-${Math.random().toString(36).substr(2,9)}`;this.formStates[s]||(this.formStates[s]={valid:!0,errors:{},errorCount:0,loading:!1,submitting:!1,disabled:!1}),this.formStates[s].submitting=e,this.updateFormState(t)}setFormDisabled(t,e){const s=t.id||`form-${Math.random().toString(36).substr(2,9)}`;this.formStates[s]||(this.formStates[s]={valid:!0,errors:{},errorCount:0,loading:!1,submitting:!1,disabled:!1}),this.formStates[s].disabled=e,this.updateFormState(t)}resetForm(t){const e=t.id||`form-${Math.random().toString(36).substr(2,9)}`;this.formStates[e]={valid:!0,errors:{},errorCount:0,loading:!1,submitting:!1,disabled:!1},t.reset(),t.querySelectorAll(".ds-input--error").forEach(t=>{t.classList.remove("ds-input--error");const e=t.parentElement?.querySelector(".ds-input__error");e&&(e.textContent="")}),this.updateFormState(t)}parseRules(t){const e={};return t.split("|").forEach(t=>{const[s,i]=t.split(":");e[s]=i?i.split(","):[]}),e}validateRequired(t){return""!==t}validateEmail(t){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)}validateUrl(t){return/^(https?:\/\/)?([\da-z.-]+)\.([a-z.]{2,6})([/\w .-]*)*\/?$/.test(t)}validateMinLength(t,[e]){return t.length>=parseInt(e)}validateMaxLength(t,[e]){return t.length<=parseInt(e)}validatePattern(t,[e]){return new RegExp(e).test(t)}validateMin(t,[e]){return parseFloat(t)>=parseFloat(e)}validateMax(t,[e]){return parseFloat(t)<=parseFloat(e)}validateEqualTo(t,[e]){const s=document.getElementById(e);return s&&t===s.value}validatePhone(t){return/^[\d\s\-\+\(\)]{7,20}$/.test(t)}validateDate(t){return/^\d{4}[-/]\d{2}[-/]\d{2}$/.test(t)&&!isNaN(Date.parse(t))}validateNumber(t){return!isNaN(parseFloat(t))&&isFinite(t)}showError(t,e){t.classList.add("ds-input--error"),t.classList.remove("ds-input--success"),t.setAttribute("aria-invalid","true");let s=t.parentElement.querySelector(".ds-input__error");s||(s=document.createElement("span"),s.className="ds-input__error",s.setAttribute("role","alert"),s.setAttribute("aria-live","polite"),t.parentElement.appendChild(s)),s.textContent=e,this.removeStatusIcon(t),t.dispatchEvent(new CustomEvent("validation-error",{detail:{message:e}}))}clearError(t){t.classList.remove("ds-input--error"),t.setAttribute("aria-invalid","false");const e=t.parentElement.querySelector(".ds-input__error");e&&e.remove(),t.dispatchEvent(new CustomEvent("validation-success"))}showSuccess(t){t.classList.add("ds-input--success"),t.classList.remove("ds-input--error"),t.setAttribute("aria-invalid","false"),this.removeStatusIcon(t);const e=document.createElement("span");e.className="ds-input__status-icon ds-input__status-icon--success",e.innerHTML='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="20 6 9 17 4 12"/></svg>',t.parentElement.appendChild(e)}removeStatusIcon(t){const e=t.parentElement.querySelector(".ds-input__status-icon");e&&e.remove()}getErrorMessage(t,e,s){const i=s.getAttribute(`data-message-${t}`);if(i)return i;return{required:"This field is required",email:"Please enter a valid email address",url:"Please enter a valid URL",minLength:`Minimum length is ${e[0]} characters`,maxLength:`Maximum length is ${e[0]} characters`,pattern:"Please enter a valid value",min:`Minimum value is ${e[0]}`,max:`Maximum value is ${e[0]}`,equalTo:"Values do not match",phone:"Please enter a valid phone number",date:"Please enter a valid date (YYYY-MM-DD)",number:"Please enter a valid number"}[t]||"Invalid input"}}const be=new ve;window.__kupolaValidationInitialized||(window.__kupolaValidationInitialized=!0,document.addEventListener("DOMContentLoaded",()=>{document.querySelectorAll("form[data-validation]").forEach(t=>{t.addEventListener("submit",async e=>{const s=t.id||`form-${Math.random().toString(36).substr(2,9)}`;if(be.submitting.has(s))return void e.preventDefault();e.preventDefault();let i;if(i=null!==t.querySelector("[data-validate-async]")?await be.validateAsync(t):be.validate(t),i){be.submitting.add(s);const e=t.querySelector('button[type="submit"]');if(e){const t=e.textContent;e.setAttribute("data-original-text",t),e.textContent="Submitting...",e.disabled=!0}try{const e=t.getAttribute("data-on-submit");e&&window[e]?await window[e](t):t.submit()}finally{be.submitting.delete(s),e&&(e.textContent=e.getAttribute("data-original-text")||"Submit",e.disabled=!1)}}else{const e=t.querySelector(".ds-input--error");e&&e.focus()}}),t.querySelectorAll("[data-validate]").forEach(t=>{t.addEventListener("blur",()=>{setTimeout(()=>{const e=document.activeElement;if(e&&e.closest(".ds-select"))return;be.validateInput(t)&&t.value.trim()&&be.showSuccess(t)},50)});const e=((t,e)=>{let s;return(...i)=>{clearTimeout(s),s=setTimeout(()=>t(...i),e)}})(()=>{const e=be.getValue(t);if(e.length>0||t.classList.contains("ds-input--error")){be.validateInput(t)&&e&&be.showSuccess(t)}else be.removeStatusIcon(t)},300);t.addEventListener("input",e),t.addEventListener("keyup",e=>{if("Enter"===e.key){be.validateInput(t)&&t.value.trim()&&be.showSuccess(t)}})})})}));class ke{constructor(t,e={}){this.element=t,this.data=e.data||[],this.itemHeight=e.itemHeight||48,this.itemWidth=e.itemWidth||200,this.bufferSize=e.bufferSize||5,this.renderItem=e.renderItem||this.defaultRenderItem,this.onItemClick=e.onItemClick||null,this.onItemSelect=e.onItemSelect||null,this.onScroll=e.onScroll||null,this.onScrollEnd=e.onScrollEnd||null,this.selectedKey=e.selectedKey||null,this.keyField=e.keyField||"id",this.useDynamicHeight=e.useDynamicHeight||!1,this.dynamicHeightCache=new Map,this.estimatedHeight=e.estimatedHeight||48,this.container=null,this.scrollbarTrack=null,this.scrollbarThumb=null,this.totalHeight=0,this.startIndex=0,this.endIndex=0,this.isScrolling=!1,this.scrollTimeout=null,this.lastScrollTop=0,this.lastScrollLeft=0,this.init()}defaultRenderItem(t,e){return`\n <div class="ds-virtual-list__item-content">\n <div class="ds-virtual-list__item-icon">\n <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">\n <path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/>\n <polyline points="14 2 14 8 20 8"/>\n <line x1="16" y1="13" x2="8" y2="13"/>\n <line x1="16" y1="17" x2="8" y2="17"/>\n <polyline points="10 9 9 9 8 9"/>\n </svg>\n </div>\n <div>\n <div class="ds-virtual-list__item-title">${t.title||t.name||`Item ${e+1}`}</div>\n <div class="ds-virtual-list__item-subtitle">${t.subtitle||"Subtitle"}</div>\n </div>\n </div>\n `}init(){this.createStructure(),this.update(),this.bindEvents()}createStructure(){this.element.innerHTML='\n <div class="ds-virtual-list__scrollbar">\n <div class="ds-virtual-list__scrollbar-track">\n <div class="ds-virtual-list__scrollbar-thumb"></div>\n </div>\n </div>\n <div class="ds-virtual-list__container"></div>\n ',this.container=this.element.querySelector(".ds-virtual-list__container"),this.scrollbarThumb=this.element.querySelector(".ds-virtual-list__scrollbar-thumb")}bindEvents(){this._scrollHandler=t=>this.handleScroll(t),this._thumbDragStartHandler=t=>this.handleThumbDragStart(t),this._thumbDragMoveHandler=t=>this.handleThumbDragMove(t),this._thumbDragEndHandler=()=>this.handleThumbDragEnd(),this._wheelHandler=t=>{t.preventDefault();this.element.classList.contains("ds-virtual-list--horizontal")?this.element.scrollLeft+=t.deltaX+t.deltaY:this.element.scrollTop+=t.deltaY+t.deltaX},this.element.addEventListener("scroll",this._scrollHandler),this.scrollbarThumb.addEventListener("mousedown",this._thumbDragStartHandler),document.addEventListener("mousemove",this._thumbDragMoveHandler),document.addEventListener("mouseup",this._thumbDragEndHandler),this.element.addEventListener("wheel",this._wheelHandler,{passive:!1}),this._listeners=[{el:this.element,event:"scroll",handler:this._scrollHandler},{el:this.scrollbarThumb,event:"mousedown",handler:this._thumbDragStartHandler},{el:document,event:"mousemove",handler:this._thumbDragMoveHandler},{el:document,event:"mouseup",handler:this._thumbDragEndHandler},{el:this.element,event:"wheel",handler:this._wheelHandler}]}handleScroll(t){const e=this.element.classList.contains("ds-virtual-list--horizontal"),s=e?this.element.scrollLeft:this.element.scrollTop;this.onScroll&&this.onScroll({scrollOffset:s,isHorizontal:e,dataLength:this.data.length,startIndex:this.startIndex,endIndex:this.endIndex}),this.updateScrollState(),this.renderVisibleItems(),this.updateScrollbar()}updateScrollState(){this.isScrolling=!0,this.element.classList.add("ds-virtual-list--scrolling"),this.scrollTimeout&&clearTimeout(this.scrollTimeout),this.scrollTimeout=setTimeout(()=>{if(this.isScrolling=!1,this.element.classList.remove("ds-virtual-list--scrolling"),this.onScrollEnd){const t=this.element.classList.contains("ds-virtual-list--horizontal"),e=t?this.element.scrollLeft:this.element.scrollTop;this.onScrollEnd({scrollOffset:e,isHorizontal:t,dataLength:this.data.length,startIndex:this.startIndex,endIndex:this.endIndex})}},200)}getItemSize(t){const e=this.element.classList.contains("ds-virtual-list--horizontal");if(this.useDynamicHeight){const e=this.data[t][this.keyField]||t;if(this.dynamicHeightCache.has(e))return this.dynamicHeightCache.get(e)}return e?this.itemWidth:this.itemHeight}getItemPositions(){const t=[];let e=0;return this.data.forEach((s,i)=>{const n=this.getItemSize(i);t.push({start:e,end:e+n,size:n}),e+=n}),t}getTotalSize(){if(this.useDynamicHeight)return this.data.reduce((t,e,s)=>t+this.getItemSize(s),0);const t=this.element.classList.contains("ds-virtual-list--horizontal")?this.itemWidth:this.itemHeight;return this.data.length*t}getIndexAtOffset(t){if(this.useDynamicHeight){const e=this.getItemPositions();for(let s=0;s<e.length;s++)if(t>=e[s].start&&t<e[s].end)return s;return this.data.length-1}const e=this.element.classList.contains("ds-virtual-list--horizontal")?this.itemWidth:this.itemHeight;return Math.floor(t/e)}renderVisibleItems(){const t=this.element.classList.contains("ds-virtual-list--horizontal"),e=t?this.element.scrollLeft:this.element.scrollTop,s=t?this.element.clientWidth:this.element.clientHeight,i=Math.max(0,this.getIndexAtOffset(e)-this.bufferSize);let n=Math.min(this.data.length-1,this.getIndexAtOffset(e+s)+this.bufferSize);n<i&&(n=i),this.startIndex=i,this.endIndex=n;const r=this.data.slice(i,n+1);let a="",o=0;if(this.useDynamicHeight){const t=this.getItemPositions();o=t[i]?.start||0}else{const e=t?this.itemWidth:this.itemHeight;o=i*e}r.forEach((e,s)=>{const n=i+s,r=e[this.keyField]||n,l=this.selectedKey===r,h=this.getItemSize(n);a+=this._buildItemHtml(e,n,r,l,h,o,t),o+=h}),this.container.innerHTML=a,this.useDynamicHeight&&this.updateDynamicHeights(),this.container.querySelectorAll(".ds-virtual-list__item").forEach(t=>{t.addEventListener("click",()=>this.handleItemClick(t))})}_buildItemHtml(t,e,s,i,n,r,a){const o=i?" is-selected":"",l=this.renderItem(t,e);return a?`<div class="ds-virtual-list__item${o}" style="position: absolute; top: 0; left: ${r}px; width: ${n}px; height: 100%;" data-index="${e}" data-key="${s}">${l}</div>`:`<div class="ds-virtual-list__item${o}" style="position: absolute; top: ${r}px; left: 0; right: 0; height: ${n}px;" data-index="${e}" data-key="${s}">${l}</div>`}updateDynamicHeights(){if(this.isUpdating)return;let t=!1;this.container.querySelectorAll(".ds-virtual-list__item").forEach(e=>{const s=parseInt(e.dataset.index),i=this.data[s][this.keyField]||s,n=e.offsetHeight;n!==this.getItemSize(s)&&(this.dynamicHeightCache.set(i,n),t=!0)}),t&&(this.isUpdating=!0,this.update(),this.isUpdating=!1)}handleItemClick(t){const e=parseInt(t.dataset.index),s=t.dataset.key,i=this.data[e];this.onItemClick&&this.onItemClick({item:i,index:e,key:s}),this.onItemSelect&&this.select(s)}select(t){if(this.selectedKey=t,this.onItemSelect){const e=this.data.findIndex(e=>e[this.keyField]===t);-1!==e&&this.onItemSelect({item:this.data[e],index:e,key:t})}this.renderVisibleItems()}updateScrollbar(){const t=this.element.classList.contains("ds-virtual-list--horizontal"),e=this.getTotalSize(),s=t?this.element.clientWidth:this.element.clientHeight,i=t?this.element.scrollLeft:this.element.scrollTop;if(t)return void(this.scrollbarThumb.style.display="none");const n=Math.max(20,s/e*s),r=i/(e-s||1)*(s-n);this.scrollbarThumb.style.height=n+"px",this.scrollbarThumb.style.top=r+"px"}handleThumbDragStart(t){t.preventDefault(),this.isDragging=!0,this.dragStartY=t.clientY,this.dragStartTop=parseFloat(this.scrollbarThumb.style.top)||0}handleThumbDragMove(t){if(!this.isDragging)return;const e=this.element.clientHeight,s=this.getTotalSize(),i=e-(parseFloat(this.scrollbarThumb.style.height)||e),n=t.clientY-this.dragStartY;let r=this.dragStartTop+n;r=Math.max(0,Math.min(r,i)),this.scrollbarThumb.style.top=r+"px";const a=r/i*(s-e||0);this.element.scrollTop=a}handleThumbDragEnd(){this.isDragging=!1}update(){const t=this.element.classList.contains("ds-virtual-list--horizontal"),e=this.getTotalSize();t?(this.container.style.width=e+"px",this.container.style.height="100%"):(this.container.style.height=e+"px",this.container.style.width="100%"),this.renderVisibleItems(),this.updateScrollbar()}setData(t){this.data=t,this.useDynamicHeight&&this.dynamicHeightCache.clear(),this.update()}addItem(t){this.data.push(t),this.update()}removeItem(t){this.data.splice(t,1),this.useDynamicHeight&&this.dynamicHeightCache.clear(),this.update()}insertItem(t,e){this.data.splice(t,0,e),this.useDynamicHeight&&this.dynamicHeightCache.clear(),this.update()}scrollTo(t,e="smooth"){const s=this.element.classList.contains("ds-virtual-list--horizontal");let i=0;if(this.useDynamicHeight){const e=this.getItemPositions();i=e[t]?.start||0}else{i=t*(s?this.itemWidth:this.itemHeight)}s?this.element.scrollTo({left:i,behavior:e}):this.element.scrollTo({top:i,behavior:e})}scrollToKey(t,e="smooth"){const s=this.data.findIndex(e=>e[this.keyField]===t);-1!==s&&this.scrollTo(s,e)}scrollToTop(t="smooth"){const e=this.element.classList.contains("ds-virtual-list--horizontal");this.element.scrollTo({[e?"left":"top"]:0,behavior:t})}scrollToBottom(t="smooth"){const e=this.element.classList.contains("ds-virtual-list--horizontal"),s=this.getTotalSize(),i=e?this.element.clientWidth:this.element.clientHeight;this.element.scrollTo({[e?"left":"top"]:s-i,behavior:t})}getVisibleItems(){return this.data.slice(this.startIndex,this.endIndex+1).map((t,e)=>({item:t,index:this.startIndex+e,key:t[this.keyField]||this.startIndex+e}))}getItemIndex(t){return this.data.findIndex(e=>e[this.keyField]===t)}getItem(t){const e=this.getItemIndex(t);return-1!==e?this.data[e]:null}refreshCache(){this.dynamicHeightCache.clear(),this.update()}destroy(){this.scrollTimeout&&clearTimeout(this.scrollTimeout),this._listeners?.forEach(({el:t,event:e,handler:s})=>{t.removeEventListener(e,s)}),this.data=[],this.dynamicHeightCache.clear(),this.container.innerHTML="",this._listeners=null,this._scrollHandler=null,this._thumbDragStartHandler=null,this._thumbDragMoveHandler=null,this._thumbDragEndHandler=null,this._wheelHandler=null,this.container=null,this.scrollbarThumb=null,this.element=null}}function Ee(t=1e3){const e=[],s=["Document","Image","Video","Folder","Archive","Spreadsheet","Presentation","Code"];for(let i=1;i<=t;i++){const t=Math.floor(Math.random()*s.length),n=Math.floor(1e4*Math.random());e.push({id:i,title:`${s[t]} ${n}`,subtitle:`Last modified ${Math.floor(30*Math.random())} days ago`,type:s[t].toLowerCase()})}return e}function we(t){if(t.__kupolaInitialized)return;const e=t.getAttribute("data-virtual-list");let s=[];if(e)try{s=JSON.parse(e)}catch(t){s=Ee(1e3)}else s=Ee(1e3);const i=new ke(t,{data:s,onItemClick:t=>{},onItemSelect:t=>{}});t.__kupolaInstance=i,t.__kupolaInitialized=!0}function xe(t){if(!t.__kupolaInitialized||!t.__kupolaInstance)return;t.__kupolaInstance.destroy(),t.__kupolaInstance=null,t.__kupolaInitialized=!1}rt.register("virtual-list",we,xe);const Ce={globe:'<circle cx="12" cy="12" r="10"/><path d="M2 12h20"/><path d="M12 2a15.3 15.3 0 0 1 0 20"/><path d="M12 2a15.3 15.3 0 0 0 0 20"/>',dashboard:'<rect x="3" y="3" width="7" height="9"/><rect x="14" y="3" width="7" height="5"/><rect x="14" y="12" width="7" height="9"/><rect x="3" y="16" width="7" height="5"/>',mouse:'<rect x="6" y="2" width="12" height="20" rx="6"/><line x1="12" y1="6" x2="12" y2="11"/>',search:'<circle cx="11" cy="11" r="7"/><path d="m20 20-3.5-3.5"/>',square:'<rect x="3" y="3" width="18" height="18"/>',circle:'<circle cx="12" cy="12" r="9"/>',list:'<line x1="8" y1="6" x2="21" y2="6"/><line x1="8" y1="12" x2="21" y2="12"/><line x1="8" y1="18" x2="21" y2="18"/><line x1="3" y1="6" x2="3.01" y2="6"/><line x1="3" y1="12" x2="3.01" y2="12"/><line x1="3" y1="18" x2="3.01" y2="18"/>',palette:'<rect x="3" y="3" width="8" height="8"/><rect x="13" y="3" width="8" height="8"/><rect x="3" y="13" width="8" height="8"/><rect x="13" y="13" width="8" height="8"/>',type:'<polyline points="4 7 4 4 20 4 20 7"/><line x1="9" y1="20" x2="15" y2="20"/><line x1="12" y1="4" x2="12" y2="20"/>',ruler:'<rect x="3" y="9" width="18" height="6" transform="rotate(-45 12 12)"/><line x1="7.5" y1="12.5" x2="9" y2="14"/><line x1="11" y1="9" x2="12.5" y2="10.5"/><line x1="14.5" y1="5.5" x2="16" y2="7"/>',sparkles:'<path d="M12 3l1.8 4.2L18 9l-4.2 1.8L12 15l-1.8-4.2L6 9l4.2-1.8L12 3z"/><path d="M19 14l1 2.2 2.2 1-2.2 1L19 20.4l-1-2.2-2.2-1 2.2-1L19 14z"/>',copy:'<rect x="8" y="8" width="13" height="13"/><path d="M16 8V4H4v13h4"/>',download:'<path d="M12 3v12"/><polyline points="7 10 12 15 17 10"/><line x1="3" y1="21" x2="21" y2="21"/>',refresh:'<polyline points="21 4 21 10 15 10"/><polyline points="3 20 3 14 9 14"/><path d="M20.5 9A9 9 0 0 0 5 5.5L3 7M3.5 15A9 9 0 0 0 19 18.5L21 17"/>',external:'<polyline points="14 4 20 4 20 10"/><line x1="20" y1="4" x2="11" y2="13"/><path d="M20 14v5a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h5"/>',settings:'<circle cx="12" cy="12" r="3"/><path d="M19.4 15a1.7 1.7 0 0 0 .3 1.8l.1.1a2 2 0 1 1-2.8 2.8l-.1-.1a1.7 1.7 0 0 0-1.8-.3 1.7 1.7 0 0 0-1 1.5V21a2 2 0 1 1-4 0v-.1a1.7 1.7 0 0 0-1-1.5 1.7 1.7 0 0 0-1.8.3l-.1.1a2 2 0 1 1-2.8-2.8l.1-.1a1.7 1.7 0 0 0 .3-1.8 1.7 1.7 0 0 0-1.5-1H3a2 2 0 1 1 0-4h.1a1.7 1.7 0 0 0 1.5-1 1.7 1.7 0 0 0-.3-1.8l-.1-.1a2 2 0 1 1 2.8-2.8l.1.1a1.7 1.7 0 0 0 1.8.3H9a1.7 1.7 0 0 0 1-1.5V3a2 2 0 1 1 4 0v.1a1.7 1.7 0 0 0 1 1.5 1.7 1.7 0 0 0 1.8-.3l.1-.1a2 2 0 1 1 2.8 2.8l-.1.1a1.7 1.7 0 0 0-.3 1.8V9a1.7 1.7 0 0 0 1.5 1H21a2 2 0 1 1 0 4h-.1a1.7 1.7 0 0 0-1.5 1z"/>',sliders:'<line x1="4" y1="21" x2="4" y2="14"/><line x1="4" y1="10" x2="4" y2="3"/><line x1="12" y1="21" x2="12" y2="12"/><line x1="12" y1="8" x2="12" y2="3"/><line x1="20" y1="21" x2="20" y2="16"/><line x1="20" y1="12" x2="20" y2="3"/><line x1="1" y1="14" x2="7" y2="14"/><line x1="9" y1="8" x2="15" y2="8"/><line x1="17" y1="16" x2="23" y2="16"/>',plus:'<line x1="12" y1="5" x2="12" y2="19"/><line x1="5" y1="12" x2="19" y2="12"/>',minus:'<line x1="5" y1="12" x2="19" y2="12"/>',x:'<line x1="6" y1="6" x2="18" y2="18"/><line x1="18" y1="6" x2="6" y2="18"/>',github:'<path d="M9 19c-4.3 1.4-4.3-2.5-6-3m12 5v-3.5c0-1 .1-1.4-.5-2 2.8-.3 5.5-1.4 5.5-6a4.6 4.6 0 0 0-1.3-3.2 4.2 4.2 0 0 0-.1-3.2s-1.1-.3-3.5 1.3a12 12 0 0 0-6.2 0C6.5 2.8 5.4 3.1 5.4 3.1a4.2 4.2 0 0 0-.1 3.2A4.6 4.6 0 0 0 4 9.5c0 4.6 2.7 5.7 5.5 6-.6.6-.6 1.2-.5 2V21"/>',"message-circle":'<path d="M21 12a9 9 0 0 1-13.5 7.8L3 21l1.2-4.5A9 9 0 1 1 21 12z"/>',"message-plus":'<path d="M21 12a9 9 0 0 1-13.5 7.8L3 21l1.2-4.5A9 9 0 1 1 21 12z"/><line x1="12" y1="9" x2="12" y2="15"/><line x1="9" y1="12" x2="15" y2="12"/>',gear:'<path d="M9.3 5.7 6.375 5.025 5.025 6.375 5.7 9.3 3 11.1 3 12.9 5.7 14.7 5.025 17.625 6.375 18.975 9.3 18.3 11.1 21 12.9 21 14.7 18.3 17.625 18.975 18.975 17.625 18.3 14.7 21 12.9 21 11.1 18.3 9.3 18.975 6.375 17.625 5.025 14.7 5.7 12.9 3 11.1 3 9.3 5.7Z"/><circle cx="12" cy="12" r="3"/>',"user-circle":'<circle cx="12" cy="12" r="9"/><circle cx="12" cy="10" r="2.5"/><path d="M7 17.5a5 5 0 0 1 10 0"/>',shield:'<path d="M12 3 4 6v6c0 5 3.5 8 8 9 4.5-1 8-4 8-9V6z"/>',check:'<polyline points="4 12 10 18 20 6"/>',"arrow-right":'<line x1="4" y1="12" x2="20" y2="12"/><polyline points="14 6 20 12 14 18"/>',"arrow-up-right":'<line x1="6" y1="18" x2="18" y2="6"/><polyline points="9 6 18 6 18 15"/>',"chevron-right":'<polyline points="9 6 15 12 9 18"/>',"chevron-down":'<polyline points="6 9 12 15 18 9"/>',"check-circle":'<circle cx="12" cy="12" r="9"/><polyline points="8 12 11 15 16 9"/>',"alert-circle":'<circle cx="12" cy="12" r="9"/><line x1="12" y1="8" x2="12" y2="13"/><line x1="12" y1="16" x2="12" y2="16.01"/>',"alert-triangle":'<path d="M12 3 22 20 2 20 Z"/><line x1="12" y1="10" x2="12" y2="15"/><line x1="12" y1="18" x2="12" y2="18.01"/>',"info-circle":'<circle cx="12" cy="12" r="9"/><line x1="12" y1="11" x2="12" y2="16"/><line x1="12" y1="8" x2="12" y2="8.01"/>',"x-circle":'<circle cx="12" cy="12" r="9"/><line x1="9" y1="9" x2="15" y2="15"/><line x1="15" y1="9" x2="9" y2="15"/>',alert:'<path d="M12 3 22 20 2 20 Z"/><line x1="12" y1="10" x2="12" y2="15"/><line x1="12" y1="18" x2="12" y2="18.01"/>',info:'<circle cx="12" cy="12" r="9"/><line x1="12" y1="11" x2="12" y2="16"/><line x1="12" y1="8" x2="12" y2="8.01"/>',mail:'<rect x="3" y="5" width="18" height="14"/><polyline points="3 6 12 13 21 6"/>',user:'<path d="M4 21v-1a6 6 0 0 1 6-6h4a6 6 0 0 1 6 6v1"/><circle cx="12" cy="8" r="4"/>',users:'<path d="M2 21v-1a5 5 0 0 1 5-5h3a5 5 0 0 1 5 5v1"/><circle cx="8.5" cy="8" r="3.5"/><path d="M22 21v-1a5 5 0 0 0-4-4.9"/><path d="M16 3.1A4 4 0 0 1 16 11"/>',box:'<polyline points="3 7 12 2 21 7 21 17 12 22 3 17 3 7"/><line x1="3" y1="7" x2="12" y2="12"/><line x1="21" y1="7" x2="12" y2="12"/><line x1="12" y1="22" x2="12" y2="12"/>',zap:'<polygon points="13 2 4 14 12 14 11 22 20 10 12 10 13 2"/>',moon:'<path d="M21 12.8A9 9 0 1 1 11.2 3a7 7 0 0 0 9.8 9.8z"/>',sun:'<circle cx="12" cy="12" r="4"/><line x1="12" y1="2" x2="12" y2="5"/><line x1="12" y1="19" x2="12" y2="22"/><line x1="2" y1="12" x2="5" y2="12"/><line x1="19" y1="12" x2="22" y2="12"/><line x1="4.6" y1="4.6" x2="6.7" y2="6.7"/><line x1="17.3" y1="17.3" x2="19.4" y2="19.4"/><line x1="4.6" y1="19.4" x2="6.7" y2="17.3"/><line x1="17.3" y1="6.7" x2="19.4" y2="4.6"/>',cmd:'<path d="M9 6h6v12H9z"/><rect x="3" y="3" width="6" height="6"/><rect x="15" y="3" width="6" height="6"/><rect x="3" y="15" width="6" height="6"/><rect x="15" y="15" width="6" height="6"/>',key:'<circle cx="7.5" cy="14.5" r="3.5"/><line x1="10" y1="12" x2="22" y2="12"/><line x1="22" y1="12" x2="22" y2="16"/><line x1="18" y1="12" x2="18" y2="15"/>',bell:'<path d="M6 8a6 6 0 0 1 12 0c0 7 3 8 3 8H3s3-1 3-8z"/><path d="M10 21a2 2 0 0 0 4 0"/>',"arrow-up":'<line x1="12" y1="20" x2="12" y2="4"/><polyline points="6 10 12 4 18 10"/>',"chevron-up":'<polyline points="6 15 12 9 18 15"/>',"arrow-left":'<line x1="20" y1="12" x2="4" y2="12"/><polyline points="10 6 4 12 10 18"/>',mic:'<rect x="9" y="3" width="6" height="12" rx="3"/><path d="M5 11a7 7 0 0 0 14 0"/><line x1="12" y1="18" x2="12" y2="22"/>',at:'<circle cx="12" cy="12" r="4"/><path d="M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8"/>',hash:'<line x1="4" y1="9" x2="20" y2="9"/><line x1="4" y1="15" x2="20" y2="15"/><line x1="10" y1="3" x2="8" y2="21"/><line x1="16" y1="3" x2="14" y2="21"/>',"sidebar-left":'<rect x="3" y="3" width="18" height="18"/><line x1="9" y1="3" x2="9" y2="21"/>',"sidebar-right":'<rect x="3" y="3" width="18" height="18"/><line x1="15" y1="3" x2="15" y2="21"/>',"panel-bottom":'<rect x="3" y="3" width="18" height="18"/><line x1="3" y1="15" x2="21" y2="15"/>',git:'<circle cx="6" cy="5" r="3"/><circle cx="6" cy="19" r="3"/><circle cx="18" cy="5" r="3"/><line x1="6" y1="8" x2="6" y2="16"/><path d="M18 8v3a4 4 0 0 1-4 4h-4"/>',bug:'<rect x="8" y="6" width="8" height="14" rx="4"/><line x1="12" y1="11" x2="12" y2="20"/><line x1="3" y1="9" x2="8" y2="9"/><line x1="3" y1="14" x2="8" y2="14"/><line x1="3" y1="19" x2="8" y2="19"/><line x1="16" y1="9" x2="21" y2="9"/><line x1="16" y1="14" x2="21" y2="14"/><line x1="16" y1="19" x2="21" y2="19"/><line x1="9" y1="6" x2="9" y2="3"/><line x1="15" y1="6" x2="15" y2="3"/>',"search-menu":'<circle cx="11" cy="11" r="6"/><line x1="20" y1="20" x2="16" y2="16"/><line x1="3" y1="20" x2="13" y2="20"/>',extensions:'<rect x="3" y="3" width="7" height="7"/><rect x="14" y="3" width="7" height="7"/><rect x="3" y="14" width="7" height="7"/><path d="M17.5 14v3.5H21a2 2 0 0 1 0 4h-3.5V21a2 2 0 0 1-4 0v-3.5H14a2 2 0 0 1 0-4h3.5z"/>',wrench:'<path d="M14.7 6.3a4 4 0 0 0 5 5L21 12.5l-7.5 7.5a3 3 0 0 1-4.2-4.2L16.7 8 14.7 6.3z"/><path d="M14.7 6.3 12 9l-3-3 2.7-2.7a4 4 0 0 1 3 3z"/>',"message-square":'<path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/>',"file-text":'<path d="M14 3H6v18h12V8z"/><polyline points="14 3 14 8 18 8"/><line x1="9" y1="13" x2="15" y2="13"/><line x1="9" y1="17" x2="15" y2="17"/>',"scroll-text":'<path d="M5 4h11a3 3 0 0 1 3 3v10H8v3a1 1 0 0 1-1 1 3 3 0 0 1-3-3V7a3 3 0 0 1 1-3z"/><line x1="9" y1="9" x2="15" y2="9"/><line x1="9" y1="13" x2="15" y2="13"/>',atom:'<circle cx="12" cy="12" r="2"/><ellipse cx="12" cy="12" rx="10" ry="4"/><ellipse cx="12" cy="12" rx="10" ry="4" transform="rotate(60 12 12)"/><ellipse cx="12" cy="12" rx="10" ry="4" transform="rotate(120 12 12)"/>',"arrow-right-to-line":'<line x1="20" y1="4" x2="20" y2="20"/><line x1="3" y1="12" x2="17" y2="12"/><polyline points="11 6 17 12 11 18"/>',"info-square":'<rect x="3" y="3" width="18" height="18"/><line x1="12" y1="11" x2="12" y2="16"/><line x1="12" y1="8" x2="12" y2="8.01"/>',"arrow-minimize":'<polyline points="20 4 14 10 20 10"/><line x1="14" y1="10" x2="14" y2="4"/><polyline points="4 20 10 14 4 14"/><line x1="10" y1="14" x2="10" y2="20"/>',"arrow-expand":'<polyline points="14 4 20 4 20 10"/><line x1="14" y1="10" x2="20" y2="4"/><polyline points="10 20 4 20 4 14"/><line x1="10" y1="14" x2="4" y2="20"/>',"arrow-down":'<line x1="12" y1="4" x2="12" y2="20"/><polyline points="6 14 12 20 18 14"/>',logo:'<rect x="3" y="3" width="18" height="18"/><line x1="3" y1="9" x2="21" y2="9"/><line x1="9" y1="21" x2="9" y2="9"/>',"more-h":'<circle cx="5" cy="12" r="1.5" fill="currentColor"/><circle cx="12" cy="12" r="1.5" fill="currentColor"/><circle cx="19" cy="12" r="1.5" fill="currentColor"/>',edit:'<path d="M4 20h4l10-10-4-4L4 16v4z"/><path d="M14 6l4 4"/>',trash:'<polyline points="4 6 20 6"/><path d="M6 6v14h12V6"/><path d="M9 6V4h6v2"/><line x1="10" y1="10" x2="10" y2="17"/><line x1="14" y1="10" x2="14" y2="17"/>',file:'<path d="M14 3H6v18h12V7z"/><polyline points="14 3 14 7 18 7"/>',files:'<path d="M21 8v13H8V3h8z"/><polyline points="16 3 16 8 21 8"/><path d="M8 7H3v14h13v-3"/>',"grid-2x2":'<rect x="3" y="3" width="8" height="8"/><rect x="13" y="3" width="8" height="8"/><rect x="3" y="13" width="8" height="8"/><rect x="13" y="13" width="8" height="8"/>',folder:'<path d="M3 6h6l2 3h10v10H3z"/>',layers:'<polygon points="12 3 22 8 12 13 2 8 12 3"/><polyline points="2 13 12 18 22 13"/>',layout:'<rect x="3" y="3" width="18" height="18"/><line x1="3" y1="9" x2="21" y2="9"/><line x1="9" y1="21" x2="9" y2="9"/>',terminal:'<polyline points="4 7 9 12 4 17"/><line x1="12" y1="17" x2="20" y2="17"/>',image:'<rect x="3" y="3" width="18" height="18"/><circle cx="9" cy="9" r="1.5" fill="currentColor"/><polyline points="3 18 9 12 13 16 17 12 21 16"/>',play:'<polygon points="6 4 20 12 6 20 6 4"/>',pause:'<rect x="6" y="4" width="4" height="16"/><rect x="14" y="4" width="4" height="16"/>',help:'<rect x="3" y="3" width="18" height="18"/><path d="M9 9a3 3 0 0 1 6 0c0 2-3 2-3 4"/><line x1="12" y1="17" x2="12" y2="17.01"/>',lock:'<rect x="4" y="11" width="16" height="10"/><path d="M8 11V8a4 4 0 0 1 8 0v3"/>',eye:'<path d="M2 12s4-7 10-7 10 7 10 7-4 7-10 7-10-7-10-7z"/><circle cx="12" cy="12" r="3"/>',star:'<polygon points="12 3 15 9 22 10 17 14 18 21 12 18 6 21 7 14 2 10 9 9 12 3"/>',heart:'<path d="M12 21s-7-5-7-11a4 4 0 0 1 7-2 4 4 0 0 1 7 2c0 6-7 11-7 11z"/>',home:'<polygon points="3 11 12 3 21 11 21 21 14 21 14 14 10 14 10 21 3 21 3 11"/>',calendar:'<rect x="3" y="5" width="18" height="16"/><line x1="3" y1="10" x2="21" y2="10"/><line x1="8" y1="3" x2="8" y2="7"/><line x1="16" y1="3" x2="16" y2="7"/>',clock:'<circle cx="12" cy="12" r="9"/><polyline points="12 7 12 12 16 14"/>',filter:'<polygon points="3 4 21 4 14 12 14 20 10 18 10 12 3 4"/>',send:'<polygon points="3 12 21 4 17 21 12 13 3 12"/>',link:'<path d="M10 14a4 4 0 0 1 0-6l3-3a4 4 0 0 1 6 6l-1.5 1.5"/><path d="M14 10a4 4 0 0 1 0 6l-3 3a4 4 0 0 1-6-6l1.5-1.5"/>',upload:'<path d="M12 21V9"/><polyline points="7 14 12 9 17 14"/><line x1="3" y1="3" x2="21" y2="3"/>',"log-out":'<path d="M14 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h9"/><polyline points="16 16 21 12 16 8"/><line x1="9" y1="12" x2="21" y2="12"/>',menu:'<line x1="4" y1="6" x2="20" y2="6"/><line x1="4" y1="12" x2="20" y2="12"/><line x1="4" y1="18" x2="20" y2="18"/>',dollar:'<line x1="12" y1="2" x2="12" y2="22"/><path d="M17 6H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6"/>',bar:'<line x1="3" y1="21" x2="21" y2="21"/><rect x="5" y="11" width="3" height="8"/><rect x="10.5" y="6" width="3" height="13"/><rect x="16" y="14" width="3" height="5"/>',"trending-up":'<polyline points="3 17 9 11 13 15 21 7"/><polyline points="15 7 21 7 21 13"/>',"trending-down":'<polyline points="3 7 9 13 13 9 21 17"/><polyline points="15 17 21 17 21 11"/>',columns:'<rect x="3" y="3" width="18" height="18"/><line x1="9" y1="3" x2="9" y2="21"/><line x1="15" y1="3" x2="15" y2="21"/>',plug:'<path d="M9 2v6"/><path d="M15 2v6"/><path d="M7 8h10v4a5 5 0 0 1-10 0V8z"/><path d="M12 17v5"/>',cpu:'<rect x="6" y="6" width="12" height="12"/><rect x="9" y="9" width="6" height="6"/><line x1="9" y1="2" x2="9" y2="6"/><line x1="15" y1="2" x2="15" y2="6"/><line x1="9" y1="18" x2="9" y2="22"/><line x1="15" y1="18" x2="15" y2="22"/><line x1="2" y1="9" x2="6" y2="9"/><line x1="2" y1="15" x2="6" y2="15"/><line x1="18" y1="9" x2="22" y2="9"/><line x1="18" y1="15" x2="22" y2="15"/>',code:'<polyline points="16 18 22 12 16 6"/><polyline points="8 6 2 12 8 18"/>',apple:'<path fill="currentColor" stroke="none" d="M17.05 12.04c-.03-3.04 2.49-4.5 2.6-4.57-1.42-2.07-3.62-2.36-4.4-2.39-1.87-.19-3.65 1.1-4.6 1.1-.96 0-2.42-1.08-3.98-1.05-2.05.03-3.94 1.19-4.99 3.02-2.13 3.69-.54 9.13 1.53 12.12 1.01 1.46 2.21 3.1 3.78 3.04 1.52-.06 2.09-.98 3.93-.98 1.83 0 2.36.98 3.97.95 1.64-.03 2.68-1.49 3.68-2.96 1.16-1.7 1.64-3.35 1.66-3.43-.04-.02-3.18-1.22-3.21-4.85zM14.06 4.34c.83-1.01 1.39-2.41 1.24-3.81-1.2.05-2.65.8-3.51 1.8-.77.89-1.45 2.31-1.27 3.68 1.34.1 2.71-.68 3.54-1.67z"/>'};function Se(t,e=16,s="0 0 24 24"){const i=Ce[t];if(!i)return"";return`<svg ${'xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="butt" stroke-linejoin="miter"'.replace('width="16"',`width="${e}"`).replace('height="16"',`height="${e}"`).replace('viewBox="0 0 24 24"',`viewBox="${s}"`)}>${i}</svg>`}function Le(t=document){t.querySelectorAll("[data-icon]").forEach(t=>{const e=t.getAttribute("data-icon"),s=+t.getAttribute("data-size")||16,i=t.getAttribute("data-viewbox")||"0 0 24 24";t.innerHTML=Se(e,s,i),t.classList.add("icon")})}const De={svg:Se,render:Le,PATHS:Ce};"undefined"!=typeof document&&("loading"!==document.readyState?Le():document.addEventListener("DOMContentLoaded",()=>Le()));class Me{constructor(t){this.element=t,this.hoursEl=t.querySelector(".ds-countdown__item--hours .ds-countdown__value"),this.minutesEl=t.querySelector(".ds-countdown__item--minutes .ds-countdown__value"),this.secondsEl=t.querySelector(".ds-countdown__item--seconds .ds-countdown__value"),this.endTime=this.parseEndTime(),this.interval=null,this.init()}parseEndTime(){const t=this.element.getAttribute("data-end-time");if(t)return new Date(t).getTime();const e=parseInt(this.element.getAttribute("data-hours"))||0,s=parseInt(this.element.getAttribute("data-minutes"))||0,i=parseInt(this.element.getAttribute("data-seconds"))||0;return(new Date).getTime()+1e3*(3600*e+60*s+i)}init(){this.update(),this.start()}start(){this.interval&&clearInterval(this.interval),this.interval=setInterval(()=>{this.update()},1e3)}stop(){this.interval&&(clearInterval(this.interval),this.interval=null)}reset(){this.stop(),this.endTime=this.parseEndTime(),this.init()}update(){const t=(new Date).getTime(),e=this.endTime-t;if(e<=0)return this.stop(),this.displayTime(0,0,0),void this.dispatchComplete();const s=Math.floor(e%864e5/36e5),i=Math.floor(e%36e5/6e4),n=Math.floor(e%6e4/1e3);this.displayTime(s,i,n)}displayTime(t,e,s){this.hoursEl&&(this.hoursEl.textContent=String(t).padStart(2,"0")),this.minutesEl&&(this.minutesEl.textContent=String(e).padStart(2,"0")),this.secondsEl&&(this.secondsEl.textContent=String(s).padStart(2,"0"))}setEndTime(t){this.endTime=t.getTime(),this.update()}addTime(t){this.endTime+=1e3*t,this.update()}dispatchComplete(){this.element.dispatchEvent(new CustomEvent("kupola:countdown-complete",{detail:{}}))}destroy(){this.stop(),this.hoursEl=null,this.minutesEl=null,this.secondsEl=null,this.element=null}}function He(t){if(t.__kupolaInitialized)return;const e=new Me(t);t.__kupolaInstance=e,t.__kupolaInitialized=!0}function Ie(t){if(!t.__kupolaInitialized||!t.__kupolaInstance)return;t.__kupolaInstance.destroy(),t.__kupolaInstance=null,t.__kupolaInitialized=!1}rt.register("countdown",He,Ie);class Te{constructor(t){if(this.element=t,this.minusBtn=t.querySelector(".ds-number-input__btn--decrease"),this.plusBtn=t.querySelector(".ds-number-input__btn--increase"),this.inputEl=t.querySelector(".ds-number-input__input"),this._listeners=[],!this.minusBtn||!this.plusBtn||!this.inputEl)throw new Error("NumberInput: Missing required elements");this.min=parseInt(this.inputEl.getAttribute("min"))||-1/0,this.max=parseInt(this.inputEl.getAttribute("max"))||1/0,this.step=parseInt(this.inputEl.getAttribute("step"))||1,this.init()}init(){this.bindEvents(),this.updateState()}bindEvents(){const t=()=>this.updateValue(-this.step),e=()=>this.updateValue(this.step),s=()=>this.handleInput();this.minusBtn.addEventListener("click",t),this.plusBtn.addEventListener("click",e),this.inputEl.addEventListener("input",s),this._listeners.push({el:this.minusBtn,event:"click",handler:t},{el:this.plusBtn,event:"click",handler:e},{el:this.inputEl,event:"input",handler:s})}updateValue(t){let e=parseInt(this.inputEl.value)||0;e+=t,e<this.min&&(e=this.min),e>this.max&&(e=this.max),this.inputEl.value=e,this.inputEl.dispatchEvent(new Event("change")),this.updateState(),this.dispatchChange()}handleInput(){let t=parseInt(this.inputEl.value);isNaN(t)&&(t=0),t<this.min&&(t=this.min),t>this.max&&(t=this.max),this.inputEl.value=t,this.updateState(),this.dispatchChange()}updateState(){const t=parseInt(this.inputEl.value)||0;this.minusBtn.disabled=t<=this.min,this.plusBtn.disabled=t>=this.max}setValue(t){t<this.min&&(t=this.min),t>this.max&&(t=this.max),this.inputEl.value=t,this.updateState(),this.dispatchChange()}getValue(){return parseInt(this.inputEl.value)||0}setRange(t,e){this.min=t,this.max=e,this.updateState()}dispatchChange(){this.element.dispatchEvent(new CustomEvent("kupola:number-input-change",{detail:{value:this.getValue()}}))}destroy(){this._listeners.forEach(({el:t,event:e,handler:s})=>{t.removeEventListener(e,s)}),this._listeners=null,this.minusBtn=null,this.plusBtn=null,this.inputEl=null,this.element=null}}function Ae(t){if(!t.__kupolaInitialized)try{const e=new Te(t);t.__kupolaInstance=e,t.__kupolaInitialized=!0}catch(t){console.error("[NumberInput] Error initializing:",t)}}function ze(t){if(!t.__kupolaInitialized||!t.__kupolaInstance)return;t.__kupolaInstance.destroy(),t.__kupolaInstance=null,t.__kupolaInitialized=!1}rt.register("number-input",Ae,ze);class $e{constructor(t){this.container=t,this.track=t.querySelector(".ds-slider-captcha__track"),this.btn=t.querySelector(".ds-slider-captcha__btn"),this.text=t.querySelector(".ds-slider-captcha__text"),this.progress=t.querySelector(".ds-slider-captcha__progress"),this.statusEl=t.querySelector(".ds-slider-captcha__status"),this.refreshBtn=t.querySelector(".ds-slider-captcha__refresh"),this.footerRefreshBtn=t.querySelector(".ds-slider-captcha__footer-refresh"),this.config={tolerance:6,minPoints:20,minDuration:300,maxDuration:1e4,minSpeedDelta:.3,maxAttempts:5},this.isDragging=!1,this.startX=0,this.startY=0,this.currentX=0,this.trackData=[],this.startTime=0,this.isVerified=!1,this.isProcessing=!1,this.attempts=0,this.targetX=0,this.distractorX=0,this.angle=0,this.distractorAngle=0,this.maxAngle=parseInt(t.getAttribute("data-angle"))||30,this.shape=t.getAttribute("data-shape")||"circle",this.hasDistractor="circle"!==this.shape,this.scope=`slidecaptcha-${Math.random().toString(36).substr(2,9)}`,this._mouseDownHandler=null,this._mouseMoveHandler=null,this._mouseUpHandler=null,this._touchStartHandler=null,this._touchMoveHandler=null,this._touchEndHandler=null,this._mouseMoveListener=null,this._mouseUpListener=null,this._touchMoveListener=null,this._touchEndListener=null}init(){this.track&&this.btn&&(this.container._initialized||(this._mouseDownHandler=t=>{this.isVerified||this.isProcessing||(t.preventDefault(),this.isDragging=!0,this.startX=t.clientX,this.startY=t.clientY,this.startTime=Date.now(),this.trackData=[],this.container.classList.add("is-active"),this.text&&(this.text.textContent="拖动中...",this.text.style.color="var(--status-info-default)"))},this._mouseMoveHandler=t=>{if(!this.isDragging)return;t.preventDefault();const e=this.track.offsetWidth-this.btn.offsetWidth-8;let s=t.clientX-this.startX;s<0&&(s=0),s>e&&(s=e),this.currentX=s,this.btn.style.left=14+s+"px",this.progress&&(this.progress.style.width=s/e*100+"%"),this.collectTrack(t.clientX,t.clientY)},this._mouseUpHandler=()=>{this.isDragging&&(this.isDragging=!1,this.container.classList.remove("is-active"),this.verifyCaptcha())},this._touchStartHandler=t=>{this.isVerified||this.isProcessing||(t.preventDefault(),this.isDragging=!0,this.startX=t.touches[0].clientX,this.startY=t.touches[0].clientY,this.startTime=Date.now(),this.trackData=[],this.container.classList.add("is-active"),this.text&&(this.text.textContent="拖动中...",this.text.style.color="var(--status-info-default)"))},this._touchMoveHandler=t=>{if(!this.isDragging)return;t.preventDefault();const e=this.track.offsetWidth-this.btn.offsetWidth-8;let s=t.touches[0].clientX-this.startX;s<0&&(s=0),s>e&&(s=e),this.currentX=s,this.btn.style.left=14+s+"px",this.progress&&(this.progress.style.width=s/e*100+"%"),this.collectTrack(t.touches[0].clientX,t.touches[0].clientY)},this._touchEndHandler=()=>{this.isDragging&&(this.isDragging=!1,this.container.classList.remove("is-active"),this.verifyCaptcha())},this.btn.addEventListener("mousedown",this._mouseDownHandler),this._mouseMoveListener=mt.on(document,"mousemove",this._mouseMoveHandler,{scope:this.scope}),this._mouseUpListener=mt.on(document,"mouseup",this._mouseUpHandler,{scope:this.scope}),this._touchMoveListener=mt.on(document,"touchmove",this._touchMoveHandler,{scope:this.scope,passive:!1}),this._touchEndListener=mt.on(document,"touchend",this._touchEndHandler,{scope:this.scope}),this.btn.addEventListener("touchstart",this._touchStartHandler,{passive:!1}),this.refreshBtn&&this.refreshBtn.addEventListener("click",()=>this.loadCaptcha()),this.footerRefreshBtn&&this.footerRefreshBtn.addEventListener("click",()=>this.loadCaptcha()),this.container._initialized=!0,this.loadCaptcha()))}generateTarget(){const t=this.track.offsetWidth,e=this.btn.offsetWidth,s=.35*t,i=.85*t-e,n=.6*t;if(this.angle=Math.floor(Math.random()*(this.maxAngle+1)),this.hasDistractor)do{this.distractorAngle=Math.floor(Math.random()*(this.maxAngle+1))}while(Math.abs(this.distractorAngle-this.angle)<5);if(this.hasDistractor){Math.random()>.5?(this.targetX=Math.floor(s+Math.random()*(n-s-e)),this.distractorX=Math.floor(n+Math.random()*(i-n))):(this.targetX=Math.floor(n+Math.random()*(i-n)),this.distractorX=Math.floor(s+Math.random()*(n-s-e)))}else this.targetX=Math.floor(s+Math.random()*(i-s));const r=this.container.querySelector(".ds-slider-captcha__target");if(r&&(r.style.left=this.targetX+14+e/2+"px",r.style.transform="translate(-50%, -50%) rotate("+this.angle+"deg)",r.style.display="block"),this.hasDistractor){const t=this.container.querySelector(".ds-slider-captcha__target--distractor");t&&(t.style.left=this.distractorX+14+e/2+"px",t.style.transform="translate(-50%, -50%) rotate("+this.distractorAngle+"deg)",t.style.display="block")}else{const t=this.container.querySelector(".ds-slider-captcha__target--distractor");t&&(t.style.display="none")}}resetSlider(){this.btn.className="ds-slider-captcha__btn",this.btn.style.transform="rotate("+this.angle+"deg)",this.btn.innerHTML="",this.btn.style.left="14px",this.btn.style.display="block",this.progress&&(this.progress.style.width="0%",this.progress.style.display="block"),this.text&&(this.text.textContent="按住滑块,拖动到缺口位置",this.text.style.color=""),this.refreshBtn&&(this.refreshBtn.style.display="none"),this.currentX=0,this.trackData=[],this.container.classList.remove("is-verified","is-error","is-disabled")}loadCaptcha(){this.isVerified=!1,this.isProcessing=!1,this.attempts=0,this.generateTarget(),this.resetSlider(),this.statusEl&&(this.statusEl.textContent="请完成验证",this.statusEl.className="ds-slider-captcha__status")}collectTrack(t,e){const s=Date.now()-this.startTime;let i=0,n=0;if(this.trackData.length>0){const t=this.trackData[this.trackData.length-1],e=this.currentX-t.x,r=s-t.t;if(r>0&&(i=e/r,this.trackData.length>1)){const e=this.trackData[this.trackData.length-2],s=t.t-e.t;if(s>0){n=i-(t.x-e.x)/s}}}this.trackData.push({x:this.currentX,y:e-this.startY,t:s,v:i,a:n});const r=this.container.querySelector(".ds-slider-captcha__point-count");r&&(r.textContent="轨迹点: "+this.trackData.length)}validateTrack(){if(!this.trackData||this.trackData.length<this.config.minPoints)return{passed:!1,msg:"验证失败"};const t=this.trackData[this.trackData.length-1].x,e=this.hasDistractor?Math.abs(t-this.distractorX):1/0,s=Math.abs(t-this.targetX);if(this.hasDistractor&&e<s&&e<=this.config.tolerance)return{passed:!1,msg:"验证失败"};if(s>this.config.tolerance)return{passed:!1,msg:"验证失败"};const i=[];for(let t=1;t<this.trackData.length;t++){const e=this.trackData[t].x-this.trackData[t-1].x,s=this.trackData[t].t-this.trackData[t-1].t;s>0&&s<500&&i.push(e/s)}if(i.length<3)return{passed:!1,msg:"验证失败"};if(Math.max(...i)-Math.min(...i)<this.config.minSpeedDelta)return{passed:!1,msg:"验证失败"};let n=!1;for(const t of this.trackData)if(Math.abs(t.y)>2){n=!0;break}if(!n&&this.trackData.length>20)return{passed:!1,msg:"验证失败"};const r=this.trackData[this.trackData.length-1].t;if(r<this.config.minDuration)return{passed:!1,msg:"验证失败"};if(r>this.config.maxDuration)return{passed:!1,msg:"验证失败"};const a=[];for(let t=1;t<i.length;t++)a.push(Math.abs(i[t]-i[t-1]));if(a.length>2){if(a.reduce((t,e)=>t+e,0)/a.length<.05)return{passed:!1,msg:"验证失败"}}return{passed:!0,msg:"验证通过"}}verifyCaptcha(){this.isProcessing||this.isVerified||(this.isProcessing=!0,this.statusEl&&(this.statusEl.textContent="验证中...",this.statusEl.className="ds-slider-captcha__status is-loading"),this.btn.style.cursor="wait",this.container.classList.add("is-disabled"),setTimeout(()=>{const t=this.validateTrack();if(this.isProcessing=!1,this.btn.style.cursor="",t.passed){this.isVerified=!0,this.btn.style.display="none",this.progress&&(this.progress.style.display="none");const t=this.container.querySelector(".ds-slider-captcha__target");t&&(t.style.display="none");const e=this.container.querySelector(".ds-slider-captcha__target--distractor");e&&(e.style.display="none"),this.text&&(this.text.textContent="验证通过",this.text.style.color="var(--status-success-default)"),this.statusEl&&(this.statusEl.textContent="验证成功",this.statusEl.className="ds-slider-captcha__status is-success"),this.container.classList.add("is-verified"),this.container.classList.remove("is-disabled");const s=this.container.getAttribute("data-on-verified");s&&"function"==typeof window[s]&&window[s](this.container)}else{this.attempts++,this.text&&(this.text.textContent=t.msg,this.text.style.color="var(--status-error-default)"),this.statusEl&&(this.statusEl.textContent=t.msg,this.statusEl.className="ds-slider-captcha__status is-error");if("auto"===this.container.getAttribute("data-err-refresh"))setTimeout(()=>{this.loadCaptcha()},1200);else{this.btn.style.display="none",this.progress&&(this.progress.style.display="none");const t=this.container.querySelector(".ds-slider-captcha__target");t&&(t.style.display="none");const e=this.container.querySelector(".ds-slider-captcha__target--distractor");e&&(e.style.display="none"),this.refreshBtn&&(this.refreshBtn.style.display="block")}}},300))}destroy(){this.container._initialized&&(this.btn&&this._mouseDownHandler&&this.btn.removeEventListener("mousedown",this._mouseDownHandler),this.btn&&this._touchStartHandler&&this.btn.removeEventListener("touchstart",this._touchStartHandler),this.refreshBtn&&this.refreshBtn.removeEventListener("click",()=>this.loadCaptcha()),this.footerRefreshBtn&&this.footerRefreshBtn.removeEventListener("click",()=>this.loadCaptcha()),this._mouseMoveListener&&this._mouseMoveListener.unsubscribe?this._mouseMoveListener.unsubscribe():this._mouseMoveHandler&&document.removeEventListener("mousemove",this._mouseMoveHandler),this._mouseUpListener&&this._mouseUpListener.unsubscribe?this._mouseUpListener.unsubscribe():this._mouseUpHandler&&document.removeEventListener("mouseup",this._mouseUpHandler),this._touchMoveListener&&this._touchMoveListener.unsubscribe?this._touchMoveListener.unsubscribe():this._touchMoveHandler&&document.removeEventListener("touchmove",this._touchMoveHandler),this._touchEndListener&&this._touchEndListener.unsubscribe?this._touchEndListener.unsubscribe():this._touchEndHandler&&document.removeEventListener("touchend",this._touchEndHandler),this.container._initialized=!1)}}function qe(){document.querySelectorAll(".ds-slider-captcha").forEach(t=>{const e=new $e(t);e.init(),t._kupolaSlideCaptcha=e})}function Pe(t){t._kupolaSlideCaptcha&&(t._kupolaSlideCaptcha.destroy(),t._kupolaSlideCaptcha=null)}function Ne(){document.querySelectorAll(".ds-slider-captcha").forEach(t=>{Pe(t)})}rt.register("slide-captcha",qe,Ne);class Fe{constructor(t){this.form=t,this.fields=[],this.validators={},this.errorMessages={},this._submitHandler=null,this._fieldHandlers=new Map,this._init()}_init(){this._setupValidators(),this._collectFields(),this._bindEvents()}_setupValidators(){this.validators={required:t=>"string"==typeof t?""!==t.trim():Array.isArray(t)?t.length>0:null!=t,email:t=>{if(!t)return!0;return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)},phone:t=>{if(!t)return!0;return/^1[3-9]\d{9}$/.test(t)},url:t=>{if(!t)return!0;try{return new URL(t),!0}catch{return!1}},number:t=>!t||!isNaN(parseFloat(t))&&isFinite(t),minlength:(t,e)=>!t||t.length>=parseInt(e),maxlength:(t,e)=>!t||t.length<=parseInt(e),min:(t,e)=>!t||parseFloat(t)>=parseFloat(e),max:(t,e)=>!t||parseFloat(t)<=parseFloat(e),pattern:(t,e)=>{if(!t)return!0;return new RegExp(e).test(t)},equalTo:(t,e)=>{const s=document.getElementById(e);return!s||t===s.value}},this.errorMessages={required:"该字段为必填项",email:"请输入有效的邮箱地址",phone:"请输入有效的手机号码",url:"请输入有效的URL地址",number:"请输入有效的数字",minlength:t=>`至少需要${t}个字符`,maxlength:t=>`最多允许${t}个字符`,min:t=>`最小值为${t}`,max:t=>`最大值为${t}`,pattern:"格式不正确",equalTo:"两次输入不一致"}}_collectFields(){this.form.querySelectorAll("input, select, textarea").forEach(t=>{t.hasAttribute("data-kupola-ignore")||this.fields.push(t)})}_bindEvents(){this._submitHandler=t=>{this.validate()||t.preventDefault()},this.form.addEventListener("submit",this._submitHandler),this.fields.forEach(t=>{const e=()=>this.validateField(t),s=()=>this.clearError(t);this._fieldHandlers.set(t,{blur:e,input:s}),t.addEventListener("blur",e),t.addEventListener("input",s)})}validate(){let t=!0;return this.fields.forEach(e=>{this.validateField(e)||(t=!1)}),t}validateField(t){const e=this._getFieldErrors(t);return e.length>0?(this.showError(t,e[0]),!1):(this.clearError(t),!0)}_getFieldErrors(t){const e=[],s=this._getFieldValue(t);for(const[i,n]of Object.entries(this.validators)){const r=t.getAttribute(`data-${i}`);if(null!==r){if(!n(s,r)){let t=this.errorMessages[i];"function"==typeof t&&(t=t(r)),e.push(t)}}}return e}_getFieldValue(t){const e=t.type;if("checkbox"===e)return t.checked;if("radio"===e){const e=t.name,s=this.form.querySelector(`input[name="${e}"]:checked`);return s?s.value:null}return"select-multiple"===e?Array.from(t.selectedOptions).map(t=>t.value):t.value}showError(t,e){this.clearError(t);const s=document.createElement("span");s.className="ds-form-error",s.textContent=e,t.classList.add("ds-form-field--error");const i=t.parentElement;i.classList.contains("ds-form-field")?i.appendChild(s):t.parentNode.insertBefore(s,t.nextSibling)}clearError(t){t.classList.remove("ds-form-field--error");const e=t.parentElement.querySelector(".ds-form-error");e&&e.remove()}addValidator(t,e,s){this.validators[t]=e,this.errorMessages[t]=s}getData(){const t={};return this.fields.forEach(e=>{const s=e.name;if(!s)return;const i=this._getFieldValue(e);"checkbox"===e.type?(t[s]||(t[s]=[]),e.checked&&t[s].push(e.value)):"radio"===e.type?!t[s]&&e.checked&&(t[s]=e.value):t[s]=i}),t}setData(t){Object.keys(t).forEach(e=>{this.form.querySelectorAll(`[name="${e}"]`).forEach(s=>{const i=s.type;if("checkbox"===i){const i=Array.isArray(t[e])?t[e]:[t[e]];s.checked=i.includes(s.value)}else if("radio"===i)s.checked=s.value===t[e];else if("select-multiple"===i){const i=Array.isArray(t[e])?t[e]:[t[e]];Array.from(s.options).forEach(t=>{t.selected=i.includes(t.value)})}else s.value=t[e]||""})})}reset(){this.form.reset(),this.fields.forEach(t=>this.clearError(t))}destroy(){this._submitHandler&&this.form&&this.form.removeEventListener("submit",this._submitHandler),this._fieldHandlers.forEach((t,e)=>{e.removeEventListener("blur",t.blur),e.removeEventListener("input",t.input)}),this._submitHandler=null,this._fieldHandlers.clear(),this._fieldHandlers=null,this.fields=null,this.validators=null,this.errorMessages=null,this.form=null}}function Oe(t){const e=document.querySelectorAll(t||".ds-form");return e.forEach(t=>{if(t._kupolaForm)return;const e=new Fe(t);t._kupolaForm=e}),e.length}rt.register("form-validation",Oe);class Be{constructor(){this._queue=new Set,this._scheduled=!1,this._flushDepth=0,this._maxDepth=10}schedule(t){this._queue.add(t),this._scheduled||(this._scheduled=!0,queueMicrotask(()=>this._flush()))}_flush(){if(this._flushDepth>=this._maxDepth)return console.warn("[Kupola Scheduler] Max flush depth reached, possible infinite loop detected"),this._queue.clear(),void(this._scheduled=!1);const t=Array.from(this._queue);this._queue.clear(),this._scheduled=!1,this._flushDepth++;const e=new Set;for(const s of t)if(!e.has(s)){e.add(s);try{s()}catch(t){console.error("[DependsScheduler]",t)}}this._flushDepth--}}const Re=new Be;class Ve{constructor(t,e){this.data=t,this.createdAt=Date.now(),this.ttl=e}get isFresh(){return Date.now()-this.createdAt<this.ttl}get isStale(){return!this.isFresh}}class Ke{constructor(){this._store=new Map}get(t){const e=this._store.get(t);return e||null}set(t,e,s=6e4){this._store.set(t,new Ve(e,s))}has(t){return this._store.has(t)}delete(t){this._store.delete(t)}clear(){this._store.clear()}getStale(t){const e=this._store.get(t);return e?e.data:null}}class je extends Error{constructor(t,e,s){super(t),this.name="DependsError",this.code=e,this.cause=s,this.timestamp=Date.now()}}let We="undefined"!=typeof globalThis&&globalThis.fetch?globalThis.fetch.bind(globalThis):"undefined"!=typeof window&&window.fetch?window.fetch.bind(window):null;class Ue{constructor(t,e){this.config=t,this.cacheKey=t.cacheKey||String(t.source),this.staleTime=t.staleTime??6e4,this.cache=e,this.subscribers=[],this.pending=null,this.retryCount=t.retry??0,this.retryDelay=t.retryDelay??1e3,this.onError=t.onError||null}subscribe(t){return this.subscribers.push(t),()=>{const e=this.subscribers.indexOf(t);e>-1&&this.subscribers.splice(e,1)}}notify(){Re.schedule(()=>{this.subscribers.forEach(t=>{try{t()}catch(t){console.error("[DependsSource.notify]",t)}})})}async fetch(t){throw new je("Source fetch not implemented","NOT_IMPLEMENTED")}async getValue(t){const e=this.cache.get(this.cacheKey);return e&&e.isFresh?e.data:e&&e.isStale?(this._revalidate(t),e.data):this._fetchWithRetry(t)}async _fetchWithRetry(t,e=0){try{const e=await this.fetch(t);return this.cache.set(this.cacheKey,e,this.staleTime),this.notify(),e}catch(s){if(e<this.retryCount){const s=this.retryDelay*Math.pow(2,e),i=s+Math.random()*s*.5;return await new Promise(t=>setTimeout(t,i)),this._fetchWithRetry(t,e+1)}const i=s instanceof je?s:new je(s.message||"Fetch failed","FETCH_ERROR",s);if(this.onError)try{this.onError(i)}catch(t){}throw i}}async _revalidate(t){try{await this._fetchWithRetry(t)}catch(t){}}invalidate(){this.cache.delete(this.cacheKey),this.pending=null}destroy(){this.subscribers=[],this.pending=null}}class Ye extends Ue{constructor(t,e){super(t,e),this.method=t.method||"GET",this.headers=t.headers||{},this.queryParams=t.query||{}}async fetch(t){let e=this.config.source;for(const s in t)e=e.replace(`:${s}`,encodeURIComponent(t[s]));const s=[];for(const[t,e]of Object.entries(this.queryParams||{}))s.push(`${encodeURIComponent(t)}=${encodeURIComponent(e)}`);for(const e in t)this.config.source.includes(`:${e}`)||s.push(`${encodeURIComponent(e)}=${encodeURIComponent(t[e])}`);s.length>0&&(e+=(e.includes("?")?"&":"?")+s.join("&"));const i={method:this.method.toUpperCase(),headers:{"Content-Type":"application/json",...this.headers}};["POST","PUT","PATCH"].includes(i.method)&&(i.body=JSON.stringify(t));const n=We;if(!n)throw new je("No HTTP client available. Use configureHttpClient() to set one.","NO_HTTP_CLIENT");const r=await n(e,i),a="boolean"==typeof r.ok?r.ok:r.status>=200&&r.status<300,o="number"==typeof r.status?r.status:0;if(!a)throw new je(`HTTP ${o}`,"HTTP_ERROR");return"function"==typeof r.json?await r.json():void 0!==r.data?r.data:r}}class Xe extends Ue{constructor(t,e){super(t,e),this.storageKey=t.source.replace("localStorage:",""),this.defaultValue=t.default,this.sync=!1!==t.sync,this.sync&&"undefined"!=typeof window&&(this._storageHandler=t=>{t.key===this.storageKey&&(this.cache.delete(this.cacheKey),this.notify())},window.addEventListener("storage",this._storageHandler))}async fetch(){try{const t=localStorage.getItem(this.storageKey);if(null===t)return this.defaultValue;try{return JSON.parse(t)}catch(e){return t}}catch(t){return this.defaultValue}}setValue(t){const e="string"==typeof t?t:JSON.stringify(t);localStorage.setItem(this.storageKey,e),this.cache.delete(this.cacheKey),this.notify()}destroy(){super.destroy(),this._storageHandler&&window.removeEventListener("storage",this._storageHandler)}}class Je extends Ue{constructor(t,e){super(t,e),this.paramName=t.source.replace("route:","")}async fetch(){if("undefined"==typeof window)return"";const t=location.hash.slice(1).match(new RegExp(`/${this.paramName}/([^/]+)`));if(t)return decodeURIComponent(t[1]);return new URLSearchParams(location.search).get(this.paramName)||""}}class Ze extends Ue{async fetch(t){return await this.config.source(t)}}class Ge extends Ue{async fetch(){return this.config.source}}class Qe extends Ue{constructor(t,e){super(t,e),this.ws=null,this.reconnect=!1!==t.reconnect,this.reconnectDelay=t.reconnectDelay||3e3,this._reconnectAttempt=0,this._maxReconnectDelay=t.maxReconnectDelay||3e4,this.messageHandler=null,this._connected=!1,this._destroyed=!1}async fetch(){return new Promise((t,e)=>{try{this.ws=new WebSocket(this.config.source),this.ws.onopen=()=>{this._connected=!0,this._reconnectAttempt=0,t(this.cache.getStale(this.cacheKey))},this.messageHandler=t=>{let e;try{e=JSON.parse(t.data)}catch(s){e=t.data}this.cache.set(this.cacheKey,e,this.staleTime),this.notify()},this.ws.onmessage=this.messageHandler,this.ws.onerror=t=>{this._connected||e(new je("WebSocket connection failed","WS_ERROR",t))},this.ws.onclose=()=>{if(this._connected=!1,this.reconnect&&!this._destroyed){const t=this.reconnectDelay*Math.pow(2,this._reconnectAttempt),e=Math.random()*t*.3,s=Math.min(t+e,this._maxReconnectDelay);this._reconnectAttempt++,setTimeout(()=>{this._destroyed||this.fetch().catch(()=>{})},s)}}}catch(t){e(new je("WebSocket creation failed","WS_ERROR",t))}})}send(t){this.ws&&this.ws.readyState===WebSocket.OPEN&&this.ws.send("string"==typeof t?t:JSON.stringify(t))}destroy(){this._destroyed=!0,super.destroy(),this.ws&&(this.ws.onmessage=null,this.ws.onclose=null,this.ws.close(),this.ws=null)}}function ts(t,e){const s=t.source;return"function"==typeof s?new Ze(t,e):"string"==typeof s&&(s.startsWith("ws://")||s.startsWith("wss://"))?new Qe(t,e):"string"==typeof s&&(s.startsWith("/")||s.startsWith("http"))?new Ye(t,e):"string"==typeof s&&s.startsWith("localStorage:")?new Xe(t,e):"string"==typeof s&&s.startsWith("route:")?new Je(t,e):new Ge(t,e)}function es(t){const e={};for(const s in t){const i=t[s];e[s]=i&&"object"==typeof i&&"value"in i?i.value:i}return e}class ss{constructor(t,e={}){this.element="string"==typeof t?document.querySelector(t):t,this.options=e,this.columns=(e.columns||[]).map((t,e)=>({...t,_index:e})),this.rowKey=e.rowKey||"id",this._data=[],this._loading=!1,this.striped=!1!==e.striped,this.bordered=e.bordered||!1,this.hoverable=!1!==e.hoverable,this.compact=e.compact||!1,this.emptyText=e.emptyText||"暂无数据",this.loadingText=e.loadingText||"加载中...",this.multiSort=e.multiSort||!1,this._sorts=[],this._filterText="",this._showPagination=!1!==e.pagination,this._pageSizes=e.pageSizes||[10,20,50,100],this._pageSize=e.pageSize||10,this._currentPage=1,this._total=0,this.selection=e.selection||null,this._selectedKeys=new Set,this.selectionColumnTitle=e.selectionColumnTitle||"",this.expandable=e.expandable||null,this._expandedKeys=new Set,this.expandColumnTitle=e.expandColumnTitle||"",this.editable=e.editable||!1,this._editingCell=null,this._editBuffer={},this.resizable=e.resizable||!1,this.draggable=e.draggable||!1,this._dragState=null,this.tree=e.tree||null,this._treeExpandedKeys=new Set,e.tree?.defaultExpandAll&&(this._treeExpandAll=!0),this.virtualScroll=e.virtualScroll||null,this._scrollContainer=null,this._scrollHandler=null,this._resizeCleanups=[],this._filterDebounceTimer=null,this._reactiveCleanups=[],this.mergeCells=e.mergeCells||null,this.onSort=e.onSort||null,this.onPageChange=e.onPageChange||null,this.onRowClick=e.onRowClick||null,this.onFilter=e.onFilter||null,this.onSelect=e.onSelect||null,this.onExpand=e.onExpand||null,this.onEditSave=e.onEditSave||null,this.onEditCancel=e.onEditCancel||null,this.onRowDragEnd=e.onRowDragEnd||null,this.onColumnResize=e.onColumnResize||null,this.sortKey=W(null),this.sortOrder=W(null),this.currentPage=W(1),this.filterText=W(""),this.selectedKeys=W([]),this._init()}_init(){this.element.classList.add("kupola-table-wrapper"),this.virtualScroll&&this.element.classList.add("kupola-table-virtual-wrapper"),this.render()}setData(t){t&&"object"==typeof t&&"value"in t?(this._data=Array.isArray(t.value)?t.value:[],t.subscribe&&this._reactiveCleanups.push(t.subscribe(t=>{this._data=Array.isArray(t)?t:[],this._total=this._data.length,this.render()}))):Array.isArray(t)?this._data=t:this._data=[],this.tree&&this._treeExpandAll&&this._flattenForExpand(this._data),this._total=this._getFlatData(this._data).length,this.render()}setLoading(t){t&&"object"==typeof t&&"value"in t?(this._loading=t.value,t.subscribe&&this._reactiveCleanups.push(t.subscribe(t=>{this._loading=t,this.render()}))):this._loading=!!t,this.render()}_flattenForExpand(t,e=0,s=null){const i=this.tree?.childrenKey||"children",n=[];for(const r of t){const t=r[this.rowKey];n.push({...r,_level:e,_parentKey:s,_hasChildren:!(!r[i]||!r[i].length)}),r[i]&&r[i].length&&n.push(...this._flattenForExpand(r[i],e+1,t))}return n}_getFlatData(t){return this.tree?this._flattenVisible(t,0):t}_flattenVisible(t,e){const s=this.tree?.childrenKey||"children",i=[];for(const n of t){const t=n[this.rowKey];i.push({...n,_level:e,_hasChildren:!(!n[s]||!n[s].length)}),n[s]&&n[s].length&&this._treeExpandedKeys.has(t)&&i.push(...this._flattenVisible(n[s],e+1))}return i}getProcessedData(){let t=(this.tree,[...this._data]);if(this._filterText){const e=this._filterText.toLowerCase();t=this.tree?this._filterTree(t,e):t.filter(t=>this.columns.some(s=>{const i=t[s.key];return null!=i&&String(i).toLowerCase().includes(e)}))}this._sorts.length>0&&(t=this.tree?this._sortTree(t):this._sortFlat(t));const e=this.tree?this._flattenVisible(t):t;this._total=e.length;let s=e;if(this._showPagination&&this._pageSize>0){const t=(this._currentPage-1)*this._pageSize;s=e.slice(t,t+this._pageSize)}return s}_filterTree(t,e){const s=this.tree?.childrenKey||"children";return t.reduce((t,i)=>{const n=i[s]?this._filterTree(i[s],e):[];return(this.columns.some(t=>{const s=i[t.key];return null!=s&&String(s).toLowerCase().includes(e)})||n.length>0)&&(t.push({...i,[s]:n}),n.length>0&&this._treeExpandedKeys.add(i[this.rowKey])),t},[])}_sortFlat(t){return[...t].sort((t,e)=>{for(const s of this._sorts){const i=this.columns.find(t=>t.key===s.key);let n=t[s.key],r=e[s.key],a=0;if(a=i?.sorter?i.sorter(n,r,s.order):null==n?1:null==r?-1:"number"==typeof n&&"number"==typeof r?"asc"===s.order?n-r:r-n:"asc"===s.order?String(n).localeCompare(String(r)):String(r).localeCompare(String(n)),0!==a)return a}return 0})}_sortTree(t){const e=this._sortFlat(t),s=this.tree?.childrenKey||"children";return e.map(t=>t[s]?.length?{...t,[s]:this._sortTree(t[s])}:t)}render(){const t=this.getProcessedData(),e=this.element;e.innerHTML="",(this.options.showFilter||this.options.showToolbar)&&e.appendChild(this._renderToolbar());const s=document.createElement("div");s.className="kupola-table-container";const i=document.createElement("table");i.className=this._getTableClass(),i.appendChild(this._renderThead()),this.virtualScroll?i.appendChild(this._renderVirtualTbody(t)):i.appendChild(this._renderTbody(t)),s.appendChild(i),e.appendChild(s),this._showPagination&&this._total>0&&e.appendChild(this._renderPagination()),this.resizable&&this._initColumnResize(),this.draggable&&this._initRowDrag(),this._applyStickyColumns()}_renderThead(){const t=document.createElement("thead"),e=document.createElement("tr");if(this.selection&&this._renderSelectionHeader(e),this.expandable){const t=document.createElement("th");t.className="kupola-table-col-expand",e.appendChild(t)}return this.columns.forEach(t=>{const s=this._renderColumnHeader(t);e.appendChild(s)}),t.appendChild(e),t}_renderSelectionHeader(t){const e=document.createElement("th");if(e.className="kupola-table-col-selection","checkbox"===this.selection){const t=document.createElement("input");t.type="checkbox";const s=this.getProcessedData().map(t=>t[this.rowKey]);t.checked=s.length>0&&s.every(t=>this._selectedKeys.has(t)),t.addEventListener("change",()=>t.checked?this.selectAll():this.deselectAll()),e.appendChild(t)}t.appendChild(e)}_renderColumnHeader(t){const e=document.createElement("th");if(e.textContent=t.title||t.key,t.width&&(e.style.width="number"==typeof t.width?t.width+"px":t.width),t.minWidth&&(e.style.minWidth="number"==typeof t.minWidth?t.minWidth+"px":t.minWidth),t.align&&(e.style.textAlign=t.align),t.fixed&&e.setAttribute("data-fixed",t.fixed),t.sortable&&this._renderSortIndicator(e,t),this.resizable&&t.key!==this.columns[this.columns.length-1]?.key){const s=document.createElement("span");s.className="kupola-table-resize-handle",s.setAttribute("data-col-key",t.key),e.appendChild(s)}return e}_renderSortIndicator(t,e){t.classList.add("kupola-table-sortable");const s=this._sorts.find(t=>t.key===e.key);s&&t.classList.add(`kupola-table-sort-${s.order}`),t.addEventListener("click",t=>{this.resizable&&t.target.classList.contains("kupola-table-resize-handle")||this._handleSort(e.key)});const i=document.createElement("span");i.className="kupola-table-sort-icon",i.textContent=s?this.multiSort?` ${this._sorts.indexOf(s)+1}${"asc"===s.order?"▲":"▼"}`:"asc"===s.order?" ▲":" ▼":" ⇅",t.appendChild(i)}_renderTbody(t){const e=document.createElement("tbody");if(this._loading)e.appendChild(this._renderStatusRow(this.loadingText,"kupola-table-loading"));else if(0===t.length)e.appendChild(this._renderStatusRow(this.emptyText,"kupola-table-empty"));else{const s=this.mergeCells?this.mergeCells(t):[],i=new Map;s.forEach(t=>i.set(`${t.row}-${t.col}`,t));const n=new Set;t.forEach((t,s)=>{const r=t[this.rowKey]??s,a=this._selectedKeys.has(r),o=this._expandedKeys.has(r),l=this._renderDataRow(t,s,r,a,n,i);if(e.appendChild(l),this.expandable&&o){const s=document.createElement("tr");s.className="kupola-table-expand-row";const i=document.createElement("td"),n=this.columns.length+(this.selection?1:0)+1;i.colSpan=n,i.className="kupola-table-expand-content";const r=this.expandable(t);"string"==typeof r?i.innerHTML=r:r instanceof HTMLElement&&i.appendChild(r),s.appendChild(i),e.appendChild(s)}})}return e}_renderDataRow(t,e,s,i,n,r){const a=document.createElement("tr");return a.setAttribute("data-row-key",s),i&&a.classList.add("kupola-table-row-selected"),this.draggable&&(a.draggable=!0,a.classList.add("kupola-table-draggable")),this.selection&&this._renderSelectionCell(a,s,i),this.expandable&&this._renderExpandCell(a,s),this.columns.forEach((i,o)=>{if(n.has(`${e}-${o}`))return;const l=this._renderDataCell(t,e,s,i,o,n,r);a.appendChild(l)}),this.onRowClick&&(a.style.cursor="pointer",a.addEventListener("click",s=>{s.target.closest(".kupola-table-expand-btn, .kupola-table-tree-toggle, input, button")||this.onRowClick(t,e,s)})),a}_renderSelectionCell(t,e,s){const i=document.createElement("td");i.className="kupola-table-col-selection";const n=document.createElement("input");n.type=this.selection,n.checked=s,n.addEventListener("change",()=>{"radio"===this.selection?(this._selectedKeys.clear(),this._selectedKeys.add(e)):s?this._selectedKeys.delete(e):this._selectedKeys.add(e),this.selectedKeys.value=[...this._selectedKeys],this.onSelect&&this.onSelect([...this._selectedKeys],this.getSelectedRows()),this.render()}),i.appendChild(n),t.appendChild(i)}_renderExpandCell(t,e){const s=document.createElement("td");s.className="kupola-table-col-expand";const i=document.createElement("button");i.className="kupola-table-expand-btn",i.textContent=this._expandedKeys.has(e)?"▼":"▶",i.type="button",i.addEventListener("click",()=>this._toggleExpand(e)),s.appendChild(i),t.appendChild(s)}_renderDataCell(t,e,s,i,n,r,a){const o=document.createElement("td");i.align&&(o.style.textAlign=i.align),i.fixed&&(o.setAttribute("data-fixed",i.fixed),o.classList.add(`kupola-table-fixed-${i.fixed}`));const l=a.get(`${e}-${n}`);if(l){l.rowSpan>1&&(o.rowSpan=l.rowSpan),l.colSpan>1&&(o.colSpan=l.colSpan);for(let t=0;t<(l.rowSpan||1);t++)for(let s=0;s<(l.colSpan||1);s++)0===t&&0===s||r.add(`${e+t}-${n+s}`)}this.tree&&0===n&&t._level>0&&this._renderTreeIndent(o,t);const h=this._editingCell&&this._editingCell.rowKey===s&&this._editingCell.colKey===i.key;if(h)o.appendChild(this._renderEditCell(i,t));else if(i.render){const s=i.render(t[i.key],t,e);"string"==typeof s?o.innerHTML=s:s instanceof HTMLElement&&o.appendChild(s)}else o.textContent=t[i.key]??"";return this.editable&&!h&&!1!==i.editable&&(o.classList.add("kupola-table-editable-cell"),o.addEventListener("dblclick",()=>this._startEdit(s,i.key,t[i.key]))),o}_renderTreeIndent(t,e){const s=document.createElement("span");if(s.className="kupola-table-tree-indent",s.style.paddingLeft=20*e._level+"px",t.appendChild(s),e._hasChildren){const s=document.createElement("button");s.className="kupola-table-tree-toggle",s.textContent=this._treeExpandedKeys.has(e[this.rowKey])?"▼":"▶",s.type="button",s.addEventListener("click",t=>{t.stopPropagation(),this._toggleTreeExpand(e[this.rowKey])}),t.appendChild(s)}else{const e=document.createElement("span");e.className="kupola-table-tree-toggle-placeholder",t.appendChild(e)}}_renderStatusRow(t,e){const s=document.createElement("tr"),i=document.createElement("td");return i.colSpan=this.columns.length+(this.selection?1:0)+(this.expandable?1:0),i.className=e,i.textContent=t,s.appendChild(i),s}_renderVirtualTbody(t){const e=document.createElement("tbody"),{rowHeight:s=40,overscan:i=5}=this.virtualScroll,n=t.length*s;if(this._loading)return this._renderTbody(t);if(0===t.length)return this._renderTbody(t);const r=document.createElement("tr");r.className="kupola-table-virtual-spacer-top",r.style.height="0px",e.appendChild(r),this._virtualData={data:t,rowHeight:s,overscan:i,totalHeight:n,tbody:e,topSpacer:r},this._updateVirtualScroll();const a=document.createElement("tr");a.className="kupola-table-virtual-spacer-bottom",a.style.height="0px",e.appendChild(a);const o=this.element.querySelector(".kupola-table-container");return o&&(o.style.maxHeight=this.virtualScroll.maxHeight||"400px",o.style.overflowY="auto",this._scrollHandler&&o.removeEventListener("scroll",this._scrollHandler),this._scrollHandler=()=>this._updateVirtualScroll(),o.addEventListener("scroll",this._scrollHandler)),e}_updateVirtualScroll(){if(!this._virtualData)return;const{data:t,rowHeight:e,overscan:s,tbody:i,topSpacer:n}=this._virtualData,r=this.element.querySelector(".kupola-table-container");if(!r)return;const a=r.scrollTop,o=r.clientHeight,l=Math.max(0,Math.floor(a/e)-s),h=Math.min(t.length,Math.ceil((a+o)/e)+s);i.querySelectorAll(".kupola-table-virtual-row").forEach(t=>t.remove());const c=document.createDocumentFragment();for(let s=l;s<h;s++){const i=t[s],n=i[this.rowKey]??s,r=this._renderDataRow(i,s,n,this._selectedKeys.has(n),new Set,new Map);r.classList.add("kupola-table-virtual-row"),r.style.height=e+"px",c.appendChild(r)}n.style.height=l*e+"px";const d=i.querySelector(".kupola-table-virtual-spacer-bottom");d&&(d.style.height=(t.length-h)*e+"px"),n.after(c)}_renderEditCell(t,e){const s=document.createElement("div");s.className="kupola-table-edit-cell";const i=document.createElement("input");if(i.type=t.editType||"text",i.className="ds-input kupola-table-edit-input",i.value=this._editBuffer[t.key]??e[t.key]??"",t.editOptions){const e=document.createElement("select");e.className="ds-input kupola-table-edit-input",t.editOptions.forEach(t=>{const s=document.createElement("option");s.value="object"==typeof t?t.value:t,s.textContent="object"==typeof t?t.label:t,String(s.value)===String(i.value)&&(s.selected=!0),e.appendChild(s)}),e.addEventListener("change",()=>{this._editBuffer[t.key]=e.value}),s.appendChild(e)}else i.addEventListener("input",()=>{this._editBuffer[t.key]=i.value}),s.appendChild(i);const n=document.createElement("div");n.className="kupola-table-edit-actions";const r=document.createElement("button");r.className="kupola-table-edit-save",r.textContent="✓",r.type="button",r.addEventListener("click",()=>this._saveEdit(e,t));const a=document.createElement("button");return a.className="kupola-table-edit-cancel",a.textContent="✗",a.type="button",a.addEventListener("click",()=>this._cancelEdit()),n.appendChild(r),n.appendChild(a),s.appendChild(n),i.addEventListener("keydown",s=>{"Enter"===s.key&&this._saveEdit(e,t),"Escape"===s.key&&this._cancelEdit()}),setTimeout(()=>i.focus?.(),0),s}_startEdit(t,e,s){this._editingCell={rowKey:t,colKey:e},this._editBuffer={[e]:s},this.render()}_saveEdit(t,e){const s=this._editBuffer[e.key];this.onEditSave?this.onEditSave(t,e.key,s,this._data):t[e.key]=s,this._editingCell=null,this._editBuffer={},this.render()}_cancelEdit(){this.onEditCancel&&this.onEditCancel(this._editingCell),this._editingCell=null,this._editBuffer={},this.render()}_handleSort(t){if(this.multiSort){const e=this._sorts.findIndex(e=>e.key===t);if(e>=0){const t=this._sorts[e];"asc"===t.order?t.order="desc":this._sorts.splice(e,1)}else this._sorts.push({key:t,order:"asc"})}else{const e=this._sorts.find(e=>e.key===t);e?"asc"===e.order?e.order="desc":this._sorts=[]:this._sorts=[{key:t,order:"asc"}]}this.sortKey.value=this._sorts.map(t=>t.key).join(","),this.sortOrder.value=this._sorts.map(t=>t.order).join(","),this._currentPage=1,this.onSort&&this.onSort(this._sorts),this.render()}_toggleExpand(t){this._expandedKeys.has(t)?this._expandedKeys.delete(t):this._expandedKeys.add(t),this.onExpand&&this.onExpand(t,this._expandedKeys.has(t)),this.render()}_toggleTreeExpand(t){this._treeExpandedKeys.has(t)?this._treeExpandedKeys.delete(t):this._treeExpandedKeys.add(t),this.render()}selectRow(t){this._selectedKeys.add(t),this._syncSelected(),this.render()}deselectRow(t){this._selectedKeys.delete(t),this._syncSelected(),this.render()}selectAll(){this.getProcessedData().forEach(t=>this._selectedKeys.add(t[this.rowKey])),this._syncSelected(),this.render()}deselectAll(){this._selectedKeys.clear(),this._syncSelected(),this.render()}invertSelection(){this.getProcessedData().forEach(t=>{const e=t[this.rowKey];this._selectedKeys.has(e)?this._selectedKeys.delete(e):this._selectedKeys.add(e)}),this._syncSelected(),this.render()}getSelectedKeys(){return[...this._selectedKeys]}getSelectedRows(){return(this.tree?this._flattenForExpand(this._data):this._data).filter(t=>this._selectedKeys.has(t[this.rowKey]))}_syncSelected(){this.selectedKeys.value=[...this._selectedKeys]}_initColumnResize(){this.element.querySelectorAll(".kupola-table-resize-handle").forEach(t=>{t.addEventListener("mousedown",e=>{e.preventDefault();const s=t.getAttribute("data-col-key"),i=t.parentElement,n=e.clientX,r=i.offsetWidth,a=t=>{const e=Math.max(50,r+(t.clientX-n));i.style.width=e+"px";const a=this.columns.find(t=>t.key===s);a&&(a.width=e),this.onColumnResize&&this.onColumnResize(s,e)},o=()=>{document.removeEventListener("mousemove",a),document.removeEventListener("mouseup",o)};document.addEventListener("mousemove",a),document.addEventListener("mouseup",o),this._resizeCleanups.push(o)})})}_initRowDrag(){this.element.querySelectorAll("tbody tr[data-row-key]").forEach(t=>{t.addEventListener("dragstart",e=>{this._dragState={fromKey:t.getAttribute("data-row-key")},t.classList.add("kupola-table-dragging"),e.dataTransfer.effectAllowed="move"}),t.addEventListener("dragover",e=>{e.preventDefault(),e.dataTransfer.dropEffect="move",t.classList.add("kupola-table-drag-over")}),t.addEventListener("dragleave",()=>t.classList.remove("kupola-table-drag-over")),t.addEventListener("drop",e=>this._handleRowDrop(e,t)),t.addEventListener("dragend",()=>{t.classList.remove("kupola-table-dragging"),this._dragState=null})})}_handleRowDrop(t,e){if(t.preventDefault(),e.classList.remove("kupola-table-drag-over"),!this._dragState)return;const s=e.getAttribute("data-row-key");if(this._dragState.fromKey===s)return;const i=this._data.findIndex(t=>String(t[this.rowKey])===this._dragState.fromKey),n=this._data.findIndex(t=>String(t[this.rowKey])===s);if(i>=0&&n>=0){const[t]=this._data.splice(i,1);this._data.splice(n,0,t),this.onRowDragEnd&&this.onRowDragEnd(t,i,n,this._data),this.render()}}_applyStickyColumns(){const t=this.columns.filter(t=>"left"===t.fixed);this.selection,this.expandable,t.forEach(t=>{const e=this.element.querySelectorAll('th[data-fixed="left"]'),s=this.element.querySelectorAll('td[data-fixed="left"]'),i=this.columns.indexOf(t);let n=(this.selection?40:0)+(this.expandable?40:0);for(let t=0;t<i;t++)"left"===this.columns[t].fixed&&(n+=this.columns[t]._resolvedWidth||120);e.forEach(e=>{e.textContent.startsWith(t.title||t.key)&&(e.style.position="sticky",e.style.left=n+"px",e.style.zIndex="2",t._resolvedWidth=e.offsetWidth)}),s.forEach(t=>{t.style.position="sticky",t.style.left=n+"px",t.style.zIndex="1",t.style.background="inherit"})});let e=0;[...this.columns].filter(t=>"right"===t.fixed).reverse().forEach(t=>{this.element.querySelectorAll('td[data-fixed="right"]').forEach(t=>{t.style.position="sticky",t.style.right=e+"px",t.style.zIndex="1"}),e+=t._resolvedWidth||t.width||120})}_renderToolbar(){const t=document.createElement("div");if(t.className="kupola-table-toolbar",this.options.showFilter){const e=document.createElement("input");e.type="text",e.className="ds-input kupola-table-filter-input",e.placeholder=this.options.filterPlaceholder||"搜索...",e.value=this._filterText,e.addEventListener("input",()=>{clearTimeout(this._filterDebounceTimer),this._filterDebounceTimer=setTimeout(()=>{this._filterText=e.value,this._currentPage=1,this.filterText.value=this._filterText,this.onFilter&&this.onFilter(this._filterText),this.render()},300)}),t.appendChild(e)}const e=document.createElement("div");if(e.className="kupola-table-toolbar-right",this.selection&&this._selectedKeys.size>0){const t=document.createElement("span");t.className="kupola-table-selection-info",t.textContent=`已选 ${this._selectedKeys.size} 项`,e.appendChild(t);const s=document.createElement("button");s.className="ds-btn ds-btn--sm",s.textContent="反选",s.type="button",s.addEventListener("click",()=>this.invertSelection()),e.appendChild(s)}if(this.options.showExport){const t=document.createElement("button");t.className="ds-btn ds-btn--sm ds-btn--secondary",t.textContent="导出 CSV",t.type="button",t.addEventListener("click",()=>this.exportCSV()),e.appendChild(t)}const s=document.createElement("span");return s.className="kupola-table-info",s.textContent=`共 ${this._total} 条`,e.appendChild(s),t.appendChild(e),t}_renderPagination(){const t=Math.ceil(this._total/this._pageSize);if(t<=1)return document.createElement("div");const e=document.createElement("div");if(e.className="kupola-table-pagination",this.options.showPageSize){const t=document.createElement("select");t.className="kupola-table-page-size",this._pageSizes.forEach(e=>{const s=document.createElement("option");s.value=e,s.textContent=`${e} 条/页`,e===this._pageSize&&(s.selected=!0),t.appendChild(s)}),t.addEventListener("change",()=>{this._pageSize=parseInt(t.value),this._currentPage=1,this.currentPage.value=1,this.render()}),e.appendChild(t)}const s=document.createElement("div");s.className="kupola-table-pages";const i=this._createPageBtn("‹",()=>this._goToPage(this._currentPage-1));i.disabled=this._currentPage<=1,s.appendChild(i),this._getPageRange(this._currentPage,t).forEach(t=>{if("..."===t){const t=document.createElement("span");t.className="kupola-table-page-ellipsis",t.textContent="...",s.appendChild(t)}else{const e=this._createPageBtn(t,()=>this._goToPage(t));t===this._currentPage&&e.classList.add("active"),s.appendChild(e)}});const n=this._createPageBtn("›",()=>this._goToPage(this._currentPage+1));n.disabled=this._currentPage>=t,s.appendChild(n),e.appendChild(s);const r=document.createElement("span");return r.className="kupola-table-page-info",r.textContent=`${this._currentPage} / ${t}`,e.appendChild(r),e}_createPageBtn(t,e){const s=document.createElement("button");return s.className="kupola-table-page-btn",s.textContent=t,s.type="button",s.addEventListener("click",e),s}_goToPage(t){const e=Math.ceil(this._total/this._pageSize);t<1||t>e||(this._currentPage=t,this.currentPage.value=t,this.onPageChange&&this.onPageChange(t,this._pageSize),this.render())}_getPageRange(t,e){if(e<=7)return Array.from({length:e},(t,e)=>e+1);const s=[];if(t<=3){for(let t=1;t<=5;t++)s.push(t);s.push("...",e)}else if(t>=e-2){s.push(1,"...");for(let t=e-4;t<=e;t++)s.push(t)}else{s.push(1,"...");for(let e=t-1;e<=t+1;e++)s.push(e);s.push("...",e)}return s}exportCSV(t="export.csv"){const e=this.getProcessedData(),s=this.columns.map(t=>t.title||t.key),i=e.map(t=>this.columns.map(e=>{let s=t[e.key];return null==s&&(s=""),s=String(s).replace(/"/g,'""'),`"${s}"`}).join(",")),n="\ufeff"+[s.join(","),...i].join("\n"),r=new Blob([n],{type:"text/csv;charset=utf-8;"}),a=URL.createObjectURL(r),o=document.createElement("a");o.href=a,o.download=t,o.click(),URL.revokeObjectURL(a)}_getTableClass(){const t=["kupola-table"];return this.striped&&t.push("kupola-table-striped"),this.bordered&&t.push("kupola-table-bordered"),this.hoverable&&t.push("kupola-table-hover"),this.compact&&t.push("kupola-table-compact"),t.join(" ")}refresh(){this.render()}getPage(){return{current:this._currentPage,pageSize:this._pageSize,total:this._total}}setColumns(t){this.columns=t.map((t,e)=>({...t,_index:e})),this.render()}destroy(){if(this._scrollHandler){const t=this.element.querySelector(".kupola-table-container");t&&t.removeEventListener("scroll",this._scrollHandler),this._scrollHandler=null}this._filterDebounceTimer&&(clearTimeout(this._filterDebounceTimer),this._filterDebounceTimer=null),this._resizeCleanups.forEach(t=>t()),this._resizeCleanups=[],this._reactiveCleanups.forEach(t=>t.unsubscribe()),this._reactiveCleanups=[],this.element.innerHTML="",this.element.classList.remove("kupola-table-wrapper","kupola-table-virtual-wrapper"),this._data=[],this._virtualData=null,this._dragState=null,this._editingCell=null,this._editBuffer={}}}function is(t,e){return new ss(t,e)}rt.register("table",is);class ns{constructor(t,e={}){this.element="string"==typeof t?document.querySelector(t):t,this.options=e,this._current=e.current||1,this._total=e.total||0,this._pageSize=e.pageSize||10,this._maxPages=e.maxPages||7,this._showTotal=!1!==e.showTotal,this._showSizeChanger=e.showSizeChanger||!1,this._pageSizes=e.pageSizes||[10,20,50,100],this._simple=e.simple||!1,this.current=W(this._current),this.total=W(this._total),this.onChange=e.onChange||null,this.onPageSizeChange=e.onPageSizeChange||null,this._init()}_init(){this.element.classList.add("kupola-pagination"),this.render()}get totalPages(){return Math.max(1,Math.ceil(this._total/this._pageSize))}setCurrent(t){(t=Math.max(1,Math.min(t,this.totalPages)))!==this._current&&(this._current=t,this.current.value=t,this.onChange&&this.onChange(t,this._pageSize),this.render())}setTotal(t){t&&"object"==typeof t&&"value"in t?(this._total=t.value||0,t._subscribers?.add(t=>{this._total=t||0,this._current>this.totalPages?this.setCurrent(this.totalPages):this.render()})):this._total=t,this.total.value=this._total,this.render()}setPageSize(t){this._pageSize=t,this._current=1,this.current.value=1,this.onPageSizeChange&&this.onPageSizeChange(t,this._current),this.render()}render(){const t=this.element;t.innerHTML="",this._total<=0||(this._simple?this._renderSimple(t):this._renderFull(t))}_renderSimple(t){const e=this.totalPages,s=this._btn("‹",()=>this.setCurrent(this._current-1));s.disabled=this._current<=1,t.appendChild(s);const i=document.createElement("span");i.className="kupola-pagination-simple-info",i.textContent=`${this._current} / ${e}`,t.appendChild(i);const n=this._btn("›",()=>this.setCurrent(this._current+1));n.disabled=this._current>=e,t.appendChild(n)}_renderFull(t){const e=this.totalPages;if(this._showTotal){const e=document.createElement("span");e.className="kupola-pagination-total",e.textContent=`共 ${this._total} 条`,t.appendChild(e)}if(this._showSizeChanger){const e=document.createElement("select");e.className="kupola-pagination-size",this._pageSizes.forEach(t=>{const s=document.createElement("option");s.value=t,s.textContent=`${t} 条/页`,t===this._pageSize&&(s.selected=!0),e.appendChild(s)}),e.addEventListener("change",()=>this.setPageSize(parseInt(e.value))),t.appendChild(e)}const s=document.createElement("div");s.className="kupola-pagination-pages";const i=this._btn("‹",()=>this.setCurrent(this._current-1));i.disabled=this._current<=1,s.appendChild(i),this._getPageRange().forEach(t=>{if("..."===t){const t=document.createElement("span");t.className="kupola-pagination-ellipsis",t.textContent="···",s.appendChild(t)}else{const e=this._btn(t,()=>this.setCurrent(t));t===this._current&&e.classList.add("active"),s.appendChild(e)}});const n=this._btn("›",()=>this.setCurrent(this._current+1));if(n.disabled=this._current>=e,s.appendChild(n),t.appendChild(s),e>10){const s=document.createElement("span");s.className="kupola-pagination-jumper",s.innerHTML='跳至 <input type="number" min="1" max="'+e+'" value="'+this._current+'"> 页';const i=s.querySelector("input");i.addEventListener("change",()=>{const t=parseInt(i.value);t>=1&&t<=e&&this.setCurrent(t)}),i.addEventListener("keydown",t=>{if("Enter"===t.key){const t=parseInt(i.value);t>=1&&t<=e&&this.setCurrent(t)}}),t.appendChild(s)}}_btn(t,e){const s=document.createElement("button");return s.className="kupola-pagination-btn",s.textContent=t,s.type="button",s.addEventListener("click",e),s}_getPageRange(){const t=this.totalPages,e=this._maxPages;if(t<=e)return Array.from({length:t},(t,e)=>e+1);const s=[],i=Math.floor(e/2);if(this._current<=i+1){for(let t=1;t<=e-2;t++)s.push(t);s.push("...",t)}else if(this._current>=t-i){s.push(1,"...");for(let i=t-e+3;i<=t;i++)s.push(i)}else{s.push(1,"...");for(let t=this._current-i+2;t<=this._current+i-2;t++)s.push(t);s.push("...",t)}return s}destroy(){this.element.innerHTML="",this.element.classList.remove("kupola-pagination")}}let rs=!1;let as=!1;class os extends HTMLElement{static get observedAttributes(){return["open"]}connectedCallback(){this._render()}_render(){const t=this.querySelector('[slot="trigger"]'),e=this.querySelectorAll('[slot="item"]'),s=document.createElement("div");s.className="ds-dropdown",s.setAttribute("data-dropdown",""),t&&(t.setAttribute("class",(t.getAttribute("class")||"")+" ds-dropdown__trigger"),s.appendChild(t));const i=document.createElement("div");i.className="ds-dropdown__menu",e.forEach(t=>{t.className="ds-dropdown__item",i.appendChild(t)}),s.appendChild(i),this.innerHTML="",this.appendChild(s)}attributeChangedCallback(t,e,s){if("open"===t){const t=this.querySelector(".ds-dropdown__menu");t&&(t.style.display=null!==s?"block":"")}}}class ls extends HTMLElement{static get observedAttributes(){return["title","position"]}connectedCallback(){const t=this.firstElementChild;t&&(t.setAttribute("data-title",this.getAttribute("title")||""),this.getAttribute("position")&&t.setAttribute("data-tooltip-position",this.getAttribute("position")))}attributeChangedCallback(t,e,s){if("title"===t){const t=this.firstElementChild;t&&t.setAttribute("data-title",s||"")}}}class hs extends HTMLElement{connectedCallback(){this._render()}_render(){const t=document.createElement("div");t.className="ds-collapse",t.setAttribute("data-collapse","");this.querySelectorAll("k-collapse-item").forEach(e=>{const s=e.getAttribute("title")||"",i=e.innerHTML,n=document.createElement("div");n.className="ds-collapse__item",n.innerHTML=`\n <button class="ds-collapse__header">\n <span>${s}</span>\n <svg class="icon ds-collapse__chevron" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="6 9 12 15 18 9"/></svg>\n </button>\n <div class="ds-collapse__body"><div class="ds-collapse__content">${i}</div></div>\n `,t.appendChild(n)}),this.innerHTML="",this.appendChild(t)}}class cs extends HTMLElement{static get observedAttributes(){return["title"]}}class ds extends HTMLElement{static get observedAttributes(){return["position","open"]}connectedCallback(){this._render()}_render(){const t=this.getAttribute("position")||"left",e=document.createElement("div");e.className=`ds-drawer ds-drawer--${t}`,e.setAttribute("data-drawer",""),e.innerHTML=this.innerHTML,this.innerHTML="",this.appendChild(e)}attributeChangedCallback(t,e,s){if("open"===t){const t=this.querySelector(".ds-drawer");t&&t.classList.toggle("is-open",null!==s)}}}class us extends HTMLElement{static get observedAttributes(){return["title","open"]}connectedCallback(){this._render()}_render(){const t=this.getAttribute("title")||"",e=document.createElement("div");e.className="ds-backdrop",e.style.display="none",e.innerHTML=`\n <div class="ds-dialog">\n <div class="ds-dialog__head">\n <span class="ds-dialog__title">${t}</span>\n <button class="ds-dialog__close" aria-label="Close">\n <svg class="icon" 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>\n </button>\n </div>\n <div class="ds-dialog__body"></div>\n <div class="ds-dialog__foot"></div>\n </div>\n `;const s=e.querySelector(".ds-dialog__body"),i=this.querySelector('[slot="body"]');i&&s.appendChild(i);const n=e.querySelector(".ds-dialog__foot"),r=this.querySelector('[slot="footer"]');r&&n.appendChild(r);const a=e.querySelector(".ds-dialog__close");a&&a.addEventListener("click",()=>this.close()),e.addEventListener("click",t=>{t.target===e&&this.close()}),this.innerHTML="",this.appendChild(e)}attributeChangedCallback(t,e,s){if("open"===t){const t=this.querySelector(".ds-backdrop");t&&(t.style.display=null!==s?"flex":"none")}}open(){this.setAttribute("open","")}close(){this.removeAttribute("open")}}t.BRAND_OPTIONS=G,t.CacheEntry=Ve,t.CacheManager=Ke,t.Calendar=Gt,t.Carousel=Ht,t.Collapse=Wt,t.ColorPicker=Xt,t.ComponentInitializerRegistry=nt,t.Countdown=Me,t.Datepicker=kt,t.DependsError=je,t.DependsSource=Ue,t.Dialog=class{static normal(t={}){return this._create({type:"normal",...t})}static success(t={}){return this._create({type:"success",...t})}static warning(t={}){return this._create({type:"warning",...t})}static error(t={}){return this._create({type:"error",...t})}static info(t={}){return this._create({type:"info",...t})}static confirm(t={}){return this._create({type:"confirm",...t})}static _create(t){const{type:e="normal",title:s="",content:i="",onConfirm:n,onCancel:r}=t,a={normal:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="12" y1="16" x2="12" y2="12"/><line x1="12" y1="8" x2="12.01" y2="8"/></svg>',success:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="20 6 9 17 4 12"/></svg>',warning:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M12 9v4M12 17h.01"/><path d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"/></svg>',error:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="15" y1="9" x2="9" y2="15"/><line x1="9" y1="9" x2="15" y2="15"/></svg>',info:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="12" y1="16" x2="12" y2="12"/><line x1="12" y1="8" x2="12.01" y2="8"/></svg>',confirm:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M12 9v4M12 17h.01"/><path d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"/></svg>'},o=document.createElement("div");o.className="ds-modal-container",o.innerHTML=`\n <div class="ds-modal-mask">\n <div class="ds-modal" style="max-width: 360px">\n <div class="ds-modal__body" style="text-align: center; padding: 24px 16px;">\n <div class="ds-dialog__icon ds-dialog__icon--${e}">${a[e]}</div>\n ${s?'<div class="ds-dialog__title"></div>':""}\n <div class="ds-dialog__content"></div>\n <div class="ds-dialog__actions">\n ${"confirm"===e||r?'<button class="ds-btn ds-btn--ghost" data-dialog-cancel>Cancel</button>':""}\n <button class="ds-btn ${"confirm"===e?"ds-btn--brand":"ds-btn--ghost"}" data-dialog-confirm>\n ${"confirm"===e?"Confirm":"OK"}\n </button>\n </div>\n </div>\n </div>\n </div>\n `,document.body.appendChild(o),s&&(o.querySelector(".ds-dialog__title").textContent=s),o.querySelector(".ds-dialog__content").textContent=i;const l=o.querySelector(".ds-modal-mask"),h=o.querySelector("[data-dialog-confirm]"),c=o.querySelector("[data-dialog-cancel]"),d=function(t){"Escape"===t.key&&(r&&r(),g())},u=function(t){t.target===l&&(r&&r(),g())},p=function(){n&&n(),g()},m=function(){r&&r(),g()},g=()=>{l.classList.remove("is-visible"),document.body.style.overflow="",document.removeEventListener("keydown",d),l.removeEventListener("click",u),h&&h.removeEventListener("click",p),c&&c.removeEventListener("click",m),setTimeout(()=>o.remove(),300)};return l.classList.add("is-visible"),document.body.style.overflow="hidden",h&&h.addEventListener("click",p),c&&c.addEventListener("click",m),l.addEventListener("click",u),document.addEventListener("keydown",d),{close:g}}},t.Drawer=At,t.Dropdown=gt,t.DynamicTags=ee,t.FetchedSource=Ye,t.FileUpload=Vt,t.FunctionSource=Ze,t.GlobalEvents=pt,t.Heatmap=ue,t.Icons=De,t.ImagePreview=ne,t.KupolaComponent=ot,t.KupolaComponentRegistry=ht,t.KupolaDataBind=R,t.KupolaEventBus=j,t.KupolaForm=Fe,t.KupolaI18n=dt,t.KupolaLifecycle=e,t.KupolaPagination=ns,t.KupolaStore=V,t.KupolaStoreManager=K,t.KupolaTable=ss,t.KupolaUtils=q,t.KupolaValidator=ve,t.Message=Bt,t.Modal=qt,t.Notification=Ot,t.NumberInput=Te,t.PATHS=Ce,t.RouteSource=Je,t.Scheduler=Be,t.Select=ft,t.SlideCaptcha=$e,t.Slider=Lt,t.StatCard=he,t.StaticSource=Ge,t.StorageSource=Xe,t.Tag=ae,t.Timepicker=xt,t.Tooltip=_e,t.VirtualList=ke,t.WebSocketSource=Qe,t.alertModal=function(t){return"string"==typeof t&&(t={content:t}),Pt({...t,showCancel:!1,showConfirm:!0})},t.applyMixin=lt,t.arrayUtils=o,t.bootstrapComponents=function(e){return t.kupolaRegistry?t.kupolaRegistry.bootstrap(e):Promise.resolve()},t.cleanupAllDropdowns=function(){document.querySelectorAll(".ds-dropdown").forEach(t=>{yt(t)})},t.cleanupAllSlideCaptchas=Ne,t.cleanupCalendar=te,t.cleanupCarousel=Tt,t.cleanupCollapse=Yt,t.cleanupColorPicker=Zt,t.cleanupCountdown=Ie,t.cleanupDatepicker=wt,t.cleanupDrawer=$t,t.cleanupDropdown=yt,t.cleanupDynamicTags=ie,t.cleanupFileUpload=jt,t.cleanupHeatmap=me,t.cleanupModal=Ft,t.cleanupNumberInput=ze,t.cleanupSelect=bt,t.cleanupSlideCaptcha=Pe,t.cleanupSlider=Mt,t.cleanupStatCard=de,t.cleanupTag=le,t.cleanupTimepicker=St,t.cleanupTooltip=fe,t.cleanupVirtualList=xe,t.clearCache=function(){},t.configureHttpClient=function(t){if(!t||"function"!=typeof t.fetch)throw new TypeError("[Kupola] configureHttpClient: client must provide a fetch function");We=t.fetch.bind(t)},t.confirmModal=function(t){return"string"==typeof t&&(t={content:t}),Pt({...t,showCancel:!0,showConfirm:!0})},t.createBrandPicker=function(){const t=document.createElement("div");t.id="brand-picker-auto",t.style.position="fixed",t.style.top="56px",t.style.right="16px",t.style.zIndex="9998",t.style.display="none",t.style.padding="12px",t.style.width="200px",t.style.gridTemplateColumns="repeat(3, 1fr)",t.style.gap="6px",t.style.backgroundColor="var(--bg-base-secondary)",t.style.border="1px solid var(--border-neutral-l1)",t.style.borderRadius="8px",t.style.boxShadow="0 4px 20px rgba(0, 0, 0, 0.2)",t.style.overflow="hidden",G.forEach(e=>{const s=document.createElement("button");s.setAttribute("data-brand-btn",e.id),s.style.display="flex",s.style.justifyContent="center",s.style.alignItems="center",s.style.height="60px",s.style.backgroundColor=e.color,s.style.color=["#32F08C","#FF9900","#E2C027","#0EB0C9","#B1A6CC"].includes(e.color)?"#0C0C0D":"#FFFFFF",s.style.fontWeight="500",s.style.borderRadius="4px",s.style.border="none",s.style.cursor="pointer",s.style.margin="0",s.style.padding="0",s.textContent=e.name,t.appendChild(s)}),document.body.appendChild(t);const e=document.createElement("button");e.setAttribute("data-brand-toggle",""),e.setAttribute("data-current-brand",et()),e.className="ds-btn ds-btn--ghost ds-btn--sm",e.style.position="fixed",e.style.top="16px",e.style.right="56px",e.style.zIndex="9999",e.style.display="flex",e.style.alignItems="center",e.style.gap="6px";const s=document.createElement("span");s.className="brand-icon",s.style.width="12px",s.style.height="12px",s.style.borderRadius="50%",s.style.backgroundColor=G.find(t=>t.id===et()).color;const i=document.createElement("span");function n(s){t.contains(s.target)||e.contains(s.target)||(t.style.display="none",document.removeEventListener("click",n,!0))}return i.className="brand-name",i.style.fontSize="11px",i.textContent=G.find(t=>t.id===et()).name,e.appendChild(s),e.appendChild(i),document.body.appendChild(e),e.onclick=function(e){e.stopPropagation(),e.preventDefault();const s="none"===t.style.display;t.style.display=s?"grid":"none",s?setTimeout(()=>{document.addEventListener("click",n,!0)},0):document.removeEventListener("click",n,!0)},t.onclick=function(t){t.stopPropagation()},t.querySelectorAll("[data-brand-btn]").forEach(e=>{e.addEventListener("click",s=>{s.stopPropagation();st(e.getAttribute("data-brand-btn")),t.style.display="none"})}),{toggleBtn:e,container:t}},t.createI18n=function(t){return new dt(t)},t.createLifecycle=function(t="app"){return new e(t)},t.createModal=Pt,t.createSource=ts,t.createStore=function(t,e){return X.createStore(t,e)},t.createThemeToggle=function(){const t=document.createElement("button");t.setAttribute("data-theme-toggle",""),t.setAttribute("data-current-theme",Q()),t.className="ds-btn ds-btn--ghost ds-btn--sm ds-btn--icon",t.style.position="fixed",t.style.top="16px",t.style.right="16px",t.style.zIndex="9999";const e=document.createElement("img");e.className="theme-icon";const s=document.getElementsByTagName("script"),i=s[s.length-1],n=i.src.substring(0,i.src.lastIndexOf("/")+1);return e.src="dark"===Q()?n+"../icons/sun.svg":n+"../icons/moon.svg",e.width=14,e.height=14,e.alt="Toggle theme",t.appendChild(e),document.body.appendChild(t),t.addEventListener("click",()=>{tt("dark"===Q()?"light":"dark")}),t},t.cryptoUtils=H,t.dateUtils=b,t.debounce=k,t.defineComponent=function(e,s){if(!s||"object"!=typeof s)throw new Error(`defineComponent("${e}"): options must be an object`);s.componentClass?t.kupolaRegistry&&t.kupolaRegistry.register(e,s.componentClass):s.lazy&&t.kupolaRegistry&&t.kupolaRegistry.registerLazy(e,s.lazy),s.init?rt.register(e,s.init,s.cleanup||null,{dataAttribute:s.dataAttribute,cssClass:s.cssClass}):(s.dataAttribute||s.cssClass)&&rt.register(e,()=>{},null,{dataAttribute:s.dataAttribute,cssClass:s.cssClass})},t.defineMixin=function(e,s){t.kupolaRegistry&&t.kupolaRegistry.defineMixin(e,s)},t.emit=function(t,e,s){return mt.emit(t,e,s)},t.emitGlobal=function(t,e){return mt.emitGlobal(t,e)},t.formatCurrency=function(t,e,s={}){return ut.formatCurrency(t,e,s)},t.formatDate=function(t,e={}){return ut.formatDate(t,e)},t.formatNumber=function(t,e={}){return ut.formatNumber(t,e)},t.getBrand=et,t.getFormInstance=function(t){return t._kupolaForm},t.getHttpClient=function(){return We},t.getListenerCount=function(t,e){return mt.getListenerCount(t,e)},t.getLocale=function(){return ut.getLocale()},t.getStore=function(t){return X.getStore(t)},t.getTheme=Q,t.globalEvents=mt,t.initAllTables=function(){document.querySelectorAll("[data-kupola-table]").forEach(t=>{const e=t.getAttribute("data-kupola-table");let s={};if(e)try{s=JSON.parse(e)}catch(t){}is(t,s)})},t.initCalendar=Qt,t.initCalendars=function(){document.querySelectorAll(".ds-calendar").forEach(t=>{Qt(t)})},t.initCarousel=It,t.initCarousels=function(t=document){t.querySelectorAll(".ds-carousel").forEach(t=>{It(t)})},t.initCollapse=Ut,t.initCollapses=function(){document.querySelectorAll(".ds-collapse").forEach(t=>{Ut(t)})},t.initColorPicker=Jt,t.initColorPickers=function(t=document){t.querySelectorAll(".ds-color-picker").forEach(t=>{Jt(t)})},t.initCountdown=He,t.initCountdowns=function(){document.querySelectorAll(".ds-countdown").forEach(t=>{He(t)})},t.initDatepicker=Et,t.initDatepickers=function(t=document){t.querySelectorAll(".ds-datepicker").forEach(t=>{Et(t)})},t.initDrawer=zt,t.initDrawers=function(){document.querySelectorAll("[data-drawer]").forEach(t=>{t.addEventListener("click",()=>{const e=t.getAttribute("data-drawer"),s=document.getElementById(e);s&&(zt(s,{placement:t.getAttribute("data-drawer-placement")||"right",width:t.getAttribute("data-drawer-width"),height:t.getAttribute("data-drawer-height")}),s.__kupolaInstance?.open())})}),document.querySelectorAll(".ds-drawer-mask").forEach(t=>{const e=t.parentElement;e&&zt(e)})},t.initDropdown=_t,t.initDropdowns=function(t=document){t.querySelectorAll(".ds-dropdown").forEach(t=>{_t(t)})},t.initDynamicTags=se,t.initDynamicTagsAll=function(){document.querySelectorAll(".ds-dynamic-tags").forEach(t=>{se(t)})},t.initFileUpload=Kt,t.initFileUploads=function(){document.querySelectorAll(".ds-fileupload").forEach(t=>{Kt(t)})},t.initFormValidation=Oe,t.initHeatmap=pe,t.initHeatmaps=function(){document.querySelectorAll(".ds-heatmap").forEach(t=>{pe(t)})},t.initImagePreview=function(){re||(re=new ne),document.querySelectorAll("[data-image-preview]").forEach(t=>{t.addEventListener("click",()=>{const e=JSON.parse(t.getAttribute("data-image-preview")),s=parseInt(t.getAttribute("data-image-index"))||0;re.show(e,s)})})},t.initMessages=function(){},t.initModal=Nt,t.initModals=function(){document.querySelectorAll(".ds-modal-container").forEach(t=>{Nt(t)})},t.initNotifications=function(){},t.initNumberInput=Ae,t.initNumberInputs=function(){document.querySelectorAll(".ds-number-input").forEach(t=>{Ae(t)})},t.initPagination=function(t,e){return function(){if(rs||"undefined"==typeof document)return;const t=document.createElement("style");t.textContent="\n .kupola-pagination { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }\n .kupola-pagination-pages { display: flex; gap: 4px; align-items: center; }\n .kupola-pagination-btn { min-width: 32px; height: 32px; border: 1px solid #d9d9d9; border-radius: 4px; background: #fff; cursor: pointer; font-size: 14px; display: flex; align-items: center; justify-content: center; transition: all 0.2s; }\n .kupola-pagination-btn:hover:not(:disabled):not(.active) { border-color: #1890ff; color: #1890ff; }\n .kupola-pagination-btn.active { background: #1890ff; color: #fff; border-color: #1890ff; }\n .kupola-pagination-btn:disabled { opacity: 0.4; cursor: not-allowed; }\n .kupola-pagination-ellipsis { padding: 0 4px; color: #999; user-select: none; }\n .kupola-pagination-total { color: #666; font-size: 14px; }\n .kupola-pagination-size { padding: 4px 8px; border: 1px solid #d9d9d9; border-radius: 4px; font-size: 13px; }\n .kupola-pagination-simple-info { padding: 0 8px; font-size: 14px; color: #333; }\n .kupola-pagination-jumper { font-size: 14px; color: #666; }\n .kupola-pagination-jumper input { width: 50px; height: 28px; margin: 0 4px; padding: 0 8px; border: 1px solid #d9d9d9; border-radius: 4px; text-align: center; font-size: 13px; }\n .kupola-pagination-jumper input:focus { outline: none; border-color: #1890ff; }\n ",document.head.appendChild(t),rs=!0}(),new ns(t,e)},t.initSelect=vt,t.initSelects=function(t=document){t.querySelectorAll(".ds-select").forEach(t=>{vt(t)})},t.initSlideCaptchas=qe,t.initSlider=Dt,t.initSliders=function(){document.querySelectorAll(".ds-slider").forEach(t=>{Dt(t)})},t.initStatCard=ce,t.initStatCards=function(){document.querySelectorAll(".ds-statcard").forEach(t=>{ce(t)})},t.initTable=is,t.initTag=oe,t.initTags=function(){document.querySelectorAll(".ds-tag").forEach(t=>{oe(t)})},t.initTheme=it,t.initTimepicker=Ct,t.initTimepickers=function(t=document){t.querySelectorAll(".ds-timepicker").forEach(t=>{Ct(t)})},t.initTooltip=ye,t.initTooltips=function(t=document){t.querySelectorAll("[data-tooltip]").forEach(t=>{ye(t)})},t.initVirtualList=we,t.kupolaBootstrap=ct,t.kupolaData=U,t.kupolaEvents=Y,t.kupolaI18n=ut,t.kupolaInitializer=rt,t.kupolaLifecycle=s,t.kupolaStoreManager=X,t.n=function(t,e,s={}){return ut.n(t,e,s)},t.numberUtils=p,t.objectUtils=h,t.off=function(t,e,s){mt.off(t,e,s)},t.offAll=function(t,e){mt.offAll(t,e)},t.offByScope=function(t){mt.offByScope(t)},t.on=function(t,e,s,i){return mt.on(t,e,s,i)},t.once=function(t,e,s,i){return mt.once(t,e,s,i)},t.preloadUtils=$,t.ref=W,t.registerComponent=function(e,s){t.kupolaRegistry&&t.kupolaRegistry.register(e,s)},t.registerLazyComponent=function(e,s){t.kupolaRegistry&&t.kupolaRegistry.registerLazy(e,s)},t.registerWebComponents=function(){if(as||"undefined"==typeof customElements)return;as=!0;const t=[["k-dropdown",os],["k-tooltip",ls],["k-collapse",hs],["k-collapse-item",cs],["k-drawer",ds],["k-modal",us]];for(const[e,s]of t)customElements.get(e)||customElements.define(e,s)},t.renderIcon=Le,t.resetHttpClient=function(){We="undefined"!=typeof globalThis&&globalThis.fetch?globalThis.fetch.bind(globalThis):"undefined"!=typeof window&&window.fetch?window.fetch.bind(window):null},t.setBrand=st,t.setLocale=function(t){return ut.setLocale(t)},t.setTheme=tt,t.showImagePreview=function(t,e=0){re||(re=new ne),re.show(t,e)},t.stringUtils=r,t.svg=Se,t.t=function(t,e={}){return ut.t(t,e)},t.throttle=E,t.useDeps=function(t,e){const s={},i=new Ke,n=[];for(const r in e){let a=e[r];"string"==typeof a&&(a={source:a});const o=ts({...a,cacheKey:a.cacheKey||`${r}-${JSON.stringify(es(t))}`},i),l=W(null),h=W(!0),c=W(null),d=W(null);let u=0;async function p(){const e=++u;h.value=!0,c.value=null;try{const s=await o.getValue(es(t));if(e!==u)return;l.value=s,d.value=Date.now()}catch(t){if(e!==u)return;c.value=t.message||"Unknown error"}finally{e===u&&(h.value=!1)}}p();const m=o.subscribe(()=>{const t=i.getStale(o.cacheKey);null!=t&&(l.value=t,d.value=Date.now())});n.push(m);const g=Object.keys(t);g.length>0&&g.forEach(e=>{const s=t[e];if(s&&"object"==typeof s&&"value"in s&&s._subscribers){const t=()=>{o.invalidate(),p()};s._subscribers.add(t),n.push(()=>s._subscribers.delete(t))}}),s[r]={data:l,loading:h,error:c,lastUpdated:d,refresh:()=>(o.invalidate(),p()),setValue(t){o instanceof Xe&&(o.setValue(t),l.value=t)},send(t){o instanceof Qe&&o.send(t)},_source:o}}return s._dispose=()=>{if(n.forEach(t=>t()),window.__kupolaDepInstances){const t=window.__kupolaDepInstances.indexOf(s);-1!==t&&window.__kupolaDepInstances.splice(t,1)}},window.__kupolaDepInstances||(window.__kupolaDepInstances=[]),window.__kupolaDepInstances.push(s),s},t.useMixin=function(e,...s){t.kupolaRegistry&&t.kupolaRegistry.useMixin(e,...s)},t.useQuery=function(t){const e=new Ke,s=ts(t,e),i=W(null),n=W(!0),r=W(null);let a=0;async function o(){const e=++a;n.value=!0,r.value=null;try{const n=await s.getValue(t.params||{});if(e!==a)return;i.value=n}catch(t){if(e!==a)return;r.value=t.message||"Unknown error"}finally{e===a&&(n.value=!1)}}return o(),s.subscribe(()=>{const t=e.getStale(s.cacheKey);null!=t&&(i.value=t)}),{data:i,loading:n,error:r,refresh:()=>(s.invalidate(),o())}},t.validateForm=function(t){const e=t._kupolaForm;return!!e&&e.validate()},t.validator=be,t.validatorUtils=M});
|
|
2
|
-
//# sourceMappingURL=kupola.min.js.map
|