monobill-mintui 0.3.17 → 0.3.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +8 -8
- package/dist/index.js +681 -681
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const ct=require("./caret-right-BsS-59-c.cjs");class F extends HTMLElement{constructor(){super(),this._darkModeObserver=null}static get observedAttributes(){return["size","data-button-variant","data-button-tone"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline","inline-block"),this.render(),this._observeDarkMode()}attributeChangedCallback(t,e,i){e!==i&&this.render()}disconnectedCallback(){this._darkModeObserver&&(this._darkModeObserver.disconnect(),this._darkModeObserver=null)}_observeDarkMode(){this._darkModeObserver||(this._darkModeObserver=new MutationObserver(()=>{this.render()}),this._darkModeObserver.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}))}getSize(){const t=this.getAttribute("size")||"default",e={default:"w-4 h-4",large:"w-16 h-16"};return e[t]||e.default}render(){const t=this.getSize(),e=this.getAttribute("size")||"default",i=!!(this.style.width&&this.style.height),s=this.getAttribute("data-button-variant"),n=document.documentElement.classList.contains("dark");let r;if(i){const c=this.getAttribute("data-button-tone")||"neutral";s==="solid"?c==="neutral"?r=n?"#ffffff":"#0f172a":r="#ffffff":r=n?"#ffffff":"#0f172a"}else r=n?"#e2e8f0":"#0f172a";const a=e==="large"?"2":"4",
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const ct=require("./caret-right-BsS-59-c.cjs");class F extends HTMLElement{constructor(){super(),this._darkModeObserver=null}static get observedAttributes(){return["size","data-button-variant","data-button-tone"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline","inline-block"),this.render(),this._observeDarkMode()}attributeChangedCallback(t,e,i){e!==i&&this.render()}disconnectedCallback(){this._darkModeObserver&&(this._darkModeObserver.disconnect(),this._darkModeObserver=null)}_observeDarkMode(){this._darkModeObserver||(this._darkModeObserver=new MutationObserver(()=>{this.render()}),this._darkModeObserver.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}))}getSize(){const t=this.getAttribute("size")||"default",e={default:"w-4 h-4",large:"w-16 h-16"};return e[t]||e.default}render(){const t=this.getSize(),e=this.getAttribute("size")||"default",i=!!(this.style.width&&this.style.height),s=this.getAttribute("data-button-variant"),n=document.documentElement.classList.contains("dark");let r;if(i){const c=this.getAttribute("data-button-tone")||"neutral";s==="solid"?c==="neutral"?r=n?"#ffffff":"#0f172a":r="#ffffff":r=n?"#ffffff":"#0f172a"}else r=n?"#e2e8f0":"#0f172a";const a=e==="large"?"2":"4",l=!!(this.style.width&&this.style.height),o=`
|
|
2
2
|
<svg
|
|
3
3
|
xmlns="http://www.w3.org/2000/svg"
|
|
4
4
|
fill="none"
|
|
5
5
|
viewBox="0 0 24 24"
|
|
6
|
-
class="animate-spin ${
|
|
7
|
-
style="${
|
|
6
|
+
class="animate-spin ${l?"":t}"
|
|
7
|
+
style="${l?`width: ${this.style.width}; height: ${this.style.height}; animation-duration: 0.8s;`:"animation-duration: 0.8s;"}"
|
|
8
8
|
>
|
|
9
9
|
<circle
|
|
10
10
|
cx="12"
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
></animate>
|
|
42
42
|
</circle>
|
|
43
43
|
</svg>
|
|
44
|
-
`;this.innerHTML=
|
|
44
|
+
`;this.innerHTML=o.trim()}}customElements.get("mint-spinner")||customElements.define("mint-spinner",F);class q extends HTMLElement{constructor(){super(),this._darkModeObserver=null}static get observedAttributes(){return["name"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","inline-flex","items-center","leading-none"),this.render(),this._observeDarkMode()}attributeChangedCallback(t,e,i){e!==i&&this.render()}disconnectedCallback(){this._darkModeObserver&&(this._darkModeObserver.disconnect(),this._darkModeObserver=null)}_observeDarkMode(){this._darkModeObserver||(this._darkModeObserver=new MutationObserver(t=>{for(const e of t)if(e.type==="attributes"&&e.attributeName==="class"){this.render();break}}),this._darkModeObserver.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}))}getName(){return this.getAttribute("name")||""}generateSVGMarkup(t){let e;return t.fill&&t.strokeWidth?e=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="${t.viewBox}" fill="none" stroke="currentColor" stroke-width="${t.strokeWidth}" stroke-linecap="${t.strokeLinecap||"round"}" stroke-linejoin="${t.strokeLinejoin||"round"}">
|
|
45
45
|
<path d="${t.path}" />
|
|
46
46
|
</svg>`:t.fill?t.viewBox==="0 0 512 512"?e=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor">
|
|
47
47
|
<g transform="scale(0.046875)">
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
<path d="${t.path}" />
|
|
52
52
|
</svg>`:e=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="${t.viewBox}" fill="none" stroke="currentColor" stroke-width="${t.strokeWidth||"2"}" stroke-linecap="${t.strokeLinecap||"round"}" stroke-linejoin="${t.strokeLinejoin||"round"}">
|
|
53
53
|
<path d="${t.path}" />
|
|
54
|
-
</svg>`,e}render(){var l,c,h;const t=this.getName();if(!t){this.innerHTML="",this.style.maskImage="",this.style.webkitMaskImage="",this.style.backgroundColor="";return}const e=ct.getIcon(t);if(!e){console.warn(`Icon "${t}" not found. Make sure you've imported the icon: import '@monobill-mintui/icon/icons/${t}'`),this.innerHTML="",this.style.maskImage="",this.style.webkitMaskImage="",this.style.backgroundColor="";return}const i=this.closest("mint-button")||((l=this.parentElement)==null?void 0:l.closest("mint-button")),s=this.closest("mint-switch")||((c=this.parentElement)==null?void 0:c.closest("mint-switch")),n=this.closest("mint-select")||((h=this.parentElement)==null?void 0:h.closest("mint-select"));if(!Array.from(this.classList).some(p=>p.startsWith("w-")||p.startsWith("h-"))&&!n){let p;s?p="w-3 h-3":i?p="w-5 h-5":p="w-[1.3em] h-[1.3em]",this.classList.remove("w-4","h-4","w-5","h-5","w-[1em]","h-[1em]","w-[1.3em]","h-[1.3em]","w-3","h-3"),p.split(" ").forEach(d=>{d&&this.classList.add(d)})}const a=this.generateSVGMarkup(e);this.innerHTML=a,this.style.maskImage="",this.style.webkitMaskImage="",this.style.maskSize="",this.style.webkitMaskSize="",this.style.maskRepeat="",this.style.webkitMaskRepeat="",this.style.maskPosition="",this.style.webkitMaskPosition="",this.style.backgroundColor="",this.style.aspectRatio="1 / 1";const o=this.querySelector("svg");if(o&&(o.style.width="100%",o.style.height="100%"),s)this.classList.remove("text-gray-100","text-gray-900"),this.classList.add("text-gray-900");else if(i)this.classList.remove("text-gray-100","text-gray-900");else{const d=document.documentElement.classList.contains("dark")?"text-gray-100":"text-gray-900";this.classList.remove("text-gray-100","text-gray-900"),this.classList.add(d)}}}customElements.get("mint-icon")||customElements.define("mint-icon",q);class P extends HTMLElement{constructor(){super(),this._button=null,this._clickHandler=null,this._isHandlingClick=!1,this._handleMouseDown=()=>{this._button&&!this.isDisabled()&&!this.isLoading()&&this._button.classList.add("mint-button-active")},this._handleMouseUp=()=>{this._button&&this._button.classList.remove("mint-button-active")},this._handleMouseLeave=()=>{this._button&&this._button.classList.remove("mint-button-active")},this._handleTouchStart=()=>{this._button&&!this.isDisabled()&&!this.isLoading()&&this._button.classList.add("mint-button-active")},this._handleTouchEnd=()=>{this._button&&this._button.classList.remove("mint-button-active")},this._handleTouchCancel=()=>{this._button&&this._button.classList.remove("mint-button-active")}}static get observedAttributes(){return["variant","tone","disabled","loading","button-type","type","full-width","icon-position","icon","active"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline","inline-block"),this.render(),this._button&&this.setupEventListeners(),this.isFullWidth()&&this.classList.add("w-full")}disconnectedCallback(){this.removeEventListeners()}attributeChangedCallback(t,e,i){e!==i&&this.render()}getVariant(){return this.getAttribute("variant")||"solid"}getTone(){return this.getAttribute("tone")||"neutral"}isDisabled(){return this.getAttribute("disabled")==="true"}isLoading(){return this.getAttribute("loading")==="true"}getType(){const t=this.getAttribute("type"),e=this.getAttribute("button-type");return(t||e||"default")==="submit"?"submit":"button"}isFullWidth(){return this.hasAttribute("full-width")}isActive(){const t=this.getAttribute("active");return!(t===null||t==="false"||t==="0")}get active(){return this.isActive()}set active(t){t?this.setAttribute("active","true"):this.removeAttribute("active")}getIconPosition(){return this.getAttribute("icon-position")||"left"}getIcon(){return this.getAttribute("icon")||""}isIconOnly(){var i,s,n,r,a;if(!(this.getIcon()||((i=this._button)==null?void 0:i.querySelector('[slot="icon"], .mint-button-icon, mint-icon'))))return!1;const e=(s=this._button)==null?void 0:s.querySelector(".mint-button-content");if(e&&((n=e.textContent)!=null&&n.trim()))return!1;if(this._button)for(let o=this._button.firstChild;o;o=o.nextSibling){if(o.nodeType===Node.TEXT_NODE&&((r=o.textContent)!=null&&r.trim()))return!1;if(o.nodeType===Node.ELEMENT_NODE){const l=o;if(l.tagName!=="MINT-ICON"&&l.tagName!=="MINT-SPINNER"&&!l.querySelector("mint-spinner")&&!l.hasAttribute("slot")&&l.className!=="mint-button-icon"&&!(l.className==="mr-2"&&l.querySelector("mint-spinner"))&&(a=l.textContent)!=null&&a.trim())return!1}}return!0}getActiveStateClasses(){const t=this.getVariant(),e=this.getTone(),i=`${t}-${e}`;return{"solid-action":["!bg-slate-900","!shadow-[inset_0_2px_4px_rgba(0,0,0,0.3)]","dark:!bg-slate-700","hover:!bg-slate-900","dark:hover:!bg-slate-700","hover:!shadow-[inset_0_2px_4px_rgba(0,0,0,0.3)]"],"solid-neutral":["!bg-gray-100","!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]","dark:!bg-gray-800","hover:!bg-gray-100","dark:hover:!bg-gray-800","hover:!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]"],"solid-info":["!bg-blue-900","!shadow-[inset_0_2px_4px_rgba(0,0,0,0.3)]","dark:!bg-blue-700","hover:!bg-blue-900","dark:hover:!bg-blue-700","hover:!shadow-[inset_0_2px_4px_rgba(0,0,0,0.3)]"],"solid-warning":["!bg-amber-900","!shadow-[inset_0_2px_4px_rgba(0,0,0,0.3)]","dark:!bg-amber-700","hover:!bg-amber-900","dark:hover:!bg-amber-700","hover:!shadow-[inset_0_2px_4px_rgba(0,0,0,0.3)]"],"solid-danger":["!bg-red-900","!shadow-[inset_0_2px_4px_rgba(0,0,0,0.3)]","dark:!bg-red-700","hover:!bg-red-900","dark:hover:!bg-red-700","hover:!shadow-[inset_0_2px_4px_rgba(0,0,0,0.3)]"],"ghost-action":["!bg-gray-100","!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]","dark:!bg-gray-800","hover:!bg-gray-100","dark:hover:!bg-gray-800","hover:!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]"],"ghost-neutral":["!bg-gray-50","!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]","dark:!bg-gray-800","!text-gray-900","dark:!text-white","hover:!bg-gray-50","dark:hover:!bg-gray-800","hover:!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]","hover:!text-gray-900","dark:hover:!text-white"],"ghost-info":["!bg-gray-100","!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]","dark:!bg-gray-800","hover:!bg-gray-100","dark:hover:!bg-gray-800","hover:!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]"],"ghost-warning":["!bg-gray-100","!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]","dark:!bg-gray-800","hover:!bg-gray-100","dark:hover:!bg-gray-800","hover:!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]"],"ghost-danger":["!bg-gray-100","!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]","dark:!bg-gray-800","hover:!bg-gray-100","dark:hover:!bg-gray-800","hover:!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]"],"link-action":["!text-slate-900","dark:!text-slate-300","hover:!text-slate-900","dark:hover:!text-slate-300"],"link-neutral":["!text-gray-950","dark:!text-gray-200","hover:!text-gray-950","dark:hover:!text-gray-200"],"link-info":["!text-blue-900","dark:!text-blue-200","hover:!text-blue-900","dark:hover:!text-blue-200"],"link-warning":["!text-amber-900","dark:!text-amber-200","hover:!text-amber-900","dark:hover:!text-amber-200"],"link-danger":["!text-red-900","dark:!text-red-200","hover:!text-red-900","dark:hover:!text-red-200"]}[i]||[]}getButtonClasses(){const t=this.isIconOnly(),e=this.getVariant(),i=["inline-flex","items-center","justify-center","font-medium","rounded-lg","box-border",...t?["p-1.5","aspect-square","w-[2.25rem]","h-[2.25rem]"]:["px-3.5","py-1.5","min-h-[2.25rem]"],"text-sm","transition-all","duration-200","outline-none","focus:outline-none","focus-visible:ring-2","focus-visible:ring-offset-1","[&.mint-button-active>*]:scale-95","[&>*]:transition-transform","[&>*]:duration-100","disabled:opacity-50","disabled:cursor-not-allowed"],s=this.getTone(),n={"solid-action":["bg-slate-800","dark:bg-slate-600","text-white","hover:bg-slate-950","dark:hover:bg-slate-700","active:bg-slate-900","active:shadow-[inset_0_2px_4px_rgba(0,0,0,0.3)]","dark:active:bg-slate-700","disabled:active:bg-slate-800","dark:disabled:active:bg-slate-600","disabled:active:shadow-none","focus-visible:ring-gray-400","dark:focus-visible:ring-gray-500","shadow-sm","hover:shadow","dark:shadow-gray-900/50","border-2","border-transparent"],"solid-neutral":["bg-white","dark:bg-gray-700","text-gray-900","dark:text-white","hover:bg-gray-50","dark:hover:bg-gray-600","active:bg-gray-100","active:shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]","dark:active:bg-gray-800","disabled:active:bg-white","dark:disabled:active:bg-gray-700","disabled:active:shadow-none","focus-visible:ring-gray-400","dark:focus-visible:ring-gray-500","shadow-sm","hover:shadow","dark:shadow-gray-900/50","border-2","border-gray-200","dark:border-gray-600"],"solid-info":["bg-blue-800","dark:bg-blue-600","text-white","hover:bg-blue-950","dark:hover:bg-blue-700","active:bg-blue-900","active:shadow-[inset_0_2px_4px_rgba(0,0,0,0.3)]","dark:active:bg-blue-700","disabled:active:bg-blue-800","dark:disabled:active:bg-blue-600","disabled:active:shadow-none","focus-visible:ring-gray-400","dark:focus-visible:ring-gray-500","shadow-sm","hover:shadow","dark:shadow-gray-900/50","border-2","border-transparent"],"solid-warning":["bg-amber-800","dark:bg-amber-600","text-white","hover:bg-amber-950","dark:hover:bg-amber-700","active:bg-amber-900","active:shadow-[inset_0_2px_4px_rgba(0,0,0,0.3)]","dark:active:bg-amber-700","disabled:active:bg-amber-800","dark:disabled:active:bg-amber-600","disabled:active:shadow-none","focus-visible:ring-gray-400","dark:focus-visible:ring-gray-500","shadow-sm","hover:shadow","dark:shadow-gray-900/50","border-2","border-transparent"],"solid-danger":["bg-red-800","dark:bg-red-600","text-white","hover:bg-red-950","dark:hover:bg-red-700","active:bg-red-900","active:shadow-[inset_0_2px_4px_rgba(0,0,0,0.3)]","dark:active:bg-red-700","disabled:active:bg-red-800","dark:disabled:active:bg-red-600","disabled:active:shadow-none","focus-visible:ring-gray-400","dark:focus-visible:ring-gray-500","shadow-sm","hover:shadow","dark:shadow-gray-900/50","border-2","border-transparent"],"ghost-action":["bg-transparent","text-slate-800","dark:text-slate-400","active:bg-gray-100","active:shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]","dark:active:bg-gray-800","disabled:active:bg-transparent","dark:disabled:active:bg-transparent","disabled:active:shadow-none","focus-visible:ring-gray-400","dark:focus-visible:ring-gray-500","shadow-none","hover:shadow-none","border-2","border-transparent"],"ghost-neutral":["bg-transparent","text-gray-700","dark:text-gray-200","active:bg-gray-50","active:shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]","dark:active:bg-gray-800","active:text-gray-900","dark:active:text-white","disabled:active:bg-transparent","dark:disabled:active:bg-transparent","disabled:active:shadow-none","focus-visible:ring-gray-400","dark:focus-visible:ring-gray-500","shadow-none","hover:shadow-none","border-2","border-transparent"],"ghost-info":["bg-transparent","text-blue-800","dark:text-blue-400","active:bg-gray-100","active:shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]","dark:active:bg-gray-800","disabled:active:bg-transparent","dark:disabled:active:bg-transparent","disabled:active:shadow-none","focus-visible:ring-gray-400","dark:focus-visible:ring-gray-500","shadow-none","hover:shadow-none","border-2","border-transparent"],"ghost-warning":["bg-transparent","text-amber-800","dark:text-amber-400","active:bg-gray-100","active:shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]","dark:active:bg-gray-800","disabled:active:bg-transparent","dark:disabled:active:bg-transparent","disabled:active:shadow-none","focus-visible:ring-gray-400","dark:focus-visible:ring-gray-500","shadow-none","hover:shadow-none","border-2","border-transparent"],"ghost-danger":["bg-transparent","text-red-800","dark:text-red-400","active:bg-gray-100","active:shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]","dark:active:bg-gray-800","disabled:active:bg-transparent","dark:disabled:active:bg-transparent","disabled:active:shadow-none","focus-visible:ring-gray-400","dark:focus-visible:ring-gray-500","shadow-none","hover:shadow-none","border-2","border-transparent"],"link-action":["bg-transparent","text-slate-800","dark:text-slate-400","hover:text-slate-950","dark:hover:text-slate-200","active:text-slate-900","dark:active:text-slate-300","disabled:active:bg-transparent","dark:disabled:active:bg-transparent","disabled:active:shadow-none","focus-visible:ring-gray-400","dark:focus-visible:ring-gray-500","shadow-none","hover:shadow-none","border-2","border-transparent"],"link-neutral":["bg-transparent","text-gray-700","dark:text-gray-300","hover:text-gray-900","dark:hover:text-gray-100","active:text-gray-950","dark:active:text-gray-200","disabled:active:bg-transparent","dark:disabled:active:bg-transparent","disabled:active:shadow-none","focus-visible:ring-gray-400","dark:focus-visible:ring-gray-500","shadow-none","hover:shadow-none","border-2","border-transparent"],"link-info":["bg-transparent","text-blue-800","dark:text-blue-400","hover:text-blue-950","dark:hover:text-blue-300","active:text-blue-900","dark:active:text-blue-200","disabled:active:bg-transparent","dark:disabled:active:bg-transparent","disabled:active:shadow-none","focus-visible:ring-gray-400","dark:focus-visible:ring-gray-500","shadow-none","hover:shadow-none","border-2","border-transparent"],"link-warning":["bg-transparent","text-amber-800","dark:text-amber-400","hover:text-amber-950","dark:hover:text-amber-300","active:text-amber-900","dark:active:text-amber-200","disabled:active:bg-transparent","dark:disabled:active:bg-transparent","disabled:active:shadow-none","focus-visible:ring-gray-400","dark:focus-visible:ring-gray-500","shadow-none","hover:shadow-none","border-2","border-transparent"],"link-danger":["bg-transparent","text-red-800","dark:text-red-400","hover:text-red-950","dark:hover:text-red-300","active:text-red-900","dark:active:text-red-200","disabled:active:bg-transparent","dark:disabled:active:bg-transparent","disabled:active:shadow-none","focus-visible:ring-gray-400","dark:focus-visible:ring-gray-500","shadow-none","hover:shadow-none","border-2","border-transparent"]},r=`${e}-${s}`,a=n[r]||n["solid-neutral"],o=[...i,...a];if(this.isActive()){const l=this.getActiveStateClasses();o.push(...l),o.push("[&>*]:scale-95")}return this.isFullWidth()&&o.push("w-full"),o.join(" ")}render(){var c,h,p,d,u;const t=this.isDisabled()||this.isLoading(),e=this.getType();if(!this._button){for(this._button=document.createElement("button");this.firstChild;)this._button.appendChild(this.firstChild);this.appendChild(this._button),this.setupEventListeners()}this._button.type=e,this._button.disabled=t;let i=this._button.querySelector("mint-spinner");if(this.isLoading())if(i)i.setAttribute("data-button-variant",this.getVariant()),i.setAttribute("data-button-tone",this.getTone()),"render"in i&&typeof i.render=="function"&&i.render();else{const f=document.createElement("span");f.className="mr-2 inline-flex items-center";const m=document.createElement("mint-spinner");m.setAttribute("size","default"),m.setAttribute("data-button-variant",this.getVariant()),m.setAttribute("data-button-tone",this.getTone()),m.style.width="0.875rem",m.style.height="0.875rem",f.appendChild(m),this._button.insertBefore(f,this._button.firstChild)}else i&&((c=i.parentElement)==null||c.remove());for(;this.firstChild&&this.firstChild!==this._button;)this._button.appendChild(this.firstChild);const s=this.getIcon();let n=this._button.querySelector('[slot="icon"], .mint-button-icon, mint-icon');s?(n&&n.tagName!=="MINT-ICON"&&(n.remove(),n=null),!n||n.tagName!=="MINT-ICON"?(n=document.createElement("mint-icon"),n.setAttribute("name",s),n.className="mint-button-icon"):n.setAttribute("name",s)):n&&n.tagName==="MINT-ICON"&&(n.remove(),n=null),n||(n=this._button.querySelector('[slot="icon"], .mint-button-icon'));const r=this.getIconPosition();let a=this._button.querySelector(".mint-button-content");if(a){const f=n&&n.tagName==="MINT-ICON";if(n&&!n.parentElement){const m=(d=this._button.querySelector("mint-spinner"))==null?void 0:d.parentElement;f||r==="left"?m?m.insertAdjacentElement("afterend",n):this._button.insertBefore(n,a):a.insertAdjacentElement("afterend",n)}else if(n&&(f||r==="left")&&n.nextSibling!==a){n.remove();const m=(u=this._button.querySelector("mint-spinner"))==null?void 0:u.parentElement;m?m.insertAdjacentElement("afterend",n):this._button.insertBefore(n,a)}else n&&!f&&r==="right"&&n.previousSibling!==a&&(n.remove(),a.insertAdjacentElement("afterend",n))}else{const f=[];for(let m=this._button.firstChild;m;m=m.nextSibling){if(m.nodeType!==Node.ELEMENT_NODE){f.push(m);continue}const g=m;g.tagName!=="MINT-SPINNER"&&!g.querySelector("mint-spinner")&&m!==n&&!g.hasAttribute("slot")&&!(g.className==="mr-2"&&g.querySelector("mint-spinner"))&&f.push(m)}if(f.length>0){a=document.createElement("span"),a.className="mint-button-content inline-flex items-center",f.forEach(g=>{a.appendChild(g)});const m=(h=this._button.querySelector("mint-spinner"))==null?void 0:h.parentElement;n&&r==="left"?m?(m.insertAdjacentElement("afterend",n),n.insertAdjacentElement("afterend",a)):(this._button.insertBefore(n,this._button.firstChild),n.insertAdjacentElement("afterend",a)):n&&r==="right"?m?(m.insertAdjacentElement("afterend",a),a.insertAdjacentElement("afterend",n)):(this._button.insertBefore(a,this._button.firstChild),a.insertAdjacentElement("afterend",n)):m?m.insertAdjacentElement("afterend",a):this._button.insertBefore(a,this._button.firstChild)}else if(n&&n.tagName==="MINT-ICON"&&!n.parentElement){const m=(p=this._button.querySelector("mint-spinner"))==null?void 0:p.parentElement;m?m.insertAdjacentElement("afterend",n):this._button.insertBefore(n,this._button.firstChild)}}const o=this.isIconOnly();n&&(n.classList.contains("mint-button-icon")||n.classList.add("mint-button-icon"),n.classList.remove("mr-1.5","ml-1.5"),o?n.tagName==="MINT-ICON"?(n.style.width="1rem",n.style.height="1rem",n.style.maxWidth="1rem",n.style.maxHeight="1rem",n.style.flexShrink="0"):(n.style.maxWidth="1rem",n.style.maxHeight="1rem",n.style.flexShrink="0",n.tagName==="svg"&&(n.style.width="1rem",n.style.height="1rem")):r==="left"?n.classList.add("mr-1.5"):n.classList.add("ml-1.5"));const l=this.getButtonClasses();this._button.className=l}setupEventListeners(){this._button&&!this._clickHandler&&(this._clickHandler=this.handleClick.bind(this),this._clickHandler&&this._button.addEventListener("click",this._clickHandler,!0),this._button.addEventListener("mousedown",this._handleMouseDown),this._button.addEventListener("mouseup",this._handleMouseUp),this._button.addEventListener("mouseleave",this._handleMouseLeave),this._button.addEventListener("touchstart",this._handleTouchStart),this._button.addEventListener("touchend",this._handleTouchEnd),this._button.addEventListener("touchcancel",this._handleTouchCancel))}removeEventListeners(){this._button&&(this._clickHandler&&(this._button.removeEventListener("click",this._clickHandler,!0),this._clickHandler=null),this._button.removeEventListener("mousedown",this._handleMouseDown),this._button.removeEventListener("mouseup",this._handleMouseUp),this._button.removeEventListener("mouseleave",this._handleMouseLeave),this._button.removeEventListener("touchstart",this._handleTouchStart),this._button.removeEventListener("touchend",this._handleTouchEnd),this._button.removeEventListener("touchcancel",this._handleTouchCancel))}handleClick(t){if(this.isDisabled()||this.isLoading()){t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation();return}if(this.getType()==="submit"){this.dispatchEvent(new CustomEvent("click",{detail:{originalEvent:t},bubbles:!0,cancelable:!0,composed:!0}));return}if(t.stopPropagation(),t.stopImmediatePropagation(),this._isHandlingClick){t.preventDefault();return}this._isHandlingClick=!0,t.preventDefault(),this.dispatchEvent(new CustomEvent("click",{detail:{originalEvent:t},bubbles:!0,cancelable:!0,composed:!0})),requestAnimationFrame(()=>{this._isHandlingClick=!1})}}customElements.get("mint-button")||customElements.define("mint-button",P);class $ extends HTMLElement{constructor(){super(),this._button=null,this._checked=!1}static get observedAttributes(){return["checked","disabled","label","icon","info","error","error-message","loading"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline","block","w-full"),this._checked=this.hasAttribute("checked"),this.render()}_getSwitchContainer(){let t=this.querySelector(".mint-switch-container");return t||(t=document.createElement("div"),t.className="mint-switch-container flex items-center gap-2",this.insertBefore(t,this.firstChild)),t}disconnectedCallback(){this.removeEventListeners()}isLoading(){return this.hasAttribute("loading")}attributeChangedCallback(t,e,i){if(t==="checked"&&(this._checked=i!==null),e!==i){if(t==="error"||t==="error-message"){this._renderErrorState();return}if(t==="loading"){this.render();return}this.render()}}get checked(){return this._checked}set checked(t){t?this.setAttribute("checked",""):this.removeAttribute("checked"),this._checked=!!t,this.render()}isDisabled(){return this.hasAttribute("disabled")}getLabel(){return this.getAttribute("label")||""}getInfo(){return this.getAttribute("info")||""}getIcon(){return this.getAttribute("icon")||""}hasIcon(){return!!this.getIcon()}hasError(){return this.hasAttribute("error")}getErrorMessage(){return this.getAttribute("error-message")||""}getSwitchClasses(){const t=this.hasError(),e=["relative","inline-flex","items-center","rounded-full","h-5","w-10","border","transition-colors","duration-200","ease-in-out","outline-none","focus:outline-none","focus-visible:ring-2","focus-visible:ring-offset-1",t?"focus-visible:ring-red-400 dark:focus-visible:ring-red-500":"focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500","active:shadow-[inset_0_2px_4px_rgba(0,0,0,0.3)]","disabled:opacity-50","disabled:cursor-not-allowed"],i=this._checked?["bg-slate-950","dark:bg-slate-600",t?"border-red-300 dark:border-red-300":"border-slate-700 dark:border-slate-500"]:["bg-slate-200","dark:bg-slate-400",t?"border-red-300 dark:border-red-300":"border-slate-300 dark:border-slate-500"];return[...e,...i].join(" ")}getThumbClasses(){const t=["relative","inline-block","rounded-full","bg-white","dark:bg-gray-50","h-4","w-4","shadow-lg","transform","transition-transform","duration-200","ease-in-out","pointer-events-none","overflow-hidden"],e=this._checked?"translate-x-5":"translate-x-0.5";return[...t,e].join(" ")}getIconClasses(){return["absolute","inset-0","flex","items-center","justify-center","pointer-events-none"].join(" ")}render(){const t=this.isLoading(),e=this.getSwitchClasses(),i=this.getThumbClasses(),s=this.getLabel(),n=this.getInfo(),r=this.getIcon(),a=this.getAttribute("id")||`mint-switch-${Math.random().toString(36).substr(2,9)}`;this.getAttribute("id")||this.setAttribute("id",a);const o=this._getSwitchContainer();this._button?this._button.parentElement!==o&&o.appendChild(this._button):(this._button=document.createElement("button"),o.appendChild(this._button),this.setupEventListeners());let l=o.querySelector(".mint-switch-label");s?(l||(l=document.createElement("label"),l.className="mint-switch-label text-sm font-medium text-gray-900 dark:text-gray-100 select-none",this._button&&this._button.parentElement===o?o.insertBefore(l,this._button.nextSibling):o.appendChild(l)),l.textContent=s,l.setAttribute("for",a),this.isDisabled()?l.classList.add("opacity-40"):l.classList.remove("opacity-40")):l&&l.remove(),this._button.className=e,this._button.disabled=this.isDisabled(),this._button.id=a,this._button.setAttribute("aria-checked",String(this._checked)),this._button.setAttribute("aria-label",s||"Toggle switch"),this._button.setAttribute("role","switch"),this._button.type="button";let c=this._button.querySelector("span");c||(c=document.createElement("span"),this._button.appendChild(c)),c.className=i;const h=c.querySelector("span");if(r){let d=h;d||(d=document.createElement("span"),d.className=this.getIconClasses(),c.appendChild(d));let u=d.querySelector("mint-icon");u||(u=document.createElement("mint-icon"),d.appendChild(u)),u.setAttribute("name",r)}else h&&h.remove();let p=this.querySelector(".mint-switch-info");n?(p||(p=document.createElement("span"),p.className="mint-switch-info text-xs text-gray-500 dark:text-gray-400 select-none mt-1 block",o&&o.parentElement===this?this.insertBefore(p,o.nextSibling):this.appendChild(p)),p.textContent=n,this.isDisabled()?p.classList.add("opacity-40"):p.classList.remove("opacity-40")):p&&p.remove(),this._renderErrorState(),this._renderSkeleton(t)}setupEventListeners(){this._button&&this._button.addEventListener("click",this.handleToggle.bind(this))}removeEventListeners(){this._button&&this._button.removeEventListener("click",this.handleToggle.bind(this))}handleToggle(t){this.isDisabled()||(this.checked=!this._checked,this.dispatchEvent(new CustomEvent("change",{detail:{checked:this._checked},bubbles:!0,cancelable:!0})),this.dispatchEvent(new CustomEvent("toggle",{detail:{checked:this._checked},bubbles:!0,cancelable:!0})))}_renderSkeleton(t){const e=this._getSwitchContainer(),i=this.getLabel(),s=this.getInfo();let n=e.querySelector(".mint-switch-skeleton-container"),r=this.querySelector(".mint-switch-info-skeleton");if(t){e.classList.contains("relative")||e.classList.add("relative"),n||(n=document.createElement("div"),n.className="mint-switch-skeleton-container absolute inset-0 z-10 pointer-events-none flex items-center gap-2",e.appendChild(n));let a=n.querySelector(".mint-switch-skeleton-box");if(a||(a=document.createElement("div"),a.className="mint-switch-skeleton-box flex-shrink-0 w-10 h-5 rounded-full bg-gray-200 dark:bg-gray-700 animate-pulse",n.appendChild(a)),i){let l=n.querySelector(".mint-switch-skeleton-label");l||(l=document.createElement("div"),l.className="mint-switch-skeleton-label h-4 w-24 rounded bg-gray-200 dark:bg-gray-700 animate-pulse",n.appendChild(l))}else{const l=n.querySelector(".mint-switch-skeleton-label");l&&l.remove()}n.style.display="flex",this._button&&(this._button.style.visibility="hidden",this._button.style.pointerEvents="none");const o=e.querySelector(".mint-switch-label");if(o&&(o.style.visibility="hidden",o.style.pointerEvents="none"),s){r||(r=document.createElement("div"),r.className="mint-switch-info-skeleton h-3 w-32 rounded bg-gray-200 dark:bg-gray-700 animate-pulse mt-2",e&&e.parentElement===this?this.insertBefore(r,e.nextSibling):this.appendChild(r)),r.style.display="block";const l=this.querySelector(".mint-switch-info");l&&(l.style.display="none")}else r&&(r.style.display="none")}else{n&&(n.style.display="none"),r&&(r.style.display="none"),this._button&&(this._button.style.visibility="visible",this._button.style.pointerEvents="auto");const a=e.querySelector(".mint-switch-label");a&&(a.style.visibility="visible",a.style.pointerEvents="auto");const o=this.querySelector(".mint-switch-info");o&&(o.style.display="")}}_renderErrorState(){const t=this.hasError(),e=this.getErrorMessage();let i=this.querySelector(".mint-switch-error");t&&e?(i||(i=document.createElement("div"),i.className="mint-switch-error mt-1 text-xs text-red-600 dark:text-red-400",this.appendChild(i)),i.textContent=e):i&&i.remove(),this._button&&(this._button.className=this.getSwitchClasses())}}customElements.get("mint-switch")||customElements.define("mint-switch",$);class O extends HTMLElement{constructor(){super(),this._darkModeObserver=null,this._userClasses=new Set}static get observedAttributes(){return["variant","size","bold","underline","strike","italic","display"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline"),this._captureUserClasses(),this.render(),this._observeDarkMode()}_captureUserClasses(){Array.from(this.classList).forEach(e=>this._userClasses.add(e))}attributeChangedCallback(t,e,i){e!==i&&this.render()}disconnectedCallback(){this._darkModeObserver&&(this._darkModeObserver.disconnect(),this._darkModeObserver=null)}_observeDarkMode(){this._darkModeObserver||(this._darkModeObserver=new MutationObserver(()=>{this.render()}),this._darkModeObserver.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}))}getVariant(){return this.getAttribute("variant")||"default"}getSize(){return this.getAttribute("size")||"regular"}isBold(){return this.hasAttribute("bold")}isUnderline(){return this.hasAttribute("underline")}isStrike(){return this.hasAttribute("strike")}isItalic(){return this.hasAttribute("italic")}getDisplay(){return this.hasAttribute("display")?this.getAttribute("display"):this.getSize()==="regular"?"inline-block":"block"}getTextClasses(){const t=this.getSize(),e=this.getVariant(),i=document.documentElement.classList.contains("dark"),s={heading:["font-semibold"],"sub-heading":["font-medium"],regular:[]},n={default:i?["text-gray-100"]:["text-gray-900"],muted:i?["text-gray-400"]:["text-gray-400"],danger:i?["text-red-400"]:["text-red-600"],success:i?["text-green-400"]:["text-green-600"]},r=[];this.isBold()&&r.push("font-bold"),this.isUnderline()&&r.push("underline"),this.isStrike()&&r.push("line-through"),this.isItalic()&&r.push("italic");const a=this.getDisplay();return[a==="block"?"block":a==="inline"?"inline":"inline-block",...s[t]||s.regular,...n[e]||n.default,...r].join(" ")}render(){const t=this.getSize(),e=["text-gray-100","text-gray-900","text-gray-400","text-red-400","text-red-600","text-green-400","text-green-600"],i=["text-2xl","text-lg","text-sm"];i.forEach(l=>{this.classList.remove(l),this._userClasses.delete(l)}),e.forEach(l=>{this.classList.remove(l),this._userClasses.delete(l)});const s=this.getTextClasses().split(" ").filter(l=>l.trim());Array.from(this.classList).forEach(l=>{!e.includes(l)&&!i.includes(l)&&this._userClasses.add(l)});const r=[...new Set([...s,...Array.from(this._userClasses)])];this.className=r.join(" ");const a={heading:"clamp(1.25rem, 2.5vw + 0.5rem, 1.5rem)","sub-heading":"clamp(1rem, 1.5vw + 0.5rem, 1.125rem)",regular:"clamp(0.875rem, 1vw + 0.5rem, 0.875rem)"},o=a[t]||a.regular;this.style.setProperty("font-size",o)}}customElements.get("mint-text")||customElements.define("mint-text",O);class B extends HTMLElement{constructor(){super(),this._childObserver=null}static get observedAttributes(){return["direction","text-align","gap"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline","block"),this.render(),this.getTextAlign()&&this._observeChildren()}attributeChangedCallback(t,e,i){e!==i&&(this.render(),t==="text-align"&&this._observeChildren())}_observeChildren(){this._childObserver||(this._childObserver=new MutationObserver(()=>{const t=this.getTextAlign();t&&this._applyTextAlignToChildren(t)}),this._childObserver.observe(this,{childList:!0,subtree:!1}))}disconnectedCallback(){this._childObserver&&(this._childObserver.disconnect(),this._childObserver=null)}getDirection(){return(this.getAttribute("direction")||"vertical")==="horizontal"?"horizontal":"vertical"}getGap(){const t=this.getAttribute("gap")||"3";return parseFloat(t)}getTextAlign(){const t=this.getAttribute("text-align")||"";return["left","center","right","justify"].includes(t)?t:""}getStackClasses(){const t=this.getDirection(),e=this.getTextAlign(),i=this.getGap(),s=["flex",t==="horizontal"?"flex-row":"flex-col",`gap-${i}`];return e&&(s.push(`text-${e}`),s.push(`[&>*]:text-${e}`),s.push(`[&>*_.mint-button-content]:text-${e}`),e==="left"?(s.push("[&>mint-button]:!justify-start"),s.push("[&>mint-button>button]:!justify-start")):e==="right"?(s.push("[&>mint-button]:!justify-end"),s.push("[&>mint-button>button]:!justify-end")):e==="center"&&(s.push("[&>mint-button]:!justify-center"),s.push("[&>mint-button>button]:!justify-center"))),s.join(" ")}render(){const t=this.getStackClasses(),e=this.getTextAlign();["flex","flex-row","flex-col","gap-1","gap-2","gap-3","text-left","text-center","text-right","text-justify","[&>*]:text-left","[&>*]:text-center","[&>*]:text-right","[&>*]:text-justify","[&>*_.mint-button-content]:text-left","[&>*_.mint-button-content]:text-center","[&>*_.mint-button-content]:text-right","[&>*_.mint-button-content]:text-justify","[&>mint-button]:!justify-start","[&>mint-button]:!justify-center","[&>mint-button]:!justify-end","[&>mint-button>button]:!justify-start","[&>mint-button>button]:!justify-center","[&>mint-button>button]:!justify-end"].forEach(n=>this.classList.remove(n)),t.split(" ").forEach(n=>{n&&this.classList.add(n)}),["box-border","m-0","p-0","border-0","align-baseline","block"].forEach(n=>{this.classList.contains(n)||this.classList.add(n)}),e?this._applyTextAlignToChildren(e):this._removeTextAlignFromChildren()}_applyTextAlignToChildren(t){Array.from(this.children).forEach(i=>{if(i.tagName==="MINT-BUTTON"){const s=i.querySelector("button");if(s){s.classList.remove("justify-start","justify-center","justify-end"),t==="left"?s.classList.add("justify-start"):t==="right"?s.classList.add("justify-end"):t==="center"&&s.classList.add("justify-center");const n=s.querySelector(".mint-button-content");n&&(n.classList.remove("text-left","text-center","text-right","text-justify"),n.classList.add(`text-${t}`))}}else i.classList.remove("text-left","text-center","text-right","text-justify"),i.classList.add(`text-${t}`)})}_removeTextAlignFromChildren(){Array.from(this.children).forEach(e=>{if(e.tagName==="MINT-BUTTON"){const i=e.querySelector("button");if(i){i.classList.remove("justify-start","justify-end"),i.classList.add("justify-center");const s=i.querySelector(".mint-button-content");s&&s.classList.remove("text-left","text-center","text-right","text-justify")}}else e.classList.remove("text-left","text-center","text-right","text-justify")})}}customElements.get("mint-stack")||customElements.define("mint-stack",B);class z extends HTMLElement{constructor(){super(),this._headingElement=null}static get observedAttributes(){return["heading"]}connectedCallback(){this.classList.add("box-border","m-0","border-0","align-baseline","block"),this.render()}attributeChangedCallback(t,e,i){e!==i&&this.render()}getHeading(){return this.getAttribute("heading")||""}hasPaddingClass(){return Array.from(this.classList).some(e=>/^p-\d+|^px-|^py-|^pt-|^pb-|^pl-|^pr-/.test(e))}render(){this.classList.add("rounded-lg","shadow","bg-white","dark:bg-gray-800","border","border-gray-200","dark:border-gray-700","overflow-hidden","transition-colors","duration-200","mb-6"),this.hasPaddingClass()||this.classList.add("p-4");const t=this.getHeading();t?(this._headingElement||(this._headingElement=document.createElement("mint-text"),this._headingElement.setAttribute("size","sub-heading"),this.insertBefore(this._headingElement,this.firstChild)),this._headingElement.textContent=t):this._headingElement&&this._headingElement.parentNode&&(this._headingElement.remove(),this._headingElement=null)}}customElements.get("mint-card")||customElements.define("mint-card",z);class R extends HTMLElement{constructor(){super(),this._link=null,this._contentObserver=null}static get observedAttributes(){return["href","target"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline","inline-block"),this.render(),this._observeContent()}disconnectedCallback(){this._contentObserver&&(this._contentObserver.disconnect(),this._contentObserver=null)}_observeContent(){this._contentObserver||(this._contentObserver=new MutationObserver(()=>{this._link&&this._link.querySelectorAll("mint-text").forEach(e=>{e.classList.contains("underline")||e.classList.add("underline")})}),this._contentObserver.observe(this,{childList:!0,subtree:!0}))}attributeChangedCallback(t,e,i){e!==i&&this.render()}getHref(){return this.getAttribute("href")||"#"}getTarget(){return this.getAttribute("target")||""}hasIcon(){var t;return!!(this.querySelector("mint-icon")||(t=this._link)!=null&&t.querySelector("mint-icon"))}render(){const t=this.getHref(),e=this.getTarget();if(!this._link){for(this._link=document.createElement("a");this.firstChild;)this._link.appendChild(this.firstChild);this.appendChild(this._link)}this._link.href=t,e?(this._link.target=e,e==="_blank"&&(this._link.rel="noopener noreferrer")):(this._link.removeAttribute("target"),this._link.removeAttribute("rel"));const i=this.hasIcon(),s=["text-slate-800","dark:text-slate-200","underline","hover:text-slate-950","dark:hover:text-slate-100","transition-colors","duration-200","focus-visible:outline-none","focus-visible:ring-2","focus-visible:ring-offset-1","focus-visible:ring-gray-400","dark:focus-visible:ring-gray-500","rounded"];i&&s.push("inline-flex","items-center","gap-2"),this._link.className=s.join(" "),this._link.querySelectorAll("mint-text").forEach(a=>{a.classList.contains("underline")||a.classList.add("underline")}),["box-border","m-0","p-0","border-0","align-baseline","inline-block"].forEach(a=>{this.classList.contains(a)||this.classList.add(a)})}}customElements.get("mint-link")||customElements.define("mint-link",R);class W extends HTMLElement{constructor(){super(),this._button=null}static get observedAttributes(){return["href","fallback-href"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline","inline-block","flex","items-center","justify-center"),this.render()}disconnectedCallback(){}attributeChangedCallback(t,e,i){e!==i&&this.render()}getFallbackHref(){return this.getAttribute("fallback-href")||this.getAttribute("href")||"/"}_getTargetUrl(){const t=document.referrer,e=window.location.origin;if(t)try{const i=new URL(t);if(i.origin===e)return i.pathname+i.search}catch{}return this.getFallbackHref()}handleClick(t){t.preventDefault(),t.stopPropagation();const e=this._getTargetUrl(),i=document.referrer,s=i&&(()=>{try{return new URL(i).origin===window.location.origin}catch{return!1}})(),n=new CustomEvent("back",{detail:{url:e,isFromReferrer:s,referrer:i||null,fallbackHref:this.getFallbackHref()},bubbles:!0,cancelable:!0,composed:!0});this.dispatchEvent(n)}render(){this._button||(this._button=document.createElement("mint-button"),this._button.setAttribute("variant","neutral"),this._button.setAttribute("icon","arrow-left"),this._button.addEventListener("click",t=>this.handleClick(t)),this.appendChild(this._button))}}customElements.get("mint-back-button")||customElements.define("mint-back-button",W);class V extends HTMLElement{constructor(){super(),this._pageContainer=null,this._header=null,this._titleElement=null,this._headingText=null,this._actionsSlot=null,this._bodySlot=null,this._darkModeObserver=null,this._backButton=null,this._backButtonHandler=null}static get observedAttributes(){return["heading","fallback-href","show-back-button","containered"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline","block"),this.render(),this._observeDarkMode(),this._setupBackButtonListener()}attributeChangedCallback(t,e,i){e!==i&&this.render()}disconnectedCallback(){this._darkModeObserver&&(this._darkModeObserver.disconnect(),this._darkModeObserver=null),this._removeBackButtonListener()}getHeading(){return this.getAttribute("heading")||""}getFallbackHref(){return this.getAttribute("fallback-href")||"/"}shouldShowBackButton(){return this.hasAttribute("show-back-button")}render(){const t=this.getHeading();this._pageContainer||(this._pageContainer=document.createElement("div"),this.appendChild(this._pageContainer)),this._applyContainerClasses(),this._header||(this._header=document.createElement("div"),this._header.className="flex justify-between mb-8",this._pageContainer.appendChild(this._header)),this._titleElement||(this._titleElement=document.createElement("div"),this._titleElement.className="flex gap-4 min-w-0 flex-1",this._header.appendChild(this._titleElement));let e=this._titleElement.querySelector("mint-back-button");if(this.shouldShowBackButton()){e||(e=document.createElement("mint-back-button"),this._titleElement.insertBefore(e,this._titleElement.firstChild));const r=this.getFallbackHref();e.setAttribute("fallback-href",r),this._backButton=e}else e&&(e.remove(),e=null,this._backButton=null);t?(this._headingText?(this._headingText.classList.add("truncate","min-w-0"),e&&e.parentElement===this._titleElement?this._headingText.previousSibling!==e&&this._titleElement.insertBefore(this._headingText,e.nextSibling):this._headingText.previousSibling&&this._titleElement.insertBefore(this._headingText,this._titleElement.firstChild)):(this._headingText=document.createElement("mint-text"),this._headingText.setAttribute("size","heading"),this._headingText.setAttribute("bold",""),this._headingText.classList.add("truncate","min-w-0"),e&&e.parentElement===this._titleElement?this._titleElement.insertBefore(this._headingText,e.nextSibling):this._titleElement.insertBefore(this._headingText,this._titleElement.firstChild)),this._headingText.textContent=t):this._headingText&&(this._headingText.remove(),this._headingText=null),this._actionsSlot?this._actionsSlot.classList.contains("ml-4")||this._actionsSlot.classList.add("ml-4"):(this._actionsSlot=document.createElement("div"),this._actionsSlot.className="flex gap-2 items-center ml-4",this._actionsSlot.setAttribute("slot","actions"),this._header.appendChild(this._actionsSlot)),Array.from(this.children).filter(r=>r!==this._pageContainer&&r!==this._actionsSlot&&r.getAttribute("slot")==="actions").forEach(r=>{this._actionsSlot&&r.parentElement!==this._actionsSlot&&this._actionsSlot.appendChild(r)}),this._bodySlot||(this._bodySlot=document.createElement("div"),this._pageContainer.appendChild(this._bodySlot)),Array.from(this.children).forEach(r=>{r!==this._pageContainer&&r.getAttribute("slot")!=="actions"&&r!==this._actionsSlot&&r!==this._header&&r!==this._bodySlot&&r!==this._headingText&&r.parentElement!==this._bodySlot&&r.parentElement!==this._pageContainer&&this._bodySlot.appendChild(r)}),this._updateBackgroundColor()}_applyContainerClasses(){this._pageContainer&&(this._pageContainer.classList.add("min-h-screen","p-8","transition-colors","duration-200"),this.hasAttribute("containered")?this._pageContainer.classList.add("max-w-6xl","mx-auto","w-full"):this._pageContainer.classList.remove("max-w-6xl","mx-auto"))}_updateBackgroundColor(){if(!this._pageContainer)return;document.documentElement.classList.contains("dark")?(this._pageContainer.classList.remove("bg-gray-20"),this._pageContainer.classList.add("bg-gray-900")):(this._pageContainer.classList.remove("bg-gray-900"),this._pageContainer.classList.add("bg-gray-20"))}_observeDarkMode(){this._darkModeObserver||(this._darkModeObserver=new MutationObserver(()=>{this._updateBackgroundColor()}),this._darkModeObserver.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}))}_setupBackButtonListener(){this._backButtonHandler||(this._backButtonHandler=t=>{const e=t.target;if(e&&e.tagName==="MINT-BACK-BUTTON"){t.stopPropagation();const i=new CustomEvent("back",{detail:t.detail,bubbles:!0,cancelable:!0,composed:!0});this.dispatchEvent(i)}}),this.addEventListener("back",this._backButtonHandler,!0)}_removeBackButtonListener(){this._backButtonHandler&&(this.removeEventListener("back",this._backButtonHandler,!0),this._backButtonHandler=null)}}customElements.get("mint-page")||customElements.define("mint-page",V);class j extends HTMLElement{static get observedAttributes(){return["columns","sm","md","lg","xl","gap"]}constructor(){super()}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline","block"),this.render()}attributeChangedCallback(t,e,i){e!==i&&this.render()}getColumns(){return this.getAttribute("columns")||"1"}getSm(){return this.getAttribute("sm")}getMd(){return this.getAttribute("md")}getLg(){return this.getAttribute("lg")}getXl(){return this.getAttribute("xl")}getGap(){return"3"}getGridClasses(){const t=["grid"],e=this.getColumns();t.push(`grid-cols-${e}`);const i=this.getSm();i&&t.push(`sm:grid-cols-${i}`);const s=this.getMd();s&&t.push(`md:grid-cols-${s}`);const n=this.getLg();n&&t.push(`lg:grid-cols-${n}`);const r=this.getXl();r&&t.push(`xl:grid-cols-${r}`);const a=this.getGap();return t.push(`gap-${a}`),t}render(){Array.from(this.classList).filter(i=>i.startsWith("grid-cols-")||i.startsWith("sm:grid-cols-")||i.startsWith("md:grid-cols-")||i.startsWith("lg:grid-cols-")||i.startsWith("xl:grid-cols-")||i.startsWith("gap-")).forEach(i=>this.classList.remove(i)),this.classList.contains("grid")||this.classList.add("grid"),this.getGridClasses().forEach(i=>{i&&i!=="grid"&&this.classList.add(i)})}}customElements.get("mint-grid")||customElements.define("mint-grid",j);class Y extends HTMLElement{constructor(){super(),this._overlay=null,this._modal=null,this._header=null,this._headingSlot=null,this._bodySlot=null,this._actionsSlot=null,this._closeButton=null,this._darkModeObserver=null}static get observedAttributes(){return["id","heading","open"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline","fixed","inset-0","z-50"),this.isOpen()||this.classList.add("hidden"),this.render(),this._observeDarkMode()}disconnectedCallback(){this._darkModeObserver&&(this._darkModeObserver.disconnect(),this._darkModeObserver=null)}attributeChangedCallback(t,e,i){e!==i&&this.render()}getId(){return this.getAttribute("id")||""}getHeading(){return this.getAttribute("heading")||""}isOpen(){return this.hasAttribute("open")}open(){this.setAttribute("open","")}close(){this.removeAttribute("open")}render(){const t=this.getId(),e=this.getHeading(),i=this.isOpen();if(t&&(this.id=t),this._overlay||(this._overlay=document.createElement("div"),this._overlay.className="fixed inset-0 bg-black bg-opacity-50 transition-opacity duration-200 z-40",this._overlay.addEventListener("click",()=>this.close()),this.appendChild(this._overlay)),this._modal||(this._modal=document.createElement("div"),this._modal.className="fixed inset-0 flex items-center justify-center p-2 pointer-events-none z-50",this.appendChild(this._modal)),i){let h=this._modal.querySelector(".modal-content");h||(h=document.createElement("div"),h.className="modal-content bg-white dark:bg-gray-800 rounded-lg shadow-xl max-w-2xl w-full max-h-[90vh] flex flex-col pointer-events-auto transition-all duration-200 ease-out transform",this._modal.appendChild(h)),this._animateEnter()}else this._animateExit();let s=this._modal.querySelector(".modal-content");s||(s=document.createElement("div"),s.className="modal-content bg-white dark:bg-gray-800 rounded-lg shadow-xl max-w-2xl w-full max-h-[90vh] flex flex-col pointer-events-auto transition-all duration-200 ease-out transform",this._modal.appendChild(s)),this._header||(this._header=document.createElement("div"),this._header.className="flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700",s.appendChild(this._header)),this._headingSlot||(this._headingSlot=document.createElement("div"),this._headingSlot.className="flex-1",this._headingSlot.setAttribute("slot","heading"),this._header.appendChild(this._headingSlot));let n=this._headingSlot.querySelector("mint-text");e?(n||(n=document.createElement("mint-text"),n.setAttribute("size","sub-heading"),n.setAttribute("bold",""),this._headingSlot.appendChild(n)),n.textContent=e):n&&n.remove(),Array.from(this.children).filter(h=>h!==this._overlay&&h!==this._modal&&h!==this._headingSlot&&h.getAttribute("slot")==="heading").forEach(h=>{this._headingSlot&&h.parentElement!==this._headingSlot&&this._headingSlot.appendChild(h)}),this._closeButton||(this._closeButton=document.createElement("mint-button"),this._closeButton.setAttribute("variant","ghost"),this._closeButton.setAttribute("icon","close"),this._closeButton.addEventListener("click",()=>this.close()),this._header.appendChild(this._closeButton)),this._bodySlot||(this._bodySlot=document.createElement("div"),this._bodySlot.className="flex-1 overflow-y-auto p-4",this._bodySlot.setAttribute("slot","body"),s.appendChild(this._bodySlot)),Array.from(this.children).filter(h=>h!==this._overlay&&h!==this._modal&&h!==this._bodySlot&&h.getAttribute("slot")==="body").forEach(h=>{this._bodySlot&&h.parentElement!==this._bodySlot&&this._bodySlot.appendChild(h)}),this._actionsSlot||(this._actionsSlot=document.createElement("div"),this._actionsSlot.className="p-4 border-t border-gray-200 dark:border-gray-700",this._actionsSlot.setAttribute("slot","actions"),s.appendChild(this._actionsSlot));let o=this._actionsSlot.querySelector("mint-stack");o||(o=document.createElement("mint-stack"),o.setAttribute("direction","horizontal"),o.className="justify-end",this._actionsSlot.appendChild(o)),Array.from(this.children).filter(h=>h!==this._overlay&&h!==this._modal&&h!==this._actionsSlot&&h.getAttribute("slot")==="actions").forEach(h=>{Array.from(h.children).forEach(d=>{d.parentElement!==o&&o.appendChild(d)}),h.parentElement&&h.remove()}),Array.from(this.children).forEach(h=>{h!==this._overlay&&h!==this._modal&&h.getAttribute("slot")!=="heading"&&h.getAttribute("slot")!=="body"&&h.getAttribute("slot")!=="actions"&&h!==this._headingSlot&&h!==this._bodySlot&&h!==this._actionsSlot&&h.parentElement!==this._bodySlot&&this._bodySlot.appendChild(h)}),this._updateBackgroundColor()}_updateBackgroundColor(){if(!this._modal)return;const t=document.documentElement.classList.contains("dark"),e=this._modal.querySelector(".modal-content");e&&(t?(e.classList.remove("bg-white"),e.classList.add("bg-gray-800")):(e.classList.remove("bg-gray-800"),e.classList.add("bg-white")))}_observeDarkMode(){this._darkModeObserver||(this._darkModeObserver=new MutationObserver(()=>{this._updateBackgroundColor()}),this._darkModeObserver.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}))}_animateEnter(){var e;const t=(e=this._modal)==null?void 0:e.querySelector(".modal-content");t&&(t.style.transform="scale(0.97) translateY(10px)",t.style.opacity="0",t.style.transition="all 200ms ease-out",this.classList.remove("hidden"),requestAnimationFrame(()=>{requestAnimationFrame(()=>{t.style.transform="scale(1) translateY(0)",t.style.opacity="1"})}))}_animateExit(){var e;const t=(e=this._modal)==null?void 0:e.querySelector(".modal-content");if(!t){this.classList.add("hidden");return}t.style.transition="all 200ms ease-in",t.style.transform="scale(0.97) translateY(10px)",t.style.opacity="0",setTimeout(()=>{this.classList.add("hidden"),t.style.transform="",t.style.opacity="",t.style.transition=""},200)}}customElements.get("mint-modal")||customElements.define("mint-modal",Y);class U extends HTMLElement{constructor(){super(),this._overlay=null,this._popover=null,this._triggerElement=null,this._darkModeObserver=null,this._clickOutsideHandler=null,this._triggerClickHandler=null,this._triggerHoverEnterHandler=null,this._triggerHoverLeaveHandler=null,this._popoverHoverEnterHandler=null,this._popoverHoverLeaveHandler=null,this._hoverCloseTimeout=null,this._scrollHandler=null,this._resizeHandler=null}static get observedAttributes(){return["id","direction","open","trigger-id","padding","hover"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline","fixed","top-0","left-0","z-50","pointer-events-none"),this.isOpen()||this.classList.add("hidden"),this.render(),this._setupTrigger(),this._observeDarkMode()}disconnectedCallback(){this._darkModeObserver&&(this._darkModeObserver.disconnect(),this._darkModeObserver=null),this._clickOutsideHandler&&(document.removeEventListener("click",this._clickOutsideHandler),this._clickOutsideHandler=null),this._triggerClickHandler&&this._triggerElement&&(this._triggerElement.removeEventListener("click",this._triggerClickHandler,!0),this._triggerClickHandler=null),this._removeHoverListeners(),this._scrollHandler&&(window.removeEventListener("scroll",this._scrollHandler,!0),this._scrollHandler=null),this._resizeHandler&&(window.removeEventListener("resize",this._resizeHandler),this._resizeHandler=null)}attributeChangedCallback(t,e,i){e!==i&&(this.render(),(t==="trigger-id"||t==="hover")&&this._setupTrigger(),t==="open"&&this.isOpen()&&this._closeOtherPopovers())}getId(){return this.getAttribute("id")||""}getPadding(){const t=this.getAttribute("padding")||"4";return{0:"p-0","0.5":"p-0.5",1:"p-1","1.5":"p-1.5",2:"p-2","2.5":"p-2.5",3:"p-3","3.5":"p-3.5",4:"p-4",5:"p-5",6:"p-6",8:"p-8",10:"p-10",12:"p-12",16:"p-16",20:"p-20",24:"p-24"}[t]||"p-4"}getDirection(){return this.getAttribute("direction")||"down"}getTriggerId(){return this.getAttribute("trigger-id")||""}isHoverEnabled(){return this.hasAttribute("hover")}isOpen(){return this.hasAttribute("open")}open(){this.setAttribute("open","")}close(){this.removeAttribute("open")}_setupTrigger(){const t=this.getTriggerId();this._triggerClickHandler&&this._triggerElement&&(this._triggerElement.removeEventListener("click",this._triggerClickHandler,!0),this._triggerClickHandler=null),this._removeHoverListeners(),t&&(this._triggerElement=document.getElementById(t),this._triggerElement?(this._attachTriggerListener(),this.isHoverEnabled()&&this._attachHoverListeners()):setTimeout(()=>{this._triggerElement=document.getElementById(t),this._triggerElement&&(this._attachTriggerListener(),this.isHoverEnabled()&&this._attachHoverListeners())},10))}_attachTriggerListener(){if(this._triggerElement&&!this._triggerClickHandler){const t=this;this._triggerClickHandler=function(e){e.stopImmediatePropagation(),e.preventDefault(),t.hasAttribute("open")?t.removeAttribute("open"):t.setAttribute("open","")},this._triggerElement.addEventListener("click",this._triggerClickHandler,!0)}}_attachHoverListeners(){if(!this.isHoverEnabled()||!this._triggerElement)return;this._removeHoverListeners();const t=this;this._triggerHoverEnterHandler=function(){t._cancelHoverClose(),t.open()},this._triggerHoverLeaveHandler=function(e){var s;const i=e.relatedTarget;i&&(t.contains(i)||(s=t._triggerElement)!=null&&s.contains(i))||t._scheduleHoverClose()},this._triggerElement.addEventListener("mouseenter",this._triggerHoverEnterHandler),this._triggerElement.addEventListener("mouseleave",this._triggerHoverLeaveHandler),this._popover&&(this._popoverHoverEnterHandler=function(){t._cancelHoverClose()},this._popoverHoverLeaveHandler=function(e){var s;const i=e.relatedTarget;i&&(t.contains(i)||(s=t._triggerElement)!=null&&s.contains(i))||t._scheduleHoverClose()},this._popover.addEventListener("mouseenter",this._popoverHoverEnterHandler),this._popover.addEventListener("mouseleave",this._popoverHoverLeaveHandler))}_removeHoverListeners(){this._triggerElement&&this._triggerHoverEnterHandler&&this._triggerElement.removeEventListener("mouseenter",this._triggerHoverEnterHandler),this._triggerElement&&this._triggerHoverLeaveHandler&&this._triggerElement.removeEventListener("mouseleave",this._triggerHoverLeaveHandler),this._popover&&this._popoverHoverEnterHandler&&this._popover.removeEventListener("mouseenter",this._popoverHoverEnterHandler),this._popover&&this._popoverHoverLeaveHandler&&this._popover.removeEventListener("mouseleave",this._popoverHoverLeaveHandler),this._triggerHoverEnterHandler=null,this._triggerHoverLeaveHandler=null,this._popoverHoverEnterHandler=null,this._popoverHoverLeaveHandler=null,this._cancelHoverClose()}_scheduleHoverClose(){this._cancelHoverClose(),this._hoverCloseTimeout=window.setTimeout(()=>{this._isHovering()||this.close()},120)}_cancelHoverClose(){this._hoverCloseTimeout!==null&&(clearTimeout(this._hoverCloseTimeout),this._hoverCloseTimeout=null)}_isHovering(){const t=this._triggerElement?this._triggerElement.matches(":hover"):!1,e=this._popover?this._popover.matches(":hover"):!1;return t||e}_calculatePosition(){if(!this._triggerElement||!this._popover)return{top:0,left:0,direction:"down"};const t=this._triggerElement.getBoundingClientRect(),e=this._popover.querySelector(".popover-content");if(!e)return{top:0,left:0,direction:"down"};this.classList.contains("hidden")&&(this.classList.remove("hidden"),this._popover.style.visibility="hidden");const s=e.getBoundingClientRect(),n=window.innerWidth,r=window.innerHeight,a=8;let o=this.getDirection(),l=0,c=0;switch(o){case"down":if(l=t.bottom+a,c=t.left+t.width/2-s.width/2,l+s.height>r){const h=t.top-s.height-a;h>=0?(o="up",l=h):(l=Math.max(0,r-s.height-a),l+s.height>r&&(l=0))}c<0&&(c=a),c+s.width>n&&(c=Math.max(a,n-s.width-a),c+s.width>n&&(c=n-s.width));break;case"up":if(l=t.top-s.height-a,c=t.left+t.width/2-s.width/2,l<0){const h=t.bottom+a;h+s.height<=r?(o="down",l=h):(l=Math.min(r-s.height-a,r-s.height),l<0&&(l=r-s.height))}c<0&&(c=a),c+s.width>n&&(c=Math.max(a,n-s.width-a),c+s.width>n&&(c=n-s.width));break;case"right":if(l=t.top+t.height/2-s.height/2,c=t.right+a,c+s.width>n){const h=t.left-s.width-a;h>=0?(o="left",c=h):(c=Math.max(0,n-s.width-a),c+s.width>n&&(c=n-s.width))}l<0&&(l=a),l+s.height>r&&(l=Math.max(a,r-s.height-a),l+s.height>r&&(l=r-s.height));break;case"left":if(l=t.top+t.height/2-s.height/2,c=t.left-s.width-a,c<0){const h=t.right+a;h+s.width<=n?(o="right",c=h):(c=Math.min(n-s.width-a,n-s.width),c<0&&(c=0))}l<0&&(l=a),l+s.height>r&&(l=Math.max(a,r-s.height-a),l+s.height>r&&(l=r-s.height));break}return{top:l,left:c,direction:o}}render(){const t=this.getId(),e=this.isOpen(),i=this.getPadding();if(t&&(this.id=t),e){if(this.classList.remove("hidden"),this.style.pointerEvents="auto",!this._clickOutsideHandler){const r=this;this._clickOutsideHandler=function(a){const o=a.composedPath(),l=o.includes(r);if(!(r._triggerElement&&o.includes(r._triggerElement))&&!l){r.close();return}},setTimeout(()=>{document.addEventListener("click",this._clickOutsideHandler,!1)},100)}}else this.classList.add("hidden"),this.style.pointerEvents="none",this._clickOutsideHandler&&(document.removeEventListener("click",this._clickOutsideHandler,!1),this._clickOutsideHandler=null);this._overlay||(this._overlay=document.createElement("div"),this._overlay.className="fixed inset-0 pointer-events-none z-40",this.appendChild(this._overlay)),this._popover||(this._popover=document.createElement("div"),this._popover.className="fixed z-50 pointer-events-auto",this.appendChild(this._popover)),this.isHoverEnabled()&&this._attachHoverListeners();let s=this._popover.querySelector(".popover-content");if(!s)s=document.createElement("div"),s.className=`popover-content bg-white dark:bg-gray-800 rounded-lg shadow-xl ${i} transition-all duration-200 ease-out transform`,this._popover.appendChild(s);else{const r=s.className.split(" "),a=["p-0","p-0.5","p-1","p-1.5","p-2","p-2.5","p-3","p-3.5","p-4","p-5","p-6","p-8","p-10","p-12","p-16","p-20","p-24"],o=r.filter(l=>!a.includes(l));s.className=[...o,i].join(" ")}Array.from(this.children).forEach(r=>{r!==this._overlay&&r!==this._popover&&r.parentElement===this&&s.appendChild(r)}),e?(this._triggerElement||this._setupTrigger(),this._setupPositionListeners(),this.offsetHeight,this._triggerElement?this._updatePosition(s):(this._popover.style.top="50%",this._popover.style.left="50%",this._popover.style.transform="translate(-50%, -50%)",this._popover.style.visibility="visible",this._popover.style.display="block",s.style.transform="scale(0.97) translateY(10px)",s.style.opacity="0",s.style.transition="all 200ms ease-out",requestAnimationFrame(()=>{requestAnimationFrame(()=>{s.style.transform="scale(1) translateY(0)",s.style.opacity="1"})}))):!e&&s&&(this._removePositionListeners(),s.style.opacity!=="0"&&s.style.opacity!==""&&(s.style.transition="all 200ms ease-in",s.style.transform="scale(0.97) translateY(10px)",s.style.opacity="0",setTimeout(()=>{s.style.transform="",s.style.opacity="",s.style.transition="",this._popover.style.visibility="",this._popover.style.display=""},200))),this._updateBackgroundColor()}_updateBackgroundColor(){if(!this._popover)return;const t=document.documentElement.classList.contains("dark"),e=this._popover.querySelector(".popover-content");e&&(t?(e.classList.remove("bg-white"),e.classList.add("bg-gray-800")):(e.classList.remove("bg-gray-800"),e.classList.add("bg-white")))}_observeDarkMode(){this._darkModeObserver||(this._darkModeObserver=new MutationObserver(()=>{this._updateBackgroundColor()}),this._darkModeObserver.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}))}_updatePosition(t){if(!this._triggerElement||!this._popover)return;const e=this._popover.style.visibility!=="hidden";e||(this._popover.style.visibility="hidden",this._popover.style.display="block",this._popover.style.top="0",this._popover.style.left="0"),this._popover.offsetHeight;const i=this._calculatePosition();this._popover.style.top=`${i.top}px`,this._popover.style.left=`${i.left}px`,e||(this._popover.style.visibility="visible",t&&(!t.style.opacity||t.style.opacity==="")&&(t.style.transform="scale(0.97) translateY(10px)",t.style.opacity="0",t.style.transition="all 200ms ease-out",requestAnimationFrame(()=>{requestAnimationFrame(()=>{t.style.transform="scale(1) translateY(0)",t.style.opacity="1"})})))}_setupPositionListeners(){if(!this._scrollHandler&&this.isOpen()){const t=this;this._scrollHandler=function(){if(t.isOpen()&&t._popover){const e=t._popover.querySelector(".popover-content");e&&t._updatePosition(e)}},window.addEventListener("scroll",this._scrollHandler,!0)}if(!this._resizeHandler&&this.isOpen()){const t=this;this._resizeHandler=function(){if(t.isOpen()&&t._popover){const e=t._popover.querySelector(".popover-content");e&&t._updatePosition(e)}},window.addEventListener("resize",this._resizeHandler)}}_removePositionListeners(){this._scrollHandler&&(window.removeEventListener("scroll",this._scrollHandler,!0),this._scrollHandler=null),this._resizeHandler&&(window.removeEventListener("resize",this._resizeHandler),this._resizeHandler=null)}_closeOtherPopovers(){Array.from(document.querySelectorAll("mint-popover[open]")).forEach(e=>{if(e!==this){const i=e;typeof i.close=="function"?i.close():e.removeAttribute("open")}})}}customElements.get("mint-popover")||customElements.define("mint-popover",U);class J extends HTMLElement{constructor(){super(),this._checkbox=null,this._checked=!1,this._clickHandler=null,this._changeHandler=null,this._mousedownHandler=null,this._mouseupHandler=null,this._mouseleaveHandler=null,this._touchstartHandler=null,this._touchendHandler=null,this._focusHandler=null,this._blurHandler=null}static get observedAttributes(){return["checked","disabled","label","info","id","name","value","error","error-message","loading"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline","inline-flex","items-start","gap-2");const t=this.getAttribute("checked");this._checked=t!==null&&t!=="false",this.render()}disconnectedCallback(){this.removeEventListeners()}isLoading(){return this.hasAttribute("loading")}attributeChangedCallback(t,e,i){if(t==="checked"&&(this._checked=i!==null&&i!=="false",this._checkbox&&(this._checkbox.checked=this._checked)),e!==i){if(t==="error"||t==="error-message"){this._renderErrorState();return}if(t==="loading"){this.render();return}this.render(),t==="checked"&&this._checkbox&&this.updateVisualState()}}get checked(){return this._checked}set checked(t){t?this.setAttribute("checked",""):this.removeAttribute("checked"),this._checked=!!t,this._checkbox&&(this._checkbox.checked=this._checked),this.updateVisualState()}isDisabled(){return this.hasAttribute("disabled")}getLabel(){return this.getAttribute("label")||""}getInfo(){return this.getAttribute("info")||""}getId(){return this.getAttribute("id")||""}getName(){return this.getAttribute("name")||""}getValue(){return this.getAttribute("value")||""}hasError(){return this.hasAttribute("error")}getErrorMessage(){return this.getAttribute("error-message")||""}getCheckboxClasses(){const t=this.hasError(),e=["relative","inline-flex","items-center","justify-center","flex-shrink-0","w-5","h-5","rounded","border-2","transition-all","duration-200","outline-none","focus:outline-none","focus-visible:ring-2","focus-visible:ring-offset-1",t?"focus-visible:ring-red-400 dark:focus-visible:ring-red-500":"focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500","cursor-pointer","disabled:opacity-40","disabled:cursor-not-allowed"],i=this._checked?["bg-slate-800","dark:bg-slate-600",t?"border-red-300 dark:border-red-300":"border-slate-800 dark:border-slate-600"]:["bg-white","dark:bg-gray-700",t?"border-red-300 dark:border-red-300":"border-gray-300 dark:border-gray-500"];return[...e,...i].join(" ")}render(){const t=this.isLoading(),e=this.getLabel(),i=this.getInfo(),s=this.isDisabled();let n=this.querySelector(".mint-checkbox-container");n||(n=document.createElement("div"),n.className="mint-checkbox-container relative inline-flex items-start gap-2",this.insertBefore(n,this.firstChild));let r=this.querySelector(".mint-checkbox-wrapper");r?r.parentElement!==n&&n.appendChild(r):(r=document.createElement("div"),r.className="mint-checkbox-wrapper",n.appendChild(r)),this._checkbox?this._checkbox.parentElement!==r&&r.appendChild(this._checkbox):(this._checkbox=document.createElement("input"),this._checkbox.type="checkbox",r.appendChild(this._checkbox),this.setupEventListeners()),this._checkbox.className="absolute inset-0 w-full h-full opacity-0 cursor-pointer",this._checkbox.style.cssText="position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; z-index: 10; pointer-events: auto; margin: 0; padding: 0;",this._checkbox.checked=this._checked,this._checkbox.disabled=s,this._changeHandler||this.setupEventListeners();const a=this.getId();a?this._checkbox.id=a:this._checkbox.removeAttribute("id");const o=this.getName();o?this._checkbox.name=o:this._checkbox.removeAttribute("name");const l=this.getValue();l?this._checkbox.value=l:this._checkbox.removeAttribute("value"),e?this._checkbox.setAttribute("aria-label",e):this._checkbox.removeAttribute("aria-label"),r.className=`mint-checkbox-wrapper ${this.getCheckboxClasses()}`,r.style.cursor="pointer",r.style.pointerEvents="auto",this._checkbox.style.pointerEvents="auto";const c=r;c._wrapperClickHandler||(c._wrapperClickHandler=u=>{u.target===r&&!s&&(u.preventDefault(),u.stopPropagation(),this.toggle())},r.addEventListener("click",c._wrapperClickHandler));let h=r.querySelector("mint-icon");h||(h=document.createElement("mint-icon"),h.setAttribute("name","check"),h.className="w-3.5 h-3.5 text-white pointer-events-none absolute inset-0 m-auto",h.style.transition="opacity 200ms ease-out, transform 200ms ease-out",h.style.zIndex="1",r.appendChild(h)),this.updateVisualState();let p=this.querySelector(".mint-checkbox-label-container");const d=this.querySelector(".mint-checkbox-container");if(e||i){p?d&&p.parentElement!==d&&d.appendChild(p):(p=document.createElement("div"),p.className="mint-checkbox-label-container flex flex-col gap-0.5 flex-1",d?d.appendChild(p):this.appendChild(p));let u=p.querySelector(".mint-checkbox-label");e?(u||(u=document.createElement("span"),u.className="mint-checkbox-label text-sm font-medium text-gray-900 dark:text-gray-100 cursor-pointer select-none",p.insertBefore(u,p.firstChild)),u.textContent=e,s?u.classList.add("opacity-40"):u.classList.remove("opacity-40")):u&&u.remove();let f=p.querySelector(".mint-checkbox-info");if(i?(f||(f=document.createElement("span"),f.className="mint-checkbox-info text-xs text-gray-500 dark:text-gray-400 cursor-pointer select-none",p.appendChild(f)),f.textContent=i,s?f.classList.add("opacity-40"):f.classList.remove("opacity-40")):f&&f.remove(),s)p.style.cursor="default",p._clickHandler&&(p.removeEventListener("click",p._clickHandler),p._clickHandler=null);else{p.style.cursor="pointer";const m=p._clickHandler;m&&p.removeEventListener("click",m),p._clickHandler=g=>{this._checkbox&&(g.target===this._checkbox||this._checkbox.contains(g.target)||g.composedPath().includes(this._checkbox))||this.toggle()},p.addEventListener("click",p._clickHandler)}}else p&&p.remove();this._renderErrorState(),this._renderSkeleton(t)}setupEventListeners(){this.removeEventListeners(),this._checkbox&&(this._changeHandler=t=>{t.stopPropagation(),this._checked=this._checkbox.checked,this._checked?this.hasAttribute("checked")||this.setAttribute("checked",""):this.hasAttribute("checked")&&this.removeAttribute("checked"),this.updateVisualState();const e=new CustomEvent("change",{detail:{checked:this._checked,value:this.getValue()},bubbles:!0,cancelable:!0});this.dispatchEvent(e)},this._checkbox.addEventListener("change",this._changeHandler),this._mousedownHandler=t=>{t.stopPropagation();const e=this.querySelector(".mint-checkbox-wrapper");e&&!this.isDisabled()&&(e.classList.add("mint-checkbox-active"),this._checked?(e.style.backgroundColor="rgb(15 23 42)",e.style.boxShadow="inset 0 2px 4px rgba(0, 0, 0, 0.3)"):(e.style.backgroundColor="rgb(243 244 246)",e.style.boxShadow="inset 0 2px 4px rgba(0, 0, 0, 0.1)"),document.documentElement.classList.contains("dark")&&(this._checked?e.style.backgroundColor="rgb(51 65 85)":e.style.backgroundColor="rgb(31 41 55)"))},this._mouseupHandler=t=>{t.stopPropagation();const e=this.querySelector(".mint-checkbox-wrapper");e&&(e.classList.remove("mint-checkbox-active"),e.style.backgroundColor="",e.style.boxShadow="")},this._mouseleaveHandler=t=>{const e=this.querySelector(".mint-checkbox-wrapper");e&&(e.classList.remove("mint-checkbox-active"),e.style.backgroundColor="",e.style.boxShadow="")},this._checkbox.addEventListener("mousedown",this._mousedownHandler),this._checkbox.addEventListener("mouseup",this._mouseupHandler),this._checkbox.addEventListener("mouseleave",this._mouseleaveHandler),this._focusHandler=t=>{const e=this.querySelector(".mint-checkbox-wrapper");e&&this._checkbox&&requestAnimationFrame(()=>{this._checkbox&&this._checkbox.matches(":focus-visible")&&(e==null||e.classList.add("ring-2","ring-offset-1","ring-gray-400","dark:ring-gray-500"))})},this._blurHandler=()=>{const t=this.querySelector(".mint-checkbox-wrapper");t&&t.classList.remove("ring-2","ring-offset-1","ring-gray-400","dark:ring-gray-500")},this._checkbox.addEventListener("focus",this._focusHandler),this._checkbox.addEventListener("blur",this._blurHandler),this._touchstartHandler=t=>{t.stopPropagation();const e=this.querySelector(".mint-checkbox-wrapper");e&&!this.isDisabled()&&(e.classList.add("mint-checkbox-active"),this._checked?(e.style.backgroundColor="rgb(15 23 42)",e.style.boxShadow="inset 0 2px 4px rgba(0, 0, 0, 0.3)"):(e.style.backgroundColor="rgb(243 244 246)",e.style.boxShadow="inset 0 2px 4px rgba(0, 0, 0, 0.1)"),document.documentElement.classList.contains("dark")&&(this._checked?e.style.backgroundColor="rgb(51 65 85)":e.style.backgroundColor="rgb(31 41 55)"))},this._touchendHandler=t=>{t.stopPropagation();const e=this.querySelector(".mint-checkbox-wrapper");e&&(e.classList.remove("mint-checkbox-active"),e.style.backgroundColor="",e.style.boxShadow="")},this._checkbox.addEventListener("touchstart",this._touchstartHandler),this._checkbox.addEventListener("touchend",this._touchendHandler))}removeEventListeners(){this._checkbox&&(this._changeHandler&&(this._checkbox.removeEventListener("change",this._changeHandler),this._changeHandler=null),this._mousedownHandler&&(this._checkbox.removeEventListener("mousedown",this._mousedownHandler),this._mousedownHandler=null),this._mouseupHandler&&(this._checkbox.removeEventListener("mouseup",this._mouseupHandler),this._mouseupHandler=null),this._mouseleaveHandler&&(this._checkbox.removeEventListener("mouseleave",this._mouseleaveHandler),this._mouseleaveHandler=null),this._touchstartHandler&&(this._checkbox.removeEventListener("touchstart",this._touchstartHandler),this._touchstartHandler=null),this._touchendHandler&&(this._checkbox.removeEventListener("touchend",this._touchendHandler),this._touchendHandler=null),this._focusHandler&&(this._checkbox.removeEventListener("focus",this._focusHandler),this._focusHandler=null),this._blurHandler&&(this._checkbox.removeEventListener("blur",this._blurHandler),this._blurHandler=null));const t=this.querySelector(".mint-checkbox-wrapper");if(t){const e=t;e._wrapperClickHandler&&(t.removeEventListener("click",e._wrapperClickHandler),e._wrapperClickHandler=null)}}updateVisualState(){const t=this.querySelector(".mint-checkbox-wrapper"),e=t==null?void 0:t.querySelector("mint-icon");e&&(e.style.opacity=this._checked?"1":"0",e.style.transform=this._checked?"scale(1)":"scale(0.8)"),t&&(t.className=`mint-checkbox-wrapper ${this.getCheckboxClasses()}`,t.classList.contains("mint-checkbox-active")||(t.style.backgroundColor="",t.style.boxShadow=""))}toggle(){if(this._checkbox&&!this.isDisabled()){this._checkbox.checked=!this._checked,this._checked=this._checkbox.checked,this._checked?this.hasAttribute("checked")||this.setAttribute("checked",""):this.hasAttribute("checked")&&this.removeAttribute("checked"),this.updateVisualState();const t=new CustomEvent("change",{detail:{checked:this._checked},bubbles:!0,cancelable:!0});this.dispatchEvent(t)}}_renderSkeleton(t){let e=this.querySelector(".mint-checkbox-skeleton-container");const i=this.querySelector(".mint-checkbox-container"),s=this.querySelector(".mint-checkbox-wrapper"),n=this.querySelector(".mint-checkbox-label-container");if(t){e||(e=document.createElement("div"),e.className="mint-checkbox-skeleton-container absolute inset-0 z-10 pointer-events-none flex items-center gap-2",i?i.appendChild(e):(this.style.position="relative",this.appendChild(e)));let r=e.querySelector(".mint-checkbox-skeleton-box");if(r||(r=document.createElement("div"),r.className="mint-checkbox-skeleton-box flex-shrink-0 w-5 h-5 rounded bg-gray-200 dark:bg-gray-700 animate-pulse",e.appendChild(r)),n){let a=e.querySelector(".mint-checkbox-skeleton-label");a||(a=document.createElement("div"),a.className="mint-checkbox-skeleton-label h-4 w-24 rounded bg-gray-200 dark:bg-gray-700 animate-pulse",e.appendChild(a))}e.style.display="flex",s&&(s.style.visibility="hidden",s.style.pointerEvents="none"),n&&(n.style.visibility="hidden",n.style.pointerEvents="none")}else e&&(e.style.display="none"),s&&(s.style.visibility="visible",s.style.pointerEvents="auto"),n&&(n.style.visibility="visible",n.style.pointerEvents="auto")}_renderErrorState(){const t=this.hasError(),e=this.getErrorMessage();let i=this.querySelector(".mint-checkbox-label-container");!i&&t&&e&&(i=document.createElement("div"),i.className="mint-checkbox-label-container flex flex-col gap-0.5 flex-1",this.appendChild(i));let s=this.querySelector(".mint-checkbox-error");t&&e?(s?(s.classList.add("block","w-full"),s.style.display="block",(i&&s.parentElement!==i||i&&s.parentElement===i)&&i.appendChild(s)):(s=document.createElement("div"),s.className="mint-checkbox-error text-xs text-red-600 dark:text-red-400 block w-full",s.style.display="block",i?i.appendChild(s):this.appendChild(s)),s.textContent=e):s&&s.remove();const n=this.querySelector(".mint-checkbox-wrapper");n&&(n.className=`mint-checkbox-wrapper ${this.getCheckboxClasses()}`)}}customElements.get("mint-checkbox")||customElements.define("mint-checkbox",J);class ht extends HTMLElement{constructor(){super(),this._radio=null,this._checked=!1,this._changeHandler=null,this._clickHandler=null,this._focusHandler=null,this._blurHandler=null,this._keydownHandler=null}static get observedAttributes(){return["value","checked","disabled","loading"]}connectedCallback(){this.classList.add("inline-flex","items-center","gap-2","cursor-pointer","select-none");const t=this.getAttribute("checked");this._checked=t!==null&&t!=="false",this.render(),this._setupClickHandler()}disconnectedCallback(){this._clickHandler&&(this.removeEventListener("click",this._clickHandler),this._clickHandler=null),this._radio&&(this._changeHandler&&(this._radio.removeEventListener("change",this._changeHandler),this._changeHandler=null),this._focusHandler&&(this._radio.removeEventListener("focus",this._focusHandler),this._focusHandler=null),this._blurHandler&&(this._radio.removeEventListener("blur",this._blurHandler),this._blurHandler=null),this._keydownHandler&&(this._radio.removeEventListener("keydown",this._keydownHandler),this._keydownHandler=null))}isLoading(){return this.hasAttribute("loading")}attributeChangedCallback(t,e,i){if(t==="checked"&&(this._checked=i!==null&&i!=="false",this._radio&&(this._radio.checked=this._checked),this._updateVisualState()),e!==i){if(t==="loading"){this.render();return}this.render()}}get checked(){return this._checked}set checked(t){this._checked=!!t,t?this.setAttribute("checked",""):this.removeAttribute("checked"),this._radio&&(this._radio.checked=this._checked),this.isConnected?requestAnimationFrame(()=>{this._updateVisualState()}):this._updateVisualState()}getValue(){return this.getAttribute("value")||""}isDisabled(){const t=this.closest("mint-choice");return this.hasAttribute("disabled")||((t==null?void 0:t.hasAttribute("disabled"))??!1)}_setupClickHandler(){this._clickHandler||(this._clickHandler=t=>{t.target!==this._radio&&(this.isDisabled()||this._radio&&(this._radio.click(),requestAnimationFrame(()=>{if(this._radio&&this._radio.checked!==this._checked){this._checked=this._radio.checked,this._checked?this.setAttribute("checked",""):this.removeAttribute("checked"),this._updateVisualState(),this._updateGroupState();const e=this.closest("mint-choice");e&&e.dispatchEvent(new CustomEvent("choice-change",{detail:{checked:this._checked,value:this.getValue()},bubbles:!0,cancelable:!0}))}})))},this.addEventListener("click",this._clickHandler))}render(){var u;const t=this.isLoading(),e=this.isDisabled(),i=this.getValue(),s=this.closest("mint-choice"),n=(s==null?void 0:s.getAttribute("name"))||"";let r="";const a=this.querySelector(".mint-choice-option-label");a?r=((u=a.textContent)==null?void 0:u.trim())||"":Array.from(this.childNodes).forEach(f=>{var m;if(f.nodeType===Node.TEXT_NODE){const g=(m=f.textContent)==null?void 0:m.trim();g&&(r+=g)}});const o=this.querySelectorAll(".mint-choice-option-wrapper");let l=null;if(o.length>0&&(this._radio&&(l=Array.from(o).find(f=>f.contains(this._radio))),l||(l=o[0]),o.forEach((f,m)=>{f!==l&&f.remove()})),l||(l=document.createElement("div"),l.className="mint-choice-option-wrapper",l.style.position="relative",this.insertBefore(l,this.firstChild)),l.className=`mint-choice-option-wrapper ${this._getWrapperClasses()}`,l.style.position="relative",this.querySelectorAll('input[type="radio"]').forEach(f=>{f!==this._radio&&f.remove()}),this._radio)this._radio.parentElement!==l&&l.appendChild(this._radio),this._radio&&this._changeHandler&&(this._radio.removeEventListener("change",this._changeHandler),this._radio.addEventListener("change",this._changeHandler)),this._radio&&(this._focusHandler||(this._focusHandler=f=>{const m=this.querySelector(".mint-choice-option-wrapper");m&&!this.isDisabled()&&m.classList.add("ring-2","ring-offset-1","ring-gray-400","dark:ring-gray-500")}),this._blurHandler||(this._blurHandler=()=>{const f=this.querySelector(".mint-choice-option-wrapper");f&&f.classList.remove("ring-2","ring-offset-1","ring-gray-400","dark:ring-gray-500")}),this._keydownHandler||(this._keydownHandler=f=>{this.isDisabled()||(f.key==="ArrowDown"||f.key==="ArrowRight"?(f.preventDefault(),this._focusNextOption()):(f.key==="ArrowUp"||f.key==="ArrowLeft")&&(f.preventDefault(),this._focusPreviousOption()))}),this._radio.removeEventListener("focus",this._focusHandler),this._radio.removeEventListener("blur",this._blurHandler),this._radio.removeEventListener("keydown",this._keydownHandler),this._radio.addEventListener("focus",this._focusHandler),this._radio.addEventListener("blur",this._blurHandler),this._radio.addEventListener("keydown",this._keydownHandler));else{this._radio=document.createElement("input"),this._radio.type="radio",this._radio.className="sr-only",this._radio.style.position="absolute",this._radio.style.width="1px",this._radio.style.height="1px",this._radio.style.padding="0",this._radio.style.margin="-1px",this._radio.style.overflow="hidden",this._radio.style.clip="rect(0, 0, 0, 0)",this._radio.style.whiteSpace="nowrap",this._radio.style.border="0",l.appendChild(this._radio),this._changeHandler=m=>{const g=this._checked;this._checked=this._radio.checked,this._checked?this.setAttribute("checked",""):this.removeAttribute("checked"),this._updateVisualState(),this._updateGroupState();const _=this.closest("mint-choice");g!==this._checked&&_&&setTimeout(()=>{_.dispatchEvent(new CustomEvent("choice-change",{detail:{checked:this._checked,value:this.getValue()},bubbles:!0,cancelable:!0}))},0)},this._radio.addEventListener("change",this._changeHandler);const f=()=>{this._radio&&this._radio.checked!==this._checked&&(this._checked=this._radio.checked,this._checked?this.setAttribute("checked",""):this.removeAttribute("checked"),this._updateVisualState(),this._updateGroupState())};this._radio.addEventListener("click",f),this._focusHandler=m=>{const g=this.querySelector(".mint-choice-option-wrapper");g&&!this.isDisabled()&&g.classList.add("ring-2","ring-offset-1","ring-gray-400","dark:ring-gray-500")},this._radio.addEventListener("focus",this._focusHandler),this._blurHandler=()=>{const m=this.querySelector(".mint-choice-option-wrapper");m&&m.classList.remove("ring-2","ring-offset-1","ring-gray-400","dark:ring-gray-500")},this._radio.addEventListener("blur",this._blurHandler),this._keydownHandler=m=>{this.isDisabled()||(m.key==="ArrowDown"||m.key==="ArrowRight"?(m.preventDefault(),this._focusNextOption()):(m.key==="ArrowUp"||m.key==="ArrowLeft")&&(m.preventDefault(),this._focusPreviousOption()))},this._radio.addEventListener("keydown",this._keydownHandler)}this._radio.name=n,this._radio.value=i,this._radio.checked!==this._checked?(this._checked=this._radio.checked,this._checked?this.hasAttribute("checked")||this.setAttribute("checked",""):this.hasAttribute("checked")&&this.removeAttribute("checked")):this._radio.checked=this._checked,this._radio.disabled=e,e?this._radio.setAttribute("tabindex","-1"):this._radio.removeAttribute("tabindex"),r?this._radio.setAttribute("aria-label",r):this._radio.removeAttribute("aria-label"),l.querySelectorAll(".mint-choice-option-indicator").forEach((f,m)=>{m>0&&f.remove()});let p=l.querySelector(".mint-choice-option-indicator");p||(p=document.createElement("div"),p.className="mint-choice-option-indicator",l.appendChild(p)),p.className="mint-choice-option-indicator w-2 h-2 rounded-full bg-white transition-all duration-200 pointer-events-none",p.style.position="absolute",p.style.top="50%",p.style.left="50%",p.style.transform=this._checked?"translate(-50%, -50%) scale(1)":"translate(-50%, -50%) scale(0)",p.style.opacity=this._checked?"1":"0",this._updateVisualState(),this._renderSkeleton(t);let d=this.querySelector(".mint-choice-option-label");r&&(d||(d=document.createElement("span"),d.className="mint-choice-option-label",this.appendChild(d),Array.from(this.childNodes).forEach(f=>{var m;f.nodeType===Node.TEXT_NODE&&((m=f.textContent)!=null&&m.trim())&&(f.textContent="")})),d.className=`mint-choice-option-label text-sm text-gray-900 dark:text-gray-100 ${e?"opacity-40":""}`,d.textContent=r),e?(this.classList.add("cursor-not-allowed"),this.classList.remove("cursor-pointer")):(this.classList.add("cursor-pointer"),this.classList.remove("cursor-not-allowed")),this._updateVisualState()}_getWrapperClasses(){const t=this.isDisabled(),e=["inline-flex","items-center","justify-center","w-5","h-5","rounded-full","border-2","transition-all","duration-200","flex-shrink-0"];return t&&e.push("opacity-40","cursor-not-allowed"),this._checked?e.push("bg-slate-800","dark:bg-slate-600","border-slate-800","dark:border-slate-600"):e.push("bg-white","dark:bg-gray-700","border-gray-300","dark:border-gray-500"),e.join(" ")}_updateVisualState(){const t=this.querySelector(".mint-choice-option-wrapper");t&&(t.className=`mint-choice-option-wrapper ${this._getWrapperClasses()}`);const e=this.querySelector(".mint-choice-option-indicator");e&&(e.style.opacity=this._checked?"1":"0",e.style.transform=this._checked?"translate(-50%, -50%) scale(1)":"translate(-50%, -50%) scale(0)")}_renderSkeleton(t){let e=this.querySelector(".mint-choice-option-skeleton-container");const i=this.querySelector(".mint-choice-option-wrapper");if(t){e||(e=document.createElement("div"),e.className="mint-choice-option-skeleton-container absolute inset-0 z-10 pointer-events-none flex items-center gap-2",i?(i.classList.contains("relative")||i.classList.add("relative"),i.appendChild(e)):(this.style.position="relative",this.appendChild(e)));let s=e.querySelector(".mint-choice-option-skeleton-radio");if(s||(s=document.createElement("div"),s.className="mint-choice-option-skeleton-radio flex-shrink-0 w-5 h-5 rounded-full bg-gray-200 dark:bg-gray-700 animate-pulse",e.appendChild(s)),e.style.display="flex",i){const n=i.querySelector('input[type="radio"]'),r=i.querySelector(".mint-choice-option-indicator");n&&(n.style.visibility="hidden"),r&&(r.style.visibility="hidden"),i.style.pointerEvents="none"}}else{if(e&&(e.style.display="none"),i){const n=i.querySelector('input[type="radio"]'),r=i.querySelector(".mint-choice-option-indicator");n&&(n.style.visibility="visible"),r&&(r.style.visibility="visible"),i.style.pointerEvents="auto"}const s=this.querySelector(".mint-choice-option-label");s&&!(i!=null&&i.contains(s))&&(s.style.visibility="visible",s.style.pointerEvents="auto")}}_updateGroupState(){var e;if(!((e=this._radio)!=null&&e.name))return;document.querySelectorAll(`input[type="radio"][name="${this._radio.name}"]`).forEach(i=>{if(i===this._radio)return;const s=i.closest("mint-choice-option");s&&s!==this&&(s._checked=i.checked,i.checked?s.setAttribute("checked",""):s.removeAttribute("checked"),s._updateVisualState())})}_focusNextOption(){var s;if(!((s=this._radio)!=null&&s.name))return;const t=Array.from(document.querySelectorAll(`input[type="radio"][name="${this._radio.name}"]`)).filter(n=>!n.disabled),e=t.indexOf(this._radio);let i=null;if(e>=0&&e<t.length-1?i=t[e+1]:t.length>0&&(i=t[0]),i){const n=i.closest("mint-choice-option");if(i.checked=!0,n){const r=n._checked;if(n._checked=!0,n.setAttribute("checked",""),n._changeHandler){const o=new Event("change",{bubbles:!0});n._changeHandler.call(n,o)}else n._updateVisualState(),n._updateGroupState();const a=n.closest("mint-choice");a&&!r&&setTimeout(()=>{a.dispatchEvent(new CustomEvent("choice-change",{detail:{checked:!0,value:n.getValue()},bubbles:!0,cancelable:!0}))},0)}i.focus(),i.dispatchEvent(new Event("change",{bubbles:!0}))}}_focusPreviousOption(){var s;if(!((s=this._radio)!=null&&s.name))return;const t=Array.from(document.querySelectorAll(`input[type="radio"][name="${this._radio.name}"]`)).filter(n=>!n.disabled),e=t.indexOf(this._radio);let i=null;if(e>0?i=t[e-1]:t.length>0&&(i=t[t.length-1]),i){const n=i.closest("mint-choice-option");if(i.checked=!0,n){const r=n._checked;if(n._checked=!0,n.setAttribute("checked",""),n._changeHandler){const o=new Event("change",{bubbles:!0});n._changeHandler.call(n,o)}else n._updateVisualState(),n._updateGroupState();const a=n.closest("mint-choice");a&&!r&&setTimeout(()=>{a.dispatchEvent(new CustomEvent("choice-change",{detail:{checked:!0,value:n.getValue()},bubbles:!0,cancelable:!0}))},0)}i.focus(),i.dispatchEvent(new Event("change",{bubbles:!0}))}}}customElements.get("mint-choice-option")||customElements.define("mint-choice-option",ht);class G extends HTMLElement{constructor(){super(),this._optionsContainer=null}static get observedAttributes(){return["label","name","info","error","error-message","id","disabled","required","loading"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","block","w-full"),this.render()}disconnectedCallback(){}isLoading(){return this.hasAttribute("loading")}attributeChangedCallback(t,e,i){e!==i&&(t==="error"||t==="error-message"?this._renderErrorState():t==="loading"?(this.render(),this.querySelectorAll("mint-choice-option").forEach(n=>{this.isLoading()?n.setAttribute("loading",""):n.removeAttribute("loading")})):(this.render(),t==="name"&&this.querySelectorAll("mint-choice-option").forEach(n=>{typeof n.render=="function"&&n.render()})))}getLabel(){return this.getAttribute("label")||""}getInfo(){return this.getAttribute("info")||""}getName(){return this.getAttribute("name")||""}hasError(){return this.hasAttribute("error")}getErrorMessage(){return this.getAttribute("error-message")||""}getId(){return this.getAttribute("id")||""}isDisabled(){return this.hasAttribute("disabled")}isRequired(){return this.hasAttribute("required")}getValue(){const t=this.querySelector('input[type="radio"]:checked');return(t==null?void 0:t.value)||""}setValue(t){const e=this.querySelectorAll("mint-choice-option");e.forEach(i=>{if((i.getAttribute("value")||"")===t){const n=i;n.checked=!0;const r=i.querySelector('input[type="radio"]');r&&(r.checked=!0,r.dispatchEvent(new Event("change",{bubbles:!0})))}else{const n=i;n.checked=!1;const r=i.querySelector('input[type="radio"]');r&&(r.checked=!1)}}),requestAnimationFrame(()=>{e.forEach(i=>{typeof i._updateVisualState=="function"&&i._updateVisualState();const s=i.querySelector('input[type="radio"]');if(s){const n=i;s.checked!==n.checked&&(s.checked=n.checked)}})})}render(){const t=this.isLoading(),e=this.getLabel(),i=this.getInfo(),s=this.getId()||`mint-choice-${Math.random().toString(36).substr(2,9)}`;this.getId()||this.setAttribute("id",s);const n=this.isDisabled();let r=this.querySelector(".mint-choice-label-container");if(e||i){r||(r=document.createElement("div"),r.className="mint-choice-label-container flex flex-col gap-0.5 mb-2",this.insertBefore(r,this.firstChild));let l=r.querySelector(".mint-choice-label");e?(l||(l=document.createElement("label"),l.className="mint-choice-label text-sm font-medium text-gray-900 dark:text-gray-100 select-none",r.insertBefore(l,r.firstChild)),l.textContent=e,l.setAttribute("for",s),n?l.classList.add("opacity-40"):l.classList.remove("opacity-40")):l&&l.remove();let c=r.querySelector(".mint-choice-info");i?(c||(c=document.createElement("span"),c.className="mint-choice-info text-xs text-gray-500 dark:text-gray-400 select-none",r.appendChild(c)),c.textContent=i,n?c.classList.add("opacity-40"):c.classList.remove("opacity-40")):c&&c.remove()}else r&&r.remove();let a=this.querySelector(".mint-choice-options-wrapper");if(!a){a=document.createElement("div"),a.className="mint-choice-options-wrapper relative";const l=this.querySelector(".mint-choice-label-container");l&&l.parentElement===this?this.insertBefore(a,l.nextSibling):this.insertBefore(a,this.firstChild)}this._optionsContainer?this._optionsContainer.parentElement!==a&&a.appendChild(this._optionsContainer):(this._optionsContainer=document.createElement("div"),this._optionsContainer.className="mint-choice-options-container flex flex-col gap-3",a.appendChild(this._optionsContainer)),Array.from(this.children).filter(l=>l.tagName==="MINT-CHOICE-OPTION"&&l.parentElement!==this._optionsContainer).forEach(l=>{this._optionsContainer.appendChild(l)}),this._renderErrorState(),this._renderSkeleton(t)}_renderSkeleton(t){let e=this.querySelector(".mint-choice-skeleton-container");const i=this.querySelector(".mint-choice-options-wrapper"),s=this.querySelector(".mint-choice-options-container");if(t){if(e||(e=document.createElement("div"),e.className="mint-choice-skeleton-container absolute inset-0 z-10 pointer-events-none flex flex-col gap-3",i?i.appendChild(e):(this.style.position="relative",this.appendChild(e))),e.querySelectorAll(".mint-choice-option-skeleton").length===0)for(let r=0;r<3;r++){const a=document.createElement("div");a.className="mint-choice-option-skeleton flex items-center gap-3";const o=document.createElement("div");o.className="flex-shrink-0 w-5 h-5 rounded-full bg-gray-200 dark:bg-gray-700 animate-pulse",a.appendChild(o);const l=document.createElement("div");l.className="h-4 w-20 rounded bg-gray-200 dark:bg-gray-700 animate-pulse",a.appendChild(l),e.appendChild(a)}e.style.display="flex",s&&(s.style.opacity="0",s.style.pointerEvents="none")}else e&&(e.style.display="none"),s&&(s.style.opacity="1",s.style.pointerEvents="auto")}_renderErrorState(){const t=this.hasError(),e=this.getErrorMessage();let i=this.querySelector(".mint-choice-error");t&&e?(i||(i=document.createElement("div"),i.className="mint-choice-error mt-1 text-xs text-red-600 dark:text-red-400",this.appendChild(i)),i.textContent=e):i&&i.remove()}}customElements.get("mint-choice")||customElements.define("mint-choice",G);class K extends HTMLElement{constructor(){super(),this._input=null,this._textarea=null,this._element=null,this._wrapper=null,this._icon=null,this._colorPicker=null,this._colorTextInput=null,this._colorContainer=null,this._colorPickerWrapper=null,this._numberSpinnerContainer=null,this._numberIncrementButton=null,this._numberDecrementButton=null,this._focusHandler=null,this._blurHandler=null,this._clickHandler=null,this._clickOutsideHandler=null}static get observedAttributes(){return["type","placeholder","value","disabled","id","name","required","readonly","rows","icon","label","info","error","error-message","loading"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline","inline-block"),this.render()}disconnectedCallback(){this.removeEventListeners()}attributeChangedCallback(t,e,i){if(e!==i){if(t==="error"||t==="error-message"){this._renderErrorState(),this._element&&(this._element.className=this.getInputClasses()),this._colorTextInput&&(this._colorTextInput.className=this.getInputClasses());return}if(t==="loading"){this.render();return}this.render()}}getType(){return this.getAttribute("type")||"text"}getRows(){const t=this.getAttribute("rows");return t?parseInt(t,10):3}_getNormalizedType(){const t=this.getType();return t==="datetime"?"datetime-local":t==="money"?"text":t==="textarea"?"textarea":t}_isTextarea(){return this.getType()==="textarea"}_isMoney(){return this.getType()==="money"}_isColor(){return this.getType()==="color"}_isNumber(){return this.getType()==="number"}getPlaceholder(){return this.getAttribute("placeholder")||""}getValue(){var t,e,i;return this._isColor()?((t=this._colorPicker)==null?void 0:t.value)||((e=this._colorTextInput)==null?void 0:e.value)||this.getAttribute("value")||"#000000":((i=this._element)==null?void 0:i.value)||this.getAttribute("value")||""}set value(t){this._isColor()?(this._colorPicker&&(this._colorPicker.value=t||"#000000"),this._colorTextInput&&(this._colorTextInput.value=t||"#000000")):this._element&&(this._element.value=t),t?this.setAttribute("value",t):this.removeAttribute("value")}get value(){return this.getValue()}isDisabled(){return this.hasAttribute("disabled")}isReadonly(){return this.hasAttribute("readonly")}isRequired(){return this.hasAttribute("required")}hasError(){return this.hasAttribute("error")}getErrorMessage(){return this.getAttribute("error-message")||""}getId(){return this.getAttribute("id")||""}getName(){return this.getAttribute("name")||""}getIcon(){return this.getAttribute("icon")||""}getLabel(){return this.getAttribute("label")||""}getInfo(){return this.getAttribute("info")||""}getInputClasses(){const t=this._isTextarea(),e=!!this.getIcon(),i=this._isColor(),s=this._isNumber(),n=this.hasError(),r=["w-full",e||i?"pl-10":"px-3.5",e||i?"pr-3.5":s?"pr-10":"",t?"py-2":"py-1.5",t?"min-h-[6rem]":"min-h-[2rem]","text-sm","font-medium","rounded-lg","box-border","bg-white","dark:bg-gray-700","text-gray-900","dark:text-white",t?"transition-colors transition-opacity":"transition-all","duration-200","outline-none","focus:outline-none","disabled:opacity-40","disabled:cursor-not-allowed","readonly:cursor-default",t?"resize-y":"",s?"[appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none":""],a=["border-2",n?"border-red-300 dark:border-red-300":"border-gray-200 dark:border-gray-600"],o=["focus-visible:ring-2","focus-visible:ring-offset-1",n?"focus-visible:ring-red-400 dark:focus-visible:ring-red-500":"focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500"];return[...r,...a,...o].filter(Boolean).join(" ")}isLoading(){return this.hasAttribute("loading")}render(){var b,x,y,E;this.getType();const t=this._getNormalizedType(),e=this._isTextarea(),i=this._isMoney(),s=this._isColor(),n=this.getPlaceholder(),r=this.isDisabled(),a=this.isReadonly(),o=this.isRequired(),l=this.getId(),c=this.getName(),h=this.getAttribute("value")||(s?"#000000":""),p=this.getRows(),d=this.getIcon(),u=this.getLabel(),f=this.getInfo(),m=this.isLoading();if(this._renderSkeleton(m),s){this._input&&(this._input.remove(),this._input=null),this._textarea&&(this._textarea.remove(),this._textarea=null),this._wrapper||(this._wrapper=document.createElement("div"),this._wrapper.className="relative w-full",this.appendChild(this._wrapper)),this._colorContainer&&(this._colorContainer.remove(),this._colorContainer=null),this._colorPickerWrapper&&!s&&(this._colorPickerWrapper.remove(),this._colorPickerWrapper=null),this._colorPickerWrapper||(this._colorPickerWrapper=document.createElement("div"),this._colorPickerWrapper.className="mint-color-picker-wrapper absolute left-[.65rem] top-1/2 -translate-y-1/2 w-6 h-6 rounded cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500",this._colorPickerWrapper.style.backgroundColor=h||"#000000",this._wrapper.appendChild(this._colorPickerWrapper),this._colorPicker=document.createElement("input"),this._colorPicker.type="color",this._colorPicker.className="absolute inset-0 w-full h-full opacity-0 cursor-pointer",this._colorPicker.style.cssText="position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; z-index: 10; pointer-events: auto; margin: 0; padding: 0; border: none;",this._colorPickerWrapper.appendChild(this._colorPicker),this._focusHandler=k=>{this._colorPickerWrapper&&this._colorPicker&&this._colorPicker.matches(":focus-visible")&&requestAnimationFrame(()=>{var w;this._colorPicker&&this._colorPicker.matches(":focus-visible")&&((w=this._colorPickerWrapper)==null||w.classList.add("ring-2","ring-offset-1","ring-gray-400","dark:ring-gray-500"))})},this._blurHandler=()=>{this._colorPickerWrapper&&this._colorPickerWrapper.classList.remove("ring-2","ring-offset-1","ring-gray-400","dark:ring-gray-500")},this._colorPicker.addEventListener("focus",this._focusHandler),this._colorPicker.addEventListener("blur",this._blurHandler),this._colorPicker.addEventListener("input",()=>{var w;const k=((w=this._colorPicker)==null?void 0:w.value)||"#000000";this._colorPickerWrapper&&(this._colorPickerWrapper.style.backgroundColor=k),this._colorTextInput&&(this._colorTextInput.value=k),this.setAttribute("value",k),this.dispatchEvent(new CustomEvent("input",{detail:{value:k},bubbles:!0,cancelable:!0}))}),this._colorPicker.addEventListener("change",()=>{var w;const k=((w=this._colorPicker)==null?void 0:w.value)||"#000000";this._colorPickerWrapper&&(this._colorPickerWrapper.style.backgroundColor=k),this.setAttribute("value",k),this.dispatchEvent(new CustomEvent("change",{detail:{value:k},bubbles:!0,cancelable:!0}))})),this._colorTextInput||(this._colorTextInput=document.createElement("input"),this._colorTextInput.type="text",this._colorTextInput.className=this.getInputClasses(),this._colorTextInput.placeholder=n||"#000000",this._colorTextInput.pattern="^#[0-9A-Fa-f]{6}$",this._wrapper.appendChild(this._colorTextInput),this._colorTextInput.addEventListener("input",()=>{var w;const k=((w=this._colorTextInput)==null?void 0:w.value)||"";/^#[0-9A-Fa-f]{6}$/.test(k)&&(this._colorPicker&&(this._colorPicker.value=k),this.setAttribute("value",k),this.dispatchEvent(new CustomEvent("input",{detail:{value:k},bubbles:!0,cancelable:!0})))}),this._colorTextInput.addEventListener("blur",()=>{var w,A;const k=((w=this._colorTextInput)==null?void 0:w.value)||"";/^#[0-9A-Fa-f]{6}$/.test(k)?(this._colorPicker&&(this._colorPicker.value=k),this.setAttribute("value",k)):this._colorPicker&&this._colorTextInput&&(this._colorTextInput.value=this._colorPicker.value),this.dispatchEvent(new CustomEvent("change",{detail:{value:((A=this._colorPicker)==null?void 0:A.value)||"#000000"},bubbles:!0,cancelable:!0}))}));const v=h||"#000000";if(this._colorPicker&&this._colorPicker.value!==v&&(this._colorPicker.value=v),this._colorPickerWrapper&&(this._colorPickerWrapper.style.backgroundColor=v),this._colorTextInput&&this._colorTextInput.value!==v&&(this._colorTextInput.value=v),this._colorPicker&&(this._colorPicker.disabled=r),this._colorPickerWrapper&&(r?(this._colorPickerWrapper.classList.add("opacity-40","cursor-not-allowed"),this._colorPickerWrapper.classList.remove("cursor-pointer")):(this._colorPickerWrapper.classList.remove("opacity-40","cursor-not-allowed"),this._colorPickerWrapper.classList.add("cursor-pointer"))),this._colorTextInput&&(this._colorTextInput.disabled=r,this._colorTextInput.readOnly=a,this._colorTextInput.required=o),this._colorTextInput){const k=this._colorTextInput;l?k.id=l:k.removeAttribute("id"),c?k.name=c:k.removeAttribute("name"),k.setAttribute("aria-invalid",this.hasError()?"true":"false"),this._element=k}this._renderErrorState();return}if(this._wrapper||(this._wrapper=document.createElement("div"),this._wrapper.className="relative w-full",this.appendChild(this._wrapper)),this._colorContainer&&(this._colorContainer.remove(),this._colorContainer=null,this._colorPicker=null,this._colorTextInput=null),this._colorPickerWrapper&&!s&&(this._colorPickerWrapper.remove(),this._colorPickerWrapper=null,this._colorPicker=null,this._colorTextInput=null),d&&!e?this._icon?this._icon.setAttribute("name",d):(this._icon=document.createElement("mint-icon"),this._icon.setAttribute("name",d),this._icon.className="absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400 dark:text-gray-500 pointer-events-none",this._wrapper.appendChild(this._icon)):this._icon&&(this._icon.remove(),this._icon=null),this._isNumber()&&!e){if(!this._numberSpinnerContainer){this._numberSpinnerContainer=document.createElement("div"),this._numberSpinnerContainer.className="absolute right-1 top-1/2 -translate-y-1/2 flex flex-col h-8 pointer-events-none",this._wrapper.appendChild(this._numberSpinnerContainer),this._numberIncrementButton=document.createElement("button"),this._numberIncrementButton.type="button",this._numberIncrementButton.className="flex items-center justify-center w-5 h-4 text-gray-400 dark:text-gray-500 hover:text-gray-600 dark:hover:text-gray-300 disabled:opacity-40 disabled:cursor-not-allowed transition-colors pointer-events-auto bg-gray-100 dark:bg-gray-600 active:bg-gray-200 dark:active:bg-gray-500 rounded";const v=document.createElement("mint-icon");v.setAttribute("name","caret-up"),v.className="w-[1rem] h-[1rem]",this._numberIncrementButton.appendChild(v),this._numberSpinnerContainer.appendChild(this._numberIncrementButton),this._numberDecrementButton=document.createElement("button"),this._numberDecrementButton.type="button",this._numberDecrementButton.className="flex items-center justify-center w-5 h-4 text-gray-400 dark:text-gray-500 hover:text-gray-600 dark:hover:text-gray-300 disabled:opacity-40 disabled:cursor-not-allowed transition-colors pointer-events-auto bg-gray-100 dark:bg-gray-600 active:bg-gray-200 dark:active:bg-gray-500 rounded";const k=document.createElement("mint-icon");k.setAttribute("name","caret-down"),k.className="w-[1rem] h-[1rem]",this._numberDecrementButton.appendChild(k),this._numberSpinnerContainer.appendChild(this._numberDecrementButton),this._numberIncrementButton.addEventListener("click",w=>{if(w.preventDefault(),w.stopPropagation(),this._input&&!this._input.disabled&&!this._input.readOnly){const A=parseFloat(this._input.value)||0,I=parseFloat(this._input.step)||1,S=this._input.min?parseFloat(this._input.min):void 0,H=this._input.max?parseFloat(this._input.max):void 0;let L=A+I;H!==void 0&&L>H&&(L=H),S!==void 0&&L<S&&(L=S),this._input.value=L.toString(),this.setAttribute("value",L.toString()),this._input.dispatchEvent(new Event("input",{bubbles:!0})),this._input.dispatchEvent(new Event("change",{bubbles:!0}))}}),this._numberDecrementButton.addEventListener("click",w=>{if(w.preventDefault(),w.stopPropagation(),this._input&&!this._input.disabled&&!this._input.readOnly){const A=parseFloat(this._input.value)||0,I=parseFloat(this._input.step)||1,S=this._input.min?parseFloat(this._input.min):void 0,H=this._input.max?parseFloat(this._input.max):void 0;let L=A-I;S!==void 0&&L<S&&(L=S),H!==void 0&&L>H&&(L=H),this._input.value=L.toString(),this.setAttribute("value",L.toString()),this._input.dispatchEvent(new Event("input",{bubbles:!0})),this._input.dispatchEvent(new Event("change",{bubbles:!0}))}})}this._numberIncrementButton&&(this._numberIncrementButton.disabled=r||a),this._numberDecrementButton&&(this._numberDecrementButton.disabled=r||a)}else this._numberSpinnerContainer&&(this._numberSpinnerContainer.remove(),this._numberSpinnerContainer=null,this._numberIncrementButton=null,this._numberDecrementButton=null);if(e){if(this._input&&(this._input.remove(),this._input=null),this._textarea||(this._textarea=document.createElement("textarea"),this._wrapper.appendChild(this._textarea),this.setupEventListeners()),this._element=this._textarea,this._textarea.placeholder=n,this._textarea.disabled=r,this._textarea.readOnly=a,this._textarea.required=o,this._textarea.rows=p,this._textarea.setAttribute("aria-invalid",this.hasError()?"true":"false"),h!==this._textarea.value&&(this._textarea.value=h),l?this._textarea.id=l:this._textarea.removeAttribute("id"),c?this._textarea.name=c:this._textarea.removeAttribute("name"),this._textarea.className=this.getInputClasses(),this.firstChild&&this.firstChild!==this._wrapper&&this.firstChild.nodeType===Node.TEXT_NODE){const v=this.firstChild.textContent;v&&!this._textarea.value&&(this._textarea.value=v.trim()),this.removeChild(this.firstChild)}}else if(this._textarea&&(this._textarea.remove(),this._textarea=null),this._input||(this._input=document.createElement("input"),this._wrapper.appendChild(this._input),this.setupEventListeners()),this._element=this._input,this._input.type=t,this._input.placeholder=n,this._input.disabled=r,this._input.readOnly=a,this._input.required=o,this._input.setAttribute("aria-invalid",this.hasError()?"true":"false"),i?(this._input.inputMode="decimal",this._input.pattern="[0-9]*\\.?[0-9]*"):(this._input.removeAttribute("inputmode"),this._input.removeAttribute("pattern")),h!==this._input.value&&(this._input.value=h),l?this._input.id=l:this._input.removeAttribute("id"),c?this._input.name=c:this._input.removeAttribute("name"),this._input.className=this.getInputClasses(),this.firstChild&&this.firstChild!==this._wrapper&&this.firstChild.nodeType===Node.TEXT_NODE){const v=this.firstChild.textContent;v&&!this._input.value&&(this._input.value=v.trim()),this.removeChild(this.firstChild)}let _=this.querySelector(".mint-input-label-container");if(u||f){_||(_=document.createElement("div"),_.className="mint-input-label-container flex flex-col gap-0.5 mb-[.25rem]",this._wrapper&&this._wrapper.parentElement===this?this.insertBefore(_,this._wrapper):this.insertBefore(_,this.firstChild));let v=_.querySelector(".mint-input-label");if(u){v||(v=document.createElement("label"),v.className="mint-input-label text-sm font-medium text-gray-900 dark:text-gray-100 select-none",_.insertBefore(v,_.firstChild)),v.textContent=u;const w=l||((b=this._element)==null?void 0:b.id)||((x=this._colorTextInput)==null?void 0:x.id)||((y=this._input)==null?void 0:y.id)||((E=this._textarea)==null?void 0:E.id);if(w)v.setAttribute("for",w);else{const A=`mint-input-${Math.random().toString(36).substr(2,9)}`;this._element?this._element.id=A:this._colorTextInput?this._colorTextInput.id=A:this._input?this._input.id=A:this._textarea&&(this._textarea.id=A),v.setAttribute("for",A)}r?v.classList.add("opacity-40"):v.classList.remove("opacity-40")}else v&&v.remove();let k=_.querySelector(".mint-input-info");f?(k||(k=document.createElement("span"),k.className="mint-input-info text-xs text-gray-500 dark:text-gray-400 select-none",_.appendChild(k)),k.textContent=f,r?k.classList.add("opacity-40"):k.classList.remove("opacity-40")):k&&k.remove()}else _&&_.remove();this._renderErrorState(),this._renderSkeleton(m)}_renderErrorState(){const t=this.hasError(),e=this.getErrorMessage();let i=this.querySelector(".mint-input-error");t&&e?(i||(i=document.createElement("div"),i.className="mint-input-error mt-1 text-xs text-red-600 dark:text-red-400",this.appendChild(i)),i.textContent=e):i&&i.remove()}setupEventListeners(){this._element&&(this._element.addEventListener("input",()=>{var e;const t=((e=this._element)==null?void 0:e.value)||"";t?this.setAttribute("value",t):this.removeAttribute("value"),this.dispatchEvent(new CustomEvent("input",{detail:{value:t},bubbles:!0,cancelable:!0}))}),this._element.addEventListener("blur",()=>{var e;const t=((e=this._element)==null?void 0:e.value)||"";t?this.setAttribute("value",t):this.removeAttribute("value"),this.dispatchEvent(new CustomEvent("change",{detail:{value:t},bubbles:!0,cancelable:!0}))}))}removeEventListeners(){this._colorPicker&&(this._focusHandler&&(this._colorPicker.removeEventListener("focus",this._focusHandler),this._focusHandler=null),this._blurHandler&&(this._colorPicker.removeEventListener("blur",this._blurHandler),this._blurHandler=null))}focus(){var t;this._isColor()&&this._colorTextInput?this._colorTextInput.focus():(t=this._element)==null||t.focus()}blur(){var t;this._isColor()&&this._colorTextInput?this._colorTextInput.blur():(t=this._element)==null||t.blur()}_renderSkeleton(t){let e=this.querySelector(".mint-input-skeleton-container");const i=this._wrapper||this.querySelector(".relative.w-full");if(t){e||(e=document.createElement("div"),e.className="mint-input-skeleton-container absolute inset-0 z-10 pointer-events-none",i?(i.classList.contains("relative")||i.classList.add("relative"),i.appendChild(e)):(this.style.position="relative",this.appendChild(e)));let s=e.querySelector(".mint-input-skeleton");if(!s){s=document.createElement("div"),s.className="mint-input-skeleton w-full rounded-lg bg-gray-200 dark:bg-gray-700 animate-pulse";const n=this._isTextarea(),r=this.getRows();if(n){const a=r*24+12;s.style.height=`${a}px`}else s.style.height="2.2rem";e.appendChild(s)}e.style.display="block",this._element&&(this._element.style.opacity="0",this._element.style.pointerEvents="none"),this._colorTextInput&&(this._colorTextInput.style.opacity="0",this._colorTextInput.style.pointerEvents="none")}else e&&(e.style.display="none"),this._element&&(this._element.style.opacity="1",this._element.style.pointerEvents="auto"),this._colorTextInput&&(this._colorTextInput.style.opacity="1",this._colorTextInput.style.pointerEvents="auto")}}customElements.get("mint-input")||customElements.define("mint-input",K);class X extends HTMLElement{constructor(){super(),this._input=null,this._textInput=null,this._popover=null,this._calendarContainer=null,this._iconButton=null,this._hiddenInput=null,this._startPartInputs=[],this._endPartInputs=[],this._displayEl=null,this._inputsWrapperEl=null,this._fieldsContainer=null,this._resetHandler=null,this._isInputMode=!1,this._currentMonth=new Date().getMonth(),this._currentYear=new Date().getFullYear(),this._viewMode="calendar",this._selectedStartDate=null,this._selectedEndDate=null,this._isRange=!1,this._popoverObserver=null,this._focusTrapHandler=null,this._escapeHandler=null}static get observedAttributes(){return["value","label","info","disabled","id","name","required","readonly","format","min","max","range","shortcuts","display-format","error","error-message","loading"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline","inline-block"),this.render(),this._setupPopoverWithRetry(),this._attachFormResetListener()}disconnectedCallback(){if(this._popoverObserver&&(this._popoverObserver.disconnect(),this._popoverObserver=null),this._removeFocusTrap(),this._resetHandler){const t=this.closest("form");t&&t.removeEventListener("reset",this._resetHandler),this._resetHandler=null}}isLoading(){return this.hasAttribute("loading")}attributeChangedCallback(t,e,i){if(e!==i){if(t==="error"||t==="error-message"){const s=this.hasError(),n=this.getErrorMessage();this._applyErrorVisuals(s,n,this.isDisabled());return}if(t==="loading"){this.render();return}this.render(),this._input&&this._setupPopoverWithRetry()}}getValue(){return this.getAttribute("value")||""}setValue(t){t?(this.setAttribute("value",t),this._textInput&&(this._textInput.value=t),this._parseValue(t)):(this.removeAttribute("value"),this._textInput&&(this._textInput.value=""),this._selectedStartDate=null,this._selectedEndDate=null),this._buildCalendar(),this._updateDisplayText()}getFormat(){return this.getAttribute("format")||"mm/dd/yyyy"}getLabel(){return this.getAttribute("label")||""}getInfo(){return this.getAttribute("info")||""}isDisabled(){return this.hasAttribute("disabled")}isReadonly(){return this.hasAttribute("readonly")}isRequired(){return this.hasAttribute("required")}hasError(){return this.hasAttribute("error")}getErrorMessage(){return this.getAttribute("error-message")||""}isRange(){return this.hasAttribute("range")}getId(){return this.getAttribute("id")||""}getName(){return this.getAttribute("name")||""}getMin(){return this.getAttribute("min")||""}getMax(){return this.getAttribute("max")||""}getDisplayFormat(){return this.getAttribute("display-format")||"F j, Y"}getShortcuts(){const t=this.getAttribute("shortcuts");if(!t)return[];try{const e=JSON.parse(t);if(Array.isArray(e))return e.map(i=>({label:i.label,action:this._createShortcutAction(i.action)}))}catch{const i=t.trim();if(i&&typeof window[i]=="function"){const s=window[i]();if(Array.isArray(s))return s.map(n=>({label:n.label,action:typeof n.action=="function"?n.action:this._createShortcutAction(n.action)}))}}return[]}_createShortcutAction(t){return typeof t=="function"?t:typeof t=="string"&&typeof window[t]=="function"?window[t]:()=>null}_getDefaultShortcuts(){const t=[{label:"Today",action:()=>new Date}];return this._isRange&&t.push({label:"This Week",action:()=>{const e=new Date,i=e.getDay(),s=new Date(e);s.setDate(e.getDate()-i),s.setHours(0,0,0,0);const n=new Date(s);return n.setDate(s.getDate()+6),n.setHours(23,59,59,999),{start:s,end:n}}},{label:"This Month",action:()=>{const e=new Date,i=new Date(e.getFullYear(),e.getMonth(),1),s=new Date(e.getFullYear(),e.getMonth()+1,0);return s.setHours(23,59,59,999),{start:i,end:s}}}),t}_getFormatTokens(t){const e=[];let i=0;const s=t.toLowerCase();for(;i<s.length;){const n=s[i];if(n==="d"||n==="m"||n==="y"){let r=1,a=i+1;for(;a<s.length&&s[a]===n;)r++,a++;e.push({type:"part",part:n,len:r}),i=a}else e.push({type:"sep",value:t[i]}),i++}return e}_createPartInput(t,e,i,s,n){const r=document.createElement("input");return r.type="text",r.inputMode="numeric",r.pattern="\\d*",r.maxLength=t,r.placeholder=e,r.className="bg-transparent border-none outline-none text-center text-sm font-medium p-0 m-0 focus:outline-none focus:ring-0 disabled:opacity-40 disabled:cursor-not-allowed",r.disabled=i||s,r.readOnly=s,r.required=n,t===4?r.className+=" w-[40px]":t===2&&(r.className+=" w-[30px]"),r}_buildValueFromParts(t,e){let i=0;return e.map(s=>{var r;if(s.type==="sep")return s.value;const n=((r=t[i])==null?void 0:r.value)||"";return i++,n}).join("")}_applyDateToParts(t,e,i,s){if(!e.length)return;if(!t){e.forEach(o=>o.value="");return}const n=this._formatDate(t,s);let r=0,a=0;i.forEach(o=>{if(o.type==="sep")r+=o.value.length;else{const l=n.substr(r,o.len);e[a]&&(e[a].value=l),a++,r+=o.len}})}_syncHiddenInput(){if(!this._hiddenInput)return;const t=this.getFormat(),e=this._getFormatTokens(t),i=this._buildValueFromParts(this._startPartInputs,e);if(this._isRange){const s=this._buildValueFromParts(this._endPartInputs,e);this._hiddenInput.value=s?`${i} - ${s}`:i}else this._hiddenInput.value=i}_focusNext(t,e){if(e+1<t.length){const i=t[e+1];i.focus(),i.setSelectionRange(0,i.value.length)}}_focusPrev(t,e){if(e-1>=0){const i=t[e-1];i.focus(),i.setSelectionRange(i.value.length,i.value.length)}}_attachPartInputHandlers(t,e,i){t.forEach((s,n)=>{const r=s.maxLength||2;s.addEventListener("input",()=>{s.value=s.value.replace(/\D/g,"").slice(0,r),s.value.length>=r&&this._focusNext(t,n),this._syncHiddenInput()}),s.addEventListener("keydown",a=>{a.key==="Backspace"&&s.selectionStart===0&&s.selectionEnd===0&&this._focusPrev(t,n),a.key==="ArrowLeft"&&s.selectionStart===0&&s.selectionEnd===0&&(this._focusPrev(t,n),a.preventDefault()),a.key==="ArrowRight"&&s.selectionStart===s.value.length&&s.selectionEnd===s.value.length&&(this._focusNext(t,n),a.preventDefault())}),s.addEventListener("blur",a=>{var c,h;this._syncHiddenInput();const o=a.relatedTarget;o&&(this.contains(o)||(c=this._popover)!=null&&c.contains(o)||this._calendarContainer&&this._calendarContainer.contains(o))||(this._handleBlur(((h=this._hiddenInput)==null?void 0:h.value)||""),this._exitInputMode(),setTimeout(()=>{if(this._hiddenInput){const p=new FocusEvent("blur",{bubbles:!0,cancelable:!0,relatedTarget:a.relatedTarget});this._hiddenInput.dispatchEvent(p)}},0))})})}_splitRangeInput(t,e){const i=t.split(/\s*-\s*/);return i.length>=2?[i[0],i.slice(1).join("-")]:[t]}_parseValue(t){const e=this.getFormat(),i=this._getFormatTokens(e);if(this._isRange){const[s,n]=this._splitRangeInput(t,e),r=s?this._parseDateString(s,e):null,a=n?this._parseDateString(n,e):null;if(r&&a){const[o,l]=r<=a?[r,a]:[a,r];this._selectedStartDate=o,this._selectedEndDate=l,this._currentMonth=o.getMonth(),this._currentYear=o.getFullYear()}else r&&(this._selectedStartDate=r,this._selectedEndDate=null,this._currentMonth=r.getMonth(),this._currentYear=r.getFullYear());this._applyDateToParts(this._selectedStartDate,this._startPartInputs,i,e),this._applyDateToParts(this._selectedEndDate,this._endPartInputs,i,e)}else{const s=this._parseDateString(t,e);s&&!isNaN(s.getTime())?(this._selectedStartDate=s,this._selectedEndDate=null,this._currentMonth=s.getMonth(),this._currentYear=s.getFullYear(),this._applyDateToParts(s,this._startPartInputs,i,e)):this._applyDateToParts(null,this._startPartInputs,i,e)}this._syncHiddenInput(),this._updateDisplayText()}_parseDateString(t,e){const i=/[\/\-\.\s]+/;if(i.test(t)){const m=t.split(i).filter(_=>_.length>0),g=e.split(/[\/\-\.\s]+/).filter(_=>_.length>0);if(m.length===g.length){let _=0,b=0,x=0;for(let y=0;y<g.length;y++){const E=g[y].toLowerCase(),v=m[y];if(E.includes("d"))_=parseInt(v,10);else if(E.includes("m"))b=parseInt(v,10)-1;else if(E.includes("y")){let k=parseInt(v,10);const w=E.length,A=v.length;A===2&&w===4?k=Math.floor(new Date().getFullYear()/100)*100+k:A===2&&w===2&&(k=Math.floor(new Date().getFullYear()/100)*100+k),x=k}}if(_&&b>=0&&b<=11&&x){const y=new Date(x,b,_);if(!isNaN(y.getTime())&&y.getDate()===_&&y.getMonth()===b&&y.getFullYear()===x)return y}}}const n=t.replace(/[\/\-\.]/g,""),r=e.replace(/[\/\-\.]/g,"").toLowerCase();let a=r.indexOf("d"),o=r.indexOf("m"),l=r.indexOf("y");const c=[{char:"d",index:a},{char:"m",index:o},{char:"y",index:l}].sort((m,g)=>m.index-g.index);let h=0,p=0,d=0,u=0;r.length,n.length;for(const m of c)if(m.char==="d"){const g=r.lastIndexOf("d")-r.indexOf("d")+1,_=n.substr(u,g);if(_.length===0)return null;h=parseInt(_,10),u+=_.length}else if(m.char==="m"){const g=r.lastIndexOf("m")-r.indexOf("m")+1,_=n.substr(u,g);if(_.length===0)return null;p=parseInt(_,10)-1,u+=_.length}else if(m.char==="y"){const g=r.lastIndexOf("y")-r.indexOf("y")+1,_=n.substr(u),b=Math.min(g,_.length),x=_.substr(0,b);if(x.length===0)return null;let y=parseInt(x,10);b===2&&g===4?y=Math.floor(new Date().getFullYear()/100)*100+y:b===2&&g===2&&(y=Math.floor(new Date().getFullYear()/100)*100+y),d=y,u+=b}if(!h||p<0||p>11||!d)return null;const f=new Date(d,p,h);return isNaN(f.getTime())||f.getDate()!==h||f.getMonth()!==p||f.getFullYear()!==d?null:f}_formatDate(t,e){const i=t.getDate(),s=t.getMonth()+1,n=t.getFullYear(),r=e.toLowerCase();let a=e;return r.includes("dd")?a=a.replace(/dd/gi,String(i).padStart(2,"0")):r.includes("d")&&(a=a.replace(/d/gi,String(i))),r.includes("mm")?a=a.replace(/mm/gi,String(s).padStart(2,"0")):r.includes("m")&&(a=a.replace(/m/gi,String(s))),r.includes("yyyy")?a=a.replace(/yyyy/gi,String(n)):r.includes("yy")&&(a=a.replace(/yy/gi,String(n).substr(2))),a}_formatDatePhp(t,e){const i=t.getDate(),s=t.getMonth()+1,n=t.getFullYear(),r=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],a=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],o=["January","February","March","April","May","June","July","August","September","October","November","December"],l=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],c=(d,u=2)=>d.toString().padStart(u,"0"),h=d=>{const u=d%10,f=d%100;return u===1&&f!==11?"st":u===2&&f!==12?"nd":u===3&&f!==13?"rd":"th"};let p="";for(let d=0;d<e.length;d++){const u=e[d];if(u==="\\"&&d+1<e.length){p+=e[d+1],d++;continue}switch(u){case"Y":p+=n.toString();break;case"y":p+=n.toString().slice(-2);break;case"m":p+=c(s);break;case"n":p+=s.toString();break;case"M":p+=l[s-1];break;case"F":p+=o[s-1];break;case"d":p+=c(i);break;case"j":p+=i.toString();break;case"D":p+=a[t.getDay()];break;case"l":p+=r[t.getDay()];break;case"S":p+=h(i);break;default:p+=u;break}}return p}_validateDateString(t,e){const i=this._parseDateString(t,e);return i!==null&&!isNaN(i.getTime())}render(){const t=this.isLoading(),e=this.getLabel(),i=this.getInfo(),s=this.getValue(),n=this.isDisabled(),r=this.isReadonly(),a=this.isRequired(),o=this.getId(),l=this.getName(),c=this.getFormat(),h=this.hasError(),p=this.getErrorMessage();this._isRange=this.isRange(),this._input||(this._input=document.createElement("div"),this._input.className="relative w-full",this.appendChild(this._input));let d=this.querySelector(".mint-date-picker-label-container");if(e||i){d||(d=document.createElement("div"),d.className="mint-date-picker-label-container flex flex-col gap-0.5 mb-[.25rem]",this.contains(this._input)?this.insertBefore(d,this._input):this.appendChild(d));let b=d.querySelector(".mint-date-picker-label");e?(b||(b=document.createElement("label"),b.className="mint-date-picker-label text-sm font-medium text-gray-900 dark:text-gray-100 select-none",d.insertBefore(b,d.firstChild)),b.textContent=e,o&&this._textInput&&b.setAttribute("for",o)):b&&b.remove();let x=d.querySelector(".mint-date-picker-info");i?(x||(x=document.createElement("span"),x.className="mint-date-picker-info text-xs text-gray-500 dark:text-gray-400 select-none",d.appendChild(x)),x.textContent=i):x&&x.remove()}else d&&d.remove();this._hiddenInput||(this._hiddenInput=document.createElement("input"),this._hiddenInput.type="hidden",this._hiddenInput.value=s||"",this._textInput=this._hiddenInput,this._input.appendChild(this._hiddenInput)),o&&(this._hiddenInput.id=o),l&&(this._hiddenInput.name=l),this._hiddenInput.value=s||"",this._hiddenInput.setAttribute("aria-invalid",h?"true":"false");let u=this._input.querySelector(".mint-date-fields");u||(u=document.createElement("div"),this._input.appendChild(u)),this._fieldsContainer=u,this._applyErrorVisuals(h,p,n),u.innerHTML="",this._displayEl=document.createElement("div");const f=r?"select-text":"select-none";this._displayEl.className=`flex-1 text-gray-900 dark:text-white ${r?"cursor-default":"cursor-text"} ${f} focus:outline-none`,this._displayEl.tabIndex=n||r?-1:0,this._displayEl.addEventListener("click",()=>{n||r||this._enterInputMode()}),this._displayEl.addEventListener("keydown",b=>{n||r||(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),this._enterInputMode())}),this._inputsWrapperEl=document.createElement("div"),this._inputsWrapperEl.className="flex items-center gap-1 w-full";const m=this._getFormatTokens(c);this._startPartInputs=[],this._endPartInputs=[];const g=b=>{const x=document.createDocumentFragment();return m.forEach(y=>{if(y.type==="sep"){const E=document.createElement("span");E.textContent=y.value,E.className="text-gray-400 dark:text-gray-500 select-none",x.appendChild(E)}else{const E=y.part==="d"?"dd":y.part==="m"?"mm":y.len===2?"yy":"yyyy",v=this._createPartInput(y.len,E,n,r,a);b==="start"?this._startPartInputs.push(v):this._endPartInputs.push(v),x.appendChild(v)}}),x};if(this._inputsWrapperEl.appendChild(g("start")),this._isRange){const b=document.createElement("span");b.textContent=" - ",b.className="text-gray-400 dark:text-gray-500 select-none",this._inputsWrapperEl.appendChild(b),this._inputsWrapperEl.appendChild(g("end"))}const _=document.createElement("div");if(_.className="flex flex-col w-full",this._displayEl.style.display=this._isInputMode?"none":"flex",this._inputsWrapperEl.style.display=this._isInputMode?"flex":"none",_.appendChild(this._displayEl),_.appendChild(this._inputsWrapperEl),u.appendChild(_),u.addEventListener("click",()=>{this._isInputMode||n||r||this._enterInputMode()}),this._attachPartInputHandlers(this._startPartInputs,m,u),this._isRange&&this._attachPartInputHandlers(this._endPartInputs,m,u),this._parseValue(s),this._syncHiddenInput(),this._updateDisplayText(),this._iconButton)this._iconButton.disabled=n||r,!n&&!r?this._iconButton.tabIndex=0:this._iconButton.tabIndex=-1;else{this._iconButton=document.createElement("button"),this._iconButton.type="button",this._iconButton.tabIndex=0,this._iconButton.className="absolute left-2 top-[.55rem] text-gray-400 dark:text-gray-500 hover:text-gray-600 dark:hover:text-gray-300 cursor-pointer z-10 focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500 pointer-events-auto disabled:opacity-40 disabled:cursor-not-allowed flex items-center justify-center rounded-sm";const b=`date-icon-${Math.random().toString(36).substr(2,9)}`;this._iconButton.id=b;const x=document.createElement("mint-icon");x.setAttribute("name","calendar"),x.className="w-4 h-4 pointer-events-none",this._iconButton.appendChild(x),this._iconButton.addEventListener("click",()=>{n||r||this._enterInputMode()}),this._input.prepend(this._iconButton),this._iconButton.disabled=n||r}this._renderErrorState(h,p),this._renderSkeleton(t)}_renderErrorState(t,e){let i=this.querySelector(".mint-date-picker-error");t&&e?(i||(i=document.createElement("div"),i.className="mint-date-picker-error mt-1 text-xs text-red-600 dark:text-red-400",this.appendChild(i)),i.textContent=e):i&&i.remove()}_applyErrorVisuals(t,e,i){if(this._renderErrorState(t,e),this._fieldsContainer){const s=this._getFieldContainerClass(t,i);this._fieldsContainer.className=s}this._hiddenInput&&this._hiddenInput.setAttribute("aria-invalid",t?"true":"false")}_attachFormResetListener(){const t=this.closest("form");!t||this._resetHandler||(this._resetHandler=()=>{this.setValue(""),this._clearPartInputs(this._startPartInputs),this._clearPartInputs(this._endPartInputs),this._isInputMode=!1,this._updateDisplayText(),this._applyErrorVisuals(!1,"",this.isDisabled())},t.addEventListener("reset",this._resetHandler))}_clearPartInputs(t){t.forEach(e=>{e.value=""})}_getFieldContainerClass(t,e){return["mint-date-fields relative w-full pl-10 pr-3.5 py-1.5 min-h-[2rem] text-sm font-medium rounded-lg box-border bg-white dark:bg-gray-700 text-gray-900 dark:text-white","border-2",t?"border-red-300 dark:border-red-300":"border-gray-200 dark:border-gray-600","transition-all duration-200 outline-none focus-within:ring-2 focus-within:ring-offset-1",t?"focus-within:ring-red-400 dark:focus-within:ring-red-500":"focus-within:ring-gray-400 dark:focus-within:ring-gray-500","flex items-center gap-1"].join(" ")+(e?" opacity-40 cursor-not-allowed":"")}_handleInputChange(t){}_cleanInputValue(t,e){return t}_handleBlur(t){const e=this.getFormat();if(!t){this.setValue(""),this._updateDisplayText();return}if(this._isRange){const[i,s]=this._splitRangeInput(t,e),n=i?this._parseDateString(i,e):null,r=s?this._parseDateString(s,e):null;if(n&&r){const[a,o]=n<=r?[n,r]:[r,n],l=this._formatDate(a,e),c=this._formatDate(o,e),h=`${l} - ${c}`;this.setValue(h),this._applyDateToParts(a,this._startPartInputs,this._getFormatTokens(e),e),this._applyDateToParts(o,this._endPartInputs,this._getFormatTokens(e),e),this._selectedStartDate=a,this._selectedEndDate=o,this._currentMonth=a.getMonth(),this._currentYear=a.getFullYear()}else if(n){const a=this._formatDate(n,e);this.setValue(a),this._applyDateToParts(n,this._startPartInputs,this._getFormatTokens(e),e),this._applyDateToParts(null,this._endPartInputs,this._getFormatTokens(e),e),this._selectedStartDate=n,this._selectedEndDate=null,this._currentMonth=n.getMonth(),this._currentYear=n.getFullYear()}else this.setValue(""),this._applyDateToParts(null,this._startPartInputs,this._getFormatTokens(e),e),this._applyDateToParts(null,this._endPartInputs,this._getFormatTokens(e),e),this._selectedStartDate=null,this._selectedEndDate=null}else if(this._validateDateString(t,e)){const i=this._parseDateString(t,e);if(i){const s=this._formatDate(i,e);this.setValue(s),this._applyDateToParts(i,this._startPartInputs,this._getFormatTokens(e),e),this._selectedStartDate=i,this._selectedEndDate=null,this._currentMonth=i.getMonth(),this._currentYear=i.getFullYear()}}else this.setValue(""),this._applyDateToParts(null,this._startPartInputs,this._getFormatTokens(e),e),this._selectedStartDate=null,this._selectedEndDate=null}_setupPopoverWithRetry(t=0){if(!this._iconButton){t<10&&requestAnimationFrame(()=>{this._setupPopoverWithRetry(t+1)});return}const e=10,i=this._iconButton.id;i&&this._iconButton.isConnected?document.getElementById(i)?this._createPopover(i):t<e&&requestAnimationFrame(()=>{this._setupPopoverWithRetry(t+1)}):t<e&&requestAnimationFrame(()=>{this._setupPopoverWithRetry(t+1)})}_createPopover(t){if(!t)return;if(!document.getElementById(t)){setTimeout(()=>{this._createPopover(t)},50);return}if(!this._popover)this._popover=document.createElement("mint-popover"),this._popover.setAttribute("direction","down"),this._popover.setAttribute("padding","0"),this.parentNode?this.parentNode.insertBefore(this._popover,this.nextSibling):document.body.appendChild(this._popover),requestAnimationFrame(()=>{requestAnimationFrame(()=>{this._popover&&this._popover.isConnected&&(this._popover.setAttribute("trigger-id",t),this._popoverObserver||(this._popoverObserver=new MutationObserver(i=>{i.forEach(s=>{var n;if(s.type==="attributes"&&s.attributeName==="open")if((n=this._popover)==null?void 0:n.hasAttribute("open"))requestAnimationFrame(()=>{this._buildCalendar();const a=this._popover;typeof a.render=="function"&&a.render(),this._setupFocusTrap()});else{if(this._removeFocusTrap(),this._iconButton&&!this._iconButton.disabled&&requestAnimationFrame(()=>{var a;(a=this._iconButton)==null||a.focus()}),this._viewMode="calendar",this._selectedStartDate)this._currentMonth=this._selectedStartDate.getMonth(),this._currentYear=this._selectedStartDate.getFullYear();else{const a=new Date;this._currentMonth=a.getMonth(),this._currentYear=a.getFullYear()}requestAnimationFrame(()=>{this._buildCalendar()}),this._hiddenInput&&(this._syncHiddenInput(),setTimeout(()=>{var o;const a=new FocusEvent("blur",{bubbles:!0,cancelable:!0,relatedTarget:null});(o=this._hiddenInput)==null||o.dispatchEvent(a)},0))}})}),this._popoverObserver.observe(this._popover,{attributes:!0,attributeFilter:["open"]})),requestAnimationFrame(()=>{this._buildCalendar()}))})});else{if(this._popover.getAttribute("trigger-id")!==t){this._popover.setAttribute("trigger-id",t);const s=this._popover;typeof s._setupTrigger=="function"&&s._setupTrigger()}this._buildCalendar()}}_buildCalendar(){if(!this._popover)return;this._calendarContainer&&this._calendarContainer.parentNode&&this._calendarContainer.remove(),this._calendarContainer=document.createElement("div"),this._calendarContainer.className="mint-date-calendar bg-white dark:bg-gray-800 rounded-lg p-4 w-[22rem] md:w-auto md:min-w-[28rem]",this._viewMode==="calendar"?this._buildCalendarView():this._viewMode==="month"?this._buildMonthView():this._viewMode==="year"&&this._buildYearView();const t=this._popover.querySelector(".popover-content");if(t){for(;t.firstChild;)t.removeChild(t.firstChild);t.appendChild(this._calendarContainer)}else this._popover.appendChild(this._calendarContainer)}_buildCalendarView(){if(!this._calendarContainer)return;const t=this._getDaysInMonth(this._currentMonth,this._currentYear),e=this._getFirstDayOfMonth(this._currentMonth,this._currentYear),i=["January","February","March","April","May","June","July","August","September","October","November","December"],s=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],n=this.getShortcuts(),r=n.length>0;this._calendarContainer.className=r?"mint-date-calendar bg-white dark:bg-gray-800 rounded-lg p-4 w-[18rem] md:w-auto md:min-w-[28rem]":"mint-date-calendar bg-white dark:bg-gray-800 rounded-lg p-4 w-[18rem] md:min-w-[18rem]";const a=document.createElement("div");a.className="flex flex-col md:flex-row md:gap-6 md:items-start";const o=document.createElement("div");o.className="flex-1 min-w-0";const l=document.createElement("div");l.className="flex items-center justify-between mb-4";const c=document.createElement("button");c.type="button",c.tabIndex=0,c.className="p-1 rounded hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-600 dark:text-gray-300 transition-colors flex items-center focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500",c.setAttribute("data-keep-popover-open","true");const h=document.createElement("mint-icon");h.setAttribute("name","caret-left"),h.className="w-4 h-4",c.appendChild(h),c.addEventListener("click",()=>{this._currentMonth===0?(this._currentMonth=11,this._currentYear--):this._currentMonth--,this._buildCalendar()}),l.appendChild(c);const p=document.createElement("div");p.className="flex items-center gap-2";const d=document.createElement("button");d.type="button",d.tabIndex=0,d.className="text-sm font-medium text-gray-900 dark:text-gray-100 hover:text-gray-600 dark:hover:text-gray-300 transition-colors flex items-center focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500",d.setAttribute("data-keep-popover-open","true"),d.textContent=i[this._currentMonth],d.addEventListener("click",()=>{this._viewMode="month",this._buildCalendar()}),p.appendChild(d);const u=document.createElement("button");u.type="button",u.tabIndex=0,u.className="text-sm font-medium text-gray-900 dark:text-gray-100 hover:text-gray-600 dark:hover:text-gray-300 transition-colors flex items-center focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500",u.setAttribute("data-keep-popover-open","true"),u.textContent=String(this._currentYear),u.addEventListener("click",()=>{this._viewMode="year",this._buildCalendar()}),p.appendChild(u),l.appendChild(p);const f=document.createElement("button");f.type="button",f.tabIndex=0,f.className="p-1 rounded hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-600 dark:text-gray-300 transition-colors flex items-center focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500",f.setAttribute("data-keep-popover-open","true");const m=document.createElement("mint-icon");m.setAttribute("name","caret-right"),m.className="w-4 h-4",f.appendChild(m),f.addEventListener("click",()=>{this._currentMonth===11?(this._currentMonth=0,this._currentYear++):this._currentMonth++,this._buildCalendar()}),l.appendChild(f);const g=document.createElement("div");g.className="grid grid-cols-7 mb-2",s.forEach(y=>{const E=document.createElement("div");E.className="text-xs font-medium text-gray-500 dark:text-gray-400 text-center py-1",E.textContent=y,g.appendChild(E)});const _=document.createElement("div");_.className="grid grid-cols-7";for(let y=0;y<e;y++){const E=document.createElement("div");E.className="w-8 h-8",_.appendChild(E)}const b=this.getMin()?this._parseDateString(this.getMin(),this.getFormat()):null,x=this.getMax()?this._parseDateString(this.getMax(),this.getFormat()):null;for(let y=1;y<=t;y++){const E=new Date(this._currentYear,this._currentMonth,y),v=this._isToday(E),k=this._isDateSelected(E),w=this._isDateInRange(E),A=b&&E<b||x&&E>x;let I="rounded-md";if(this._isRange&&this._selectedStartDate&&this._selectedEndDate){const H=this._isSameDate(E,this._selectedStartDate),L=this._isSameDate(E,this._selectedEndDate);H&&L?I="rounded-md":H?I="rounded-l-md":L?I="rounded-r-md":w&&(I="rounded-none")}else k&&!this._isRange&&(I="rounded-md");const S=document.createElement("button");S.type="button",S.disabled=!!A,S.tabIndex=A?-1:0,S.className=`w-full h-8 ${I} border-0 text-sm font-medium transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500 ${k?"bg-slate-800 dark:bg-slate-600 text-white":w?"bg-slate-100 dark:bg-slate-700 text-slate-800 dark:text-slate-200":v?"text-gray-900 dark:text-gray-100 font-semibold":"text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700"} ${A?"opacity-40 cursor-not-allowed":""}`,S.textContent=y.toString(),A||S.addEventListener("click",()=>{this._handleDateClick(E)}),_.appendChild(S)}if(r){const y=document.createElement("div");y.className="mb-4 pb-4 border-b border-gray-200 dark:border-gray-700 md:mb-0 md:pb-0 md:border-b-0 md:border-r md:border-r-gray-200 dark:md:border-r-gray-700 md:pr-6 md:mr-0 md:w-32 md:flex-shrink-0 md:h-full md:flex md:flex-col";const E=document.createElement("div");E.className="relative md:relative md:flex-1 md:min-h-0";const v=document.createElement("div");v.className="flex gap-2 overflow-x-auto pb-1 md:flex-col md:overflow-x-visible md:overflow-y-auto md:pb-0 md:gap-2",v.style.scrollbarWidth="none",v.style.msOverflowStyle="none",v.style.setProperty("-webkit-overflow-scrolling","touch");const k=document.createElement("style");k.textContent=`
|
|
54
|
+
</svg>`,e}render(){var o,c,d;const t=this.getName();if(!t){this.innerHTML="",this.style.maskImage="",this.style.webkitMaskImage="",this.style.backgroundColor="";return}const e=ct.getIcon(t);if(!e){console.warn(`Icon "${t}" not found. Make sure you've imported the icon: import '@monobill-mintui/icon/icons/${t}'`),this.innerHTML="",this.style.maskImage="",this.style.webkitMaskImage="",this.style.backgroundColor="";return}const i=this.closest("mint-button")||((o=this.parentElement)==null?void 0:o.closest("mint-button")),s=this.closest("mint-switch")||((c=this.parentElement)==null?void 0:c.closest("mint-switch")),n=this.closest("mint-select")||((d=this.parentElement)==null?void 0:d.closest("mint-select"));if(!Array.from(this.classList).some(p=>p.startsWith("w-")||p.startsWith("h-"))&&!n){let p;s?p="w-3 h-3":i?p="w-5 h-5":p="w-[1.3em] h-[1.3em]",this.classList.remove("w-4","h-4","w-5","h-5","w-[1em]","h-[1em]","w-[1.3em]","h-[1.3em]","w-3","h-3"),p.split(" ").forEach(h=>{h&&this.classList.add(h)})}const a=this.generateSVGMarkup(e);this.innerHTML=a,this.style.maskImage="",this.style.webkitMaskImage="",this.style.maskSize="",this.style.webkitMaskSize="",this.style.maskRepeat="",this.style.webkitMaskRepeat="",this.style.maskPosition="",this.style.webkitMaskPosition="",this.style.backgroundColor="",this.style.aspectRatio="1 / 1";const l=this.querySelector("svg");if(l&&(l.style.width="100%",l.style.height="100%"),s)this.classList.remove("text-gray-100","text-gray-900"),this.classList.add("text-gray-900");else if(i)this.classList.remove("text-gray-100","text-gray-900");else{const h=document.documentElement.classList.contains("dark")?"text-gray-100":"text-gray-900";this.classList.remove("text-gray-100","text-gray-900"),this.classList.add(h)}}}customElements.get("mint-icon")||customElements.define("mint-icon",q);class P extends HTMLElement{constructor(){super(),this._button=null,this._clickHandler=null,this._isHandlingClick=!1,this._handleMouseDown=()=>{this._button&&!this.isDisabled()&&!this.isLoading()&&this._button.classList.add("mint-button-active")},this._handleMouseUp=()=>{this._button&&this._button.classList.remove("mint-button-active")},this._handleMouseLeave=()=>{this._button&&this._button.classList.remove("mint-button-active")},this._handleTouchStart=()=>{this._button&&!this.isDisabled()&&!this.isLoading()&&this._button.classList.add("mint-button-active")},this._handleTouchEnd=()=>{this._button&&this._button.classList.remove("mint-button-active")},this._handleTouchCancel=()=>{this._button&&this._button.classList.remove("mint-button-active")}}static get observedAttributes(){return["variant","tone","disabled","loading","button-type","type","full-width","icon-position","icon","active"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline","inline-block"),this.render(),this._button&&this.setupEventListeners(),this.isFullWidth()&&this.classList.add("w-full")}disconnectedCallback(){this.removeEventListeners()}attributeChangedCallback(t,e,i){e!==i&&this.render()}getVariant(){return this.getAttribute("variant")||"solid"}getTone(){return this.getAttribute("tone")||"neutral"}isDisabled(){return this.getAttribute("disabled")==="true"}isLoading(){return this.getAttribute("loading")==="true"}getType(){const t=this.getAttribute("type"),e=this.getAttribute("button-type");return(t||e||"default")==="submit"?"submit":"button"}isFullWidth(){return this.hasAttribute("full-width")}isActive(){const t=this.getAttribute("active");return!(t===null||t==="false"||t==="0")}get active(){return this.isActive()}set active(t){t?this.setAttribute("active","true"):this.removeAttribute("active")}getIconPosition(){return this.getAttribute("icon-position")||"left"}getIcon(){return this.getAttribute("icon")||""}isIconOnly(){var i,s,n,r,a;if(!(this.getIcon()||((i=this._button)==null?void 0:i.querySelector('[slot="icon"], .mint-button-icon, mint-icon'))))return!1;const e=(s=this._button)==null?void 0:s.querySelector(".mint-button-content");if(e&&((n=e.textContent)!=null&&n.trim()))return!1;if(this._button)for(let l=this._button.firstChild;l;l=l.nextSibling){if(l.nodeType===Node.TEXT_NODE&&((r=l.textContent)!=null&&r.trim()))return!1;if(l.nodeType===Node.ELEMENT_NODE){const o=l;if(o.tagName!=="MINT-ICON"&&o.tagName!=="MINT-SPINNER"&&!o.querySelector("mint-spinner")&&!o.hasAttribute("slot")&&o.className!=="mint-button-icon"&&!(o.className==="mr-2"&&o.querySelector("mint-spinner"))&&(a=o.textContent)!=null&&a.trim())return!1}}return!0}getActiveStateClasses(){const t=this.getVariant(),e=this.getTone(),i=`${t}-${e}`;return{"solid-action":["!bg-slate-900","!shadow-[inset_0_2px_4px_rgba(0,0,0,0.3)]","dark:!bg-slate-700","hover:!bg-slate-900","dark:hover:!bg-slate-700","hover:!shadow-[inset_0_2px_4px_rgba(0,0,0,0.3)]"],"solid-neutral":["!bg-gray-100","!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]","dark:!bg-gray-800","hover:!bg-gray-100","dark:hover:!bg-gray-800","hover:!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]"],"solid-info":["!bg-blue-900","!shadow-[inset_0_2px_4px_rgba(0,0,0,0.3)]","dark:!bg-blue-700","hover:!bg-blue-900","dark:hover:!bg-blue-700","hover:!shadow-[inset_0_2px_4px_rgba(0,0,0,0.3)]"],"solid-warning":["!bg-amber-900","!shadow-[inset_0_2px_4px_rgba(0,0,0,0.3)]","dark:!bg-amber-700","hover:!bg-amber-900","dark:hover:!bg-amber-700","hover:!shadow-[inset_0_2px_4px_rgba(0,0,0,0.3)]"],"solid-danger":["!bg-red-900","!shadow-[inset_0_2px_4px_rgba(0,0,0,0.3)]","dark:!bg-red-700","hover:!bg-red-900","dark:hover:!bg-red-700","hover:!shadow-[inset_0_2px_4px_rgba(0,0,0,0.3)]"],"ghost-action":["!bg-gray-100","!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]","dark:!bg-gray-800","hover:!bg-gray-100","dark:hover:!bg-gray-800","hover:!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]"],"ghost-neutral":["!bg-gray-50","!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]","dark:!bg-gray-800","!text-gray-900","dark:!text-white","hover:!bg-gray-50","dark:hover:!bg-gray-800","hover:!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]","hover:!text-gray-900","dark:hover:!text-white"],"ghost-info":["!bg-gray-100","!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]","dark:!bg-gray-800","hover:!bg-gray-100","dark:hover:!bg-gray-800","hover:!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]"],"ghost-warning":["!bg-gray-100","!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]","dark:!bg-gray-800","hover:!bg-gray-100","dark:hover:!bg-gray-800","hover:!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]"],"ghost-danger":["!bg-gray-100","!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]","dark:!bg-gray-800","hover:!bg-gray-100","dark:hover:!bg-gray-800","hover:!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]"],"link-action":["!text-slate-900","dark:!text-slate-300","hover:!text-slate-900","dark:hover:!text-slate-300"],"link-neutral":["!text-gray-950","dark:!text-gray-200","hover:!text-gray-950","dark:hover:!text-gray-200"],"link-info":["!text-blue-900","dark:!text-blue-200","hover:!text-blue-900","dark:hover:!text-blue-200"],"link-warning":["!text-amber-900","dark:!text-amber-200","hover:!text-amber-900","dark:hover:!text-amber-200"],"link-danger":["!text-red-900","dark:!text-red-200","hover:!text-red-900","dark:hover:!text-red-200"]}[i]||[]}getButtonClasses(){const t=this.isIconOnly(),e=this.getVariant(),i=["inline-flex","items-center","justify-center","font-medium","rounded-lg","box-border",...t?["p-1.5","aspect-square","w-[2.25rem]","h-[2.25rem]"]:["px-3.5","py-1.5","min-h-[2.25rem]"],"text-sm","transition-all","duration-200","outline-none","focus:outline-none","focus-visible:ring-2","focus-visible:ring-offset-1","[&.mint-button-active>*]:scale-95","[&>*]:transition-transform","[&>*]:duration-100","disabled:opacity-50","disabled:cursor-not-allowed"],s=this.getTone(),n={"solid-action":["bg-slate-800","dark:bg-slate-600","text-white","hover:bg-slate-950","dark:hover:bg-slate-700","active:bg-slate-900","active:shadow-[inset_0_2px_4px_rgba(0,0,0,0.3)]","dark:active:bg-slate-700","disabled:active:bg-slate-800","dark:disabled:active:bg-slate-600","disabled:active:shadow-none","focus-visible:ring-gray-400","dark:focus-visible:ring-gray-500","shadow-sm","hover:shadow","dark:shadow-gray-900/50","border-2","border-transparent"],"solid-neutral":["bg-white","dark:bg-gray-700","text-gray-900","dark:text-white","hover:bg-gray-50","dark:hover:bg-gray-600","active:bg-gray-100","active:shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]","dark:active:bg-gray-800","disabled:active:bg-white","dark:disabled:active:bg-gray-700","disabled:active:shadow-none","focus-visible:ring-gray-400","dark:focus-visible:ring-gray-500","shadow-sm","hover:shadow","dark:shadow-gray-900/50","border-2","border-gray-200","dark:border-gray-600"],"solid-info":["bg-blue-800","dark:bg-blue-600","text-white","hover:bg-blue-950","dark:hover:bg-blue-700","active:bg-blue-900","active:shadow-[inset_0_2px_4px_rgba(0,0,0,0.3)]","dark:active:bg-blue-700","disabled:active:bg-blue-800","dark:disabled:active:bg-blue-600","disabled:active:shadow-none","focus-visible:ring-gray-400","dark:focus-visible:ring-gray-500","shadow-sm","hover:shadow","dark:shadow-gray-900/50","border-2","border-transparent"],"solid-warning":["bg-amber-800","dark:bg-amber-600","text-white","hover:bg-amber-950","dark:hover:bg-amber-700","active:bg-amber-900","active:shadow-[inset_0_2px_4px_rgba(0,0,0,0.3)]","dark:active:bg-amber-700","disabled:active:bg-amber-800","dark:disabled:active:bg-amber-600","disabled:active:shadow-none","focus-visible:ring-gray-400","dark:focus-visible:ring-gray-500","shadow-sm","hover:shadow","dark:shadow-gray-900/50","border-2","border-transparent"],"solid-danger":["bg-red-800","dark:bg-red-600","text-white","hover:bg-red-950","dark:hover:bg-red-700","active:bg-red-900","active:shadow-[inset_0_2px_4px_rgba(0,0,0,0.3)]","dark:active:bg-red-700","disabled:active:bg-red-800","dark:disabled:active:bg-red-600","disabled:active:shadow-none","focus-visible:ring-gray-400","dark:focus-visible:ring-gray-500","shadow-sm","hover:shadow","dark:shadow-gray-900/50","border-2","border-transparent"],"ghost-action":["bg-transparent","text-slate-800","dark:text-slate-400","active:bg-gray-100","active:shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]","dark:active:bg-gray-800","disabled:active:bg-transparent","dark:disabled:active:bg-transparent","disabled:active:shadow-none","focus-visible:ring-gray-400","dark:focus-visible:ring-gray-500","shadow-none","hover:shadow-none","border-2","border-transparent"],"ghost-neutral":["bg-transparent","text-gray-700","dark:text-gray-200","active:bg-gray-50","active:shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]","dark:active:bg-gray-800","active:text-gray-900","dark:active:text-white","disabled:active:bg-transparent","dark:disabled:active:bg-transparent","disabled:active:shadow-none","focus-visible:ring-gray-400","dark:focus-visible:ring-gray-500","shadow-none","hover:shadow-none","border-2","border-transparent"],"ghost-info":["bg-transparent","text-blue-800","dark:text-blue-400","active:bg-gray-100","active:shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]","dark:active:bg-gray-800","disabled:active:bg-transparent","dark:disabled:active:bg-transparent","disabled:active:shadow-none","focus-visible:ring-gray-400","dark:focus-visible:ring-gray-500","shadow-none","hover:shadow-none","border-2","border-transparent"],"ghost-warning":["bg-transparent","text-amber-800","dark:text-amber-400","active:bg-gray-100","active:shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]","dark:active:bg-gray-800","disabled:active:bg-transparent","dark:disabled:active:bg-transparent","disabled:active:shadow-none","focus-visible:ring-gray-400","dark:focus-visible:ring-gray-500","shadow-none","hover:shadow-none","border-2","border-transparent"],"ghost-danger":["bg-transparent","text-red-800","dark:text-red-400","active:bg-gray-100","active:shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]","dark:active:bg-gray-800","disabled:active:bg-transparent","dark:disabled:active:bg-transparent","disabled:active:shadow-none","focus-visible:ring-gray-400","dark:focus-visible:ring-gray-500","shadow-none","hover:shadow-none","border-2","border-transparent"],"link-action":["bg-transparent","text-slate-800","dark:text-slate-400","hover:text-slate-950","dark:hover:text-slate-200","active:text-slate-900","dark:active:text-slate-300","disabled:active:bg-transparent","dark:disabled:active:bg-transparent","disabled:active:shadow-none","focus-visible:ring-gray-400","dark:focus-visible:ring-gray-500","shadow-none","hover:shadow-none","border-2","border-transparent"],"link-neutral":["bg-transparent","text-gray-700","dark:text-gray-300","hover:text-gray-900","dark:hover:text-gray-100","active:text-gray-950","dark:active:text-gray-200","disabled:active:bg-transparent","dark:disabled:active:bg-transparent","disabled:active:shadow-none","focus-visible:ring-gray-400","dark:focus-visible:ring-gray-500","shadow-none","hover:shadow-none","border-2","border-transparent"],"link-info":["bg-transparent","text-blue-800","dark:text-blue-400","hover:text-blue-950","dark:hover:text-blue-300","active:text-blue-900","dark:active:text-blue-200","disabled:active:bg-transparent","dark:disabled:active:bg-transparent","disabled:active:shadow-none","focus-visible:ring-gray-400","dark:focus-visible:ring-gray-500","shadow-none","hover:shadow-none","border-2","border-transparent"],"link-warning":["bg-transparent","text-amber-800","dark:text-amber-400","hover:text-amber-950","dark:hover:text-amber-300","active:text-amber-900","dark:active:text-amber-200","disabled:active:bg-transparent","dark:disabled:active:bg-transparent","disabled:active:shadow-none","focus-visible:ring-gray-400","dark:focus-visible:ring-gray-500","shadow-none","hover:shadow-none","border-2","border-transparent"],"link-danger":["bg-transparent","text-red-800","dark:text-red-400","hover:text-red-950","dark:hover:text-red-300","active:text-red-900","dark:active:text-red-200","disabled:active:bg-transparent","dark:disabled:active:bg-transparent","disabled:active:shadow-none","focus-visible:ring-gray-400","dark:focus-visible:ring-gray-500","shadow-none","hover:shadow-none","border-2","border-transparent"]},r=`${e}-${s}`,a=n[r]||n["solid-neutral"],l=[...i,...a];if(this.isActive()){const o=this.getActiveStateClasses();l.push(...o),l.push("[&>*]:scale-95")}return this.isFullWidth()&&l.push("w-full"),l.join(" ")}render(){var c,d,p,h,m;const t=this.isDisabled()||this.isLoading(),e=this.getType();if(!this._button){for(this._button=document.createElement("button");this.firstChild;)this._button.appendChild(this.firstChild);this.appendChild(this._button),this.setupEventListeners()}this._button.type=e,this._button.disabled=t;let i=this._button.querySelector("mint-spinner");if(this.isLoading())if(i)i.setAttribute("data-button-variant",this.getVariant()),i.setAttribute("data-button-tone",this.getTone()),"render"in i&&typeof i.render=="function"&&i.render();else{const f=document.createElement("span");f.className="mr-2 inline-flex items-center";const u=document.createElement("mint-spinner");u.setAttribute("size","default"),u.setAttribute("data-button-variant",this.getVariant()),u.setAttribute("data-button-tone",this.getTone()),u.style.width="0.875rem",u.style.height="0.875rem",f.appendChild(u),this._button.insertBefore(f,this._button.firstChild)}else i&&((c=i.parentElement)==null||c.remove());for(;this.firstChild&&this.firstChild!==this._button;)this._button.appendChild(this.firstChild);const s=this.getIcon();let n=this._button.querySelector('[slot="icon"], .mint-button-icon, mint-icon');s?(n&&n.tagName!=="MINT-ICON"&&(n.remove(),n=null),!n||n.tagName!=="MINT-ICON"?(n=document.createElement("mint-icon"),n.setAttribute("name",s),n.className="mint-button-icon"):n.setAttribute("name",s)):n&&n.tagName==="MINT-ICON"&&(n.remove(),n=null),n||(n=this._button.querySelector('[slot="icon"], .mint-button-icon'));const r=this.getIconPosition();let a=this._button.querySelector(".mint-button-content");if(a){const f=n&&n.tagName==="MINT-ICON";if(n&&!n.parentElement){const u=(h=this._button.querySelector("mint-spinner"))==null?void 0:h.parentElement;f||r==="left"?u?u.insertAdjacentElement("afterend",n):this._button.insertBefore(n,a):a.insertAdjacentElement("afterend",n)}else if(n&&(f||r==="left")&&n.nextSibling!==a){n.remove();const u=(m=this._button.querySelector("mint-spinner"))==null?void 0:m.parentElement;u?u.insertAdjacentElement("afterend",n):this._button.insertBefore(n,a)}else n&&!f&&r==="right"&&n.previousSibling!==a&&(n.remove(),a.insertAdjacentElement("afterend",n))}else{const f=[];for(let u=this._button.firstChild;u;u=u.nextSibling){if(u.nodeType!==Node.ELEMENT_NODE){f.push(u);continue}const _=u;_.tagName!=="MINT-SPINNER"&&!_.querySelector("mint-spinner")&&u!==n&&!_.hasAttribute("slot")&&!(_.className==="mr-2"&&_.querySelector("mint-spinner"))&&f.push(u)}if(f.length>0){a=document.createElement("span"),a.className="mint-button-content inline-flex items-center",f.forEach(_=>{a.appendChild(_)});const u=(d=this._button.querySelector("mint-spinner"))==null?void 0:d.parentElement;n&&r==="left"?u?(u.insertAdjacentElement("afterend",n),n.insertAdjacentElement("afterend",a)):(this._button.insertBefore(n,this._button.firstChild),n.insertAdjacentElement("afterend",a)):n&&r==="right"?u?(u.insertAdjacentElement("afterend",a),a.insertAdjacentElement("afterend",n)):(this._button.insertBefore(a,this._button.firstChild),a.insertAdjacentElement("afterend",n)):u?u.insertAdjacentElement("afterend",a):this._button.insertBefore(a,this._button.firstChild)}else if(n&&n.tagName==="MINT-ICON"&&!n.parentElement){const u=(p=this._button.querySelector("mint-spinner"))==null?void 0:p.parentElement;u?u.insertAdjacentElement("afterend",n):this._button.insertBefore(n,this._button.firstChild)}}const l=this.isIconOnly();n&&(n.classList.contains("mint-button-icon")||n.classList.add("mint-button-icon"),n.classList.remove("mr-1.5","ml-1.5"),l?n.tagName==="MINT-ICON"?(n.style.width="1rem",n.style.height="1rem",n.style.maxWidth="1rem",n.style.maxHeight="1rem",n.style.flexShrink="0"):(n.style.maxWidth="1rem",n.style.maxHeight="1rem",n.style.flexShrink="0",n.tagName==="svg"&&(n.style.width="1rem",n.style.height="1rem")):r==="left"?n.classList.add("mr-1.5"):n.classList.add("ml-1.5"));const o=this.getButtonClasses();this._button.className=o}setupEventListeners(){this._button&&!this._clickHandler&&(this._clickHandler=this.handleClick.bind(this),this._clickHandler&&this._button.addEventListener("click",this._clickHandler,!0),this._button.addEventListener("mousedown",this._handleMouseDown),this._button.addEventListener("mouseup",this._handleMouseUp),this._button.addEventListener("mouseleave",this._handleMouseLeave),this._button.addEventListener("touchstart",this._handleTouchStart),this._button.addEventListener("touchend",this._handleTouchEnd),this._button.addEventListener("touchcancel",this._handleTouchCancel))}removeEventListeners(){this._button&&(this._clickHandler&&(this._button.removeEventListener("click",this._clickHandler,!0),this._clickHandler=null),this._button.removeEventListener("mousedown",this._handleMouseDown),this._button.removeEventListener("mouseup",this._handleMouseUp),this._button.removeEventListener("mouseleave",this._handleMouseLeave),this._button.removeEventListener("touchstart",this._handleTouchStart),this._button.removeEventListener("touchend",this._handleTouchEnd),this._button.removeEventListener("touchcancel",this._handleTouchCancel))}handleClick(t){if(this.isDisabled()||this.isLoading()){t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation();return}if(this.getType()==="submit"){this.dispatchEvent(new CustomEvent("click",{detail:{originalEvent:t},bubbles:!0,cancelable:!0,composed:!0}));return}if(t.stopPropagation(),t.stopImmediatePropagation(),this._isHandlingClick){t.preventDefault();return}this._isHandlingClick=!0,t.preventDefault(),this.dispatchEvent(new CustomEvent("click",{detail:{originalEvent:t},bubbles:!0,cancelable:!0,composed:!0})),requestAnimationFrame(()=>{this._isHandlingClick=!1})}}customElements.get("mint-button")||customElements.define("mint-button",P);class $ extends HTMLElement{constructor(){super(),this._button=null,this._checked=!1}static get observedAttributes(){return["checked","disabled","label","icon","info","error","error-message","loading"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline","block","w-full"),this._checked=this.hasAttribute("checked"),this.render()}_getSwitchContainer(){let t=this.querySelector(".mint-switch-container");return t||(t=document.createElement("div"),t.className="mint-switch-container flex items-center gap-2",this.insertBefore(t,this.firstChild)),t}disconnectedCallback(){this.removeEventListeners()}isLoading(){return this.hasAttribute("loading")}attributeChangedCallback(t,e,i){if(t==="checked"&&(this._checked=i!==null),e!==i){if(t==="error"||t==="error-message"){this._renderErrorState();return}if(t==="loading"){this.render();return}this.render()}}get checked(){return this._checked}set checked(t){t?this.setAttribute("checked",""):this.removeAttribute("checked"),this._checked=!!t,this.render()}isDisabled(){return this.hasAttribute("disabled")}getLabel(){return this.getAttribute("label")||""}getInfo(){return this.getAttribute("info")||""}getIcon(){return this.getAttribute("icon")||""}hasIcon(){return!!this.getIcon()}hasError(){return this.hasAttribute("error")}getErrorMessage(){return this.getAttribute("error-message")||""}getSwitchClasses(){const t=this.hasError(),e=["relative","inline-flex","items-center","rounded-full","h-5","w-10","border","transition-colors","duration-200","ease-in-out","outline-none","focus:outline-none","focus-visible:ring-2","focus-visible:ring-offset-1",t?"focus-visible:ring-red-400 dark:focus-visible:ring-red-500":"focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500","active:shadow-[inset_0_2px_4px_rgba(0,0,0,0.3)]","disabled:opacity-50","disabled:cursor-not-allowed"],i=this._checked?["bg-slate-950","dark:bg-slate-600",t?"border-red-300 dark:border-red-300":"border-slate-700 dark:border-slate-500"]:["bg-slate-200","dark:bg-slate-400",t?"border-red-300 dark:border-red-300":"border-slate-300 dark:border-slate-500"];return[...e,...i].join(" ")}getThumbClasses(){const t=["relative","inline-block","rounded-full","bg-white","dark:bg-gray-50","h-4","w-4","shadow-lg","transform","transition-transform","duration-200","ease-in-out","pointer-events-none","overflow-hidden"],e=this._checked?"translate-x-5":"translate-x-0.5";return[...t,e].join(" ")}getIconClasses(){return["absolute","inset-0","flex","items-center","justify-center","pointer-events-none"].join(" ")}render(){const t=this.isLoading(),e=this.getSwitchClasses(),i=this.getThumbClasses(),s=this.getLabel(),n=this.getInfo(),r=this.getIcon(),a=this.getAttribute("id")||`mint-switch-${Math.random().toString(36).substr(2,9)}`;this.getAttribute("id")||this.setAttribute("id",a);const l=this._getSwitchContainer();this._button?this._button.parentElement!==l&&l.appendChild(this._button):(this._button=document.createElement("button"),l.appendChild(this._button),this.setupEventListeners());let o=l.querySelector(".mint-switch-label");s?(o||(o=document.createElement("label"),o.className="mint-switch-label text-sm font-medium text-gray-900 dark:text-gray-100 select-none",this._button&&this._button.parentElement===l?l.insertBefore(o,this._button.nextSibling):l.appendChild(o)),o.textContent=s,o.setAttribute("for",a),this.isDisabled()?o.classList.add("opacity-40"):o.classList.remove("opacity-40")):o&&o.remove(),this._button.className=e,this._button.disabled=this.isDisabled(),this._button.id=a,this._button.setAttribute("aria-checked",String(this._checked)),this._button.setAttribute("aria-label",s||"Toggle switch"),this._button.setAttribute("role","switch"),this._button.type="button";let c=this._button.querySelector("span");c||(c=document.createElement("span"),this._button.appendChild(c)),c.className=i;const d=c.querySelector("span");if(r){let h=d;h||(h=document.createElement("span"),h.className=this.getIconClasses(),c.appendChild(h));let m=h.querySelector("mint-icon");m||(m=document.createElement("mint-icon"),h.appendChild(m)),m.setAttribute("name",r)}else d&&d.remove();let p=this.querySelector(".mint-switch-info");n?(p||(p=document.createElement("span"),p.className="mint-switch-info text-xs text-gray-500 dark:text-gray-400 select-none mt-1 block",l&&l.parentElement===this?this.insertBefore(p,l.nextSibling):this.appendChild(p)),p.textContent=n,this.isDisabled()?p.classList.add("opacity-40"):p.classList.remove("opacity-40")):p&&p.remove(),this._renderErrorState(),this._renderSkeleton(t)}setupEventListeners(){this._button&&this._button.addEventListener("click",this.handleToggle.bind(this))}removeEventListeners(){this._button&&this._button.removeEventListener("click",this.handleToggle.bind(this))}handleToggle(t){this.isDisabled()||(this.checked=!this._checked,this.dispatchEvent(new CustomEvent("change",{detail:{checked:this._checked},bubbles:!0,cancelable:!0})),this.dispatchEvent(new CustomEvent("toggle",{detail:{checked:this._checked},bubbles:!0,cancelable:!0})))}_renderSkeleton(t){const e=this._getSwitchContainer(),i=this.getLabel(),s=this.getInfo();let n=e.querySelector(".mint-switch-skeleton-container"),r=this.querySelector(".mint-switch-info-skeleton");if(t){e.classList.contains("relative")||e.classList.add("relative"),n||(n=document.createElement("div"),n.className="mint-switch-skeleton-container absolute inset-0 z-10 pointer-events-none flex items-center gap-2",e.appendChild(n));let a=n.querySelector(".mint-switch-skeleton-box");if(a||(a=document.createElement("div"),a.className="mint-switch-skeleton-box flex-shrink-0 w-10 h-5 rounded-full bg-gray-200 dark:bg-gray-700 animate-pulse",n.appendChild(a)),i){let o=n.querySelector(".mint-switch-skeleton-label");o||(o=document.createElement("div"),o.className="mint-switch-skeleton-label h-4 w-24 rounded bg-gray-200 dark:bg-gray-700 animate-pulse",n.appendChild(o))}else{const o=n.querySelector(".mint-switch-skeleton-label");o&&o.remove()}n.style.display="flex",this._button&&(this._button.style.visibility="hidden",this._button.style.pointerEvents="none");const l=e.querySelector(".mint-switch-label");if(l&&(l.style.visibility="hidden",l.style.pointerEvents="none"),s){r||(r=document.createElement("div"),r.className="mint-switch-info-skeleton h-3 w-32 rounded bg-gray-200 dark:bg-gray-700 animate-pulse mt-2",e&&e.parentElement===this?this.insertBefore(r,e.nextSibling):this.appendChild(r)),r.style.display="block";const o=this.querySelector(".mint-switch-info");o&&(o.style.display="none")}else r&&(r.style.display="none")}else{n&&(n.style.display="none"),r&&(r.style.display="none"),this._button&&(this._button.style.visibility="visible",this._button.style.pointerEvents="auto");const a=e.querySelector(".mint-switch-label");a&&(a.style.visibility="visible",a.style.pointerEvents="auto");const l=this.querySelector(".mint-switch-info");l&&(l.style.display="")}}_renderErrorState(){const t=this.hasError(),e=this.getErrorMessage();let i=this.querySelector(".mint-switch-error");t&&e?(i||(i=document.createElement("div"),i.className="mint-switch-error mt-1 text-xs text-red-600 dark:text-red-400",this.appendChild(i)),i.textContent=e):i&&i.remove(),this._button&&(this._button.className=this.getSwitchClasses())}}customElements.get("mint-switch")||customElements.define("mint-switch",$);class O extends HTMLElement{constructor(){super(),this._darkModeObserver=null,this._userClasses=new Set}static get observedAttributes(){return["variant","size","bold","underline","strike","italic","display"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline"),this._captureUserClasses(),this.render(),this._observeDarkMode()}_captureUserClasses(){Array.from(this.classList).forEach(e=>this._userClasses.add(e))}attributeChangedCallback(t,e,i){e!==i&&this.render()}disconnectedCallback(){this._darkModeObserver&&(this._darkModeObserver.disconnect(),this._darkModeObserver=null)}_observeDarkMode(){this._darkModeObserver||(this._darkModeObserver=new MutationObserver(()=>{this.render()}),this._darkModeObserver.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}))}getVariant(){return this.getAttribute("variant")||"default"}getSize(){return this.getAttribute("size")||"regular"}isBold(){return this.hasAttribute("bold")}isUnderline(){return this.hasAttribute("underline")}isStrike(){return this.hasAttribute("strike")}isItalic(){return this.hasAttribute("italic")}getDisplay(){return this.hasAttribute("display")?this.getAttribute("display"):this.getSize()==="regular"?"inline-block":"block"}getTextClasses(){const t=this.getSize(),e=this.getVariant(),i=document.documentElement.classList.contains("dark"),s={heading:["font-semibold"],"sub-heading":["font-medium"],regular:[]},n={default:i?["text-gray-100"]:["text-gray-900"],muted:i?["text-gray-400"]:["text-gray-400"],danger:i?["text-red-400"]:["text-red-600"],success:i?["text-green-400"]:["text-green-600"]},r=[];this.isBold()&&r.push("font-bold"),this.isUnderline()&&r.push("underline"),this.isStrike()&&r.push("line-through"),this.isItalic()&&r.push("italic");const a=this.getDisplay();return[a==="block"?"block":a==="inline"?"inline":"inline-block",...s[t]||s.regular,...n[e]||n.default,...r].join(" ")}render(){const t=this.getSize(),e=["text-gray-100","text-gray-900","text-gray-400","text-red-400","text-red-600","text-green-400","text-green-600"],i=["text-2xl","text-lg","text-sm"];i.forEach(o=>{this.classList.remove(o),this._userClasses.delete(o)}),e.forEach(o=>{this.classList.remove(o),this._userClasses.delete(o)});const s=this.getTextClasses().split(" ").filter(o=>o.trim());Array.from(this.classList).forEach(o=>{!e.includes(o)&&!i.includes(o)&&this._userClasses.add(o)});const r=[...new Set([...s,...Array.from(this._userClasses)])];this.className=r.join(" ");const a={heading:"clamp(1.25rem, 2.5vw + 0.5rem, 1.5rem)","sub-heading":"clamp(1rem, 1.5vw + 0.5rem, 1.125rem)",regular:"clamp(0.875rem, 1vw + 0.5rem, 0.875rem)"},l=a[t]||a.regular;this.style.setProperty("font-size",l)}}customElements.get("mint-text")||customElements.define("mint-text",O);class B extends HTMLElement{constructor(){super(),this._childObserver=null}static get observedAttributes(){return["direction","text-align","gap"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline","block"),this.render(),this.getTextAlign()&&this._observeChildren()}attributeChangedCallback(t,e,i){e!==i&&(this.render(),t==="text-align"&&this._observeChildren())}_observeChildren(){this._childObserver||(this._childObserver=new MutationObserver(()=>{const t=this.getTextAlign();t&&this._applyTextAlignToChildren(t)}),this._childObserver.observe(this,{childList:!0,subtree:!1}))}disconnectedCallback(){this._childObserver&&(this._childObserver.disconnect(),this._childObserver=null)}getDirection(){return(this.getAttribute("direction")||"vertical")==="horizontal"?"horizontal":"vertical"}getGap(){const t=this.getAttribute("gap")||"3";return parseFloat(t)}getTextAlign(){const t=this.getAttribute("text-align")||"";return["left","center","right","justify"].includes(t)?t:""}getStackClasses(){const t=this.getDirection(),e=this.getTextAlign(),i=this.getGap(),s=["flex",t==="horizontal"?"flex-row":"flex-col",`gap-${i}`];return e&&(s.push(`text-${e}`),s.push(`[&>*]:text-${e}`),s.push(`[&>*_.mint-button-content]:text-${e}`),e==="left"?(s.push("[&>mint-button]:!justify-start"),s.push("[&>mint-button>button]:!justify-start")):e==="right"?(s.push("[&>mint-button]:!justify-end"),s.push("[&>mint-button>button]:!justify-end")):e==="center"&&(s.push("[&>mint-button]:!justify-center"),s.push("[&>mint-button>button]:!justify-center"))),s.join(" ")}render(){const t=this.getStackClasses(),e=this.getTextAlign();["flex","flex-row","flex-col","gap-1","gap-2","gap-3","text-left","text-center","text-right","text-justify","[&>*]:text-left","[&>*]:text-center","[&>*]:text-right","[&>*]:text-justify","[&>*_.mint-button-content]:text-left","[&>*_.mint-button-content]:text-center","[&>*_.mint-button-content]:text-right","[&>*_.mint-button-content]:text-justify","[&>mint-button]:!justify-start","[&>mint-button]:!justify-center","[&>mint-button]:!justify-end","[&>mint-button>button]:!justify-start","[&>mint-button>button]:!justify-center","[&>mint-button>button]:!justify-end"].forEach(n=>this.classList.remove(n)),t.split(" ").forEach(n=>{n&&this.classList.add(n)}),["box-border","m-0","p-0","border-0","align-baseline","block"].forEach(n=>{this.classList.contains(n)||this.classList.add(n)}),e?this._applyTextAlignToChildren(e):this._removeTextAlignFromChildren()}_applyTextAlignToChildren(t){Array.from(this.children).forEach(i=>{if(i.tagName==="MINT-BUTTON"){const s=i.querySelector("button");if(s){s.classList.remove("justify-start","justify-center","justify-end"),t==="left"?s.classList.add("justify-start"):t==="right"?s.classList.add("justify-end"):t==="center"&&s.classList.add("justify-center");const n=s.querySelector(".mint-button-content");n&&(n.classList.remove("text-left","text-center","text-right","text-justify"),n.classList.add(`text-${t}`))}}else i.classList.remove("text-left","text-center","text-right","text-justify"),i.classList.add(`text-${t}`)})}_removeTextAlignFromChildren(){Array.from(this.children).forEach(e=>{if(e.tagName==="MINT-BUTTON"){const i=e.querySelector("button");if(i){i.classList.remove("justify-start","justify-end"),i.classList.add("justify-center");const s=i.querySelector(".mint-button-content");s&&s.classList.remove("text-left","text-center","text-right","text-justify")}}else e.classList.remove("text-left","text-center","text-right","text-justify")})}}customElements.get("mint-stack")||customElements.define("mint-stack",B);class z extends HTMLElement{constructor(){super(),this._headingElement=null}static get observedAttributes(){return["heading"]}connectedCallback(){this.classList.add("box-border","m-0","border-0","align-baseline","block"),this.render()}attributeChangedCallback(t,e,i){e!==i&&this.render()}getHeading(){return this.getAttribute("heading")||""}hasPaddingClass(){return Array.from(this.classList).some(e=>/^p-\d+|^px-|^py-|^pt-|^pb-|^pl-|^pr-/.test(e))}render(){this.classList.add("rounded-lg","shadow","bg-white","dark:bg-gray-800","border","border-gray-200","dark:border-gray-700","overflow-hidden","transition-colors","duration-200","mb-6"),this.hasPaddingClass()||this.classList.add("p-4");const t=this.getHeading();t?(this._headingElement||(this._headingElement=document.createElement("mint-text"),this._headingElement.setAttribute("size","sub-heading"),this.insertBefore(this._headingElement,this.firstChild)),this._headingElement.textContent=t):this._headingElement&&this._headingElement.parentNode&&(this._headingElement.remove(),this._headingElement=null)}}customElements.get("mint-card")||customElements.define("mint-card",z);class R extends HTMLElement{constructor(){super(),this._link=null,this._contentObserver=null}static get observedAttributes(){return["href","target"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline","inline-block"),this.render(),this._observeContent()}disconnectedCallback(){this._contentObserver&&(this._contentObserver.disconnect(),this._contentObserver=null)}_observeContent(){this._contentObserver||(this._contentObserver=new MutationObserver(()=>{this._link&&this._link.querySelectorAll("mint-text").forEach(e=>{e.classList.contains("underline")||e.classList.add("underline")})}),this._contentObserver.observe(this,{childList:!0,subtree:!0}))}attributeChangedCallback(t,e,i){e!==i&&this.render()}getHref(){return this.getAttribute("href")||"#"}getTarget(){return this.getAttribute("target")||""}hasIcon(){var t;return!!(this.querySelector("mint-icon")||(t=this._link)!=null&&t.querySelector("mint-icon"))}render(){const t=this.getHref(),e=this.getTarget();if(!this._link){for(this._link=document.createElement("a");this.firstChild;)this._link.appendChild(this.firstChild);this.appendChild(this._link)}this._link.href=t,e?(this._link.target=e,e==="_blank"&&(this._link.rel="noopener noreferrer")):(this._link.removeAttribute("target"),this._link.removeAttribute("rel"));const i=this.hasIcon(),s=["text-slate-800","dark:text-slate-200","underline","hover:text-slate-950","dark:hover:text-slate-100","transition-colors","duration-200","focus-visible:outline-none","focus-visible:ring-2","focus-visible:ring-offset-1","focus-visible:ring-gray-400","dark:focus-visible:ring-gray-500","rounded"];i&&s.push("inline-flex","items-center","gap-2"),this._link.className=s.join(" "),this._link.querySelectorAll("mint-text").forEach(a=>{a.classList.contains("underline")||a.classList.add("underline")}),["box-border","m-0","p-0","border-0","align-baseline","inline-block"].forEach(a=>{this.classList.contains(a)||this.classList.add(a)})}}customElements.get("mint-link")||customElements.define("mint-link",R);class W extends HTMLElement{constructor(){super(),this._button=null}static get observedAttributes(){return["href","fallback-href"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline","inline-block","flex","items-center","justify-center"),this.render()}disconnectedCallback(){}attributeChangedCallback(t,e,i){e!==i&&this.render()}getFallbackHref(){return this.getAttribute("fallback-href")||this.getAttribute("href")||"/"}_getTargetUrl(){const t=document.referrer,e=window.location.origin;if(t)try{const i=new URL(t);if(i.origin===e)return i.pathname+i.search}catch{}return this.getFallbackHref()}handleClick(t){t.preventDefault(),t.stopPropagation();const e=this._getTargetUrl(),i=document.referrer,s=i&&(()=>{try{return new URL(i).origin===window.location.origin}catch{return!1}})(),n=new CustomEvent("back",{detail:{url:e,isFromReferrer:s,referrer:i||null,fallbackHref:this.getFallbackHref()},bubbles:!0,cancelable:!0,composed:!0});this.dispatchEvent(n)}render(){this._button||(this._button=document.createElement("mint-button"),this._button.setAttribute("variant","neutral"),this._button.setAttribute("icon","arrow-left"),this._button.addEventListener("click",t=>this.handleClick(t)),this.appendChild(this._button))}}customElements.get("mint-back-button")||customElements.define("mint-back-button",W);class V extends HTMLElement{constructor(){super(),this._pageContainer=null,this._header=null,this._titleElement=null,this._headingText=null,this._actionsSlot=null,this._bodySlot=null,this._darkModeObserver=null,this._backButton=null,this._backButtonHandler=null}static get observedAttributes(){return["heading","fallback-href","show-back-button","containered"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline","block"),this.render(),this._observeDarkMode(),this._setupBackButtonListener()}attributeChangedCallback(t,e,i){e!==i&&this.render()}disconnectedCallback(){this._darkModeObserver&&(this._darkModeObserver.disconnect(),this._darkModeObserver=null),this._removeBackButtonListener()}getHeading(){return this.getAttribute("heading")||""}getFallbackHref(){return this.getAttribute("fallback-href")||"/"}shouldShowBackButton(){return this.hasAttribute("show-back-button")}render(){const t=this.getHeading();this._pageContainer||(this._pageContainer=document.createElement("div"),this.appendChild(this._pageContainer)),this._applyContainerClasses(),this._header||(this._header=document.createElement("div"),this._header.className="flex justify-between mb-8",this._pageContainer.appendChild(this._header)),this._titleElement||(this._titleElement=document.createElement("div"),this._titleElement.className="flex gap-4 min-w-0 flex-1",this._header.appendChild(this._titleElement));let e=this._titleElement.querySelector("mint-back-button");if(this.shouldShowBackButton()){e||(e=document.createElement("mint-back-button"),this._titleElement.insertBefore(e,this._titleElement.firstChild));const r=this.getFallbackHref();e.setAttribute("fallback-href",r),this._backButton=e}else e&&(e.remove(),e=null,this._backButton=null);t?(this._headingText?(this._headingText.classList.add("truncate","min-w-0"),e&&e.parentElement===this._titleElement?this._headingText.previousSibling!==e&&this._titleElement.insertBefore(this._headingText,e.nextSibling):this._headingText.previousSibling&&this._titleElement.insertBefore(this._headingText,this._titleElement.firstChild)):(this._headingText=document.createElement("mint-text"),this._headingText.setAttribute("size","heading"),this._headingText.setAttribute("bold",""),this._headingText.classList.add("truncate","min-w-0"),e&&e.parentElement===this._titleElement?this._titleElement.insertBefore(this._headingText,e.nextSibling):this._titleElement.insertBefore(this._headingText,this._titleElement.firstChild)),this._headingText.textContent=t):this._headingText&&(this._headingText.remove(),this._headingText=null),this._actionsSlot?this._actionsSlot.classList.contains("ml-4")||this._actionsSlot.classList.add("ml-4"):(this._actionsSlot=document.createElement("div"),this._actionsSlot.className="flex gap-2 items-center ml-4",this._actionsSlot.setAttribute("slot","actions"),this._header.appendChild(this._actionsSlot)),Array.from(this.children).filter(r=>r!==this._pageContainer&&r!==this._actionsSlot&&r.getAttribute("slot")==="actions").forEach(r=>{this._actionsSlot&&r.parentElement!==this._actionsSlot&&this._actionsSlot.appendChild(r)}),this._bodySlot||(this._bodySlot=document.createElement("div"),this._pageContainer.appendChild(this._bodySlot)),Array.from(this.children).forEach(r=>{r!==this._pageContainer&&r.getAttribute("slot")!=="actions"&&r!==this._actionsSlot&&r!==this._header&&r!==this._bodySlot&&r!==this._headingText&&r.parentElement!==this._bodySlot&&r.parentElement!==this._pageContainer&&this._bodySlot.appendChild(r)}),this._updateBackgroundColor()}_applyContainerClasses(){this._pageContainer&&(this._pageContainer.classList.add("min-h-screen","p-8","transition-colors","duration-200"),this.hasAttribute("containered")?this._pageContainer.classList.add("max-w-6xl","mx-auto","w-full"):this._pageContainer.classList.remove("max-w-6xl","mx-auto"))}_updateBackgroundColor(){if(!this._pageContainer)return;document.documentElement.classList.contains("dark")?(this._pageContainer.classList.remove("bg-gray-20"),this._pageContainer.classList.add("bg-gray-900")):(this._pageContainer.classList.remove("bg-gray-900"),this._pageContainer.classList.add("bg-gray-20"))}_observeDarkMode(){this._darkModeObserver||(this._darkModeObserver=new MutationObserver(()=>{this._updateBackgroundColor()}),this._darkModeObserver.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}))}_setupBackButtonListener(){this._backButtonHandler||(this._backButtonHandler=t=>{const e=t.target;if(e&&e.tagName==="MINT-BACK-BUTTON"){t.stopPropagation();const i=new CustomEvent("back",{detail:t.detail,bubbles:!0,cancelable:!0,composed:!0});this.dispatchEvent(i)}}),this.addEventListener("back",this._backButtonHandler,!0)}_removeBackButtonListener(){this._backButtonHandler&&(this.removeEventListener("back",this._backButtonHandler,!0),this._backButtonHandler=null)}}customElements.get("mint-page")||customElements.define("mint-page",V);class j extends HTMLElement{static get observedAttributes(){return["columns","sm","md","lg","xl","gap"]}constructor(){super()}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline","block"),this.render()}attributeChangedCallback(t,e,i){e!==i&&this.render()}getColumns(){return this.getAttribute("columns")||"1"}getSm(){return this.getAttribute("sm")}getMd(){return this.getAttribute("md")}getLg(){return this.getAttribute("lg")}getXl(){return this.getAttribute("xl")}getGap(){return"3"}getGridClasses(){const t=["grid"],e=this.getColumns();t.push(`grid-cols-${e}`);const i=this.getSm();i&&t.push(`sm:grid-cols-${i}`);const s=this.getMd();s&&t.push(`md:grid-cols-${s}`);const n=this.getLg();n&&t.push(`lg:grid-cols-${n}`);const r=this.getXl();r&&t.push(`xl:grid-cols-${r}`);const a=this.getGap();return t.push(`gap-${a}`),t}render(){Array.from(this.classList).filter(i=>i.startsWith("grid-cols-")||i.startsWith("sm:grid-cols-")||i.startsWith("md:grid-cols-")||i.startsWith("lg:grid-cols-")||i.startsWith("xl:grid-cols-")||i.startsWith("gap-")).forEach(i=>this.classList.remove(i)),this.classList.contains("grid")||this.classList.add("grid"),this.getGridClasses().forEach(i=>{i&&i!=="grid"&&this.classList.add(i)})}}customElements.get("mint-grid")||customElements.define("mint-grid",j);class Y extends HTMLElement{constructor(){super(),this._overlay=null,this._modal=null,this._header=null,this._headingSlot=null,this._bodySlot=null,this._actionsSlot=null,this._closeButton=null,this._darkModeObserver=null}static get observedAttributes(){return["id","heading","open"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline","fixed","inset-0","z-50"),this.isOpen()||this.classList.add("hidden"),this.render(),this._observeDarkMode()}disconnectedCallback(){this._darkModeObserver&&(this._darkModeObserver.disconnect(),this._darkModeObserver=null)}attributeChangedCallback(t,e,i){e!==i&&this.render()}getId(){return this.getAttribute("id")||""}getHeading(){return this.getAttribute("heading")||""}isOpen(){return this.hasAttribute("open")}open(){this.setAttribute("open","")}close(){this.removeAttribute("open")}render(){const t=this.getId(),e=this.getHeading(),i=this.isOpen();if(t&&(this.id=t),this._overlay||(this._overlay=document.createElement("div"),this._overlay.className="fixed inset-0 bg-black bg-opacity-50 transition-opacity duration-200 z-40",this._overlay.addEventListener("click",()=>this.close()),this.appendChild(this._overlay)),this._modal||(this._modal=document.createElement("div"),this._modal.className="fixed inset-0 flex items-center justify-center p-2 pointer-events-none z-50",this.appendChild(this._modal)),i){let d=this._modal.querySelector(".modal-content");d||(d=document.createElement("div"),d.className="modal-content bg-white dark:bg-gray-800 rounded-lg shadow-xl max-w-2xl w-full max-h-[90vh] flex flex-col pointer-events-auto transition-all duration-200 ease-out transform",this._modal.appendChild(d)),this._animateEnter()}else this._animateExit();let s=this._modal.querySelector(".modal-content");s||(s=document.createElement("div"),s.className="modal-content bg-white dark:bg-gray-800 rounded-lg shadow-xl max-w-2xl w-full max-h-[90vh] flex flex-col pointer-events-auto transition-all duration-200 ease-out transform",this._modal.appendChild(s)),this._header||(this._header=document.createElement("div"),this._header.className="flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700",s.appendChild(this._header)),this._headingSlot||(this._headingSlot=document.createElement("div"),this._headingSlot.className="flex-1",this._headingSlot.setAttribute("slot","heading"),this._header.appendChild(this._headingSlot));let n=this._headingSlot.querySelector("mint-text");e?(n||(n=document.createElement("mint-text"),n.setAttribute("size","sub-heading"),n.setAttribute("bold",""),this._headingSlot.appendChild(n)),n.textContent=e):n&&n.remove(),Array.from(this.children).filter(d=>d!==this._overlay&&d!==this._modal&&d!==this._headingSlot&&d.getAttribute("slot")==="heading").forEach(d=>{this._headingSlot&&d.parentElement!==this._headingSlot&&this._headingSlot.appendChild(d)}),this._closeButton||(this._closeButton=document.createElement("mint-button"),this._closeButton.setAttribute("variant","ghost"),this._closeButton.setAttribute("icon","close"),this._closeButton.addEventListener("click",()=>this.close()),this._header.appendChild(this._closeButton)),this._bodySlot||(this._bodySlot=document.createElement("div"),this._bodySlot.className="flex-1 overflow-y-auto p-4",this._bodySlot.setAttribute("slot","body"),s.appendChild(this._bodySlot)),Array.from(this.children).filter(d=>d!==this._overlay&&d!==this._modal&&d!==this._bodySlot&&d.getAttribute("slot")==="body").forEach(d=>{this._bodySlot&&d.parentElement!==this._bodySlot&&this._bodySlot.appendChild(d)}),this._actionsSlot||(this._actionsSlot=document.createElement("div"),this._actionsSlot.className="p-4 border-t border-gray-200 dark:border-gray-700",this._actionsSlot.setAttribute("slot","actions"),s.appendChild(this._actionsSlot));let l=this._actionsSlot.querySelector("mint-stack");l||(l=document.createElement("mint-stack"),l.setAttribute("direction","horizontal"),l.className="justify-end",this._actionsSlot.appendChild(l)),Array.from(this.children).filter(d=>d!==this._overlay&&d!==this._modal&&d!==this._actionsSlot&&d.getAttribute("slot")==="actions").forEach(d=>{Array.from(d.children).forEach(h=>{h.parentElement!==l&&l.appendChild(h)}),d.parentElement&&d.remove()}),Array.from(this.children).forEach(d=>{d!==this._overlay&&d!==this._modal&&d.getAttribute("slot")!=="heading"&&d.getAttribute("slot")!=="body"&&d.getAttribute("slot")!=="actions"&&d!==this._headingSlot&&d!==this._bodySlot&&d!==this._actionsSlot&&d.parentElement!==this._bodySlot&&this._bodySlot.appendChild(d)}),this._updateBackgroundColor()}_updateBackgroundColor(){if(!this._modal)return;const t=document.documentElement.classList.contains("dark"),e=this._modal.querySelector(".modal-content");e&&(t?(e.classList.remove("bg-white"),e.classList.add("bg-gray-800")):(e.classList.remove("bg-gray-800"),e.classList.add("bg-white")))}_observeDarkMode(){this._darkModeObserver||(this._darkModeObserver=new MutationObserver(()=>{this._updateBackgroundColor()}),this._darkModeObserver.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}))}_animateEnter(){var e;const t=(e=this._modal)==null?void 0:e.querySelector(".modal-content");t&&(t.style.transform="scale(0.97) translateY(10px)",t.style.opacity="0",t.style.transition="all 200ms ease-out",this.classList.remove("hidden"),requestAnimationFrame(()=>{requestAnimationFrame(()=>{t.style.transform="scale(1) translateY(0)",t.style.opacity="1"})}))}_animateExit(){var e;const t=(e=this._modal)==null?void 0:e.querySelector(".modal-content");if(!t){this.classList.add("hidden");return}t.style.transition="all 200ms ease-in",t.style.transform="scale(0.97) translateY(10px)",t.style.opacity="0",setTimeout(()=>{this.classList.add("hidden"),t.style.transform="",t.style.opacity="",t.style.transition=""},200)}}customElements.get("mint-modal")||customElements.define("mint-modal",Y);class U extends HTMLElement{constructor(){super(),this._overlay=null,this._popover=null,this._triggerElement=null,this._darkModeObserver=null,this._clickOutsideHandler=null,this._triggerClickHandler=null,this._triggerHoverEnterHandler=null,this._triggerHoverLeaveHandler=null,this._popoverHoverEnterHandler=null,this._popoverHoverLeaveHandler=null,this._hoverCloseTimeout=null,this._scrollHandler=null,this._resizeHandler=null}static get observedAttributes(){return["id","direction","open","trigger-id","padding","hover"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline","fixed","top-0","left-0","z-50","pointer-events-none"),this.isOpen()||this.classList.add("hidden"),this.render(),this._setupTrigger(),this._observeDarkMode()}disconnectedCallback(){this._darkModeObserver&&(this._darkModeObserver.disconnect(),this._darkModeObserver=null),this._clickOutsideHandler&&(document.removeEventListener("click",this._clickOutsideHandler),this._clickOutsideHandler=null),this._triggerClickHandler&&this._triggerElement&&(this._triggerElement.removeEventListener("click",this._triggerClickHandler,!0),this._triggerClickHandler=null),this._removeHoverListeners(),this._scrollHandler&&(window.removeEventListener("scroll",this._scrollHandler,!0),this._scrollHandler=null),this._resizeHandler&&(window.removeEventListener("resize",this._resizeHandler),this._resizeHandler=null)}attributeChangedCallback(t,e,i){e!==i&&(this.render(),(t==="trigger-id"||t==="hover")&&this._setupTrigger(),t==="open"&&this.isOpen()&&this._closeOtherPopovers())}getId(){return this.getAttribute("id")||""}getPadding(){const t=this.getAttribute("padding")||"4";return{0:"p-0","0.5":"p-0.5",1:"p-1","1.5":"p-1.5",2:"p-2","2.5":"p-2.5",3:"p-3","3.5":"p-3.5",4:"p-4",5:"p-5",6:"p-6",8:"p-8",10:"p-10",12:"p-12",16:"p-16",20:"p-20",24:"p-24"}[t]||"p-4"}getDirection(){return this.getAttribute("direction")||"down"}getTriggerId(){return this.getAttribute("trigger-id")||""}isHoverEnabled(){return this.hasAttribute("hover")}isOpen(){return this.hasAttribute("open")}open(){this.setAttribute("open","")}close(){this.removeAttribute("open")}_setupTrigger(){const t=this.getTriggerId();this._triggerClickHandler&&this._triggerElement&&(this._triggerElement.removeEventListener("click",this._triggerClickHandler,!0),this._triggerClickHandler=null),this._removeHoverListeners(),t&&(this._triggerElement=document.getElementById(t),this._triggerElement?(this._attachTriggerListener(),this.isHoverEnabled()&&this._attachHoverListeners()):setTimeout(()=>{this._triggerElement=document.getElementById(t),this._triggerElement&&(this._attachTriggerListener(),this.isHoverEnabled()&&this._attachHoverListeners())},10))}_attachTriggerListener(){if(this._triggerElement&&!this._triggerClickHandler){const t=this;this._triggerClickHandler=function(e){e.stopImmediatePropagation(),e.preventDefault(),t.hasAttribute("open")?t.removeAttribute("open"):t.setAttribute("open","")},this._triggerElement.addEventListener("click",this._triggerClickHandler,!0)}}_attachHoverListeners(){if(!this.isHoverEnabled()||!this._triggerElement)return;this._removeHoverListeners();const t=this;this._triggerHoverEnterHandler=function(){t._cancelHoverClose(),t.open()},this._triggerHoverLeaveHandler=function(e){var s;const i=e.relatedTarget;i&&(t.contains(i)||(s=t._triggerElement)!=null&&s.contains(i))||t._scheduleHoverClose()},this._triggerElement.addEventListener("mouseenter",this._triggerHoverEnterHandler),this._triggerElement.addEventListener("mouseleave",this._triggerHoverLeaveHandler),this._popover&&(this._popoverHoverEnterHandler=function(){t._cancelHoverClose()},this._popoverHoverLeaveHandler=function(e){var s;const i=e.relatedTarget;i&&(t.contains(i)||(s=t._triggerElement)!=null&&s.contains(i))||t._scheduleHoverClose()},this._popover.addEventListener("mouseenter",this._popoverHoverEnterHandler),this._popover.addEventListener("mouseleave",this._popoverHoverLeaveHandler))}_removeHoverListeners(){this._triggerElement&&this._triggerHoverEnterHandler&&this._triggerElement.removeEventListener("mouseenter",this._triggerHoverEnterHandler),this._triggerElement&&this._triggerHoverLeaveHandler&&this._triggerElement.removeEventListener("mouseleave",this._triggerHoverLeaveHandler),this._popover&&this._popoverHoverEnterHandler&&this._popover.removeEventListener("mouseenter",this._popoverHoverEnterHandler),this._popover&&this._popoverHoverLeaveHandler&&this._popover.removeEventListener("mouseleave",this._popoverHoverLeaveHandler),this._triggerHoverEnterHandler=null,this._triggerHoverLeaveHandler=null,this._popoverHoverEnterHandler=null,this._popoverHoverLeaveHandler=null,this._cancelHoverClose()}_scheduleHoverClose(){this._cancelHoverClose(),this._hoverCloseTimeout=window.setTimeout(()=>{this._isHovering()||this.close()},120)}_cancelHoverClose(){this._hoverCloseTimeout!==null&&(clearTimeout(this._hoverCloseTimeout),this._hoverCloseTimeout=null)}_isHovering(){const t=this._triggerElement?this._triggerElement.matches(":hover"):!1,e=this._popover?this._popover.matches(":hover"):!1;return t||e}_calculatePosition(){if(!this._triggerElement||!this._popover)return{top:0,left:0,direction:"down"};const t=this._triggerElement.getBoundingClientRect(),e=this._popover.querySelector(".popover-content");if(!e)return{top:0,left:0,direction:"down"};this.classList.contains("hidden")&&(this.classList.remove("hidden"),this._popover.style.visibility="hidden");const s=e.getBoundingClientRect(),n=window.innerWidth,r=window.innerHeight,a=8;let l=this.getDirection(),o=0,c=0;switch(l){case"down":if(o=t.bottom+a,c=t.left+t.width/2-s.width/2,o+s.height>r){const d=t.top-s.height-a;d>=0?(l="up",o=d):(o=Math.max(0,r-s.height-a),o+s.height>r&&(o=0))}c<0&&(c=a),c+s.width>n&&(c=Math.max(a,n-s.width-a),c+s.width>n&&(c=n-s.width));break;case"up":if(o=t.top-s.height-a,c=t.left+t.width/2-s.width/2,o<0){const d=t.bottom+a;d+s.height<=r?(l="down",o=d):(o=Math.min(r-s.height-a,r-s.height),o<0&&(o=r-s.height))}c<0&&(c=a),c+s.width>n&&(c=Math.max(a,n-s.width-a),c+s.width>n&&(c=n-s.width));break;case"right":if(o=t.top+t.height/2-s.height/2,c=t.right+a,c+s.width>n){const d=t.left-s.width-a;d>=0?(l="left",c=d):(c=Math.max(0,n-s.width-a),c+s.width>n&&(c=n-s.width))}o<0&&(o=a),o+s.height>r&&(o=Math.max(a,r-s.height-a),o+s.height>r&&(o=r-s.height));break;case"left":if(o=t.top+t.height/2-s.height/2,c=t.left-s.width-a,c<0){const d=t.right+a;d+s.width<=n?(l="right",c=d):(c=Math.min(n-s.width-a,n-s.width),c<0&&(c=0))}o<0&&(o=a),o+s.height>r&&(o=Math.max(a,r-s.height-a),o+s.height>r&&(o=r-s.height));break}return{top:o,left:c,direction:l}}render(){const t=this.getId(),e=this.isOpen(),i=this.getPadding();if(t&&(this.id=t),e){if(this.classList.remove("hidden"),this.style.pointerEvents="auto",!this._clickOutsideHandler){const r=this;this._clickOutsideHandler=function(a){const l=a.composedPath(),o=l.includes(r);if(!(r._triggerElement&&l.includes(r._triggerElement))&&!o){r.close();return}},setTimeout(()=>{document.addEventListener("click",this._clickOutsideHandler,!1)},100)}}else this.classList.add("hidden"),this.style.pointerEvents="none",this._clickOutsideHandler&&(document.removeEventListener("click",this._clickOutsideHandler,!1),this._clickOutsideHandler=null);this._overlay||(this._overlay=document.createElement("div"),this._overlay.className="fixed inset-0 pointer-events-none z-40",this.appendChild(this._overlay)),this._popover||(this._popover=document.createElement("div"),this._popover.className="fixed z-50 pointer-events-auto",this.appendChild(this._popover)),this.isHoverEnabled()&&this._attachHoverListeners();let s=this._popover.querySelector(".popover-content");if(!s)s=document.createElement("div"),s.className=`popover-content bg-white dark:bg-gray-800 rounded-lg shadow-xl ${i} transition-all duration-200 ease-out transform`,this._popover.appendChild(s);else{const r=s.className.split(" "),a=["p-0","p-0.5","p-1","p-1.5","p-2","p-2.5","p-3","p-3.5","p-4","p-5","p-6","p-8","p-10","p-12","p-16","p-20","p-24"],l=r.filter(o=>!a.includes(o));s.className=[...l,i].join(" ")}Array.from(this.children).forEach(r=>{r!==this._overlay&&r!==this._popover&&r.parentElement===this&&s.appendChild(r)}),e?(this._triggerElement||this._setupTrigger(),this._setupPositionListeners(),this.offsetHeight,this._triggerElement?this._updatePosition(s):(this._popover.style.top="50%",this._popover.style.left="50%",this._popover.style.transform="translate(-50%, -50%)",this._popover.style.visibility="visible",this._popover.style.display="block",s.style.transform="scale(0.97) translateY(10px)",s.style.opacity="0",s.style.transition="all 200ms ease-out",requestAnimationFrame(()=>{requestAnimationFrame(()=>{s.style.transform="scale(1) translateY(0)",s.style.opacity="1"})}))):!e&&s&&(this._removePositionListeners(),s.style.opacity!=="0"&&s.style.opacity!==""&&(s.style.transition="all 200ms ease-in",s.style.transform="scale(0.97) translateY(10px)",s.style.opacity="0",setTimeout(()=>{s.style.transform="",s.style.opacity="",s.style.transition="",this._popover.style.visibility="",this._popover.style.display=""},200))),this._updateBackgroundColor()}_updateBackgroundColor(){if(!this._popover)return;const t=document.documentElement.classList.contains("dark"),e=this._popover.querySelector(".popover-content");e&&(t?(e.classList.remove("bg-white"),e.classList.add("bg-gray-800")):(e.classList.remove("bg-gray-800"),e.classList.add("bg-white")))}_observeDarkMode(){this._darkModeObserver||(this._darkModeObserver=new MutationObserver(()=>{this._updateBackgroundColor()}),this._darkModeObserver.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}))}_updatePosition(t){if(!this._triggerElement||!this._popover)return;const e=this._popover.style.visibility!=="hidden";e||(this._popover.style.visibility="hidden",this._popover.style.display="block",this._popover.style.top="0",this._popover.style.left="0"),this._popover.offsetHeight;const i=this._calculatePosition();this._popover.style.top=`${i.top}px`,this._popover.style.left=`${i.left}px`,e||(this._popover.style.visibility="visible",t&&(!t.style.opacity||t.style.opacity==="")&&(t.style.transform="scale(0.97) translateY(10px)",t.style.opacity="0",t.style.transition="all 200ms ease-out",requestAnimationFrame(()=>{requestAnimationFrame(()=>{t.style.transform="scale(1) translateY(0)",t.style.opacity="1"})})))}_setupPositionListeners(){if(!this._scrollHandler&&this.isOpen()){const t=this;this._scrollHandler=function(){if(t.isOpen()&&t._popover){const e=t._popover.querySelector(".popover-content");e&&t._updatePosition(e)}},window.addEventListener("scroll",this._scrollHandler,!0)}if(!this._resizeHandler&&this.isOpen()){const t=this;this._resizeHandler=function(){if(t.isOpen()&&t._popover){const e=t._popover.querySelector(".popover-content");e&&t._updatePosition(e)}},window.addEventListener("resize",this._resizeHandler)}}_removePositionListeners(){this._scrollHandler&&(window.removeEventListener("scroll",this._scrollHandler,!0),this._scrollHandler=null),this._resizeHandler&&(window.removeEventListener("resize",this._resizeHandler),this._resizeHandler=null)}_closeOtherPopovers(){Array.from(document.querySelectorAll("mint-popover[open]")).forEach(e=>{if(e!==this){const i=e;typeof i.close=="function"?i.close():e.removeAttribute("open")}})}}customElements.get("mint-popover")||customElements.define("mint-popover",U);class J extends HTMLElement{constructor(){super(),this._checkbox=null,this._checked=!1,this._clickHandler=null,this._changeHandler=null,this._mousedownHandler=null,this._mouseupHandler=null,this._mouseleaveHandler=null,this._touchstartHandler=null,this._touchendHandler=null,this._focusHandler=null,this._blurHandler=null}static get observedAttributes(){return["checked","disabled","label","info","id","name","value","error","error-message","loading"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline","inline-flex","items-start","gap-2");const t=this.getAttribute("checked");this._checked=t!==null&&t!=="false",this.render()}disconnectedCallback(){this.removeEventListeners()}isLoading(){return this.hasAttribute("loading")}attributeChangedCallback(t,e,i){if(t==="checked"&&(this._checked=i!==null&&i!=="false",this._checkbox&&(this._checkbox.checked=this._checked)),e!==i){if(t==="error"||t==="error-message"){this._renderErrorState();return}if(t==="loading"){this.render();return}this.render(),t==="checked"&&this._checkbox&&this.updateVisualState()}}get checked(){return this._checked}set checked(t){t?this.setAttribute("checked",""):this.removeAttribute("checked"),this._checked=!!t,this._checkbox&&(this._checkbox.checked=this._checked),this.updateVisualState()}isDisabled(){return this.hasAttribute("disabled")}getLabel(){return this.getAttribute("label")||""}getInfo(){return this.getAttribute("info")||""}getId(){return this.getAttribute("id")||""}getName(){return this.getAttribute("name")||""}getValue(){return this.getAttribute("value")||""}hasError(){return this.hasAttribute("error")}getErrorMessage(){return this.getAttribute("error-message")||""}getCheckboxClasses(){const t=this.hasError(),e=["relative","inline-flex","items-center","justify-center","flex-shrink-0","w-5","h-5","rounded","border-2","transition-all","duration-200","outline-none","focus:outline-none","focus-visible:ring-2","focus-visible:ring-offset-1",t?"focus-visible:ring-red-400 dark:focus-visible:ring-red-500":"focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500","cursor-pointer","disabled:opacity-40","disabled:cursor-not-allowed"],i=this._checked?["bg-slate-800","dark:bg-slate-600",t?"border-red-300 dark:border-red-300":"border-slate-800 dark:border-slate-600"]:["bg-white","dark:bg-gray-700",t?"border-red-300 dark:border-red-300":"border-gray-300 dark:border-gray-500"];return[...e,...i].join(" ")}render(){const t=this.isLoading(),e=this.getLabel(),i=this.getInfo(),s=this.isDisabled();let n=this.querySelector(".mint-checkbox-container");n||(n=document.createElement("div"),n.className="mint-checkbox-container relative inline-flex items-start gap-2",this.insertBefore(n,this.firstChild));let r=this.querySelector(".mint-checkbox-wrapper");r?r.parentElement!==n&&n.appendChild(r):(r=document.createElement("div"),r.className="mint-checkbox-wrapper",n.appendChild(r)),this._checkbox?this._checkbox.parentElement!==r&&r.appendChild(this._checkbox):(this._checkbox=document.createElement("input"),this._checkbox.type="checkbox",r.appendChild(this._checkbox),this.setupEventListeners()),this._checkbox.className="absolute inset-0 w-full h-full opacity-0 cursor-pointer",this._checkbox.style.cssText="position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; z-index: 10; pointer-events: auto; margin: 0; padding: 0;",this._checkbox.checked=this._checked,this._checkbox.disabled=s,this._changeHandler||this.setupEventListeners();const a=this.getId();a?this._checkbox.id=a:this._checkbox.removeAttribute("id");const l=this.getName();l?this._checkbox.name=l:this._checkbox.removeAttribute("name");const o=this.getValue();o?this._checkbox.value=o:this._checkbox.removeAttribute("value"),e?this._checkbox.setAttribute("aria-label",e):this._checkbox.removeAttribute("aria-label"),r.className=`mint-checkbox-wrapper ${this.getCheckboxClasses()}`,r.style.cursor="pointer",r.style.pointerEvents="auto",this._checkbox.style.pointerEvents="auto";const c=r;c._wrapperClickHandler||(c._wrapperClickHandler=m=>{m.target===r&&!s&&(m.preventDefault(),m.stopPropagation(),this.toggle())},r.addEventListener("click",c._wrapperClickHandler));let d=r.querySelector("mint-icon");d||(d=document.createElement("mint-icon"),d.setAttribute("name","check"),d.className="w-3.5 h-3.5 text-white pointer-events-none absolute inset-0 m-auto",d.style.transition="opacity 200ms ease-out, transform 200ms ease-out",d.style.zIndex="1",r.appendChild(d)),this.updateVisualState();let p=this.querySelector(".mint-checkbox-label-container");const h=this.querySelector(".mint-checkbox-container");if(e||i){p?h&&p.parentElement!==h&&h.appendChild(p):(p=document.createElement("div"),p.className="mint-checkbox-label-container flex flex-col gap-0.5 flex-1",h?h.appendChild(p):this.appendChild(p));let m=p.querySelector(".mint-checkbox-label");e?(m||(m=document.createElement("span"),m.className="mint-checkbox-label text-sm font-medium text-gray-900 dark:text-gray-100 cursor-pointer select-none",p.insertBefore(m,p.firstChild)),m.textContent=e,s?m.classList.add("opacity-40"):m.classList.remove("opacity-40")):m&&m.remove();let f=p.querySelector(".mint-checkbox-info");if(i?(f||(f=document.createElement("span"),f.className="mint-checkbox-info text-xs text-gray-500 dark:text-gray-400 cursor-pointer select-none",p.appendChild(f)),f.textContent=i,s?f.classList.add("opacity-40"):f.classList.remove("opacity-40")):f&&f.remove(),s)p.style.cursor="default",p._clickHandler&&(p.removeEventListener("click",p._clickHandler),p._clickHandler=null);else{p.style.cursor="pointer";const u=p._clickHandler;u&&p.removeEventListener("click",u),p._clickHandler=_=>{this._checkbox&&(_.target===this._checkbox||this._checkbox.contains(_.target)||_.composedPath().includes(this._checkbox))||this.toggle()},p.addEventListener("click",p._clickHandler)}}else p&&p.remove();this._renderErrorState(),this._renderSkeleton(t)}setupEventListeners(){this.removeEventListeners(),this._checkbox&&(this._changeHandler=t=>{t.stopPropagation(),this._checked=this._checkbox.checked,this._checked?this.hasAttribute("checked")||this.setAttribute("checked",""):this.hasAttribute("checked")&&this.removeAttribute("checked"),this.updateVisualState();const e=new CustomEvent("change",{detail:{checked:this._checked,value:this.getValue()},bubbles:!0,cancelable:!0});this.dispatchEvent(e)},this._checkbox.addEventListener("change",this._changeHandler),this._mousedownHandler=t=>{t.stopPropagation();const e=this.querySelector(".mint-checkbox-wrapper");e&&!this.isDisabled()&&(e.classList.add("mint-checkbox-active"),this._checked?(e.style.backgroundColor="rgb(15 23 42)",e.style.boxShadow="inset 0 2px 4px rgba(0, 0, 0, 0.3)"):(e.style.backgroundColor="rgb(243 244 246)",e.style.boxShadow="inset 0 2px 4px rgba(0, 0, 0, 0.1)"),document.documentElement.classList.contains("dark")&&(this._checked?e.style.backgroundColor="rgb(51 65 85)":e.style.backgroundColor="rgb(31 41 55)"))},this._mouseupHandler=t=>{t.stopPropagation();const e=this.querySelector(".mint-checkbox-wrapper");e&&(e.classList.remove("mint-checkbox-active"),e.style.backgroundColor="",e.style.boxShadow="")},this._mouseleaveHandler=t=>{const e=this.querySelector(".mint-checkbox-wrapper");e&&(e.classList.remove("mint-checkbox-active"),e.style.backgroundColor="",e.style.boxShadow="")},this._checkbox.addEventListener("mousedown",this._mousedownHandler),this._checkbox.addEventListener("mouseup",this._mouseupHandler),this._checkbox.addEventListener("mouseleave",this._mouseleaveHandler),this._focusHandler=t=>{const e=this.querySelector(".mint-checkbox-wrapper");e&&this._checkbox&&requestAnimationFrame(()=>{this._checkbox&&this._checkbox.matches(":focus-visible")&&(e==null||e.classList.add("ring-2","ring-offset-1","ring-gray-400","dark:ring-gray-500"))})},this._blurHandler=()=>{const t=this.querySelector(".mint-checkbox-wrapper");t&&t.classList.remove("ring-2","ring-offset-1","ring-gray-400","dark:ring-gray-500")},this._checkbox.addEventListener("focus",this._focusHandler),this._checkbox.addEventListener("blur",this._blurHandler),this._touchstartHandler=t=>{t.stopPropagation();const e=this.querySelector(".mint-checkbox-wrapper");e&&!this.isDisabled()&&(e.classList.add("mint-checkbox-active"),this._checked?(e.style.backgroundColor="rgb(15 23 42)",e.style.boxShadow="inset 0 2px 4px rgba(0, 0, 0, 0.3)"):(e.style.backgroundColor="rgb(243 244 246)",e.style.boxShadow="inset 0 2px 4px rgba(0, 0, 0, 0.1)"),document.documentElement.classList.contains("dark")&&(this._checked?e.style.backgroundColor="rgb(51 65 85)":e.style.backgroundColor="rgb(31 41 55)"))},this._touchendHandler=t=>{t.stopPropagation();const e=this.querySelector(".mint-checkbox-wrapper");e&&(e.classList.remove("mint-checkbox-active"),e.style.backgroundColor="",e.style.boxShadow="")},this._checkbox.addEventListener("touchstart",this._touchstartHandler),this._checkbox.addEventListener("touchend",this._touchendHandler))}removeEventListeners(){this._checkbox&&(this._changeHandler&&(this._checkbox.removeEventListener("change",this._changeHandler),this._changeHandler=null),this._mousedownHandler&&(this._checkbox.removeEventListener("mousedown",this._mousedownHandler),this._mousedownHandler=null),this._mouseupHandler&&(this._checkbox.removeEventListener("mouseup",this._mouseupHandler),this._mouseupHandler=null),this._mouseleaveHandler&&(this._checkbox.removeEventListener("mouseleave",this._mouseleaveHandler),this._mouseleaveHandler=null),this._touchstartHandler&&(this._checkbox.removeEventListener("touchstart",this._touchstartHandler),this._touchstartHandler=null),this._touchendHandler&&(this._checkbox.removeEventListener("touchend",this._touchendHandler),this._touchendHandler=null),this._focusHandler&&(this._checkbox.removeEventListener("focus",this._focusHandler),this._focusHandler=null),this._blurHandler&&(this._checkbox.removeEventListener("blur",this._blurHandler),this._blurHandler=null));const t=this.querySelector(".mint-checkbox-wrapper");if(t){const e=t;e._wrapperClickHandler&&(t.removeEventListener("click",e._wrapperClickHandler),e._wrapperClickHandler=null)}}updateVisualState(){const t=this.querySelector(".mint-checkbox-wrapper"),e=t==null?void 0:t.querySelector("mint-icon");e&&(e.style.opacity=this._checked?"1":"0",e.style.transform=this._checked?"scale(1)":"scale(0.8)"),t&&(t.className=`mint-checkbox-wrapper ${this.getCheckboxClasses()}`,t.classList.contains("mint-checkbox-active")||(t.style.backgroundColor="",t.style.boxShadow=""))}toggle(){if(this._checkbox&&!this.isDisabled()){this._checkbox.checked=!this._checked,this._checked=this._checkbox.checked,this._checked?this.hasAttribute("checked")||this.setAttribute("checked",""):this.hasAttribute("checked")&&this.removeAttribute("checked"),this.updateVisualState();const t=new CustomEvent("change",{detail:{checked:this._checked},bubbles:!0,cancelable:!0});this.dispatchEvent(t)}}_renderSkeleton(t){let e=this.querySelector(".mint-checkbox-skeleton-container");const i=this.querySelector(".mint-checkbox-container"),s=this.querySelector(".mint-checkbox-wrapper"),n=this.querySelector(".mint-checkbox-label-container");if(t){e||(e=document.createElement("div"),e.className="mint-checkbox-skeleton-container absolute inset-0 z-10 pointer-events-none flex items-center gap-2",i?i.appendChild(e):(this.style.position="relative",this.appendChild(e)));let r=e.querySelector(".mint-checkbox-skeleton-box");if(r||(r=document.createElement("div"),r.className="mint-checkbox-skeleton-box flex-shrink-0 w-5 h-5 rounded bg-gray-200 dark:bg-gray-700 animate-pulse",e.appendChild(r)),n){let a=e.querySelector(".mint-checkbox-skeleton-label");a||(a=document.createElement("div"),a.className="mint-checkbox-skeleton-label h-4 w-24 rounded bg-gray-200 dark:bg-gray-700 animate-pulse",e.appendChild(a))}e.style.display="flex",s&&(s.style.visibility="hidden",s.style.pointerEvents="none"),n&&(n.style.visibility="hidden",n.style.pointerEvents="none")}else e&&(e.style.display="none"),s&&(s.style.visibility="visible",s.style.pointerEvents="auto"),n&&(n.style.visibility="visible",n.style.pointerEvents="auto")}_renderErrorState(){const t=this.hasError(),e=this.getErrorMessage();let i=this.querySelector(".mint-checkbox-label-container");!i&&t&&e&&(i=document.createElement("div"),i.className="mint-checkbox-label-container flex flex-col gap-0.5 flex-1",this.appendChild(i));let s=this.querySelector(".mint-checkbox-error");t&&e?(s?(s.classList.add("block","w-full"),s.style.display="block",(i&&s.parentElement!==i||i&&s.parentElement===i)&&i.appendChild(s)):(s=document.createElement("div"),s.className="mint-checkbox-error text-xs text-red-600 dark:text-red-400 block w-full",s.style.display="block",i?i.appendChild(s):this.appendChild(s)),s.textContent=e):s&&s.remove();const n=this.querySelector(".mint-checkbox-wrapper");n&&(n.className=`mint-checkbox-wrapper ${this.getCheckboxClasses()}`)}}customElements.get("mint-checkbox")||customElements.define("mint-checkbox",J);class ht extends HTMLElement{constructor(){super(),this._radio=null,this._checked=!1,this._changeHandler=null,this._clickHandler=null,this._focusHandler=null,this._blurHandler=null,this._keydownHandler=null}static get observedAttributes(){return["value","checked","disabled","loading"]}connectedCallback(){this.classList.add("inline-flex","items-center","gap-2","cursor-pointer","select-none");const t=this.getAttribute("checked");this._checked=t!==null&&t!=="false",this.render(),this._setupClickHandler()}disconnectedCallback(){this._clickHandler&&(this.removeEventListener("click",this._clickHandler),this._clickHandler=null),this._radio&&(this._changeHandler&&(this._radio.removeEventListener("change",this._changeHandler),this._changeHandler=null),this._focusHandler&&(this._radio.removeEventListener("focus",this._focusHandler),this._focusHandler=null),this._blurHandler&&(this._radio.removeEventListener("blur",this._blurHandler),this._blurHandler=null),this._keydownHandler&&(this._radio.removeEventListener("keydown",this._keydownHandler),this._keydownHandler=null))}isLoading(){return this.hasAttribute("loading")}attributeChangedCallback(t,e,i){if(t==="checked"&&(this._checked=i!==null&&i!=="false",this._radio&&(this._radio.checked=this._checked),this._updateVisualState()),e!==i){if(t==="loading"){this.render();return}this.render()}}get checked(){return this._checked}set checked(t){this._checked=!!t,t?this.setAttribute("checked",""):this.removeAttribute("checked"),this._radio&&(this._radio.checked=this._checked),this.isConnected?requestAnimationFrame(()=>{this._updateVisualState()}):this._updateVisualState()}getValue(){return this.getAttribute("value")||""}isDisabled(){const t=this.closest("mint-choice");return this.hasAttribute("disabled")||((t==null?void 0:t.hasAttribute("disabled"))??!1)}_setupClickHandler(){this._clickHandler||(this._clickHandler=t=>{t.target!==this._radio&&(this.isDisabled()||this._radio&&(this._radio.click(),requestAnimationFrame(()=>{if(this._radio&&this._radio.checked!==this._checked){this._checked=this._radio.checked,this._checked?this.setAttribute("checked",""):this.removeAttribute("checked"),this._updateVisualState(),this._updateGroupState();const e=this.closest("mint-choice");e&&e.dispatchEvent(new CustomEvent("choice-change",{detail:{checked:this._checked,value:this.getValue()},bubbles:!0,cancelable:!0}))}})))},this.addEventListener("click",this._clickHandler))}render(){var m;const t=this.isLoading(),e=this.isDisabled(),i=this.getValue(),s=this.closest("mint-choice"),n=(s==null?void 0:s.getAttribute("name"))||"";let r="";const a=this.querySelector(".mint-choice-option-label");a?r=((m=a.textContent)==null?void 0:m.trim())||"":Array.from(this.childNodes).forEach(f=>{var u;if(f.nodeType===Node.TEXT_NODE){const _=(u=f.textContent)==null?void 0:u.trim();_&&(r+=_)}});const l=this.querySelectorAll(".mint-choice-option-wrapper");let o=null;if(l.length>0&&(this._radio&&(o=Array.from(l).find(f=>f.contains(this._radio))),o||(o=l[0]),l.forEach((f,u)=>{f!==o&&f.remove()})),o||(o=document.createElement("div"),o.className="mint-choice-option-wrapper",o.style.position="relative",this.insertBefore(o,this.firstChild)),o.className=`mint-choice-option-wrapper ${this._getWrapperClasses()}`,o.style.position="relative",this.querySelectorAll('input[type="radio"]').forEach(f=>{f!==this._radio&&f.remove()}),this._radio)this._radio.parentElement!==o&&o.appendChild(this._radio),this._radio&&this._changeHandler&&(this._radio.removeEventListener("change",this._changeHandler),this._radio.addEventListener("change",this._changeHandler)),this._radio&&(this._focusHandler||(this._focusHandler=f=>{const u=this.querySelector(".mint-choice-option-wrapper");u&&!this.isDisabled()&&u.classList.add("ring-2","ring-offset-1","ring-gray-400","dark:ring-gray-500")}),this._blurHandler||(this._blurHandler=()=>{const f=this.querySelector(".mint-choice-option-wrapper");f&&f.classList.remove("ring-2","ring-offset-1","ring-gray-400","dark:ring-gray-500")}),this._keydownHandler||(this._keydownHandler=f=>{this.isDisabled()||(f.key==="ArrowDown"||f.key==="ArrowRight"?(f.preventDefault(),this._focusNextOption()):(f.key==="ArrowUp"||f.key==="ArrowLeft")&&(f.preventDefault(),this._focusPreviousOption()))}),this._radio.removeEventListener("focus",this._focusHandler),this._radio.removeEventListener("blur",this._blurHandler),this._radio.removeEventListener("keydown",this._keydownHandler),this._radio.addEventListener("focus",this._focusHandler),this._radio.addEventListener("blur",this._blurHandler),this._radio.addEventListener("keydown",this._keydownHandler));else{this._radio=document.createElement("input"),this._radio.type="radio",this._radio.className="sr-only",this._radio.style.position="absolute",this._radio.style.width="1px",this._radio.style.height="1px",this._radio.style.padding="0",this._radio.style.margin="-1px",this._radio.style.overflow="hidden",this._radio.style.clip="rect(0, 0, 0, 0)",this._radio.style.whiteSpace="nowrap",this._radio.style.border="0",o.appendChild(this._radio),this._changeHandler=u=>{const _=this._checked;this._checked=this._radio.checked,this._checked?this.setAttribute("checked",""):this.removeAttribute("checked"),this._updateVisualState(),this._updateGroupState();const g=this.closest("mint-choice");_!==this._checked&&g&&setTimeout(()=>{g.dispatchEvent(new CustomEvent("choice-change",{detail:{checked:this._checked,value:this.getValue()},bubbles:!0,cancelable:!0}))},0)},this._radio.addEventListener("change",this._changeHandler);const f=()=>{this._radio&&this._radio.checked!==this._checked&&(this._checked=this._radio.checked,this._checked?this.setAttribute("checked",""):this.removeAttribute("checked"),this._updateVisualState(),this._updateGroupState())};this._radio.addEventListener("click",f),this._focusHandler=u=>{const _=this.querySelector(".mint-choice-option-wrapper");_&&!this.isDisabled()&&_.classList.add("ring-2","ring-offset-1","ring-gray-400","dark:ring-gray-500")},this._radio.addEventListener("focus",this._focusHandler),this._blurHandler=()=>{const u=this.querySelector(".mint-choice-option-wrapper");u&&u.classList.remove("ring-2","ring-offset-1","ring-gray-400","dark:ring-gray-500")},this._radio.addEventListener("blur",this._blurHandler),this._keydownHandler=u=>{this.isDisabled()||(u.key==="ArrowDown"||u.key==="ArrowRight"?(u.preventDefault(),this._focusNextOption()):(u.key==="ArrowUp"||u.key==="ArrowLeft")&&(u.preventDefault(),this._focusPreviousOption()))},this._radio.addEventListener("keydown",this._keydownHandler)}this._radio.name=n,this._radio.value=i,this._radio.checked!==this._checked?(this._checked=this._radio.checked,this._checked?this.hasAttribute("checked")||this.setAttribute("checked",""):this.hasAttribute("checked")&&this.removeAttribute("checked")):this._radio.checked=this._checked,this._radio.disabled=e,e?this._radio.setAttribute("tabindex","-1"):this._radio.removeAttribute("tabindex"),r?this._radio.setAttribute("aria-label",r):this._radio.removeAttribute("aria-label"),o.querySelectorAll(".mint-choice-option-indicator").forEach((f,u)=>{u>0&&f.remove()});let p=o.querySelector(".mint-choice-option-indicator");p||(p=document.createElement("div"),p.className="mint-choice-option-indicator",o.appendChild(p)),p.className="mint-choice-option-indicator w-2 h-2 rounded-full bg-white transition-all duration-200 pointer-events-none",p.style.position="absolute",p.style.top="50%",p.style.left="50%",p.style.transform=this._checked?"translate(-50%, -50%) scale(1)":"translate(-50%, -50%) scale(0)",p.style.opacity=this._checked?"1":"0",this._updateVisualState(),this._renderSkeleton(t);let h=this.querySelector(".mint-choice-option-label");r&&(h||(h=document.createElement("span"),h.className="mint-choice-option-label",this.appendChild(h),Array.from(this.childNodes).forEach(f=>{var u;f.nodeType===Node.TEXT_NODE&&((u=f.textContent)!=null&&u.trim())&&(f.textContent="")})),h.className=`mint-choice-option-label text-sm text-gray-900 dark:text-gray-100 ${e?"opacity-40":""}`,h.textContent=r),e?(this.classList.add("cursor-not-allowed"),this.classList.remove("cursor-pointer")):(this.classList.add("cursor-pointer"),this.classList.remove("cursor-not-allowed")),this._updateVisualState()}_getWrapperClasses(){const t=this.isDisabled(),e=["inline-flex","items-center","justify-center","w-5","h-5","rounded-full","border-2","transition-all","duration-200","flex-shrink-0"];return t&&e.push("opacity-40","cursor-not-allowed"),this._checked?e.push("bg-slate-800","dark:bg-slate-600","border-slate-800","dark:border-slate-600"):e.push("bg-white","dark:bg-gray-700","border-gray-300","dark:border-gray-500"),e.join(" ")}_updateVisualState(){const t=this.querySelector(".mint-choice-option-wrapper");t&&(t.className=`mint-choice-option-wrapper ${this._getWrapperClasses()}`);const e=this.querySelector(".mint-choice-option-indicator");e&&(e.style.opacity=this._checked?"1":"0",e.style.transform=this._checked?"translate(-50%, -50%) scale(1)":"translate(-50%, -50%) scale(0)")}_renderSkeleton(t){let e=this.querySelector(".mint-choice-option-skeleton-container");const i=this.querySelector(".mint-choice-option-wrapper");if(t){e||(e=document.createElement("div"),e.className="mint-choice-option-skeleton-container absolute inset-0 z-10 pointer-events-none flex items-center gap-2",i?(i.classList.contains("relative")||i.classList.add("relative"),i.appendChild(e)):(this.style.position="relative",this.appendChild(e)));let s=e.querySelector(".mint-choice-option-skeleton-radio");if(s||(s=document.createElement("div"),s.className="mint-choice-option-skeleton-radio flex-shrink-0 w-5 h-5 rounded-full bg-gray-200 dark:bg-gray-700 animate-pulse",e.appendChild(s)),e.style.display="flex",i){const n=i.querySelector('input[type="radio"]'),r=i.querySelector(".mint-choice-option-indicator");n&&(n.style.visibility="hidden"),r&&(r.style.visibility="hidden"),i.style.pointerEvents="none"}}else{if(e&&(e.style.display="none"),i){const n=i.querySelector('input[type="radio"]'),r=i.querySelector(".mint-choice-option-indicator");n&&(n.style.visibility="visible"),r&&(r.style.visibility="visible"),i.style.pointerEvents="auto"}const s=this.querySelector(".mint-choice-option-label");s&&!(i!=null&&i.contains(s))&&(s.style.visibility="visible",s.style.pointerEvents="auto")}}_updateGroupState(){var e;if(!((e=this._radio)!=null&&e.name))return;document.querySelectorAll(`input[type="radio"][name="${this._radio.name}"]`).forEach(i=>{if(i===this._radio)return;const s=i.closest("mint-choice-option");s&&s!==this&&(s._checked=i.checked,i.checked?s.setAttribute("checked",""):s.removeAttribute("checked"),s._updateVisualState())})}_focusNextOption(){var s;if(!((s=this._radio)!=null&&s.name))return;const t=Array.from(document.querySelectorAll(`input[type="radio"][name="${this._radio.name}"]`)).filter(n=>!n.disabled),e=t.indexOf(this._radio);let i=null;if(e>=0&&e<t.length-1?i=t[e+1]:t.length>0&&(i=t[0]),i){const n=i.closest("mint-choice-option");if(i.checked=!0,n){const r=n._checked;if(n._checked=!0,n.setAttribute("checked",""),n._changeHandler){const l=new Event("change",{bubbles:!0});n._changeHandler.call(n,l)}else n._updateVisualState(),n._updateGroupState();const a=n.closest("mint-choice");a&&!r&&setTimeout(()=>{a.dispatchEvent(new CustomEvent("choice-change",{detail:{checked:!0,value:n.getValue()},bubbles:!0,cancelable:!0}))},0)}i.focus(),i.dispatchEvent(new Event("change",{bubbles:!0}))}}_focusPreviousOption(){var s;if(!((s=this._radio)!=null&&s.name))return;const t=Array.from(document.querySelectorAll(`input[type="radio"][name="${this._radio.name}"]`)).filter(n=>!n.disabled),e=t.indexOf(this._radio);let i=null;if(e>0?i=t[e-1]:t.length>0&&(i=t[t.length-1]),i){const n=i.closest("mint-choice-option");if(i.checked=!0,n){const r=n._checked;if(n._checked=!0,n.setAttribute("checked",""),n._changeHandler){const l=new Event("change",{bubbles:!0});n._changeHandler.call(n,l)}else n._updateVisualState(),n._updateGroupState();const a=n.closest("mint-choice");a&&!r&&setTimeout(()=>{a.dispatchEvent(new CustomEvent("choice-change",{detail:{checked:!0,value:n.getValue()},bubbles:!0,cancelable:!0}))},0)}i.focus(),i.dispatchEvent(new Event("change",{bubbles:!0}))}}}customElements.get("mint-choice-option")||customElements.define("mint-choice-option",ht);class G extends HTMLElement{constructor(){super(),this._optionsContainer=null}static get observedAttributes(){return["label","name","info","error","error-message","id","disabled","required","loading"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","block","w-full"),this.render()}disconnectedCallback(){}isLoading(){return this.hasAttribute("loading")}attributeChangedCallback(t,e,i){e!==i&&(t==="error"||t==="error-message"?this._renderErrorState():t==="loading"?(this.render(),this.querySelectorAll("mint-choice-option").forEach(n=>{this.isLoading()?n.setAttribute("loading",""):n.removeAttribute("loading")})):(this.render(),t==="name"&&this.querySelectorAll("mint-choice-option").forEach(n=>{typeof n.render=="function"&&n.render()})))}getLabel(){return this.getAttribute("label")||""}getInfo(){return this.getAttribute("info")||""}getName(){return this.getAttribute("name")||""}hasError(){return this.hasAttribute("error")}getErrorMessage(){return this.getAttribute("error-message")||""}getId(){return this.getAttribute("id")||""}isDisabled(){return this.hasAttribute("disabled")}isRequired(){return this.hasAttribute("required")}getValue(){const t=this.querySelector('input[type="radio"]:checked');return(t==null?void 0:t.value)||""}setValue(t){const e=this.querySelectorAll("mint-choice-option");e.forEach(i=>{if((i.getAttribute("value")||"")===t){const n=i;n.checked=!0;const r=i.querySelector('input[type="radio"]');r&&(r.checked=!0,r.dispatchEvent(new Event("change",{bubbles:!0})))}else{const n=i;n.checked=!1;const r=i.querySelector('input[type="radio"]');r&&(r.checked=!1)}}),requestAnimationFrame(()=>{e.forEach(i=>{typeof i._updateVisualState=="function"&&i._updateVisualState();const s=i.querySelector('input[type="radio"]');if(s){const n=i;s.checked!==n.checked&&(s.checked=n.checked)}})})}render(){const t=this.isLoading(),e=this.getLabel(),i=this.getInfo(),s=this.getId()||`mint-choice-${Math.random().toString(36).substr(2,9)}`;this.getId()||this.setAttribute("id",s);const n=this.isDisabled();let r=this.querySelector(".mint-choice-label-container");if(e||i){r||(r=document.createElement("div"),r.className="mint-choice-label-container flex flex-col gap-0.5 mb-2",this.insertBefore(r,this.firstChild));let o=r.querySelector(".mint-choice-label");e?(o||(o=document.createElement("label"),o.className="mint-choice-label text-sm font-medium text-gray-900 dark:text-gray-100 select-none",r.insertBefore(o,r.firstChild)),o.textContent=e,o.setAttribute("for",s),n?o.classList.add("opacity-40"):o.classList.remove("opacity-40")):o&&o.remove();let c=r.querySelector(".mint-choice-info");i?(c||(c=document.createElement("span"),c.className="mint-choice-info text-xs text-gray-500 dark:text-gray-400 select-none",r.appendChild(c)),c.textContent=i,n?c.classList.add("opacity-40"):c.classList.remove("opacity-40")):c&&c.remove()}else r&&r.remove();let a=this.querySelector(".mint-choice-options-wrapper");if(!a){a=document.createElement("div"),a.className="mint-choice-options-wrapper relative";const o=this.querySelector(".mint-choice-label-container");o&&o.parentElement===this?this.insertBefore(a,o.nextSibling):this.insertBefore(a,this.firstChild)}this._optionsContainer?this._optionsContainer.parentElement!==a&&a.appendChild(this._optionsContainer):(this._optionsContainer=document.createElement("div"),this._optionsContainer.className="mint-choice-options-container flex flex-col gap-3",a.appendChild(this._optionsContainer)),Array.from(this.children).filter(o=>o.tagName==="MINT-CHOICE-OPTION"&&o.parentElement!==this._optionsContainer).forEach(o=>{this._optionsContainer.appendChild(o)}),this._renderErrorState(),this._renderSkeleton(t)}_renderSkeleton(t){let e=this.querySelector(".mint-choice-skeleton-container");const i=this.querySelector(".mint-choice-options-wrapper"),s=this.querySelector(".mint-choice-options-container");if(t){if(e||(e=document.createElement("div"),e.className="mint-choice-skeleton-container absolute inset-0 z-10 pointer-events-none flex flex-col gap-3",i?i.appendChild(e):(this.style.position="relative",this.appendChild(e))),e.querySelectorAll(".mint-choice-option-skeleton").length===0)for(let r=0;r<3;r++){const a=document.createElement("div");a.className="mint-choice-option-skeleton flex items-center gap-3";const l=document.createElement("div");l.className="flex-shrink-0 w-5 h-5 rounded-full bg-gray-200 dark:bg-gray-700 animate-pulse",a.appendChild(l);const o=document.createElement("div");o.className="h-4 w-20 rounded bg-gray-200 dark:bg-gray-700 animate-pulse",a.appendChild(o),e.appendChild(a)}e.style.display="flex",s&&(s.style.opacity="0",s.style.pointerEvents="none")}else e&&(e.style.display="none"),s&&(s.style.opacity="1",s.style.pointerEvents="auto")}_renderErrorState(){const t=this.hasError(),e=this.getErrorMessage();let i=this.querySelector(".mint-choice-error");t&&e?(i||(i=document.createElement("div"),i.className="mint-choice-error mt-1 text-xs text-red-600 dark:text-red-400",this.appendChild(i)),i.textContent=e):i&&i.remove()}}customElements.get("mint-choice")||customElements.define("mint-choice",G);class K extends HTMLElement{constructor(){super(),this._input=null,this._textarea=null,this._element=null,this._wrapper=null,this._icon=null,this._colorPicker=null,this._colorTextInput=null,this._colorContainer=null,this._colorPickerWrapper=null,this._numberSpinnerContainer=null,this._numberIncrementButton=null,this._numberDecrementButton=null,this._focusHandler=null,this._blurHandler=null,this._clickHandler=null,this._clickOutsideHandler=null}static get observedAttributes(){return["type","placeholder","value","disabled","id","name","required","readonly","rows","icon","label","info","error","error-message","loading"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline","inline-block"),this.render()}disconnectedCallback(){this.removeEventListeners()}attributeChangedCallback(t,e,i){if(e!==i){if(t==="error"||t==="error-message"){this._renderErrorState(),this._element&&(this._element.className=this.getInputClasses()),this._colorTextInput&&(this._colorTextInput.className=this.getInputClasses());return}if(t==="loading"){this.render();return}this.render()}}getType(){return this.getAttribute("type")||"text"}getRows(){const t=this.getAttribute("rows");return t?parseInt(t,10):3}_getNormalizedType(){const t=this.getType();return t==="datetime"?"datetime-local":t==="money"?"text":t==="textarea"?"textarea":t}_isTextarea(){return this.getType()==="textarea"}_isMoney(){return this.getType()==="money"}_isColor(){return this.getType()==="color"}_isNumber(){return this.getType()==="number"}getPlaceholder(){return this.getAttribute("placeholder")||""}getValue(){var t,e,i;return this._isColor()?((t=this._colorPicker)==null?void 0:t.value)||((e=this._colorTextInput)==null?void 0:e.value)||this.getAttribute("value")||"#000000":((i=this._element)==null?void 0:i.value)||this.getAttribute("value")||""}set value(t){this._isColor()?(this._colorPicker&&(this._colorPicker.value=t||"#000000"),this._colorTextInput&&(this._colorTextInput.value=t||"#000000")):this._element&&(this._element.value=t),t?this.setAttribute("value",t):this.removeAttribute("value")}get value(){return this.getValue()}isDisabled(){return this.hasAttribute("disabled")}isReadonly(){return this.hasAttribute("readonly")}isRequired(){return this.hasAttribute("required")}hasError(){return this.hasAttribute("error")}getErrorMessage(){return this.getAttribute("error-message")||""}getId(){return this.getAttribute("id")||""}getName(){return this.getAttribute("name")||""}getIcon(){return this.getAttribute("icon")||""}getLabel(){return this.getAttribute("label")||""}getInfo(){return this.getAttribute("info")||""}getInputClasses(){const t=this._isTextarea(),e=!!this.getIcon(),i=this._isColor(),s=this._isNumber(),n=this.hasError(),r=["w-full",e||i?"pl-10":"px-3.5",e||i?"pr-3.5":s?"pr-10":"",t?"py-2":"py-1.5",t?"min-h-[6rem]":"min-h-[2rem]","text-sm","font-medium","rounded-lg","box-border","bg-white","dark:bg-gray-700","text-gray-900","dark:text-white",t?"transition-colors transition-opacity":"transition-all","duration-200","outline-none","focus:outline-none","disabled:opacity-40","disabled:cursor-not-allowed","readonly:cursor-default",t?"resize-y":"",s?"[appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none":""],a=["border-2",n?"border-red-300 dark:border-red-300":"border-gray-200 dark:border-gray-600"],l=["focus-visible:ring-2","focus-visible:ring-offset-1",n?"focus-visible:ring-red-400 dark:focus-visible:ring-red-500":"focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500"];return[...r,...a,...l].filter(Boolean).join(" ")}isLoading(){return this.hasAttribute("loading")}render(){var b,k,x,E;this.getType();const t=this._getNormalizedType(),e=this._isTextarea(),i=this._isMoney(),s=this._isColor(),n=this.getPlaceholder(),r=this.isDisabled(),a=this.isReadonly(),l=this.isRequired(),o=this.getId(),c=this.getName(),d=this.getAttribute("value")||(s?"#000000":""),p=this.getRows(),h=this.getIcon(),m=this.getLabel(),f=this.getInfo(),u=this.isLoading();if(this._renderSkeleton(u),s){this._input&&(this._input.remove(),this._input=null),this._textarea&&(this._textarea.remove(),this._textarea=null),this._wrapper||(this._wrapper=document.createElement("div"),this._wrapper.className="relative w-full",this.appendChild(this._wrapper)),this._colorContainer&&(this._colorContainer.remove(),this._colorContainer=null),this._colorPickerWrapper&&!s&&(this._colorPickerWrapper.remove(),this._colorPickerWrapper=null),this._colorPickerWrapper||(this._colorPickerWrapper=document.createElement("div"),this._colorPickerWrapper.className="mint-color-picker-wrapper absolute left-[.65rem] top-1/2 -translate-y-1/2 w-6 h-6 rounded cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500",this._colorPickerWrapper.style.backgroundColor=d||"#000000",this._wrapper.appendChild(this._colorPickerWrapper),this._colorPicker=document.createElement("input"),this._colorPicker.type="color",this._colorPicker.className="absolute inset-0 w-full h-full opacity-0 cursor-pointer",this._colorPicker.style.cssText="position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; z-index: 10; pointer-events: auto; margin: 0; padding: 0; border: none;",this._colorPickerWrapper.appendChild(this._colorPicker),this._focusHandler=y=>{this._colorPickerWrapper&&this._colorPicker&&this._colorPicker.matches(":focus-visible")&&requestAnimationFrame(()=>{var w;this._colorPicker&&this._colorPicker.matches(":focus-visible")&&((w=this._colorPickerWrapper)==null||w.classList.add("ring-2","ring-offset-1","ring-gray-400","dark:ring-gray-500"))})},this._blurHandler=()=>{this._colorPickerWrapper&&this._colorPickerWrapper.classList.remove("ring-2","ring-offset-1","ring-gray-400","dark:ring-gray-500")},this._colorPicker.addEventListener("focus",this._focusHandler),this._colorPicker.addEventListener("blur",this._blurHandler),this._colorPicker.addEventListener("input",()=>{var w;const y=((w=this._colorPicker)==null?void 0:w.value)||"#000000";this._colorPickerWrapper&&(this._colorPickerWrapper.style.backgroundColor=y),this._colorTextInput&&(this._colorTextInput.value=y),this.setAttribute("value",y),this.dispatchEvent(new CustomEvent("input",{detail:{value:y},bubbles:!0,cancelable:!0}))}),this._colorPicker.addEventListener("change",()=>{var w;const y=((w=this._colorPicker)==null?void 0:w.value)||"#000000";this._colorPickerWrapper&&(this._colorPickerWrapper.style.backgroundColor=y),this.setAttribute("value",y),this.dispatchEvent(new CustomEvent("change",{detail:{value:y},bubbles:!0,cancelable:!0}))})),this._colorTextInput||(this._colorTextInput=document.createElement("input"),this._colorTextInput.type="text",this._colorTextInput.className=this.getInputClasses(),this._colorTextInput.placeholder=n||"#000000",this._colorTextInput.pattern="^#[0-9A-Fa-f]{6}$",this._wrapper.appendChild(this._colorTextInput),this._colorTextInput.addEventListener("input",()=>{var w;const y=((w=this._colorTextInput)==null?void 0:w.value)||"";/^#[0-9A-Fa-f]{6}$/.test(y)&&(this._colorPicker&&(this._colorPicker.value=y),this.setAttribute("value",y),this.dispatchEvent(new CustomEvent("input",{detail:{value:y},bubbles:!0,cancelable:!0})))}),this._colorTextInput.addEventListener("blur",()=>{var w,A;const y=((w=this._colorTextInput)==null?void 0:w.value)||"";/^#[0-9A-Fa-f]{6}$/.test(y)?(this._colorPicker&&(this._colorPicker.value=y),this.setAttribute("value",y)):this._colorPicker&&this._colorTextInput&&(this._colorTextInput.value=this._colorPicker.value),this.dispatchEvent(new CustomEvent("change",{detail:{value:((A=this._colorPicker)==null?void 0:A.value)||"#000000"},bubbles:!0,cancelable:!0}))}));const v=d||"#000000";if(this._colorPicker&&this._colorPicker.value!==v&&(this._colorPicker.value=v),this._colorPickerWrapper&&(this._colorPickerWrapper.style.backgroundColor=v),this._colorTextInput&&this._colorTextInput.value!==v&&(this._colorTextInput.value=v),this._colorPicker&&(this._colorPicker.disabled=r),this._colorPickerWrapper&&(r?(this._colorPickerWrapper.classList.add("opacity-40","cursor-not-allowed"),this._colorPickerWrapper.classList.remove("cursor-pointer")):(this._colorPickerWrapper.classList.remove("opacity-40","cursor-not-allowed"),this._colorPickerWrapper.classList.add("cursor-pointer"))),this._colorTextInput&&(this._colorTextInput.disabled=r,this._colorTextInput.readOnly=a,this._colorTextInput.required=l),this._colorTextInput){const y=this._colorTextInput;o?y.id=o:y.removeAttribute("id"),c?y.name=c:y.removeAttribute("name"),y.setAttribute("aria-invalid",this.hasError()?"true":"false"),this._element=y}this._renderErrorState();return}if(this._wrapper||(this._wrapper=document.createElement("div"),this._wrapper.className="relative w-full",this.appendChild(this._wrapper)),this._colorContainer&&(this._colorContainer.remove(),this._colorContainer=null,this._colorPicker=null,this._colorTextInput=null),this._colorPickerWrapper&&!s&&(this._colorPickerWrapper.remove(),this._colorPickerWrapper=null,this._colorPicker=null,this._colorTextInput=null),h&&!e?this._icon?this._icon.setAttribute("name",h):(this._icon=document.createElement("mint-icon"),this._icon.setAttribute("name",h),this._icon.className="absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400 dark:text-gray-500 pointer-events-none",this._wrapper.appendChild(this._icon)):this._icon&&(this._icon.remove(),this._icon=null),this._isNumber()&&!e){if(!this._numberSpinnerContainer){this._numberSpinnerContainer=document.createElement("div"),this._numberSpinnerContainer.className="absolute right-1 top-1/2 -translate-y-1/2 flex flex-col h-8 pointer-events-none",this._wrapper.appendChild(this._numberSpinnerContainer),this._numberIncrementButton=document.createElement("button"),this._numberIncrementButton.type="button",this._numberIncrementButton.className="flex items-center justify-center w-5 h-4 text-gray-400 dark:text-gray-500 hover:text-gray-600 dark:hover:text-gray-300 disabled:opacity-40 disabled:cursor-not-allowed transition-colors pointer-events-auto bg-gray-100 dark:bg-gray-600 active:bg-gray-200 dark:active:bg-gray-500 rounded";const v=document.createElement("mint-icon");v.setAttribute("name","caret-up"),v.className="w-[1rem] h-[1rem]",this._numberIncrementButton.appendChild(v),this._numberSpinnerContainer.appendChild(this._numberIncrementButton),this._numberDecrementButton=document.createElement("button"),this._numberDecrementButton.type="button",this._numberDecrementButton.className="flex items-center justify-center w-5 h-4 text-gray-400 dark:text-gray-500 hover:text-gray-600 dark:hover:text-gray-300 disabled:opacity-40 disabled:cursor-not-allowed transition-colors pointer-events-auto bg-gray-100 dark:bg-gray-600 active:bg-gray-200 dark:active:bg-gray-500 rounded";const y=document.createElement("mint-icon");y.setAttribute("name","caret-down"),y.className="w-[1rem] h-[1rem]",this._numberDecrementButton.appendChild(y),this._numberSpinnerContainer.appendChild(this._numberDecrementButton),this._numberIncrementButton.addEventListener("click",w=>{if(w.preventDefault(),w.stopPropagation(),this._input&&!this._input.disabled&&!this._input.readOnly){const A=parseFloat(this._input.value)||0,I=parseFloat(this._input.step)||1,S=this._input.min?parseFloat(this._input.min):void 0,H=this._input.max?parseFloat(this._input.max):void 0;let L=A+I;H!==void 0&&L>H&&(L=H),S!==void 0&&L<S&&(L=S),this._input.value=L.toString(),this.setAttribute("value",L.toString()),this._input.dispatchEvent(new Event("input",{bubbles:!0})),this._input.dispatchEvent(new Event("change",{bubbles:!0}))}}),this._numberDecrementButton.addEventListener("click",w=>{if(w.preventDefault(),w.stopPropagation(),this._input&&!this._input.disabled&&!this._input.readOnly){const A=parseFloat(this._input.value)||0,I=parseFloat(this._input.step)||1,S=this._input.min?parseFloat(this._input.min):void 0,H=this._input.max?parseFloat(this._input.max):void 0;let L=A-I;S!==void 0&&L<S&&(L=S),H!==void 0&&L>H&&(L=H),this._input.value=L.toString(),this.setAttribute("value",L.toString()),this._input.dispatchEvent(new Event("input",{bubbles:!0})),this._input.dispatchEvent(new Event("change",{bubbles:!0}))}})}this._numberIncrementButton&&(this._numberIncrementButton.disabled=r||a),this._numberDecrementButton&&(this._numberDecrementButton.disabled=r||a)}else this._numberSpinnerContainer&&(this._numberSpinnerContainer.remove(),this._numberSpinnerContainer=null,this._numberIncrementButton=null,this._numberDecrementButton=null);if(e){if(this._input&&(this._input.remove(),this._input=null),this._textarea||(this._textarea=document.createElement("textarea"),this._wrapper.appendChild(this._textarea),this.setupEventListeners()),this._element=this._textarea,this._textarea.placeholder=n,this._textarea.disabled=r,this._textarea.readOnly=a,this._textarea.required=l,this._textarea.rows=p,this._textarea.setAttribute("aria-invalid",this.hasError()?"true":"false"),d!==this._textarea.value&&(this._textarea.value=d),o?this._textarea.id=o:this._textarea.removeAttribute("id"),c?this._textarea.name=c:this._textarea.removeAttribute("name"),this._textarea.className=this.getInputClasses(),this.firstChild&&this.firstChild!==this._wrapper&&this.firstChild.nodeType===Node.TEXT_NODE){const v=this.firstChild.textContent;v&&!this._textarea.value&&(this._textarea.value=v.trim()),this.removeChild(this.firstChild)}}else if(this._textarea&&(this._textarea.remove(),this._textarea=null),this._input||(this._input=document.createElement("input"),this._wrapper.appendChild(this._input),this.setupEventListeners()),this._element=this._input,this._input.type=t,this._input.placeholder=n,this._input.disabled=r,this._input.readOnly=a,this._input.required=l,this._input.setAttribute("aria-invalid",this.hasError()?"true":"false"),i?(this._input.inputMode="decimal",this._input.pattern="[0-9]*\\.?[0-9]*"):(this._input.removeAttribute("inputmode"),this._input.removeAttribute("pattern")),d!==this._input.value&&(this._input.value=d),o?this._input.id=o:this._input.removeAttribute("id"),c?this._input.name=c:this._input.removeAttribute("name"),this._input.className=this.getInputClasses(),this.firstChild&&this.firstChild!==this._wrapper&&this.firstChild.nodeType===Node.TEXT_NODE){const v=this.firstChild.textContent;v&&!this._input.value&&(this._input.value=v.trim()),this.removeChild(this.firstChild)}let g=this.querySelector(".mint-input-label-container");if(m||f){g||(g=document.createElement("div"),g.className="mint-input-label-container flex flex-col gap-0.5 mb-[.25rem]",this._wrapper&&this._wrapper.parentElement===this?this.insertBefore(g,this._wrapper):this.insertBefore(g,this.firstChild));let v=g.querySelector(".mint-input-label");if(m){v||(v=document.createElement("label"),v.className="mint-input-label text-sm font-medium text-gray-900 dark:text-gray-100 select-none",g.insertBefore(v,g.firstChild)),v.textContent=m;const w=o||((b=this._element)==null?void 0:b.id)||((k=this._colorTextInput)==null?void 0:k.id)||((x=this._input)==null?void 0:x.id)||((E=this._textarea)==null?void 0:E.id);if(w)v.setAttribute("for",w);else{const A=`mint-input-${Math.random().toString(36).substr(2,9)}`;this._element?this._element.id=A:this._colorTextInput?this._colorTextInput.id=A:this._input?this._input.id=A:this._textarea&&(this._textarea.id=A),v.setAttribute("for",A)}r?v.classList.add("opacity-40"):v.classList.remove("opacity-40")}else v&&v.remove();let y=g.querySelector(".mint-input-info");f?(y||(y=document.createElement("span"),y.className="mint-input-info text-xs text-gray-500 dark:text-gray-400 select-none",g.appendChild(y)),y.textContent=f,r?y.classList.add("opacity-40"):y.classList.remove("opacity-40")):y&&y.remove()}else g&&g.remove();this._renderErrorState(),this._renderSkeleton(u)}_renderErrorState(){const t=this.hasError(),e=this.getErrorMessage();let i=this.querySelector(".mint-input-error");t&&e?(i||(i=document.createElement("div"),i.className="mint-input-error mt-1 text-xs text-red-600 dark:text-red-400",this.appendChild(i)),i.textContent=e):i&&i.remove()}setupEventListeners(){this._element&&(this._element.addEventListener("input",()=>{var e;const t=((e=this._element)==null?void 0:e.value)||"";t?this.setAttribute("value",t):this.removeAttribute("value"),this.dispatchEvent(new CustomEvent("input",{detail:{value:t},bubbles:!0,cancelable:!0}))}),this._element.addEventListener("blur",()=>{var e;const t=((e=this._element)==null?void 0:e.value)||"";t?this.setAttribute("value",t):this.removeAttribute("value"),this.dispatchEvent(new CustomEvent("change",{detail:{value:t},bubbles:!0,cancelable:!0}))}))}removeEventListeners(){this._colorPicker&&(this._focusHandler&&(this._colorPicker.removeEventListener("focus",this._focusHandler),this._focusHandler=null),this._blurHandler&&(this._colorPicker.removeEventListener("blur",this._blurHandler),this._blurHandler=null))}focus(){var t;this._isColor()&&this._colorTextInput?this._colorTextInput.focus():(t=this._element)==null||t.focus()}blur(){var t;this._isColor()&&this._colorTextInput?this._colorTextInput.blur():(t=this._element)==null||t.blur()}_renderSkeleton(t){let e=this.querySelector(".mint-input-skeleton-container");const i=this._wrapper||this.querySelector(".relative.w-full");if(t){e||(e=document.createElement("div"),e.className="mint-input-skeleton-container absolute inset-0 z-10 pointer-events-none",i?(i.classList.contains("relative")||i.classList.add("relative"),i.appendChild(e)):(this.style.position="relative",this.appendChild(e)));let s=e.querySelector(".mint-input-skeleton");if(!s){s=document.createElement("div"),s.className="mint-input-skeleton w-full rounded-lg bg-gray-200 dark:bg-gray-700 animate-pulse";const n=this._isTextarea(),r=this.getRows();if(n){const a=r*24+12;s.style.height=`${a}px`}else s.style.height="2.2rem";e.appendChild(s)}e.style.display="block",this._element&&(this._element.style.opacity="0",this._element.style.pointerEvents="none"),this._colorTextInput&&(this._colorTextInput.style.opacity="0",this._colorTextInput.style.pointerEvents="none")}else e&&(e.style.display="none"),this._element&&(this._element.style.opacity="1",this._element.style.pointerEvents="auto"),this._colorTextInput&&(this._colorTextInput.style.opacity="1",this._colorTextInput.style.pointerEvents="auto")}}customElements.get("mint-input")||customElements.define("mint-input",K);class X extends HTMLElement{constructor(){super(),this._input=null,this._textInput=null,this._popover=null,this._calendarContainer=null,this._iconButton=null,this._hiddenInput=null,this._startPartInputs=[],this._endPartInputs=[],this._displayEl=null,this._inputsWrapperEl=null,this._fieldsContainer=null,this._resetHandler=null,this._isInputMode=!1,this._currentMonth=new Date().getMonth(),this._currentYear=new Date().getFullYear(),this._viewMode="calendar",this._selectedStartDate=null,this._selectedEndDate=null,this._isRange=!1,this._popoverObserver=null,this._focusTrapHandler=null,this._escapeHandler=null}static get observedAttributes(){return["value","label","info","disabled","id","name","required","readonly","format","min","max","range","shortcuts","display-format","error","error-message","loading"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline","inline-block"),this.render(),this._setupPopoverWithRetry(),this._attachFormResetListener()}disconnectedCallback(){if(this._popoverObserver&&(this._popoverObserver.disconnect(),this._popoverObserver=null),this._removeFocusTrap(),this._resetHandler){const t=this.closest("form");t&&t.removeEventListener("reset",this._resetHandler),this._resetHandler=null}}isLoading(){return this.hasAttribute("loading")}attributeChangedCallback(t,e,i){if(e!==i){if(t==="error"||t==="error-message"){const s=this.hasError(),n=this.getErrorMessage();this._applyErrorVisuals(s,n,this.isDisabled());return}if(t==="loading"){this.render();return}this.render(),this._input&&this._setupPopoverWithRetry()}}getValue(){return this.getAttribute("value")||""}setValue(t){t?(this.setAttribute("value",t),this._textInput&&(this._textInput.value=t),this._parseValue(t)):(this.removeAttribute("value"),this._textInput&&(this._textInput.value=""),this._selectedStartDate=null,this._selectedEndDate=null),this._buildCalendar(),this._updateDisplayText()}getFormat(){return this.getAttribute("format")||"mm/dd/yyyy"}getLabel(){return this.getAttribute("label")||""}getInfo(){return this.getAttribute("info")||""}isDisabled(){return this.hasAttribute("disabled")}isReadonly(){return this.hasAttribute("readonly")}isRequired(){return this.hasAttribute("required")}hasError(){return this.hasAttribute("error")}getErrorMessage(){return this.getAttribute("error-message")||""}isRange(){return this.hasAttribute("range")}getId(){return this.getAttribute("id")||""}getName(){return this.getAttribute("name")||""}getMin(){return this.getAttribute("min")||""}getMax(){return this.getAttribute("max")||""}getDisplayFormat(){return this.getAttribute("display-format")||"F j, Y"}getShortcuts(){const t=this.getAttribute("shortcuts");if(!t)return[];try{const e=JSON.parse(t);if(Array.isArray(e))return e.map(i=>({label:i.label,action:this._createShortcutAction(i.action)}))}catch{const i=t.trim();if(i&&typeof window[i]=="function"){const s=window[i]();if(Array.isArray(s))return s.map(n=>({label:n.label,action:typeof n.action=="function"?n.action:this._createShortcutAction(n.action)}))}}return[]}_createShortcutAction(t){return typeof t=="function"?t:typeof t=="string"&&typeof window[t]=="function"?window[t]:()=>null}_getDefaultShortcuts(){const t=[{label:"Today",action:()=>new Date}];return this._isRange&&t.push({label:"This Week",action:()=>{const e=new Date,i=e.getDay(),s=new Date(e);s.setDate(e.getDate()-i),s.setHours(0,0,0,0);const n=new Date(s);return n.setDate(s.getDate()+6),n.setHours(23,59,59,999),{start:s,end:n}}},{label:"This Month",action:()=>{const e=new Date,i=new Date(e.getFullYear(),e.getMonth(),1),s=new Date(e.getFullYear(),e.getMonth()+1,0);return s.setHours(23,59,59,999),{start:i,end:s}}}),t}_getFormatTokens(t){const e=[];let i=0;const s=t.toLowerCase();for(;i<s.length;){const n=s[i];if(n==="d"||n==="m"||n==="y"){let r=1,a=i+1;for(;a<s.length&&s[a]===n;)r++,a++;e.push({type:"part",part:n,len:r}),i=a}else e.push({type:"sep",value:t[i]}),i++}return e}_createPartInput(t,e,i,s,n){const r=document.createElement("input");return r.type="text",r.inputMode="numeric",r.pattern="\\d*",r.maxLength=t,r.placeholder=e,r.className="bg-transparent border-none outline-none text-center text-sm font-medium p-0 m-0 focus:outline-none focus:ring-0 disabled:opacity-40 disabled:cursor-not-allowed",r.disabled=i||s,r.readOnly=s,r.required=n,t===4?r.className+=" w-[40px]":t===2&&(r.className+=" w-[30px]"),r}_buildValueFromParts(t,e){let i=0;return e.map(s=>{var r;if(s.type==="sep")return s.value;const n=((r=t[i])==null?void 0:r.value)||"";return i++,n}).join("")}_applyDateToParts(t,e,i,s){if(!e.length)return;if(!t){e.forEach(l=>l.value="");return}const n=this._formatDate(t,s);let r=0,a=0;i.forEach(l=>{if(l.type==="sep")r+=l.value.length;else{const o=n.substr(r,l.len);e[a]&&(e[a].value=o),a++,r+=l.len}})}_syncHiddenInput(){if(!this._hiddenInput)return;const t=this.getFormat(),e=this._getFormatTokens(t),i=this._buildValueFromParts(this._startPartInputs,e);if(this._isRange){const s=this._buildValueFromParts(this._endPartInputs,e);this._hiddenInput.value=s?`${i} - ${s}`:i}else this._hiddenInput.value=i}_focusNext(t,e){if(e+1<t.length){const i=t[e+1];i.focus(),i.setSelectionRange(0,i.value.length)}}_focusPrev(t,e){if(e-1>=0){const i=t[e-1];i.focus(),i.setSelectionRange(i.value.length,i.value.length)}}_attachPartInputHandlers(t,e,i){t.forEach((s,n)=>{const r=s.maxLength||2;s.addEventListener("input",()=>{s.value=s.value.replace(/\D/g,"").slice(0,r),s.value.length>=r&&this._focusNext(t,n),this._syncHiddenInput()}),s.addEventListener("keydown",a=>{a.key==="Backspace"&&s.selectionStart===0&&s.selectionEnd===0&&this._focusPrev(t,n),a.key==="ArrowLeft"&&s.selectionStart===0&&s.selectionEnd===0&&(this._focusPrev(t,n),a.preventDefault()),a.key==="ArrowRight"&&s.selectionStart===s.value.length&&s.selectionEnd===s.value.length&&(this._focusNext(t,n),a.preventDefault())}),s.addEventListener("blur",a=>{var c,d;this._syncHiddenInput();const l=a.relatedTarget;l&&(this.contains(l)||(c=this._popover)!=null&&c.contains(l)||this._calendarContainer&&this._calendarContainer.contains(l))||(this._handleBlur(((d=this._hiddenInput)==null?void 0:d.value)||""),this._exitInputMode(),setTimeout(()=>{if(this._hiddenInput){const p=new FocusEvent("blur",{bubbles:!0,cancelable:!0,relatedTarget:a.relatedTarget});this._hiddenInput.dispatchEvent(p)}},0))})})}_splitRangeInput(t,e){const i=t.split(/\s*-\s*/);return i.length>=2?[i[0],i.slice(1).join("-")]:[t]}_parseValue(t){const e=this.getFormat(),i=this._getFormatTokens(e);if(this._isRange){const[s,n]=this._splitRangeInput(t,e),r=s?this._parseDateString(s,e):null,a=n?this._parseDateString(n,e):null;if(r&&a){const[l,o]=r<=a?[r,a]:[a,r];this._selectedStartDate=l,this._selectedEndDate=o,this._currentMonth=l.getMonth(),this._currentYear=l.getFullYear()}else r&&(this._selectedStartDate=r,this._selectedEndDate=null,this._currentMonth=r.getMonth(),this._currentYear=r.getFullYear());this._applyDateToParts(this._selectedStartDate,this._startPartInputs,i,e),this._applyDateToParts(this._selectedEndDate,this._endPartInputs,i,e)}else{const s=this._parseDateString(t,e);s&&!isNaN(s.getTime())?(this._selectedStartDate=s,this._selectedEndDate=null,this._currentMonth=s.getMonth(),this._currentYear=s.getFullYear(),this._applyDateToParts(s,this._startPartInputs,i,e)):this._applyDateToParts(null,this._startPartInputs,i,e)}this._syncHiddenInput(),this._updateDisplayText()}_parseDateString(t,e){const i=/[\/\-\.\s]+/;if(i.test(t)){const u=t.split(i).filter(g=>g.length>0),_=e.split(/[\/\-\.\s]+/).filter(g=>g.length>0);if(u.length===_.length){let g=0,b=0,k=0;for(let x=0;x<_.length;x++){const E=_[x].toLowerCase(),v=u[x];if(E.includes("d"))g=parseInt(v,10);else if(E.includes("m"))b=parseInt(v,10)-1;else if(E.includes("y")){let y=parseInt(v,10);const w=E.length,A=v.length;A===2&&w===4?y=Math.floor(new Date().getFullYear()/100)*100+y:A===2&&w===2&&(y=Math.floor(new Date().getFullYear()/100)*100+y),k=y}}if(g&&b>=0&&b<=11&&k){const x=new Date(k,b,g);if(!isNaN(x.getTime())&&x.getDate()===g&&x.getMonth()===b&&x.getFullYear()===k)return x}}}const n=t.replace(/[\/\-\.]/g,""),r=e.replace(/[\/\-\.]/g,"").toLowerCase();let a=r.indexOf("d"),l=r.indexOf("m"),o=r.indexOf("y");const c=[{char:"d",index:a},{char:"m",index:l},{char:"y",index:o}].sort((u,_)=>u.index-_.index);let d=0,p=0,h=0,m=0;r.length,n.length;for(const u of c)if(u.char==="d"){const _=r.lastIndexOf("d")-r.indexOf("d")+1,g=n.substr(m,_);if(g.length===0)return null;d=parseInt(g,10),m+=g.length}else if(u.char==="m"){const _=r.lastIndexOf("m")-r.indexOf("m")+1,g=n.substr(m,_);if(g.length===0)return null;p=parseInt(g,10)-1,m+=g.length}else if(u.char==="y"){const _=r.lastIndexOf("y")-r.indexOf("y")+1,g=n.substr(m),b=Math.min(_,g.length),k=g.substr(0,b);if(k.length===0)return null;let x=parseInt(k,10);b===2&&_===4?x=Math.floor(new Date().getFullYear()/100)*100+x:b===2&&_===2&&(x=Math.floor(new Date().getFullYear()/100)*100+x),h=x,m+=b}if(!d||p<0||p>11||!h)return null;const f=new Date(h,p,d);return isNaN(f.getTime())||f.getDate()!==d||f.getMonth()!==p||f.getFullYear()!==h?null:f}_formatDate(t,e){const i=t.getDate(),s=t.getMonth()+1,n=t.getFullYear(),r=e.toLowerCase();let a=e;return r.includes("dd")?a=a.replace(/dd/gi,String(i).padStart(2,"0")):r.includes("d")&&(a=a.replace(/d/gi,String(i))),r.includes("mm")?a=a.replace(/mm/gi,String(s).padStart(2,"0")):r.includes("m")&&(a=a.replace(/m/gi,String(s))),r.includes("yyyy")?a=a.replace(/yyyy/gi,String(n)):r.includes("yy")&&(a=a.replace(/yy/gi,String(n).substr(2))),a}_formatDatePhp(t,e){const i=t.getDate(),s=t.getMonth()+1,n=t.getFullYear(),r=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],a=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],l=["January","February","March","April","May","June","July","August","September","October","November","December"],o=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],c=(h,m=2)=>h.toString().padStart(m,"0"),d=h=>{const m=h%10,f=h%100;return m===1&&f!==11?"st":m===2&&f!==12?"nd":m===3&&f!==13?"rd":"th"};let p="";for(let h=0;h<e.length;h++){const m=e[h];if(m==="\\"&&h+1<e.length){p+=e[h+1],h++;continue}switch(m){case"Y":p+=n.toString();break;case"y":p+=n.toString().slice(-2);break;case"m":p+=c(s);break;case"n":p+=s.toString();break;case"M":p+=o[s-1];break;case"F":p+=l[s-1];break;case"d":p+=c(i);break;case"j":p+=i.toString();break;case"D":p+=a[t.getDay()];break;case"l":p+=r[t.getDay()];break;case"S":p+=d(i);break;default:p+=m;break}}return p}_validateDateString(t,e){const i=this._parseDateString(t,e);return i!==null&&!isNaN(i.getTime())}render(){const t=this.isLoading(),e=this.getLabel(),i=this.getInfo(),s=this.getValue(),n=this.isDisabled(),r=this.isReadonly(),a=this.isRequired(),l=this.getId(),o=this.getName(),c=this.getFormat(),d=this.hasError(),p=this.getErrorMessage();this._isRange=this.isRange(),this._input||(this._input=document.createElement("div"),this._input.className="relative w-full",this.appendChild(this._input));let h=this.querySelector(".mint-date-picker-label-container");if(e||i){h||(h=document.createElement("div"),h.className="mint-date-picker-label-container flex flex-col gap-0.5 mb-[.25rem]",this.contains(this._input)?this.insertBefore(h,this._input):this.appendChild(h));let b=h.querySelector(".mint-date-picker-label");e?(b||(b=document.createElement("label"),b.className="mint-date-picker-label text-sm font-medium text-gray-900 dark:text-gray-100 select-none",h.insertBefore(b,h.firstChild)),b.textContent=e,l&&this._textInput&&b.setAttribute("for",l)):b&&b.remove();let k=h.querySelector(".mint-date-picker-info");i?(k||(k=document.createElement("span"),k.className="mint-date-picker-info text-xs text-gray-500 dark:text-gray-400 select-none",h.appendChild(k)),k.textContent=i):k&&k.remove()}else h&&h.remove();this._hiddenInput||(this._hiddenInput=document.createElement("input"),this._hiddenInput.type="hidden",this._hiddenInput.value=s||"",this._textInput=this._hiddenInput,this._input.appendChild(this._hiddenInput)),l&&(this._hiddenInput.id=l),o&&(this._hiddenInput.name=o),this._hiddenInput.value=s||"",this._hiddenInput.setAttribute("aria-invalid",d?"true":"false");let m=this._input.querySelector(".mint-date-fields");m||(m=document.createElement("div"),this._input.appendChild(m)),this._fieldsContainer=m,this._applyErrorVisuals(d,p,n),m.innerHTML="",this._displayEl=document.createElement("div");const f=r?"select-text":"select-none";this._displayEl.className=`flex-1 text-gray-900 dark:text-white ${r?"cursor-default":"cursor-text"} ${f} focus:outline-none`,this._displayEl.tabIndex=n||r?-1:0,this._displayEl.addEventListener("click",()=>{n||r||this._enterInputMode()}),this._displayEl.addEventListener("keydown",b=>{n||r||(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),this._enterInputMode())}),this._inputsWrapperEl=document.createElement("div"),this._inputsWrapperEl.className="flex items-center gap-1 w-full";const u=this._getFormatTokens(c);this._startPartInputs=[],this._endPartInputs=[];const _=b=>{const k=document.createDocumentFragment();return u.forEach(x=>{if(x.type==="sep"){const E=document.createElement("span");E.textContent=x.value,E.className="text-gray-400 dark:text-gray-500 select-none",k.appendChild(E)}else{const E=x.part==="d"?"dd":x.part==="m"?"mm":x.len===2?"yy":"yyyy",v=this._createPartInput(x.len,E,n,r,a);b==="start"?this._startPartInputs.push(v):this._endPartInputs.push(v),k.appendChild(v)}}),k};if(this._inputsWrapperEl.appendChild(_("start")),this._isRange){const b=document.createElement("span");b.textContent=" - ",b.className="text-gray-400 dark:text-gray-500 select-none",this._inputsWrapperEl.appendChild(b),this._inputsWrapperEl.appendChild(_("end"))}const g=document.createElement("div");if(g.className="flex flex-col w-full",this._displayEl.style.display=this._isInputMode?"none":"flex",this._inputsWrapperEl.style.display=this._isInputMode?"flex":"none",g.appendChild(this._displayEl),g.appendChild(this._inputsWrapperEl),m.appendChild(g),m.addEventListener("click",()=>{this._isInputMode||n||r||this._enterInputMode()}),this._attachPartInputHandlers(this._startPartInputs,u,m),this._isRange&&this._attachPartInputHandlers(this._endPartInputs,u,m),this._parseValue(s),this._syncHiddenInput(),this._updateDisplayText(),this._iconButton)this._iconButton.disabled=n||r,!n&&!r?this._iconButton.tabIndex=0:this._iconButton.tabIndex=-1;else{this._iconButton=document.createElement("button"),this._iconButton.type="button",this._iconButton.tabIndex=0,this._iconButton.className="absolute left-2 top-[.55rem] text-gray-400 dark:text-gray-500 hover:text-gray-600 dark:hover:text-gray-300 cursor-pointer z-10 focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500 pointer-events-auto disabled:opacity-40 disabled:cursor-not-allowed flex items-center justify-center rounded-sm";const b=`date-icon-${Math.random().toString(36).substr(2,9)}`;this._iconButton.id=b;const k=document.createElement("mint-icon");k.setAttribute("name","calendar"),k.className="w-4 h-4 pointer-events-none",this._iconButton.appendChild(k),this._iconButton.addEventListener("click",()=>{n||r||this._enterInputMode()}),this._input.prepend(this._iconButton),this._iconButton.disabled=n||r}this._renderErrorState(d,p),this._renderSkeleton(t)}_renderErrorState(t,e){let i=this.querySelector(".mint-date-picker-error");t&&e?(i||(i=document.createElement("div"),i.className="mint-date-picker-error mt-1 text-xs text-red-600 dark:text-red-400",this.appendChild(i)),i.textContent=e):i&&i.remove()}_applyErrorVisuals(t,e,i){if(this._renderErrorState(t,e),this._fieldsContainer){const s=this._getFieldContainerClass(t,i);this._fieldsContainer.className=s}this._hiddenInput&&this._hiddenInput.setAttribute("aria-invalid",t?"true":"false")}_attachFormResetListener(){const t=this.closest("form");!t||this._resetHandler||(this._resetHandler=()=>{this.setValue(""),this._clearPartInputs(this._startPartInputs),this._clearPartInputs(this._endPartInputs),this._isInputMode=!1,this._updateDisplayText(),this._applyErrorVisuals(!1,"",this.isDisabled())},t.addEventListener("reset",this._resetHandler))}_clearPartInputs(t){t.forEach(e=>{e.value=""})}_getFieldContainerClass(t,e){return["mint-date-fields relative w-full pl-10 pr-3.5 py-1.5 min-h-[2rem] text-sm font-medium rounded-lg box-border bg-white dark:bg-gray-700 text-gray-900 dark:text-white","border-2",t?"border-red-300 dark:border-red-300":"border-gray-200 dark:border-gray-600","transition-all duration-200 outline-none focus-within:ring-2 focus-within:ring-offset-1",t?"focus-within:ring-red-400 dark:focus-within:ring-red-500":"focus-within:ring-gray-400 dark:focus-within:ring-gray-500","flex items-center gap-1"].join(" ")+(e?" opacity-40 cursor-not-allowed":"")}_handleInputChange(t){}_cleanInputValue(t,e){return t}_handleBlur(t){const e=this.getFormat();if(!t){this.setValue(""),this._updateDisplayText();return}if(this._isRange){const[i,s]=this._splitRangeInput(t,e),n=i?this._parseDateString(i,e):null,r=s?this._parseDateString(s,e):null;if(n&&r){const[a,l]=n<=r?[n,r]:[r,n],o=this._formatDate(a,e),c=this._formatDate(l,e),d=`${o} - ${c}`;this.setValue(d),this._applyDateToParts(a,this._startPartInputs,this._getFormatTokens(e),e),this._applyDateToParts(l,this._endPartInputs,this._getFormatTokens(e),e),this._selectedStartDate=a,this._selectedEndDate=l,this._currentMonth=a.getMonth(),this._currentYear=a.getFullYear()}else if(n){const a=this._formatDate(n,e);this.setValue(a),this._applyDateToParts(n,this._startPartInputs,this._getFormatTokens(e),e),this._applyDateToParts(null,this._endPartInputs,this._getFormatTokens(e),e),this._selectedStartDate=n,this._selectedEndDate=null,this._currentMonth=n.getMonth(),this._currentYear=n.getFullYear()}else this.setValue(""),this._applyDateToParts(null,this._startPartInputs,this._getFormatTokens(e),e),this._applyDateToParts(null,this._endPartInputs,this._getFormatTokens(e),e),this._selectedStartDate=null,this._selectedEndDate=null}else if(this._validateDateString(t,e)){const i=this._parseDateString(t,e);if(i){const s=this._formatDate(i,e);this.setValue(s),this._applyDateToParts(i,this._startPartInputs,this._getFormatTokens(e),e),this._selectedStartDate=i,this._selectedEndDate=null,this._currentMonth=i.getMonth(),this._currentYear=i.getFullYear()}}else this.setValue(""),this._applyDateToParts(null,this._startPartInputs,this._getFormatTokens(e),e),this._selectedStartDate=null,this._selectedEndDate=null}_setupPopoverWithRetry(t=0){if(!this._iconButton){t<10&&requestAnimationFrame(()=>{this._setupPopoverWithRetry(t+1)});return}const e=10,i=this._iconButton.id;i&&this._iconButton.isConnected?document.getElementById(i)?this._createPopover(i):t<e&&requestAnimationFrame(()=>{this._setupPopoverWithRetry(t+1)}):t<e&&requestAnimationFrame(()=>{this._setupPopoverWithRetry(t+1)})}_createPopover(t){if(!t)return;if(!document.getElementById(t)){setTimeout(()=>{this._createPopover(t)},50);return}if(!this._popover)this._popover=document.createElement("mint-popover"),this._popover.setAttribute("direction","down"),this._popover.setAttribute("padding","0"),this.parentNode?this.parentNode.insertBefore(this._popover,this.nextSibling):document.body.appendChild(this._popover),requestAnimationFrame(()=>{requestAnimationFrame(()=>{this._popover&&this._popover.isConnected&&(this._popover.setAttribute("trigger-id",t),this._popoverObserver||(this._popoverObserver=new MutationObserver(i=>{i.forEach(s=>{var n;if(s.type==="attributes"&&s.attributeName==="open")if((n=this._popover)==null?void 0:n.hasAttribute("open"))requestAnimationFrame(()=>{this._buildCalendar();const a=this._popover;typeof a.render=="function"&&a.render(),this._setupFocusTrap()});else{if(this._removeFocusTrap(),this._iconButton&&!this._iconButton.disabled&&requestAnimationFrame(()=>{var a;(a=this._iconButton)==null||a.focus()}),this._viewMode="calendar",this._selectedStartDate)this._currentMonth=this._selectedStartDate.getMonth(),this._currentYear=this._selectedStartDate.getFullYear();else{const a=new Date;this._currentMonth=a.getMonth(),this._currentYear=a.getFullYear()}requestAnimationFrame(()=>{this._buildCalendar()}),this._hiddenInput&&(this._syncHiddenInput(),setTimeout(()=>{var l;const a=new FocusEvent("blur",{bubbles:!0,cancelable:!0,relatedTarget:null});(l=this._hiddenInput)==null||l.dispatchEvent(a)},0))}})}),this._popoverObserver.observe(this._popover,{attributes:!0,attributeFilter:["open"]})),requestAnimationFrame(()=>{this._buildCalendar()}))})});else{if(this._popover.getAttribute("trigger-id")!==t){this._popover.setAttribute("trigger-id",t);const s=this._popover;typeof s._setupTrigger=="function"&&s._setupTrigger()}this._buildCalendar()}}_buildCalendar(){if(!this._popover)return;this._calendarContainer&&this._calendarContainer.parentNode&&this._calendarContainer.remove(),this._calendarContainer=document.createElement("div"),this._calendarContainer.className="mint-date-calendar bg-white dark:bg-gray-800 rounded-lg p-4 w-[22rem] md:w-auto md:min-w-[28rem]",this._viewMode==="calendar"?this._buildCalendarView():this._viewMode==="month"?this._buildMonthView():this._viewMode==="year"&&this._buildYearView();const t=this._popover.querySelector(".popover-content");if(t){for(;t.firstChild;)t.removeChild(t.firstChild);t.appendChild(this._calendarContainer)}else this._popover.appendChild(this._calendarContainer)}_buildCalendarView(){if(!this._calendarContainer)return;const t=this._getDaysInMonth(this._currentMonth,this._currentYear),e=this._getFirstDayOfMonth(this._currentMonth,this._currentYear),i=["January","February","March","April","May","June","July","August","September","October","November","December"],s=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],n=this.getShortcuts(),r=n.length>0;this._calendarContainer.className=r?"mint-date-calendar bg-white dark:bg-gray-800 rounded-lg p-4 w-[18rem] md:w-auto md:min-w-[28rem]":"mint-date-calendar bg-white dark:bg-gray-800 rounded-lg p-4 w-[18rem] md:min-w-[18rem]";const a=document.createElement("div");a.className="flex flex-col md:flex-row md:gap-6 md:items-start";const l=document.createElement("div");l.className="flex-1 min-w-0";const o=document.createElement("div");o.className="flex items-center justify-between mb-4";const c=document.createElement("button");c.type="button",c.tabIndex=0,c.className="p-1 rounded hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-600 dark:text-gray-300 transition-colors flex items-center focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500",c.setAttribute("data-keep-popover-open","true");const d=document.createElement("mint-icon");d.setAttribute("name","caret-left"),d.className="w-4 h-4",c.appendChild(d),c.addEventListener("click",()=>{this._currentMonth===0?(this._currentMonth=11,this._currentYear--):this._currentMonth--,this._buildCalendar()}),o.appendChild(c);const p=document.createElement("div");p.className="flex items-center gap-2";const h=document.createElement("button");h.type="button",h.tabIndex=0,h.className="text-sm font-medium text-gray-900 dark:text-gray-100 hover:text-gray-600 dark:hover:text-gray-300 transition-colors flex items-center focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500",h.setAttribute("data-keep-popover-open","true"),h.textContent=i[this._currentMonth],h.addEventListener("click",()=>{this._viewMode="month",this._buildCalendar()}),p.appendChild(h);const m=document.createElement("button");m.type="button",m.tabIndex=0,m.className="text-sm font-medium text-gray-900 dark:text-gray-100 hover:text-gray-600 dark:hover:text-gray-300 transition-colors flex items-center focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500",m.setAttribute("data-keep-popover-open","true"),m.textContent=String(this._currentYear),m.addEventListener("click",()=>{this._viewMode="year",this._buildCalendar()}),p.appendChild(m),o.appendChild(p);const f=document.createElement("button");f.type="button",f.tabIndex=0,f.className="p-1 rounded hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-600 dark:text-gray-300 transition-colors flex items-center focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500",f.setAttribute("data-keep-popover-open","true");const u=document.createElement("mint-icon");u.setAttribute("name","caret-right"),u.className="w-4 h-4",f.appendChild(u),f.addEventListener("click",()=>{this._currentMonth===11?(this._currentMonth=0,this._currentYear++):this._currentMonth++,this._buildCalendar()}),o.appendChild(f);const _=document.createElement("div");_.className="grid grid-cols-7 mb-2",s.forEach(x=>{const E=document.createElement("div");E.className="text-xs font-medium text-gray-500 dark:text-gray-400 text-center py-1",E.textContent=x,_.appendChild(E)});const g=document.createElement("div");g.className="grid grid-cols-7";for(let x=0;x<e;x++){const E=document.createElement("div");E.className="w-8 h-8",g.appendChild(E)}const b=this.getMin()?this._parseDateString(this.getMin(),this.getFormat()):null,k=this.getMax()?this._parseDateString(this.getMax(),this.getFormat()):null;for(let x=1;x<=t;x++){const E=new Date(this._currentYear,this._currentMonth,x),v=this._isToday(E),y=this._isDateSelected(E),w=this._isDateInRange(E),A=b&&E<b||k&&E>k;let I="rounded-md";if(this._isRange&&this._selectedStartDate&&this._selectedEndDate){const H=this._isSameDate(E,this._selectedStartDate),L=this._isSameDate(E,this._selectedEndDate);H&&L?I="rounded-md":H?I="rounded-l-md":L?I="rounded-r-md":w&&(I="rounded-none")}else y&&!this._isRange&&(I="rounded-md");const S=document.createElement("button");S.type="button",S.disabled=!!A,S.tabIndex=A?-1:0,S.className=`w-full h-8 ${I} border-0 text-sm font-medium transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500 ${y?"bg-slate-800 dark:bg-slate-600 text-white":w?"bg-slate-100 dark:bg-slate-700 text-slate-800 dark:text-slate-200":v?"text-gray-900 dark:text-gray-100 font-semibold":"text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700"} ${A?"opacity-40 cursor-not-allowed":""}`,S.textContent=x.toString(),A||S.addEventListener("click",()=>{this._handleDateClick(E)}),g.appendChild(S)}if(r){const x=document.createElement("div");x.className="mb-4 pb-4 border-b border-gray-200 dark:border-gray-700 md:mb-0 md:pb-0 md:border-b-0 md:border-r md:border-r-gray-200 dark:md:border-r-gray-700 md:pr-6 md:mr-0 md:w-32 md:flex-shrink-0 md:h-full md:flex md:flex-col";const E=document.createElement("div");E.className="relative md:relative md:flex-1 md:min-h-0";const v=document.createElement("div");v.className="flex gap-2 overflow-x-auto pb-1 md:flex-col md:overflow-x-visible md:overflow-y-auto md:pb-0 md:gap-2",v.style.scrollbarWidth="none",v.style.msOverflowStyle="none",v.style.setProperty("-webkit-overflow-scrolling","touch");const y=document.createElement("style");y.textContent=`
|
|
55
55
|
.mint-date-shortcuts-row::-webkit-scrollbar {
|
|
56
56
|
display: none;
|
|
57
57
|
}
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
background: rgba(255, 255, 255, 0.2);
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
|
-
`,v.classList.add("mint-date-shortcuts-row"),document.head.querySelector("style[data-mint-date-shortcuts]")||(k.setAttribute("data-mint-date-shortcuts","true"),document.head.appendChild(k));const w=document.createElement("div");w.className="absolute left-0 top-0 bottom-0 w-8 pointer-events-none z-10 bg-gradient-to-r from-white dark:from-gray-800 to-transparent opacity-0 transition-opacity duration-200 md:hidden",E.appendChild(w);const A=document.createElement("div");A.className="absolute right-0 top-0 bottom-0 w-8 pointer-events-none z-10 bg-gradient-to-l from-white dark:from-gray-800 to-transparent opacity-100 transition-opacity duration-200 md:hidden",E.appendChild(A);const I=document.createElement("div");I.className="hidden md:block absolute top-0 left-0 right-0 h-8 pointer-events-none z-10 bg-gradient-to-b from-white dark:from-gray-800 to-transparent opacity-0 transition-opacity duration-200",E.appendChild(I);const S=document.createElement("div");S.className="hidden md:block absolute bottom-0 left-0 right-0 h-8 pointer-events-none z-10 bg-gradient-to-t from-white dark:from-gray-800 to-transparent opacity-100 transition-opacity duration-200",E.appendChild(S);const H=()=>{if(window.innerWidth>=768){const D=v.scrollTop,T=v.scrollHeight,N=v.clientHeight;D>0?I.style.opacity="1":I.style.opacity="0",D+N<T-1?S.style.opacity="1":S.style.opacity="0",w.style.opacity="0",A.style.opacity="0"}else{const D=v.scrollLeft,T=v.scrollWidth,N=v.clientWidth;D>0?w.style.opacity="1":w.style.opacity="0",D+N<T-1?A.style.opacity="1":A.style.opacity="0",I.style.opacity="0",S.style.opacity="0"}};v.addEventListener("scroll",H),window.addEventListener("resize",H),setTimeout(H,0),n.forEach(L=>{const D=document.createElement("button");D.type="button",D.tabIndex=0,D.className="px-3 py-1.5 text-xs font-medium rounded-md bg-gray-100 dark:bg-gray-700 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-600 transition-colors whitespace-nowrap flex-shrink-0 md:w-full md:text-left focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500",D.textContent=L.label,D.setAttribute("data-keep-popover-open","true"),D.addEventListener("click",()=>{const T=L.action();if(T){if(this._isRange&&"start"in T&&"end"in T){this._selectedStartDate=T.start,this._selectedEndDate=T.end;const N=this.getFormat(),M=this._formatDate(T.start,N),ot=this._formatDate(T.end,N),lt=`${M} - ${ot}`;this.setValue(lt),this._currentMonth=T.start.getMonth(),this._currentYear=T.start.getFullYear()}else if(T instanceof Date){this._selectedStartDate=T,this._selectedEndDate=null;const N=this.getFormat(),M=this._formatDate(T,N);this.setValue(M),this._currentMonth=T.getMonth(),this._currentYear=T.getFullYear()}this._buildCalendar(),this._popover&&typeof this._popover.close=="function"&&this._popover.close(),this.dispatchEvent(new CustomEvent("input",{detail:{value:this.getValue()},bubbles:!0,cancelable:!0})),this.dispatchEvent(new CustomEvent("change",{detail:{value:this.getValue()},bubbles:!0,cancelable:!0}))}}),v.appendChild(D)}),E.appendChild(v),y.appendChild(E),a.appendChild(y)}o.appendChild(l),o.appendChild(g),o.appendChild(_),a.appendChild(o),this._calendarContainer.appendChild(a)}_buildMonthView(){if(!this._calendarContainer)return;const t=["January","February","March","April","May","June","July","August","September","October","November","December"],e=document.createElement("div");e.className="flex items-center justify-between mb-4";const i=document.createElement("button");i.type="button",i.tabIndex=0,i.className="p-1 rounded hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-600 dark:text-gray-300 transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500",i.setAttribute("data-keep-popover-open","true");const s=document.createElement("mint-icon");s.setAttribute("name","caret-left"),s.className="w-4 h-4",i.appendChild(s),i.addEventListener("click",()=>{this._currentYear--,this._buildCalendar()}),e.appendChild(i);const n=document.createElement("button");n.type="button",n.tabIndex=0,n.className="text-sm font-medium text-gray-900 dark:text-gray-100 hover:text-gray-600 dark:hover:text-gray-300 cursor-pointer transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500 rounded px-1",n.setAttribute("data-keep-popover-open","true"),n.textContent=String(this._currentYear),n.addEventListener("click",()=>{this._viewMode="year",this._buildCalendar()}),e.appendChild(n);const r=document.createElement("button");r.type="button",r.tabIndex=0,r.className="p-1 rounded hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-600 dark:text-gray-300 transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500",r.setAttribute("data-keep-popover-open","true");const a=document.createElement("mint-icon");a.setAttribute("name","caret-right"),a.className="w-4 h-4",r.appendChild(a),r.addEventListener("click",()=>{this._currentYear++,this._buildCalendar()}),e.appendChild(r);const o=document.createElement("div");o.className="grid grid-cols-3 gap-2",t.forEach((l,c)=>{const h=document.createElement("button");h.type="button",h.tabIndex=0,h.setAttribute("data-keep-popover-open","true");const p=this._currentMonth===c;h.className=`p-2 rounded text-sm font-medium transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500 ${p?"bg-slate-800 dark:bg-slate-600 text-white":"text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700"}`,h.textContent=l,h.addEventListener("click",()=>{this._currentMonth=c,this._viewMode="calendar",this._buildCalendar()}),o.appendChild(h)}),this._calendarContainer.appendChild(e),this._calendarContainer.appendChild(o)}_buildYearView(){if(!this._calendarContainer)return;const t=this._currentYear-6,e=this._currentYear+6,i=document.createElement("div");i.className="flex items-center justify-between mb-4";const s=document.createElement("button");s.type="button",s.tabIndex=0,s.className="p-1 rounded hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-600 dark:text-gray-300 transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500",s.setAttribute("data-keep-popover-open","true");const n=document.createElement("mint-icon");n.setAttribute("name","caret-left"),n.className="w-4 h-4",s.appendChild(n),s.addEventListener("click",()=>{this._currentYear-=12,this._buildCalendar()}),i.appendChild(s);const r=document.createElement("div");r.className="text-sm font-medium text-gray-900 dark:text-gray-100",r.textContent=`${t} - ${e}`,i.appendChild(r);const a=document.createElement("button");a.type="button",a.tabIndex=0,a.className="p-1 rounded hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-600 dark:text-gray-300 transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500",a.setAttribute("data-keep-popover-open","true");const o=document.createElement("mint-icon");o.setAttribute("name","caret-right"),o.className="w-4 h-4",a.appendChild(o),a.addEventListener("click",()=>{this._currentYear+=12,this._buildCalendar()}),i.appendChild(a);const l=document.createElement("div");l.className="grid grid-cols-3 gap-2";for(let c=t;c<=e;c++){const h=document.createElement("button");h.type="button",h.tabIndex=0,h.setAttribute("data-keep-popover-open","true");const p=this._currentYear===c;h.className=`p-2 rounded text-sm font-medium transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500 ${p?"bg-slate-800 dark:bg-slate-600 text-white":"text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700"}`,h.textContent=String(c),h.addEventListener("click",()=>{this._currentYear=c,this._viewMode="calendar",this._buildCalendar()}),l.appendChild(h)}this._calendarContainer.appendChild(i),this._calendarContainer.appendChild(l)}_getDaysInMonth(t,e){return new Date(e,t+1,0).getDate()}_getFirstDayOfMonth(t,e){return new Date(e,t,1).getDay()}_isToday(t){const e=new Date;return t.getDate()===e.getDate()&&t.getMonth()===e.getMonth()&&t.getFullYear()===e.getFullYear()}_isDateSelected(t){return this._isRange?this._selectedStartDate!==null&&this._isSameDate(t,this._selectedStartDate)||this._selectedEndDate!==null&&this._isSameDate(t,this._selectedEndDate):this._selectedStartDate!==null&&this._isSameDate(t,this._selectedStartDate)}_isDateInRange(t){return!this._isRange||!this._selectedStartDate||!this._selectedEndDate?!1:t>=this._selectedStartDate&&t<=this._selectedEndDate}_hasIncompleteRange(){return this._isRange&&this._selectedStartDate!==null&&this._selectedEndDate===null}_isSameDate(t,e){return t.getDate()===e.getDate()&&t.getMonth()===e.getMonth()&&t.getFullYear()===e.getFullYear()}_handleDateClick(t){const e=this.getFormat();if(this._isRange){if(!this._selectedStartDate||this._selectedStartDate&&this._selectedEndDate?(this._selectedStartDate=t,this._selectedEndDate=null):this._selectedStartDate&&!this._selectedEndDate&&(t<this._selectedStartDate?(this._selectedEndDate=this._selectedStartDate,this._selectedStartDate=t):this._selectedEndDate=t),this._selectedStartDate&&this._selectedEndDate){const i=this._formatDate(this._selectedStartDate,e),s=this._formatDate(this._selectedEndDate,e),n=`${i} - ${s}`;this.setValue(n),this._textInput&&(this._textInput.value=n),this._popover&&typeof this._popover.close=="function"&&this._popover.close()}else if(this._selectedStartDate){const i=this._formatDate(this._selectedStartDate,e);this.setValue(i),this._textInput&&(this._textInput.value=i)}}else{this._selectedStartDate=t;const i=this._formatDate(t,e);this.setValue(i),this._textInput&&(this._textInput.value=i),this._popover&&typeof this._popover.close=="function"&&this._popover.close()}this._buildCalendar(),this._updateDisplayText(),this._exitInputMode(),this.dispatchEvent(new CustomEvent("input",{detail:{value:this.getValue()},bubbles:!0,cancelable:!0})),this.dispatchEvent(new CustomEvent("change",{detail:{value:this.getValue()},bubbles:!0,cancelable:!0}))}_updateDisplayText(){if(!this._displayEl)return;const t=this.getDisplayFormat();let e="";this._isRange?this._selectedStartDate&&this._selectedEndDate?e=`${this._formatDatePhp(this._selectedStartDate,t)} - ${this._formatDatePhp(this._selectedEndDate,t)}`:this._selectedStartDate&&(e=this._formatDatePhp(this._selectedStartDate,t)):this._selectedStartDate&&(e=this._formatDatePhp(this._selectedStartDate,t)),e?(this._displayEl.textContent=e,this._displayEl.classList.remove("text-gray-400","dark:text-gray-500"),this._displayEl.classList.add("text-gray-900","dark:text-white")):(this._displayEl.textContent="Select date",this._displayEl.classList.add("text-gray-400","dark:text-gray-500"),this._displayEl.classList.remove("text-gray-900","dark:text-white")),this._displayEl&&this._inputsWrapperEl&&(this._displayEl.style.display=this._isInputMode?"none":"flex",this._inputsWrapperEl.style.display=this._isInputMode?"flex":"none")}_enterInputMode(){if(!this._isInputMode&&!(this.isReadonly()||this.isDisabled())&&(this._isInputMode=!0,this._displayEl&&this._inputsWrapperEl&&(this._displayEl.style.display="none",this._inputsWrapperEl.style.display="flex"),this._startPartInputs.length>0)){const t=this._startPartInputs[0];requestAnimationFrame(()=>{t.focus();try{t.setSelectionRange(0,t.value.length)}catch{}})}}_exitInputMode(){this._isInputMode&&(this._isInputMode=!1,this._displayEl&&this._inputsWrapperEl&&(this._displayEl.style.display="flex",this._inputsWrapperEl.style.display="none"),this._updateDisplayText())}_renderSkeleton(t){let e=this.querySelector(".mint-date-picker-skeleton-container");const i=this._fieldsContainer,s=this._input;if(t){e||(e=document.createElement("div"),e.className="mint-date-picker-skeleton-container absolute inset-0 z-10 pointer-events-none",s?(s.classList.contains("relative")||s.classList.add("relative"),s.appendChild(e)):(this.style.position="relative",this.appendChild(e)));let n=e.querySelector(".mint-date-picker-skeleton");n||(n=document.createElement("div"),n.className="mint-date-picker-skeleton w-full rounded-lg bg-gray-200 dark:bg-gray-700 animate-pulse",n.style.height="2.25rem",e.appendChild(n)),e.style.display="block",i&&(i.style.visibility="hidden",i.style.pointerEvents="none"),this._displayEl&&(this._displayEl.style.visibility="hidden",this._displayEl.style.pointerEvents="none")}else e&&(e.style.display="none"),i&&(i.style.visibility="visible",i.style.pointerEvents="auto"),this._displayEl&&(this._displayEl.style.visibility="visible",this._displayEl.style.pointerEvents="auto")}_getFocusableElements(){if(!this._calendarContainer)return[];const t=["button:not([disabled])","a[href]",'input:not([disabled]):not([type="hidden"])',"select:not([disabled])","textarea:not([disabled])",'[tabindex]:not([tabindex="-1"])'].join(", ");return Array.from(this._calendarContainer.querySelectorAll(t)).filter(i=>{const s=window.getComputedStyle(i);return s.display!=="none"&&s.visibility!=="hidden"})}_setupFocusTrap(){if(!this._popover||!this._popover.hasAttribute("open"))return;this._removeFocusTrap();const t=this;this._focusTrapHandler=function(e){var o;if(e.key!=="Tab")return;if(!t._popover||!t._popover.hasAttribute("open")){t._removeFocusTrap();return}const i=t._getFocusableElements();if(i.length===0)return;const s=i[0],n=i[i.length-1],r=document.activeElement;if(!(((o=t._calendarContainer)==null?void 0:o.contains(r))||!1)){e.preventDefault(),s.focus();return}if(e.shiftKey&&r===s){e.preventDefault(),n.focus();return}if(!e.shiftKey&&r===n){e.preventDefault(),s.focus();return}},this._escapeHandler=function(e){(e.key==="Escape"||e.key==="Esc")&&t._popover&&t._popover.hasAttribute("open")&&(e.preventDefault(),e.stopPropagation(),typeof t._popover.close=="function"&&t._popover.close())},document.addEventListener("keydown",this._focusTrapHandler,!0),document.addEventListener("keydown",this._escapeHandler,!0),requestAnimationFrame(()=>{const e=this._getFocusableElements();e.length>0&&e[0].focus()})}_removeFocusTrap(){this._focusTrapHandler&&(document.removeEventListener("keydown",this._focusTrapHandler,!0),this._focusTrapHandler=null),this._escapeHandler&&(document.removeEventListener("keydown",this._escapeHandler,!0),this._escapeHandler=null)}}customElements.get("mint-date-picker")||customElements.define("mint-date-picker",X);class Z extends HTMLElement{constructor(){super(),this._select=null,this._wrapper=null,this._caretUpIcon=null,this._caretDownIcon=null,this._changeHandler=null}static get observedAttributes(){return["name","value","disabled","id","required","label","info","error","error-message","multiple","loading"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline","inline-block","w-full"),this.getLabel()||console.error('mint-select: The "label" attribute is required. Please provide a label for the select.'),this.render()}disconnectedCallback(){this._select&&this._changeHandler&&(this._select.removeEventListener("change",this._changeHandler),this._changeHandler=null)}isLoading(){return this.hasAttribute("loading")}attributeChangedCallback(t,e,i){if(e!==i){if(t==="error"||t==="error-message"){this._renderErrorState(),this._select&&(this._select.className=this.getSelectClasses(),this._select.setAttribute("aria-invalid",this.hasError()?"true":"false"));return}if(t==="loading"){this.render();return}if(t==="value"){this._select&&(this._select.value=i||"");return}this.render()}}getName(){return this.getAttribute("name")||""}getValue(){return this.hasAttribute("value")?this.getAttribute("value")||"":this._select?this._select.value:""}setValue(t){const e=t||"";this.setAttribute("value",e),this._select&&(this._select.value=e)}isDisabled(){return this.hasAttribute("disabled")}isMultiple(){return this.hasAttribute("multiple")}hasError(){return this.hasAttribute("error")}getErrorMessage(){return this.getAttribute("error-message")||""}getId(){return this.getAttribute("id")||""}getLabel(){return this.getAttribute("label")||""}getInfo(){return this.getAttribute("info")||""}getSelectClasses(){const t=this.hasError(),e=this.isMultiple(),i=["w-full","px-3.5",e?"pr-3.5":"pr-10",e?"py-2":"py-1.5",e?"min-h-[6rem]":"min-h-[2rem]","text-sm","font-medium","rounded-lg","box-border","bg-white","dark:bg-gray-700","text-gray-900","dark:text-white","transition-all","duration-200","outline-none","focus:outline-none","disabled:opacity-40","disabled:cursor-not-allowed","appearance-none","bg-no-repeat","bg-right","cursor-pointer"],s=["border-2",t?"border-red-300 dark:border-red-300":"border-gray-200 dark:border-gray-600"],n=["focus-visible:ring-2","focus-visible:ring-offset-1",t?"focus-visible:ring-red-400 dark:focus-visible:ring-red-500":"focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500"];return[...i,...s,...n].filter(Boolean).join(" ")}render(){const t=this.isLoading(),e=[];this._select&&Array.from(this._select.children).forEach(d=>{(d.tagName==="OPTION"||d.tagName==="OPTGROUP")&&e.push(d.cloneNode(!0))});const i=Array.from(this.children).filter(d=>d.tagName==="OPTION"||d.tagName==="OPTGROUP").map(d=>d.cloneNode(!0));for(;this.firstChild;)this.removeChild(this.firstChild);this._wrapper=null,this._select=null;const s=this.getLabel(),n=this.getInfo(),r=this.getId(),a=this.getName(),o=this.getValue(),l=this.isDisabled(),c=this.isMultiple(),h=this.hasError();if(s){const d=document.createElement("label");d.className="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",r&&d.setAttribute("for",r);const u=document.createTextNode(s);d.appendChild(u),this.appendChild(d)}this._wrapper=document.createElement("div"),this._wrapper.className="relative w-full",this.appendChild(this._wrapper),this._select=document.createElement("select"),this._select.className=this.getSelectClasses(),r&&(this._select.id=r),a&&(this._select.name=a),l&&(this._select.disabled=!0),c&&(this._select.multiple=!0),this._select.setAttribute("aria-invalid",h?"true":"false");const p=e.length>0?e:i;if(p.length>0&&p.forEach(d=>{this._select.appendChild(d)}),this._select.options.length===0){const d=document.createElement("option");d.value="",d.textContent="Select an option",d.disabled=!0,d.selected=!0,this._select.appendChild(d)}if(this._select.value=o||"",this._changeHandler&&this._select&&this._select.removeEventListener("change",this._changeHandler),this._changeHandler=d=>{const f=d.target.value;f?this.setAttribute("value",f):this.removeAttribute("value"),this.dispatchEvent(new CustomEvent("change",{detail:{value:f},bubbles:!0,cancelable:!0,composed:!0}))},this._select.addEventListener("change",this._changeHandler),this._wrapper.appendChild(this._select),c)this._caretUpIcon=null,this._caretDownIcon=null;else{const d=document.createElement("div");d.className="absolute right-2 top-1/2 -translate-y-1/2 pointer-events-none z-10 flex flex-col",this._caretUpIcon=document.createElement("mint-icon"),this._caretUpIcon.setAttribute("name","caret-up"),this._caretUpIcon.className="w-[.9em] h-[.9em] text-gray-400 dark:text-gray-500 mb-[-.2rem]",d.appendChild(this._caretUpIcon),this._caretDownIcon=document.createElement("mint-icon"),this._caretDownIcon.setAttribute("name","caret-down"),this._caretDownIcon.className="w-[.9em] h-[.9em] text-gray-400 dark:text-gray-500 mt-[-.2rem]",d.appendChild(this._caretDownIcon),this._wrapper.appendChild(d)}if(n){const d=document.createElement("div");d.className="mt-1 text-xs text-gray-500 dark:text-gray-400",d.textContent=n,this.appendChild(d)}this._renderErrorState(),this._renderSkeleton(t)}_renderSkeleton(t){let e=this.querySelector(".mint-select-skeleton-container");const i=this._wrapper;if(t){e||(e=document.createElement("div"),e.className="mint-select-skeleton-container absolute inset-0 z-10 pointer-events-none",i?(i.classList.contains("relative")||i.classList.add("relative"),i.appendChild(e)):(this.style.position="relative",this.appendChild(e)));let s=e.querySelector(".mint-select-skeleton");if(!s){s=document.createElement("div"),s.className="mint-select-skeleton w-full rounded-lg bg-gray-200 dark:bg-gray-700 animate-pulse";const n=this.isMultiple();s.style.height=n?"6rem":"2.25rem",e.appendChild(s)}e.style.display="block",this._select&&(this._select.style.opacity="0",this._select.style.pointerEvents="none")}else e&&(e.style.display="none"),this._select&&(this._select.style.opacity="1",this._select.style.pointerEvents="auto")}_renderErrorState(){const t=this.hasError(),e=this.getErrorMessage();let i=this.querySelector(".mint-select-error");t&&e?(i||(i=document.createElement("div"),i.className="mint-select-error mt-1 text-xs text-red-600 dark:text-red-400",this.appendChild(i)),i.textContent=e):i&&i.remove()}}customElements.get("mint-select")||customElements.define("mint-select",Z);class Q extends HTMLElement{constructor(){super(),this._dropzone=null,this._fileInput=null,this._previewContainer=null,this._isDragging=!1,this._wasDragging=!1,this._isUpdatingFiles=!1,this._listenersInitialized=!1,this._selectedFiles=[],this._previewUrls=[],this._resetHandler=null}static get observedAttributes(){return["label","accept","multiple","width","height","disabled","name","error","error-message","loading"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline","inline-block"),this.render(),this._attachFormResetListener()}disconnectedCallback(){if(this.removeEventListeners(),this._cleanupPreviewUrls(),this._resetHandler){const t=this.closest("form");t&&t.removeEventListener("reset",this._resetHandler),this._resetHandler=null}}attributeChangedCallback(t,e,i){if(e!==i){if(t==="error"||t==="error-message"){this._updateDragStateClass(),this._renderErrorState(this.hasError(),this.getErrorMessage());return}if(t==="loading"){this.render();return}this.render()}}getLabel(){return this.getAttribute("label")||""}getAccept(){return this.getAttribute("accept")||""}isMultiple(){return this.hasAttribute("multiple")}getWidth(){return this.getAttribute("width")||"200px"}getHeight(){return this.getAttribute("height")||"200px"}_renderSkeleton(t){let e=this.querySelector(".mint-dropzone-skeleton-container");const i=this._dropzone;if(t){e||(e=document.createElement("div"),e.className="mint-dropzone-skeleton-container absolute inset-0 z-10 pointer-events-none flex items-center justify-center",i?(i.classList.contains("relative")||i.classList.add("relative"),i.appendChild(e)):(this.style.position="relative",this.appendChild(e)));let s=e.querySelector(".mint-dropzone-skeleton");if(s||(s=document.createElement("div"),s.className="mint-dropzone-skeleton rounded-lg border-2 border-dashed border-gray-300 dark:border-gray-600 bg-gray-200 dark:bg-gray-700 animate-pulse",s.style.width="100%",s.style.height="100%",e.appendChild(s)),e.style.display="flex",i){const n=i.querySelector(".mint-dropzone-icon"),r=i.querySelector(".mint-dropzone-label"),a=i.querySelector(".mint-dropzone-previews-wrapper"),o=this._fileInput;if(n){const l=n;l.style.visibility="hidden",l.style.pointerEvents="none"}if(r){const l=r;l.style.visibility="hidden",l.style.pointerEvents="none"}if(a){const l=a;l.style.visibility="hidden",l.style.pointerEvents="none"}o&&(o.style.visibility="hidden",o.style.pointerEvents="none"),i.style.pointerEvents="none"}}else if(e&&(e.style.display="none"),i){const s=i.querySelector(".mint-dropzone-icon"),n=i.querySelector(".mint-dropzone-label"),r=i.querySelector(".mint-dropzone-previews-wrapper"),a=this._fileInput;if(s){const o=s;o.style.visibility="visible",o.style.pointerEvents="auto"}if(n){const o=n;o.style.visibility="visible",o.style.pointerEvents="auto"}if(r){const o=r;o.style.visibility="visible",o.style.pointerEvents="auto"}a&&(a.style.visibility="visible",a.style.pointerEvents="auto"),i.style.pointerEvents="auto"}}getName(){return this.getAttribute("name")||""}hasError(){return this.hasAttribute("error")}getErrorMessage(){return this.getAttribute("error-message")||""}isDisabled(){return this.hasAttribute("disabled")}isLoading(){return this.hasAttribute("loading")}render(){const t=this.isLoading(),e=this.getLabel(),i=this.getAccept(),s=this.isMultiple(),n=this.isDisabled(),r=this.getWidth(),a=this.getHeight(),o=this.getName(),l=this.hasError(),c=this.getErrorMessage();this._dropzone||(this._dropzone=document.createElement("div"),this.appendChild(this._dropzone)),this._updateDragStateClass(),this._dropzone.setAttribute("aria-invalid",l?"true":"false"),n?(this._dropzone.setAttribute("tabindex","-1"),this._dropzone.removeAttribute("role")):(this._dropzone.setAttribute("tabindex","0"),this._dropzone.setAttribute("role","button"),this._dropzone.setAttribute("aria-label",e||"File upload dropzone")),this._dropzone.style.width=r,this._dropzone.style.height=a,this._dropzone.style.minWidth=r,this._dropzone.style.minHeight=a,this._fileInput||(this._fileInput=document.createElement("input"),this._fileInput.type="file",this._fileInput.style.display="none",this._fileInput.setAttribute("tabindex","-1"),this._fileInput.setAttribute("aria-hidden","true"),this._dropzone.appendChild(this._fileInput)),this._fileInput.accept=i,this._fileInput.multiple=s,this._fileInput.disabled=n,o?this._fileInput.name=o:this._fileInput.removeAttribute("name"),this._fileInput.setAttribute("aria-invalid",l?"true":"false");const h=this._dropzone.querySelector(".mint-dropzone-icon"),p=this._dropzone.querySelector(".mint-dropzone-label");h&&h.remove(),p&&p.remove();const d=document.createElement("div");d.className="mint-dropzone-icon flex items-center justify-center mt-2 mb-2 flex-shrink-0";const u=document.createElement("mint-icon");if(u.setAttribute("name","upload"),u.className="w-12 h-12 text-gray-400 dark:text-gray-500",d.appendChild(u),this._dropzone.appendChild(d),e){const f=document.createElement("div");f.className="mint-dropzone-label text-sm font-medium text-gray-600 dark:text-gray-400 text-center px-4 flex-shrink-0",f.textContent=e,this._dropzone.appendChild(f)}this.setupEventListeners(),this._renderErrorState(l,c),this._renderPreviews(),this._renderSkeleton(t)}_updateDragState(){this._dropzone&&this._updateDragStateClass()}_renderErrorState(t,e){let i=this.querySelector(".mint-dropzone-error");t&&e?(i||(i=document.createElement("div"),i.className="mint-dropzone-error mt-1 text-xs text-red-600 dark:text-red-400",this.appendChild(i)),i.textContent=e):i&&i.remove()}_updateDragStateClass(){if(!this._dropzone)return;const t=this.isDisabled(),e=this.hasError(),n=`relative border-2 border-dashed rounded-lg transition-all duration-200 flex flex-col items-center ${this._selectedFiles.length>0?"justify-start":"justify-center"} cursor-pointer overflow-hidden`,r=this._isDragging?"border-gray-400 dark:border-gray-500 bg-gray-50 dark:bg-gray-800":"border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 hover:border-gray-400 dark:hover:border-gray-500",a=e?"border-red-300 dark:border-red-300 bg-red-50/50 dark:bg-red-900/30":"",o=t?"opacity-40 cursor-not-allowed":"",l="focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500";this._dropzone.className=`${n} ${e?a:r} ${o} ${l}`.trim()}setupEventListeners(){this._listenersInitialized||(this._listenersInitialized=!0,this.removeEventListeners(),!(!this._dropzone||!this._fileInput||this.isDisabled())&&(this._onDropzoneClick||(this._onDropzoneClick=t=>{if(!(this.isDisabled()||!this._fileInput)&&t.target!==this._fileInput&&(t.stopPropagation(),t.preventDefault(),t.isTrusted))try{this._fileInput.click()}catch(e){console.debug("File chooser blocked:",e)}}),this._onDragOver||(this._onDragOver=t=>{t.preventDefault(),t.stopPropagation(),this.isDisabled()||this._isDragging||(this._isDragging=!0,this._wasDragging=!0,this._updateDragState())}),this._onDragLeave||(this._onDragLeave=t=>{var i;t.preventDefault(),t.stopPropagation();const e=(i=this._dropzone)==null?void 0:i.getBoundingClientRect();e&&(t.clientX<e.left||t.clientX>e.right||t.clientY<e.top||t.clientY>e.bottom)&&this._isDragging&&(this._isDragging=!1,this._wasDragging=!1,this._updateDragState())}),this._onDrop||(this._onDrop=t=>{var i;if(t.preventDefault(),t.stopPropagation(),this._isDragging&&(this._isDragging=!1,this._wasDragging=!1,this._updateDragState()),this.isDisabled())return;const e=(i=t.dataTransfer)==null?void 0:i.files;e&&e.length>0&&this._handleFiles(e)}),this._onFileInputInput||(this._onFileInputInput=t=>{t.stopImmediatePropagation(),t.stopPropagation()}),this._onKeyDown||(this._onKeyDown=t=>{if(!(this.isDisabled()||!this._fileInput)&&(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),t.stopPropagation(),t.isTrusted))try{this._fileInput.click()}catch(e){console.debug("File chooser blocked:",e)}}),this._onFocus||(this._onFocus=t=>{this._dropzone&&!this.isDisabled()&&this._dropzone.classList.add("focus-visible:ring-2")}),this._onBlur||(this._onBlur=t=>{this._dropzone}),this._onFileInputChange||(this._onFileInputChange=t=>{if(t.stopImmediatePropagation(),t.stopPropagation(),this._isUpdatingFiles)return;const i=t.target.files;if(i&&i.length>0){const s=this.getAccept(),n=this.isMultiple(),r=[],a=[];for(let o=0;o<i.length;o++){const l=i[o];this._isFileAccepted(l,s)?r.push(l):a.push(l)}if(!n&&r.length>1&&(a.push(...r.slice(1)),r.splice(1)),a.length>0){const o=new CustomEvent("dropRejected",{detail:{files:a,reason:"File type not accepted or multiple files not allowed"},bubbles:!0,cancelable:!0});this.dispatchEvent(o)}r.length>0&&this._applyValidFiles(r)}}),this._dropzone.addEventListener("click",this._onDropzoneClick),this._dropzone.addEventListener("dragover",this._onDragOver),this._dropzone.addEventListener("dragleave",this._onDragLeave),this._dropzone.addEventListener("drop",this._onDrop),this._dropzone.addEventListener("keydown",this._onKeyDown),this._dropzone.addEventListener("focus",this._onFocus),this._dropzone.addEventListener("blur",this._onBlur),this._fileInput.addEventListener("change",this._onFileInputChange),this._fileInput.addEventListener("input",this._onFileInputInput,!0)))}removeEventListeners(){this._dropzone&&(this._onDropzoneClick&&this._dropzone.removeEventListener("click",this._onDropzoneClick),this._onDragOver&&this._dropzone.removeEventListener("dragover",this._onDragOver),this._onDragLeave&&this._dropzone.removeEventListener("dragleave",this._onDragLeave),this._onDrop&&this._dropzone.removeEventListener("drop",this._onDrop),this._onKeyDown&&this._dropzone.removeEventListener("keydown",this._onKeyDown),this._onFocus&&this._dropzone.removeEventListener("focus",this._onFocus),this._onBlur&&this._dropzone.removeEventListener("blur",this._onBlur)),this._fileInput&&(this._onFileInputChange&&this._fileInput.removeEventListener("change",this._onFileInputChange),this._onFileInputInput&&this._fileInput.removeEventListener("input",this._onFileInputInput,!0)),this._isDragging=!1,this._listenersInitialized=!1}_handleFiles(t){const e=this.getAccept(),i=this.isMultiple(),s=[],n=[];for(let r=0;r<t.length;r++){const a=t[r];this._isFileAccepted(a,e)?s.push(a):n.push(a)}if(!i&&s.length>1&&(n.push(...s.slice(1)),s.splice(1)),n.length>0){const r=new CustomEvent("dropRejected",{detail:{files:n,reason:"File type not accepted or multiple files not allowed"},bubbles:!0,cancelable:!0});this.dispatchEvent(r)}s.length>0&&this._applyValidFiles(s)}_isFileAccepted(t,e){var s;if(!e)return!0;const i=e.split(",").map(n=>n.trim().toLowerCase());for(const n of i)if(n.startsWith(".")){if("."+((s=t.name.split(".").pop())==null?void 0:s.toLowerCase())===n)return!0}else if(n.includes("/*")){const r=n.split("/")[0],a=t.type.split("/")[0];if(r===a)return!0}else if(t.type===n)return!0;return!1}_dispatchEvent(t,e){const i=e.target,s=new CustomEvent(t,{detail:{files:i.files?Array.from(i.files):[],value:i.value||""},bubbles:!0,cancelable:!0});this.dispatchEvent(s)}_dispatchSelectionEvents(){const e={files:[...this._selectedFiles],value:""};this.dispatchEvent(new CustomEvent("input",{detail:e,bubbles:!0,cancelable:!0,composed:!0})),this.dispatchEvent(new CustomEvent("change",{detail:e,bubbles:!0,cancelable:!0,composed:!0}))}_syncFileInputFromSelected(){if(!this._fileInput)return;const t=new DataTransfer;this._selectedFiles.forEach(e=>{try{t.items.add(e)}catch(i){console.warn("Failed to add file to DataTransfer:",i)}}),this._isUpdatingFiles=!0;try{this._fileInput.files=t.files}catch(e){console.warn("Failed to set files on input:",e)}setTimeout(()=>{this._isUpdatingFiles=!1},0)}get files(){var t;return this._syncFileInputFromSelected(),((t=this._fileInput)==null?void 0:t.files)||null}syncFiles(){this._syncFileInputFromSelected()}_renderPreviews(){if(!this._dropzone)return;if(this._previewContainer&&(this._cleanupPreviewUrls(),this._previewContainer.remove()),this._selectedFiles.length===0){this._previewContainer=null,this._updateDragStateClass();return}const t=document.createElement("div");t.className="mint-dropzone-previews-wrapper mt-3 w-full relative max-h-48";const e=document.createElement("div");e.className="mint-dropzone-previews w-full flex flex-col gap-2 max-h-48 overflow-y-auto overflow-x-hidden px-2 pb-2",this._selectedFiles.forEach((l,c)=>{const h=document.createElement("div");if(h.className="flex items-center gap-3 p-2 rounded border border-gray-200 dark:border-gray-600 bg-gray-50 dark:bg-gray-800",l.type.startsWith("image/")){const f=document.createElement("img");f.className="w-12 h-12 object-cover rounded border border-gray-200 dark:border-gray-700";const m=URL.createObjectURL(l);this._previewUrls.push(m),f.src=m,h.appendChild(f)}else{const f=document.createElement("mint-icon");f.setAttribute("name","attach"),f.className="w-5 h-5 text-gray-500 dark:text-gray-300",h.appendChild(f)}const p=document.createElement("div");p.className="flex-1 text-sm text-gray-800 dark:text-gray-100 truncate",p.textContent=l.name,h.appendChild(p);const d=document.createElement("button");d.type="button",d.className="text-gray-500 hover:bg-red-100 dark:hover:bg-red-900/30 transition-colors flex items-center justify-center w-6 h-6 rounded-full";const u=document.createElement("mint-icon");u.setAttribute("name","close"),u.className="w-4 h-4",d.appendChild(u),d.addEventListener("click",f=>{f.preventDefault(),f.stopPropagation(),this._removeFileAt(c)}),h.appendChild(d),e.appendChild(h)});const i=this.hasError(),s=this._isDragging;let n="from-white dark:from-gray-700";i?n="from-red-50 dark:from-red-900/30":s&&(n="from-gray-50 dark:from-gray-800");const r=document.createElement("div");r.className=`absolute top-0 left-0 right-0 h-4 pointer-events-none z-10 bg-gradient-to-b ${n} to-transparent opacity-0 transition-opacity duration-200`,t.appendChild(r);const a=document.createElement("div");a.className=`absolute bottom-0 left-0 right-0 h-4 pointer-events-none z-10 bg-gradient-to-t ${n} to-transparent opacity-100 transition-opacity duration-200`,t.appendChild(a);const o=()=>{const l=e.scrollTop,c=e.scrollHeight,h=e.clientHeight;l>0?r.style.opacity="1":r.style.opacity="0",l+h<c-1?a.style.opacity="1":a.style.opacity="0"};o(),e.addEventListener("scroll",o),t.appendChild(e),this._previewContainer=t,this._dropzone.appendChild(t),this._updateDragStateClass()}_removeFileAt(t){if(t<0||t>=this._selectedFiles.length)return;const[e]=this._selectedFiles.splice(t,1);e&&this._cleanupPreviewUrls(),this._syncFileInputFromSelected(),this._renderPreviews(),this._dispatchSelectionEvents()}_cleanupPreviewUrls(){this._previewUrls.forEach(t=>URL.revokeObjectURL(t)),this._previewUrls=[]}_attachFormResetListener(){const t=this.closest("form");!t||this._resetHandler||(this._resetHandler=()=>{this._selectedFiles=[],this._syncFileInputFromSelected(),this._renderPreviews(),this._cleanupPreviewUrls()},t.addEventListener("reset",this._resetHandler))}_applyValidFiles(t){if(this.isMultiple()){const i=t.filter(s=>!this._isDuplicateFile(s));this._selectedFiles.push(...i)}else this._selectedFiles=[t[0]];this._syncFileInputFromSelected(),this._selectedFiles.length>0&&(this.removeAttribute("error"),this.removeAttribute("error-message"),this._fileInput&&this._fileInput.removeAttribute("aria-invalid")),this._renderPreviews(),this._dispatchSelectionEvents()}_isDuplicateFile(t){return this._selectedFiles.some(e=>e.name===t.name&&e.size===t.size&&e.lastModified===t.lastModified)}}customElements.get("mint-dropzone")||customElements.define("mint-dropzone",Q);class tt extends HTMLElement{constructor(){super(),this._form=null,this._submitHandler=null,this._hostSubmitHandler=null,this._errors={},this._fieldBlurHandlers=new Map,this._fieldChangeHandlers=new Map,this._observer=null,this._formData=null,this._headers=null,this._buttonStates=new Map,this._reactiveDataProxy=null,this._reactiveDataObserver=null,this._lastDataSnapshot=null}static get observedAttributes(){return["action","method","enctype","data-form-data","loading","headers"]}connectedCallback(){this._render(),this._ensureSubmitHandler(),this._setupBlurValidation();const t=this.getAttribute("headers");t&&this._parseHeaders(t),requestAnimationFrame(()=>{requestAnimationFrame(()=>{if(this._formData){if(this._isReactiveObject(this._formData)){const e=this._getReactiveValue(this._formData);e&&typeof e=="object"&&!Array.isArray(e)&&(this._lastDataSnapshot=this._createDataSnapshot(e),this._setupReactiveDataObserver(this._formData))}this._applyFormData()}else{const e=this.getAttribute("data-form-data");e&&(this._parseFormData(e),this._applyFormData())}this._propagateLoadingState()})})}disconnectedCallback(){this._form&&this._submitHandler&&this._form.removeEventListener("submit",this._submitHandler,!0),this._hostSubmitHandler&&this.removeEventListener("submit",this._hostSubmitHandler),this._cleanupBlurValidation(),this._stopReactiveDataObserver()}reset(){this._clearErrors(),this._formData?this._applyFormData():this.clear()}clear(){this._clearErrors(),this._form&&this._form.reset(),this._resetCustomFields()}attributeChangedCallback(t,e,i){t==="form-data"?(this._parseFormData(i),this.isConnected&&this._form&&requestAnimationFrame(()=>{requestAnimationFrame(()=>{this._applyFormData()})})):t==="headers"?this._parseHeaders(i):t==="loading"?this.isConnected&&this._form?requestAnimationFrame(()=>{this._propagateLoadingState()}):this._propagateLoadingState():this._applyFormAttributes()}get data(){return this._formData}set data(t){this._stopReactiveDataObserver(),this._reactiveDataProxy=null,this._lastDataSnapshot=null,t&&typeof t=="object"&&!Array.isArray(t)?(this._formData=t,this._isReactiveObject(t)&&this._setupReactiveDataObserver(t),this._lastDataSnapshot=this._createDataSnapshot(t)):t==null?this._formData=null:this._parseFormData(t),this.isConnected&&this._form&&requestAnimationFrame(()=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{this._applyFormData()})})})}get headers(){return this._headers}set headers(t){if(t&&typeof t=="object"&&!Array.isArray(t))this._headers=t;else if(t==null)this._headers=null;else if(typeof t=="string")try{this._headers=JSON.parse(t)}catch{this._headers=null}else this._headers=null}_render(){if(this.classList.add("block","w-full"),!this._form){for(this._form=document.createElement("form"),this._form.noValidate=!0;this.firstChild;)this._form.appendChild(this.firstChild);this.appendChild(this._form)}this._ensureSubmitHandler(),this._applyFormAttributes()}_ensureSubmitHandler(){this._form&&(this._submitHandler&&this._form.removeEventListener("submit",this._submitHandler,!0),this._submitHandler=t=>{t.preventDefault(),t.stopImmediatePropagation(),this._handleSubmit(t)},this._form.addEventListener("submit",this._submitHandler,!0))}_applyFormAttributes(){if(!this._form)return;const t=this.getAttribute("action")||"",e=this.getAttribute("method")||"",i=this.getAttribute("enctype")||"application/x-www-form-urlencoded";t&&(this._form.action=t),e&&(this._form.method=e),this._form.enctype=i}async _handleSubmit(t){if(t.preventDefault(),!this._form)return;this._clearErrors(),this._syncDropzoneFiles();const e=this._collectValidationRules(),i=new FormData(this._form),s=this._formDataToValues(i);if(!this._validate(s,e)){this.dispatchEvent(new CustomEvent("invalid",{detail:{errors:this._errors},bubbles:!0,cancelable:!0,composed:!0}));return}const r=new CustomEvent("submit",{detail:{formData:i,values:s},bubbles:!0,cancelable:!0,composed:!0});if(this.dispatchEvent(r),r.defaultPrevented)return;const a=this.getAttribute("action"),o=this.getAttribute("method");if(!(!a||!o)){this._setButtonsSubmitting();try{const l=await this._submitData(i,s);this.dispatchEvent(new CustomEvent("submitsuccess",{detail:l,bubbles:!0,cancelable:!0}))}catch(l){this.dispatchEvent(new CustomEvent("submiterror",{detail:{error:l},bubbles:!0,cancelable:!0}))}finally{this._restoreButtonsState()}}}async _submitData(t,e){var h,p,d;const i=this.getAttribute("action"),s=this.getAttribute("method"),n=this.getAttribute("enctype")||"application/x-www-form-urlencoded";if(!i)return{status:0,ok:!0,data:{values:e}};const r=Array.from(t.values()).some(u=>u instanceof File);let a=null;const o={};let l=i;if(typeof window<"u"&&((d=(p=(h=window.mintForm)==null?void 0:h.defaults)==null?void 0:p.headers)!=null&&d.common)&&Object.assign(o,window.mintForm.defaults.headers.common),this._headers&&Object.assign(o,this._headers),s==="GET"){const u=new URLSearchParams;t.forEach((f,m)=>{f instanceof File||u.append(m,String(f))}),l+=(i.includes("?")?"&":"?")+u.toString()}else if(n==="multipart/form-data"||r)a=t;else if(n==="application/json")a=JSON.stringify(e),o["Content-Type"]="application/json";else{const u=new URLSearchParams;t.forEach((f,m)=>{f instanceof File||u.append(m,String(f))}),a=u,o["Content-Type"]="application/x-www-form-urlencoded"}if(typeof fetch=="function")try{const u=await fetch(l,{method:s||"POST",body:s==="GET"?null:a,headers:o}),f=await u.text().catch(()=>"");let m=f;try{m=JSON.parse(f)}catch{}if(!u.ok){const _={status:u.status,data:m,response:{status:u.status,data:m}};throw await this._applyErrorInterceptors(_)}const g={status:u.status,ok:u.ok,data:m};return await this._applySuccessInterceptors(g)}catch(u){if(u.response)throw u;const f={status:u.status||0,data:u.data||u.message||"Network error",response:{status:u.status||0,data:u.data||u.message||"Network error"}};throw await this._applyErrorInterceptors(f)}const c=this;return await new Promise(async(u,f)=>{const m=new XMLHttpRequest;m.open(s||"POST",l,!0),Object.entries(o).forEach(([g,_])=>m.setRequestHeader(g,_)),m.onload=async function(){const{status:g,responseText:_}=m;if(g>=200&&g<300){let b=_;try{b=JSON.parse(_)}catch{}try{const x={status:g,ok:!0,data:b},y=await c._applySuccessInterceptors(x);u(y)}catch(x){f(x)}}else{let b=_;try{b=JSON.parse(_)}catch{}try{const x={status:g,data:b,response:{status:g,data:b}},y=await c._applyErrorInterceptors(x);f(y)}catch(x){f(x)}}},m.onerror=async function(){try{const g={status:m.status||0,data:m.responseText||"Network error",response:{status:m.status||0,data:m.responseText||"Network error"}},_=await c._applyErrorInterceptors(g);f(_)}catch(g){f(g)}},m.send(s==="GET"?null:a)})}async _applySuccessInterceptors(t){var s,n,r;if(typeof window>"u"||!((r=(n=(s=window.mintForm)==null?void 0:s.interceptors)==null?void 0:n.response)!=null&&r.handlers))return t;let e=t;const i=window.mintForm.interceptors.response.handlers;for(const a of i)a.fulfilled&&(e=await a.fulfilled(e));return e}async _applyErrorInterceptors(t){var s,n,r;if(typeof window>"u"||!((r=(n=(s=window.mintForm)==null?void 0:s.interceptors)==null?void 0:n.response)!=null&&r.handlers))return Promise.reject(t);let e=t;const i=window.mintForm.interceptors.response.handlers;for(let a=i.length-1;a>=0;a--){const o=i[a];if(o.rejected)try{if(e=await o.rejected(e),e!==void 0)return e}catch(l){e=l}}return Promise.reject(e)}_formDataToValues(t){const e={};return t.forEach((i,s)=>{i instanceof File?(e[s]||(e[s]=[]),e[s].push(i)):s in e?Array.isArray(e[s])?(e[s].length>0&&e[s][0]instanceof File,e[s].push(i)):e[s]=[e[s],i]:e[s]=i}),this._form&&(Array.from(this._form.querySelectorAll("mint-dropzone[name]")).forEach(r=>{const a=r.getAttribute("name");if(a&&typeof r.files<"u"&&r.files){const o=r.files;if(o.length>0){const l=Array.from(o);e[a]&&Array.isArray(e[a])?l.forEach(c=>{e[a].some(p=>p.name===c.name&&p.size===c.size&&p.lastModified===c.lastModified)||e[a].push(c)}):e[a]=l}}}),Array.from(this._form.querySelectorAll('input[type="file"][name]')).forEach(r=>{const a=r.name;if(a&&r.files&&r.files.length>0){const o=Array.from(r.files);e[a]&&Array.isArray(e[a])?o.forEach(l=>{e[a].some(h=>h.name===l.name&&h.size===l.size&&h.lastModified===l.lastModified)||e[a].push(l)}):e[a]=o}}),Array.from(this._form.querySelectorAll("mint-tags[name]")).forEach(r=>{const a=r.getAttribute("name");if(a){let o=[];if(typeof r.tags<"u"?o=r.tags:typeof r.getTags=="function"&&(o=r.getTags()),Array.isArray(o)&&o.length>0){const l=o.map(c=>typeof c=="string"?c:(c==null?void 0:c.value)||(c==null?void 0:c.label)||"").filter(c=>c.trim()!=="");e[a]=l}else e[a]=[]}})),e}_collectValidationRules(){const t={};return this._form&&Array.from(this._form.querySelectorAll("[name][validation]")).forEach(i=>{const s=i.getAttribute("name")||"",n=i.getAttribute("validation");if(!s||!n)return;const r=this._parseRules(n);r.length&&(t[s]=r)}),t}_parseRules(t){if(!t)return[];try{const e=t.replace(/'/g,'"'),i=JSON.parse(e);if(Array.isArray(i))return i.map(s=>String(s))}catch{}return t.split(",").map(e=>e.trim()).filter(Boolean)}_validate(t,e){let i=!0;return this._errors={},Object.entries(e||{}).forEach(([s,n])=>{const r=Array.isArray(n)?n:[n],a=this._getFieldElements(s),o=this._extractFieldValue(a),l=this._validateRules(o,r);l?(i=!1,this._errors[s]=l,this._flagFieldError(a,l)):this._clearFieldError(a)}),i}_validateField(t){const e=this._collectValidationRules();if(!e[t])return;const i=e[t],s=Array.isArray(i)?i:[i],n=this._getFieldElements(t),r=this._extractFieldValue(n),a=this._validateRules(r,s);a?(this._errors[t]=a,this._flagFieldError(n,a)):(this._clearFieldError(n),delete this._errors[t])}_validateRules(t,e){for(const i of e){const[s,n]=i.split(":");switch(s){case"required":{if(t==null||typeof t=="string"&&t.trim()===""||t instanceof FileList&&t.length===0||Array.isArray(t)&&t.length===0)return"This field is required.";break}case"string":{if(typeof t!="string")return"Must be a string.";break}case"email":{if(typeof t=="string"&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t.trim()))return"Enter a valid email.";break}case"number":{const r=Number(t);if(Number.isNaN(r))return"Must be a number.";break}case"min":{const r=Number(n);if(Number.isNaN(r))break;if(typeof t=="string"&&t.trim().length<r)return`Must be at least ${r} characters.`;if(Array.isArray(t)&&t.length<r)return`Select at least ${r}.`;if(t instanceof FileList&&t.length<r)return`Upload at least ${r} files.`;if(t!=null&&!Number.isNaN(Number(t))&&Number(t)<r)return`Must be at least ${r}.`;break}case"max":{const r=Number(n);if(Number.isNaN(r))break;if(typeof t=="string"&&t.trim().length>r)return`Must be at most ${r} characters.`;if(Array.isArray(t)&&t.length>r)return`Select no more than ${r}.`;if(t instanceof FileList&&t.length>r)return`Upload no more than ${r} files.`;if(t!=null&&!Number.isNaN(Number(t))&&Number(t)>r)return`Must be at most ${r}.`;break}}}return null}_getFieldElements(t){if(!this._form)return[];const e=Array.from(this._form.querySelectorAll(`[name="${t}"]`)),i=e.filter(r=>r.tagName==="MINT-SELECT");if(i.length>0){const r=[];return i.forEach(a=>{const o=a.querySelector('select[name="'+t+'"]');o&&r.push(o)}),e.filter(a=>a.tagName!=="MINT-SELECT").concat(r)}if(e.filter(r=>r.tagName==="MINT-TAGS").length>0)return e.filter(r=>r.tagName!=="INPUT"||!r.closest("mint-tags"));const n=e.filter(r=>r.tagName==="INPUT"&&r.closest("mint-tags"));if(n.length>0){const r=[];return n.forEach(a=>{const o=a.closest("mint-tags");o&&!r.includes(o)&&r.push(o)}),e.filter(a=>a.tagName!=="INPUT"||!a.closest("mint-tags")).concat(r)}return e}_extractFieldValue(t){if(t.length===0)return"";const e=t.find(s=>s instanceof HTMLSelectElement);if(e)return e.value;if(t.length>1){const s=t.filter(a=>a instanceof HTMLInputElement);if(s.length>0&&s.length===t.length){const a=s.filter(o=>o.checked);if(s.every(o=>o.type==="radio"))return a.length>0?a[0].value||"on":"";if(s.every(o=>o.type==="checkbox"))return a.map(o=>o.value||"on")}const n=t.filter(a=>a.tagName==="MINT-CHOICE");if(n.length>0&&n.length===t.length){const a=n.find(o=>typeof o.getValue=="function"?o.getValue()!=="":o.querySelector("mint-choice-option[checked]")!==null);if(a){if(typeof a.getValue=="function")return a.getValue();const o=a.querySelector("mint-choice-option[checked]");if(o)return o.getAttribute("value")||""}return""}const r=t.filter(a=>a.tagName==="MINT-CHECKBOX");if(r.length>0&&r.length===t.length)return r.filter(o=>typeof o.checked<"u"?o.checked:o.hasAttribute("checked")).map(o=>o.getAttribute("value")||"on")}const i=t[0];if(i instanceof HTMLInputElement)return i.type==="file"?i.files:i.type==="checkbox"||i.type==="radio"?i.checked?i.value||"on":"":i.value;if(i instanceof HTMLTextAreaElement)return i.value;if(i.tagName==="MINT-SELECT"){const s=i.querySelector("select");if(s)return s.value;if(typeof i.getValue=="function"){const r=i.getValue();if(r!=null&&r!=="")return r}const n=i.getAttribute("value");return n||""}if(i.tagName==="MINT-DROPZONE"&&typeof i.files<"u")return i.files;if(i.tagName==="MINT-TAGS"){let s=null;return typeof i.tags<"u"?s=i.tags:typeof i.getTags=="function"&&(s=i.getTags()),Array.isArray(s)?s.map(r=>typeof r=="string"?r:(r==null?void 0:r.value)||(r==null?void 0:r.label)||"").filter(r=>r.trim()!==""):[]}return i.tagName==="MINT-CHECKBOX"||i.tagName==="MINT-SWITCH"?(typeof i.checked<"u"?i.checked:i.hasAttribute("checked"))?i.getAttribute("value")||"on":"":i.tagName==="MINT-CHOICE"?(typeof i.getValue=="function"?i.getValue():"")||"":typeof i.value<"u"?i.value:i.getAttribute("value")||""}_flagFieldError(t,e){t.length!==0&&t.forEach(i=>{(i instanceof HTMLInputElement||i instanceof HTMLTextAreaElement||i instanceof HTMLSelectElement)&&i.setAttribute("aria-invalid","true");const s=this._resolveHost(i);s&&(s.setAttribute("error",""),s.setAttribute("error-message",e),s.setAttribute("data-mint-form-error","true"))})}_clearFieldError(t){t.length!==0&&t.forEach(e=>{(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)&&e.removeAttribute("aria-invalid");const i=this._resolveHost(e);i&&(i.removeAttribute("error"),i.removeAttribute("error-message"),i.removeAttribute("data-mint-form-error"))})}_clearErrors(){this.querySelectorAll("[data-mint-form-error]").forEach(t=>{const e=t;e.removeAttribute("error"),e.removeAttribute("error-message"),e.removeAttribute("data-mint-form-error")}),this._form&&this._form.querySelectorAll('[aria-invalid="true"]').forEach(t=>{t.removeAttribute("aria-invalid")})}_parseFormData(t){if(!t){this._formData=null;return}if(typeof t=="object"&&!Array.isArray(t)){this._formData=t;return}if(typeof t=="string")try{this._formData=JSON.parse(t)}catch{this._formData=null}else this._formData=null}_parseHeaders(t){if(!t){this._headers=null;return}if(typeof t=="string")try{this._headers=JSON.parse(t)}catch{this._headers=null}else this._headers=null}_applyFormData(){if(!this._formData||!this._form)return;const t=this._getReactiveValue(this._formData);if(!t||typeof t!="object"||Array.isArray(t))return;const e=()=>{Object.entries(t).forEach(([i,s])=>{const n=this._getFieldElements(i);if(n.length===0){setTimeout(()=>{const r=this._getFieldElements(i);r.length>0&&this._applyValueToField(r,i,s)},300);return}this._applyValueToField(n,i,s)})};requestAnimationFrame(()=>{requestAnimationFrame(()=>{e()})})}_applyValueToField(t,e,i){t.forEach(s=>{var r;const n=s.tagName;try{if(n==="MINT-INPUT")typeof s.value<"u"&&(s.value=i||"");else if(n==="MINT-DATE-PICKER")typeof s.setValue=="function"&&s.setValue(i||"");else if(n==="MINT-SELECT"||n==="SELECT")n==="SELECT"?(r=s.closest("mint-select"))==null||r.setValue(i||""):typeof s.setValue=="function"&&s.setValue(i||"");else if(n==="MINT-CHOICE")typeof s.setValue=="function"?s.setValue(i||""):s.querySelectorAll("mint-choice-option").forEach(o=>{o.checked=o.getAttribute("value")===i});else if(n==="MINT-CHECKBOX"||n==="MINT-SWITCH"){const a=i===!0||i==="true"||i==="on"||i===1||i==="1";typeof s.checked<"u"?s.checked=a:a?s.setAttribute("checked",""):s.removeAttribute("checked")}else n==="MINT-TAGS"?Array.isArray(i)&&typeof s.tags<"u"&&(s.tags=i.map(a=>typeof a=="string"?{value:a,label:a,dismissable:!0}:a)):s instanceof HTMLInputElement?s.type==="checkbox"||s.type==="radio"?s.checked=i===!0||i==="true"||i==="on"||i===1||i==="1":s.value=i||"":(s instanceof HTMLTextAreaElement||s instanceof HTMLSelectElement)&&(s.value=i||"")}catch(a){console.warn(`Failed to set value for field ${e}:`,a)}})}_resetCustomFields(){this.querySelectorAll("mint-input, mint-date-picker, mint-select, mint-dropzone, mint-checkbox, mint-choice, mint-switch, mint-tags").forEach(e=>{var s,n;e.removeAttribute("error"),e.removeAttribute("error-message");const i=e.tagName;if(i==="MINT-INPUT")try{e.value=""}catch{}else if(i==="MINT-DATE-PICKER")try{(s=e.setValue)==null||s.call(e,"")}catch{}else if(i==="MINT-SELECT")try{(n=e.setValue)==null||n.call(e,"")}catch{}else if(i==="MINT-DROPZONE"){const r=e.querySelector('input[type="file"]');r&&(r.value="")}else if(i==="MINT-CHECKBOX"||i==="MINT-SWITCH")try{if(typeof e.checked<"u")e.checked=!1;else{e.removeAttribute("checked");const r=e.querySelector('input[type="checkbox"], input[type="radio"]');r&&(r.checked=!1)}}catch{}else if(i==="MINT-CHOICE")try{typeof e.setValue=="function"?e.setValue(""):e.querySelectorAll("mint-choice-option").forEach(a=>{a.checked=!1})}catch{}else if(i==="MINT-TAGS")try{e.tags=[]}catch{}})}_resolveHost(t){if(t.tagName==="MINT-CHOICE-OPTION"){const i=t.closest("mint-choice");if(i)return i}const e=t.closest("mint-input, mint-date-picker, mint-select, mint-dropzone, mint-checkbox, mint-choice, mint-switch, mint-tags");return e||t}_setupBlurValidation(){if(!this._form)return;const t=i=>{const s=i.target;if(!s)return;const n=this._findFieldElement(s);if(!n)return;const r=this._getFieldName(n);if(!r||!this._collectValidationRules()[r])return;const o=this._extractFieldValue([n]),l=o!=null&&(typeof o=="string"?o.trim()!=="":o instanceof FileList||Array.isArray(o)?o.length>0:!0),c=n.hasAttribute("data-mint-form-error")||s instanceof HTMLElement&&(s.hasAttribute("aria-invalid")||s.closest("[data-mint-form-error]")),h=!!n.closest("mint-tags"),p=n.tagName==="MINT-CHECKBOX"||n.tagName==="MINT-SWITCH"||n.tagName==="MINT-CHOICE"||s instanceof HTMLElement&&(s.closest("mint-checkbox, mint-switch, mint-choice")||s.closest("mint-choice-option")),d=n.tagName==="MINT-DATE-PICKER"||s instanceof HTMLElement&&s.closest("mint-date-picker");(l||c||h||p||d)&&setTimeout(()=>{this._validateField(r)},0)};this._form.addEventListener("blur",t,!0),this._fieldBlurHandlers.set(this._form,t);const e=i=>{const s=i.target;if(!s)return;if(i.type==="tags-change"&&s.tagName==="MINT-TAGS"){const c=s,h=this._getFieldName(c);if(!h||!this._collectValidationRules()[h])return;setTimeout(()=>{this._validateField(h)},0);return}if(s instanceof HTMLSelectElement||s.tagName==="MINT-SELECT"||s.closest("mint-select")){const c=this._findFieldElement(s);if(!c)return;const h=this._getFieldName(c);if(!h||!this._collectValidationRules()[h])return;setTimeout(()=>{this._validateField(h)},0);return}if(i.type==="choice-change"&&s.tagName==="MINT-CHOICE"){const c=s,h=this._getFieldName(c);if(!h||!this._collectValidationRules()[h])return;setTimeout(()=>{this._validateField(h)},0);return}if(s instanceof HTMLInputElement&&s.type==="checkbox"||s.tagName==="MINT-CHECKBOX"||s.tagName==="MINT-SWITCH"||s.closest("mint-checkbox, mint-switch")){const c=this._findFieldElement(s);if(!c)return;const h=this._getFieldName(c);if(!h||!this._collectValidationRules()[h])return;setTimeout(()=>{this._validateField(h)},0);return}const a=this._findFieldElement(s);if(!a)return;const o=this._getFieldName(a);!o||!this._collectValidationRules()[o]||(a.hasAttribute("data-mint-form-error")||s instanceof HTMLElement&&s.hasAttribute("aria-invalid"))&&setTimeout(()=>{this._validateField(o)},0)};this._form.addEventListener("change",e,!0),this._form.addEventListener("tags-change",e,!0),this._form.addEventListener("choice-change",e,!0),this._fieldChangeHandlers.set(this._form,e)}_findFieldElement(t){if(t.hasAttribute("name")&&(t.tagName.startsWith("MINT-")||t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement))return t;const e=t.closest("mint-input, mint-date-picker, mint-select, mint-dropzone, mint-checkbox, mint-choice, mint-switch, mint-tags");if(e&&e.hasAttribute("name"))return e;if((t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement)&&t.hasAttribute("name"))return t;let i=t;for(;i&&i!==this._form;){if(i.hasAttribute("name"))return i;i=i.parentElement}return null}_getFieldName(t){return t.hasAttribute("name")||t.tagName.startsWith("MINT-")?t.getAttribute("name"):(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement)&&t.name||null}_cleanupBlurValidation(){if(this._form&&this._fieldBlurHandlers.has(this._form)){const t=this._fieldBlurHandlers.get(this._form);t&&this._form.removeEventListener("blur",t,!0),this._fieldBlurHandlers.delete(this._form)}if(this._form&&this._fieldChangeHandlers.has(this._form)){const t=this._fieldChangeHandlers.get(this._form);t&&(this._form.removeEventListener("change",t,!0),this._form.removeEventListener("tags-change",t,!0),this._form.removeEventListener("choice-change",t,!0)),this._fieldChangeHandlers.delete(this._form)}this._observer&&(this._observer.disconnect(),this._observer=null)}_syncDropzoneFiles(){if(!this._form)return;Array.from(this._form.querySelectorAll("mint-dropzone[name]")).forEach(e=>{typeof e.syncFiles=="function"&&e.syncFiles()})}_propagateLoadingState(){if(!this._form)return;const t=this.getAttribute("loading"),e=t!==null&&t!=="false";Array.from(this._form.querySelectorAll("mint-input, mint-select, mint-date-picker, mint-dropzone, mint-checkbox, mint-choice, mint-switch, mint-tags")).forEach(s=>{e?s.setAttribute("loading",""):s.removeAttribute("loading"),typeof s.render=="function"&&s.render()})}_setButtonsSubmitting(){if(!this._form)return;this._buttonStates.clear();const t=Array.from(this.querySelectorAll("mint-button")),e=Array.from(this.querySelectorAll("button"));t.forEach(i=>{const s=i.getAttribute("disabled")==="true",n=i.getAttribute("loading")==="true";this._buttonStates.set(i,{disabled:s,loading:n});const a=(i.getAttribute("type")||i.getAttribute("button-type")||"default")==="submit";s||i.setAttribute("disabled","true"),a&&i.setAttribute("loading","true"),typeof i.render=="function"&&i.render()}),e.forEach(i=>{if(i.closest("mint-button"))return;const s=i.disabled;this._buttonStates.set(i,{disabled:s,loading:!1}),s||(i.disabled=!0)})}_restoreButtonsState(){if(!this._form)return;const t=Array.from(this.querySelectorAll("mint-button")),e=Array.from(this.querySelectorAll("button"));t.forEach(i=>{const s=this._buttonStates.get(i);s&&(s.disabled?i.setAttribute("disabled","true"):i.removeAttribute("disabled"),s.loading?i.setAttribute("loading","true"):i.removeAttribute("loading"),typeof i.render=="function"&&i.render())}),e.forEach(i=>{if(i.closest("mint-button"))return;const s=this._buttonStates.get(i);s&&(i.disabled=s.disabled)}),this._buttonStates.clear()}_isReactiveObject(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;if("__v_isRef"in t||"_value"in t||"__v_raw"in t||"__ob__"in t)return!0;try{const e=Object.keys(t);if(e.length>0){const i=Object.getOwnPropertyDescriptor(t,e[0]);if(i&&(i.get||i.set))return!0}}catch{return!0}return!0}_createDataSnapshot(t){try{return JSON.parse(JSON.stringify(t))}catch{return{...t}}}_hasDataChanged(t,e){try{return JSON.stringify(t)!==JSON.stringify(e)}catch{return!0}}_getReactiveValue(t){return t&&typeof t=="object"&&"_value"in t?t._value:(t&&typeof t=="object"&&"__ob__"in t,t)}_setupReactiveDataObserver(t){if(!this.isConnected)return;const e=()=>{if(!this._formData||!this._lastDataSnapshot){this._stopReactiveDataObserver();return}const i=this._getReactiveValue(this._formData);i&&typeof i=="object"&&!Array.isArray(i)&&this._hasDataChanged(i,this._lastDataSnapshot)&&(this._lastDataSnapshot=this._createDataSnapshot(i),requestAnimationFrame(()=>{this._applyFormData()})),this.isConnected&&this._formData&&(this._reactiveDataObserver=requestAnimationFrame(e))};this._reactiveDataObserver=requestAnimationFrame(e)}_stopReactiveDataObserver(){this._reactiveDataObserver!==null&&(cancelAnimationFrame(this._reactiveDataObserver),this._reactiveDataObserver=null),this._reactiveDataProxy=null,this._lastDataSnapshot=null}}customElements.get("mint-form")||customElements.define("mint-form",tt);typeof window<"u"&&(window.mintForm=window.mintForm||{defaults:{headers:{common:{}}},interceptors:{response:{handlers:[]}}},window.mintForm.interceptors.response.use||(window.mintForm.interceptors.response.use=function(C,t){return window.mintForm.interceptors.response.handlers.push({fulfilled:C,rejected:t}),window.mintForm.interceptors.response.handlers.length-1}));class et extends HTMLElement{constructor(){super(...arguments),this._observer=null}static get observedAttributes(){return["collapse","scroll"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","align-baseline","block","w-full","overflow-x-auto"),this.hasAttribute("collapse")&&!this.hasAttribute("scroll")&&this._ensureResponsiveStyles(),this._observeChanges(),this._applyStyles(),requestAnimationFrame(()=>{this._applyStyles(),setTimeout(()=>this._applyStyles(),0)})}disconnectedCallback(){this._observer&&(this._observer.disconnect(),this._observer=null)}attributeChangedCallback(){this.hasAttribute("collapse")&&!this.hasAttribute("scroll")&&this._ensureResponsiveStyles(),this._applyStyles()}_observeChanges(){this._observer=new MutationObserver(()=>this._applyStyles()),this._observer.observe(this,{childList:!0,subtree:!0,attributes:!1})}_applyStyles(){this._observer&&this._observer.disconnect();const t=this.querySelector("table");if(!t){this._observer&&this._observeChanges();return}const e=this.hasAttribute("collapse")&&!this.hasAttribute("scroll"),i=this.hasAttribute("scroll");i?this.classList.add("relative"):this.classList.remove("relative");const s=[],n=t.querySelector("thead tr");n&&n.querySelectorAll("th").forEach(c=>s.push((c.textContent||"").trim())),this._setClasses(t,["w-full",i?"min-w-[1200px]":"","border-collapse","text-sm","font-medium","overflow-hidden"]);const r=t.querySelector("thead");if(r){this._setClasses(r,["bg-[#F7F7F7]","dark:bg-gray-800"]);const l=r.querySelectorAll("th");l.forEach((c,h)=>{const p=c.querySelector("mint-icon"),d=(p==null?void 0:p.getAttribute("name"))||"",u=p!==null&&d!=="ellipsis";this._setClasses(c,["text-left","font-semibold","text-gray-900","dark:text-white","px-3","py-2","border-b","border-gray-200","dark:border-gray-700"]),u&&c.classList.add("cursor-pointer","hover:bg-gray-100","dark:hover:bg-gray-700","transition-colors"),h===0&&c.classList.add("pl-6"),h===l.length-1&&c.classList.add("pr-6")})}const a=t.querySelector("tbody");if(a){const l=Array.from(a.querySelectorAll("tr"));l.forEach((c,h)=>{const p=c.hasAttribute("data-row-clickable");this._setClasses(c,["bg-white","dark:bg-gray-900","border-b","border-gray-200","dark:border-gray-700"]),p&&c.classList.add("cursor-pointer","hover:bg-gray-50","dark:hover:bg-gray-800","transition-colors"),h===l.length-1&&c.classList.remove("border-b");const d=c.querySelectorAll("td");d.forEach((u,f)=>{this._setClasses(u,["text-gray-900","dark:text-gray-100","px-3","py-2"]),f===0&&u.classList.add("pl-6"),f===d.length-1&&u.classList.add("pr-6"),e?this._applyMobileCell(u,s):this._restoreCell(u)})})}const o=t.querySelector("tfoot");o&&(this._setClasses(o,["bg-[#F7F7F7]","dark:bg-gray-800","font-semibold"]),o.querySelectorAll("td").forEach(c=>{this._setClasses(c,["text-gray-900","dark:text-gray-100","px-3","py-2","border-t","border-gray-200","dark:border-gray-700"]),this._restoreCell(c)})),this._observer&&this._observeChanges()}_applyMobileCell(t,e){if(t.closest("tfoot")||t.dataset.mtProcessed==="true")return;const i=e[t.cellIndex]||"",s={};Array.from(t.attributes).forEach(l=>{l.name.startsWith("data-")&&l.name!=="data-original"&&l.name!=="data-mt-processed"&&(s[l.name]=l.value)});const n=t.getAttribute("data-original"),r=n!==null?n:t.innerHTML;t.setAttribute("data-original",r),t.dataset.mtProcessed="true",t.innerHTML="";const a=document.createElement("span");a.className="mt-label font-semibold text-gray-700 dark:text-gray-200 hidden",a.textContent=i;const o=document.createElement("span");o.className="mt-value text-gray-900 dark:text-gray-100 text-right md:text-left w-full",o.innerHTML=r,t.appendChild(a),t.appendChild(o),Object.entries(s).forEach(([l,c])=>{t.setAttribute(l,c)})}_restoreCell(t){if(t.dataset.mtProcessed!=="true")return;const e={};Array.from(t.attributes).forEach(s=>{s.name.startsWith("data-")&&s.name!=="data-original"&&s.name!=="data-mt-processed"&&(e[s.name]=s.value)});const i=t.getAttribute("data-original")||"";t.dataset.mtProcessed="",t.innerHTML=i,Object.entries(e).forEach(([s,n])=>{t.setAttribute(s,n)})}_setClasses(t,e){t.className="",e.filter(Boolean).forEach(i=>t.classList.add(...i.split(" ")))}_ensureResponsiveStyles(){if(document.getElementById("mint-table-responsive-style"))return;const t=document.createElement("style");t.id="mint-table-responsive-style",t.textContent=`
|
|
78
|
+
`,v.classList.add("mint-date-shortcuts-row"),document.head.querySelector("style[data-mint-date-shortcuts]")||(y.setAttribute("data-mint-date-shortcuts","true"),document.head.appendChild(y));const w=document.createElement("div");w.className="absolute left-0 top-0 bottom-0 w-8 pointer-events-none z-10 bg-gradient-to-r from-white dark:from-gray-800 to-transparent opacity-0 transition-opacity duration-200 md:hidden",E.appendChild(w);const A=document.createElement("div");A.className="absolute right-0 top-0 bottom-0 w-8 pointer-events-none z-10 bg-gradient-to-l from-white dark:from-gray-800 to-transparent opacity-100 transition-opacity duration-200 md:hidden",E.appendChild(A);const I=document.createElement("div");I.className="hidden md:block absolute top-0 left-0 right-0 h-8 pointer-events-none z-10 bg-gradient-to-b from-white dark:from-gray-800 to-transparent opacity-0 transition-opacity duration-200",E.appendChild(I);const S=document.createElement("div");S.className="hidden md:block absolute bottom-0 left-0 right-0 h-8 pointer-events-none z-10 bg-gradient-to-t from-white dark:from-gray-800 to-transparent opacity-100 transition-opacity duration-200",E.appendChild(S);const H=()=>{if(window.innerWidth>=768){const D=v.scrollTop,T=v.scrollHeight,N=v.clientHeight;D>0?I.style.opacity="1":I.style.opacity="0",D+N<T-1?S.style.opacity="1":S.style.opacity="0",w.style.opacity="0",A.style.opacity="0"}else{const D=v.scrollLeft,T=v.scrollWidth,N=v.clientWidth;D>0?w.style.opacity="1":w.style.opacity="0",D+N<T-1?A.style.opacity="1":A.style.opacity="0",I.style.opacity="0",S.style.opacity="0"}};v.addEventListener("scroll",H),window.addEventListener("resize",H),setTimeout(H,0),n.forEach(L=>{const D=document.createElement("button");D.type="button",D.tabIndex=0,D.className="px-3 py-1.5 text-xs font-medium rounded-md bg-gray-100 dark:bg-gray-700 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-600 transition-colors whitespace-nowrap flex-shrink-0 md:w-full md:text-left focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500",D.textContent=L.label,D.setAttribute("data-keep-popover-open","true"),D.addEventListener("click",()=>{const T=L.action();if(T){if(this._isRange&&"start"in T&&"end"in T){this._selectedStartDate=T.start,this._selectedEndDate=T.end;const N=this.getFormat(),M=this._formatDate(T.start,N),ot=this._formatDate(T.end,N),lt=`${M} - ${ot}`;this.setValue(lt),this._currentMonth=T.start.getMonth(),this._currentYear=T.start.getFullYear()}else if(T instanceof Date){this._selectedStartDate=T,this._selectedEndDate=null;const N=this.getFormat(),M=this._formatDate(T,N);this.setValue(M),this._currentMonth=T.getMonth(),this._currentYear=T.getFullYear()}this._buildCalendar(),this._popover&&typeof this._popover.close=="function"&&this._popover.close(),this.dispatchEvent(new CustomEvent("input",{detail:{value:this.getValue()},bubbles:!0,cancelable:!0})),this.dispatchEvent(new CustomEvent("change",{detail:{value:this.getValue()},bubbles:!0,cancelable:!0}))}}),v.appendChild(D)}),E.appendChild(v),x.appendChild(E),a.appendChild(x)}l.appendChild(o),l.appendChild(_),l.appendChild(g),a.appendChild(l),this._calendarContainer.appendChild(a)}_buildMonthView(){if(!this._calendarContainer)return;const t=["January","February","March","April","May","June","July","August","September","October","November","December"],e=document.createElement("div");e.className="flex items-center justify-between mb-4";const i=document.createElement("button");i.type="button",i.tabIndex=0,i.className="p-1 rounded hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-600 dark:text-gray-300 transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500",i.setAttribute("data-keep-popover-open","true");const s=document.createElement("mint-icon");s.setAttribute("name","caret-left"),s.className="w-4 h-4",i.appendChild(s),i.addEventListener("click",()=>{this._currentYear--,this._buildCalendar()}),e.appendChild(i);const n=document.createElement("button");n.type="button",n.tabIndex=0,n.className="text-sm font-medium text-gray-900 dark:text-gray-100 hover:text-gray-600 dark:hover:text-gray-300 cursor-pointer transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500 rounded px-1",n.setAttribute("data-keep-popover-open","true"),n.textContent=String(this._currentYear),n.addEventListener("click",()=>{this._viewMode="year",this._buildCalendar()}),e.appendChild(n);const r=document.createElement("button");r.type="button",r.tabIndex=0,r.className="p-1 rounded hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-600 dark:text-gray-300 transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500",r.setAttribute("data-keep-popover-open","true");const a=document.createElement("mint-icon");a.setAttribute("name","caret-right"),a.className="w-4 h-4",r.appendChild(a),r.addEventListener("click",()=>{this._currentYear++,this._buildCalendar()}),e.appendChild(r);const l=document.createElement("div");l.className="grid grid-cols-3 gap-2",t.forEach((o,c)=>{const d=document.createElement("button");d.type="button",d.tabIndex=0,d.setAttribute("data-keep-popover-open","true");const p=this._currentMonth===c;d.className=`p-2 rounded text-sm font-medium transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500 ${p?"bg-slate-800 dark:bg-slate-600 text-white":"text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700"}`,d.textContent=o,d.addEventListener("click",()=>{this._currentMonth=c,this._viewMode="calendar",this._buildCalendar()}),l.appendChild(d)}),this._calendarContainer.appendChild(e),this._calendarContainer.appendChild(l)}_buildYearView(){if(!this._calendarContainer)return;const t=this._currentYear-6,e=this._currentYear+6,i=document.createElement("div");i.className="flex items-center justify-between mb-4";const s=document.createElement("button");s.type="button",s.tabIndex=0,s.className="p-1 rounded hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-600 dark:text-gray-300 transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500",s.setAttribute("data-keep-popover-open","true");const n=document.createElement("mint-icon");n.setAttribute("name","caret-left"),n.className="w-4 h-4",s.appendChild(n),s.addEventListener("click",()=>{this._currentYear-=12,this._buildCalendar()}),i.appendChild(s);const r=document.createElement("div");r.className="text-sm font-medium text-gray-900 dark:text-gray-100",r.textContent=`${t} - ${e}`,i.appendChild(r);const a=document.createElement("button");a.type="button",a.tabIndex=0,a.className="p-1 rounded hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-600 dark:text-gray-300 transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500",a.setAttribute("data-keep-popover-open","true");const l=document.createElement("mint-icon");l.setAttribute("name","caret-right"),l.className="w-4 h-4",a.appendChild(l),a.addEventListener("click",()=>{this._currentYear+=12,this._buildCalendar()}),i.appendChild(a);const o=document.createElement("div");o.className="grid grid-cols-3 gap-2";for(let c=t;c<=e;c++){const d=document.createElement("button");d.type="button",d.tabIndex=0,d.setAttribute("data-keep-popover-open","true");const p=this._currentYear===c;d.className=`p-2 rounded text-sm font-medium transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500 ${p?"bg-slate-800 dark:bg-slate-600 text-white":"text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700"}`,d.textContent=String(c),d.addEventListener("click",()=>{this._currentYear=c,this._viewMode="calendar",this._buildCalendar()}),o.appendChild(d)}this._calendarContainer.appendChild(i),this._calendarContainer.appendChild(o)}_getDaysInMonth(t,e){return new Date(e,t+1,0).getDate()}_getFirstDayOfMonth(t,e){return new Date(e,t,1).getDay()}_isToday(t){const e=new Date;return t.getDate()===e.getDate()&&t.getMonth()===e.getMonth()&&t.getFullYear()===e.getFullYear()}_isDateSelected(t){return this._isRange?this._selectedStartDate!==null&&this._isSameDate(t,this._selectedStartDate)||this._selectedEndDate!==null&&this._isSameDate(t,this._selectedEndDate):this._selectedStartDate!==null&&this._isSameDate(t,this._selectedStartDate)}_isDateInRange(t){return!this._isRange||!this._selectedStartDate||!this._selectedEndDate?!1:t>=this._selectedStartDate&&t<=this._selectedEndDate}_hasIncompleteRange(){return this._isRange&&this._selectedStartDate!==null&&this._selectedEndDate===null}_isSameDate(t,e){return t.getDate()===e.getDate()&&t.getMonth()===e.getMonth()&&t.getFullYear()===e.getFullYear()}_handleDateClick(t){const e=this.getFormat();if(this._isRange){if(!this._selectedStartDate||this._selectedStartDate&&this._selectedEndDate?(this._selectedStartDate=t,this._selectedEndDate=null):this._selectedStartDate&&!this._selectedEndDate&&(t<this._selectedStartDate?(this._selectedEndDate=this._selectedStartDate,this._selectedStartDate=t):this._selectedEndDate=t),this._selectedStartDate&&this._selectedEndDate){const i=this._formatDate(this._selectedStartDate,e),s=this._formatDate(this._selectedEndDate,e),n=`${i} - ${s}`;this.setValue(n),this._textInput&&(this._textInput.value=n),this._popover&&typeof this._popover.close=="function"&&this._popover.close()}else if(this._selectedStartDate){const i=this._formatDate(this._selectedStartDate,e);this.setValue(i),this._textInput&&(this._textInput.value=i)}}else{this._selectedStartDate=t;const i=this._formatDate(t,e);this.setValue(i),this._textInput&&(this._textInput.value=i),this._popover&&typeof this._popover.close=="function"&&this._popover.close()}this._buildCalendar(),this._updateDisplayText(),this._exitInputMode(),this.dispatchEvent(new CustomEvent("input",{detail:{value:this.getValue()},bubbles:!0,cancelable:!0})),this.dispatchEvent(new CustomEvent("change",{detail:{value:this.getValue()},bubbles:!0,cancelable:!0}))}_updateDisplayText(){if(!this._displayEl)return;const t=this.getDisplayFormat();let e="";this._isRange?this._selectedStartDate&&this._selectedEndDate?e=`${this._formatDatePhp(this._selectedStartDate,t)} - ${this._formatDatePhp(this._selectedEndDate,t)}`:this._selectedStartDate&&(e=this._formatDatePhp(this._selectedStartDate,t)):this._selectedStartDate&&(e=this._formatDatePhp(this._selectedStartDate,t)),e?(this._displayEl.textContent=e,this._displayEl.classList.remove("text-gray-400","dark:text-gray-500"),this._displayEl.classList.add("text-gray-900","dark:text-white")):(this._displayEl.textContent="Select date",this._displayEl.classList.add("text-gray-400","dark:text-gray-500"),this._displayEl.classList.remove("text-gray-900","dark:text-white")),this._displayEl&&this._inputsWrapperEl&&(this._displayEl.style.display=this._isInputMode?"none":"flex",this._inputsWrapperEl.style.display=this._isInputMode?"flex":"none")}_enterInputMode(){if(!this._isInputMode&&!(this.isReadonly()||this.isDisabled())&&(this._isInputMode=!0,this._displayEl&&this._inputsWrapperEl&&(this._displayEl.style.display="none",this._inputsWrapperEl.style.display="flex"),this._startPartInputs.length>0)){const t=this._startPartInputs[0];requestAnimationFrame(()=>{t.focus();try{t.setSelectionRange(0,t.value.length)}catch{}})}}_exitInputMode(){this._isInputMode&&(this._isInputMode=!1,this._displayEl&&this._inputsWrapperEl&&(this._displayEl.style.display="flex",this._inputsWrapperEl.style.display="none"),this._updateDisplayText())}_renderSkeleton(t){let e=this.querySelector(".mint-date-picker-skeleton-container");const i=this._fieldsContainer,s=this._input;if(t){e||(e=document.createElement("div"),e.className="mint-date-picker-skeleton-container absolute inset-0 z-10 pointer-events-none",s?(s.classList.contains("relative")||s.classList.add("relative"),s.appendChild(e)):(this.style.position="relative",this.appendChild(e)));let n=e.querySelector(".mint-date-picker-skeleton");n||(n=document.createElement("div"),n.className="mint-date-picker-skeleton w-full rounded-lg bg-gray-200 dark:bg-gray-700 animate-pulse",n.style.height="2.25rem",e.appendChild(n)),e.style.display="block",i&&(i.style.visibility="hidden",i.style.pointerEvents="none"),this._displayEl&&(this._displayEl.style.visibility="hidden",this._displayEl.style.pointerEvents="none")}else e&&(e.style.display="none"),i&&(i.style.visibility="visible",i.style.pointerEvents="auto"),this._displayEl&&(this._displayEl.style.visibility="visible",this._displayEl.style.pointerEvents="auto")}_getFocusableElements(){if(!this._calendarContainer)return[];const t=["button:not([disabled])","a[href]",'input:not([disabled]):not([type="hidden"])',"select:not([disabled])","textarea:not([disabled])",'[tabindex]:not([tabindex="-1"])'].join(", ");return Array.from(this._calendarContainer.querySelectorAll(t)).filter(i=>{const s=window.getComputedStyle(i);return s.display!=="none"&&s.visibility!=="hidden"})}_setupFocusTrap(){if(!this._popover||!this._popover.hasAttribute("open"))return;this._removeFocusTrap();const t=this;this._focusTrapHandler=function(e){var l;if(e.key!=="Tab")return;if(!t._popover||!t._popover.hasAttribute("open")){t._removeFocusTrap();return}const i=t._getFocusableElements();if(i.length===0)return;const s=i[0],n=i[i.length-1],r=document.activeElement;if(!(((l=t._calendarContainer)==null?void 0:l.contains(r))||!1)){e.preventDefault(),s.focus();return}if(e.shiftKey&&r===s){e.preventDefault(),n.focus();return}if(!e.shiftKey&&r===n){e.preventDefault(),s.focus();return}},this._escapeHandler=function(e){(e.key==="Escape"||e.key==="Esc")&&t._popover&&t._popover.hasAttribute("open")&&(e.preventDefault(),e.stopPropagation(),typeof t._popover.close=="function"&&t._popover.close())},document.addEventListener("keydown",this._focusTrapHandler,!0),document.addEventListener("keydown",this._escapeHandler,!0),requestAnimationFrame(()=>{const e=this._getFocusableElements();e.length>0&&e[0].focus()})}_removeFocusTrap(){this._focusTrapHandler&&(document.removeEventListener("keydown",this._focusTrapHandler,!0),this._focusTrapHandler=null),this._escapeHandler&&(document.removeEventListener("keydown",this._escapeHandler,!0),this._escapeHandler=null)}}customElements.get("mint-date-picker")||customElements.define("mint-date-picker",X);class Z extends HTMLElement{constructor(){super(),this._select=null,this._wrapper=null,this._caretUpIcon=null,this._caretDownIcon=null,this._changeHandler=null}static get observedAttributes(){return["name","value","disabled","id","required","label","info","error","error-message","multiple","loading"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline","inline-block","w-full"),this.getLabel()||console.error('mint-select: The "label" attribute is required. Please provide a label for the select.'),this.render()}disconnectedCallback(){this._select&&this._changeHandler&&(this._select.removeEventListener("change",this._changeHandler),this._changeHandler=null)}isLoading(){return this.hasAttribute("loading")}attributeChangedCallback(t,e,i){if(e!==i){if(t==="error"||t==="error-message"){this._renderErrorState(),this._select&&(this._select.className=this.getSelectClasses(),this._select.setAttribute("aria-invalid",this.hasError()?"true":"false"));return}if(t==="loading"){this.render();return}if(t==="value"){this._select&&(this._select.value=i||"");return}this.render()}}getName(){return this.getAttribute("name")||""}getValue(){return this.hasAttribute("value")?this.getAttribute("value")||"":this._select?this._select.value:""}setValue(t){const e=t||"";this.setAttribute("value",e),this._select&&(this._select.value=e)}isDisabled(){return this.hasAttribute("disabled")}isMultiple(){return this.hasAttribute("multiple")}hasError(){return this.hasAttribute("error")}getErrorMessage(){return this.getAttribute("error-message")||""}getId(){return this.getAttribute("id")||""}getLabel(){return this.getAttribute("label")||""}getInfo(){return this.getAttribute("info")||""}getSelectClasses(){const t=this.hasError(),e=this.isMultiple(),i=["w-full","px-3.5",e?"pr-3.5":"pr-10",e?"py-2":"py-1.5",e?"min-h-[6rem]":"min-h-[2rem]","text-sm","font-medium","rounded-lg","box-border","bg-white","dark:bg-gray-700","text-gray-900","dark:text-white","transition-all","duration-200","outline-none","focus:outline-none","disabled:opacity-40","disabled:cursor-not-allowed","appearance-none","bg-no-repeat","bg-right","cursor-pointer"],s=["border-2",t?"border-red-300 dark:border-red-300":"border-gray-200 dark:border-gray-600"],n=["focus-visible:ring-2","focus-visible:ring-offset-1",t?"focus-visible:ring-red-400 dark:focus-visible:ring-red-500":"focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500"];return[...i,...s,...n].filter(Boolean).join(" ")}render(){const t=this.isLoading(),e=[];this._select&&Array.from(this._select.children).forEach(h=>{(h.tagName==="OPTION"||h.tagName==="OPTGROUP")&&e.push(h.cloneNode(!0))});const i=Array.from(this.children).filter(h=>h.tagName==="OPTION"||h.tagName==="OPTGROUP").map(h=>h.cloneNode(!0));for(;this.firstChild;)this.removeChild(this.firstChild);this._wrapper=null,this._select=null;const s=this.getLabel(),n=this.getInfo(),r=this.getId(),a=this.getName(),l=this.getValue(),o=this.isDisabled(),c=this.isMultiple(),d=this.hasError();if(s){const h=document.createElement("label");h.className="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",r&&h.setAttribute("for",r);const m=document.createTextNode(s);h.appendChild(m),this.appendChild(h)}this._wrapper=document.createElement("div"),this._wrapper.className="relative w-full",this.appendChild(this._wrapper),this._select=document.createElement("select"),this._select.className=this.getSelectClasses(),r&&(this._select.id=r),a&&(this._select.name=a),o&&(this._select.disabled=!0),c&&(this._select.multiple=!0),this._select.setAttribute("aria-invalid",d?"true":"false");const p=e.length>0?e:i;if(p.length>0&&p.forEach(h=>{this._select.appendChild(h)}),this._select.options.length===0){const h=document.createElement("option");h.value="",h.textContent="Select an option",h.disabled=!0,h.selected=!0,this._select.appendChild(h)}if(this._select.value=l||"",this._changeHandler&&this._select&&this._select.removeEventListener("change",this._changeHandler),this._changeHandler=h=>{const f=h.target.value;f?this.setAttribute("value",f):this.removeAttribute("value"),this.dispatchEvent(new CustomEvent("change",{detail:{value:f},bubbles:!0,cancelable:!0,composed:!0}))},this._select.addEventListener("change",this._changeHandler),this._wrapper.appendChild(this._select),c)this._caretUpIcon=null,this._caretDownIcon=null;else{const h=document.createElement("div");h.className="absolute right-2 top-1/2 -translate-y-1/2 pointer-events-none z-10 flex flex-col",this._caretUpIcon=document.createElement("mint-icon"),this._caretUpIcon.setAttribute("name","caret-up"),this._caretUpIcon.className="w-[.9em] h-[.9em] text-gray-400 dark:text-gray-500 mb-[-.2rem]",h.appendChild(this._caretUpIcon),this._caretDownIcon=document.createElement("mint-icon"),this._caretDownIcon.setAttribute("name","caret-down"),this._caretDownIcon.className="w-[.9em] h-[.9em] text-gray-400 dark:text-gray-500 mt-[-.2rem]",h.appendChild(this._caretDownIcon),this._wrapper.appendChild(h)}if(n){const h=document.createElement("div");h.className="mt-1 text-xs text-gray-500 dark:text-gray-400",h.textContent=n,this.appendChild(h)}this._renderErrorState(),this._renderSkeleton(t)}_renderSkeleton(t){let e=this.querySelector(".mint-select-skeleton-container");const i=this._wrapper;if(t){e||(e=document.createElement("div"),e.className="mint-select-skeleton-container absolute inset-0 z-10 pointer-events-none",i?(i.classList.contains("relative")||i.classList.add("relative"),i.appendChild(e)):(this.style.position="relative",this.appendChild(e)));let s=e.querySelector(".mint-select-skeleton");if(!s){s=document.createElement("div"),s.className="mint-select-skeleton w-full rounded-lg bg-gray-200 dark:bg-gray-700 animate-pulse";const n=this.isMultiple();s.style.height=n?"6rem":"2.25rem",e.appendChild(s)}e.style.display="block",this._select&&(this._select.style.opacity="0",this._select.style.pointerEvents="none")}else e&&(e.style.display="none"),this._select&&(this._select.style.opacity="1",this._select.style.pointerEvents="auto")}_renderErrorState(){const t=this.hasError(),e=this.getErrorMessage();let i=this.querySelector(".mint-select-error");t&&e?(i||(i=document.createElement("div"),i.className="mint-select-error mt-1 text-xs text-red-600 dark:text-red-400",this.appendChild(i)),i.textContent=e):i&&i.remove()}}customElements.get("mint-select")||customElements.define("mint-select",Z);class Q extends HTMLElement{constructor(){super(),this._dropzone=null,this._fileInput=null,this._previewContainer=null,this._isDragging=!1,this._wasDragging=!1,this._isUpdatingFiles=!1,this._listenersInitialized=!1,this._selectedFiles=[],this._previewUrls=[],this._resetHandler=null}static get observedAttributes(){return["label","accept","multiple","width","height","disabled","name","error","error-message","loading"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline","inline-block"),this.render(),this._attachFormResetListener()}disconnectedCallback(){if(this.removeEventListeners(),this._cleanupPreviewUrls(),this._resetHandler){const t=this.closest("form");t&&t.removeEventListener("reset",this._resetHandler),this._resetHandler=null}}attributeChangedCallback(t,e,i){if(e!==i){if(t==="error"||t==="error-message"){this._updateDragStateClass(),this._renderErrorState(this.hasError(),this.getErrorMessage());return}if(t==="loading"){this.render();return}this.render()}}getLabel(){return this.getAttribute("label")||""}getAccept(){return this.getAttribute("accept")||""}isMultiple(){return this.hasAttribute("multiple")}getWidth(){return this.getAttribute("width")||"200px"}getHeight(){return this.getAttribute("height")||"200px"}_renderSkeleton(t){let e=this.querySelector(".mint-dropzone-skeleton-container");const i=this._dropzone;if(t){e||(e=document.createElement("div"),e.className="mint-dropzone-skeleton-container absolute inset-0 z-10 pointer-events-none flex items-center justify-center",i?(i.classList.contains("relative")||i.classList.add("relative"),i.appendChild(e)):(this.style.position="relative",this.appendChild(e)));let s=e.querySelector(".mint-dropzone-skeleton");if(s||(s=document.createElement("div"),s.className="mint-dropzone-skeleton rounded-lg border-2 border-dashed border-gray-300 dark:border-gray-600 bg-gray-200 dark:bg-gray-700 animate-pulse",s.style.width="100%",s.style.height="100%",e.appendChild(s)),e.style.display="flex",i){const n=i.querySelector(".mint-dropzone-icon"),r=i.querySelector(".mint-dropzone-label"),a=i.querySelector(".mint-dropzone-previews-wrapper"),l=this._fileInput;if(n){const o=n;o.style.visibility="hidden",o.style.pointerEvents="none"}if(r){const o=r;o.style.visibility="hidden",o.style.pointerEvents="none"}if(a){const o=a;o.style.visibility="hidden",o.style.pointerEvents="none"}l&&(l.style.visibility="hidden",l.style.pointerEvents="none"),i.style.pointerEvents="none"}}else if(e&&(e.style.display="none"),i){const s=i.querySelector(".mint-dropzone-icon"),n=i.querySelector(".mint-dropzone-label"),r=i.querySelector(".mint-dropzone-previews-wrapper"),a=this._fileInput;if(s){const l=s;l.style.visibility="visible",l.style.pointerEvents="auto"}if(n){const l=n;l.style.visibility="visible",l.style.pointerEvents="auto"}if(r){const l=r;l.style.visibility="visible",l.style.pointerEvents="auto"}a&&(a.style.visibility="visible",a.style.pointerEvents="auto"),i.style.pointerEvents="auto"}}getName(){return this.getAttribute("name")||""}hasError(){return this.hasAttribute("error")}getErrorMessage(){return this.getAttribute("error-message")||""}isDisabled(){return this.hasAttribute("disabled")}isLoading(){return this.hasAttribute("loading")}render(){const t=this.isLoading(),e=this.getLabel(),i=this.getAccept(),s=this.isMultiple(),n=this.isDisabled(),r=this.getWidth(),a=this.getHeight(),l=this.getName(),o=this.hasError(),c=this.getErrorMessage();this._dropzone||(this._dropzone=document.createElement("div"),this.appendChild(this._dropzone)),this._updateDragStateClass(),this._dropzone.setAttribute("aria-invalid",o?"true":"false"),n?(this._dropzone.setAttribute("tabindex","-1"),this._dropzone.removeAttribute("role")):(this._dropzone.setAttribute("tabindex","0"),this._dropzone.setAttribute("role","button"),this._dropzone.setAttribute("aria-label",e||"File upload dropzone")),this._dropzone.style.width=r,this._dropzone.style.height=a,this._dropzone.style.minWidth=r,this._dropzone.style.minHeight=a,this._fileInput||(this._fileInput=document.createElement("input"),this._fileInput.type="file",this._fileInput.style.display="none",this._fileInput.setAttribute("tabindex","-1"),this._fileInput.setAttribute("aria-hidden","true"),this._dropzone.appendChild(this._fileInput)),this._fileInput.accept=i,this._fileInput.multiple=s,this._fileInput.disabled=n,l?this._fileInput.name=l:this._fileInput.removeAttribute("name"),this._fileInput.setAttribute("aria-invalid",o?"true":"false");const d=this._dropzone.querySelector(".mint-dropzone-icon"),p=this._dropzone.querySelector(".mint-dropzone-label");d&&d.remove(),p&&p.remove();const h=document.createElement("div");h.className="mint-dropzone-icon flex items-center justify-center mt-2 mb-2 flex-shrink-0";const m=document.createElement("mint-icon");if(m.setAttribute("name","upload"),m.className="w-12 h-12 text-gray-400 dark:text-gray-500",h.appendChild(m),this._dropzone.appendChild(h),e){const f=document.createElement("div");f.className="mint-dropzone-label text-sm font-medium text-gray-600 dark:text-gray-400 text-center px-4 flex-shrink-0",f.textContent=e,this._dropzone.appendChild(f)}this.setupEventListeners(),this._renderErrorState(o,c),this._renderPreviews(),this._renderSkeleton(t)}_updateDragState(){this._dropzone&&this._updateDragStateClass()}_renderErrorState(t,e){let i=this.querySelector(".mint-dropzone-error");t&&e?(i||(i=document.createElement("div"),i.className="mint-dropzone-error mt-1 text-xs text-red-600 dark:text-red-400",this.appendChild(i)),i.textContent=e):i&&i.remove()}_updateDragStateClass(){if(!this._dropzone)return;const t=this.isDisabled(),e=this.hasError(),n=`relative border-2 border-dashed rounded-lg transition-all duration-200 flex flex-col items-center ${this._selectedFiles.length>0?"justify-start":"justify-center"} cursor-pointer overflow-hidden`,r=this._isDragging?"border-gray-400 dark:border-gray-500 bg-gray-50 dark:bg-gray-800":"border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 hover:border-gray-400 dark:hover:border-gray-500",a=e?"border-red-300 dark:border-red-300 bg-red-50/50 dark:bg-red-900/30":"",l=t?"opacity-40 cursor-not-allowed":"",o="focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500";this._dropzone.className=`${n} ${e?a:r} ${l} ${o}`.trim()}setupEventListeners(){this._listenersInitialized||(this._listenersInitialized=!0,this.removeEventListeners(),!(!this._dropzone||!this._fileInput||this.isDisabled())&&(this._onDropzoneClick||(this._onDropzoneClick=t=>{if(!(this.isDisabled()||!this._fileInput)&&t.target!==this._fileInput&&(t.stopPropagation(),t.preventDefault(),t.isTrusted))try{this._fileInput.click()}catch(e){console.debug("File chooser blocked:",e)}}),this._onDragOver||(this._onDragOver=t=>{t.preventDefault(),t.stopPropagation(),this.isDisabled()||this._isDragging||(this._isDragging=!0,this._wasDragging=!0,this._updateDragState())}),this._onDragLeave||(this._onDragLeave=t=>{var i;t.preventDefault(),t.stopPropagation();const e=(i=this._dropzone)==null?void 0:i.getBoundingClientRect();e&&(t.clientX<e.left||t.clientX>e.right||t.clientY<e.top||t.clientY>e.bottom)&&this._isDragging&&(this._isDragging=!1,this._wasDragging=!1,this._updateDragState())}),this._onDrop||(this._onDrop=t=>{var i;if(t.preventDefault(),t.stopPropagation(),this._isDragging&&(this._isDragging=!1,this._wasDragging=!1,this._updateDragState()),this.isDisabled())return;const e=(i=t.dataTransfer)==null?void 0:i.files;e&&e.length>0&&this._handleFiles(e)}),this._onFileInputInput||(this._onFileInputInput=t=>{t.stopImmediatePropagation(),t.stopPropagation()}),this._onKeyDown||(this._onKeyDown=t=>{if(!(this.isDisabled()||!this._fileInput)&&(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),t.stopPropagation(),t.isTrusted))try{this._fileInput.click()}catch(e){console.debug("File chooser blocked:",e)}}),this._onFocus||(this._onFocus=t=>{this._dropzone&&!this.isDisabled()&&this._dropzone.classList.add("focus-visible:ring-2")}),this._onBlur||(this._onBlur=t=>{this._dropzone}),this._onFileInputChange||(this._onFileInputChange=t=>{if(t.stopImmediatePropagation(),t.stopPropagation(),this._isUpdatingFiles)return;const i=t.target.files;if(i&&i.length>0){const s=this.getAccept(),n=this.isMultiple(),r=[],a=[];for(let l=0;l<i.length;l++){const o=i[l];this._isFileAccepted(o,s)?r.push(o):a.push(o)}if(!n&&r.length>1&&(a.push(...r.slice(1)),r.splice(1)),a.length>0){const l=new CustomEvent("dropRejected",{detail:{files:a,reason:"File type not accepted or multiple files not allowed"},bubbles:!0,cancelable:!0});this.dispatchEvent(l)}r.length>0&&this._applyValidFiles(r)}}),this._dropzone.addEventListener("click",this._onDropzoneClick),this._dropzone.addEventListener("dragover",this._onDragOver),this._dropzone.addEventListener("dragleave",this._onDragLeave),this._dropzone.addEventListener("drop",this._onDrop),this._dropzone.addEventListener("keydown",this._onKeyDown),this._dropzone.addEventListener("focus",this._onFocus),this._dropzone.addEventListener("blur",this._onBlur),this._fileInput.addEventListener("change",this._onFileInputChange),this._fileInput.addEventListener("input",this._onFileInputInput,!0)))}removeEventListeners(){this._dropzone&&(this._onDropzoneClick&&this._dropzone.removeEventListener("click",this._onDropzoneClick),this._onDragOver&&this._dropzone.removeEventListener("dragover",this._onDragOver),this._onDragLeave&&this._dropzone.removeEventListener("dragleave",this._onDragLeave),this._onDrop&&this._dropzone.removeEventListener("drop",this._onDrop),this._onKeyDown&&this._dropzone.removeEventListener("keydown",this._onKeyDown),this._onFocus&&this._dropzone.removeEventListener("focus",this._onFocus),this._onBlur&&this._dropzone.removeEventListener("blur",this._onBlur)),this._fileInput&&(this._onFileInputChange&&this._fileInput.removeEventListener("change",this._onFileInputChange),this._onFileInputInput&&this._fileInput.removeEventListener("input",this._onFileInputInput,!0)),this._isDragging=!1,this._listenersInitialized=!1}_handleFiles(t){const e=this.getAccept(),i=this.isMultiple(),s=[],n=[];for(let r=0;r<t.length;r++){const a=t[r];this._isFileAccepted(a,e)?s.push(a):n.push(a)}if(!i&&s.length>1&&(n.push(...s.slice(1)),s.splice(1)),n.length>0){const r=new CustomEvent("dropRejected",{detail:{files:n,reason:"File type not accepted or multiple files not allowed"},bubbles:!0,cancelable:!0});this.dispatchEvent(r)}s.length>0&&this._applyValidFiles(s)}_isFileAccepted(t,e){var s;if(!e)return!0;const i=e.split(",").map(n=>n.trim().toLowerCase());for(const n of i)if(n.startsWith(".")){if("."+((s=t.name.split(".").pop())==null?void 0:s.toLowerCase())===n)return!0}else if(n.includes("/*")){const r=n.split("/")[0],a=t.type.split("/")[0];if(r===a)return!0}else if(t.type===n)return!0;return!1}_dispatchEvent(t,e){const i=e.target,s=new CustomEvent(t,{detail:{files:i.files?Array.from(i.files):[],value:i.value||""},bubbles:!0,cancelable:!0});this.dispatchEvent(s)}_dispatchSelectionEvents(){const e={files:[...this._selectedFiles],value:""};this.dispatchEvent(new CustomEvent("input",{detail:e,bubbles:!0,cancelable:!0,composed:!0})),this.dispatchEvent(new CustomEvent("change",{detail:e,bubbles:!0,cancelable:!0,composed:!0}))}_syncFileInputFromSelected(){if(!this._fileInput)return;const t=new DataTransfer;this._selectedFiles.forEach(e=>{try{t.items.add(e)}catch(i){console.warn("Failed to add file to DataTransfer:",i)}}),this._isUpdatingFiles=!0;try{this._fileInput.files=t.files}catch(e){console.warn("Failed to set files on input:",e)}setTimeout(()=>{this._isUpdatingFiles=!1},0)}get files(){var t;return this._syncFileInputFromSelected(),((t=this._fileInput)==null?void 0:t.files)||null}syncFiles(){this._syncFileInputFromSelected()}_renderPreviews(){if(!this._dropzone)return;if(this._previewContainer&&(this._cleanupPreviewUrls(),this._previewContainer.remove()),this._selectedFiles.length===0){this._previewContainer=null,this._updateDragStateClass();return}const t=document.createElement("div");t.className="mint-dropzone-previews-wrapper mt-3 w-full relative max-h-48";const e=document.createElement("div");e.className="mint-dropzone-previews w-full flex flex-col gap-2 max-h-48 overflow-y-auto overflow-x-hidden px-2 pb-2",this._selectedFiles.forEach((o,c)=>{const d=document.createElement("div");if(d.className="flex items-center gap-3 p-2 rounded border border-gray-200 dark:border-gray-600 bg-gray-50 dark:bg-gray-800",o.type.startsWith("image/")){const f=document.createElement("img");f.className="w-12 h-12 object-cover rounded border border-gray-200 dark:border-gray-700";const u=URL.createObjectURL(o);this._previewUrls.push(u),f.src=u,d.appendChild(f)}else{const f=document.createElement("mint-icon");f.setAttribute("name","attach"),f.className="w-5 h-5 text-gray-500 dark:text-gray-300",d.appendChild(f)}const p=document.createElement("div");p.className="flex-1 text-sm text-gray-800 dark:text-gray-100 truncate",p.textContent=o.name,d.appendChild(p);const h=document.createElement("button");h.type="button",h.className="text-gray-500 hover:bg-red-100 dark:hover:bg-red-900/30 transition-colors flex items-center justify-center w-6 h-6 rounded-full";const m=document.createElement("mint-icon");m.setAttribute("name","close"),m.className="w-4 h-4",h.appendChild(m),h.addEventListener("click",f=>{f.preventDefault(),f.stopPropagation(),this._removeFileAt(c)}),d.appendChild(h),e.appendChild(d)});const i=this.hasError(),s=this._isDragging;let n="from-white dark:from-gray-700";i?n="from-red-50 dark:from-red-900/30":s&&(n="from-gray-50 dark:from-gray-800");const r=document.createElement("div");r.className=`absolute top-0 left-0 right-0 h-4 pointer-events-none z-10 bg-gradient-to-b ${n} to-transparent opacity-0 transition-opacity duration-200`,t.appendChild(r);const a=document.createElement("div");a.className=`absolute bottom-0 left-0 right-0 h-4 pointer-events-none z-10 bg-gradient-to-t ${n} to-transparent opacity-100 transition-opacity duration-200`,t.appendChild(a);const l=()=>{const o=e.scrollTop,c=e.scrollHeight,d=e.clientHeight;o>0?r.style.opacity="1":r.style.opacity="0",o+d<c-1?a.style.opacity="1":a.style.opacity="0"};l(),e.addEventListener("scroll",l),t.appendChild(e),this._previewContainer=t,this._dropzone.appendChild(t),this._updateDragStateClass()}_removeFileAt(t){if(t<0||t>=this._selectedFiles.length)return;const[e]=this._selectedFiles.splice(t,1);e&&this._cleanupPreviewUrls(),this._syncFileInputFromSelected(),this._renderPreviews(),this._dispatchSelectionEvents()}_cleanupPreviewUrls(){this._previewUrls.forEach(t=>URL.revokeObjectURL(t)),this._previewUrls=[]}_attachFormResetListener(){const t=this.closest("form");!t||this._resetHandler||(this._resetHandler=()=>{this._selectedFiles=[],this._syncFileInputFromSelected(),this._renderPreviews(),this._cleanupPreviewUrls()},t.addEventListener("reset",this._resetHandler))}_applyValidFiles(t){if(this.isMultiple()){const i=t.filter(s=>!this._isDuplicateFile(s));this._selectedFiles.push(...i)}else this._selectedFiles=[t[0]];this._syncFileInputFromSelected(),this._selectedFiles.length>0&&(this.removeAttribute("error"),this.removeAttribute("error-message"),this._fileInput&&this._fileInput.removeAttribute("aria-invalid")),this._renderPreviews(),this._dispatchSelectionEvents()}_isDuplicateFile(t){return this._selectedFiles.some(e=>e.name===t.name&&e.size===t.size&&e.lastModified===t.lastModified)}}customElements.get("mint-dropzone")||customElements.define("mint-dropzone",Q);class tt extends HTMLElement{constructor(){super(),this._form=null,this._submitHandler=null,this._hostSubmitHandler=null,this._errors={},this._fieldBlurHandlers=new Map,this._fieldChangeHandlers=new Map,this._observer=null,this._formData=null,this._headers=null,this._buttonStates=new Map,this._reactiveDataProxy=null,this._reactiveDataObserver=null,this._lastDataSnapshot=null}static get observedAttributes(){return["action","method","enctype","data-form-data","loading","headers"]}connectedCallback(){this._render(),this._ensureSubmitHandler(),this._setupBlurValidation();const t=this.getAttribute("headers");t&&this._parseHeaders(t),requestAnimationFrame(()=>{requestAnimationFrame(()=>{if(this._formData){if(this._isReactiveObject(this._formData)){const e=this._getReactiveValue(this._formData);e&&typeof e=="object"&&!Array.isArray(e)&&(this._lastDataSnapshot=this._createDataSnapshot(e),this._setupReactiveDataObserver(this._formData))}this._applyFormData()}else{const e=this.getAttribute("data-form-data");e&&(this._parseFormData(e),this._applyFormData())}this._propagateLoadingState()})})}disconnectedCallback(){this._form&&this._submitHandler&&this._form.removeEventListener("submit",this._submitHandler,!0),this._hostSubmitHandler&&this.removeEventListener("submit",this._hostSubmitHandler),this._cleanupBlurValidation(),this._stopReactiveDataObserver()}reset(){this._clearErrors(),this._formData?this._applyFormData():this.clear()}clear(){this._clearErrors(),this._form&&this._form.reset(),this._resetCustomFields()}attributeChangedCallback(t,e,i){t==="form-data"?(this._parseFormData(i),this.isConnected&&this._form&&requestAnimationFrame(()=>{requestAnimationFrame(()=>{this._applyFormData()})})):t==="headers"?this._parseHeaders(i):t==="loading"?this.isConnected&&this._form?requestAnimationFrame(()=>{this._propagateLoadingState()}):this._propagateLoadingState():this._applyFormAttributes()}get data(){return this._formData}set data(t){this._stopReactiveDataObserver(),this._reactiveDataProxy=null,this._lastDataSnapshot=null,t&&typeof t=="object"&&!Array.isArray(t)?(this._formData=t,this._isReactiveObject(t)&&this._setupReactiveDataObserver(t),this._lastDataSnapshot=this._createDataSnapshot(t)):t==null?this._formData=null:this._parseFormData(t),this.isConnected&&this._form&&requestAnimationFrame(()=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{this._applyFormData()})})})}get headers(){return this._headers}set headers(t){if(t&&typeof t=="object"&&!Array.isArray(t))this._headers=t;else if(t==null)this._headers=null;else if(typeof t=="string")try{this._headers=JSON.parse(t)}catch{this._headers=null}else this._headers=null}_render(){if(this.classList.add("block","w-full"),!this._form){for(this._form=document.createElement("form"),this._form.noValidate=!0;this.firstChild;)this._form.appendChild(this.firstChild);this.appendChild(this._form)}this._ensureSubmitHandler(),this._applyFormAttributes()}_ensureSubmitHandler(){this._form&&(this._submitHandler&&this._form.removeEventListener("submit",this._submitHandler,!0),this._submitHandler=t=>{t.preventDefault(),t.stopImmediatePropagation(),this._handleSubmit(t)},this._form.addEventListener("submit",this._submitHandler,!0))}_applyFormAttributes(){if(!this._form)return;const t=this.getAttribute("action")||"",e=this.getAttribute("method")||"",i=this.getAttribute("enctype")||"application/x-www-form-urlencoded";t&&(this._form.action=t),e&&(this._form.method=e),this._form.enctype=i}async _handleSubmit(t){if(t.preventDefault(),!this._form)return;this._clearErrors(),this._syncDropzoneFiles();const e=this._collectValidationRules(),i=new FormData(this._form),s=this._formDataToValues(i);if(!this._validate(s,e)){this.dispatchEvent(new CustomEvent("invalid",{detail:{errors:this._errors},bubbles:!0,cancelable:!0,composed:!0}));return}const r=new CustomEvent("submit",{detail:{formData:i,values:s},bubbles:!0,cancelable:!0,composed:!0});if(this.dispatchEvent(r),r.defaultPrevented)return;const a=this.getAttribute("action"),l=this.getAttribute("method");if(!(!a||!l)){this._setButtonsSubmitting();try{const o=await this._submitData(i,s);this.dispatchEvent(new CustomEvent("submitsuccess",{detail:o,bubbles:!0,cancelable:!0}))}catch(o){this.dispatchEvent(new CustomEvent("submiterror",{detail:{error:o},bubbles:!0,cancelable:!0}))}finally{this._restoreButtonsState()}}}async _submitData(t,e){var d,p,h;const i=this.getAttribute("action"),s=this.getAttribute("method"),n=this.getAttribute("enctype")||"application/x-www-form-urlencoded";if(!i)return{status:0,ok:!0,data:{values:e}};const r=Array.from(t.values()).some(m=>m instanceof File);let a=null;const l={};let o=i;if(typeof window<"u"&&((h=(p=(d=window.mintForm)==null?void 0:d.defaults)==null?void 0:p.headers)!=null&&h.common)&&Object.assign(l,window.mintForm.defaults.headers.common),this._headers&&Object.assign(l,this._headers),s==="GET"){const m=new URLSearchParams;t.forEach((f,u)=>{f instanceof File||m.append(u,String(f))}),o+=(i.includes("?")?"&":"?")+m.toString()}else if(n==="multipart/form-data"||r)a=t;else if(n==="application/json")a=JSON.stringify(e),l["Content-Type"]="application/json";else{const m=new URLSearchParams;t.forEach((f,u)=>{f instanceof File||m.append(u,String(f))}),a=m,l["Content-Type"]="application/x-www-form-urlencoded"}if(typeof fetch=="function")try{const m=await fetch(o,{method:s||"POST",body:s==="GET"?null:a,headers:l}),f=await m.text().catch(()=>"");let u=f;try{u=JSON.parse(f)}catch{}if(!m.ok){const g={status:m.status,data:u,response:{status:m.status,data:u}};throw await this._applyErrorInterceptors(g)}const _={status:m.status,ok:m.ok,data:u};return await this._applySuccessInterceptors(_)}catch(m){if(m.response)throw m;const f={status:m.status||0,data:m.data||m.message||"Network error",response:{status:m.status||0,data:m.data||m.message||"Network error"}};throw await this._applyErrorInterceptors(f)}const c=this;return await new Promise(async(m,f)=>{const u=new XMLHttpRequest;u.open(s||"POST",o,!0),Object.entries(l).forEach(([_,g])=>u.setRequestHeader(_,g)),u.onload=async function(){const{status:_,responseText:g}=u;if(_>=200&&_<300){let b=g;try{b=JSON.parse(g)}catch{}try{const k={status:_,ok:!0,data:b},x=await c._applySuccessInterceptors(k);m(x)}catch(k){f(k)}}else{let b=g;try{b=JSON.parse(g)}catch{}try{const k={status:_,data:b,response:{status:_,data:b}},x=await c._applyErrorInterceptors(k);f(x)}catch(k){f(k)}}},u.onerror=async function(){try{const _={status:u.status||0,data:u.responseText||"Network error",response:{status:u.status||0,data:u.responseText||"Network error"}},g=await c._applyErrorInterceptors(_);f(g)}catch(_){f(_)}},u.send(s==="GET"?null:a)})}async _applySuccessInterceptors(t){var s,n,r;if(typeof window>"u"||!((r=(n=(s=window.mintForm)==null?void 0:s.interceptors)==null?void 0:n.response)!=null&&r.handlers))return t;let e=t;const i=window.mintForm.interceptors.response.handlers;for(const a of i)a.fulfilled&&(e=await a.fulfilled(e));return e}async _applyErrorInterceptors(t){var s,n,r;if(typeof window>"u"||!((r=(n=(s=window.mintForm)==null?void 0:s.interceptors)==null?void 0:n.response)!=null&&r.handlers))return Promise.reject(t);let e=t;const i=window.mintForm.interceptors.response.handlers;for(let a=i.length-1;a>=0;a--){const l=i[a];if(l.rejected)try{if(e=await l.rejected(e),e!==void 0)return e}catch(o){e=o}}return Promise.reject(e)}_formDataToValues(t){const e={};return t.forEach((i,s)=>{i instanceof File?(e[s]||(e[s]=[]),e[s].push(i)):s in e?Array.isArray(e[s])?(e[s].length>0&&e[s][0]instanceof File,e[s].push(i)):e[s]=[e[s],i]:e[s]=i}),this._form&&(Array.from(this._form.querySelectorAll("mint-dropzone[name]")).forEach(r=>{const a=r.getAttribute("name");if(a&&typeof r.files<"u"&&r.files){const l=r.files;if(l.length>0){const o=Array.from(l);e[a]&&Array.isArray(e[a])?o.forEach(c=>{e[a].some(p=>p.name===c.name&&p.size===c.size&&p.lastModified===c.lastModified)||e[a].push(c)}):e[a]=o}}}),Array.from(this._form.querySelectorAll('input[type="file"][name]')).forEach(r=>{const a=r.name;if(a&&r.files&&r.files.length>0){const l=Array.from(r.files);e[a]&&Array.isArray(e[a])?l.forEach(o=>{e[a].some(d=>d.name===o.name&&d.size===o.size&&d.lastModified===o.lastModified)||e[a].push(o)}):e[a]=l}}),Array.from(this._form.querySelectorAll("mint-tags[name]")).forEach(r=>{const a=r.getAttribute("name");if(a){let l=[];if(typeof r.tags<"u"?l=r.tags:typeof r.getTags=="function"&&(l=r.getTags()),Array.isArray(l)&&l.length>0){const o=l.map(c=>typeof c=="string"?c:(c==null?void 0:c.value)||(c==null?void 0:c.label)||"").filter(c=>c.trim()!=="");e[a]=o}else e[a]=[]}})),e}_collectValidationRules(){const t={};return this._form&&Array.from(this._form.querySelectorAll("[name][validation]")).forEach(i=>{const s=i.getAttribute("name")||"",n=i.getAttribute("validation");if(!s||!n)return;const r=this._parseRules(n);r.length&&(t[s]=r)}),t}_parseRules(t){if(!t)return[];try{const e=t.replace(/'/g,'"'),i=JSON.parse(e);if(Array.isArray(i))return i.map(s=>String(s))}catch{}return t.split(",").map(e=>e.trim()).filter(Boolean)}_validate(t,e){let i=!0;return this._errors={},Object.entries(e||{}).forEach(([s,n])=>{const r=Array.isArray(n)?n:[n],a=this._getFieldElements(s),l=this._extractFieldValue(a),o=this._validateRules(l,r);o?(i=!1,this._errors[s]=o,this._flagFieldError(a,o)):this._clearFieldError(a)}),i}_validateField(t){const e=this._collectValidationRules();if(!e[t])return;const i=e[t],s=Array.isArray(i)?i:[i],n=this._getFieldElements(t),r=this._extractFieldValue(n),a=this._validateRules(r,s);a?(this._errors[t]=a,this._flagFieldError(n,a)):(this._clearFieldError(n),delete this._errors[t])}_validateRules(t,e){for(const i of e){const[s,n]=i.split(":");switch(s){case"required":{if(t==null||typeof t=="string"&&t.trim()===""||t instanceof FileList&&t.length===0||Array.isArray(t)&&t.length===0)return"This field is required.";break}case"string":{if(typeof t!="string")return"Must be a string.";break}case"email":{if(typeof t=="string"&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t.trim()))return"Enter a valid email.";break}case"number":{const r=Number(t);if(Number.isNaN(r))return"Must be a number.";break}case"min":{const r=Number(n);if(Number.isNaN(r))break;if(typeof t=="string"&&t.trim().length<r)return`Must be at least ${r} characters.`;if(Array.isArray(t)&&t.length<r)return`Select at least ${r}.`;if(t instanceof FileList&&t.length<r)return`Upload at least ${r} files.`;if(t!=null&&!Number.isNaN(Number(t))&&Number(t)<r)return`Must be at least ${r}.`;break}case"max":{const r=Number(n);if(Number.isNaN(r))break;if(typeof t=="string"&&t.trim().length>r)return`Must be at most ${r} characters.`;if(Array.isArray(t)&&t.length>r)return`Select no more than ${r}.`;if(t instanceof FileList&&t.length>r)return`Upload no more than ${r} files.`;if(t!=null&&!Number.isNaN(Number(t))&&Number(t)>r)return`Must be at most ${r}.`;break}}}return null}_getFieldElements(t){if(!this._form)return[];const e=Array.from(this._form.querySelectorAll(`[name="${t}"]`)),i=e.filter(r=>r.tagName==="MINT-SELECT");if(i.length>0){const r=[];return i.forEach(a=>{const l=a.querySelector('select[name="'+t+'"]');l&&r.push(l)}),e.filter(a=>a.tagName!=="MINT-SELECT").concat(r)}if(e.filter(r=>r.tagName==="MINT-TAGS").length>0)return e.filter(r=>r.tagName!=="INPUT"||!r.closest("mint-tags"));const n=e.filter(r=>r.tagName==="INPUT"&&r.closest("mint-tags"));if(n.length>0){const r=[];return n.forEach(a=>{const l=a.closest("mint-tags");l&&!r.includes(l)&&r.push(l)}),e.filter(a=>a.tagName!=="INPUT"||!a.closest("mint-tags")).concat(r)}return e}_extractFieldValue(t){if(t.length===0)return"";const e=t.find(s=>s instanceof HTMLSelectElement);if(e)return e.value;if(t.length>1){const s=t.filter(a=>a instanceof HTMLInputElement);if(s.length>0&&s.length===t.length){const a=s.filter(l=>l.checked);if(s.every(l=>l.type==="radio"))return a.length>0?a[0].value||"on":"";if(s.every(l=>l.type==="checkbox"))return a.map(l=>l.value||"on")}const n=t.filter(a=>a.tagName==="MINT-CHOICE");if(n.length>0&&n.length===t.length){const a=n.find(l=>typeof l.getValue=="function"?l.getValue()!=="":l.querySelector("mint-choice-option[checked]")!==null);if(a){if(typeof a.getValue=="function")return a.getValue();const l=a.querySelector("mint-choice-option[checked]");if(l)return l.getAttribute("value")||""}return""}const r=t.filter(a=>a.tagName==="MINT-CHECKBOX");if(r.length>0&&r.length===t.length)return r.filter(l=>typeof l.checked<"u"?l.checked:l.hasAttribute("checked")).map(l=>l.getAttribute("value")||"on")}const i=t[0];if(i instanceof HTMLInputElement)return i.type==="file"?i.files:i.type==="checkbox"||i.type==="radio"?i.checked?i.value||"on":"":i.value;if(i instanceof HTMLTextAreaElement)return i.value;if(i.tagName==="MINT-SELECT"){const s=i.querySelector("select");if(s)return s.value;if(typeof i.getValue=="function"){const r=i.getValue();if(r!=null&&r!=="")return r}const n=i.getAttribute("value");return n||""}if(i.tagName==="MINT-DROPZONE"&&typeof i.files<"u")return i.files;if(i.tagName==="MINT-TAGS"){let s=null;return typeof i.tags<"u"?s=i.tags:typeof i.getTags=="function"&&(s=i.getTags()),Array.isArray(s)?s.map(r=>typeof r=="string"?r:(r==null?void 0:r.value)||(r==null?void 0:r.label)||"").filter(r=>r.trim()!==""):[]}return i.tagName==="MINT-CHECKBOX"||i.tagName==="MINT-SWITCH"?(typeof i.checked<"u"?i.checked:i.hasAttribute("checked"))?i.getAttribute("value")||"on":"":i.tagName==="MINT-CHOICE"?(typeof i.getValue=="function"?i.getValue():"")||"":typeof i.value<"u"?i.value:i.getAttribute("value")||""}_flagFieldError(t,e){t.length!==0&&t.forEach(i=>{(i instanceof HTMLInputElement||i instanceof HTMLTextAreaElement||i instanceof HTMLSelectElement)&&i.setAttribute("aria-invalid","true");const s=this._resolveHost(i);s&&(s.setAttribute("error",""),s.setAttribute("error-message",e),s.setAttribute("data-mint-form-error","true"))})}_clearFieldError(t){t.length!==0&&t.forEach(e=>{(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)&&e.removeAttribute("aria-invalid");const i=this._resolveHost(e);i&&(i.removeAttribute("error"),i.removeAttribute("error-message"),i.removeAttribute("data-mint-form-error"))})}_clearErrors(){this.querySelectorAll("[data-mint-form-error]").forEach(t=>{const e=t;e.removeAttribute("error"),e.removeAttribute("error-message"),e.removeAttribute("data-mint-form-error")}),this._form&&this._form.querySelectorAll('[aria-invalid="true"]').forEach(t=>{t.removeAttribute("aria-invalid")})}_parseFormData(t){if(!t){this._formData=null;return}if(typeof t=="object"&&!Array.isArray(t)){this._formData=t;return}if(typeof t=="string")try{this._formData=JSON.parse(t)}catch{this._formData=null}else this._formData=null}_parseHeaders(t){if(!t){this._headers=null;return}if(typeof t=="string")try{this._headers=JSON.parse(t)}catch{this._headers=null}else this._headers=null}_applyFormData(){if(!this._formData||!this._form)return;const t=this._getReactiveValue(this._formData);if(!t||typeof t!="object"||Array.isArray(t))return;const e=()=>{Object.entries(t).forEach(([i,s])=>{const n=this._getFieldElements(i);if(n.length===0){setTimeout(()=>{const r=this._getFieldElements(i);r.length>0&&this._applyValueToField(r,i,s)},300);return}this._applyValueToField(n,i,s)})};requestAnimationFrame(()=>{requestAnimationFrame(()=>{e()})})}_applyValueToField(t,e,i){t.forEach(s=>{var r;const n=s.tagName;try{if(n==="MINT-INPUT")typeof s.value<"u"&&(s.value=i||"");else if(n==="MINT-DATE-PICKER")typeof s.setValue=="function"&&s.setValue(i||"");else if(n==="MINT-SELECT"||n==="SELECT")n==="SELECT"?(r=s.closest("mint-select"))==null||r.setValue(i||""):typeof s.setValue=="function"&&s.setValue(i||"");else if(n==="MINT-CHOICE")typeof s.setValue=="function"?s.setValue(i||""):s.querySelectorAll("mint-choice-option").forEach(l=>{l.checked=l.getAttribute("value")===i});else if(n==="MINT-CHECKBOX"||n==="MINT-SWITCH"){const a=i===!0||i==="true"||i==="on"||i===1||i==="1";typeof s.checked<"u"?s.checked=a:a?s.setAttribute("checked",""):s.removeAttribute("checked")}else n==="MINT-TAGS"?Array.isArray(i)&&typeof s.tags<"u"&&(s.tags=i.map(a=>typeof a=="string"?{value:a,label:a,dismissable:!0}:a)):s instanceof HTMLInputElement?s.type==="checkbox"||s.type==="radio"?s.checked=i===!0||i==="true"||i==="on"||i===1||i==="1":s.value=i||"":(s instanceof HTMLTextAreaElement||s instanceof HTMLSelectElement)&&(s.value=i||"")}catch(a){console.warn(`Failed to set value for field ${e}:`,a)}})}_resetCustomFields(){this.querySelectorAll("mint-input, mint-date-picker, mint-select, mint-dropzone, mint-checkbox, mint-choice, mint-switch, mint-tags").forEach(e=>{var s,n;e.removeAttribute("error"),e.removeAttribute("error-message");const i=e.tagName;if(i==="MINT-INPUT")try{e.value=""}catch{}else if(i==="MINT-DATE-PICKER")try{(s=e.setValue)==null||s.call(e,"")}catch{}else if(i==="MINT-SELECT")try{(n=e.setValue)==null||n.call(e,"")}catch{}else if(i==="MINT-DROPZONE"){const r=e.querySelector('input[type="file"]');r&&(r.value="")}else if(i==="MINT-CHECKBOX"||i==="MINT-SWITCH")try{if(typeof e.checked<"u")e.checked=!1;else{e.removeAttribute("checked");const r=e.querySelector('input[type="checkbox"], input[type="radio"]');r&&(r.checked=!1)}}catch{}else if(i==="MINT-CHOICE")try{typeof e.setValue=="function"?e.setValue(""):e.querySelectorAll("mint-choice-option").forEach(a=>{a.checked=!1})}catch{}else if(i==="MINT-TAGS")try{e.tags=[]}catch{}})}_resolveHost(t){if(t.tagName==="MINT-CHOICE-OPTION"){const i=t.closest("mint-choice");if(i)return i}const e=t.closest("mint-input, mint-date-picker, mint-select, mint-dropzone, mint-checkbox, mint-choice, mint-switch, mint-tags");return e||t}_setupBlurValidation(){if(!this._form)return;const t=i=>{const s=i.target;if(!s)return;const n=this._findFieldElement(s);if(!n)return;const r=this._getFieldName(n);if(!r||!this._collectValidationRules()[r])return;const l=this._extractFieldValue([n]),o=l!=null&&(typeof l=="string"?l.trim()!=="":l instanceof FileList||Array.isArray(l)?l.length>0:!0),c=n.hasAttribute("data-mint-form-error")||s instanceof HTMLElement&&(s.hasAttribute("aria-invalid")||s.closest("[data-mint-form-error]")),d=!!n.closest("mint-tags"),p=n.tagName==="MINT-CHECKBOX"||n.tagName==="MINT-SWITCH"||n.tagName==="MINT-CHOICE"||s instanceof HTMLElement&&(s.closest("mint-checkbox, mint-switch, mint-choice")||s.closest("mint-choice-option")),h=n.tagName==="MINT-DATE-PICKER"||s instanceof HTMLElement&&s.closest("mint-date-picker");(o||c||d||p||h)&&setTimeout(()=>{this._validateField(r)},0)};this._form.addEventListener("blur",t,!0),this._fieldBlurHandlers.set(this._form,t);const e=i=>{const s=i.target;if(!s)return;if(i.type==="tags-change"&&s.tagName==="MINT-TAGS"){const c=s,d=this._getFieldName(c);if(!d||!this._collectValidationRules()[d])return;setTimeout(()=>{this._validateField(d)},0);return}if(s instanceof HTMLSelectElement||s.tagName==="MINT-SELECT"||s.closest("mint-select")){const c=this._findFieldElement(s);if(!c)return;const d=this._getFieldName(c);if(!d||!this._collectValidationRules()[d])return;setTimeout(()=>{this._validateField(d)},0);return}if(i.type==="choice-change"&&s.tagName==="MINT-CHOICE"){const c=s,d=this._getFieldName(c);if(!d||!this._collectValidationRules()[d])return;setTimeout(()=>{this._validateField(d)},0);return}if(s instanceof HTMLInputElement&&s.type==="checkbox"||s.tagName==="MINT-CHECKBOX"||s.tagName==="MINT-SWITCH"||s.closest("mint-checkbox, mint-switch")){const c=this._findFieldElement(s);if(!c)return;const d=this._getFieldName(c);if(!d||!this._collectValidationRules()[d])return;setTimeout(()=>{this._validateField(d)},0);return}const a=this._findFieldElement(s);if(!a)return;const l=this._getFieldName(a);!l||!this._collectValidationRules()[l]||(a.hasAttribute("data-mint-form-error")||s instanceof HTMLElement&&s.hasAttribute("aria-invalid"))&&setTimeout(()=>{this._validateField(l)},0)};this._form.addEventListener("change",e,!0),this._form.addEventListener("tags-change",e,!0),this._form.addEventListener("choice-change",e,!0),this._fieldChangeHandlers.set(this._form,e)}_findFieldElement(t){if(t.hasAttribute("name")&&(t.tagName.startsWith("MINT-")||t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement))return t;const e=t.closest("mint-input, mint-date-picker, mint-select, mint-dropzone, mint-checkbox, mint-choice, mint-switch, mint-tags");if(e&&e.hasAttribute("name"))return e;if((t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement)&&t.hasAttribute("name"))return t;let i=t;for(;i&&i!==this._form;){if(i.hasAttribute("name"))return i;i=i.parentElement}return null}_getFieldName(t){return t.hasAttribute("name")||t.tagName.startsWith("MINT-")?t.getAttribute("name"):(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement)&&t.name||null}_cleanupBlurValidation(){if(this._form&&this._fieldBlurHandlers.has(this._form)){const t=this._fieldBlurHandlers.get(this._form);t&&this._form.removeEventListener("blur",t,!0),this._fieldBlurHandlers.delete(this._form)}if(this._form&&this._fieldChangeHandlers.has(this._form)){const t=this._fieldChangeHandlers.get(this._form);t&&(this._form.removeEventListener("change",t,!0),this._form.removeEventListener("tags-change",t,!0),this._form.removeEventListener("choice-change",t,!0)),this._fieldChangeHandlers.delete(this._form)}this._observer&&(this._observer.disconnect(),this._observer=null)}_syncDropzoneFiles(){if(!this._form)return;Array.from(this._form.querySelectorAll("mint-dropzone[name]")).forEach(e=>{typeof e.syncFiles=="function"&&e.syncFiles()})}_propagateLoadingState(){if(!this._form)return;const t=this.getAttribute("loading"),e=t!==null&&t!=="false";Array.from(this._form.querySelectorAll("mint-input, mint-select, mint-date-picker, mint-dropzone, mint-checkbox, mint-choice, mint-switch, mint-tags")).forEach(s=>{e?s.setAttribute("loading",""):s.removeAttribute("loading"),typeof s.render=="function"&&s.render()})}_setButtonsSubmitting(){if(!this._form)return;this._buttonStates.clear();const t=Array.from(this.querySelectorAll("mint-button")),e=Array.from(this.querySelectorAll("button"));t.forEach(i=>{const s=i.getAttribute("disabled")==="true",n=i.getAttribute("loading")==="true";this._buttonStates.set(i,{disabled:s,loading:n});const a=(i.getAttribute("type")||i.getAttribute("button-type")||"default")==="submit";s||i.setAttribute("disabled","true"),a&&i.setAttribute("loading","true"),typeof i.render=="function"&&i.render()}),e.forEach(i=>{if(i.closest("mint-button"))return;const s=i.disabled;this._buttonStates.set(i,{disabled:s,loading:!1}),s||(i.disabled=!0)})}_restoreButtonsState(){if(!this._form)return;const t=Array.from(this.querySelectorAll("mint-button")),e=Array.from(this.querySelectorAll("button"));t.forEach(i=>{const s=this._buttonStates.get(i);s&&(s.disabled?i.setAttribute("disabled","true"):i.removeAttribute("disabled"),s.loading?i.setAttribute("loading","true"):i.removeAttribute("loading"),typeof i.render=="function"&&i.render())}),e.forEach(i=>{if(i.closest("mint-button"))return;const s=this._buttonStates.get(i);s&&(i.disabled=s.disabled)}),this._buttonStates.clear()}_isReactiveObject(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;if("__v_isRef"in t||"_value"in t||"__v_raw"in t||"__ob__"in t)return!0;try{const e=Object.keys(t);if(e.length>0){const i=Object.getOwnPropertyDescriptor(t,e[0]);if(i&&(i.get||i.set))return!0}}catch{return!0}return!0}_createDataSnapshot(t){try{return JSON.parse(JSON.stringify(t))}catch{return{...t}}}_hasDataChanged(t,e){try{return JSON.stringify(t)!==JSON.stringify(e)}catch{return!0}}_getReactiveValue(t){return t&&typeof t=="object"&&"_value"in t?t._value:(t&&typeof t=="object"&&"__ob__"in t,t)}_setupReactiveDataObserver(t){if(!this.isConnected)return;const e=()=>{if(!this._formData||!this._lastDataSnapshot){this._stopReactiveDataObserver();return}const i=this._getReactiveValue(this._formData);i&&typeof i=="object"&&!Array.isArray(i)&&this._hasDataChanged(i,this._lastDataSnapshot)&&(this._lastDataSnapshot=this._createDataSnapshot(i),requestAnimationFrame(()=>{this._applyFormData()})),this.isConnected&&this._formData&&(this._reactiveDataObserver=requestAnimationFrame(e))};this._reactiveDataObserver=requestAnimationFrame(e)}_stopReactiveDataObserver(){this._reactiveDataObserver!==null&&(cancelAnimationFrame(this._reactiveDataObserver),this._reactiveDataObserver=null),this._reactiveDataProxy=null,this._lastDataSnapshot=null}}customElements.get("mint-form")||customElements.define("mint-form",tt);typeof window<"u"&&(window.mintForm=window.mintForm||{defaults:{headers:{common:{}}},interceptors:{response:{handlers:[]}}},window.mintForm.interceptors.response.use||(window.mintForm.interceptors.response.use=function(C,t){return window.mintForm.interceptors.response.handlers.push({fulfilled:C,rejected:t}),window.mintForm.interceptors.response.handlers.length-1}));class et extends HTMLElement{constructor(){super(...arguments),this._observer=null}static get observedAttributes(){return["collapse","scroll"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","align-baseline","block","w-full","overflow-x-auto"),this.hasAttribute("collapse")&&!this.hasAttribute("scroll")&&this._ensureResponsiveStyles(),this._observeChanges(),this._applyStyles(),requestAnimationFrame(()=>{this._applyStyles(),setTimeout(()=>this._applyStyles(),0)})}disconnectedCallback(){this._observer&&(this._observer.disconnect(),this._observer=null)}attributeChangedCallback(){this.hasAttribute("collapse")&&!this.hasAttribute("scroll")&&this._ensureResponsiveStyles(),this._applyStyles()}_observeChanges(){this._observer=new MutationObserver(()=>this._applyStyles()),this._observer.observe(this,{childList:!0,subtree:!0,attributes:!1})}_applyStyles(){this._observer&&this._observer.disconnect();const t=this.querySelector("table");if(!t){this._observer&&this._observeChanges();return}const e=this.hasAttribute("collapse")&&!this.hasAttribute("scroll"),i=this.hasAttribute("scroll");i?this.classList.add("relative"):this.classList.remove("relative");const s=[],n=t.querySelector("thead tr");n&&n.querySelectorAll("th").forEach(c=>s.push((c.textContent||"").trim())),this._setClasses(t,["w-full",i?"min-w-[1200px]":"","border-collapse","text-sm","font-medium","overflow-hidden"]);const r=t.querySelector("thead");if(r){this._setClasses(r,["bg-[#F7F7F7]","dark:bg-gray-800"]);const o=r.querySelectorAll("th");o.forEach((c,d)=>{const p=c.querySelector("mint-icon"),h=(p==null?void 0:p.getAttribute("name"))||"",m=p!==null&&h!=="ellipsis";this._setClasses(c,["text-left","font-semibold","text-gray-900","dark:text-white","px-3","py-2","border-b","border-gray-200","dark:border-gray-700"]),m&&c.classList.add("cursor-pointer","hover:bg-gray-100","dark:hover:bg-gray-700","transition-colors"),d===0&&c.classList.add("pl-6"),d===o.length-1&&c.classList.add("pr-6")})}const a=t.querySelector("tbody");if(a){const o=Array.from(a.querySelectorAll("tr"));o.forEach((c,d)=>{const p=c.hasAttribute("data-row-clickable");this._setClasses(c,["bg-white","dark:bg-gray-900","border-b","border-gray-200","dark:border-gray-700"]),p&&c.classList.add("cursor-pointer","hover:bg-gray-50","dark:hover:bg-gray-800","transition-colors"),d===o.length-1&&c.classList.remove("border-b");const h=c.querySelectorAll("td");h.forEach((m,f)=>{this._setClasses(m,["text-gray-900","dark:text-gray-100","px-3","py-2"]),f===0&&m.classList.add("pl-6"),f===h.length-1&&m.classList.add("pr-6"),e?this._applyMobileCell(m,s):this._restoreCell(m)})})}const l=t.querySelector("tfoot");l&&(this._setClasses(l,["bg-[#F7F7F7]","dark:bg-gray-800","font-semibold"]),l.querySelectorAll("td").forEach(c=>{this._setClasses(c,["text-gray-900","dark:text-gray-100","px-3","py-2","border-t","border-gray-200","dark:border-gray-700"]),this._restoreCell(c)})),this._observer&&this._observeChanges()}_applyMobileCell(t,e){if(t.closest("tfoot")||t.dataset.mtProcessed==="true")return;const i=e[t.cellIndex]||"",s={};Array.from(t.attributes).forEach(o=>{o.name.startsWith("data-")&&o.name!=="data-original"&&o.name!=="data-mt-processed"&&(s[o.name]=o.value)});const n=t.getAttribute("data-original"),r=n!==null?n:t.innerHTML;t.setAttribute("data-original",r),t.dataset.mtProcessed="true",t.innerHTML="";const a=document.createElement("span");a.className="mt-label font-semibold text-gray-700 dark:text-gray-200 hidden",a.textContent=i;const l=document.createElement("span");l.className="mt-value text-gray-900 dark:text-gray-100 text-right md:text-left w-full",l.innerHTML=r,t.appendChild(a),t.appendChild(l),Object.entries(s).forEach(([o,c])=>{t.setAttribute(o,c)})}_restoreCell(t){if(t.dataset.mtProcessed!=="true")return;const e={};Array.from(t.attributes).forEach(s=>{s.name.startsWith("data-")&&s.name!=="data-original"&&s.name!=="data-mt-processed"&&(e[s.name]=s.value)});const i=t.getAttribute("data-original")||"";t.dataset.mtProcessed="",t.innerHTML=i,Object.entries(e).forEach(([s,n])=>{t.setAttribute(s,n)})}_setClasses(t,e){t.className="",e.filter(Boolean).forEach(i=>t.classList.add(...i.split(" ")))}_ensureResponsiveStyles(){if(document.getElementById("mint-table-responsive-style"))return;const t=document.createElement("style");t.id="mint-table-responsive-style",t.textContent=`
|
|
79
79
|
@media (max-width: 640px) {
|
|
80
80
|
mint-table[collapse] {
|
|
81
81
|
display: block;
|
|
@@ -138,5 +138,5 @@
|
|
|
138
138
|
border: inherit;
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
|
-
`,document.head.appendChild(t)}}customElements.get("mint-table")||customElements.define("mint-table",et);class it extends HTMLElement{constructor(){super(...arguments),this._root=null,this._textWrap=null,this._dismissBtn=null,this._clickHandler=null}static get observedAttributes(){return["dismissable"]}connectedCallback(){this._render()}disconnectedCallback(){this._dismissBtn&&this._clickHandler&&this._dismissBtn.removeEventListener("click",this._clickHandler)}attributeChangedCallback(){this._render()}_render(){var e;if(this.classList.add("inline-flex","items-center","gap-2","px-3","py-1","rounded-full","border","border-gray-200","dark:border-gray-700","bg-gray-100","dark:bg-gray-800","text-gray-900","dark:text-gray-100","text-sm","font-medium"),!this._root){for(this._root=document.createElement("div"),this._root.className="flex items-center gap-2 w-full",this._textWrap=document.createElement("span"),this._textWrap.className="inline-flex items-center min-w-[0.5rem]",this._textWrap.setAttribute("data-mt-chip-text","");this.firstChild;){const i=this.firstChild;if(i===this._root)break;this._textWrap.appendChild(i)}this._root.appendChild(this._textWrap),this.appendChild(this._root)}this.hasAttribute("dismissable")?(this._dismissBtn||this._createDismissBtn(),this._dismissBtn&&!this._dismissBtn.isConnected&&((e=this._root)==null||e.appendChild(this._dismissBtn))):this._dismissBtn&&this._dismissBtn.parentElement===this._root&&this._dismissBtn.remove()}_createDismissBtn(){const t=document.createElement("button");t.type="button",t.setAttribute("aria-label","Dismiss"),t.className=["shrink-0","inline-flex","items-center","justify-center","w-5","h-5","rounded-full","text-gray-500","dark:text-gray-300","hover:text-gray-700","dark:hover:text-gray-100","focus-visible:outline-none","focus-visible:ring-2","focus-visible:ring-offset-1","focus-visible:ring-gray-400","dark:focus-visible:ring-gray-500","transition-colors","duration-150","border-none","bg-transparent","cursor-pointer"].join(" ");const e=document.createElement("mint-icon");e.setAttribute("name","close"),e.className="w-3 h-3",t.appendChild(e),this._clickHandler=i=>{i.stopPropagation(),this.dispatchEvent(new CustomEvent("dismissed",{bubbles:!0,composed:!0}))},t.addEventListener("click",this._clickHandler),this._dismissBtn=t}}customElements.get("mint-chip")||customElements.define("mint-chip",it);class st extends HTMLElement{constructor(){super(...arguments),this._container=null,this._chipsWrap=null,this._input=null,this._tags=[],this._placeholder="Add tag",this._dragIndex=null,this._dragChip=null,this._isPointerDragging=!1,this._pointerMoveHandler=null,this._pointerUpHandler=null}static get observedAttributes(){return["tags","placeholder","sortable","label","info","error","error-message","name","id","required","loading"]}connectedCallback(){this._parseAttrs(),this._render(),this._pointerMoveHandler||(this._pointerMoveHandler=t=>this._onPointerMove(t),window.addEventListener("pointermove",this._pointerMoveHandler)),this._pointerUpHandler||(this._pointerUpHandler=t=>this._onPointerUp(t),window.addEventListener("pointerup",this._pointerUpHandler),window.addEventListener("pointercancel",this._pointerUpHandler))}attributeChangedCallback(t,e,i){if(e!==i){if(t==="error"||t==="error-message"){if(this._renderErrorState(),this._container){const s=this.hasError(),n=["flex","flex-wrap","items-center","gap-2","w-full","px-2","py-1.5","min-h-[2rem]","rounded-lg","border-2",s?"border-red-300 dark:border-red-300":"border-gray-200 dark:border-gray-700","bg-white","dark:bg-gray-800","focus-within:ring-2","focus-within:ring-offset-1",s?"focus-within:ring-red-400 dark:focus-within:ring-red-500":"focus-within:ring-gray-400 dark:focus-within:ring-gray-500","transition-colors","duration-200"];this._container.className=n.join(" ")}return}if(t==="loading"){this._parseAttrs(),this._render();return}this._parseAttrs(),this._render()}}set tags(t){this._tags=Array.isArray(t)?[...t]:[],this._syncAttr(),this._render()}get tags(){return[...this._tags]}_parseAttrs(){const t=this.getAttribute("tags");if(!t)return;try{const i=JSON.parse(t);Array.isArray(i)&&(this._tags=i)}catch(i){console.warn("mint-tags: failed to parse tags attribute",i)}const e=this.getAttribute("placeholder");e!==null&&(this._placeholder=e)}_syncAttr(){this.setAttribute("tags",JSON.stringify(this._tags))}getLabel(){return this.getAttribute("label")||""}getInfo(){return this.getAttribute("info")||""}hasError(){return this.hasAttribute("error")}getErrorMessage(){return this.getAttribute("error-message")||""}getName(){return this.getAttribute("name")||""}getId(){return this.getAttribute("id")||""}isRequired(){return this.hasAttribute("required")}isLoading(){return this.hasAttribute("loading")}_render(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline","block","w-full");const t=this.isLoading(),e=this.getLabel(),i=this.getInfo(),s=this.hasError(),n=this.getId()||`mint-tags-${Math.random().toString(36).substr(2,9)}`;if(this.getId()||this.setAttribute("id",n),this._container)this._input&&(this._input.placeholder=this._placeholder);else{this._container=document.createElement("div");const l=["flex","flex-wrap","items-center","gap-2","w-full","px-2","py-1","min-h-[2rem]","rounded-lg","border-2",s?"border-red-300 dark:border-red-300":"border-gray-200 dark:border-gray-700","bg-white","dark:bg-gray-800","focus-within:ring-2","focus-within:ring-offset-1",s?"focus-within:ring-red-400 dark:focus-within:ring-red-500":"focus-within:ring-gray-400 dark:focus-within:ring-gray-500","transition-colors","duration-200"];this._container.className=l.join(" "),this._chipsWrap=document.createElement("div"),this._chipsWrap.className="flex flex-wrap items-center gap-2",this._chipsWrap.addEventListener("dragover",c=>{this.hasAttribute("sortable")&&c.preventDefault()}),this._chipsWrap.addEventListener("drop",c=>{this.hasAttribute("sortable")&&c.preventDefault()}),this._input=document.createElement("input"),this._input.type="text",this._input.placeholder=this._placeholder,this._input.className=["min-w-[6rem]","flex-1","bg-transparent","border-none","outline-none","text-sm","text-gray-900","dark:text-gray-100","placeholder:text-gray-400","dark:placeholder:text-gray-500","p-1.5"].join(" "),this._input.addEventListener("keydown",c=>{c.key==="Enter"&&(c.preventDefault(),this._addFromInput())}),this._container.appendChild(this._chipsWrap),this.appendChild(this._container)}if(this._container){const l=["flex","flex-wrap","items-center","gap-2","w-full","px-2","py-1","min-h-[2rem]","rounded-lg","border-2",s?"border-red-300 dark:border-red-300":"border-gray-200 dark:border-gray-700","bg-white","dark:bg-gray-800","focus-within:ring-2","focus-within:ring-offset-1",s?"focus-within:ring-red-400 dark:focus-within:ring-red-500":"focus-within:ring-gray-400 dark:focus-within:ring-gray-500","transition-colors","duration-200"];this._container.className=l.join(" ")}let r=this.querySelector(".mint-tags-label-container");if(e){r||(r=document.createElement("div"),r.className="mint-tags-label-container mb-[.25rem]",this._container&&this._container.parentElement===this?this.insertBefore(r,this._container):this.insertBefore(r,this.firstChild));let l=r.querySelector(".mint-tags-label");e?(l||(l=document.createElement("label"),l.className="mint-tags-label text-sm font-medium text-gray-900 dark:text-gray-100 select-none",r.appendChild(l)),l.textContent=e,l.setAttribute("for",n)):l&&l.remove()}else r&&r.remove();let a=this.querySelector(".mint-tags-info");i?(a||(a=document.createElement("span"),a.className="mint-tags-info text-xs text-gray-500 dark:text-gray-400 select-none mt-1 block",this._container&&this._container.parentElement===this?this.insertBefore(a,this._container.nextSibling):this.appendChild(a)),a.textContent=i):a&&a.remove();const o=this.getName();o?(this.setAttribute("name",o),this._input&&(this._input.name=o,this._input.id=n)):(this.removeAttribute("name"),this._input&&(this._input.removeAttribute("name"),this._input.id=n)),this._wireInputBackspace(),this._renderChips(),this._renderErrorState(),this._renderSkeleton(t)}_renderSkeleton(t){const e=this._container;if(!e)return;e.classList.contains("relative")||e.classList.add("relative");let i=e.querySelector(".mint-tags-skeleton");t?(i||(i=document.createElement("div"),i.className="mint-tags-skeleton absolute inset-0 z-10 pointer-events-none rounded-lg bg-gray-200 dark:bg-gray-700 animate-pulse",e.appendChild(i)),i.style.display="block",this._chipsWrap&&(this._chipsWrap.style.visibility="hidden",this._chipsWrap.style.pointerEvents="none"),this._input&&(this._input.style.visibility="hidden",this._input.style.pointerEvents="none")):(i&&(i.style.display="none"),this._chipsWrap&&(this._chipsWrap.style.visibility="visible",this._chipsWrap.style.pointerEvents="auto"),this._input&&(this._input.style.visibility="visible",this._input.style.pointerEvents="auto"))}_renderErrorState(){const t=this.hasError(),e=this.getErrorMessage();let i=this.querySelector(".mint-tags-error");t&&e?(i||(i=document.createElement("div"),i.className="mint-tags-error mt-1 text-xs text-red-600 dark:text-red-400",this.appendChild(i)),i.textContent=e):i&&i.remove()}_renderChips(){if(!this._chipsWrap)return;this._chipsWrap.innerHTML="";let t=0;this._tags.forEach(e=>{const i=document.createElement("mint-chip");i.dataset.index=String(t++),i.dataset.value=e.value,i.draggable=this.hasAttribute("sortable"),i.draggable&&i.classList.add("cursor-move"),e.dismissable&&(i.setAttribute("dismissable",""),i.addEventListener("dismissed",()=>this._removeTag(e.value))),this._chipsWrap.appendChild(i);const s=i.querySelector("[data-mt-chip-text]");s&&(s.textContent=e.label||e.value),this._setupChipEvents(i,e),i.draggable&&(i.addEventListener("dragstart",n=>this._onDragStart(n,i)),i.addEventListener("dragover",n=>this._onDragOverChip(n,i)),i.addEventListener("drop",n=>this._onDrop(n)),i.addEventListener("dragend",()=>this._onDragEnd())),this.hasAttribute("sortable")&&i.addEventListener("pointerdown",n=>this._onPointerDown(n,i))}),this._input&&(this.hasAttribute("sortable")&&(this._input.addEventListener("dragover",e=>this._onDragOverInput(e)),this._input.addEventListener("drop",e=>this._onDrop(e)),this._input.addEventListener("dragend",()=>this._onDragEnd())),this._chipsWrap.appendChild(this._input))}_addFromInput(){if(!this._input)return;const t=this._input.value.trim();if(!t)return;if(this._tags.some(i=>i.value.toLowerCase()===t.toLowerCase())){this._input.value="";return}this._tags.push({value:t,label:t,dismissable:!0}),this._syncAttr(),this._renderChips(),this._emitChange(),this._input.value="",setTimeout(()=>{var i;(i=this._input)==null||i.focus()},10)}_removeTag(t){this._tags=this._tags.filter(e=>e.value!==t),this._syncAttr(),this._renderChips(),this._emitChange()}_emitChange(){this.dispatchEvent(new CustomEvent("tags-change",{bubbles:!0,composed:!0,detail:{tags:this.tags}}))}_focusLastChip(){var e;const t=(e=this._chipsWrap)==null?void 0:e.querySelectorAll("mint-chip");t&&t.length>0&&t[t.length-1].focus({preventScroll:!0})}_focusInput(){setTimeout(()=>{var t;(t=this._input)==null||t.focus({preventScroll:!0})},10)}_wireInputBackspace(){this._input&&this._input.addEventListener("keydown",t=>{var e;t.key==="Backspace"&&((e=this._input)==null?void 0:e.value)===""&&(t.preventDefault(),this._focusLastChip())})}_setupChipEvents(t,e){t.tabIndex=0,t.addEventListener("keydown",i=>{(i.key==="Backspace"||i.key==="Delete")&&e.dismissable&&(i.preventDefault(),this._removeTag(e.value),this._focusInput())})}_onDragStart(t,e){var i;this.hasAttribute("sortable")&&(this._dragChip=e,this._dragIndex=Number(e.dataset.index),(i=t.dataTransfer)==null||i.setData("text/plain",e.dataset.index||""),t.dataTransfer&&(t.dataTransfer.effectAllowed="move",t.dataTransfer.dropEffect="move"),e.classList.add("opacity-60"))}_reorderTags(t,e){if(t<0||e<0||t>=this._tags.length||e>=this._tags.length)return;const i=[...this._tags],[s]=i.splice(t,1);i.splice(e,0,s),this._tags=i,this._syncAttr(),this._renderChips(),this._emitChange()}_onDragOverInput(t){this.hasAttribute("sortable")&&(t.preventDefault(),t.dataTransfer&&(t.dataTransfer.dropEffect="move"),this._dragChip&&this._chipsWrap&&this._input&&this._chipsWrap.insertBefore(this._dragChip,this._input))}_onDragOverChip(t,e){if(!this.hasAttribute("sortable")||(t.preventDefault(),t.dataTransfer&&(t.dataTransfer.dropEffect="move"),!this._dragChip||!this._chipsWrap)||e===this._dragChip)return;const i=e.getBoundingClientRect(),s=t.clientX,n=i.left+i.width*.5;if(s<n){if(this._dragChip.nextSibling===e)return;this._chipsWrap.insertBefore(this._dragChip,e)}else{if(e.nextSibling===this._dragChip)return;const r=e.nextSibling;r?this._chipsWrap.insertBefore(this._dragChip,r):this._chipsWrap.appendChild(this._dragChip)}}_onDrop(t){this.hasAttribute("sortable")&&t.preventDefault()}_onDragEnd(){this._dragChip&&this._dragChip.classList.remove("opacity-60"),this._syncOrderFromDom(),this._dragChip=null,this._dragIndex=null}_syncOrderFromDom(){if(!this._chipsWrap)return;const t=Array.from(this._chipsWrap.querySelectorAll("mint-chip"));if(t.length===0)return;const e=[];t.forEach(i=>{const s=i.dataset.value;if(!s)return;const n=this._tags.find(r=>r.value===s);n&&e.push(n)}),e.length===this._tags.length&&(this._tags=e,this._syncAttr(),this._renderChips(),this._emitChange())}_onPointerDown(t,e){if(this.hasAttribute("sortable")&&t.pointerType!=="mouse"){this._isPointerDragging=!0,this._dragChip=e,this._dragIndex=Number(e.dataset.index);try{e.setPointerCapture(t.pointerId)}catch{}e.classList.add("opacity-60","select-none"),t.preventDefault()}}_onPointerMove(t){if(!this._isPointerDragging||!this._dragChip||!this._chipsWrap||t.pointerType==="mouse")return;const e=document.elementFromPoint(t.clientX,t.clientY);if(!e)return;const i=e.closest("mint-chip");if(i&&i!==this._dragChip){const s=i.getBoundingClientRect(),n=t.clientX,r=s.left+s.width*.5;if(n<r)this._dragChip.nextSibling!==i&&this._chipsWrap.insertBefore(this._dragChip,i);else if(i.nextSibling!==this._dragChip){const a=i.nextSibling;a?this._chipsWrap.insertBefore(this._dragChip,a):this._chipsWrap.appendChild(this._dragChip)}return}this._input&&e.closest("input")===this._input&&this._chipsWrap.insertBefore(this._dragChip,this._input)}_onPointerUp(t){if(this._isPointerDragging){if(this._isPointerDragging=!1,this._dragChip){try{this._dragChip.releasePointerCapture(t.pointerId)}catch{}this._dragChip.classList.remove("opacity-60","select-none")}this._syncOrderFromDom(),this._dragChip=null,this._dragIndex=null}}}customElements.get("mint-tags")||customElements.define("mint-tags",st);class rt extends HTMLElement{constructor(){super(...arguments),this._clickHandler=null,this._keydownHandler=null}connectedCallback(){this._render(),this._setupEventListeners()}disconnectedCallback(){this._cleanupEventListeners()}_render(){this.classList.add("transition-colors","duration-200","focus-visible:outline-none","focus-visible:ring-2","focus-visible:ring-offset-1","focus-visible:ring-gray-400","dark:focus-visible:ring-gray-500","rounded"),this.hasAttribute("disabled")?this.classList.add("cursor-not-allowed","opacity-50"):this.classList.add("cursor-pointer"),this.hasAttribute("role")||this.setAttribute("role","button"),this.hasAttribute("tabindex")||this.setAttribute("tabindex","0")}_setupEventListeners(){this._clickHandler=t=>{if(this.hasAttribute("disabled")){t.preventDefault(),t.stopPropagation();return}this._handleClick(t)},this._keydownHandler=t=>{if(t.key==="Enter"||t.key===" "){if(this.hasAttribute("disabled")){t.preventDefault(),t.stopPropagation();return}t.preventDefault(),this._handleClick(t)}},this.addEventListener("click",this._clickHandler),this.addEventListener("keydown",this._keydownHandler)}_cleanupEventListeners(){this._clickHandler&&(this.removeEventListener("click",this._clickHandler),this._clickHandler=null),this._keydownHandler&&(this.removeEventListener("keydown",this._keydownHandler),this._keydownHandler=null)}_handleClick(t){this.dispatchEvent(new CustomEvent("clickable-click",{bubbles:!0,composed:!0,detail:{originalEvent:t}}))}static get observedAttributes(){return["disabled"]}attributeChangedCallback(t,e,i){t==="disabled"&&(i!==null?(this.classList.remove("cursor-pointer"),this.classList.add("opacity-50","cursor-not-allowed"),this.setAttribute("aria-disabled","true")):(this.classList.remove("opacity-50","cursor-not-allowed"),this.classList.add("cursor-pointer"),this.removeAttribute("aria-disabled")))}}customElements.get("mint-clickable")||customElements.define("mint-clickable",rt);class nt extends HTMLElement{constructor(){super(),this._headingElement=null,this._iconElement=null,this._dismissButton=null,this._headerWrapper=null,this._bodyWrapper=null,this._dismissHandler=null}static get observedAttributes(){return["heading","dismissable","tone"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline","block"),this.render()}disconnectedCallback(){this._dismissButton&&this._dismissHandler&&this._dismissButton.removeEventListener("click",this._dismissHandler)}attributeChangedCallback(t,e,i){e!==i&&this.render()}getHeading(){return this.getAttribute("heading")||""}getTone(){const t=this.getAttribute("tone");return t==="info"||t==="success"||t==="warning"||t==="danger"?t:"info"}isDismissable(){return this.hasAttribute("dismissable")}getIconName(){switch(this.getTone()){case"info":return"info";case"success":return"success";case"warning":return"warning";case"danger":return"error";default:return"info"}}getIconColorClasses(){switch(this.getTone()){case"info":return"text-blue-600 dark:text-blue-400";case"success":return"text-green-600 dark:text-green-400";case"warning":return"text-yellow-600 dark:text-yellow-400";case"danger":return"text-red-600 dark:text-red-400";default:return"text-blue-600 dark:text-blue-400"}}getHeadingColorClasses(){return"text-gray-900 dark:text-gray-100"}getHeaderBackgroundClasses(){switch(this.getTone()){case"info":return"bg-blue-100 dark:bg-blue-900/30";case"success":return"bg-green-100 dark:bg-green-900/30";case"warning":return"bg-yellow-100 dark:bg-yellow-900/30";case"danger":return"bg-red-100 dark:bg-red-900/30";default:return"bg-blue-100 dark:bg-blue-900/30"}}getBorderClasses(){switch(this.getTone()){case"info":return"border-blue-200 dark:border-blue-800";case"success":return"border-green-200 dark:border-green-800";case"warning":return"border-yellow-200 dark:border-yellow-800";case"danger":return"border-red-200 dark:border-red-800";default:return"border-blue-200 dark:border-blue-800"}}getAriaLive(){return this.getTone()==="danger"?"assertive":"polite"}render(){const t=this.getTone(),e=this.getHeading(),i=this.isDismissable();this.className=`box-border m-0 p-0 border-0 align-baseline block rounded-lg border shadow-sm overflow-hidden transition-colors duration-200 ${this.getBorderClasses()}`;const s=this.getAriaLive();this.setAttribute("role","alert"),this.setAttribute("aria-live",s),t==="danger"?this.setAttribute("aria-atomic","true"):this.removeAttribute("aria-atomic");const n=[];for(this._bodyWrapper?Array.from(this._bodyWrapper.childNodes).forEach(a=>{n.push(a)}):Array.from(this.childNodes).forEach(r=>{r!==this._headerWrapper&&r!==this._bodyWrapper&&r!==this._iconElement&&r!==this._headingElement&&r!==this._dismissButton&&n.push(r)}),this._dismissButton&&this._dismissHandler&&this._dismissButton.removeEventListener("click",this._dismissHandler);this.firstChild;)this.removeChild(this.firstChild);if(this._headerWrapper=null,this._bodyWrapper=null,this._iconElement=null,this._headingElement=null,this._dismissButton=null,this._headerWrapper=document.createElement("div"),this._headerWrapper.className=`px-4 py-3 flex items-center gap-3 ${this.getHeaderBackgroundClasses()}`,this._iconElement=document.createElement("mint-icon"),this._iconElement.setAttribute("name",this.getIconName()),this._iconElement.className=`flex-shrink-0 w-5 h-5 ${this.getIconColorClasses()}`,this._headerWrapper.appendChild(this._iconElement),this._headingElement=document.createElement("mint-text"),this._headingElement.className=`font-semibold flex-1 ${this.getHeadingColorClasses()}`,this._headingElement.textContent=e||"",this._headerWrapper.appendChild(this._headingElement),i){this._dismissButton=document.createElement("button"),this._dismissButton.className="flex-shrink-0 p-1 rounded hover:bg-black/10 dark:hover:bg-white/10 transition-colors",this._dismissButton.setAttribute("aria-label","Dismiss alert"),this._dismissButton.setAttribute("type","button");const r=document.createElement("mint-icon");r.setAttribute("name","close"),r.className="w-4 h-4 text-gray-700 dark:text-gray-300",this._dismissButton.appendChild(r),this._dismissHandler=a=>{a.preventDefault(),a.stopPropagation(),this.dispatchEvent(new CustomEvent("dismissed",{bubbles:!0,composed:!0})),this.remove()},this._dismissButton.addEventListener("click",this._dismissHandler),this._headerWrapper.appendChild(this._dismissButton)}this._bodyWrapper=document.createElement("div"),this._bodyWrapper.className="px-4 py-3 bg-white dark:bg-gray-800",n.forEach(r=>{this._bodyWrapper.appendChild(r)}),this.appendChild(this._headerWrapper),this.appendChild(this._bodyWrapper)}}customElements.get("mint-alert")||customElements.define("mint-alert",nt);class at extends HTMLElement{constructor(){super(),this._configuration=null,this._rows=[],this._search="",this._currentPage=1,this._perPage=15,this._totalRows=0,this._lastPage=0,this._offset=0,this._rowsToShow=15,this._loaded=!1,this._fetching=!1,this._loading=!1,this._fetchError=null,this._searching=!1,this._sorting=!1,this._sortingColumn=null,this._type="provided",this._searchTimeoutId=null,this._searchColumns=[],this._exportColumns={},this._columns=[],this._tableId="",this._searchInput=null,this._tableContainer=null,this._paginationContainer=null,this._skeletonContainer=null,this._inMintCard=!1}static get observedAttributes(){return["configuration"]}get inMintCard(){return this._inMintCard}get configuration(){return this._configuration}set configuration(t){t&&typeof t=="object"&&!Array.isArray(t)?(this._configuration=t,this._tableId=this._configuration.id||`mint-resource-table-${Date.now()}`,this._perPage=this._configuration.perPage||15,this._rowsToShow=this._perPage,this._type=typeof this._configuration.data=="string"?"ajax":"provided",this._loaded=!1,this._currentPage=1,this._offset=0,this._type==="provided"&&Array.isArray(this._configuration.data)&&(this._rows=[...this._configuration.data],this._totalRows=this._configuration.data.length),this._initializeColumns(),this._loadColumnVisibility(),this.isConnected&&this.render()):t==null?this._configuration=null:this._parseConfiguration()}connectedCallback(){var t,e;this.classList.add("box-border","m-0","p-0","border-0","align-baseline","block","w-full"),this._inMintCard=((e=(t=this.parentElement)==null?void 0:t.tagName)==null?void 0:e.toLowerCase())==="mint-card",this._configuration||this._parseConfiguration(),this._initializeColumns(),this._loadColumnVisibility(),this._attachRowClickHandler(),this.render()}disconnectedCallback(){this._searchTimeoutId&&clearTimeout(this._searchTimeoutId),this._rowClickHandler&&(this.removeEventListener("click",this._rowClickHandler,!0),this._rowClickHandler=null),this._scrollHandler&&(window.removeEventListener("scroll",this._scrollHandler),this._scrollHandler=null)}attributeChangedCallback(t,e,i){t==="configuration"&&e!==i&&(!this._configuration||typeof i=="string")&&(this._parseConfiguration(),this.render())}_parseConfiguration(){const t=this.getAttribute("configuration");if(!t){console.error("mint-resource-table: configuration attribute is required");return}try{this._configuration=JSON.parse(t),this._tableId=this._configuration.id||`mint-resource-table-${Date.now()}`,this._perPage=this._configuration.perPage||15,this._rowsToShow=this._perPage,this._type=typeof this._configuration.data=="string"?"ajax":"provided",this._loaded=!1,this._currentPage=1,this._offset=0,this._type==="provided"&&Array.isArray(this._configuration.data)&&(this._rows=[...this._configuration.data],this._totalRows=this._configuration.data.length),this._initializeColumns(),this._loadColumnVisibility()}catch(e){console.error("mint-resource-table: Invalid configuration JSON",e)}}_getColumnVisibilityStorageKey(){return`mrtc-${this._tableId}`}_saveColumnVisibility(){if(!this._configuration)return;const t={};this._configuration.columns.forEach((e,i)=>{t[i]=e.hidden||!1});try{localStorage.setItem(this._getColumnVisibilityStorageKey(),JSON.stringify(t))}catch(e){console.warn("Failed to save column visibility to localStorage:",e)}}_loadColumnVisibility(){if(this._configuration)try{const t=localStorage.getItem(this._getColumnVisibilityStorageKey());if(t){const e=JSON.parse(t);this._configuration.columns.forEach((i,s)=>{e[s]!==void 0&&(i.hidden=e[s])})}}catch(t){console.warn("Failed to load column visibility from localStorage:",t)}}_initializeColumns(){this._configuration&&(this._searchColumns=[],this._exportColumns={},this._columns=[],this._configuration.columns.forEach(t=>{t.searchable&&t.data&&this._searchColumns.push(t.data),t.export&&t.data&&(this._exportColumns[t.data]=t.label),t.data&&this._columns.push(t.data)}),this._configuration.sortBy||(this._configuration.sortBy="id"),this._configuration.sort||(this._configuration.sort="asc"))}async _fetchData(t,e=!0,i,s){var o,l,c,h,p,d,u,f;if(!this._configuration)return;const n=t||(typeof this._configuration.data=="string"?this._configuration.data:null);if(!n||this._fetching||this._loading)return;e&&(this._fetching=!0,this.render()),this._loading=!0;const r=i||this._perPage,a=s!==void 0?s:this._offset;try{const m=new URLSearchParams({perPage:r.toString(),offset:a.toString(),search:this._search,sortBy:this._configuration.sortBy||"id",sort:this._configuration.sort||"asc",searchColumns:this._searchColumns.join(","),columns:this._columns.join(",")}),g={};this._configuration.headers&&(g.headers=this._configuration.headers);const _=await fetch(`${n}?${m.toString()}`,g);if(!_.ok)throw new Error(`HTTP error! status: ${_.status}`);const b=await _.json(),x=((o=b.content)==null?void 0:o.rows)||[],y=((l=b.content)==null?void 0:l.total)||0;if(this._configuration.loadMore&&a!==0)this._rows=this._rows.concat(x);else{let w=x;this._configuration.predefinedData?(w=[...this._configuration.predefinedData,...x],this._totalRows=y+this._configuration.predefinedData.length):this._totalRows=y,this._rows=w}const E=Math.floor(a/r)+1;this._configuration.loadMore||(((c=b.content)==null?void 0:c.current_page)!==void 0&&b.content.current_page===E?this._currentPage=b.content.current_page:this._currentPage=E,this._offset=(this._currentPage-1)*r),this._lastPage=((h=b.content)==null?void 0:h.last_page)||1,this._fetching=!1,this._loaded=!0,this._loading=!1,this._fetchError=null,this._searching=!1;const v=this._sorting;if(v&&this._updateSortIcons(),this._sorting=!1,this._sortingColumn=null,v&&this._updateSortIcons(),this.dispatchEvent(new CustomEvent("loaded",{detail:{rows:this._rows}})),this._updateSearchIcon(),(d=(p=this.querySelector(`#${this._tableId}`))==null?void 0:p.closest("table"))==null?void 0:d.querySelector("tbody")){if(this._configuration.loadMore&&v){const w=this._loading,A=this._fetching;this._loading=!1,this._fetching=!1,this._updateTableBody(),this._loading=w,this._fetching=A}else this._updateTableBody();this._updatePagination()}else this.render()}catch(m){this._fetching=!1,this._loading=!1,this._loaded=!0,this._searching=!1,this._fetchError=m instanceof Error?m.message:"Failed to fetch data",console.error("mint-resource-table: Error fetching data",m),this._updateSearchIcon(),((f=(u=this.querySelector(`#${this._tableId}`))==null?void 0:u.closest("table"))==null?void 0:f.querySelector("tbody"))?(this._updateTableBody(),this._updatePagination()):this.render()}}_getRows(){if(!this._configuration)return[];if(this._type==="ajax")return this._rows;let t=[...this._rows];const e=this._configuration.sortBy||"id",i=this._configuration.sort||"asc";if(this._search){const s=this._search.toLowerCase().trim().split(/\s+/);t=t.filter(n=>{const r=Object.values(n).map(a=>String(a).toLowerCase()).join(" ");return s.every(a=>r.includes(a))})}if(t.sort((s,n)=>{const r=s[e],a=n[e];if(r==null&&a==null)return 0;if(r==null)return 1;if(a==null)return-1;const o=typeof r=="number"?r:typeof r=="string"&&!isNaN(Number(r))&&r.trim()!==""?Number(r):null,l=typeof a=="number"?a:typeof a=="string"&&!isNaN(Number(a))&&a.trim()!==""?Number(a):null;if(o!==null&&l!==null){const d=o-l;return i==="asc"?d:-d}const c=r instanceof Date?r:typeof r=="string"?new Date(r):null,h=a instanceof Date?a:typeof a=="string"?new Date(a):null;if(c&&h&&!isNaN(c.getTime())&&!isNaN(h.getTime())){const d=c.getTime()-h.getTime();return i==="asc"?d:-d}const p=String(r).localeCompare(String(a),void 0,{numeric:!0,sensitivity:"base"});return i==="asc"?p:-p}),this._perPage){const s=Math.ceil(t.length/this._perPage);this._lastPage=s,t.forEach((n,r)=>{n.page=Math.ceil((r+1)/this._perPage)}),this._currentPage>s&&s>0&&(this._currentPage=s)}return this._configuration.loadMore?t.slice(0,this._rowsToShow):t.filter(s=>!this._perPage||s.page===this._currentPage)}_toggleSort(t){var i;if(!this._configuration||!t.data||!t.sortable)return;let e=this._configuration.sort||"asc";((i=this._configuration.sortBy)==null?void 0:i.toLowerCase())===t.data.toLowerCase()&&(e=e==="desc"?"asc":"desc"),this._configuration.sort=e,this._configuration.sortBy=t.data,this._sorting=!0,this._sortingColumn=t,this._type==="ajax"?(this._updateSortIcons(),this._offset=0,this._currentPage=1,this._configuration.loadMore&&(this._rowsToShow=this._perPage),this._fetching=!1,this._loading=!1,this._configuration.loadMore?this._fetchData(void 0,!1,this._perPage,0):this._fetchData(void 0,!0,this._rows.length,this._offset)):(this._currentPage=1,this._sorting=!1,this._sortingColumn=null,this.render())}_getSortClass(t){var e,i,s,n,r;return this._sorting&&this._sortingColumn===t?"spinner":((i=(e=this._configuration)==null?void 0:e.sortBy)==null?void 0:i.toLowerCase())===((s=t.data)==null?void 0:s.toLowerCase())?((r=(n=this._configuration)==null?void 0:n.sort)==null?void 0:r.toLowerCase())==="desc"?"caret-down":"caret-up":""}_updateSortIcons(){this._configuration&&this._configuration.columns.forEach((t,e)=>{if(!t.sortable||t.hidden)return;const i=this.querySelector(`th[data-column-key="${e}"]`);if(!i)return;const s=i.querySelector(".ml-2.flex.items-center");if(!s)return;const n=s.querySelector("mint-icon"),r=s.querySelector("mint-spinner"),a=this._getSortClass(t);if(a==="spinner"){if(n&&n.remove(),!r){const o=document.createElement("mint-spinner");o.className="w-4 h-4",s.appendChild(o)}}else if(r&&r.remove(),n)n.setAttribute("name",a),n.className=`w-4 h-4 ${a==="sort-arrows"?"text-gray-400":""}`;else{const o=document.createElement("mint-icon");o.setAttribute("name",a),o.className=`w-4 h-4 ${a==="sort-arrows"?"text-gray-400":""}`,s.appendChild(o)}})}_showFetchingState(){}_triggerSearch(){this._searchTimeoutId&&clearTimeout(this._searchTimeoutId),this._searching=!0,this._type==="ajax"&&this._updateSearchIcon(),this._type!=="ajax"&&(this._currentPage=1),this._updateTableBody(),this._type!=="ajax"&&this._updatePagination(),this._searchTimeoutId=window.setTimeout(()=>{this._type==="ajax"?(this._offset=0,this._fetchData(void 0,!1,this._perPage,0)):this._searching=!1},400)}_updateSearchIcon(){const t=this.querySelector(`#search-${this._tableId}`);if(!t)return;const e=this._type==="ajax"&&(this._searching||this._fetching);setTimeout(()=>{const i=t.querySelector(".relative")||t.querySelector("div");if(!i)return;const s=i.querySelector("mint-icon"),n=i.querySelector("mint-spinner");if(e){if(s&&!n){const r=document.createElement("mint-spinner");r.className="absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 pointer-events-none",s.replaceWith(r)}else if(!s&&!n){const r=document.createElement("mint-spinner");r.className="absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 pointer-events-none",i.appendChild(r)}}else if(n){t.getAttribute("icon")||t.setAttribute("icon","search");const r=document.createElement("mint-icon");r.setAttribute("name","search"),r.className="absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400 dark:text-gray-500 pointer-events-none",n.replaceWith(r)}},0)}_updateTableBody(){var a,o,l;if(!this._configuration)return;const t=this._getRows(),e=(o=(a=this.querySelector(`#${this._tableId}`))==null?void 0:a.closest("table"))==null?void 0:o.querySelector("tbody");if(!e){this.render();return}const i=this.querySelector(`#search-${this._tableId}`),s=document.activeElement===i||(i==null?void 0:i.querySelector("input"))===document.activeElement,n=this._search;let r="";if(!((this._fetching||this._loading)&&!(this._sorting&&((l=this._configuration)!=null&&l.loadMore)))&&(t.forEach((c,h)=>{const p=typeof this._configuration.onRowClick=="function",d=p?"cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors":"";r+=`<tr data-row-index="${h}" ${p?'data-row-clickable="true"':""}${d?` class="${d}"`:""}>`,this._configuration.columns.forEach((u,f)=>{if(u.hidden)return;const m=!u.show||u.show(this,c);if(r+=`<td style="${this._getStyle(u)}" class="${this._getClasses(u,!0)}">`,m)if(u.raw)if(u.action)(!u.action.show||u.action.show(this,c))&&(r+=`<mint-button variant="solid" data-action="column-action" data-row-index="${h}" data-column-key="${this._configuration.columns.indexOf(u)}">${u.action.label}</mint-button>`);else if(u.actions)if(u.actionStyle!=="buttons"){const g=`actions-popover-${this._tableId}-${h}`,_=`actions-button-${this._tableId}-${h}`;r+=`<mint-button id="${_}" variant="link" icon="ellipsis">`,r+="</mint-button>",r+=`<mint-popover id="${g}" trigger-id="${_}" direction="down">`,u.actions.forEach((b,x)=>{if(!b.show||b.show(this,c)){const y=typeof b.label=="function"?b.label(this,c):b.label;r+=`<div class="p-2 cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-700" data-action="row-action" data-row-index="${h}" data-action-index="${x}" data-column-key="${this._configuration.columns.indexOf(u)}">${y}</div>`}}),r+="</mint-popover>"}else u.actions.forEach((g,_)=>{if(!g.show||g.show(this,c)){const b=g.label?typeof g.label=="function"?g.label(this,c):g.label:"",x=g.icon?` icon="${this._escapeHtml(g.icon)}"`:"",y=g.tone?` tone="${this._escapeHtml(g.tone)}"`:"";r+=`<mint-button variant="link" class="${g.classes||""}" data-action="row-action" data-row-index="${h}" data-action-index="${_}" data-column-key="${this._configuration.columns.indexOf(u)}"${x}${y}>`,b&&(r+=this._escapeHtml(String(b))),r+="</mint-button>"}});else typeof u.format=="function"?r+=u.format(this,c):u.data&&(r+=this._escapeHtml(String(c[u.data]||"")));else if(u.action){if(!u.action.show||u.action.show(this,c)){const g=typeof u.action.label=="function"?u.action.label(this,c):u.action.label;r+=`<mint-button variant="solid" data-action="column-action" data-row-index="${h}" data-column-key="${this._configuration.columns.indexOf(u)}">${this._escapeHtml(String(g))}</mint-button>`}}else if(u.actions)if(u.actionStyle!=="buttons"){const g=`actions-popover-${this._tableId}-${h}`,_=`actions-button-${this._tableId}-${h}`;r+=`<mint-button id="${_}" variant="link" icon="ellipsis">`,r+="</mint-button>",r+=`<mint-popover id="${g}" trigger-id="${_}" direction="down">`,u.actions.forEach((b,x)=>{if(!b.show||b.show(this,c)){const y=typeof b.label=="function"?b.label(this,c):b.label;r+=`<div class="p-2 cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-700" data-action="row-action" data-row-index="${h}" data-action-index="${x}" data-column-key="${this._configuration.columns.indexOf(u)}">${y}</div>`}}),r+="</mint-popover>"}else u.actions.forEach((g,_)=>{if(!g.show||g.show(this,c)){const b=g.label?typeof g.label=="function"?g.label(this,c):g.label:"",x=g.icon?` icon="${this._escapeHtml(g.icon)}"`:"",y=g.tone?` tone="${this._escapeHtml(g.tone)}"`:"";r+=`<mint-button variant="link" class="${g.classes||""}" data-action="row-action" data-row-index="${h}" data-action-index="${_}" data-column-key="${this._configuration.columns.indexOf(u)}"${x}${y}>`,b&&(r+=this._escapeHtml(String(b))),r+="</mint-button>"}});else typeof u.format=="function"?r+=this._escapeHtml(u.format(this,c)):u.data&&(r+=this._escapeHtml(String(c[u.data]||"")));r+="</td>"}),r+="</tr>"}),t.length===0&&(this._fetchError?r+=`<tr><td colspan="${this._configuration.columns.filter(c=>!c.hidden).length}" class="text-center py-8 text-red-500 dark:text-red-400">Failed to load data: ${this._escapeHtml(this._fetchError)}</td></tr>`:r+=`<tr><td colspan="${this._configuration.columns.filter(c=>!c.hidden).length}" class="text-center py-8">No records found.</td></tr>`),e.innerHTML=r,this._attachTableEventListeners(),this._attachRowClickHandler(),s&&i)){const c=i.querySelector("input")||i._element;c?(c.value=n,setTimeout(()=>{c.focus(),c.setSelectionRange(n.length,n.length)},0)):i.value!==void 0&&(i.value=n,setTimeout(()=>{i.focus()},0))}}_updatePagination(){var s,n;if(!this._configuration)return;const t=this._lastPage||Math.ceil(this._rows.length/this._perPage);if(!this._configuration.perPage||this._configuration.loadMore||t<=1){const r=(s=this.querySelector("nav"))==null?void 0:s.closest(".flex.justify-end");r&&r.remove();return}let e=(n=this.querySelector("nav"))==null?void 0:n.closest(".flex.justify-end");if(!e){const r=this.querySelector("mint-table");if(!r){this.render();return}e=document.createElement("div"),e.className="flex justify-end "+(this._inMintCard?"p-3.5":"mt-4"),r.insertAdjacentElement("afterend",e)}let i="<nav>";i+='<ul class="flex gap-1">',i+=`<li><mint-button variant="solid" size="sm" icon="caret-left" ${this._currentPage===1?'disabled="true"':""} data-action="page-prev"></mint-button></li>`;for(let r=1;r<=Math.min(2,t);r++){const o=this._currentPage===r?' disabled="true"':"";i+=`<li><mint-button variant="solid" size="sm"${o} data-action="page" data-page="${r}">${r}</mint-button></li>`}if(t>2&&(i+='<li><span class="px-2">...</span></li>'),this._currentPage>2&&this._currentPage<t-1&&(i+=`<li><mint-button variant="solid" size="sm" data-action="page" data-page="${this._currentPage-1}">${this._currentPage-1}</mint-button></li>`,i+=`<li><mint-button variant="solid" size="sm" disabled="true" data-action="page" data-page="${this._currentPage}">${this._currentPage}</mint-button></li>`,i+=`<li><mint-button variant="solid" size="sm" data-action="page" data-page="${this._currentPage+1}">${this._currentPage+1}</mint-button></li>`),t>2)for(let r=Math.max(t-1,this._currentPage+2);r<=t;r++){const o=this._currentPage===r?' disabled="true"':"";i+=`<li><mint-button variant="solid" size="sm"${o} data-action="page" data-page="${r}">${r}</mint-button></li>`}i+=`<li><mint-button variant="solid" size="sm" icon="caret-right" ${this._currentPage>=t?'disabled="true"':""} data-action="page-next"></mint-button></li>`,i+="</ul>",i+="</nav>",e.innerHTML=i,setTimeout(()=>{this._attachPaginationListeners(),e.querySelectorAll("mint-button[data-action]").forEach(r=>{"render"in r&&typeof r.render=="function"&&r.render()})},0)}_loadMore(){this._loading||this._fetching||!(this._type==="ajax"?this._lastPage>0&&this._currentPage<this._lastPage:this._totalRows>0&&this._rowsToShow<this._totalRows)||(this._offset+=this._perPage,this._currentPage+=1,this._rowsToShow+=this._perPage,this._type==="ajax"?this._fetchData():this.render())}_goToPage(t){const e=this._lastPage||Math.ceil(this._rows.length/this._perPage);t>e&&(t=e),t<1&&(t=1),this._currentPage=t,this._offset=(t-1)*this._perPage,this._type==="ajax"?this._fetchData():this.render()}_handleButtonClick(t){if(this._configuration)switch(t.type){case"export":break;case"print":window.print();break;case"csv":this._downloadCSV();break;default:t.onClick&&t.onClick(this);break}}_downloadCSV(){if(!this._configuration)return;const t=this.querySelector("table");if(!t)return;const e=t.querySelectorAll("tr");let i="data:text/csv;charset=utf-8,";e.forEach(r=>{const a=[];r.querySelectorAll("th, td").forEach(o=>{var c;const l=o.getAttribute("colspan");if(l)for(let h=0;h<parseInt(l)-1;h++)a.push("");a.push('"'+((c=o.textContent)==null?void 0:c.trim().replace(/"/g,'""'))+'"')}),i+=a.join(",")+`
|
|
142
|
-
`});const s=encodeURI(i),n=document.createElement("a");n.setAttribute("href",s),n.setAttribute("download",`${this._configuration.export_name||this._tableId}.csv`),document.body.appendChild(n),n.click(),document.body.removeChild(n)}_columnChange(t,e){const i=t.target.checked;e.hidden=!i,this._saveColumnVisibility();const s=`edit-columns-popover-${this._tableId}`,n=this.querySelector(`#${s}`),r=n==null?void 0:n.hasAttribute("open");this.render(),r&&n&&requestAnimationFrame(()=>{const a=this.querySelector(`#${s}`);a&&typeof a.open=="function"&&a.open()})}_getStyle(t){let e="";return(t.nowrap||t.actions)&&(e+="white-space: nowrap;"),t.offsetLeft&&(e+=`left: ${t.offsetLeft} !important;`),t.offsetRight&&(e+=`right: ${t.offsetRight} !important;`),t.width&&(e+=`min-width: ${t.width}px; max-width: ${t.width}px;`),e}_getClasses(t,e=!1){const i=[];return t.class&&i.push(t.class.trim()),t.sortable&&!e&&i.push("cursor-pointer"),t.stickLeft&&i.push("sticky-left"),t.stickRight&&i.push("sticky-right"),i.join(" ")}render(){if(!this._configuration){this.innerHTML='<div class="p-4 text-red-500">Error: Invalid configuration</div>';return}const t=!this._loaded||this._rows.length>0||this._search.length>0||this._searching,e=this._getRows(),i=this._lastPage||Math.ceil(this._rows.length/this._perPage);let s="";if(t){if(s+='<div class="flex '+(this._inMintCard?"p-3.5":"mb-3")+'">',s+='<div class="flex-grow-1 flex-1">',s+='<div class="flex gap-2 items-center">',this._configuration.showSearch!==!1){const r=`search-${this._tableId}`;s+=`<mint-input id="${r}" type="search" label="" placeholder="Search..." class="flex-1" icon="search" value="${this._escapeHtml(this._search)}"></mint-input>`}if(this._configuration.buttons&&this._configuration.buttons.forEach(r=>{const a=r.icon?` icon="${this._escapeHtml(r.icon)}"`:"",o=r.tone?` tone="${this._escapeHtml(r.tone)}"`:"";s+=`<mint-button variant="solid" class="${r.class||""}" data-button-type="${r.type||"custom"}"${a}${o}>`,r.label&&(s+=this._escapeHtml(r.label)),s+="</mint-button>"}),s+="</div>",s+="</div>",this._configuration.editColumns!==!1&&this._configuration.columns.some(a=>!a.actions&&a.editable!==!1)){const a=`edit-columns-popover-${this._tableId}`,o=`edit-columns-button-${this._tableId}`;s+='<div class="ml-2">',s+=`<mint-button id="${o}" variant="solid" icon="edit"></mint-button>`,s+=`<mint-popover id="${a}" trigger-id="${o}" direction="down">`,this._configuration.columns.forEach(l=>{!l.actions&&l.editable!==!1&&(s+='<div class="p-2">',s+=`<mint-checkbox label="${l.label}" ${l.hidden?"":"checked"} data-column-key="${this._configuration.columns.indexOf(l)}"></mint-checkbox>`,s+="</div>")}),s+="</mint-popover>",s+="</div>"}s+="</div>"}if(this._type==="ajax"&&(!this._loaded||this._fetching||this._loading)&&!this._fetchError&&!this._sorting){s+='<div class="space-y-0 flex gap-2 flex-col"><div class="h-9 bg-gray-200 dark:bg-gray-700 border-b border-gray-200 dark:border-gray-700 animate-pulse"></div>';for(let r=0;r<3;r++)s+='<div class="h-9 bg-gray-200 dark:bg-gray-700 border-b border-gray-200 dark:border-gray-700 animate-pulse"></div>';if(s+="</div>",this._configuration.perPage&&!this._configuration.loadMore){if(!this._loaded)s+='<div class="flex justify-end '+(this._inMintCard?"p-3.5":"mt-4")+'">',s+="<nav>",s+='<ul class="flex gap-1">',s+='<li><div class="h-8 w-8 bg-gray-200 dark:bg-gray-700 rounded animate-pulse"></div></li>',s+='<li><div class="h-8 w-8 bg-gray-200 dark:bg-gray-700 rounded animate-pulse"></div></li>',s+='<li><div class="h-8 w-8 bg-gray-200 dark:bg-gray-700 rounded animate-pulse"></div></li>',s+='<li><div class="h-8 w-8 bg-gray-200 dark:bg-gray-700 rounded animate-pulse"></div></li>',s+="</ul>",s+="</nav>",s+="</div>";else if(i>1||this._lastPage>0){const r=this._lastPage>0?this._lastPage:i;if(r>1){s+='<div class="flex justify-end '+(this._inMintCard?"p-3.5":"mt-4")+'">',s+="<nav>",s+='<ul class="flex gap-1">',s+=`<li><mint-button variant="solid" size="sm" icon="caret-left" ${this._currentPage===1?'disabled="true"':""} data-action="page-prev"></mint-button></li>`;for(let a=1;a<=Math.min(2,r);a++){const l=this._currentPage===a?' disabled="true"':"";s+=`<li><mint-button variant="solid" size="sm"${l} data-action="page" data-page="${a}">${a}</mint-button></li>`}if(r>2&&(s+='<li><span class="px-2">...</span></li>'),this._currentPage>2&&this._currentPage<r-1&&(s+=`<li><mint-button variant="solid" size="sm" data-action="page" data-page="${this._currentPage-1}">${this._currentPage-1}</mint-button></li>`,s+=`<li><mint-button variant="solid" size="sm" disabled="true" data-action="page" data-page="${this._currentPage}">${this._currentPage}</mint-button></li>`,s+=`<li><mint-button variant="solid" size="sm" data-action="page" data-page="${this._currentPage+1}">${this._currentPage+1}</mint-button></li>`),r>2)for(let a=Math.max(r-1,this._currentPage+2);a<=r;a++){const l=this._currentPage===a?' disabled="true"':"";s+=`<li><mint-button variant="solid" size="sm"${l} data-action="page" data-page="${a}">${a}</mint-button></li>`}s+=`<li><mint-button variant="solid" size="sm" icon="caret-right" ${this._currentPage>=r?'disabled="true"':""} data-action="page-next"></mint-button></li>`,s+="</ul>",s+="</nav>",s+="</div>"}}}}else if(e.length>0||this._search.length>0||this._searching||this._fetchError){if(s+='<mint-table class="table-section'+(this._inMintCard?" rounded-t-none":"")+'">',s+=`<table id="${this._tableId}">`,s+="<thead><tr>",this._configuration.columns.forEach((r,a)=>{if(!r.hidden){if(s+=`<th width="${r.width||""}" style="${this._getStyle(r)}" class="${this._getClasses(r)}" data-column-key="${a}">`,r.showLabel!==!1){if(s+='<div class="flex items-center">',s+=`<div class="flex-1">${r.raw?r.label:this._escapeHtml(r.label)}</div>`,r.sortable){s+='<div class="ml-2 flex items-center">';const o=this._getSortClass(r);o==="spinner"?s+='<mint-spinner class="w-4 h-4"></mint-spinner>':s+=`<mint-icon name="${o}" class="w-4 h-4 ${o==="sort-arrows"?"text-gray-400":""}"></mint-icon>`,s+="</div>"}s+="</div>"}s+="</th>"}}),s+="</tr></thead>",s+="<tbody>",!this._fetching&&!this._loading&&e.forEach((r,a)=>{const o=typeof this._configuration.onRowClick=="function",l=o?"cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors":"";s+=`<tr data-row-index="${a}" ${o?'data-row-clickable="true"':""}${l?` class="${l}"`:""}>`,this._configuration.columns.forEach((c,h)=>{if(c.hidden)return;const p=!c.show||c.show(this,r);if(s+=`<td style="${this._getStyle(c)}" class="${this._getClasses(c,!0)}">`,p)if(c.raw)if(c.action){if(!c.action.show||c.action.show(this,r)){const d=typeof c.action.label=="function"?c.action.label(this,r):c.action.label;s+=`<mint-button variant="solid" data-action="column-action" data-row-index="${a}" data-column-key="${this._configuration.columns.indexOf(c)}">${this._escapeHtml(String(d))}</mint-button>`}}else if(c.actions)if(c.actionStyle!=="buttons"){const d=`actions-popover-${this._tableId}-${a}`,u=`actions-button-${this._tableId}-${a}`;s+=`<mint-button id="${u}" variant="link" icon="ellipsis">`,s+="</mint-button>",s+=`<mint-popover id="${d}" trigger-id="${u}" direction="down">`,c.actions.forEach((f,m)=>{if(!f.show||f.show(this,r)){const g=typeof f.label=="function"?f.label(this,r):f.label;s+=`<div class="p-2 cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-700" data-action="row-action" data-row-index="${a}" data-action-index="${m}" data-column-key="${this._configuration.columns.indexOf(c)}">${this._escapeHtml(String(g))}</div>`}}),s+="</mint-popover>"}else c.actions.forEach((d,u)=>{if(!d.show||d.show(this,r)){const f=d.label?typeof d.label=="function"?d.label(this,r):d.label:"",m=d.icon?` icon="${this._escapeHtml(d.icon)}"`:"",g=d.tone?` tone="${this._escapeHtml(d.tone)}"`:"";s+=`<mint-button variant="link" class="${d.classes||""}" data-action="row-action" data-row-index="${a}" data-action-index="${u}" data-column-key="${this._configuration.columns.indexOf(c)}"${m}${g}>`,f&&(s+=this._escapeHtml(String(f))),s+="</mint-button>"}});else typeof c.format=="function"?s+=c.format(this,r):c.data&&(s+=this._escapeHtml(String(r[c.data]||"")));else if(c.action)(!c.action.show||c.action.show(this,r))&&(s+=`<mint-button variant="solid" data-action="column-action" data-row-index="${a}" data-column-key="${this._configuration.columns.indexOf(c)}">${c.action.label}</mint-button>`);else if(c.actions)if(c.actionStyle!=="buttons"){const d=`actions-popover-${this._tableId}-${a}`,u=`actions-button-${this._tableId}-${a}`;s+=`<mint-button id="${u}" variant="link" icon="ellipsis">`,s+="</mint-button>",s+=`<mint-popover id="${d}" trigger-id="${u}" direction="down">`,c.actions.forEach((f,m)=>{if(!f.show||f.show(this,r)){const g=typeof f.label=="function"?f.label(this,r):f.label;s+=`<div class="p-2 cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-700" data-action="row-action" data-row-index="${a}" data-action-index="${m}" data-column-key="${this._configuration.columns.indexOf(c)}">${this._escapeHtml(String(g))}</div>`}}),s+="</mint-popover>"}else c.actions.forEach((d,u)=>{if(!d.show||d.show(this,r)){const f=d.label?typeof d.label=="function"?d.label(this,r):d.label:"",m=d.icon?` icon="${this._escapeHtml(d.icon)}"`:"",g=d.tone?` tone="${this._escapeHtml(d.tone)}"`:"";s+=`<mint-button variant="link" class="${d.classes||""}" data-action="row-action" data-row-index="${a}" data-action-index="${u}" data-column-key="${this._configuration.columns.indexOf(c)}"${m}${g}>`,f&&(s+=this._escapeHtml(String(f))),s+="</mint-button>"}});else typeof c.format=="function"?s+=this._escapeHtml(c.format(this,r)):c.data&&(s+=this._escapeHtml(String(r[c.data]||"")));s+="</td>"}),s+="</tr>"}),!this._fetching&&!this._loading&&e.length===0&&(this._fetchError?s+=`<tr><td colspan="${this._configuration.columns.filter(r=>!r.hidden).length}" class="text-center py-8 text-red-500 dark:text-red-400">Failed to load data: ${this._escapeHtml(this._fetchError)}</td></tr>`:s+=`<tr><td colspan="${this._configuration.columns.filter(r=>!r.hidden).length}" class="text-center py-8">No records found.</td></tr>`),s+="</tbody>",s+="</table>",this._configuration.loadMore&&(this._loading||this._fetching?(s+='<div class="flex justify-center '+(this._inMintCard?"p-3.5":"mt-4")+'">',s+="<mint-spinner></mint-spinner>",s+="</div>"):(this._type==="ajax"?this._lastPage>0&&this._currentPage<this._lastPage:this._totalRows>0&&this._rowsToShow<this._totalRows)&&(s+='<div class="flex justify-center '+(this._inMintCard?"p-3.5":"mt-4")+'">',s+='<mint-button variant="ghost" data-action="load-more">Load more</mint-button>',s+="</div>")),this._configuration.perPage&&!this._configuration.loadMore&&this._loaded&&i>1){s+='<div class="flex justify-end '+(this._inMintCard?"p-3.5":"mt-4")+'">',s+="<nav>",s+='<ul class="flex gap-1">',s+=`<li><mint-button variant="solid" size="sm" icon="caret-left" ${this._currentPage===1?'disabled="true"':""} data-action="page-prev"></mint-button></li>`;for(let r=1;r<=Math.min(2,i);r++){const o=this._currentPage===r?' disabled="true"':"";s+=`<li><mint-button variant="solid" size="sm"${o} data-action="page" data-page="${r}">${r}</mint-button></li>`}if(i>2&&(s+='<li><span class="px-2">...</span></li>'),this._currentPage>2&&this._currentPage<i-1&&(s+=`<li><mint-button variant="solid" size="sm" data-action="page" data-page="${this._currentPage-1}">${this._currentPage-1}</mint-button></li>`,s+=`<li><mint-button variant="solid" size="sm" disabled="true" data-action="page" data-page="${this._currentPage}">${this._currentPage}</mint-button></li>`,s+=`<li><mint-button variant="solid" size="sm" data-action="page" data-page="${this._currentPage+1}">${this._currentPage+1}</mint-button></li>`),i>2)for(let r=Math.max(i-1,this._currentPage+2);r<=i;r++){const o=this._currentPage===r?' disabled="true"':"";s+=`<li><mint-button variant="solid" size="sm"${o} data-action="page" data-page="${r}">${r}</mint-button></li>`}s+=`<li><mint-button variant="solid" size="sm" icon="caret-right" ${this._currentPage>=i?'disabled="true"':""} data-action="page-next"></mint-button></li>`,s+="</ul>",s+="</nav>",s+="</div>"}s+="</mint-table>"}else s+='<slot name="empty"></slot>';this.innerHTML=s,this.querySelectorAll("mint-button[data-action]").forEach(r=>{r.render&&r.render()}),this.querySelectorAll("mint-button[data-button-type]").forEach(r=>{r.render&&r.render()}),this._attachEventListeners(),this._type==="ajax"&&!this._loaded&&!this._fetching&&!this._loading&&this._fetchData()}_attachRowClickHandler(){this._rowClickHandler&&this.removeEventListener("click",this._rowClickHandler,!0);const t=e=>{var l;const i=e.target;if(i.tagName==="MINT-BUTTON"||i.tagName==="BUTTON"||i.closest("mint-button")||i.closest("button")||i.closest("mint-popover")||i.closest("[data-action]"))return;const s=i.closest('tr[data-row-clickable="true"]');if(!s)return;const n=s.getAttribute("data-row-index");if(!n)return;const r=parseInt(n),o=this._getRows()[r];!o||!((l=this._configuration)!=null&&l.onRowClick)||(this._configuration.onRowClick.length===1?this._configuration.onRowClick(o):this._configuration.onRowClick(this,o))};this.addEventListener("click",t,!0),this._rowClickHandler=t}_attachPaginationListeners(){this.querySelectorAll('[data-action="page"]').forEach(t=>{t.addEventListener("click",()=>{const e=parseInt(t.getAttribute("data-page")||"1");this._goToPage(e)})}),this.querySelectorAll('[data-action="page-prev"]').forEach(t=>{t.addEventListener("click",()=>{this._goToPage(this._currentPage-1)})}),this.querySelectorAll('[data-action="page-next"]').forEach(t=>{t.addEventListener("click",()=>{this._goToPage(this._currentPage+1)})})}_attachTableEventListeners(){this.querySelectorAll('[data-action="row-action"]').forEach(t=>{t.addEventListener("click",()=>{var o;const e=parseInt(t.getAttribute("data-row-index")||"0"),i=parseInt(t.getAttribute("data-action-index")||"0"),s=parseInt(t.getAttribute("data-column-key")||"0"),r=this._getRows()[e],a=(o=this._configuration)==null?void 0:o.columns[s];a&&a.actions&&a.actions[i]&&a.actions[i].onClick(this,r)})}),this.querySelectorAll('[data-action="column-action"]').forEach(t=>{t.addEventListener("click",()=>{var a;const e=parseInt(t.getAttribute("data-row-index")||"0"),i=parseInt(t.getAttribute("data-column-key")||"0"),n=this._getRows()[e],r=(a=this._configuration)==null?void 0:a.columns[i];r&&r.action&&r.action.onClick(this,n)})})}_attachEventListeners(){var e;const t=this.querySelector(`#search-${this._tableId}`);if(t){const i=t.querySelector("input")||t._element;i?i.addEventListener("input",s=>{this._search=s.target.value,this._triggerSearch()}):t.addEventListener("input",s=>{this._search=t.value||s.target.value||"",this._triggerSearch()})}if(this._attachTableEventListeners(),this._attachRowClickHandler(),this.querySelectorAll("th[data-column-key]").forEach(i=>{i.addEventListener("click",()=>{var r;const s=parseInt(i.getAttribute("data-column-key")||"0"),n=(r=this._configuration)==null?void 0:r.columns[s];n&&this._toggleSort(n)})}),this.querySelectorAll("[data-button-type]").forEach(i=>{i.addEventListener("click",()=>{var r,a;const s=i.getAttribute("data-button-type"),n=(a=(r=this._configuration)==null?void 0:r.buttons)==null?void 0:a.find(o=>(o.type||"custom")===s);n&&this._handleButtonClick(n)})}),this.querySelectorAll("mint-checkbox[data-column-key]").forEach(i=>{i.addEventListener("change",s=>{var a;s.stopPropagation();const n=parseInt(i.getAttribute("data-column-key")||"0"),r=(a=this._configuration)==null?void 0:a.columns[n];r&&this._columnChange(s,r)}),i.addEventListener("click",s=>{s.stopPropagation()})}),this._attachPaginationListeners(),this.querySelectorAll('[data-action="load-more"]').forEach(i=>{i.addEventListener("click",()=>{this._loadMore()})}),(e=this._configuration)!=null&&e.loadMore){this._scrollHandler&&window.removeEventListener("scroll",this._scrollHandler);const i=()=>{const s=window.pageYOffset||document.documentElement.scrollTop,n=window.innerHeight;if(document.documentElement.scrollHeight-s-n<=100){const a=this._type==="ajax"?this._lastPage>0&&this._currentPage<this._lastPage:this._totalRows>0&&this._rowsToShow<this._totalRows;!this._loading&&!this._fetching&&a&&this._loadMore()}};this._scrollHandler=i,window.addEventListener("scroll",i)}}_escapeHtml(t){const e=document.createElement("div");return e.textContent=t,e.innerHTML}}customElements.get("mint-resource-table")||customElements.define("mint-resource-table",at);exports.Alert=nt;exports.BackButton=W;exports.Button=P;exports.Card=z;exports.Checkbox=J;exports.Chip=it;exports.Choice=G;exports.Clickable=rt;exports.DatePicker=X;exports.Dropzone=Q;exports.Form=tt;exports.Grid=j;exports.Icon=q;exports.Input=K;exports.Link=R;exports.Modal=Y;exports.Page=V;exports.Popover=U;exports.ResourceTable=at;exports.Select=Z;exports.Spinner=F;exports.Stack=B;exports.Switch=$;exports.Table=et;exports.Tags=st;exports.Text=O;exports.default=P;
|
|
141
|
+
`,document.head.appendChild(t)}}customElements.get("mint-table")||customElements.define("mint-table",et);class it extends HTMLElement{constructor(){super(...arguments),this._root=null,this._textWrap=null,this._dismissBtn=null,this._clickHandler=null}static get observedAttributes(){return["dismissable"]}connectedCallback(){this._render()}disconnectedCallback(){this._dismissBtn&&this._clickHandler&&this._dismissBtn.removeEventListener("click",this._clickHandler)}attributeChangedCallback(){this._render()}_render(){var e;if(this.classList.add("inline-flex","items-center","gap-2","px-3","py-1","rounded-full","border","border-gray-200","dark:border-gray-700","bg-gray-100","dark:bg-gray-800","text-gray-900","dark:text-gray-100","text-sm","font-medium"),!this._root){for(this._root=document.createElement("div"),this._root.className="flex items-center gap-2 w-full",this._textWrap=document.createElement("span"),this._textWrap.className="inline-flex items-center min-w-[0.5rem]",this._textWrap.setAttribute("data-mt-chip-text","");this.firstChild;){const i=this.firstChild;if(i===this._root)break;this._textWrap.appendChild(i)}this._root.appendChild(this._textWrap),this.appendChild(this._root)}this.hasAttribute("dismissable")?(this._dismissBtn||this._createDismissBtn(),this._dismissBtn&&!this._dismissBtn.isConnected&&((e=this._root)==null||e.appendChild(this._dismissBtn))):this._dismissBtn&&this._dismissBtn.parentElement===this._root&&this._dismissBtn.remove()}_createDismissBtn(){const t=document.createElement("button");t.type="button",t.setAttribute("aria-label","Dismiss"),t.className=["shrink-0","inline-flex","items-center","justify-center","w-5","h-5","rounded-full","text-gray-500","dark:text-gray-300","hover:text-gray-700","dark:hover:text-gray-100","focus-visible:outline-none","focus-visible:ring-2","focus-visible:ring-offset-1","focus-visible:ring-gray-400","dark:focus-visible:ring-gray-500","transition-colors","duration-150","border-none","bg-transparent","cursor-pointer"].join(" ");const e=document.createElement("mint-icon");e.setAttribute("name","close"),e.className="w-3 h-3",t.appendChild(e),this._clickHandler=i=>{i.stopPropagation(),this.dispatchEvent(new CustomEvent("dismissed",{bubbles:!0,composed:!0}))},t.addEventListener("click",this._clickHandler),this._dismissBtn=t}}customElements.get("mint-chip")||customElements.define("mint-chip",it);class st extends HTMLElement{constructor(){super(...arguments),this._container=null,this._chipsWrap=null,this._input=null,this._tags=[],this._placeholder="Add tag",this._dragIndex=null,this._dragChip=null,this._isPointerDragging=!1,this._pointerMoveHandler=null,this._pointerUpHandler=null}static get observedAttributes(){return["tags","placeholder","sortable","label","info","error","error-message","name","id","required","loading"]}connectedCallback(){this._parseAttrs(),this._render(),this._pointerMoveHandler||(this._pointerMoveHandler=t=>this._onPointerMove(t),window.addEventListener("pointermove",this._pointerMoveHandler)),this._pointerUpHandler||(this._pointerUpHandler=t=>this._onPointerUp(t),window.addEventListener("pointerup",this._pointerUpHandler),window.addEventListener("pointercancel",this._pointerUpHandler))}attributeChangedCallback(t,e,i){if(e!==i){if(t==="error"||t==="error-message"){if(this._renderErrorState(),this._container){const s=this.hasError(),n=["flex","flex-wrap","items-center","gap-2","w-full","px-2","py-1.5","min-h-[2rem]","rounded-lg","border-2",s?"border-red-300 dark:border-red-300":"border-gray-200 dark:border-gray-700","bg-white","dark:bg-gray-800","focus-within:ring-2","focus-within:ring-offset-1",s?"focus-within:ring-red-400 dark:focus-within:ring-red-500":"focus-within:ring-gray-400 dark:focus-within:ring-gray-500","transition-colors","duration-200"];this._container.className=n.join(" ")}return}if(t==="loading"){this._parseAttrs(),this._render();return}this._parseAttrs(),this._render()}}set tags(t){this._tags=Array.isArray(t)?[...t]:[],this._syncAttr(),this._render()}get tags(){return[...this._tags]}_parseAttrs(){const t=this.getAttribute("tags");if(!t)return;try{const i=JSON.parse(t);Array.isArray(i)&&(this._tags=i)}catch(i){console.warn("mint-tags: failed to parse tags attribute",i)}const e=this.getAttribute("placeholder");e!==null&&(this._placeholder=e)}_syncAttr(){this.setAttribute("tags",JSON.stringify(this._tags))}getLabel(){return this.getAttribute("label")||""}getInfo(){return this.getAttribute("info")||""}hasError(){return this.hasAttribute("error")}getErrorMessage(){return this.getAttribute("error-message")||""}getName(){return this.getAttribute("name")||""}getId(){return this.getAttribute("id")||""}isRequired(){return this.hasAttribute("required")}isLoading(){return this.hasAttribute("loading")}_render(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline","block","w-full");const t=this.isLoading(),e=this.getLabel(),i=this.getInfo(),s=this.hasError(),n=this.getId()||`mint-tags-${Math.random().toString(36).substr(2,9)}`;if(this.getId()||this.setAttribute("id",n),this._container)this._input&&(this._input.placeholder=this._placeholder);else{this._container=document.createElement("div");const o=["flex","flex-wrap","items-center","gap-2","w-full","px-2","py-1","min-h-[2rem]","rounded-lg","border-2",s?"border-red-300 dark:border-red-300":"border-gray-200 dark:border-gray-700","bg-white","dark:bg-gray-800","focus-within:ring-2","focus-within:ring-offset-1",s?"focus-within:ring-red-400 dark:focus-within:ring-red-500":"focus-within:ring-gray-400 dark:focus-within:ring-gray-500","transition-colors","duration-200"];this._container.className=o.join(" "),this._chipsWrap=document.createElement("div"),this._chipsWrap.className="flex flex-wrap items-center gap-2",this._chipsWrap.addEventListener("dragover",c=>{this.hasAttribute("sortable")&&c.preventDefault()}),this._chipsWrap.addEventListener("drop",c=>{this.hasAttribute("sortable")&&c.preventDefault()}),this._input=document.createElement("input"),this._input.type="text",this._input.placeholder=this._placeholder,this._input.className=["min-w-[6rem]","flex-1","bg-transparent","border-none","outline-none","text-sm","text-gray-900","dark:text-gray-100","placeholder:text-gray-400","dark:placeholder:text-gray-500","p-1.5"].join(" "),this._input.addEventListener("keydown",c=>{c.key==="Enter"&&(c.preventDefault(),this._addFromInput())}),this._container.appendChild(this._chipsWrap),this.appendChild(this._container)}if(this._container){const o=["flex","flex-wrap","items-center","gap-2","w-full","px-2","py-1","min-h-[2rem]","rounded-lg","border-2",s?"border-red-300 dark:border-red-300":"border-gray-200 dark:border-gray-700","bg-white","dark:bg-gray-800","focus-within:ring-2","focus-within:ring-offset-1",s?"focus-within:ring-red-400 dark:focus-within:ring-red-500":"focus-within:ring-gray-400 dark:focus-within:ring-gray-500","transition-colors","duration-200"];this._container.className=o.join(" ")}let r=this.querySelector(".mint-tags-label-container");if(e){r||(r=document.createElement("div"),r.className="mint-tags-label-container mb-[.25rem]",this._container&&this._container.parentElement===this?this.insertBefore(r,this._container):this.insertBefore(r,this.firstChild));let o=r.querySelector(".mint-tags-label");e?(o||(o=document.createElement("label"),o.className="mint-tags-label text-sm font-medium text-gray-900 dark:text-gray-100 select-none",r.appendChild(o)),o.textContent=e,o.setAttribute("for",n)):o&&o.remove()}else r&&r.remove();let a=this.querySelector(".mint-tags-info");i?(a||(a=document.createElement("span"),a.className="mint-tags-info text-xs text-gray-500 dark:text-gray-400 select-none mt-1 block",this._container&&this._container.parentElement===this?this.insertBefore(a,this._container.nextSibling):this.appendChild(a)),a.textContent=i):a&&a.remove();const l=this.getName();l?(this.setAttribute("name",l),this._input&&(this._input.name=l,this._input.id=n)):(this.removeAttribute("name"),this._input&&(this._input.removeAttribute("name"),this._input.id=n)),this._wireInputBackspace(),this._renderChips(),this._renderErrorState(),this._renderSkeleton(t)}_renderSkeleton(t){const e=this._container;if(!e)return;e.classList.contains("relative")||e.classList.add("relative");let i=e.querySelector(".mint-tags-skeleton");t?(i||(i=document.createElement("div"),i.className="mint-tags-skeleton absolute inset-0 z-10 pointer-events-none rounded-lg bg-gray-200 dark:bg-gray-700 animate-pulse",e.appendChild(i)),i.style.display="block",this._chipsWrap&&(this._chipsWrap.style.visibility="hidden",this._chipsWrap.style.pointerEvents="none"),this._input&&(this._input.style.visibility="hidden",this._input.style.pointerEvents="none")):(i&&(i.style.display="none"),this._chipsWrap&&(this._chipsWrap.style.visibility="visible",this._chipsWrap.style.pointerEvents="auto"),this._input&&(this._input.style.visibility="visible",this._input.style.pointerEvents="auto"))}_renderErrorState(){const t=this.hasError(),e=this.getErrorMessage();let i=this.querySelector(".mint-tags-error");t&&e?(i||(i=document.createElement("div"),i.className="mint-tags-error mt-1 text-xs text-red-600 dark:text-red-400",this.appendChild(i)),i.textContent=e):i&&i.remove()}_renderChips(){if(!this._chipsWrap)return;this._chipsWrap.innerHTML="";let t=0;this._tags.forEach(e=>{const i=document.createElement("mint-chip");i.dataset.index=String(t++),i.dataset.value=e.value,i.draggable=this.hasAttribute("sortable"),i.draggable&&i.classList.add("cursor-move"),e.dismissable&&(i.setAttribute("dismissable",""),i.addEventListener("dismissed",()=>this._removeTag(e.value))),this._chipsWrap.appendChild(i);const s=i.querySelector("[data-mt-chip-text]");s&&(s.textContent=e.label||e.value),this._setupChipEvents(i,e),i.draggable&&(i.addEventListener("dragstart",n=>this._onDragStart(n,i)),i.addEventListener("dragover",n=>this._onDragOverChip(n,i)),i.addEventListener("drop",n=>this._onDrop(n)),i.addEventListener("dragend",()=>this._onDragEnd())),this.hasAttribute("sortable")&&i.addEventListener("pointerdown",n=>this._onPointerDown(n,i))}),this._input&&(this.hasAttribute("sortable")&&(this._input.addEventListener("dragover",e=>this._onDragOverInput(e)),this._input.addEventListener("drop",e=>this._onDrop(e)),this._input.addEventListener("dragend",()=>this._onDragEnd())),this._chipsWrap.appendChild(this._input))}_addFromInput(){if(!this._input)return;const t=this._input.value.trim();if(!t)return;if(this._tags.some(i=>i.value.toLowerCase()===t.toLowerCase())){this._input.value="";return}this._tags.push({value:t,label:t,dismissable:!0}),this._syncAttr(),this._renderChips(),this._emitChange(),this._input.value="",setTimeout(()=>{var i;(i=this._input)==null||i.focus()},10)}_removeTag(t){this._tags=this._tags.filter(e=>e.value!==t),this._syncAttr(),this._renderChips(),this._emitChange()}_emitChange(){this.dispatchEvent(new CustomEvent("tags-change",{bubbles:!0,composed:!0,detail:{tags:this.tags}}))}_focusLastChip(){var e;const t=(e=this._chipsWrap)==null?void 0:e.querySelectorAll("mint-chip");t&&t.length>0&&t[t.length-1].focus({preventScroll:!0})}_focusInput(){setTimeout(()=>{var t;(t=this._input)==null||t.focus({preventScroll:!0})},10)}_wireInputBackspace(){this._input&&this._input.addEventListener("keydown",t=>{var e;t.key==="Backspace"&&((e=this._input)==null?void 0:e.value)===""&&(t.preventDefault(),this._focusLastChip())})}_setupChipEvents(t,e){t.tabIndex=0,t.addEventListener("keydown",i=>{(i.key==="Backspace"||i.key==="Delete")&&e.dismissable&&(i.preventDefault(),this._removeTag(e.value),this._focusInput())})}_onDragStart(t,e){var i;this.hasAttribute("sortable")&&(this._dragChip=e,this._dragIndex=Number(e.dataset.index),(i=t.dataTransfer)==null||i.setData("text/plain",e.dataset.index||""),t.dataTransfer&&(t.dataTransfer.effectAllowed="move",t.dataTransfer.dropEffect="move"),e.classList.add("opacity-60"))}_reorderTags(t,e){if(t<0||e<0||t>=this._tags.length||e>=this._tags.length)return;const i=[...this._tags],[s]=i.splice(t,1);i.splice(e,0,s),this._tags=i,this._syncAttr(),this._renderChips(),this._emitChange()}_onDragOverInput(t){this.hasAttribute("sortable")&&(t.preventDefault(),t.dataTransfer&&(t.dataTransfer.dropEffect="move"),this._dragChip&&this._chipsWrap&&this._input&&this._chipsWrap.insertBefore(this._dragChip,this._input))}_onDragOverChip(t,e){if(!this.hasAttribute("sortable")||(t.preventDefault(),t.dataTransfer&&(t.dataTransfer.dropEffect="move"),!this._dragChip||!this._chipsWrap)||e===this._dragChip)return;const i=e.getBoundingClientRect(),s=t.clientX,n=i.left+i.width*.5;if(s<n){if(this._dragChip.nextSibling===e)return;this._chipsWrap.insertBefore(this._dragChip,e)}else{if(e.nextSibling===this._dragChip)return;const r=e.nextSibling;r?this._chipsWrap.insertBefore(this._dragChip,r):this._chipsWrap.appendChild(this._dragChip)}}_onDrop(t){this.hasAttribute("sortable")&&t.preventDefault()}_onDragEnd(){this._dragChip&&this._dragChip.classList.remove("opacity-60"),this._syncOrderFromDom(),this._dragChip=null,this._dragIndex=null}_syncOrderFromDom(){if(!this._chipsWrap)return;const t=Array.from(this._chipsWrap.querySelectorAll("mint-chip"));if(t.length===0)return;const e=[];t.forEach(i=>{const s=i.dataset.value;if(!s)return;const n=this._tags.find(r=>r.value===s);n&&e.push(n)}),e.length===this._tags.length&&(this._tags=e,this._syncAttr(),this._renderChips(),this._emitChange())}_onPointerDown(t,e){if(this.hasAttribute("sortable")&&t.pointerType!=="mouse"){this._isPointerDragging=!0,this._dragChip=e,this._dragIndex=Number(e.dataset.index);try{e.setPointerCapture(t.pointerId)}catch{}e.classList.add("opacity-60","select-none"),t.preventDefault()}}_onPointerMove(t){if(!this._isPointerDragging||!this._dragChip||!this._chipsWrap||t.pointerType==="mouse")return;const e=document.elementFromPoint(t.clientX,t.clientY);if(!e)return;const i=e.closest("mint-chip");if(i&&i!==this._dragChip){const s=i.getBoundingClientRect(),n=t.clientX,r=s.left+s.width*.5;if(n<r)this._dragChip.nextSibling!==i&&this._chipsWrap.insertBefore(this._dragChip,i);else if(i.nextSibling!==this._dragChip){const a=i.nextSibling;a?this._chipsWrap.insertBefore(this._dragChip,a):this._chipsWrap.appendChild(this._dragChip)}return}this._input&&e.closest("input")===this._input&&this._chipsWrap.insertBefore(this._dragChip,this._input)}_onPointerUp(t){if(this._isPointerDragging){if(this._isPointerDragging=!1,this._dragChip){try{this._dragChip.releasePointerCapture(t.pointerId)}catch{}this._dragChip.classList.remove("opacity-60","select-none")}this._syncOrderFromDom(),this._dragChip=null,this._dragIndex=null}}}customElements.get("mint-tags")||customElements.define("mint-tags",st);class rt extends HTMLElement{constructor(){super(...arguments),this._clickHandler=null,this._keydownHandler=null}connectedCallback(){this._render(),this._setupEventListeners()}disconnectedCallback(){this._cleanupEventListeners()}_render(){this.classList.add("transition-colors","duration-200","focus-visible:outline-none","focus-visible:ring-2","focus-visible:ring-offset-1","focus-visible:ring-gray-400","dark:focus-visible:ring-gray-500","rounded"),this.hasAttribute("disabled")?this.classList.add("cursor-not-allowed","opacity-50"):this.classList.add("cursor-pointer"),this.hasAttribute("role")||this.setAttribute("role","button"),this.hasAttribute("tabindex")||this.setAttribute("tabindex","0")}_setupEventListeners(){this._clickHandler=t=>{if(this.hasAttribute("disabled")){t.preventDefault(),t.stopPropagation();return}this._handleClick(t)},this._keydownHandler=t=>{if(t.key==="Enter"||t.key===" "){if(this.hasAttribute("disabled")){t.preventDefault(),t.stopPropagation();return}t.preventDefault(),this._handleClick(t)}},this.addEventListener("click",this._clickHandler),this.addEventListener("keydown",this._keydownHandler)}_cleanupEventListeners(){this._clickHandler&&(this.removeEventListener("click",this._clickHandler),this._clickHandler=null),this._keydownHandler&&(this.removeEventListener("keydown",this._keydownHandler),this._keydownHandler=null)}_handleClick(t){this.dispatchEvent(new CustomEvent("clickable-click",{bubbles:!0,composed:!0,detail:{originalEvent:t}}))}static get observedAttributes(){return["disabled"]}attributeChangedCallback(t,e,i){t==="disabled"&&(i!==null?(this.classList.remove("cursor-pointer"),this.classList.add("opacity-50","cursor-not-allowed"),this.setAttribute("aria-disabled","true")):(this.classList.remove("opacity-50","cursor-not-allowed"),this.classList.add("cursor-pointer"),this.removeAttribute("aria-disabled")))}}customElements.get("mint-clickable")||customElements.define("mint-clickable",rt);class nt extends HTMLElement{constructor(){super(),this._headingElement=null,this._iconElement=null,this._dismissButton=null,this._headerWrapper=null,this._bodyWrapper=null,this._dismissHandler=null}static get observedAttributes(){return["heading","dismissable","tone"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline","block"),this.render()}disconnectedCallback(){this._dismissButton&&this._dismissHandler&&this._dismissButton.removeEventListener("click",this._dismissHandler)}attributeChangedCallback(t,e,i){e!==i&&this.render()}getHeading(){return this.getAttribute("heading")||""}getTone(){const t=this.getAttribute("tone");return t==="info"||t==="success"||t==="warning"||t==="danger"?t:"info"}isDismissable(){return this.hasAttribute("dismissable")}getIconName(){switch(this.getTone()){case"info":return"info";case"success":return"success";case"warning":return"warning";case"danger":return"error";default:return"info"}}getIconColorClasses(){switch(this.getTone()){case"info":return"text-blue-600 dark:text-blue-400";case"success":return"text-green-600 dark:text-green-400";case"warning":return"text-yellow-600 dark:text-yellow-400";case"danger":return"text-red-600 dark:text-red-400";default:return"text-blue-600 dark:text-blue-400"}}getHeadingColorClasses(){return"text-gray-900 dark:text-gray-100"}getHeaderBackgroundClasses(){switch(this.getTone()){case"info":return"bg-blue-100 dark:bg-blue-900/30";case"success":return"bg-green-100 dark:bg-green-900/30";case"warning":return"bg-yellow-100 dark:bg-yellow-900/30";case"danger":return"bg-red-100 dark:bg-red-900/30";default:return"bg-blue-100 dark:bg-blue-900/30"}}getBorderClasses(){switch(this.getTone()){case"info":return"border-blue-200 dark:border-blue-800";case"success":return"border-green-200 dark:border-green-800";case"warning":return"border-yellow-200 dark:border-yellow-800";case"danger":return"border-red-200 dark:border-red-800";default:return"border-blue-200 dark:border-blue-800"}}getAriaLive(){return this.getTone()==="danger"?"assertive":"polite"}render(){const t=this.getTone(),e=this.getHeading(),i=this.isDismissable();this.className=`box-border m-0 p-0 border-0 align-baseline block rounded-lg border shadow-sm overflow-hidden transition-colors duration-200 ${this.getBorderClasses()}`;const s=this.getAriaLive();this.setAttribute("role","alert"),this.setAttribute("aria-live",s),t==="danger"?this.setAttribute("aria-atomic","true"):this.removeAttribute("aria-atomic");const n=[];for(this._bodyWrapper?Array.from(this._bodyWrapper.childNodes).forEach(a=>{n.push(a)}):Array.from(this.childNodes).forEach(r=>{r!==this._headerWrapper&&r!==this._bodyWrapper&&r!==this._iconElement&&r!==this._headingElement&&r!==this._dismissButton&&n.push(r)}),this._dismissButton&&this._dismissHandler&&this._dismissButton.removeEventListener("click",this._dismissHandler);this.firstChild;)this.removeChild(this.firstChild);if(this._headerWrapper=null,this._bodyWrapper=null,this._iconElement=null,this._headingElement=null,this._dismissButton=null,this._headerWrapper=document.createElement("div"),this._headerWrapper.className=`px-4 py-3 flex items-center gap-3 ${this.getHeaderBackgroundClasses()}`,this._iconElement=document.createElement("mint-icon"),this._iconElement.setAttribute("name",this.getIconName()),this._iconElement.className=`flex-shrink-0 w-5 h-5 ${this.getIconColorClasses()}`,this._headerWrapper.appendChild(this._iconElement),this._headingElement=document.createElement("mint-text"),this._headingElement.className=`font-semibold flex-1 ${this.getHeadingColorClasses()}`,this._headingElement.textContent=e||"",this._headerWrapper.appendChild(this._headingElement),i){this._dismissButton=document.createElement("button"),this._dismissButton.className="flex-shrink-0 p-1 rounded hover:bg-black/10 dark:hover:bg-white/10 transition-colors",this._dismissButton.setAttribute("aria-label","Dismiss alert"),this._dismissButton.setAttribute("type","button");const r=document.createElement("mint-icon");r.setAttribute("name","close"),r.className="w-4 h-4 text-gray-700 dark:text-gray-300",this._dismissButton.appendChild(r),this._dismissHandler=a=>{a.preventDefault(),a.stopPropagation(),this.dispatchEvent(new CustomEvent("dismissed",{bubbles:!0,composed:!0})),this.remove()},this._dismissButton.addEventListener("click",this._dismissHandler),this._headerWrapper.appendChild(this._dismissButton)}this._bodyWrapper=document.createElement("div"),this._bodyWrapper.className="px-4 py-3 bg-white dark:bg-gray-800",n.forEach(r=>{this._bodyWrapper.appendChild(r)}),this.appendChild(this._headerWrapper),this.appendChild(this._bodyWrapper)}}customElements.get("mint-alert")||customElements.define("mint-alert",nt);class at extends HTMLElement{constructor(){super(),this._configuration=null,this._rows=[],this._search="",this._currentPage=1,this._perPage=15,this._totalRows=0,this._lastPage=0,this._offset=0,this._rowsToShow=15,this._loaded=!1,this._fetching=!1,this._loading=!1,this._fetchError=null,this._searching=!1,this._sorting=!1,this._sortingColumn=null,this._type="provided",this._searchTimeoutId=null,this._searchColumns=[],this._exportColumns={},this._columns=[],this._tableId="",this._searchInput=null,this._tableContainer=null,this._paginationContainer=null,this._skeletonContainer=null,this._inMintCard=!1}static get observedAttributes(){return["configuration"]}get inMintCard(){return this._inMintCard}get configuration(){return this._configuration}set configuration(t){t&&typeof t=="object"&&!Array.isArray(t)?(this._configuration=t,this._tableId=this._configuration.id||`mint-resource-table-${Date.now()}`,this._perPage=this._configuration.perPage||15,this._rowsToShow=this._perPage,this._type=typeof this._configuration.data=="string"?"ajax":"provided",this._loaded=!1,this._currentPage=1,this._offset=0,this._type==="provided"&&Array.isArray(this._configuration.data)&&(this._rows=[...this._configuration.data],this._totalRows=this._configuration.data.length),this._initializeColumns(),this._loadColumnVisibility(),this.isConnected&&this.render()):t==null?this._configuration=null:this._parseConfiguration()}connectedCallback(){var t,e;this.classList.add("box-border","m-0","p-0","border-0","align-baseline","block","w-full"),this._inMintCard=((e=(t=this.parentElement)==null?void 0:t.tagName)==null?void 0:e.toLowerCase())==="mint-card",this._configuration||this._parseConfiguration(),this._initializeColumns(),this._loadColumnVisibility(),this._attachRowClickHandler(),this.render()}disconnectedCallback(){this._searchTimeoutId&&clearTimeout(this._searchTimeoutId),this._rowClickHandler&&(this.removeEventListener("click",this._rowClickHandler,!0),this._rowClickHandler=null),this._scrollHandler&&(window.removeEventListener("scroll",this._scrollHandler),this._scrollHandler=null)}attributeChangedCallback(t,e,i){t==="configuration"&&e!==i&&(!this._configuration||typeof i=="string")&&(this._parseConfiguration(),this.render())}_parseConfiguration(){const t=this.getAttribute("configuration");if(!t){console.error("mint-resource-table: configuration attribute is required");return}try{this._configuration=JSON.parse(t),this._tableId=this._configuration.id||`mint-resource-table-${Date.now()}`,this._perPage=this._configuration.perPage||15,this._rowsToShow=this._perPage,this._type=typeof this._configuration.data=="string"?"ajax":"provided",this._loaded=!1,this._currentPage=1,this._offset=0,this._type==="provided"&&Array.isArray(this._configuration.data)&&(this._rows=[...this._configuration.data],this._totalRows=this._configuration.data.length),this._initializeColumns(),this._loadColumnVisibility()}catch(e){console.error("mint-resource-table: Invalid configuration JSON",e)}}_getColumnVisibilityStorageKey(){return`mrtc-${this._tableId}`}_saveColumnVisibility(){if(!this._configuration)return;const t={};this._configuration.columns.forEach((e,i)=>{t[i]=e.hidden||!1});try{localStorage.setItem(this._getColumnVisibilityStorageKey(),JSON.stringify(t))}catch(e){console.warn("Failed to save column visibility to localStorage:",e)}}_loadColumnVisibility(){if(this._configuration)try{const t=localStorage.getItem(this._getColumnVisibilityStorageKey());if(t){const e=JSON.parse(t);this._configuration.columns.forEach((i,s)=>{e[s]!==void 0&&(i.hidden=e[s])})}}catch(t){console.warn("Failed to load column visibility from localStorage:",t)}}_initializeColumns(){this._configuration&&(this._searchColumns=[],this._exportColumns={},this._columns=[],this._configuration.columns.forEach(t=>{t.searchable&&t.data&&this._searchColumns.push(t.data),t.export&&t.data&&(this._exportColumns[t.data]=t.label),t.data&&this._columns.push(t.data)}),this._configuration.sortBy||(this._configuration.sortBy="id"),this._configuration.sort||(this._configuration.sort="asc"))}async _fetchData(t,e=!0,i,s){var l,o,c,d,p,h,m,f;if(!this._configuration)return;const n=t||(typeof this._configuration.data=="string"?this._configuration.data:null);if(!n||this._fetching||this._loading)return;e&&(this._fetching=!0,this.render()),this._loading=!0;const r=i||this._perPage,a=s!==void 0?s:this._offset;try{const u=new URLSearchParams({perPage:r.toString(),offset:a.toString(),search:this._search,sortBy:this._configuration.sortBy||"id",sort:this._configuration.sort||"asc",searchColumns:this._searchColumns.join(","),columns:this._columns.join(",")}),_={};this._configuration.headers&&(_.headers=this._configuration.headers);const g=await fetch(`${n}?${u.toString()}`,_);if(!g.ok)throw new Error(`HTTP error! status: ${g.status}`);const b=await g.json(),k=((l=b.content)==null?void 0:l.rows)||[],x=((o=b.content)==null?void 0:o.total)||0;if(this._configuration.loadMore&&a!==0)this._rows=this._rows.concat(k);else{let w=k;this._configuration.predefinedData?(w=[...this._configuration.predefinedData,...k],this._totalRows=x+this._configuration.predefinedData.length):this._totalRows=x,this._rows=w}const E=Math.floor(a/r)+1;this._configuration.loadMore||(((c=b.content)==null?void 0:c.current_page)!==void 0&&b.content.current_page===E?this._currentPage=b.content.current_page:this._currentPage=E,this._offset=(this._currentPage-1)*r),this._lastPage=((d=b.content)==null?void 0:d.last_page)||1,this._fetching=!1,this._loaded=!0,this._loading=!1,this._fetchError=null,this._searching=!1;const v=this._sorting;if(v&&this._updateSortIcons(),this._sorting=!1,this._sortingColumn=null,v&&this._updateSortIcons(),this.dispatchEvent(new CustomEvent("loaded",{detail:{rows:this._rows}})),this._updateSearchIcon(),(h=(p=this.querySelector(`#${this._tableId}`))==null?void 0:p.closest("table"))==null?void 0:h.querySelector("tbody")){if(v){const w=this._loading,A=this._fetching;this._loading=!1,this._fetching=!1,this._updateTableBody(),this._loading=w,this._fetching=A}else this._updateTableBody();this._updatePagination()}else this.render()}catch(u){this._fetching=!1,this._loading=!1,this._loaded=!0,this._searching=!1,this._fetchError=u instanceof Error?u.message:"Failed to fetch data",console.error("mint-resource-table: Error fetching data",u),this._updateSearchIcon(),((f=(m=this.querySelector(`#${this._tableId}`))==null?void 0:m.closest("table"))==null?void 0:f.querySelector("tbody"))?(this._updateTableBody(),this._updatePagination()):this.render()}}_getRows(){if(!this._configuration)return[];if(this._type==="ajax")return this._rows;let t=[...this._rows];const e=this._configuration.sortBy||"id",i=this._configuration.sort||"asc";if(this._search){const s=this._search.toLowerCase().trim().split(/\s+/);t=t.filter(n=>{const r=Object.values(n).map(a=>String(a).toLowerCase()).join(" ");return s.every(a=>r.includes(a))})}if(t.sort((s,n)=>{const r=s[e],a=n[e];if(r==null&&a==null)return 0;if(r==null)return 1;if(a==null)return-1;const l=typeof r=="number"?r:typeof r=="string"&&!isNaN(Number(r))&&r.trim()!==""?Number(r):null,o=typeof a=="number"?a:typeof a=="string"&&!isNaN(Number(a))&&a.trim()!==""?Number(a):null;if(l!==null&&o!==null){const h=l-o;return i==="asc"?h:-h}const c=r instanceof Date?r:typeof r=="string"?new Date(r):null,d=a instanceof Date?a:typeof a=="string"?new Date(a):null;if(c&&d&&!isNaN(c.getTime())&&!isNaN(d.getTime())){const h=c.getTime()-d.getTime();return i==="asc"?h:-h}const p=String(r).localeCompare(String(a),void 0,{numeric:!0,sensitivity:"base"});return i==="asc"?p:-p}),this._perPage){const s=Math.ceil(t.length/this._perPage);this._lastPage=s,t.forEach((n,r)=>{n.page=Math.ceil((r+1)/this._perPage)}),this._currentPage>s&&s>0&&(this._currentPage=s)}return this._configuration.loadMore?t.slice(0,this._rowsToShow):t.filter(s=>!this._perPage||s.page===this._currentPage)}_toggleSort(t){var i;if(!this._configuration||!t.data||!t.sortable)return;let e=this._configuration.sort||"asc";((i=this._configuration.sortBy)==null?void 0:i.toLowerCase())===t.data.toLowerCase()&&(e=e==="desc"?"asc":"desc"),this._configuration.sort=e,this._configuration.sortBy=t.data,this._sorting=!0,this._sortingColumn=t,this._type==="ajax"?(this._updateSortIcons(),this._offset=0,this._currentPage=1,this._configuration.loadMore&&(this._rowsToShow=this._perPage),this._fetching=!1,this._loading=!1,this._configuration.loadMore?this._fetchData(void 0,!1,this._perPage,0):this._fetchData(void 0,!1,this._perPage,0)):(this._currentPage=1,this._sorting=!1,this._sortingColumn=null,this.render())}_getSortClass(t){var e,i,s,n,r;return this._sorting&&this._sortingColumn===t?"spinner":((i=(e=this._configuration)==null?void 0:e.sortBy)==null?void 0:i.toLowerCase())===((s=t.data)==null?void 0:s.toLowerCase())?((r=(n=this._configuration)==null?void 0:n.sort)==null?void 0:r.toLowerCase())==="desc"?"caret-down":"caret-up":""}_updateSortIcons(){this._configuration&&this._configuration.columns.forEach((t,e)=>{if(!t.sortable||t.hidden)return;const i=this.querySelector(`th[data-column-key="${e}"]`);if(!i)return;const s=i.querySelector(".ml-2.flex.items-center");if(!s)return;const n=s.querySelector("mint-icon"),r=s.querySelector("mint-spinner"),a=this._getSortClass(t);if(a==="spinner"){if(n&&n.remove(),!r){const l=document.createElement("mint-spinner");l.className="w-4 h-4",s.appendChild(l)}}else if(r&&r.remove(),n)n.setAttribute("name",a),n.className=`w-4 h-4 ${a==="sort-arrows"?"text-gray-400":""}`;else{const l=document.createElement("mint-icon");l.setAttribute("name",a),l.className=`w-4 h-4 ${a==="sort-arrows"?"text-gray-400":""}`,s.appendChild(l)}})}_showFetchingState(){}_triggerSearch(){this._searchTimeoutId&&clearTimeout(this._searchTimeoutId),this._searching=!0,this._type==="ajax"&&this._updateSearchIcon(),this._type!=="ajax"&&(this._currentPage=1),this._updateTableBody(),this._type!=="ajax"&&this._updatePagination(),this._searchTimeoutId=window.setTimeout(()=>{this._type==="ajax"?(this._offset=0,this._fetchData(void 0,!1,this._perPage,0)):this._searching=!1},400)}_updateSearchIcon(){const t=this.querySelector(`#search-${this._tableId}`);if(!t)return;const e=this._type==="ajax"&&(this._searching||this._fetching);setTimeout(()=>{const i=t.querySelector(".relative")||t.querySelector("div");if(!i)return;const s=i.querySelector("mint-icon"),n=i.querySelector("mint-spinner");if(e){if(s&&!n){const r=document.createElement("mint-spinner");r.className="absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 pointer-events-none",s.replaceWith(r)}else if(!s&&!n){const r=document.createElement("mint-spinner");r.className="absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 pointer-events-none",i.appendChild(r)}}else if(n){t.getAttribute("icon")||t.setAttribute("icon","search");const r=document.createElement("mint-icon");r.setAttribute("name","search"),r.className="absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400 dark:text-gray-500 pointer-events-none",n.replaceWith(r)}},0)}_updateTableBody(){var a,l;if(!this._configuration)return;const t=this._getRows(),e=(l=(a=this.querySelector(`#${this._tableId}`))==null?void 0:a.closest("table"))==null?void 0:l.querySelector("tbody");if(!e){this.render();return}const i=this.querySelector(`#search-${this._tableId}`),s=document.activeElement===i||(i==null?void 0:i.querySelector("input"))===document.activeElement,n=this._search;let r="";if(!((this._fetching||this._loading)&&!this._sorting)&&(t.forEach((o,c)=>{const d=typeof this._configuration.onRowClick=="function",p=d?"cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors":"";r+=`<tr data-row-index="${c}" ${d?'data-row-clickable="true"':""}${p?` class="${p}"`:""}>`,this._configuration.columns.forEach((h,m)=>{if(h.hidden)return;const f=!h.show||h.show(this,o);if(r+=`<td style="${this._getStyle(h)}" class="${this._getClasses(h,!0)}">`,f)if(h.raw)if(h.action)(!h.action.show||h.action.show(this,o))&&(r+=`<mint-button variant="solid" data-action="column-action" data-row-index="${c}" data-column-key="${this._configuration.columns.indexOf(h)}">${h.action.label}</mint-button>`);else if(h.actions)if(h.actionStyle!=="buttons"){const u=`actions-popover-${this._tableId}-${c}`,_=`actions-button-${this._tableId}-${c}`;r+=`<mint-button id="${_}" variant="link" icon="ellipsis">`,r+="</mint-button>",r+=`<mint-popover id="${u}" trigger-id="${_}" direction="down">`,h.actions.forEach((g,b)=>{if(!g.show||g.show(this,o)){const k=typeof g.label=="function"?g.label(this,o):g.label;r+=`<div class="p-2 cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-700" data-action="row-action" data-row-index="${c}" data-action-index="${b}" data-column-key="${this._configuration.columns.indexOf(h)}">${k}</div>`}}),r+="</mint-popover>"}else h.actions.forEach((u,_)=>{if(!u.show||u.show(this,o)){const g=u.label?typeof u.label=="function"?u.label(this,o):u.label:"",b=u.icon?` icon="${this._escapeHtml(u.icon)}"`:"",k=u.tone?` tone="${this._escapeHtml(u.tone)}"`:"";r+=`<mint-button variant="link" class="${u.classes||""}" data-action="row-action" data-row-index="${c}" data-action-index="${_}" data-column-key="${this._configuration.columns.indexOf(h)}"${b}${k}>`,g&&(r+=this._escapeHtml(String(g))),r+="</mint-button>"}});else typeof h.format=="function"?r+=h.format(this,o):h.data&&(r+=this._escapeHtml(String(o[h.data]||"")));else if(h.action){if(!h.action.show||h.action.show(this,o)){const u=typeof h.action.label=="function"?h.action.label(this,o):h.action.label;r+=`<mint-button variant="solid" data-action="column-action" data-row-index="${c}" data-column-key="${this._configuration.columns.indexOf(h)}">${this._escapeHtml(String(u))}</mint-button>`}}else if(h.actions)if(h.actionStyle!=="buttons"){const u=`actions-popover-${this._tableId}-${c}`,_=`actions-button-${this._tableId}-${c}`;r+=`<mint-button id="${_}" variant="link" icon="ellipsis">`,r+="</mint-button>",r+=`<mint-popover id="${u}" trigger-id="${_}" direction="down">`,h.actions.forEach((g,b)=>{if(!g.show||g.show(this,o)){const k=typeof g.label=="function"?g.label(this,o):g.label;r+=`<div class="p-2 cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-700" data-action="row-action" data-row-index="${c}" data-action-index="${b}" data-column-key="${this._configuration.columns.indexOf(h)}">${k}</div>`}}),r+="</mint-popover>"}else h.actions.forEach((u,_)=>{if(!u.show||u.show(this,o)){const g=u.label?typeof u.label=="function"?u.label(this,o):u.label:"",b=u.icon?` icon="${this._escapeHtml(u.icon)}"`:"",k=u.tone?` tone="${this._escapeHtml(u.tone)}"`:"";r+=`<mint-button variant="link" class="${u.classes||""}" data-action="row-action" data-row-index="${c}" data-action-index="${_}" data-column-key="${this._configuration.columns.indexOf(h)}"${b}${k}>`,g&&(r+=this._escapeHtml(String(g))),r+="</mint-button>"}});else typeof h.format=="function"?r+=this._escapeHtml(h.format(this,o)):h.data&&(r+=this._escapeHtml(String(o[h.data]||"")));r+="</td>"}),r+="</tr>"}),t.length===0&&(this._fetchError?r+=`<tr><td colspan="${this._configuration.columns.filter(o=>!o.hidden).length}" class="text-center py-8 text-red-500 dark:text-red-400">Failed to load data: ${this._escapeHtml(this._fetchError)}</td></tr>`:r+=`<tr><td colspan="${this._configuration.columns.filter(o=>!o.hidden).length}" class="text-center py-8">No records found.</td></tr>`),e.innerHTML=r,this._attachTableEventListeners(),this._attachRowClickHandler(),s&&i)){const o=i.querySelector("input")||i._element;o?(o.value=n,setTimeout(()=>{o.focus(),o.setSelectionRange(n.length,n.length)},0)):i.value!==void 0&&(i.value=n,setTimeout(()=>{i.focus()},0))}}_updatePagination(){var s,n;if(!this._configuration)return;const t=this._lastPage||Math.ceil(this._rows.length/this._perPage);if(!this._configuration.perPage||this._configuration.loadMore||t<=1){const r=(s=this.querySelector("nav"))==null?void 0:s.closest(".flex.justify-end");r&&r.remove();return}let e=(n=this.querySelector("nav"))==null?void 0:n.closest(".flex.justify-end");if(!e){const r=this.querySelector("mint-table");if(!r){this.render();return}e=document.createElement("div"),e.className="flex justify-end "+(this._inMintCard?"p-3.5":"mt-4"),r.insertAdjacentElement("afterend",e)}let i="<nav>";i+='<ul class="flex gap-1">',i+=`<li><mint-button variant="solid" size="sm" icon="caret-left" ${this._currentPage===1?'disabled="true"':""} data-action="page-prev"></mint-button></li>`;for(let r=1;r<=Math.min(2,t);r++){const l=this._currentPage===r?' disabled="true"':"";i+=`<li><mint-button variant="solid" size="sm"${l} data-action="page" data-page="${r}">${r}</mint-button></li>`}if(t>2&&(i+='<li><span class="px-2">...</span></li>'),this._currentPage>2&&this._currentPage<t-1&&(i+=`<li><mint-button variant="solid" size="sm" data-action="page" data-page="${this._currentPage-1}">${this._currentPage-1}</mint-button></li>`,i+=`<li><mint-button variant="solid" size="sm" disabled="true" data-action="page" data-page="${this._currentPage}">${this._currentPage}</mint-button></li>`,i+=`<li><mint-button variant="solid" size="sm" data-action="page" data-page="${this._currentPage+1}">${this._currentPage+1}</mint-button></li>`),t>2)for(let r=Math.max(t-1,this._currentPage+2);r<=t;r++){const l=this._currentPage===r?' disabled="true"':"";i+=`<li><mint-button variant="solid" size="sm"${l} data-action="page" data-page="${r}">${r}</mint-button></li>`}i+=`<li><mint-button variant="solid" size="sm" icon="caret-right" ${this._currentPage>=t?'disabled="true"':""} data-action="page-next"></mint-button></li>`,i+="</ul>",i+="</nav>",e.innerHTML=i,setTimeout(()=>{this._attachPaginationListeners(),e.querySelectorAll("mint-button[data-action]").forEach(r=>{"render"in r&&typeof r.render=="function"&&r.render()})},0)}_loadMore(){this._loading||this._fetching||!(this._type==="ajax"?this._lastPage>0&&this._currentPage<this._lastPage:this._totalRows>0&&this._rowsToShow<this._totalRows)||(this._offset+=this._perPage,this._currentPage+=1,this._rowsToShow+=this._perPage,this._type==="ajax"?this._fetchData():this.render())}_goToPage(t){const e=this._lastPage||Math.ceil(this._rows.length/this._perPage);t>e&&(t=e),t<1&&(t=1),this._currentPage=t,this._offset=(t-1)*this._perPage,this._type==="ajax"?this._fetchData():this.render()}_handleButtonClick(t){if(this._configuration)switch(t.type){case"export":break;case"print":window.print();break;case"csv":this._downloadCSV();break;default:t.onClick&&t.onClick(this);break}}_downloadCSV(){if(!this._configuration)return;const t=this.querySelector("table");if(!t)return;const e=t.querySelectorAll("tr");let i="data:text/csv;charset=utf-8,";e.forEach(r=>{const a=[];r.querySelectorAll("th, td").forEach(l=>{var c;const o=l.getAttribute("colspan");if(o)for(let d=0;d<parseInt(o)-1;d++)a.push("");a.push('"'+((c=l.textContent)==null?void 0:c.trim().replace(/"/g,'""'))+'"')}),i+=a.join(",")+`
|
|
142
|
+
`});const s=encodeURI(i),n=document.createElement("a");n.setAttribute("href",s),n.setAttribute("download",`${this._configuration.export_name||this._tableId}.csv`),document.body.appendChild(n),n.click(),document.body.removeChild(n)}_columnChange(t,e){const i=t.target.checked;e.hidden=!i,this._saveColumnVisibility();const s=`edit-columns-popover-${this._tableId}`,n=this.querySelector(`#${s}`),r=n==null?void 0:n.hasAttribute("open");this.render(),r&&n&&requestAnimationFrame(()=>{const a=this.querySelector(`#${s}`);a&&typeof a.open=="function"&&a.open()})}_getStyle(t){let e="";return(t.nowrap||t.actions)&&(e+="white-space: nowrap;"),t.offsetLeft&&(e+=`left: ${t.offsetLeft} !important;`),t.offsetRight&&(e+=`right: ${t.offsetRight} !important;`),t.width&&(e+=`min-width: ${t.width}px; max-width: ${t.width}px;`),e}_getClasses(t,e=!1){const i=[];return t.class&&i.push(t.class.trim()),t.sortable&&!e&&i.push("cursor-pointer"),t.stickLeft&&i.push("sticky-left"),t.stickRight&&i.push("sticky-right"),i.join(" ")}render(){if(!this._configuration){this.innerHTML='<div class="p-4 text-red-500">Error: Invalid configuration</div>';return}const t=!this._loaded||this._rows.length>0||this._search.length>0||this._searching,e=this._getRows(),i=this._lastPage||Math.ceil(this._rows.length/this._perPage);let s="";if(t){if(s+='<div class="flex '+(this._inMintCard?"p-3.5":"mb-3")+'">',s+='<div class="flex-grow-1 flex-1">',s+='<div class="flex gap-2 items-center">',this._configuration.showSearch!==!1){const r=`search-${this._tableId}`;s+=`<mint-input id="${r}" type="search" label="" placeholder="Search..." class="flex-1" icon="search" value="${this._escapeHtml(this._search)}"></mint-input>`}if(this._configuration.buttons&&this._configuration.buttons.forEach(r=>{const a=r.icon?` icon="${this._escapeHtml(r.icon)}"`:"",l=r.tone?` tone="${this._escapeHtml(r.tone)}"`:"";s+=`<mint-button variant="solid" class="${r.class||""}" data-button-type="${r.type||"custom"}"${a}${l}>`,r.label&&(s+=this._escapeHtml(r.label)),s+="</mint-button>"}),s+="</div>",s+="</div>",this._configuration.editColumns!==!1&&this._configuration.columns.some(a=>!a.actions&&a.editable!==!1)){const a=`edit-columns-popover-${this._tableId}`,l=`edit-columns-button-${this._tableId}`;s+='<div class="ml-2">',s+=`<mint-button id="${l}" variant="solid" icon="edit"></mint-button>`,s+=`<mint-popover id="${a}" trigger-id="${l}" direction="down">`,this._configuration.columns.forEach(o=>{!o.actions&&o.editable!==!1&&(s+='<div class="p-2">',s+=`<mint-checkbox label="${o.label}" ${o.hidden?"":"checked"} data-column-key="${this._configuration.columns.indexOf(o)}"></mint-checkbox>`,s+="</div>")}),s+="</mint-popover>",s+="</div>"}s+="</div>"}if(this._type==="ajax"&&(!this._loaded||this._fetching||this._loading)&&!this._fetchError&&!this._sorting){s+='<div class="space-y-0 flex gap-2 flex-col"><div class="h-9 bg-gray-200 dark:bg-gray-700 border-b border-gray-200 dark:border-gray-700 animate-pulse"></div>';for(let r=0;r<3;r++)s+='<div class="h-9 bg-gray-200 dark:bg-gray-700 border-b border-gray-200 dark:border-gray-700 animate-pulse"></div>';if(s+="</div>",this._configuration.perPage&&!this._configuration.loadMore){if(!this._loaded)s+='<div class="flex justify-end '+(this._inMintCard?"p-3.5":"mt-4")+'">',s+="<nav>",s+='<ul class="flex gap-1">',s+='<li><div class="h-8 w-8 bg-gray-200 dark:bg-gray-700 rounded animate-pulse"></div></li>',s+='<li><div class="h-8 w-8 bg-gray-200 dark:bg-gray-700 rounded animate-pulse"></div></li>',s+='<li><div class="h-8 w-8 bg-gray-200 dark:bg-gray-700 rounded animate-pulse"></div></li>',s+='<li><div class="h-8 w-8 bg-gray-200 dark:bg-gray-700 rounded animate-pulse"></div></li>',s+="</ul>",s+="</nav>",s+="</div>";else if(i>1||this._lastPage>0){const r=this._lastPage>0?this._lastPage:i;if(r>1){s+='<div class="flex justify-end '+(this._inMintCard?"p-3.5":"mt-4")+'">',s+="<nav>",s+='<ul class="flex gap-1">',s+=`<li><mint-button variant="solid" size="sm" icon="caret-left" ${this._currentPage===1?'disabled="true"':""} data-action="page-prev"></mint-button></li>`;for(let a=1;a<=Math.min(2,r);a++){const o=this._currentPage===a?' disabled="true"':"";s+=`<li><mint-button variant="solid" size="sm"${o} data-action="page" data-page="${a}">${a}</mint-button></li>`}if(r>2&&(s+='<li><span class="px-2">...</span></li>'),this._currentPage>2&&this._currentPage<r-1&&(s+=`<li><mint-button variant="solid" size="sm" data-action="page" data-page="${this._currentPage-1}">${this._currentPage-1}</mint-button></li>`,s+=`<li><mint-button variant="solid" size="sm" disabled="true" data-action="page" data-page="${this._currentPage}">${this._currentPage}</mint-button></li>`,s+=`<li><mint-button variant="solid" size="sm" data-action="page" data-page="${this._currentPage+1}">${this._currentPage+1}</mint-button></li>`),r>2)for(let a=Math.max(r-1,this._currentPage+2);a<=r;a++){const o=this._currentPage===a?' disabled="true"':"";s+=`<li><mint-button variant="solid" size="sm"${o} data-action="page" data-page="${a}">${a}</mint-button></li>`}s+=`<li><mint-button variant="solid" size="sm" icon="caret-right" ${this._currentPage>=r?'disabled="true"':""} data-action="page-next"></mint-button></li>`,s+="</ul>",s+="</nav>",s+="</div>"}}}}else if(e.length>0||this._search.length>0||this._searching||this._fetchError){if(s+='<mint-table class="table-section'+(this._inMintCard?" rounded-t-none":"")+'">',s+=`<table id="${this._tableId}">`,s+="<thead><tr>",this._configuration.columns.forEach((r,a)=>{if(!r.hidden){if(s+=`<th width="${r.width||""}" style="${this._getStyle(r)}" class="${this._getClasses(r)}" data-column-key="${a}">`,r.showLabel!==!1){if(s+='<div class="flex items-center">',s+=`<div class="flex-1">${r.raw?r.label:this._escapeHtml(r.label)}</div>`,r.sortable){s+='<div class="ml-2 flex items-center">';const l=this._getSortClass(r);l==="spinner"?s+='<mint-spinner class="w-4 h-4"></mint-spinner>':s+=`<mint-icon name="${l}" class="w-4 h-4 ${l==="sort-arrows"?"text-gray-400":""}"></mint-icon>`,s+="</div>"}s+="</div>"}s+="</th>"}}),s+="</tr></thead>",s+="<tbody>",!this._fetching&&!this._loading&&e.forEach((r,a)=>{const l=typeof this._configuration.onRowClick=="function",o=l?"cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors":"";s+=`<tr data-row-index="${a}" ${l?'data-row-clickable="true"':""}${o?` class="${o}"`:""}>`,this._configuration.columns.forEach((c,d)=>{if(c.hidden)return;const p=!c.show||c.show(this,r);if(s+=`<td style="${this._getStyle(c)}" class="${this._getClasses(c,!0)}">`,p)if(c.raw)if(c.action){if(!c.action.show||c.action.show(this,r)){const h=typeof c.action.label=="function"?c.action.label(this,r):c.action.label;s+=`<mint-button variant="solid" data-action="column-action" data-row-index="${a}" data-column-key="${this._configuration.columns.indexOf(c)}">${this._escapeHtml(String(h))}</mint-button>`}}else if(c.actions)if(c.actionStyle!=="buttons"){const h=`actions-popover-${this._tableId}-${a}`,m=`actions-button-${this._tableId}-${a}`;s+=`<mint-button id="${m}" variant="link" icon="ellipsis">`,s+="</mint-button>",s+=`<mint-popover id="${h}" trigger-id="${m}" direction="down">`,c.actions.forEach((f,u)=>{if(!f.show||f.show(this,r)){const _=typeof f.label=="function"?f.label(this,r):f.label;s+=`<div class="p-2 cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-700" data-action="row-action" data-row-index="${a}" data-action-index="${u}" data-column-key="${this._configuration.columns.indexOf(c)}">${this._escapeHtml(String(_))}</div>`}}),s+="</mint-popover>"}else c.actions.forEach((h,m)=>{if(!h.show||h.show(this,r)){const f=h.label?typeof h.label=="function"?h.label(this,r):h.label:"",u=h.icon?` icon="${this._escapeHtml(h.icon)}"`:"",_=h.tone?` tone="${this._escapeHtml(h.tone)}"`:"";s+=`<mint-button variant="link" class="${h.classes||""}" data-action="row-action" data-row-index="${a}" data-action-index="${m}" data-column-key="${this._configuration.columns.indexOf(c)}"${u}${_}>`,f&&(s+=this._escapeHtml(String(f))),s+="</mint-button>"}});else typeof c.format=="function"?s+=c.format(this,r):c.data&&(s+=this._escapeHtml(String(r[c.data]||"")));else if(c.action)(!c.action.show||c.action.show(this,r))&&(s+=`<mint-button variant="solid" data-action="column-action" data-row-index="${a}" data-column-key="${this._configuration.columns.indexOf(c)}">${c.action.label}</mint-button>`);else if(c.actions)if(c.actionStyle!=="buttons"){const h=`actions-popover-${this._tableId}-${a}`,m=`actions-button-${this._tableId}-${a}`;s+=`<mint-button id="${m}" variant="link" icon="ellipsis">`,s+="</mint-button>",s+=`<mint-popover id="${h}" trigger-id="${m}" direction="down">`,c.actions.forEach((f,u)=>{if(!f.show||f.show(this,r)){const _=typeof f.label=="function"?f.label(this,r):f.label;s+=`<div class="p-2 cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-700" data-action="row-action" data-row-index="${a}" data-action-index="${u}" data-column-key="${this._configuration.columns.indexOf(c)}">${this._escapeHtml(String(_))}</div>`}}),s+="</mint-popover>"}else c.actions.forEach((h,m)=>{if(!h.show||h.show(this,r)){const f=h.label?typeof h.label=="function"?h.label(this,r):h.label:"",u=h.icon?` icon="${this._escapeHtml(h.icon)}"`:"",_=h.tone?` tone="${this._escapeHtml(h.tone)}"`:"";s+=`<mint-button variant="link" class="${h.classes||""}" data-action="row-action" data-row-index="${a}" data-action-index="${m}" data-column-key="${this._configuration.columns.indexOf(c)}"${u}${_}>`,f&&(s+=this._escapeHtml(String(f))),s+="</mint-button>"}});else typeof c.format=="function"?s+=this._escapeHtml(c.format(this,r)):c.data&&(s+=this._escapeHtml(String(r[c.data]||"")));s+="</td>"}),s+="</tr>"}),!this._fetching&&!this._loading&&e.length===0&&(this._fetchError?s+=`<tr><td colspan="${this._configuration.columns.filter(r=>!r.hidden).length}" class="text-center py-8 text-red-500 dark:text-red-400">Failed to load data: ${this._escapeHtml(this._fetchError)}</td></tr>`:s+=`<tr><td colspan="${this._configuration.columns.filter(r=>!r.hidden).length}" class="text-center py-8">No records found.</td></tr>`),s+="</tbody>",s+="</table>",this._configuration.loadMore&&(this._loading||this._fetching?(s+='<div class="flex justify-center '+(this._inMintCard?"p-3.5":"mt-4")+'">',s+="<mint-spinner></mint-spinner>",s+="</div>"):(this._type==="ajax"?this._lastPage>0&&this._currentPage<this._lastPage:this._totalRows>0&&this._rowsToShow<this._totalRows)&&(s+='<div class="flex justify-center '+(this._inMintCard?"p-3.5":"mt-4")+'">',s+='<mint-button variant="ghost" data-action="load-more">Load more</mint-button>',s+="</div>")),this._configuration.perPage&&!this._configuration.loadMore&&this._loaded&&i>1){s+='<div class="flex justify-end '+(this._inMintCard?"p-3.5":"mt-4")+'">',s+="<nav>",s+='<ul class="flex gap-1">',s+=`<li><mint-button variant="solid" size="sm" icon="caret-left" ${this._currentPage===1?'disabled="true"':""} data-action="page-prev"></mint-button></li>`;for(let r=1;r<=Math.min(2,i);r++){const l=this._currentPage===r?' disabled="true"':"";s+=`<li><mint-button variant="solid" size="sm"${l} data-action="page" data-page="${r}">${r}</mint-button></li>`}if(i>2&&(s+='<li><span class="px-2">...</span></li>'),this._currentPage>2&&this._currentPage<i-1&&(s+=`<li><mint-button variant="solid" size="sm" data-action="page" data-page="${this._currentPage-1}">${this._currentPage-1}</mint-button></li>`,s+=`<li><mint-button variant="solid" size="sm" disabled="true" data-action="page" data-page="${this._currentPage}">${this._currentPage}</mint-button></li>`,s+=`<li><mint-button variant="solid" size="sm" data-action="page" data-page="${this._currentPage+1}">${this._currentPage+1}</mint-button></li>`),i>2)for(let r=Math.max(i-1,this._currentPage+2);r<=i;r++){const l=this._currentPage===r?' disabled="true"':"";s+=`<li><mint-button variant="solid" size="sm"${l} data-action="page" data-page="${r}">${r}</mint-button></li>`}s+=`<li><mint-button variant="solid" size="sm" icon="caret-right" ${this._currentPage>=i?'disabled="true"':""} data-action="page-next"></mint-button></li>`,s+="</ul>",s+="</nav>",s+="</div>"}s+="</mint-table>"}else s+='<slot name="empty"></slot>';this.innerHTML=s,this.querySelectorAll("mint-button[data-action]").forEach(r=>{r.render&&r.render()}),this.querySelectorAll("mint-button[data-button-type]").forEach(r=>{r.render&&r.render()}),this._attachEventListeners(),this._type==="ajax"&&!this._loaded&&!this._fetching&&!this._loading&&this._fetchData()}_attachRowClickHandler(){this._rowClickHandler&&this.removeEventListener("click",this._rowClickHandler,!0);const t=e=>{var o;const i=e.target;if(i.tagName==="MINT-BUTTON"||i.tagName==="BUTTON"||i.closest("mint-button")||i.closest("button")||i.closest("mint-popover")||i.closest("[data-action]"))return;const s=i.closest('tr[data-row-clickable="true"]');if(!s)return;const n=s.getAttribute("data-row-index");if(!n)return;const r=parseInt(n),l=this._getRows()[r];!l||!((o=this._configuration)!=null&&o.onRowClick)||(this._configuration.onRowClick.length===1?this._configuration.onRowClick(l):this._configuration.onRowClick(this,l))};this.addEventListener("click",t,!0),this._rowClickHandler=t}_attachPaginationListeners(){this.querySelectorAll('[data-action="page"]').forEach(t=>{t.addEventListener("click",()=>{const e=parseInt(t.getAttribute("data-page")||"1");this._goToPage(e)})}),this.querySelectorAll('[data-action="page-prev"]').forEach(t=>{t.addEventListener("click",()=>{this._goToPage(this._currentPage-1)})}),this.querySelectorAll('[data-action="page-next"]').forEach(t=>{t.addEventListener("click",()=>{this._goToPage(this._currentPage+1)})})}_attachTableEventListeners(){this.querySelectorAll('[data-action="row-action"]').forEach(t=>{t.addEventListener("click",()=>{var l;const e=parseInt(t.getAttribute("data-row-index")||"0"),i=parseInt(t.getAttribute("data-action-index")||"0"),s=parseInt(t.getAttribute("data-column-key")||"0"),r=this._getRows()[e],a=(l=this._configuration)==null?void 0:l.columns[s];a&&a.actions&&a.actions[i]&&a.actions[i].onClick(this,r)})}),this.querySelectorAll('[data-action="column-action"]').forEach(t=>{t.addEventListener("click",()=>{var a;const e=parseInt(t.getAttribute("data-row-index")||"0"),i=parseInt(t.getAttribute("data-column-key")||"0"),n=this._getRows()[e],r=(a=this._configuration)==null?void 0:a.columns[i];r&&r.action&&r.action.onClick(this,n)})})}_attachEventListeners(){var e;const t=this.querySelector(`#search-${this._tableId}`);if(t){const i=t.querySelector("input")||t._element;i?i.addEventListener("input",s=>{this._search=s.target.value,this._triggerSearch()}):t.addEventListener("input",s=>{this._search=t.value||s.target.value||"",this._triggerSearch()})}if(this._attachTableEventListeners(),this._attachRowClickHandler(),this.querySelectorAll("th[data-column-key]").forEach(i=>{i.addEventListener("click",()=>{var r;const s=parseInt(i.getAttribute("data-column-key")||"0"),n=(r=this._configuration)==null?void 0:r.columns[s];n&&this._toggleSort(n)})}),this.querySelectorAll("[data-button-type]").forEach(i=>{i.addEventListener("click",()=>{var r,a;const s=i.getAttribute("data-button-type"),n=(a=(r=this._configuration)==null?void 0:r.buttons)==null?void 0:a.find(l=>(l.type||"custom")===s);n&&this._handleButtonClick(n)})}),this.querySelectorAll("mint-checkbox[data-column-key]").forEach(i=>{i.addEventListener("change",s=>{var a;s.stopPropagation();const n=parseInt(i.getAttribute("data-column-key")||"0"),r=(a=this._configuration)==null?void 0:a.columns[n];r&&this._columnChange(s,r)}),i.addEventListener("click",s=>{s.stopPropagation()})}),this._attachPaginationListeners(),this.querySelectorAll('[data-action="load-more"]').forEach(i=>{i.addEventListener("click",()=>{this._loadMore()})}),(e=this._configuration)!=null&&e.loadMore){this._scrollHandler&&window.removeEventListener("scroll",this._scrollHandler);const i=()=>{const s=window.pageYOffset||document.documentElement.scrollTop,n=window.innerHeight;if(document.documentElement.scrollHeight-s-n<=100){const a=this._type==="ajax"?this._lastPage>0&&this._currentPage<this._lastPage:this._totalRows>0&&this._rowsToShow<this._totalRows;!this._loading&&!this._fetching&&a&&this._loadMore()}};this._scrollHandler=i,window.addEventListener("scroll",i)}}_escapeHtml(t){const e=document.createElement("div");return e.textContent=t,e.innerHTML}}customElements.get("mint-resource-table")||customElements.define("mint-resource-table",at);exports.Alert=nt;exports.BackButton=W;exports.Button=P;exports.Card=z;exports.Checkbox=J;exports.Chip=it;exports.Choice=G;exports.Clickable=rt;exports.DatePicker=X;exports.Dropzone=Q;exports.Form=tt;exports.Grid=j;exports.Icon=q;exports.Input=K;exports.Link=R;exports.Modal=Y;exports.Page=V;exports.Popover=U;exports.ResourceTable=at;exports.Select=Z;exports.Spinner=F;exports.Stack=B;exports.Switch=$;exports.Table=et;exports.Tags=st;exports.Text=O;exports.default=P;
|