monobill-mintui 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +63 -18
- package/dist/components/table/Table.d.ts +13 -0
- package/dist/components/table/Table.d.ts.map +1 -0
- package/dist/components/table/index.d.ts +3 -0
- package/dist/components/table/index.d.ts.map +1 -0
- package/dist/index.cjs +2 -2
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +145 -69
- package/package.json +6 -2
package/dist/index.cjs
CHANGED
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
></animate>
|
|
42
42
|
</circle>
|
|
43
43
|
</svg>
|
|
44
|
-
`;this.innerHTML=o.trim()}}customElements.get("mint-spinner")||customElements.define("mint-spinner",P);const O=new Map;function q(x){O.set(x.name,x)}function ne(x){return O.get(x)}class B 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(e,t,i){t!==i&&this.render()}disconnectedCallback(){this._darkModeObserver&&(this._darkModeObserver.disconnect(),this._darkModeObserver=null)}_observeDarkMode(){this._darkModeObserver||(this._darkModeObserver=new MutationObserver(e=>{for(const t of e)if(t.type==="attributes"&&t.attributeName==="class"){this.render();break}}),this._darkModeObserver.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}))}getName(){return this.getAttribute("name")||""}getIconUrl(){var t;const e=document.documentElement.getAttribute("data-icon-base-url")||((t=document.querySelector('meta[name="icon-base-url"]'))==null?void 0:t.getAttribute("content"));return e?`${e}/${this.getName()}.svg`:`/icons/${this.getName()}.svg`}render(){var a,l;const e=this.getName();if(!e){this.innerHTML="",this.style.maskImage="",this.style.webkitMaskImage="";return}if(!ne(e)){console.warn(`Icon "${e}" not found. Make sure you've imported the icon: import '@monobill-mintui/icon/icons/${e}'`),this.innerHTML="",this.style.maskImage="",this.style.webkitMaskImage="";return}const i=this.closest("mint-button")||((a=this.parentElement)==null?void 0:a.closest("mint-button")),s=this.closest("mint-switch")||((l=this.parentElement)==null?void 0:l.closest("mint-switch"));let r;s?r="w-3 h-3":i?r="w-5 h-5":r="w-[1.3em] h-[1.3em]",this.classList.remove("w-4","h-4","w-5","h-5","w-[1em]","h-[1em]"),r.split(" ").forEach(o=>{o&&this.classList.add(o)});const n=this.getIconUrl();if(this.style.maskImage=`url(${n})`,this.style.webkitMaskImage=`url(${n})`,this.style.maskSize="contain",this.style.webkitMaskSize="contain",this.style.maskRepeat="no-repeat",this.style.webkitMaskRepeat="no-repeat",this.style.maskPosition="center",this.style.webkitMaskPosition="center",this.style.aspectRatio="1 / 1",this.style.backgroundColor="currentColor",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)}this.innerHTML=""}}customElements.get("mint-icon")||customElements.define("mint-icon",B);class F 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","full-width","icon-position","icon"]}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(e,t,i){t!==i&&this.render()}getVariant(){return this.getAttribute("variant")||"solid"}getTone(){return this.getAttribute("tone")||"neutral"}isDisabled(){return this.hasAttribute("disabled")}isLoading(){return this.hasAttribute("loading")}getType(){return(this.getAttribute("button-type")||"default")==="submit"?"submit":"button"}isFullWidth(){return this.hasAttribute("full-width")}getIconPosition(){return this.getAttribute("icon-position")||"left"}getIcon(){return this.getAttribute("icon")||""}isIconOnly(){var i,s,r,n,a;if(!(this.getIcon()||((i=this._button)==null?void 0:i.querySelector('[slot="icon"], .mint-button-icon, mint-icon'))))return!1;const t=(s=this._button)==null?void 0:s.querySelector(".mint-button-content");if(t&&((r=t.textContent)!=null&&r.trim()))return!1;if(this._button)for(let l=this._button.firstChild;l;l=l.nextSibling){if(l.nodeType===Node.TEXT_NODE&&((n=l.textContent)!=null&&n.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}getButtonClasses(){const e=this.isIconOnly(),t=this.getVariant(),i=["inline-flex","items-center","justify-center","font-medium","rounded-lg","box-border",...e?["p-1.5","aspect-square","w-[2rem]","h-[2rem]"]:["px-3.5","py-1.5","min-h-[2rem]"],"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(),r={"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"]},n=`${t}-${s}`,a=r[n]||r["solid-neutral"],l=[...i,...a];return this.isFullWidth()&&l.push("w-full"),l.join(" ")}render(){var h,c,d,u,f;const e=this.isDisabled()||this.isLoading(),t=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=t,this._button.disabled=e;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 _=document.createElement("span");_.className="mr-2 inline-flex items-center";const g=document.createElement("mint-spinner");g.setAttribute("size","default"),g.setAttribute("data-button-variant",this.getVariant()),g.setAttribute("data-button-tone",this.getTone()),g.style.width="0.875rem",g.style.height="0.875rem",_.appendChild(g),this._button.insertBefore(_,this._button.firstChild)}else i&&((h=i.parentElement)==null||h.remove());for(;this.firstChild&&this.firstChild!==this._button;)this._button.appendChild(this.firstChild);const s=this.getIcon();let r=this._button.querySelector('[slot="icon"], .mint-button-icon, mint-icon');s?(r&&r.tagName!=="MINT-ICON"&&(r.remove(),r=null),!r||r.tagName!=="MINT-ICON"?(r=document.createElement("mint-icon"),r.setAttribute("name",s),r.className="mint-button-icon"):r.setAttribute("name",s)):r&&r.tagName==="MINT-ICON"&&(r.remove(),r=null),r||(r=this._button.querySelector('[slot="icon"], .mint-button-icon'));const n=this.getIconPosition();let a=this._button.querySelector(".mint-button-content");if(a){const _=r&&r.tagName==="MINT-ICON";if(r&&!r.parentElement){const g=(u=this._button.querySelector("mint-spinner"))==null?void 0:u.parentElement;_||n==="left"?g?g.insertAdjacentElement("afterend",r):this._button.insertBefore(r,a):a.insertAdjacentElement("afterend",r)}else if(r&&(_||n==="left")&&r.nextSibling!==a){r.remove();const g=(f=this._button.querySelector("mint-spinner"))==null?void 0:f.parentElement;g?g.insertAdjacentElement("afterend",r):this._button.insertBefore(r,a)}else r&&!_&&n==="right"&&r.previousSibling!==a&&(r.remove(),a.insertAdjacentElement("afterend",r))}else{const _=[];for(let g=this._button.firstChild;g;g=g.nextSibling){if(g.nodeType!==Node.ELEMENT_NODE){_.push(g);continue}const m=g;m.tagName!=="MINT-SPINNER"&&!m.querySelector("mint-spinner")&&g!==r&&!m.hasAttribute("slot")&&!(m.className==="mr-2"&&m.querySelector("mint-spinner"))&&_.push(g)}if(_.length>0){a=document.createElement("span"),a.className="mint-button-content inline-flex items-center",_.forEach(m=>{a.appendChild(m)});const g=(c=this._button.querySelector("mint-spinner"))==null?void 0:c.parentElement;r&&n==="left"?g?(g.insertAdjacentElement("afterend",r),r.insertAdjacentElement("afterend",a)):(this._button.insertBefore(r,this._button.firstChild),r.insertAdjacentElement("afterend",a)):r&&n==="right"?g?(g.insertAdjacentElement("afterend",a),a.insertAdjacentElement("afterend",r)):(this._button.insertBefore(a,this._button.firstChild),a.insertAdjacentElement("afterend",r)):g?g.insertAdjacentElement("afterend",a):this._button.insertBefore(a,this._button.firstChild)}else if(r&&r.tagName==="MINT-ICON"&&!r.parentElement){const g=(d=this._button.querySelector("mint-spinner"))==null?void 0:d.parentElement;g?g.insertAdjacentElement("afterend",r):this._button.insertBefore(r,this._button.firstChild)}}const l=this.isIconOnly();r&&(r.classList.contains("mint-button-icon")||r.classList.add("mint-button-icon"),r.classList.remove("mr-1.5","ml-1.5"),l?r.tagName==="MINT-ICON"?(r.style.width="1rem",r.style.height="1rem",r.style.maxWidth="1rem",r.style.maxHeight="1rem",r.style.flexShrink="0"):(r.style.maxWidth="1rem",r.style.maxHeight="1rem",r.style.flexShrink="0",r.tagName==="svg"&&(r.style.width="1rem",r.style.height="1rem")):n==="left"?r.classList.add("mr-1.5"):r.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(e){if(this.isDisabled()||this.isLoading()){e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation();return}if(e.stopPropagation(),e.stopImmediatePropagation(),this._isHandlingClick){e.preventDefault();return}this._isHandlingClick=!0,e.preventDefault(),this.dispatchEvent(new CustomEvent("click",{detail:{originalEvent:e},bubbles:!0,cancelable:!0,composed:!0})),requestAnimationFrame(()=>{this._isHandlingClick=!1})}}customElements.get("mint-button")||customElements.define("mint-button",F);class z extends HTMLElement{constructor(){super(),this._button=null,this._checked=!1}static get observedAttributes(){return["checked","disabled","label","icon"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline","inline-block","flex","items-center"),this._checked=this.hasAttribute("checked"),this.render()}disconnectedCallback(){this.removeEventListeners()}attributeChangedCallback(e,t,i){e==="checked"&&(this._checked=i!==null),t!==i&&this.render()}get checked(){return this._checked}set checked(e){e?this.setAttribute("checked",""):this.removeAttribute("checked"),this._checked=!!e,this.render()}isDisabled(){return this.hasAttribute("disabled")}getLabel(){return this.getAttribute("label")||""}getIcon(){return this.getAttribute("icon")||""}hasIcon(){return!!this.getIcon()}getSwitchClasses(){const 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","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"],t=this._checked?["bg-slate-950","dark:bg-slate-600","border-slate-700","dark:border-slate-500"]:["bg-slate-200","dark:bg-slate-400","border-slate-300","dark:border-slate-500"];return[...e,...t].join(" ")}getThumbClasses(){const e=["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"],t=this._checked?"translate-x-5":"translate-x-0.5";return[...e,t].join(" ")}getIconClasses(){return["absolute","inset-0","flex","items-center","justify-center","pointer-events-none"].join(" ")}render(){const e=this.getSwitchClasses(),t=this.getThumbClasses(),i=this.getLabel(),s=this.getIcon();this._button||(this._button=document.createElement("button"),this.appendChild(this._button),this.setupEventListeners()),this._button.className=e,this._button.disabled=this.isDisabled(),this._button.setAttribute("aria-checked",String(this._checked)),this._button.setAttribute("aria-label",i),this._button.setAttribute("role","switch"),this._button.type="button";let r=this._button.querySelector("span");r||(r=document.createElement("span"),this._button.appendChild(r)),r.className=t;const n=r.querySelector("span");if(s){let a=n;a||(a=document.createElement("span"),a.className=this.getIconClasses(),r.appendChild(a));let l=a.querySelector("mint-icon");l||(l=document.createElement("mint-icon"),a.appendChild(l)),l.setAttribute("name",s)}else n&&n.remove()}setupEventListeners(){this._button&&this._button.addEventListener("click",this.handleToggle.bind(this))}removeEventListeners(){this._button&&this._button.removeEventListener("click",this.handleToggle.bind(this))}handleToggle(e){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})))}}customElements.get("mint-switch")||customElements.define("mint-switch",z);class V 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(t=>this._userClasses.add(t))}attributeChangedCallback(e,t,i){t!==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 e=this.getSize(),t=this.getVariant(),i=document.documentElement.classList.contains("dark"),s={heading:["font-semibold"],"sub-heading":["font-medium"],regular:[]},r={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"]},n=[];this.isBold()&&n.push("font-bold"),this.isUnderline()&&n.push("underline"),this.isStrike()&&n.push("line-through"),this.isItalic()&&n.push("italic");const a=this.getDisplay();return[a==="block"?"block":a==="inline"?"inline":"inline-block",...s[e]||s.regular,...r[t]||r.default,...n].join(" ")}render(){const e=this.getSize(),t=["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)}),t.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=>{!t.includes(o)&&!i.includes(o)&&this._userClasses.add(o)});const n=[...new Set([...s,...Array.from(this._userClasses)])];this.className=n.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[e]||a.regular;this.style.setProperty("font-size",l)}}customElements.get("mint-text")||customElements.define("mint-text",V);class R 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(e,t,i){t!==i&&(this.render(),e==="text-align"&&this._observeChildren())}_observeChildren(){this._childObserver||(this._childObserver=new MutationObserver(()=>{const e=this.getTextAlign();e&&this._applyTextAlignToChildren(e)}),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 e=this.getAttribute("gap")||"3";return parseFloat(e)}getTextAlign(){const e=this.getAttribute("text-align")||"";return["left","center","right","justify"].includes(e)?e:""}getStackClasses(){const e=this.getDirection(),t=this.getTextAlign(),i=this.getGap(),s=["flex",e==="horizontal"?"flex-row":"flex-col",`gap-${i}`];return t&&(s.push(`text-${t}`),s.push(`[&>*]:text-${t}`),s.push(`[&>*_.mint-button-content]:text-${t}`),t==="left"?(s.push("[&>mint-button]:!justify-start"),s.push("[&>mint-button>button]:!justify-start")):t==="right"?(s.push("[&>mint-button]:!justify-end"),s.push("[&>mint-button>button]:!justify-end")):t==="center"&&(s.push("[&>mint-button]:!justify-center"),s.push("[&>mint-button>button]:!justify-center"))),s.join(" ")}render(){const e=this.getStackClasses(),t=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(r=>this.classList.remove(r)),e.split(" ").forEach(r=>{r&&this.classList.add(r)}),["box-border","m-0","p-0","border-0","align-baseline","block"].forEach(r=>{this.classList.contains(r)||this.classList.add(r)}),t?this._applyTextAlignToChildren(t):this._removeTextAlignFromChildren()}_applyTextAlignToChildren(e){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"),e==="left"?s.classList.add("justify-start"):e==="right"?s.classList.add("justify-end"):e==="center"&&s.classList.add("justify-center");const r=s.querySelector(".mint-button-content");r&&(r.classList.remove("text-left","text-center","text-right","text-justify"),r.classList.add(`text-${e}`))}}else i.classList.remove("text-left","text-center","text-right","text-justify"),i.classList.add(`text-${e}`)})}_removeTextAlignFromChildren(){Array.from(this.children).forEach(t=>{if(t.tagName==="MINT-BUTTON"){const i=t.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 t.classList.remove("text-left","text-center","text-right","text-justify")})}}customElements.get("mint-stack")||customElements.define("mint-stack",R);class W extends HTMLElement{static get observedAttributes(){return[]}constructor(){super()}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline","block"),this.render()}attributeChangedCallback(e,t,i){t!==i&&this.render()}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")}}customElements.get("mint-card")||customElements.define("mint-card",W);class j 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(t=>{t.classList.contains("underline")||t.classList.add("underline")})}),this._contentObserver.observe(this,{childList:!0,subtree:!0}))}attributeChangedCallback(e,t,i){t!==i&&this.render()}getHref(){return this.getAttribute("href")||"#"}getTarget(){return this.getAttribute("target")||""}hasIcon(){var e;return!!(this.querySelector("mint-icon")||(e=this._link)!=null&&e.querySelector("mint-icon"))}render(){const e=this.getHref(),t=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=e,t?(this._link.target=t,t==="_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",j);class $ extends HTMLElement{constructor(){super(),this._button=null,this._historyDepth=0,this._maxBackAttempts=10,this._backAttempts=0,this._initialUrl="",this._initialOrigin="",this._popstateHandler=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(),this._setupHistoryTracking()}disconnectedCallback(){this._popstateHandler&&(window.removeEventListener("popstate",this._popstateHandler),this._popstateHandler=null)}attributeChangedCallback(e,t,i){t!==i&&this.render()}_setupHistoryTracking(){this._initialUrl=window.location.href,this._initialOrigin=window.location.origin,this._historyDepth=window.history.length,this._popstateHandler||(this._popstateHandler=e=>{this._backAttempts=0,setTimeout(()=>{const t=window.location.origin,i=window.location.href;if(t!==this._initialOrigin){this._navigateToFallback();return}if(i.startsWith("chrome://")||i.startsWith("about:")||i.startsWith("edge://")||i==="about:blank"||i==="about:newtab"){this._navigateToFallback();return}},0)},window.addEventListener("popstate",this._popstateHandler))}getFallbackHref(){return this.getAttribute("fallback-href")||this.getAttribute("href")||"/"}handleClick(e){if(e.preventDefault(),e.stopPropagation(),this._wouldBackLeaveApp()){this._navigateToFallback();return}if(window.history.length>1&&this._backAttempts<this._maxBackAttempts&&this._backAttempts===0){this._backAttempts++;const s=window.location.href,r=window.location.origin;window.history.back(),setTimeout(()=>{if(window.location.href===s)this._navigateToFallback();else{if(window.location.origin!==r){this._navigateToFallback();return}const n=window.location.href;if(n.startsWith("chrome://")||n.startsWith("about:")||n.startsWith("edge://")||n==="about:blank"||n==="about:newtab"){this._navigateToFallback();return}setTimeout(()=>{this._backAttempts=0},500)}},200)}else this._navigateToFallback()}_wouldBackLeaveApp(){const e=document.referrer,t=window.location.origin;if(window.history.length<=1||!e&&window.history.length<=2)return!0;if(e)try{if(new URL(e).origin!==t&&window.history.length<=2)return!0}catch{if(window.history.length<=2)return!0}return!1}_navigateToFallback(){var t,i,s;const e=this.getFallbackHref();if(this._backAttempts=0,e.startsWith("/")&&!e.startsWith("//")){const r=document.querySelector("#app");if((s=(i=(t=r==null?void 0:r.__vue_app__)==null?void 0:t.config)==null?void 0:i.globalProperties)!=null&&s.$router)try{r.__vue_app__.config.globalProperties.$router.push(e);return}catch{}try{window.history.pushState({},"",e),window.dispatchEvent(new PopStateEvent("popstate"));return}catch{}}window.location.href=e}render(){this._button||(this._button=document.createElement("mint-button"),this._button.setAttribute("variant","neutral"),this._button.setAttribute("icon","arrow-left"),this._button.addEventListener("click",e=>this.handleClick(e)),this.appendChild(this._button))}}customElements.get("mint-back-button")||customElements.define("mint-back-button",$);class Y 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}static get observedAttributes(){return["heading","fallback-href","show-back-button"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline","block"),this.render(),this._observeDarkMode()}disconnectedCallback(){this._darkModeObserver&&(this._darkModeObserver.disconnect(),this._darkModeObserver=null)}getHeading(){return this.getAttribute("heading")||""}getFallbackHref(){return this.getAttribute("fallback-href")||"/"}shouldShowBackButton(){return this.hasAttribute("show-back-button")}render(){const e=this.getHeading();this._pageContainer||(this._pageContainer=document.createElement("div"),this._pageContainer.className="min-h-screen p-8 transition-colors duration-200",this.appendChild(this._pageContainer)),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 t=this._titleElement.querySelector("mint-back-button");if(this.shouldShowBackButton()){t||(t=document.createElement("mint-back-button"),this._titleElement.insertBefore(t,this._titleElement.firstChild));const n=this.getFallbackHref();t.setAttribute("fallback-href",n)}else t&&(t.remove(),t=null);e?(this._headingText?(this._headingText.classList.add("truncate","min-w-0"),t&&t.parentElement===this._titleElement?this._headingText.previousSibling!==t&&this._titleElement.insertBefore(this._headingText,t.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"),t&&t.parentElement===this._titleElement?this._titleElement.insertBefore(this._headingText,t.nextSibling):this._titleElement.insertBefore(this._headingText,this._titleElement.firstChild)),this._headingText.textContent=e):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(n=>n!==this._pageContainer&&n!==this._actionsSlot&&n.getAttribute("slot")==="actions").forEach(n=>{n.parentElement!==this._actionsSlot&&this._actionsSlot.appendChild(n)}),this._bodySlot||(this._bodySlot=document.createElement("div"),this._pageContainer.appendChild(this._bodySlot)),Array.from(this.children).forEach(n=>{n!==this._pageContainer&&n.getAttribute("slot")!=="actions"&&n!==this._actionsSlot&&n!==this._header&&n!==this._bodySlot&&n!==this._headingText&&n.parentElement!==this._bodySlot&&n.parentElement!==this._pageContainer&&this._bodySlot.appendChild(n)}),this._updateBackgroundColor()}_updateBackgroundColor(){if(!this._pageContainer)return;document.documentElement.classList.contains("dark")?(this._pageContainer.classList.remove("bg-gray-50"),this._pageContainer.classList.add("bg-gray-900")):(this._pageContainer.classList.remove("bg-gray-900"),this._pageContainer.classList.add("bg-gray-50"))}_observeDarkMode(){this._darkModeObserver||(this._darkModeObserver=new MutationObserver(()=>{this._updateBackgroundColor()}),this._darkModeObserver.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}))}}customElements.get("mint-page")||customElements.define("mint-page",Y);class U 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(e,t,i){t!==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 e=["grid"],t=this.getColumns();e.push(`grid-cols-${t}`);const i=this.getSm();i&&e.push(`sm:grid-cols-${i}`);const s=this.getMd();s&&e.push(`md:grid-cols-${s}`);const r=this.getLg();r&&e.push(`lg:grid-cols-${r}`);const n=this.getXl();n&&e.push(`xl:grid-cols-${n}`);const a=this.getGap();return e.push(`gap-${a}`),e}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",U);const ae={name:"close",viewBox:"0 0 24 24",path:"M6 18L18 6M6 6l12 12",strokeLinecap:"round",strokeLinejoin:"round"};q(ae);class J 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(e,t,i){t!==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 e=this.getId(),t=this.getHeading(),i=this.isOpen();if(e&&(this.id=e),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 c=this._modal.querySelector(".modal-content");c||(c=document.createElement("div"),c.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(c)),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 r=this._headingSlot.querySelector("mint-text");t?(r||(r=document.createElement("mint-text"),r.setAttribute("size","sub-heading"),r.setAttribute("bold",""),this._headingSlot.appendChild(r)),r.textContent=t):r&&r.remove(),Array.from(this.children).filter(c=>c!==this._overlay&&c!==this._modal&&c!==this._headingSlot&&c.getAttribute("slot")==="heading").forEach(c=>{c.parentElement!==this._headingSlot&&this._headingSlot.appendChild(c)}),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(c=>c!==this._overlay&&c!==this._modal&&c!==this._bodySlot&&c.getAttribute("slot")==="body").forEach(c=>{c.parentElement!==this._bodySlot&&this._bodySlot.appendChild(c)}),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(c=>c!==this._overlay&&c!==this._modal&&c!==this._actionsSlot&&c.getAttribute("slot")==="actions").forEach(c=>{Array.from(c.children).forEach(u=>{u.parentElement!==l&&l.appendChild(u)}),c.parentElement&&c.remove()}),Array.from(this.children).forEach(c=>{c!==this._overlay&&c!==this._modal&&c.getAttribute("slot")!=="heading"&&c.getAttribute("slot")!=="body"&&c.getAttribute("slot")!=="actions"&&c!==this._headingSlot&&c!==this._bodySlot&&c!==this._actionsSlot&&c.parentElement!==this._bodySlot&&this._bodySlot.appendChild(c)}),this._updateBackgroundColor()}_updateBackgroundColor(){if(!this._modal)return;const e=document.documentElement.classList.contains("dark"),t=this._modal.querySelector(".modal-content");t&&(e?(t.classList.remove("bg-white"),t.classList.add("bg-gray-800")):(t.classList.remove("bg-gray-800"),t.classList.add("bg-white")))}_observeDarkMode(){this._darkModeObserver||(this._darkModeObserver=new MutationObserver(()=>{this._updateBackgroundColor()}),this._darkModeObserver.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}))}_animateEnter(){var t;const e=(t=this._modal)==null?void 0:t.querySelector(".modal-content");e&&(e.style.transform="scale(0.97) translateY(10px)",e.style.opacity="0",e.style.transition="all 200ms ease-out",this.classList.remove("hidden"),requestAnimationFrame(()=>{requestAnimationFrame(()=>{e.style.transform="scale(1) translateY(0)",e.style.opacity="1"})}))}_animateExit(){var t;const e=(t=this._modal)==null?void 0:t.querySelector(".modal-content");if(!e){this.classList.add("hidden");return}e.style.transition="all 200ms ease-in",e.style.transform="scale(0.97) translateY(10px)",e.style.opacity="0",setTimeout(()=>{this.classList.add("hidden"),e.style.transform="",e.style.opacity="",e.style.transition=""},200)}}customElements.get("mint-modal")||customElements.define("mint-modal",J);class G 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(e,t,i){t!==i&&(this.render(),(e==="trigger-id"||e==="hover")&&this._setupTrigger(),e==="open"&&this.isOpen()&&this._closeOtherPopovers())}getId(){return this.getAttribute("id")||""}getPadding(){const e=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"}[e]||"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 e=this.getTriggerId();this._triggerClickHandler&&this._triggerElement&&(this._triggerElement.removeEventListener("click",this._triggerClickHandler,!0),this._triggerClickHandler=null),this._removeHoverListeners(),e&&(this._triggerElement=document.getElementById(e),this._triggerElement?(this._attachTriggerListener(),this.isHoverEnabled()&&this._attachHoverListeners()):setTimeout(()=>{this._triggerElement=document.getElementById(e),this._triggerElement&&(this._attachTriggerListener(),this.isHoverEnabled()&&this._attachHoverListeners())},10))}_attachTriggerListener(){if(this._triggerElement&&!this._triggerClickHandler){const e=this;this._triggerClickHandler=function(t){t.stopImmediatePropagation(),t.preventDefault(),e.hasAttribute("open")?e.removeAttribute("open"):e.setAttribute("open","")},this._triggerElement.addEventListener("click",this._triggerClickHandler,!0)}}_attachHoverListeners(){if(!this.isHoverEnabled()||!this._triggerElement)return;this._removeHoverListeners();const e=this;this._triggerHoverEnterHandler=function(){e._cancelHoverClose(),e.open()},this._triggerHoverLeaveHandler=function(t){var s;const i=t.relatedTarget;i&&(e.contains(i)||(s=e._triggerElement)!=null&&s.contains(i))||e._scheduleHoverClose()},this._triggerElement.addEventListener("mouseenter",this._triggerHoverEnterHandler),this._triggerElement.addEventListener("mouseleave",this._triggerHoverLeaveHandler),this._popover&&(this._popoverHoverEnterHandler=function(){e._cancelHoverClose()},this._popoverHoverLeaveHandler=function(t){var s;const i=t.relatedTarget;i&&(e.contains(i)||(s=e._triggerElement)!=null&&s.contains(i))||e._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 e=this._triggerElement?this._triggerElement.matches(":hover"):!1,t=this._popover?this._popover.matches(":hover"):!1;return e||t}_calculatePosition(){if(!this._triggerElement||!this._popover)return{top:0,left:0,direction:"down"};const e=this._triggerElement.getBoundingClientRect(),t=this._popover.querySelector(".popover-content");if(!t)return{top:0,left:0,direction:"down"};this.classList.contains("hidden")&&(this.classList.remove("hidden"),this._popover.style.visibility="hidden");const s=t.getBoundingClientRect(),r=window.innerWidth,n=window.innerHeight,a=8;let l=this.getDirection(),o=0,h=0;switch(l){case"down":if(o=e.bottom+a,h=e.left+e.width/2-s.width/2,o+s.height>n){const c=e.top-s.height-a;c>=0?(l="up",o=c):(o=Math.max(0,n-s.height-a),o+s.height>n&&(o=0))}h<0&&(h=a),h+s.width>r&&(h=Math.max(a,r-s.width-a),h+s.width>r&&(h=r-s.width));break;case"up":if(o=e.top-s.height-a,h=e.left+e.width/2-s.width/2,o<0){const c=e.bottom+a;c+s.height<=n?(l="down",o=c):(o=Math.min(n-s.height-a,n-s.height),o<0&&(o=n-s.height))}h<0&&(h=a),h+s.width>r&&(h=Math.max(a,r-s.width-a),h+s.width>r&&(h=r-s.width));break;case"right":if(o=e.top+e.height/2-s.height/2,h=e.right+a,h+s.width>r){const c=e.left-s.width-a;c>=0?(l="left",h=c):(h=Math.max(0,r-s.width-a),h+s.width>r&&(h=r-s.width))}o<0&&(o=a),o+s.height>n&&(o=Math.max(a,n-s.height-a),o+s.height>n&&(o=n-s.height));break;case"left":if(o=e.top+e.height/2-s.height/2,h=e.left-s.width-a,h<0){const c=e.right+a;c+s.width<=r?(l="right",h=c):(h=Math.min(r-s.width-a,r-s.width),h<0&&(h=0))}o<0&&(o=a),o+s.height>n&&(o=Math.max(a,n-s.height-a),o+s.height>n&&(o=n-s.height));break}return{top:o,left:h,direction:l}}render(){const e=this.getId(),t=this.isOpen(),i=this.getPadding();if(e&&(this.id=e),t){if(this.classList.remove("hidden"),this.style.pointerEvents="auto",!this._clickOutsideHandler){const n=this;this._clickOutsideHandler=function(a){const l=a.composedPath(),o=l.includes(n);if(!(n._triggerElement&&l.includes(n._triggerElement))&&!o){n.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 n=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=n.filter(o=>!a.includes(o));s.className=[...l,i].join(" ")}Array.from(this.children).forEach(n=>{n!==this._overlay&&n!==this._popover&&n.parentElement===this&&s.appendChild(n)}),t?(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"})}))):!t&&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 e=document.documentElement.classList.contains("dark"),t=this._popover.querySelector(".popover-content");t&&(e?(t.classList.remove("bg-white"),t.classList.add("bg-gray-800")):(t.classList.remove("bg-gray-800"),t.classList.add("bg-white")))}_observeDarkMode(){this._darkModeObserver||(this._darkModeObserver=new MutationObserver(()=>{this._updateBackgroundColor()}),this._darkModeObserver.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}))}_updatePosition(e){if(!this._triggerElement||!this._popover)return;const t=this._popover.style.visibility!=="hidden";t||(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`,t||(this._popover.style.visibility="visible",e&&(!e.style.opacity||e.style.opacity==="")&&(e.style.transform="scale(0.97) translateY(10px)",e.style.opacity="0",e.style.transition="all 200ms ease-out",requestAnimationFrame(()=>{requestAnimationFrame(()=>{e.style.transform="scale(1) translateY(0)",e.style.opacity="1"})})))}_setupPositionListeners(){if(!this._scrollHandler&&this.isOpen()){const e=this;this._scrollHandler=function(){if(e.isOpen()&&e._popover){const t=e._popover.querySelector(".popover-content");t&&e._updatePosition(t)}},window.addEventListener("scroll",this._scrollHandler,!0)}if(!this._resizeHandler&&this.isOpen()){const e=this;this._resizeHandler=function(){if(e.isOpen()&&e._popover){const t=e._popover.querySelector(".popover-content");t&&e._updatePosition(t)}},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(t=>{if(t!==this){const i=t;typeof i.close=="function"?i.close():t.removeAttribute("open")}})}}customElements.get("mint-popover")||customElements.define("mint-popover",G);const oe={name:"check",viewBox:"0 0 24 24",path:"M5 13l4 4L19 7",strokeLinecap:"round",strokeLinejoin:"round"};q(oe);class X 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"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline","inline-flex","items-start","gap-2");const e=this.getAttribute("checked");this._checked=e!==null&&e!=="false",this.render()}disconnectedCallback(){this.removeEventListeners()}attributeChangedCallback(e,t,i){e==="checked"&&(this._checked=i!==null&&i!=="false",this._checkbox&&(this._checkbox.checked=this._checked)),t!==i&&(this.render(),e==="checked"&&this._checkbox&&this.updateVisualState())}get checked(){return this._checked}set checked(e){e?this.setAttribute("checked",""):this.removeAttribute("checked"),this._checked=!!e,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")||""}getCheckboxClasses(){const 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","focus-visible:ring-gray-400","dark:focus-visible:ring-gray-500","cursor-pointer","disabled:opacity-40","disabled:cursor-not-allowed"],t=this._checked?["bg-slate-800","dark:bg-slate-600","border-slate-800","dark:border-slate-600"]:["bg-white","dark:bg-gray-700","border-gray-300","dark:border-gray-500"];return[...e,...t].join(" ")}render(){const e=this.getLabel(),t=this.getInfo(),i=this.isDisabled();let s=this.querySelector(".mint-checkbox-wrapper");s||(s=document.createElement("div"),s.className="mint-checkbox-wrapper",this.insertBefore(s,this.firstChild)),this._checkbox?this._checkbox.parentElement!==s&&s.appendChild(this._checkbox):(this._checkbox=document.createElement("input"),this._checkbox.type="checkbox",s.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=i,this._changeHandler||this.setupEventListeners();const r=this.getId();r?this._checkbox.id=r:this._checkbox.removeAttribute("id");const n=this.getName();n?this._checkbox.name=n:this._checkbox.removeAttribute("name");const a=this.getValue();a?this._checkbox.value=a:this._checkbox.removeAttribute("value"),e?this._checkbox.setAttribute("aria-label",e):this._checkbox.removeAttribute("aria-label"),s.className=`mint-checkbox-wrapper ${this.getCheckboxClasses()}`,s.style.pointerEvents="none",this._checkbox.style.pointerEvents="auto";let l=s.querySelector("mint-icon");l||(l=document.createElement("mint-icon"),l.setAttribute("name","check"),l.className="w-3.5 h-3.5 text-white pointer-events-none absolute inset-0 m-auto",l.style.transition="opacity 200ms ease-out, transform 200ms ease-out",l.style.zIndex="1",s.appendChild(l)),this.updateVisualState();let o=this.querySelector(".mint-checkbox-label-container");if(e||t){o||(o=document.createElement("div"),o.className="mint-checkbox-label-container flex flex-col gap-0.5 flex-1",this.appendChild(o));let h=o.querySelector(".mint-checkbox-label");e?(h||(h=document.createElement("span"),h.className="mint-checkbox-label text-sm font-medium text-gray-900 dark:text-gray-100 cursor-pointer select-none",o.insertBefore(h,o.firstChild)),h.textContent=e,i?h.classList.add("opacity-40"):h.classList.remove("opacity-40")):h&&h.remove();let c=o.querySelector(".mint-checkbox-info");if(t?(c||(c=document.createElement("span"),c.className="mint-checkbox-info text-xs text-gray-500 dark:text-gray-400 cursor-pointer select-none",o.appendChild(c)),c.textContent=t,i?c.classList.add("opacity-40"):c.classList.remove("opacity-40")):c&&c.remove(),i)o.style.cursor="default",o._clickHandler&&(o.removeEventListener("click",o._clickHandler),o._clickHandler=null);else{o.style.cursor="pointer";const d=o._clickHandler;d&&o.removeEventListener("click",d),o._clickHandler=u=>{this._checkbox&&(u.target===this._checkbox||this._checkbox.contains(u.target)||u.composedPath().includes(this._checkbox))||this.toggle()},o.addEventListener("click",o._clickHandler)}}else o&&o.remove()}setupEventListeners(){this.removeEventListeners(),this._checkbox&&(this._changeHandler=e=>{e.stopPropagation(),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,value:this.getValue()},bubbles:!0,cancelable:!0});this.dispatchEvent(t)},this._checkbox.addEventListener("change",this._changeHandler),this._mousedownHandler=e=>{e.stopPropagation();const t=this.querySelector(".mint-checkbox-wrapper");t&&!this.isDisabled()&&(t.classList.add("mint-checkbox-active"),this._checked?(t.style.backgroundColor="rgb(15 23 42)",t.style.boxShadow="inset 0 2px 4px rgba(0, 0, 0, 0.3)"):(t.style.backgroundColor="rgb(243 244 246)",t.style.boxShadow="inset 0 2px 4px rgba(0, 0, 0, 0.1)"),document.documentElement.classList.contains("dark")&&(this._checked?t.style.backgroundColor="rgb(51 65 85)":t.style.backgroundColor="rgb(31 41 55)"))},this._mouseupHandler=e=>{e.stopPropagation();const t=this.querySelector(".mint-checkbox-wrapper");t&&(t.classList.remove("mint-checkbox-active"),t.style.backgroundColor="",t.style.boxShadow="")},this._mouseleaveHandler=e=>{const t=this.querySelector(".mint-checkbox-wrapper");t&&(t.classList.remove("mint-checkbox-active"),t.style.backgroundColor="",t.style.boxShadow="")},this._checkbox.addEventListener("mousedown",this._mousedownHandler),this._checkbox.addEventListener("mouseup",this._mouseupHandler),this._checkbox.addEventListener("mouseleave",this._mouseleaveHandler),this._focusHandler=e=>{const t=this.querySelector(".mint-checkbox-wrapper");t&&this._checkbox&&requestAnimationFrame(()=>{this._checkbox&&this._checkbox.matches(":focus-visible")&&(t==null||t.classList.add("ring-2","ring-offset-1","ring-gray-400","dark:ring-gray-500"))})},this._blurHandler=()=>{const e=this.querySelector(".mint-checkbox-wrapper");e&&e.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=e=>{e.stopPropagation();const t=this.querySelector(".mint-checkbox-wrapper");t&&!this.isDisabled()&&(t.classList.add("mint-checkbox-active"),this._checked?(t.style.backgroundColor="rgb(15 23 42)",t.style.boxShadow="inset 0 2px 4px rgba(0, 0, 0, 0.3)"):(t.style.backgroundColor="rgb(243 244 246)",t.style.boxShadow="inset 0 2px 4px rgba(0, 0, 0, 0.1)"),document.documentElement.classList.contains("dark")&&(this._checked?t.style.backgroundColor="rgb(51 65 85)":t.style.backgroundColor="rgb(31 41 55)"))},this._touchendHandler=e=>{e.stopPropagation();const t=this.querySelector(".mint-checkbox-wrapper");t&&(t.classList.remove("mint-checkbox-active"),t.style.backgroundColor="",t.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))}updateVisualState(){const e=this.querySelector(".mint-checkbox-wrapper"),t=e==null?void 0:e.querySelector("mint-icon");t&&(t.style.opacity=this._checked?"1":"0",t.style.transform=this._checked?"scale(1)":"scale(0.8)"),e&&(e.className=`mint-checkbox-wrapper ${this.getCheckboxClasses()}`,e.classList.contains("mint-checkbox-active")||(e.style.backgroundColor="",e.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 e=new CustomEvent("change",{detail:{checked:this._checked},bubbles:!0,cancelable:!0});this.dispatchEvent(e)}}}customElements.get("mint-checkbox")||customElements.define("mint-checkbox",X);class K extends HTMLElement{constructor(){super(),this._radio=null,this._checked=!1,this._changeHandler=null,this._groupChangeHandler=null,this._clickHandler=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"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline","inline-flex","items-start","gap-2");const e=this.getAttribute("checked");this._checked=e!==null&&e!=="false",this.render()}disconnectedCallback(){this.removeEventListeners()}attributeChangedCallback(e,t,i){e==="checked"&&(this._checked=i!==null&&i!=="false",this._radio&&(this._radio.checked=this._checked)),t!==i&&(this.render(),e==="checked"&&this._radio&&this.updateVisualState())}get checked(){return this._checked}set checked(e){e?this.setAttribute("checked",""):this.removeAttribute("checked"),this._checked=!!e,this._radio&&(this._radio.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")||""}getChoiceClasses(){const e=["relative","inline-flex","items-center","justify-center","flex-shrink-0","w-5","h-5","rounded-full","border-2","transition-all","duration-200","outline-none","focus:outline-none","focus-visible:ring-2","focus-visible:ring-offset-1","focus-visible:ring-gray-400","dark:focus-visible:ring-gray-500","cursor-pointer","disabled:opacity-40","disabled:cursor-not-allowed"],t=this._checked?["bg-slate-800","dark:bg-slate-600","border-slate-800","dark:border-slate-600"]:["bg-white","dark:bg-gray-700","border-gray-300","dark:border-gray-500"];return[...e,...t].join(" ")}render(){const e=this.getLabel(),t=this.getInfo(),i=this.isDisabled();let s=this.querySelector(".mint-choice-wrapper");s||(s=document.createElement("div"),s.className="mint-choice-wrapper",this.insertBefore(s,this.firstChild)),this._radio?this._radio.parentElement!==s&&s.appendChild(this._radio):(this._radio=document.createElement("input"),this._radio.type="radio",s.appendChild(this._radio),this.setupEventListeners()),this._radio.className="absolute inset-0 w-full h-full opacity-0 cursor-pointer",this._radio.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._radio.checked=this._checked,this._radio.disabled=i,this._changeHandler||this.setupEventListeners();const r=this.getId();r?this._radio.id=r:this._radio.removeAttribute("id");const n=this.getName();n?this._radio.name=n:this._radio.removeAttribute("name");const a=this.getValue();a?this._radio.value=a:this._radio.removeAttribute("value"),e?this._radio.setAttribute("aria-label",e):this._radio.removeAttribute("aria-label"),s.className=`mint-choice-wrapper ${this.getChoiceClasses()}`,s.style.pointerEvents="none",this._radio.style.pointerEvents="auto";let l=s.querySelector(".mint-choice-indicator");l||(l=document.createElement("div"),l.className="mint-choice-indicator w-2.5 h-2.5 rounded-full bg-white pointer-events-none absolute inset-0 m-auto",l.style.transition="opacity 200ms ease-out, transform 200ms ease-out",l.style.zIndex="1",s.appendChild(l)),l.style.opacity=this._checked?"1":"0",l.style.transform=this._checked?"scale(1)":"scale(0.8)",this.updateVisualState();let o=this.querySelector(".mint-choice-label-container");if(e||t){o||(o=document.createElement("div"),o.className="mint-choice-label-container flex flex-col gap-0.5 flex-1",this.appendChild(o));let h=o.querySelector(".mint-choice-label");e?(h||(h=document.createElement("span"),h.className="mint-choice-label text-sm font-medium text-gray-900 dark:text-gray-100 cursor-pointer select-none",o.insertBefore(h,o.firstChild)),h.textContent=e,i?h.classList.add("opacity-40"):h.classList.remove("opacity-40")):h&&h.remove();let c=o.querySelector(".mint-choice-info");if(t?(c||(c=document.createElement("span"),c.className="mint-choice-info text-xs text-gray-500 dark:text-gray-400 cursor-pointer select-none",o.appendChild(c)),c.textContent=t,i?c.classList.add("opacity-40"):c.classList.remove("opacity-40")):c&&c.remove(),i)o.style.cursor="default",o._clickHandler&&(o.removeEventListener("click",o._clickHandler),o._clickHandler=null);else{o.style.cursor="pointer";const d=o._clickHandler;d&&o.removeEventListener("click",d),o._clickHandler=u=>{this._radio&&(u.target===this._radio||this._radio.contains(u.target)||u.composedPath().includes(this._radio))||this.select()},o.addEventListener("click",o._clickHandler)}}else o&&o.remove()}setupEventListeners(){this.removeEventListeners(),this._radio&&(this._changeHandler=e=>{e.stopPropagation();const t=this._checked;if(this._checked=this._radio.checked,this._checked?this.hasAttribute("checked")||this.setAttribute("checked",""):this.hasAttribute("checked")&&this.removeAttribute("checked"),this.updateVisualState(),this._checked){const i=this._radio.name;i&&document.querySelectorAll(`input[type="radio"][name="${i}"]`).forEach(r=>{if(r!==this._radio){const n=r.closest("mint-choice");n&&n.updateVisualState&&(n._checked=r.checked,r.checked?n.hasAttribute("checked")||n.setAttribute("checked",""):n.hasAttribute("checked")&&n.removeAttribute("checked"),n.updateVisualState())}})}if(t!==this._checked){const i=new CustomEvent("change",{detail:{checked:this._checked,value:this.getValue()},bubbles:!0,cancelable:!0});this.dispatchEvent(i)}},this._radio.addEventListener("change",this._changeHandler),this._groupChangeHandler=e=>{const t=e.target;t!==this._radio&&t.type==="radio"&&t.name===this._radio.name&&t.checked&&setTimeout(()=>{this._radio&&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.updateVisualState())},0)},document.addEventListener("change",this._groupChangeHandler,!0),this._clickHandler=e=>{const t=this._radio.name;t&&document.querySelectorAll(`input[type="radio"][name="${t}"]`).forEach(s=>{if(s!==this._radio){const r=s.closest("mint-choice");r&&r.updateVisualState&&(r._checked=s.checked,s.checked?r.hasAttribute("checked")||r.setAttribute("checked",""):r.hasAttribute("checked")&&r.removeAttribute("checked"),r.updateVisualState())}}),requestAnimationFrame(()=>{this._radio&&(this._checked=this._radio.checked,this.updateVisualState())})},this._radio.addEventListener("click",this._clickHandler),this._mousedownHandler=e=>{e.stopPropagation();const t=this.querySelector(".mint-choice-wrapper");t&&!this.isDisabled()&&(t.classList.add("mint-choice-active"),this._checked?(t.style.backgroundColor="rgb(15 23 42)",t.style.boxShadow="inset 0 2px 4px rgba(0, 0, 0, 0.3)"):(t.style.backgroundColor="rgb(243 244 246)",t.style.boxShadow="inset 0 2px 4px rgba(0, 0, 0, 0.1)"),document.documentElement.classList.contains("dark")&&(this._checked?t.style.backgroundColor="rgb(51 65 85)":t.style.backgroundColor="rgb(31 41 55)"))},this._mouseupHandler=e=>{e.stopPropagation();const t=this.querySelector(".mint-choice-wrapper");t&&(t.classList.remove("mint-choice-active"),t.style.backgroundColor="",t.style.boxShadow="")},this._mouseleaveHandler=e=>{const t=this.querySelector(".mint-choice-wrapper");t&&(t.classList.remove("mint-choice-active"),t.style.backgroundColor="",t.style.boxShadow="")},this._radio.addEventListener("mousedown",this._mousedownHandler),this._radio.addEventListener("mouseup",this._mouseupHandler),this._radio.addEventListener("mouseleave",this._mouseleaveHandler),this._touchstartHandler=e=>{e.stopPropagation();const t=this.querySelector(".mint-choice-wrapper");t&&!this.isDisabled()&&(t.classList.add("mint-choice-active"),this._checked?(t.style.backgroundColor="rgb(15 23 42)",t.style.boxShadow="inset 0 2px 4px rgba(0, 0, 0, 0.3)"):(t.style.backgroundColor="rgb(243 244 246)",t.style.boxShadow="inset 0 2px 4px rgba(0, 0, 0, 0.1)"),document.documentElement.classList.contains("dark")&&(this._checked?t.style.backgroundColor="rgb(51 65 85)":t.style.backgroundColor="rgb(31 41 55)"))},this._touchendHandler=e=>{e.stopPropagation();const t=this.querySelector(".mint-choice-wrapper");t&&(t.classList.remove("mint-choice-active"),t.style.backgroundColor="",t.style.boxShadow="")},this._radio.addEventListener("touchstart",this._touchstartHandler),this._radio.addEventListener("touchend",this._touchendHandler),this._focusHandler=e=>{const t=this.querySelector(".mint-choice-wrapper");t&&this._radio&&requestAnimationFrame(()=>{this._radio&&this._radio.matches(":focus-visible")&&(t==null||t.classList.add("ring-2","ring-offset-1","ring-gray-400","dark:ring-gray-500"))})},this._blurHandler=()=>{const e=this.querySelector(".mint-choice-wrapper");e&&e.classList.remove("ring-2","ring-offset-1","ring-gray-400","dark:ring-gray-500")},this._radio.addEventListener("focus",this._focusHandler),this._radio.addEventListener("blur",this._blurHandler))}removeEventListeners(){this._radio&&(this._changeHandler&&(this._radio.removeEventListener("change",this._changeHandler),this._changeHandler=null),this._groupChangeHandler&&(document.removeEventListener("change",this._groupChangeHandler,!0),this._groupChangeHandler=null),this._clickHandler&&(this._radio.removeEventListener("click",this._clickHandler),this._clickHandler=null),this._mousedownHandler&&(this._radio.removeEventListener("mousedown",this._mousedownHandler),this._mousedownHandler=null),this._mouseupHandler&&(this._radio.removeEventListener("mouseup",this._mouseupHandler),this._mouseupHandler=null),this._mouseleaveHandler&&(this._radio.removeEventListener("mouseleave",this._mouseleaveHandler),this._mouseleaveHandler=null),this._touchstartHandler&&(this._radio.removeEventListener("touchstart",this._touchstartHandler),this._touchstartHandler=null),this._touchendHandler&&(this._radio.removeEventListener("touchend",this._touchendHandler),this._touchendHandler=null),this._focusHandler&&(this._radio.removeEventListener("focus",this._focusHandler),this._focusHandler=null),this._blurHandler&&(this._radio.removeEventListener("blur",this._blurHandler),this._blurHandler=null))}updateVisualState(){const e=this.querySelector(".mint-choice-wrapper"),t=e==null?void 0:e.querySelector(".mint-choice-indicator");t&&(t.style.opacity=this._checked?"1":"0",t.style.transform=this._checked?"scale(1)":"scale(0.8)"),e&&(e.className=`mint-choice-wrapper ${this.getChoiceClasses()}`,e.classList.contains("mint-choice-active")||(e.style.backgroundColor="",e.style.boxShadow=""))}select(){if(this._radio&&!this.isDisabled()){this._radio.checked=!0,this._radio.dispatchEvent(new Event("change",{bubbles:!0})),this._checked=!0,this.hasAttribute("checked")||this.setAttribute("checked","");const e=this._radio.name;e&&document.querySelectorAll(`input[type="radio"][name="${e}"]`).forEach(s=>{if(s!==this._radio){const r=s.closest("mint-choice");r&&r.updateVisualState&&(r._checked=s.checked,s.checked?r.hasAttribute("checked")||r.setAttribute("checked",""):r.hasAttribute("checked")&&r.removeAttribute("checked"),r.updateVisualState())}}),this.updateVisualState();const t=new CustomEvent("change",{detail:{checked:this._checked,value:this.getValue()},bubbles:!0,cancelable:!0});this.dispatchEvent(t)}}}customElements.get("mint-choice")||customElements.define("mint-choice",K);class Z 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"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline","inline-block"),this.getLabel()||console.error('mint-input: The "label" attribute is required. Please provide a label for the input.'),this.render()}disconnectedCallback(){this.removeEventListeners()}attributeChangedCallback(e,t,i){if(t!==i){if(e==="error"||e==="error-message"){this._renderErrorState(),this._element&&(this._element.className=this.getInputClasses()),this._colorTextInput&&(this._colorTextInput.className=this.getInputClasses());return}this.render()}}getType(){return this.getAttribute("type")||"text"}getRows(){const e=this.getAttribute("rows");return e?parseInt(e,10):3}_getNormalizedType(){const e=this.getType();return e==="datetime"?"datetime-local":e==="money"?"text":e==="textarea"?"textarea":e}_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 e,t,i;return this._isColor()?((e=this._colorPicker)==null?void 0:e.value)||((t=this._colorTextInput)==null?void 0:t.value)||this.getAttribute("value")||"#000000":((i=this._element)==null?void 0:i.value)||this.getAttribute("value")||""}set value(e){this._isColor()?(this._colorPicker&&(this._colorPicker.value=e||"#000000"),this._colorTextInput&&(this._colorTextInput.value=e||"#000000")):this._element&&(this._element.value=e),e?this.setAttribute("value",e):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 e=this._isTextarea(),t=!!this.getIcon(),i=this._isColor(),s=this._isNumber(),r=this.hasError(),n=["w-full",t||i?"pl-10":"px-3.5",t||i?"pr-3.5":s?"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",e?"transition-colors transition-opacity":"transition-all","duration-200","outline-none","focus:outline-none","disabled:opacity-40","disabled:cursor-not-allowed","readonly:cursor-default",e?"resize-y":"",s?"[appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none":""],a=["border-2",r?"border-red-300 dark:border-red-300":"border-gray-200 dark:border-gray-600"],l=["focus-visible:ring-2","focus-visible:ring-offset-1",r?"focus-visible:ring-red-400 dark:focus-visible:ring-red-500":"focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500"];return[...n,...a,...l].filter(Boolean).join(" ")}render(){var v,C,S,y;this.getType();const e=this._getNormalizedType(),t=this._isTextarea(),i=this._isMoney(),s=this._isColor(),r=this.getPlaceholder(),n=this.isDisabled(),a=this.isReadonly(),l=this.isRequired(),o=this.getId(),h=this.getName(),c=this.getAttribute("value")||(s?"#000000":""),d=this.getRows(),u=this.getIcon(),f=this.getLabel(),_=this.getInfo();if(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=c||"#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=p=>{this._colorPickerWrapper&&this._colorPicker&&this._colorPicker.matches(":focus-visible")&&requestAnimationFrame(()=>{var k;this._colorPicker&&this._colorPicker.matches(":focus-visible")&&((k=this._colorPickerWrapper)==null||k.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 k;const p=((k=this._colorPicker)==null?void 0:k.value)||"#000000";this._colorPickerWrapper&&(this._colorPickerWrapper.style.backgroundColor=p),this._colorTextInput&&(this._colorTextInput.value=p),this.setAttribute("value",p),this.dispatchEvent(new CustomEvent("input",{detail:{value:p},bubbles:!0,cancelable:!0}))}),this._colorPicker.addEventListener("change",()=>{var k;const p=((k=this._colorPicker)==null?void 0:k.value)||"#000000";this._colorPickerWrapper&&(this._colorPickerWrapper.style.backgroundColor=p),this.setAttribute("value",p),this.dispatchEvent(new CustomEvent("change",{detail:{value:p},bubbles:!0,cancelable:!0}))})),this._colorTextInput||(this._colorTextInput=document.createElement("input"),this._colorTextInput.type="text",this._colorTextInput.className=this.getInputClasses(),this._colorTextInput.placeholder=r||"#000000",this._colorTextInput.pattern="^#[0-9A-Fa-f]{6}$",this._wrapper.appendChild(this._colorTextInput),this._colorTextInput.addEventListener("input",()=>{var k;const p=((k=this._colorTextInput)==null?void 0:k.value)||"";/^#[0-9A-Fa-f]{6}$/.test(p)&&(this._colorPicker&&(this._colorPicker.value=p),this.setAttribute("value",p),this.dispatchEvent(new CustomEvent("input",{detail:{value:p},bubbles:!0,cancelable:!0})))}),this._colorTextInput.addEventListener("blur",()=>{var k,E;const p=((k=this._colorTextInput)==null?void 0:k.value)||"";/^#[0-9A-Fa-f]{6}$/.test(p)?(this._colorPicker&&(this._colorPicker.value=p),this.setAttribute("value",p)):this._colorPicker&&this._colorTextInput&&(this._colorTextInput.value=this._colorPicker.value),this.dispatchEvent(new CustomEvent("change",{detail:{value:((E=this._colorPicker)==null?void 0:E.value)||"#000000"},bubbles:!0,cancelable:!0}))}));const b=c||"#000000";if(this._colorPicker&&this._colorPicker.value!==b&&(this._colorPicker.value=b),this._colorPickerWrapper&&(this._colorPickerWrapper.style.backgroundColor=b),this._colorTextInput&&this._colorTextInput.value!==b&&(this._colorTextInput.value=b),this._colorPicker&&(this._colorPicker.disabled=n),this._colorPickerWrapper&&(n?(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=n,this._colorTextInput.readOnly=a,this._colorTextInput.required=l),this._colorTextInput){const p=this._colorTextInput;o?p.id=o:p.removeAttribute("id"),h?p.name=h:p.removeAttribute("name"),p.setAttribute("aria-invalid",this.hasError()?"true":"false"),this._element=p}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),u&&!t?this._icon?this._icon.setAttribute("name",u):(this._icon=document.createElement("mint-icon"),this._icon.setAttribute("name",u),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()&&!t){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 b=document.createElement("mint-icon");b.setAttribute("name","caret-up"),b.className="w-[1rem] h-[1rem]",this._numberIncrementButton.appendChild(b),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 p=document.createElement("mint-icon");p.setAttribute("name","caret-down"),p.className="w-[1rem] h-[1rem]",this._numberDecrementButton.appendChild(p),this._numberSpinnerContainer.appendChild(this._numberDecrementButton),this._numberIncrementButton.addEventListener("click",k=>{if(k.preventDefault(),k.stopPropagation(),this._input&&!this._input.disabled&&!this._input.readOnly){const E=parseFloat(this._input.value)||0,I=parseFloat(this._input.step)||1,w=this._input.min?parseFloat(this._input.min):void 0,A=this._input.max?parseFloat(this._input.max):void 0;let L=E+I;A!==void 0&&L>A&&(L=A),w!==void 0&&L<w&&(L=w),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",k=>{if(k.preventDefault(),k.stopPropagation(),this._input&&!this._input.disabled&&!this._input.readOnly){const E=parseFloat(this._input.value)||0,I=parseFloat(this._input.step)||1,w=this._input.min?parseFloat(this._input.min):void 0,A=this._input.max?parseFloat(this._input.max):void 0;let L=E-I;w!==void 0&&L<w&&(L=w),A!==void 0&&L>A&&(L=A),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=n||a),this._numberDecrementButton&&(this._numberDecrementButton.disabled=n||a)}else this._numberSpinnerContainer&&(this._numberSpinnerContainer.remove(),this._numberSpinnerContainer=null,this._numberIncrementButton=null,this._numberDecrementButton=null);if(t){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=r,this._textarea.disabled=n,this._textarea.readOnly=a,this._textarea.required=l,this._textarea.rows=d,this._textarea.setAttribute("aria-invalid",this.hasError()?"true":"false"),c!==this._textarea.value&&(this._textarea.value=c),o?this._textarea.id=o:this._textarea.removeAttribute("id"),h?this._textarea.name=h:this._textarea.removeAttribute("name"),this._textarea.className=this.getInputClasses(),this.firstChild&&this.firstChild!==this._wrapper&&this.firstChild.nodeType===Node.TEXT_NODE){const b=this.firstChild.textContent;b&&!this._textarea.value&&(this._textarea.value=b.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=e,this._input.placeholder=r,this._input.disabled=n,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")),c!==this._input.value&&(this._input.value=c),o?this._input.id=o:this._input.removeAttribute("id"),h?this._input.name=h:this._input.removeAttribute("name"),this._input.className=this.getInputClasses(),this.firstChild&&this.firstChild!==this._wrapper&&this.firstChild.nodeType===Node.TEXT_NODE){const b=this.firstChild.textContent;b&&!this._input.value&&(this._input.value=b.trim()),this.removeChild(this.firstChild)}let m=this.querySelector(".mint-input-label-container");if(f||_){m||(m=document.createElement("div"),m.className="mint-input-label-container flex flex-col gap-0.5 mb-[.25rem]",this._wrapper&&this._wrapper.parentElement===this?this.insertBefore(m,this._wrapper):this.insertBefore(m,this.firstChild));let b=m.querySelector(".mint-input-label");if(f){b||(b=document.createElement("label"),b.className="mint-input-label text-sm font-medium text-gray-900 dark:text-gray-100 select-none",m.insertBefore(b,m.firstChild)),b.textContent=f;const k=o||((v=this._element)==null?void 0:v.id)||((C=this._colorTextInput)==null?void 0:C.id)||((S=this._input)==null?void 0:S.id)||((y=this._textarea)==null?void 0:y.id);if(k)b.setAttribute("for",k);else{const E=`mint-input-${Math.random().toString(36).substr(2,9)}`;this._element?this._element.id=E:this._colorTextInput?this._colorTextInput.id=E:this._input?this._input.id=E:this._textarea&&(this._textarea.id=E),b.setAttribute("for",E)}n?b.classList.add("opacity-40"):b.classList.remove("opacity-40")}else b&&b.remove();let p=m.querySelector(".mint-input-info");_?(p||(p=document.createElement("span"),p.className="mint-input-info text-xs text-gray-500 dark:text-gray-400 select-none",m.appendChild(p)),p.textContent=_,n?p.classList.add("opacity-40"):p.classList.remove("opacity-40")):p&&p.remove()}else m&&m.remove();this._renderErrorState()}_renderErrorState(){const e=this.hasError(),t=this.getErrorMessage();let i=this.querySelector(".mint-input-error");e&&t?(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=t):i&&i.remove()}setupEventListeners(){this._element&&(this._element.addEventListener("input",()=>{var t;const e=((t=this._element)==null?void 0:t.value)||"";e?this.setAttribute("value",e):this.removeAttribute("value"),this.dispatchEvent(new CustomEvent("input",{detail:{value:e},bubbles:!0,cancelable:!0}))}),this._element.addEventListener("blur",()=>{var t;const e=((t=this._element)==null?void 0:t.value)||"";e?this.setAttribute("value",e):this.removeAttribute("value"),this.dispatchEvent(new CustomEvent("change",{detail:{value:e},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 e;this._isColor()&&this._colorTextInput?this._colorTextInput.focus():(e=this._element)==null||e.focus()}blur(){var e;this._isColor()&&this._colorTextInput?this._colorTextInput.blur():(e=this._element)==null||e.blur()}}customElements.get("mint-input")||customElements.define("mint-input",Z);class Q 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"]}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 e=this.closest("form");e&&e.removeEventListener("reset",this._resetHandler),this._resetHandler=null}}attributeChangedCallback(e,t,i){if(t!==i){if(e==="error"||e==="error-message"){const s=this.hasError(),r=this.getErrorMessage();this._applyErrorVisuals(s,r,this.isDisabled());return}this.render(),this._input&&this._setupPopoverWithRetry()}}getValue(){return this.getAttribute("value")||""}setValue(e){e?(this.setAttribute("value",e),this._textInput&&(this._textInput.value=e),this._parseValue(e)):(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 e=this.getAttribute("shortcuts");if(!e)return[];try{const t=JSON.parse(e);if(Array.isArray(t))return t.map(i=>({label:i.label,action:this._createShortcutAction(i.action)}))}catch{const i=e.trim();if(i&&typeof window[i]=="function"){const s=window[i]();if(Array.isArray(s))return s.map(r=>({label:r.label,action:typeof r.action=="function"?r.action:this._createShortcutAction(r.action)}))}}return[]}_createShortcutAction(e){return typeof e=="function"?e:typeof e=="string"&&typeof window[e]=="function"?window[e]:()=>null}_getDefaultShortcuts(){const e=[{label:"Today",action:()=>new Date}];return this._isRange&&e.push({label:"This Week",action:()=>{const t=new Date,i=t.getDay(),s=new Date(t);s.setDate(t.getDate()-i),s.setHours(0,0,0,0);const r=new Date(s);return r.setDate(s.getDate()+6),r.setHours(23,59,59,999),{start:s,end:r}}},{label:"This Month",action:()=>{const t=new Date,i=new Date(t.getFullYear(),t.getMonth(),1),s=new Date(t.getFullYear(),t.getMonth()+1,0);return s.setHours(23,59,59,999),{start:i,end:s}}}),e}_getFormatTokens(e){const t=[];let i=0;const s=e.toLowerCase();for(;i<s.length;){const r=s[i];if(r==="d"||r==="m"||r==="y"){let n=1,a=i+1;for(;a<s.length&&s[a]===r;)n++,a++;t.push({type:"part",part:r,len:n}),i=a}else t.push({type:"sep",value:e[i]}),i++}return t}_createPartInput(e,t,i,s,r){const n=document.createElement("input");return n.type="text",n.inputMode="numeric",n.pattern="\\d*",n.maxLength=e,n.placeholder=t,n.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",n.disabled=i,n.readOnly=s,n.required=r,e===4?n.className+=" w-[40px]":e===2&&(n.className+=" w-[30px]"),n}_buildValueFromParts(e,t){let i=0;return t.map(s=>{var n;if(s.type==="sep")return s.value;const r=((n=e[i])==null?void 0:n.value)||"";return i++,r}).join("")}_applyDateToParts(e,t,i,s){if(!t.length)return;if(!e){t.forEach(l=>l.value="");return}const r=this._formatDate(e,s);let n=0,a=0;i.forEach(l=>{if(l.type==="sep")n+=l.value.length;else{const o=r.substr(n,l.len);t[a]&&(t[a].value=o),a++,n+=l.len}})}_syncHiddenInput(){if(!this._hiddenInput)return;const e=this.getFormat(),t=this._getFormatTokens(e),i=this._buildValueFromParts(this._startPartInputs,t);if(this._isRange){const s=this._buildValueFromParts(this._endPartInputs,t);this._hiddenInput.value=s?`${i} - ${s}`:i}else this._hiddenInput.value=i}_focusNext(e,t){if(t+1<e.length){const i=e[t+1];i.focus(),i.setSelectionRange(0,i.value.length)}}_focusPrev(e,t){if(t-1>=0){const i=e[t-1];i.focus(),i.setSelectionRange(i.value.length,i.value.length)}}_attachPartInputHandlers(e,t,i){e.forEach((s,r)=>{const n=s.maxLength||2;s.addEventListener("input",()=>{s.value=s.value.replace(/\D/g,"").slice(0,n),s.value.length>=n&&this._focusNext(e,r),this._syncHiddenInput()}),s.addEventListener("keydown",a=>{a.key==="Backspace"&&s.selectionStart===0&&s.selectionEnd===0&&this._focusPrev(e,r),a.key==="ArrowLeft"&&s.selectionStart===0&&s.selectionEnd===0&&(this._focusPrev(e,r),a.preventDefault()),a.key==="ArrowRight"&&s.selectionStart===s.value.length&&s.selectionEnd===s.value.length&&(this._focusNext(e,r),a.preventDefault())}),s.addEventListener("blur",a=>{var o;this._syncHiddenInput();const l=a.relatedTarget;l&&i.contains(l)||(this._handleBlur(((o=this._hiddenInput)==null?void 0:o.value)||""),this._exitInputMode())})})}_splitRangeInput(e,t){const i=e.split(/\s*-\s*/);return i.length>=2?[i[0],i.slice(1).join("-")]:[e]}_parseValue(e){const t=this.getFormat(),i=this._getFormatTokens(t);if(this._isRange){const[s,r]=this._splitRangeInput(e,t),n=s?this._parseDateString(s,t):null,a=r?this._parseDateString(r,t):null;if(n&&a){const[l,o]=n<=a?[n,a]:[a,n];this._selectedStartDate=l,this._selectedEndDate=o,this._currentMonth=l.getMonth(),this._currentYear=l.getFullYear()}else n&&(this._selectedStartDate=n,this._selectedEndDate=null,this._currentMonth=n.getMonth(),this._currentYear=n.getFullYear());this._applyDateToParts(this._selectedStartDate,this._startPartInputs,i,t),this._applyDateToParts(this._selectedEndDate,this._endPartInputs,i,t)}else{const s=this._parseDateString(e,t);s&&!isNaN(s.getTime())?(this._selectedStartDate=s,this._selectedEndDate=null,this._currentMonth=s.getMonth(),this._currentYear=s.getFullYear(),this._applyDateToParts(s,this._startPartInputs,i,t)):this._applyDateToParts(null,this._startPartInputs,i,t)}this._syncHiddenInput(),this._updateDisplayText()}_parseDateString(e,t){const i=/[\/\-\.\s]+/;if(i.test(e)){const g=e.split(i).filter(v=>v.length>0),m=t.split(/[\/\-\.\s]+/).filter(v=>v.length>0);if(g.length===m.length){let v=0,C=0,S=0;for(let y=0;y<m.length;y++){const b=m[y].toLowerCase(),p=g[y];if(b.includes("d"))v=parseInt(p,10);else if(b.includes("m"))C=parseInt(p,10)-1;else if(b.includes("y")){let k=parseInt(p,10);const E=b.length,I=p.length;I===2&&E===4?k=Math.floor(new Date().getFullYear()/100)*100+k:I===2&&E===2&&(k=Math.floor(new Date().getFullYear()/100)*100+k),S=k}}if(v&&C>=0&&C<=11&&S){const y=new Date(S,C,v);if(!isNaN(y.getTime())&&y.getDate()===v&&y.getMonth()===C&&y.getFullYear()===S)return y}}}const r=e.replace(/[\/\-\.]/g,""),n=t.replace(/[\/\-\.]/g,"").toLowerCase();let a=n.indexOf("d"),l=n.indexOf("m"),o=n.indexOf("y");const h=[{char:"d",index:a},{char:"m",index:l},{char:"y",index:o}].sort((g,m)=>g.index-m.index);let c=0,d=0,u=0,f=0;n.length,r.length;for(const g of h)if(g.char==="d"){const m=n.lastIndexOf("d")-n.indexOf("d")+1,v=r.substr(f,m);if(v.length===0)return null;c=parseInt(v,10),f+=v.length}else if(g.char==="m"){const m=n.lastIndexOf("m")-n.indexOf("m")+1,v=r.substr(f,m);if(v.length===0)return null;d=parseInt(v,10)-1,f+=v.length}else if(g.char==="y"){const m=n.lastIndexOf("y")-n.indexOf("y")+1,v=r.substr(f),C=Math.min(m,v.length),S=v.substr(0,C);if(S.length===0)return null;let y=parseInt(S,10);C===2&&m===4?y=Math.floor(new Date().getFullYear()/100)*100+y:C===2&&m===2&&(y=Math.floor(new Date().getFullYear()/100)*100+y),u=y,f+=C}if(!c||d<0||d>11||!u)return null;const _=new Date(u,d,c);return isNaN(_.getTime())||_.getDate()!==c||_.getMonth()!==d||_.getFullYear()!==u?null:_}_formatDate(e,t){const i=e.getDate(),s=e.getMonth()+1,r=e.getFullYear(),n=t.toLowerCase();let a=t;return n.includes("dd")?a=a.replace(/dd/gi,String(i).padStart(2,"0")):n.includes("d")&&(a=a.replace(/d/gi,String(i))),n.includes("mm")?a=a.replace(/mm/gi,String(s).padStart(2,"0")):n.includes("m")&&(a=a.replace(/m/gi,String(s))),n.includes("yyyy")?a=a.replace(/yyyy/gi,String(r)):n.includes("yy")&&(a=a.replace(/yy/gi,String(r).substr(2))),a}_formatDatePhp(e,t){const i=e.getDate(),s=e.getMonth()+1,r=e.getFullYear(),n=["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"],h=(u,f=2)=>u.toString().padStart(f,"0"),c=u=>{const f=u%10,_=u%100;return f===1&&_!==11?"st":f===2&&_!==12?"nd":f===3&&_!==13?"rd":"th"};let d="";for(let u=0;u<t.length;u++){const f=t[u];if(f==="\\"&&u+1<t.length){d+=t[u+1],u++;continue}switch(f){case"Y":d+=r.toString();break;case"y":d+=r.toString().slice(-2);break;case"m":d+=h(s);break;case"n":d+=s.toString();break;case"M":d+=o[s-1];break;case"F":d+=l[s-1];break;case"d":d+=h(i);break;case"j":d+=i.toString();break;case"D":d+=a[e.getDay()];break;case"l":d+=n[e.getDay()];break;case"S":d+=c(i);break;default:d+=f;break}}return d}_validateDateString(e,t){const i=this._parseDateString(e,t);return i!==null&&!isNaN(i.getTime())}render(){const e=this.getLabel(),t=this.getInfo(),i=this.getValue(),s=this.isDisabled(),r=this.isReadonly(),n=this.isRequired(),a=this.getId(),l=this.getName(),o=this.getFormat(),h=this.hasError(),c=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||t){d||(d=document.createElement("div"),d.className="mint-date-picker-label-container flex flex-col gap-0.5 mb-[.25rem]",this.insertBefore(d,this._input));let m=d.querySelector(".mint-date-picker-label");e?(m||(m=document.createElement("label"),m.className="mint-date-picker-label text-sm font-medium text-gray-900 dark:text-gray-100 select-none",d.insertBefore(m,d.firstChild)),m.textContent=e,a&&this._textInput&&m.setAttribute("for",a)):m&&m.remove();let v=d.querySelector(".mint-date-picker-info");t?(v||(v=document.createElement("span"),v.className="mint-date-picker-info text-xs text-gray-500 dark:text-gray-400 select-none",d.appendChild(v)),v.textContent=t):v&&v.remove()}else d&&d.remove();this._hiddenInput||(this._hiddenInput=document.createElement("input"),this._hiddenInput.type="hidden",this._hiddenInput.value=i||"",this._textInput=this._hiddenInput,this._input.appendChild(this._hiddenInput)),a&&(this._hiddenInput.id=a),l&&(this._hiddenInput.name=l),this._hiddenInput.value=i||"",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,c,s),u.innerHTML="",this._displayEl=document.createElement("div"),this._displayEl.className="flex-1 text-gray-900 dark:text-white cursor-text select-none focus:outline-none",this._displayEl.tabIndex=s?-1:0,this._displayEl.addEventListener("click",()=>{s||r||this._enterInputMode()}),this._displayEl.addEventListener("keydown",m=>{s||r||(m.key==="Enter"||m.key===" ")&&(m.preventDefault(),this._enterInputMode())}),this._inputsWrapperEl=document.createElement("div"),this._inputsWrapperEl.className="flex items-center gap-1 w-full";const f=this._getFormatTokens(o);this._startPartInputs=[],this._endPartInputs=[];const _=m=>{const v=document.createDocumentFragment();return f.forEach(C=>{if(C.type==="sep"){const S=document.createElement("span");S.textContent=C.value,S.className="text-gray-400 dark:text-gray-500 select-none",v.appendChild(S)}else{const S=C.part==="d"?"dd":C.part==="m"?"mm":C.len===2?"yy":"yyyy",y=this._createPartInput(C.len,S,s,r,n);m==="start"?this._startPartInputs.push(y):this._endPartInputs.push(y),v.appendChild(y)}}),v};if(this._inputsWrapperEl.appendChild(_("start")),this._isRange){const m=document.createElement("span");m.textContent=" - ",m.className="text-gray-400 dark:text-gray-500 select-none",this._inputsWrapperEl.appendChild(m),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),u.appendChild(g),u.addEventListener("click",()=>{this._isInputMode||s||r||this._enterInputMode()}),this._attachPartInputHandlers(this._startPartInputs,f,u),this._isRange&&this._attachPartInputHandlers(this._endPartInputs,f,u),this._parseValue(i),this._syncHiddenInput(),this._updateDisplayText(),this._iconButton)this._iconButton.disabled=s||r,!s&&!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-2 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 m=`date-icon-${Math.random().toString(36).substr(2,9)}`;this._iconButton.id=m;const v=document.createElement("mint-icon");v.setAttribute("name","calendar"),v.className="w-4 h-4 pointer-events-none",this._iconButton.appendChild(v),this._iconButton.addEventListener("click",()=>{s||r||this._enterInputMode()}),this._input.prepend(this._iconButton),this._iconButton.disabled=s||r}this._renderErrorState(h,c)}_renderErrorState(e,t){let i=this.querySelector(".mint-date-picker-error");e&&t?(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=t):i&&i.remove()}_applyErrorVisuals(e,t,i){if(this._renderErrorState(e,t),this._fieldsContainer){const s=this._getFieldContainerClass(e,i);this._fieldsContainer.className=s}this._hiddenInput&&this._hiddenInput.setAttribute("aria-invalid",e?"true":"false")}_attachFormResetListener(){const e=this.closest("form");!e||this._resetHandler||(this._resetHandler=()=>{this.setValue(""),this._clearPartInputs(this._startPartInputs),this._clearPartInputs(this._endPartInputs),this._isInputMode=!1,this._updateDisplayText(),this._applyErrorVisuals(!1,"",this.isDisabled())},e.addEventListener("reset",this._resetHandler))}_clearPartInputs(e){e.forEach(t=>{t.value=""})}_getFieldContainerClass(e,t){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",e?"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",e?"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(" ")+(t?" opacity-40 cursor-not-allowed":"")}_handleInputChange(e){}_cleanInputValue(e,t){return e}_handleBlur(e){const t=this.getFormat();if(!e){this.setValue(""),this._updateDisplayText();return}if(this._isRange){const[i,s]=this._splitRangeInput(e,t),r=i?this._parseDateString(i,t):null,n=s?this._parseDateString(s,t):null;if(r&&n){const[a,l]=r<=n?[r,n]:[n,r],o=this._formatDate(a,t),h=this._formatDate(l,t),c=`${o} - ${h}`;this.setValue(c),this._applyDateToParts(a,this._startPartInputs,this._getFormatTokens(t),t),this._applyDateToParts(l,this._endPartInputs,this._getFormatTokens(t),t),this._selectedStartDate=a,this._selectedEndDate=l,this._currentMonth=a.getMonth(),this._currentYear=a.getFullYear()}else if(r){const a=this._formatDate(r,t);this.setValue(a),this._applyDateToParts(r,this._startPartInputs,this._getFormatTokens(t),t),this._applyDateToParts(null,this._endPartInputs,this._getFormatTokens(t),t),this._selectedStartDate=r,this._selectedEndDate=null,this._currentMonth=r.getMonth(),this._currentYear=r.getFullYear()}else this.setValue(""),this._applyDateToParts(null,this._startPartInputs,this._getFormatTokens(t),t),this._applyDateToParts(null,this._endPartInputs,this._getFormatTokens(t),t),this._selectedStartDate=null,this._selectedEndDate=null}else if(this._validateDateString(e,t)){const i=this._parseDateString(e,t);if(i){const s=this._formatDate(i,t);this.setValue(s),this._applyDateToParts(i,this._startPartInputs,this._getFormatTokens(t),t),this._selectedStartDate=i,this._selectedEndDate=null,this._currentMonth=i.getMonth(),this._currentYear=i.getFullYear()}}else this.setValue(""),this._applyDateToParts(null,this._startPartInputs,this._getFormatTokens(t),t),this._selectedStartDate=null,this._selectedEndDate=null}_setupPopoverWithRetry(e=0){if(!this._iconButton){e<10&&requestAnimationFrame(()=>{this._setupPopoverWithRetry(e+1)});return}const t=10,i=this._iconButton.id;i&&this._iconButton.isConnected?document.getElementById(i)?this._createPopover(i):e<t&&requestAnimationFrame(()=>{this._setupPopoverWithRetry(e+1)}):e<t&&requestAnimationFrame(()=>{this._setupPopoverWithRetry(e+1)})}_createPopover(e){if(!e)return;if(!document.getElementById(e)){setTimeout(()=>{this._createPopover(e)},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",e),this._popoverObserver||(this._popoverObserver=new MutationObserver(i=>{i.forEach(s=>{var r;if(s.type==="attributes"&&s.attributeName==="open")if((r=this._popover)==null?void 0:r.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._popoverObserver.observe(this._popover,{attributes:!0,attributeFilter:["open"]})),requestAnimationFrame(()=>{this._buildCalendar()}))})});else{if(this._popover.getAttribute("trigger-id")!==e){this._popover.setAttribute("trigger-id",e);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 e=this._popover.querySelector(".popover-content");if(e){for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(this._calendarContainer)}else this._popover.appendChild(this._calendarContainer)}_buildCalendarView(){if(!this._calendarContainer)return;const e=this._getDaysInMonth(this._currentMonth,this._currentYear),t=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"],r=this.getShortcuts(),n=r.length>0;this._calendarContainer.className=n?"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 h=document.createElement("button");h.type="button",h.tabIndex=0,h.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",h.setAttribute("data-keep-popover-open","true");const c=document.createElement("mint-icon");c.setAttribute("name","caret-left"),c.className="w-4 h-4",h.appendChild(c),h.addEventListener("click",()=>{this._currentMonth===0?(this._currentMonth=11,this._currentYear--):this._currentMonth--,this._buildCalendar()}),o.appendChild(h);const d=document.createElement("div");d.className="flex items-center gap-2";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=i[this._currentMonth],u.addEventListener("click",()=>{this._viewMode="month",this._buildCalendar()}),d.appendChild(u);const f=document.createElement("button");f.type="button",f.tabIndex=0,f.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",f.setAttribute("data-keep-popover-open","true"),f.textContent=String(this._currentYear),f.addEventListener("click",()=>{this._viewMode="year",this._buildCalendar()}),d.appendChild(f),o.appendChild(d);const _=document.createElement("button");_.type="button",_.tabIndex=0,_.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",_.setAttribute("data-keep-popover-open","true");const g=document.createElement("mint-icon");g.setAttribute("name","caret-right"),g.className="w-4 h-4",_.appendChild(g),_.addEventListener("click",()=>{this._currentMonth===11?(this._currentMonth=0,this._currentYear++):this._currentMonth++,this._buildCalendar()}),o.appendChild(_);const m=document.createElement("div");m.className="grid grid-cols-7 mb-2",s.forEach(y=>{const b=document.createElement("div");b.className="text-xs font-medium text-gray-500 dark:text-gray-400 text-center py-1",b.textContent=y,m.appendChild(b)});const v=document.createElement("div");v.className="grid grid-cols-7";for(let y=0;y<t;y++){const b=document.createElement("div");b.className="w-8 h-8",v.appendChild(b)}const C=this.getMin()?this._parseDateString(this.getMin(),this.getFormat()):null,S=this.getMax()?this._parseDateString(this.getMax(),this.getFormat()):null;for(let y=1;y<=e;y++){const b=new Date(this._currentYear,this._currentMonth,y),p=this._isToday(b),k=this._isDateSelected(b),E=this._isDateInRange(b),I=C&&b<C||S&&b>S;let w="rounded-md";if(this._isRange&&this._selectedStartDate&&this._selectedEndDate){const L=this._isSameDate(b,this._selectedStartDate),M=this._isSameDate(b,this._selectedEndDate);L&&M?w="rounded-md":L?w="rounded-l-md":M?w="rounded-r-md":E&&(w="rounded-none")}else k&&!this._isRange&&(w="rounded-md");const A=document.createElement("button");A.type="button",A.disabled=!!I,A.tabIndex=I?-1:0,A.className=`w-full h-8 ${w} 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":E?"bg-slate-100 dark:bg-slate-700 text-slate-800 dark:text-slate-200":p?"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"} ${I?"opacity-40 cursor-not-allowed":""}`,A.textContent=y.toString(),I||A.addEventListener("click",()=>{this._handleDateClick(b)}),v.appendChild(A)}if(n){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 b=document.createElement("div");b.className="relative md:relative md:flex-1 md:min-h-0";const p=document.createElement("div");p.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",p.style.scrollbarWidth="none",p.style.msOverflowStyle="none",p.style.setProperty("-webkit-overflow-scrolling","touch");const k=document.createElement("style");k.textContent=`
|
|
44
|
+
`;this.innerHTML=o.trim()}}customElements.get("mint-spinner")||customElements.define("mint-spinner",P);const O=new Map;function q(x){O.set(x.name,x)}function ae(x){return O.get(x)}class B 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(e,t,i){t!==i&&this.render()}disconnectedCallback(){this._darkModeObserver&&(this._darkModeObserver.disconnect(),this._darkModeObserver=null)}_observeDarkMode(){this._darkModeObserver||(this._darkModeObserver=new MutationObserver(e=>{for(const t of e)if(t.type==="attributes"&&t.attributeName==="class"){this.render();break}}),this._darkModeObserver.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}))}getName(){return this.getAttribute("name")||""}getIconUrl(){var t;const e=document.documentElement.getAttribute("data-icon-base-url")||((t=document.querySelector('meta[name="icon-base-url"]'))==null?void 0:t.getAttribute("content"));return e?`${e}/${this.getName()}.svg`:`/icons/${this.getName()}.svg`}render(){var a,l;const e=this.getName();if(!e){this.innerHTML="",this.style.maskImage="",this.style.webkitMaskImage="";return}if(!ae(e)){console.warn(`Icon "${e}" not found. Make sure you've imported the icon: import '@monobill-mintui/icon/icons/${e}'`),this.innerHTML="",this.style.maskImage="",this.style.webkitMaskImage="";return}const i=this.closest("mint-button")||((a=this.parentElement)==null?void 0:a.closest("mint-button")),s=this.closest("mint-switch")||((l=this.parentElement)==null?void 0:l.closest("mint-switch"));let r;s?r="w-3 h-3":i?r="w-5 h-5":r="w-[1.3em] h-[1.3em]",this.classList.remove("w-4","h-4","w-5","h-5","w-[1em]","h-[1em]"),r.split(" ").forEach(o=>{o&&this.classList.add(o)});const n=this.getIconUrl();if(this.style.maskImage=`url(${n})`,this.style.webkitMaskImage=`url(${n})`,this.style.maskSize="contain",this.style.webkitMaskSize="contain",this.style.maskRepeat="no-repeat",this.style.webkitMaskRepeat="no-repeat",this.style.maskPosition="center",this.style.webkitMaskPosition="center",this.style.aspectRatio="1 / 1",this.style.backgroundColor="currentColor",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)}this.innerHTML=""}}customElements.get("mint-icon")||customElements.define("mint-icon",B);class F 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","full-width","icon-position","icon"]}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(e,t,i){t!==i&&this.render()}getVariant(){return this.getAttribute("variant")||"solid"}getTone(){return this.getAttribute("tone")||"neutral"}isDisabled(){return this.hasAttribute("disabled")}isLoading(){return this.hasAttribute("loading")}getType(){return(this.getAttribute("button-type")||"default")==="submit"?"submit":"button"}isFullWidth(){return this.hasAttribute("full-width")}getIconPosition(){return this.getAttribute("icon-position")||"left"}getIcon(){return this.getAttribute("icon")||""}isIconOnly(){var i,s,r,n,a;if(!(this.getIcon()||((i=this._button)==null?void 0:i.querySelector('[slot="icon"], .mint-button-icon, mint-icon'))))return!1;const t=(s=this._button)==null?void 0:s.querySelector(".mint-button-content");if(t&&((r=t.textContent)!=null&&r.trim()))return!1;if(this._button)for(let l=this._button.firstChild;l;l=l.nextSibling){if(l.nodeType===Node.TEXT_NODE&&((n=l.textContent)!=null&&n.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}getButtonClasses(){const e=this.isIconOnly(),t=this.getVariant(),i=["inline-flex","items-center","justify-center","font-medium","rounded-lg","box-border",...e?["p-1.5","aspect-square","w-[2rem]","h-[2rem]"]:["px-3.5","py-1.5","min-h-[2rem]"],"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(),r={"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"]},n=`${t}-${s}`,a=r[n]||r["solid-neutral"],l=[...i,...a];return this.isFullWidth()&&l.push("w-full"),l.join(" ")}render(){var h,c,d,u,f;const e=this.isDisabled()||this.isLoading(),t=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=t,this._button.disabled=e;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 g=document.createElement("span");g.className="mr-2 inline-flex items-center";const _=document.createElement("mint-spinner");_.setAttribute("size","default"),_.setAttribute("data-button-variant",this.getVariant()),_.setAttribute("data-button-tone",this.getTone()),_.style.width="0.875rem",_.style.height="0.875rem",g.appendChild(_),this._button.insertBefore(g,this._button.firstChild)}else i&&((h=i.parentElement)==null||h.remove());for(;this.firstChild&&this.firstChild!==this._button;)this._button.appendChild(this.firstChild);const s=this.getIcon();let r=this._button.querySelector('[slot="icon"], .mint-button-icon, mint-icon');s?(r&&r.tagName!=="MINT-ICON"&&(r.remove(),r=null),!r||r.tagName!=="MINT-ICON"?(r=document.createElement("mint-icon"),r.setAttribute("name",s),r.className="mint-button-icon"):r.setAttribute("name",s)):r&&r.tagName==="MINT-ICON"&&(r.remove(),r=null),r||(r=this._button.querySelector('[slot="icon"], .mint-button-icon'));const n=this.getIconPosition();let a=this._button.querySelector(".mint-button-content");if(a){const g=r&&r.tagName==="MINT-ICON";if(r&&!r.parentElement){const _=(u=this._button.querySelector("mint-spinner"))==null?void 0:u.parentElement;g||n==="left"?_?_.insertAdjacentElement("afterend",r):this._button.insertBefore(r,a):a.insertAdjacentElement("afterend",r)}else if(r&&(g||n==="left")&&r.nextSibling!==a){r.remove();const _=(f=this._button.querySelector("mint-spinner"))==null?void 0:f.parentElement;_?_.insertAdjacentElement("afterend",r):this._button.insertBefore(r,a)}else r&&!g&&n==="right"&&r.previousSibling!==a&&(r.remove(),a.insertAdjacentElement("afterend",r))}else{const g=[];for(let _=this._button.firstChild;_;_=_.nextSibling){if(_.nodeType!==Node.ELEMENT_NODE){g.push(_);continue}const m=_;m.tagName!=="MINT-SPINNER"&&!m.querySelector("mint-spinner")&&_!==r&&!m.hasAttribute("slot")&&!(m.className==="mr-2"&&m.querySelector("mint-spinner"))&&g.push(_)}if(g.length>0){a=document.createElement("span"),a.className="mint-button-content inline-flex items-center",g.forEach(m=>{a.appendChild(m)});const _=(c=this._button.querySelector("mint-spinner"))==null?void 0:c.parentElement;r&&n==="left"?_?(_.insertAdjacentElement("afterend",r),r.insertAdjacentElement("afterend",a)):(this._button.insertBefore(r,this._button.firstChild),r.insertAdjacentElement("afterend",a)):r&&n==="right"?_?(_.insertAdjacentElement("afterend",a),a.insertAdjacentElement("afterend",r)):(this._button.insertBefore(a,this._button.firstChild),a.insertAdjacentElement("afterend",r)):_?_.insertAdjacentElement("afterend",a):this._button.insertBefore(a,this._button.firstChild)}else if(r&&r.tagName==="MINT-ICON"&&!r.parentElement){const _=(d=this._button.querySelector("mint-spinner"))==null?void 0:d.parentElement;_?_.insertAdjacentElement("afterend",r):this._button.insertBefore(r,this._button.firstChild)}}const l=this.isIconOnly();r&&(r.classList.contains("mint-button-icon")||r.classList.add("mint-button-icon"),r.classList.remove("mr-1.5","ml-1.5"),l?r.tagName==="MINT-ICON"?(r.style.width="1rem",r.style.height="1rem",r.style.maxWidth="1rem",r.style.maxHeight="1rem",r.style.flexShrink="0"):(r.style.maxWidth="1rem",r.style.maxHeight="1rem",r.style.flexShrink="0",r.tagName==="svg"&&(r.style.width="1rem",r.style.height="1rem")):n==="left"?r.classList.add("mr-1.5"):r.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(e){if(this.isDisabled()||this.isLoading()){e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation();return}if(e.stopPropagation(),e.stopImmediatePropagation(),this._isHandlingClick){e.preventDefault();return}this._isHandlingClick=!0,e.preventDefault(),this.dispatchEvent(new CustomEvent("click",{detail:{originalEvent:e},bubbles:!0,cancelable:!0,composed:!0})),requestAnimationFrame(()=>{this._isHandlingClick=!1})}}customElements.get("mint-button")||customElements.define("mint-button",F);class z extends HTMLElement{constructor(){super(),this._button=null,this._checked=!1}static get observedAttributes(){return["checked","disabled","label","icon"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline","inline-block","flex","items-center"),this._checked=this.hasAttribute("checked"),this.render()}disconnectedCallback(){this.removeEventListeners()}attributeChangedCallback(e,t,i){e==="checked"&&(this._checked=i!==null),t!==i&&this.render()}get checked(){return this._checked}set checked(e){e?this.setAttribute("checked",""):this.removeAttribute("checked"),this._checked=!!e,this.render()}isDisabled(){return this.hasAttribute("disabled")}getLabel(){return this.getAttribute("label")||""}getIcon(){return this.getAttribute("icon")||""}hasIcon(){return!!this.getIcon()}getSwitchClasses(){const 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","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"],t=this._checked?["bg-slate-950","dark:bg-slate-600","border-slate-700","dark:border-slate-500"]:["bg-slate-200","dark:bg-slate-400","border-slate-300","dark:border-slate-500"];return[...e,...t].join(" ")}getThumbClasses(){const e=["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"],t=this._checked?"translate-x-5":"translate-x-0.5";return[...e,t].join(" ")}getIconClasses(){return["absolute","inset-0","flex","items-center","justify-center","pointer-events-none"].join(" ")}render(){const e=this.getSwitchClasses(),t=this.getThumbClasses(),i=this.getLabel(),s=this.getIcon();this._button||(this._button=document.createElement("button"),this.appendChild(this._button),this.setupEventListeners()),this._button.className=e,this._button.disabled=this.isDisabled(),this._button.setAttribute("aria-checked",String(this._checked)),this._button.setAttribute("aria-label",i),this._button.setAttribute("role","switch"),this._button.type="button";let r=this._button.querySelector("span");r||(r=document.createElement("span"),this._button.appendChild(r)),r.className=t;const n=r.querySelector("span");if(s){let a=n;a||(a=document.createElement("span"),a.className=this.getIconClasses(),r.appendChild(a));let l=a.querySelector("mint-icon");l||(l=document.createElement("mint-icon"),a.appendChild(l)),l.setAttribute("name",s)}else n&&n.remove()}setupEventListeners(){this._button&&this._button.addEventListener("click",this.handleToggle.bind(this))}removeEventListeners(){this._button&&this._button.removeEventListener("click",this.handleToggle.bind(this))}handleToggle(e){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})))}}customElements.get("mint-switch")||customElements.define("mint-switch",z);class V 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(t=>this._userClasses.add(t))}attributeChangedCallback(e,t,i){t!==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 e=this.getSize(),t=this.getVariant(),i=document.documentElement.classList.contains("dark"),s={heading:["font-semibold"],"sub-heading":["font-medium"],regular:[]},r={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"]},n=[];this.isBold()&&n.push("font-bold"),this.isUnderline()&&n.push("underline"),this.isStrike()&&n.push("line-through"),this.isItalic()&&n.push("italic");const a=this.getDisplay();return[a==="block"?"block":a==="inline"?"inline":"inline-block",...s[e]||s.regular,...r[t]||r.default,...n].join(" ")}render(){const e=this.getSize(),t=["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)}),t.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=>{!t.includes(o)&&!i.includes(o)&&this._userClasses.add(o)});const n=[...new Set([...s,...Array.from(this._userClasses)])];this.className=n.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[e]||a.regular;this.style.setProperty("font-size",l)}}customElements.get("mint-text")||customElements.define("mint-text",V);class R 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(e,t,i){t!==i&&(this.render(),e==="text-align"&&this._observeChildren())}_observeChildren(){this._childObserver||(this._childObserver=new MutationObserver(()=>{const e=this.getTextAlign();e&&this._applyTextAlignToChildren(e)}),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 e=this.getAttribute("gap")||"3";return parseFloat(e)}getTextAlign(){const e=this.getAttribute("text-align")||"";return["left","center","right","justify"].includes(e)?e:""}getStackClasses(){const e=this.getDirection(),t=this.getTextAlign(),i=this.getGap(),s=["flex",e==="horizontal"?"flex-row":"flex-col",`gap-${i}`];return t&&(s.push(`text-${t}`),s.push(`[&>*]:text-${t}`),s.push(`[&>*_.mint-button-content]:text-${t}`),t==="left"?(s.push("[&>mint-button]:!justify-start"),s.push("[&>mint-button>button]:!justify-start")):t==="right"?(s.push("[&>mint-button]:!justify-end"),s.push("[&>mint-button>button]:!justify-end")):t==="center"&&(s.push("[&>mint-button]:!justify-center"),s.push("[&>mint-button>button]:!justify-center"))),s.join(" ")}render(){const e=this.getStackClasses(),t=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(r=>this.classList.remove(r)),e.split(" ").forEach(r=>{r&&this.classList.add(r)}),["box-border","m-0","p-0","border-0","align-baseline","block"].forEach(r=>{this.classList.contains(r)||this.classList.add(r)}),t?this._applyTextAlignToChildren(t):this._removeTextAlignFromChildren()}_applyTextAlignToChildren(e){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"),e==="left"?s.classList.add("justify-start"):e==="right"?s.classList.add("justify-end"):e==="center"&&s.classList.add("justify-center");const r=s.querySelector(".mint-button-content");r&&(r.classList.remove("text-left","text-center","text-right","text-justify"),r.classList.add(`text-${e}`))}}else i.classList.remove("text-left","text-center","text-right","text-justify"),i.classList.add(`text-${e}`)})}_removeTextAlignFromChildren(){Array.from(this.children).forEach(t=>{if(t.tagName==="MINT-BUTTON"){const i=t.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 t.classList.remove("text-left","text-center","text-right","text-justify")})}}customElements.get("mint-stack")||customElements.define("mint-stack",R);class W extends HTMLElement{static get observedAttributes(){return[]}constructor(){super()}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline","block"),this.render()}attributeChangedCallback(e,t,i){t!==i&&this.render()}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")}}customElements.get("mint-card")||customElements.define("mint-card",W);class j 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(t=>{t.classList.contains("underline")||t.classList.add("underline")})}),this._contentObserver.observe(this,{childList:!0,subtree:!0}))}attributeChangedCallback(e,t,i){t!==i&&this.render()}getHref(){return this.getAttribute("href")||"#"}getTarget(){return this.getAttribute("target")||""}hasIcon(){var e;return!!(this.querySelector("mint-icon")||(e=this._link)!=null&&e.querySelector("mint-icon"))}render(){const e=this.getHref(),t=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=e,t?(this._link.target=t,t==="_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",j);class $ extends HTMLElement{constructor(){super(),this._button=null,this._historyDepth=0,this._maxBackAttempts=10,this._backAttempts=0,this._initialUrl="",this._initialOrigin="",this._popstateHandler=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(),this._setupHistoryTracking()}disconnectedCallback(){this._popstateHandler&&(window.removeEventListener("popstate",this._popstateHandler),this._popstateHandler=null)}attributeChangedCallback(e,t,i){t!==i&&this.render()}_setupHistoryTracking(){this._initialUrl=window.location.href,this._initialOrigin=window.location.origin,this._historyDepth=window.history.length,this._popstateHandler||(this._popstateHandler=e=>{this._backAttempts=0,setTimeout(()=>{const t=window.location.origin,i=window.location.href;if(t!==this._initialOrigin){this._navigateToFallback();return}if(i.startsWith("chrome://")||i.startsWith("about:")||i.startsWith("edge://")||i==="about:blank"||i==="about:newtab"){this._navigateToFallback();return}},0)},window.addEventListener("popstate",this._popstateHandler))}getFallbackHref(){return this.getAttribute("fallback-href")||this.getAttribute("href")||"/"}handleClick(e){if(e.preventDefault(),e.stopPropagation(),this._wouldBackLeaveApp()){this._navigateToFallback();return}if(window.history.length>1&&this._backAttempts<this._maxBackAttempts&&this._backAttempts===0){this._backAttempts++;const s=window.location.href,r=window.location.origin;window.history.back(),setTimeout(()=>{if(window.location.href===s)this._navigateToFallback();else{if(window.location.origin!==r){this._navigateToFallback();return}const n=window.location.href;if(n.startsWith("chrome://")||n.startsWith("about:")||n.startsWith("edge://")||n==="about:blank"||n==="about:newtab"){this._navigateToFallback();return}setTimeout(()=>{this._backAttempts=0},500)}},200)}else this._navigateToFallback()}_wouldBackLeaveApp(){const e=document.referrer,t=window.location.origin;if(window.history.length<=1||!e&&window.history.length<=2)return!0;if(e)try{if(new URL(e).origin!==t&&window.history.length<=2)return!0}catch{if(window.history.length<=2)return!0}return!1}_navigateToFallback(){var t,i,s;const e=this.getFallbackHref();if(this._backAttempts=0,e.startsWith("/")&&!e.startsWith("//")){const r=document.querySelector("#app");if((s=(i=(t=r==null?void 0:r.__vue_app__)==null?void 0:t.config)==null?void 0:i.globalProperties)!=null&&s.$router)try{r.__vue_app__.config.globalProperties.$router.push(e);return}catch{}try{window.history.pushState({},"",e),window.dispatchEvent(new PopStateEvent("popstate"));return}catch{}}window.location.href=e}render(){this._button||(this._button=document.createElement("mint-button"),this._button.setAttribute("variant","neutral"),this._button.setAttribute("icon","arrow-left"),this._button.addEventListener("click",e=>this.handleClick(e)),this.appendChild(this._button))}}customElements.get("mint-back-button")||customElements.define("mint-back-button",$);class Y 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}static get observedAttributes(){return["heading","fallback-href","show-back-button"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline","block"),this.render(),this._observeDarkMode()}disconnectedCallback(){this._darkModeObserver&&(this._darkModeObserver.disconnect(),this._darkModeObserver=null)}getHeading(){return this.getAttribute("heading")||""}getFallbackHref(){return this.getAttribute("fallback-href")||"/"}shouldShowBackButton(){return this.hasAttribute("show-back-button")}render(){const e=this.getHeading();this._pageContainer||(this._pageContainer=document.createElement("div"),this._pageContainer.className="min-h-screen p-8 transition-colors duration-200",this.appendChild(this._pageContainer)),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 t=this._titleElement.querySelector("mint-back-button");if(this.shouldShowBackButton()){t||(t=document.createElement("mint-back-button"),this._titleElement.insertBefore(t,this._titleElement.firstChild));const n=this.getFallbackHref();t.setAttribute("fallback-href",n)}else t&&(t.remove(),t=null);e?(this._headingText?(this._headingText.classList.add("truncate","min-w-0"),t&&t.parentElement===this._titleElement?this._headingText.previousSibling!==t&&this._titleElement.insertBefore(this._headingText,t.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"),t&&t.parentElement===this._titleElement?this._titleElement.insertBefore(this._headingText,t.nextSibling):this._titleElement.insertBefore(this._headingText,this._titleElement.firstChild)),this._headingText.textContent=e):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(n=>n!==this._pageContainer&&n!==this._actionsSlot&&n.getAttribute("slot")==="actions").forEach(n=>{n.parentElement!==this._actionsSlot&&this._actionsSlot.appendChild(n)}),this._bodySlot||(this._bodySlot=document.createElement("div"),this._pageContainer.appendChild(this._bodySlot)),Array.from(this.children).forEach(n=>{n!==this._pageContainer&&n.getAttribute("slot")!=="actions"&&n!==this._actionsSlot&&n!==this._header&&n!==this._bodySlot&&n!==this._headingText&&n.parentElement!==this._bodySlot&&n.parentElement!==this._pageContainer&&this._bodySlot.appendChild(n)}),this._updateBackgroundColor()}_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"]}))}}customElements.get("mint-page")||customElements.define("mint-page",Y);class U 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(e,t,i){t!==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 e=["grid"],t=this.getColumns();e.push(`grid-cols-${t}`);const i=this.getSm();i&&e.push(`sm:grid-cols-${i}`);const s=this.getMd();s&&e.push(`md:grid-cols-${s}`);const r=this.getLg();r&&e.push(`lg:grid-cols-${r}`);const n=this.getXl();n&&e.push(`xl:grid-cols-${n}`);const a=this.getGap();return e.push(`gap-${a}`),e}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",U);const oe={name:"close",viewBox:"0 0 24 24",path:"M6 18L18 6M6 6l12 12",strokeLinecap:"round",strokeLinejoin:"round"};q(oe);class J 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(e,t,i){t!==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 e=this.getId(),t=this.getHeading(),i=this.isOpen();if(e&&(this.id=e),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 c=this._modal.querySelector(".modal-content");c||(c=document.createElement("div"),c.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(c)),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 r=this._headingSlot.querySelector("mint-text");t?(r||(r=document.createElement("mint-text"),r.setAttribute("size","sub-heading"),r.setAttribute("bold",""),this._headingSlot.appendChild(r)),r.textContent=t):r&&r.remove(),Array.from(this.children).filter(c=>c!==this._overlay&&c!==this._modal&&c!==this._headingSlot&&c.getAttribute("slot")==="heading").forEach(c=>{c.parentElement!==this._headingSlot&&this._headingSlot.appendChild(c)}),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(c=>c!==this._overlay&&c!==this._modal&&c!==this._bodySlot&&c.getAttribute("slot")==="body").forEach(c=>{c.parentElement!==this._bodySlot&&this._bodySlot.appendChild(c)}),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(c=>c!==this._overlay&&c!==this._modal&&c!==this._actionsSlot&&c.getAttribute("slot")==="actions").forEach(c=>{Array.from(c.children).forEach(u=>{u.parentElement!==l&&l.appendChild(u)}),c.parentElement&&c.remove()}),Array.from(this.children).forEach(c=>{c!==this._overlay&&c!==this._modal&&c.getAttribute("slot")!=="heading"&&c.getAttribute("slot")!=="body"&&c.getAttribute("slot")!=="actions"&&c!==this._headingSlot&&c!==this._bodySlot&&c!==this._actionsSlot&&c.parentElement!==this._bodySlot&&this._bodySlot.appendChild(c)}),this._updateBackgroundColor()}_updateBackgroundColor(){if(!this._modal)return;const e=document.documentElement.classList.contains("dark"),t=this._modal.querySelector(".modal-content");t&&(e?(t.classList.remove("bg-white"),t.classList.add("bg-gray-800")):(t.classList.remove("bg-gray-800"),t.classList.add("bg-white")))}_observeDarkMode(){this._darkModeObserver||(this._darkModeObserver=new MutationObserver(()=>{this._updateBackgroundColor()}),this._darkModeObserver.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}))}_animateEnter(){var t;const e=(t=this._modal)==null?void 0:t.querySelector(".modal-content");e&&(e.style.transform="scale(0.97) translateY(10px)",e.style.opacity="0",e.style.transition="all 200ms ease-out",this.classList.remove("hidden"),requestAnimationFrame(()=>{requestAnimationFrame(()=>{e.style.transform="scale(1) translateY(0)",e.style.opacity="1"})}))}_animateExit(){var t;const e=(t=this._modal)==null?void 0:t.querySelector(".modal-content");if(!e){this.classList.add("hidden");return}e.style.transition="all 200ms ease-in",e.style.transform="scale(0.97) translateY(10px)",e.style.opacity="0",setTimeout(()=>{this.classList.add("hidden"),e.style.transform="",e.style.opacity="",e.style.transition=""},200)}}customElements.get("mint-modal")||customElements.define("mint-modal",J);class G 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(e,t,i){t!==i&&(this.render(),(e==="trigger-id"||e==="hover")&&this._setupTrigger(),e==="open"&&this.isOpen()&&this._closeOtherPopovers())}getId(){return this.getAttribute("id")||""}getPadding(){const e=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"}[e]||"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 e=this.getTriggerId();this._triggerClickHandler&&this._triggerElement&&(this._triggerElement.removeEventListener("click",this._triggerClickHandler,!0),this._triggerClickHandler=null),this._removeHoverListeners(),e&&(this._triggerElement=document.getElementById(e),this._triggerElement?(this._attachTriggerListener(),this.isHoverEnabled()&&this._attachHoverListeners()):setTimeout(()=>{this._triggerElement=document.getElementById(e),this._triggerElement&&(this._attachTriggerListener(),this.isHoverEnabled()&&this._attachHoverListeners())},10))}_attachTriggerListener(){if(this._triggerElement&&!this._triggerClickHandler){const e=this;this._triggerClickHandler=function(t){t.stopImmediatePropagation(),t.preventDefault(),e.hasAttribute("open")?e.removeAttribute("open"):e.setAttribute("open","")},this._triggerElement.addEventListener("click",this._triggerClickHandler,!0)}}_attachHoverListeners(){if(!this.isHoverEnabled()||!this._triggerElement)return;this._removeHoverListeners();const e=this;this._triggerHoverEnterHandler=function(){e._cancelHoverClose(),e.open()},this._triggerHoverLeaveHandler=function(t){var s;const i=t.relatedTarget;i&&(e.contains(i)||(s=e._triggerElement)!=null&&s.contains(i))||e._scheduleHoverClose()},this._triggerElement.addEventListener("mouseenter",this._triggerHoverEnterHandler),this._triggerElement.addEventListener("mouseleave",this._triggerHoverLeaveHandler),this._popover&&(this._popoverHoverEnterHandler=function(){e._cancelHoverClose()},this._popoverHoverLeaveHandler=function(t){var s;const i=t.relatedTarget;i&&(e.contains(i)||(s=e._triggerElement)!=null&&s.contains(i))||e._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 e=this._triggerElement?this._triggerElement.matches(":hover"):!1,t=this._popover?this._popover.matches(":hover"):!1;return e||t}_calculatePosition(){if(!this._triggerElement||!this._popover)return{top:0,left:0,direction:"down"};const e=this._triggerElement.getBoundingClientRect(),t=this._popover.querySelector(".popover-content");if(!t)return{top:0,left:0,direction:"down"};this.classList.contains("hidden")&&(this.classList.remove("hidden"),this._popover.style.visibility="hidden");const s=t.getBoundingClientRect(),r=window.innerWidth,n=window.innerHeight,a=8;let l=this.getDirection(),o=0,h=0;switch(l){case"down":if(o=e.bottom+a,h=e.left+e.width/2-s.width/2,o+s.height>n){const c=e.top-s.height-a;c>=0?(l="up",o=c):(o=Math.max(0,n-s.height-a),o+s.height>n&&(o=0))}h<0&&(h=a),h+s.width>r&&(h=Math.max(a,r-s.width-a),h+s.width>r&&(h=r-s.width));break;case"up":if(o=e.top-s.height-a,h=e.left+e.width/2-s.width/2,o<0){const c=e.bottom+a;c+s.height<=n?(l="down",o=c):(o=Math.min(n-s.height-a,n-s.height),o<0&&(o=n-s.height))}h<0&&(h=a),h+s.width>r&&(h=Math.max(a,r-s.width-a),h+s.width>r&&(h=r-s.width));break;case"right":if(o=e.top+e.height/2-s.height/2,h=e.right+a,h+s.width>r){const c=e.left-s.width-a;c>=0?(l="left",h=c):(h=Math.max(0,r-s.width-a),h+s.width>r&&(h=r-s.width))}o<0&&(o=a),o+s.height>n&&(o=Math.max(a,n-s.height-a),o+s.height>n&&(o=n-s.height));break;case"left":if(o=e.top+e.height/2-s.height/2,h=e.left-s.width-a,h<0){const c=e.right+a;c+s.width<=r?(l="right",h=c):(h=Math.min(r-s.width-a,r-s.width),h<0&&(h=0))}o<0&&(o=a),o+s.height>n&&(o=Math.max(a,n-s.height-a),o+s.height>n&&(o=n-s.height));break}return{top:o,left:h,direction:l}}render(){const e=this.getId(),t=this.isOpen(),i=this.getPadding();if(e&&(this.id=e),t){if(this.classList.remove("hidden"),this.style.pointerEvents="auto",!this._clickOutsideHandler){const n=this;this._clickOutsideHandler=function(a){const l=a.composedPath(),o=l.includes(n);if(!(n._triggerElement&&l.includes(n._triggerElement))&&!o){n.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 n=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=n.filter(o=>!a.includes(o));s.className=[...l,i].join(" ")}Array.from(this.children).forEach(n=>{n!==this._overlay&&n!==this._popover&&n.parentElement===this&&s.appendChild(n)}),t?(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"})}))):!t&&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 e=document.documentElement.classList.contains("dark"),t=this._popover.querySelector(".popover-content");t&&(e?(t.classList.remove("bg-white"),t.classList.add("bg-gray-800")):(t.classList.remove("bg-gray-800"),t.classList.add("bg-white")))}_observeDarkMode(){this._darkModeObserver||(this._darkModeObserver=new MutationObserver(()=>{this._updateBackgroundColor()}),this._darkModeObserver.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}))}_updatePosition(e){if(!this._triggerElement||!this._popover)return;const t=this._popover.style.visibility!=="hidden";t||(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`,t||(this._popover.style.visibility="visible",e&&(!e.style.opacity||e.style.opacity==="")&&(e.style.transform="scale(0.97) translateY(10px)",e.style.opacity="0",e.style.transition="all 200ms ease-out",requestAnimationFrame(()=>{requestAnimationFrame(()=>{e.style.transform="scale(1) translateY(0)",e.style.opacity="1"})})))}_setupPositionListeners(){if(!this._scrollHandler&&this.isOpen()){const e=this;this._scrollHandler=function(){if(e.isOpen()&&e._popover){const t=e._popover.querySelector(".popover-content");t&&e._updatePosition(t)}},window.addEventListener("scroll",this._scrollHandler,!0)}if(!this._resizeHandler&&this.isOpen()){const e=this;this._resizeHandler=function(){if(e.isOpen()&&e._popover){const t=e._popover.querySelector(".popover-content");t&&e._updatePosition(t)}},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(t=>{if(t!==this){const i=t;typeof i.close=="function"?i.close():t.removeAttribute("open")}})}}customElements.get("mint-popover")||customElements.define("mint-popover",G);const le={name:"check",viewBox:"0 0 24 24",path:"M5 13l4 4L19 7",strokeLinecap:"round",strokeLinejoin:"round"};q(le);class X 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"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline","inline-flex","items-start","gap-2");const e=this.getAttribute("checked");this._checked=e!==null&&e!=="false",this.render()}disconnectedCallback(){this.removeEventListeners()}attributeChangedCallback(e,t,i){e==="checked"&&(this._checked=i!==null&&i!=="false",this._checkbox&&(this._checkbox.checked=this._checked)),t!==i&&(this.render(),e==="checked"&&this._checkbox&&this.updateVisualState())}get checked(){return this._checked}set checked(e){e?this.setAttribute("checked",""):this.removeAttribute("checked"),this._checked=!!e,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")||""}getCheckboxClasses(){const 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","focus-visible:ring-gray-400","dark:focus-visible:ring-gray-500","cursor-pointer","disabled:opacity-40","disabled:cursor-not-allowed"],t=this._checked?["bg-slate-800","dark:bg-slate-600","border-slate-800","dark:border-slate-600"]:["bg-white","dark:bg-gray-700","border-gray-300","dark:border-gray-500"];return[...e,...t].join(" ")}render(){const e=this.getLabel(),t=this.getInfo(),i=this.isDisabled();let s=this.querySelector(".mint-checkbox-wrapper");s||(s=document.createElement("div"),s.className="mint-checkbox-wrapper",this.insertBefore(s,this.firstChild)),this._checkbox?this._checkbox.parentElement!==s&&s.appendChild(this._checkbox):(this._checkbox=document.createElement("input"),this._checkbox.type="checkbox",s.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=i,this._changeHandler||this.setupEventListeners();const r=this.getId();r?this._checkbox.id=r:this._checkbox.removeAttribute("id");const n=this.getName();n?this._checkbox.name=n:this._checkbox.removeAttribute("name");const a=this.getValue();a?this._checkbox.value=a:this._checkbox.removeAttribute("value"),e?this._checkbox.setAttribute("aria-label",e):this._checkbox.removeAttribute("aria-label"),s.className=`mint-checkbox-wrapper ${this.getCheckboxClasses()}`,s.style.pointerEvents="none",this._checkbox.style.pointerEvents="auto";let l=s.querySelector("mint-icon");l||(l=document.createElement("mint-icon"),l.setAttribute("name","check"),l.className="w-3.5 h-3.5 text-white pointer-events-none absolute inset-0 m-auto",l.style.transition="opacity 200ms ease-out, transform 200ms ease-out",l.style.zIndex="1",s.appendChild(l)),this.updateVisualState();let o=this.querySelector(".mint-checkbox-label-container");if(e||t){o||(o=document.createElement("div"),o.className="mint-checkbox-label-container flex flex-col gap-0.5 flex-1",this.appendChild(o));let h=o.querySelector(".mint-checkbox-label");e?(h||(h=document.createElement("span"),h.className="mint-checkbox-label text-sm font-medium text-gray-900 dark:text-gray-100 cursor-pointer select-none",o.insertBefore(h,o.firstChild)),h.textContent=e,i?h.classList.add("opacity-40"):h.classList.remove("opacity-40")):h&&h.remove();let c=o.querySelector(".mint-checkbox-info");if(t?(c||(c=document.createElement("span"),c.className="mint-checkbox-info text-xs text-gray-500 dark:text-gray-400 cursor-pointer select-none",o.appendChild(c)),c.textContent=t,i?c.classList.add("opacity-40"):c.classList.remove("opacity-40")):c&&c.remove(),i)o.style.cursor="default",o._clickHandler&&(o.removeEventListener("click",o._clickHandler),o._clickHandler=null);else{o.style.cursor="pointer";const d=o._clickHandler;d&&o.removeEventListener("click",d),o._clickHandler=u=>{this._checkbox&&(u.target===this._checkbox||this._checkbox.contains(u.target)||u.composedPath().includes(this._checkbox))||this.toggle()},o.addEventListener("click",o._clickHandler)}}else o&&o.remove()}setupEventListeners(){this.removeEventListeners(),this._checkbox&&(this._changeHandler=e=>{e.stopPropagation(),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,value:this.getValue()},bubbles:!0,cancelable:!0});this.dispatchEvent(t)},this._checkbox.addEventListener("change",this._changeHandler),this._mousedownHandler=e=>{e.stopPropagation();const t=this.querySelector(".mint-checkbox-wrapper");t&&!this.isDisabled()&&(t.classList.add("mint-checkbox-active"),this._checked?(t.style.backgroundColor="rgb(15 23 42)",t.style.boxShadow="inset 0 2px 4px rgba(0, 0, 0, 0.3)"):(t.style.backgroundColor="rgb(243 244 246)",t.style.boxShadow="inset 0 2px 4px rgba(0, 0, 0, 0.1)"),document.documentElement.classList.contains("dark")&&(this._checked?t.style.backgroundColor="rgb(51 65 85)":t.style.backgroundColor="rgb(31 41 55)"))},this._mouseupHandler=e=>{e.stopPropagation();const t=this.querySelector(".mint-checkbox-wrapper");t&&(t.classList.remove("mint-checkbox-active"),t.style.backgroundColor="",t.style.boxShadow="")},this._mouseleaveHandler=e=>{const t=this.querySelector(".mint-checkbox-wrapper");t&&(t.classList.remove("mint-checkbox-active"),t.style.backgroundColor="",t.style.boxShadow="")},this._checkbox.addEventListener("mousedown",this._mousedownHandler),this._checkbox.addEventListener("mouseup",this._mouseupHandler),this._checkbox.addEventListener("mouseleave",this._mouseleaveHandler),this._focusHandler=e=>{const t=this.querySelector(".mint-checkbox-wrapper");t&&this._checkbox&&requestAnimationFrame(()=>{this._checkbox&&this._checkbox.matches(":focus-visible")&&(t==null||t.classList.add("ring-2","ring-offset-1","ring-gray-400","dark:ring-gray-500"))})},this._blurHandler=()=>{const e=this.querySelector(".mint-checkbox-wrapper");e&&e.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=e=>{e.stopPropagation();const t=this.querySelector(".mint-checkbox-wrapper");t&&!this.isDisabled()&&(t.classList.add("mint-checkbox-active"),this._checked?(t.style.backgroundColor="rgb(15 23 42)",t.style.boxShadow="inset 0 2px 4px rgba(0, 0, 0, 0.3)"):(t.style.backgroundColor="rgb(243 244 246)",t.style.boxShadow="inset 0 2px 4px rgba(0, 0, 0, 0.1)"),document.documentElement.classList.contains("dark")&&(this._checked?t.style.backgroundColor="rgb(51 65 85)":t.style.backgroundColor="rgb(31 41 55)"))},this._touchendHandler=e=>{e.stopPropagation();const t=this.querySelector(".mint-checkbox-wrapper");t&&(t.classList.remove("mint-checkbox-active"),t.style.backgroundColor="",t.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))}updateVisualState(){const e=this.querySelector(".mint-checkbox-wrapper"),t=e==null?void 0:e.querySelector("mint-icon");t&&(t.style.opacity=this._checked?"1":"0",t.style.transform=this._checked?"scale(1)":"scale(0.8)"),e&&(e.className=`mint-checkbox-wrapper ${this.getCheckboxClasses()}`,e.classList.contains("mint-checkbox-active")||(e.style.backgroundColor="",e.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 e=new CustomEvent("change",{detail:{checked:this._checked},bubbles:!0,cancelable:!0});this.dispatchEvent(e)}}}customElements.get("mint-checkbox")||customElements.define("mint-checkbox",X);class K extends HTMLElement{constructor(){super(),this._radio=null,this._checked=!1,this._changeHandler=null,this._groupChangeHandler=null,this._clickHandler=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"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline","inline-flex","items-start","gap-2");const e=this.getAttribute("checked");this._checked=e!==null&&e!=="false",this.render()}disconnectedCallback(){this.removeEventListeners()}attributeChangedCallback(e,t,i){e==="checked"&&(this._checked=i!==null&&i!=="false",this._radio&&(this._radio.checked=this._checked)),t!==i&&(this.render(),e==="checked"&&this._radio&&this.updateVisualState())}get checked(){return this._checked}set checked(e){e?this.setAttribute("checked",""):this.removeAttribute("checked"),this._checked=!!e,this._radio&&(this._radio.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")||""}getChoiceClasses(){const e=["relative","inline-flex","items-center","justify-center","flex-shrink-0","w-5","h-5","rounded-full","border-2","transition-all","duration-200","outline-none","focus:outline-none","focus-visible:ring-2","focus-visible:ring-offset-1","focus-visible:ring-gray-400","dark:focus-visible:ring-gray-500","cursor-pointer","disabled:opacity-40","disabled:cursor-not-allowed"],t=this._checked?["bg-slate-800","dark:bg-slate-600","border-slate-800","dark:border-slate-600"]:["bg-white","dark:bg-gray-700","border-gray-300","dark:border-gray-500"];return[...e,...t].join(" ")}render(){const e=this.getLabel(),t=this.getInfo(),i=this.isDisabled();let s=this.querySelector(".mint-choice-wrapper");s||(s=document.createElement("div"),s.className="mint-choice-wrapper",this.insertBefore(s,this.firstChild)),this._radio?this._radio.parentElement!==s&&s.appendChild(this._radio):(this._radio=document.createElement("input"),this._radio.type="radio",s.appendChild(this._radio),this.setupEventListeners()),this._radio.className="absolute inset-0 w-full h-full opacity-0 cursor-pointer",this._radio.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._radio.checked=this._checked,this._radio.disabled=i,this._changeHandler||this.setupEventListeners();const r=this.getId();r?this._radio.id=r:this._radio.removeAttribute("id");const n=this.getName();n?this._radio.name=n:this._radio.removeAttribute("name");const a=this.getValue();a?this._radio.value=a:this._radio.removeAttribute("value"),e?this._radio.setAttribute("aria-label",e):this._radio.removeAttribute("aria-label"),s.className=`mint-choice-wrapper ${this.getChoiceClasses()}`,s.style.pointerEvents="none",this._radio.style.pointerEvents="auto";let l=s.querySelector(".mint-choice-indicator");l||(l=document.createElement("div"),l.className="mint-choice-indicator w-2.5 h-2.5 rounded-full bg-white pointer-events-none absolute inset-0 m-auto",l.style.transition="opacity 200ms ease-out, transform 200ms ease-out",l.style.zIndex="1",s.appendChild(l)),l.style.opacity=this._checked?"1":"0",l.style.transform=this._checked?"scale(1)":"scale(0.8)",this.updateVisualState();let o=this.querySelector(".mint-choice-label-container");if(e||t){o||(o=document.createElement("div"),o.className="mint-choice-label-container flex flex-col gap-0.5 flex-1",this.appendChild(o));let h=o.querySelector(".mint-choice-label");e?(h||(h=document.createElement("span"),h.className="mint-choice-label text-sm font-medium text-gray-900 dark:text-gray-100 cursor-pointer select-none",o.insertBefore(h,o.firstChild)),h.textContent=e,i?h.classList.add("opacity-40"):h.classList.remove("opacity-40")):h&&h.remove();let c=o.querySelector(".mint-choice-info");if(t?(c||(c=document.createElement("span"),c.className="mint-choice-info text-xs text-gray-500 dark:text-gray-400 cursor-pointer select-none",o.appendChild(c)),c.textContent=t,i?c.classList.add("opacity-40"):c.classList.remove("opacity-40")):c&&c.remove(),i)o.style.cursor="default",o._clickHandler&&(o.removeEventListener("click",o._clickHandler),o._clickHandler=null);else{o.style.cursor="pointer";const d=o._clickHandler;d&&o.removeEventListener("click",d),o._clickHandler=u=>{this._radio&&(u.target===this._radio||this._radio.contains(u.target)||u.composedPath().includes(this._radio))||this.select()},o.addEventListener("click",o._clickHandler)}}else o&&o.remove()}setupEventListeners(){this.removeEventListeners(),this._radio&&(this._changeHandler=e=>{e.stopPropagation();const t=this._checked;if(this._checked=this._radio.checked,this._checked?this.hasAttribute("checked")||this.setAttribute("checked",""):this.hasAttribute("checked")&&this.removeAttribute("checked"),this.updateVisualState(),this._checked){const i=this._radio.name;i&&document.querySelectorAll(`input[type="radio"][name="${i}"]`).forEach(r=>{if(r!==this._radio){const n=r.closest("mint-choice");n&&n.updateVisualState&&(n._checked=r.checked,r.checked?n.hasAttribute("checked")||n.setAttribute("checked",""):n.hasAttribute("checked")&&n.removeAttribute("checked"),n.updateVisualState())}})}if(t!==this._checked){const i=new CustomEvent("change",{detail:{checked:this._checked,value:this.getValue()},bubbles:!0,cancelable:!0});this.dispatchEvent(i)}},this._radio.addEventListener("change",this._changeHandler),this._groupChangeHandler=e=>{const t=e.target;t!==this._radio&&t.type==="radio"&&t.name===this._radio.name&&t.checked&&setTimeout(()=>{this._radio&&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.updateVisualState())},0)},document.addEventListener("change",this._groupChangeHandler,!0),this._clickHandler=e=>{const t=this._radio.name;t&&document.querySelectorAll(`input[type="radio"][name="${t}"]`).forEach(s=>{if(s!==this._radio){const r=s.closest("mint-choice");r&&r.updateVisualState&&(r._checked=s.checked,s.checked?r.hasAttribute("checked")||r.setAttribute("checked",""):r.hasAttribute("checked")&&r.removeAttribute("checked"),r.updateVisualState())}}),requestAnimationFrame(()=>{this._radio&&(this._checked=this._radio.checked,this.updateVisualState())})},this._radio.addEventListener("click",this._clickHandler),this._mousedownHandler=e=>{e.stopPropagation();const t=this.querySelector(".mint-choice-wrapper");t&&!this.isDisabled()&&(t.classList.add("mint-choice-active"),this._checked?(t.style.backgroundColor="rgb(15 23 42)",t.style.boxShadow="inset 0 2px 4px rgba(0, 0, 0, 0.3)"):(t.style.backgroundColor="rgb(243 244 246)",t.style.boxShadow="inset 0 2px 4px rgba(0, 0, 0, 0.1)"),document.documentElement.classList.contains("dark")&&(this._checked?t.style.backgroundColor="rgb(51 65 85)":t.style.backgroundColor="rgb(31 41 55)"))},this._mouseupHandler=e=>{e.stopPropagation();const t=this.querySelector(".mint-choice-wrapper");t&&(t.classList.remove("mint-choice-active"),t.style.backgroundColor="",t.style.boxShadow="")},this._mouseleaveHandler=e=>{const t=this.querySelector(".mint-choice-wrapper");t&&(t.classList.remove("mint-choice-active"),t.style.backgroundColor="",t.style.boxShadow="")},this._radio.addEventListener("mousedown",this._mousedownHandler),this._radio.addEventListener("mouseup",this._mouseupHandler),this._radio.addEventListener("mouseleave",this._mouseleaveHandler),this._touchstartHandler=e=>{e.stopPropagation();const t=this.querySelector(".mint-choice-wrapper");t&&!this.isDisabled()&&(t.classList.add("mint-choice-active"),this._checked?(t.style.backgroundColor="rgb(15 23 42)",t.style.boxShadow="inset 0 2px 4px rgba(0, 0, 0, 0.3)"):(t.style.backgroundColor="rgb(243 244 246)",t.style.boxShadow="inset 0 2px 4px rgba(0, 0, 0, 0.1)"),document.documentElement.classList.contains("dark")&&(this._checked?t.style.backgroundColor="rgb(51 65 85)":t.style.backgroundColor="rgb(31 41 55)"))},this._touchendHandler=e=>{e.stopPropagation();const t=this.querySelector(".mint-choice-wrapper");t&&(t.classList.remove("mint-choice-active"),t.style.backgroundColor="",t.style.boxShadow="")},this._radio.addEventListener("touchstart",this._touchstartHandler),this._radio.addEventListener("touchend",this._touchendHandler),this._focusHandler=e=>{const t=this.querySelector(".mint-choice-wrapper");t&&this._radio&&requestAnimationFrame(()=>{this._radio&&this._radio.matches(":focus-visible")&&(t==null||t.classList.add("ring-2","ring-offset-1","ring-gray-400","dark:ring-gray-500"))})},this._blurHandler=()=>{const e=this.querySelector(".mint-choice-wrapper");e&&e.classList.remove("ring-2","ring-offset-1","ring-gray-400","dark:ring-gray-500")},this._radio.addEventListener("focus",this._focusHandler),this._radio.addEventListener("blur",this._blurHandler))}removeEventListeners(){this._radio&&(this._changeHandler&&(this._radio.removeEventListener("change",this._changeHandler),this._changeHandler=null),this._groupChangeHandler&&(document.removeEventListener("change",this._groupChangeHandler,!0),this._groupChangeHandler=null),this._clickHandler&&(this._radio.removeEventListener("click",this._clickHandler),this._clickHandler=null),this._mousedownHandler&&(this._radio.removeEventListener("mousedown",this._mousedownHandler),this._mousedownHandler=null),this._mouseupHandler&&(this._radio.removeEventListener("mouseup",this._mouseupHandler),this._mouseupHandler=null),this._mouseleaveHandler&&(this._radio.removeEventListener("mouseleave",this._mouseleaveHandler),this._mouseleaveHandler=null),this._touchstartHandler&&(this._radio.removeEventListener("touchstart",this._touchstartHandler),this._touchstartHandler=null),this._touchendHandler&&(this._radio.removeEventListener("touchend",this._touchendHandler),this._touchendHandler=null),this._focusHandler&&(this._radio.removeEventListener("focus",this._focusHandler),this._focusHandler=null),this._blurHandler&&(this._radio.removeEventListener("blur",this._blurHandler),this._blurHandler=null))}updateVisualState(){const e=this.querySelector(".mint-choice-wrapper"),t=e==null?void 0:e.querySelector(".mint-choice-indicator");t&&(t.style.opacity=this._checked?"1":"0",t.style.transform=this._checked?"scale(1)":"scale(0.8)"),e&&(e.className=`mint-choice-wrapper ${this.getChoiceClasses()}`,e.classList.contains("mint-choice-active")||(e.style.backgroundColor="",e.style.boxShadow=""))}select(){if(this._radio&&!this.isDisabled()){this._radio.checked=!0,this._radio.dispatchEvent(new Event("change",{bubbles:!0})),this._checked=!0,this.hasAttribute("checked")||this.setAttribute("checked","");const e=this._radio.name;e&&document.querySelectorAll(`input[type="radio"][name="${e}"]`).forEach(s=>{if(s!==this._radio){const r=s.closest("mint-choice");r&&r.updateVisualState&&(r._checked=s.checked,s.checked?r.hasAttribute("checked")||r.setAttribute("checked",""):r.hasAttribute("checked")&&r.removeAttribute("checked"),r.updateVisualState())}}),this.updateVisualState();const t=new CustomEvent("change",{detail:{checked:this._checked,value:this.getValue()},bubbles:!0,cancelable:!0});this.dispatchEvent(t)}}}customElements.get("mint-choice")||customElements.define("mint-choice",K);class Z 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"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline","inline-block"),this.getLabel()||console.error('mint-input: The "label" attribute is required. Please provide a label for the input.'),this.render()}disconnectedCallback(){this.removeEventListeners()}attributeChangedCallback(e,t,i){if(t!==i){if(e==="error"||e==="error-message"){this._renderErrorState(),this._element&&(this._element.className=this.getInputClasses()),this._colorTextInput&&(this._colorTextInput.className=this.getInputClasses());return}this.render()}}getType(){return this.getAttribute("type")||"text"}getRows(){const e=this.getAttribute("rows");return e?parseInt(e,10):3}_getNormalizedType(){const e=this.getType();return e==="datetime"?"datetime-local":e==="money"?"text":e==="textarea"?"textarea":e}_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 e,t,i;return this._isColor()?((e=this._colorPicker)==null?void 0:e.value)||((t=this._colorTextInput)==null?void 0:t.value)||this.getAttribute("value")||"#000000":((i=this._element)==null?void 0:i.value)||this.getAttribute("value")||""}set value(e){this._isColor()?(this._colorPicker&&(this._colorPicker.value=e||"#000000"),this._colorTextInput&&(this._colorTextInput.value=e||"#000000")):this._element&&(this._element.value=e),e?this.setAttribute("value",e):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 e=this._isTextarea(),t=!!this.getIcon(),i=this._isColor(),s=this._isNumber(),r=this.hasError(),n=["w-full",t||i?"pl-10":"px-3.5",t||i?"pr-3.5":s?"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",e?"transition-colors transition-opacity":"transition-all","duration-200","outline-none","focus:outline-none","disabled:opacity-40","disabled:cursor-not-allowed","readonly:cursor-default",e?"resize-y":"",s?"[appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none":""],a=["border-2",r?"border-red-300 dark:border-red-300":"border-gray-200 dark:border-gray-600"],l=["focus-visible:ring-2","focus-visible:ring-offset-1",r?"focus-visible:ring-red-400 dark:focus-visible:ring-red-500":"focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500"];return[...n,...a,...l].filter(Boolean).join(" ")}render(){var v,C,S,y;this.getType();const e=this._getNormalizedType(),t=this._isTextarea(),i=this._isMoney(),s=this._isColor(),r=this.getPlaceholder(),n=this.isDisabled(),a=this.isReadonly(),l=this.isRequired(),o=this.getId(),h=this.getName(),c=this.getAttribute("value")||(s?"#000000":""),d=this.getRows(),u=this.getIcon(),f=this.getLabel(),g=this.getInfo();if(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=c||"#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=p=>{this._colorPickerWrapper&&this._colorPicker&&this._colorPicker.matches(":focus-visible")&&requestAnimationFrame(()=>{var k;this._colorPicker&&this._colorPicker.matches(":focus-visible")&&((k=this._colorPickerWrapper)==null||k.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 k;const p=((k=this._colorPicker)==null?void 0:k.value)||"#000000";this._colorPickerWrapper&&(this._colorPickerWrapper.style.backgroundColor=p),this._colorTextInput&&(this._colorTextInput.value=p),this.setAttribute("value",p),this.dispatchEvent(new CustomEvent("input",{detail:{value:p},bubbles:!0,cancelable:!0}))}),this._colorPicker.addEventListener("change",()=>{var k;const p=((k=this._colorPicker)==null?void 0:k.value)||"#000000";this._colorPickerWrapper&&(this._colorPickerWrapper.style.backgroundColor=p),this.setAttribute("value",p),this.dispatchEvent(new CustomEvent("change",{detail:{value:p},bubbles:!0,cancelable:!0}))})),this._colorTextInput||(this._colorTextInput=document.createElement("input"),this._colorTextInput.type="text",this._colorTextInput.className=this.getInputClasses(),this._colorTextInput.placeholder=r||"#000000",this._colorTextInput.pattern="^#[0-9A-Fa-f]{6}$",this._wrapper.appendChild(this._colorTextInput),this._colorTextInput.addEventListener("input",()=>{var k;const p=((k=this._colorTextInput)==null?void 0:k.value)||"";/^#[0-9A-Fa-f]{6}$/.test(p)&&(this._colorPicker&&(this._colorPicker.value=p),this.setAttribute("value",p),this.dispatchEvent(new CustomEvent("input",{detail:{value:p},bubbles:!0,cancelable:!0})))}),this._colorTextInput.addEventListener("blur",()=>{var k,E;const p=((k=this._colorTextInput)==null?void 0:k.value)||"";/^#[0-9A-Fa-f]{6}$/.test(p)?(this._colorPicker&&(this._colorPicker.value=p),this.setAttribute("value",p)):this._colorPicker&&this._colorTextInput&&(this._colorTextInput.value=this._colorPicker.value),this.dispatchEvent(new CustomEvent("change",{detail:{value:((E=this._colorPicker)==null?void 0:E.value)||"#000000"},bubbles:!0,cancelable:!0}))}));const b=c||"#000000";if(this._colorPicker&&this._colorPicker.value!==b&&(this._colorPicker.value=b),this._colorPickerWrapper&&(this._colorPickerWrapper.style.backgroundColor=b),this._colorTextInput&&this._colorTextInput.value!==b&&(this._colorTextInput.value=b),this._colorPicker&&(this._colorPicker.disabled=n),this._colorPickerWrapper&&(n?(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=n,this._colorTextInput.readOnly=a,this._colorTextInput.required=l),this._colorTextInput){const p=this._colorTextInput;o?p.id=o:p.removeAttribute("id"),h?p.name=h:p.removeAttribute("name"),p.setAttribute("aria-invalid",this.hasError()?"true":"false"),this._element=p}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),u&&!t?this._icon?this._icon.setAttribute("name",u):(this._icon=document.createElement("mint-icon"),this._icon.setAttribute("name",u),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()&&!t){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 b=document.createElement("mint-icon");b.setAttribute("name","caret-up"),b.className="w-[1rem] h-[1rem]",this._numberIncrementButton.appendChild(b),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 p=document.createElement("mint-icon");p.setAttribute("name","caret-down"),p.className="w-[1rem] h-[1rem]",this._numberDecrementButton.appendChild(p),this._numberSpinnerContainer.appendChild(this._numberDecrementButton),this._numberIncrementButton.addEventListener("click",k=>{if(k.preventDefault(),k.stopPropagation(),this._input&&!this._input.disabled&&!this._input.readOnly){const E=parseFloat(this._input.value)||0,I=parseFloat(this._input.step)||1,w=this._input.min?parseFloat(this._input.min):void 0,A=this._input.max?parseFloat(this._input.max):void 0;let L=E+I;A!==void 0&&L>A&&(L=A),w!==void 0&&L<w&&(L=w),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",k=>{if(k.preventDefault(),k.stopPropagation(),this._input&&!this._input.disabled&&!this._input.readOnly){const E=parseFloat(this._input.value)||0,I=parseFloat(this._input.step)||1,w=this._input.min?parseFloat(this._input.min):void 0,A=this._input.max?parseFloat(this._input.max):void 0;let L=E-I;w!==void 0&&L<w&&(L=w),A!==void 0&&L>A&&(L=A),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=n||a),this._numberDecrementButton&&(this._numberDecrementButton.disabled=n||a)}else this._numberSpinnerContainer&&(this._numberSpinnerContainer.remove(),this._numberSpinnerContainer=null,this._numberIncrementButton=null,this._numberDecrementButton=null);if(t){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=r,this._textarea.disabled=n,this._textarea.readOnly=a,this._textarea.required=l,this._textarea.rows=d,this._textarea.setAttribute("aria-invalid",this.hasError()?"true":"false"),c!==this._textarea.value&&(this._textarea.value=c),o?this._textarea.id=o:this._textarea.removeAttribute("id"),h?this._textarea.name=h:this._textarea.removeAttribute("name"),this._textarea.className=this.getInputClasses(),this.firstChild&&this.firstChild!==this._wrapper&&this.firstChild.nodeType===Node.TEXT_NODE){const b=this.firstChild.textContent;b&&!this._textarea.value&&(this._textarea.value=b.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=e,this._input.placeholder=r,this._input.disabled=n,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")),c!==this._input.value&&(this._input.value=c),o?this._input.id=o:this._input.removeAttribute("id"),h?this._input.name=h:this._input.removeAttribute("name"),this._input.className=this.getInputClasses(),this.firstChild&&this.firstChild!==this._wrapper&&this.firstChild.nodeType===Node.TEXT_NODE){const b=this.firstChild.textContent;b&&!this._input.value&&(this._input.value=b.trim()),this.removeChild(this.firstChild)}let m=this.querySelector(".mint-input-label-container");if(f||g){m||(m=document.createElement("div"),m.className="mint-input-label-container flex flex-col gap-0.5 mb-[.25rem]",this._wrapper&&this._wrapper.parentElement===this?this.insertBefore(m,this._wrapper):this.insertBefore(m,this.firstChild));let b=m.querySelector(".mint-input-label");if(f){b||(b=document.createElement("label"),b.className="mint-input-label text-sm font-medium text-gray-900 dark:text-gray-100 select-none",m.insertBefore(b,m.firstChild)),b.textContent=f;const k=o||((v=this._element)==null?void 0:v.id)||((C=this._colorTextInput)==null?void 0:C.id)||((S=this._input)==null?void 0:S.id)||((y=this._textarea)==null?void 0:y.id);if(k)b.setAttribute("for",k);else{const E=`mint-input-${Math.random().toString(36).substr(2,9)}`;this._element?this._element.id=E:this._colorTextInput?this._colorTextInput.id=E:this._input?this._input.id=E:this._textarea&&(this._textarea.id=E),b.setAttribute("for",E)}n?b.classList.add("opacity-40"):b.classList.remove("opacity-40")}else b&&b.remove();let p=m.querySelector(".mint-input-info");g?(p||(p=document.createElement("span"),p.className="mint-input-info text-xs text-gray-500 dark:text-gray-400 select-none",m.appendChild(p)),p.textContent=g,n?p.classList.add("opacity-40"):p.classList.remove("opacity-40")):p&&p.remove()}else m&&m.remove();this._renderErrorState()}_renderErrorState(){const e=this.hasError(),t=this.getErrorMessage();let i=this.querySelector(".mint-input-error");e&&t?(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=t):i&&i.remove()}setupEventListeners(){this._element&&(this._element.addEventListener("input",()=>{var t;const e=((t=this._element)==null?void 0:t.value)||"";e?this.setAttribute("value",e):this.removeAttribute("value"),this.dispatchEvent(new CustomEvent("input",{detail:{value:e},bubbles:!0,cancelable:!0}))}),this._element.addEventListener("blur",()=>{var t;const e=((t=this._element)==null?void 0:t.value)||"";e?this.setAttribute("value",e):this.removeAttribute("value"),this.dispatchEvent(new CustomEvent("change",{detail:{value:e},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 e;this._isColor()&&this._colorTextInput?this._colorTextInput.focus():(e=this._element)==null||e.focus()}blur(){var e;this._isColor()&&this._colorTextInput?this._colorTextInput.blur():(e=this._element)==null||e.blur()}}customElements.get("mint-input")||customElements.define("mint-input",Z);class Q 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"]}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 e=this.closest("form");e&&e.removeEventListener("reset",this._resetHandler),this._resetHandler=null}}attributeChangedCallback(e,t,i){if(t!==i){if(e==="error"||e==="error-message"){const s=this.hasError(),r=this.getErrorMessage();this._applyErrorVisuals(s,r,this.isDisabled());return}this.render(),this._input&&this._setupPopoverWithRetry()}}getValue(){return this.getAttribute("value")||""}setValue(e){e?(this.setAttribute("value",e),this._textInput&&(this._textInput.value=e),this._parseValue(e)):(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 e=this.getAttribute("shortcuts");if(!e)return[];try{const t=JSON.parse(e);if(Array.isArray(t))return t.map(i=>({label:i.label,action:this._createShortcutAction(i.action)}))}catch{const i=e.trim();if(i&&typeof window[i]=="function"){const s=window[i]();if(Array.isArray(s))return s.map(r=>({label:r.label,action:typeof r.action=="function"?r.action:this._createShortcutAction(r.action)}))}}return[]}_createShortcutAction(e){return typeof e=="function"?e:typeof e=="string"&&typeof window[e]=="function"?window[e]:()=>null}_getDefaultShortcuts(){const e=[{label:"Today",action:()=>new Date}];return this._isRange&&e.push({label:"This Week",action:()=>{const t=new Date,i=t.getDay(),s=new Date(t);s.setDate(t.getDate()-i),s.setHours(0,0,0,0);const r=new Date(s);return r.setDate(s.getDate()+6),r.setHours(23,59,59,999),{start:s,end:r}}},{label:"This Month",action:()=>{const t=new Date,i=new Date(t.getFullYear(),t.getMonth(),1),s=new Date(t.getFullYear(),t.getMonth()+1,0);return s.setHours(23,59,59,999),{start:i,end:s}}}),e}_getFormatTokens(e){const t=[];let i=0;const s=e.toLowerCase();for(;i<s.length;){const r=s[i];if(r==="d"||r==="m"||r==="y"){let n=1,a=i+1;for(;a<s.length&&s[a]===r;)n++,a++;t.push({type:"part",part:r,len:n}),i=a}else t.push({type:"sep",value:e[i]}),i++}return t}_createPartInput(e,t,i,s,r){const n=document.createElement("input");return n.type="text",n.inputMode="numeric",n.pattern="\\d*",n.maxLength=e,n.placeholder=t,n.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",n.disabled=i,n.readOnly=s,n.required=r,e===4?n.className+=" w-[40px]":e===2&&(n.className+=" w-[30px]"),n}_buildValueFromParts(e,t){let i=0;return t.map(s=>{var n;if(s.type==="sep")return s.value;const r=((n=e[i])==null?void 0:n.value)||"";return i++,r}).join("")}_applyDateToParts(e,t,i,s){if(!t.length)return;if(!e){t.forEach(l=>l.value="");return}const r=this._formatDate(e,s);let n=0,a=0;i.forEach(l=>{if(l.type==="sep")n+=l.value.length;else{const o=r.substr(n,l.len);t[a]&&(t[a].value=o),a++,n+=l.len}})}_syncHiddenInput(){if(!this._hiddenInput)return;const e=this.getFormat(),t=this._getFormatTokens(e),i=this._buildValueFromParts(this._startPartInputs,t);if(this._isRange){const s=this._buildValueFromParts(this._endPartInputs,t);this._hiddenInput.value=s?`${i} - ${s}`:i}else this._hiddenInput.value=i}_focusNext(e,t){if(t+1<e.length){const i=e[t+1];i.focus(),i.setSelectionRange(0,i.value.length)}}_focusPrev(e,t){if(t-1>=0){const i=e[t-1];i.focus(),i.setSelectionRange(i.value.length,i.value.length)}}_attachPartInputHandlers(e,t,i){e.forEach((s,r)=>{const n=s.maxLength||2;s.addEventListener("input",()=>{s.value=s.value.replace(/\D/g,"").slice(0,n),s.value.length>=n&&this._focusNext(e,r),this._syncHiddenInput()}),s.addEventListener("keydown",a=>{a.key==="Backspace"&&s.selectionStart===0&&s.selectionEnd===0&&this._focusPrev(e,r),a.key==="ArrowLeft"&&s.selectionStart===0&&s.selectionEnd===0&&(this._focusPrev(e,r),a.preventDefault()),a.key==="ArrowRight"&&s.selectionStart===s.value.length&&s.selectionEnd===s.value.length&&(this._focusNext(e,r),a.preventDefault())}),s.addEventListener("blur",a=>{var o;this._syncHiddenInput();const l=a.relatedTarget;l&&i.contains(l)||(this._handleBlur(((o=this._hiddenInput)==null?void 0:o.value)||""),this._exitInputMode())})})}_splitRangeInput(e,t){const i=e.split(/\s*-\s*/);return i.length>=2?[i[0],i.slice(1).join("-")]:[e]}_parseValue(e){const t=this.getFormat(),i=this._getFormatTokens(t);if(this._isRange){const[s,r]=this._splitRangeInput(e,t),n=s?this._parseDateString(s,t):null,a=r?this._parseDateString(r,t):null;if(n&&a){const[l,o]=n<=a?[n,a]:[a,n];this._selectedStartDate=l,this._selectedEndDate=o,this._currentMonth=l.getMonth(),this._currentYear=l.getFullYear()}else n&&(this._selectedStartDate=n,this._selectedEndDate=null,this._currentMonth=n.getMonth(),this._currentYear=n.getFullYear());this._applyDateToParts(this._selectedStartDate,this._startPartInputs,i,t),this._applyDateToParts(this._selectedEndDate,this._endPartInputs,i,t)}else{const s=this._parseDateString(e,t);s&&!isNaN(s.getTime())?(this._selectedStartDate=s,this._selectedEndDate=null,this._currentMonth=s.getMonth(),this._currentYear=s.getFullYear(),this._applyDateToParts(s,this._startPartInputs,i,t)):this._applyDateToParts(null,this._startPartInputs,i,t)}this._syncHiddenInput(),this._updateDisplayText()}_parseDateString(e,t){const i=/[\/\-\.\s]+/;if(i.test(e)){const _=e.split(i).filter(v=>v.length>0),m=t.split(/[\/\-\.\s]+/).filter(v=>v.length>0);if(_.length===m.length){let v=0,C=0,S=0;for(let y=0;y<m.length;y++){const b=m[y].toLowerCase(),p=_[y];if(b.includes("d"))v=parseInt(p,10);else if(b.includes("m"))C=parseInt(p,10)-1;else if(b.includes("y")){let k=parseInt(p,10);const E=b.length,I=p.length;I===2&&E===4?k=Math.floor(new Date().getFullYear()/100)*100+k:I===2&&E===2&&(k=Math.floor(new Date().getFullYear()/100)*100+k),S=k}}if(v&&C>=0&&C<=11&&S){const y=new Date(S,C,v);if(!isNaN(y.getTime())&&y.getDate()===v&&y.getMonth()===C&&y.getFullYear()===S)return y}}}const r=e.replace(/[\/\-\.]/g,""),n=t.replace(/[\/\-\.]/g,"").toLowerCase();let a=n.indexOf("d"),l=n.indexOf("m"),o=n.indexOf("y");const h=[{char:"d",index:a},{char:"m",index:l},{char:"y",index:o}].sort((_,m)=>_.index-m.index);let c=0,d=0,u=0,f=0;n.length,r.length;for(const _ of h)if(_.char==="d"){const m=n.lastIndexOf("d")-n.indexOf("d")+1,v=r.substr(f,m);if(v.length===0)return null;c=parseInt(v,10),f+=v.length}else if(_.char==="m"){const m=n.lastIndexOf("m")-n.indexOf("m")+1,v=r.substr(f,m);if(v.length===0)return null;d=parseInt(v,10)-1,f+=v.length}else if(_.char==="y"){const m=n.lastIndexOf("y")-n.indexOf("y")+1,v=r.substr(f),C=Math.min(m,v.length),S=v.substr(0,C);if(S.length===0)return null;let y=parseInt(S,10);C===2&&m===4?y=Math.floor(new Date().getFullYear()/100)*100+y:C===2&&m===2&&(y=Math.floor(new Date().getFullYear()/100)*100+y),u=y,f+=C}if(!c||d<0||d>11||!u)return null;const g=new Date(u,d,c);return isNaN(g.getTime())||g.getDate()!==c||g.getMonth()!==d||g.getFullYear()!==u?null:g}_formatDate(e,t){const i=e.getDate(),s=e.getMonth()+1,r=e.getFullYear(),n=t.toLowerCase();let a=t;return n.includes("dd")?a=a.replace(/dd/gi,String(i).padStart(2,"0")):n.includes("d")&&(a=a.replace(/d/gi,String(i))),n.includes("mm")?a=a.replace(/mm/gi,String(s).padStart(2,"0")):n.includes("m")&&(a=a.replace(/m/gi,String(s))),n.includes("yyyy")?a=a.replace(/yyyy/gi,String(r)):n.includes("yy")&&(a=a.replace(/yy/gi,String(r).substr(2))),a}_formatDatePhp(e,t){const i=e.getDate(),s=e.getMonth()+1,r=e.getFullYear(),n=["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"],h=(u,f=2)=>u.toString().padStart(f,"0"),c=u=>{const f=u%10,g=u%100;return f===1&&g!==11?"st":f===2&&g!==12?"nd":f===3&&g!==13?"rd":"th"};let d="";for(let u=0;u<t.length;u++){const f=t[u];if(f==="\\"&&u+1<t.length){d+=t[u+1],u++;continue}switch(f){case"Y":d+=r.toString();break;case"y":d+=r.toString().slice(-2);break;case"m":d+=h(s);break;case"n":d+=s.toString();break;case"M":d+=o[s-1];break;case"F":d+=l[s-1];break;case"d":d+=h(i);break;case"j":d+=i.toString();break;case"D":d+=a[e.getDay()];break;case"l":d+=n[e.getDay()];break;case"S":d+=c(i);break;default:d+=f;break}}return d}_validateDateString(e,t){const i=this._parseDateString(e,t);return i!==null&&!isNaN(i.getTime())}render(){const e=this.getLabel(),t=this.getInfo(),i=this.getValue(),s=this.isDisabled(),r=this.isReadonly(),n=this.isRequired(),a=this.getId(),l=this.getName(),o=this.getFormat(),h=this.hasError(),c=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||t){d||(d=document.createElement("div"),d.className="mint-date-picker-label-container flex flex-col gap-0.5 mb-[.25rem]",this.insertBefore(d,this._input));let m=d.querySelector(".mint-date-picker-label");e?(m||(m=document.createElement("label"),m.className="mint-date-picker-label text-sm font-medium text-gray-900 dark:text-gray-100 select-none",d.insertBefore(m,d.firstChild)),m.textContent=e,a&&this._textInput&&m.setAttribute("for",a)):m&&m.remove();let v=d.querySelector(".mint-date-picker-info");t?(v||(v=document.createElement("span"),v.className="mint-date-picker-info text-xs text-gray-500 dark:text-gray-400 select-none",d.appendChild(v)),v.textContent=t):v&&v.remove()}else d&&d.remove();this._hiddenInput||(this._hiddenInput=document.createElement("input"),this._hiddenInput.type="hidden",this._hiddenInput.value=i||"",this._textInput=this._hiddenInput,this._input.appendChild(this._hiddenInput)),a&&(this._hiddenInput.id=a),l&&(this._hiddenInput.name=l),this._hiddenInput.value=i||"",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,c,s),u.innerHTML="",this._displayEl=document.createElement("div"),this._displayEl.className="flex-1 text-gray-900 dark:text-white cursor-text select-none focus:outline-none",this._displayEl.tabIndex=s?-1:0,this._displayEl.addEventListener("click",()=>{s||r||this._enterInputMode()}),this._displayEl.addEventListener("keydown",m=>{s||r||(m.key==="Enter"||m.key===" ")&&(m.preventDefault(),this._enterInputMode())}),this._inputsWrapperEl=document.createElement("div"),this._inputsWrapperEl.className="flex items-center gap-1 w-full";const f=this._getFormatTokens(o);this._startPartInputs=[],this._endPartInputs=[];const g=m=>{const v=document.createDocumentFragment();return f.forEach(C=>{if(C.type==="sep"){const S=document.createElement("span");S.textContent=C.value,S.className="text-gray-400 dark:text-gray-500 select-none",v.appendChild(S)}else{const S=C.part==="d"?"dd":C.part==="m"?"mm":C.len===2?"yy":"yyyy",y=this._createPartInput(C.len,S,s,r,n);m==="start"?this._startPartInputs.push(y):this._endPartInputs.push(y),v.appendChild(y)}}),v};if(this._inputsWrapperEl.appendChild(g("start")),this._isRange){const m=document.createElement("span");m.textContent=" - ",m.className="text-gray-400 dark:text-gray-500 select-none",this._inputsWrapperEl.appendChild(m),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||s||r||this._enterInputMode()}),this._attachPartInputHandlers(this._startPartInputs,f,u),this._isRange&&this._attachPartInputHandlers(this._endPartInputs,f,u),this._parseValue(i),this._syncHiddenInput(),this._updateDisplayText(),this._iconButton)this._iconButton.disabled=s||r,!s&&!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-2 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 m=`date-icon-${Math.random().toString(36).substr(2,9)}`;this._iconButton.id=m;const v=document.createElement("mint-icon");v.setAttribute("name","calendar"),v.className="w-4 h-4 pointer-events-none",this._iconButton.appendChild(v),this._iconButton.addEventListener("click",()=>{s||r||this._enterInputMode()}),this._input.prepend(this._iconButton),this._iconButton.disabled=s||r}this._renderErrorState(h,c)}_renderErrorState(e,t){let i=this.querySelector(".mint-date-picker-error");e&&t?(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=t):i&&i.remove()}_applyErrorVisuals(e,t,i){if(this._renderErrorState(e,t),this._fieldsContainer){const s=this._getFieldContainerClass(e,i);this._fieldsContainer.className=s}this._hiddenInput&&this._hiddenInput.setAttribute("aria-invalid",e?"true":"false")}_attachFormResetListener(){const e=this.closest("form");!e||this._resetHandler||(this._resetHandler=()=>{this.setValue(""),this._clearPartInputs(this._startPartInputs),this._clearPartInputs(this._endPartInputs),this._isInputMode=!1,this._updateDisplayText(),this._applyErrorVisuals(!1,"",this.isDisabled())},e.addEventListener("reset",this._resetHandler))}_clearPartInputs(e){e.forEach(t=>{t.value=""})}_getFieldContainerClass(e,t){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",e?"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",e?"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(" ")+(t?" opacity-40 cursor-not-allowed":"")}_handleInputChange(e){}_cleanInputValue(e,t){return e}_handleBlur(e){const t=this.getFormat();if(!e){this.setValue(""),this._updateDisplayText();return}if(this._isRange){const[i,s]=this._splitRangeInput(e,t),r=i?this._parseDateString(i,t):null,n=s?this._parseDateString(s,t):null;if(r&&n){const[a,l]=r<=n?[r,n]:[n,r],o=this._formatDate(a,t),h=this._formatDate(l,t),c=`${o} - ${h}`;this.setValue(c),this._applyDateToParts(a,this._startPartInputs,this._getFormatTokens(t),t),this._applyDateToParts(l,this._endPartInputs,this._getFormatTokens(t),t),this._selectedStartDate=a,this._selectedEndDate=l,this._currentMonth=a.getMonth(),this._currentYear=a.getFullYear()}else if(r){const a=this._formatDate(r,t);this.setValue(a),this._applyDateToParts(r,this._startPartInputs,this._getFormatTokens(t),t),this._applyDateToParts(null,this._endPartInputs,this._getFormatTokens(t),t),this._selectedStartDate=r,this._selectedEndDate=null,this._currentMonth=r.getMonth(),this._currentYear=r.getFullYear()}else this.setValue(""),this._applyDateToParts(null,this._startPartInputs,this._getFormatTokens(t),t),this._applyDateToParts(null,this._endPartInputs,this._getFormatTokens(t),t),this._selectedStartDate=null,this._selectedEndDate=null}else if(this._validateDateString(e,t)){const i=this._parseDateString(e,t);if(i){const s=this._formatDate(i,t);this.setValue(s),this._applyDateToParts(i,this._startPartInputs,this._getFormatTokens(t),t),this._selectedStartDate=i,this._selectedEndDate=null,this._currentMonth=i.getMonth(),this._currentYear=i.getFullYear()}}else this.setValue(""),this._applyDateToParts(null,this._startPartInputs,this._getFormatTokens(t),t),this._selectedStartDate=null,this._selectedEndDate=null}_setupPopoverWithRetry(e=0){if(!this._iconButton){e<10&&requestAnimationFrame(()=>{this._setupPopoverWithRetry(e+1)});return}const t=10,i=this._iconButton.id;i&&this._iconButton.isConnected?document.getElementById(i)?this._createPopover(i):e<t&&requestAnimationFrame(()=>{this._setupPopoverWithRetry(e+1)}):e<t&&requestAnimationFrame(()=>{this._setupPopoverWithRetry(e+1)})}_createPopover(e){if(!e)return;if(!document.getElementById(e)){setTimeout(()=>{this._createPopover(e)},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",e),this._popoverObserver||(this._popoverObserver=new MutationObserver(i=>{i.forEach(s=>{var r;if(s.type==="attributes"&&s.attributeName==="open")if((r=this._popover)==null?void 0:r.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._popoverObserver.observe(this._popover,{attributes:!0,attributeFilter:["open"]})),requestAnimationFrame(()=>{this._buildCalendar()}))})});else{if(this._popover.getAttribute("trigger-id")!==e){this._popover.setAttribute("trigger-id",e);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 e=this._popover.querySelector(".popover-content");if(e){for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(this._calendarContainer)}else this._popover.appendChild(this._calendarContainer)}_buildCalendarView(){if(!this._calendarContainer)return;const e=this._getDaysInMonth(this._currentMonth,this._currentYear),t=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"],r=this.getShortcuts(),n=r.length>0;this._calendarContainer.className=n?"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 h=document.createElement("button");h.type="button",h.tabIndex=0,h.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",h.setAttribute("data-keep-popover-open","true");const c=document.createElement("mint-icon");c.setAttribute("name","caret-left"),c.className="w-4 h-4",h.appendChild(c),h.addEventListener("click",()=>{this._currentMonth===0?(this._currentMonth=11,this._currentYear--):this._currentMonth--,this._buildCalendar()}),o.appendChild(h);const d=document.createElement("div");d.className="flex items-center gap-2";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=i[this._currentMonth],u.addEventListener("click",()=>{this._viewMode="month",this._buildCalendar()}),d.appendChild(u);const f=document.createElement("button");f.type="button",f.tabIndex=0,f.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",f.setAttribute("data-keep-popover-open","true"),f.textContent=String(this._currentYear),f.addEventListener("click",()=>{this._viewMode="year",this._buildCalendar()}),d.appendChild(f),o.appendChild(d);const g=document.createElement("button");g.type="button",g.tabIndex=0,g.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",g.setAttribute("data-keep-popover-open","true");const _=document.createElement("mint-icon");_.setAttribute("name","caret-right"),_.className="w-4 h-4",g.appendChild(_),g.addEventListener("click",()=>{this._currentMonth===11?(this._currentMonth=0,this._currentYear++):this._currentMonth++,this._buildCalendar()}),o.appendChild(g);const m=document.createElement("div");m.className="grid grid-cols-7 mb-2",s.forEach(y=>{const b=document.createElement("div");b.className="text-xs font-medium text-gray-500 dark:text-gray-400 text-center py-1",b.textContent=y,m.appendChild(b)});const v=document.createElement("div");v.className="grid grid-cols-7";for(let y=0;y<t;y++){const b=document.createElement("div");b.className="w-8 h-8",v.appendChild(b)}const C=this.getMin()?this._parseDateString(this.getMin(),this.getFormat()):null,S=this.getMax()?this._parseDateString(this.getMax(),this.getFormat()):null;for(let y=1;y<=e;y++){const b=new Date(this._currentYear,this._currentMonth,y),p=this._isToday(b),k=this._isDateSelected(b),E=this._isDateInRange(b),I=C&&b<C||S&&b>S;let w="rounded-md";if(this._isRange&&this._selectedStartDate&&this._selectedEndDate){const L=this._isSameDate(b,this._selectedStartDate),M=this._isSameDate(b,this._selectedEndDate);L&&M?w="rounded-md":L?w="rounded-l-md":M?w="rounded-r-md":E&&(w="rounded-none")}else k&&!this._isRange&&(w="rounded-md");const A=document.createElement("button");A.type="button",A.disabled=!!I,A.tabIndex=I?-1:0,A.className=`w-full h-8 ${w} 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":E?"bg-slate-100 dark:bg-slate-700 text-slate-800 dark:text-slate-200":p?"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"} ${I?"opacity-40 cursor-not-allowed":""}`,A.textContent=y.toString(),I||A.addEventListener("click",()=>{this._handleDateClick(b)}),v.appendChild(A)}if(n){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 b=document.createElement("div");b.className="relative md:relative md:flex-1 md:min-h-0";const p=document.createElement("div");p.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",p.style.scrollbarWidth="none",p.style.msOverflowStyle="none",p.style.setProperty("-webkit-overflow-scrolling","touch");const k=document.createElement("style");k.textContent=`
|
|
45
45
|
.mint-date-shortcuts-row::-webkit-scrollbar {
|
|
46
46
|
display: none;
|
|
47
47
|
}
|
|
@@ -65,4 +65,4 @@
|
|
|
65
65
|
background: rgba(255, 255, 255, 0.2);
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
|
-
`,p.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 E=document.createElement("div");E.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",b.appendChild(E);const I=document.createElement("div");I.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",b.appendChild(I);const w=document.createElement("div");w.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",b.appendChild(w);const A=document.createElement("div");A.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",b.appendChild(A);const L=()=>{if(window.innerWidth>=768){const D=p.scrollTop,H=p.scrollHeight,T=p.clientHeight;D>0?w.style.opacity="1":w.style.opacity="0",D+T<H-1?A.style.opacity="1":A.style.opacity="0",E.style.opacity="0",I.style.opacity="0"}else{const D=p.scrollLeft,H=p.scrollWidth,T=p.clientWidth;D>0?E.style.opacity="1":E.style.opacity="0",D+T<H-1?I.style.opacity="1":I.style.opacity="0",w.style.opacity="0",A.style.opacity="0"}};p.addEventListener("scroll",L),window.addEventListener("resize",L),setTimeout(L,0),r.forEach(M=>{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=M.label,D.setAttribute("data-keep-popover-open","true"),D.addEventListener("click",()=>{const H=M.action();if(H){if(this._isRange&&"start"in H&&"end"in H){this._selectedStartDate=H.start,this._selectedEndDate=H.end;const T=this.getFormat(),N=this._formatDate(H.start,T),se=this._formatDate(H.end,T),re=`${N} - ${se}`;this.setValue(re),this._currentMonth=H.start.getMonth(),this._currentYear=H.start.getFullYear()}else if(H instanceof Date){this._selectedStartDate=H,this._selectedEndDate=null;const T=this.getFormat(),N=this._formatDate(H,T);this.setValue(N),this._currentMonth=H.getMonth(),this._currentYear=H.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}))}}),p.appendChild(D)}),b.appendChild(p),y.appendChild(b),a.appendChild(y)}l.appendChild(o),l.appendChild(m),l.appendChild(v),a.appendChild(l),this._calendarContainer.appendChild(a)}_buildMonthView(){if(!this._calendarContainer)return;const e=["January","February","March","April","May","June","July","August","September","October","November","December"],t=document.createElement("div");t.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()}),t.appendChild(i);const r=document.createElement("button");r.type="button",r.tabIndex=0,r.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",r.setAttribute("data-keep-popover-open","true"),r.textContent=String(this._currentYear),r.addEventListener("click",()=>{this._viewMode="year",this._buildCalendar()}),t.appendChild(r);const n=document.createElement("button");n.type="button",n.tabIndex=0,n.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",n.setAttribute("data-keep-popover-open","true");const a=document.createElement("mint-icon");a.setAttribute("name","caret-right"),a.className="w-4 h-4",n.appendChild(a),n.addEventListener("click",()=>{this._currentYear++,this._buildCalendar()}),t.appendChild(n);const l=document.createElement("div");l.className="grid grid-cols-3 gap-2",e.forEach((o,h)=>{const c=document.createElement("button");c.type="button",c.tabIndex=0,c.setAttribute("data-keep-popover-open","true");const d=this._currentMonth===h;c.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 ${d?"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"}`,c.textContent=o,c.addEventListener("click",()=>{this._currentMonth=h,this._viewMode="calendar",this._buildCalendar()}),l.appendChild(c)}),this._calendarContainer.appendChild(t),this._calendarContainer.appendChild(l)}_buildYearView(){if(!this._calendarContainer)return;const e=this._currentYear-6,t=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 r=document.createElement("mint-icon");r.setAttribute("name","caret-left"),r.className="w-4 h-4",s.appendChild(r),s.addEventListener("click",()=>{this._currentYear-=12,this._buildCalendar()}),i.appendChild(s);const n=document.createElement("div");n.className="text-sm font-medium text-gray-900 dark:text-gray-100",n.textContent=`${e} - ${t}`,i.appendChild(n);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 h=e;h<=t;h++){const c=document.createElement("button");c.type="button",c.tabIndex=0,c.setAttribute("data-keep-popover-open","true");const d=this._currentYear===h;c.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 ${d?"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"}`,c.textContent=String(h),c.addEventListener("click",()=>{this._currentYear=h,this._viewMode="calendar",this._buildCalendar()}),o.appendChild(c)}this._calendarContainer.appendChild(i),this._calendarContainer.appendChild(o)}_getDaysInMonth(e,t){return new Date(t,e+1,0).getDate()}_getFirstDayOfMonth(e,t){return new Date(t,e,1).getDay()}_isToday(e){const t=new Date;return e.getDate()===t.getDate()&&e.getMonth()===t.getMonth()&&e.getFullYear()===t.getFullYear()}_isDateSelected(e){return this._isRange?this._selectedStartDate!==null&&this._isSameDate(e,this._selectedStartDate)||this._selectedEndDate!==null&&this._isSameDate(e,this._selectedEndDate):this._selectedStartDate!==null&&this._isSameDate(e,this._selectedStartDate)}_isDateInRange(e){return!this._isRange||!this._selectedStartDate||!this._selectedEndDate?!1:e>=this._selectedStartDate&&e<=this._selectedEndDate}_hasIncompleteRange(){return this._isRange&&this._selectedStartDate!==null&&this._selectedEndDate===null}_isSameDate(e,t){return e.getDate()===t.getDate()&&e.getMonth()===t.getMonth()&&e.getFullYear()===t.getFullYear()}_handleDateClick(e){const t=this.getFormat();if(this._isRange){if(!this._selectedStartDate||this._selectedStartDate&&this._selectedEndDate?(this._selectedStartDate=e,this._selectedEndDate=null):this._selectedStartDate&&!this._selectedEndDate&&(e<this._selectedStartDate?(this._selectedEndDate=this._selectedStartDate,this._selectedStartDate=e):this._selectedEndDate=e),this._selectedStartDate&&this._selectedEndDate){const i=this._formatDate(this._selectedStartDate,t),s=this._formatDate(this._selectedEndDate,t),r=`${i} - ${s}`;this.setValue(r),this._textInput&&(this._textInput.value=r),this._popover&&typeof this._popover.close=="function"&&this._popover.close()}else if(this._selectedStartDate){const i=this._formatDate(this._selectedStartDate,t);this.setValue(i),this._textInput&&(this._textInput.value=i)}}else{this._selectedStartDate=e;const i=this._formatDate(e,t);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 e=this.getDisplayFormat();let t="";this._isRange?this._selectedStartDate&&this._selectedEndDate?t=`${this._formatDatePhp(this._selectedStartDate,e)} - ${this._formatDatePhp(this._selectedEndDate,e)}`:this._selectedStartDate&&(t=this._formatDatePhp(this._selectedStartDate,e)):this._selectedStartDate&&(t=this._formatDatePhp(this._selectedStartDate,e)),t?(this._displayEl.textContent=t,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._isInputMode=!0,this._displayEl&&this._inputsWrapperEl&&(this._displayEl.style.display="none",this._inputsWrapperEl.style.display="flex"),this._startPartInputs.length>0)){const e=this._startPartInputs[0];requestAnimationFrame(()=>{e.focus();try{e.setSelectionRange(0,e.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())}_getFocusableElements(){if(!this._calendarContainer)return[];const e=["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(e)).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 e=this;this._focusTrapHandler=function(t){var l;if(t.key!=="Tab")return;if(!e._popover||!e._popover.hasAttribute("open")){e._removeFocusTrap();return}const i=e._getFocusableElements();if(i.length===0)return;const s=i[0],r=i[i.length-1],n=document.activeElement;if(!(((l=e._calendarContainer)==null?void 0:l.contains(n))||!1)){t.preventDefault(),s.focus();return}if(t.shiftKey&&n===s){t.preventDefault(),r.focus();return}if(!t.shiftKey&&n===r){t.preventDefault(),s.focus();return}},this._escapeHandler=function(t){(t.key==="Escape"||t.key==="Esc")&&e._popover&&e._popover.hasAttribute("open")&&(t.preventDefault(),t.stopPropagation(),typeof e._popover.close=="function"&&e._popover.close())},document.addEventListener("keydown",this._focusTrapHandler,!0),document.addEventListener("keydown",this._escapeHandler,!0),requestAnimationFrame(()=>{const t=this._getFocusableElements();t.length>0&&t[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",Q);class ee 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"]}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)}attributeChangedCallback(e,t,i){if(t!==i){if(e==="error"||e==="error-message"){this._renderErrorState(),this._select&&(this._select.className=this.getSelectClasses(),this._select.setAttribute("aria-invalid",this.hasError()?"true":"false"));return}if(e==="value"&&this._select){this._select.value=i||"";return}this.render()}}getName(){return this.getAttribute("name")||""}getValue(){return this.getAttribute("value")||(this._select?this._select.value:"")}setValue(e){this._select&&(this._select.value=e,this.setAttribute("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 e=this.hasError(),t=this.isMultiple(),i=["w-full","px-3.5",t?"pr-3.5":"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","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",e?"border-red-300 dark:border-red-300":"border-gray-200 dark:border-gray-600"],r=["focus-visible:ring-2","focus-visible:ring-offset-1",e?"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,...r].filter(Boolean).join(" ")}render(){const e=[];this._select&&Array.from(this._select.options).forEach(d=>{e.push(d.cloneNode(!0))});const t=Array.from(this.querySelectorAll("option")).filter(d=>d.parentElement===this).map(d=>d.cloneNode(!0));for(;this.firstChild;)this.removeChild(this.firstChild);this._wrapper=null,this._select=null;const i=this.getLabel(),s=this.getInfo(),r=this.getId(),n=this.getName(),a=this.getValue(),l=this.isDisabled(),o=this.isMultiple(),h=this.hasError();if(i){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(i);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),n&&(this._select.name=n),l&&(this._select.disabled=!0),o&&(this._select.multiple=!0),a&&(this._select.value=a),this._select.setAttribute("aria-invalid",h?"true":"false");const c=e.length>0?e:t;if(c.length>0&&c.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._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),o)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(s){const d=document.createElement("div");d.className="mt-1 text-xs text-gray-500 dark:text-gray-400",d.textContent=s,this.appendChild(d)}this._renderErrorState()}_renderErrorState(){const e=this.hasError(),t=this.getErrorMessage();let i=this.querySelector(".mint-select-error");e&&t?(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=t):i&&i.remove()}}customElements.get("mint-select")||customElements.define("mint-select",ee);class te 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"]}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 e=this.closest("form");e&&e.removeEventListener("reset",this._resetHandler),this._resetHandler=null}}attributeChangedCallback(e,t,i){if(t!==i){if(e==="error"||e==="error-message"){this._updateDragStateClass(),this._renderErrorState(this.hasError(),this.getErrorMessage());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"}getName(){return this.getAttribute("name")||""}hasError(){return this.hasAttribute("error")}getErrorMessage(){return this.getAttribute("error-message")||""}isDisabled(){return this.hasAttribute("disabled")}render(){const e=this.getLabel(),t=this.getAccept(),i=this.isMultiple(),s=this.isDisabled(),r=this.getWidth(),n=this.getHeight(),a=this.getName(),l=this.hasError(),o=this.getErrorMessage();this._dropzone||(this._dropzone=document.createElement("div"),this.appendChild(this._dropzone)),this._updateDragStateClass(),this._dropzone.setAttribute("aria-invalid",l?"true":"false"),this._dropzone.style.width=r,this._dropzone.style.height=n,this._dropzone.style.minWidth=r,this._dropzone.style.minHeight=n,this._fileInput||(this._fileInput=document.createElement("input"),this._fileInput.type="file",this._fileInput.style.display="none",this._dropzone.appendChild(this._fileInput)),this._fileInput.accept=t,this._fileInput.multiple=i,this._fileInput.disabled=s,a?this._fileInput.name=a:this._fileInput.removeAttribute("name"),this._fileInput.setAttribute("aria-invalid",l?"true":"false");const h=this._dropzone.querySelector(".mint-dropzone-icon"),c=this._dropzone.querySelector(".mint-dropzone-label");h&&h.remove(),c&&c.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,o),this._renderPreviews()}_updateDragState(){this._dropzone&&this._updateDragStateClass()}_renderErrorState(e,t){let i=this.querySelector(".mint-dropzone-error");e&&t?(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=t):i&&i.remove()}_updateDragStateClass(){if(!this._dropzone)return;const e=this.isDisabled(),t=this.hasError(),r=`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`,n=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=t?"border-red-300 dark:border-red-300 bg-red-50/50 dark:bg-red-900/30":"",l=e?"opacity-40 cursor-not-allowed":"";this._dropzone.className=`${r} ${t?a:n} ${l}`.trim()}setupEventListeners(){this._listenersInitialized||(this._listenersInitialized=!0,this.removeEventListeners(),!(!this._dropzone||!this._fileInput||this.isDisabled())&&(this._onDropzoneClick||(this._onDropzoneClick=e=>{if(!(this.isDisabled()||!this._fileInput)&&e.target!==this._fileInput&&(e.stopPropagation(),e.preventDefault(),e.isTrusted))try{this._fileInput.click()}catch(t){console.debug("File chooser blocked:",t)}}),this._onDragOver||(this._onDragOver=e=>{e.preventDefault(),e.stopPropagation(),this.isDisabled()||this._isDragging||(this._isDragging=!0,this._wasDragging=!0,this._updateDragState())}),this._onDragLeave||(this._onDragLeave=e=>{var i;e.preventDefault(),e.stopPropagation();const t=(i=this._dropzone)==null?void 0:i.getBoundingClientRect();t&&(e.clientX<t.left||e.clientX>t.right||e.clientY<t.top||e.clientY>t.bottom)&&this._isDragging&&(this._isDragging=!1,this._wasDragging=!1,this._updateDragState())}),this._onDrop||(this._onDrop=e=>{var i;if(e.preventDefault(),e.stopPropagation(),this._isDragging&&(this._isDragging=!1,this._wasDragging=!1,this._updateDragState()),this.isDisabled())return;const t=(i=e.dataTransfer)==null?void 0:i.files;t&&t.length>0&&this._handleFiles(t)}),this._onFileInputInput||(this._onFileInputInput=e=>{e.stopImmediatePropagation(),e.stopPropagation()}),this._onFileInputChange||(this._onFileInputChange=e=>{if(e.stopImmediatePropagation(),e.stopPropagation(),this._isUpdatingFiles)return;const i=e.target.files;if(i&&i.length>0){const s=this.getAccept(),r=this.isMultiple(),n=[],a=[];for(let l=0;l<i.length;l++){const o=i[l];this._isFileAccepted(o,s)?n.push(o):a.push(o)}if(!r&&n.length>1&&(a.push(...n.slice(1)),n.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)}n.length>0&&this._applyValidFiles(n)}}),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._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._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(e){const t=this.getAccept(),i=this.isMultiple(),s=[],r=[];for(let n=0;n<e.length;n++){const a=e[n];this._isFileAccepted(a,t)?s.push(a):r.push(a)}if(!i&&s.length>1&&(r.push(...s.slice(1)),s.splice(1)),r.length>0){const n=new CustomEvent("dropRejected",{detail:{files:r,reason:"File type not accepted or multiple files not allowed"},bubbles:!0,cancelable:!0});this.dispatchEvent(n)}s.length>0&&this._applyValidFiles(s)}_isFileAccepted(e,t){var s;if(!t)return!0;const i=t.split(",").map(r=>r.trim().toLowerCase());for(const r of i)if(r.startsWith(".")){if("."+((s=e.name.split(".").pop())==null?void 0:s.toLowerCase())===r)return!0}else if(r.includes("/*")){const n=r.split("/")[0],a=e.type.split("/")[0];if(n===a)return!0}else if(e.type===r)return!0;return!1}_dispatchEvent(e,t){const i=t.target,s=new CustomEvent(e,{detail:{files:i.files?Array.from(i.files):[],value:i.value||""},bubbles:!0,cancelable:!0});this.dispatchEvent(s)}_dispatchSelectionEvents(){const t={files:[...this._selectedFiles],value:""};this.dispatchEvent(new CustomEvent("input",{detail:t,bubbles:!0,cancelable:!0,composed:!0})),this.dispatchEvent(new CustomEvent("change",{detail:t,bubbles:!0,cancelable:!0,composed:!0}))}_syncFileInputFromSelected(){if(!this._fileInput)return;const e=new DataTransfer;this._selectedFiles.forEach(t=>{try{e.items.add(t)}catch(i){console.warn("Failed to add file to DataTransfer:",i)}}),this._isUpdatingFiles=!0;try{this._fileInput.files=e.files}catch(t){console.warn("Failed to set files on input:",t)}setTimeout(()=>{this._isUpdatingFiles=!1},0)}get files(){var e;return this._syncFileInputFromSelected(),((e=this._fileInput)==null?void 0:e.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 e=document.createElement("div");e.className="mint-dropzone-previews-wrapper mt-3 w-full relative max-h-48";const t=document.createElement("div");t.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,h)=>{const c=document.createElement("div");if(c.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 _=document.createElement("img");_.className="w-12 h-12 object-cover rounded border border-gray-200 dark:border-gray-700";const g=URL.createObjectURL(o);this._previewUrls.push(g),_.src=g,c.appendChild(_)}else{const _=document.createElement("mint-icon");_.setAttribute("name","attach"),_.className="w-5 h-5 text-gray-500 dark:text-gray-300",c.appendChild(_)}const d=document.createElement("div");d.className="flex-1 text-sm text-gray-800 dark:text-gray-100 truncate",d.textContent=o.name,c.appendChild(d);const u=document.createElement("button");u.type="button",u.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 f=document.createElement("mint-icon");f.setAttribute("name","close"),f.className="w-4 h-4",u.appendChild(f),u.addEventListener("click",_=>{_.preventDefault(),_.stopPropagation(),this._removeFileAt(h)}),c.appendChild(u),t.appendChild(c)});const i=this.hasError(),s=this._isDragging;let r="from-white dark:from-gray-700";i?r="from-red-50 dark:from-red-900/30":s&&(r="from-gray-50 dark:from-gray-800");const n=document.createElement("div");n.className=`absolute top-0 left-0 right-0 h-4 pointer-events-none z-10 bg-gradient-to-b ${r} to-transparent opacity-0 transition-opacity duration-200`,e.appendChild(n);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 ${r} to-transparent opacity-100 transition-opacity duration-200`,e.appendChild(a);const l=()=>{const o=t.scrollTop,h=t.scrollHeight,c=t.clientHeight;o>0?n.style.opacity="1":n.style.opacity="0",o+c<h-1?a.style.opacity="1":a.style.opacity="0"};l(),t.addEventListener("scroll",l),e.appendChild(t),this._previewContainer=e,this._dropzone.appendChild(e),this._updateDragStateClass()}_removeFileAt(e){if(e<0||e>=this._selectedFiles.length)return;const[t]=this._selectedFiles.splice(e,1);t&&this._cleanupPreviewUrls(),this._syncFileInputFromSelected(),this._renderPreviews(),this._dispatchSelectionEvents()}_cleanupPreviewUrls(){this._previewUrls.forEach(e=>URL.revokeObjectURL(e)),this._previewUrls=[]}_attachFormResetListener(){const e=this.closest("form");!e||this._resetHandler||(this._resetHandler=()=>{this._selectedFiles=[],this._syncFileInputFromSelected(),this._renderPreviews(),this._cleanupPreviewUrls()},e.addEventListener("reset",this._resetHandler))}_applyValidFiles(e){if(this.isMultiple()){const i=e.filter(s=>!this._isDuplicateFile(s));this._selectedFiles.push(...i)}else this._selectedFiles=[e[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(e){return this._selectedFiles.some(t=>t.name===e.name&&t.size===e.size&&t.lastModified===e.lastModified)}}customElements.get("mint-dropzone")||customElements.define("mint-dropzone",te);class ie 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}static get observedAttributes(){return["action","method","enctype"]}connectedCallback(){this._render(),this._setupBlurValidation()}disconnectedCallback(){this._form&&this._submitHandler&&this._form.removeEventListener("submit",this._submitHandler,!0),this._hostSubmitHandler&&this.removeEventListener("submit",this._hostSubmitHandler),this._cleanupBlurValidation()}reset(){this._clearErrors(),this._form&&this._form.reset(),this._resetCustomFields()}attributeChangedCallback(e,t,i){this._applyFormAttributes()}_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._submitHandler=e=>this._handleSubmit(e),this._form.addEventListener("submit",function(e){var t;(t=this.closest("mint-form"))==null||t._handleSubmit(e)})}this._applyFormAttributes()}_applyFormAttributes(){if(!this._form)return;const e=this.getAttribute("action")||"",t=(this.getAttribute("method")||"POST").toUpperCase(),i=this.getAttribute("enctype")||"application/x-www-form-urlencoded";e&&(this._form.action=e),this._form.method=t,this._form.enctype=i}async _handleSubmit(e){if(e.preventDefault(),!this._form)return;this._clearErrors(),this._syncDropzoneFiles();const t=this._collectValidationRules(),i=new FormData(this._form),s=this._formDataToValues(i);if(!this._validate(s,t)){this.dispatchEvent(new CustomEvent("invalid",{detail:{errors:this._errors},bubbles:!0,cancelable:!0,composed:!0}));return}const n=new CustomEvent("submit",{detail:{formData:i,values:s},bubbles:!0,cancelable:!0,composed:!0});if(this.dispatchEvent(n),!n.defaultPrevented)try{const a=await this._submitData(i,s);this.dispatchEvent(new CustomEvent("submitsuccess",{detail:a,bubbles:!0,cancelable:!0}))}catch(a){this.dispatchEvent(new CustomEvent("submiterror",{detail:{error:a},bubbles:!0,cancelable:!0}))}}async _submitData(e,t){const i=this.getAttribute("action"),s=(this.getAttribute("method")||"POST").toUpperCase(),r=this.getAttribute("enctype")||"application/x-www-form-urlencoded";if(!i)return{status:0,ok:!0,data:{values:t}};const n=Array.from(e.values()).some(h=>h instanceof File);let a=null;const l={};let o=i;if(s==="GET"){const h=new URLSearchParams;e.forEach((c,d)=>{c instanceof File||h.append(d,String(c))}),o+=(i.includes("?")?"&":"?")+h.toString()}else if(r==="multipart/form-data"||n)a=e;else if(r==="application/json")a=JSON.stringify(t),l["Content-Type"]="application/json";else{const h=new URLSearchParams;e.forEach((c,d)=>{c instanceof File||h.append(d,String(c))}),a=h,l["Content-Type"]="application/x-www-form-urlencoded"}if(typeof fetch=="function"){const h=await fetch(o,{method:s,body:s==="GET"?null:a,headers:l}),c=await h.text().catch(()=>"");let d=c;try{d=JSON.parse(c)}catch{}if(!h.ok)throw{status:h.status,data:d};return{status:h.status,ok:h.ok,data:d}}return await new Promise((h,c)=>{const d=new XMLHttpRequest;d.open(s,o,!0),Object.entries(l).forEach(([u,f])=>d.setRequestHeader(u,f)),d.onload=function(){const{status:u,responseText:f}=d;if(u>=200&&u<300){let _=f;try{_=JSON.parse(f)}catch{}h({status:u,ok:!0,data:_})}else c({status:u,data:f})},d.onerror=function(){c({status:d.status,data:d.responseText})},d.send(s==="GET"?null:a)})}_formDataToValues(e){const t={};return e.forEach((i,s)=>{i instanceof File?(t[s]||(t[s]=[]),t[s].push(i)):s in t?Array.isArray(t[s])?(t[s].length>0&&t[s][0]instanceof File,t[s].push(i)):t[s]=[t[s],i]:t[s]=i}),this._form&&Array.from(this._form.querySelectorAll("mint-dropzone[name]")).forEach(s=>{const r=s.getAttribute("name");if(r&&typeof s.files<"u"&&s.files){const n=s.files;if(n.length>0){const a=Array.from(n);t[r]&&Array.isArray(t[r])?a.forEach(l=>{t[r].some(h=>h.name===l.name&&h.size===l.size&&h.lastModified===l.lastModified)||t[r].push(l)}):t[r]=a}}}),t}_collectValidationRules(){const e={};return this._form&&Array.from(this._form.querySelectorAll("[name][validation]")).forEach(i=>{const s=i.getAttribute("name")||"",r=i.getAttribute("validation");if(!s||!r)return;const n=this._parseRules(r);n.length&&(e[s]=n)}),e}_parseRules(e){if(!e)return[];try{const t=e.replace(/'/g,'"'),i=JSON.parse(t);if(Array.isArray(i))return i.map(s=>String(s))}catch{}return e.split(",").map(t=>t.trim()).filter(Boolean)}_validate(e,t){let i=!0;return this._errors={},Object.entries(t||{}).forEach(([s,r])=>{const n=Array.isArray(r)?r:[r],a=this._getFieldElements(s),l=this._extractFieldValue(a),o=this._validateRules(l,n);o?(i=!1,this._errors[s]=o,this._flagFieldError(a,o)):this._clearFieldError(a)}),i}_validateField(e){const t=this._collectValidationRules();if(!t[e])return;const i=t[e],s=Array.isArray(i)?i:[i],r=this._getFieldElements(e),n=this._extractFieldValue(r),a=this._validateRules(n,s);a?(this._errors[e]=a,this._flagFieldError(r,a)):(this._clearFieldError(r),delete this._errors[e])}_validateRules(e,t){for(const i of t){const[s,r]=i.split(":");switch(s){case"required":{if(e==null||typeof e=="string"&&e.trim()===""||e instanceof FileList&&e.length===0||Array.isArray(e)&&e.length===0)return"This field is required.";break}case"string":{if(typeof e!="string")return"Must be a string.";break}case"email":{if(typeof e=="string"&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e.trim()))return"Enter a valid email.";break}case"number":{const n=Number(e);if(Number.isNaN(n))return"Must be a number.";break}case"min":{const n=Number(r);if(Number.isNaN(n))break;if(typeof e=="string"&&e.trim().length<n)return`Must be at least ${n} characters.`;if(Array.isArray(e)&&e.length<n)return`Select at least ${n}.`;if(e instanceof FileList&&e.length<n)return`Upload at least ${n} files.`;if(e!=null&&!Number.isNaN(Number(e))&&Number(e)<n)return`Must be at least ${n}.`;break}case"max":{const n=Number(r);if(Number.isNaN(n))break;if(typeof e=="string"&&e.trim().length>n)return`Must be at most ${n} characters.`;if(Array.isArray(e)&&e.length>n)return`Select no more than ${n}.`;if(e instanceof FileList&&e.length>n)return`Upload no more than ${n} files.`;if(e!=null&&!Number.isNaN(Number(e))&&Number(e)>n)return`Must be at most ${n}.`;break}}}return null}_getFieldElements(e){if(!this._form)return[];const t=Array.from(this._form.querySelectorAll(`[name="${e}"]`)),i=t.filter(s=>s.tagName==="MINT-SELECT");if(i.length>0){const s=[];return i.forEach(r=>{const n=r.querySelector('select[name="'+e+'"]');n&&s.push(n)}),t.filter(r=>r.tagName!=="MINT-SELECT").concat(s)}return t}_extractFieldValue(e){if(e.length===0)return"";const t=e.find(s=>s instanceof HTMLSelectElement);if(t)return t.value;if(e.length>1){const s=e.filter(n=>n instanceof HTMLInputElement),r=s.filter(n=>n.checked);if(s.every(n=>n.type==="radio"))return r.length>0?r[0].value||"on":"";if(s.every(n=>n.type==="checkbox"))return r.map(n=>n.value||"on")}const i=e[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 n=i.getValue();if(n!=null&&n!=="")return n}const r=i.getAttribute("value");return r||""}return i.tagName==="MINT-DROPZONE"&&typeof i.files<"u"?i.files:typeof i.value<"u"?i.value:i.getAttribute("value")||""}_flagFieldError(e,t){e.length!==0&&e.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",t),s.setAttribute("data-mint-form-error","true"))})}_clearFieldError(e){e.length!==0&&e.forEach(t=>{(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement)&&t.removeAttribute("aria-invalid");const i=this._resolveHost(t);i&&(i.removeAttribute("error"),i.removeAttribute("error-message"),i.removeAttribute("data-mint-form-error"))})}_clearErrors(){this.querySelectorAll("[data-mint-form-error]").forEach(e=>{const t=e;t.removeAttribute("error"),t.removeAttribute("error-message"),t.removeAttribute("data-mint-form-error")}),this._form&&this._form.querySelectorAll('[aria-invalid="true"]').forEach(e=>{e.removeAttribute("aria-invalid")})}_resetCustomFields(){this.querySelectorAll("mint-input, mint-date-picker, mint-select, mint-dropzone, mint-checkbox, mint-choice, mint-switch").forEach(t=>{var s,r;t.removeAttribute("error"),t.removeAttribute("error-message");const i=t.tagName;if(i==="MINT-INPUT")try{t.value=""}catch{}else if(i==="MINT-DATE-PICKER")try{(s=t.setValue)==null||s.call(t,"")}catch{}else if(i==="MINT-SELECT")try{(r=t.setValue)==null||r.call(t,"")}catch{}else if(i==="MINT-DROPZONE"){const n=t.querySelector('input[type="file"]');n&&(n.value="")}else if(i==="MINT-CHECKBOX"||i==="MINT-CHOICE"){const n=t.querySelector('input[type="checkbox"], input[type="radio"]');n&&(n.checked=!1)}else if(i==="MINT-SWITCH"){const n=t.querySelector('input[type="checkbox"]');n&&(n.checked=!1)}})}_resolveHost(e){const t=e.closest("mint-input, mint-date-picker, mint-select, mint-dropzone, mint-checkbox, mint-choice, mint-switch");return t||e}_setupBlurValidation(){if(!this._form)return;const e=i=>{const s=i.target;if(!s)return;const r=this._findFieldElement(s);if(!r)return;const n=this._getFieldName(r);if(!n||!this._collectValidationRules()[n])return;const l=this._extractFieldValue([r]),o=l!=null&&(typeof l=="string"?l.trim()!=="":l instanceof FileList||Array.isArray(l)?l.length>0:!0),h=r.hasAttribute("data-mint-form-error")||s instanceof HTMLElement&&(s.hasAttribute("aria-invalid")||s.closest("[data-mint-form-error]"));(o||h)&&setTimeout(()=>{this._validateField(n)},0)};this._form.addEventListener("blur",e,!0),this._fieldBlurHandlers.set(this._form,e);const t=i=>{const s=i.target;if(!s)return;if(s instanceof HTMLSelectElement||s.tagName==="MINT-SELECT"||s.closest("mint-select")){const o=this._findFieldElement(s);if(!o)return;const h=this._getFieldName(o);if(!h||!this._collectValidationRules()[h])return;setTimeout(()=>{this._validateField(h)},0);return}const n=this._findFieldElement(s);if(!n)return;const a=this._getFieldName(n);!a||!this._collectValidationRules()[a]||(n.hasAttribute("data-mint-form-error")||s instanceof HTMLElement&&s.hasAttribute("aria-invalid"))&&setTimeout(()=>{this._validateField(a)},0)};this._form.addEventListener("change",t,!0),this._fieldChangeHandlers.set(this._form,t)}_findFieldElement(e){if(e.hasAttribute("name")&&(e.tagName.startsWith("MINT-")||e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement))return e;const t=e.closest("mint-input, mint-date-picker, mint-select, mint-dropzone, mint-checkbox, mint-choice, mint-switch");if(t&&t.hasAttribute("name"))return t;if((e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)&&e.hasAttribute("name"))return e;let i=e;for(;i&&i!==this._form;){if(i.hasAttribute("name"))return i;i=i.parentElement}return null}_getFieldName(e){return e.hasAttribute("name")||e.tagName.startsWith("MINT-")?e.getAttribute("name"):(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)&&e.name||null}_cleanupBlurValidation(){if(this._form&&this._fieldBlurHandlers.has(this._form)){const e=this._fieldBlurHandlers.get(this._form);e&&this._form.removeEventListener("blur",e,!0),this._fieldBlurHandlers.delete(this._form)}if(this._form&&this._fieldChangeHandlers.has(this._form)){const e=this._fieldChangeHandlers.get(this._form);e&&this._form.removeEventListener("change",e,!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(t=>{typeof t.syncFiles=="function"&&t.syncFiles()})}}customElements.get("mint-form")||customElements.define("mint-form",ie);exports.BackButton=$;exports.Button=F;exports.Card=W;exports.Checkbox=X;exports.Choice=K;exports.DatePicker=Q;exports.Dropzone=te;exports.Form=ie;exports.Grid=U;exports.Icon=B;exports.Input=Z;exports.Link=j;exports.Modal=J;exports.Page=Y;exports.Popover=G;exports.Select=ee;exports.Spinner=P;exports.Stack=R;exports.Switch=z;exports.Text=V;exports.default=F;
|
|
68
|
+
`,p.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 E=document.createElement("div");E.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",b.appendChild(E);const I=document.createElement("div");I.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",b.appendChild(I);const w=document.createElement("div");w.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",b.appendChild(w);const A=document.createElement("div");A.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",b.appendChild(A);const L=()=>{if(window.innerWidth>=768){const T=p.scrollTop,H=p.scrollHeight,D=p.clientHeight;T>0?w.style.opacity="1":w.style.opacity="0",T+D<H-1?A.style.opacity="1":A.style.opacity="0",E.style.opacity="0",I.style.opacity="0"}else{const T=p.scrollLeft,H=p.scrollWidth,D=p.clientWidth;T>0?E.style.opacity="1":E.style.opacity="0",T+D<H-1?I.style.opacity="1":I.style.opacity="0",w.style.opacity="0",A.style.opacity="0"}};p.addEventListener("scroll",L),window.addEventListener("resize",L),setTimeout(L,0),r.forEach(M=>{const T=document.createElement("button");T.type="button",T.tabIndex=0,T.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",T.textContent=M.label,T.setAttribute("data-keep-popover-open","true"),T.addEventListener("click",()=>{const H=M.action();if(H){if(this._isRange&&"start"in H&&"end"in H){this._selectedStartDate=H.start,this._selectedEndDate=H.end;const D=this.getFormat(),N=this._formatDate(H.start,D),re=this._formatDate(H.end,D),ne=`${N} - ${re}`;this.setValue(ne),this._currentMonth=H.start.getMonth(),this._currentYear=H.start.getFullYear()}else if(H instanceof Date){this._selectedStartDate=H,this._selectedEndDate=null;const D=this.getFormat(),N=this._formatDate(H,D);this.setValue(N),this._currentMonth=H.getMonth(),this._currentYear=H.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}))}}),p.appendChild(T)}),b.appendChild(p),y.appendChild(b),a.appendChild(y)}l.appendChild(o),l.appendChild(m),l.appendChild(v),a.appendChild(l),this._calendarContainer.appendChild(a)}_buildMonthView(){if(!this._calendarContainer)return;const e=["January","February","March","April","May","June","July","August","September","October","November","December"],t=document.createElement("div");t.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()}),t.appendChild(i);const r=document.createElement("button");r.type="button",r.tabIndex=0,r.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",r.setAttribute("data-keep-popover-open","true"),r.textContent=String(this._currentYear),r.addEventListener("click",()=>{this._viewMode="year",this._buildCalendar()}),t.appendChild(r);const n=document.createElement("button");n.type="button",n.tabIndex=0,n.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",n.setAttribute("data-keep-popover-open","true");const a=document.createElement("mint-icon");a.setAttribute("name","caret-right"),a.className="w-4 h-4",n.appendChild(a),n.addEventListener("click",()=>{this._currentYear++,this._buildCalendar()}),t.appendChild(n);const l=document.createElement("div");l.className="grid grid-cols-3 gap-2",e.forEach((o,h)=>{const c=document.createElement("button");c.type="button",c.tabIndex=0,c.setAttribute("data-keep-popover-open","true");const d=this._currentMonth===h;c.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 ${d?"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"}`,c.textContent=o,c.addEventListener("click",()=>{this._currentMonth=h,this._viewMode="calendar",this._buildCalendar()}),l.appendChild(c)}),this._calendarContainer.appendChild(t),this._calendarContainer.appendChild(l)}_buildYearView(){if(!this._calendarContainer)return;const e=this._currentYear-6,t=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 r=document.createElement("mint-icon");r.setAttribute("name","caret-left"),r.className="w-4 h-4",s.appendChild(r),s.addEventListener("click",()=>{this._currentYear-=12,this._buildCalendar()}),i.appendChild(s);const n=document.createElement("div");n.className="text-sm font-medium text-gray-900 dark:text-gray-100",n.textContent=`${e} - ${t}`,i.appendChild(n);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 h=e;h<=t;h++){const c=document.createElement("button");c.type="button",c.tabIndex=0,c.setAttribute("data-keep-popover-open","true");const d=this._currentYear===h;c.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 ${d?"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"}`,c.textContent=String(h),c.addEventListener("click",()=>{this._currentYear=h,this._viewMode="calendar",this._buildCalendar()}),o.appendChild(c)}this._calendarContainer.appendChild(i),this._calendarContainer.appendChild(o)}_getDaysInMonth(e,t){return new Date(t,e+1,0).getDate()}_getFirstDayOfMonth(e,t){return new Date(t,e,1).getDay()}_isToday(e){const t=new Date;return e.getDate()===t.getDate()&&e.getMonth()===t.getMonth()&&e.getFullYear()===t.getFullYear()}_isDateSelected(e){return this._isRange?this._selectedStartDate!==null&&this._isSameDate(e,this._selectedStartDate)||this._selectedEndDate!==null&&this._isSameDate(e,this._selectedEndDate):this._selectedStartDate!==null&&this._isSameDate(e,this._selectedStartDate)}_isDateInRange(e){return!this._isRange||!this._selectedStartDate||!this._selectedEndDate?!1:e>=this._selectedStartDate&&e<=this._selectedEndDate}_hasIncompleteRange(){return this._isRange&&this._selectedStartDate!==null&&this._selectedEndDate===null}_isSameDate(e,t){return e.getDate()===t.getDate()&&e.getMonth()===t.getMonth()&&e.getFullYear()===t.getFullYear()}_handleDateClick(e){const t=this.getFormat();if(this._isRange){if(!this._selectedStartDate||this._selectedStartDate&&this._selectedEndDate?(this._selectedStartDate=e,this._selectedEndDate=null):this._selectedStartDate&&!this._selectedEndDate&&(e<this._selectedStartDate?(this._selectedEndDate=this._selectedStartDate,this._selectedStartDate=e):this._selectedEndDate=e),this._selectedStartDate&&this._selectedEndDate){const i=this._formatDate(this._selectedStartDate,t),s=this._formatDate(this._selectedEndDate,t),r=`${i} - ${s}`;this.setValue(r),this._textInput&&(this._textInput.value=r),this._popover&&typeof this._popover.close=="function"&&this._popover.close()}else if(this._selectedStartDate){const i=this._formatDate(this._selectedStartDate,t);this.setValue(i),this._textInput&&(this._textInput.value=i)}}else{this._selectedStartDate=e;const i=this._formatDate(e,t);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 e=this.getDisplayFormat();let t="";this._isRange?this._selectedStartDate&&this._selectedEndDate?t=`${this._formatDatePhp(this._selectedStartDate,e)} - ${this._formatDatePhp(this._selectedEndDate,e)}`:this._selectedStartDate&&(t=this._formatDatePhp(this._selectedStartDate,e)):this._selectedStartDate&&(t=this._formatDatePhp(this._selectedStartDate,e)),t?(this._displayEl.textContent=t,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._isInputMode=!0,this._displayEl&&this._inputsWrapperEl&&(this._displayEl.style.display="none",this._inputsWrapperEl.style.display="flex"),this._startPartInputs.length>0)){const e=this._startPartInputs[0];requestAnimationFrame(()=>{e.focus();try{e.setSelectionRange(0,e.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())}_getFocusableElements(){if(!this._calendarContainer)return[];const e=["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(e)).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 e=this;this._focusTrapHandler=function(t){var l;if(t.key!=="Tab")return;if(!e._popover||!e._popover.hasAttribute("open")){e._removeFocusTrap();return}const i=e._getFocusableElements();if(i.length===0)return;const s=i[0],r=i[i.length-1],n=document.activeElement;if(!(((l=e._calendarContainer)==null?void 0:l.contains(n))||!1)){t.preventDefault(),s.focus();return}if(t.shiftKey&&n===s){t.preventDefault(),r.focus();return}if(!t.shiftKey&&n===r){t.preventDefault(),s.focus();return}},this._escapeHandler=function(t){(t.key==="Escape"||t.key==="Esc")&&e._popover&&e._popover.hasAttribute("open")&&(t.preventDefault(),t.stopPropagation(),typeof e._popover.close=="function"&&e._popover.close())},document.addEventListener("keydown",this._focusTrapHandler,!0),document.addEventListener("keydown",this._escapeHandler,!0),requestAnimationFrame(()=>{const t=this._getFocusableElements();t.length>0&&t[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",Q);class ee 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"]}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)}attributeChangedCallback(e,t,i){if(t!==i){if(e==="error"||e==="error-message"){this._renderErrorState(),this._select&&(this._select.className=this.getSelectClasses(),this._select.setAttribute("aria-invalid",this.hasError()?"true":"false"));return}if(e==="value"&&this._select){this._select.value=i||"";return}this.render()}}getName(){return this.getAttribute("name")||""}getValue(){return this.getAttribute("value")||(this._select?this._select.value:"")}setValue(e){this._select&&(this._select.value=e,this.setAttribute("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 e=this.hasError(),t=this.isMultiple(),i=["w-full","px-3.5",t?"pr-3.5":"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","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",e?"border-red-300 dark:border-red-300":"border-gray-200 dark:border-gray-600"],r=["focus-visible:ring-2","focus-visible:ring-offset-1",e?"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,...r].filter(Boolean).join(" ")}render(){const e=[];this._select&&Array.from(this._select.options).forEach(d=>{e.push(d.cloneNode(!0))});const t=Array.from(this.querySelectorAll("option")).filter(d=>d.parentElement===this).map(d=>d.cloneNode(!0));for(;this.firstChild;)this.removeChild(this.firstChild);this._wrapper=null,this._select=null;const i=this.getLabel(),s=this.getInfo(),r=this.getId(),n=this.getName(),a=this.getValue(),l=this.isDisabled(),o=this.isMultiple(),h=this.hasError();if(i){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(i);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),n&&(this._select.name=n),l&&(this._select.disabled=!0),o&&(this._select.multiple=!0),a&&(this._select.value=a),this._select.setAttribute("aria-invalid",h?"true":"false");const c=e.length>0?e:t;if(c.length>0&&c.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._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),o)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(s){const d=document.createElement("div");d.className="mt-1 text-xs text-gray-500 dark:text-gray-400",d.textContent=s,this.appendChild(d)}this._renderErrorState()}_renderErrorState(){const e=this.hasError(),t=this.getErrorMessage();let i=this.querySelector(".mint-select-error");e&&t?(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=t):i&&i.remove()}}customElements.get("mint-select")||customElements.define("mint-select",ee);class te 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"]}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 e=this.closest("form");e&&e.removeEventListener("reset",this._resetHandler),this._resetHandler=null}}attributeChangedCallback(e,t,i){if(t!==i){if(e==="error"||e==="error-message"){this._updateDragStateClass(),this._renderErrorState(this.hasError(),this.getErrorMessage());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"}getName(){return this.getAttribute("name")||""}hasError(){return this.hasAttribute("error")}getErrorMessage(){return this.getAttribute("error-message")||""}isDisabled(){return this.hasAttribute("disabled")}render(){const e=this.getLabel(),t=this.getAccept(),i=this.isMultiple(),s=this.isDisabled(),r=this.getWidth(),n=this.getHeight(),a=this.getName(),l=this.hasError(),o=this.getErrorMessage();this._dropzone||(this._dropzone=document.createElement("div"),this.appendChild(this._dropzone)),this._updateDragStateClass(),this._dropzone.setAttribute("aria-invalid",l?"true":"false"),this._dropzone.style.width=r,this._dropzone.style.height=n,this._dropzone.style.minWidth=r,this._dropzone.style.minHeight=n,this._fileInput||(this._fileInput=document.createElement("input"),this._fileInput.type="file",this._fileInput.style.display="none",this._dropzone.appendChild(this._fileInput)),this._fileInput.accept=t,this._fileInput.multiple=i,this._fileInput.disabled=s,a?this._fileInput.name=a:this._fileInput.removeAttribute("name"),this._fileInput.setAttribute("aria-invalid",l?"true":"false");const h=this._dropzone.querySelector(".mint-dropzone-icon"),c=this._dropzone.querySelector(".mint-dropzone-label");h&&h.remove(),c&&c.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,o),this._renderPreviews()}_updateDragState(){this._dropzone&&this._updateDragStateClass()}_renderErrorState(e,t){let i=this.querySelector(".mint-dropzone-error");e&&t?(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=t):i&&i.remove()}_updateDragStateClass(){if(!this._dropzone)return;const e=this.isDisabled(),t=this.hasError(),r=`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`,n=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=t?"border-red-300 dark:border-red-300 bg-red-50/50 dark:bg-red-900/30":"",l=e?"opacity-40 cursor-not-allowed":"";this._dropzone.className=`${r} ${t?a:n} ${l}`.trim()}setupEventListeners(){this._listenersInitialized||(this._listenersInitialized=!0,this.removeEventListeners(),!(!this._dropzone||!this._fileInput||this.isDisabled())&&(this._onDropzoneClick||(this._onDropzoneClick=e=>{if(!(this.isDisabled()||!this._fileInput)&&e.target!==this._fileInput&&(e.stopPropagation(),e.preventDefault(),e.isTrusted))try{this._fileInput.click()}catch(t){console.debug("File chooser blocked:",t)}}),this._onDragOver||(this._onDragOver=e=>{e.preventDefault(),e.stopPropagation(),this.isDisabled()||this._isDragging||(this._isDragging=!0,this._wasDragging=!0,this._updateDragState())}),this._onDragLeave||(this._onDragLeave=e=>{var i;e.preventDefault(),e.stopPropagation();const t=(i=this._dropzone)==null?void 0:i.getBoundingClientRect();t&&(e.clientX<t.left||e.clientX>t.right||e.clientY<t.top||e.clientY>t.bottom)&&this._isDragging&&(this._isDragging=!1,this._wasDragging=!1,this._updateDragState())}),this._onDrop||(this._onDrop=e=>{var i;if(e.preventDefault(),e.stopPropagation(),this._isDragging&&(this._isDragging=!1,this._wasDragging=!1,this._updateDragState()),this.isDisabled())return;const t=(i=e.dataTransfer)==null?void 0:i.files;t&&t.length>0&&this._handleFiles(t)}),this._onFileInputInput||(this._onFileInputInput=e=>{e.stopImmediatePropagation(),e.stopPropagation()}),this._onFileInputChange||(this._onFileInputChange=e=>{if(e.stopImmediatePropagation(),e.stopPropagation(),this._isUpdatingFiles)return;const i=e.target.files;if(i&&i.length>0){const s=this.getAccept(),r=this.isMultiple(),n=[],a=[];for(let l=0;l<i.length;l++){const o=i[l];this._isFileAccepted(o,s)?n.push(o):a.push(o)}if(!r&&n.length>1&&(a.push(...n.slice(1)),n.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)}n.length>0&&this._applyValidFiles(n)}}),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._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._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(e){const t=this.getAccept(),i=this.isMultiple(),s=[],r=[];for(let n=0;n<e.length;n++){const a=e[n];this._isFileAccepted(a,t)?s.push(a):r.push(a)}if(!i&&s.length>1&&(r.push(...s.slice(1)),s.splice(1)),r.length>0){const n=new CustomEvent("dropRejected",{detail:{files:r,reason:"File type not accepted or multiple files not allowed"},bubbles:!0,cancelable:!0});this.dispatchEvent(n)}s.length>0&&this._applyValidFiles(s)}_isFileAccepted(e,t){var s;if(!t)return!0;const i=t.split(",").map(r=>r.trim().toLowerCase());for(const r of i)if(r.startsWith(".")){if("."+((s=e.name.split(".").pop())==null?void 0:s.toLowerCase())===r)return!0}else if(r.includes("/*")){const n=r.split("/")[0],a=e.type.split("/")[0];if(n===a)return!0}else if(e.type===r)return!0;return!1}_dispatchEvent(e,t){const i=t.target,s=new CustomEvent(e,{detail:{files:i.files?Array.from(i.files):[],value:i.value||""},bubbles:!0,cancelable:!0});this.dispatchEvent(s)}_dispatchSelectionEvents(){const t={files:[...this._selectedFiles],value:""};this.dispatchEvent(new CustomEvent("input",{detail:t,bubbles:!0,cancelable:!0,composed:!0})),this.dispatchEvent(new CustomEvent("change",{detail:t,bubbles:!0,cancelable:!0,composed:!0}))}_syncFileInputFromSelected(){if(!this._fileInput)return;const e=new DataTransfer;this._selectedFiles.forEach(t=>{try{e.items.add(t)}catch(i){console.warn("Failed to add file to DataTransfer:",i)}}),this._isUpdatingFiles=!0;try{this._fileInput.files=e.files}catch(t){console.warn("Failed to set files on input:",t)}setTimeout(()=>{this._isUpdatingFiles=!1},0)}get files(){var e;return this._syncFileInputFromSelected(),((e=this._fileInput)==null?void 0:e.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 e=document.createElement("div");e.className="mint-dropzone-previews-wrapper mt-3 w-full relative max-h-48";const t=document.createElement("div");t.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,h)=>{const c=document.createElement("div");if(c.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 g=document.createElement("img");g.className="w-12 h-12 object-cover rounded border border-gray-200 dark:border-gray-700";const _=URL.createObjectURL(o);this._previewUrls.push(_),g.src=_,c.appendChild(g)}else{const g=document.createElement("mint-icon");g.setAttribute("name","attach"),g.className="w-5 h-5 text-gray-500 dark:text-gray-300",c.appendChild(g)}const d=document.createElement("div");d.className="flex-1 text-sm text-gray-800 dark:text-gray-100 truncate",d.textContent=o.name,c.appendChild(d);const u=document.createElement("button");u.type="button",u.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 f=document.createElement("mint-icon");f.setAttribute("name","close"),f.className="w-4 h-4",u.appendChild(f),u.addEventListener("click",g=>{g.preventDefault(),g.stopPropagation(),this._removeFileAt(h)}),c.appendChild(u),t.appendChild(c)});const i=this.hasError(),s=this._isDragging;let r="from-white dark:from-gray-700";i?r="from-red-50 dark:from-red-900/30":s&&(r="from-gray-50 dark:from-gray-800");const n=document.createElement("div");n.className=`absolute top-0 left-0 right-0 h-4 pointer-events-none z-10 bg-gradient-to-b ${r} to-transparent opacity-0 transition-opacity duration-200`,e.appendChild(n);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 ${r} to-transparent opacity-100 transition-opacity duration-200`,e.appendChild(a);const l=()=>{const o=t.scrollTop,h=t.scrollHeight,c=t.clientHeight;o>0?n.style.opacity="1":n.style.opacity="0",o+c<h-1?a.style.opacity="1":a.style.opacity="0"};l(),t.addEventListener("scroll",l),e.appendChild(t),this._previewContainer=e,this._dropzone.appendChild(e),this._updateDragStateClass()}_removeFileAt(e){if(e<0||e>=this._selectedFiles.length)return;const[t]=this._selectedFiles.splice(e,1);t&&this._cleanupPreviewUrls(),this._syncFileInputFromSelected(),this._renderPreviews(),this._dispatchSelectionEvents()}_cleanupPreviewUrls(){this._previewUrls.forEach(e=>URL.revokeObjectURL(e)),this._previewUrls=[]}_attachFormResetListener(){const e=this.closest("form");!e||this._resetHandler||(this._resetHandler=()=>{this._selectedFiles=[],this._syncFileInputFromSelected(),this._renderPreviews(),this._cleanupPreviewUrls()},e.addEventListener("reset",this._resetHandler))}_applyValidFiles(e){if(this.isMultiple()){const i=e.filter(s=>!this._isDuplicateFile(s));this._selectedFiles.push(...i)}else this._selectedFiles=[e[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(e){return this._selectedFiles.some(t=>t.name===e.name&&t.size===e.size&&t.lastModified===e.lastModified)}}customElements.get("mint-dropzone")||customElements.define("mint-dropzone",te);class ie 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}static get observedAttributes(){return["action","method","enctype"]}connectedCallback(){this._render(),this._setupBlurValidation()}disconnectedCallback(){this._form&&this._submitHandler&&this._form.removeEventListener("submit",this._submitHandler,!0),this._hostSubmitHandler&&this.removeEventListener("submit",this._hostSubmitHandler),this._cleanupBlurValidation()}reset(){this._clearErrors(),this._form&&this._form.reset(),this._resetCustomFields()}attributeChangedCallback(e,t,i){this._applyFormAttributes()}_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._submitHandler=e=>this._handleSubmit(e),this._form.addEventListener("submit",function(e){var t;(t=this.closest("mint-form"))==null||t._handleSubmit(e)})}this._applyFormAttributes()}_applyFormAttributes(){if(!this._form)return;const e=this.getAttribute("action")||"",t=(this.getAttribute("method")||"POST").toUpperCase(),i=this.getAttribute("enctype")||"application/x-www-form-urlencoded";e&&(this._form.action=e),this._form.method=t,this._form.enctype=i}async _handleSubmit(e){if(e.preventDefault(),!this._form)return;this._clearErrors(),this._syncDropzoneFiles();const t=this._collectValidationRules(),i=new FormData(this._form),s=this._formDataToValues(i);if(!this._validate(s,t)){this.dispatchEvent(new CustomEvent("invalid",{detail:{errors:this._errors},bubbles:!0,cancelable:!0,composed:!0}));return}const n=new CustomEvent("submit",{detail:{formData:i,values:s},bubbles:!0,cancelable:!0,composed:!0});if(this.dispatchEvent(n),!n.defaultPrevented)try{const a=await this._submitData(i,s);this.dispatchEvent(new CustomEvent("submitsuccess",{detail:a,bubbles:!0,cancelable:!0}))}catch(a){this.dispatchEvent(new CustomEvent("submiterror",{detail:{error:a},bubbles:!0,cancelable:!0}))}}async _submitData(e,t){const i=this.getAttribute("action"),s=(this.getAttribute("method")||"POST").toUpperCase(),r=this.getAttribute("enctype")||"application/x-www-form-urlencoded";if(!i)return{status:0,ok:!0,data:{values:t}};const n=Array.from(e.values()).some(h=>h instanceof File);let a=null;const l={};let o=i;if(s==="GET"){const h=new URLSearchParams;e.forEach((c,d)=>{c instanceof File||h.append(d,String(c))}),o+=(i.includes("?")?"&":"?")+h.toString()}else if(r==="multipart/form-data"||n)a=e;else if(r==="application/json")a=JSON.stringify(t),l["Content-Type"]="application/json";else{const h=new URLSearchParams;e.forEach((c,d)=>{c instanceof File||h.append(d,String(c))}),a=h,l["Content-Type"]="application/x-www-form-urlencoded"}if(typeof fetch=="function"){const h=await fetch(o,{method:s,body:s==="GET"?null:a,headers:l}),c=await h.text().catch(()=>"");let d=c;try{d=JSON.parse(c)}catch{}if(!h.ok)throw{status:h.status,data:d};return{status:h.status,ok:h.ok,data:d}}return await new Promise((h,c)=>{const d=new XMLHttpRequest;d.open(s,o,!0),Object.entries(l).forEach(([u,f])=>d.setRequestHeader(u,f)),d.onload=function(){const{status:u,responseText:f}=d;if(u>=200&&u<300){let g=f;try{g=JSON.parse(f)}catch{}h({status:u,ok:!0,data:g})}else c({status:u,data:f})},d.onerror=function(){c({status:d.status,data:d.responseText})},d.send(s==="GET"?null:a)})}_formDataToValues(e){const t={};return e.forEach((i,s)=>{i instanceof File?(t[s]||(t[s]=[]),t[s].push(i)):s in t?Array.isArray(t[s])?(t[s].length>0&&t[s][0]instanceof File,t[s].push(i)):t[s]=[t[s],i]:t[s]=i}),this._form&&Array.from(this._form.querySelectorAll("mint-dropzone[name]")).forEach(s=>{const r=s.getAttribute("name");if(r&&typeof s.files<"u"&&s.files){const n=s.files;if(n.length>0){const a=Array.from(n);t[r]&&Array.isArray(t[r])?a.forEach(l=>{t[r].some(h=>h.name===l.name&&h.size===l.size&&h.lastModified===l.lastModified)||t[r].push(l)}):t[r]=a}}}),t}_collectValidationRules(){const e={};return this._form&&Array.from(this._form.querySelectorAll("[name][validation]")).forEach(i=>{const s=i.getAttribute("name")||"",r=i.getAttribute("validation");if(!s||!r)return;const n=this._parseRules(r);n.length&&(e[s]=n)}),e}_parseRules(e){if(!e)return[];try{const t=e.replace(/'/g,'"'),i=JSON.parse(t);if(Array.isArray(i))return i.map(s=>String(s))}catch{}return e.split(",").map(t=>t.trim()).filter(Boolean)}_validate(e,t){let i=!0;return this._errors={},Object.entries(t||{}).forEach(([s,r])=>{const n=Array.isArray(r)?r:[r],a=this._getFieldElements(s),l=this._extractFieldValue(a),o=this._validateRules(l,n);o?(i=!1,this._errors[s]=o,this._flagFieldError(a,o)):this._clearFieldError(a)}),i}_validateField(e){const t=this._collectValidationRules();if(!t[e])return;const i=t[e],s=Array.isArray(i)?i:[i],r=this._getFieldElements(e),n=this._extractFieldValue(r),a=this._validateRules(n,s);a?(this._errors[e]=a,this._flagFieldError(r,a)):(this._clearFieldError(r),delete this._errors[e])}_validateRules(e,t){for(const i of t){const[s,r]=i.split(":");switch(s){case"required":{if(e==null||typeof e=="string"&&e.trim()===""||e instanceof FileList&&e.length===0||Array.isArray(e)&&e.length===0)return"This field is required.";break}case"string":{if(typeof e!="string")return"Must be a string.";break}case"email":{if(typeof e=="string"&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e.trim()))return"Enter a valid email.";break}case"number":{const n=Number(e);if(Number.isNaN(n))return"Must be a number.";break}case"min":{const n=Number(r);if(Number.isNaN(n))break;if(typeof e=="string"&&e.trim().length<n)return`Must be at least ${n} characters.`;if(Array.isArray(e)&&e.length<n)return`Select at least ${n}.`;if(e instanceof FileList&&e.length<n)return`Upload at least ${n} files.`;if(e!=null&&!Number.isNaN(Number(e))&&Number(e)<n)return`Must be at least ${n}.`;break}case"max":{const n=Number(r);if(Number.isNaN(n))break;if(typeof e=="string"&&e.trim().length>n)return`Must be at most ${n} characters.`;if(Array.isArray(e)&&e.length>n)return`Select no more than ${n}.`;if(e instanceof FileList&&e.length>n)return`Upload no more than ${n} files.`;if(e!=null&&!Number.isNaN(Number(e))&&Number(e)>n)return`Must be at most ${n}.`;break}}}return null}_getFieldElements(e){if(!this._form)return[];const t=Array.from(this._form.querySelectorAll(`[name="${e}"]`)),i=t.filter(s=>s.tagName==="MINT-SELECT");if(i.length>0){const s=[];return i.forEach(r=>{const n=r.querySelector('select[name="'+e+'"]');n&&s.push(n)}),t.filter(r=>r.tagName!=="MINT-SELECT").concat(s)}return t}_extractFieldValue(e){if(e.length===0)return"";const t=e.find(s=>s instanceof HTMLSelectElement);if(t)return t.value;if(e.length>1){const s=e.filter(n=>n instanceof HTMLInputElement),r=s.filter(n=>n.checked);if(s.every(n=>n.type==="radio"))return r.length>0?r[0].value||"on":"";if(s.every(n=>n.type==="checkbox"))return r.map(n=>n.value||"on")}const i=e[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 n=i.getValue();if(n!=null&&n!=="")return n}const r=i.getAttribute("value");return r||""}return i.tagName==="MINT-DROPZONE"&&typeof i.files<"u"?i.files:typeof i.value<"u"?i.value:i.getAttribute("value")||""}_flagFieldError(e,t){e.length!==0&&e.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",t),s.setAttribute("data-mint-form-error","true"))})}_clearFieldError(e){e.length!==0&&e.forEach(t=>{(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement)&&t.removeAttribute("aria-invalid");const i=this._resolveHost(t);i&&(i.removeAttribute("error"),i.removeAttribute("error-message"),i.removeAttribute("data-mint-form-error"))})}_clearErrors(){this.querySelectorAll("[data-mint-form-error]").forEach(e=>{const t=e;t.removeAttribute("error"),t.removeAttribute("error-message"),t.removeAttribute("data-mint-form-error")}),this._form&&this._form.querySelectorAll('[aria-invalid="true"]').forEach(e=>{e.removeAttribute("aria-invalid")})}_resetCustomFields(){this.querySelectorAll("mint-input, mint-date-picker, mint-select, mint-dropzone, mint-checkbox, mint-choice, mint-switch").forEach(t=>{var s,r;t.removeAttribute("error"),t.removeAttribute("error-message");const i=t.tagName;if(i==="MINT-INPUT")try{t.value=""}catch{}else if(i==="MINT-DATE-PICKER")try{(s=t.setValue)==null||s.call(t,"")}catch{}else if(i==="MINT-SELECT")try{(r=t.setValue)==null||r.call(t,"")}catch{}else if(i==="MINT-DROPZONE"){const n=t.querySelector('input[type="file"]');n&&(n.value="")}else if(i==="MINT-CHECKBOX"||i==="MINT-CHOICE"){const n=t.querySelector('input[type="checkbox"], input[type="radio"]');n&&(n.checked=!1)}else if(i==="MINT-SWITCH"){const n=t.querySelector('input[type="checkbox"]');n&&(n.checked=!1)}})}_resolveHost(e){const t=e.closest("mint-input, mint-date-picker, mint-select, mint-dropzone, mint-checkbox, mint-choice, mint-switch");return t||e}_setupBlurValidation(){if(!this._form)return;const e=i=>{const s=i.target;if(!s)return;const r=this._findFieldElement(s);if(!r)return;const n=this._getFieldName(r);if(!n||!this._collectValidationRules()[n])return;const l=this._extractFieldValue([r]),o=l!=null&&(typeof l=="string"?l.trim()!=="":l instanceof FileList||Array.isArray(l)?l.length>0:!0),h=r.hasAttribute("data-mint-form-error")||s instanceof HTMLElement&&(s.hasAttribute("aria-invalid")||s.closest("[data-mint-form-error]"));(o||h)&&setTimeout(()=>{this._validateField(n)},0)};this._form.addEventListener("blur",e,!0),this._fieldBlurHandlers.set(this._form,e);const t=i=>{const s=i.target;if(!s)return;if(s instanceof HTMLSelectElement||s.tagName==="MINT-SELECT"||s.closest("mint-select")){const o=this._findFieldElement(s);if(!o)return;const h=this._getFieldName(o);if(!h||!this._collectValidationRules()[h])return;setTimeout(()=>{this._validateField(h)},0);return}const n=this._findFieldElement(s);if(!n)return;const a=this._getFieldName(n);!a||!this._collectValidationRules()[a]||(n.hasAttribute("data-mint-form-error")||s instanceof HTMLElement&&s.hasAttribute("aria-invalid"))&&setTimeout(()=>{this._validateField(a)},0)};this._form.addEventListener("change",t,!0),this._fieldChangeHandlers.set(this._form,t)}_findFieldElement(e){if(e.hasAttribute("name")&&(e.tagName.startsWith("MINT-")||e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement))return e;const t=e.closest("mint-input, mint-date-picker, mint-select, mint-dropzone, mint-checkbox, mint-choice, mint-switch");if(t&&t.hasAttribute("name"))return t;if((e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)&&e.hasAttribute("name"))return e;let i=e;for(;i&&i!==this._form;){if(i.hasAttribute("name"))return i;i=i.parentElement}return null}_getFieldName(e){return e.hasAttribute("name")||e.tagName.startsWith("MINT-")?e.getAttribute("name"):(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)&&e.name||null}_cleanupBlurValidation(){if(this._form&&this._fieldBlurHandlers.has(this._form)){const e=this._fieldBlurHandlers.get(this._form);e&&this._form.removeEventListener("blur",e,!0),this._fieldBlurHandlers.delete(this._form)}if(this._form&&this._fieldChangeHandlers.has(this._form)){const e=this._fieldChangeHandlers.get(this._form);e&&this._form.removeEventListener("change",e,!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(t=>{typeof t.syncFiles=="function"&&t.syncFiles()})}}customElements.get("mint-form")||customElements.define("mint-form",ie);class se extends HTMLElement{constructor(){super(),this._observer=null}static get observedAttributes(){return["striped","hover","bordered","compact"]}connectedCallback(){this.classList.add("block","w-full","overflow-x-auto"),this._applyStyles(),this._observeChanges(),setTimeout(()=>this._applyStyles(),0),setTimeout(()=>this._applyStyles(),100)}disconnectedCallback(){this._observer&&(this._observer.disconnect(),this._observer=null)}attributeChangedCallback(){this._applyStyles()}_observeChanges(){this._observer=new MutationObserver(()=>{this._applyStyles()}),this._observer.observe(this,{childList:!0,subtree:!0,attributes:!1})}_applyStyles(){const e=this.querySelector("table");if(!e)return;const t=this.hasAttribute("bordered"),i=this.hasAttribute("striped"),s=this.hasAttribute("hover"),r=this.hasAttribute("compact");this._setClasses(e,["w-full","border-collapse","text-sm","font-medium"]);const n=e.querySelector("thead");n&&(this._setClasses(n,["bg-gray-50","dark:bg-gray-800"]),n.querySelectorAll("th").forEach(h=>{const c=["text-left","font-semibold","text-gray-900","dark:text-white","uppercase","tracking-wider","text-xs"];t&&c.push("border","border-gray-200","dark:border-gray-700"),r?c.push("px-3","py-1.5"):c.push("px-4","py-3"),this._setClasses(h,c)}));const a=e.querySelector("tbody");a&&(i?this._setClasses(a,["divide-y","divide-gray-200","dark:divide-gray-700"]):this._setClasses(a,[]),a.querySelectorAll("tr").forEach((h,c)=>{const d=[];t&&d.push("border-b","border-gray-200","dark:border-gray-700"),i?c%2===0?d.push("bg-white","dark:bg-gray-900"):d.push("bg-gray-50","dark:bg-gray-800"):d.push("bg-white","dark:bg-gray-900"),s&&d.push("transition-colors","duration-150","hover:bg-gray-100","dark:hover:bg-gray-800"),this._setClasses(h,d),h.querySelectorAll("td").forEach(f=>{const g=["text-gray-900","dark:text-gray-100"];t&&g.push("border","border-gray-200","dark:border-gray-700"),r?g.push("px-3","py-1.5"):g.push("px-4","py-3"),this._setClasses(f,g)})}));const l=e.querySelector("tfoot");l&&(this._setClasses(l,["bg-gray-50","dark:bg-gray-800","font-semibold"]),l.querySelectorAll("td").forEach(h=>{const c=["text-gray-900","dark:text-gray-100"];t&&c.push("border","border-gray-200","dark:border-gray-700"),r?c.push("px-3","py-1.5"):c.push("px-4","py-3"),this._setClasses(h,c)}))}_setClasses(e,t){e.className="",t.forEach(i=>{i&&i.trim()&&e.classList.add(i)})}}customElements.get("mint-table")||customElements.define("mint-table",se);exports.BackButton=$;exports.Button=F;exports.Card=W;exports.Checkbox=X;exports.Choice=K;exports.DatePicker=Q;exports.Dropzone=te;exports.Form=ie;exports.Grid=U;exports.Icon=B;exports.Input=Z;exports.Link=j;exports.Modal=J;exports.Page=Y;exports.Popover=G;exports.Select=ee;exports.Spinner=P;exports.Stack=R;exports.Switch=z;exports.Table=se;exports.Text=V;exports.default=F;
|