@kupola/kupola 1.9.11 → 1.9.13
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/css/scaffold.css +5 -35
- package/dist/{core-D0uN-4lt.cjs → core-Cs-VWZ5H.cjs} +1 -1
- package/dist/{core-oOQWnSRW.js → core-DBjFFC_n.js} +83 -83
- package/dist/core.cjs.js +1 -1
- package/dist/core.esm.js +1 -1
- package/dist/css/scaffold.css +5 -35
- package/dist/kupola.cjs.js +1 -1
- package/dist/kupola.css +5 -35
- package/dist/kupola.esm.js +2 -2
- package/dist/kupola.min.css +1 -1
- package/dist/plugins/vite-plugin-kupola.js +13 -2
- package/dist/plugins/webpack-plugin-kupola.js +13 -2
- package/dist/theme-preload.js +72 -4
- package/dist/theme-standalone.js +161 -104
- package/js/theme-preload.js +72 -4
- package/js/theme-standalone.js +161 -104
- package/js/theme.js +371 -371
- package/package.json +1 -1
- package/plugins/vite-plugin-kupola.js +15 -4
- package/plugins/webpack-plugin-kupola.js +14 -3
package/dist/kupola.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./core-D0uN-4lt.cjs");class e{constructor(e,i={}){this.element=e,this.trigger=e.querySelector(".ds-dropdown__trigger"),this.menu=e.querySelector(".ds-dropdown__menu"),this.triggerText=this.trigger?this.trigger.querySelector("span"):null,this.scope=`dropdown-${Math.random().toString(36).substr(2,9)}`;const s=t.getUiConfig();this.triggerMode=i.trigger||e.getAttribute("data-dropdown-trigger")||"click",this.hoverDelay=i.hoverDelay||parseInt(e.getAttribute("data-dropdown-hover-delay"))||150,this.disabled=i.disabled||e.hasAttribute("data-dropdown-disabled"),this.keyboardNav=!1!==i.keyboardNav,this.autoPosition=!1!==i.autoPosition,this.closeOnClick=void 0!==i.closeOnClick?i.closeOnClick:void 0===s.dropdown?.closeOnClick||s.dropdown.closeOnClick,this.appendToBody=!1!==i.appendToBody,this.onSelect=i.onSelect||null,this.onShow=i.onShow||null,this.onHide=i.onHide||null,this.isOpen=!1,this.focusIndex=-1,this._hoverTimer=null,this._hoverLeaveTimer=null,this._originalParent=null,this._originalPosition=null,this._triggerClickHandler=null,this._documentClickHandler=null,this._documentClickListener=null,this._itemClickHandler=null,this._keydownHandler=null,this._mouseenterHandler=null,this._mouseleaveHandler=null,this._triggerMouseenterHandler=null,this._triggerMouseleaveHandler=null,this._triggerKeydownHandler=null}init(){this.trigger&&this.menu&&(this.element.__kupolaInitialized||(this._itemClickHandler=t=>{t.stopPropagation();const e=t.currentTarget;e.classList.contains("is-disabled")||e.classList.contains("ds-dropdown__divider")||(this.menu.querySelectorAll(".ds-dropdown__item").forEach(t=>t.classList.remove("is-selected")),e.classList.add("is-selected"),this.triggerText&&!e.hasAttribute("data-no-update-trigger")&&(this.triggerText.textContent=e.textContent.trim()),this.element.setAttribute("data-value",e.getAttribute("data-value")||""),this.onSelect&&this.onSelect({item:e,value:e.getAttribute("data-value"),text:e.textContent.trim()}),!1!==this.closeOnClick&&(this.hideMenu(),this.trigger&&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=>{if(!this.isOpen)return;const e=this.element.contains(t.target),i=this.menu&&this.menu.contains(t.target);e||i||this.hideMenu()},this._documentClickListener=t.globalEvents.on(document,"click",this._documentClickHandler,{scope:this.scope}),this.menu.style.display="none",this.element.__kupolaInitialized=!0))}_bindMenuItems(){this.menu.querySelectorAll(".ds-dropdown__item").forEach(t=>{t._dropdownItemClickHandler=t=>this._itemClickHandler(t),t.addEventListener("click",t._dropdownItemClickHandler)})}_getNavigableItems(){return Array.from(this.menu.querySelectorAll(".ds-dropdown__item")).filter(t=>!t.classList.contains("is-disabled")&&!t.classList.contains("ds-dropdown__divider"))}_focusItem(t){t.forEach(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=window.innerHeight,i=window.innerWidth;if(this.menu.classList.remove("ds-dropdown--top","ds-dropdown--right","ds-dropdown--dropup"),this.appendToBody){this.menu.style.width=`${t.width}px`;const s=this.menu.getBoundingClientRect(),n=e-t.bottom,a=t.top;n<s.height&&a>n?(this.menu.style.top=t.top-s.height-4+"px",this.menu.style.bottom="auto"):(this.menu.style.top=`${t.bottom+4}px`,this.menu.style.bottom="auto"),t.left+s.width>i?(this.menu.style.left=t.right-s.width+"px",this.menu.style.right="auto"):(this.menu.style.left=`${t.left}px`,this.menu.style.right="auto")}else{const s=e-t.bottom,n=t.top;s<menuRect.height&&n>s?(this.menu.classList.add("ds-dropdown--dropup"),this.menu.style.top="auto",this.menu.style.bottom="100%",this.menu.style.marginBottom="4px"):(this.menu.style.top="100%",this.menu.style.bottom="auto",this.menu.style.marginBottom="0"),t.left+menuRect.width>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.element.classList.add("is-open"),this.appendToBody&&(this._appendMenuToBody(),this._addScrollListener()),this.menu.style.display="block",this._calculatePosition(),this.onShow&&this.onShow(),this.element.dispatchEvent(new CustomEvent("kupola:dropdown-show",{bubbles:!0})))}hideMenu(){this.isOpen&&(this.isOpen=!1,this.menu.style.display="none",this.element.classList.remove("is-open"),this.appendToBody&&(this._restoreMenuFromBody(),this._removeScrollListener()),this.menu.querySelectorAll(".ds-dropdown__item").forEach(t=>t.classList.remove("is-focused")),this.onHide&&this.onHide(),this.element.dispatchEvent(new CustomEvent("kupola:dropdown-hide",{bubbles:!0})))}_appendMenuToBody(){if(!this.menu)return;this._originalParent=this.menu.parentNode,this._originalPosition=this.menu.style.position,this._originalTop=this.menu.style.top,this._originalLeft=this.menu.style.left,this._originalRight=this.menu.style.right,this._originalBottom=this.menu.style.bottom,this._originalMarginBottom=this.menu.style.marginBottom,this._originalWidth=this.menu.style.width,this._originalTransform=this.menu.style.transform,this._originalZIndex=this.menu.style.zIndex,this._originalDisplay=this.menu.style.display;const e=this.element.getBoundingClientRect(),i=t.getZIndexConfig().dropdown;this.menu.style.position="fixed",this.menu.style.width=`${e.width}px`,this.menu.style.zIndex=i,this.menu.style.transform="translateZ(0)",document.body.appendChild(this.menu)}_restoreMenuFromBody(){this.menu&&this._originalParent&&(this._originalParent.appendChild(this.menu),this.menu.style.position=this._originalPosition||"",this.menu.style.top=this._originalTop||"",this.menu.style.left=this._originalLeft||"",this.menu.style.right=this._originalRight||"",this.menu.style.bottom=this._originalBottom||"",this.menu.style.marginBottom=this._originalMarginBottom||"",this.menu.style.width=this._originalWidth||"",this.menu.style.zIndex=this._originalZIndex||"",this.menu.style.transform=this._originalTransform||"",this.menu.style.display=this._originalDisplay||"",this._originalParent=null,console.log("[Dropdown] Menu restored from body"))}_addScrollListener(){this._scrollHandler=()=>{this.hideMenu()},window.addEventListener("scroll",this._scrollHandler,!0)}_removeScrollListener(){this._scrollHandler&&(window.removeEventListener("scroll",this._scrollHandler,!0),this._scrollHandler=null)}toggleMenu(){this.isOpen?this.hideMenu():this.showMenu()}enable(){this.disabled=!1,this.element.removeAttribute("data-dropdown-disabled")}disable(){this.disabled=!0,this.element.setAttribute("data-dropdown-disabled",""),this.hideMenu()}setItems(t){this._itemClickHandler||(this._itemClickHandler=t=>{t.stopPropagation();const e=t.currentTarget;e.classList.contains("is-disabled")||e.classList.contains("ds-dropdown__divider")||(this.menu.querySelectorAll(".ds-dropdown__item").forEach(t=>t.classList.remove("is-selected")),e.classList.add("is-selected"),this.triggerText&&!e.hasAttribute("data-no-update-trigger")&&(this.triggerText.textContent=e.textContent.trim()),this.element.setAttribute("data-value",e.getAttribute("data-value")||""),this.onSelect&&this.onSelect({item:e,value:e.getAttribute("data-value"),text:e.textContent.trim()}),!1!==this.closeOnClick&&(this.hideMenu(),this.trigger&&this.trigger.focus()))}),this.menu.querySelectorAll(".ds-dropdown__item").forEach(t=>{t._dropdownItemClickHandler&&t.removeEventListener("click",t._dropdownItemClickHandler)}),this.menu.innerHTML="",t.forEach((t,e)=>{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"),e._dropdownItemClickHandler=t=>this._itemClickHandler(t),e.addEventListener("click",e._dropdownItemClickHandler),this.menu.appendChild(e)}})}destroy(){this.element.__kupolaInitialized&&(clearTimeout(this._hoverTimer),clearTimeout(this._hoverLeaveTimer),this.trigger&&(this._triggerClickHandler&&this.trigger.removeEventListener("click",this._triggerClickHandler),this._triggerMouseenterHandler&&this.trigger.removeEventListener("mouseenter",this._triggerMouseenterHandler),this._triggerMouseleaveHandler&&this.trigger.removeEventListener("mouseleave",this._triggerMouseleaveHandler),this._triggerKeydownHandler&&this.trigger.removeEventListener("keydown",this._triggerKeydownHandler)),this.menu&&(this.menu.querySelectorAll(".ds-dropdown__item").forEach(t=>{t._dropdownItemClickHandler&&t.removeEventListener("click",t._dropdownItemClickHandler)}),this._mouseenterHandler&&this.menu.removeEventListener("mouseenter",this._mouseenterHandler),this._mouseleaveHandler&&this.menu.removeEventListener("mouseleave",this._mouseleaveHandler)),this._keydownHandler&&document.removeEventListener("keydown",this._keydownHandler),this._documentClickListener&&this._documentClickListener.unsubscribe?this._documentClickListener.unsubscribe():this._documentClickHandler&&document.removeEventListener("click",this._documentClickHandler),this.appendToBody&&this._originalParent&&this._restoreMenuFromBody(),this._documentClickHandler=null,this._documentClickListener=null,this._triggerClickHandler=null,this._itemClickHandler=null,this._keydownHandler=null,this._mouseenterHandler=null,this._mouseleaveHandler=null,this._triggerMouseenterHandler=null,this._triggerMouseleaveHandler=null,this._triggerKeydownHandler=null,this.element.__kupolaInitialized=!1)}}function i(t,i){t._kupolaDropdown&&t._kupolaDropdown.destroy();const s=new e(t,i);s.init(),t._kupolaDropdown=s}function s(t){t._kupolaDropdown&&(t._kupolaDropdown.destroy(),t._kupolaDropdown=null)}t.kupolaInitializer.register("dropdown",i,s);class n{constructor(t,e={}){this.element=t,this.trigger=t.querySelector(".ds-select__trigger"),this.valueEl=t.querySelector(".ds-select__value")||t.querySelector(".ds-select__trigger span"),this.optionsEl=t.querySelector(".ds-select__options")||t.querySelector(".ds-select__menu"),this.nativeSelect=t.querySelector("select"),this.icon=t.querySelector(".ds-select__icon"),this.scope=`select-${Math.random().toString(36).substr(2,9)}`,this.multiple=e.multiple||t.hasAttribute("data-select-multiple"),this.searchable=e.searchable||t.hasAttribute("data-select-search"),this.clearable=e.clearable||t.hasAttribute("data-select-clear"),this.placeholder=e.placeholder||t.getAttribute("data-select-placeholder")||"",this.disabled=e.disabled||t.hasAttribute("data-select-disabled"),this.maxSelection=e.maxSelection||parseInt(t.getAttribute("data-select-max"))||1/0,this.remoteMethod=e.remoteMethod||null,this.onChange=e.onChange||null,this.appendToBody=!1!==e.appendToBody,this.isOpen=!1,this.selectedValues=new Set,this.allOptions=[],this.filteredOptions=[],this.focusIndex=-1,this.searchInput=null,this.clearBtn=null,this.tagsWrap=null,this._originalParent=null,this._originalPosition=null,this._triggerClickHandler=null,this._documentClickHandler=null,this._documentClickListener=null,this._optionClickHandler=null,this._keydownHandler=null}init(){this.trigger&&this.optionsEl&&(this.element.__kupolaInitialized||(this._collectOptions(),this.searchable&&this._createSearchInput(),this.clearable&&this._createClearButton(),this.multiple&&this._createTagsWrap(),this.placeholder&&this.valueEl&&(this.valueEl.setAttribute("data-placeholder",this.placeholder),this.selectedValues.size||(this.valueEl.classList.add("ds-select__value--placeholder"),this.valueEl.textContent=this.placeholder)),this._optionClickHandler=t=>{t.stopPropagation();const e=t.currentTarget;if(e.classList.contains("is-disabled"))return;const i=e.getAttribute("data-value");this.multiple?this._toggleMultiOption(i,e):this._selectSingleOption(i,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=>{if(!this.isOpen)return;const e=this.element.contains(t.target),i=this.optionsEl&&this.optionsEl.contains(t.target);e||i||this.hideOptions()},this._documentClickListener=t.globalEvents.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"),i=this.filteredOptions.some(t=>t.group===e);t.style.display=i?"":"none"}),this.focusIndex=-1)}_renderRemoteOptions(t){this._optionClickHandler||(this._optionClickHandler=t=>{t.stopPropagation();const e=t.currentTarget;if(e.classList.contains("is-disabled"))return;const i=e.getAttribute("data-value");this.multiple?this._toggleMultiOption(i,e):this._selectSingleOption(i,e)}),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._selectOptionClickHandler=t=>this._optionClickHandler(t),e.addEventListener("click",e._selectOptionClickHandler),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 i=document.createElement("span");i.className="ds-select__tag",i.textContent=e.text;const s=document.createElement("button");s.className="ds-select__tag-close",s.type="button",s.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>',s.addEventListener("click",e=>{e.stopPropagation(),this.selectedValues.delete(t);const i=this.optionsEl.querySelector(`[data-value="${t}"]`);i&&i.classList.remove("is-selected"),this._updateTags(),this._updateValueDisplay(),this._syncNativeSelect(),this._updateClearBtn(),this._fireChange()}),i.appendChild(s),this.tagsWrap.appendChild(i)}))}_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._selectOptionClickHandler=t=>this._optionClickHandler(t),t.addEventListener("click",t._selectOptionClickHandler)})}_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.element.classList.add("is-open"),this.icon&&(this.icon.style.transform="rotate(180deg)"),this.focusIndex=-1,this.appendToBody&&(this._appendOptionsToBody(),this._addScrollListener()),this.optionsEl.style.display="block",this._calculateOptionsPosition(),this.searchInput&&setTimeout(()=>this.searchInput.focus(),50))}hideOptions(){this.isOpen&&(this.isOpen=!1,this.optionsEl.style.display="none",this.icon&&(this.icon.style.transform="rotate(0deg)"),this.element.classList.remove("is-open"),this.appendToBody&&(this._restoreOptionsFromBody(),this._removeScrollListener()),this.searchInput&&(this.searchInput.value="",this._handleSearch()),this.optionsEl.querySelectorAll(".ds-select__option, .ds-select__item").forEach(t=>t.classList.remove("is-focused")))}_addScrollListener(){this._scrollHandler=()=>{this.hideOptions()},window.addEventListener("scroll",this._scrollHandler,!0)}_removeScrollListener(){this._scrollHandler&&(window.removeEventListener("scroll",this._scrollHandler,!0),this._scrollHandler=null)}_appendOptionsToBody(){if(!this.optionsEl)return;this._originalParent=this.optionsEl.parentNode,this._originalPosition=this.optionsEl.style.position,this._originalTop=this.optionsEl.style.top,this._originalLeft=this.optionsEl.style.left,this._originalRight=this.optionsEl.style.right,this._originalWidth=this.optionsEl.style.width,this._originalTransform=this.optionsEl.style.transform,this._originalZIndex=this.optionsEl.style.zIndex;const e=this.element.getBoundingClientRect(),i=t.getZIndexConfig().dropdown;this.optionsEl.style.position="fixed",this.optionsEl.style.width=`${e.width}px`,this.optionsEl.style.zIndex=i,this.optionsEl.style.transform="translateZ(0)",document.body.appendChild(this.optionsEl)}_restoreOptionsFromBody(){this.optionsEl&&this._originalParent&&(this._originalParent.appendChild(this.optionsEl),this.optionsEl.style.position=this._originalPosition||"",this.optionsEl.style.top=this._originalTop||"",this.optionsEl.style.left=this._originalLeft||"",this.optionsEl.style.right=this._originalRight||"",this.optionsEl.style.width=this._originalWidth||"",this.optionsEl.style.zIndex=this._originalZIndex||"",this.optionsEl.style.transform=this._originalTransform||"",this._originalParent=null)}_calculateOptionsPosition(){if(!this.appendToBody||!this.optionsEl)return;const t=this.element.getBoundingClientRect(),e=window.innerHeight,i=window.innerWidth;this.optionsEl.style.width=`${t.width}px`;const s=this.optionsEl.getBoundingClientRect(),n=e-t.bottom,a=t.top;n<s.height&&a>n?this.optionsEl.style.top=t.top-s.height-4+"px":this.optionsEl.style.top=`${t.bottom+4}px`,t.left+s.width>i?this.optionsEl.style.left=t.right-s.width+"px":this.optionsEl.style.left=`${t.left}px`}toggleOptions(){this.isOpen?this.hideOptions():this.showOptions()}clear(){this.selectedValues.clear(),this.optionsEl.querySelectorAll(".ds-select__option, .ds-select__item").forEach(t=>t.classList.remove("is-selected")),this._updateTags(),this._updateValueDisplay(),this._syncNativeSelect(),this._updateClearBtn(),this._fireChange()}getSelectedOptions(){return Array.from(this.selectedValues).map(t=>{const e=this.allOptions.find(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 i=e.getAttribute("data-value")===t;e.classList.toggle("is-selected",i),i&&this.updateValue(e.textContent.trim())})),this._syncNativeSelect(),this._updateClearBtn()}enable(){this.disabled=!1,this.element.removeAttribute("data-select-disabled")}disable(){this.disabled=!0,this.element.setAttribute("data-select-disabled",""),this.hideOptions()}destroy(){this.element.__kupolaInitialized&&(this.trigger&&this._triggerClickHandler&&this.trigger.removeEventListener("click",this._triggerClickHandler),this.optionsEl&&this.optionsEl.querySelectorAll(".ds-select__option, .ds-select__item").forEach(t=>{t._selectOptionClickHandler&&t.removeEventListener("click",t._selectOptionClickHandler)}),this._keydownHandler&&document.removeEventListener("keydown",this._keydownHandler),this._documentClickListener&&this._documentClickListener.unsubscribe?this._documentClickListener.unsubscribe():this._documentClickHandler&&document.removeEventListener("click",this._documentClickHandler),this.searchInput&&this.searchInput.remove(),this.clearBtn&&this.clearBtn.remove(),this.tagsWrap&&this.tagsWrap.remove(),this.appendToBody&&this._originalParent&&this._restoreOptionsFromBody(),this._documentClickHandler=null,this._documentClickListener=null,this._triggerClickHandler=null,this._optionClickHandler=null,this._keydownHandler=null,this.element.__kupolaInitialized=!1)}}function a(t,e){const i=new n(t,e);i.init(),t._kupolaSelect=i}function l(t){t._kupolaSelect&&(t._kupolaSelect.destroy(),t._kupolaSelect=null)}t.kupolaInitializer.register("select",a,l);class r{constructor(e,i={}){this.element=e,this.input=e.querySelector("input"),this.endInput=e.querySelector(".ds-datepicker__end-input"),this.icon=e.querySelector(".ds-datepicker__icon"),this.calendarEl=e.querySelector(".ds-datepicker__calendar"),this.scope=`datepicker-${Math.random().toString(36).substr(2,9)}`;const s=t.getUiConfig(),n=void 0!==s.datepicker?.weekStart?s.datepicker.weekStart:1;this.format=i.format||e.getAttribute("data-datepicker-format")||"YYYY-MM-DD",this.range=i.range||e.hasAttribute("data-datepicker-range"),this.minDate=i.minDate||e.getAttribute("data-datepicker-min")||null,this.maxDate=i.maxDate||e.getAttribute("data-datepicker-max")||null,this.disabledDate=i.disabledDate||null,this.weekStart=void 0!==i.weekStart?i.weekStart:parseInt(e.getAttribute("data-datepicker-week-start"))||n,this.appendToBody=!1!==i.appendToBody,this.placeholder=i.placeholder||e.getAttribute("data-datepicker-placeholder")||"",this.showToday=!1!==i.showToday,this.showWeekNumber=i.showWeekNumber||e.hasAttribute("data-datepicker-week-number"),this.onChange=i.onChange||null,this.months=i.months||["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],this.weekDays=i.weekDays||["Su","Mo","Tu","We","Th","Fr","Sa"],this.todayText=i.todayText||"Today",this.clearText=i.clearText||"Clear",this.currentDate=new Date,this.viewMode="days",this.selectedDate=null,this.rangeStart=null,this.rangeEnd=null,this.isSelectingEnd=!1,this._iconClickHandler=null,this._inputClickHandler=null,this._endInputClickHandler=null,this._documentClickHandler=null,this._originalParent=null,this._documentClickListener=null,this._resizeHandler=null,this._resizeListener=null,this._keydownHandler=null}init(){if(this.calendarEl&&!this.element.__kupolaInitialized){if(this.input&&this.input.value)if(this.range){const t=this.input.value.split(" ~ ");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=t.globalEvents.on(document,"click",t=>this.hideCalendar(t),{scope:this.scope}),this._resizeListener=t.globalEvents.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(),i=String(t.getMonth()+1).padStart(2,"0"),s=String(t.getDate()).padStart(2,"0");return this.format.replace("YYYY",e).replace("MM",i).replace("DD",s)}_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(),i=Math.min(this.rangeStart.getTime(),this.rangeEnd.getTime()),s=Math.max(this.rangeStart.getTime(),this.rangeEnd.getTime());return e>=i&&e<=s}calculatePosition(){const t=this.element.getBoundingClientRect(),e=this.calendarEl.getBoundingClientRect(),i=window.innerHeight-t.bottom,s=t.top,n=e.height||320;this.appendToBody?(this.calendarEl.style.left=`${t.left}px`,i>=n?(this.calendarEl.style.top=`${t.bottom+4}px`,this.calendarEl.style.bottom="auto"):s>=n?(this.calendarEl.style.top=t.top-n-4+"px",this.calendarEl.style.bottom="auto"):(this.calendarEl.style.top=`${t.bottom+4}px`,this.calendarEl.style.bottom="auto")):i>=n?(this.calendarEl.style.top="calc(100% + 4px)",this.calendarEl.style.bottom="auto"):s>=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.appendToBody&&(this._appendCalendarToBody(),this._addScrollListener()),this.calendarEl.style.display="block",this.calendarEl.removeAttribute("hidden"),this.calculatePosition())}hideCalendar(t){this.element.contains(t.target)||this.calendarEl.contains(t.target)||(this.calendarEl.style.display="none",this.calendarEl.setAttribute("hidden",""),this.viewMode="days",this.appendToBody&&(this._restoreCalendarFromBody(),this._removeScrollListener()))}_addScrollListener(){this._scrollHandler=()=>{this.hideCalendar({target:document})},window.addEventListener("scroll",this._scrollHandler,!0)}_removeScrollListener(){this._scrollHandler&&(window.removeEventListener("scroll",this._scrollHandler,!0),this._scrollHandler=null)}_appendCalendarToBody(){if(!this.calendarEl)return;this._originalParent=this.calendarEl.parentNode,this._originalPosition=this.calendarEl.style.position,this._originalTop=this.calendarEl.style.top,this._originalLeft=this.calendarEl.style.left,this._originalWidth=this.calendarEl.style.width,this._originalTransform=this.calendarEl.style.transform,this._originalZIndex=this.calendarEl.style.zIndex;const e=t.getZIndexConfig().datepicker;this.calendarEl.style.position="fixed",this.calendarEl.style.zIndex=e,this.calendarEl.style.transform="translateZ(0)",document.body.appendChild(this.calendarEl)}_restoreCalendarFromBody(){this.calendarEl&&this._originalParent&&(this._originalParent.appendChild(this.calendarEl),this.calendarEl.style.position=this._originalPosition||"",this.calendarEl.style.top=this._originalTop||"",this.calendarEl.style.left=this._originalLeft||"",this.calendarEl.style.width=this._originalWidth||"",this.calendarEl.style.zIndex=this._originalZIndex||"",this.calendarEl.style.transform=this._originalTransform||"",this._originalParent=null)}resizeHandler(){"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(),i=this.currentDate.getMonth();t.innerHTML="";const s=document.createElement("div");s.className="ds-datepicker__header";const n=document.createElement("button");n.className="ds-datepicker__nav ds-datepicker__nav--prev",n.type="button",n.innerHTML='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="15 18 9 12 15 6"/></svg>',n.addEventListener("click",t=>{t.stopPropagation(),this._prevMonth()});const a=document.createElement("button");a.className="ds-datepicker__title",a.type="button",a.textContent=`${e} ${this.months[i]}`,a.addEventListener("click",t=>{t.stopPropagation(),this.viewMode="months",this._renderCalendar()});const l=document.createElement("button");l.className="ds-datepicker__nav ds-datepicker__nav--next",l.type="button",l.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>',l.addEventListener("click",t=>{t.stopPropagation(),this._nextMonth()}),s.appendChild(n),s.appendChild(a),s.appendChild(l),t.appendChild(s);const r=document.createElement("div");r.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,r.appendChild(e)}),t.appendChild(r);const o=document.createElement("div");o.className="ds-datepicker__days";const h=new Date(e,i,1).getDay(),d=new Date(e,i+1,0).getDate(),c=(h-this.weekStart+7)%7;for(let u=0;u<c;u++){const t=document.createElement("span");t.className="ds-datepicker__day ds-datepicker__day--empty",o.appendChild(t)}for(let u=1;u<=d;u++){const t=new Date(e,i,u),s=document.createElement("button");s.className="ds-datepicker__day",s.type="button",s.textContent=u,this._formatDate(t),this._isToday(t)&&s.classList.add("is-today"),this.range?((this._isSameDay(t,this.rangeStart)||this._isSameDay(t,this.rangeEnd))&&s.classList.add("is-selected"),this._isInRange(t)&&s.classList.add("is-in-range")):this._isSameDay(t,this.selectedDate)&&s.classList.add("is-selected"),this._isDateDisabled(t)&&(s.classList.add("is-disabled"),s.disabled=!0);const n=()=>this._selectDate(t);s.addEventListener("click",n),s._dayClickHandler=n,o.appendChild(s)}if(t.appendChild(o),this.showToday){const e=document.createElement("div");e.className="ds-datepicker__footer";const i=document.createElement("button");i.className="ds-datepicker__today-btn",i.type="button",i.textContent=this.todayText,i.addEventListener("click",t=>{t.stopPropagation(),this._goToToday()});const s=document.createElement("button");s.className="ds-datepicker__clear-btn",s.type="button",s.textContent=this.clearText,s.addEventListener("click",t=>{t.stopPropagation(),this._clearDate()}),e.appendChild(i),e.appendChild(s),t.appendChild(e)}}_renderYearsView(){const t=this.calendarEl;t.innerHTML="";const e=this.currentDate.getFullYear(),i=e-6,s=document.createElement("div");s.className="ds-datepicker__header";const n=document.createElement("button");n.className="ds-datepicker__nav ds-datepicker__nav--prev",n.type="button",n.innerHTML='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="15 18 9 12 15 6"/></svg>',n.addEventListener("click",t=>{t.stopPropagation(),this.currentDate.setFullYear(this.currentDate.getFullYear()-12),this._renderCalendar()});const a=document.createElement("button");a.className="ds-datepicker__title",a.type="button",a.textContent=`${i} - ${i+11}`,a.addEventListener("click",t=>{t.stopPropagation()});const l=document.createElement("button");l.className="ds-datepicker__nav ds-datepicker__nav--next",l.type="button",l.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>',l.addEventListener("click",t=>{t.stopPropagation(),this.currentDate.setFullYear(this.currentDate.getFullYear()+12),this._renderCalendar()}),s.appendChild(n),s.appendChild(a),s.appendChild(l),t.appendChild(s);const r=document.createElement("div");r.className="ds-datepicker__years-grid";for(let o=0;o<12;o++){const t=i+o,s=document.createElement("button");s.className="ds-datepicker__year-cell",s.type="button",s.textContent=t,t===e&&s.classList.add("is-selected"),s.addEventListener("click",e=>{e.stopPropagation(),this.currentDate.setFullYear(t),this.viewMode="months",this._renderCalendar()}),r.appendChild(s)}t.appendChild(r)}_renderMonthsView(){const t=this.calendarEl;t.innerHTML="";const e=this.currentDate.getFullYear(),i=document.createElement("div");i.className="ds-datepicker__header";const s=document.createElement("button");s.className="ds-datepicker__nav ds-datepicker__nav--prev",s.type="button",s.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>',s.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 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()+1),this._renderCalendar()}),i.appendChild(s),i.appendChild(n),i.appendChild(a),t.appendChild(i);const l=document.createElement("div");l.className="ds-datepicker__months-grid",this.months.forEach((t,e)=>{const i=document.createElement("button");i.className="ds-datepicker__month-cell",i.type="button",i.textContent=t,e===this.currentDate.getMonth()&&i.classList.add("is-selected"),i.addEventListener("click",t=>{t.stopPropagation(),this.currentDate.setMonth(e),this.viewMode="days",this._renderCalendar()}),l.appendChild(i)}),t.appendChild(l)}_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.appendToBody&&this._originalParent&&this._restoreCalendarFromBody(),this._documentClickHandler=null,this._resizeHandler=null,this._documentClickListener=null,this._resizeListener=null,this._iconClickHandler=null,this._inputClickHandler=null,this._endInputClickHandler=null,this._keydownHandler=null,this.element.__kupolaInitialized=!1)}}function o(t,e){const i=new r(t,e);i.init(),t._kupolaDatepicker=i}function h(t){t._kupolaDatepicker&&(t._kupolaDatepicker.destroy(),t._kupolaDatepicker=null)}t.kupolaInitializer.register("datepicker",o,h);class d{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=t.globalEvents.on(document,"click",t=>this.hideTimepicker(t),{scope:this.scope}),this._resizeListener=t.globalEvents.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 i=t.split(":");i.length>=2&&(this.selectedHour=parseInt(i[0])||0,this.selectedMinute=parseInt(i[1])||0,this.selectedSecond=i[2]&&parseInt(i[2])||0)}_isTimeDisabled(t,e,i){if(this.disabledTime)return this.disabledTime(t,e,i);const s=3600*t+60*e+i;if(this.minTime){const t=this.minTime.split(":");if(s<3600*parseInt(t[0])+60*parseInt(t[1])+(parseInt(t[2])||0))return!0}if(this.maxTime){const t=this.maxTime.split(":");if(s>3600*parseInt(t[0])+60*parseInt(t[1])+(parseInt(t[2])||0))return!0}return!1}_formatTime(){let t=this.selectedHour,e=this.selectedMinute,i=this.selectedSecond;if(this.use12Hour){const s=t>=12?"PM":"AM";return t=t%12||12,this.showSeconds?`${t}:${String(e).padStart(2,"0")}:${String(i).padStart(2,"0")} ${s}`:`${t}:${String(e).padStart(2,"0")} ${s}`}return this.showSeconds?`${String(t).padStart(2,"0")}:${String(e).padStart(2,"0")}:${String(i).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(),i=window.innerHeight-t.bottom,s=t.top,n=e.height||320;i>=n?(this.panelEl.style.top="calc(100% + 4px)",this.panelEl.style.bottom="auto"):s>=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 i=document.createElement("button");i.type="button",i.className="ds-timepicker__item",i.textContent=String(e).padStart(2,"0"),i.dataset.value=e,i.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(i)}}_populateMinuteGrid(){const t=this.panelEl.querySelector('[data-type="minute"]');if(t)for(let e=0;e<60;e+=this.minuteStep){const i=document.createElement("button");i.type="button",i.className="ds-timepicker__item",i.textContent=String(e).padStart(2,"0"),i.dataset.value=e,i.addEventListener("click",()=>{this.selectedMinute=e,this._updateDisplay(),this._syncGridSelection("minute",e),this._confirmSelection()}),t.appendChild(i)}}_populateSecondGrid(){const t=this.panelEl.querySelector('[data-type="second"]');if(t)for(let e=0;e<60;e+=this.secondStep){const i=document.createElement("button");i.type="button",i.className="ds-timepicker__item",i.textContent=String(e).padStart(2,"0"),i.dataset.value=e,i.addEventListener("click",()=>{this.selectedSecond=e,this._updateDisplay(),this._syncGridSelection("second",e),this._confirmSelection()}),t.appendChild(i)}}_populateAmPmGrid(){const t=this.panelEl.querySelector('[data-type="ampm"]');t&&["AM","PM"].forEach(e=>{const i=document.createElement("button");i.type="button",i.className="ds-timepicker__item",i.textContent=e,i.dataset.value=e,i.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")),i.classList.add("is-selected"),this._confirmSelection()}),t.appendChild(i)})}_updateDisplay(){if(!this.panelEl)return;const t=this.panelEl.querySelector(".ds-timepicker__display-hour"),e=this.panelEl.querySelector(".ds-timepicker__display-minute"),i=this.panelEl.querySelector(".ds-timepicker__display-second"),s=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")),i&&(i.textContent=String(this.selectedSecond).padStart(2,"0")),s&&(s.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 i=this.panelEl.querySelector(`[data-type="${t}"]`);i&&i.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 i=e.querySelector(".is-selected");i&&i.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,i){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,i||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 c(t,e){const i=new d(t,e);i.init(),t._kupolaTimepicker=i}function u(t){t._kupolaTimepicker&&(t._kupolaTimepicker.destroy(),t._kupolaTimepicker=null)}t.kupolaInitializer.register("timepicker",c,u);class p{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 i=t;i<=e;i+=this.markStep){const s=document.createElement("div");s.className="ds-slider__mark";const n=(i-t)/(e-t)*100;this.vertical?s.style.bottom=n+"%":s.style.left=n+"%";const a=document.createElement("span");a.className="ds-slider__mark-label",a.textContent=i,s.appendChild(a),this.marksEl.appendChild(s)}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 i=t=>{this.disabled||(t.preventDefault(),this._isDragging=!0,this._activeThumb=e,this.element.classList.add("is-dragging"),document.addEventListener("mousemove",s),document.addEventListener("mouseup",n),document.addEventListener("touchmove",s,{passive:!1}),document.addEventListener("touchend",n))},s=t=>{if(!this._isDragging)return;t.preventDefault();const i=t.touches?t.touches[0].clientX:t.clientX,s=t.touches?t.touches[0].clientY:t.clientY,n=this.track.getBoundingClientRect();let a;a=this.vertical?1-(s-n.top)/n.height:(i-n.left)/n.width,a=Math.max(0,Math.min(1,a));const l=parseFloat(this.input?.min||0),r=parseFloat(this.input?.max||100),o=parseFloat(this.input?.step||1);let h=l+a*(r-l);if(h=Math.round(h/o)*o,h=Math.max(l,Math.min(r,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:a})},n=()=>{this._isDragging=!1,this._activeThumb=null,this.element.classList.remove("is-dragging"),document.removeEventListener("mousemove",s),document.removeEventListener("mouseup",n),document.removeEventListener("touchmove",s),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",i),t.addEventListener("touchstart",i,{passive:!1}),this._listeners.push({el:t,event:"mousedown",handler:i},{el:t,event:"touchstart",handler:i})}_handleTrackClick(t){if(t.target.classList.contains("ds-slider__thumb"))return;const e=this.track.getBoundingClientRect(),i=t.clientX,s=t.clientY;let n;n=this.vertical?1-(s-e.top)/e.height:(i-e.left)/e.width,n=Math.max(0,Math.min(1,n));const a=parseFloat(this.input?.min||0),l=parseFloat(this.input?.max||100),r=parseFloat(this.input?.step||1);let o=a+n*(l-a);if(o=Math.round(o/r)*r,this.range){const t=parseFloat(this.input?.value||0),e=parseFloat(this.inputEnd?.value||0);Math.abs(o-t)<=Math.abs(o-e)?this.input&&(this.input.value=Math.min(o,e)):this.inputEnd&&(this.inputEnd.value=Math.max(o,t))}else this.input&&(this.input.value=o);this.updateSlider()}_handleKeyboard(t,e){if(this.disabled)return;const i="start"===e?this.input:this.inputEnd;if(!i)return;const s=parseFloat(i.step||1),n=parseFloat(i.min||0),a=parseFloat(i.max||100);let l=parseFloat(i.value);switch(t.key){case"ArrowRight":case"ArrowUp":t.preventDefault(),l=Math.min(a,l+s);break;case"ArrowLeft":case"ArrowDown":t.preventDefault(),l=Math.max(n,l-s);break;case"Home":t.preventDefault(),l=n;break;case"End":t.preventDefault(),l=a;break;default:return}i.value=l,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 i=parseFloat(this.input?.value||0),s=parseFloat(this.inputEnd?.value||0),n=(i-t)/(e-t)*100,a=(s-t)/(e-t)*100;this.vertical?(this.fill.style.bottom=n+"%",this.fill.style.height=a-n+"%"):(this.fill.style.left=n+"%",this.fill.style.width=a-n+"%"),this.thumbStart&&(this.vertical?this.thumbStart.style.bottom=n+"%":this.thumbStart.style.left=n+"%"),this.thumbEnd&&(this.vertical?this.thumbEnd.style.bottom=a+"%":this.thumbEnd.style.left=a+"%"),this.tooltipStart&&(this.tooltipStart.textContent=this.tooltipFormat(i)),this.tooltipEnd&&(this.tooltipEnd.textContent=this.tooltipFormat(s)),this.valueEl&&(this.valueEl.textContent=`${this.tooltipFormat(i)} - ${this.tooltipFormat(s)}`),this.thumbStart&&this.thumbStart.setAttribute("aria-valuenow",i),this.thumbEnd&&this.thumbEnd.setAttribute("aria-valuenow",s)}else{const i=this.input?.value||0,s=(i-t)/(e-t)*100;this.vertical?this.fill.style.height=`${s}%`:this.fill.style.width=`${s}%`,this.thumbStart&&(this.vertical?this.thumbStart.style.bottom=s+"%":this.thumbStart.style.left=s+"%"),this.tooltipStart&&(this.tooltipStart.textContent=this.tooltipFormat(parseFloat(i))),this.valueEl&&(this.valueEl.textContent=this.tooltipFormat(parseFloat(i))),this.thumbStart&&this.thumbStart.setAttribute("aria-valuenow",i),this.element.setAttribute("aria-valuenow",i)}}destroy(){this._listeners?.forEach(({el:t,event:e,handler:i})=>{t.removeEventListener(e,i)}),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 m(t,e){if(!t.__kupolaInitialized)try{const i=new p(t,e);t.__kupolaInstance=i,t.__kupolaInitialized=!0}catch(i){console.error("[Slider] Error initializing:",i)}}function g(t){if(!t.__kupolaInitialized||!t.__kupolaInstance)return;t.__kupolaInstance.destroy(),t.__kupolaInstance=null,t.__kupolaInitialized=!1}t.kupolaInitializer.register("slider",m,g);class _{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 i=()=>this.goTo(e);this._indicatorClickHandlers.push(i),t.addEventListener("click",i)}),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,i)=>{e.style.opacity=i===t?"1":"0",e.style.zIndex=i===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 i=this._indicatorClickHandlers[e];i&&t.removeEventListener("click",i)}),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 v(t,e){if(t.__kupolaInitialized)return;const i=new _(t,e);t.__kupolaInstance=i,t.__kupolaInitialized=!0}function y(t){if(!t.__kupolaInitialized||!t.__kupolaInstance)return;t.__kupolaInstance.destroy(),t.__kupolaInstance=null,t.__kupolaInitialized=!1}t.kupolaInitializer.register("carousel",v,y);class f{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"),i=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),i&&i.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:i,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:i})=>{t.removeEventListener(e,i)}),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 b(t,e){if(t.__kupolaInitialized)return;const i=new f(t,e);t.__kupolaInstance=i,t.__kupolaInitialized=!0}function k(t){if(!t.__kupolaInitialized||!t.__kupolaInstance)return;t.__kupolaInstance.destroy(),t.__kupolaInstance=null,t.__kupolaInitialized=!1}t.kupolaInitializer.register("drawer",b,k);class x{constructor(e,i={}){this.element=e,this.mask=e.querySelector(".ds-modal-mask"),this.modal=e.querySelector(".ds-modal"),this.closeBtn=e.querySelector(".ds-modal__close");const s=t.getUiConfig(),n=void 0===s.modal?.backdropClick||s.modal.backdropClick;this.fullscreen=i.fullscreen||e.hasAttribute("data-modal-fullscreen"),this.closableOnMask=void 0!==i.closableOnMask?i.closableOnMask:n,this.escClose=!1!==i.escClose,this.width=i.width||e.getAttribute("data-modal-width")||"",this.center=!1!==i.center,this.onBeforeOpen=i.onBeforeOpen||null,this.onBeforeClose=i.onBeforeClose||null,this.onOpened=i.onOpened||null,this.onClosed=i.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||(x._openCount=(x._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&&(x._openCount=Math.max(0,(x._openCount||0)-1),this._isOpen=!1,0===x._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&&(x._openCount=Math.max(0,(x._openCount||0)-1),this._isOpen=!1,0===x._openCount&&(document.body.style.overflow=""))}}function E(e={}){const{title:i="",content:s="",html:n=!1,width:a="480px",fullscreen:l=!1,showCancel:r=!0,showConfirm:o=!0,confirmText:h="OK",cancelText:d="Cancel",confirmClass:c="ds-btn--brand",cancelClass:u="ds-btn--ghost",closable:p=!0,maskClosable:m=!0,onConfirm:g,onCancel:_,onOpen:v,onClose:y,footer:f=null,size:b=t.getUiConfig().defaultSize}=e,k="sm"===b?"ds-btn--sm":"lg"===b?"ds-btn--lg":"",E=document.createElement("div");E.className="ds-modal-container";let C="";null!==f&&("string"==typeof f?C=`<div class="ds-modal__footer">${f}</div>`:(o||r)&&(C=`<div class="ds-modal__footer">\n ${r?`<button class="ds-btn ${k} ${u}" data-modal-cancel>${d}</button>`:""}\n ${o?`<button class="ds-btn ${k} ${c}" data-modal-confirm>${h}</button>`:""}\n </div>`)),E.innerHTML=`\n <div class="ds-modal-mask">\n <div class="ds-modal${l?" ds-modal--fullscreen":""}" style="${l?"":"max-width: "+a}">\n <div class="ds-modal__header">\n <span class="ds-modal__title"></span>\n ${p?'<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 ${C}\n </div>\n </div>\n `,document.body.appendChild(E);const w=new x(E,{fullscreen:l,closableOnMask:m}),S=E.querySelector(".ds-modal__title");S&&(S.textContent=i);const L=E.querySelector(".ds-modal__body");L&&(n?L.innerHTML=s:L.textContent=s);const H=E.querySelector("[data-modal-confirm]"),D=E.querySelector("[data-modal-cancel]");let M=!1;const I=async()=>{if(g){H.disabled=!0,H.classList.add("is-loading");try{if(!1===await g())return H.disabled=!1,void H.classList.remove("is-loading")}catch(t){return H.disabled=!1,void H.classList.remove("is-loading")}}M=!0,w.close()},T=()=>{_&&_(),w.close()};H&&H.addEventListener("click",I),D&&D.addEventListener("click",T);const A=w.close.bind(w);return w.close=()=>{A(),setTimeout(()=>{H&&H.removeEventListener("click",I),D&&D.removeEventListener("click",T),w.destroy(),E.remove(),y&&y(M)},300)},w.open(),v&&setTimeout(()=>v(),50),w}function C(t){if(t.__kupolaInitialized)return;const e=new x(t);t.__kupolaInstance=e,t.__kupolaInitialized=!0}function w(t){if(!t.__kupolaInitialized||!t.__kupolaInstance)return;t.__kupolaInstance.destroy(),t.__kupolaInstance=null,t.__kupolaInitialized=!1}x._openCount=0,t.kupolaInitializer.register("modal",C,w);const S={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(e){const i=t.getNotificationConfig(),{title:s,message:n,type:a="normal",duration:l=i.duration,position:r=i.position}=e,o=document.createElement("div");o.className=`ds-notification__item ds-notification__item--${a}`;o.innerHTML=`\n <div class="ds-notification__icon ds-notification__icon--${a}">${{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>'}[a]}</div>\n <div class="ds-notification__content">\n ${s?'<div class="ds-notification__title"></div>':""}\n ${n?'<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 `,s&&(o.querySelector(".ds-notification__title").textContent=s),n&&(o.querySelector(".ds-notification__message").textContent=n);let h=document.querySelector(".ds-notification");if(!h){h=document.createElement("div"),h.className=`ds-notification ds-notification--${r}`;const e=t.getZIndexConfig().notification;h.style.zIndex=e,h.style.transform="translateZ(0)",document.body.appendChild(h)}h.appendChild(o),setTimeout(()=>{o.classList.add("is-visible")},10),o.querySelector(".ds-notification__close").addEventListener("click",()=>{o.classList.remove("is-visible"),o.classList.add("is-exiting"),setTimeout(()=>o.remove(),300)}),l>0&&setTimeout(()=>{o.classList.remove("is-visible"),o.classList.add("is-exiting"),setTimeout(()=>o.remove(),300)},l)}};const L={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(e,i="normal",s={}){const n=t.getMessageConfig(),{duration:a=n.duration,position:l=n.position}=s,r=n.maxCount||5,o=document.createElement("div");o.className=`ds-message__item ds-message__item--${i}`;o.innerHTML=`\n <div class="ds-message__icon ds-message__icon--${i}">${{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>'}[i]}</div>\n <div class="ds-message__content"></div>\n `,o.querySelector(".ds-message__content").textContent=e;let h=document.querySelector(".ds-message");if(!h){h=document.createElement("div"),h.className=`ds-message ds-message--${l}`;const e=t.getZIndexConfig().message;h.style.zIndex=e,h.style.transform="translateZ(0)",document.body.appendChild(h)}const d=h.querySelectorAll(".ds-message__item");if(d.length>=r){const t=d[0];t.classList.remove("is-visible"),t.classList.add("is-exiting"),setTimeout(()=>t.remove(),300)}h.appendChild(o),setTimeout(()=>{o.classList.add("is-visible")},10),a>0&&setTimeout(()=>{o.classList.remove("is-visible"),o.classList.add("is-exiting"),setTimeout(()=>o.remove(),300)},a)}};function H(t){return t?t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"):""}class D{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=""},i=t=>{t.preventDefault(),t.stopPropagation(),this.dropzone.classList.add("is-dragging")},s=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",i),this.dropzone.addEventListener("dragleave",s),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:i},{el:this.dropzone,event:"dragleave",handler:s},{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 i=e.split(",").map(t=>t.trim()),s=t.type,n=t.name.toLowerCase();if(!i.some(t=>t.startsWith(".")?n.endsWith(t):!t.includes("/")||(t.endsWith("/*")?s.startsWith(t.replace("/*","")):s===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 i=this.getFileIcon(t.type);e.innerHTML=`\n <div class="ds-fileupload__icon" style="width: 24px; height: 24px; border-radius: 4px;">\n ${i}\n </div>\n <span class="ds-fileupload__filename">${this.truncateFilename(H(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 s=e.querySelector(".ds-fileupload__remove"),n=()=>{this.removeFile(t,e)};s.addEventListener("click",n),this._listeners.push({el:s,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 i=t.substring(t.lastIndexOf("."));return t.substring(0,t.lastIndexOf(".")).substring(0,e-i.length-3)+"..."+i}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 i=document.createElement("div");i.className="ds-fileupload__preview-item",i.innerHTML=`\n <img src="${e.target.result}" alt="${H(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 s=i.querySelector(".ds-fileupload__preview-remove"),n=()=>{this.removeFile(t,this.list?.querySelector(`[data-filename="${t.name}"]`)),i.remove(),this.preview&&0===this.preview.children.length&&(this.preview.remove(),this.preview=null)};s.addEventListener("click",n),this._listeners.push({el:s,event:"click",handler:n}),this.preview.appendChild(i)},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 i=0;Math.max(1,Math.floor(t.size/e));const s=setInterval(()=>{i++;const t=Math.min(100,Math.floor(i/e*100));this.updateProgress(t),i>=e&&(clearInterval(s),this.updateProgress(100))},Math.max(50,Math.floor(50)));return s}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:i})=>{t.removeEventListener(e,i)}),this._listeners=null,this.files=[],this.dropzone=null,this.input=null,this.list=null,this.progress=null,this.preview=null,this.element=null}}function M(t){if(t.__kupolaInitialized)return;const e=new D(t);t.__kupolaInstance=e,t.__kupolaInitialized=!0}function I(t){if(!t.__kupolaInitialized||!t.__kupolaInstance)return;t.__kupolaInstance.destroy(),t.__kupolaInstance=null,t.__kupolaInitialized=!1}t.kupolaInitializer.register("fileupload",M,I);class T{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 i=t.closest(".ds-collapse__item"),s=t.nextElementSibling;if(!i||!s||!s.classList.contains("ds-collapse__content"))return;const n=i.hasAttribute("data-collapse-disabled")||this.disabledItems.includes(e);n&&i.classList.add("is-disabled");let a=i.classList.contains("is-active");("all"===this.defaultExpanded||Array.isArray(this.defaultExpanded)&&this.defaultExpanded.includes(e))&&(a=!0),a?(i.classList.add("is-active"),s.style.height=s.scrollHeight+"px",s.style.overflow="hidden",setTimeout(()=>{i.classList.contains("is-active")&&(s.style.height="auto",s.style.overflow="visible")},this.animationDuration)):(i.classList.remove("is-active"),s.style.height="0",s.style.overflow="hidden");const l=()=>{if(n)return;const t=i.classList.contains("is-active");this.accordion&&!t&&this.headers.forEach((t,i)=>{i!==e&&t.item.classList.contains("is-active")&&this._collapseItem(t)}),t?this._collapseItem({item:i,content:s}):this._expandItem({item:i,content:s}),this.element.dispatchEvent(new CustomEvent("kupola:collapse-toggle",{detail:{index:e,expanded:!t,item:i},bubbles:!0}))};t.addEventListener("click",l),this.headers.push({header:t,item:i,content:s,clickHandler:l,isDisabled:n}),this._listeners.push({el:t,event:"click",handler:l})})}_expandItem(t){const{item:e,content:i}=t;i.style.overflow="hidden",i.style.height="0",i.offsetHeight,i.style.transition=`height ${this.animationDuration}ms ease`,i.style.height=i.scrollHeight+"px",e.classList.add("is-active");const s=()=>{i.removeEventListener("transitionend",s),e.classList.contains("is-active")&&(i.style.height="auto",i.style.overflow="visible"),i.style.transition=""};i.addEventListener("transitionend",s),this._listeners.push({el:i,event:"transitionend",handler:s})}_collapseItem(t){const{item:e,content:i}=t;i.style.overflow="hidden",i.style.height=i.scrollHeight+"px",i.offsetHeight,i.style.transition=`height ${this.animationDuration}ms ease`,i.style.height="0",e.classList.remove("is-active");const s=()=>{i.removeEventListener("transitionend",s),i.style.transition=""};i.addEventListener("transitionend",s),this._listeners.push({el:i,event:"transitionend",handler:s})}destroy(){this._listeners.forEach(({el:t,event:e,handler:i})=>{t.removeEventListener(e,i)}),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,i)=>{i!==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 A(t,e){if(t.__kupolaInitialized)return;const i=new T(t,e);t.__kupolaInstance=i,t.__kupolaInitialized=!0}function z(t){if(!t.__kupolaInitialized||!t.__kupolaInstance)return;t.__kupolaInstance.destroy(),t.__kupolaInstance=null,t.__kupolaInitialized=!1}t.kupolaInitializer.register("collapse",A,z);class q{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(/^#/,""),i=parseInt(e.substring(0,2),16)/255,s=parseInt(e.substring(2,4),16)/255,n=parseInt(e.substring(4,6),16)/255,a=8===e.length?parseInt(e.substring(6,8),16)/255:1,l=Math.max(i,s,n),r=Math.min(i,s,n);let o=0,h=0,d=l;const c=l-r;if(h=0===l?0:c/l,l!==r)switch(l){case i:o=((s-n)/c+(s<n?6:0))/6;break;case s:o=((n-i)/c+2)/6;break;case n:o=((i-s)/c+4)/6}this.hue=Math.round(360*o),this.saturation=Math.round(100*h),this.brightness=Math.round(100*d),this.alpha=Math.round(100*a)}_HSBToColorString(t,e,i,s=1){e/=100,i/=100,s/=100;const n=e=>(e+t/60)%6,a=t=>i*(1-e*Math.max(0,Math.min(n(t),4-n(t),1))),l=Math.round(255*a(5)),r=Math.round(255*a(3)),o=Math.round(255*a(1));if("rgb"===this.mode)return s<1?`rgba(${l}, ${r}, ${o}, ${s.toFixed(2)})`:`rgb(${l}, ${r}, ${o})`;if("hsl"===this.mode)return s<1?`hsla(${t}, ${Math.round(100*e)}%, ${Math.round(100*i)}%, ${s.toFixed(2)})`:`hsl(${t}, ${Math.round(100*e)}%, ${Math.round(100*i)}%)`;const h=`#${l.toString(16).padStart(2,"0")}${r.toString(16).padStart(2,"0")}${o.toString(16).padStart(2,"0")}`;return s<1?h+Math.round(255*s).toString(16).padStart(2,"0"):h}_renderPreviousColors(){const t=this.panel.querySelector(".ds-color-picker__previous");t&&(t.innerHTML="",this.previousColors.forEach(e=>{const i=document.createElement("button");i.className="ds-color-picker__color",i.style.backgroundColor=e,i.setAttribute("data-color",e),i.addEventListener("click",this._colorClickHandler),t.appendChild(i)}))}_renderColorPanel(){const t=this.panel.querySelector(".ds-color-picker__hue"),e=this.panel.querySelector(".ds-color-picker__sv"),i=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%)`),i&&this.showAlpha&&(i.value=this.alpha,i.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(),i=t.clientX-e.left,s=t.clientY-e.top;this.saturation=Math.round(i/e.width*100),this.brightness=Math.round(100*(1-s/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 e=this.panel.querySelector(".ds-color-picker__hue");e&&e.addEventListener("input",this._hueChangeHandler);const i=this.panel.querySelector(".ds-color-picker__sv");i&&(i.addEventListener("click",this._saturationChangeHandler),i.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=t.globalEvents.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 i=this.panel?.querySelector(".ds-color-picker__alpha");i&&this._alphaChangeHandler&&i.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 B(t,e){const i=new q(t,e);i.init(),t._kupolaColorPicker=i}function P(t){t._kupolaColorPicker&&(t._kupolaColorPicker.destroy(),t._kupolaColorPicker=null)}t.kupolaInitializer.register("color-picker",B,P);class ${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()},i=()=>{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",i),this._listeners.push({el:this.todayBtn,event:"click",handler:i}))}_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),i=this._formatDate(this.rangeStart),s=this._formatDate(this.rangeEnd);return e>=i&&e<=s}_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 i=t.date||t.start,s=t.end;if(!i)return!1;const n="string"==typeof i?i:this._formatDate(i);if(!s)return n===e;const a="string"==typeof s?s:this._formatDate(s);return e>=n&&e<=a})}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 i=new Date(t,e,1).getDay(),s=new Date(t,e+1,0).getDate();this.daysEl.innerHTML="";for(let l=0;l<i;l++){const t=document.createElement("span");t.className="ds-calendar__day ds-calendar__day--empty",this.daysEl.appendChild(t)}const n=new Date,a=this._formatDate(n);for(let l=1;l<=s;l++){const i=new Date(t,e,l),s=document.createElement("button");s.className="ds-calendar__day",s.textContent=l;const n=this._formatDate(i);n===a&&s.classList.add("is-today"),this._isSameDay(i,this.selectedDate)&&s.classList.add("is-selected"),this.isRangeMode&&(this._isRangeStart(i)&&s.classList.add("is-range-start"),this._isRangeEnd(i)&&s.classList.add("is-range-end"),this._isDateInRange(i)&&s.classList.add("is-in-range"));const r=this._getEventsForDate(i);if(r.length>0){s.classList.add("has-events");const t=document.createElement("span");t.className="ds-calendar__day-event",t.style.backgroundColor=r[0].color||"#007bff",s.appendChild(t)}const o=()=>{this.element.querySelectorAll(".ds-calendar__day").forEach(t=>t.classList.remove("is-selected")),s.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:n}),this.element.dispatchEvent(new CustomEvent("kupola:calendar-select",{detail:{date:i,dateStr:n},bubbles:!0}))),r.forEach(t=>{this.onEventClick&&this.onEventClick(t,i)}),this.render()};s.addEventListener("click",o),this._listeners.push({el:s,event:"click",handler:o}),this.daysEl.appendChild(s)}}_renderWeekView(t,e){const i=this.currentDate.getDay(),s=new Date(t,e,this.currentDate.getDate()-i+(0===i?-6:1)),n=s,a=new Date(s);a.setDate(s.getDate()+6),this.titleEl.textContent=`${this.i18n.shortMonths[n.getMonth()]} ${n.getDate()} - ${this.i18n.shortMonths[a.getMonth()]} ${a.getDate()} ${t}`,this.daysEl.innerHTML="";const l=new Date,r=this._formatDate(l);for(let o=0;o<7;o++){const t=new Date(s);t.setDate(s.getDate()+o);const e=document.createElement("button");e.className="ds-calendar__day ds-calendar__day--week";const i=document.createElement("span");i.className="ds-calendar__day-header",i.textContent=this.i18n.shortWeekdays[t.getDay()],e.appendChild(i);const n=document.createElement("span");n.className="ds-calendar__day-number",n.textContent=t.getDate(),e.appendChild(n);const a=this._formatDate(t);a===r&&e.classList.add("is-today"),this._isSameDay(t,this.selectedDate)&&e.classList.add("is-selected");const l=this._getEventsForDate(t);if(l.length>0){const t=document.createElement("span");t.className="ds-calendar__day-events",l.slice(0,3).forEach(e=>{const i=document.createElement("span");i.className="ds-calendar__day-event",i.style.backgroundColor=e.color||"#007bff",t.appendChild(i)}),e.appendChild(t)}const h=()=>{this.element.querySelectorAll(".ds-calendar__day").forEach(t=>t.classList.remove("is-selected")),e.classList.add("is-selected"),this.selectedDate=t,this.onSelect&&this.onSelect({date:t,dateStr:a}),this.element.dispatchEvent(new CustomEvent("kupola:calendar-select",{detail:{date:t,dateStr:a},bubbles:!0})),this.render()};e.addEventListener("click",h),this._listeners.push({el:e,event:"click",handler:h}),this.daysEl.appendChild(e)}}destroy(){this._listeners.forEach(({el:t,event:e,handler:i})=>{t.removeEventListener(e,i)}),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 F(t,e){if(!t.__kupolaInitialized)try{const i=new $(t,e);t.__kupolaInstance=i,t.__kupolaInitialized=!0}catch(i){console.error("[Calendar] Error initializing:",i)}}function N(t){if(!t.__kupolaInitialized||!t.__kupolaInstance)return;t.__kupolaInstance.destroy(),t.__kupolaInstance=null,t.__kupolaInitialized=!1}t.kupolaInitializer.register("calendar",F,N);class O{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 i=e=>{e.stopPropagation(),t.remove(),this.dispatchChange()};e.addEventListener("click",i),this._listeners.push({el:e,event:"click",handler:i})}}),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 i=()=>{this.input.focus()};this.element.addEventListener("click",i),this._listeners.push({el:this.element,event:"click",handler:i})}}createTag(t){const e=document.createElement("span");e.className=`ds-dynamic-tags__tag ds-dynamic-tags__tag--${this.color}`;const i=document.createTextNode(t);e.appendChild(i);const s=document.createElement("button");s.className="ds-dynamic-tags__remove",s.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(s);const n=t=>{t.stopPropagation(),e.remove(),this.dispatchChange()};return s.addEventListener("click",n),this._listeners.push({el:s,event:"click",handler:n}),e}hasTag(t){const e=this.element.querySelectorAll(".ds-dynamic-tags__tag");for(const i of e)if(i.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 i=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=>i.classList.remove(t)),t.includes(`ds-dynamic-tags__tag--${e}`)&&i.classList.add(`ds-dynamic-tags__tag--${e}`)}this.element.insertBefore(i,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 i of e)if(i.textContent.trim()===t)return i.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 i=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:i})}),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:i})=>{t.removeEventListener(e,i)}),this._listeners=null,this.input=null,this.element=null}}function V(t,e){if(t.__kupolaInitialized)return;const i=new O(t,e);t.__kupolaInstance=i,t.__kupolaInitialized=!0}function R(t){if(!t.__kupolaInitialized||!t.__kupolaInstance)return;t.__kupolaInstance.destroy(),t.__kupolaInstance=null,t.__kupolaInitialized=!1}t.kupolaInitializer.register("dynamic-tags",V,R);class K{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"),i=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),i.addEventListener("click",this._nextHandler);this.overlay.querySelectorAll(".ds-image-preview__toolbar-btn").forEach(t=>{t.addEventListener("click",e=>{const i=t.getAttribute("data-action");this.handleToolbarAction(i)})});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"),i=this.overlay.querySelector(".ds-image-preview__meta"),s=this.overlay.querySelector(".ds-image-preview__indicators"),n=this.overlay.querySelector(".ds-image-preview__nav-btn--prev"),a=this.overlay.querySelector(".ds-image-preview__nav-btn--next"),l=this.images[this.currentIndex];t.src=l.src,t.alt=l.alt||"",e.textContent=l.title||"",i.textContent=l.meta||`${this.currentIndex+1} / ${this.images.length}`,n.disabled=0===this.currentIndex,a.disabled=this.currentIndex===this.images.length-1,s.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(""),s.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"),i=this.overlay?.querySelector(".ds-image-preview__nav-btn--prev"),s=this.overlay?.querySelector(".ds-image-preview__nav-btn--next");e&&e.removeEventListener("click",this.closeHandler),i&&this._prevHandler&&i.removeEventListener("click",this._prevHandler),s&&this._nextHandler&&s.removeEventListener("click",this._nextHandler),this.overlay&&this.overlay.parentNode&&this.overlay.parentNode.removeChild(this.overlay)}}let W=null;class Y{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 i=this.element.querySelector(".ds-tag__close"),s=this.element.querySelector(".ds-tag__checkbox"),n=this.element.querySelector(".ds-tag__input"),a=i||s||n||null;this.element.insertBefore(document.createTextNode(t),a),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 i=this.element.querySelector(".ds-tag__close");this.element.insertBefore(e,i);const s=()=>this.endEdit(),n=t=>{"Enter"===t.key?this.endEdit():"Escape"===t.key&&this.cancelEdit()};e.addEventListener("blur",s),e.addEventListener("keydown",n),this._listeners.push({el:e,event:"blur",handler:s}),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:i})=>{t.removeEventListener(e,i)}),this._listeners=[],this.closeBtn=null,this.checkbox=null,this.editInput=null,this.element=null}}function U(t,e){if(t.__kupolaInitialized)return;const i=new Y(t,e);t.__kupolaInstance=i,t.__kupolaInitialized=!0}function X(t){if(!t.__kupolaInitialized||!t.__kupolaInstance)return;t.__kupolaInstance.destroy(),t.__kupolaInstance=null,t.__kupolaInitialized=!1}t.kupolaInitializer.register("tag",U,X);class Z{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 i=parseFloat(e[0].replace(",","")),s=t.substring(0,e.index),n=t.substring(e.index+e[0].length),a=performance.now(),l=t=>{const e=t-a,r=Math.min(e/1500,1),o=1-Math.pow(1-r,3),h=0+(i-0)*o;let d;d=i>=1e6?(h/1e6).toFixed(1)+"M":i>=1e3?(h/1e3).toFixed(1)+"K":Number.isInteger(i)?Math.floor(h).toLocaleString():h.toFixed(2),this.valueElement.textContent=s+d+n,r<1&&requestAnimationFrame(l)};requestAnimationFrame(l)}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 i=e.duration||800,s=this.valueElement.textContent,n=s.match(/[\d.,]+/);if(!n)return void(this.valueElement.textContent=t);const a=s.substring(0,n.index),l=s.substring(n.index+n[0].length),r=parseFloat(n[0].replace(",","")),o=parseFloat(t),h=performance.now(),d=t=>{const e=t-h,s=Math.min(e/i,1),n=1-Math.pow(1-s,3),c=r+(o-r)*n;let u;u=o>=1e6?(c/1e6).toFixed(1)+"M":o>=1e3?(c/1e3).toFixed(1)+"K":Number.isInteger(o)?Math.floor(c).toLocaleString():c.toFixed(2),this.valueElement.textContent=a+u+l,s<1&&requestAnimationFrame(d)};requestAnimationFrame(d)}updateProgress(t,e={}){if(!this.progressFill)return;const i=e.duration||600,s=parseFloat(this.progressFill.style.width||"0"),n=Math.min(Math.max(t,0),100),a=performance.now(),l=t=>{const e=t-a,r=Math.min(e/i,1),o=1-Math.pow(1-r,3),h=s+(n-s)*o;this.progressFill.style.width=h+"%",r<1&&requestAnimationFrame(l)};requestAnimationFrame(l)}setTrend(t,e){const i=this.element.querySelector(".ds-statcard__trend");if(!i)return;i.className=`ds-statcard__trend ds-statcard__trend--${t}`;const s="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>';i.innerHTML=s+e}destroy(){this._observer&&(this._observer.disconnect(),this._observer=null),this.animated=!1,this.valueElement=null,this.progressFill=null,this.element=null}}function j(t){if(t.__kupolaInitialized)return;const e=new Z(t);t.__kupolaInstance=e,t.__kupolaInitialized=!0}function G(t){if(!t.__kupolaInitialized||!t.__kupolaInstance)return;t.__kupolaInstance.destroy(),t.__kupolaInstance=null,t.__kupolaInitialized=!1}t.kupolaInitializer.register("statcard",j,G);class J{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),i=this.data.find(t=>t.date===e);return i?i.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 i=t/e;return i<.2?1:i<.4?2:i<.6?3:i<.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 i=[.2,.4,.6,.8,1][t-1];return`rgba(${e.r}, ${e.g}, ${e.b}, ${i})`}getWeekdayLabels(){return["","一","","三","","五",""]}getMonthLabels(){const t=["1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"],e=[];let i=-1;for(let s=new Date(this.startDate);s<=this.endDate;s.setDate(s.getDate()+1)){const n=s.getMonth(),a=s.getDate();n!==i&&1===a&&(e.push({month:n,label:t[n],offset:Math.floor((s-this.startDate)/864e5)}),i=n)}return e}getWeekCount(){let t=0;const e=new Date(this.startDate).getDay();for(let i=new Date(this.startDate);i<=this.endDate;i.setDate(i.getDate()+1))0===i.getDay()&&t++;return 0!==e&&t++,t}render(){const t=this.element.querySelector(".ds-heatmap__body");if(!t)return;t.innerHTML="";const e=[];let i=[];const s=new Date(this.startDate).getDay();for(let g=1;g<s;g++)i.push(null);for(let g=new Date(this.startDate);g<=this.endDate;g.setDate(g.getDate()+1))i.push(new Date(g)),6!==g.getDay()&&g.getTime()!==this.endDate.getTime()||(e.push(i),i=[]);const n=e.length,a=this.element.classList.contains("ds-heatmap--compact")?12:16,l=n*a,r=document.createElement("div");r.className="ds-heatmap__container";const o=document.createElement("div");o.className="ds-heatmap__labels-and-grid";const h=document.createElement("div");h.className="ds-heatmap__weekday-labels";const d=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=d+"px",e.style.lineHeight=d+"px",h.appendChild(e)}),o.appendChild(h);const c=document.createElement("div");c.className="ds-heatmap__grid-container";const u=document.createElement("div");u.className="ds-heatmap__month-labels",u.style.width=l+"px";const p=this.getMonthLabels();p.forEach((t,e)=>{const i=document.createElement("div");i.className="ds-heatmap__month-label",i.textContent=t.label;const s=p[e+1];let l;l=s?Math.ceil((s.offset-t.offset)/7):n-Math.floor(t.offset/7),i.style.width=l*a+"px",u.appendChild(i)}),c.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 i=this.getDataByDate(t),s=Math.max(...this.data.map(t=>t.value),1),n=this.getLevel(i,s),a=document.createElement("div");a.className="ds-heatmap__cell",a.dataset.date=this.formatDate(t),a.dataset.value=i,a.style.backgroundColor=this.getCellColor(n);const l=e=>this.showTooltip(e,t,i),r=()=>this.hideTooltip(),o=()=>{this.onCellClick&&this.onCellClick({date:this.formatDate(t),value:i})};a.addEventListener("mouseenter",l),a.addEventListener("mouseleave",r),a.addEventListener("click",o),this._listeners.push({el:a,event:"mouseenter",handler:l},{el:a,event:"mouseleave",handler:r},{el:a,event:"click",handler:o}),e.appendChild(a)}}),m.appendChild(e)}),c.appendChild(m),o.appendChild(c),r.appendChild(o),t.appendChild(r),this.renderLegend(t)}renderLegend(t){const e=document.createElement("div");e.className="ds-heatmap__legend";const i=document.createElement("span");i.className="ds-heatmap__legend-label",i.textContent="少";const s=document.createElement("div");s.className="ds-heatmap__legend-cells";for(let a=0;a<=5;a++){const t=document.createElement("div");t.className="ds-heatmap__legend-cell",t.style.backgroundColor=this.getCellColor(a),s.appendChild(t)}const n=document.createElement("span");n.className="ds-heatmap__legend-label",n.textContent="多",e.appendChild(i),e.appendChild(s),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,i){const s=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">${i} contributions</div>\n `,this.tooltip.style.left=Math.min(s.left+s.width/2-75,window.innerWidth-150-16)+"px",this.tooltip.style.top=s.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:i})=>{t.removeEventListener(e,i)}),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:i})=>{t.removeEventListener(e,i)}),this._listeners=null,this.tooltip&&this.tooltip.parentNode&&this.tooltip.parentNode.removeChild(this.tooltip),this.tooltip=null,this.data=[],this.element=null}}function Q(t){if(t.__kupolaInitialized)return;const e=t.getAttribute("data-heatmap-data");let i=[];if(e)try{i=JSON.parse(e)}catch(n){i=et()}else i=et();const s=new J(t,{data:i,onCellClick:t=>{}});t.__kupolaInstance=s,t.__kupolaInitialized=!0}function tt(t){if(!t.__kupolaInitialized||!t.__kupolaInstance)return;t.__kupolaInstance.destroy(),t.__kupolaInstance=null,t.__kupolaInitialized=!1}function et(){const t=[],e=new Date,i=new Date;i.setFullYear(i.getFullYear()-1);for(let s=new Date(i);s<=e;s.setDate(s.getDate()+1)){const e=s.getFullYear(),i=String(s.getMonth()+1).padStart(2,"0"),n=String(s.getDate()).padStart(2,"0"),a=0===s.getDay()||6===s.getDay()?20*Math.random():50*Math.random(),l=Math.floor(a);t.push({date:`${e}-${i}-${n}`,value:l>0?l:Math.floor(30*Math.random())+1})}return t}t.kupolaInitializer.register("heatmap",Q,tt);class it{constructor(e,i={}){this.element=e,this.tooltipEl=null,this.options=i;const s=t.getUiConfig(),n=void 0!==s.tooltip?.delay?s.tooltip.delay:300;this.delay=void 0!==i.delay?i.delay:parseInt(e.getAttribute("data-tooltip-delay"))||n,this.hideDelay=i.hideDelay||parseInt(e.getAttribute("data-tooltip-hide-delay"))||0,this.trigger=i.trigger||e.getAttribute("data-tooltip-trigger")||"hover",this.html=i.html||e.hasAttribute("data-tooltip-html"),this.theme=i.theme||e.getAttribute("data-tooltip-theme")||"default",this.position=i.position||e.getAttribute("data-tooltip-position")||"top",this.animation=!1!==i.animation,this.mouseFollow=i.mouseFollow||e.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 i=t.clientX+10,s=t.clientY+10;const n=window.innerWidth,a=window.innerHeight;i+e.width>n&&(i=t.clientX-e.width-10),s+e.height>a&&(s=t.clientY-e.height-10),this.tooltipEl.style.left=`${i}px`,this.tooltipEl.style.top=`${s}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 e=this.element.getAttribute("data-tooltip");if(!e)return;this.tooltipEl=document.createElement("div"),this.tooltipEl.className=`ds-tooltip ds-tooltip--${this.position} ds-tooltip--${this.theme}`;const i=t.getZIndexConfig().tooltip;this.tooltipEl.style.zIndex=i,this.tooltipEl.style.transform="translateZ(0)",this.html?this.tooltipEl.innerHTML=e:this.tooltipEl.textContent=e,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(),i=window.innerWidth,s=window.innerHeight;let n,a;switch(this.position){case"bottom":n=t.left+t.width/2-e.width/2,a=t.bottom+8;break;case"right":n=t.right+8,a=t.top+t.height/2-e.height/2;break;case"left":n=t.left-e.width-8,a=t.top+t.height/2-e.height/2;break;default:n=t.left+t.width/2-e.width/2,a=t.top-e.height-8}n<8&&(n=8),n+e.width>i&&(n=i-e.width-8),a<8&&(a=8),a+e.height>s&&(a=s-e.height-8),this.tooltipEl.style.left=`${n}px`,this.tooltipEl.style.top=`${a}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 st(t,e){const i=new it(t,e);i.init(),t._kupolaTooltip=i}function nt(t){t._kupolaTooltip&&(t._kupolaTooltip.destroy(),t._kupolaTooltip=null)}t.kupolaInitializer.register("tooltip",st,nt);class at{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)}`,i={},s=t.querySelectorAll("[data-validate]");let n=!1;return s.forEach(t=>{const e=t.name||t.id,s=this.parseRules(t.getAttribute("data-validate")),a=this.getValue(t);for(const[l,r]of Object.entries(s)){const s=this.customValidators[l]||this.validators[l],o=s?.(a,r);if(!o){i[e]=this.getErrorMessage(l,r,t),this.showError(t,i[e]),n=!0;break}this.clearError(t)}}),this.formStates[e]={valid:!n,errors:i,errorCount:Object.keys(i).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"),i=e.querySelector(".ds-select__value")||e.querySelector(".ds-select__trigger span");return i?i.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")),i=this.getValue(t);for(const[s,n]of Object.entries(e)){const e=this.customValidators[s]||this.validators[s],a=e?.(i,n);if(!a)return this.showError(t,this.getErrorMessage(s,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 i=t.id||`form-${Math.random().toString(36).substr(2,9)}`,s=e.group,n=s?t.querySelectorAll(`[data-validate][data-validate-group="${s}"]`):t.querySelectorAll("[data-validate]");let a=!1;for(const r of n){await this.validateInputAsync(r)||(a=!0)}const l={};return n.forEach(t=>{const e=t.name||t.id,i=t.parentElement.querySelector(".ds-input__error");i&&(l[e]=i.textContent)}),this.formStates[i]={valid:!a,errors:l,errorCount:Object.keys(l).length},this.updateFormState(t),!a}async validateInputAsync(t){const e=this.parseRules(t.getAttribute("data-validate")),i=this.parseRules(t.getAttribute("data-validate-async")||""),s=this.getValue(t);for(const[a,l]of Object.entries(e)){const e=this.customValidators[a]||this.validators[a],i=e?.(s,l);if(!i)return this.showError(t,this.getErrorMessage(a,l,t)),!1}for(const[a,l]of Object.entries(i)){const e=this.customAsyncValidators[a]||this.asyncValidators[a];if(e)try{if(!(await e(s,l,t)))return this.showError(t,this.getErrorMessage(a,l,t)),!1}catch(n){return this.showError(t,n.message||"Validation error"),!1}}return this.clearError(t),!0}async validateGroup(t,e){const i=t.querySelectorAll(`[data-validate][data-validate-group="${e}"]`);let s=!1;for(const n of i){await this.validateInputAsync(n)||(s=!0)}return!s}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 i=t.querySelector(".ds-form__status");i&&(e.errorCount>0?(i.textContent=`${e.errorCount} ${1===e.errorCount?"error":"errors"} found`,i.classList.add("ds-form__status--error")):(i.textContent="All fields are valid",i.classList.remove("ds-form__status--error")))}setFormLoading(t,e){const i=t.id||`form-${Math.random().toString(36).substr(2,9)}`;this.formStates[i]||(this.formStates[i]={valid:!0,errors:{},errorCount:0,loading:!1,submitting:!1,disabled:!1}),this.formStates[i].loading=e,this.updateFormState(t)}setFormSubmitting(t,e){const i=t.id||`form-${Math.random().toString(36).substr(2,9)}`;this.formStates[i]||(this.formStates[i]={valid:!0,errors:{},errorCount:0,loading:!1,submitting:!1,disabled:!1}),this.formStates[i].submitting=e,this.updateFormState(t)}setFormDisabled(t,e){const i=t.id||`form-${Math.random().toString(36).substr(2,9)}`;this.formStates[i]||(this.formStates[i]={valid:!0,errors:{},errorCount:0,loading:!1,submitting:!1,disabled:!1}),this.formStates[i].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[i,s]=t.split(":");e[i]=s?s.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 i=document.getElementById(e);return i&&t===i.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 i=t.parentElement.querySelector(".ds-input__error");i||(i=document.createElement("span"),i.className="ds-input__error",i.setAttribute("role","alert"),i.setAttribute("aria-live","polite"),t.parentElement.appendChild(i)),i.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,i){const s=i.getAttribute(`data-message-${t}`);if(s)return s;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 lt=new at;window.__kupolaValidationInitialized||(window.__kupolaValidationInitialized=!0,document.addEventListener("DOMContentLoaded",()=>{document.querySelectorAll("form[data-validation]").forEach(e=>{e.addEventListener("submit",async t=>{const i=e.id||`form-${Math.random().toString(36).substr(2,9)}`;if(lt.submitting.has(i))return void t.preventDefault();t.preventDefault();let s;if(s=null!==e.querySelector("[data-validate-async]")?await lt.validateAsync(e):lt.validate(e),s){lt.submitting.add(i);const t=e.querySelector('button[type="submit"]');if(t){const e=t.textContent;t.setAttribute("data-original-text",e),t.textContent="Submitting...",t.disabled=!0}try{const t=e.getAttribute("data-on-submit");t&&window[t]?await window[t](e):e.submit()}finally{lt.submitting.delete(i),t&&(t.textContent=t.getAttribute("data-original-text")||"Submit",t.disabled=!1)}}else{const t=e.querySelector(".ds-input--error");t&&t.focus()}}),e.querySelectorAll("[data-validate]").forEach(e=>{const i=t.getValidationConfig(),s=i.trigger||"blur",n=()=>{i.showErrors&&setTimeout(()=>{const t=document.activeElement;if(t&&t.closest(".ds-select"))return;lt.validateInput(e)&&e.value.trim()&<.showSuccess(e)},50)};"blur"!==s&&"both"!==s||e.addEventListener("blur",n);const a=((t,e)=>{let i;return(...s)=>{clearTimeout(i),i=setTimeout(()=>t(...s),e)}})(()=>{if(!i.showErrors)return;const t=lt.getValue(e);if(t.length>0||e.classList.contains("ds-input--error")){lt.validateInput(e)&&t&<.showSuccess(e)}else lt.removeStatusIcon(e)},t.getPerformanceConfig().debounceDelay);"input"!==s&&"both"!==s||e.addEventListener("input",a),e.addEventListener("keyup",t=>{if("Enter"===t.key){lt.validateInput(e)&&e.value.trim()&<.showSuccess(e)}})})})}));class rt{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"),i=e?this.element.scrollLeft:this.element.scrollTop;this.onScroll&&this.onScroll({scrollOffset:i,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((i,s)=>{const n=this.getItemSize(s);t.push({start:e,end:e+n,size:n}),e+=n}),t}getTotalSize(){if(this.useDynamicHeight)return this.data.reduce((t,e,i)=>t+this.getItemSize(i),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 i=0;i<e.length;i++)if(t>=e[i].start&&t<e[i].end)return i;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,i=t?this.element.clientWidth:this.element.clientHeight,s=Math.max(0,this.getIndexAtOffset(e)-this.bufferSize);let n=Math.min(this.data.length-1,this.getIndexAtOffset(e+i)+this.bufferSize);n<s&&(n=s),this.startIndex=s,this.endIndex=n;const a=this.data.slice(s,n+1);let l="",r=0;if(this.useDynamicHeight){const t=this.getItemPositions();r=t[s]?.start||0}else{const e=t?this.itemWidth:this.itemHeight;r=s*e}a.forEach((e,i)=>{const n=s+i,a=e[this.keyField]||n,o=this.selectedKey===a,h=this.getItemSize(n);l+=this._buildItemHtml(e,n,a,o,h,r,t),r+=h}),this.container.innerHTML=l,this.useDynamicHeight&&this.updateDynamicHeights(),this.container.querySelectorAll(".ds-virtual-list__item").forEach(t=>{t.addEventListener("click",()=>this.handleItemClick(t))})}_buildItemHtml(t,e,i,s,n,a,l){const r=s?" is-selected":"",o=this.renderItem(t,e);return l?`<div class="ds-virtual-list__item${r}" style="position: absolute; top: 0; left: ${a}px; width: ${n}px; height: 100%;" data-index="${e}" data-key="${i}">${o}</div>`:`<div class="ds-virtual-list__item${r}" style="position: absolute; top: ${a}px; left: 0; right: 0; height: ${n}px;" data-index="${e}" data-key="${i}">${o}</div>`}updateDynamicHeights(){if(this.isUpdating)return;let t=!1;this.container.querySelectorAll(".ds-virtual-list__item").forEach(e=>{const i=parseInt(e.dataset.index),s=this.data[i][this.keyField]||i,n=e.offsetHeight;n!==this.getItemSize(i)&&(this.dynamicHeightCache.set(s,n),t=!0)}),t&&(this.isUpdating=!0,this.update(),this.isUpdating=!1)}handleItemClick(t){const e=parseInt(t.dataset.index),i=t.dataset.key,s=this.data[e];this.onItemClick&&this.onItemClick({item:s,index:e,key:i}),this.onItemSelect&&this.select(i)}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(),i=t?this.element.clientWidth:this.element.clientHeight,s=t?this.element.scrollLeft:this.element.scrollTop;if(t)return void(this.scrollbarThumb.style.display="none");const n=Math.max(20,i/e*i),a=s/(e-i||1)*(i-n);this.scrollbarThumb.style.height=n+"px",this.scrollbarThumb.style.top=a+"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,i=this.getTotalSize(),s=e-(parseFloat(this.scrollbarThumb.style.height)||e),n=t.clientY-this.dragStartY;let a=this.dragStartTop+n;a=Math.max(0,Math.min(a,s)),this.scrollbarThumb.style.top=a+"px";const l=a/s*(i-e||0);this.element.scrollTop=l}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 i=this.element.classList.contains("ds-virtual-list--horizontal");let s=0;if(this.useDynamicHeight){const e=this.getItemPositions();s=e[t]?.start||0}else{s=t*(i?this.itemWidth:this.itemHeight)}i?this.element.scrollTo({left:s,behavior:e}):this.element.scrollTo({top:s,behavior:e})}scrollToKey(t,e="smooth"){const i=this.data.findIndex(e=>e[this.keyField]===t);-1!==i&&this.scrollTo(i,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"),i=this.getTotalSize(),s=e?this.element.clientWidth:this.element.clientHeight;this.element.scrollTo({[e?"left":"top"]:i-s,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:i})=>{t.removeEventListener(e,i)}),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 ot(t=1e3){const e=[],i=["Document","Image","Video","Folder","Archive","Spreadsheet","Presentation","Code"];for(let s=1;s<=t;s++){const t=Math.floor(Math.random()*i.length),n=Math.floor(1e4*Math.random());e.push({id:s,title:`${i[t]} ${n}`,subtitle:`Last modified ${Math.floor(30*Math.random())} days ago`,type:i[t].toLowerCase()})}return e}function ht(t){if(t.__kupolaInitialized)return;const e=t.getAttribute("data-virtual-list");let i=[];if(e)try{i=JSON.parse(e)}catch(n){i=ot(1e3)}else i=ot(1e3);const s=new rt(t,{data:i,onItemClick:t=>{},onItemSelect:t=>{}});t.__kupolaInstance=s,t.__kupolaInitialized=!0}function dt(t){if(!t.__kupolaInitialized||!t.__kupolaInstance)return;t.__kupolaInstance.destroy(),t.__kupolaInstance=null,t.__kupolaInitialized=!1}t.kupolaInitializer.register("virtual-list",ht,dt);const ct={check:'<polyline points="4 12 10 18 20 6"/>',x:'<line x1="6" y1="6" x2="18" y2="18"/><line x1="18" y1="6" x2="6" y2="18"/>',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"/>',"chevron-right":'<polyline points="9 6 15 12 9 18"/>',"chevron-down":'<polyline points="6 9 12 15 18 9"/>',"chevron-up":'<polyline points="6 15 12 9 18 15"/>',"chevron-left":'<polyline points="15 6 9 12 15 18"/>'},ut={...ct},pt={core:ct,interface:{search:'<circle cx="11" cy="11" r="7"/><path d="m20 20-3.5-3.5"/>',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"/>',"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"/>',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"/>',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"/>',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"/>'},navigation:{"arrow-right":'<line x1="4" y1="12" x2="20" y2="12"/><polyline points="14 6 20 12 14 18"/>',"arrow-left":'<line x1="20" y1="12" x2="4" y2="12"/><polyline points="10 6 4 12 10 18"/>',"arrow-up":'<line x1="12" y1="20" x2="12" y2="4"/><polyline points="6 10 12 4 18 10"/>',"arrow-down":'<line x1="12" y1="4" x2="12" y2="20"/><polyline points="6 14 12 20 18 14"/>',"arrow-up-right":'<line x1="6" y1="18" x2="18" y2="6"/><polyline points="9 6 18 6 18 15"/>',"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-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"/>',home:'<polygon points="3 11 12 3 21 11 21 21 14 21 14 14 10 14 10 21 3 21 3 11"/>'},action:{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"/>',download:'<path d="M12 3v12"/><polyline points="7 10 12 15 17 10"/><line x1="3" y1="21" x2="21" y2="21"/>',upload:'<path d="M12 21V9"/><polyline points="7 14 12 9 17 14"/><line x1="3" y1="3" x2="21" y2="3"/>',copy:'<rect x="8" y="8" width="13" height="13"/><path d="M16 8V4H4v13h4"/>',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"/>',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"/>',"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"/>'},status:{"check-circle":'<circle cx="12" cy="12" r="9"/><polyline points="8 12 11 15 16 9"/>',"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-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"/>',"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"/>',"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"/>',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"/>'},user:{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"/>',"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"/>',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"/>',lock:'<rect x="4" y="11" width="16" height="10"/><path d="M8 11V8a4 4 0 0 1 8 0v3"/>'},media:{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"/>',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"/>',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"/>'},data:{table:'<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"/>',"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"/>',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"/>',layers:'<polygon points="12 3 22 8 12 13 2 8 12 3"/><polyline points="2 13 12 18 22 13"/>',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"/>',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"/>'},file:{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"/>',"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"/>',folder:'<path d="M3 6h6l2 3h10v10H3z"/>',mail:'<rect x="3" y="5" width="18" height="14"/><polyline points="3 6 12 13 21 6"/>'},time:{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"/>'},misc:{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"/>',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"/>',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"/>',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"/>',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-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"/>',"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"/>',"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)"/>',"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"/>',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"/>',terminal:'<polyline points="4 7 9 12 4 17"/><line x1="12" y1="17" x2="20" y2="17"/>',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"/>',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"/>',filter:'<polygon points="3 4 21 4 14 12 14 20 10 18 10 12 3 4"/>',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"/>',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"/>',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 mt(t,e=16,i="0 0 24 24"){const s=ut[t];if(!s)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="${i}"`)}>${s}</svg>`}function gt(t=document){t.querySelectorAll("[data-icon]").forEach(t=>{const e=t.getAttribute("data-icon"),i=+t.getAttribute("data-size")||16,s=t.getAttribute("data-viewbox")||"0 0 24 24";t.innerHTML=mt(e,i,s),t.classList.add("icon")})}const _t={svg:mt,render:gt,PATHS:ut,registerIcons:function(t){Object.assign(ut,t)},registerGroup:function(t){const e=pt[t];return!!e&&(Object.assign(ut,e),!0)},registerAllGroups:function(){Object.values(pt).forEach(t=>{Object.assign(ut,t)})},iconGroups:pt};"undefined"!=typeof document&&("loading"!==document.readyState?gt():document.addEventListener("DOMContentLoaded",()=>gt()));class vt{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,i=parseInt(this.element.getAttribute("data-minutes"))||0,s=parseInt(this.element.getAttribute("data-seconds"))||0;return(new Date).getTime()+1e3*(3600*e+60*i+s)}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 i=Math.floor(e%864e5/36e5),s=Math.floor(e%36e5/6e4),n=Math.floor(e%6e4/1e3);this.displayTime(i,s,n)}displayTime(t,e,i){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(i).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 yt(t){if(t.__kupolaInitialized)return;const e=new vt(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}t.kupolaInitializer.register("countdown",yt,ft);class bt{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),i=()=>this.handleInput();this.minusBtn.addEventListener("click",t),this.plusBtn.addEventListener("click",e),this.inputEl.addEventListener("input",i),this._listeners.push({el:this.minusBtn,event:"click",handler:t},{el:this.plusBtn,event:"click",handler:e},{el:this.inputEl,event:"input",handler:i})}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:i})=>{t.removeEventListener(e,i)}),this._listeners=null,this.minusBtn=null,this.plusBtn=null,this.inputEl=null,this.element=null}}function kt(t){if(!t.__kupolaInitialized)try{const e=new bt(t);t.__kupolaInstance=e,t.__kupolaInitialized=!0}catch(e){console.error("[NumberInput] Error initializing:",e)}}function xt(t){if(!t.__kupolaInitialized||!t.__kupolaInstance)return;t.__kupolaInstance.destroy(),t.__kupolaInstance=null,t.__kupolaInitialized=!1}t.kupolaInitializer.register("number-input",kt,xt);class Et{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 i=t.clientX-this.startX;i<0&&(i=0),i>e&&(i=e),this.currentX=i,this.btn.style.left=14+i+"px",this.progress&&(this.progress.style.width=i/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 i=t.touches[0].clientX-this.startX;i<0&&(i=0),i>e&&(i=e),this.currentX=i,this.btn.style.left=14+i+"px",this.progress&&(this.progress.style.width=i/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=t.globalEvents.on(document,"mousemove",this._mouseMoveHandler,{scope:this.scope}),this._mouseUpListener=t.globalEvents.on(document,"mouseup",this._mouseUpHandler,{scope:this.scope}),this._touchMoveListener=t.globalEvents.on(document,"touchmove",this._touchMoveHandler,{scope:this.scope,passive:!1}),this._touchEndListener=t.globalEvents.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,i=.35*t,s=.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(i+Math.random()*(n-i-e)),this.distractorX=Math.floor(n+Math.random()*(s-n))):(this.targetX=Math.floor(n+Math.random()*(s-n)),this.distractorX=Math.floor(i+Math.random()*(n-i-e)))}else this.targetX=Math.floor(i+Math.random()*(s-i));const a=this.container.querySelector(".ds-slider-captcha__target");if(a&&(a.style.left=this.targetX+14+e/2+"px",a.style.transform="translate(-50%, -50%) rotate("+this.angle+"deg)",a.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 i=Date.now()-this.startTime;let s=0,n=0;if(this.trackData.length>0){const t=this.trackData[this.trackData.length-1],e=this.currentX-t.x,a=i-t.t;if(a>0&&(s=e/a,this.trackData.length>1)){const e=this.trackData[this.trackData.length-2],i=t.t-e.t;if(i>0){n=s-(t.x-e.x)/i}}}this.trackData.push({x:this.currentX,y:e-this.startY,t:i,v:s,a:n});const a=this.container.querySelector(".ds-slider-captcha__point-count");a&&(a.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,i=Math.abs(t-this.targetX);if(this.hasDistractor&&e<i&&e<=this.config.tolerance)return{passed:!1,msg:"验证失败"};if(i>this.config.tolerance)return{passed:!1,msg:"验证失败"};const s=[];for(let r=1;r<this.trackData.length;r++){const t=this.trackData[r].x-this.trackData[r-1].x,e=this.trackData[r].t-this.trackData[r-1].t;e>0&&e<500&&s.push(t/e)}if(s.length<3)return{passed:!1,msg:"验证失败"};if(Math.max(...s)-Math.min(...s)<this.config.minSpeedDelta)return{passed:!1,msg:"验证失败"};let n=!1;for(const r of this.trackData)if(Math.abs(r.y)>2){n=!0;break}if(!n&&this.trackData.length>20)return{passed:!1,msg:"验证失败"};const a=this.trackData[this.trackData.length-1].t;if(a<this.config.minDuration)return{passed:!1,msg:"验证失败"};if(a>this.config.maxDuration)return{passed:!1,msg:"验证失败"};const l=[];for(let r=1;r<s.length;r++)l.push(Math.abs(s[r]-s[r-1]));if(l.length>2){if(l.reduce((t,e)=>t+e,0)/l.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 i=this.container.getAttribute("data-on-verified");i&&"function"==typeof window[i]&&window[i](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 Ct(){document.querySelectorAll(".ds-slider-captcha").forEach(t=>{const e=new Et(t);e.init(),t._kupolaSlideCaptcha=e})}function wt(t){t._kupolaSlideCaptcha&&(t._kupolaSlideCaptcha.destroy(),t._kupolaSlideCaptcha=null)}function St(){document.querySelectorAll(".ds-slider-captcha").forEach(t=>{wt(t)})}t.kupolaInitializer.register("slide-captcha",Ct,St);class Lt{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 i=document.getElementById(e);return!i||t===i.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),i=()=>this.clearError(t);this._fieldHandlers.set(t,{blur:e,input:i}),t.addEventListener("blur",e),t.addEventListener("input",i)})}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=[],i=this._getFieldValue(t);for(const[s,n]of Object.entries(this.validators)){const a=t.getAttribute(`data-${s}`);if(null!==a){if(!n(i,a)){let t=this.errorMessages[s];"function"==typeof t&&(t=t(a)),e.push(t)}}}return e}_getFieldValue(t){const e=t.type;if("checkbox"===e)return t.checked;if("radio"===e){const e=t.name,i=this.form.querySelector(`input[name="${e}"]:checked`);return i?i.value:null}return"select-multiple"===e?Array.from(t.selectedOptions).map(t=>t.value):t.value}showError(t,e){this.clearError(t);const i=document.createElement("span");i.className="ds-form-error",i.textContent=e,t.classList.add("ds-form-field--error");const s=t.parentElement;s.classList.contains("ds-form-field")?s.appendChild(i):t.parentNode.insertBefore(i,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,i){this.validators[t]=e,this.errorMessages[t]=i}getData(){const t={};return this.fields.forEach(e=>{const i=e.name;if(!i)return;const s=this._getFieldValue(e);"checkbox"===e.type?(t[i]||(t[i]=[]),e.checked&&t[i].push(e.value)):"radio"===e.type?!t[i]&&e.checked&&(t[i]=e.value):t[i]=s}),t}setData(t){Object.keys(t).forEach(e=>{this.form.querySelectorAll(`[name="${e}"]`).forEach(i=>{const s=i.type;if("checkbox"===s){const s=Array.isArray(t[e])?t[e]:[t[e]];i.checked=s.includes(i.value)}else if("radio"===s)i.checked=i.value===t[e];else if("select-multiple"===s){const s=Array.isArray(t[e])?t[e]:[t[e]];Array.from(i.options).forEach(t=>{t.selected=s.includes(t.value)})}else i.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 Ht(t){const e=document.querySelectorAll(t||".ds-form");return e.forEach(t=>{if(t._kupolaForm)return;const e=new Lt(t);t._kupolaForm=e}),e.length}t.kupolaInitializer.register("form-validation",Ht);class Dt{constructor(e,i={}){this.element="string"==typeof e?document.querySelector(e):e,this.options=i,this.columns=(i.columns||[]).map((t,e)=>({...t,_index:e})),this.rowKey=i.rowKey||"id",this._data=[],this._loading=!1,this.striped=!1!==i.striped,this.bordered=i.bordered||!1,this.hoverable=!1!==i.hoverable,this.compact=i.compact||!1,this.emptyText=i.emptyText||"暂无数据",this.loadingText=i.loadingText||"加载中...",this.multiSort=i.multiSort||!1,this._sorts=[],this._filterText="",this._showPagination=!1!==i.pagination,this._pageSizes=i.pageSizes||[10,20,50,100],this._pageSize=i.pageSize||10,this._currentPage=1,this._total=0,this.selection=i.selection||null,this._selectedKeys=new Set,this.selectionColumnTitle=i.selectionColumnTitle||"",this.expandable=i.expandable||null,this._expandedKeys=new Set,this.expandColumnTitle=i.expandColumnTitle||"",this.editable=i.editable||!1,this._editingCell=null,this._editBuffer={},this.resizable=i.resizable||!1,this.draggable=i.draggable||!1,this._dragState=null,this.tree=i.tree||null,this._treeExpandedKeys=new Set,i.tree?.defaultExpandAll&&(this._treeExpandAll=!0),this.virtualScroll=i.virtualScroll||null,this._scrollContainer=null,this._scrollHandler=null,this._resizeCleanups=[],this._filterDebounceTimer=null,this._reactiveCleanups=[],this.mergeCells=i.mergeCells||null,this.onSort=i.onSort||null,this.onPageChange=i.onPageChange||null,this.onRowClick=i.onRowClick||null,this.onFilter=i.onFilter||null,this.onSelect=i.onSelect||null,this.onExpand=i.onExpand||null,this.onEditSave=i.onEditSave||null,this.onEditCancel=i.onEditCancel||null,this.onRowDragEnd=i.onRowDragEnd||null,this.onColumnResize=i.onColumnResize||null,this.sortKey=t.ref(null),this.sortOrder=t.ref(null),this.currentPage=t.ref(1),this.filterText=t.ref(""),this.selectedKeys=t.ref([]),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,i=null){const s=this.tree?.childrenKey||"children",n=[];for(const a of t){const t=a[this.rowKey];n.push({...a,_level:e,_parentKey:i,_hasChildren:!(!a[s]||!a[s].length)}),a[s]&&a[s].length&&n.push(...this._flattenForExpand(a[s],e+1,t))}return n}_getFlatData(t){return this.tree?this._flattenVisible(t,0):t}_flattenVisible(t,e){const i=this.tree?.childrenKey||"children",s=[];for(const n of t){const t=n[this.rowKey];s.push({...n,_level:e,_hasChildren:!(!n[i]||!n[i].length)}),n[i]&&n[i].length&&this._treeExpandedKeys.has(t)&&s.push(...this._flattenVisible(n[i],e+1))}return s}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(i=>{const s=t[i.key];return null!=s&&String(s).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 i=e;if(this._showPagination&&this._pageSize>0){const t=(this._currentPage-1)*this._pageSize;i=e.slice(t,t+this._pageSize)}return i}_filterTree(t,e){const i=this.tree?.childrenKey||"children";return t.reduce((t,s)=>{const n=s[i]?this._filterTree(s[i],e):[];return(this.columns.some(t=>{const i=s[t.key];return null!=i&&String(i).toLowerCase().includes(e)})||n.length>0)&&(t.push({...s,[i]:n}),n.length>0&&this._treeExpandedKeys.add(s[this.rowKey])),t},[])}_sortFlat(t){return[...t].sort((t,e)=>{for(const i of this._sorts){const s=this.columns.find(t=>t.key===i.key);let n=t[i.key],a=e[i.key],l=0;if(l=s?.sorter?s.sorter(n,a,i.order):null==n?1:null==a?-1:"number"==typeof n&&"number"==typeof a?"asc"===i.order?n-a:a-n:"asc"===i.order?String(n).localeCompare(String(a)):String(a).localeCompare(String(n)),0!==l)return l}return 0})}_sortTree(t){const e=this._sortFlat(t),i=this.tree?.childrenKey||"children";return e.map(t=>t[i]?.length?{...t,[i]:this._sortTree(t[i])}:t)}render(){const t=this.getProcessedData(),e=this.element;e.innerHTML="",(this.options.showFilter||this.options.showToolbar)&&e.appendChild(this._renderToolbar());const i=document.createElement("div");i.className="kupola-table-container";const s=document.createElement("table");s.className=this._getTableClass(),s.appendChild(this._renderThead()),this.virtualScroll?s.appendChild(this._renderVirtualTbody(t)):s.appendChild(this._renderTbody(t)),i.appendChild(s),e.appendChild(i),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 i=this._renderColumnHeader(t);e.appendChild(i)}),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 i=this.getProcessedData().map(t=>t[this.rowKey]);t.checked=i.length>0&&i.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 i=document.createElement("span");i.className="kupola-table-resize-handle",i.setAttribute("data-col-key",t.key),e.appendChild(i)}return e}_renderSortIndicator(t,e){t.classList.add("kupola-table-sortable");const i=this._sorts.find(t=>t.key===e.key);i&&t.classList.add(`kupola-table-sort-${i.order}`),t.addEventListener("click",t=>{this.resizable&&t.target.classList.contains("kupola-table-resize-handle")||this._handleSort(e.key)});const s=document.createElement("span");s.className="kupola-table-sort-icon",s.textContent=i?this.multiSort?` ${this._sorts.indexOf(i)+1}${"asc"===i.order?"▲":"▼"}`:"asc"===i.order?" ▲":" ▼":" ⇅",t.appendChild(s)}_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 i=this.mergeCells?this.mergeCells(t):[],s=new Map;i.forEach(t=>s.set(`${t.row}-${t.col}`,t));const n=new Set;t.forEach((t,i)=>{const a=t[this.rowKey]??i,l=this._selectedKeys.has(a),r=this._expandedKeys.has(a),o=this._renderDataRow(t,i,a,l,n,s);if(e.appendChild(o),this.expandable&&r){const i=document.createElement("tr");i.className="kupola-table-expand-row";const s=document.createElement("td"),n=this.columns.length+(this.selection?1:0)+1;s.colSpan=n,s.className="kupola-table-expand-content";const a=this.expandable(t);"string"==typeof a?s.innerHTML=a:a instanceof HTMLElement&&s.appendChild(a),i.appendChild(s),e.appendChild(i)}})}return e}_renderDataRow(t,e,i,s,n,a){const l=document.createElement("tr");return l.setAttribute("data-row-key",i),s&&l.classList.add("kupola-table-row-selected"),this.draggable&&(l.draggable=!0,l.classList.add("kupola-table-draggable")),this.selection&&this._renderSelectionCell(l,i,s),this.expandable&&this._renderExpandCell(l,i),this.columns.forEach((s,r)=>{if(n.has(`${e}-${r}`))return;const o=this._renderDataCell(t,e,i,s,r,n,a);l.appendChild(o)}),this.onRowClick&&(l.style.cursor="pointer",l.addEventListener("click",i=>{i.target.closest(".kupola-table-expand-btn, .kupola-table-tree-toggle, input, button")||this.onRowClick(t,e,i)})),l}_renderSelectionCell(t,e,i){const s=document.createElement("td");s.className="kupola-table-col-selection";const n=document.createElement("input");n.type=this.selection,n.checked=i,n.addEventListener("change",()=>{"radio"===this.selection?(this._selectedKeys.clear(),this._selectedKeys.add(e)):i?this._selectedKeys.delete(e):this._selectedKeys.add(e),this.selectedKeys.value=[...this._selectedKeys],this.onSelect&&this.onSelect([...this._selectedKeys],this.getSelectedRows()),this.render()}),s.appendChild(n),t.appendChild(s)}_renderExpandCell(t,e){const i=document.createElement("td");i.className="kupola-table-col-expand";const s=document.createElement("button");s.className="kupola-table-expand-btn",s.textContent=this._expandedKeys.has(e)?"▼":"▶",s.type="button",s.addEventListener("click",()=>this._toggleExpand(e)),i.appendChild(s),t.appendChild(i)}_renderDataCell(t,e,i,s,n,a,l){const r=document.createElement("td");s.align&&(r.style.textAlign=s.align),s.fixed&&(r.setAttribute("data-fixed",s.fixed),r.classList.add(`kupola-table-fixed-${s.fixed}`));const o=l.get(`${e}-${n}`);if(o){o.rowSpan>1&&(r.rowSpan=o.rowSpan),o.colSpan>1&&(r.colSpan=o.colSpan);for(let t=0;t<(o.rowSpan||1);t++)for(let i=0;i<(o.colSpan||1);i++)0===t&&0===i||a.add(`${e+t}-${n+i}`)}this.tree&&0===n&&t._level>0&&this._renderTreeIndent(r,t);const h=this._editingCell&&this._editingCell.rowKey===i&&this._editingCell.colKey===s.key;if(h)r.appendChild(this._renderEditCell(s,t));else if(s.render){const i=s.render(t[s.key],t,e);"string"==typeof i?r.innerHTML=i:i instanceof HTMLElement&&r.appendChild(i)}else r.textContent=t[s.key]??"";return this.editable&&!h&&!1!==s.editable&&(r.classList.add("kupola-table-editable-cell"),r.addEventListener("dblclick",()=>this._startEdit(i,s.key,t[s.key]))),r}_renderTreeIndent(t,e){const i=document.createElement("span");if(i.className="kupola-table-tree-indent",i.style.paddingLeft=20*e._level+"px",t.appendChild(i),e._hasChildren){const i=document.createElement("button");i.className="kupola-table-tree-toggle",i.textContent=this._treeExpandedKeys.has(e[this.rowKey])?"▼":"▶",i.type="button",i.addEventListener("click",t=>{t.stopPropagation(),this._toggleTreeExpand(e[this.rowKey])}),t.appendChild(i)}else{const e=document.createElement("span");e.className="kupola-table-tree-toggle-placeholder",t.appendChild(e)}}_renderStatusRow(t,e){const i=document.createElement("tr"),s=document.createElement("td");return s.colSpan=this.columns.length+(this.selection?1:0)+(this.expandable?1:0),s.className=e,s.textContent=t,i.appendChild(s),i}_renderVirtualTbody(t){const e=document.createElement("tbody"),{rowHeight:i=40,overscan:s=5}=this.virtualScroll,n=t.length*i;if(this._loading)return this._renderTbody(t);if(0===t.length)return this._renderTbody(t);const a=document.createElement("tr");a.className="kupola-table-virtual-spacer-top",a.style.height="0px",e.appendChild(a),this._virtualData={data:t,rowHeight:i,overscan:s,totalHeight:n,tbody:e,topSpacer:a},this._updateVirtualScroll();const l=document.createElement("tr");l.className="kupola-table-virtual-spacer-bottom",l.style.height="0px",e.appendChild(l);const r=this.element.querySelector(".kupola-table-container");return r&&(r.style.maxHeight=this.virtualScroll.maxHeight||"400px",r.style.overflowY="auto",this._scrollHandler&&r.removeEventListener("scroll",this._scrollHandler),this._scrollHandler=()=>this._updateVirtualScroll(),r.addEventListener("scroll",this._scrollHandler)),e}_updateVirtualScroll(){if(!this._virtualData)return;const{data:t,rowHeight:e,overscan:i,tbody:s,topSpacer:n}=this._virtualData,a=this.element.querySelector(".kupola-table-container");if(!a)return;const l=a.scrollTop,r=a.clientHeight,o=Math.max(0,Math.floor(l/e)-i),h=Math.min(t.length,Math.ceil((l+r)/e)+i);s.querySelectorAll(".kupola-table-virtual-row").forEach(t=>t.remove());const d=document.createDocumentFragment();for(let u=o;u<h;u++){const i=t[u],s=i[this.rowKey]??u,n=this._renderDataRow(i,u,s,this._selectedKeys.has(s),new Set,new Map);n.classList.add("kupola-table-virtual-row"),n.style.height=e+"px",d.appendChild(n)}n.style.height=o*e+"px";const c=s.querySelector(".kupola-table-virtual-spacer-bottom");c&&(c.style.height=(t.length-h)*e+"px"),n.after(d)}_renderEditCell(t,e){const i=document.createElement("div");i.className="kupola-table-edit-cell";const s=document.createElement("input");if(s.type=t.editType||"text",s.className="ds-input kupola-table-edit-input",s.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 i=document.createElement("option");i.value="object"==typeof t?t.value:t,i.textContent="object"==typeof t?t.label:t,String(i.value)===String(s.value)&&(i.selected=!0),e.appendChild(i)}),e.addEventListener("change",()=>{this._editBuffer[t.key]=e.value}),i.appendChild(e)}else s.addEventListener("input",()=>{this._editBuffer[t.key]=s.value}),i.appendChild(s);const n=document.createElement("div");n.className="kupola-table-edit-actions";const a=document.createElement("button");a.className="kupola-table-edit-save",a.textContent="✓",a.type="button",a.addEventListener("click",()=>this._saveEdit(e,t));const l=document.createElement("button");return l.className="kupola-table-edit-cancel",l.textContent="✗",l.type="button",l.addEventListener("click",()=>this._cancelEdit()),n.appendChild(a),n.appendChild(l),i.appendChild(n),s.addEventListener("keydown",i=>{"Enter"===i.key&&this._saveEdit(e,t),"Escape"===i.key&&this._cancelEdit()}),setTimeout(()=>s.focus?.(),0),i}_startEdit(t,e,i){this._editingCell={rowKey:t,colKey:e},this._editBuffer={[e]:i},this.render()}_saveEdit(t,e){const i=this._editBuffer[e.key];this.onEditSave?this.onEditSave(t,e.key,i,this._data):t[e.key]=i,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 i=t.getAttribute("data-col-key"),s=t.parentElement,n=e.clientX,a=s.offsetWidth,l=t=>{const e=Math.max(50,a+(t.clientX-n));s.style.width=e+"px";const l=this.columns.find(t=>t.key===i);l&&(l.width=e),this.onColumnResize&&this.onColumnResize(i,e)},r=()=>{document.removeEventListener("mousemove",l),document.removeEventListener("mouseup",r)};document.addEventListener("mousemove",l),document.addEventListener("mouseup",r),this._resizeCleanups.push(r)})})}_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 i=e.getAttribute("data-row-key");if(this._dragState.fromKey===i)return;const s=this._data.findIndex(t=>String(t[this.rowKey])===this._dragState.fromKey),n=this._data.findIndex(t=>String(t[this.rowKey])===i);if(s>=0&&n>=0){const[t]=this._data.splice(s,1);this._data.splice(n,0,t),this.onRowDragEnd&&this.onRowDragEnd(t,s,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"]'),i=this.element.querySelectorAll('td[data-fixed="left"]'),s=this.columns.indexOf(t);let n=(this.selection?40:0)+(this.expandable?40:0);for(let a=0;a<s;a++)"left"===this.columns[a].fixed&&(n+=this.columns[a]._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)}),i.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 i=document.createElement("button");i.className="ds-btn ds-btn--sm",i.textContent="反选",i.type="button",i.addEventListener("click",()=>this.invertSelection()),e.appendChild(i)}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 i=document.createElement("span");return i.className="kupola-table-info",i.textContent=`共 ${this._total} 条`,e.appendChild(i),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 i=document.createElement("option");i.value=e,i.textContent=`${e} 条/页`,e===this._pageSize&&(i.selected=!0),t.appendChild(i)}),t.addEventListener("change",()=>{this._pageSize=parseInt(t.value),this._currentPage=1,this.currentPage.value=1,this.render()}),e.appendChild(t)}const i=document.createElement("div");i.className="kupola-table-pages";const s=this._createPageBtn("‹",()=>this._goToPage(this._currentPage-1));s.disabled=this._currentPage<=1,i.appendChild(s),this._getPageRange(this._currentPage,t).forEach(t=>{if("..."===t){const t=document.createElement("span");t.className="kupola-table-page-ellipsis",t.textContent="...",i.appendChild(t)}else{const e=this._createPageBtn(t,()=>this._goToPage(t));t===this._currentPage&&e.classList.add("active"),i.appendChild(e)}});const n=this._createPageBtn("›",()=>this._goToPage(this._currentPage+1));n.disabled=this._currentPage>=t,i.appendChild(n),e.appendChild(i);const a=document.createElement("span");return a.className="kupola-table-page-info",a.textContent=`${this._currentPage} / ${t}`,e.appendChild(a),e}_createPageBtn(t,e){const i=document.createElement("button");return i.className="kupola-table-page-btn",i.textContent=t,i.type="button",i.addEventListener("click",e),i}_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 i=[];if(t<=3){for(let t=1;t<=5;t++)i.push(t);i.push("...",e)}else if(t>=e-2){i.push(1,"...");for(let t=e-4;t<=e;t++)i.push(t)}else{i.push(1,"...");for(let e=t-1;e<=t+1;e++)i.push(e);i.push("...",e)}return i}exportCSV(t="export.csv"){const e=this.getProcessedData(),i=this.columns.map(t=>t.title||t.key),s=e.map(t=>this.columns.map(e=>{let i=t[e.key];return null==i&&(i=""),i=String(i).replace(/"/g,'""'),`"${i}"`}).join(",")),n="\ufeff"+[i.join(","),...s].join("\n"),a=new Blob([n],{type:"text/csv;charset=utf-8;"}),l=URL.createObjectURL(a),r=document.createElement("a");r.href=l,r.download=t,r.click(),URL.revokeObjectURL(l)}_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 Mt(t,e){return new Dt(t,e)}t.kupolaInitializer.register("table",Mt);class It{constructor(e,i={}){this.element="string"==typeof e?document.querySelector(e):e,this.options=i,this._current=i.current||1,this._total=i.total||0,this._pageSize=i.pageSize||10,this._maxPages=i.maxPages||7,this._showTotal=!1!==i.showTotal,this._showSizeChanger=i.showSizeChanger||!1,this._pageSizes=i.pageSizes||[10,20,50,100],this._simple=i.simple||!1,this.current=t.ref(this._current),this.total=t.ref(this._total),this.onChange=i.onChange||null,this.onPageSizeChange=i.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,i=this._btn("‹",()=>this.setCurrent(this._current-1));i.disabled=this._current<=1,t.appendChild(i);const s=document.createElement("span");s.className="kupola-pagination-simple-info",s.textContent=`${this._current} / ${e}`,t.appendChild(s);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 i=document.createElement("option");i.value=t,i.textContent=`${t} 条/页`,t===this._pageSize&&(i.selected=!0),e.appendChild(i)}),e.addEventListener("change",()=>this.setPageSize(parseInt(e.value))),t.appendChild(e)}const i=document.createElement("div");i.className="kupola-pagination-pages";const s=this._btn("‹",()=>this.setCurrent(this._current-1));s.disabled=this._current<=1,i.appendChild(s),this._getPageRange().forEach(t=>{if("..."===t){const t=document.createElement("span");t.className="kupola-pagination-ellipsis",t.textContent="···",i.appendChild(t)}else{const e=this._btn(t,()=>this.setCurrent(t));t===this._current&&e.classList.add("active"),i.appendChild(e)}});const n=this._btn("›",()=>this.setCurrent(this._current+1));if(n.disabled=this._current>=e,i.appendChild(n),t.appendChild(i),e>10){const i=document.createElement("span");i.className="kupola-pagination-jumper",i.innerHTML='跳至 <input type="number" min="1" max="'+e+'" value="'+this._current+'"> 页';const s=i.querySelector("input");s.addEventListener("change",()=>{const t=parseInt(s.value);t>=1&&t<=e&&this.setCurrent(t)}),s.addEventListener("keydown",t=>{if("Enter"===t.key){const t=parseInt(s.value);t>=1&&t<=e&&this.setCurrent(t)}}),t.appendChild(i)}}_btn(t,e){const i=document.createElement("button");return i.className="kupola-pagination-btn",i.textContent=t,i.type="button",i.addEventListener("click",e),i}_getPageRange(){const t=this.totalPages,e=this._maxPages;if(t<=e)return Array.from({length:t},(t,e)=>e+1);const i=[],s=Math.floor(e/2);if(this._current<=s+1){for(let t=1;t<=e-2;t++)i.push(t);i.push("...",t)}else if(this._current>=t-s){i.push(1,"...");for(let s=t-e+3;s<=t;s++)i.push(s)}else{i.push(1,"...");for(let t=this._current-s+2;t<=this._current+s-2;t++)i.push(t);i.push("...",t)}return i}destroy(){this.element.innerHTML="",this.element.classList.remove("kupola-pagination")}}let Tt=!1;let At=!1;class zt extends HTMLElement{static get observedAttributes(){return["open"]}connectedCallback(){this._render()}_render(){const t=this.querySelector('[slot="trigger"]'),e=this.querySelectorAll('[slot="item"]'),i=document.createElement("div");i.className="ds-dropdown",i.setAttribute("data-dropdown",""),t&&(t.setAttribute("class",(t.getAttribute("class")||"")+" ds-dropdown__trigger"),i.appendChild(t));const s=document.createElement("div");s.className="ds-dropdown__menu",e.forEach(t=>{t.className="ds-dropdown__item",s.appendChild(t)}),i.appendChild(s),this.innerHTML="",this.appendChild(i)}attributeChangedCallback(t,e,i){if("open"===t){const t=this.querySelector(".ds-dropdown__menu");t&&(t.style.display=null!==i?"block":"")}}}class qt 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,i){if("title"===t){const t=this.firstElementChild;t&&t.setAttribute("data-title",i||"")}}}class Bt 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 i=e.getAttribute("title")||"",s=e.innerHTML,n=document.createElement("div");n.className="ds-collapse__item",n.innerHTML=`\n <button class="ds-collapse__header">\n <span>${i}</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">${s}</div></div>\n `,t.appendChild(n)}),this.innerHTML="",this.appendChild(t)}}class Pt extends HTMLElement{static get observedAttributes(){return["title"]}}class $t 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,i){if("open"===t){const t=this.querySelector(".ds-drawer");t&&t.classList.toggle("is-open",null!==i)}}}class Ft 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 i=e.querySelector(".ds-dialog__body"),s=this.querySelector('[slot="body"]');s&&i.appendChild(s);const n=e.querySelector(".ds-dialog__foot"),a=this.querySelector('[slot="footer"]');a&&n.appendChild(a);const l=e.querySelector(".ds-dialog__close");l&&l.addEventListener("click",()=>this.close()),e.addEventListener("click",t=>{t.target===e&&this.close()}),this.innerHTML="",this.appendChild(e)}attributeChangedCallback(t,e,i){if("open"===t){const t=this.querySelector(".ds-backdrop");t&&(t.style.display=null!==i?"flex":"none")}}open(){this.setAttribute("open","")}close(){this.removeAttribute("open")}}exports.BRAND_OPTIONS=t.BRAND_OPTIONS,exports.CacheEntry=t.CacheEntry,exports.CacheManager=t.CacheManager,exports.ComponentInitializerRegistry=t.ComponentInitializerRegistry,exports.DependsError=t.DependsError,exports.DependsSource=t.DependsSource,exports.FetchedSource=t.FetchedSource,exports.FunctionSource=t.FunctionSource,exports.GlobalEvents=t.GlobalEvents,exports.KupolaComponent=t.KupolaComponent,exports.KupolaComponentRegistry=t.KupolaComponentRegistry,exports.KupolaDataBind=t.KupolaDataBind,exports.KupolaEventBus=t.KupolaEventBus,exports.KupolaI18n=t.KupolaI18n,exports.KupolaLifecycle=t.KupolaLifecycle,exports.KupolaStore=t.KupolaStore,exports.KupolaStoreManager=t.KupolaStoreManager,exports.KupolaUtils=t.KupolaUtils,exports.RouteSource=t.RouteSource,exports.Scheduler=t.Scheduler,exports.StaticSource=t.StaticSource,exports.StorageSource=t.StorageSource,exports.WebSocketSource=t.WebSocketSource,exports.applyMixin=t.applyMixin,exports.arrayUtils=t.arrayUtils,exports.bootstrapComponents=t.bootstrapComponents,exports.clearCache=t.clearCache,exports.configureHttpClient=t.configureHttpClient,exports.createBrandPicker=t.createBrandPicker,exports.createI18n=t.createI18n,exports.createLifecycle=t.createLifecycle,exports.createSource=t.createSource,exports.createStore=t.createStore,exports.createThemeToggle=t.createThemeToggle,exports.cryptoUtils=t.cryptoUtils,exports.dateUtils=t.dateUtils,exports.debounce=t.debounce,exports.defineComponent=t.defineComponent,exports.defineMixin=t.defineMixin,exports.emit=t.emit,exports.emitGlobal=t.emitGlobal,exports.escapeHtml=t.escapeHtml,exports.formatCurrency=t.formatCurrency,exports.formatDate=t.formatDate,exports.formatNumber=t.formatNumber,exports.generateSecureId=t.generateSecureId,exports.getBasePath=t.getBasePath,exports.getBrand=t.getBrand,exports.getConfig=t.getConfig,exports.getDefaultBrand=t.getDefaultBrand,exports.getDefaultTheme=t.getDefaultTheme,exports.getHttpClient=t.getHttpClient,exports.getHttpConfig=t.getHttpConfig,exports.getIconsPath=t.getIconsPath,exports.getListenerCount=t.getListenerCount,exports.getLocale=t.getLocale,exports.getMessageConfig=t.getMessageConfig,exports.getNotificationConfig=t.getNotificationConfig,exports.getPerformanceConfig=t.getPerformanceConfig,exports.getSecurityConfig=t.getSecurityConfig,exports.getStore=t.getStore,exports.getTheme=t.getTheme,exports.getUiConfig=t.getUiConfig,exports.getValidationConfig=t.getValidationConfig,exports.globalEvents=t.globalEvents,exports.initTheme=t.initTheme,exports.kupolaBootstrap=t.kupolaBootstrap,exports.kupolaData=t.kupolaData,exports.kupolaEvents=t.kupolaEvents,exports.kupolaI18n=t.kupolaI18n,exports.kupolaInitializer=t.kupolaInitializer,exports.kupolaLifecycle=t.kupolaLifecycle,Object.defineProperty(exports,"kupolaRegistry",{enumerable:!0,get:()=>t.kupolaRegistry}),exports.kupolaStoreManager=t.kupolaStoreManager,exports.maskData=t.maskData,exports.n=t.n,exports.numberUtils=t.numberUtils,exports.objectUtils=t.objectUtils,exports.off=t.off,exports.offAll=t.offAll,exports.offByScope=t.offByScope,exports.offConfigChange=t.offConfigChange,exports.on=t.on,exports.onConfigChange=t.onConfigChange,exports.once=t.once,exports.preloadUtils=t.preloadUtils,exports.ref=t.ref,exports.registerComponent=t.registerComponent,exports.registerLazyComponent=t.registerLazyComponent,exports.resetHttpClient=t.resetHttpClient,exports.sanitizeHtml=t.sanitizeHtml,exports.setBrand=t.setBrand,exports.setConfig=t.setConfig,exports.setLocale=t.setLocale,exports.setTheme=t.setTheme,exports.stringUtils=t.stringUtils,exports.stripHtml=t.stripHtml,exports.t=t.t,exports.throttle=t.throttle,exports.useDeps=t.useDeps,exports.useMixin=t.useMixin,exports.useQuery=t.useQuery,exports.validatorUtils=t.validatorUtils,exports.Calendar=$,exports.Carousel=_,exports.Collapse=T,exports.ColorPicker=q,exports.Countdown=vt,exports.Datepicker=r,exports.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:i="",content:s="",onConfirm:n,onCancel:a}=t,l={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>'},r=document.createElement("div");r.className="ds-modal-container",r.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}">${l[e]}</div>\n ${i?'<div class="ds-dialog__title"></div>':""}\n <div class="ds-dialog__content"></div>\n <div class="ds-dialog__actions">\n ${"confirm"===e||a?'<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(r),i&&(r.querySelector(".ds-dialog__title").textContent=i),r.querySelector(".ds-dialog__content").textContent=s;const o=r.querySelector(".ds-modal-mask"),h=r.querySelector("[data-dialog-confirm]"),d=r.querySelector("[data-dialog-cancel]"),c=function(t){"Escape"===t.key&&(a&&a(),g())},u=function(t){t.target===o&&(a&&a(),g())},p=function(){n&&n(),g()},m=function(){a&&a(),g()},g=()=>{o.classList.remove("is-visible"),document.body.style.overflow="",document.removeEventListener("keydown",c),o.removeEventListener("click",u),h&&h.removeEventListener("click",p),d&&d.removeEventListener("click",m),setTimeout(()=>r.remove(),300)};return o.classList.add("is-visible"),document.body.style.overflow="hidden",h&&h.addEventListener("click",p),d&&d.addEventListener("click",m),o.addEventListener("click",u),document.addEventListener("keydown",c),{close:g}}},exports.Drawer=f,exports.Dropdown=e,exports.DynamicTags=O,exports.FileUpload=D,exports.Heatmap=J,exports.Icons=_t,exports.ImagePreview=K,exports.KupolaForm=Lt,exports.KupolaPagination=It,exports.KupolaTable=Dt,exports.KupolaValidator=at,exports.Message=L,exports.Modal=x,exports.Notification=S,exports.NumberInput=bt,exports.PATHS=ut,exports.Select=n,exports.SlideCaptcha=Et,exports.Slider=p,exports.StatCard=Z,exports.Tag=Y,exports.Timepicker=d,exports.Tooltip=it,exports.VirtualList=rt,exports.alertModal=function(t){return"string"==typeof t&&(t={content:t}),E({...t,showCancel:!1,showConfirm:!0})},exports.cleanupAllDropdowns=function(){document.querySelectorAll(".ds-dropdown").forEach(t=>{s(t)})},exports.cleanupAllSlideCaptchas=St,exports.cleanupCalendar=N,exports.cleanupCarousel=y,exports.cleanupCollapse=z,exports.cleanupColorPicker=P,exports.cleanupCountdown=ft,exports.cleanupDatepicker=h,exports.cleanupDrawer=k,exports.cleanupDropdown=s,exports.cleanupDynamicTags=R,exports.cleanupFileUpload=I,exports.cleanupHeatmap=tt,exports.cleanupModal=w,exports.cleanupNumberInput=xt,exports.cleanupSelect=l,exports.cleanupSlideCaptcha=wt,exports.cleanupSlider=g,exports.cleanupStatCard=G,exports.cleanupTag=X,exports.cleanupTimepicker=u,exports.cleanupTooltip=nt,exports.cleanupVirtualList=dt,exports.confirmModal=function(t){return"string"==typeof t&&(t={content:t}),E({...t,showCancel:!0,showConfirm:!0})},exports.createModal=E,exports.getFormInstance=function(t){return t._kupolaForm},exports.initAllTables=function(){document.querySelectorAll("[data-kupola-table]").forEach(t=>{const e=t.getAttribute("data-kupola-table");let i={};if(e)try{i=JSON.parse(e)}catch(s){}Mt(t,i)})},exports.initCalendar=F,exports.initCalendars=function(){document.querySelectorAll(".ds-calendar").forEach(t=>{F(t)})},exports.initCarousel=v,exports.initCarousels=function(t=document){t.querySelectorAll(".ds-carousel").forEach(t=>{v(t)})},exports.initCollapse=A,exports.initCollapses=function(){document.querySelectorAll(".ds-collapse").forEach(t=>{A(t)})},exports.initColorPicker=B,exports.initColorPickers=function(t=document){t.querySelectorAll(".ds-color-picker").forEach(t=>{B(t)})},exports.initCountdown=yt,exports.initCountdowns=function(){document.querySelectorAll(".ds-countdown").forEach(t=>{yt(t)})},exports.initDatepicker=o,exports.initDatepickers=function(t=document){t.querySelectorAll(".ds-datepicker").forEach(t=>{o(t)})},exports.initDrawer=b,exports.initDrawers=function(){document.querySelectorAll("[data-drawer]").forEach(t=>{t.addEventListener("click",()=>{const e=t.getAttribute("data-drawer"),i=document.getElementById(e);i&&(b(i,{placement:t.getAttribute("data-drawer-placement")||"right",width:t.getAttribute("data-drawer-width"),height:t.getAttribute("data-drawer-height")}),i.__kupolaInstance?.open())})}),document.querySelectorAll(".ds-drawer-mask").forEach(t=>{const e=t.parentElement;e&&b(e)})},exports.initDropdown=i,exports.initDropdowns=function(t=document){t.querySelectorAll(".ds-dropdown").forEach(t=>{i(t)})},exports.initDynamicTags=V,exports.initDynamicTagsAll=function(){document.querySelectorAll(".ds-dynamic-tags").forEach(t=>{V(t)})},exports.initFileUpload=M,exports.initFileUploads=function(){document.querySelectorAll(".ds-fileupload").forEach(t=>{M(t)})},exports.initFormValidation=Ht,exports.initHeatmap=Q,exports.initHeatmaps=function(){document.querySelectorAll(".ds-heatmap").forEach(t=>{Q(t)})},exports.initImagePreview=function(){W||(W=new K),document.querySelectorAll("[data-image-preview]").forEach(t=>{t.addEventListener("click",()=>{const e=JSON.parse(t.getAttribute("data-image-preview")),i=parseInt(t.getAttribute("data-image-index"))||0;W.show(e,i)})})},exports.initMessages=function(){},exports.initModal=C,exports.initModals=function(){document.querySelectorAll(".ds-modal-container").forEach(t=>{C(t)})},exports.initNotifications=function(){},exports.initNumberInput=kt,exports.initNumberInputs=function(){document.querySelectorAll(".ds-number-input").forEach(t=>{kt(t)})},exports.initPagination=function(t,e){return function(){if(Tt||"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),Tt=!0}(),new It(t,e)},exports.initSelect=a,exports.initSelects=function(t=document){t.querySelectorAll(".ds-select").forEach(t=>{a(t)})},exports.initSlideCaptchas=Ct,exports.initSlider=m,exports.initSliders=function(){document.querySelectorAll(".ds-slider").forEach(t=>{m(t)})},exports.initStatCard=j,exports.initStatCards=function(){document.querySelectorAll(".ds-statcard").forEach(t=>{j(t)})},exports.initTable=Mt,exports.initTag=U,exports.initTags=function(){document.querySelectorAll(".ds-tag").forEach(t=>{U(t)})},exports.initTimepicker=c,exports.initTimepickers=function(t=document){t.querySelectorAll(".ds-timepicker").forEach(t=>{c(t)})},exports.initTooltip=st,exports.initTooltips=function(t=document){t.querySelectorAll("[data-tooltip]").forEach(t=>{st(t)})},exports.initVirtualList=ht,exports.registerWebComponents=function(){if(At||"undefined"==typeof customElements)return;At=!0;const t=[["k-dropdown",zt],["k-tooltip",qt],["k-collapse",Bt],["k-collapse-item",Pt],["k-drawer",$t],["k-modal",Ft]];for(const[e,i]of t)customElements.get(e)||customElements.define(e,i)},exports.renderIcon=gt,exports.showImagePreview=function(t,e=0){W||(W=new K),W.show(t,e)},exports.svg=mt,exports.validateForm=function(t){const e=t._kupolaForm;return!!e&&e.validate()},exports.validator=lt;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./core-Cs-VWZ5H.cjs");class e{constructor(e,i={}){this.element=e,this.trigger=e.querySelector(".ds-dropdown__trigger"),this.menu=e.querySelector(".ds-dropdown__menu"),this.triggerText=this.trigger?this.trigger.querySelector("span"):null,this.scope=`dropdown-${Math.random().toString(36).substr(2,9)}`;const s=t.getUiConfig();this.triggerMode=i.trigger||e.getAttribute("data-dropdown-trigger")||"click",this.hoverDelay=i.hoverDelay||parseInt(e.getAttribute("data-dropdown-hover-delay"))||150,this.disabled=i.disabled||e.hasAttribute("data-dropdown-disabled"),this.keyboardNav=!1!==i.keyboardNav,this.autoPosition=!1!==i.autoPosition,this.closeOnClick=void 0!==i.closeOnClick?i.closeOnClick:void 0===s.dropdown?.closeOnClick||s.dropdown.closeOnClick,this.appendToBody=!1!==i.appendToBody,this.onSelect=i.onSelect||null,this.onShow=i.onShow||null,this.onHide=i.onHide||null,this.isOpen=!1,this.focusIndex=-1,this._hoverTimer=null,this._hoverLeaveTimer=null,this._originalParent=null,this._originalPosition=null,this._triggerClickHandler=null,this._documentClickHandler=null,this._documentClickListener=null,this._itemClickHandler=null,this._keydownHandler=null,this._mouseenterHandler=null,this._mouseleaveHandler=null,this._triggerMouseenterHandler=null,this._triggerMouseleaveHandler=null,this._triggerKeydownHandler=null}init(){this.trigger&&this.menu&&(this.element.__kupolaInitialized||(this._itemClickHandler=t=>{t.stopPropagation();const e=t.currentTarget;e.classList.contains("is-disabled")||e.classList.contains("ds-dropdown__divider")||(this.menu.querySelectorAll(".ds-dropdown__item").forEach(t=>t.classList.remove("is-selected")),e.classList.add("is-selected"),this.triggerText&&!e.hasAttribute("data-no-update-trigger")&&(this.triggerText.textContent=e.textContent.trim()),this.element.setAttribute("data-value",e.getAttribute("data-value")||""),this.onSelect&&this.onSelect({item:e,value:e.getAttribute("data-value"),text:e.textContent.trim()}),!1!==this.closeOnClick&&(this.hideMenu(),this.trigger&&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=>{if(!this.isOpen)return;const e=this.element.contains(t.target),i=this.menu&&this.menu.contains(t.target);e||i||this.hideMenu()},this._documentClickListener=t.globalEvents.on(document,"click",this._documentClickHandler,{scope:this.scope}),this.menu.style.display="none",this.element.__kupolaInitialized=!0))}_bindMenuItems(){this.menu.querySelectorAll(".ds-dropdown__item").forEach(t=>{t._dropdownItemClickHandler=t=>this._itemClickHandler(t),t.addEventListener("click",t._dropdownItemClickHandler)})}_getNavigableItems(){return Array.from(this.menu.querySelectorAll(".ds-dropdown__item")).filter(t=>!t.classList.contains("is-disabled")&&!t.classList.contains("ds-dropdown__divider"))}_focusItem(t){t.forEach(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=window.innerHeight,i=window.innerWidth;if(this.menu.classList.remove("ds-dropdown--top","ds-dropdown--right","ds-dropdown--dropup"),this.appendToBody){this.menu.style.width=`${t.width}px`;const s=this.menu.getBoundingClientRect(),n=e-t.bottom,a=t.top;n<s.height&&a>n?(this.menu.style.top=t.top-s.height-4+"px",this.menu.style.bottom="auto"):(this.menu.style.top=`${t.bottom+4}px`,this.menu.style.bottom="auto"),t.left+s.width>i?(this.menu.style.left=t.right-s.width+"px",this.menu.style.right="auto"):(this.menu.style.left=`${t.left}px`,this.menu.style.right="auto")}else{const s=e-t.bottom,n=t.top;s<menuRect.height&&n>s?(this.menu.classList.add("ds-dropdown--dropup"),this.menu.style.top="auto",this.menu.style.bottom="100%",this.menu.style.marginBottom="4px"):(this.menu.style.top="100%",this.menu.style.bottom="auto",this.menu.style.marginBottom="0"),t.left+menuRect.width>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.element.classList.add("is-open"),this.appendToBody&&(this._appendMenuToBody(),this._addScrollListener()),this.menu.style.display="block",this._calculatePosition(),this.onShow&&this.onShow(),this.element.dispatchEvent(new CustomEvent("kupola:dropdown-show",{bubbles:!0})))}hideMenu(){this.isOpen&&(this.isOpen=!1,this.menu.style.display="none",this.element.classList.remove("is-open"),this.appendToBody&&(this._restoreMenuFromBody(),this._removeScrollListener()),this.menu.querySelectorAll(".ds-dropdown__item").forEach(t=>t.classList.remove("is-focused")),this.onHide&&this.onHide(),this.element.dispatchEvent(new CustomEvent("kupola:dropdown-hide",{bubbles:!0})))}_appendMenuToBody(){if(!this.menu)return;this._originalParent=this.menu.parentNode,this._originalPosition=this.menu.style.position,this._originalTop=this.menu.style.top,this._originalLeft=this.menu.style.left,this._originalRight=this.menu.style.right,this._originalBottom=this.menu.style.bottom,this._originalMarginBottom=this.menu.style.marginBottom,this._originalWidth=this.menu.style.width,this._originalTransform=this.menu.style.transform,this._originalZIndex=this.menu.style.zIndex,this._originalDisplay=this.menu.style.display;const e=this.element.getBoundingClientRect(),i=t.getZIndexConfig().dropdown;this.menu.style.position="fixed",this.menu.style.width=`${e.width}px`,this.menu.style.zIndex=i,this.menu.style.transform="translateZ(0)",document.body.appendChild(this.menu)}_restoreMenuFromBody(){this.menu&&this._originalParent&&(this._originalParent.appendChild(this.menu),this.menu.style.position=this._originalPosition||"",this.menu.style.top=this._originalTop||"",this.menu.style.left=this._originalLeft||"",this.menu.style.right=this._originalRight||"",this.menu.style.bottom=this._originalBottom||"",this.menu.style.marginBottom=this._originalMarginBottom||"",this.menu.style.width=this._originalWidth||"",this.menu.style.zIndex=this._originalZIndex||"",this.menu.style.transform=this._originalTransform||"",this.menu.style.display=this._originalDisplay||"",this._originalParent=null,console.log("[Dropdown] Menu restored from body"))}_addScrollListener(){this._scrollHandler=()=>{this.hideMenu()},window.addEventListener("scroll",this._scrollHandler,!0)}_removeScrollListener(){this._scrollHandler&&(window.removeEventListener("scroll",this._scrollHandler,!0),this._scrollHandler=null)}toggleMenu(){this.isOpen?this.hideMenu():this.showMenu()}enable(){this.disabled=!1,this.element.removeAttribute("data-dropdown-disabled")}disable(){this.disabled=!0,this.element.setAttribute("data-dropdown-disabled",""),this.hideMenu()}setItems(t){this._itemClickHandler||(this._itemClickHandler=t=>{t.stopPropagation();const e=t.currentTarget;e.classList.contains("is-disabled")||e.classList.contains("ds-dropdown__divider")||(this.menu.querySelectorAll(".ds-dropdown__item").forEach(t=>t.classList.remove("is-selected")),e.classList.add("is-selected"),this.triggerText&&!e.hasAttribute("data-no-update-trigger")&&(this.triggerText.textContent=e.textContent.trim()),this.element.setAttribute("data-value",e.getAttribute("data-value")||""),this.onSelect&&this.onSelect({item:e,value:e.getAttribute("data-value"),text:e.textContent.trim()}),!1!==this.closeOnClick&&(this.hideMenu(),this.trigger&&this.trigger.focus()))}),this.menu.querySelectorAll(".ds-dropdown__item").forEach(t=>{t._dropdownItemClickHandler&&t.removeEventListener("click",t._dropdownItemClickHandler)}),this.menu.innerHTML="",t.forEach((t,e)=>{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"),e._dropdownItemClickHandler=t=>this._itemClickHandler(t),e.addEventListener("click",e._dropdownItemClickHandler),this.menu.appendChild(e)}})}destroy(){this.element.__kupolaInitialized&&(clearTimeout(this._hoverTimer),clearTimeout(this._hoverLeaveTimer),this.trigger&&(this._triggerClickHandler&&this.trigger.removeEventListener("click",this._triggerClickHandler),this._triggerMouseenterHandler&&this.trigger.removeEventListener("mouseenter",this._triggerMouseenterHandler),this._triggerMouseleaveHandler&&this.trigger.removeEventListener("mouseleave",this._triggerMouseleaveHandler),this._triggerKeydownHandler&&this.trigger.removeEventListener("keydown",this._triggerKeydownHandler)),this.menu&&(this.menu.querySelectorAll(".ds-dropdown__item").forEach(t=>{t._dropdownItemClickHandler&&t.removeEventListener("click",t._dropdownItemClickHandler)}),this._mouseenterHandler&&this.menu.removeEventListener("mouseenter",this._mouseenterHandler),this._mouseleaveHandler&&this.menu.removeEventListener("mouseleave",this._mouseleaveHandler)),this._keydownHandler&&document.removeEventListener("keydown",this._keydownHandler),this._documentClickListener&&this._documentClickListener.unsubscribe?this._documentClickListener.unsubscribe():this._documentClickHandler&&document.removeEventListener("click",this._documentClickHandler),this.appendToBody&&this._originalParent&&this._restoreMenuFromBody(),this._documentClickHandler=null,this._documentClickListener=null,this._triggerClickHandler=null,this._itemClickHandler=null,this._keydownHandler=null,this._mouseenterHandler=null,this._mouseleaveHandler=null,this._triggerMouseenterHandler=null,this._triggerMouseleaveHandler=null,this._triggerKeydownHandler=null,this.element.__kupolaInitialized=!1)}}function i(t,i){t._kupolaDropdown&&t._kupolaDropdown.destroy();const s=new e(t,i);s.init(),t._kupolaDropdown=s}function s(t){t._kupolaDropdown&&(t._kupolaDropdown.destroy(),t._kupolaDropdown=null)}t.kupolaInitializer.register("dropdown",i,s);class n{constructor(t,e={}){this.element=t,this.trigger=t.querySelector(".ds-select__trigger"),this.valueEl=t.querySelector(".ds-select__value")||t.querySelector(".ds-select__trigger span"),this.optionsEl=t.querySelector(".ds-select__options")||t.querySelector(".ds-select__menu"),this.nativeSelect=t.querySelector("select"),this.icon=t.querySelector(".ds-select__icon"),this.scope=`select-${Math.random().toString(36).substr(2,9)}`,this.multiple=e.multiple||t.hasAttribute("data-select-multiple"),this.searchable=e.searchable||t.hasAttribute("data-select-search"),this.clearable=e.clearable||t.hasAttribute("data-select-clear"),this.placeholder=e.placeholder||t.getAttribute("data-select-placeholder")||"",this.disabled=e.disabled||t.hasAttribute("data-select-disabled"),this.maxSelection=e.maxSelection||parseInt(t.getAttribute("data-select-max"))||1/0,this.remoteMethod=e.remoteMethod||null,this.onChange=e.onChange||null,this.appendToBody=!1!==e.appendToBody,this.isOpen=!1,this.selectedValues=new Set,this.allOptions=[],this.filteredOptions=[],this.focusIndex=-1,this.searchInput=null,this.clearBtn=null,this.tagsWrap=null,this._originalParent=null,this._originalPosition=null,this._triggerClickHandler=null,this._documentClickHandler=null,this._documentClickListener=null,this._optionClickHandler=null,this._keydownHandler=null}init(){this.trigger&&this.optionsEl&&(this.element.__kupolaInitialized||(this._collectOptions(),this.searchable&&this._createSearchInput(),this.clearable&&this._createClearButton(),this.multiple&&this._createTagsWrap(),this.placeholder&&this.valueEl&&(this.valueEl.setAttribute("data-placeholder",this.placeholder),this.selectedValues.size||(this.valueEl.classList.add("ds-select__value--placeholder"),this.valueEl.textContent=this.placeholder)),this._optionClickHandler=t=>{t.stopPropagation();const e=t.currentTarget;if(e.classList.contains("is-disabled"))return;const i=e.getAttribute("data-value");this.multiple?this._toggleMultiOption(i,e):this._selectSingleOption(i,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=>{if(!this.isOpen)return;const e=this.element.contains(t.target),i=this.optionsEl&&this.optionsEl.contains(t.target);e||i||this.hideOptions()},this._documentClickListener=t.globalEvents.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"),i=this.filteredOptions.some(t=>t.group===e);t.style.display=i?"":"none"}),this.focusIndex=-1)}_renderRemoteOptions(t){this._optionClickHandler||(this._optionClickHandler=t=>{t.stopPropagation();const e=t.currentTarget;if(e.classList.contains("is-disabled"))return;const i=e.getAttribute("data-value");this.multiple?this._toggleMultiOption(i,e):this._selectSingleOption(i,e)}),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._selectOptionClickHandler=t=>this._optionClickHandler(t),e.addEventListener("click",e._selectOptionClickHandler),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 i=document.createElement("span");i.className="ds-select__tag",i.textContent=e.text;const s=document.createElement("button");s.className="ds-select__tag-close",s.type="button",s.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>',s.addEventListener("click",e=>{e.stopPropagation(),this.selectedValues.delete(t);const i=this.optionsEl.querySelector(`[data-value="${t}"]`);i&&i.classList.remove("is-selected"),this._updateTags(),this._updateValueDisplay(),this._syncNativeSelect(),this._updateClearBtn(),this._fireChange()}),i.appendChild(s),this.tagsWrap.appendChild(i)}))}_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._selectOptionClickHandler=t=>this._optionClickHandler(t),t.addEventListener("click",t._selectOptionClickHandler)})}_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.element.classList.add("is-open"),this.icon&&(this.icon.style.transform="rotate(180deg)"),this.focusIndex=-1,this.appendToBody&&(this._appendOptionsToBody(),this._addScrollListener()),this.optionsEl.style.display="block",this._calculateOptionsPosition(),this.searchInput&&setTimeout(()=>this.searchInput.focus(),50))}hideOptions(){this.isOpen&&(this.isOpen=!1,this.optionsEl.style.display="none",this.icon&&(this.icon.style.transform="rotate(0deg)"),this.element.classList.remove("is-open"),this.appendToBody&&(this._restoreOptionsFromBody(),this._removeScrollListener()),this.searchInput&&(this.searchInput.value="",this._handleSearch()),this.optionsEl.querySelectorAll(".ds-select__option, .ds-select__item").forEach(t=>t.classList.remove("is-focused")))}_addScrollListener(){this._scrollHandler=()=>{this.hideOptions()},window.addEventListener("scroll",this._scrollHandler,!0)}_removeScrollListener(){this._scrollHandler&&(window.removeEventListener("scroll",this._scrollHandler,!0),this._scrollHandler=null)}_appendOptionsToBody(){if(!this.optionsEl)return;this._originalParent=this.optionsEl.parentNode,this._originalPosition=this.optionsEl.style.position,this._originalTop=this.optionsEl.style.top,this._originalLeft=this.optionsEl.style.left,this._originalRight=this.optionsEl.style.right,this._originalWidth=this.optionsEl.style.width,this._originalTransform=this.optionsEl.style.transform,this._originalZIndex=this.optionsEl.style.zIndex;const e=this.element.getBoundingClientRect(),i=t.getZIndexConfig().dropdown;this.optionsEl.style.position="fixed",this.optionsEl.style.width=`${e.width}px`,this.optionsEl.style.zIndex=i,this.optionsEl.style.transform="translateZ(0)",document.body.appendChild(this.optionsEl)}_restoreOptionsFromBody(){this.optionsEl&&this._originalParent&&(this._originalParent.appendChild(this.optionsEl),this.optionsEl.style.position=this._originalPosition||"",this.optionsEl.style.top=this._originalTop||"",this.optionsEl.style.left=this._originalLeft||"",this.optionsEl.style.right=this._originalRight||"",this.optionsEl.style.width=this._originalWidth||"",this.optionsEl.style.zIndex=this._originalZIndex||"",this.optionsEl.style.transform=this._originalTransform||"",this._originalParent=null)}_calculateOptionsPosition(){if(!this.appendToBody||!this.optionsEl)return;const t=this.element.getBoundingClientRect(),e=window.innerHeight,i=window.innerWidth;this.optionsEl.style.width=`${t.width}px`;const s=this.optionsEl.getBoundingClientRect(),n=e-t.bottom,a=t.top;n<s.height&&a>n?this.optionsEl.style.top=t.top-s.height-4+"px":this.optionsEl.style.top=`${t.bottom+4}px`,t.left+s.width>i?this.optionsEl.style.left=t.right-s.width+"px":this.optionsEl.style.left=`${t.left}px`}toggleOptions(){this.isOpen?this.hideOptions():this.showOptions()}clear(){this.selectedValues.clear(),this.optionsEl.querySelectorAll(".ds-select__option, .ds-select__item").forEach(t=>t.classList.remove("is-selected")),this._updateTags(),this._updateValueDisplay(),this._syncNativeSelect(),this._updateClearBtn(),this._fireChange()}getSelectedOptions(){return Array.from(this.selectedValues).map(t=>{const e=this.allOptions.find(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 i=e.getAttribute("data-value")===t;e.classList.toggle("is-selected",i),i&&this.updateValue(e.textContent.trim())})),this._syncNativeSelect(),this._updateClearBtn()}enable(){this.disabled=!1,this.element.removeAttribute("data-select-disabled")}disable(){this.disabled=!0,this.element.setAttribute("data-select-disabled",""),this.hideOptions()}destroy(){this.element.__kupolaInitialized&&(this.trigger&&this._triggerClickHandler&&this.trigger.removeEventListener("click",this._triggerClickHandler),this.optionsEl&&this.optionsEl.querySelectorAll(".ds-select__option, .ds-select__item").forEach(t=>{t._selectOptionClickHandler&&t.removeEventListener("click",t._selectOptionClickHandler)}),this._keydownHandler&&document.removeEventListener("keydown",this._keydownHandler),this._documentClickListener&&this._documentClickListener.unsubscribe?this._documentClickListener.unsubscribe():this._documentClickHandler&&document.removeEventListener("click",this._documentClickHandler),this.searchInput&&this.searchInput.remove(),this.clearBtn&&this.clearBtn.remove(),this.tagsWrap&&this.tagsWrap.remove(),this.appendToBody&&this._originalParent&&this._restoreOptionsFromBody(),this._documentClickHandler=null,this._documentClickListener=null,this._triggerClickHandler=null,this._optionClickHandler=null,this._keydownHandler=null,this.element.__kupolaInitialized=!1)}}function a(t,e){const i=new n(t,e);i.init(),t._kupolaSelect=i}function l(t){t._kupolaSelect&&(t._kupolaSelect.destroy(),t._kupolaSelect=null)}t.kupolaInitializer.register("select",a,l);class r{constructor(e,i={}){this.element=e,this.input=e.querySelector("input"),this.endInput=e.querySelector(".ds-datepicker__end-input"),this.icon=e.querySelector(".ds-datepicker__icon"),this.calendarEl=e.querySelector(".ds-datepicker__calendar"),this.scope=`datepicker-${Math.random().toString(36).substr(2,9)}`;const s=t.getUiConfig(),n=void 0!==s.datepicker?.weekStart?s.datepicker.weekStart:1;this.format=i.format||e.getAttribute("data-datepicker-format")||"YYYY-MM-DD",this.range=i.range||e.hasAttribute("data-datepicker-range"),this.minDate=i.minDate||e.getAttribute("data-datepicker-min")||null,this.maxDate=i.maxDate||e.getAttribute("data-datepicker-max")||null,this.disabledDate=i.disabledDate||null,this.weekStart=void 0!==i.weekStart?i.weekStart:parseInt(e.getAttribute("data-datepicker-week-start"))||n,this.appendToBody=!1!==i.appendToBody,this.placeholder=i.placeholder||e.getAttribute("data-datepicker-placeholder")||"",this.showToday=!1!==i.showToday,this.showWeekNumber=i.showWeekNumber||e.hasAttribute("data-datepicker-week-number"),this.onChange=i.onChange||null,this.months=i.months||["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],this.weekDays=i.weekDays||["Su","Mo","Tu","We","Th","Fr","Sa"],this.todayText=i.todayText||"Today",this.clearText=i.clearText||"Clear",this.currentDate=new Date,this.viewMode="days",this.selectedDate=null,this.rangeStart=null,this.rangeEnd=null,this.isSelectingEnd=!1,this._iconClickHandler=null,this._inputClickHandler=null,this._endInputClickHandler=null,this._documentClickHandler=null,this._originalParent=null,this._documentClickListener=null,this._resizeHandler=null,this._resizeListener=null,this._keydownHandler=null}init(){if(this.calendarEl&&!this.element.__kupolaInitialized){if(this.input&&this.input.value)if(this.range){const t=this.input.value.split(" ~ ");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=t.globalEvents.on(document,"click",t=>this.hideCalendar(t),{scope:this.scope}),this._resizeListener=t.globalEvents.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(),i=String(t.getMonth()+1).padStart(2,"0"),s=String(t.getDate()).padStart(2,"0");return this.format.replace("YYYY",e).replace("MM",i).replace("DD",s)}_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(),i=Math.min(this.rangeStart.getTime(),this.rangeEnd.getTime()),s=Math.max(this.rangeStart.getTime(),this.rangeEnd.getTime());return e>=i&&e<=s}calculatePosition(){const t=this.element.getBoundingClientRect(),e=this.calendarEl.getBoundingClientRect(),i=window.innerHeight-t.bottom,s=t.top,n=e.height||320;this.appendToBody?(this.calendarEl.style.left=`${t.left}px`,i>=n?(this.calendarEl.style.top=`${t.bottom+4}px`,this.calendarEl.style.bottom="auto"):s>=n?(this.calendarEl.style.top=t.top-n-4+"px",this.calendarEl.style.bottom="auto"):(this.calendarEl.style.top=`${t.bottom+4}px`,this.calendarEl.style.bottom="auto")):i>=n?(this.calendarEl.style.top="calc(100% + 4px)",this.calendarEl.style.bottom="auto"):s>=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.appendToBody&&(this._appendCalendarToBody(),this._addScrollListener()),this.calendarEl.style.display="block",this.calendarEl.removeAttribute("hidden"),this.calculatePosition())}hideCalendar(t){this.element.contains(t.target)||this.calendarEl.contains(t.target)||(this.calendarEl.style.display="none",this.calendarEl.setAttribute("hidden",""),this.viewMode="days",this.appendToBody&&(this._restoreCalendarFromBody(),this._removeScrollListener()))}_addScrollListener(){this._scrollHandler=()=>{this.hideCalendar({target:document})},window.addEventListener("scroll",this._scrollHandler,!0)}_removeScrollListener(){this._scrollHandler&&(window.removeEventListener("scroll",this._scrollHandler,!0),this._scrollHandler=null)}_appendCalendarToBody(){if(!this.calendarEl)return;this._originalParent=this.calendarEl.parentNode,this._originalPosition=this.calendarEl.style.position,this._originalTop=this.calendarEl.style.top,this._originalLeft=this.calendarEl.style.left,this._originalWidth=this.calendarEl.style.width,this._originalTransform=this.calendarEl.style.transform,this._originalZIndex=this.calendarEl.style.zIndex;const e=t.getZIndexConfig().datepicker;this.calendarEl.style.position="fixed",this.calendarEl.style.zIndex=e,this.calendarEl.style.transform="translateZ(0)",document.body.appendChild(this.calendarEl)}_restoreCalendarFromBody(){this.calendarEl&&this._originalParent&&(this._originalParent.appendChild(this.calendarEl),this.calendarEl.style.position=this._originalPosition||"",this.calendarEl.style.top=this._originalTop||"",this.calendarEl.style.left=this._originalLeft||"",this.calendarEl.style.width=this._originalWidth||"",this.calendarEl.style.zIndex=this._originalZIndex||"",this.calendarEl.style.transform=this._originalTransform||"",this._originalParent=null)}resizeHandler(){"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(),i=this.currentDate.getMonth();t.innerHTML="";const s=document.createElement("div");s.className="ds-datepicker__header";const n=document.createElement("button");n.className="ds-datepicker__nav ds-datepicker__nav--prev",n.type="button",n.innerHTML='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="15 18 9 12 15 6"/></svg>',n.addEventListener("click",t=>{t.stopPropagation(),this._prevMonth()});const a=document.createElement("button");a.className="ds-datepicker__title",a.type="button",a.textContent=`${e} ${this.months[i]}`,a.addEventListener("click",t=>{t.stopPropagation(),this.viewMode="months",this._renderCalendar()});const l=document.createElement("button");l.className="ds-datepicker__nav ds-datepicker__nav--next",l.type="button",l.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>',l.addEventListener("click",t=>{t.stopPropagation(),this._nextMonth()}),s.appendChild(n),s.appendChild(a),s.appendChild(l),t.appendChild(s);const r=document.createElement("div");r.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,r.appendChild(e)}),t.appendChild(r);const o=document.createElement("div");o.className="ds-datepicker__days";const h=new Date(e,i,1).getDay(),d=new Date(e,i+1,0).getDate(),c=(h-this.weekStart+7)%7;for(let u=0;u<c;u++){const t=document.createElement("span");t.className="ds-datepicker__day ds-datepicker__day--empty",o.appendChild(t)}for(let u=1;u<=d;u++){const t=new Date(e,i,u),s=document.createElement("button");s.className="ds-datepicker__day",s.type="button",s.textContent=u,this._formatDate(t),this._isToday(t)&&s.classList.add("is-today"),this.range?((this._isSameDay(t,this.rangeStart)||this._isSameDay(t,this.rangeEnd))&&s.classList.add("is-selected"),this._isInRange(t)&&s.classList.add("is-in-range")):this._isSameDay(t,this.selectedDate)&&s.classList.add("is-selected"),this._isDateDisabled(t)&&(s.classList.add("is-disabled"),s.disabled=!0);const n=()=>this._selectDate(t);s.addEventListener("click",n),s._dayClickHandler=n,o.appendChild(s)}if(t.appendChild(o),this.showToday){const e=document.createElement("div");e.className="ds-datepicker__footer";const i=document.createElement("button");i.className="ds-datepicker__today-btn",i.type="button",i.textContent=this.todayText,i.addEventListener("click",t=>{t.stopPropagation(),this._goToToday()});const s=document.createElement("button");s.className="ds-datepicker__clear-btn",s.type="button",s.textContent=this.clearText,s.addEventListener("click",t=>{t.stopPropagation(),this._clearDate()}),e.appendChild(i),e.appendChild(s),t.appendChild(e)}}_renderYearsView(){const t=this.calendarEl;t.innerHTML="";const e=this.currentDate.getFullYear(),i=e-6,s=document.createElement("div");s.className="ds-datepicker__header";const n=document.createElement("button");n.className="ds-datepicker__nav ds-datepicker__nav--prev",n.type="button",n.innerHTML='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="15 18 9 12 15 6"/></svg>',n.addEventListener("click",t=>{t.stopPropagation(),this.currentDate.setFullYear(this.currentDate.getFullYear()-12),this._renderCalendar()});const a=document.createElement("button");a.className="ds-datepicker__title",a.type="button",a.textContent=`${i} - ${i+11}`,a.addEventListener("click",t=>{t.stopPropagation()});const l=document.createElement("button");l.className="ds-datepicker__nav ds-datepicker__nav--next",l.type="button",l.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>',l.addEventListener("click",t=>{t.stopPropagation(),this.currentDate.setFullYear(this.currentDate.getFullYear()+12),this._renderCalendar()}),s.appendChild(n),s.appendChild(a),s.appendChild(l),t.appendChild(s);const r=document.createElement("div");r.className="ds-datepicker__years-grid";for(let o=0;o<12;o++){const t=i+o,s=document.createElement("button");s.className="ds-datepicker__year-cell",s.type="button",s.textContent=t,t===e&&s.classList.add("is-selected"),s.addEventListener("click",e=>{e.stopPropagation(),this.currentDate.setFullYear(t),this.viewMode="months",this._renderCalendar()}),r.appendChild(s)}t.appendChild(r)}_renderMonthsView(){const t=this.calendarEl;t.innerHTML="";const e=this.currentDate.getFullYear(),i=document.createElement("div");i.className="ds-datepicker__header";const s=document.createElement("button");s.className="ds-datepicker__nav ds-datepicker__nav--prev",s.type="button",s.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>',s.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 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()+1),this._renderCalendar()}),i.appendChild(s),i.appendChild(n),i.appendChild(a),t.appendChild(i);const l=document.createElement("div");l.className="ds-datepicker__months-grid",this.months.forEach((t,e)=>{const i=document.createElement("button");i.className="ds-datepicker__month-cell",i.type="button",i.textContent=t,e===this.currentDate.getMonth()&&i.classList.add("is-selected"),i.addEventListener("click",t=>{t.stopPropagation(),this.currentDate.setMonth(e),this.viewMode="days",this._renderCalendar()}),l.appendChild(i)}),t.appendChild(l)}_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.appendToBody&&this._originalParent&&this._restoreCalendarFromBody(),this._documentClickHandler=null,this._resizeHandler=null,this._documentClickListener=null,this._resizeListener=null,this._iconClickHandler=null,this._inputClickHandler=null,this._endInputClickHandler=null,this._keydownHandler=null,this.element.__kupolaInitialized=!1)}}function o(t,e){const i=new r(t,e);i.init(),t._kupolaDatepicker=i}function h(t){t._kupolaDatepicker&&(t._kupolaDatepicker.destroy(),t._kupolaDatepicker=null)}t.kupolaInitializer.register("datepicker",o,h);class d{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=t.globalEvents.on(document,"click",t=>this.hideTimepicker(t),{scope:this.scope}),this._resizeListener=t.globalEvents.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 i=t.split(":");i.length>=2&&(this.selectedHour=parseInt(i[0])||0,this.selectedMinute=parseInt(i[1])||0,this.selectedSecond=i[2]&&parseInt(i[2])||0)}_isTimeDisabled(t,e,i){if(this.disabledTime)return this.disabledTime(t,e,i);const s=3600*t+60*e+i;if(this.minTime){const t=this.minTime.split(":");if(s<3600*parseInt(t[0])+60*parseInt(t[1])+(parseInt(t[2])||0))return!0}if(this.maxTime){const t=this.maxTime.split(":");if(s>3600*parseInt(t[0])+60*parseInt(t[1])+(parseInt(t[2])||0))return!0}return!1}_formatTime(){let t=this.selectedHour,e=this.selectedMinute,i=this.selectedSecond;if(this.use12Hour){const s=t>=12?"PM":"AM";return t=t%12||12,this.showSeconds?`${t}:${String(e).padStart(2,"0")}:${String(i).padStart(2,"0")} ${s}`:`${t}:${String(e).padStart(2,"0")} ${s}`}return this.showSeconds?`${String(t).padStart(2,"0")}:${String(e).padStart(2,"0")}:${String(i).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(),i=window.innerHeight-t.bottom,s=t.top,n=e.height||320;i>=n?(this.panelEl.style.top="calc(100% + 4px)",this.panelEl.style.bottom="auto"):s>=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 i=document.createElement("button");i.type="button",i.className="ds-timepicker__item",i.textContent=String(e).padStart(2,"0"),i.dataset.value=e,i.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(i)}}_populateMinuteGrid(){const t=this.panelEl.querySelector('[data-type="minute"]');if(t)for(let e=0;e<60;e+=this.minuteStep){const i=document.createElement("button");i.type="button",i.className="ds-timepicker__item",i.textContent=String(e).padStart(2,"0"),i.dataset.value=e,i.addEventListener("click",()=>{this.selectedMinute=e,this._updateDisplay(),this._syncGridSelection("minute",e),this._confirmSelection()}),t.appendChild(i)}}_populateSecondGrid(){const t=this.panelEl.querySelector('[data-type="second"]');if(t)for(let e=0;e<60;e+=this.secondStep){const i=document.createElement("button");i.type="button",i.className="ds-timepicker__item",i.textContent=String(e).padStart(2,"0"),i.dataset.value=e,i.addEventListener("click",()=>{this.selectedSecond=e,this._updateDisplay(),this._syncGridSelection("second",e),this._confirmSelection()}),t.appendChild(i)}}_populateAmPmGrid(){const t=this.panelEl.querySelector('[data-type="ampm"]');t&&["AM","PM"].forEach(e=>{const i=document.createElement("button");i.type="button",i.className="ds-timepicker__item",i.textContent=e,i.dataset.value=e,i.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")),i.classList.add("is-selected"),this._confirmSelection()}),t.appendChild(i)})}_updateDisplay(){if(!this.panelEl)return;const t=this.panelEl.querySelector(".ds-timepicker__display-hour"),e=this.panelEl.querySelector(".ds-timepicker__display-minute"),i=this.panelEl.querySelector(".ds-timepicker__display-second"),s=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")),i&&(i.textContent=String(this.selectedSecond).padStart(2,"0")),s&&(s.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 i=this.panelEl.querySelector(`[data-type="${t}"]`);i&&i.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 i=e.querySelector(".is-selected");i&&i.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,i){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,i||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 c(t,e){const i=new d(t,e);i.init(),t._kupolaTimepicker=i}function u(t){t._kupolaTimepicker&&(t._kupolaTimepicker.destroy(),t._kupolaTimepicker=null)}t.kupolaInitializer.register("timepicker",c,u);class p{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 i=t;i<=e;i+=this.markStep){const s=document.createElement("div");s.className="ds-slider__mark";const n=(i-t)/(e-t)*100;this.vertical?s.style.bottom=n+"%":s.style.left=n+"%";const a=document.createElement("span");a.className="ds-slider__mark-label",a.textContent=i,s.appendChild(a),this.marksEl.appendChild(s)}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 i=t=>{this.disabled||(t.preventDefault(),this._isDragging=!0,this._activeThumb=e,this.element.classList.add("is-dragging"),document.addEventListener("mousemove",s),document.addEventListener("mouseup",n),document.addEventListener("touchmove",s,{passive:!1}),document.addEventListener("touchend",n))},s=t=>{if(!this._isDragging)return;t.preventDefault();const i=t.touches?t.touches[0].clientX:t.clientX,s=t.touches?t.touches[0].clientY:t.clientY,n=this.track.getBoundingClientRect();let a;a=this.vertical?1-(s-n.top)/n.height:(i-n.left)/n.width,a=Math.max(0,Math.min(1,a));const l=parseFloat(this.input?.min||0),r=parseFloat(this.input?.max||100),o=parseFloat(this.input?.step||1);let h=l+a*(r-l);if(h=Math.round(h/o)*o,h=Math.max(l,Math.min(r,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:a})},n=()=>{this._isDragging=!1,this._activeThumb=null,this.element.classList.remove("is-dragging"),document.removeEventListener("mousemove",s),document.removeEventListener("mouseup",n),document.removeEventListener("touchmove",s),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",i),t.addEventListener("touchstart",i,{passive:!1}),this._listeners.push({el:t,event:"mousedown",handler:i},{el:t,event:"touchstart",handler:i})}_handleTrackClick(t){if(t.target.classList.contains("ds-slider__thumb"))return;const e=this.track.getBoundingClientRect(),i=t.clientX,s=t.clientY;let n;n=this.vertical?1-(s-e.top)/e.height:(i-e.left)/e.width,n=Math.max(0,Math.min(1,n));const a=parseFloat(this.input?.min||0),l=parseFloat(this.input?.max||100),r=parseFloat(this.input?.step||1);let o=a+n*(l-a);if(o=Math.round(o/r)*r,this.range){const t=parseFloat(this.input?.value||0),e=parseFloat(this.inputEnd?.value||0);Math.abs(o-t)<=Math.abs(o-e)?this.input&&(this.input.value=Math.min(o,e)):this.inputEnd&&(this.inputEnd.value=Math.max(o,t))}else this.input&&(this.input.value=o);this.updateSlider()}_handleKeyboard(t,e){if(this.disabled)return;const i="start"===e?this.input:this.inputEnd;if(!i)return;const s=parseFloat(i.step||1),n=parseFloat(i.min||0),a=parseFloat(i.max||100);let l=parseFloat(i.value);switch(t.key){case"ArrowRight":case"ArrowUp":t.preventDefault(),l=Math.min(a,l+s);break;case"ArrowLeft":case"ArrowDown":t.preventDefault(),l=Math.max(n,l-s);break;case"Home":t.preventDefault(),l=n;break;case"End":t.preventDefault(),l=a;break;default:return}i.value=l,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 i=parseFloat(this.input?.value||0),s=parseFloat(this.inputEnd?.value||0),n=(i-t)/(e-t)*100,a=(s-t)/(e-t)*100;this.vertical?(this.fill.style.bottom=n+"%",this.fill.style.height=a-n+"%"):(this.fill.style.left=n+"%",this.fill.style.width=a-n+"%"),this.thumbStart&&(this.vertical?this.thumbStart.style.bottom=n+"%":this.thumbStart.style.left=n+"%"),this.thumbEnd&&(this.vertical?this.thumbEnd.style.bottom=a+"%":this.thumbEnd.style.left=a+"%"),this.tooltipStart&&(this.tooltipStart.textContent=this.tooltipFormat(i)),this.tooltipEnd&&(this.tooltipEnd.textContent=this.tooltipFormat(s)),this.valueEl&&(this.valueEl.textContent=`${this.tooltipFormat(i)} - ${this.tooltipFormat(s)}`),this.thumbStart&&this.thumbStart.setAttribute("aria-valuenow",i),this.thumbEnd&&this.thumbEnd.setAttribute("aria-valuenow",s)}else{const i=this.input?.value||0,s=(i-t)/(e-t)*100;this.vertical?this.fill.style.height=`${s}%`:this.fill.style.width=`${s}%`,this.thumbStart&&(this.vertical?this.thumbStart.style.bottom=s+"%":this.thumbStart.style.left=s+"%"),this.tooltipStart&&(this.tooltipStart.textContent=this.tooltipFormat(parseFloat(i))),this.valueEl&&(this.valueEl.textContent=this.tooltipFormat(parseFloat(i))),this.thumbStart&&this.thumbStart.setAttribute("aria-valuenow",i),this.element.setAttribute("aria-valuenow",i)}}destroy(){this._listeners?.forEach(({el:t,event:e,handler:i})=>{t.removeEventListener(e,i)}),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 m(t,e){if(!t.__kupolaInitialized)try{const i=new p(t,e);t.__kupolaInstance=i,t.__kupolaInitialized=!0}catch(i){console.error("[Slider] Error initializing:",i)}}function g(t){if(!t.__kupolaInitialized||!t.__kupolaInstance)return;t.__kupolaInstance.destroy(),t.__kupolaInstance=null,t.__kupolaInitialized=!1}t.kupolaInitializer.register("slider",m,g);class _{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 i=()=>this.goTo(e);this._indicatorClickHandlers.push(i),t.addEventListener("click",i)}),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,i)=>{e.style.opacity=i===t?"1":"0",e.style.zIndex=i===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 i=this._indicatorClickHandlers[e];i&&t.removeEventListener("click",i)}),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 v(t,e){if(t.__kupolaInitialized)return;const i=new _(t,e);t.__kupolaInstance=i,t.__kupolaInitialized=!0}function y(t){if(!t.__kupolaInitialized||!t.__kupolaInstance)return;t.__kupolaInstance.destroy(),t.__kupolaInstance=null,t.__kupolaInitialized=!1}t.kupolaInitializer.register("carousel",v,y);class f{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"),i=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),i&&i.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:i,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:i})=>{t.removeEventListener(e,i)}),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 b(t,e){if(t.__kupolaInitialized)return;const i=new f(t,e);t.__kupolaInstance=i,t.__kupolaInitialized=!0}function k(t){if(!t.__kupolaInitialized||!t.__kupolaInstance)return;t.__kupolaInstance.destroy(),t.__kupolaInstance=null,t.__kupolaInitialized=!1}t.kupolaInitializer.register("drawer",b,k);class x{constructor(e,i={}){this.element=e,this.mask=e.querySelector(".ds-modal-mask"),this.modal=e.querySelector(".ds-modal"),this.closeBtn=e.querySelector(".ds-modal__close");const s=t.getUiConfig(),n=void 0===s.modal?.backdropClick||s.modal.backdropClick;this.fullscreen=i.fullscreen||e.hasAttribute("data-modal-fullscreen"),this.closableOnMask=void 0!==i.closableOnMask?i.closableOnMask:n,this.escClose=!1!==i.escClose,this.width=i.width||e.getAttribute("data-modal-width")||"",this.center=!1!==i.center,this.onBeforeOpen=i.onBeforeOpen||null,this.onBeforeClose=i.onBeforeClose||null,this.onOpened=i.onOpened||null,this.onClosed=i.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||(x._openCount=(x._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&&(x._openCount=Math.max(0,(x._openCount||0)-1),this._isOpen=!1,0===x._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&&(x._openCount=Math.max(0,(x._openCount||0)-1),this._isOpen=!1,0===x._openCount&&(document.body.style.overflow=""))}}function E(e={}){const{title:i="",content:s="",html:n=!1,width:a="480px",fullscreen:l=!1,showCancel:r=!0,showConfirm:o=!0,confirmText:h="OK",cancelText:d="Cancel",confirmClass:c="ds-btn--brand",cancelClass:u="ds-btn--ghost",closable:p=!0,maskClosable:m=!0,onConfirm:g,onCancel:_,onOpen:v,onClose:y,footer:f=null,size:b=t.getUiConfig().defaultSize}=e,k="sm"===b?"ds-btn--sm":"lg"===b?"ds-btn--lg":"",E=document.createElement("div");E.className="ds-modal-container";let C="";null!==f&&("string"==typeof f?C=`<div class="ds-modal__footer">${f}</div>`:(o||r)&&(C=`<div class="ds-modal__footer">\n ${r?`<button class="ds-btn ${k} ${u}" data-modal-cancel>${d}</button>`:""}\n ${o?`<button class="ds-btn ${k} ${c}" data-modal-confirm>${h}</button>`:""}\n </div>`)),E.innerHTML=`\n <div class="ds-modal-mask">\n <div class="ds-modal${l?" ds-modal--fullscreen":""}" style="${l?"":"max-width: "+a}">\n <div class="ds-modal__header">\n <span class="ds-modal__title"></span>\n ${p?'<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 ${C}\n </div>\n </div>\n `,document.body.appendChild(E);const w=new x(E,{fullscreen:l,closableOnMask:m}),S=E.querySelector(".ds-modal__title");S&&(S.textContent=i);const L=E.querySelector(".ds-modal__body");L&&(n?L.innerHTML=s:L.textContent=s);const H=E.querySelector("[data-modal-confirm]"),D=E.querySelector("[data-modal-cancel]");let M=!1;const I=async()=>{if(g){H.disabled=!0,H.classList.add("is-loading");try{if(!1===await g())return H.disabled=!1,void H.classList.remove("is-loading")}catch(t){return H.disabled=!1,void H.classList.remove("is-loading")}}M=!0,w.close()},T=()=>{_&&_(),w.close()};H&&H.addEventListener("click",I),D&&D.addEventListener("click",T);const A=w.close.bind(w);return w.close=()=>{A(),setTimeout(()=>{H&&H.removeEventListener("click",I),D&&D.removeEventListener("click",T),w.destroy(),E.remove(),y&&y(M)},300)},w.open(),v&&setTimeout(()=>v(),50),w}function C(t){if(t.__kupolaInitialized)return;const e=new x(t);t.__kupolaInstance=e,t.__kupolaInitialized=!0}function w(t){if(!t.__kupolaInitialized||!t.__kupolaInstance)return;t.__kupolaInstance.destroy(),t.__kupolaInstance=null,t.__kupolaInitialized=!1}x._openCount=0,t.kupolaInitializer.register("modal",C,w);const S={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(e){const i=t.getNotificationConfig(),{title:s,message:n,type:a="normal",duration:l=i.duration,position:r=i.position}=e,o=document.createElement("div");o.className=`ds-notification__item ds-notification__item--${a}`;o.innerHTML=`\n <div class="ds-notification__icon ds-notification__icon--${a}">${{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>'}[a]}</div>\n <div class="ds-notification__content">\n ${s?'<div class="ds-notification__title"></div>':""}\n ${n?'<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 `,s&&(o.querySelector(".ds-notification__title").textContent=s),n&&(o.querySelector(".ds-notification__message").textContent=n);let h=document.querySelector(".ds-notification");if(!h){h=document.createElement("div"),h.className=`ds-notification ds-notification--${r}`;const e=t.getZIndexConfig().notification;h.style.zIndex=e,h.style.transform="translateZ(0)",document.body.appendChild(h)}h.appendChild(o),setTimeout(()=>{o.classList.add("is-visible")},10),o.querySelector(".ds-notification__close").addEventListener("click",()=>{o.classList.remove("is-visible"),o.classList.add("is-exiting"),setTimeout(()=>o.remove(),300)}),l>0&&setTimeout(()=>{o.classList.remove("is-visible"),o.classList.add("is-exiting"),setTimeout(()=>o.remove(),300)},l)}};const L={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(e,i="normal",s={}){const n=t.getMessageConfig(),{duration:a=n.duration,position:l=n.position}=s,r=n.maxCount||5,o=document.createElement("div");o.className=`ds-message__item ds-message__item--${i}`;o.innerHTML=`\n <div class="ds-message__icon ds-message__icon--${i}">${{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>'}[i]}</div>\n <div class="ds-message__content"></div>\n `,o.querySelector(".ds-message__content").textContent=e;let h=document.querySelector(".ds-message");if(!h){h=document.createElement("div"),h.className=`ds-message ds-message--${l}`;const e=t.getZIndexConfig().message;h.style.zIndex=e,h.style.transform="translateZ(0)",document.body.appendChild(h)}const d=h.querySelectorAll(".ds-message__item");if(d.length>=r){const t=d[0];t.classList.remove("is-visible"),t.classList.add("is-exiting"),setTimeout(()=>t.remove(),300)}h.appendChild(o),setTimeout(()=>{o.classList.add("is-visible")},10),a>0&&setTimeout(()=>{o.classList.remove("is-visible"),o.classList.add("is-exiting"),setTimeout(()=>o.remove(),300)},a)}};function H(t){return t?t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"):""}class D{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=""},i=t=>{t.preventDefault(),t.stopPropagation(),this.dropzone.classList.add("is-dragging")},s=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",i),this.dropzone.addEventListener("dragleave",s),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:i},{el:this.dropzone,event:"dragleave",handler:s},{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 i=e.split(",").map(t=>t.trim()),s=t.type,n=t.name.toLowerCase();if(!i.some(t=>t.startsWith(".")?n.endsWith(t):!t.includes("/")||(t.endsWith("/*")?s.startsWith(t.replace("/*","")):s===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 i=this.getFileIcon(t.type);e.innerHTML=`\n <div class="ds-fileupload__icon" style="width: 24px; height: 24px; border-radius: 4px;">\n ${i}\n </div>\n <span class="ds-fileupload__filename">${this.truncateFilename(H(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 s=e.querySelector(".ds-fileupload__remove"),n=()=>{this.removeFile(t,e)};s.addEventListener("click",n),this._listeners.push({el:s,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 i=t.substring(t.lastIndexOf("."));return t.substring(0,t.lastIndexOf(".")).substring(0,e-i.length-3)+"..."+i}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 i=document.createElement("div");i.className="ds-fileupload__preview-item",i.innerHTML=`\n <img src="${e.target.result}" alt="${H(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 s=i.querySelector(".ds-fileupload__preview-remove"),n=()=>{this.removeFile(t,this.list?.querySelector(`[data-filename="${t.name}"]`)),i.remove(),this.preview&&0===this.preview.children.length&&(this.preview.remove(),this.preview=null)};s.addEventListener("click",n),this._listeners.push({el:s,event:"click",handler:n}),this.preview.appendChild(i)},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 i=0;Math.max(1,Math.floor(t.size/e));const s=setInterval(()=>{i++;const t=Math.min(100,Math.floor(i/e*100));this.updateProgress(t),i>=e&&(clearInterval(s),this.updateProgress(100))},Math.max(50,Math.floor(50)));return s}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:i})=>{t.removeEventListener(e,i)}),this._listeners=null,this.files=[],this.dropzone=null,this.input=null,this.list=null,this.progress=null,this.preview=null,this.element=null}}function M(t){if(t.__kupolaInitialized)return;const e=new D(t);t.__kupolaInstance=e,t.__kupolaInitialized=!0}function I(t){if(!t.__kupolaInitialized||!t.__kupolaInstance)return;t.__kupolaInstance.destroy(),t.__kupolaInstance=null,t.__kupolaInitialized=!1}t.kupolaInitializer.register("fileupload",M,I);class T{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 i=t.closest(".ds-collapse__item"),s=t.nextElementSibling;if(!i||!s||!s.classList.contains("ds-collapse__content"))return;const n=i.hasAttribute("data-collapse-disabled")||this.disabledItems.includes(e);n&&i.classList.add("is-disabled");let a=i.classList.contains("is-active");("all"===this.defaultExpanded||Array.isArray(this.defaultExpanded)&&this.defaultExpanded.includes(e))&&(a=!0),a?(i.classList.add("is-active"),s.style.height=s.scrollHeight+"px",s.style.overflow="hidden",setTimeout(()=>{i.classList.contains("is-active")&&(s.style.height="auto",s.style.overflow="visible")},this.animationDuration)):(i.classList.remove("is-active"),s.style.height="0",s.style.overflow="hidden");const l=()=>{if(n)return;const t=i.classList.contains("is-active");this.accordion&&!t&&this.headers.forEach((t,i)=>{i!==e&&t.item.classList.contains("is-active")&&this._collapseItem(t)}),t?this._collapseItem({item:i,content:s}):this._expandItem({item:i,content:s}),this.element.dispatchEvent(new CustomEvent("kupola:collapse-toggle",{detail:{index:e,expanded:!t,item:i},bubbles:!0}))};t.addEventListener("click",l),this.headers.push({header:t,item:i,content:s,clickHandler:l,isDisabled:n}),this._listeners.push({el:t,event:"click",handler:l})})}_expandItem(t){const{item:e,content:i}=t;i.style.overflow="hidden",i.style.height="0",i.offsetHeight,i.style.transition=`height ${this.animationDuration}ms ease`,i.style.height=i.scrollHeight+"px",e.classList.add("is-active");const s=()=>{i.removeEventListener("transitionend",s),e.classList.contains("is-active")&&(i.style.height="auto",i.style.overflow="visible"),i.style.transition=""};i.addEventListener("transitionend",s),this._listeners.push({el:i,event:"transitionend",handler:s})}_collapseItem(t){const{item:e,content:i}=t;i.style.overflow="hidden",i.style.height=i.scrollHeight+"px",i.offsetHeight,i.style.transition=`height ${this.animationDuration}ms ease`,i.style.height="0",e.classList.remove("is-active");const s=()=>{i.removeEventListener("transitionend",s),i.style.transition=""};i.addEventListener("transitionend",s),this._listeners.push({el:i,event:"transitionend",handler:s})}destroy(){this._listeners.forEach(({el:t,event:e,handler:i})=>{t.removeEventListener(e,i)}),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,i)=>{i!==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 A(t,e){if(t.__kupolaInitialized)return;const i=new T(t,e);t.__kupolaInstance=i,t.__kupolaInitialized=!0}function z(t){if(!t.__kupolaInitialized||!t.__kupolaInstance)return;t.__kupolaInstance.destroy(),t.__kupolaInstance=null,t.__kupolaInitialized=!1}t.kupolaInitializer.register("collapse",A,z);class q{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(/^#/,""),i=parseInt(e.substring(0,2),16)/255,s=parseInt(e.substring(2,4),16)/255,n=parseInt(e.substring(4,6),16)/255,a=8===e.length?parseInt(e.substring(6,8),16)/255:1,l=Math.max(i,s,n),r=Math.min(i,s,n);let o=0,h=0,d=l;const c=l-r;if(h=0===l?0:c/l,l!==r)switch(l){case i:o=((s-n)/c+(s<n?6:0))/6;break;case s:o=((n-i)/c+2)/6;break;case n:o=((i-s)/c+4)/6}this.hue=Math.round(360*o),this.saturation=Math.round(100*h),this.brightness=Math.round(100*d),this.alpha=Math.round(100*a)}_HSBToColorString(t,e,i,s=1){e/=100,i/=100,s/=100;const n=e=>(e+t/60)%6,a=t=>i*(1-e*Math.max(0,Math.min(n(t),4-n(t),1))),l=Math.round(255*a(5)),r=Math.round(255*a(3)),o=Math.round(255*a(1));if("rgb"===this.mode)return s<1?`rgba(${l}, ${r}, ${o}, ${s.toFixed(2)})`:`rgb(${l}, ${r}, ${o})`;if("hsl"===this.mode)return s<1?`hsla(${t}, ${Math.round(100*e)}%, ${Math.round(100*i)}%, ${s.toFixed(2)})`:`hsl(${t}, ${Math.round(100*e)}%, ${Math.round(100*i)}%)`;const h=`#${l.toString(16).padStart(2,"0")}${r.toString(16).padStart(2,"0")}${o.toString(16).padStart(2,"0")}`;return s<1?h+Math.round(255*s).toString(16).padStart(2,"0"):h}_renderPreviousColors(){const t=this.panel.querySelector(".ds-color-picker__previous");t&&(t.innerHTML="",this.previousColors.forEach(e=>{const i=document.createElement("button");i.className="ds-color-picker__color",i.style.backgroundColor=e,i.setAttribute("data-color",e),i.addEventListener("click",this._colorClickHandler),t.appendChild(i)}))}_renderColorPanel(){const t=this.panel.querySelector(".ds-color-picker__hue"),e=this.panel.querySelector(".ds-color-picker__sv"),i=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%)`),i&&this.showAlpha&&(i.value=this.alpha,i.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(),i=t.clientX-e.left,s=t.clientY-e.top;this.saturation=Math.round(i/e.width*100),this.brightness=Math.round(100*(1-s/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 e=this.panel.querySelector(".ds-color-picker__hue");e&&e.addEventListener("input",this._hueChangeHandler);const i=this.panel.querySelector(".ds-color-picker__sv");i&&(i.addEventListener("click",this._saturationChangeHandler),i.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=t.globalEvents.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 i=this.panel?.querySelector(".ds-color-picker__alpha");i&&this._alphaChangeHandler&&i.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 B(t,e){const i=new q(t,e);i.init(),t._kupolaColorPicker=i}function P(t){t._kupolaColorPicker&&(t._kupolaColorPicker.destroy(),t._kupolaColorPicker=null)}t.kupolaInitializer.register("color-picker",B,P);class ${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()},i=()=>{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",i),this._listeners.push({el:this.todayBtn,event:"click",handler:i}))}_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),i=this._formatDate(this.rangeStart),s=this._formatDate(this.rangeEnd);return e>=i&&e<=s}_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 i=t.date||t.start,s=t.end;if(!i)return!1;const n="string"==typeof i?i:this._formatDate(i);if(!s)return n===e;const a="string"==typeof s?s:this._formatDate(s);return e>=n&&e<=a})}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 i=new Date(t,e,1).getDay(),s=new Date(t,e+1,0).getDate();this.daysEl.innerHTML="";for(let l=0;l<i;l++){const t=document.createElement("span");t.className="ds-calendar__day ds-calendar__day--empty",this.daysEl.appendChild(t)}const n=new Date,a=this._formatDate(n);for(let l=1;l<=s;l++){const i=new Date(t,e,l),s=document.createElement("button");s.className="ds-calendar__day",s.textContent=l;const n=this._formatDate(i);n===a&&s.classList.add("is-today"),this._isSameDay(i,this.selectedDate)&&s.classList.add("is-selected"),this.isRangeMode&&(this._isRangeStart(i)&&s.classList.add("is-range-start"),this._isRangeEnd(i)&&s.classList.add("is-range-end"),this._isDateInRange(i)&&s.classList.add("is-in-range"));const r=this._getEventsForDate(i);if(r.length>0){s.classList.add("has-events");const t=document.createElement("span");t.className="ds-calendar__day-event",t.style.backgroundColor=r[0].color||"#007bff",s.appendChild(t)}const o=()=>{this.element.querySelectorAll(".ds-calendar__day").forEach(t=>t.classList.remove("is-selected")),s.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:n}),this.element.dispatchEvent(new CustomEvent("kupola:calendar-select",{detail:{date:i,dateStr:n},bubbles:!0}))),r.forEach(t=>{this.onEventClick&&this.onEventClick(t,i)}),this.render()};s.addEventListener("click",o),this._listeners.push({el:s,event:"click",handler:o}),this.daysEl.appendChild(s)}}_renderWeekView(t,e){const i=this.currentDate.getDay(),s=new Date(t,e,this.currentDate.getDate()-i+(0===i?-6:1)),n=s,a=new Date(s);a.setDate(s.getDate()+6),this.titleEl.textContent=`${this.i18n.shortMonths[n.getMonth()]} ${n.getDate()} - ${this.i18n.shortMonths[a.getMonth()]} ${a.getDate()} ${t}`,this.daysEl.innerHTML="";const l=new Date,r=this._formatDate(l);for(let o=0;o<7;o++){const t=new Date(s);t.setDate(s.getDate()+o);const e=document.createElement("button");e.className="ds-calendar__day ds-calendar__day--week";const i=document.createElement("span");i.className="ds-calendar__day-header",i.textContent=this.i18n.shortWeekdays[t.getDay()],e.appendChild(i);const n=document.createElement("span");n.className="ds-calendar__day-number",n.textContent=t.getDate(),e.appendChild(n);const a=this._formatDate(t);a===r&&e.classList.add("is-today"),this._isSameDay(t,this.selectedDate)&&e.classList.add("is-selected");const l=this._getEventsForDate(t);if(l.length>0){const t=document.createElement("span");t.className="ds-calendar__day-events",l.slice(0,3).forEach(e=>{const i=document.createElement("span");i.className="ds-calendar__day-event",i.style.backgroundColor=e.color||"#007bff",t.appendChild(i)}),e.appendChild(t)}const h=()=>{this.element.querySelectorAll(".ds-calendar__day").forEach(t=>t.classList.remove("is-selected")),e.classList.add("is-selected"),this.selectedDate=t,this.onSelect&&this.onSelect({date:t,dateStr:a}),this.element.dispatchEvent(new CustomEvent("kupola:calendar-select",{detail:{date:t,dateStr:a},bubbles:!0})),this.render()};e.addEventListener("click",h),this._listeners.push({el:e,event:"click",handler:h}),this.daysEl.appendChild(e)}}destroy(){this._listeners.forEach(({el:t,event:e,handler:i})=>{t.removeEventListener(e,i)}),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 F(t,e){if(!t.__kupolaInitialized)try{const i=new $(t,e);t.__kupolaInstance=i,t.__kupolaInitialized=!0}catch(i){console.error("[Calendar] Error initializing:",i)}}function N(t){if(!t.__kupolaInitialized||!t.__kupolaInstance)return;t.__kupolaInstance.destroy(),t.__kupolaInstance=null,t.__kupolaInitialized=!1}t.kupolaInitializer.register("calendar",F,N);class O{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 i=e=>{e.stopPropagation(),t.remove(),this.dispatchChange()};e.addEventListener("click",i),this._listeners.push({el:e,event:"click",handler:i})}}),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 i=()=>{this.input.focus()};this.element.addEventListener("click",i),this._listeners.push({el:this.element,event:"click",handler:i})}}createTag(t){const e=document.createElement("span");e.className=`ds-dynamic-tags__tag ds-dynamic-tags__tag--${this.color}`;const i=document.createTextNode(t);e.appendChild(i);const s=document.createElement("button");s.className="ds-dynamic-tags__remove",s.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(s);const n=t=>{t.stopPropagation(),e.remove(),this.dispatchChange()};return s.addEventListener("click",n),this._listeners.push({el:s,event:"click",handler:n}),e}hasTag(t){const e=this.element.querySelectorAll(".ds-dynamic-tags__tag");for(const i of e)if(i.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 i=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=>i.classList.remove(t)),t.includes(`ds-dynamic-tags__tag--${e}`)&&i.classList.add(`ds-dynamic-tags__tag--${e}`)}this.element.insertBefore(i,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 i of e)if(i.textContent.trim()===t)return i.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 i=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:i})}),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:i})=>{t.removeEventListener(e,i)}),this._listeners=null,this.input=null,this.element=null}}function V(t,e){if(t.__kupolaInitialized)return;const i=new O(t,e);t.__kupolaInstance=i,t.__kupolaInitialized=!0}function R(t){if(!t.__kupolaInitialized||!t.__kupolaInstance)return;t.__kupolaInstance.destroy(),t.__kupolaInstance=null,t.__kupolaInitialized=!1}t.kupolaInitializer.register("dynamic-tags",V,R);class K{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"),i=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),i.addEventListener("click",this._nextHandler);this.overlay.querySelectorAll(".ds-image-preview__toolbar-btn").forEach(t=>{t.addEventListener("click",e=>{const i=t.getAttribute("data-action");this.handleToolbarAction(i)})});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"),i=this.overlay.querySelector(".ds-image-preview__meta"),s=this.overlay.querySelector(".ds-image-preview__indicators"),n=this.overlay.querySelector(".ds-image-preview__nav-btn--prev"),a=this.overlay.querySelector(".ds-image-preview__nav-btn--next"),l=this.images[this.currentIndex];t.src=l.src,t.alt=l.alt||"",e.textContent=l.title||"",i.textContent=l.meta||`${this.currentIndex+1} / ${this.images.length}`,n.disabled=0===this.currentIndex,a.disabled=this.currentIndex===this.images.length-1,s.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(""),s.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"),i=this.overlay?.querySelector(".ds-image-preview__nav-btn--prev"),s=this.overlay?.querySelector(".ds-image-preview__nav-btn--next");e&&e.removeEventListener("click",this.closeHandler),i&&this._prevHandler&&i.removeEventListener("click",this._prevHandler),s&&this._nextHandler&&s.removeEventListener("click",this._nextHandler),this.overlay&&this.overlay.parentNode&&this.overlay.parentNode.removeChild(this.overlay)}}let W=null;class Y{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 i=this.element.querySelector(".ds-tag__close"),s=this.element.querySelector(".ds-tag__checkbox"),n=this.element.querySelector(".ds-tag__input"),a=i||s||n||null;this.element.insertBefore(document.createTextNode(t),a),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 i=this.element.querySelector(".ds-tag__close");this.element.insertBefore(e,i);const s=()=>this.endEdit(),n=t=>{"Enter"===t.key?this.endEdit():"Escape"===t.key&&this.cancelEdit()};e.addEventListener("blur",s),e.addEventListener("keydown",n),this._listeners.push({el:e,event:"blur",handler:s}),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:i})=>{t.removeEventListener(e,i)}),this._listeners=[],this.closeBtn=null,this.checkbox=null,this.editInput=null,this.element=null}}function U(t,e){if(t.__kupolaInitialized)return;const i=new Y(t,e);t.__kupolaInstance=i,t.__kupolaInitialized=!0}function X(t){if(!t.__kupolaInitialized||!t.__kupolaInstance)return;t.__kupolaInstance.destroy(),t.__kupolaInstance=null,t.__kupolaInitialized=!1}t.kupolaInitializer.register("tag",U,X);class Z{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 i=parseFloat(e[0].replace(",","")),s=t.substring(0,e.index),n=t.substring(e.index+e[0].length),a=performance.now(),l=t=>{const e=t-a,r=Math.min(e/1500,1),o=1-Math.pow(1-r,3),h=0+(i-0)*o;let d;d=i>=1e6?(h/1e6).toFixed(1)+"M":i>=1e3?(h/1e3).toFixed(1)+"K":Number.isInteger(i)?Math.floor(h).toLocaleString():h.toFixed(2),this.valueElement.textContent=s+d+n,r<1&&requestAnimationFrame(l)};requestAnimationFrame(l)}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 i=e.duration||800,s=this.valueElement.textContent,n=s.match(/[\d.,]+/);if(!n)return void(this.valueElement.textContent=t);const a=s.substring(0,n.index),l=s.substring(n.index+n[0].length),r=parseFloat(n[0].replace(",","")),o=parseFloat(t),h=performance.now(),d=t=>{const e=t-h,s=Math.min(e/i,1),n=1-Math.pow(1-s,3),c=r+(o-r)*n;let u;u=o>=1e6?(c/1e6).toFixed(1)+"M":o>=1e3?(c/1e3).toFixed(1)+"K":Number.isInteger(o)?Math.floor(c).toLocaleString():c.toFixed(2),this.valueElement.textContent=a+u+l,s<1&&requestAnimationFrame(d)};requestAnimationFrame(d)}updateProgress(t,e={}){if(!this.progressFill)return;const i=e.duration||600,s=parseFloat(this.progressFill.style.width||"0"),n=Math.min(Math.max(t,0),100),a=performance.now(),l=t=>{const e=t-a,r=Math.min(e/i,1),o=1-Math.pow(1-r,3),h=s+(n-s)*o;this.progressFill.style.width=h+"%",r<1&&requestAnimationFrame(l)};requestAnimationFrame(l)}setTrend(t,e){const i=this.element.querySelector(".ds-statcard__trend");if(!i)return;i.className=`ds-statcard__trend ds-statcard__trend--${t}`;const s="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>';i.innerHTML=s+e}destroy(){this._observer&&(this._observer.disconnect(),this._observer=null),this.animated=!1,this.valueElement=null,this.progressFill=null,this.element=null}}function j(t){if(t.__kupolaInitialized)return;const e=new Z(t);t.__kupolaInstance=e,t.__kupolaInitialized=!0}function G(t){if(!t.__kupolaInitialized||!t.__kupolaInstance)return;t.__kupolaInstance.destroy(),t.__kupolaInstance=null,t.__kupolaInitialized=!1}t.kupolaInitializer.register("statcard",j,G);class J{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),i=this.data.find(t=>t.date===e);return i?i.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 i=t/e;return i<.2?1:i<.4?2:i<.6?3:i<.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 i=[.2,.4,.6,.8,1][t-1];return`rgba(${e.r}, ${e.g}, ${e.b}, ${i})`}getWeekdayLabels(){return["","一","","三","","五",""]}getMonthLabels(){const t=["1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"],e=[];let i=-1;for(let s=new Date(this.startDate);s<=this.endDate;s.setDate(s.getDate()+1)){const n=s.getMonth(),a=s.getDate();n!==i&&1===a&&(e.push({month:n,label:t[n],offset:Math.floor((s-this.startDate)/864e5)}),i=n)}return e}getWeekCount(){let t=0;const e=new Date(this.startDate).getDay();for(let i=new Date(this.startDate);i<=this.endDate;i.setDate(i.getDate()+1))0===i.getDay()&&t++;return 0!==e&&t++,t}render(){const t=this.element.querySelector(".ds-heatmap__body");if(!t)return;t.innerHTML="";const e=[];let i=[];const s=new Date(this.startDate).getDay();for(let g=1;g<s;g++)i.push(null);for(let g=new Date(this.startDate);g<=this.endDate;g.setDate(g.getDate()+1))i.push(new Date(g)),6!==g.getDay()&&g.getTime()!==this.endDate.getTime()||(e.push(i),i=[]);const n=e.length,a=this.element.classList.contains("ds-heatmap--compact")?12:16,l=n*a,r=document.createElement("div");r.className="ds-heatmap__container";const o=document.createElement("div");o.className="ds-heatmap__labels-and-grid";const h=document.createElement("div");h.className="ds-heatmap__weekday-labels";const d=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=d+"px",e.style.lineHeight=d+"px",h.appendChild(e)}),o.appendChild(h);const c=document.createElement("div");c.className="ds-heatmap__grid-container";const u=document.createElement("div");u.className="ds-heatmap__month-labels",u.style.width=l+"px";const p=this.getMonthLabels();p.forEach((t,e)=>{const i=document.createElement("div");i.className="ds-heatmap__month-label",i.textContent=t.label;const s=p[e+1];let l;l=s?Math.ceil((s.offset-t.offset)/7):n-Math.floor(t.offset/7),i.style.width=l*a+"px",u.appendChild(i)}),c.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 i=this.getDataByDate(t),s=Math.max(...this.data.map(t=>t.value),1),n=this.getLevel(i,s),a=document.createElement("div");a.className="ds-heatmap__cell",a.dataset.date=this.formatDate(t),a.dataset.value=i,a.style.backgroundColor=this.getCellColor(n);const l=e=>this.showTooltip(e,t,i),r=()=>this.hideTooltip(),o=()=>{this.onCellClick&&this.onCellClick({date:this.formatDate(t),value:i})};a.addEventListener("mouseenter",l),a.addEventListener("mouseleave",r),a.addEventListener("click",o),this._listeners.push({el:a,event:"mouseenter",handler:l},{el:a,event:"mouseleave",handler:r},{el:a,event:"click",handler:o}),e.appendChild(a)}}),m.appendChild(e)}),c.appendChild(m),o.appendChild(c),r.appendChild(o),t.appendChild(r),this.renderLegend(t)}renderLegend(t){const e=document.createElement("div");e.className="ds-heatmap__legend";const i=document.createElement("span");i.className="ds-heatmap__legend-label",i.textContent="少";const s=document.createElement("div");s.className="ds-heatmap__legend-cells";for(let a=0;a<=5;a++){const t=document.createElement("div");t.className="ds-heatmap__legend-cell",t.style.backgroundColor=this.getCellColor(a),s.appendChild(t)}const n=document.createElement("span");n.className="ds-heatmap__legend-label",n.textContent="多",e.appendChild(i),e.appendChild(s),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,i){const s=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">${i} contributions</div>\n `,this.tooltip.style.left=Math.min(s.left+s.width/2-75,window.innerWidth-150-16)+"px",this.tooltip.style.top=s.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:i})=>{t.removeEventListener(e,i)}),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:i})=>{t.removeEventListener(e,i)}),this._listeners=null,this.tooltip&&this.tooltip.parentNode&&this.tooltip.parentNode.removeChild(this.tooltip),this.tooltip=null,this.data=[],this.element=null}}function Q(t){if(t.__kupolaInitialized)return;const e=t.getAttribute("data-heatmap-data");let i=[];if(e)try{i=JSON.parse(e)}catch(n){i=et()}else i=et();const s=new J(t,{data:i,onCellClick:t=>{}});t.__kupolaInstance=s,t.__kupolaInitialized=!0}function tt(t){if(!t.__kupolaInitialized||!t.__kupolaInstance)return;t.__kupolaInstance.destroy(),t.__kupolaInstance=null,t.__kupolaInitialized=!1}function et(){const t=[],e=new Date,i=new Date;i.setFullYear(i.getFullYear()-1);for(let s=new Date(i);s<=e;s.setDate(s.getDate()+1)){const e=s.getFullYear(),i=String(s.getMonth()+1).padStart(2,"0"),n=String(s.getDate()).padStart(2,"0"),a=0===s.getDay()||6===s.getDay()?20*Math.random():50*Math.random(),l=Math.floor(a);t.push({date:`${e}-${i}-${n}`,value:l>0?l:Math.floor(30*Math.random())+1})}return t}t.kupolaInitializer.register("heatmap",Q,tt);class it{constructor(e,i={}){this.element=e,this.tooltipEl=null,this.options=i;const s=t.getUiConfig(),n=void 0!==s.tooltip?.delay?s.tooltip.delay:300;this.delay=void 0!==i.delay?i.delay:parseInt(e.getAttribute("data-tooltip-delay"))||n,this.hideDelay=i.hideDelay||parseInt(e.getAttribute("data-tooltip-hide-delay"))||0,this.trigger=i.trigger||e.getAttribute("data-tooltip-trigger")||"hover",this.html=i.html||e.hasAttribute("data-tooltip-html"),this.theme=i.theme||e.getAttribute("data-tooltip-theme")||"default",this.position=i.position||e.getAttribute("data-tooltip-position")||"top",this.animation=!1!==i.animation,this.mouseFollow=i.mouseFollow||e.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 i=t.clientX+10,s=t.clientY+10;const n=window.innerWidth,a=window.innerHeight;i+e.width>n&&(i=t.clientX-e.width-10),s+e.height>a&&(s=t.clientY-e.height-10),this.tooltipEl.style.left=`${i}px`,this.tooltipEl.style.top=`${s}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 e=this.element.getAttribute("data-tooltip");if(!e)return;this.tooltipEl=document.createElement("div"),this.tooltipEl.className=`ds-tooltip ds-tooltip--${this.position} ds-tooltip--${this.theme}`;const i=t.getZIndexConfig().tooltip;this.tooltipEl.style.zIndex=i,this.tooltipEl.style.transform="translateZ(0)",this.html?this.tooltipEl.innerHTML=e:this.tooltipEl.textContent=e,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(),i=window.innerWidth,s=window.innerHeight;let n,a;switch(this.position){case"bottom":n=t.left+t.width/2-e.width/2,a=t.bottom+8;break;case"right":n=t.right+8,a=t.top+t.height/2-e.height/2;break;case"left":n=t.left-e.width-8,a=t.top+t.height/2-e.height/2;break;default:n=t.left+t.width/2-e.width/2,a=t.top-e.height-8}n<8&&(n=8),n+e.width>i&&(n=i-e.width-8),a<8&&(a=8),a+e.height>s&&(a=s-e.height-8),this.tooltipEl.style.left=`${n}px`,this.tooltipEl.style.top=`${a}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 st(t,e){const i=new it(t,e);i.init(),t._kupolaTooltip=i}function nt(t){t._kupolaTooltip&&(t._kupolaTooltip.destroy(),t._kupolaTooltip=null)}t.kupolaInitializer.register("tooltip",st,nt);class at{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)}`,i={},s=t.querySelectorAll("[data-validate]");let n=!1;return s.forEach(t=>{const e=t.name||t.id,s=this.parseRules(t.getAttribute("data-validate")),a=this.getValue(t);for(const[l,r]of Object.entries(s)){const s=this.customValidators[l]||this.validators[l],o=s?.(a,r);if(!o){i[e]=this.getErrorMessage(l,r,t),this.showError(t,i[e]),n=!0;break}this.clearError(t)}}),this.formStates[e]={valid:!n,errors:i,errorCount:Object.keys(i).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"),i=e.querySelector(".ds-select__value")||e.querySelector(".ds-select__trigger span");return i?i.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")),i=this.getValue(t);for(const[s,n]of Object.entries(e)){const e=this.customValidators[s]||this.validators[s],a=e?.(i,n);if(!a)return this.showError(t,this.getErrorMessage(s,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 i=t.id||`form-${Math.random().toString(36).substr(2,9)}`,s=e.group,n=s?t.querySelectorAll(`[data-validate][data-validate-group="${s}"]`):t.querySelectorAll("[data-validate]");let a=!1;for(const r of n){await this.validateInputAsync(r)||(a=!0)}const l={};return n.forEach(t=>{const e=t.name||t.id,i=t.parentElement.querySelector(".ds-input__error");i&&(l[e]=i.textContent)}),this.formStates[i]={valid:!a,errors:l,errorCount:Object.keys(l).length},this.updateFormState(t),!a}async validateInputAsync(t){const e=this.parseRules(t.getAttribute("data-validate")),i=this.parseRules(t.getAttribute("data-validate-async")||""),s=this.getValue(t);for(const[a,l]of Object.entries(e)){const e=this.customValidators[a]||this.validators[a],i=e?.(s,l);if(!i)return this.showError(t,this.getErrorMessage(a,l,t)),!1}for(const[a,l]of Object.entries(i)){const e=this.customAsyncValidators[a]||this.asyncValidators[a];if(e)try{if(!(await e(s,l,t)))return this.showError(t,this.getErrorMessage(a,l,t)),!1}catch(n){return this.showError(t,n.message||"Validation error"),!1}}return this.clearError(t),!0}async validateGroup(t,e){const i=t.querySelectorAll(`[data-validate][data-validate-group="${e}"]`);let s=!1;for(const n of i){await this.validateInputAsync(n)||(s=!0)}return!s}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 i=t.querySelector(".ds-form__status");i&&(e.errorCount>0?(i.textContent=`${e.errorCount} ${1===e.errorCount?"error":"errors"} found`,i.classList.add("ds-form__status--error")):(i.textContent="All fields are valid",i.classList.remove("ds-form__status--error")))}setFormLoading(t,e){const i=t.id||`form-${Math.random().toString(36).substr(2,9)}`;this.formStates[i]||(this.formStates[i]={valid:!0,errors:{},errorCount:0,loading:!1,submitting:!1,disabled:!1}),this.formStates[i].loading=e,this.updateFormState(t)}setFormSubmitting(t,e){const i=t.id||`form-${Math.random().toString(36).substr(2,9)}`;this.formStates[i]||(this.formStates[i]={valid:!0,errors:{},errorCount:0,loading:!1,submitting:!1,disabled:!1}),this.formStates[i].submitting=e,this.updateFormState(t)}setFormDisabled(t,e){const i=t.id||`form-${Math.random().toString(36).substr(2,9)}`;this.formStates[i]||(this.formStates[i]={valid:!0,errors:{},errorCount:0,loading:!1,submitting:!1,disabled:!1}),this.formStates[i].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[i,s]=t.split(":");e[i]=s?s.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 i=document.getElementById(e);return i&&t===i.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 i=t.parentElement.querySelector(".ds-input__error");i||(i=document.createElement("span"),i.className="ds-input__error",i.setAttribute("role","alert"),i.setAttribute("aria-live","polite"),t.parentElement.appendChild(i)),i.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,i){const s=i.getAttribute(`data-message-${t}`);if(s)return s;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 lt=new at;window.__kupolaValidationInitialized||(window.__kupolaValidationInitialized=!0,document.addEventListener("DOMContentLoaded",()=>{document.querySelectorAll("form[data-validation]").forEach(e=>{e.addEventListener("submit",async t=>{const i=e.id||`form-${Math.random().toString(36).substr(2,9)}`;if(lt.submitting.has(i))return void t.preventDefault();t.preventDefault();let s;if(s=null!==e.querySelector("[data-validate-async]")?await lt.validateAsync(e):lt.validate(e),s){lt.submitting.add(i);const t=e.querySelector('button[type="submit"]');if(t){const e=t.textContent;t.setAttribute("data-original-text",e),t.textContent="Submitting...",t.disabled=!0}try{const t=e.getAttribute("data-on-submit");t&&window[t]?await window[t](e):e.submit()}finally{lt.submitting.delete(i),t&&(t.textContent=t.getAttribute("data-original-text")||"Submit",t.disabled=!1)}}else{const t=e.querySelector(".ds-input--error");t&&t.focus()}}),e.querySelectorAll("[data-validate]").forEach(e=>{const i=t.getValidationConfig(),s=i.trigger||"blur",n=()=>{i.showErrors&&setTimeout(()=>{const t=document.activeElement;if(t&&t.closest(".ds-select"))return;lt.validateInput(e)&&e.value.trim()&<.showSuccess(e)},50)};"blur"!==s&&"both"!==s||e.addEventListener("blur",n);const a=((t,e)=>{let i;return(...s)=>{clearTimeout(i),i=setTimeout(()=>t(...s),e)}})(()=>{if(!i.showErrors)return;const t=lt.getValue(e);if(t.length>0||e.classList.contains("ds-input--error")){lt.validateInput(e)&&t&<.showSuccess(e)}else lt.removeStatusIcon(e)},t.getPerformanceConfig().debounceDelay);"input"!==s&&"both"!==s||e.addEventListener("input",a),e.addEventListener("keyup",t=>{if("Enter"===t.key){lt.validateInput(e)&&e.value.trim()&<.showSuccess(e)}})})})}));class rt{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"),i=e?this.element.scrollLeft:this.element.scrollTop;this.onScroll&&this.onScroll({scrollOffset:i,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((i,s)=>{const n=this.getItemSize(s);t.push({start:e,end:e+n,size:n}),e+=n}),t}getTotalSize(){if(this.useDynamicHeight)return this.data.reduce((t,e,i)=>t+this.getItemSize(i),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 i=0;i<e.length;i++)if(t>=e[i].start&&t<e[i].end)return i;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,i=t?this.element.clientWidth:this.element.clientHeight,s=Math.max(0,this.getIndexAtOffset(e)-this.bufferSize);let n=Math.min(this.data.length-1,this.getIndexAtOffset(e+i)+this.bufferSize);n<s&&(n=s),this.startIndex=s,this.endIndex=n;const a=this.data.slice(s,n+1);let l="",r=0;if(this.useDynamicHeight){const t=this.getItemPositions();r=t[s]?.start||0}else{const e=t?this.itemWidth:this.itemHeight;r=s*e}a.forEach((e,i)=>{const n=s+i,a=e[this.keyField]||n,o=this.selectedKey===a,h=this.getItemSize(n);l+=this._buildItemHtml(e,n,a,o,h,r,t),r+=h}),this.container.innerHTML=l,this.useDynamicHeight&&this.updateDynamicHeights(),this.container.querySelectorAll(".ds-virtual-list__item").forEach(t=>{t.addEventListener("click",()=>this.handleItemClick(t))})}_buildItemHtml(t,e,i,s,n,a,l){const r=s?" is-selected":"",o=this.renderItem(t,e);return l?`<div class="ds-virtual-list__item${r}" style="position: absolute; top: 0; left: ${a}px; width: ${n}px; height: 100%;" data-index="${e}" data-key="${i}">${o}</div>`:`<div class="ds-virtual-list__item${r}" style="position: absolute; top: ${a}px; left: 0; right: 0; height: ${n}px;" data-index="${e}" data-key="${i}">${o}</div>`}updateDynamicHeights(){if(this.isUpdating)return;let t=!1;this.container.querySelectorAll(".ds-virtual-list__item").forEach(e=>{const i=parseInt(e.dataset.index),s=this.data[i][this.keyField]||i,n=e.offsetHeight;n!==this.getItemSize(i)&&(this.dynamicHeightCache.set(s,n),t=!0)}),t&&(this.isUpdating=!0,this.update(),this.isUpdating=!1)}handleItemClick(t){const e=parseInt(t.dataset.index),i=t.dataset.key,s=this.data[e];this.onItemClick&&this.onItemClick({item:s,index:e,key:i}),this.onItemSelect&&this.select(i)}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(),i=t?this.element.clientWidth:this.element.clientHeight,s=t?this.element.scrollLeft:this.element.scrollTop;if(t)return void(this.scrollbarThumb.style.display="none");const n=Math.max(20,i/e*i),a=s/(e-i||1)*(i-n);this.scrollbarThumb.style.height=n+"px",this.scrollbarThumb.style.top=a+"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,i=this.getTotalSize(),s=e-(parseFloat(this.scrollbarThumb.style.height)||e),n=t.clientY-this.dragStartY;let a=this.dragStartTop+n;a=Math.max(0,Math.min(a,s)),this.scrollbarThumb.style.top=a+"px";const l=a/s*(i-e||0);this.element.scrollTop=l}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 i=this.element.classList.contains("ds-virtual-list--horizontal");let s=0;if(this.useDynamicHeight){const e=this.getItemPositions();s=e[t]?.start||0}else{s=t*(i?this.itemWidth:this.itemHeight)}i?this.element.scrollTo({left:s,behavior:e}):this.element.scrollTo({top:s,behavior:e})}scrollToKey(t,e="smooth"){const i=this.data.findIndex(e=>e[this.keyField]===t);-1!==i&&this.scrollTo(i,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"),i=this.getTotalSize(),s=e?this.element.clientWidth:this.element.clientHeight;this.element.scrollTo({[e?"left":"top"]:i-s,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:i})=>{t.removeEventListener(e,i)}),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 ot(t=1e3){const e=[],i=["Document","Image","Video","Folder","Archive","Spreadsheet","Presentation","Code"];for(let s=1;s<=t;s++){const t=Math.floor(Math.random()*i.length),n=Math.floor(1e4*Math.random());e.push({id:s,title:`${i[t]} ${n}`,subtitle:`Last modified ${Math.floor(30*Math.random())} days ago`,type:i[t].toLowerCase()})}return e}function ht(t){if(t.__kupolaInitialized)return;const e=t.getAttribute("data-virtual-list");let i=[];if(e)try{i=JSON.parse(e)}catch(n){i=ot(1e3)}else i=ot(1e3);const s=new rt(t,{data:i,onItemClick:t=>{},onItemSelect:t=>{}});t.__kupolaInstance=s,t.__kupolaInitialized=!0}function dt(t){if(!t.__kupolaInitialized||!t.__kupolaInstance)return;t.__kupolaInstance.destroy(),t.__kupolaInstance=null,t.__kupolaInitialized=!1}t.kupolaInitializer.register("virtual-list",ht,dt);const ct={check:'<polyline points="4 12 10 18 20 6"/>',x:'<line x1="6" y1="6" x2="18" y2="18"/><line x1="18" y1="6" x2="6" y2="18"/>',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"/>',"chevron-right":'<polyline points="9 6 15 12 9 18"/>',"chevron-down":'<polyline points="6 9 12 15 18 9"/>',"chevron-up":'<polyline points="6 15 12 9 18 15"/>',"chevron-left":'<polyline points="15 6 9 12 15 18"/>'},ut={...ct},pt={core:ct,interface:{search:'<circle cx="11" cy="11" r="7"/><path d="m20 20-3.5-3.5"/>',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"/>',"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"/>',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"/>',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"/>',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"/>'},navigation:{"arrow-right":'<line x1="4" y1="12" x2="20" y2="12"/><polyline points="14 6 20 12 14 18"/>',"arrow-left":'<line x1="20" y1="12" x2="4" y2="12"/><polyline points="10 6 4 12 10 18"/>',"arrow-up":'<line x1="12" y1="20" x2="12" y2="4"/><polyline points="6 10 12 4 18 10"/>',"arrow-down":'<line x1="12" y1="4" x2="12" y2="20"/><polyline points="6 14 12 20 18 14"/>',"arrow-up-right":'<line x1="6" y1="18" x2="18" y2="6"/><polyline points="9 6 18 6 18 15"/>',"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-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"/>',home:'<polygon points="3 11 12 3 21 11 21 21 14 21 14 14 10 14 10 21 3 21 3 11"/>'},action:{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"/>',download:'<path d="M12 3v12"/><polyline points="7 10 12 15 17 10"/><line x1="3" y1="21" x2="21" y2="21"/>',upload:'<path d="M12 21V9"/><polyline points="7 14 12 9 17 14"/><line x1="3" y1="3" x2="21" y2="3"/>',copy:'<rect x="8" y="8" width="13" height="13"/><path d="M16 8V4H4v13h4"/>',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"/>',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"/>',"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"/>'},status:{"check-circle":'<circle cx="12" cy="12" r="9"/><polyline points="8 12 11 15 16 9"/>',"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-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"/>',"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"/>',"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"/>',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"/>'},user:{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"/>',"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"/>',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"/>',lock:'<rect x="4" y="11" width="16" height="10"/><path d="M8 11V8a4 4 0 0 1 8 0v3"/>'},media:{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"/>',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"/>',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"/>'},data:{table:'<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"/>',"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"/>',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"/>',layers:'<polygon points="12 3 22 8 12 13 2 8 12 3"/><polyline points="2 13 12 18 22 13"/>',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"/>',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"/>'},file:{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"/>',"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"/>',folder:'<path d="M3 6h6l2 3h10v10H3z"/>',mail:'<rect x="3" y="5" width="18" height="14"/><polyline points="3 6 12 13 21 6"/>'},time:{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"/>'},misc:{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"/>',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"/>',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"/>',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"/>',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-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"/>',"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"/>',"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)"/>',"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"/>',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"/>',terminal:'<polyline points="4 7 9 12 4 17"/><line x1="12" y1="17" x2="20" y2="17"/>',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"/>',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"/>',filter:'<polygon points="3 4 21 4 14 12 14 20 10 18 10 12 3 4"/>',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"/>',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"/>',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 mt(t,e=16,i="0 0 24 24"){const s=ut[t];if(!s)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="${i}"`)}>${s}</svg>`}function gt(t=document){t.querySelectorAll("[data-icon]").forEach(t=>{const e=t.getAttribute("data-icon"),i=+t.getAttribute("data-size")||16,s=t.getAttribute("data-viewbox")||"0 0 24 24";t.innerHTML=mt(e,i,s),t.classList.add("icon")})}const _t={svg:mt,render:gt,PATHS:ut,registerIcons:function(t){Object.assign(ut,t)},registerGroup:function(t){const e=pt[t];return!!e&&(Object.assign(ut,e),!0)},registerAllGroups:function(){Object.values(pt).forEach(t=>{Object.assign(ut,t)})},iconGroups:pt};"undefined"!=typeof document&&("loading"!==document.readyState?gt():document.addEventListener("DOMContentLoaded",()=>gt()));class vt{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,i=parseInt(this.element.getAttribute("data-minutes"))||0,s=parseInt(this.element.getAttribute("data-seconds"))||0;return(new Date).getTime()+1e3*(3600*e+60*i+s)}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 i=Math.floor(e%864e5/36e5),s=Math.floor(e%36e5/6e4),n=Math.floor(e%6e4/1e3);this.displayTime(i,s,n)}displayTime(t,e,i){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(i).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 yt(t){if(t.__kupolaInitialized)return;const e=new vt(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}t.kupolaInitializer.register("countdown",yt,ft);class bt{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),i=()=>this.handleInput();this.minusBtn.addEventListener("click",t),this.plusBtn.addEventListener("click",e),this.inputEl.addEventListener("input",i),this._listeners.push({el:this.minusBtn,event:"click",handler:t},{el:this.plusBtn,event:"click",handler:e},{el:this.inputEl,event:"input",handler:i})}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:i})=>{t.removeEventListener(e,i)}),this._listeners=null,this.minusBtn=null,this.plusBtn=null,this.inputEl=null,this.element=null}}function kt(t){if(!t.__kupolaInitialized)try{const e=new bt(t);t.__kupolaInstance=e,t.__kupolaInitialized=!0}catch(e){console.error("[NumberInput] Error initializing:",e)}}function xt(t){if(!t.__kupolaInitialized||!t.__kupolaInstance)return;t.__kupolaInstance.destroy(),t.__kupolaInstance=null,t.__kupolaInitialized=!1}t.kupolaInitializer.register("number-input",kt,xt);class Et{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 i=t.clientX-this.startX;i<0&&(i=0),i>e&&(i=e),this.currentX=i,this.btn.style.left=14+i+"px",this.progress&&(this.progress.style.width=i/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 i=t.touches[0].clientX-this.startX;i<0&&(i=0),i>e&&(i=e),this.currentX=i,this.btn.style.left=14+i+"px",this.progress&&(this.progress.style.width=i/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=t.globalEvents.on(document,"mousemove",this._mouseMoveHandler,{scope:this.scope}),this._mouseUpListener=t.globalEvents.on(document,"mouseup",this._mouseUpHandler,{scope:this.scope}),this._touchMoveListener=t.globalEvents.on(document,"touchmove",this._touchMoveHandler,{scope:this.scope,passive:!1}),this._touchEndListener=t.globalEvents.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,i=.35*t,s=.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(i+Math.random()*(n-i-e)),this.distractorX=Math.floor(n+Math.random()*(s-n))):(this.targetX=Math.floor(n+Math.random()*(s-n)),this.distractorX=Math.floor(i+Math.random()*(n-i-e)))}else this.targetX=Math.floor(i+Math.random()*(s-i));const a=this.container.querySelector(".ds-slider-captcha__target");if(a&&(a.style.left=this.targetX+14+e/2+"px",a.style.transform="translate(-50%, -50%) rotate("+this.angle+"deg)",a.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 i=Date.now()-this.startTime;let s=0,n=0;if(this.trackData.length>0){const t=this.trackData[this.trackData.length-1],e=this.currentX-t.x,a=i-t.t;if(a>0&&(s=e/a,this.trackData.length>1)){const e=this.trackData[this.trackData.length-2],i=t.t-e.t;if(i>0){n=s-(t.x-e.x)/i}}}this.trackData.push({x:this.currentX,y:e-this.startY,t:i,v:s,a:n});const a=this.container.querySelector(".ds-slider-captcha__point-count");a&&(a.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,i=Math.abs(t-this.targetX);if(this.hasDistractor&&e<i&&e<=this.config.tolerance)return{passed:!1,msg:"验证失败"};if(i>this.config.tolerance)return{passed:!1,msg:"验证失败"};const s=[];for(let r=1;r<this.trackData.length;r++){const t=this.trackData[r].x-this.trackData[r-1].x,e=this.trackData[r].t-this.trackData[r-1].t;e>0&&e<500&&s.push(t/e)}if(s.length<3)return{passed:!1,msg:"验证失败"};if(Math.max(...s)-Math.min(...s)<this.config.minSpeedDelta)return{passed:!1,msg:"验证失败"};let n=!1;for(const r of this.trackData)if(Math.abs(r.y)>2){n=!0;break}if(!n&&this.trackData.length>20)return{passed:!1,msg:"验证失败"};const a=this.trackData[this.trackData.length-1].t;if(a<this.config.minDuration)return{passed:!1,msg:"验证失败"};if(a>this.config.maxDuration)return{passed:!1,msg:"验证失败"};const l=[];for(let r=1;r<s.length;r++)l.push(Math.abs(s[r]-s[r-1]));if(l.length>2){if(l.reduce((t,e)=>t+e,0)/l.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 i=this.container.getAttribute("data-on-verified");i&&"function"==typeof window[i]&&window[i](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 Ct(){document.querySelectorAll(".ds-slider-captcha").forEach(t=>{const e=new Et(t);e.init(),t._kupolaSlideCaptcha=e})}function wt(t){t._kupolaSlideCaptcha&&(t._kupolaSlideCaptcha.destroy(),t._kupolaSlideCaptcha=null)}function St(){document.querySelectorAll(".ds-slider-captcha").forEach(t=>{wt(t)})}t.kupolaInitializer.register("slide-captcha",Ct,St);class Lt{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 i=document.getElementById(e);return!i||t===i.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),i=()=>this.clearError(t);this._fieldHandlers.set(t,{blur:e,input:i}),t.addEventListener("blur",e),t.addEventListener("input",i)})}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=[],i=this._getFieldValue(t);for(const[s,n]of Object.entries(this.validators)){const a=t.getAttribute(`data-${s}`);if(null!==a){if(!n(i,a)){let t=this.errorMessages[s];"function"==typeof t&&(t=t(a)),e.push(t)}}}return e}_getFieldValue(t){const e=t.type;if("checkbox"===e)return t.checked;if("radio"===e){const e=t.name,i=this.form.querySelector(`input[name="${e}"]:checked`);return i?i.value:null}return"select-multiple"===e?Array.from(t.selectedOptions).map(t=>t.value):t.value}showError(t,e){this.clearError(t);const i=document.createElement("span");i.className="ds-form-error",i.textContent=e,t.classList.add("ds-form-field--error");const s=t.parentElement;s.classList.contains("ds-form-field")?s.appendChild(i):t.parentNode.insertBefore(i,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,i){this.validators[t]=e,this.errorMessages[t]=i}getData(){const t={};return this.fields.forEach(e=>{const i=e.name;if(!i)return;const s=this._getFieldValue(e);"checkbox"===e.type?(t[i]||(t[i]=[]),e.checked&&t[i].push(e.value)):"radio"===e.type?!t[i]&&e.checked&&(t[i]=e.value):t[i]=s}),t}setData(t){Object.keys(t).forEach(e=>{this.form.querySelectorAll(`[name="${e}"]`).forEach(i=>{const s=i.type;if("checkbox"===s){const s=Array.isArray(t[e])?t[e]:[t[e]];i.checked=s.includes(i.value)}else if("radio"===s)i.checked=i.value===t[e];else if("select-multiple"===s){const s=Array.isArray(t[e])?t[e]:[t[e]];Array.from(i.options).forEach(t=>{t.selected=s.includes(t.value)})}else i.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 Ht(t){const e=document.querySelectorAll(t||".ds-form");return e.forEach(t=>{if(t._kupolaForm)return;const e=new Lt(t);t._kupolaForm=e}),e.length}t.kupolaInitializer.register("form-validation",Ht);class Dt{constructor(e,i={}){this.element="string"==typeof e?document.querySelector(e):e,this.options=i,this.columns=(i.columns||[]).map((t,e)=>({...t,_index:e})),this.rowKey=i.rowKey||"id",this._data=[],this._loading=!1,this.striped=!1!==i.striped,this.bordered=i.bordered||!1,this.hoverable=!1!==i.hoverable,this.compact=i.compact||!1,this.emptyText=i.emptyText||"暂无数据",this.loadingText=i.loadingText||"加载中...",this.multiSort=i.multiSort||!1,this._sorts=[],this._filterText="",this._showPagination=!1!==i.pagination,this._pageSizes=i.pageSizes||[10,20,50,100],this._pageSize=i.pageSize||10,this._currentPage=1,this._total=0,this.selection=i.selection||null,this._selectedKeys=new Set,this.selectionColumnTitle=i.selectionColumnTitle||"",this.expandable=i.expandable||null,this._expandedKeys=new Set,this.expandColumnTitle=i.expandColumnTitle||"",this.editable=i.editable||!1,this._editingCell=null,this._editBuffer={},this.resizable=i.resizable||!1,this.draggable=i.draggable||!1,this._dragState=null,this.tree=i.tree||null,this._treeExpandedKeys=new Set,i.tree?.defaultExpandAll&&(this._treeExpandAll=!0),this.virtualScroll=i.virtualScroll||null,this._scrollContainer=null,this._scrollHandler=null,this._resizeCleanups=[],this._filterDebounceTimer=null,this._reactiveCleanups=[],this.mergeCells=i.mergeCells||null,this.onSort=i.onSort||null,this.onPageChange=i.onPageChange||null,this.onRowClick=i.onRowClick||null,this.onFilter=i.onFilter||null,this.onSelect=i.onSelect||null,this.onExpand=i.onExpand||null,this.onEditSave=i.onEditSave||null,this.onEditCancel=i.onEditCancel||null,this.onRowDragEnd=i.onRowDragEnd||null,this.onColumnResize=i.onColumnResize||null,this.sortKey=t.ref(null),this.sortOrder=t.ref(null),this.currentPage=t.ref(1),this.filterText=t.ref(""),this.selectedKeys=t.ref([]),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,i=null){const s=this.tree?.childrenKey||"children",n=[];for(const a of t){const t=a[this.rowKey];n.push({...a,_level:e,_parentKey:i,_hasChildren:!(!a[s]||!a[s].length)}),a[s]&&a[s].length&&n.push(...this._flattenForExpand(a[s],e+1,t))}return n}_getFlatData(t){return this.tree?this._flattenVisible(t,0):t}_flattenVisible(t,e){const i=this.tree?.childrenKey||"children",s=[];for(const n of t){const t=n[this.rowKey];s.push({...n,_level:e,_hasChildren:!(!n[i]||!n[i].length)}),n[i]&&n[i].length&&this._treeExpandedKeys.has(t)&&s.push(...this._flattenVisible(n[i],e+1))}return s}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(i=>{const s=t[i.key];return null!=s&&String(s).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 i=e;if(this._showPagination&&this._pageSize>0){const t=(this._currentPage-1)*this._pageSize;i=e.slice(t,t+this._pageSize)}return i}_filterTree(t,e){const i=this.tree?.childrenKey||"children";return t.reduce((t,s)=>{const n=s[i]?this._filterTree(s[i],e):[];return(this.columns.some(t=>{const i=s[t.key];return null!=i&&String(i).toLowerCase().includes(e)})||n.length>0)&&(t.push({...s,[i]:n}),n.length>0&&this._treeExpandedKeys.add(s[this.rowKey])),t},[])}_sortFlat(t){return[...t].sort((t,e)=>{for(const i of this._sorts){const s=this.columns.find(t=>t.key===i.key);let n=t[i.key],a=e[i.key],l=0;if(l=s?.sorter?s.sorter(n,a,i.order):null==n?1:null==a?-1:"number"==typeof n&&"number"==typeof a?"asc"===i.order?n-a:a-n:"asc"===i.order?String(n).localeCompare(String(a)):String(a).localeCompare(String(n)),0!==l)return l}return 0})}_sortTree(t){const e=this._sortFlat(t),i=this.tree?.childrenKey||"children";return e.map(t=>t[i]?.length?{...t,[i]:this._sortTree(t[i])}:t)}render(){const t=this.getProcessedData(),e=this.element;e.innerHTML="",(this.options.showFilter||this.options.showToolbar)&&e.appendChild(this._renderToolbar());const i=document.createElement("div");i.className="kupola-table-container";const s=document.createElement("table");s.className=this._getTableClass(),s.appendChild(this._renderThead()),this.virtualScroll?s.appendChild(this._renderVirtualTbody(t)):s.appendChild(this._renderTbody(t)),i.appendChild(s),e.appendChild(i),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 i=this._renderColumnHeader(t);e.appendChild(i)}),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 i=this.getProcessedData().map(t=>t[this.rowKey]);t.checked=i.length>0&&i.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 i=document.createElement("span");i.className="kupola-table-resize-handle",i.setAttribute("data-col-key",t.key),e.appendChild(i)}return e}_renderSortIndicator(t,e){t.classList.add("kupola-table-sortable");const i=this._sorts.find(t=>t.key===e.key);i&&t.classList.add(`kupola-table-sort-${i.order}`),t.addEventListener("click",t=>{this.resizable&&t.target.classList.contains("kupola-table-resize-handle")||this._handleSort(e.key)});const s=document.createElement("span");s.className="kupola-table-sort-icon",s.textContent=i?this.multiSort?` ${this._sorts.indexOf(i)+1}${"asc"===i.order?"▲":"▼"}`:"asc"===i.order?" ▲":" ▼":" ⇅",t.appendChild(s)}_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 i=this.mergeCells?this.mergeCells(t):[],s=new Map;i.forEach(t=>s.set(`${t.row}-${t.col}`,t));const n=new Set;t.forEach((t,i)=>{const a=t[this.rowKey]??i,l=this._selectedKeys.has(a),r=this._expandedKeys.has(a),o=this._renderDataRow(t,i,a,l,n,s);if(e.appendChild(o),this.expandable&&r){const i=document.createElement("tr");i.className="kupola-table-expand-row";const s=document.createElement("td"),n=this.columns.length+(this.selection?1:0)+1;s.colSpan=n,s.className="kupola-table-expand-content";const a=this.expandable(t);"string"==typeof a?s.innerHTML=a:a instanceof HTMLElement&&s.appendChild(a),i.appendChild(s),e.appendChild(i)}})}return e}_renderDataRow(t,e,i,s,n,a){const l=document.createElement("tr");return l.setAttribute("data-row-key",i),s&&l.classList.add("kupola-table-row-selected"),this.draggable&&(l.draggable=!0,l.classList.add("kupola-table-draggable")),this.selection&&this._renderSelectionCell(l,i,s),this.expandable&&this._renderExpandCell(l,i),this.columns.forEach((s,r)=>{if(n.has(`${e}-${r}`))return;const o=this._renderDataCell(t,e,i,s,r,n,a);l.appendChild(o)}),this.onRowClick&&(l.style.cursor="pointer",l.addEventListener("click",i=>{i.target.closest(".kupola-table-expand-btn, .kupola-table-tree-toggle, input, button")||this.onRowClick(t,e,i)})),l}_renderSelectionCell(t,e,i){const s=document.createElement("td");s.className="kupola-table-col-selection";const n=document.createElement("input");n.type=this.selection,n.checked=i,n.addEventListener("change",()=>{"radio"===this.selection?(this._selectedKeys.clear(),this._selectedKeys.add(e)):i?this._selectedKeys.delete(e):this._selectedKeys.add(e),this.selectedKeys.value=[...this._selectedKeys],this.onSelect&&this.onSelect([...this._selectedKeys],this.getSelectedRows()),this.render()}),s.appendChild(n),t.appendChild(s)}_renderExpandCell(t,e){const i=document.createElement("td");i.className="kupola-table-col-expand";const s=document.createElement("button");s.className="kupola-table-expand-btn",s.textContent=this._expandedKeys.has(e)?"▼":"▶",s.type="button",s.addEventListener("click",()=>this._toggleExpand(e)),i.appendChild(s),t.appendChild(i)}_renderDataCell(t,e,i,s,n,a,l){const r=document.createElement("td");s.align&&(r.style.textAlign=s.align),s.fixed&&(r.setAttribute("data-fixed",s.fixed),r.classList.add(`kupola-table-fixed-${s.fixed}`));const o=l.get(`${e}-${n}`);if(o){o.rowSpan>1&&(r.rowSpan=o.rowSpan),o.colSpan>1&&(r.colSpan=o.colSpan);for(let t=0;t<(o.rowSpan||1);t++)for(let i=0;i<(o.colSpan||1);i++)0===t&&0===i||a.add(`${e+t}-${n+i}`)}this.tree&&0===n&&t._level>0&&this._renderTreeIndent(r,t);const h=this._editingCell&&this._editingCell.rowKey===i&&this._editingCell.colKey===s.key;if(h)r.appendChild(this._renderEditCell(s,t));else if(s.render){const i=s.render(t[s.key],t,e);"string"==typeof i?r.innerHTML=i:i instanceof HTMLElement&&r.appendChild(i)}else r.textContent=t[s.key]??"";return this.editable&&!h&&!1!==s.editable&&(r.classList.add("kupola-table-editable-cell"),r.addEventListener("dblclick",()=>this._startEdit(i,s.key,t[s.key]))),r}_renderTreeIndent(t,e){const i=document.createElement("span");if(i.className="kupola-table-tree-indent",i.style.paddingLeft=20*e._level+"px",t.appendChild(i),e._hasChildren){const i=document.createElement("button");i.className="kupola-table-tree-toggle",i.textContent=this._treeExpandedKeys.has(e[this.rowKey])?"▼":"▶",i.type="button",i.addEventListener("click",t=>{t.stopPropagation(),this._toggleTreeExpand(e[this.rowKey])}),t.appendChild(i)}else{const e=document.createElement("span");e.className="kupola-table-tree-toggle-placeholder",t.appendChild(e)}}_renderStatusRow(t,e){const i=document.createElement("tr"),s=document.createElement("td");return s.colSpan=this.columns.length+(this.selection?1:0)+(this.expandable?1:0),s.className=e,s.textContent=t,i.appendChild(s),i}_renderVirtualTbody(t){const e=document.createElement("tbody"),{rowHeight:i=40,overscan:s=5}=this.virtualScroll,n=t.length*i;if(this._loading)return this._renderTbody(t);if(0===t.length)return this._renderTbody(t);const a=document.createElement("tr");a.className="kupola-table-virtual-spacer-top",a.style.height="0px",e.appendChild(a),this._virtualData={data:t,rowHeight:i,overscan:s,totalHeight:n,tbody:e,topSpacer:a},this._updateVirtualScroll();const l=document.createElement("tr");l.className="kupola-table-virtual-spacer-bottom",l.style.height="0px",e.appendChild(l);const r=this.element.querySelector(".kupola-table-container");return r&&(r.style.maxHeight=this.virtualScroll.maxHeight||"400px",r.style.overflowY="auto",this._scrollHandler&&r.removeEventListener("scroll",this._scrollHandler),this._scrollHandler=()=>this._updateVirtualScroll(),r.addEventListener("scroll",this._scrollHandler)),e}_updateVirtualScroll(){if(!this._virtualData)return;const{data:t,rowHeight:e,overscan:i,tbody:s,topSpacer:n}=this._virtualData,a=this.element.querySelector(".kupola-table-container");if(!a)return;const l=a.scrollTop,r=a.clientHeight,o=Math.max(0,Math.floor(l/e)-i),h=Math.min(t.length,Math.ceil((l+r)/e)+i);s.querySelectorAll(".kupola-table-virtual-row").forEach(t=>t.remove());const d=document.createDocumentFragment();for(let u=o;u<h;u++){const i=t[u],s=i[this.rowKey]??u,n=this._renderDataRow(i,u,s,this._selectedKeys.has(s),new Set,new Map);n.classList.add("kupola-table-virtual-row"),n.style.height=e+"px",d.appendChild(n)}n.style.height=o*e+"px";const c=s.querySelector(".kupola-table-virtual-spacer-bottom");c&&(c.style.height=(t.length-h)*e+"px"),n.after(d)}_renderEditCell(t,e){const i=document.createElement("div");i.className="kupola-table-edit-cell";const s=document.createElement("input");if(s.type=t.editType||"text",s.className="ds-input kupola-table-edit-input",s.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 i=document.createElement("option");i.value="object"==typeof t?t.value:t,i.textContent="object"==typeof t?t.label:t,String(i.value)===String(s.value)&&(i.selected=!0),e.appendChild(i)}),e.addEventListener("change",()=>{this._editBuffer[t.key]=e.value}),i.appendChild(e)}else s.addEventListener("input",()=>{this._editBuffer[t.key]=s.value}),i.appendChild(s);const n=document.createElement("div");n.className="kupola-table-edit-actions";const a=document.createElement("button");a.className="kupola-table-edit-save",a.textContent="✓",a.type="button",a.addEventListener("click",()=>this._saveEdit(e,t));const l=document.createElement("button");return l.className="kupola-table-edit-cancel",l.textContent="✗",l.type="button",l.addEventListener("click",()=>this._cancelEdit()),n.appendChild(a),n.appendChild(l),i.appendChild(n),s.addEventListener("keydown",i=>{"Enter"===i.key&&this._saveEdit(e,t),"Escape"===i.key&&this._cancelEdit()}),setTimeout(()=>s.focus?.(),0),i}_startEdit(t,e,i){this._editingCell={rowKey:t,colKey:e},this._editBuffer={[e]:i},this.render()}_saveEdit(t,e){const i=this._editBuffer[e.key];this.onEditSave?this.onEditSave(t,e.key,i,this._data):t[e.key]=i,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 i=t.getAttribute("data-col-key"),s=t.parentElement,n=e.clientX,a=s.offsetWidth,l=t=>{const e=Math.max(50,a+(t.clientX-n));s.style.width=e+"px";const l=this.columns.find(t=>t.key===i);l&&(l.width=e),this.onColumnResize&&this.onColumnResize(i,e)},r=()=>{document.removeEventListener("mousemove",l),document.removeEventListener("mouseup",r)};document.addEventListener("mousemove",l),document.addEventListener("mouseup",r),this._resizeCleanups.push(r)})})}_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 i=e.getAttribute("data-row-key");if(this._dragState.fromKey===i)return;const s=this._data.findIndex(t=>String(t[this.rowKey])===this._dragState.fromKey),n=this._data.findIndex(t=>String(t[this.rowKey])===i);if(s>=0&&n>=0){const[t]=this._data.splice(s,1);this._data.splice(n,0,t),this.onRowDragEnd&&this.onRowDragEnd(t,s,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"]'),i=this.element.querySelectorAll('td[data-fixed="left"]'),s=this.columns.indexOf(t);let n=(this.selection?40:0)+(this.expandable?40:0);for(let a=0;a<s;a++)"left"===this.columns[a].fixed&&(n+=this.columns[a]._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)}),i.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 i=document.createElement("button");i.className="ds-btn ds-btn--sm",i.textContent="反选",i.type="button",i.addEventListener("click",()=>this.invertSelection()),e.appendChild(i)}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 i=document.createElement("span");return i.className="kupola-table-info",i.textContent=`共 ${this._total} 条`,e.appendChild(i),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 i=document.createElement("option");i.value=e,i.textContent=`${e} 条/页`,e===this._pageSize&&(i.selected=!0),t.appendChild(i)}),t.addEventListener("change",()=>{this._pageSize=parseInt(t.value),this._currentPage=1,this.currentPage.value=1,this.render()}),e.appendChild(t)}const i=document.createElement("div");i.className="kupola-table-pages";const s=this._createPageBtn("‹",()=>this._goToPage(this._currentPage-1));s.disabled=this._currentPage<=1,i.appendChild(s),this._getPageRange(this._currentPage,t).forEach(t=>{if("..."===t){const t=document.createElement("span");t.className="kupola-table-page-ellipsis",t.textContent="...",i.appendChild(t)}else{const e=this._createPageBtn(t,()=>this._goToPage(t));t===this._currentPage&&e.classList.add("active"),i.appendChild(e)}});const n=this._createPageBtn("›",()=>this._goToPage(this._currentPage+1));n.disabled=this._currentPage>=t,i.appendChild(n),e.appendChild(i);const a=document.createElement("span");return a.className="kupola-table-page-info",a.textContent=`${this._currentPage} / ${t}`,e.appendChild(a),e}_createPageBtn(t,e){const i=document.createElement("button");return i.className="kupola-table-page-btn",i.textContent=t,i.type="button",i.addEventListener("click",e),i}_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 i=[];if(t<=3){for(let t=1;t<=5;t++)i.push(t);i.push("...",e)}else if(t>=e-2){i.push(1,"...");for(let t=e-4;t<=e;t++)i.push(t)}else{i.push(1,"...");for(let e=t-1;e<=t+1;e++)i.push(e);i.push("...",e)}return i}exportCSV(t="export.csv"){const e=this.getProcessedData(),i=this.columns.map(t=>t.title||t.key),s=e.map(t=>this.columns.map(e=>{let i=t[e.key];return null==i&&(i=""),i=String(i).replace(/"/g,'""'),`"${i}"`}).join(",")),n="\ufeff"+[i.join(","),...s].join("\n"),a=new Blob([n],{type:"text/csv;charset=utf-8;"}),l=URL.createObjectURL(a),r=document.createElement("a");r.href=l,r.download=t,r.click(),URL.revokeObjectURL(l)}_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 Mt(t,e){return new Dt(t,e)}t.kupolaInitializer.register("table",Mt);class It{constructor(e,i={}){this.element="string"==typeof e?document.querySelector(e):e,this.options=i,this._current=i.current||1,this._total=i.total||0,this._pageSize=i.pageSize||10,this._maxPages=i.maxPages||7,this._showTotal=!1!==i.showTotal,this._showSizeChanger=i.showSizeChanger||!1,this._pageSizes=i.pageSizes||[10,20,50,100],this._simple=i.simple||!1,this.current=t.ref(this._current),this.total=t.ref(this._total),this.onChange=i.onChange||null,this.onPageSizeChange=i.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,i=this._btn("‹",()=>this.setCurrent(this._current-1));i.disabled=this._current<=1,t.appendChild(i);const s=document.createElement("span");s.className="kupola-pagination-simple-info",s.textContent=`${this._current} / ${e}`,t.appendChild(s);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 i=document.createElement("option");i.value=t,i.textContent=`${t} 条/页`,t===this._pageSize&&(i.selected=!0),e.appendChild(i)}),e.addEventListener("change",()=>this.setPageSize(parseInt(e.value))),t.appendChild(e)}const i=document.createElement("div");i.className="kupola-pagination-pages";const s=this._btn("‹",()=>this.setCurrent(this._current-1));s.disabled=this._current<=1,i.appendChild(s),this._getPageRange().forEach(t=>{if("..."===t){const t=document.createElement("span");t.className="kupola-pagination-ellipsis",t.textContent="···",i.appendChild(t)}else{const e=this._btn(t,()=>this.setCurrent(t));t===this._current&&e.classList.add("active"),i.appendChild(e)}});const n=this._btn("›",()=>this.setCurrent(this._current+1));if(n.disabled=this._current>=e,i.appendChild(n),t.appendChild(i),e>10){const i=document.createElement("span");i.className="kupola-pagination-jumper",i.innerHTML='跳至 <input type="number" min="1" max="'+e+'" value="'+this._current+'"> 页';const s=i.querySelector("input");s.addEventListener("change",()=>{const t=parseInt(s.value);t>=1&&t<=e&&this.setCurrent(t)}),s.addEventListener("keydown",t=>{if("Enter"===t.key){const t=parseInt(s.value);t>=1&&t<=e&&this.setCurrent(t)}}),t.appendChild(i)}}_btn(t,e){const i=document.createElement("button");return i.className="kupola-pagination-btn",i.textContent=t,i.type="button",i.addEventListener("click",e),i}_getPageRange(){const t=this.totalPages,e=this._maxPages;if(t<=e)return Array.from({length:t},(t,e)=>e+1);const i=[],s=Math.floor(e/2);if(this._current<=s+1){for(let t=1;t<=e-2;t++)i.push(t);i.push("...",t)}else if(this._current>=t-s){i.push(1,"...");for(let s=t-e+3;s<=t;s++)i.push(s)}else{i.push(1,"...");for(let t=this._current-s+2;t<=this._current+s-2;t++)i.push(t);i.push("...",t)}return i}destroy(){this.element.innerHTML="",this.element.classList.remove("kupola-pagination")}}let Tt=!1;let At=!1;class zt extends HTMLElement{static get observedAttributes(){return["open"]}connectedCallback(){this._render()}_render(){const t=this.querySelector('[slot="trigger"]'),e=this.querySelectorAll('[slot="item"]'),i=document.createElement("div");i.className="ds-dropdown",i.setAttribute("data-dropdown",""),t&&(t.setAttribute("class",(t.getAttribute("class")||"")+" ds-dropdown__trigger"),i.appendChild(t));const s=document.createElement("div");s.className="ds-dropdown__menu",e.forEach(t=>{t.className="ds-dropdown__item",s.appendChild(t)}),i.appendChild(s),this.innerHTML="",this.appendChild(i)}attributeChangedCallback(t,e,i){if("open"===t){const t=this.querySelector(".ds-dropdown__menu");t&&(t.style.display=null!==i?"block":"")}}}class qt 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,i){if("title"===t){const t=this.firstElementChild;t&&t.setAttribute("data-title",i||"")}}}class Bt 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 i=e.getAttribute("title")||"",s=e.innerHTML,n=document.createElement("div");n.className="ds-collapse__item",n.innerHTML=`\n <button class="ds-collapse__header">\n <span>${i}</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">${s}</div></div>\n `,t.appendChild(n)}),this.innerHTML="",this.appendChild(t)}}class Pt extends HTMLElement{static get observedAttributes(){return["title"]}}class $t 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,i){if("open"===t){const t=this.querySelector(".ds-drawer");t&&t.classList.toggle("is-open",null!==i)}}}class Ft 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 i=e.querySelector(".ds-dialog__body"),s=this.querySelector('[slot="body"]');s&&i.appendChild(s);const n=e.querySelector(".ds-dialog__foot"),a=this.querySelector('[slot="footer"]');a&&n.appendChild(a);const l=e.querySelector(".ds-dialog__close");l&&l.addEventListener("click",()=>this.close()),e.addEventListener("click",t=>{t.target===e&&this.close()}),this.innerHTML="",this.appendChild(e)}attributeChangedCallback(t,e,i){if("open"===t){const t=this.querySelector(".ds-backdrop");t&&(t.style.display=null!==i?"flex":"none")}}open(){this.setAttribute("open","")}close(){this.removeAttribute("open")}}exports.BRAND_OPTIONS=t.BRAND_OPTIONS,exports.CacheEntry=t.CacheEntry,exports.CacheManager=t.CacheManager,exports.ComponentInitializerRegistry=t.ComponentInitializerRegistry,exports.DependsError=t.DependsError,exports.DependsSource=t.DependsSource,exports.FetchedSource=t.FetchedSource,exports.FunctionSource=t.FunctionSource,exports.GlobalEvents=t.GlobalEvents,exports.KupolaComponent=t.KupolaComponent,exports.KupolaComponentRegistry=t.KupolaComponentRegistry,exports.KupolaDataBind=t.KupolaDataBind,exports.KupolaEventBus=t.KupolaEventBus,exports.KupolaI18n=t.KupolaI18n,exports.KupolaLifecycle=t.KupolaLifecycle,exports.KupolaStore=t.KupolaStore,exports.KupolaStoreManager=t.KupolaStoreManager,exports.KupolaUtils=t.KupolaUtils,exports.RouteSource=t.RouteSource,exports.Scheduler=t.Scheduler,exports.StaticSource=t.StaticSource,exports.StorageSource=t.StorageSource,exports.WebSocketSource=t.WebSocketSource,exports.applyMixin=t.applyMixin,exports.arrayUtils=t.arrayUtils,exports.bootstrapComponents=t.bootstrapComponents,exports.clearCache=t.clearCache,exports.configureHttpClient=t.configureHttpClient,exports.createBrandPicker=t.createBrandPicker,exports.createI18n=t.createI18n,exports.createLifecycle=t.createLifecycle,exports.createSource=t.createSource,exports.createStore=t.createStore,exports.createThemeToggle=t.createThemeToggle,exports.cryptoUtils=t.cryptoUtils,exports.dateUtils=t.dateUtils,exports.debounce=t.debounce,exports.defineComponent=t.defineComponent,exports.defineMixin=t.defineMixin,exports.emit=t.emit,exports.emitGlobal=t.emitGlobal,exports.escapeHtml=t.escapeHtml,exports.formatCurrency=t.formatCurrency,exports.formatDate=t.formatDate,exports.formatNumber=t.formatNumber,exports.generateSecureId=t.generateSecureId,exports.getBasePath=t.getBasePath,exports.getBrand=t.getBrand,exports.getConfig=t.getConfig,exports.getDefaultBrand=t.getDefaultBrand,exports.getDefaultTheme=t.getDefaultTheme,exports.getHttpClient=t.getHttpClient,exports.getHttpConfig=t.getHttpConfig,exports.getIconsPath=t.getIconsPath,exports.getListenerCount=t.getListenerCount,exports.getLocale=t.getLocale,exports.getMessageConfig=t.getMessageConfig,exports.getNotificationConfig=t.getNotificationConfig,exports.getPerformanceConfig=t.getPerformanceConfig,exports.getSecurityConfig=t.getSecurityConfig,exports.getStore=t.getStore,exports.getTheme=t.getTheme,exports.getUiConfig=t.getUiConfig,exports.getValidationConfig=t.getValidationConfig,exports.globalEvents=t.globalEvents,exports.initTheme=t.initTheme,exports.kupolaBootstrap=t.kupolaBootstrap,exports.kupolaData=t.kupolaData,exports.kupolaEvents=t.kupolaEvents,exports.kupolaI18n=t.kupolaI18n,exports.kupolaInitializer=t.kupolaInitializer,exports.kupolaLifecycle=t.kupolaLifecycle,Object.defineProperty(exports,"kupolaRegistry",{enumerable:!0,get:()=>t.kupolaRegistry}),exports.kupolaStoreManager=t.kupolaStoreManager,exports.maskData=t.maskData,exports.n=t.n,exports.numberUtils=t.numberUtils,exports.objectUtils=t.objectUtils,exports.off=t.off,exports.offAll=t.offAll,exports.offByScope=t.offByScope,exports.offConfigChange=t.offConfigChange,exports.on=t.on,exports.onConfigChange=t.onConfigChange,exports.once=t.once,exports.preloadUtils=t.preloadUtils,exports.ref=t.ref,exports.registerComponent=t.registerComponent,exports.registerLazyComponent=t.registerLazyComponent,exports.resetHttpClient=t.resetHttpClient,exports.sanitizeHtml=t.sanitizeHtml,exports.setBrand=t.setBrand,exports.setConfig=t.setConfig,exports.setLocale=t.setLocale,exports.setTheme=t.setTheme,exports.stringUtils=t.stringUtils,exports.stripHtml=t.stripHtml,exports.t=t.t,exports.throttle=t.throttle,exports.useDeps=t.useDeps,exports.useMixin=t.useMixin,exports.useQuery=t.useQuery,exports.validatorUtils=t.validatorUtils,exports.Calendar=$,exports.Carousel=_,exports.Collapse=T,exports.ColorPicker=q,exports.Countdown=vt,exports.Datepicker=r,exports.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:i="",content:s="",onConfirm:n,onCancel:a}=t,l={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>'},r=document.createElement("div");r.className="ds-modal-container",r.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}">${l[e]}</div>\n ${i?'<div class="ds-dialog__title"></div>':""}\n <div class="ds-dialog__content"></div>\n <div class="ds-dialog__actions">\n ${"confirm"===e||a?'<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(r),i&&(r.querySelector(".ds-dialog__title").textContent=i),r.querySelector(".ds-dialog__content").textContent=s;const o=r.querySelector(".ds-modal-mask"),h=r.querySelector("[data-dialog-confirm]"),d=r.querySelector("[data-dialog-cancel]"),c=function(t){"Escape"===t.key&&(a&&a(),g())},u=function(t){t.target===o&&(a&&a(),g())},p=function(){n&&n(),g()},m=function(){a&&a(),g()},g=()=>{o.classList.remove("is-visible"),document.body.style.overflow="",document.removeEventListener("keydown",c),o.removeEventListener("click",u),h&&h.removeEventListener("click",p),d&&d.removeEventListener("click",m),setTimeout(()=>r.remove(),300)};return o.classList.add("is-visible"),document.body.style.overflow="hidden",h&&h.addEventListener("click",p),d&&d.addEventListener("click",m),o.addEventListener("click",u),document.addEventListener("keydown",c),{close:g}}},exports.Drawer=f,exports.Dropdown=e,exports.DynamicTags=O,exports.FileUpload=D,exports.Heatmap=J,exports.Icons=_t,exports.ImagePreview=K,exports.KupolaForm=Lt,exports.KupolaPagination=It,exports.KupolaTable=Dt,exports.KupolaValidator=at,exports.Message=L,exports.Modal=x,exports.Notification=S,exports.NumberInput=bt,exports.PATHS=ut,exports.Select=n,exports.SlideCaptcha=Et,exports.Slider=p,exports.StatCard=Z,exports.Tag=Y,exports.Timepicker=d,exports.Tooltip=it,exports.VirtualList=rt,exports.alertModal=function(t){return"string"==typeof t&&(t={content:t}),E({...t,showCancel:!1,showConfirm:!0})},exports.cleanupAllDropdowns=function(){document.querySelectorAll(".ds-dropdown").forEach(t=>{s(t)})},exports.cleanupAllSlideCaptchas=St,exports.cleanupCalendar=N,exports.cleanupCarousel=y,exports.cleanupCollapse=z,exports.cleanupColorPicker=P,exports.cleanupCountdown=ft,exports.cleanupDatepicker=h,exports.cleanupDrawer=k,exports.cleanupDropdown=s,exports.cleanupDynamicTags=R,exports.cleanupFileUpload=I,exports.cleanupHeatmap=tt,exports.cleanupModal=w,exports.cleanupNumberInput=xt,exports.cleanupSelect=l,exports.cleanupSlideCaptcha=wt,exports.cleanupSlider=g,exports.cleanupStatCard=G,exports.cleanupTag=X,exports.cleanupTimepicker=u,exports.cleanupTooltip=nt,exports.cleanupVirtualList=dt,exports.confirmModal=function(t){return"string"==typeof t&&(t={content:t}),E({...t,showCancel:!0,showConfirm:!0})},exports.createModal=E,exports.getFormInstance=function(t){return t._kupolaForm},exports.initAllTables=function(){document.querySelectorAll("[data-kupola-table]").forEach(t=>{const e=t.getAttribute("data-kupola-table");let i={};if(e)try{i=JSON.parse(e)}catch(s){}Mt(t,i)})},exports.initCalendar=F,exports.initCalendars=function(){document.querySelectorAll(".ds-calendar").forEach(t=>{F(t)})},exports.initCarousel=v,exports.initCarousels=function(t=document){t.querySelectorAll(".ds-carousel").forEach(t=>{v(t)})},exports.initCollapse=A,exports.initCollapses=function(){document.querySelectorAll(".ds-collapse").forEach(t=>{A(t)})},exports.initColorPicker=B,exports.initColorPickers=function(t=document){t.querySelectorAll(".ds-color-picker").forEach(t=>{B(t)})},exports.initCountdown=yt,exports.initCountdowns=function(){document.querySelectorAll(".ds-countdown").forEach(t=>{yt(t)})},exports.initDatepicker=o,exports.initDatepickers=function(t=document){t.querySelectorAll(".ds-datepicker").forEach(t=>{o(t)})},exports.initDrawer=b,exports.initDrawers=function(){document.querySelectorAll("[data-drawer]").forEach(t=>{t.addEventListener("click",()=>{const e=t.getAttribute("data-drawer"),i=document.getElementById(e);i&&(b(i,{placement:t.getAttribute("data-drawer-placement")||"right",width:t.getAttribute("data-drawer-width"),height:t.getAttribute("data-drawer-height")}),i.__kupolaInstance?.open())})}),document.querySelectorAll(".ds-drawer-mask").forEach(t=>{const e=t.parentElement;e&&b(e)})},exports.initDropdown=i,exports.initDropdowns=function(t=document){t.querySelectorAll(".ds-dropdown").forEach(t=>{i(t)})},exports.initDynamicTags=V,exports.initDynamicTagsAll=function(){document.querySelectorAll(".ds-dynamic-tags").forEach(t=>{V(t)})},exports.initFileUpload=M,exports.initFileUploads=function(){document.querySelectorAll(".ds-fileupload").forEach(t=>{M(t)})},exports.initFormValidation=Ht,exports.initHeatmap=Q,exports.initHeatmaps=function(){document.querySelectorAll(".ds-heatmap").forEach(t=>{Q(t)})},exports.initImagePreview=function(){W||(W=new K),document.querySelectorAll("[data-image-preview]").forEach(t=>{t.addEventListener("click",()=>{const e=JSON.parse(t.getAttribute("data-image-preview")),i=parseInt(t.getAttribute("data-image-index"))||0;W.show(e,i)})})},exports.initMessages=function(){},exports.initModal=C,exports.initModals=function(){document.querySelectorAll(".ds-modal-container").forEach(t=>{C(t)})},exports.initNotifications=function(){},exports.initNumberInput=kt,exports.initNumberInputs=function(){document.querySelectorAll(".ds-number-input").forEach(t=>{kt(t)})},exports.initPagination=function(t,e){return function(){if(Tt||"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),Tt=!0}(),new It(t,e)},exports.initSelect=a,exports.initSelects=function(t=document){t.querySelectorAll(".ds-select").forEach(t=>{a(t)})},exports.initSlideCaptchas=Ct,exports.initSlider=m,exports.initSliders=function(){document.querySelectorAll(".ds-slider").forEach(t=>{m(t)})},exports.initStatCard=j,exports.initStatCards=function(){document.querySelectorAll(".ds-statcard").forEach(t=>{j(t)})},exports.initTable=Mt,exports.initTag=U,exports.initTags=function(){document.querySelectorAll(".ds-tag").forEach(t=>{U(t)})},exports.initTimepicker=c,exports.initTimepickers=function(t=document){t.querySelectorAll(".ds-timepicker").forEach(t=>{c(t)})},exports.initTooltip=st,exports.initTooltips=function(t=document){t.querySelectorAll("[data-tooltip]").forEach(t=>{st(t)})},exports.initVirtualList=ht,exports.registerWebComponents=function(){if(At||"undefined"==typeof customElements)return;At=!0;const t=[["k-dropdown",zt],["k-tooltip",qt],["k-collapse",Bt],["k-collapse-item",Pt],["k-drawer",$t],["k-modal",Ft]];for(const[e,i]of t)customElements.get(e)||customElements.define(e,i)},exports.renderIcon=gt,exports.showImagePreview=function(t,e=0){W||(W=new K),W.show(t,e)},exports.svg=mt,exports.validateForm=function(t){const e=t._kupolaForm;return!!e&&e.validate()},exports.validator=lt;
|