monobill-mintui 0.6.3 → 0.6.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/form/Form.d.ts +12 -0
- package/dist/components/form/Form.d.ts.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +60 -13
- package/package.json +1 -1
|
@@ -10,6 +10,11 @@ declare class MintForm extends HTMLElement {
|
|
|
10
10
|
private _formData;
|
|
11
11
|
private _headers;
|
|
12
12
|
private _buttonStates;
|
|
13
|
+
/** Snapshot for `submitting` attribute (separate from built-in fetch button state). */
|
|
14
|
+
private _attrSubmittingMintFields;
|
|
15
|
+
private _attrSubmittingNativeFields;
|
|
16
|
+
private _attrSubmittingMintButtons;
|
|
17
|
+
private _attrSubmittingNativeButtons;
|
|
13
18
|
private _reactiveDataProxy;
|
|
14
19
|
private _reactiveDataObserver;
|
|
15
20
|
private _lastDataSnapshot;
|
|
@@ -68,6 +73,13 @@ declare class MintForm extends HTMLElement {
|
|
|
68
73
|
private _normalizeReactiveValue;
|
|
69
74
|
private _cleanupBlurValidation;
|
|
70
75
|
private _syncDropzoneFiles;
|
|
76
|
+
private _isSubmittingAttrActive;
|
|
77
|
+
/**
|
|
78
|
+
* When `submitting` is set on mint-form: disable all fields and non-submit controls,
|
|
79
|
+
* set mint-button type=submit to loading (spinner) while preserving button dimensions.
|
|
80
|
+
*/
|
|
81
|
+
private _applySubmittingAttributeState;
|
|
82
|
+
private _restoreSubmittingAttributeState;
|
|
71
83
|
private _propagateLoadingState;
|
|
72
84
|
private _setButtonsSubmitting;
|
|
73
85
|
private _restoreButtonsState;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Form.d.ts","sourceRoot":"","sources":["../../../src/components/form/Form.ts"],"names":[],"mappings":"AAOA,cAAM,QAAS,SAAQ,WAAW;IAChC,MAAM,KAAK,kBAAkB,IAAI,MAAM,EAAE,CAExC;IAED,OAAO,CAAC,KAAK,CAA+B;IAC5C,OAAO,CAAC,cAAc,CAAoC;IAC1D,OAAO,CAAC,kBAAkB,CAAoC;IAC9D,OAAO,CAAC,OAAO,CAA6B;IAC5C,OAAO,CAAC,kBAAkB,CAAkD;IAC5E,OAAO,CAAC,oBAAoB,CAAkD;IAC9E,OAAO,CAAC,SAAS,CAAgC;IACjD,OAAO,CAAC,SAAS,CAAmC;IACpD,OAAO,CAAC,QAAQ,CAAsC;IACtD,OAAO,CAAC,aAAa,CAAuE;IAC5F,OAAO,CAAC,kBAAkB,CAAY;IACtC,OAAO,CAAC,qBAAqB,CAAsB;IACnD,OAAO,CAAC,iBAAiB,CAAmC;;IAM5D,iBAAiB,IAAI,IAAI;
|
|
1
|
+
{"version":3,"file":"Form.d.ts","sourceRoot":"","sources":["../../../src/components/form/Form.ts"],"names":[],"mappings":"AAOA,cAAM,QAAS,SAAQ,WAAW;IAChC,MAAM,KAAK,kBAAkB,IAAI,MAAM,EAAE,CAExC;IAED,OAAO,CAAC,KAAK,CAA+B;IAC5C,OAAO,CAAC,cAAc,CAAoC;IAC1D,OAAO,CAAC,kBAAkB,CAAoC;IAC9D,OAAO,CAAC,OAAO,CAA6B;IAC5C,OAAO,CAAC,kBAAkB,CAAkD;IAC5E,OAAO,CAAC,oBAAoB,CAAkD;IAC9E,OAAO,CAAC,SAAS,CAAgC;IACjD,OAAO,CAAC,SAAS,CAAmC;IACpD,OAAO,CAAC,QAAQ,CAAsC;IACtD,OAAO,CAAC,aAAa,CAAuE;IAC5F,uFAAuF;IACvF,OAAO,CAAC,yBAAyB,CAAkC;IACnE,OAAO,CAAC,2BAA2B,CAGhC;IACH,OAAO,CAAC,0BAA0B,CAAkE;IACpG,OAAO,CAAC,4BAA4B,CAAwC;IAC5E,OAAO,CAAC,kBAAkB,CAAY;IACtC,OAAO,CAAC,qBAAqB,CAAsB;IACnD,OAAO,CAAC,iBAAiB,CAAmC;;IAM5D,iBAAiB,IAAI,IAAI;IAyCzB,oBAAoB,IAAI,IAAI;IAY5B;;;OAGG;IACH,KAAK,IAAI,IAAI;IAWb;;;OAGG;IACH,KAAK,IAAI,IAAI;IAQb,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAqC9F,IAAI,IAAI,IAAI,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,CAErC;IAED,IAAI,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,EAqCzC;IAGD,IAAI,OAAO,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAE3C;IAED,IAAI,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,EAgB/C;IAED,OAAO,CAAC,OAAO;IAkBf,OAAO,CAAC,oBAAoB;IAoB5B,OAAO,CAAC,oBAAoB;YAYd,aAAa;YAwGb,WAAW;YAkJX,yBAAyB;YAiBzB,uBAAuB;IA2BrC,OAAO,CAAC,iBAAiB;IA+GzB,OAAO,CAAC,uBAAuB;IAkB/B,OAAO,CAAC,WAAW;IAcnB,OAAO,CAAC,SAAS;IAuBjB,OAAO,CAAC,cAAc;IAoBtB,OAAO,CAAC,cAAc;IAqDtB,OAAO,CAAC,iBAAiB;IAgDzB,OAAO,CAAC,kBAAkB;IAqI1B,OAAO,CAAC,eAAe;IAgBvB,OAAO,CAAC,gBAAgB;IAgBxB,OAAO,CAAC,YAAY;IAoBpB;;;OAGG;IACH,aAAa,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,GAAG,IAAI;IAI9D,OAAO,CAAC,kBAAkB;IAuB1B,OAAO,CAAC,cAAc;IAyBtB,OAAO,CAAC,aAAa;IAmBrB,OAAO,CAAC,cAAc;IAoCtB,OAAO,CAAC,kBAAkB;IA2E1B,OAAO,CAAC,kBAAkB;IAmD1B,OAAO,CAAC,YAAY;IAWpB,OAAO,CAAC,oBAAoB;IA0K5B,OAAO,CAAC,iBAAiB;IAoCzB,OAAO,CAAC,aAAa;IAqBrB,OAAO,CAAC,wBAAwB;IAchC,OAAO,CAAC,uBAAuB;IAyB/B,OAAO,CAAC,sBAAsB;IA6B9B,OAAO,CAAC,kBAAkB;IAa1B,OAAO,CAAC,uBAAuB;IAK/B;;;OAGG;IACH,OAAO,CAAC,8BAA8B;IAwEtC,OAAO,CAAC,gCAAgC;IAgCxC,OAAO,CAAC,sBAAsB;IAyB9B,OAAO,CAAC,qBAAqB;IAoD7B,OAAO,CAAC,oBAAoB;IAuD5B;;;OAGG;IACH,OAAO,CAAC,iBAAiB;IA0CzB;;;OAGG;IACH,OAAO,CAAC,mBAAmB;IAa3B;;OAEG;IACH,OAAO,CAAC,oBAAoB;IA2B5B;;OAEG;IACH,OAAO,CAAC,eAAe;IASvB;;;OAGG;IACH,OAAO,CAAC,iBAAiB;IAoCzB;;;OAGG;IACH,OAAO,CAAC,0BAA0B;IAyDlC;;OAEG;IACH,OAAO,CAAC,yBAAyB;CASlC;AAsCD,eAAe,QAAQ,CAAA"}
|
package/dist/index.cjs
CHANGED
|
@@ -79,7 +79,7 @@ Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{val
|
|
|
79
79
|
background: rgba(255, 255, 255, 0.2);
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
|
-
`,n.classList.add(`mint-date-shortcuts-row`),document.head.querySelector(`style[data-mint-date-shortcuts]`)||(r.setAttribute(`data-mint-date-shortcuts`,`true`),document.head.appendChild(r));let i=document.createElement(`div`);i.className=`absolute left-0 top-0 bottom-0 w-8 pointer-events-none z-10 bg-gradient-to-r from-white dark:from-mint-elevated to-transparent opacity-0 md:hidden`,t.appendChild(i);let a=document.createElement(`div`);a.className=`absolute right-0 top-0 bottom-0 w-8 pointer-events-none z-10 bg-gradient-to-l from-white dark:from-mint-elevated to-transparent opacity-100 md:hidden`,t.appendChild(a);let s=document.createElement(`div`);s.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-mint-elevated to-transparent opacity-0`,t.appendChild(s);let l=document.createElement(`div`);l.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-mint-elevated to-transparent opacity-100`,t.appendChild(l);let u=()=>{if(window.innerWidth>=768){let e=n.scrollTop,t=n.scrollHeight,r=n.clientHeight;e>0?s.style.opacity=`1`:s.style.opacity=`0`,e+r<t-1?l.style.opacity=`1`:l.style.opacity=`0`,i.style.opacity=`0`,a.style.opacity=`0`}else{let e=n.scrollLeft,t=n.scrollWidth,r=n.clientWidth;e>0?i.style.opacity=`1`:i.style.opacity=`0`,e+r<t-1?a.style.opacity=`1`:a.style.opacity=`0`,s.style.opacity=`0`,l.style.opacity=`0`}};n.addEventListener(`scroll`,u),window.addEventListener(`resize`,u),setTimeout(u,0),o.forEach(e=>{let 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-mint-hover text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-mint-elevated 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=e.label,t.setAttribute(`data-keep-popover-open`,`true`);let r=()=>{let t=e.action();if(t){if(this._isRange&&`start`in t&&`end`in t){this._selectedStartDate=t.start,this._selectedEndDate=t.end;let e=this.getFormat(),n=`${this._formatDate(t.start,e)} - ${this._formatDate(t.end,e)}`;this.setValue(n),this._currentMonth=t.start.getMonth(),this._currentYear=t.start.getFullYear()}else if(t instanceof Date){this._selectedStartDate=t,this._selectedEndDate=null;let e=this.getFormat(),n=this._formatDate(t,e);this.setValue(n),this._currentMonth=t.getMonth(),this._currentYear=t.getFullYear()}this._buildCalendar(),this._popover&&typeof this._popover.close==`function`&&this._popover.close(),this.dispatchEvent(new CustomEvent(`input`,{detail:{value:this.getValue()},bubbles:!0,cancelable:!0})),this.dispatchEvent(new CustomEvent(`change`,{detail:{value:this.getValue()},bubbles:!0,cancelable:!0}))}};t.addEventListener(`click`,r),t.addEventListener(`touchend`,e=>{e.preventDefault(),r()},{passive:!1}),n.appendChild(t)}),t.appendChild(n),e.appendChild(t),c.appendChild(e)}l.appendChild(u),l.appendChild(b),l.appendChild(x),c.appendChild(l),this._calendarContainer.appendChild(c)}_buildMonthView(){if(!this._calendarContainer)return;let 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`;let n=document.createElement(`button`);n.type=`button`,n.tabIndex=0,n.className=`p-1 rounded hover:bg-gray-100 dark:hover:bg-mint-hover text-gray-600 dark:text-gray-300 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`);let r=document.createElement(`mint-icon`);r.setAttribute(`name`,`caret-left`),r.className=`w-4 h-4`,n.appendChild(r);let i=()=>{let e=this._currentMonth,t=this._currentYear;this._currentYear--,this._buildCalendar(),this._dispatchMonthChangeEvent(e,t,this._currentMonth,this._currentYear)};n.addEventListener(`click`,i),n.addEventListener(`touchend`,e=>{e.preventDefault(),i()},{passive:!1}),t.appendChild(n);let a=document.createElement(`button`);a.type=`button`,a.tabIndex=0,a.className=`text-sm font-medium text-gray-900 dark:text-gray-100 hover:text-gray-600 dark:hover:text-gray-300 cursor-pointer 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`,a.setAttribute(`data-keep-popover-open`,`true`),a.textContent=String(this._currentYear);let o=()=>{this.getMode()!==`year`&&(this._viewMode=`year`,this._buildCalendar())};a.addEventListener(`click`,o),a.addEventListener(`touchend`,e=>{e.preventDefault(),o()},{passive:!1}),t.appendChild(a);let s=document.createElement(`button`);s.type=`button`,s.tabIndex=0,s.className=`p-1 rounded hover:bg-gray-100 dark:hover:bg-mint-hover text-gray-600 dark:text-gray-300 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`);let c=document.createElement(`mint-icon`);c.setAttribute(`name`,`caret-right`),c.className=`w-4 h-4`,s.appendChild(c);let l=()=>{let e=this._currentMonth,t=this._currentYear;this._currentYear++,this._buildCalendar(),this._dispatchMonthChangeEvent(e,t,this._currentMonth,this._currentYear)};s.addEventListener(`click`,l),s.addEventListener(`touchend`,e=>{e.preventDefault(),l()},{passive:!1}),t.appendChild(s);let u=document.createElement(`div`);u.className=`grid grid-cols-3 gap-2`,e.forEach((e,t)=>{let n=document.createElement(`button`);n.type=`button`,n.tabIndex=0,n.setAttribute(`data-keep-popover-open`,`true`),n.className=`p-2 rounded text-sm font-medium focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500 ${this._currentMonth===t?`bg-slate-800 dark:bg-slate-600 text-white`:`text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-mint-hover`}`,n.textContent=e;let r=()=>{if(this.getMode()===`month`){let e=new Date(this._currentYear,t,1),n=this.getFormat(),r=this._formatDate(e,n);this.setValue(r),this._selectedStartDate=e,this._selectedEndDate=null;let i=this._currentMonth,a=this._currentYear;this._currentMonth=t,this._dispatchMonthChangeEvent(i,a,this._currentMonth,this._currentYear),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})),this._dispatchDateChangeEvent(),this._popover&&typeof this._popover.close==`function`&&this._popover.close()}else{let e=this._currentMonth,n=this._currentYear;this._currentMonth=t,this._viewMode=`calendar`,this._buildCalendar(),this._dispatchMonthChangeEvent(e,n,this._currentMonth,this._currentYear)}};n.addEventListener(`click`,r),n.addEventListener(`touchend`,e=>{e.preventDefault(),r()},{passive:!1}),u.appendChild(n)}),this._calendarContainer.appendChild(t),this._calendarContainer.appendChild(u)}_buildYearView(){if(!this._calendarContainer)return;let e=this._currentYear-6,t=this._currentYear+6,n=document.createElement(`div`);n.className=`flex items-center justify-between mb-4`;let r=document.createElement(`button`);r.type=`button`,r.tabIndex=0,r.className=`p-1 rounded hover:bg-gray-100 dark:hover:bg-mint-hover text-gray-600 dark:text-gray-300 focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500`,r.setAttribute(`data-keep-popover-open`,`true`);let i=document.createElement(`mint-icon`);i.setAttribute(`name`,`caret-left`),i.className=`w-4 h-4`,r.appendChild(i);let a=()=>{let e=this._currentMonth,t=this._currentYear;this._currentYear-=12,this._buildCalendar(),this._dispatchMonthChangeEvent(e,t,this._currentMonth,this._currentYear)};r.addEventListener(`click`,a),r.addEventListener(`touchend`,e=>{e.preventDefault(),a()},{passive:!1}),n.appendChild(r);let o=document.createElement(`div`);o.className=`text-sm font-medium text-gray-900 dark:text-gray-100`,o.textContent=`${e} - ${t}`,n.appendChild(o);let s=document.createElement(`button`);s.type=`button`,s.tabIndex=0,s.className=`p-1 rounded hover:bg-gray-100 dark:hover:bg-mint-hover text-gray-600 dark:text-gray-300 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`);let c=document.createElement(`mint-icon`);c.setAttribute(`name`,`caret-right`),c.className=`w-4 h-4`,s.appendChild(c);let l=()=>{let e=this._currentMonth,t=this._currentYear;this._currentYear+=12,this._buildCalendar(),this._dispatchMonthChangeEvent(e,t,this._currentMonth,this._currentYear)};s.addEventListener(`click`,l),s.addEventListener(`touchend`,e=>{e.preventDefault(),l()},{passive:!1}),n.appendChild(s);let u=document.createElement(`div`);u.className=`grid grid-cols-3 gap-2`;for(let n=e;n<=t;n++){let e=document.createElement(`button`);e.type=`button`,e.tabIndex=0,e.setAttribute(`data-keep-popover-open`,`true`),e.className=`p-2 rounded text-sm font-medium focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500 ${this._currentYear===n?`bg-slate-800 dark:bg-slate-600 text-white`:`text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-mint-hover`}`,e.textContent=String(n),e.addEventListener(`click`,()=>{let e=this.getMode();if(e===`year`){let e=new Date(n,0,1),t=this.getFormat(),r=this._formatDate(e,t);this.setValue(r),this._selectedStartDate=e,this._selectedEndDate=null;let i=this._currentMonth,a=this._currentYear;this._currentYear=n,this._currentMonth=0,this._dispatchMonthChangeEvent(i,a,this._currentMonth,this._currentYear),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})),this._dispatchDateChangeEvent(),this._popover&&typeof this._popover.close==`function`&&this._popover.close()}else if(e===`month`){let e=this._currentMonth,t=this._currentYear;this._currentYear=n,this._viewMode=`month`,this._buildCalendar(),this._dispatchMonthChangeEvent(e,t,this._currentMonth,this._currentYear)}else{let e=this._currentMonth,t=this._currentYear;this._currentYear=n,this._viewMode=`calendar`,this._buildCalendar(),this._dispatchMonthChangeEvent(e,t,this._currentMonth,this._currentYear)}}),u.appendChild(e)}this._calendarContainer.appendChild(n),this._calendarContainer.appendChild(u)}_getDaysInMonth(e,t){return new Date(t,e+1,0).getDate()}_getFirstDayOfMonth(e,t){let n=this.getWeekStartDay(),r=new Date(t,e,1).getDay();return r>=n?r-n:7-(n-r)}_isToday(e){let t=new Date;return e.getDate()===t.getDate()&&e.getMonth()===t.getMonth()&&e.getFullYear()===t.getFullYear()}_isDateSelected(e){let t=this.getSelectionMode();return this._isRange||t===`week`||t===`month`?this._selectedStartDate&&this._selectedEndDate?this._isSameDate(e,this._selectedStartDate)||this._isSameDate(e,this._selectedEndDate):this._isRange&&this._selectedStartDate&&!this._selectedEndDate?this._isSameDate(e,this._selectedStartDate):!1:this._selectedStartDate!==null&&this._isSameDate(e,this._selectedStartDate)}_isDateInRange(e){let t=this.getSelectionMode();if((this._isRange||t===`week`||t===`month`)&&this._selectedStartDate&&this._selectedEndDate)return this._rangeIncludesDisabledDates(this._selectedStartDate,this._selectedEndDate)?!1:e>=this._selectedStartDate&&e<=this._selectedEndDate;if(this._isRange&&this._selectedStartDate&&!this._selectedEndDate&&this._hoveredDate){let t=this._selectedStartDate<this._hoveredDate?this._selectedStartDate:this._hoveredDate,n=this._selectedStartDate<this._hoveredDate?this._hoveredDate:this._selectedStartDate;if(this._rangeIncludesDisabledDates(t,n)){let r=this._findFirstDisabledDateInRange(t,n);return r?this._selectedStartDate<this._hoveredDate?e>=t&&e<r&&!this._isSameDate(e,t):e>r&&e<=n&&!this._isSameDate(e,n):!1}return e>=t&&e<=n&&!this._isSameDate(e,t)&&!this._isSameDate(e,n)}return!1}_rangeIncludesDisabledDates(e,t){let n=this.getDisabledDates(),r=new Date(e.getFullYear(),e.getMonth(),e.getDate()),i=new Date(t.getFullYear(),t.getMonth(),t.getDate());return n.some(e=>{let t=new Date(e.getFullYear(),e.getMonth(),e.getDate());return t>=r&&t<=i})}_findFirstDisabledDateInRange(e,t){let n=this.getDisabledDates(),r=new Date(e.getFullYear(),e.getMonth(),e.getDate()),i=new Date(t.getFullYear(),t.getMonth(),t.getDate()),a=n.map(e=>new Date(e.getFullYear(),e.getMonth(),e.getDate())).filter(e=>e>=r&&e<=i).sort((e,t)=>e.getTime()-t.getTime());return a.length>0?a[0]:null}_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()}_isDateDisabled(e){return this.getDisabledDates().some(t=>this._isSameDate(e,t))}_dispatchMonthChangeEvent(e,t,n,r){(e!==n||t!==r)&&this.dispatchEvent(new CustomEvent(`month-change`,{detail:{month:n,year:r,oldMonth:e,oldYear:t},bubbles:!0,cancelable:!0,composed:!0}))}_dispatchDateChangeEvent(){let e=this.getFormat(),t={value:this.getValue()};this._selectedStartDate&&(t.startDate=this._selectedStartDate,t.startDateFormatted=this._formatDate(this._selectedStartDate,e)),this._selectedEndDate&&(t.endDate=this._selectedEndDate,t.endDateFormatted=this._formatDate(this._selectedEndDate,e)),this.dispatchEvent(new CustomEvent(`date-change`,{detail:t,bubbles:!0,cancelable:!0,composed:!0}))}_setupContainerObserver(){if(this._resizeObserver&&=(this._resizeObserver.disconnect(),null),!this._inputsWrapperEl)return;let e=e=>{this._inputsWrapperEl&&(e<400?(this._inputsWrapperEl.classList.add(`flex-wrap`),this._inputsWrapperEl.classList.remove(`flex-nowrap`)):(this._inputsWrapperEl.classList.remove(`flex-wrap`),this._inputsWrapperEl.classList.add(`flex-nowrap`)))};e(this._inputsWrapperEl.offsetWidth||this.offsetWidth),this._resizeObserver=new ResizeObserver(t=>{for(let n of t){let t=n.contentRect.width;e(t)}}),this._resizeObserver.observe(this)}_getWeekStart(e){let t=this.getWeekStartDay(),n=e.getDay(),r;r=n>=t?n-t:7-(t-n);let i=new Date(e);return i.setDate(e.getDate()-r),i.setHours(0,0,0,0),i}_getWeekEnd(e){let t=this._getWeekStart(e),n=new Date(t);return n.setDate(t.getDate()+6),n.setHours(23,59,59,999),n}_getMonthStart(e){let t=new Date(e.getFullYear(),e.getMonth(),1);return t.setHours(0,0,0,0),t}_getMonthEnd(e){let t=new Date(e.getFullYear(),e.getMonth()+1,0);return t.setHours(23,59,59,999),t}_handleDateClick(e){this._isHandlingClick=!0;try{let t=this.getFormat(),n=this.getSelectionMode(),r,i;if(n===`week`?(r=this._getWeekStart(e),i=this._getWeekEnd(e)):n===`month`?(r=this._getMonthStart(e),i=this._getMonthEnd(e)):(r=e,i=e),this.isRange()||n===`week`||n===`month`)if(n===`week`||n===`month`){if(this._rangeIncludesDisabledDates(r,i)){this._buildCalendar();return}this._selectedStartDate=r,this._selectedEndDate=i;let e=`${this._formatDate(this._selectedStartDate,t)} - ${this._formatDate(this._selectedEndDate,t)}`;this.setValue(e),this._textInput&&(this._textInput.value=e),this._popover&&typeof this._popover.close==`function`&&this._popover.close()}else if(this._hoveredDate=null,this._selectedStartDate===null){if(this._isDateDisabled(r)){this._buildCalendar();return}this._selectedStartDate=new Date(r.getFullYear(),r.getMonth(),r.getDate()),this._selectedEndDate=null,this._currentMonth=this._selectedStartDate.getMonth(),this._currentYear=this._selectedStartDate.getFullYear(),this._hoveredDate=null,this._buildCalendar()}else if(this._selectedEndDate===null){let n=new Date(e.getFullYear(),e.getMonth(),e.getDate()),r=this._selectedStartDate?new Date(this._selectedStartDate.getFullYear(),this._selectedStartDate.getMonth(),this._selectedStartDate.getDate()):null,i,a;if(r&&n<r?(i=n,a=r):(i=r,a=n),this._rangeIncludesDisabledDates(i,a)){this._buildCalendar();return}r&&n<r?(this._selectedEndDate=r,this._selectedStartDate=n):(this._selectedEndDate=n,r&&(this._selectedStartDate=r)),this._currentMonth=this._selectedStartDate.getMonth(),this._currentYear=this._selectedStartDate.getFullYear();let o=`${this._formatDate(this._selectedStartDate,t)} - ${this._formatDate(this._selectedEndDate,t)}`;this.setAttribute(`value`,o),this._textInput&&(this._textInput.value=o),this._hiddenInput&&(this._hiddenInput.value=o),this._updateDisplayText(),this._buildCalendar(),this._popover&&typeof this._popover.close==`function`&&this._popover.close()}else this._selectedStartDate=r,this._selectedEndDate=null;else{this._selectedStartDate=r,this._selectedEndDate=null;let e=this._formatDate(r,t);this.setValue(e),this._textInput&&(this._textInput.value=e),this._popover&&typeof this._popover.close==`function`&&this._popover.close()}this._buildCalendar(),this._updateDisplayText(),this._exitInputMode();let a=new Event(`input`,{bubbles:!0,cancelable:!0,composed:!0});this.dispatchEvent(a),this.dispatchEvent(new CustomEvent(`input`,{detail:{value:this.getValue()},bubbles:!0,cancelable:!0,composed:!0})),this.dispatchEvent(new CustomEvent(`change`,{detail:{value:this.getValue()},bubbles:!0,cancelable:!0,composed:!0})),this._dispatchDateChangeEvent()}finally{this._isHandlingClick=!1}}_updateDisplayText(){if(!this._displayEl)return;let e=this.getDisplayFormat(),t=this.getSelectionMode(),n=this._isRange||t===`week`||t===`month`,r=``;n&&this._selectedStartDate&&this._selectedEndDate?r=`${this._formatDatePhp(this._selectedStartDate,e)} - ${this._formatDatePhp(this._selectedEndDate,e)}`:this._selectedStartDate&&(r=this._formatDatePhp(this._selectedStartDate,e)),r?(this._displayEl.textContent=r,this._displayEl.classList.remove(`text-gray-400`,`dark:text-gray-500`),this._displayEl.classList.add(`text-gray-900`,`dark:text-white`)):(this._displayEl.textContent=`Select date`,this._displayEl.classList.add(`text-gray-400`,`dark:text-gray-500`),this._displayEl.classList.remove(`text-gray-900`,`dark:text-white`)),this._displayEl&&this._inputsWrapperEl&&(this._displayEl.style.display=this._isInputMode?`none`:`flex`,this._inputsWrapperEl.style.display=this._isInputMode?`flex`:`none`)}_enterInputMode(){if(!this._isInputMode&&!(this.isReadonly()||this.isDisabled())&&(this._isInputMode=!0,this._displayEl&&this._inputsWrapperEl&&(this._displayEl.style.display=`none`,this._inputsWrapperEl.style.display=`flex`),this._startPartInputs.length>0)){let 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())}_renderSkeleton(e){let t=this.querySelector(`.mint-date-picker-skeleton-container`),n=this._fieldsContainer,r=this._input;if(e){t||(t=document.createElement(`div`),t.className=`mint-date-picker-skeleton-container absolute inset-0 z-10 pointer-events-none`,r?(r.classList.contains(`relative`)||r.classList.add(`relative`),r.appendChild(t)):(this.style.position=`relative`,this.appendChild(t)));let e=t.querySelector(`.mint-date-picker-skeleton`);e||(e=document.createElement(`div`),e.className=`mint-date-picker-skeleton w-full rounded-lg bg-gray-200 dark:bg-mint-hover animate-pulse`,e.style.height=`2.25rem`,t.appendChild(e)),t.style.display=`block`,n&&(n.style.visibility=`hidden`,n.style.pointerEvents=`none`),this._displayEl&&(this._displayEl.style.visibility=`hidden`,this._displayEl.style.pointerEvents=`none`)}else t&&(t.style.display=`none`),n&&(n.style.visibility=`visible`,n.style.pointerEvents=`auto`),this._displayEl&&(this._displayEl.style.visibility=`visible`,this._displayEl.style.pointerEvents=`auto`)}_getFocusableElements(){if(!this._calendarContainer)return[];let 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(e=>{let t=window.getComputedStyle(e);return t.display!==`none`&&t.visibility!==`hidden`})}_setupFocusTrap(){if(!this._popover||!this._popover.hasAttribute(`open`))return;this._removeFocusTrap();let e=this;this._focusTrapHandler=function(t){if(t.key!==`Tab`)return;if(!e._popover||!e._popover.hasAttribute(`open`)){e._removeFocusTrap();return}let n=e._getFocusableElements();if(n.length===0)return;let r=n[0],i=n[n.length-1],a=document.activeElement;if(!e._calendarContainer?.contains(a)){t.preventDefault(),r.focus();return}if(t.shiftKey&&a===r){t.preventDefault(),i.focus();return}if(!t.shiftKey&&a===i){t.preventDefault(),r.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(()=>{let e=this._getFocusableElements();e.length>0&&e[0].focus()})}_removeFocusTrap(){this._focusTrapHandler&&=(document.removeEventListener(`keydown`,this._focusTrapHandler,!0),null),this._escapeHandler&&=(document.removeEventListener(`keydown`,this._escapeHandler,!0),null)}};customElements.get(`mint-date-picker`)||customElements.define(`mint-date-picker`,S);var C=class extends HTMLElement{static get observedAttributes(){return[`name`,`value`,`disabled`,`id`,`required`,`label`,`info`,`error`,`error-message`,`multiple`,`loading`]}constructor(){super(),this._select=null,this._wrapper=null,this._caretUpIcon=null,this._caretDownIcon=null,this._changeHandler=null,this._optionObserver=null,this._childrenObserver=null}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(),this._childrenObserver&&this._childrenObserver.disconnect(),this._childrenObserver=new MutationObserver(e=>{e.some(e=>{let t=Array.from(e.addedNodes).some(e=>e.nodeType===Node.ELEMENT_NODE&&(e.tagName===`OPTION`||e.tagName===`OPTGROUP`))||Array.from(e.removedNodes).some(e=>e.nodeType===Node.ELEMENT_NODE&&(e.tagName===`OPTION`||e.tagName===`OPTGROUP`)),n=e.type===`attributes`&&e.target.nodeType===Node.ELEMENT_NODE&&(e.target.tagName===`OPTION`||e.target.tagName===`OPTGROUP`);return t||n})&&requestAnimationFrame(()=>{this.render()})}),this._childrenObserver.observe(this,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`value`,`selected`,`disabled`]})}disconnectedCallback(){this._select&&this._changeHandler&&(this._select.removeEventListener(`change`,this._changeHandler),this._changeHandler=null),this._optionObserver&&=(this._optionObserver.disconnect(),null),this._childrenObserver&&=(this._childrenObserver.disconnect(),null)}isLoading(){return this.getAttribute(`loading`)===`true`}attributeChangedCallback(e,t,n){if(t!==n){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===`loading`){this.render();return}if(e===`value`){this._select&&(this._select.value=n||``);return}this.render()}}getName(){return this.getAttribute(`name`)||``}getValue(){return this.hasAttribute(`value`)?this.getAttribute(`value`)||``:this._select?this._select.value:``}setValue(e){let t=e||``;this.setAttribute(`value`,t),this._select&&(this._select.value=t)}get value(){try{return this.getValue()||``}catch{return``}}set value(e){try{let t=e||``;(this.getAttribute(`value`)||``)!==t&&this.setAttribute(`value`,t),this._select&&requestAnimationFrame(()=>{this._select&&(t===``||Array.from(this._select.options).some(e=>e.value===t))&&this._select.value!==t&&(this._select.value=t)})}catch{}}isDisabled(){return this.getAttribute(`disabled`)===`true`}isMultiple(){return this.getAttribute(`multiple`)===`true`}hasError(){return this.getAttribute(`error`)===`true`}getErrorMessage(){return this.getAttribute(`error-message`)||``}getId(){return this.getAttribute(`id`)||``}getLabel(){return this.getAttribute(`label`)||``}getInfo(){return this.getAttribute(`info`)||``}getSelectClasses(){let e=this.hasError(),t=this.isMultiple(),n=[`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-mint-elevated`,`text-gray-900`,`dark:text-white`,`outline-none`,`focus:outline-none`,`disabled:opacity-40`,`disabled:cursor-not-allowed`,`appearance-none`,`bg-no-repeat`,`bg-right`,`cursor-pointer`],r=[`border-2`,e?`border-red-300 dark:border-red-300`:`border-gray-200 dark:border-mint-divider`],i=[`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[...n,...r,...i].filter(Boolean).join(` `)}render(){let e=this.isLoading(),t=[];this._select&&Array.from(this._select.children).forEach(e=>{(e.tagName===`OPTION`||e.tagName===`OPTGROUP`)&&t.push(e.cloneNode(!0))});let n=Array.from(this.children).filter(e=>e.tagName===`OPTION`||e.tagName===`OPTGROUP`).map(e=>e.cloneNode(!0));for(;this.firstChild;)this.removeChild(this.firstChild);this._wrapper=null,this._select=null;let r=this.getLabel(),i=this.getInfo(),a=this.getId(),o=this.getName(),s=this.getValue(),c=this.isDisabled(),l=this.isMultiple(),u=this.hasError();if(r){let e=document.createElement(`label`);e.className=`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,a&&e.setAttribute(`for`,a);let t=document.createTextNode(r);e.appendChild(t),this.appendChild(e)}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(),a&&(this._select.id=a),o&&(this._select.name=o),c&&(this._select.disabled=!0),l&&(this._select.multiple=!0),this._select.setAttribute(`aria-invalid`,u?`true`:`false`);let d=n.length>0?n:t;if(d.length>0&&d.forEach(e=>{this._select.appendChild(e)}),this._select.options.length===0){let e=document.createElement(`option`);e.value=``,e.textContent=`Select an option`,e.disabled=!0,e.selected=!0,this._select.appendChild(e)}if(this._select.value=s||``,this._changeHandler&&this._select&&this._select.removeEventListener(`change`,this._changeHandler),this._changeHandler=e=>{let t=e.target.value;(this.getAttribute(`value`)||``)!==t&&(t?this.setAttribute(`value`,t):this.removeAttribute(`value`));let n=new Event(`input`,{bubbles:!0,cancelable:!0,composed:!0});this.dispatchEvent(n),this.dispatchEvent(new CustomEvent(`input`,{detail:{value:t},bubbles:!0,cancelable:!0,composed:!0})),this.dispatchEvent(new CustomEvent(`change`,{detail:{value:t},bubbles:!0,cancelable:!0,composed:!0}))},this._select.addEventListener(`change`,this._changeHandler),this._optionObserver&&this._optionObserver.disconnect(),this._optionObserver=new MutationObserver(()=>{let e=this.getAttribute(`value`)||this.value||``;this._select&&e&&requestAnimationFrame(()=>{this._select&&Array.from(this._select.options).some(t=>t.value===e)&&this._select.value!==e&&(this._select.value=e)})}),this._optionObserver.observe(this._select,{childList:!0,subtree:!0}),this._wrapper.appendChild(this._select),l)this._caretUpIcon=null,this._caretDownIcon=null;else{let e=document.createElement(`div`);e.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]`,e.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]`,e.appendChild(this._caretDownIcon),this._wrapper.appendChild(e)}if(i){let e=document.createElement(`div`);e.className=`mt-1 text-xs text-gray-500 dark:text-gray-400`,e.textContent=i,this.appendChild(e)}this._renderErrorState(),this._renderSkeleton(e)}_renderSkeleton(e){let t=this.querySelector(`.mint-select-skeleton-container`),n=this._wrapper;if(e){t||(t=document.createElement(`div`),t.className=`mint-select-skeleton-container absolute inset-0 z-10 pointer-events-none`,n?(n.classList.contains(`relative`)||n.classList.add(`relative`),n.appendChild(t)):(this.style.position=`relative`,this.appendChild(t)));let e=t.querySelector(`.mint-select-skeleton`);if(!e){e=document.createElement(`div`),e.className=`mint-select-skeleton w-full rounded-lg bg-gray-200 dark:bg-mint-hover animate-pulse`;let n=this.isMultiple();e.style.height=n?`6rem`:`2.25rem`,t.appendChild(e)}t.style.display=`block`,this._select&&(this._select.style.opacity=`0`,this._select.style.pointerEvents=`none`)}else t&&(t.style.display=`none`),this._select&&(this._select.style.opacity=`1`,this._select.style.pointerEvents=`auto`)}_renderErrorState(){let e=this.hasError(),t=this.getErrorMessage(),n=this.querySelector(`.mint-select-error`);e&&t?(n||(n=document.createElement(`div`),n.className=`mint-select-error mt-1 text-xs text-red-600 dark:text-red-400`,this.appendChild(n)),n.textContent=t):n&&n.remove()}};customElements.get(`mint-select`)||customElements.define(`mint-select`,C);var w=class extends HTMLElement{static get observedAttributes(){return[`label`,`accept`,`multiple`,`width`,`height`,`disabled`,`name`,`error`,`error-message`,`loading`]}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}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){let e=this.closest(`form`);e&&e.removeEventListener(`reset`,this._resetHandler),this._resetHandler=null}}attributeChangedCallback(e,t,n){if(t!==n){if(e===`error`||e===`error-message`){this._updateDragStateClass(),this._renderErrorState(this.hasError(),this.getErrorMessage());return}if(e===`loading`){this.render();return}this.render()}}getLabel(){return this.getAttribute(`label`)||``}getAccept(){return this.getAttribute(`accept`)||``}isMultiple(){return this.getAttribute(`multiple`)===`true`}getWidth(){return this.getAttribute(`width`)||`200px`}getHeight(){return this.getAttribute(`height`)||`200px`}_renderSkeleton(e){let t=this.querySelector(`.mint-dropzone-skeleton-container`),n=this._dropzone;if(e){t||(t=document.createElement(`div`),t.className=`mint-dropzone-skeleton-container absolute inset-0 z-10 pointer-events-none flex items-center justify-center`,n?(n.classList.contains(`relative`)||n.classList.add(`relative`),n.appendChild(t)):(this.style.position=`relative`,this.appendChild(t)));let e=t.querySelector(`.mint-dropzone-skeleton`);if(e||(e=document.createElement(`div`),e.className=`mint-dropzone-skeleton rounded-lg border-2 border-dashed border-gray-300 dark:border-mint-divider bg-gray-200 dark:bg-mint-hover animate-pulse`,e.style.width=`100%`,e.style.height=`100%`,t.appendChild(e)),t.style.display=`flex`,n){let e=n.querySelector(`.mint-dropzone-icon`),t=n.querySelector(`.mint-dropzone-label`),r=n.querySelector(`.mint-dropzone-previews-wrapper`),i=this._fileInput;if(e){let t=e;t.style.visibility=`hidden`,t.style.pointerEvents=`none`}if(t){let e=t;e.style.visibility=`hidden`,e.style.pointerEvents=`none`}if(r){let e=r;e.style.visibility=`hidden`,e.style.pointerEvents=`none`}i&&(i.style.visibility=`hidden`,i.style.pointerEvents=`none`),n.style.pointerEvents=`none`}}else if(t&&(t.style.display=`none`),n){let e=n.querySelector(`.mint-dropzone-icon`),t=n.querySelector(`.mint-dropzone-label`),r=n.querySelector(`.mint-dropzone-previews-wrapper`),i=this._fileInput;if(e){let t=e;t.style.visibility=`visible`,t.style.pointerEvents=`auto`}if(t){let e=t;e.style.visibility=`visible`,e.style.pointerEvents=`auto`}if(r){let e=r;e.style.visibility=`visible`,e.style.pointerEvents=`auto`}i&&(i.style.visibility=`visible`,i.style.pointerEvents=`auto`),n.style.pointerEvents=`auto`}}getName(){return this.getAttribute(`name`)||``}hasError(){return this.getAttribute(`error`)===`true`}getErrorMessage(){return this.getAttribute(`error-message`)||``}isDisabled(){return this.getAttribute(`disabled`)===`true`}isLoading(){return this.getAttribute(`loading`)===`true`}render(){let e=this.isLoading(),t=this.getLabel(),n=this.getAccept(),r=this.isMultiple(),i=this.isDisabled(),a=this.getWidth(),o=this.getHeight(),s=this.getName(),c=this.hasError(),l=this.getErrorMessage();this._dropzone||(this._dropzone=document.createElement(`div`),this.appendChild(this._dropzone)),this._updateDragStateClass(),this._dropzone.setAttribute(`aria-invalid`,c?`true`:`false`),i?(this._dropzone.setAttribute(`tabindex`,`-1`),this._dropzone.removeAttribute(`role`)):(this._dropzone.setAttribute(`tabindex`,`0`),this._dropzone.setAttribute(`role`,`button`),this._dropzone.setAttribute(`aria-label`,t||`File upload dropzone`)),this._dropzone.style.width=a,this._dropzone.style.height=o,this._dropzone.style.minWidth=a,this._dropzone.style.minHeight=o,this._fileInput||(this._fileInput=document.createElement(`input`),this._fileInput.type=`file`,this._fileInput.style.display=`none`,this._fileInput.setAttribute(`tabindex`,`-1`),this._fileInput.setAttribute(`aria-hidden`,`true`),this._dropzone.appendChild(this._fileInput)),this._fileInput.accept=n,this._fileInput.multiple=r,this._fileInput.disabled=i,s?this._fileInput.name=s:this._fileInput.removeAttribute(`name`),this._fileInput.setAttribute(`aria-invalid`,c?`true`:`false`);let u=this._dropzone.querySelector(`.mint-dropzone-icon`),d=this._dropzone.querySelector(`.mint-dropzone-label`);u&&u.remove(),d&&d.remove();let f=document.createElement(`div`);f.className=`mint-dropzone-icon flex items-center justify-center mt-2 mb-2 flex-shrink-0`;let p=document.createElement(`mint-icon`);if(p.setAttribute(`name`,`upload`),p.className=`w-12 h-12 text-gray-400 dark:text-gray-500`,f.appendChild(p),this._dropzone.appendChild(f),t){let e=document.createElement(`div`);e.className=`mint-dropzone-label text-sm font-medium text-gray-600 dark:text-gray-400 text-center px-4 flex-shrink-0`,e.textContent=t,this._dropzone.appendChild(e)}this.setupEventListeners(),this._renderErrorState(c,l),this._renderPreviews(),this._renderSkeleton(e)}_updateDragState(){this._dropzone&&this._updateDragStateClass()}_renderErrorState(e,t){let n=this.querySelector(`.mint-dropzone-error`);e&&t?(n||(n=document.createElement(`div`),n.className=`mint-dropzone-error mt-1 text-xs text-red-600 dark:text-red-400`,this.appendChild(n)),n.textContent=t):n&&n.remove()}_updateDragStateClass(){if(!this._dropzone)return;let e=this.isDisabled(),t=this.hasError(),n=`relative border-2 border-dashed rounded-lg flex flex-col items-center ${this._selectedFiles.length>0?`justify-start`:`justify-center`} cursor-pointer overflow-hidden`,r=this._isDragging?`border-gray-400 dark:border-gray-500 bg-gray-50 dark:bg-mint-elevated dark:border-mint-divider`:`border-gray-300 dark:border-mint-divider bg-white dark:bg-mint-elevated dark:border-mint-divider hover:border-gray-400 dark:hover:border-mint-divider`,i=t?`border-red-300 dark:border-red-300 bg-red-50/50 dark:bg-red-900/30`:``,a=e?`opacity-40 cursor-not-allowed`:``;this._dropzone.className=`${n} ${t?i:r} ${a} focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500`.trim()}setupEventListeners(){this._listenersInitialized||(this._listenersInitialized=!0,this.removeEventListeners(),!(!this._dropzone||!this._fileInput||this.isDisabled())&&(this._onDropzoneClick||=e=>{if(!(this.isDisabled()||!this._fileInput)&&e.target!==this._fileInput&&(e.stopPropagation(),e.preventDefault(),e.isTrusted))try{this._fileInput.click()}catch(e){console.debug(`File chooser blocked:`,e)}},this._onDragOver||=e=>{e.preventDefault(),e.stopPropagation(),this.isDisabled()||this._isDragging||(this._isDragging=!0,this._wasDragging=!0,this._updateDragState())},this._onDragLeave||=e=>{e.preventDefault(),e.stopPropagation();let t=this._dropzone?.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||=e=>{if(e.preventDefault(),e.stopPropagation(),this._isDragging&&(this._isDragging=!1,this._wasDragging=!1,this._updateDragState()),this.isDisabled())return;let t=e.dataTransfer?.files;t&&t.length>0&&this._handleFiles(t)},this._onFileInputInput||=e=>{e.stopImmediatePropagation(),e.stopPropagation()},this._onKeyDown||=e=>{if(!(this.isDisabled()||!this._fileInput)&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopPropagation(),e.isTrusted))try{this._fileInput.click()}catch(e){console.debug(`File chooser blocked:`,e)}},this._onFocus||=e=>{this._dropzone&&!this.isDisabled()&&this._dropzone.classList.add(`focus-visible:ring-2`)},this._onBlur||=e=>{this._dropzone},this._onFileInputChange||=e=>{if(e.stopImmediatePropagation(),e.stopPropagation(),this._isUpdatingFiles)return;let t=e.target.files;if(t&&t.length>0){let e=this.getAccept(),n=this.isMultiple(),r=[],i=[];for(let n=0;n<t.length;n++){let a=t[n];this._isFileAccepted(a,e)?r.push(a):i.push(a)}if(!n&&r.length>1&&(i.push(...r.slice(1)),r.splice(1)),i.length>0){let e=new CustomEvent(`dropRejected`,{detail:{files:i,reason:`File type not accepted or multiple files not allowed`},bubbles:!0,cancelable:!0});this.dispatchEvent(e)}r.length>0&&this._applyValidFiles(r)}},this._dropzone.addEventListener(`click`,this._onDropzoneClick),this._dropzone.addEventListener(`dragover`,this._onDragOver),this._dropzone.addEventListener(`dragleave`,this._onDragLeave),this._dropzone.addEventListener(`drop`,this._onDrop),this._dropzone.addEventListener(`keydown`,this._onKeyDown),this._dropzone.addEventListener(`focus`,this._onFocus),this._dropzone.addEventListener(`blur`,this._onBlur),this._fileInput.addEventListener(`change`,this._onFileInputChange),this._fileInput.addEventListener(`input`,this._onFileInputInput,!0)))}removeEventListeners(){this._dropzone&&(this._onDropzoneClick&&this._dropzone.removeEventListener(`click`,this._onDropzoneClick),this._onDragOver&&this._dropzone.removeEventListener(`dragover`,this._onDragOver),this._onDragLeave&&this._dropzone.removeEventListener(`dragleave`,this._onDragLeave),this._onDrop&&this._dropzone.removeEventListener(`drop`,this._onDrop),this._onKeyDown&&this._dropzone.removeEventListener(`keydown`,this._onKeyDown),this._onFocus&&this._dropzone.removeEventListener(`focus`,this._onFocus),this._onBlur&&this._dropzone.removeEventListener(`blur`,this._onBlur)),this._fileInput&&(this._onFileInputChange&&this._fileInput.removeEventListener(`change`,this._onFileInputChange),this._onFileInputInput&&this._fileInput.removeEventListener(`input`,this._onFileInputInput,!0)),this._isDragging=!1,this._listenersInitialized=!1}_handleFiles(e){let t=this.getAccept(),n=this.isMultiple(),r=[],i=[];for(let n=0;n<e.length;n++){let a=e[n];this._isFileAccepted(a,t)?r.push(a):i.push(a)}if(!n&&r.length>1&&(i.push(...r.slice(1)),r.splice(1)),i.length>0){let e=new CustomEvent(`dropRejected`,{detail:{files:i,reason:`File type not accepted or multiple files not allowed`},bubbles:!0,cancelable:!0});this.dispatchEvent(e)}r.length>0&&this._applyValidFiles(r)}_isFileAccepted(e,t){if(!t)return!0;let n=t.split(`,`).map(e=>e.trim().toLowerCase());for(let t of n)if(t.startsWith(`.`)){if(`.`+e.name.split(`.`).pop()?.toLowerCase()===t)return!0}else if(t.includes(`/*`)){if(t.split(`/`)[0]===e.type.split(`/`)[0])return!0}else if(e.type===t)return!0;return!1}_dispatchEvent(e,t){let n=t.target,r=new CustomEvent(e,{detail:{files:n.files?Array.from(n.files):[],value:n.value||``},bubbles:!0,cancelable:!0});this.dispatchEvent(r)}_dispatchSelectionEvents(){let e={files:[...this._selectedFiles],value:``};this.dispatchEvent(new CustomEvent(`input`,{detail:e,bubbles:!0,cancelable:!0,composed:!0})),this.dispatchEvent(new CustomEvent(`change`,{detail:e,bubbles:!0,cancelable:!0,composed:!0}))}_syncFileInputFromSelected(){if(!this._fileInput)return;let e=new DataTransfer;this._selectedFiles.forEach(t=>{try{e.items.add(t)}catch(e){console.warn(`Failed to add file to DataTransfer:`,e)}}),this._isUpdatingFiles=!0;try{this._fileInput.files=e.files}catch(e){console.warn(`Failed to set files on input:`,e)}setTimeout(()=>{this._isUpdatingFiles=!1},0)}get files(){return this._syncFileInputFromSelected(),this._fileInput?.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}let e=document.createElement(`div`);e.className=`mint-dropzone-previews-wrapper mt-3 w-full relative max-h-48`;let 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((e,n)=>{let r=document.createElement(`div`);if(r.className=`flex items-center gap-3 p-2 rounded border border-gray-200 dark:border-mint-divider bg-gray-50 dark:bg-mint-elevated`,e.type.startsWith(`image/`)){let t=document.createElement(`img`);t.className=`w-12 h-12 object-cover rounded border border-gray-200 dark:border-mint-divider`;let n=URL.createObjectURL(e);this._previewUrls.push(n),t.src=n,r.appendChild(t)}else{let e=document.createElement(`mint-icon`);e.setAttribute(`name`,`attach`),e.className=`w-5 h-5 text-gray-500 dark:text-gray-300`,r.appendChild(e)}let i=document.createElement(`div`);i.className=`flex-1 text-sm text-gray-800 dark:text-gray-100 truncate`,i.textContent=e.name,r.appendChild(i);let a=document.createElement(`button`);a.type=`button`,a.className=`text-gray-500 hover:bg-red-100 dark:hover:bg-red-900/30 flex items-center justify-center w-6 h-6 rounded-full`;let o=document.createElement(`mint-icon`);o.setAttribute(`name`,`close`),o.className=`w-4 h-4`,a.appendChild(o),a.addEventListener(`click`,e=>{e.preventDefault(),e.stopPropagation(),this._removeFileAt(n)}),r.appendChild(a),t.appendChild(r)});let n=this.hasError(),r=this._isDragging,i=`from-white dark:from-mint-elevated`;n?i=`from-red-50 dark:from-red-900/30`:r&&(i=`from-gray-50 dark:from-mint-elevated`);let a=document.createElement(`div`);a.className=`absolute top-0 left-0 right-0 h-4 pointer-events-none z-10 bg-gradient-to-b ${i} to-transparent opacity-0`,e.appendChild(a);let o=document.createElement(`div`);o.className=`absolute bottom-0 left-0 right-0 h-4 pointer-events-none z-10 bg-gradient-to-t ${i} to-transparent opacity-100`,e.appendChild(o);let s=()=>{let e=t.scrollTop,n=t.scrollHeight,r=t.clientHeight;e>0?a.style.opacity=`1`:a.style.opacity=`0`,e+r<n-1?o.style.opacity=`1`:o.style.opacity=`0`};s(),t.addEventListener(`scroll`,s),e.appendChild(t),this._previewContainer=e,this._dropzone.appendChild(e),this._updateDragStateClass()}_removeFileAt(e){if(e<0||e>=this._selectedFiles.length)return;let[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(){let 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()){let t=e.filter(e=>!this._isDuplicateFile(e));this._selectedFiles.push(...t)}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`,w);var T=class extends HTMLElement{static get observedAttributes(){return[`action`,`method`,`enctype`,`data-form-data`,`loading`,`headers`]}constructor(){super(),this._form=null,this._submitHandler=null,this._hostSubmitHandler=null,this._errors={},this._fieldBlurHandlers=new Map,this._fieldChangeHandlers=new Map,this._observer=null,this._formData=null,this._headers=null,this._buttonStates=new Map,this._reactiveDataProxy=null,this._reactiveDataObserver=null,this._lastDataSnapshot=null}connectedCallback(){this._render(),this._ensureSubmitHandler(),this._setupBlurValidation();let e=this.getAttribute(`headers`);e&&this._parseHeaders(e),requestAnimationFrame(()=>{requestAnimationFrame(()=>{if(this._formData)this._isReactiveObject(this._formData)?this._setupReactiveDataObserver(this._formData):this._lastDataSnapshot||=this._createDataSnapshot(this._formData),this._applyFormData();else{let e=this.getAttribute(`data-form-data`);e&&(this._parseFormData(e),this._applyFormData())}this._propagateLoadingState()})})}disconnectedCallback(){this._form&&this._submitHandler&&this._form.removeEventListener(`submit`,this._submitHandler,!0),this._hostSubmitHandler&&this.removeEventListener(`submit`,this._hostSubmitHandler),this._cleanupBlurValidation(),this._stopReactiveDataObserver()}reset(){this._clearErrors(),this._formData?this._applyFormData():this.clear()}clear(){this._clearErrors(),this._form&&this._form.reset(),this._resetCustomFields()}attributeChangedCallback(e,t,n){e===`form-data`?(this._parseFormData(n),this.isConnected&&this._form&&requestAnimationFrame(()=>{requestAnimationFrame(()=>{this._applyFormData()})})):e===`headers`?this._parseHeaders(n):e===`loading`?this.isConnected&&this._form?requestAnimationFrame(()=>{this._propagateLoadingState()}):this._propagateLoadingState():this._applyFormAttributes()}get data(){return this._formData}set data(e){this._stopReactiveDataObserver(),this._reactiveDataProxy=null,this._lastDataSnapshot=null,e&&typeof e==`object`&&!Array.isArray(e)?(this._formData=e,this._isReactiveObject(e)?this._setupReactiveDataObserver(e):this._lastDataSnapshot=this._createDataSnapshot(e)):e==null?this._formData=null:this._parseFormData(e),this.isConnected&&this._form&&requestAnimationFrame(()=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{this._applyFormData()})})})}get headers(){return this._headers}set headers(e){if(e&&typeof e==`object`&&!Array.isArray(e))this._headers=e;else if(e==null)this._headers=null;else if(typeof e==`string`)try{this._headers=JSON.parse(e)}catch{this._headers=null}else this._headers=null}_render(){if(this.classList.add(`block`,`w-full`),!this._form){for(this._form=document.createElement(`form`),this._form.noValidate=!0;this.firstChild;)this._form.appendChild(this.firstChild);this.appendChild(this._form)}this._ensureSubmitHandler(),this._applyFormAttributes()}_ensureSubmitHandler(){this._form&&(this._submitHandler&&this._form.removeEventListener(`submit`,this._submitHandler,!0),this._submitHandler=e=>{e.preventDefault(),e.stopImmediatePropagation(),this._handleSubmit(e)},this._form.addEventListener(`submit`,this._submitHandler,!0))}_applyFormAttributes(){if(!this._form)return;let e=this.getAttribute(`action`)||``,t=this.getAttribute(`method`)||``,n=this.getAttribute(`enctype`)||`application/x-www-form-urlencoded`;e&&(this._form.action=e),t&&(this._form.method=t),this._form.enctype=n}async _handleSubmit(e){if(e.preventDefault(),!this._form)return;this._clearErrors(),this._syncDropzoneFiles();let t=this._collectValidationRules(),n=new FormData(this._form),r=this._formDataToValues(n);if(this._formData){let e=this._getReactiveValue(this._formData);e&&typeof e==`object`&&!Array.isArray(e)&&(r={...this._extractReactiveData(e),...r})}if(!this._validate(r,t)){this.dispatchEvent(new CustomEvent(`invalid`,{detail:{errors:this._errors},bubbles:!0,cancelable:!0,composed:!0}));return}let i=new CustomEvent(`submit`,{detail:{formData:n,values:r,form:this},bubbles:!0,cancelable:!0,composed:!0});this.dispatchEvent(i),i.form=this;let a=new CustomEvent(`mintFormSubmit`,{detail:{formData:n,values:r,form:this},bubbles:!0,cancelable:!0,composed:!0});if(a.form=this,this.dispatchEvent(a),i.defaultPrevented||a.defaultPrevented)return;let o=this.getAttribute(`action`),s=this.getAttribute(`method`);if(!(!o||!s)){this._setButtonsSubmitting();try{let e=await this._submitData(n,r);this.dispatchEvent(new CustomEvent(`submitsuccess`,{detail:e,bubbles:!0,cancelable:!0}))}catch(e){e?.status===422&&e?.data?.errors&&this._applyServerErrors(e.data.errors),this.dispatchEvent(new CustomEvent(`submiterror`,{detail:{error:e},bubbles:!0,cancelable:!0}))}finally{this._restoreButtonsState()}}}async _submitData(e,t){let n=this.getAttribute(`action`),r=this.getAttribute(`method`),i=this.getAttribute(`enctype`)||`application/x-www-form-urlencoded`;if(!n)return{status:0,ok:!0,data:{values:t}};let a=Array.from(e.values()).some(e=>e instanceof File),o=null,s={},c=n;if(typeof window<`u`&&window.mintForm?.defaults?.headers?.common&&Object.assign(s,window.mintForm.defaults.headers.common),this._headers&&Object.assign(s,this._headers),r===`GET`){let t=new URLSearchParams;e.forEach((e,n)=>{e instanceof File||t.append(n,String(e))}),c+=(n.includes(`?`)?`&`:`?`)+t.toString()}else if(i===`multipart/form-data`||a)o=e;else if(i===`application/json`)o=JSON.stringify(t),s[`Content-Type`]=`application/json`;else{let t=new URLSearchParams;e.forEach((e,n)=>{e instanceof File||t.append(n,String(e))}),o=t,s[`Content-Type`]=`application/x-www-form-urlencoded`}if(typeof fetch==`function`)try{let e=await fetch(c,{method:r||`POST`,body:r===`GET`?null:o,headers:s}),t=await e.text().catch(()=>``),n=t;try{n=JSON.parse(t)}catch{}if(!e.ok){let t={status:e.status,data:n,response:{status:e.status,data:n}};throw await this._applyErrorInterceptors(t)}let i={status:e.status,ok:e.ok,data:n};return await this._applySuccessInterceptors(i)}catch(e){if(e.response)throw e;let t={status:e.status||0,data:e.data||e.message||`Network error`,response:{status:e.status||0,data:e.data||e.message||`Network error`}};throw await this._applyErrorInterceptors(t)}let l=this;return await new Promise(async(e,t)=>{let n=new XMLHttpRequest;n.open(r||`POST`,c,!0),Object.entries(s).forEach(([e,t])=>n.setRequestHeader(e,t)),n.onload=async function(){let{status:r,responseText:i}=n;if(r>=200&&r<300){let n=i;try{n=JSON.parse(i)}catch{}try{let t={status:r,ok:!0,data:n};e(await l._applySuccessInterceptors(t))}catch(e){t(e)}}else{let e=i;try{e=JSON.parse(i)}catch{}try{let n={status:r,data:e,response:{status:r,data:e}};t(await l._applyErrorInterceptors(n))}catch(e){t(e)}}},n.onerror=async function(){try{let e={status:n.status||0,data:n.responseText||`Network error`,response:{status:n.status||0,data:n.responseText||`Network error`}};t(await l._applyErrorInterceptors(e))}catch(e){t(e)}},n.send(r===`GET`?null:o)})}async _applySuccessInterceptors(e){if(typeof window>`u`||!window.mintForm?.interceptors?.response?.handlers)return e;let t=e,n=window.mintForm.interceptors.response.handlers;for(let e of n)e.fulfilled&&(t=await e.fulfilled(t));return t}async _applyErrorInterceptors(e){if(typeof window>`u`||!window.mintForm?.interceptors?.response?.handlers)return Promise.reject(e);let t=e,n=window.mintForm.interceptors.response.handlers;for(let e=n.length-1;e>=0;e--){let r=n[e];if(r.rejected)try{if(t=await r.rejected(t),t!==void 0)return t}catch(e){t=e}}return Promise.reject(t)}_formDataToValues(e){let t={};return e.forEach((e,n)=>{e instanceof File?(t[n]||(t[n]=[]),t[n].push(e)):n in t?Array.isArray(t[n])?(t[n].length>0&&t[n][0]instanceof File,t[n].push(e)):t[n]=[t[n],e]:t[n]=e}),this._form&&(Array.from(this._form.querySelectorAll(`mint-dropzone[name]`)).forEach(e=>{let n=e.getAttribute(`name`);if(n&&e.files!==void 0&&e.files){let r=e.files;if(r.length>0){let e=Array.from(r);t[n]&&Array.isArray(t[n])?e.forEach(e=>{t[n].some(t=>t.name===e.name&&t.size===e.size&&t.lastModified===e.lastModified)||t[n].push(e)}):t[n]=e}}}),Array.from(this._form.querySelectorAll(`input[type="file"][name]`)).forEach(e=>{let n=e.name;if(n&&e.files&&e.files.length>0){let r=Array.from(e.files);t[n]&&Array.isArray(t[n])?r.forEach(e=>{t[n].some(t=>t.name===e.name&&t.size===e.size&&t.lastModified===e.lastModified)||t[n].push(e)}):t[n]=r}}),Array.from(this._form.querySelectorAll(`mint-tags[name]`)).forEach(e=>{let n=e.getAttribute(`name`);if(n){let r=[];e.tags===void 0?typeof e.getTags==`function`&&(r=e.getTags()):r=e.tags,Array.isArray(r)&&r.length>0?t[n]=r.map(e=>typeof e==`string`?e:e?.value||e?.label||``).filter(e=>e.trim()!==``):t[n]=[]}})),t}_collectValidationRules(){let e={};return this._form&&Array.from(this._form.querySelectorAll(`[name][validation]`)).forEach(t=>{let n=t.getAttribute(`name`)||``,r=t.getAttribute(`validation`);if(!n||!r)return;let i=this._parseRules(r);i.length&&(e[n]=i)}),e}_parseRules(e){if(!e)return[];try{let t=e.replace(/'/g,`"`),n=JSON.parse(t);if(Array.isArray(n))return n.map(e=>String(e))}catch{}return e.split(`,`).map(e=>e.trim()).filter(Boolean)}_validate(e,t){let n=!0;return this._errors={},Object.entries(t||{}).forEach(([e,t])=>{let r=Array.isArray(t)?t:[t],i=this._getFieldElements(e),a=this._extractFieldValue(i),o=this._validateRules(a,r);o?(n=!1,this._errors[e]=o,this._flagFieldError(i,o)):this._clearFieldError(i)}),n}_validateField(e){let t=this._collectValidationRules();if(!t[e])return;let n=t[e],r=Array.isArray(n)?n:[n],i=this._getFieldElements(e),a=this._extractFieldValue(i),o=this._validateRules(a,r);o?(this._errors[e]=o,this._flagFieldError(i,o)):(this._clearFieldError(i),delete this._errors[e])}_validateRules(e,t){for(let n of t){let[t,r]=n.split(`:`);switch(t){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`:{let t=Number(e);if(Number.isNaN(t))return`Must be a number.`;break}case`min`:{let t=Number(r);if(Number.isNaN(t))break;if(typeof e==`string`&&e.trim().length<t)return`Must be at least ${t} characters.`;if(Array.isArray(e)&&e.length<t)return`Select at least ${t}.`;if(e instanceof FileList&&e.length<t)return`Upload at least ${t} files.`;if(e!=null&&!Number.isNaN(Number(e))&&Number(e)<t)return`Must be at least ${t}.`;break}case`max`:{let t=Number(r);if(Number.isNaN(t))break;if(typeof e==`string`&&e.trim().length>t)return`Must be at most ${t} characters.`;if(Array.isArray(e)&&e.length>t)return`Select no more than ${t}.`;if(e instanceof FileList&&e.length>t)return`Upload no more than ${t} files.`;if(e!=null&&!Number.isNaN(Number(e))&&Number(e)>t)return`Must be at most ${t}.`;break}default:break}}return null}_getFieldElements(e){if(!this._form)return[];let t=Array.from(this._form.querySelectorAll(`[name="${e}"]`)),n=t.filter(e=>e.tagName===`MINT-SELECT`);if(n.length>0){let r=[];return n.forEach(t=>{let n=t.querySelector(`select[name="`+e+`"]`);n&&r.push(n)}),t.filter(e=>e.tagName!==`MINT-SELECT`).concat(r)}if(t.filter(e=>e.tagName===`MINT-TAGS`).length>0)return t.filter(e=>e.tagName!==`INPUT`||!e.closest(`mint-tags`));let r=t.filter(e=>e.tagName===`INPUT`&&e.closest(`mint-tags`));if(r.length>0){let e=[];return r.forEach(t=>{let n=t.closest(`mint-tags`);n&&!e.includes(n)&&e.push(n)}),t.filter(e=>e.tagName!==`INPUT`||!e.closest(`mint-tags`)).concat(e)}return t}_extractFieldValue(e){if(e.length===0)return``;let t=e.find(e=>e instanceof HTMLSelectElement);if(t)return t.value;if(e.length>1){let t=e.filter(e=>e instanceof HTMLInputElement);if(t.length>0&&t.length===e.length){let e=t.filter(e=>e.checked);if(t.every(e=>e.type===`radio`))return e.length>0?e[0].value||`on`:``;if(t.every(e=>e.type===`checkbox`))return e.map(e=>e.value||`on`)}let n=e.filter(e=>e.tagName===`MINT-CHOICE`);if(n.length>0&&n.length===e.length){let e=n.find(e=>typeof e.getValue==`function`?e.getValue()!==``:e.querySelector(`mint-choice-option[checked]`)!==null);if(e){if(typeof e.getValue==`function`)return e.getValue();let t=e.querySelector(`mint-choice-option[checked]`);if(t)return t.getAttribute(`value`)||``}return``}let r=e.filter(e=>e.tagName===`MINT-CHECKBOX`);if(r.length>0&&r.length===e.length)return r.filter(e=>e.checked===void 0?e.hasAttribute(`checked`):e.checked).map(e=>e.getAttribute(`value`)||`on`)}let n=e[0];if(n instanceof HTMLInputElement)return n.type===`file`?n.files:n.type===`checkbox`||n.type===`radio`?n.checked?n.value||`on`:``:n.value;if(n instanceof HTMLTextAreaElement)return n.value;if(n.tagName===`MINT-SELECT`){let e=n.querySelector(`select`);if(e)return e.value;if(typeof n.getValue==`function`){let e=n.getValue();if(e!=null&&e!==``)return e}return n.getAttribute(`value`)||``}if(n.tagName===`MINT-DROPZONE`&&n.files!==void 0)return n.files;if(n.tagName===`MINT-TAGS`){let e=null;return n.tags===void 0?typeof n.getTags==`function`&&(e=n.getTags()):e=n.tags,Array.isArray(e)?e.map(e=>typeof e==`string`?e:e?.value||e?.label||``).filter(e=>e.trim()!==``):[]}return n.tagName===`MINT-CHECKBOX`||n.tagName===`MINT-SWITCH`?(n.checked===void 0?n.hasAttribute(`checked`):n.checked)?n.getAttribute(`value`)||`on`:``:n.tagName===`MINT-CHOICE`?(typeof n.getValue==`function`?n.getValue():``)||``:n.value===void 0?n.getAttribute(`value`)||``:n.value}_flagFieldError(e,t){e.length!==0&&e.forEach(e=>{(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)&&e.setAttribute(`aria-invalid`,`true`);let n=this._resolveHost(e);n&&(n.setAttribute(`error`,`true`),n.setAttribute(`error-message`,t),n.setAttribute(`data-mint-form-error`,`true`))})}_clearFieldError(e){e.length!==0&&e.forEach(e=>{(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)&&e.removeAttribute(`aria-invalid`);let t=this._resolveHost(e);t&&(t.removeAttribute(`error`),t.removeAttribute(`error-message`),t.removeAttribute(`data-mint-form-error`))})}_clearErrors(){this.querySelectorAll(`[data-mint-form-error]`).forEach(e=>{let 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`)}),this._errors={}}setFormErrors(e){this._applyServerErrors(e)}_applyServerErrors(e){this._clearErrors(),Object.entries(e).forEach(([e,t])=>{let n=Array.isArray(t)?t[0]||`Validation error`:t||`Validation error`,r=this._getFieldElements(e);r.length>0&&(this._errors[e]=n,this._flagFieldError(r,n))})}_parseFormData(e){if(!e){this._formData=null;return}if(typeof e==`object`&&!Array.isArray(e)){this._formData=e;return}if(typeof e==`string`)try{this._formData=JSON.parse(e)}catch{this._formData=null}else this._formData=null}_parseHeaders(e){if(!e){this._headers=null;return}if(typeof e==`string`)try{this._headers=JSON.parse(e)}catch{this._headers=null}else this._headers=null}_applyFormData(){if(!this._formData||!this._form)return;let e=this._getReactiveValue(this._formData);if(!e||typeof e!=`object`||Array.isArray(e))return;let t=()=>{Object.entries(e).forEach(([e,t])=>{let n=this._getFieldElements(e);if(n.length===0){setTimeout(()=>{let n=this._getFieldElements(e);n.length>0&&this._applyValueToField(n,e,t)},300);return}this._applyValueToField(n,e,t)})};requestAnimationFrame(()=>{requestAnimationFrame(()=>{t()})})}_applyValueToField(e,t,n){e.forEach(e=>{let r=e.tagName;try{if(r===`MINT-INPUT`)e.value!==void 0&&(e.value=n||``);else if(r===`MINT-DATE-PICKER`)typeof e.setValue==`function`&&e.setValue(n||``);else if(r===`MINT-SELECT`||r===`SELECT`)r===`SELECT`?e.closest(`mint-select`)?.setValue(n||``):typeof e.setValue==`function`&&e.setValue(n||``);else if(r===`MINT-CHOICE`)typeof e.setValue==`function`?e.setValue(n||``):e.querySelectorAll(`mint-choice-option`).forEach(e=>{e.checked=e.getAttribute(`value`)===n});else if(r===`MINT-CHECKBOX`||r===`MINT-SWITCH`){let t=n===!0||n===`true`||n===`on`||n===1||n===`1`;e.checked===void 0?t?e.setAttribute(`checked`,`true`):e.removeAttribute(`checked`):e.checked=t}else if(r===`MINT-TAGS`)Array.isArray(n)&&e.tags!==void 0&&(e.tags=n.map(e=>typeof e==`string`?{value:e,label:e,dismissable:!0}:e));else if(e instanceof HTMLInputElement){if(e.type===`file`)return;e.type===`checkbox`||e.type===`radio`?e.checked=n===!0||n===`true`||n===`on`||n===1||n===`1`:e.value=n||``}else (e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)&&(e.value=n||``)}catch(e){console.warn(`Failed to set value for field ${t}:`,e)}})}_resetCustomFields(){this.querySelectorAll(`mint-input, mint-date-picker, mint-select, mint-dropzone, mint-checkbox, mint-choice, mint-switch, mint-tags`).forEach(e=>{e.removeAttribute(`error`),e.removeAttribute(`error-message`);let t=e.tagName;if(t===`MINT-INPUT`)try{e.value=``}catch{}else if(t===`MINT-DATE-PICKER`)try{e.setValue?.(``)}catch{}else if(t===`MINT-SELECT`)try{e.setValue?.(``)}catch{}else if(t===`MINT-DROPZONE`){let t=e.querySelector(`input[type="file"]`);t&&(t.value=``)}else if(t===`MINT-CHECKBOX`||t===`MINT-SWITCH`)try{if(e.checked!==void 0)e.checked=!1;else{e.removeAttribute(`checked`);let t=e.querySelector(`input[type="checkbox"], input[type="radio"]`);t&&(t.checked=!1)}}catch{}else if(t===`MINT-CHOICE`)try{typeof e.setValue==`function`?e.setValue(``):e.querySelectorAll(`mint-choice-option`).forEach(e=>{e.checked=!1})}catch{}else if(t===`MINT-TAGS`)try{e.tags=[]}catch{}})}_resolveHost(e){if(e.tagName===`MINT-CHOICE-OPTION`){let t=e.closest(`mint-choice`);if(t)return t}return e.closest(`mint-input, mint-date-picker, mint-select, mint-dropzone, mint-checkbox, mint-choice, mint-switch, mint-tags`)||e}_setupBlurValidation(){if(!this._form)return;let e=e=>{let t=e.target;if(!t)return;let n=this._findFieldElement(t);if(!n)return;let r=this._getFieldName(n);if(!r||!this._collectValidationRules()[r])return;let i=this._extractFieldValue([n]),a=i!=null&&(typeof i==`string`?i.trim()!==``:i instanceof FileList||Array.isArray(i)?i.length>0:!0),o=n.hasAttribute(`data-mint-form-error`)||t instanceof HTMLElement&&(t.hasAttribute(`aria-invalid`)||t.closest(`[data-mint-form-error]`)),s=!!n.closest(`mint-tags`),c=n.tagName===`MINT-CHECKBOX`||n.tagName===`MINT-SWITCH`||n.tagName===`MINT-CHOICE`||t instanceof HTMLElement&&(t.closest(`mint-checkbox, mint-switch, mint-choice`)||t.closest(`mint-choice-option`)),l=n.tagName===`MINT-DATE-PICKER`||t instanceof HTMLElement&&t.closest(`mint-date-picker`);(a||o||s||c||l)&&setTimeout(()=>{this._validateField(r)},0)};this._form.addEventListener(`blur`,e,!0),this._fieldBlurHandlers.set(this._form,e);let t=e=>{let t=e.target;if(!t)return;if(!(t instanceof HTMLInputElement&&t.type===`file`)){let e=this._findFieldElement(t),n=e?this._getFieldName(e):null;e&&n&&this._syncFieldToReactiveData(e,n)}if(e.type===`tags-change`&&t.tagName===`MINT-TAGS`){let e=t,n=this._getFieldName(e);if(!n||!this._collectValidationRules()[n])return;setTimeout(()=>{this._validateField(n)},0);return}if(t instanceof HTMLSelectElement||t.tagName===`MINT-SELECT`||t.closest(`mint-select`)){let e=this._findFieldElement(t);if(!e)return;let n=this._getFieldName(e);if(!n||!this._collectValidationRules()[n])return;setTimeout(()=>{this._validateField(n)},0);return}if(e.type===`choice-change`&&t.tagName===`MINT-CHOICE`){let e=t,n=this._getFieldName(e);if(!n||!this._collectValidationRules()[n])return;setTimeout(()=>{this._validateField(n)},0);return}if(t instanceof HTMLInputElement&&t.type===`checkbox`||t.tagName===`MINT-CHECKBOX`||t.tagName===`MINT-SWITCH`||t.closest(`mint-checkbox, mint-switch`)){let e=this._findFieldElement(t);if(!e)return;let n=this._getFieldName(e);if(!n||!this._collectValidationRules()[n])return;setTimeout(()=>{this._validateField(n)},0);return}let n=this._findFieldElement(t);if(!n)return;let r=this._getFieldName(n);r&&this._collectValidationRules()[r]&&(n.hasAttribute(`data-mint-form-error`)||t instanceof HTMLElement&&t.hasAttribute(`aria-invalid`))&&setTimeout(()=>{this._validateField(r)},0)};this._form.addEventListener(`change`,t,!0),this._form.addEventListener(`input`,t,!0),this._form.addEventListener(`tags-change`,t,!0),this._form.addEventListener(`choice-change`,t,!0),this._fieldChangeHandlers.set(this._form,t)}_findFieldElement(e){let t=e.closest(`mint-input, mint-date-picker, mint-select, mint-dropzone, mint-checkbox, mint-choice, mint-switch, mint-tags`);if(t&&t.hasAttribute(`name`))return t;if(e.hasAttribute(`name`)&&(e.tagName.startsWith(`MINT-`)||e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)||(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)&&e.hasAttribute(`name`))return e;let n=e;for(;n&&n!==this._form;){if(n.hasAttribute(`name`))return n;n=n.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}_syncFieldToReactiveData(e,t){if(!this._formData||!t)return;let n=this._getReactiveValue(this._formData);if(!n||typeof n!=`object`||Array.isArray(n))return;let r=this._getFieldElements(t),i=this._extractFieldValue(r.length?r:[e]);n[t]=this._normalizeReactiveValue(r,i),this._lastDataSnapshot=this._createDataSnapshot(n)}_normalizeReactiveValue(e,t){if(t instanceof FileList)return Array.from(t);if(Array.isArray(t))return t;let n=e[0];return e.length===1&&(n instanceof HTMLInputElement&&n.type===`checkbox`||n?.tagName===`MINT-CHECKBOX`||n?.tagName===`MINT-SWITCH`)?!!t:t??``}_cleanupBlurValidation(){if(this._form&&this._fieldBlurHandlers.has(this._form)){let 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)){let e=this._fieldChangeHandlers.get(this._form);e&&(this._form.removeEventListener(`change`,e,!0),this._form.removeEventListener(`input`,e,!0),this._form.removeEventListener(`tags-change`,e,!0),this._form.removeEventListener(`choice-change`,e,!0)),this._fieldChangeHandlers.delete(this._form)}this._observer&&=(this._observer.disconnect(),null)}_syncDropzoneFiles(){this._form&&Array.from(this._form.querySelectorAll(`mint-dropzone[name]`)).forEach(e=>{typeof e.syncFiles==`function`&&e.syncFiles()})}_propagateLoadingState(){if(!this._form)return;let e=this.getAttribute(`loading`),t=e!==null&&e!==`false`;Array.from(this._form.querySelectorAll(`mint-input, mint-select, mint-date-picker, mint-dropzone, mint-checkbox, mint-choice, mint-switch, mint-tags`)).forEach(e=>{t?e.setAttribute(`loading`,`true`):e.removeAttribute(`loading`),typeof e.render==`function`&&e.render()})}_setButtonsSubmitting(){if(!this._form)return;this._buttonStates.clear();let e=Array.from(this.querySelectorAll(`mint-button`)),t=Array.from(this.querySelectorAll(`button`));e.forEach(e=>{let t=e.getAttribute(`disabled`)===`true`,n=e.getAttribute(`loading`)===`true`;this._buttonStates.set(e,{disabled:t,loading:n});let r=(e.getAttribute(`type`)||e.getAttribute(`button-type`)||`default`)===`submit`;t||e.setAttribute(`disabled`,`true`),r&&e.setAttribute(`loading`,`true`),typeof e.render==`function`&&e.render()}),t.forEach(e=>{if(e.closest(`mint-button`))return;let t=e.disabled;this._buttonStates.set(e,{disabled:t,loading:!1}),t||(e.disabled=!0)})}_restoreButtonsState(){if(!this._form)return;let e=Array.from(this.querySelectorAll(`mint-button`)),t=Array.from(this.querySelectorAll(`button`));e.forEach(e=>{let t=this._buttonStates.get(e);t&&(t.disabled?e.setAttribute(`disabled`,`true`):e.removeAttribute(`disabled`),t.loading?e.setAttribute(`loading`,`true`):e.removeAttribute(`loading`),typeof e.render==`function`&&e.render())}),t.forEach(e=>{if(e.closest(`mint-button`))return;let t=this._buttonStates.get(e);t&&(e.disabled=t.disabled)}),this._buttonStates.clear()}_isReactiveObject(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;if(`__v_isRef`in e||`_value`in e||`__v_raw`in e||`__v_isReactive`in e||`__ob__`in e)return!0;try{let t=e.toString();if(t===`[object Object]`||t.includes(`Proxy`)){let t=Object.keys(e)[0];if(t){let n=Object.getOwnPropertyDescriptor(e,t);if(n&&(n.get||n.set))return!0}}}catch{return!0}return!0}_createDataSnapshot(e){try{let t=this._extractReactiveData(e);return JSON.parse(JSON.stringify(t))}catch{return{...this._extractReactiveData(e)}}}_extractReactiveData(e){if(!e||typeof e!=`object`)return e;if(Array.isArray(e))return e.map(e=>this._extractReactiveData(e));let t=this._getReactiveValue(e);if(t&&typeof t==`object`&&!Array.isArray(t)){let e={};for(let n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=this._extractReactiveData(t[n]));return e}return t}_hasDataChanged(e,t){try{return JSON.stringify(e)!==JSON.stringify(t)}catch{return!0}}_getReactiveValue(e){if(!e||typeof e!=`object`)return e;if(`_value`in e||`__v_isRef`in e){if(e.value!==void 0)return e.value;if(`_value`in e)return e._value}return`__v_raw`in e||`__v_isReactive`in e||`__ob__`in e,e}_setupReactiveDataObserver(e){if(this._stopReactiveDataObserver(),!this.isConnected)return;let t=this._getReactiveValue(e);if(t&&typeof t==`object`&&!Array.isArray(t))this._lastDataSnapshot=this._createDataSnapshot(t);else{this._lastDataSnapshot=null;return}let n=()=>{if(!this._formData||!this._lastDataSnapshot){this._stopReactiveDataObserver();return}let e=this._getReactiveValue(this._formData);if(e&&typeof e==`object`&&!Array.isArray(e)){let t=this._createDataSnapshot(e);this._hasDataChanged(t,this._lastDataSnapshot)&&(this._lastDataSnapshot=t,requestAnimationFrame(()=>{this._applyFormData()}))}this.isConnected&&this._formData?this._reactiveDataObserver=requestAnimationFrame(n):this._stopReactiveDataObserver()};this._reactiveDataObserver=requestAnimationFrame(n)}_stopReactiveDataObserver(){this._reactiveDataObserver!==null&&(cancelAnimationFrame(this._reactiveDataObserver),this._reactiveDataObserver=null),this._reactiveDataProxy=null,this._lastDataSnapshot=null}};customElements.get(`mint-form`)||customElements.define(`mint-form`,T),typeof window<`u`&&(window.mintForm=window.mintForm||{defaults:{headers:{common:{}}},interceptors:{response:{handlers:[]}}},window.mintForm.interceptors.response.use||(window.mintForm.interceptors.response.use=function(e,t){return window.mintForm.interceptors.response.handlers.push({fulfilled:e,rejected:t}),window.mintForm.interceptors.response.handlers.length-1}));var E=class extends HTMLElement{constructor(...e){super(...e),this._observer=null}connectedCallback(){this.classList.add(`box-border`,`m-0`,`p-0`,`align-baseline`,`block`,`w-full`,`rounded-lg`,`border`,`border-gray-200`,`dark:border-mint-divider`),this.hasAttribute(`data-mint-rt-scroll-inner`)?this.classList.add(`min-w-0`,`overflow-x-visible`,`overflow-y-visible`):this.classList.add(`min-w-0`,`overflow-x-auto`),this._observeChanges(),this._applyStyles(),requestAnimationFrame(()=>{this._applyStyles(),setTimeout(()=>this._applyStyles(),0)})}disconnectedCallback(){this._observer&&=(this._observer.disconnect(),null)}_observeChanges(){this._observer=new MutationObserver(()=>this._applyStyles()),this._observer.observe(this,{childList:!0,subtree:!0,attributes:!1})}_applyStyles(){this._observer&&this._observer.disconnect();let e=Array.from(this.querySelectorAll(`table`));if(e.length===0){this._observer&&this._observeChanges();return}let t=e.find(e=>e.querySelector(`thead`))??e[0],n=e.find(e=>e.querySelector(`tbody`))??e[0];e.forEach(e=>{let t=!!e.closest(`[id^="mint-rt-vscroll-"]`),n=!!e.closest(`mint-resource-table[data-mint-rt-fixed-header]`),r=t||n,i=[`w-full`,r?`border-separate border-spacing-0`:`border-collapse`,`text-sm`,`font-medium`,...r?[]:[`overflow-hidden`]];this._setClasses(e,i)});let r=t.querySelector(`thead`);if(r){r.classList.add(`bg-[#F7F7F7]`,`dark:bg-mint-nav`);let e=r.querySelectorAll(`th`);e.forEach((t,n)=>{let r=t.querySelector(`mint-icon`),i=r?.getAttribute(`name`)||``,a=t.hasAttribute(`data-mint-rt-sortable`)||r!==null&&i!==`ellipsis`;this._setClasses(t,[`text-left`,`font-semibold`,`text-gray-900`,`dark:text-white`,`px-3`,`py-2`,`border-b`,`border-gray-200`,`dark:border-mint-divider`,`bg-[#F7F7F7]`,`dark:bg-mint-nav`]),a&&t.classList.add(`cursor-pointer`,`hover:bg-gray-100`,`dark:hover:bg-mint-hover`),n===0&&t.classList.add(`pl-3`),n===e.length-1&&t.classList.add(`pr-3`);let o=t.closest(`table`),s=o?.closest(`mint-resource-table`),c=!!s?.hasAttribute(`data-mint-rt-fixed-header`),l=!!s?.hasAttribute(`data-mint-rt-fixed-controls`);if(o?.closest(`[id^="mint-rt-vscroll-"]`)||c){let e=c&&l?`top-[var(--mint-rt-fixed-controls-h,0px)]`:`top-0`;t.classList.add(`sticky`,e,`z-30`,`bg-[#F7F7F7]`,`dark:bg-mint-nav`,`shadow-sm`)}})}let i=n.querySelector(`tbody`);if(i){let e=Array.from(i.querySelectorAll(`tr`)),t=!!n.closest(`[id^="mint-rt-vscroll-"]`)||!!n.closest(`mint-resource-table`)?.hasAttribute(`data-mint-rt-fixed-header`),r=e.findIndex(e=>e.getAttribute(`data-mint-rt-spacer`)===`bottom`);e.forEach((n,i)=>{let a=n.hasAttribute(`data-mint-rt-spacer`),o=n.hasAttribute(`data-row-clickable`);a||t?this._setClasses(n,[`bg-white`,`dark:bg-mint-canvas`]):this._setClasses(n,[`bg-white`,`dark:bg-mint-canvas`,`border-b`,`border-gray-200`,`dark:border-mint-divider`]),o&&!a&&n.classList.add(`cursor-pointer`,`hover:bg-gray-50`,`dark:hover:bg-mint-elevated`),!t&&i===e.length-1&&n.classList.remove(`border-b`);let s=n.querySelectorAll(`td`);s.forEach((o,c)=>{let l=[`text-gray-900`,`dark:text-gray-100`,`px-3`,`py-2`];if(t&&!a){let t=n.hasAttribute(`data-mint-rt-last-row`),a=r===-1&&i===e.length-1;!t&&!a&&l.push(`border-b`,`border-gray-200`,`dark:border-mint-divider`)}this._setClasses(o,l),c===0&&o.classList.add(`pl-3`),c===s.length-1&&o.classList.add(`pr-3`),this._restoreCell(o)})})}let a=n.querySelector(`tfoot`);a&&(this._setClasses(a,[`bg-[#F7F7F7]`,`dark:bg-mint-nav`,`font-semibold`]),a.querySelectorAll(`td`).forEach(e=>{this._setClasses(e,[`text-gray-900`,`dark:text-gray-100`,`px-3`,`py-2`,`border-t`,`border-gray-200`,`dark:border-mint-divider`]),this._restoreCell(e)})),this._observer&&this._observeChanges()}_restoreCell(e){if(e.dataset.mtProcessed!==`true`)return;let t={};Array.from(e.attributes).forEach(e=>{e.name.startsWith(`data-`)&&e.name!==`data-original`&&e.name!==`data-mt-processed`&&(t[e.name]=e.value)});let n=e.getAttribute(`data-original`)||``;e.dataset.mtProcessed=``,e.innerHTML=n,Object.entries(t).forEach(([t,n])=>{e.setAttribute(t,n)})}_setClasses(e,t){e.className=``,t.filter(Boolean).forEach(t=>e.classList.add(...t.split(` `)))}};customElements.get(`mint-table`)||customElements.define(`mint-table`,E);var D=class extends HTMLElement{constructor(...e){super(...e),this._root=null,this._textWrap=null,this._dismissBtn=null,this._clickHandler=null}static get observedAttributes(){return[`dismissable`]}connectedCallback(){this._render()}disconnectedCallback(){this._dismissBtn&&this._clickHandler&&this._dismissBtn.removeEventListener(`click`,this._clickHandler)}attributeChangedCallback(){this._render()}_render(){if(this.classList.add(`inline-flex`,`items-center`,`gap-2`,`px-3`,`py-1`,`rounded-full`,`border`,`border-gray-200`,`dark:border-mint-divider`,`bg-gray-100`,`dark:bg-mint-elevated`,`text-gray-900`,`dark:text-gray-100`,`text-sm`,`font-medium`),!this._root){for(this._root=document.createElement(`div`),this._root.className=`flex items-center gap-2 w-full`,this._textWrap=document.createElement(`span`),this._textWrap.className=`inline-flex items-center min-w-[0.5rem]`,this._textWrap.setAttribute(`data-mt-chip-text`,``);this.firstChild;){let e=this.firstChild;if(e===this._root)break;this._textWrap.appendChild(e)}this._root.appendChild(this._textWrap),this.appendChild(this._root)}let e=this.getAttribute(`dismissable`);e===``||e===`true`||this.hasAttribute(`dismissable`)?(this._dismissBtn||this._createDismissBtn(),this._dismissBtn&&!this._dismissBtn.isConnected&&this._root?.appendChild(this._dismissBtn)):this._dismissBtn&&this._dismissBtn.parentElement===this._root&&this._dismissBtn.remove()}_createDismissBtn(){let e=document.createElement(`button`);e.type=`button`,e.setAttribute(`aria-label`,`Dismiss`),e.className=[`shrink-0`,`inline-flex`,`items-center`,`justify-center`,`w-5`,`h-5`,`rounded-full`,`text-gray-500`,`dark:text-gray-300`,`hover:text-gray-700`,`dark:hover:text-gray-100`,`focus-visible:outline-none`,`focus-visible:ring-2`,`focus-visible:ring-offset-1`,`focus-visible:ring-gray-400`,`dark:focus-visible:ring-gray-500`,`border-none`,`bg-transparent`,`cursor-pointer`].join(` `);let t=document.createElement(`mint-icon`);t.setAttribute(`name`,`close`),t.className=`w-3 h-3`,e.appendChild(t),this._clickHandler=e=>{e.stopPropagation(),this.dispatchEvent(new CustomEvent(`dismiss`,{bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent(`dismissed`,{bubbles:!0,composed:!0})),this.remove()},e.addEventListener(`click`,this._clickHandler),this._dismissBtn=e}};customElements.get(`mint-chip`)||customElements.define(`mint-chip`,D);var O=class extends HTMLElement{constructor(...e){super(...e),this._container=null,this._chipsWrap=null,this._input=null,this._tags=[],this._placeholder=`Add tag`,this._dragIndex=null,this._dragChip=null,this._isPointerDragging=!1,this._pointerMoveHandler=null,this._pointerUpHandler=null}static get observedAttributes(){return[`tags`,`placeholder`,`sortable`,`label`,`info`,`error`,`error-message`,`name`,`id`,`required`,`loading`]}connectedCallback(){this._parseAttrs(),this._render(),this._pointerMoveHandler||(this._pointerMoveHandler=e=>this._onPointerMove(e),window.addEventListener(`pointermove`,this._pointerMoveHandler)),this._pointerUpHandler||(this._pointerUpHandler=e=>this._onPointerUp(e),window.addEventListener(`pointerup`,this._pointerUpHandler),window.addEventListener(`pointercancel`,this._pointerUpHandler))}attributeChangedCallback(e,t,n){if(t!==n){if(e===`error`||e===`error-message`){if(this._renderErrorState(),this._container){let e=this.hasError(),t=[`flex`,`flex-wrap`,`items-center`,`gap-2`,`w-full`,`px-2`,`py-1.5`,`min-h-[2rem]`,`rounded-lg`,`border-2`,e?`border-red-300 dark:border-red-300`:`border-gray-200 dark:border-mint-divider`,`bg-white`,`dark:bg-mint-elevated`,`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`];this._container.className=t.join(` `)}return}if(e===`loading`){this._parseAttrs(),this._render();return}this._parseAttrs(),this._render()}}set tags(e){this._tags=Array.isArray(e)?[...e]:[],this._syncAttr(),this._render()}get tags(){return[...this._tags]}_parseAttrs(){let e=this.getAttribute(`tags`);if(!e)return;try{let t=JSON.parse(e);Array.isArray(t)&&(this._tags=t)}catch(e){console.warn(`mint-tags: failed to parse tags attribute`,e)}let t=this.getAttribute(`placeholder`);t!==null&&(this._placeholder=t)}_syncAttr(){this.setAttribute(`tags`,JSON.stringify(this._tags))}getLabel(){return this.getAttribute(`label`)||``}getInfo(){return this.getAttribute(`info`)||``}hasError(){return this.getAttribute(`error`)===`true`}getErrorMessage(){return this.getAttribute(`error-message`)||``}getName(){return this.getAttribute(`name`)||``}getId(){return this.getAttribute(`id`)||``}isRequired(){return this.getAttribute(`required`)===`true`}isLoading(){return this.hasAttribute(`loading`)}_render(){this.classList.add(`box-border`,`m-0`,`p-0`,`border-0`,`align-baseline`,`block`,`w-full`);let e=this.isLoading(),t=this.getLabel(),n=this.getInfo(),r=this.hasError(),i=this.getId()||`mint-tags-${Math.random().toString(36).substr(2,9)}`;if(this.getId()||this.setAttribute(`id`,i),this._container)this._input&&(this._input.placeholder=this._placeholder);else{this._container=document.createElement(`div`);let e=[`flex`,`flex-wrap`,`items-center`,`gap-2`,`w-full`,`px-2`,`py-1`,`min-h-[2rem]`,`rounded-lg`,`border-2`,r?`border-red-300 dark:border-red-300`:`border-gray-200 dark:border-mint-divider`,`bg-white`,`dark:bg-mint-elevated`,`focus-within:ring-2`,`focus-within:ring-offset-1`,r?`focus-within:ring-red-400 dark:focus-within:ring-red-500`:`focus-within:ring-gray-400 dark:focus-within:ring-gray-500`];this._container.className=e.join(` `),this._chipsWrap=document.createElement(`div`),this._chipsWrap.className=`flex flex-wrap items-center gap-2`,this._chipsWrap.addEventListener(`dragover`,e=>{this.hasAttribute(`sortable`)&&e.preventDefault()}),this._chipsWrap.addEventListener(`drop`,e=>{this.hasAttribute(`sortable`)&&e.preventDefault()}),this._input=document.createElement(`input`),this._input.type=`text`,this._input.placeholder=this._placeholder,this._input.className=[`min-w-[6rem]`,`flex-1`,`bg-transparent`,`border-none`,`outline-none`,`text-sm`,`text-gray-900`,`dark:text-gray-100`,`placeholder:text-gray-400`,`dark:placeholder:text-gray-500`,`p-1.5`].join(` `),this._input.addEventListener(`keydown`,e=>{e.key===`Enter`&&(e.preventDefault(),this._addFromInput())}),this._container.appendChild(this._chipsWrap),this.appendChild(this._container)}if(this._container){let e=[`flex`,`flex-wrap`,`items-center`,`gap-2`,`w-full`,`px-2`,`py-1`,`min-h-[2rem]`,`rounded-lg`,`border-2`,r?`border-red-300 dark:border-red-300`:`border-gray-200 dark:border-mint-divider`,`bg-white`,`dark:bg-mint-elevated`,`focus-within:ring-2`,`focus-within:ring-offset-1`,r?`focus-within:ring-red-400 dark:focus-within:ring-red-500`:`focus-within:ring-gray-400 dark:focus-within:ring-gray-500`];this._container.className=e.join(` `)}let a=this.querySelector(`.mint-tags-label-container`);if(t){a||(a=document.createElement(`div`),a.className=`mint-tags-label-container mb-[.25rem]`,this._container&&this._container.parentElement===this?this.insertBefore(a,this._container):this.insertBefore(a,this.firstChild));let e=a.querySelector(`.mint-tags-label`);t?(e||(e=document.createElement(`label`),e.className=`mint-tags-label text-sm font-medium text-gray-900 dark:text-gray-100 select-none`,a.appendChild(e)),e.textContent=t,e.setAttribute(`for`,i)):e&&e.remove()}else a&&a.remove();let o=this.querySelector(`.mint-tags-info`);n?(o||(o=document.createElement(`span`),o.className=`mint-tags-info text-xs text-gray-500 dark:text-gray-400 select-none mt-1 block`,this._container&&this._container.parentElement===this?this.insertBefore(o,this._container.nextSibling):this.appendChild(o)),o.textContent=n):o&&o.remove();let s=this.getName();s?(this.setAttribute(`name`,s),this._input&&(this._input.name=s,this._input.id=i)):(this.removeAttribute(`name`),this._input&&(this._input.removeAttribute(`name`),this._input.id=i)),this._wireInputBackspace(),this._renderChips(),this._renderErrorState(),this._renderSkeleton(e)}_renderSkeleton(e){let t=this._container;if(!t)return;t.classList.contains(`relative`)||t.classList.add(`relative`);let n=t.querySelector(`.mint-tags-skeleton`);e?(n||(n=document.createElement(`div`),n.className=`mint-tags-skeleton absolute inset-0 z-10 pointer-events-none rounded-lg bg-gray-200 dark:bg-mint-hover animate-pulse`,t.appendChild(n)),n.style.display=`block`,this._chipsWrap&&(this._chipsWrap.style.visibility=`hidden`,this._chipsWrap.style.pointerEvents=`none`),this._input&&(this._input.style.visibility=`hidden`,this._input.style.pointerEvents=`none`)):(n&&(n.style.display=`none`),this._chipsWrap&&(this._chipsWrap.style.visibility=`visible`,this._chipsWrap.style.pointerEvents=`auto`),this._input&&(this._input.style.visibility=`visible`,this._input.style.pointerEvents=`auto`))}_renderErrorState(){let e=this.hasError(),t=this.getErrorMessage(),n=this.querySelector(`.mint-tags-error`);e&&t?(n||(n=document.createElement(`div`),n.className=`mint-tags-error mt-1 text-xs text-red-600 dark:text-red-400`,this.appendChild(n)),n.textContent=t):n&&n.remove()}_renderChips(){if(!this._chipsWrap)return;this._chipsWrap.innerHTML=``;let e=0;this._tags.forEach(t=>{let n=document.createElement(`mint-chip`);n.dataset.index=String(e++),n.dataset.value=t.value,n.draggable=this.hasAttribute(`sortable`),n.draggable&&n.classList.add(`cursor-move`),t.dismissable&&(n.setAttribute(`dismissable`,`true`),n.addEventListener(`dismissed`,()=>this._removeTag(t.value))),this._chipsWrap.appendChild(n);let r=n.querySelector(`[data-mt-chip-text]`);r&&(r.textContent=t.label||t.value),this._setupChipEvents(n,t),n.draggable&&(n.addEventListener(`dragstart`,e=>this._onDragStart(e,n)),n.addEventListener(`dragover`,e=>this._onDragOverChip(e,n)),n.addEventListener(`drop`,e=>this._onDrop(e)),n.addEventListener(`dragend`,()=>this._onDragEnd())),this.hasAttribute(`sortable`)&&n.addEventListener(`pointerdown`,e=>this._onPointerDown(e,n))}),this._input&&(this.hasAttribute(`sortable`)&&(this._input.addEventListener(`dragover`,e=>this._onDragOverInput(e)),this._input.addEventListener(`drop`,e=>this._onDrop(e)),this._input.addEventListener(`dragend`,()=>this._onDragEnd())),this._chipsWrap.appendChild(this._input))}_addFromInput(){if(!this._input)return;let e=this._input.value.trim();if(e){if(this._tags.some(t=>t.value.toLowerCase()===e.toLowerCase())){this._input.value=``;return}this._tags.push({value:e,label:e,dismissable:!0}),this._syncAttr(),this._renderChips(),this._emitChange(),this._input.value=``,setTimeout(()=>{this._input?.focus()},10)}}_removeTag(e){this._tags=this._tags.filter(t=>t.value!==e),this._syncAttr(),this._renderChips(),this._emitChange()}_emitChange(){this.dispatchEvent(new CustomEvent(`tags-change`,{bubbles:!0,composed:!0,detail:{tags:this.tags}}))}_focusLastChip(){let e=this._chipsWrap?.querySelectorAll(`mint-chip`);e&&e.length>0&&e[e.length-1].focus({preventScroll:!0})}_focusInput(){setTimeout(()=>{this._input?.focus({preventScroll:!0})},10)}_wireInputBackspace(){this._input&&this._input.addEventListener(`keydown`,e=>{e.key===`Backspace`&&this._input?.value===``&&(e.preventDefault(),this._focusLastChip())})}_setupChipEvents(e,t){e.tabIndex=0,e.addEventListener(`keydown`,e=>{(e.key===`Backspace`||e.key===`Delete`)&&t.dismissable&&(e.preventDefault(),this._removeTag(t.value),this._focusInput())})}_onDragStart(e,t){this.hasAttribute(`sortable`)&&(this._dragChip=t,this._dragIndex=Number(t.dataset.index),e.dataTransfer?.setData(`text/plain`,t.dataset.index||``),e.dataTransfer&&(e.dataTransfer.effectAllowed=`move`,e.dataTransfer.dropEffect=`move`),t.classList.add(`opacity-60`))}_reorderTags(e,t){if(e<0||t<0||e>=this._tags.length||t>=this._tags.length)return;let n=[...this._tags],[r]=n.splice(e,1);n.splice(t,0,r),this._tags=n,this._syncAttr(),this._renderChips(),this._emitChange()}_onDragOverInput(e){this.hasAttribute(`sortable`)&&(e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect=`move`),this._dragChip&&this._chipsWrap&&this._input&&this._chipsWrap.insertBefore(this._dragChip,this._input))}_onDragOverChip(e,t){if(!this.hasAttribute(`sortable`)||(e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect=`move`),!this._dragChip||!this._chipsWrap)||t===this._dragChip)return;let n=t.getBoundingClientRect();if(e.clientX<n.left+n.width*.5){if(this._dragChip.nextSibling===t)return;this._chipsWrap.insertBefore(this._dragChip,t)}else{if(t.nextSibling===this._dragChip)return;let e=t.nextSibling;e?this._chipsWrap.insertBefore(this._dragChip,e):this._chipsWrap.appendChild(this._dragChip)}}_onDrop(e){this.hasAttribute(`sortable`)&&e.preventDefault()}_onDragEnd(){this._dragChip&&this._dragChip.classList.remove(`opacity-60`),this._syncOrderFromDom(),this._dragChip=null,this._dragIndex=null}_syncOrderFromDom(){if(!this._chipsWrap)return;let e=Array.from(this._chipsWrap.querySelectorAll(`mint-chip`));if(e.length===0)return;let t=[];e.forEach(e=>{let n=e.dataset.value;if(!n)return;let r=this._tags.find(e=>e.value===n);r&&t.push(r)}),t.length===this._tags.length&&(this._tags=t,this._syncAttr(),this._renderChips(),this._emitChange())}_onPointerDown(e,t){if(this.hasAttribute(`sortable`)&&e.pointerType!==`mouse`){this._isPointerDragging=!0,this._dragChip=t,this._dragIndex=Number(t.dataset.index);try{t.setPointerCapture(e.pointerId)}catch{}t.classList.add(`opacity-60`,`select-none`),e.preventDefault()}}_onPointerMove(e){if(!this._isPointerDragging||!this._dragChip||!this._chipsWrap||e.pointerType===`mouse`)return;let t=document.elementFromPoint(e.clientX,e.clientY);if(!t)return;let n=t.closest(`mint-chip`);if(n&&n!==this._dragChip){let t=n.getBoundingClientRect();if(e.clientX<t.left+t.width*.5)this._dragChip.nextSibling!==n&&this._chipsWrap.insertBefore(this._dragChip,n);else if(n.nextSibling!==this._dragChip){let e=n.nextSibling;e?this._chipsWrap.insertBefore(this._dragChip,e):this._chipsWrap.appendChild(this._dragChip)}return}this._input&&t.closest(`input`)===this._input&&this._chipsWrap.insertBefore(this._dragChip,this._input)}_onPointerUp(e){if(this._isPointerDragging){if(this._isPointerDragging=!1,this._dragChip){try{this._dragChip.releasePointerCapture(e.pointerId)}catch{}this._dragChip.classList.remove(`opacity-60`,`select-none`)}this._syncOrderFromDom(),this._dragChip=null,this._dragIndex=null}}};customElements.get(`mint-tags`)||customElements.define(`mint-tags`,O);var k=class extends HTMLElement{constructor(...e){super(...e),this._clickHandler=null,this._keydownHandler=null}connectedCallback(){this._render(),this._setupEventListeners()}disconnectedCallback(){this._cleanupEventListeners()}_render(){this.classList.add(`focus-visible:outline-none`,`focus-visible:ring-2`,`focus-visible:ring-offset-1`,`focus-visible:ring-gray-400`,`dark:focus-visible:ring-gray-500`,`rounded`),this.getAttribute(`disabled`)===`true`?this.classList.add(`cursor-not-allowed`,`opacity-50`):this.classList.add(`cursor-pointer`),this.getAttribute(`role`)||this.setAttribute(`role`,`button`),this.getAttribute(`tabindex`)||this.setAttribute(`tabindex`,`0`)}_setupEventListeners(){this._clickHandler=e=>{if(this.getAttribute(`disabled`)===`true`){e.preventDefault(),e.stopPropagation();return}this._handleClick(e)},this._keydownHandler=e=>{if(e.key===`Enter`||e.key===` `){if(this.getAttribute(`disabled`)===`true`){e.preventDefault(),e.stopPropagation();return}e.preventDefault(),this._handleClick(e)}},this.addEventListener(`click`,this._clickHandler),this.addEventListener(`keydown`,this._keydownHandler)}_cleanupEventListeners(){this._clickHandler&&=(this.removeEventListener(`click`,this._clickHandler),null),this._keydownHandler&&=(this.removeEventListener(`keydown`,this._keydownHandler),null)}_handleClick(e){this.dispatchEvent(new CustomEvent(`clickable-click`,{bubbles:!0,composed:!0,detail:{originalEvent:e}}))}static get observedAttributes(){return[`disabled`]}attributeChangedCallback(e,t,n){e===`disabled`&&(n===`true`?(this.classList.remove(`cursor-pointer`),this.classList.add(`opacity-50`,`cursor-not-allowed`),this.setAttribute(`aria-disabled`,`true`)):(this.classList.remove(`opacity-50`,`cursor-not-allowed`),this.classList.add(`cursor-pointer`),this.removeAttribute(`aria-disabled`)))}};customElements.get(`mint-clickable`)||customElements.define(`mint-clickable`,k);var A=class extends HTMLElement{static get observedAttributes(){return[`heading`,`dismissable`,`tone`]}constructor(){super(),this._headingElement=null,this._iconElement=null,this._dismissButton=null,this._headerWrapper=null,this._bodyWrapper=null,this._dismissHandler=null}connectedCallback(){this.classList.add(`box-border`,`m-0`,`p-0`,`border-0`,`align-baseline`,`block`),this.render()}disconnectedCallback(){this._dismissButton&&this._dismissHandler&&this._dismissButton.removeEventListener(`click`,this._dismissHandler)}attributeChangedCallback(e,t,n){t!==n&&this.render()}getHeading(){return this.getAttribute(`heading`)||``}getTone(){let e=this.getAttribute(`tone`);return e===`info`||e===`success`||e===`warning`||e===`danger`?e:`info`}isDismissable(){return this.getAttribute(`dismissable`)===`true`}getIconName(){switch(this.getTone()){case`info`:return`info`;case`success`:return`success`;case`warning`:return`warning`;case`danger`:return`error`;default:return`info`}}getIconColorClasses(){switch(this.getTone()){case`info`:return`text-gray-700 dark:text-gray-300`;case`success`:return`text-green-600 dark:text-green-400`;case`warning`:return`text-yellow-600 dark:text-yellow-400`;case`danger`:return`text-red-600 dark:text-red-400`;default:return`text-gray-700 dark:text-gray-300`}}getHeadingColorClasses(){return`text-gray-900 dark:text-gray-100`}getHeaderBackgroundClasses(){switch(this.getTone()){case`info`:return`bg-gray-100 dark:bg-white/5`;case`success`:return`bg-green-100 dark:bg-green-900/30`;case`warning`:return`bg-yellow-100 dark:bg-yellow-900/30`;case`danger`:return`bg-red-100 dark:bg-red-900/30`;default:return`bg-gray-100 dark:bg-white/5`}}getBorderClasses(){switch(this.getTone()){case`info`:return`border-gray-200 dark:border-mint-divider`;case`success`:return`border-green-200 dark:border-green-800`;case`warning`:return`border-yellow-200 dark:border-yellow-800`;case`danger`:return`border-red-200 dark:border-red-800`;default:return`border-gray-200 dark:border-mint-divider`}}getAriaLive(){return this.getTone()===`danger`?`assertive`:`polite`}render(){let e=this.getTone(),t=this.getHeading(),n=this.isDismissable();this.className=`box-border m-0 p-0 border-0 align-baseline block rounded-lg border shadow-sm overflow-hidden ${this.getBorderClasses()}`;let r=this.getAriaLive();this.setAttribute(`role`,`alert`),this.setAttribute(`aria-live`,r),e===`danger`?this.setAttribute(`aria-atomic`,`true`):this.removeAttribute(`aria-atomic`);let i=[];for(this._bodyWrapper?Array.from(this._bodyWrapper.childNodes).forEach(e=>{i.push(e)}):Array.from(this.childNodes).forEach(e=>{e!==this._headerWrapper&&e!==this._bodyWrapper&&e!==this._iconElement&&e!==this._headingElement&&e!==this._dismissButton&&i.push(e)}),this._dismissButton&&this._dismissHandler&&this._dismissButton.removeEventListener(`click`,this._dismissHandler);this.firstChild;)this.removeChild(this.firstChild);if(this._headerWrapper=null,this._bodyWrapper=null,this._iconElement=null,this._headingElement=null,this._dismissButton=null,this._headerWrapper=document.createElement(`div`),this._headerWrapper.className=`px-4 py-3 flex items-center gap-3 ${this.getHeaderBackgroundClasses()}`,this._iconElement=document.createElement(`mint-icon`),this._iconElement.setAttribute(`name`,this.getIconName()),this._iconElement.className=`flex-shrink-0 w-5 h-5 ${this.getIconColorClasses()}`,this._headerWrapper.appendChild(this._iconElement),this._headingElement=document.createElement(`mint-text`),this._headingElement.className=`font-semibold flex-1 ${this.getHeadingColorClasses()}`,this._headingElement.textContent=t||``,this._headerWrapper.appendChild(this._headingElement),n){this._dismissButton=document.createElement(`button`),this._dismissButton.className=`flex-shrink-0 p-1 rounded hover:bg-black/10 dark:hover:bg-white/10`,this._dismissButton.setAttribute(`aria-label`,`Dismiss alert`),this._dismissButton.setAttribute(`type`,`button`);let e=document.createElement(`mint-icon`);e.setAttribute(`name`,`close`),e.className=`w-4 h-4 text-gray-700 dark:text-gray-300`,this._dismissButton.appendChild(e),this._dismissHandler=e=>{e.preventDefault(),e.stopPropagation(),this.dispatchEvent(new CustomEvent(`dismissed`,{bubbles:!0,composed:!0})),this.remove()},this._dismissButton.addEventListener(`click`,this._dismissHandler),this._headerWrapper.appendChild(this._dismissButton)}this._bodyWrapper=document.createElement(`div`),this._bodyWrapper.className=`px-4 py-3 bg-white dark:bg-mint-elevated`,i.forEach(e=>{this._bodyWrapper.appendChild(e)}),this.appendChild(this._headerWrapper),this.appendChild(this._bodyWrapper)}};customElements.get(`mint-alert`)||customElements.define(`mint-alert`,A);var j=class extends HTMLElement{static get observedAttributes(){return[`configuration`,`virtual-scroll`,`virtual-scroll-root`,`virtual-row-height`,`virtual-max-height`,`fixed-header`,`fixed-controls`]}constructor(){super(),this._configuration=null,this._rows=[],this._search=``,this._currentPage=1,this._perPage=15,this._totalRows=0,this._lastPage=0,this._offset=0,this._loaded=!1,this._fetching=!1,this._loading=!1,this._loadingPage=null,this._fetchError=null,this._searching=!1,this._sorting=!1,this._sortingColumn=null,this._type=`provided`,this._searchTimeoutId=null,this._sortTimeoutId=null,this._searchColumns=[],this._exportColumns={},this._columns=[],this._tableId=``,this._searchInput=null,this._tableContainer=null,this._paginationContainer=null,this._skeletonContainer=null,this._inMintCard=!1,this._virtualBodyScrollEl=null,this._virtualScrollHandler=null,this._virtualWindowRaf=null,this._virtualLastRangeStart=-1,this._virtualLastRangeEnd=-1,this._virtualLastRangeCacheSig=``,this._virtualResizeObserver=null,this._virtualWindowResizeHandler=null,this._virtualRowCache=new Map,this._virtualRangeFetching=!1,this._mobileListMql=null,this._boundMobileListMqlListener=null,this._virtualFetchGeneration=0,this._virtualAjaxPrefetchTimer=null,this._fixedChromeResizeObserver=null}get inMintCard(){return this._inMintCard}get configuration(){return this._configuration}set configuration(e){e&&typeof e==`object`&&!Array.isArray(e)?(this._configuration=e,this._tableId=this._configuration.id||`mint-resource-table-${Date.now()}`,this._perPage=this._configuration.perPage||15,this._type=typeof this._configuration.data==`string`?`ajax`:`provided`,this._loaded=!1,this._currentPage=1,this._offset=0,this._type===`provided`&&Array.isArray(this._configuration.data)&&(this._rows=[...this._configuration.data],this._totalRows=this._configuration.data.length),this._initializeColumns(),this.isConnected&&this.render()):e==null?this._configuration=null:this._parseConfiguration()}connectedCallback(){this.classList.add(`box-border`,`m-0`,`p-0`,`border-0`,`align-baseline`,`block`,`w-full`),this._inMintCard=this.parentElement?.tagName?.toLowerCase()===`mint-card`,this._configuration||this._parseConfiguration(),this._initializeColumns(),this._loadPageFromUrl(),this._attachRowClickHandler(),this.render()}disconnectedCallback(){this._searchTimeoutId&&clearTimeout(this._searchTimeoutId),this._detachVirtualScroll(),this._detachFixedChromeResize(),this._detachMobileListMql(),this._rowClickHandler&&=(this.removeEventListener(`click`,this._rowClickHandler,!0),null),this._scrollHandler&&=(window.removeEventListener(`scroll`,this._scrollHandler),null)}attributeChangedCallback(e,t,n){e===`configuration`&&t!==n?(!this._configuration||typeof n==`string`)&&(this._parseConfiguration(),this.render()):t!==n&&(e===`virtual-scroll`||e===`virtual-scroll-root`||e===`virtual-row-height`||e===`virtual-max-height`||e===`fixed-header`||e===`fixed-controls`)&&this._configuration&&this.isConnected&&this.render()}refresh(){this._configuration&&(this._type===`ajax`?this._fetchData(void 0,!0,this._perPage,this._offset):this.render())}_parseConfiguration(){let e=this.getAttribute(`configuration`);if(!e){console.error(`mint-resource-table: configuration attribute is required`);return}try{this._configuration=JSON.parse(e),this._tableId=this._configuration.id||`mint-resource-table-${Date.now()}`,this._perPage=this._configuration.perPage||15,this._type=typeof this._configuration.data==`string`?`ajax`:`provided`,this._loaded=!1,this._currentPage=this._getPageFromUrl()||1,this._offset=(this._currentPage-1)*this._perPage,this._type===`provided`&&Array.isArray(this._configuration.data)&&(this._rows=[...this._configuration.data],this._totalRows=this._configuration.data.length),this._initializeColumns()}catch(e){console.error(`mint-resource-table: Invalid configuration JSON`,e)}}_initializeColumns(){this._configuration&&(this._searchColumns=[],this._exportColumns={},this._columns=[],this._configuration.columns.forEach(e=>{e.searchable&&e.data&&this._searchColumns.push(e.data),e.export&&e.data&&(this._exportColumns[e.data]=e.label),e.data&&this._columns.push(e.data)}),this._configuration.sortBy||(this._configuration.sortBy=`id`),this._configuration.sort||(this._configuration.sort=`asc`))}async _fetchData(e,t=!0,n,r){if(!this._configuration)return;let i=e||(typeof this._configuration.data==`string`?this._configuration.data:null);if(!i||this._fetching||this._loading)return;t&&(this._fetching=!0,this._loaded?this._updatePagination():this.render()),this._loading=!0;let a=n||this._perPage,o=r===void 0?this._offset:r;this._virtualScrollActive()&&this._type===`ajax`&&o===0&&(this._virtualFetchGeneration++,this._virtualRowCache.clear(),this._virtualInvalidate());try{let e=new URLSearchParams({perPage:a.toString(),offset:o.toString(),search:this._search,sortBy:this._configuration.sortBy||`id`,sort:this._configuration.sort||`asc`,searchColumns:this._searchColumns.join(`,`),columns:this._columns.join(`,`)}),t={};this._configuration.headers&&(t.headers=this._configuration.headers);let n=await fetch(`${i}?${e.toString()}`,t);if(!n.ok)throw Error(`HTTP error! status: ${n.status}`);let r=await n.json(),s=r.content?.rows||[],c=r.content?.total||0,l=s;this._configuration.predefinedData?(l=[...this._configuration.predefinedData,...s],this._totalRows=c+this._configuration.predefinedData.length):this._totalRows=c,this._rows=l;let u=Math.floor(o/a)+1;r.content?.current_page!==void 0&&r.content.current_page===u?this._currentPage=r.content.current_page:this._currentPage=u,this._offset=(this._currentPage-1)*a,this._lastPage=r.content?.last_page||1,this._fetching=!1,this._loaded=!0,this._loading=!1,this._fetchError=null,this._searching=!1;let d=this._sorting;d&&this._updateSortIcons(),this._sorting=!1,this._sortingColumn=null,d&&this._updateSortIcons(),this.dispatchEvent(new CustomEvent(`loaded`,{detail:{rows:this._rows}})),this._updateSearchIcon();let f=`tbody[data-mint-rt-tbody="${this._tableId}"]`,p=!!this.querySelector(f);if(this._virtualScrollActive()&&this._type===`ajax`)p||this.render(),s.forEach((e,t)=>{this._virtualRowCache.set(o+t,e)}),this._virtualInvalidate(),o===0?queueMicrotask(()=>this._scrollVirtualTableTopIntoView()):this._scheduleVirtualWindowSync(),this._loadingPage,this._loadingPage=null,this._updatePagination(),setTimeout(()=>{let e=this._paginationMountedRoot();e&&e.querySelectorAll(`mint-button[data-action="page"]`).forEach(e=>{`render`in e&&typeof e.render==`function`&&e.render()})},0);else if(this.querySelector(`#${this._tableId}`)?.closest(`table`)?.querySelector(`tbody`)){if(d){let e=this._loading,t=this._fetching;this._loading=!1,this._fetching=!1,this._updateTableBody(),this._loading=e,this._fetching=t}else this._updateTableBody();this._loadingPage,this._loadingPage=null,this._updatePagination(),setTimeout(()=>{let e=this._paginationMountedRoot();e&&e.querySelectorAll(`mint-button[data-action="page"]`).forEach(e=>{`render`in e&&typeof e.render==`function`&&e.render()})},0)}else this.render()}catch(e){this._fetching=!1,this._loading=!1,this._loadingPage=null,this._loaded=!0,this._searching=!1,this._fetchError=e instanceof Error?e.message:`Failed to fetch data`,console.error(`mint-resource-table: Error fetching data`,e),this._updateSearchIcon(),this.querySelector(`#${this._tableId}`)?.closest(`table`)?.querySelector(`tbody`)?(this._updateTableBody(),this._loadingPage=null,this._updatePagination()):this.render()}}_getRows(){if(!this._configuration)return[];if(this._type===`ajax`)return this._rows;let e=[...this._rows],t=this._configuration.sortBy||`id`,n=this._configuration.sort||`asc`;if(this._search){let t=this._search.toLowerCase().trim().split(/\s+/);e=e.filter(e=>{let n=Object.values(e).map(e=>String(e).toLowerCase()).join(` `);return t.every(e=>n.includes(e))})}if(e.sort((e,r)=>{let i=e[t],a=r[t];if(i==null&&a==null)return 0;if(i==null)return 1;if(a==null)return-1;let o=typeof i==`number`?i:typeof i==`string`&&!isNaN(Number(i))&&i.trim()!==``?Number(i):null,s=typeof a==`number`?a:typeof a==`string`&&!isNaN(Number(a))&&a.trim()!==``?Number(a):null;if(o!==null&&s!==null){let e=o-s;return n===`asc`?e:-e}let c=i instanceof Date?i:typeof i==`string`?new Date(i):null,l=a instanceof Date?a:typeof a==`string`?new Date(a):null;if(c&&l&&!isNaN(c.getTime())&&!isNaN(l.getTime())){let e=c.getTime()-l.getTime();return n===`asc`?e:-e}let u=String(i).localeCompare(String(a),void 0,{numeric:!0,sensitivity:`base`});return n===`asc`?u:-u}),this._perPage){let t=Math.ceil(e.length/this._perPage);this._lastPage=t,e.forEach((e,t)=>{e.page=Math.ceil((t+1)/this._perPage)}),this._currentPage>t&&t>0&&(this._currentPage=t)}return e.filter(e=>!this._perPage||e.page===this._currentPage)}_getAllFilteredRowsSorted(){if(!this._configuration||this._type!==`provided`)return[];let e=[...this._rows],t=this._configuration.sortBy||`id`,n=this._configuration.sort||`asc`;if(this._search){let t=this._search.toLowerCase().trim().split(/\s+/);e=e.filter(e=>{let n=Object.values(e).map(e=>String(e).toLowerCase()).join(` `);return t.every(e=>n.includes(e))})}if(e.sort((e,r)=>{let i=e[t],a=r[t];if(i==null&&a==null)return 0;if(i==null)return 1;if(a==null)return-1;let o=typeof i==`number`?i:typeof i==`string`&&!isNaN(Number(i))&&i.trim()!==``?Number(i):null,s=typeof a==`number`?a:typeof a==`string`&&!isNaN(Number(a))&&a.trim()!==``?Number(a):null;if(o!==null&&s!==null){let e=o-s;return n===`asc`?e:-e}let c=i instanceof Date?i:typeof i==`string`?new Date(i):null,l=a instanceof Date?a:typeof a==`string`?new Date(a):null;if(c&&l&&!isNaN(c.getTime())&&!isNaN(l.getTime())){let e=c.getTime()-l.getTime();return n===`asc`?e:-e}let u=String(i).localeCompare(String(a),void 0,{numeric:!0,sensitivity:`base`});return n===`asc`?u:-u}),this._perPage){let t=Math.ceil(e.length/this._perPage);this._lastPage=t,e.forEach((e,t)=>{e.page=Math.ceil((t+1)/this._perPage)}),this._currentPage>t&&t>0&&(this._currentPage=t)}return e.filter(e=>!this._perPage||e.page===this._currentPage)}_virtualInvalidate(){this._virtualLastRangeStart=-1,this._virtualLastRangeEnd=-1,this._virtualLastRangeCacheSig=``}_getRowDataForEventIndex(e){if(this._configuration){if(!this._virtualScrollActive())return this._getRows()[e];if(this._type===`provided`)return this._getAllFilteredRowsSorted()[e];if(this._type===`ajax`)return this._virtualRowCache.get(e)}}getRowByIndex(e){return this._getRowDataForEventIndex(e)}_virtualScrollActive(){return this._configuration?(this.getAttribute(`virtual-scroll`)||``).toLowerCase().trim()===`true`:!1}_virtualScrollRoot(){let e=(this.getAttribute(`virtual-scroll-root`)||``).toLowerCase().trim();return e===`table-body`||e===`body`||this._configuration?.virtualScrollRoot===`table-body`?`table-body`:`document`}_virtualBodyScrollDisablesDocumentFixedChrome(){return this._virtualScrollActive()&&this._virtualScrollRoot()===`table-body`}_fixedHeader(){if(this._virtualBodyScrollDisablesDocumentFixedChrome()||!this.hasAttribute(`fixed-header`))return!1;let e=(this.getAttribute(`fixed-header`)||``).toLowerCase().trim();return e!==`false`&&e!==`0`}_fixedControls(){if(this._virtualBodyScrollDisablesDocumentFixedChrome()||!this.hasAttribute(`fixed-controls`))return!1;let e=(this.getAttribute(`fixed-controls`)||``).toLowerCase().trim();return e!==`false`&&e!==`0`}_virtualRowHeightPx(){let e=parseInt(this.getAttribute(`virtual-row-height`)||``,10);if(!isNaN(e)&&e>0)return e;let t=this._configuration?.virtualRowHeight;return typeof t==`number`&&t>0?t:48}_virtualRowHeightPxForSync(e){let t=this._virtualRowHeightPx();if(!this._configuration)return t;if(e){let e=this._mobileThumbnailColumn();if(e){let n=this._thumbnailMobilePx(e);return Math.max(t,n+36)}return Math.max(t,80)}let n=this._mobileThumbnailColumn();if(n){let e=this._thumbnailDesktopPx(n);return Math.max(t,e+28)}return t}_virtualMaxHeightCss(){let e=this.getAttribute(`virtual-max-height`);if(e&&e.trim())return e.trim();let t=this._configuration?.virtualMaxHeight;return t&&String(t).trim()?String(t).trim():`min(70dvh, 28rem)`}_virtualColspan(){return this._configuration?Math.max(1,this._configuration.columns.filter(e=>!e.hidden).length):1}_ensureMobileListMql(){typeof window>`u`||!window.matchMedia||this._mobileListMql||(this._mobileListMql=window.matchMedia(`(max-width: 767px)`),this._boundMobileListMqlListener=()=>{this._configuration&&this.isConnected&&this.render()},this._mobileListMql.addEventListener(`change`,this._boundMobileListMqlListener))}_detachMobileListMql(){this._mobileListMql&&this._boundMobileListMqlListener&&this._mobileListMql.removeEventListener(`change`,this._boundMobileListMqlListener),this._mobileListMql=null,this._boundMobileListMqlListener=null}_useMobileListLayout(){return!!this._mobileListMql?.matches}_paginationHostPlaceholderHtml(){if(!this._configuration?.perPage||this._virtualScrollActive())return``;let e=this._lastPage||Math.ceil(this._rows.length/this._perPage);if((this._lastPage>0?this._lastPage:e)<=1)return``;let t=[`mint-rt-pagination-host`,`w-full min-w-0 overflow-x-auto overflow-y-hidden overscroll-x-contain`,`flex justify-center [-webkit-overflow-scrolling:touch] md:justify-end`,this._inMintCard?`border-t border-gray-200 px-3.5 pb-3.5 pt-3 dark:border-mint-divider md:border-t-0 md:pt-0`:`border-t border-gray-200 px-2 py-3 dark:border-mint-divider md:border-t-0 md:py-0 md:mt-4`].join(` `);return`<div id="mint-rt-pagination-host-${this._tableId}" data-mint-rt-pagination-wrap="" class="${t}"></div>`}_getPaginationHostEl(){return this.querySelector(`#mint-rt-pagination-host-${this._tableId}`)}_paginationMountedRoot(){return this._getPaginationHostEl()||this.querySelector(`nav[data-mint-rt-pagination-nav]`)?.parentElement||this.querySelector(`nav`)?.closest(`.flex.justify-end`)}_paginationPageButtonLi(e){let t=this._currentPage===e,n=this._loadingPage===e;return`<li class="shrink-0"><mint-button variant="solid" size="sm"${t?` active="true"`:``}${this._loading||this._fetching?` disabled="true"`:``}${n?` loading="true"`:``} data-action="page" data-page="${e}">${n?``:`${e}`}</mint-button></li>`}_paginationHtmlCompactMiddle(e){let t=``,n=this._currentPage;if(e<=5){for(let n=1;n<=e;n++)t+=this._paginationPageButtonLi(n);return t}let r=[...new Set([1,e,n-1,n,n+1].map(t=>Math.min(e,Math.max(1,t))))].sort((e,t)=>e-t),i=0;for(let e of r)i>0&&e-i>1&&(t+=`<li class="shrink-0"><span class="px-1 text-gray-500 dark:text-gray-400" aria-hidden="true">…</span></li>`),t+=this._paginationPageButtonLi(e),i=e;return t}_paginationHtmlDesktopMiddle(e){let t=``,n=e>=10,r=Math.max(1,this._currentPage-1),i=Math.min(e,this._currentPage+1);if(n){for(let e=1;e<=3;e++)t+=this._paginationPageButtonLi(e);let n=i<=3,a=r>=e-2;if(!n&&!a){r>4&&(t+=`<li class="shrink-0"><span class="px-2">...</span></li>`);for(let e=r;e<=i;e++)e<=3||(t+=this._paginationPageButtonLi(e));i<e-3&&(t+=`<li class="shrink-0"><span class="px-2">...</span></li>`)}else (n&&!a||!n&&a&&e-2>4)&&(t+=`<li class="shrink-0"><span class="px-2">...</span></li>`);for(let o=e-2;o<=e;o++)o<=3||!n&&!a&&o>=r&&o<=i||(t+=this._paginationPageButtonLi(o))}else for(let n=1;n<=e;n++)t+=this._paginationPageButtonLi(n);return t}_buildPaginationNavMarkup(e){let t=this._currentPage===1||this._loading||this._fetching,n=`<nav data-mint-rt-pagination-nav="" class="w-max max-w-none shrink-0" aria-label="Pagination">`;n+=`<ul class="flex flex-nowrap items-center gap-1">`,n+=`<li class="shrink-0"><mint-button variant="solid" size="sm" icon="caret-left" ${t?`disabled="true"`:``} data-action="page-prev"></mint-button></li>`,n+=this._useMobileListLayout()?this._paginationHtmlCompactMiddle(e):this._paginationHtmlDesktopMiddle(e);let r=this._currentPage>=e||this._loading||this._fetching;return n+=`<li class="shrink-0"><mint-button variant="solid" size="sm" icon="caret-right" ${r?`disabled="true"`:``} data-action="page-next"></mint-button></li>`,n+=`</ul></nav>`,n}_hasSortableColumns(){return!!this._configuration?.columns.some(e=>!e.hidden&&e.sortable&&e.data)}_getMobileSortTriggerIconName(){return`sort-arrows`}_mobileSortPopoverAffordanceInnerHtml(e){return e===`spinner`?`<span class="inline-block h-4 w-4 shrink-0 animate-spin rounded-full border-2 border-gray-300 border-t-gray-700 dark:border-gray-600 dark:border-t-gray-200" aria-hidden="true"></span>`:e===`caret-up`||e===`caret-down`?`<mint-icon name="${e}" class="h-4 w-4 shrink-0 text-gray-500 dark:text-gray-400"></mint-icon>`:``}_buildMobileSortPopoverInnerHtml(){if(!this._configuration)return``;let e=`<div class="flex w-full min-w-[11rem] flex-col gap-0.5 p-1">`;return this._configuration.columns.forEach((t,n)=>{if(t.hidden||!t.sortable||!t.data)return;let r=t.raw?t.label:this._escapeHtml(t.label),i=this._getSortClass(t),a=this._mobileSortPopoverAffordanceInnerHtml(i),o=` type="button" variant="ghost" tone="neutral" size="sm" full-width="true" align="left" data-action="mobile-sort" data-column-key="${n}"`;e+=`<mint-button${o}>`,e+=`<span class="flex w-full min-w-0 flex-1 items-center justify-between gap-2">`,e+=`<span class="min-w-0 flex-1 truncate text-left">${r}</span>`,e+=`<span class="inline-flex shrink-0 items-center justify-end" data-mint-rt-mobile-sort-affordance="">${a}</span>`,e+=`</span></mint-button>`}),e+=`</div>`,e}_syncMobileSortPopoverIcons(){if(!this._configuration)return;let e=this.querySelector(`#mint-rt-mobile-sort-popover-${this._tableId}`);e&&this._configuration.columns.forEach((t,n)=>{if(t.hidden||!t.sortable||!t.data)return;let r=e.querySelector(`[data-action="mobile-sort"][data-column-key="${n}"]`);if(!r||r.tagName!==`MINT-BUTTON`)return;let i=r.querySelector(`[data-mint-rt-mobile-sort-affordance]`);if(!i)return;let a=this._getSortClass(t);i.innerHTML=this._mobileSortPopoverAffordanceInnerHtml(a),i.querySelectorAll(`mint-icon`).forEach(e=>{let t=e;typeof t.render==`function`&&t.render()})})}_closeMobileSortPopover(){let e=this.querySelector(`#mint-rt-mobile-sort-popover-${this._tableId}`);e&&typeof e.close==`function`?e.close():e&&e.removeAttribute(`open`)}_buildMobileSortToolbarHtml(){if(!this._hasSortableColumns())return``;let e=`mint-rt-mobile-sort-btn-${this._tableId}`,t=`mint-rt-mobile-sort-popover-${this._tableId}`,n=this._sorting?` loading="true"`:``,r=` icon="${this._escapeHtml(this._getMobileSortTriggerIconName())}"`,i=`<div class="flex shrink-0 items-center md:hidden">`;return i+=`<mint-button id="${e}" data-mint-rt-toolbar="mobile-sort" variant="solid" tone="neutral" size="sm"${n}${r}></mint-button>`,i+=`<mint-popover id="${t}" trigger-id="${e}" direction="down" padding="0">`,i+=this._buildMobileSortPopoverInnerHtml(),i+=`</mint-popover></div>`,i}_stripHtml(e){if(!e)return``;let t=document.createElement(`div`);return t.innerHTML=e,(t.textContent||t.innerText||``).replace(/\s+/g,` `).trim()}_visibleDataColumns(){return this._configuration?this._configuration.columns.filter(e=>!e.hidden):[]}_mobileThumbnailColumn(){return this._visibleDataColumns().find(e=>e.thumbnail)||null}_thumbnailDesktopPx(e){let t=typeof e.thumbnailDesktopPx==`number`&&e.thumbnailDesktopPx>0?e.thumbnailDesktopPx:void 0,n=this._configuration,r=n&&typeof n.thumbnailDesktopPx==`number`&&n.thumbnailDesktopPx>0?n.thumbnailDesktopPx:void 0;return Math.round(t??r??40)}_thumbnailMobilePx(e){let t=typeof e.thumbnailMobilePx==`number`&&e.thumbnailMobilePx>0?e.thumbnailMobilePx:void 0,n=this._configuration,r=n&&typeof n.thumbnailMobilePx==`number`&&n.thumbnailMobilePx>0?n.thumbnailMobilePx:void 0;return Math.round(t??r??56)}_wrapThumbnailDesktopBox(e,t){let n=this._thumbnailDesktopPx(t);return`<div class="flex shrink-0 items-stretch overflow-hidden rounded-md border border-gray-200 bg-gray-100 p-0 dark:border-mint-divider dark:bg-mint-hover [&>*]:m-0 [&>*]:min-h-0 [&>*]:min-w-0 [&>*]:w-full [&>*]:max-w-full [&>*]:p-0 [&>span]:flex [&>span]:h-full [&>span]:w-full [&>span]:min-h-0 [&>span]:min-w-0 [&>span]:items-stretch [&>span]:justify-stretch [&_img]:!m-0 [&_img]:!box-border [&_img]:!block [&_img]:!h-full [&_img]:!w-full [&_img]:!min-h-0 [&_img]:!min-w-0 [&_img]:!max-h-full [&_img]:!max-w-full [&_img]:!border-0 [&_img]:!p-0 [&_img]:!rounded-none [&_img]:!object-cover [&_img]:!object-center" style="${`width:${n}px;height:${n}px;min-width:${n}px;min-height:${n}px`}">${e}</div>`}_mobilePrimaryColumn(){let e=this._visibleDataColumns();return e.find(e=>e.primary)||e.find(e=>(e.data||typeof e.format==`function`)&&!e.thumbnail&&!e.actions)||e[0]||null}_mobileActionsDropdownColumn(){return this._visibleDataColumns().find(e=>e.actions&&e.actionStyle!==`buttons`)||null}_columnPlainSummaryText(e,t){if(!(!e.show||e.show(this,t))||e.actions||e.action)return``;try{if(e.raw){if(typeof e.format==`function`)return this._stripHtml(e.format(this,t));if(e.data)return String(t[e.data]??``)}else{if(typeof e.format==`function`)return this._stripHtml(e.format(this,t));if(e.data)return String(t[e.data]??``)}}catch{return``}return``}_buildTableCellInnerHtml(e,t,n,r=`table`){if(!this._configuration)return``;let i=n,a=``;if(!(!e.show||e.show(this,t)))return``;if(e.raw)if(e.action){if(!e.action.show||e.action.show(this,t)){let n=typeof e.action.label==`function`?e.action.label(this,t):e.action.label;a+=`<mint-button variant="solid" data-action="column-action" data-row-index="${i}" data-column-key="${this._configuration.columns.indexOf(e)}">${this._escapeHtml(String(n))}</mint-button>`}}else if(e.actions)if(e.actionStyle!==`buttons`){let n=`actions-popover-${this._tableId}-${i}`,r=`actions-button-${this._tableId}-${i}`;a+=`<mint-button id="${r}" variant="link" icon="ellipsis">`,a+=`</mint-button>`,a+=`<mint-popover id="${n}" trigger-id="${r}" direction="down">`,e.actions.forEach((n,r)=>{if(!n.show||n.show(this,t)){let o=typeof n.label==`function`?n.label(this,t):n.label;a+=`<div class="p-2 cursor-pointer hover:bg-gray-100 dark:hover:bg-mint-hover" data-action="row-action" data-row-index="${i}" data-action-index="${r}" data-column-key="${this._configuration.columns.indexOf(e)}">${this._escapeHtml(String(o))}</div>`}}),a+=`</mint-popover>`}else e.actions.forEach((n,r)=>{if(!n.show||n.show(this,t)){let o=n.label?typeof n.label==`function`?n.label(this,t):n.label:``,s=n.icon?` icon="${this._escapeHtml(n.icon)}"`:``,c=n.tone?` tone="${this._escapeHtml(n.tone)}"`:``;a+=`<mint-button variant="link" class="${n.classes||``}" data-action="row-action" data-row-index="${i}" data-action-index="${r}" data-column-key="${this._configuration.columns.indexOf(e)}"${s}${c}>`,o&&(a+=this._escapeHtml(String(o))),a+=`</mint-button>`}});else typeof e.format==`function`?a+=e.format(this,t):e.data&&(a+=this._escapeHtml(String(t[e.data]||``)));else if(e.action)(!e.action.show||e.action.show(this,t))&&(a+=`<mint-button variant="solid" data-action="column-action" data-row-index="${i}" data-column-key="${this._configuration.columns.indexOf(e)}">${e.action.label}</mint-button>`);else if(e.actions)if(e.actionStyle!==`buttons`){let n=`actions-popover-${this._tableId}-${i}`,r=`actions-button-${this._tableId}-${i}`;a+=`<mint-button id="${r}" variant="link" icon="ellipsis">`,a+=`</mint-button>`,a+=`<mint-popover id="${n}" trigger-id="${r}" direction="down">`,e.actions.forEach((n,r)=>{if(!n.show||n.show(this,t)){let o=typeof n.label==`function`?n.label(this,t):n.label;a+=`<div class="p-2 cursor-pointer hover:bg-gray-100 dark:hover:bg-mint-hover" data-action="row-action" data-row-index="${i}" data-action-index="${r}" data-column-key="${this._configuration.columns.indexOf(e)}">${this._escapeHtml(String(o))}</div>`}}),a+=`</mint-popover>`}else e.actions.forEach((n,r)=>{if(!n.show||n.show(this,t)){let o=n.label?typeof n.label==`function`?n.label(this,t):n.label:``,s=n.icon?` icon="${this._escapeHtml(n.icon)}"`:``,c=n.tone?` tone="${this._escapeHtml(n.tone)}"`:``;a+=`<mint-button variant="link" class="${n.classes||``}" data-action="row-action" data-row-index="${i}" data-action-index="${r}" data-column-key="${this._configuration.columns.indexOf(e)}"${s}${c}>`,o&&(a+=this._escapeHtml(String(o))),a+=`</mint-button>`}});else typeof e.format==`function`?a+=this._escapeHtml(e.format(this,t)):e.data&&(a+=this._escapeHtml(String(t[e.data]||``)));return r===`table`&&e.thumbnail&&a&&!e.actions&&!e.action?this._wrapThumbnailDesktopBox(a,e):a}_buildMobileListItemHtml(e,t,n,r=!1){if(!this._configuration)return``;let i=t,a=typeof this._configuration.onRowClick==`function`,o=this._mobileThumbnailColumn(),s=this._mobilePrimaryColumn(),c=this._mobileActionsDropdownColumn(),l=o?this._buildTableCellInnerHtml(o,e,i,`mobile`):``,u=s?this._buildTableCellInnerHtml(s,e,i,`mobile`):``,d=c?this._buildTableCellInnerHtml(c,e,i,`mobile`):``,f=[];for(let t of this._configuration.columns){if(t.hidden||o&&t===o||s&&t===s||c&&t===c)continue;let n=this._columnPlainSummaryText(t,e);n&&f.push(this._escapeHtml(n))}let p=f.join(`<span class="text-gray-300 dark:text-gray-600" aria-hidden="true"> · </span>`),m=[`list-none`,...r?[]:[`border-b`,`border-gray-200`,`dark:border-mint-divider`],`bg-white`,`dark:bg-mint-canvas`,a?`cursor-pointer hover:bg-gray-50 dark:hover:bg-mint-elevated`:``].filter(Boolean).join(` `),h=`<div class="flex items-center gap-3 py-3 pr-4${o?` pl-0`:` pl-4`}">`;if(o){let e=this._thumbnailMobilePx(o),t=`width:${e}px;height:${e}px;min-width:${e}px;min-height:${e}px`;h+=`<div class="flex shrink-0 items-stretch overflow-hidden rounded-md border border-gray-200 bg-gray-100 p-0 dark:border-mint-divider dark:bg-mint-hover [&>*]:m-0 [&>*]:min-h-0 [&>*]:min-w-0 [&>*]:w-full [&>*]:max-w-full [&>*]:p-0 [&>span]:flex [&>span]:h-full [&>span]:w-full [&>span]:min-h-0 [&>span]:min-w-0 [&>span]:items-stretch [&>span]:justify-stretch [&_img]:!m-0 [&_img]:!box-border [&_img]:!block [&_img]:!h-full [&_img]:!w-full [&_img]:!min-h-0 [&_img]:!min-w-0 [&_img]:!max-h-full [&_img]:!max-w-full [&_img]:!border-0 [&_img]:!p-0 [&_img]:!rounded-none [&_img]:!object-cover [&_img]:!object-center" style="${t}">${l}</div>`}h+=`<div class="flex min-w-0 flex-1 flex-col justify-center gap-1">`,h+=`<div class="flex items-start justify-between gap-2">`,h+=`<div class="min-w-0 text-sm font-semibold leading-snug text-gray-900 dark:text-white">${u}</div>`,d&&(h+=`<div class="shrink-0 -mr-1">${d}</div>`),h+=`</div>`,p&&(h+=`<div class="text-xs font-normal leading-snug text-gray-500 dark:text-gray-400">${p}</div>`),h+=`</div></div>`;let g=typeof n==`number`&&n>0?` style="box-sizing:border-box;min-height:${n}px;max-height:${n}px;height:${n}px;overflow:hidden"`:``;return`<li data-row-index="${i}" ${a?`data-row-clickable="true" `:``}class="${m}"${g}>${h}</li>`}_buildMobileListPlaceholderLi(e,t,n=!1){let r=this._mobileThumbnailColumn(),i=r?this._thumbnailMobilePx(r):56,a=`width:${i}px;height:${i}px;min-width:${i}px;min-height:${i}px`;return`<li data-row-index="${e}" data-mint-rt-placeholder="true" class="list-none${n?``:` border-b border-gray-200 dark:border-mint-divider`} bg-white dark:bg-mint-canvas" style="box-sizing:border-box;min-height:${t}px;max-height:${t}px;height:${t}px;overflow:hidden"><div class="flex h-full min-h-0 items-center gap-3 py-3 pl-0 pr-4"><div class="shrink-0 overflow-hidden rounded-md bg-gray-200 dark:bg-white/15" style="${a}"></div><div class="flex min-h-0 min-w-0 flex-1 flex-col justify-center gap-1 py-0.5"><div class="h-4 w-40 rounded bg-gray-200 dark:bg-white/15"></div><div class="h-3 w-full max-w-xs rounded bg-gray-200 dark:bg-white/15"></div></div></div></li>`}_renderColgroupHtml(){if(!this._configuration)return``;let e=this._configuration.columns.filter(e=>!e.hidden),t=[],n=0;for(let r of e){let e=r.width==null?``:String(r.width).trim();e?/^\d+(\.\d+)?$/.test(e)?(n+=parseFloat(e),t.push(`px`)):t.push(`lit`):t.push(`flex`)}let r=t.filter(e=>e===`flex`).length,i=t.includes(`lit`),a=``;r>0&&!i&&(a=n>0?`width:calc((100% - ${n}px) / ${r});min-width:0`:`width:${100/r}%;min-width:0`);let o=`<colgroup>`;return e.forEach((e,n)=>{let r=e.width==null?``:String(e.width).trim(),i=t[n],s=``;i===`px`?s=` style="width:${r}px;min-width:0"`:i===`lit`?s=` style="width:${this._escapeHtml(r)};min-width:0"`:a&&(s=` style="${a}"`),o+=`<col${s} />`}),o+=`</colgroup>`,o}_buildDataRowHtml(e,t,n,r=!1){if(!this._configuration)return``;let i=t,a=n,o=`box-sizing:border-box;min-height:${a}px;max-height:${a}px;height:${a}px;overflow:hidden`,s=``,c=typeof this._configuration.onRowClick==`function`,l=c?`cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800`:``,u=c?` data-row-clickable="true"`:``,d=l?` class="${l}"`:``;return s+=`<tr data-row-index="${i}"${r?` data-mint-rt-last-row=""`:``}${u}${d} style="${o}">`,this._configuration.columns.forEach(t=>{if(t.hidden)return;let n=!t.show||t.show(this,e),r=`${this._getStyle(t)}box-sizing:border-box;max-height:${a}px;overflow:hidden;vertical-align:middle;`;s+=`<td style="${r}" class="${this._getClasses(t,!0)}">`,s+=n?this._buildTableCellInnerHtml(t,e,i):``,s+=`</td>`}),s+=`</tr>`,s}_getVirtualRowCount(){return!this._virtualScrollActive()||!this._configuration?0:this._type===`provided`?this._getAllFilteredRowsSorted().length:this._type===`ajax`?this._totalRows:0}_getVirtualRowAt(e){return this._type===`provided`?this._getAllFilteredRowsSorted()[e]??null:this._type===`ajax`&&this._virtualRowCache.has(e)?this._virtualRowCache.get(e):null}_buildVirtualPlaceholderRowHtml(e,t,n=!1){if(!this._configuration)return``;let r=t,i=`box-sizing:border-box;min-height:${r}px;max-height:${r}px;height:${r}px;overflow:hidden`,a=`<tr data-row-index="${e}" data-mint-rt-placeholder="true"${n?` data-mint-rt-last-row=""`:``} class="bg-white dark:bg-mint-canvas" style="${i}">`;return this._configuration.columns.forEach(e=>{if(e.hidden)return;let t=`${this._getStyle(e)}box-sizing:border-box;max-height:${r}px;height:${r}px;overflow:hidden;vertical-align:middle;line-height:0;`;if(a+=`<td style="${t}" class="${this._getClasses(e,!0)}">`,e.thumbnail){let t=this._thumbnailDesktopPx(e);a+=`<div class="rounded-md bg-gray-200 dark:bg-white/15" style="width:${t}px;height:${t}px;max-width:100%;box-sizing:border-box"></div>`}else a+=`<div class="h-4 max-w-[95%] rounded bg-gray-200 dark:bg-white/15"></div>`;a+=`</td>`}),a+=`</tr>`,a}_virtualScrollStickyOverlapPx(e){let t=0;if(this._fixedControls()){let e=this.querySelector(`#mint-rt-fixed-controls-${this._tableId}`);if(e)t+=Math.ceil(e.getBoundingClientRect().height);else{let e=getComputedStyle(this).getPropertyValue(`--mint-rt-fixed-controls-h`).trim(),n=parseFloat(e);isNaN(n)||(t+=Math.ceil(n))}}if(this._fixedHeader()&&e){let n=e.querySelector(`thead`);n&&(t+=Math.ceil(n.getBoundingClientRect().height))}return t}_scrollVirtualTableTopIntoView(){if(!this._virtualScrollActive()||!this.isConnected)return;if(this._virtualScrollRoot()===`table-body`){let e=this._virtualBodyScrollEl?.isConnected?this._virtualBodyScrollEl:this.querySelector(`#mint-rt-vscroll-${this._tableId}`),t=this._useMobileListLayout()&&e?e.querySelector(`ul[data-mint-rt-mobile-list="${this._tableId}"]`):null,n=e?.querySelector(`mint-table.table-section`)||e?.querySelector(`mint-table`),r=n?.querySelector(`#${this._tableId}`)?.closest(`table`)||n?.querySelector(`table`),i=this._virtualScrollStickyOverlapPx(r),a=t||n;if(a&&i>0){let e=a.getBoundingClientRect(),t=window.scrollY+e.top-i;window.scrollTo({top:Math.max(0,t),behavior:`auto`})}e&&(e.scrollTop=0,this._virtualBodyScrollEl=e,this._virtualInvalidate(),this._scheduleVirtualWindowSync());return}let e=this.querySelector(`ul[data-mint-rt-mobile-list="${this._tableId}"]`),t=this.querySelector(`mint-table.table-section`),n=this.querySelector(`#${this._tableId}`)?.closest(`table`)||t?.querySelector(`table`),r=this._useMobileListLayout()&&e?e:t||n;if(!r)return;let i=this._virtualScrollStickyOverlapPx(n),a=r.getBoundingClientRect(),o=window.scrollY+a.top-i;window.scrollTo({top:Math.max(0,o),behavior:`auto`}),this._virtualInvalidate(),this._scheduleVirtualWindowSync()}_scheduleVirtualWindowSync(){this._virtualScrollActive()&&this._virtualWindowRaf===null&&(this._virtualWindowRaf=window.requestAnimationFrame(()=>{this._virtualWindowRaf=null,this._syncVirtualWindow()}))}_syncVirtualWindow(){if(!this._virtualScrollActive()||!this._configuration)return;let e=this._useMobileListLayout(),t=this.querySelector(`tbody[data-mint-rt-tbody="${this._tableId}"]`),n=this.querySelector(`ul[data-mint-rt-mobile-list="${this._tableId}"]`),r=e?n:t;if(!r)return;let i=this._getVirtualRowCount(),a=this._virtualRowHeightPxForSync(e),o=this._virtualColspan();if(i===0){e?this._fetchError?r.innerHTML=`<li class="list-none px-4 py-8 text-center text-sm text-red-500 dark:text-red-400">Failed to load data: ${this._escapeHtml(this._fetchError)}</li>`:r.innerHTML=`<li class="list-none px-4 py-8 text-center text-sm">No records found.</li>`:this._fetchError?r.innerHTML=`<tr><td colspan="${o}" class="text-center py-8 text-red-500 dark:text-red-400">Failed to load data: ${this._escapeHtml(this._fetchError)}</td></tr>`:r.innerHTML=`<tr><td colspan="${o}" class="text-center py-8">No records found.</td></tr>`,this._virtualLastRangeStart=-1,this._virtualLastRangeEnd=-1,this._virtualLastRangeCacheSig=``;return}let s=0,c=window.innerHeight;if(this._virtualScrollRoot()===`table-body`){let e=this._virtualBodyScrollEl;if((!e||!e.isConnected)&&(e=this.querySelector(`#mint-rt-vscroll-${this._tableId}`),this._virtualBodyScrollEl=e),!e)return;s=e.scrollTop,c=e.clientHeight||400}else{let e=r.getBoundingClientRect();s=Math.max(0,-e.top)}let l=Math.min(Math.max(0,Math.floor(s/a)),Math.max(0,i-1)),u=Math.ceil(c/a)+16,d=Math.max(0,l-8),f=Math.min(i,l+u),p=``;if(this._type===`ajax`)for(let e=d;e<f;e++)p+=this._virtualRowCache.has(e)?`1`:`0`;if(d===this._virtualLastRangeStart&&f===this._virtualLastRangeEnd&&(this._type!==`ajax`||p===this._virtualLastRangeCacheSig))return;this._virtualLastRangeStart=d,this._virtualLastRangeEnd=f,this._virtualLastRangeCacheSig=p;let m=d*a,h=Math.max(0,(i-f)*a),g=``;if(e){g+=`<li aria-hidden="true" class="pointer-events-none m-0 block list-none border-0 p-0" style="height:${m}px"></li>`;for(let e=d;e<f;e++){let t=this._getVirtualRowAt(e),n=i>0&&e===i-1;t?g+=this._buildMobileListItemHtml(t,e,a,n):g+=this._buildMobileListPlaceholderLi(e,a,n)}g+=`<li aria-hidden="true" class="pointer-events-none m-0 block list-none border-0 p-0" style="height:${h}px"></li>`}else{g+=`<tr data-mint-rt-spacer="top" aria-hidden="true"><td colspan="${o}" style="height:${m}px;padding:0;border:0;line-height:0;font-size:0"></td></tr>`;for(let e=d;e<f;e++){let t=this._getVirtualRowAt(e),n=i>0&&e===i-1;t?g+=this._buildDataRowHtml(t,e,a,n):g+=this._buildVirtualPlaceholderRowHtml(e,a,n)}g+=`<tr data-mint-rt-spacer="bottom" aria-hidden="true"><td colspan="${o}" style="height:${h}px;padding:0;border:0;line-height:0;font-size:0"></td></tr>`}if(r.innerHTML=g,this.querySelectorAll(`tbody[data-mint-rt-tbody="${this._tableId}"] mint-button[data-action], ul[data-mint-rt-mobile-list="${this._tableId}"] mint-button[data-action]`).forEach(e=>{e.render&&e.render()}),this._attachTableEventListeners(),this._attachRowClickHandler(),this._type===`ajax`&&this._virtualScrollActive()&&this._scheduleVirtualAjaxPrefetch(d,f),this._virtualScrollRoot()===`table-body`&&!e){let e=this._virtualBodyScrollEl;e?.isConnected&&requestAnimationFrame(()=>{if(!e.isConnected)return;let t=Math.max(0,e.scrollHeight-e.clientHeight);e.scrollTop>t&&(e.scrollTop=t)})}}_detachVirtualScroll(){this._virtualScrollHandler&&=(window.removeEventListener(`scroll`,this._virtualScrollHandler),this._virtualBodyScrollEl?.removeEventListener(`scroll`,this._virtualScrollHandler),null),this._virtualWindowResizeHandler&&=(window.removeEventListener(`resize`,this._virtualWindowResizeHandler),null),this._virtualResizeObserver&&=(this._virtualResizeObserver.disconnect(),null),this._virtualBodyScrollEl=null,this._virtualWindowRaf!==null&&(window.cancelAnimationFrame(this._virtualWindowRaf),this._virtualWindowRaf=null),this._virtualLastRangeStart=-1,this._virtualLastRangeEnd=-1,this._virtualLastRangeCacheSig=``,this._virtualAjaxPrefetchTimer!==null&&(window.clearTimeout(this._virtualAjaxPrefetchTimer),this._virtualAjaxPrefetchTimer=null),this._virtualRangeFetching=!1}_scheduleVirtualAjaxPrefetch(e,t){if(this._type!==`ajax`||!this._virtualScrollActive()||!this._configuration)return;let n=!1;for(let r=e;r<t;r++)if(!this._virtualRowCache.has(r)){n=!0;break}if(!n)return;this._virtualAjaxPrefetchTimer!==null&&window.clearTimeout(this._virtualAjaxPrefetchTimer);let r=e,i=t;this._virtualAjaxPrefetchTimer=window.setTimeout(()=>{this._virtualAjaxPrefetchTimer=null,this._fetchVirtualAjaxRange(r,i-r)},60)}async _fetchVirtualAjaxRange(e,t){if(!this._configuration||this._type!==`ajax`||!this._virtualScrollActive())return;let n=typeof this._configuration.data==`string`?this._configuration.data:null;if(!n||t<=0||this._virtualRangeFetching||e<0||e>=this._totalRows)return;this._virtualRangeFetching=!0;let r=this._virtualFetchGeneration,i=Math.min(e,Math.max(0,this._totalRows-1)),a=Math.min(150,Math.max(this._perPage,t,15),Math.max(1,this._totalRows-i));try{let e=new URLSearchParams({perPage:a.toString(),offset:i.toString(),search:this._search,sortBy:this._configuration.sortBy||`id`,sort:this._configuration.sort||`asc`,searchColumns:this._searchColumns.join(`,`),columns:this._columns.join(`,`)}),t={};this._configuration.headers&&(t.headers=this._configuration.headers);let o=await fetch(`${n}?${e.toString()}`,t);if(!o.ok)throw Error(`HTTP error! status: ${o.status}`);let s=await o.json();if(r!==this._virtualFetchGeneration)return;(s.content?.rows||[]).forEach((e,t)=>{let n=i+t;n<this._totalRows&&this._virtualRowCache.set(n,e)})}catch(e){console.error(`mint-resource-table: virtual range fetch failed`,e)}finally{this._virtualRangeFetching=!1,r===this._virtualFetchGeneration&&(this._virtualInvalidate(),this._scheduleVirtualWindowSync())}}_detachFixedChromeResize(){this._fixedChromeResizeObserver?.disconnect(),this._fixedChromeResizeObserver=null,this.style.removeProperty(`--mint-rt-fixed-controls-h`)}_syncFixedControlsChromeHeight(){if(!this._fixedHeader()||!this._fixedControls())return;this._fixedChromeResizeObserver?.disconnect(),this._fixedChromeResizeObserver=null;let e=this.querySelector(`#mint-rt-fixed-controls-${this._tableId}`);if(!e)return;let t=()=>{let t=Math.ceil(e.getBoundingClientRect().height);this.style.setProperty(`--mint-rt-fixed-controls-h`,`${t}px`)};t(),this._fixedChromeResizeObserver=new ResizeObserver(t),this._fixedChromeResizeObserver.observe(e)}_attachVirtualScrollListeners(){if(this._detachVirtualScroll(),!this._virtualScrollActive())return;let e=()=>{this._scheduleVirtualWindowSync()};this._virtualScrollHandler=e,this._virtualScrollRoot()===`table-body`?(this._virtualBodyScrollEl=this.querySelector(`#mint-rt-vscroll-${this._tableId}`),this._virtualBodyScrollEl?.addEventListener(`scroll`,e,{passive:!0}),this._virtualBodyScrollEl&&typeof ResizeObserver<`u`&&(this._virtualResizeObserver=new ResizeObserver(()=>this._scheduleVirtualWindowSync()),this._virtualResizeObserver.observe(this._virtualBodyScrollEl))):window.addEventListener(`scroll`,e,{passive:!0}),this._virtualWindowResizeHandler=()=>this._scheduleVirtualWindowSync(),window.addEventListener(`resize`,this._virtualWindowResizeHandler,{passive:!0}),this._scheduleVirtualWindowSync()}_toggleSort(e){if(!this._configuration||!e.data||!e.sortable)return;let t=e.data;if(this._sortTimeoutId!==null&&(clearTimeout(this._sortTimeoutId),this._sortTimeoutId=null),this._sorting=!0,this._sortingColumn=e,this._updateSortIcons(),this._type===`ajax`)this._sortTimeoutId=window.setTimeout(()=>{if(this._sortTimeoutId=null,!this._configuration||!t||!e.sortable)return;let n=this._configuration.sort||`asc`;this._configuration.sortBy?.toLowerCase()===t.toLowerCase()&&(n=n===`desc`?`asc`:`desc`),this._configuration.sort=n,this._configuration.sortBy=t,this._updateSortIcons(),this._offset=0,this._currentPage=1,this._fetching=!1,this._loading=!1,this._fetchData(void 0,!1,this._perPage,0)},10);else{let e=this._configuration.sort||`asc`;this._configuration.sortBy?.toLowerCase()===t.toLowerCase()&&(e=e===`desc`?`asc`:`desc`),this._configuration.sort=e,this._configuration.sortBy=t,this._currentPage=1,this._sorting=!1,this._sortingColumn=null,this._updateSortIcons(),this.render(),this._virtualScrollActive()&&queueMicrotask(()=>this._scrollVirtualTableTopIntoView())}}_getSortClass(e){return this._sorting&&this._sortingColumn===e?`spinner`:this._configuration?.sortBy?.toLowerCase()===e.data?.toLowerCase()?this._configuration?.sort?.toLowerCase()===`desc`?`caret-down`:`caret-up`:``}_updateSortIcons(){if(!this._configuration)return;this._configuration.columns.forEach((e,t)=>{if(!e.sortable||e.hidden)return;let n=this.querySelector(`th[data-column-key="${t}"]`);if(!n)return;let r=n.querySelector(`:scope > div.flex.items-center`);if(!r)return;let i=r.querySelector(`:scope > div.ml-2.flex.items-center`),a=this._getSortClass(e),o=()=>{if(!i){let e=document.createElement(`div`);e.className=`ml-2 flex items-center`,r.appendChild(e),i=e}return i},s=()=>{i&&=(i.remove(),null)};if(a===`spinner`){let e=o();if(e.querySelector(`mint-icon`)?.remove(),!e.querySelector(`mint-spinner`)){let t=document.createElement(`mint-spinner`);t.className=`w-4 h-4`,e.appendChild(t)}}else if(a===`caret-up`||a===`caret-down`){let e=o();e.querySelector(`mint-spinner`)?.remove();let t=e.querySelector(`mint-icon`);t||(t=document.createElement(`mint-icon`),e.appendChild(t)),t.setAttribute(`name`,a),t.className=`w-4 h-4`}else s()}),this._syncMobileSortPopoverIcons();let e=this.querySelector(`#mint-rt-mobile-sort-btn-${this._tableId}`);e&&(e.setAttribute(`icon`,this._getMobileSortTriggerIconName()),this._sorting?e.setAttribute(`loading`,`true`):e.removeAttribute(`loading`),typeof e.render==`function`&&e.render())}_showFetchingState(){}_triggerSearch(){this._searchTimeoutId&&clearTimeout(this._searchTimeoutId),this._searching=!0,this._type===`ajax`&&this._updateSearchIcon(),this._type!==`ajax`&&(this._currentPage=1),this._updateTableBody(),this._type!==`ajax`&&this._updatePagination(),this._searchTimeoutId=window.setTimeout(()=>{this._type===`ajax`?(this._offset=0,this._fetchData(void 0,!1,this._perPage,0)):(this._searching=!1,this._virtualScrollActive()&&queueMicrotask(()=>this._scrollVirtualTableTopIntoView()))},400)}_updateSearchIcon(){let e=this.querySelector(`#search-${this._tableId}`);if(!e)return;let t=this._type===`ajax`&&(this._searching||this._fetching);setTimeout(()=>{let n=e.querySelector(`.relative`)||e.querySelector(`div`);if(!n)return;let r=n.querySelector(`mint-icon`),i=n.querySelector(`mint-spinner`);if(t){if(r&&!i){let e=document.createElement(`mint-spinner`);e.className=`absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 pointer-events-none`,r.replaceWith(e)}else if(!r&&!i){let e=document.createElement(`mint-spinner`);e.className=`absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 pointer-events-none`,n.appendChild(e)}}else if(i){e.getAttribute(`icon`)||e.setAttribute(`icon`,`search`);let t=document.createElement(`mint-icon`);t.setAttribute(`name`,`search`),t.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`,i.replaceWith(t)}},0)}_updateTableBody(){if(!this._configuration)return;let e=this.querySelector(`tbody[data-mint-rt-tbody="${this._tableId}"]`),t=this.querySelector(`#${this._tableId}`)?.closest(`table`)?.querySelector(`tbody`);if(this._virtualScrollActive()&&(this._type===`provided`||this._type===`ajax`)){if(!(e||t)){this.render();return}let n=this.querySelector(`#search-${this._tableId}`),r=document.activeElement===n||n?.querySelector(`input`)===document.activeElement,i=this._search;if((this._fetching||this._loading)&&!this._loaded&&!this._sorting)return;if(this._virtualInvalidate(),this._syncVirtualWindow(),r&&n){let e=n.querySelector(`input`)||n._element;e?(e.value=i,setTimeout(()=>{e.focus(),e.setSelectionRange(i.length,i.length)},0)):n.value!==void 0&&(n.value=i,setTimeout(()=>{n.focus()},0))}return}let n=this._getRows(),r=t;if(!r){this.render();return}let i=this.querySelector(`#search-${this._tableId}`),a=document.activeElement===i||i?.querySelector(`input`)===document.activeElement,o=this._search,s=``,c=``;if((this._fetching||this._loading)&&!this._loaded&&!this._sorting)return;n.forEach((e,t)=>{c+=this._buildMobileListItemHtml(e,t,void 0,t===n.length-1);let r=typeof this._configuration.onRowClick==`function`,i=r?`cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800`:``;s+=`<tr data-row-index="${t}" ${r?`data-row-clickable="true"`:``}${i?` class="${i}"`:``}>`,this._configuration.columns.forEach(n=>{if(n.hidden)return;let r=!n.show||n.show(this,e);s+=`<td style="${this._getStyle(n)}" class="${this._getClasses(n,!0)}">`,r&&(s+=this._buildTableCellInnerHtml(n,e,t,`table`)),s+=`</td>`}),s+=`</tr>`}),n.length===0&&(this._fetchError?(s+=`<tr><td colspan="${this._configuration.columns.filter(e=>!e.hidden).length}" class="text-center py-8 text-red-500 dark:text-red-400">Failed to load data: ${this._escapeHtml(this._fetchError)}</td></tr>`,c+=`<li class="list-none px-4 py-8 text-center text-sm text-red-500 dark:text-red-400">Failed to load data: ${this._escapeHtml(this._fetchError)}</li>`):(s+=`<tr><td colspan="${this._configuration.columns.filter(e=>!e.hidden).length}" class="text-center py-8">No records found.</td></tr>`,c+=`<li class="list-none px-4 py-8 text-center text-sm">No records found.</li>`)),r.innerHTML=s;let l=this.querySelector(`ul[data-mint-rt-mobile-list="${this._tableId}"]`);if(l&&(l.innerHTML=c),this._attachTableEventListeners(),this._attachRowClickHandler(),a&&i){let e=i.querySelector(`input`)||i._element;e?(e.value=o,setTimeout(()=>{e.focus(),e.setSelectionRange(o.length,o.length)},0)):i.value!==void 0&&(i.value=o,setTimeout(()=>{i.focus()},0))}}_updatePagination(){if(!this._configuration)return;let e=this._lastPage||Math.ceil(this._rows.length/this._perPage),t=()=>{let e=this.querySelector(`mint-table`),t=e?.nextElementSibling;e&&t&&t.id!==`mint-rt-pagination-host-${this._tableId}`&&!t.classList.contains(`mint-rt-pagination-host`)&&t.querySelector?.(`[data-action="page"]`)&&t.remove()};if(!this._configuration.perPage||e<=1||this._virtualScrollActive()){this._getPaginationHostEl()?.replaceChildren(),t();return}let n=this._getPaginationHostEl();if(!n){let e=this.querySelector(`[data-mint-rt-mobile-list="${this._tableId}"]`)||this.querySelector(`mint-table`);if(!e){this.render();return}n=document.createElement(`div`),n.id=`mint-rt-pagination-host-${this._tableId}`,n.setAttribute(`data-mint-rt-pagination-wrap`,``),n.className=`mint-rt-pagination-host w-full min-w-0 overflow-x-auto overflow-y-hidden overscroll-x-contain flex justify-center [-webkit-overflow-scrolling:touch] md:justify-end `+(this._inMintCard?`border-t border-gray-200 px-3.5 pb-3.5 pt-3 dark:border-mint-divider md:border-t-0 md:pt-0`:`border-t border-gray-200 px-2 py-3 dark:border-mint-divider md:border-t-0 md:py-0 md:mt-4`),e.insertAdjacentElement(`afterend`,n)}let r=this._buildPaginationNavMarkup(e);n.innerHTML=r,setTimeout(()=>{this._attachPaginationListeners(),n.querySelectorAll(`mint-button[data-action="page"]`).forEach(e=>{let t=e.getAttribute(`data-page`),n=t&&this._loadingPage===parseInt(t),r=e._button||e.querySelector(`button`);if(r)if(n){let e=[],t=document.createTreeWalker(r,NodeFilter.SHOW_TEXT,null),n;for(;n=t.nextNode();)e.push(n);e.forEach(e=>e.parentNode?.removeChild(e));let i=r.querySelector(`.mint-button-content`);if(i){let e=i.textContent?.trim();e&&/^\d+$/.test(e)&&i.remove()}let a=r.querySelector(`span.mr-2`);a&&a.querySelector(`mint-spinner`)&&(a.classList.remove(`mr-2`),a.classList.add(`mr-0`))}else{let e=r.textContent?.trim();if(!e||!/^\d+$/.test(e)){let e=t||``,n=r.querySelector(`mint-spinner`);r.innerHTML=``,n&&r.appendChild(n),r.appendChild(document.createTextNode(e))}}if(`render`in e&&typeof e.render==`function`&&(e.render(),n&&r)){let e=r.querySelector(`span.mr-2`);e&&e.querySelector(`mint-spinner`)&&(e.classList.remove(`mr-2`),e.classList.add(`mr-0`))}}),n.querySelectorAll(`mint-button[data-action="page-prev"], mint-button[data-action="page-next"]`).forEach(e=>{`render`in e&&typeof e.render==`function`&&e.render()}),this._loadingPage!==null&&!this._loading&&!this._fetching&&this._updatePagination()},0)}_goToPage(e){let t=this._lastPage||Math.ceil(this._rows.length/this._perPage);e>t&&(e=t),e<1&&(e=1),e!==this._currentPage&&(this._currentPage=e,this._offset=(e-1)*this._perPage,this._updatePageInUrl(e),this._type===`ajax`?(this._loadingPage=e,this._updatePagination(),this._fetchData()):this.render())}_handleButtonClick(e){if(this._configuration)switch(e.type){case`export`:break;case`print`:window.print();break;case`csv`:this._downloadCSV();break;default:e.onClick&&e.onClick(this);break}}_downloadCSV(){if(!this._configuration)return;let e=this.querySelector(`#${this._tableId}`)||this.querySelector(`table`);if(!e)return;let t=`data:text/csv;charset=utf-8,`,n=e=>{let n=[];e.querySelectorAll(`th, td`).forEach(e=>{let t=e.getAttribute(`colspan`);if(t)for(let e=0;e<parseInt(t,10)-1;e++)n.push(``);n.push(`"`+e.textContent?.trim().replace(/"/g,`""`)+`"`)}),t+=n.join(`,`)+`
|
|
82
|
+
`,n.classList.add(`mint-date-shortcuts-row`),document.head.querySelector(`style[data-mint-date-shortcuts]`)||(r.setAttribute(`data-mint-date-shortcuts`,`true`),document.head.appendChild(r));let i=document.createElement(`div`);i.className=`absolute left-0 top-0 bottom-0 w-8 pointer-events-none z-10 bg-gradient-to-r from-white dark:from-mint-elevated to-transparent opacity-0 md:hidden`,t.appendChild(i);let a=document.createElement(`div`);a.className=`absolute right-0 top-0 bottom-0 w-8 pointer-events-none z-10 bg-gradient-to-l from-white dark:from-mint-elevated to-transparent opacity-100 md:hidden`,t.appendChild(a);let s=document.createElement(`div`);s.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-mint-elevated to-transparent opacity-0`,t.appendChild(s);let l=document.createElement(`div`);l.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-mint-elevated to-transparent opacity-100`,t.appendChild(l);let u=()=>{if(window.innerWidth>=768){let e=n.scrollTop,t=n.scrollHeight,r=n.clientHeight;e>0?s.style.opacity=`1`:s.style.opacity=`0`,e+r<t-1?l.style.opacity=`1`:l.style.opacity=`0`,i.style.opacity=`0`,a.style.opacity=`0`}else{let e=n.scrollLeft,t=n.scrollWidth,r=n.clientWidth;e>0?i.style.opacity=`1`:i.style.opacity=`0`,e+r<t-1?a.style.opacity=`1`:a.style.opacity=`0`,s.style.opacity=`0`,l.style.opacity=`0`}};n.addEventListener(`scroll`,u),window.addEventListener(`resize`,u),setTimeout(u,0),o.forEach(e=>{let 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-mint-hover text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-mint-elevated 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=e.label,t.setAttribute(`data-keep-popover-open`,`true`);let r=()=>{let t=e.action();if(t){if(this._isRange&&`start`in t&&`end`in t){this._selectedStartDate=t.start,this._selectedEndDate=t.end;let e=this.getFormat(),n=`${this._formatDate(t.start,e)} - ${this._formatDate(t.end,e)}`;this.setValue(n),this._currentMonth=t.start.getMonth(),this._currentYear=t.start.getFullYear()}else if(t instanceof Date){this._selectedStartDate=t,this._selectedEndDate=null;let e=this.getFormat(),n=this._formatDate(t,e);this.setValue(n),this._currentMonth=t.getMonth(),this._currentYear=t.getFullYear()}this._buildCalendar(),this._popover&&typeof this._popover.close==`function`&&this._popover.close(),this.dispatchEvent(new CustomEvent(`input`,{detail:{value:this.getValue()},bubbles:!0,cancelable:!0})),this.dispatchEvent(new CustomEvent(`change`,{detail:{value:this.getValue()},bubbles:!0,cancelable:!0}))}};t.addEventListener(`click`,r),t.addEventListener(`touchend`,e=>{e.preventDefault(),r()},{passive:!1}),n.appendChild(t)}),t.appendChild(n),e.appendChild(t),c.appendChild(e)}l.appendChild(u),l.appendChild(b),l.appendChild(x),c.appendChild(l),this._calendarContainer.appendChild(c)}_buildMonthView(){if(!this._calendarContainer)return;let 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`;let n=document.createElement(`button`);n.type=`button`,n.tabIndex=0,n.className=`p-1 rounded hover:bg-gray-100 dark:hover:bg-mint-hover text-gray-600 dark:text-gray-300 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`);let r=document.createElement(`mint-icon`);r.setAttribute(`name`,`caret-left`),r.className=`w-4 h-4`,n.appendChild(r);let i=()=>{let e=this._currentMonth,t=this._currentYear;this._currentYear--,this._buildCalendar(),this._dispatchMonthChangeEvent(e,t,this._currentMonth,this._currentYear)};n.addEventListener(`click`,i),n.addEventListener(`touchend`,e=>{e.preventDefault(),i()},{passive:!1}),t.appendChild(n);let a=document.createElement(`button`);a.type=`button`,a.tabIndex=0,a.className=`text-sm font-medium text-gray-900 dark:text-gray-100 hover:text-gray-600 dark:hover:text-gray-300 cursor-pointer 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`,a.setAttribute(`data-keep-popover-open`,`true`),a.textContent=String(this._currentYear);let o=()=>{this.getMode()!==`year`&&(this._viewMode=`year`,this._buildCalendar())};a.addEventListener(`click`,o),a.addEventListener(`touchend`,e=>{e.preventDefault(),o()},{passive:!1}),t.appendChild(a);let s=document.createElement(`button`);s.type=`button`,s.tabIndex=0,s.className=`p-1 rounded hover:bg-gray-100 dark:hover:bg-mint-hover text-gray-600 dark:text-gray-300 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`);let c=document.createElement(`mint-icon`);c.setAttribute(`name`,`caret-right`),c.className=`w-4 h-4`,s.appendChild(c);let l=()=>{let e=this._currentMonth,t=this._currentYear;this._currentYear++,this._buildCalendar(),this._dispatchMonthChangeEvent(e,t,this._currentMonth,this._currentYear)};s.addEventListener(`click`,l),s.addEventListener(`touchend`,e=>{e.preventDefault(),l()},{passive:!1}),t.appendChild(s);let u=document.createElement(`div`);u.className=`grid grid-cols-3 gap-2`,e.forEach((e,t)=>{let n=document.createElement(`button`);n.type=`button`,n.tabIndex=0,n.setAttribute(`data-keep-popover-open`,`true`),n.className=`p-2 rounded text-sm font-medium focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500 ${this._currentMonth===t?`bg-slate-800 dark:bg-slate-600 text-white`:`text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-mint-hover`}`,n.textContent=e;let r=()=>{if(this.getMode()===`month`){let e=new Date(this._currentYear,t,1),n=this.getFormat(),r=this._formatDate(e,n);this.setValue(r),this._selectedStartDate=e,this._selectedEndDate=null;let i=this._currentMonth,a=this._currentYear;this._currentMonth=t,this._dispatchMonthChangeEvent(i,a,this._currentMonth,this._currentYear),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})),this._dispatchDateChangeEvent(),this._popover&&typeof this._popover.close==`function`&&this._popover.close()}else{let e=this._currentMonth,n=this._currentYear;this._currentMonth=t,this._viewMode=`calendar`,this._buildCalendar(),this._dispatchMonthChangeEvent(e,n,this._currentMonth,this._currentYear)}};n.addEventListener(`click`,r),n.addEventListener(`touchend`,e=>{e.preventDefault(),r()},{passive:!1}),u.appendChild(n)}),this._calendarContainer.appendChild(t),this._calendarContainer.appendChild(u)}_buildYearView(){if(!this._calendarContainer)return;let e=this._currentYear-6,t=this._currentYear+6,n=document.createElement(`div`);n.className=`flex items-center justify-between mb-4`;let r=document.createElement(`button`);r.type=`button`,r.tabIndex=0,r.className=`p-1 rounded hover:bg-gray-100 dark:hover:bg-mint-hover text-gray-600 dark:text-gray-300 focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500`,r.setAttribute(`data-keep-popover-open`,`true`);let i=document.createElement(`mint-icon`);i.setAttribute(`name`,`caret-left`),i.className=`w-4 h-4`,r.appendChild(i);let a=()=>{let e=this._currentMonth,t=this._currentYear;this._currentYear-=12,this._buildCalendar(),this._dispatchMonthChangeEvent(e,t,this._currentMonth,this._currentYear)};r.addEventListener(`click`,a),r.addEventListener(`touchend`,e=>{e.preventDefault(),a()},{passive:!1}),n.appendChild(r);let o=document.createElement(`div`);o.className=`text-sm font-medium text-gray-900 dark:text-gray-100`,o.textContent=`${e} - ${t}`,n.appendChild(o);let s=document.createElement(`button`);s.type=`button`,s.tabIndex=0,s.className=`p-1 rounded hover:bg-gray-100 dark:hover:bg-mint-hover text-gray-600 dark:text-gray-300 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`);let c=document.createElement(`mint-icon`);c.setAttribute(`name`,`caret-right`),c.className=`w-4 h-4`,s.appendChild(c);let l=()=>{let e=this._currentMonth,t=this._currentYear;this._currentYear+=12,this._buildCalendar(),this._dispatchMonthChangeEvent(e,t,this._currentMonth,this._currentYear)};s.addEventListener(`click`,l),s.addEventListener(`touchend`,e=>{e.preventDefault(),l()},{passive:!1}),n.appendChild(s);let u=document.createElement(`div`);u.className=`grid grid-cols-3 gap-2`;for(let n=e;n<=t;n++){let e=document.createElement(`button`);e.type=`button`,e.tabIndex=0,e.setAttribute(`data-keep-popover-open`,`true`),e.className=`p-2 rounded text-sm font-medium focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500 ${this._currentYear===n?`bg-slate-800 dark:bg-slate-600 text-white`:`text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-mint-hover`}`,e.textContent=String(n),e.addEventListener(`click`,()=>{let e=this.getMode();if(e===`year`){let e=new Date(n,0,1),t=this.getFormat(),r=this._formatDate(e,t);this.setValue(r),this._selectedStartDate=e,this._selectedEndDate=null;let i=this._currentMonth,a=this._currentYear;this._currentYear=n,this._currentMonth=0,this._dispatchMonthChangeEvent(i,a,this._currentMonth,this._currentYear),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})),this._dispatchDateChangeEvent(),this._popover&&typeof this._popover.close==`function`&&this._popover.close()}else if(e===`month`){let e=this._currentMonth,t=this._currentYear;this._currentYear=n,this._viewMode=`month`,this._buildCalendar(),this._dispatchMonthChangeEvent(e,t,this._currentMonth,this._currentYear)}else{let e=this._currentMonth,t=this._currentYear;this._currentYear=n,this._viewMode=`calendar`,this._buildCalendar(),this._dispatchMonthChangeEvent(e,t,this._currentMonth,this._currentYear)}}),u.appendChild(e)}this._calendarContainer.appendChild(n),this._calendarContainer.appendChild(u)}_getDaysInMonth(e,t){return new Date(t,e+1,0).getDate()}_getFirstDayOfMonth(e,t){let n=this.getWeekStartDay(),r=new Date(t,e,1).getDay();return r>=n?r-n:7-(n-r)}_isToday(e){let t=new Date;return e.getDate()===t.getDate()&&e.getMonth()===t.getMonth()&&e.getFullYear()===t.getFullYear()}_isDateSelected(e){let t=this.getSelectionMode();return this._isRange||t===`week`||t===`month`?this._selectedStartDate&&this._selectedEndDate?this._isSameDate(e,this._selectedStartDate)||this._isSameDate(e,this._selectedEndDate):this._isRange&&this._selectedStartDate&&!this._selectedEndDate?this._isSameDate(e,this._selectedStartDate):!1:this._selectedStartDate!==null&&this._isSameDate(e,this._selectedStartDate)}_isDateInRange(e){let t=this.getSelectionMode();if((this._isRange||t===`week`||t===`month`)&&this._selectedStartDate&&this._selectedEndDate)return this._rangeIncludesDisabledDates(this._selectedStartDate,this._selectedEndDate)?!1:e>=this._selectedStartDate&&e<=this._selectedEndDate;if(this._isRange&&this._selectedStartDate&&!this._selectedEndDate&&this._hoveredDate){let t=this._selectedStartDate<this._hoveredDate?this._selectedStartDate:this._hoveredDate,n=this._selectedStartDate<this._hoveredDate?this._hoveredDate:this._selectedStartDate;if(this._rangeIncludesDisabledDates(t,n)){let r=this._findFirstDisabledDateInRange(t,n);return r?this._selectedStartDate<this._hoveredDate?e>=t&&e<r&&!this._isSameDate(e,t):e>r&&e<=n&&!this._isSameDate(e,n):!1}return e>=t&&e<=n&&!this._isSameDate(e,t)&&!this._isSameDate(e,n)}return!1}_rangeIncludesDisabledDates(e,t){let n=this.getDisabledDates(),r=new Date(e.getFullYear(),e.getMonth(),e.getDate()),i=new Date(t.getFullYear(),t.getMonth(),t.getDate());return n.some(e=>{let t=new Date(e.getFullYear(),e.getMonth(),e.getDate());return t>=r&&t<=i})}_findFirstDisabledDateInRange(e,t){let n=this.getDisabledDates(),r=new Date(e.getFullYear(),e.getMonth(),e.getDate()),i=new Date(t.getFullYear(),t.getMonth(),t.getDate()),a=n.map(e=>new Date(e.getFullYear(),e.getMonth(),e.getDate())).filter(e=>e>=r&&e<=i).sort((e,t)=>e.getTime()-t.getTime());return a.length>0?a[0]:null}_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()}_isDateDisabled(e){return this.getDisabledDates().some(t=>this._isSameDate(e,t))}_dispatchMonthChangeEvent(e,t,n,r){(e!==n||t!==r)&&this.dispatchEvent(new CustomEvent(`month-change`,{detail:{month:n,year:r,oldMonth:e,oldYear:t},bubbles:!0,cancelable:!0,composed:!0}))}_dispatchDateChangeEvent(){let e=this.getFormat(),t={value:this.getValue()};this._selectedStartDate&&(t.startDate=this._selectedStartDate,t.startDateFormatted=this._formatDate(this._selectedStartDate,e)),this._selectedEndDate&&(t.endDate=this._selectedEndDate,t.endDateFormatted=this._formatDate(this._selectedEndDate,e)),this.dispatchEvent(new CustomEvent(`date-change`,{detail:t,bubbles:!0,cancelable:!0,composed:!0}))}_setupContainerObserver(){if(this._resizeObserver&&=(this._resizeObserver.disconnect(),null),!this._inputsWrapperEl)return;let e=e=>{this._inputsWrapperEl&&(e<400?(this._inputsWrapperEl.classList.add(`flex-wrap`),this._inputsWrapperEl.classList.remove(`flex-nowrap`)):(this._inputsWrapperEl.classList.remove(`flex-wrap`),this._inputsWrapperEl.classList.add(`flex-nowrap`)))};e(this._inputsWrapperEl.offsetWidth||this.offsetWidth),this._resizeObserver=new ResizeObserver(t=>{for(let n of t){let t=n.contentRect.width;e(t)}}),this._resizeObserver.observe(this)}_getWeekStart(e){let t=this.getWeekStartDay(),n=e.getDay(),r;r=n>=t?n-t:7-(t-n);let i=new Date(e);return i.setDate(e.getDate()-r),i.setHours(0,0,0,0),i}_getWeekEnd(e){let t=this._getWeekStart(e),n=new Date(t);return n.setDate(t.getDate()+6),n.setHours(23,59,59,999),n}_getMonthStart(e){let t=new Date(e.getFullYear(),e.getMonth(),1);return t.setHours(0,0,0,0),t}_getMonthEnd(e){let t=new Date(e.getFullYear(),e.getMonth()+1,0);return t.setHours(23,59,59,999),t}_handleDateClick(e){this._isHandlingClick=!0;try{let t=this.getFormat(),n=this.getSelectionMode(),r,i;if(n===`week`?(r=this._getWeekStart(e),i=this._getWeekEnd(e)):n===`month`?(r=this._getMonthStart(e),i=this._getMonthEnd(e)):(r=e,i=e),this.isRange()||n===`week`||n===`month`)if(n===`week`||n===`month`){if(this._rangeIncludesDisabledDates(r,i)){this._buildCalendar();return}this._selectedStartDate=r,this._selectedEndDate=i;let e=`${this._formatDate(this._selectedStartDate,t)} - ${this._formatDate(this._selectedEndDate,t)}`;this.setValue(e),this._textInput&&(this._textInput.value=e),this._popover&&typeof this._popover.close==`function`&&this._popover.close()}else if(this._hoveredDate=null,this._selectedStartDate===null){if(this._isDateDisabled(r)){this._buildCalendar();return}this._selectedStartDate=new Date(r.getFullYear(),r.getMonth(),r.getDate()),this._selectedEndDate=null,this._currentMonth=this._selectedStartDate.getMonth(),this._currentYear=this._selectedStartDate.getFullYear(),this._hoveredDate=null,this._buildCalendar()}else if(this._selectedEndDate===null){let n=new Date(e.getFullYear(),e.getMonth(),e.getDate()),r=this._selectedStartDate?new Date(this._selectedStartDate.getFullYear(),this._selectedStartDate.getMonth(),this._selectedStartDate.getDate()):null,i,a;if(r&&n<r?(i=n,a=r):(i=r,a=n),this._rangeIncludesDisabledDates(i,a)){this._buildCalendar();return}r&&n<r?(this._selectedEndDate=r,this._selectedStartDate=n):(this._selectedEndDate=n,r&&(this._selectedStartDate=r)),this._currentMonth=this._selectedStartDate.getMonth(),this._currentYear=this._selectedStartDate.getFullYear();let o=`${this._formatDate(this._selectedStartDate,t)} - ${this._formatDate(this._selectedEndDate,t)}`;this.setAttribute(`value`,o),this._textInput&&(this._textInput.value=o),this._hiddenInput&&(this._hiddenInput.value=o),this._updateDisplayText(),this._buildCalendar(),this._popover&&typeof this._popover.close==`function`&&this._popover.close()}else this._selectedStartDate=r,this._selectedEndDate=null;else{this._selectedStartDate=r,this._selectedEndDate=null;let e=this._formatDate(r,t);this.setValue(e),this._textInput&&(this._textInput.value=e),this._popover&&typeof this._popover.close==`function`&&this._popover.close()}this._buildCalendar(),this._updateDisplayText(),this._exitInputMode();let a=new Event(`input`,{bubbles:!0,cancelable:!0,composed:!0});this.dispatchEvent(a),this.dispatchEvent(new CustomEvent(`input`,{detail:{value:this.getValue()},bubbles:!0,cancelable:!0,composed:!0})),this.dispatchEvent(new CustomEvent(`change`,{detail:{value:this.getValue()},bubbles:!0,cancelable:!0,composed:!0})),this._dispatchDateChangeEvent()}finally{this._isHandlingClick=!1}}_updateDisplayText(){if(!this._displayEl)return;let e=this.getDisplayFormat(),t=this.getSelectionMode(),n=this._isRange||t===`week`||t===`month`,r=``;n&&this._selectedStartDate&&this._selectedEndDate?r=`${this._formatDatePhp(this._selectedStartDate,e)} - ${this._formatDatePhp(this._selectedEndDate,e)}`:this._selectedStartDate&&(r=this._formatDatePhp(this._selectedStartDate,e)),r?(this._displayEl.textContent=r,this._displayEl.classList.remove(`text-gray-400`,`dark:text-gray-500`),this._displayEl.classList.add(`text-gray-900`,`dark:text-white`)):(this._displayEl.textContent=`Select date`,this._displayEl.classList.add(`text-gray-400`,`dark:text-gray-500`),this._displayEl.classList.remove(`text-gray-900`,`dark:text-white`)),this._displayEl&&this._inputsWrapperEl&&(this._displayEl.style.display=this._isInputMode?`none`:`flex`,this._inputsWrapperEl.style.display=this._isInputMode?`flex`:`none`)}_enterInputMode(){if(!this._isInputMode&&!(this.isReadonly()||this.isDisabled())&&(this._isInputMode=!0,this._displayEl&&this._inputsWrapperEl&&(this._displayEl.style.display=`none`,this._inputsWrapperEl.style.display=`flex`),this._startPartInputs.length>0)){let 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())}_renderSkeleton(e){let t=this.querySelector(`.mint-date-picker-skeleton-container`),n=this._fieldsContainer,r=this._input;if(e){t||(t=document.createElement(`div`),t.className=`mint-date-picker-skeleton-container absolute inset-0 z-10 pointer-events-none`,r?(r.classList.contains(`relative`)||r.classList.add(`relative`),r.appendChild(t)):(this.style.position=`relative`,this.appendChild(t)));let e=t.querySelector(`.mint-date-picker-skeleton`);e||(e=document.createElement(`div`),e.className=`mint-date-picker-skeleton w-full rounded-lg bg-gray-200 dark:bg-mint-hover animate-pulse`,e.style.height=`2.25rem`,t.appendChild(e)),t.style.display=`block`,n&&(n.style.visibility=`hidden`,n.style.pointerEvents=`none`),this._displayEl&&(this._displayEl.style.visibility=`hidden`,this._displayEl.style.pointerEvents=`none`)}else t&&(t.style.display=`none`),n&&(n.style.visibility=`visible`,n.style.pointerEvents=`auto`),this._displayEl&&(this._displayEl.style.visibility=`visible`,this._displayEl.style.pointerEvents=`auto`)}_getFocusableElements(){if(!this._calendarContainer)return[];let 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(e=>{let t=window.getComputedStyle(e);return t.display!==`none`&&t.visibility!==`hidden`})}_setupFocusTrap(){if(!this._popover||!this._popover.hasAttribute(`open`))return;this._removeFocusTrap();let e=this;this._focusTrapHandler=function(t){if(t.key!==`Tab`)return;if(!e._popover||!e._popover.hasAttribute(`open`)){e._removeFocusTrap();return}let n=e._getFocusableElements();if(n.length===0)return;let r=n[0],i=n[n.length-1],a=document.activeElement;if(!e._calendarContainer?.contains(a)){t.preventDefault(),r.focus();return}if(t.shiftKey&&a===r){t.preventDefault(),i.focus();return}if(!t.shiftKey&&a===i){t.preventDefault(),r.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(()=>{let e=this._getFocusableElements();e.length>0&&e[0].focus()})}_removeFocusTrap(){this._focusTrapHandler&&=(document.removeEventListener(`keydown`,this._focusTrapHandler,!0),null),this._escapeHandler&&=(document.removeEventListener(`keydown`,this._escapeHandler,!0),null)}};customElements.get(`mint-date-picker`)||customElements.define(`mint-date-picker`,S);var C=class extends HTMLElement{static get observedAttributes(){return[`name`,`value`,`disabled`,`id`,`required`,`label`,`info`,`error`,`error-message`,`multiple`,`loading`]}constructor(){super(),this._select=null,this._wrapper=null,this._caretUpIcon=null,this._caretDownIcon=null,this._changeHandler=null,this._optionObserver=null,this._childrenObserver=null}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(),this._childrenObserver&&this._childrenObserver.disconnect(),this._childrenObserver=new MutationObserver(e=>{e.some(e=>{let t=Array.from(e.addedNodes).some(e=>e.nodeType===Node.ELEMENT_NODE&&(e.tagName===`OPTION`||e.tagName===`OPTGROUP`))||Array.from(e.removedNodes).some(e=>e.nodeType===Node.ELEMENT_NODE&&(e.tagName===`OPTION`||e.tagName===`OPTGROUP`)),n=e.type===`attributes`&&e.target.nodeType===Node.ELEMENT_NODE&&(e.target.tagName===`OPTION`||e.target.tagName===`OPTGROUP`);return t||n})&&requestAnimationFrame(()=>{this.render()})}),this._childrenObserver.observe(this,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`value`,`selected`,`disabled`]})}disconnectedCallback(){this._select&&this._changeHandler&&(this._select.removeEventListener(`change`,this._changeHandler),this._changeHandler=null),this._optionObserver&&=(this._optionObserver.disconnect(),null),this._childrenObserver&&=(this._childrenObserver.disconnect(),null)}isLoading(){return this.getAttribute(`loading`)===`true`}attributeChangedCallback(e,t,n){if(t!==n){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===`loading`){this.render();return}if(e===`value`){this._select&&(this._select.value=n||``);return}this.render()}}getName(){return this.getAttribute(`name`)||``}getValue(){return this.hasAttribute(`value`)?this.getAttribute(`value`)||``:this._select?this._select.value:``}setValue(e){let t=e||``;this.setAttribute(`value`,t),this._select&&(this._select.value=t)}get value(){try{return this.getValue()||``}catch{return``}}set value(e){try{let t=e||``;(this.getAttribute(`value`)||``)!==t&&this.setAttribute(`value`,t),this._select&&requestAnimationFrame(()=>{this._select&&(t===``||Array.from(this._select.options).some(e=>e.value===t))&&this._select.value!==t&&(this._select.value=t)})}catch{}}isDisabled(){return this.getAttribute(`disabled`)===`true`}isMultiple(){return this.getAttribute(`multiple`)===`true`}hasError(){return this.getAttribute(`error`)===`true`}getErrorMessage(){return this.getAttribute(`error-message`)||``}getId(){return this.getAttribute(`id`)||``}getLabel(){return this.getAttribute(`label`)||``}getInfo(){return this.getAttribute(`info`)||``}getSelectClasses(){let e=this.hasError(),t=this.isMultiple(),n=[`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-mint-elevated`,`text-gray-900`,`dark:text-white`,`outline-none`,`focus:outline-none`,`disabled:opacity-40`,`disabled:cursor-not-allowed`,`appearance-none`,`bg-no-repeat`,`bg-right`,`cursor-pointer`],r=[`border-2`,e?`border-red-300 dark:border-red-300`:`border-gray-200 dark:border-mint-divider`],i=[`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[...n,...r,...i].filter(Boolean).join(` `)}render(){let e=this.isLoading(),t=[];this._select&&Array.from(this._select.children).forEach(e=>{(e.tagName===`OPTION`||e.tagName===`OPTGROUP`)&&t.push(e.cloneNode(!0))});let n=Array.from(this.children).filter(e=>e.tagName===`OPTION`||e.tagName===`OPTGROUP`).map(e=>e.cloneNode(!0));for(;this.firstChild;)this.removeChild(this.firstChild);this._wrapper=null,this._select=null;let r=this.getLabel(),i=this.getInfo(),a=this.getId(),o=this.getName(),s=this.getValue(),c=this.isDisabled(),l=this.isMultiple(),u=this.hasError();if(r){let e=document.createElement(`label`);e.className=`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,a&&e.setAttribute(`for`,a);let t=document.createTextNode(r);e.appendChild(t),this.appendChild(e)}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(),a&&(this._select.id=a),o&&(this._select.name=o),c&&(this._select.disabled=!0),l&&(this._select.multiple=!0),this._select.setAttribute(`aria-invalid`,u?`true`:`false`);let d=n.length>0?n:t;if(d.length>0&&d.forEach(e=>{this._select.appendChild(e)}),this._select.options.length===0){let e=document.createElement(`option`);e.value=``,e.textContent=`Select an option`,e.disabled=!0,e.selected=!0,this._select.appendChild(e)}if(this._select.value=s||``,this._changeHandler&&this._select&&this._select.removeEventListener(`change`,this._changeHandler),this._changeHandler=e=>{let t=e.target.value;(this.getAttribute(`value`)||``)!==t&&(t?this.setAttribute(`value`,t):this.removeAttribute(`value`));let n=new Event(`input`,{bubbles:!0,cancelable:!0,composed:!0});this.dispatchEvent(n),this.dispatchEvent(new CustomEvent(`input`,{detail:{value:t},bubbles:!0,cancelable:!0,composed:!0})),this.dispatchEvent(new CustomEvent(`change`,{detail:{value:t},bubbles:!0,cancelable:!0,composed:!0}))},this._select.addEventListener(`change`,this._changeHandler),this._optionObserver&&this._optionObserver.disconnect(),this._optionObserver=new MutationObserver(()=>{let e=this.getAttribute(`value`)||this.value||``;this._select&&e&&requestAnimationFrame(()=>{this._select&&Array.from(this._select.options).some(t=>t.value===e)&&this._select.value!==e&&(this._select.value=e)})}),this._optionObserver.observe(this._select,{childList:!0,subtree:!0}),this._wrapper.appendChild(this._select),l)this._caretUpIcon=null,this._caretDownIcon=null;else{let e=document.createElement(`div`);e.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]`,e.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]`,e.appendChild(this._caretDownIcon),this._wrapper.appendChild(e)}if(i){let e=document.createElement(`div`);e.className=`mt-1 text-xs text-gray-500 dark:text-gray-400`,e.textContent=i,this.appendChild(e)}this._renderErrorState(),this._renderSkeleton(e)}_renderSkeleton(e){let t=this.querySelector(`.mint-select-skeleton-container`),n=this._wrapper;if(e){t||(t=document.createElement(`div`),t.className=`mint-select-skeleton-container absolute inset-0 z-10 pointer-events-none`,n?(n.classList.contains(`relative`)||n.classList.add(`relative`),n.appendChild(t)):(this.style.position=`relative`,this.appendChild(t)));let e=t.querySelector(`.mint-select-skeleton`);if(!e){e=document.createElement(`div`),e.className=`mint-select-skeleton w-full rounded-lg bg-gray-200 dark:bg-mint-hover animate-pulse`;let n=this.isMultiple();e.style.height=n?`6rem`:`2.25rem`,t.appendChild(e)}t.style.display=`block`,this._select&&(this._select.style.opacity=`0`,this._select.style.pointerEvents=`none`)}else t&&(t.style.display=`none`),this._select&&(this._select.style.opacity=`1`,this._select.style.pointerEvents=`auto`)}_renderErrorState(){let e=this.hasError(),t=this.getErrorMessage(),n=this.querySelector(`.mint-select-error`);e&&t?(n||(n=document.createElement(`div`),n.className=`mint-select-error mt-1 text-xs text-red-600 dark:text-red-400`,this.appendChild(n)),n.textContent=t):n&&n.remove()}};customElements.get(`mint-select`)||customElements.define(`mint-select`,C);var w=class extends HTMLElement{static get observedAttributes(){return[`label`,`accept`,`multiple`,`width`,`height`,`disabled`,`name`,`error`,`error-message`,`loading`]}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}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){let e=this.closest(`form`);e&&e.removeEventListener(`reset`,this._resetHandler),this._resetHandler=null}}attributeChangedCallback(e,t,n){if(t!==n){if(e===`error`||e===`error-message`){this._updateDragStateClass(),this._renderErrorState(this.hasError(),this.getErrorMessage());return}if(e===`loading`){this.render();return}this.render()}}getLabel(){return this.getAttribute(`label`)||``}getAccept(){return this.getAttribute(`accept`)||``}isMultiple(){return this.getAttribute(`multiple`)===`true`}getWidth(){return this.getAttribute(`width`)||`200px`}getHeight(){return this.getAttribute(`height`)||`200px`}_renderSkeleton(e){let t=this.querySelector(`.mint-dropzone-skeleton-container`),n=this._dropzone;if(e){t||(t=document.createElement(`div`),t.className=`mint-dropzone-skeleton-container absolute inset-0 z-10 pointer-events-none flex items-center justify-center`,n?(n.classList.contains(`relative`)||n.classList.add(`relative`),n.appendChild(t)):(this.style.position=`relative`,this.appendChild(t)));let e=t.querySelector(`.mint-dropzone-skeleton`);if(e||(e=document.createElement(`div`),e.className=`mint-dropzone-skeleton rounded-lg border-2 border-dashed border-gray-300 dark:border-mint-divider bg-gray-200 dark:bg-mint-hover animate-pulse`,e.style.width=`100%`,e.style.height=`100%`,t.appendChild(e)),t.style.display=`flex`,n){let e=n.querySelector(`.mint-dropzone-icon`),t=n.querySelector(`.mint-dropzone-label`),r=n.querySelector(`.mint-dropzone-previews-wrapper`),i=this._fileInput;if(e){let t=e;t.style.visibility=`hidden`,t.style.pointerEvents=`none`}if(t){let e=t;e.style.visibility=`hidden`,e.style.pointerEvents=`none`}if(r){let e=r;e.style.visibility=`hidden`,e.style.pointerEvents=`none`}i&&(i.style.visibility=`hidden`,i.style.pointerEvents=`none`),n.style.pointerEvents=`none`}}else if(t&&(t.style.display=`none`),n){let e=n.querySelector(`.mint-dropzone-icon`),t=n.querySelector(`.mint-dropzone-label`),r=n.querySelector(`.mint-dropzone-previews-wrapper`),i=this._fileInput;if(e){let t=e;t.style.visibility=`visible`,t.style.pointerEvents=`auto`}if(t){let e=t;e.style.visibility=`visible`,e.style.pointerEvents=`auto`}if(r){let e=r;e.style.visibility=`visible`,e.style.pointerEvents=`auto`}i&&(i.style.visibility=`visible`,i.style.pointerEvents=`auto`),n.style.pointerEvents=`auto`}}getName(){return this.getAttribute(`name`)||``}hasError(){return this.getAttribute(`error`)===`true`}getErrorMessage(){return this.getAttribute(`error-message`)||``}isDisabled(){return this.getAttribute(`disabled`)===`true`}isLoading(){return this.getAttribute(`loading`)===`true`}render(){let e=this.isLoading(),t=this.getLabel(),n=this.getAccept(),r=this.isMultiple(),i=this.isDisabled(),a=this.getWidth(),o=this.getHeight(),s=this.getName(),c=this.hasError(),l=this.getErrorMessage();this._dropzone||(this._dropzone=document.createElement(`div`),this.appendChild(this._dropzone)),this._updateDragStateClass(),this._dropzone.setAttribute(`aria-invalid`,c?`true`:`false`),i?(this._dropzone.setAttribute(`tabindex`,`-1`),this._dropzone.removeAttribute(`role`)):(this._dropzone.setAttribute(`tabindex`,`0`),this._dropzone.setAttribute(`role`,`button`),this._dropzone.setAttribute(`aria-label`,t||`File upload dropzone`)),this._dropzone.style.width=a,this._dropzone.style.height=o,this._dropzone.style.minWidth=a,this._dropzone.style.minHeight=o,this._fileInput||(this._fileInput=document.createElement(`input`),this._fileInput.type=`file`,this._fileInput.style.display=`none`,this._fileInput.setAttribute(`tabindex`,`-1`),this._fileInput.setAttribute(`aria-hidden`,`true`),this._dropzone.appendChild(this._fileInput)),this._fileInput.accept=n,this._fileInput.multiple=r,this._fileInput.disabled=i,s?this._fileInput.name=s:this._fileInput.removeAttribute(`name`),this._fileInput.setAttribute(`aria-invalid`,c?`true`:`false`);let u=this._dropzone.querySelector(`.mint-dropzone-icon`),d=this._dropzone.querySelector(`.mint-dropzone-label`);u&&u.remove(),d&&d.remove();let f=document.createElement(`div`);f.className=`mint-dropzone-icon flex items-center justify-center mt-2 mb-2 flex-shrink-0`;let p=document.createElement(`mint-icon`);if(p.setAttribute(`name`,`upload`),p.className=`w-12 h-12 text-gray-400 dark:text-gray-500`,f.appendChild(p),this._dropzone.appendChild(f),t){let e=document.createElement(`div`);e.className=`mint-dropzone-label text-sm font-medium text-gray-600 dark:text-gray-400 text-center px-4 flex-shrink-0`,e.textContent=t,this._dropzone.appendChild(e)}this.setupEventListeners(),this._renderErrorState(c,l),this._renderPreviews(),this._renderSkeleton(e)}_updateDragState(){this._dropzone&&this._updateDragStateClass()}_renderErrorState(e,t){let n=this.querySelector(`.mint-dropzone-error`);e&&t?(n||(n=document.createElement(`div`),n.className=`mint-dropzone-error mt-1 text-xs text-red-600 dark:text-red-400`,this.appendChild(n)),n.textContent=t):n&&n.remove()}_updateDragStateClass(){if(!this._dropzone)return;let e=this.isDisabled(),t=this.hasError(),n=`relative border-2 border-dashed rounded-lg flex flex-col items-center ${this._selectedFiles.length>0?`justify-start`:`justify-center`} cursor-pointer overflow-hidden`,r=this._isDragging?`border-gray-400 dark:border-gray-500 bg-gray-50 dark:bg-mint-elevated dark:border-mint-divider`:`border-gray-300 dark:border-mint-divider bg-white dark:bg-mint-elevated dark:border-mint-divider hover:border-gray-400 dark:hover:border-mint-divider`,i=t?`border-red-300 dark:border-red-300 bg-red-50/50 dark:bg-red-900/30`:``,a=e?`opacity-40 cursor-not-allowed`:``;this._dropzone.className=`${n} ${t?i:r} ${a} focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500`.trim()}setupEventListeners(){this._listenersInitialized||(this._listenersInitialized=!0,this.removeEventListeners(),!(!this._dropzone||!this._fileInput||this.isDisabled())&&(this._onDropzoneClick||=e=>{if(!(this.isDisabled()||!this._fileInput)&&e.target!==this._fileInput&&(e.stopPropagation(),e.preventDefault(),e.isTrusted))try{this._fileInput.click()}catch(e){console.debug(`File chooser blocked:`,e)}},this._onDragOver||=e=>{e.preventDefault(),e.stopPropagation(),this.isDisabled()||this._isDragging||(this._isDragging=!0,this._wasDragging=!0,this._updateDragState())},this._onDragLeave||=e=>{e.preventDefault(),e.stopPropagation();let t=this._dropzone?.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||=e=>{if(e.preventDefault(),e.stopPropagation(),this._isDragging&&(this._isDragging=!1,this._wasDragging=!1,this._updateDragState()),this.isDisabled())return;let t=e.dataTransfer?.files;t&&t.length>0&&this._handleFiles(t)},this._onFileInputInput||=e=>{e.stopImmediatePropagation(),e.stopPropagation()},this._onKeyDown||=e=>{if(!(this.isDisabled()||!this._fileInput)&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopPropagation(),e.isTrusted))try{this._fileInput.click()}catch(e){console.debug(`File chooser blocked:`,e)}},this._onFocus||=e=>{this._dropzone&&!this.isDisabled()&&this._dropzone.classList.add(`focus-visible:ring-2`)},this._onBlur||=e=>{this._dropzone},this._onFileInputChange||=e=>{if(e.stopImmediatePropagation(),e.stopPropagation(),this._isUpdatingFiles)return;let t=e.target.files;if(t&&t.length>0){let e=this.getAccept(),n=this.isMultiple(),r=[],i=[];for(let n=0;n<t.length;n++){let a=t[n];this._isFileAccepted(a,e)?r.push(a):i.push(a)}if(!n&&r.length>1&&(i.push(...r.slice(1)),r.splice(1)),i.length>0){let e=new CustomEvent(`dropRejected`,{detail:{files:i,reason:`File type not accepted or multiple files not allowed`},bubbles:!0,cancelable:!0});this.dispatchEvent(e)}r.length>0&&this._applyValidFiles(r)}},this._dropzone.addEventListener(`click`,this._onDropzoneClick),this._dropzone.addEventListener(`dragover`,this._onDragOver),this._dropzone.addEventListener(`dragleave`,this._onDragLeave),this._dropzone.addEventListener(`drop`,this._onDrop),this._dropzone.addEventListener(`keydown`,this._onKeyDown),this._dropzone.addEventListener(`focus`,this._onFocus),this._dropzone.addEventListener(`blur`,this._onBlur),this._fileInput.addEventListener(`change`,this._onFileInputChange),this._fileInput.addEventListener(`input`,this._onFileInputInput,!0)))}removeEventListeners(){this._dropzone&&(this._onDropzoneClick&&this._dropzone.removeEventListener(`click`,this._onDropzoneClick),this._onDragOver&&this._dropzone.removeEventListener(`dragover`,this._onDragOver),this._onDragLeave&&this._dropzone.removeEventListener(`dragleave`,this._onDragLeave),this._onDrop&&this._dropzone.removeEventListener(`drop`,this._onDrop),this._onKeyDown&&this._dropzone.removeEventListener(`keydown`,this._onKeyDown),this._onFocus&&this._dropzone.removeEventListener(`focus`,this._onFocus),this._onBlur&&this._dropzone.removeEventListener(`blur`,this._onBlur)),this._fileInput&&(this._onFileInputChange&&this._fileInput.removeEventListener(`change`,this._onFileInputChange),this._onFileInputInput&&this._fileInput.removeEventListener(`input`,this._onFileInputInput,!0)),this._isDragging=!1,this._listenersInitialized=!1}_handleFiles(e){let t=this.getAccept(),n=this.isMultiple(),r=[],i=[];for(let n=0;n<e.length;n++){let a=e[n];this._isFileAccepted(a,t)?r.push(a):i.push(a)}if(!n&&r.length>1&&(i.push(...r.slice(1)),r.splice(1)),i.length>0){let e=new CustomEvent(`dropRejected`,{detail:{files:i,reason:`File type not accepted or multiple files not allowed`},bubbles:!0,cancelable:!0});this.dispatchEvent(e)}r.length>0&&this._applyValidFiles(r)}_isFileAccepted(e,t){if(!t)return!0;let n=t.split(`,`).map(e=>e.trim().toLowerCase());for(let t of n)if(t.startsWith(`.`)){if(`.`+e.name.split(`.`).pop()?.toLowerCase()===t)return!0}else if(t.includes(`/*`)){if(t.split(`/`)[0]===e.type.split(`/`)[0])return!0}else if(e.type===t)return!0;return!1}_dispatchEvent(e,t){let n=t.target,r=new CustomEvent(e,{detail:{files:n.files?Array.from(n.files):[],value:n.value||``},bubbles:!0,cancelable:!0});this.dispatchEvent(r)}_dispatchSelectionEvents(){let e={files:[...this._selectedFiles],value:``};this.dispatchEvent(new CustomEvent(`input`,{detail:e,bubbles:!0,cancelable:!0,composed:!0})),this.dispatchEvent(new CustomEvent(`change`,{detail:e,bubbles:!0,cancelable:!0,composed:!0}))}_syncFileInputFromSelected(){if(!this._fileInput)return;let e=new DataTransfer;this._selectedFiles.forEach(t=>{try{e.items.add(t)}catch(e){console.warn(`Failed to add file to DataTransfer:`,e)}}),this._isUpdatingFiles=!0;try{this._fileInput.files=e.files}catch(e){console.warn(`Failed to set files on input:`,e)}setTimeout(()=>{this._isUpdatingFiles=!1},0)}get files(){return this._syncFileInputFromSelected(),this._fileInput?.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}let e=document.createElement(`div`);e.className=`mint-dropzone-previews-wrapper mt-3 w-full relative max-h-48`;let 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((e,n)=>{let r=document.createElement(`div`);if(r.className=`flex items-center gap-3 p-2 rounded border border-gray-200 dark:border-mint-divider bg-gray-50 dark:bg-mint-elevated`,e.type.startsWith(`image/`)){let t=document.createElement(`img`);t.className=`w-12 h-12 object-cover rounded border border-gray-200 dark:border-mint-divider`;let n=URL.createObjectURL(e);this._previewUrls.push(n),t.src=n,r.appendChild(t)}else{let e=document.createElement(`mint-icon`);e.setAttribute(`name`,`attach`),e.className=`w-5 h-5 text-gray-500 dark:text-gray-300`,r.appendChild(e)}let i=document.createElement(`div`);i.className=`flex-1 text-sm text-gray-800 dark:text-gray-100 truncate`,i.textContent=e.name,r.appendChild(i);let a=document.createElement(`button`);a.type=`button`,a.className=`text-gray-500 hover:bg-red-100 dark:hover:bg-red-900/30 flex items-center justify-center w-6 h-6 rounded-full`;let o=document.createElement(`mint-icon`);o.setAttribute(`name`,`close`),o.className=`w-4 h-4`,a.appendChild(o),a.addEventListener(`click`,e=>{e.preventDefault(),e.stopPropagation(),this._removeFileAt(n)}),r.appendChild(a),t.appendChild(r)});let n=this.hasError(),r=this._isDragging,i=`from-white dark:from-mint-elevated`;n?i=`from-red-50 dark:from-red-900/30`:r&&(i=`from-gray-50 dark:from-mint-elevated`);let a=document.createElement(`div`);a.className=`absolute top-0 left-0 right-0 h-4 pointer-events-none z-10 bg-gradient-to-b ${i} to-transparent opacity-0`,e.appendChild(a);let o=document.createElement(`div`);o.className=`absolute bottom-0 left-0 right-0 h-4 pointer-events-none z-10 bg-gradient-to-t ${i} to-transparent opacity-100`,e.appendChild(o);let s=()=>{let e=t.scrollTop,n=t.scrollHeight,r=t.clientHeight;e>0?a.style.opacity=`1`:a.style.opacity=`0`,e+r<n-1?o.style.opacity=`1`:o.style.opacity=`0`};s(),t.addEventListener(`scroll`,s),e.appendChild(t),this._previewContainer=e,this._dropzone.appendChild(e),this._updateDragStateClass()}_removeFileAt(e){if(e<0||e>=this._selectedFiles.length)return;let[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(){let 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()){let t=e.filter(e=>!this._isDuplicateFile(e));this._selectedFiles.push(...t)}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`,w);var T=class extends HTMLElement{static get observedAttributes(){return[`action`,`method`,`enctype`,`data-form-data`,`loading`,`headers`,`submitting`]}constructor(){super(),this._form=null,this._submitHandler=null,this._hostSubmitHandler=null,this._errors={},this._fieldBlurHandlers=new Map,this._fieldChangeHandlers=new Map,this._observer=null,this._formData=null,this._headers=null,this._buttonStates=new Map,this._attrSubmittingMintFields=new Map,this._attrSubmittingNativeFields=new Map,this._attrSubmittingMintButtons=new Map,this._attrSubmittingNativeButtons=new Map,this._reactiveDataProxy=null,this._reactiveDataObserver=null,this._lastDataSnapshot=null}connectedCallback(){this._render(),this._ensureSubmitHandler(),this._setupBlurValidation();let e=this.getAttribute(`headers`);e&&this._parseHeaders(e),requestAnimationFrame(()=>{requestAnimationFrame(()=>{if(this._formData)this._isReactiveObject(this._formData)?this._setupReactiveDataObserver(this._formData):this._lastDataSnapshot||=this._createDataSnapshot(this._formData),this._applyFormData();else{let e=this.getAttribute(`data-form-data`);e&&(this._parseFormData(e),this._applyFormData())}this._propagateLoadingState(),this._applySubmittingAttributeState()})})}disconnectedCallback(){this._form&&this._submitHandler&&this._form.removeEventListener(`submit`,this._submitHandler,!0),this._hostSubmitHandler&&this.removeEventListener(`submit`,this._hostSubmitHandler),this._restoreSubmittingAttributeState(),this._cleanupBlurValidation(),this._stopReactiveDataObserver()}reset(){this._clearErrors(),this._formData?this._applyFormData():this.clear()}clear(){this._clearErrors(),this._form&&this._form.reset(),this._resetCustomFields()}attributeChangedCallback(e,t,n){e===`form-data`?(this._parseFormData(n),this.isConnected&&this._form&&requestAnimationFrame(()=>{requestAnimationFrame(()=>{this._applyFormData()})})):e===`headers`?this._parseHeaders(n):e===`loading`?this.isConnected&&this._form?requestAnimationFrame(()=>{this._propagateLoadingState()}):this._propagateLoadingState():e===`submitting`?this.isConnected&&this._form?requestAnimationFrame(()=>{this._applySubmittingAttributeState()}):this._applySubmittingAttributeState():this._applyFormAttributes()}get data(){return this._formData}set data(e){this._stopReactiveDataObserver(),this._reactiveDataProxy=null,this._lastDataSnapshot=null,e&&typeof e==`object`&&!Array.isArray(e)?(this._formData=e,this._isReactiveObject(e)?this._setupReactiveDataObserver(e):this._lastDataSnapshot=this._createDataSnapshot(e)):e==null?this._formData=null:this._parseFormData(e),this.isConnected&&this._form&&requestAnimationFrame(()=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{this._applyFormData()})})})}get headers(){return this._headers}set headers(e){if(e&&typeof e==`object`&&!Array.isArray(e))this._headers=e;else if(e==null)this._headers=null;else if(typeof e==`string`)try{this._headers=JSON.parse(e)}catch{this._headers=null}else this._headers=null}_render(){if(this.classList.add(`block`,`w-full`),!this._form){for(this._form=document.createElement(`form`),this._form.noValidate=!0;this.firstChild;)this._form.appendChild(this.firstChild);this.appendChild(this._form)}this._ensureSubmitHandler(),this._applyFormAttributes()}_ensureSubmitHandler(){this._form&&(this._submitHandler&&this._form.removeEventListener(`submit`,this._submitHandler,!0),this._submitHandler=e=>{e.preventDefault(),e.stopImmediatePropagation(),this._handleSubmit(e)},this._form.addEventListener(`submit`,this._submitHandler,!0))}_applyFormAttributes(){if(!this._form)return;let e=this.getAttribute(`action`)||``,t=this.getAttribute(`method`)||``,n=this.getAttribute(`enctype`)||`application/x-www-form-urlencoded`;e&&(this._form.action=e),t&&(this._form.method=t),this._form.enctype=n}async _handleSubmit(e){if(e.preventDefault(),!this._form)return;this._clearErrors(),this._syncDropzoneFiles();let t=this._collectValidationRules(),n=new FormData(this._form),r=this._formDataToValues(n);if(this._formData){let e=this._getReactiveValue(this._formData);e&&typeof e==`object`&&!Array.isArray(e)&&(r={...this._extractReactiveData(e),...r})}if(!this._validate(r,t)){this.dispatchEvent(new CustomEvent(`invalid`,{detail:{errors:this._errors},bubbles:!0,cancelable:!0,composed:!0}));return}let i=new CustomEvent(`submit`,{detail:{formData:n,values:r,form:this},bubbles:!0,cancelable:!0,composed:!0});this.dispatchEvent(i),i.form=this;let a=new CustomEvent(`mintFormSubmit`,{detail:{formData:n,values:r,form:this},bubbles:!0,cancelable:!0,composed:!0});if(a.form=this,this.dispatchEvent(a),i.defaultPrevented||a.defaultPrevented)return;let o=this.getAttribute(`action`),s=this.getAttribute(`method`);if(!(!o||!s)){this._setButtonsSubmitting();try{let e=await this._submitData(n,r);this.dispatchEvent(new CustomEvent(`submitsuccess`,{detail:e,bubbles:!0,cancelable:!0}))}catch(e){e?.status===422&&e?.data?.errors&&this._applyServerErrors(e.data.errors),this.dispatchEvent(new CustomEvent(`submiterror`,{detail:{error:e},bubbles:!0,cancelable:!0}))}finally{this._restoreButtonsState()}}}async _submitData(e,t){let n=this.getAttribute(`action`),r=this.getAttribute(`method`),i=this.getAttribute(`enctype`)||`application/x-www-form-urlencoded`;if(!n)return{status:0,ok:!0,data:{values:t}};let a=Array.from(e.values()).some(e=>e instanceof File),o=null,s={},c=n;if(typeof window<`u`&&window.mintForm?.defaults?.headers?.common&&Object.assign(s,window.mintForm.defaults.headers.common),this._headers&&Object.assign(s,this._headers),r===`GET`){let t=new URLSearchParams;e.forEach((e,n)=>{e instanceof File||t.append(n,String(e))}),c+=(n.includes(`?`)?`&`:`?`)+t.toString()}else if(i===`multipart/form-data`||a)o=e;else if(i===`application/json`)o=JSON.stringify(t),s[`Content-Type`]=`application/json`;else{let t=new URLSearchParams;e.forEach((e,n)=>{e instanceof File||t.append(n,String(e))}),o=t,s[`Content-Type`]=`application/x-www-form-urlencoded`}if(typeof fetch==`function`)try{let e=await fetch(c,{method:r||`POST`,body:r===`GET`?null:o,headers:s}),t=await e.text().catch(()=>``),n=t;try{n=JSON.parse(t)}catch{}if(!e.ok){let t={status:e.status,data:n,response:{status:e.status,data:n}};throw await this._applyErrorInterceptors(t)}let i={status:e.status,ok:e.ok,data:n};return await this._applySuccessInterceptors(i)}catch(e){if(e.response)throw e;let t={status:e.status||0,data:e.data||e.message||`Network error`,response:{status:e.status||0,data:e.data||e.message||`Network error`}};throw await this._applyErrorInterceptors(t)}let l=this;return await new Promise(async(e,t)=>{let n=new XMLHttpRequest;n.open(r||`POST`,c,!0),Object.entries(s).forEach(([e,t])=>n.setRequestHeader(e,t)),n.onload=async function(){let{status:r,responseText:i}=n;if(r>=200&&r<300){let n=i;try{n=JSON.parse(i)}catch{}try{let t={status:r,ok:!0,data:n};e(await l._applySuccessInterceptors(t))}catch(e){t(e)}}else{let e=i;try{e=JSON.parse(i)}catch{}try{let n={status:r,data:e,response:{status:r,data:e}};t(await l._applyErrorInterceptors(n))}catch(e){t(e)}}},n.onerror=async function(){try{let e={status:n.status||0,data:n.responseText||`Network error`,response:{status:n.status||0,data:n.responseText||`Network error`}};t(await l._applyErrorInterceptors(e))}catch(e){t(e)}},n.send(r===`GET`?null:o)})}async _applySuccessInterceptors(e){if(typeof window>`u`||!window.mintForm?.interceptors?.response?.handlers)return e;let t=e,n=window.mintForm.interceptors.response.handlers;for(let e of n)e.fulfilled&&(t=await e.fulfilled(t));return t}async _applyErrorInterceptors(e){if(typeof window>`u`||!window.mintForm?.interceptors?.response?.handlers)return Promise.reject(e);let t=e,n=window.mintForm.interceptors.response.handlers;for(let e=n.length-1;e>=0;e--){let r=n[e];if(r.rejected)try{if(t=await r.rejected(t),t!==void 0)return t}catch(e){t=e}}return Promise.reject(t)}_formDataToValues(e){let t={};return e.forEach((e,n)=>{e instanceof File?(t[n]||(t[n]=[]),t[n].push(e)):n in t?Array.isArray(t[n])?(t[n].length>0&&t[n][0]instanceof File,t[n].push(e)):t[n]=[t[n],e]:t[n]=e}),this._form&&(Array.from(this._form.querySelectorAll(`mint-dropzone[name]`)).forEach(e=>{let n=e.getAttribute(`name`);if(n&&e.files!==void 0&&e.files){let r=e.files;if(r.length>0){let e=Array.from(r);t[n]&&Array.isArray(t[n])?e.forEach(e=>{t[n].some(t=>t.name===e.name&&t.size===e.size&&t.lastModified===e.lastModified)||t[n].push(e)}):t[n]=e}}}),Array.from(this._form.querySelectorAll(`input[type="file"][name]`)).forEach(e=>{let n=e.name;if(n&&e.files&&e.files.length>0){let r=Array.from(e.files);t[n]&&Array.isArray(t[n])?r.forEach(e=>{t[n].some(t=>t.name===e.name&&t.size===e.size&&t.lastModified===e.lastModified)||t[n].push(e)}):t[n]=r}}),Array.from(this._form.querySelectorAll(`mint-tags[name]`)).forEach(e=>{let n=e.getAttribute(`name`);if(n){let r=[];e.tags===void 0?typeof e.getTags==`function`&&(r=e.getTags()):r=e.tags,Array.isArray(r)&&r.length>0?t[n]=r.map(e=>typeof e==`string`?e:e?.value||e?.label||``).filter(e=>e.trim()!==``):t[n]=[]}})),t}_collectValidationRules(){let e={};return this._form&&Array.from(this._form.querySelectorAll(`[name][validation]`)).forEach(t=>{let n=t.getAttribute(`name`)||``,r=t.getAttribute(`validation`);if(!n||!r)return;let i=this._parseRules(r);i.length&&(e[n]=i)}),e}_parseRules(e){if(!e)return[];try{let t=e.replace(/'/g,`"`),n=JSON.parse(t);if(Array.isArray(n))return n.map(e=>String(e))}catch{}return e.split(`,`).map(e=>e.trim()).filter(Boolean)}_validate(e,t){let n=!0;return this._errors={},Object.entries(t||{}).forEach(([e,t])=>{let r=Array.isArray(t)?t:[t],i=this._getFieldElements(e),a=this._extractFieldValue(i),o=this._validateRules(a,r);o?(n=!1,this._errors[e]=o,this._flagFieldError(i,o)):this._clearFieldError(i)}),n}_validateField(e){let t=this._collectValidationRules();if(!t[e])return;let n=t[e],r=Array.isArray(n)?n:[n],i=this._getFieldElements(e),a=this._extractFieldValue(i),o=this._validateRules(a,r);o?(this._errors[e]=o,this._flagFieldError(i,o)):(this._clearFieldError(i),delete this._errors[e])}_validateRules(e,t){for(let n of t){let[t,r]=n.split(`:`);switch(t){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`:{let t=Number(e);if(Number.isNaN(t))return`Must be a number.`;break}case`min`:{let t=Number(r);if(Number.isNaN(t))break;if(typeof e==`string`&&e.trim().length<t)return`Must be at least ${t} characters.`;if(Array.isArray(e)&&e.length<t)return`Select at least ${t}.`;if(e instanceof FileList&&e.length<t)return`Upload at least ${t} files.`;if(e!=null&&!Number.isNaN(Number(e))&&Number(e)<t)return`Must be at least ${t}.`;break}case`max`:{let t=Number(r);if(Number.isNaN(t))break;if(typeof e==`string`&&e.trim().length>t)return`Must be at most ${t} characters.`;if(Array.isArray(e)&&e.length>t)return`Select no more than ${t}.`;if(e instanceof FileList&&e.length>t)return`Upload no more than ${t} files.`;if(e!=null&&!Number.isNaN(Number(e))&&Number(e)>t)return`Must be at most ${t}.`;break}default:break}}return null}_getFieldElements(e){if(!this._form)return[];let t=Array.from(this._form.querySelectorAll(`[name="${e}"]`)),n=t.filter(e=>e.tagName===`MINT-SELECT`);if(n.length>0){let r=[];return n.forEach(t=>{let n=t.querySelector(`select[name="`+e+`"]`);n&&r.push(n)}),t.filter(e=>e.tagName!==`MINT-SELECT`).concat(r)}if(t.filter(e=>e.tagName===`MINT-TAGS`).length>0)return t.filter(e=>e.tagName!==`INPUT`||!e.closest(`mint-tags`));let r=t.filter(e=>e.tagName===`INPUT`&&e.closest(`mint-tags`));if(r.length>0){let e=[];return r.forEach(t=>{let n=t.closest(`mint-tags`);n&&!e.includes(n)&&e.push(n)}),t.filter(e=>e.tagName!==`INPUT`||!e.closest(`mint-tags`)).concat(e)}return t}_extractFieldValue(e){if(e.length===0)return``;let t=e.find(e=>e instanceof HTMLSelectElement);if(t)return t.value;if(e.length>1){let t=e.filter(e=>e instanceof HTMLInputElement);if(t.length>0&&t.length===e.length){let e=t.filter(e=>e.checked);if(t.every(e=>e.type===`radio`))return e.length>0?e[0].value||`on`:``;if(t.every(e=>e.type===`checkbox`))return e.map(e=>e.value||`on`)}let n=e.filter(e=>e.tagName===`MINT-CHOICE`);if(n.length>0&&n.length===e.length){let e=n.find(e=>typeof e.getValue==`function`?e.getValue()!==``:e.querySelector(`mint-choice-option[checked]`)!==null);if(e){if(typeof e.getValue==`function`)return e.getValue();let t=e.querySelector(`mint-choice-option[checked]`);if(t)return t.getAttribute(`value`)||``}return``}let r=e.filter(e=>e.tagName===`MINT-CHECKBOX`);if(r.length>0&&r.length===e.length)return r.filter(e=>e.checked===void 0?e.hasAttribute(`checked`):e.checked).map(e=>e.getAttribute(`value`)||`on`)}let n=e[0];if(n instanceof HTMLInputElement)return n.type===`file`?n.files:n.type===`checkbox`||n.type===`radio`?n.checked?n.value||`on`:``:n.value;if(n instanceof HTMLTextAreaElement)return n.value;if(n.tagName===`MINT-SELECT`){let e=n.querySelector(`select`);if(e)return e.value;if(typeof n.getValue==`function`){let e=n.getValue();if(e!=null&&e!==``)return e}return n.getAttribute(`value`)||``}if(n.tagName===`MINT-DROPZONE`&&n.files!==void 0)return n.files;if(n.tagName===`MINT-TAGS`){let e=null;return n.tags===void 0?typeof n.getTags==`function`&&(e=n.getTags()):e=n.tags,Array.isArray(e)?e.map(e=>typeof e==`string`?e:e?.value||e?.label||``).filter(e=>e.trim()!==``):[]}return n.tagName===`MINT-CHECKBOX`||n.tagName===`MINT-SWITCH`?(n.checked===void 0?n.hasAttribute(`checked`):n.checked)?n.getAttribute(`value`)||`on`:``:n.tagName===`MINT-CHOICE`?(typeof n.getValue==`function`?n.getValue():``)||``:n.value===void 0?n.getAttribute(`value`)||``:n.value}_flagFieldError(e,t){e.length!==0&&e.forEach(e=>{(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)&&e.setAttribute(`aria-invalid`,`true`);let n=this._resolveHost(e);n&&(n.setAttribute(`error`,`true`),n.setAttribute(`error-message`,t),n.setAttribute(`data-mint-form-error`,`true`))})}_clearFieldError(e){e.length!==0&&e.forEach(e=>{(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)&&e.removeAttribute(`aria-invalid`);let t=this._resolveHost(e);t&&(t.removeAttribute(`error`),t.removeAttribute(`error-message`),t.removeAttribute(`data-mint-form-error`))})}_clearErrors(){this.querySelectorAll(`[data-mint-form-error]`).forEach(e=>{let 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`)}),this._errors={}}setFormErrors(e){this._applyServerErrors(e)}_applyServerErrors(e){this._clearErrors(),Object.entries(e).forEach(([e,t])=>{let n=Array.isArray(t)?t[0]||`Validation error`:t||`Validation error`,r=this._getFieldElements(e);r.length>0&&(this._errors[e]=n,this._flagFieldError(r,n))})}_parseFormData(e){if(!e){this._formData=null;return}if(typeof e==`object`&&!Array.isArray(e)){this._formData=e;return}if(typeof e==`string`)try{this._formData=JSON.parse(e)}catch{this._formData=null}else this._formData=null}_parseHeaders(e){if(!e){this._headers=null;return}if(typeof e==`string`)try{this._headers=JSON.parse(e)}catch{this._headers=null}else this._headers=null}_applyFormData(){if(!this._formData||!this._form)return;let e=this._getReactiveValue(this._formData);if(!e||typeof e!=`object`||Array.isArray(e))return;let t=()=>{Object.entries(e).forEach(([e,t])=>{let n=this._getFieldElements(e);if(n.length===0){setTimeout(()=>{let n=this._getFieldElements(e);n.length>0&&this._applyValueToField(n,e,t)},300);return}this._applyValueToField(n,e,t)})};requestAnimationFrame(()=>{requestAnimationFrame(()=>{t()})})}_applyValueToField(e,t,n){e.forEach(e=>{let r=e.tagName;try{if(r===`MINT-INPUT`)e.value!==void 0&&(e.value=n||``);else if(r===`MINT-DATE-PICKER`)typeof e.setValue==`function`&&e.setValue(n||``);else if(r===`MINT-SELECT`||r===`SELECT`)r===`SELECT`?e.closest(`mint-select`)?.setValue(n||``):typeof e.setValue==`function`&&e.setValue(n||``);else if(r===`MINT-CHOICE`)typeof e.setValue==`function`?e.setValue(n||``):e.querySelectorAll(`mint-choice-option`).forEach(e=>{e.checked=e.getAttribute(`value`)===n});else if(r===`MINT-CHECKBOX`||r===`MINT-SWITCH`){let t=n===!0||n===`true`||n===`on`||n===1||n===`1`;e.checked===void 0?t?e.setAttribute(`checked`,`true`):e.removeAttribute(`checked`):e.checked=t}else if(r===`MINT-TAGS`)Array.isArray(n)&&e.tags!==void 0&&(e.tags=n.map(e=>typeof e==`string`?{value:e,label:e,dismissable:!0}:e));else if(e instanceof HTMLInputElement){if(e.type===`file`)return;e.type===`checkbox`||e.type===`radio`?e.checked=n===!0||n===`true`||n===`on`||n===1||n===`1`:e.value=n||``}else (e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)&&(e.value=n||``)}catch(e){console.warn(`Failed to set value for field ${t}:`,e)}})}_resetCustomFields(){this.querySelectorAll(`mint-input, mint-date-picker, mint-select, mint-dropzone, mint-checkbox, mint-choice, mint-switch, mint-tags`).forEach(e=>{e.removeAttribute(`error`),e.removeAttribute(`error-message`);let t=e.tagName;if(t===`MINT-INPUT`)try{e.value=``}catch{}else if(t===`MINT-DATE-PICKER`)try{e.setValue?.(``)}catch{}else if(t===`MINT-SELECT`)try{e.setValue?.(``)}catch{}else if(t===`MINT-DROPZONE`){let t=e.querySelector(`input[type="file"]`);t&&(t.value=``)}else if(t===`MINT-CHECKBOX`||t===`MINT-SWITCH`)try{if(e.checked!==void 0)e.checked=!1;else{e.removeAttribute(`checked`);let t=e.querySelector(`input[type="checkbox"], input[type="radio"]`);t&&(t.checked=!1)}}catch{}else if(t===`MINT-CHOICE`)try{typeof e.setValue==`function`?e.setValue(``):e.querySelectorAll(`mint-choice-option`).forEach(e=>{e.checked=!1})}catch{}else if(t===`MINT-TAGS`)try{e.tags=[]}catch{}})}_resolveHost(e){if(e.tagName===`MINT-CHOICE-OPTION`){let t=e.closest(`mint-choice`);if(t)return t}return e.closest(`mint-input, mint-date-picker, mint-select, mint-dropzone, mint-checkbox, mint-choice, mint-switch, mint-tags`)||e}_setupBlurValidation(){if(!this._form)return;let e=e=>{let t=e.target;if(!t)return;let n=this._findFieldElement(t);if(!n)return;let r=this._getFieldName(n);if(!r||!this._collectValidationRules()[r])return;let i=this._extractFieldValue([n]),a=i!=null&&(typeof i==`string`?i.trim()!==``:i instanceof FileList||Array.isArray(i)?i.length>0:!0),o=n.hasAttribute(`data-mint-form-error`)||t instanceof HTMLElement&&(t.hasAttribute(`aria-invalid`)||t.closest(`[data-mint-form-error]`)),s=!!n.closest(`mint-tags`),c=n.tagName===`MINT-CHECKBOX`||n.tagName===`MINT-SWITCH`||n.tagName===`MINT-CHOICE`||t instanceof HTMLElement&&(t.closest(`mint-checkbox, mint-switch, mint-choice`)||t.closest(`mint-choice-option`)),l=n.tagName===`MINT-DATE-PICKER`||t instanceof HTMLElement&&t.closest(`mint-date-picker`);(a||o||s||c||l)&&setTimeout(()=>{this._validateField(r)},0)};this._form.addEventListener(`blur`,e,!0),this._fieldBlurHandlers.set(this._form,e);let t=e=>{let t=e.target;if(!t)return;if(!(t instanceof HTMLInputElement&&t.type===`file`)){let e=this._findFieldElement(t),n=e?this._getFieldName(e):null;e&&n&&this._syncFieldToReactiveData(e,n)}if(e.type===`tags-change`&&t.tagName===`MINT-TAGS`){let e=t,n=this._getFieldName(e);if(!n||!this._collectValidationRules()[n])return;setTimeout(()=>{this._validateField(n)},0);return}if(t instanceof HTMLSelectElement||t.tagName===`MINT-SELECT`||t.closest(`mint-select`)){let e=this._findFieldElement(t);if(!e)return;let n=this._getFieldName(e);if(!n||!this._collectValidationRules()[n])return;setTimeout(()=>{this._validateField(n)},0);return}if(e.type===`choice-change`&&t.tagName===`MINT-CHOICE`){let e=t,n=this._getFieldName(e);if(!n||!this._collectValidationRules()[n])return;setTimeout(()=>{this._validateField(n)},0);return}if(t instanceof HTMLInputElement&&t.type===`checkbox`||t.tagName===`MINT-CHECKBOX`||t.tagName===`MINT-SWITCH`||t.closest(`mint-checkbox, mint-switch`)){let e=this._findFieldElement(t);if(!e)return;let n=this._getFieldName(e);if(!n||!this._collectValidationRules()[n])return;setTimeout(()=>{this._validateField(n)},0);return}let n=this._findFieldElement(t);if(!n)return;let r=this._getFieldName(n);r&&this._collectValidationRules()[r]&&(n.hasAttribute(`data-mint-form-error`)||t instanceof HTMLElement&&t.hasAttribute(`aria-invalid`))&&setTimeout(()=>{this._validateField(r)},0)};this._form.addEventListener(`change`,t,!0),this._form.addEventListener(`input`,t,!0),this._form.addEventListener(`tags-change`,t,!0),this._form.addEventListener(`choice-change`,t,!0),this._fieldChangeHandlers.set(this._form,t)}_findFieldElement(e){let t=e.closest(`mint-input, mint-date-picker, mint-select, mint-dropzone, mint-checkbox, mint-choice, mint-switch, mint-tags`);if(t&&t.hasAttribute(`name`))return t;if(e.hasAttribute(`name`)&&(e.tagName.startsWith(`MINT-`)||e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)||(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)&&e.hasAttribute(`name`))return e;let n=e;for(;n&&n!==this._form;){if(n.hasAttribute(`name`))return n;n=n.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}_syncFieldToReactiveData(e,t){if(!this._formData||!t)return;let n=this._getReactiveValue(this._formData);if(!n||typeof n!=`object`||Array.isArray(n))return;let r=this._getFieldElements(t),i=this._extractFieldValue(r.length?r:[e]);n[t]=this._normalizeReactiveValue(r,i),this._lastDataSnapshot=this._createDataSnapshot(n)}_normalizeReactiveValue(e,t){if(t instanceof FileList)return Array.from(t);if(Array.isArray(t))return t;let n=e[0];return e.length===1&&(n instanceof HTMLInputElement&&n.type===`checkbox`||n?.tagName===`MINT-CHECKBOX`||n?.tagName===`MINT-SWITCH`)?!!t:t??``}_cleanupBlurValidation(){if(this._form&&this._fieldBlurHandlers.has(this._form)){let 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)){let e=this._fieldChangeHandlers.get(this._form);e&&(this._form.removeEventListener(`change`,e,!0),this._form.removeEventListener(`input`,e,!0),this._form.removeEventListener(`tags-change`,e,!0),this._form.removeEventListener(`choice-change`,e,!0)),this._fieldChangeHandlers.delete(this._form)}this._observer&&=(this._observer.disconnect(),null)}_syncDropzoneFiles(){this._form&&Array.from(this._form.querySelectorAll(`mint-dropzone[name]`)).forEach(e=>{typeof e.syncFiles==`function`&&e.syncFiles()})}_isSubmittingAttrActive(){let e=this.getAttribute(`submitting`);return e!==null&&e!==`false`}_applySubmittingAttributeState(){if(this._form){if(!this._isSubmittingAttrActive()){this._restoreSubmittingAttributeState();return}this._attrSubmittingMintFields.size>0||this._attrSubmittingNativeFields.size>0||this._attrSubmittingMintButtons.size>0||this._attrSubmittingNativeButtons.size>0||(this._form.querySelectorAll(`mint-input, mint-select, mint-date-picker, mint-dropzone, mint-checkbox, mint-choice, mint-switch, mint-tags`).forEach(e=>{let t=e.getAttribute(`disabled`)===`true`;this._attrSubmittingMintFields.set(e,t),t||e.setAttribute(`disabled`,`true`),typeof e.render==`function`&&e.render()}),this._form.querySelectorAll(`input, textarea, select`).forEach(e=>{if(e.closest(`mint-input, mint-select, mint-date-picker, mint-dropzone, mint-checkbox, mint-choice, mint-switch, mint-tags, mint-button`)||e instanceof HTMLInputElement&&e.type===`hidden`)return;let t=e.disabled;this._attrSubmittingNativeFields.set(e,t),t||(e.disabled=!0)}),Array.from(this.querySelectorAll(`mint-button`)).forEach(e=>{let t=e.getAttribute(`disabled`)===`true`,n=e.getAttribute(`loading`)===`true`;this._attrSubmittingMintButtons.set(e,{disabled:t,loading:n});let r=(e.getAttribute(`type`)||e.getAttribute(`button-type`)||`default`)===`submit`;t||e.setAttribute(`disabled`,`true`),r&&!n&&e.setAttribute(`loading`,`true`),typeof e.render==`function`&&e.render()}),Array.from(this.querySelectorAll(`button`)).forEach(e=>{if(e.closest(`mint-button`))return;let t=e.disabled;this._attrSubmittingNativeButtons.set(e,t),t||(e.disabled=!0)}))}}_restoreSubmittingAttributeState(){this._attrSubmittingMintFields.forEach((e,t)=>{e?t.setAttribute(`disabled`,`true`):t.removeAttribute(`disabled`),typeof t.render==`function`&&t.render()}),this._attrSubmittingMintFields.clear(),this._attrSubmittingNativeFields.forEach((e,t)=>{t.disabled=e}),this._attrSubmittingNativeFields.clear(),this._attrSubmittingMintButtons.forEach((e,t)=>{e.disabled?t.setAttribute(`disabled`,`true`):t.removeAttribute(`disabled`),e.loading?t.setAttribute(`loading`,`true`):t.removeAttribute(`loading`),typeof t.render==`function`&&t.render()}),this._attrSubmittingMintButtons.clear(),this._attrSubmittingNativeButtons.forEach((e,t)=>{t.disabled=e}),this._attrSubmittingNativeButtons.clear()}_propagateLoadingState(){if(!this._form)return;let e=this.getAttribute(`loading`),t=e!==null&&e!==`false`;Array.from(this._form.querySelectorAll(`mint-input, mint-select, mint-date-picker, mint-dropzone, mint-checkbox, mint-choice, mint-switch, mint-tags`)).forEach(e=>{t?e.setAttribute(`loading`,`true`):e.removeAttribute(`loading`),typeof e.render==`function`&&e.render()})}_setButtonsSubmitting(){if(!this._form)return;this._buttonStates.clear();let e=Array.from(this.querySelectorAll(`mint-button`)),t=Array.from(this.querySelectorAll(`button`));e.forEach(e=>{let t=e.getAttribute(`disabled`)===`true`,n=e.getAttribute(`loading`)===`true`;this._buttonStates.set(e,{disabled:t,loading:n});let r=(e.getAttribute(`type`)||e.getAttribute(`button-type`)||`default`)===`submit`;t||e.setAttribute(`disabled`,`true`),r&&e.setAttribute(`loading`,`true`),typeof e.render==`function`&&e.render()}),t.forEach(e=>{if(e.closest(`mint-button`))return;let t=e.disabled;this._buttonStates.set(e,{disabled:t,loading:!1}),t||(e.disabled=!0)})}_restoreButtonsState(){if(!this._form)return;let e=this._isSubmittingAttrActive()&&(this._attrSubmittingMintButtons.size>0||this._attrSubmittingNativeButtons.size>0),t=Array.from(this.querySelectorAll(`mint-button`)),n=Array.from(this.querySelectorAll(`button`));t.forEach(t=>{if(e&&this._attrSubmittingMintButtons.has(t))return;let n=this._buttonStates.get(t);n&&(n.disabled?t.setAttribute(`disabled`,`true`):t.removeAttribute(`disabled`),n.loading?t.setAttribute(`loading`,`true`):t.removeAttribute(`loading`),typeof t.render==`function`&&t.render())}),n.forEach(t=>{if(t.closest(`mint-button`)||e&&this._attrSubmittingNativeButtons.has(t))return;let n=this._buttonStates.get(t);n&&(t.disabled=n.disabled)}),this._buttonStates.clear()}_isReactiveObject(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;if(`__v_isRef`in e||`_value`in e||`__v_raw`in e||`__v_isReactive`in e||`__ob__`in e)return!0;try{let t=e.toString();if(t===`[object Object]`||t.includes(`Proxy`)){let t=Object.keys(e)[0];if(t){let n=Object.getOwnPropertyDescriptor(e,t);if(n&&(n.get||n.set))return!0}}}catch{return!0}return!0}_createDataSnapshot(e){try{let t=this._extractReactiveData(e);return JSON.parse(JSON.stringify(t))}catch{return{...this._extractReactiveData(e)}}}_extractReactiveData(e){if(!e||typeof e!=`object`)return e;if(Array.isArray(e))return e.map(e=>this._extractReactiveData(e));let t=this._getReactiveValue(e);if(t&&typeof t==`object`&&!Array.isArray(t)){let e={};for(let n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=this._extractReactiveData(t[n]));return e}return t}_hasDataChanged(e,t){try{return JSON.stringify(e)!==JSON.stringify(t)}catch{return!0}}_getReactiveValue(e){if(!e||typeof e!=`object`)return e;if(`_value`in e||`__v_isRef`in e){if(e.value!==void 0)return e.value;if(`_value`in e)return e._value}return`__v_raw`in e||`__v_isReactive`in e||`__ob__`in e,e}_setupReactiveDataObserver(e){if(this._stopReactiveDataObserver(),!this.isConnected)return;let t=this._getReactiveValue(e);if(t&&typeof t==`object`&&!Array.isArray(t))this._lastDataSnapshot=this._createDataSnapshot(t);else{this._lastDataSnapshot=null;return}let n=()=>{if(!this._formData||!this._lastDataSnapshot){this._stopReactiveDataObserver();return}let e=this._getReactiveValue(this._formData);if(e&&typeof e==`object`&&!Array.isArray(e)){let t=this._createDataSnapshot(e);this._hasDataChanged(t,this._lastDataSnapshot)&&(this._lastDataSnapshot=t,requestAnimationFrame(()=>{this._applyFormData()}))}this.isConnected&&this._formData?this._reactiveDataObserver=requestAnimationFrame(n):this._stopReactiveDataObserver()};this._reactiveDataObserver=requestAnimationFrame(n)}_stopReactiveDataObserver(){this._reactiveDataObserver!==null&&(cancelAnimationFrame(this._reactiveDataObserver),this._reactiveDataObserver=null),this._reactiveDataProxy=null,this._lastDataSnapshot=null}};customElements.get(`mint-form`)||customElements.define(`mint-form`,T),typeof window<`u`&&(window.mintForm=window.mintForm||{defaults:{headers:{common:{}}},interceptors:{response:{handlers:[]}}},window.mintForm.interceptors.response.use||(window.mintForm.interceptors.response.use=function(e,t){return window.mintForm.interceptors.response.handlers.push({fulfilled:e,rejected:t}),window.mintForm.interceptors.response.handlers.length-1}));var E=class extends HTMLElement{constructor(...e){super(...e),this._observer=null}connectedCallback(){this.classList.add(`box-border`,`m-0`,`p-0`,`align-baseline`,`block`,`w-full`,`rounded-lg`,`border`,`border-gray-200`,`dark:border-mint-divider`),this.hasAttribute(`data-mint-rt-scroll-inner`)?this.classList.add(`min-w-0`,`overflow-x-visible`,`overflow-y-visible`):this.classList.add(`min-w-0`,`overflow-x-auto`),this._observeChanges(),this._applyStyles(),requestAnimationFrame(()=>{this._applyStyles(),setTimeout(()=>this._applyStyles(),0)})}disconnectedCallback(){this._observer&&=(this._observer.disconnect(),null)}_observeChanges(){this._observer=new MutationObserver(()=>this._applyStyles()),this._observer.observe(this,{childList:!0,subtree:!0,attributes:!1})}_applyStyles(){this._observer&&this._observer.disconnect();let e=Array.from(this.querySelectorAll(`table`));if(e.length===0){this._observer&&this._observeChanges();return}let t=e.find(e=>e.querySelector(`thead`))??e[0],n=e.find(e=>e.querySelector(`tbody`))??e[0];e.forEach(e=>{let t=!!e.closest(`[id^="mint-rt-vscroll-"]`),n=!!e.closest(`mint-resource-table[data-mint-rt-fixed-header]`),r=t||n,i=[`w-full`,r?`border-separate border-spacing-0`:`border-collapse`,`text-sm`,`font-medium`,...r?[]:[`overflow-hidden`]];this._setClasses(e,i)});let r=t.querySelector(`thead`);if(r){r.classList.add(`bg-[#F7F7F7]`,`dark:bg-mint-nav`);let e=r.querySelectorAll(`th`);e.forEach((t,n)=>{let r=t.querySelector(`mint-icon`),i=r?.getAttribute(`name`)||``,a=t.hasAttribute(`data-mint-rt-sortable`)||r!==null&&i!==`ellipsis`;this._setClasses(t,[`text-left`,`font-semibold`,`text-gray-900`,`dark:text-white`,`px-3`,`py-2`,`border-b`,`border-gray-200`,`dark:border-mint-divider`,`bg-[#F7F7F7]`,`dark:bg-mint-nav`]),a&&t.classList.add(`cursor-pointer`,`hover:bg-gray-100`,`dark:hover:bg-mint-hover`),n===0&&t.classList.add(`pl-3`),n===e.length-1&&t.classList.add(`pr-3`);let o=t.closest(`table`),s=o?.closest(`mint-resource-table`),c=!!s?.hasAttribute(`data-mint-rt-fixed-header`),l=!!s?.hasAttribute(`data-mint-rt-fixed-controls`);if(o?.closest(`[id^="mint-rt-vscroll-"]`)||c){let e=c&&l?`top-[var(--mint-rt-fixed-controls-h,0px)]`:`top-0`;t.classList.add(`sticky`,e,`z-30`,`bg-[#F7F7F7]`,`dark:bg-mint-nav`,`shadow-sm`)}})}let i=n.querySelector(`tbody`);if(i){let e=Array.from(i.querySelectorAll(`tr`)),t=!!n.closest(`[id^="mint-rt-vscroll-"]`)||!!n.closest(`mint-resource-table`)?.hasAttribute(`data-mint-rt-fixed-header`),r=e.findIndex(e=>e.getAttribute(`data-mint-rt-spacer`)===`bottom`);e.forEach((n,i)=>{let a=n.hasAttribute(`data-mint-rt-spacer`),o=n.hasAttribute(`data-row-clickable`);a||t?this._setClasses(n,[`bg-white`,`dark:bg-mint-canvas`]):this._setClasses(n,[`bg-white`,`dark:bg-mint-canvas`,`border-b`,`border-gray-200`,`dark:border-mint-divider`]),o&&!a&&n.classList.add(`cursor-pointer`,`hover:bg-gray-50`,`dark:hover:bg-mint-elevated`),!t&&i===e.length-1&&n.classList.remove(`border-b`);let s=n.querySelectorAll(`td`);s.forEach((o,c)=>{let l=[`text-gray-900`,`dark:text-gray-100`,`px-3`,`py-2`];if(t&&!a){let t=n.hasAttribute(`data-mint-rt-last-row`),a=r===-1&&i===e.length-1;!t&&!a&&l.push(`border-b`,`border-gray-200`,`dark:border-mint-divider`)}this._setClasses(o,l),c===0&&o.classList.add(`pl-3`),c===s.length-1&&o.classList.add(`pr-3`),this._restoreCell(o)})})}let a=n.querySelector(`tfoot`);a&&(this._setClasses(a,[`bg-[#F7F7F7]`,`dark:bg-mint-nav`,`font-semibold`]),a.querySelectorAll(`td`).forEach(e=>{this._setClasses(e,[`text-gray-900`,`dark:text-gray-100`,`px-3`,`py-2`,`border-t`,`border-gray-200`,`dark:border-mint-divider`]),this._restoreCell(e)})),this._observer&&this._observeChanges()}_restoreCell(e){if(e.dataset.mtProcessed!==`true`)return;let t={};Array.from(e.attributes).forEach(e=>{e.name.startsWith(`data-`)&&e.name!==`data-original`&&e.name!==`data-mt-processed`&&(t[e.name]=e.value)});let n=e.getAttribute(`data-original`)||``;e.dataset.mtProcessed=``,e.innerHTML=n,Object.entries(t).forEach(([t,n])=>{e.setAttribute(t,n)})}_setClasses(e,t){e.className=``,t.filter(Boolean).forEach(t=>e.classList.add(...t.split(` `)))}};customElements.get(`mint-table`)||customElements.define(`mint-table`,E);var D=class extends HTMLElement{constructor(...e){super(...e),this._root=null,this._textWrap=null,this._dismissBtn=null,this._clickHandler=null}static get observedAttributes(){return[`dismissable`]}connectedCallback(){this._render()}disconnectedCallback(){this._dismissBtn&&this._clickHandler&&this._dismissBtn.removeEventListener(`click`,this._clickHandler)}attributeChangedCallback(){this._render()}_render(){if(this.classList.add(`inline-flex`,`items-center`,`gap-2`,`px-3`,`py-1`,`rounded-full`,`border`,`border-gray-200`,`dark:border-mint-divider`,`bg-gray-100`,`dark:bg-mint-elevated`,`text-gray-900`,`dark:text-gray-100`,`text-sm`,`font-medium`),!this._root){for(this._root=document.createElement(`div`),this._root.className=`flex items-center gap-2 w-full`,this._textWrap=document.createElement(`span`),this._textWrap.className=`inline-flex items-center min-w-[0.5rem]`,this._textWrap.setAttribute(`data-mt-chip-text`,``);this.firstChild;){let e=this.firstChild;if(e===this._root)break;this._textWrap.appendChild(e)}this._root.appendChild(this._textWrap),this.appendChild(this._root)}let e=this.getAttribute(`dismissable`);e===``||e===`true`||this.hasAttribute(`dismissable`)?(this._dismissBtn||this._createDismissBtn(),this._dismissBtn&&!this._dismissBtn.isConnected&&this._root?.appendChild(this._dismissBtn)):this._dismissBtn&&this._dismissBtn.parentElement===this._root&&this._dismissBtn.remove()}_createDismissBtn(){let e=document.createElement(`button`);e.type=`button`,e.setAttribute(`aria-label`,`Dismiss`),e.className=[`shrink-0`,`inline-flex`,`items-center`,`justify-center`,`w-5`,`h-5`,`rounded-full`,`text-gray-500`,`dark:text-gray-300`,`hover:text-gray-700`,`dark:hover:text-gray-100`,`focus-visible:outline-none`,`focus-visible:ring-2`,`focus-visible:ring-offset-1`,`focus-visible:ring-gray-400`,`dark:focus-visible:ring-gray-500`,`border-none`,`bg-transparent`,`cursor-pointer`].join(` `);let t=document.createElement(`mint-icon`);t.setAttribute(`name`,`close`),t.className=`w-3 h-3`,e.appendChild(t),this._clickHandler=e=>{e.stopPropagation(),this.dispatchEvent(new CustomEvent(`dismiss`,{bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent(`dismissed`,{bubbles:!0,composed:!0})),this.remove()},e.addEventListener(`click`,this._clickHandler),this._dismissBtn=e}};customElements.get(`mint-chip`)||customElements.define(`mint-chip`,D);var O=class extends HTMLElement{constructor(...e){super(...e),this._container=null,this._chipsWrap=null,this._input=null,this._tags=[],this._placeholder=`Add tag`,this._dragIndex=null,this._dragChip=null,this._isPointerDragging=!1,this._pointerMoveHandler=null,this._pointerUpHandler=null}static get observedAttributes(){return[`tags`,`placeholder`,`sortable`,`label`,`info`,`error`,`error-message`,`name`,`id`,`required`,`loading`]}connectedCallback(){this._parseAttrs(),this._render(),this._pointerMoveHandler||(this._pointerMoveHandler=e=>this._onPointerMove(e),window.addEventListener(`pointermove`,this._pointerMoveHandler)),this._pointerUpHandler||(this._pointerUpHandler=e=>this._onPointerUp(e),window.addEventListener(`pointerup`,this._pointerUpHandler),window.addEventListener(`pointercancel`,this._pointerUpHandler))}attributeChangedCallback(e,t,n){if(t!==n){if(e===`error`||e===`error-message`){if(this._renderErrorState(),this._container){let e=this.hasError(),t=[`flex`,`flex-wrap`,`items-center`,`gap-2`,`w-full`,`px-2`,`py-1.5`,`min-h-[2rem]`,`rounded-lg`,`border-2`,e?`border-red-300 dark:border-red-300`:`border-gray-200 dark:border-mint-divider`,`bg-white`,`dark:bg-mint-elevated`,`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`];this._container.className=t.join(` `)}return}if(e===`loading`){this._parseAttrs(),this._render();return}this._parseAttrs(),this._render()}}set tags(e){this._tags=Array.isArray(e)?[...e]:[],this._syncAttr(),this._render()}get tags(){return[...this._tags]}_parseAttrs(){let e=this.getAttribute(`tags`);if(!e)return;try{let t=JSON.parse(e);Array.isArray(t)&&(this._tags=t)}catch(e){console.warn(`mint-tags: failed to parse tags attribute`,e)}let t=this.getAttribute(`placeholder`);t!==null&&(this._placeholder=t)}_syncAttr(){this.setAttribute(`tags`,JSON.stringify(this._tags))}getLabel(){return this.getAttribute(`label`)||``}getInfo(){return this.getAttribute(`info`)||``}hasError(){return this.getAttribute(`error`)===`true`}getErrorMessage(){return this.getAttribute(`error-message`)||``}getName(){return this.getAttribute(`name`)||``}getId(){return this.getAttribute(`id`)||``}isRequired(){return this.getAttribute(`required`)===`true`}isLoading(){return this.hasAttribute(`loading`)}_render(){this.classList.add(`box-border`,`m-0`,`p-0`,`border-0`,`align-baseline`,`block`,`w-full`);let e=this.isLoading(),t=this.getLabel(),n=this.getInfo(),r=this.hasError(),i=this.getId()||`mint-tags-${Math.random().toString(36).substr(2,9)}`;if(this.getId()||this.setAttribute(`id`,i),this._container)this._input&&(this._input.placeholder=this._placeholder);else{this._container=document.createElement(`div`);let e=[`flex`,`flex-wrap`,`items-center`,`gap-2`,`w-full`,`px-2`,`py-1`,`min-h-[2rem]`,`rounded-lg`,`border-2`,r?`border-red-300 dark:border-red-300`:`border-gray-200 dark:border-mint-divider`,`bg-white`,`dark:bg-mint-elevated`,`focus-within:ring-2`,`focus-within:ring-offset-1`,r?`focus-within:ring-red-400 dark:focus-within:ring-red-500`:`focus-within:ring-gray-400 dark:focus-within:ring-gray-500`];this._container.className=e.join(` `),this._chipsWrap=document.createElement(`div`),this._chipsWrap.className=`flex flex-wrap items-center gap-2`,this._chipsWrap.addEventListener(`dragover`,e=>{this.hasAttribute(`sortable`)&&e.preventDefault()}),this._chipsWrap.addEventListener(`drop`,e=>{this.hasAttribute(`sortable`)&&e.preventDefault()}),this._input=document.createElement(`input`),this._input.type=`text`,this._input.placeholder=this._placeholder,this._input.className=[`min-w-[6rem]`,`flex-1`,`bg-transparent`,`border-none`,`outline-none`,`text-sm`,`text-gray-900`,`dark:text-gray-100`,`placeholder:text-gray-400`,`dark:placeholder:text-gray-500`,`p-1.5`].join(` `),this._input.addEventListener(`keydown`,e=>{e.key===`Enter`&&(e.preventDefault(),this._addFromInput())}),this._container.appendChild(this._chipsWrap),this.appendChild(this._container)}if(this._container){let e=[`flex`,`flex-wrap`,`items-center`,`gap-2`,`w-full`,`px-2`,`py-1`,`min-h-[2rem]`,`rounded-lg`,`border-2`,r?`border-red-300 dark:border-red-300`:`border-gray-200 dark:border-mint-divider`,`bg-white`,`dark:bg-mint-elevated`,`focus-within:ring-2`,`focus-within:ring-offset-1`,r?`focus-within:ring-red-400 dark:focus-within:ring-red-500`:`focus-within:ring-gray-400 dark:focus-within:ring-gray-500`];this._container.className=e.join(` `)}let a=this.querySelector(`.mint-tags-label-container`);if(t){a||(a=document.createElement(`div`),a.className=`mint-tags-label-container mb-[.25rem]`,this._container&&this._container.parentElement===this?this.insertBefore(a,this._container):this.insertBefore(a,this.firstChild));let e=a.querySelector(`.mint-tags-label`);t?(e||(e=document.createElement(`label`),e.className=`mint-tags-label text-sm font-medium text-gray-900 dark:text-gray-100 select-none`,a.appendChild(e)),e.textContent=t,e.setAttribute(`for`,i)):e&&e.remove()}else a&&a.remove();let o=this.querySelector(`.mint-tags-info`);n?(o||(o=document.createElement(`span`),o.className=`mint-tags-info text-xs text-gray-500 dark:text-gray-400 select-none mt-1 block`,this._container&&this._container.parentElement===this?this.insertBefore(o,this._container.nextSibling):this.appendChild(o)),o.textContent=n):o&&o.remove();let s=this.getName();s?(this.setAttribute(`name`,s),this._input&&(this._input.name=s,this._input.id=i)):(this.removeAttribute(`name`),this._input&&(this._input.removeAttribute(`name`),this._input.id=i)),this._wireInputBackspace(),this._renderChips(),this._renderErrorState(),this._renderSkeleton(e)}_renderSkeleton(e){let t=this._container;if(!t)return;t.classList.contains(`relative`)||t.classList.add(`relative`);let n=t.querySelector(`.mint-tags-skeleton`);e?(n||(n=document.createElement(`div`),n.className=`mint-tags-skeleton absolute inset-0 z-10 pointer-events-none rounded-lg bg-gray-200 dark:bg-mint-hover animate-pulse`,t.appendChild(n)),n.style.display=`block`,this._chipsWrap&&(this._chipsWrap.style.visibility=`hidden`,this._chipsWrap.style.pointerEvents=`none`),this._input&&(this._input.style.visibility=`hidden`,this._input.style.pointerEvents=`none`)):(n&&(n.style.display=`none`),this._chipsWrap&&(this._chipsWrap.style.visibility=`visible`,this._chipsWrap.style.pointerEvents=`auto`),this._input&&(this._input.style.visibility=`visible`,this._input.style.pointerEvents=`auto`))}_renderErrorState(){let e=this.hasError(),t=this.getErrorMessage(),n=this.querySelector(`.mint-tags-error`);e&&t?(n||(n=document.createElement(`div`),n.className=`mint-tags-error mt-1 text-xs text-red-600 dark:text-red-400`,this.appendChild(n)),n.textContent=t):n&&n.remove()}_renderChips(){if(!this._chipsWrap)return;this._chipsWrap.innerHTML=``;let e=0;this._tags.forEach(t=>{let n=document.createElement(`mint-chip`);n.dataset.index=String(e++),n.dataset.value=t.value,n.draggable=this.hasAttribute(`sortable`),n.draggable&&n.classList.add(`cursor-move`),t.dismissable&&(n.setAttribute(`dismissable`,`true`),n.addEventListener(`dismissed`,()=>this._removeTag(t.value))),this._chipsWrap.appendChild(n);let r=n.querySelector(`[data-mt-chip-text]`);r&&(r.textContent=t.label||t.value),this._setupChipEvents(n,t),n.draggable&&(n.addEventListener(`dragstart`,e=>this._onDragStart(e,n)),n.addEventListener(`dragover`,e=>this._onDragOverChip(e,n)),n.addEventListener(`drop`,e=>this._onDrop(e)),n.addEventListener(`dragend`,()=>this._onDragEnd())),this.hasAttribute(`sortable`)&&n.addEventListener(`pointerdown`,e=>this._onPointerDown(e,n))}),this._input&&(this.hasAttribute(`sortable`)&&(this._input.addEventListener(`dragover`,e=>this._onDragOverInput(e)),this._input.addEventListener(`drop`,e=>this._onDrop(e)),this._input.addEventListener(`dragend`,()=>this._onDragEnd())),this._chipsWrap.appendChild(this._input))}_addFromInput(){if(!this._input)return;let e=this._input.value.trim();if(e){if(this._tags.some(t=>t.value.toLowerCase()===e.toLowerCase())){this._input.value=``;return}this._tags.push({value:e,label:e,dismissable:!0}),this._syncAttr(),this._renderChips(),this._emitChange(),this._input.value=``,setTimeout(()=>{this._input?.focus()},10)}}_removeTag(e){this._tags=this._tags.filter(t=>t.value!==e),this._syncAttr(),this._renderChips(),this._emitChange()}_emitChange(){this.dispatchEvent(new CustomEvent(`tags-change`,{bubbles:!0,composed:!0,detail:{tags:this.tags}}))}_focusLastChip(){let e=this._chipsWrap?.querySelectorAll(`mint-chip`);e&&e.length>0&&e[e.length-1].focus({preventScroll:!0})}_focusInput(){setTimeout(()=>{this._input?.focus({preventScroll:!0})},10)}_wireInputBackspace(){this._input&&this._input.addEventListener(`keydown`,e=>{e.key===`Backspace`&&this._input?.value===``&&(e.preventDefault(),this._focusLastChip())})}_setupChipEvents(e,t){e.tabIndex=0,e.addEventListener(`keydown`,e=>{(e.key===`Backspace`||e.key===`Delete`)&&t.dismissable&&(e.preventDefault(),this._removeTag(t.value),this._focusInput())})}_onDragStart(e,t){this.hasAttribute(`sortable`)&&(this._dragChip=t,this._dragIndex=Number(t.dataset.index),e.dataTransfer?.setData(`text/plain`,t.dataset.index||``),e.dataTransfer&&(e.dataTransfer.effectAllowed=`move`,e.dataTransfer.dropEffect=`move`),t.classList.add(`opacity-60`))}_reorderTags(e,t){if(e<0||t<0||e>=this._tags.length||t>=this._tags.length)return;let n=[...this._tags],[r]=n.splice(e,1);n.splice(t,0,r),this._tags=n,this._syncAttr(),this._renderChips(),this._emitChange()}_onDragOverInput(e){this.hasAttribute(`sortable`)&&(e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect=`move`),this._dragChip&&this._chipsWrap&&this._input&&this._chipsWrap.insertBefore(this._dragChip,this._input))}_onDragOverChip(e,t){if(!this.hasAttribute(`sortable`)||(e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect=`move`),!this._dragChip||!this._chipsWrap)||t===this._dragChip)return;let n=t.getBoundingClientRect();if(e.clientX<n.left+n.width*.5){if(this._dragChip.nextSibling===t)return;this._chipsWrap.insertBefore(this._dragChip,t)}else{if(t.nextSibling===this._dragChip)return;let e=t.nextSibling;e?this._chipsWrap.insertBefore(this._dragChip,e):this._chipsWrap.appendChild(this._dragChip)}}_onDrop(e){this.hasAttribute(`sortable`)&&e.preventDefault()}_onDragEnd(){this._dragChip&&this._dragChip.classList.remove(`opacity-60`),this._syncOrderFromDom(),this._dragChip=null,this._dragIndex=null}_syncOrderFromDom(){if(!this._chipsWrap)return;let e=Array.from(this._chipsWrap.querySelectorAll(`mint-chip`));if(e.length===0)return;let t=[];e.forEach(e=>{let n=e.dataset.value;if(!n)return;let r=this._tags.find(e=>e.value===n);r&&t.push(r)}),t.length===this._tags.length&&(this._tags=t,this._syncAttr(),this._renderChips(),this._emitChange())}_onPointerDown(e,t){if(this.hasAttribute(`sortable`)&&e.pointerType!==`mouse`){this._isPointerDragging=!0,this._dragChip=t,this._dragIndex=Number(t.dataset.index);try{t.setPointerCapture(e.pointerId)}catch{}t.classList.add(`opacity-60`,`select-none`),e.preventDefault()}}_onPointerMove(e){if(!this._isPointerDragging||!this._dragChip||!this._chipsWrap||e.pointerType===`mouse`)return;let t=document.elementFromPoint(e.clientX,e.clientY);if(!t)return;let n=t.closest(`mint-chip`);if(n&&n!==this._dragChip){let t=n.getBoundingClientRect();if(e.clientX<t.left+t.width*.5)this._dragChip.nextSibling!==n&&this._chipsWrap.insertBefore(this._dragChip,n);else if(n.nextSibling!==this._dragChip){let e=n.nextSibling;e?this._chipsWrap.insertBefore(this._dragChip,e):this._chipsWrap.appendChild(this._dragChip)}return}this._input&&t.closest(`input`)===this._input&&this._chipsWrap.insertBefore(this._dragChip,this._input)}_onPointerUp(e){if(this._isPointerDragging){if(this._isPointerDragging=!1,this._dragChip){try{this._dragChip.releasePointerCapture(e.pointerId)}catch{}this._dragChip.classList.remove(`opacity-60`,`select-none`)}this._syncOrderFromDom(),this._dragChip=null,this._dragIndex=null}}};customElements.get(`mint-tags`)||customElements.define(`mint-tags`,O);var k=class extends HTMLElement{constructor(...e){super(...e),this._clickHandler=null,this._keydownHandler=null}connectedCallback(){this._render(),this._setupEventListeners()}disconnectedCallback(){this._cleanupEventListeners()}_render(){this.classList.add(`focus-visible:outline-none`,`focus-visible:ring-2`,`focus-visible:ring-offset-1`,`focus-visible:ring-gray-400`,`dark:focus-visible:ring-gray-500`,`rounded`),this.getAttribute(`disabled`)===`true`?this.classList.add(`cursor-not-allowed`,`opacity-50`):this.classList.add(`cursor-pointer`),this.getAttribute(`role`)||this.setAttribute(`role`,`button`),this.getAttribute(`tabindex`)||this.setAttribute(`tabindex`,`0`)}_setupEventListeners(){this._clickHandler=e=>{if(this.getAttribute(`disabled`)===`true`){e.preventDefault(),e.stopPropagation();return}this._handleClick(e)},this._keydownHandler=e=>{if(e.key===`Enter`||e.key===` `){if(this.getAttribute(`disabled`)===`true`){e.preventDefault(),e.stopPropagation();return}e.preventDefault(),this._handleClick(e)}},this.addEventListener(`click`,this._clickHandler),this.addEventListener(`keydown`,this._keydownHandler)}_cleanupEventListeners(){this._clickHandler&&=(this.removeEventListener(`click`,this._clickHandler),null),this._keydownHandler&&=(this.removeEventListener(`keydown`,this._keydownHandler),null)}_handleClick(e){this.dispatchEvent(new CustomEvent(`clickable-click`,{bubbles:!0,composed:!0,detail:{originalEvent:e}}))}static get observedAttributes(){return[`disabled`]}attributeChangedCallback(e,t,n){e===`disabled`&&(n===`true`?(this.classList.remove(`cursor-pointer`),this.classList.add(`opacity-50`,`cursor-not-allowed`),this.setAttribute(`aria-disabled`,`true`)):(this.classList.remove(`opacity-50`,`cursor-not-allowed`),this.classList.add(`cursor-pointer`),this.removeAttribute(`aria-disabled`)))}};customElements.get(`mint-clickable`)||customElements.define(`mint-clickable`,k);var A=class extends HTMLElement{static get observedAttributes(){return[`heading`,`dismissable`,`tone`]}constructor(){super(),this._headingElement=null,this._iconElement=null,this._dismissButton=null,this._headerWrapper=null,this._bodyWrapper=null,this._dismissHandler=null}connectedCallback(){this.classList.add(`box-border`,`m-0`,`p-0`,`border-0`,`align-baseline`,`block`),this.render()}disconnectedCallback(){this._dismissButton&&this._dismissHandler&&this._dismissButton.removeEventListener(`click`,this._dismissHandler)}attributeChangedCallback(e,t,n){t!==n&&this.render()}getHeading(){return this.getAttribute(`heading`)||``}getTone(){let e=this.getAttribute(`tone`);return e===`info`||e===`success`||e===`warning`||e===`danger`?e:`info`}isDismissable(){return this.getAttribute(`dismissable`)===`true`}getIconName(){switch(this.getTone()){case`info`:return`info`;case`success`:return`success`;case`warning`:return`warning`;case`danger`:return`error`;default:return`info`}}getIconColorClasses(){switch(this.getTone()){case`info`:return`text-gray-700 dark:text-gray-300`;case`success`:return`text-green-600 dark:text-green-400`;case`warning`:return`text-yellow-600 dark:text-yellow-400`;case`danger`:return`text-red-600 dark:text-red-400`;default:return`text-gray-700 dark:text-gray-300`}}getHeadingColorClasses(){return`text-gray-900 dark:text-gray-100`}getHeaderBackgroundClasses(){switch(this.getTone()){case`info`:return`bg-gray-100 dark:bg-white/5`;case`success`:return`bg-green-100 dark:bg-green-900/30`;case`warning`:return`bg-yellow-100 dark:bg-yellow-900/30`;case`danger`:return`bg-red-100 dark:bg-red-900/30`;default:return`bg-gray-100 dark:bg-white/5`}}getBorderClasses(){switch(this.getTone()){case`info`:return`border-gray-200 dark:border-mint-divider`;case`success`:return`border-green-200 dark:border-green-800`;case`warning`:return`border-yellow-200 dark:border-yellow-800`;case`danger`:return`border-red-200 dark:border-red-800`;default:return`border-gray-200 dark:border-mint-divider`}}getAriaLive(){return this.getTone()===`danger`?`assertive`:`polite`}render(){let e=this.getTone(),t=this.getHeading(),n=this.isDismissable();this.className=`box-border m-0 p-0 border-0 align-baseline block rounded-lg border shadow-sm overflow-hidden ${this.getBorderClasses()}`;let r=this.getAriaLive();this.setAttribute(`role`,`alert`),this.setAttribute(`aria-live`,r),e===`danger`?this.setAttribute(`aria-atomic`,`true`):this.removeAttribute(`aria-atomic`);let i=[];for(this._bodyWrapper?Array.from(this._bodyWrapper.childNodes).forEach(e=>{i.push(e)}):Array.from(this.childNodes).forEach(e=>{e!==this._headerWrapper&&e!==this._bodyWrapper&&e!==this._iconElement&&e!==this._headingElement&&e!==this._dismissButton&&i.push(e)}),this._dismissButton&&this._dismissHandler&&this._dismissButton.removeEventListener(`click`,this._dismissHandler);this.firstChild;)this.removeChild(this.firstChild);if(this._headerWrapper=null,this._bodyWrapper=null,this._iconElement=null,this._headingElement=null,this._dismissButton=null,this._headerWrapper=document.createElement(`div`),this._headerWrapper.className=`px-4 py-3 flex items-center gap-3 ${this.getHeaderBackgroundClasses()}`,this._iconElement=document.createElement(`mint-icon`),this._iconElement.setAttribute(`name`,this.getIconName()),this._iconElement.className=`flex-shrink-0 w-5 h-5 ${this.getIconColorClasses()}`,this._headerWrapper.appendChild(this._iconElement),this._headingElement=document.createElement(`mint-text`),this._headingElement.className=`font-semibold flex-1 ${this.getHeadingColorClasses()}`,this._headingElement.textContent=t||``,this._headerWrapper.appendChild(this._headingElement),n){this._dismissButton=document.createElement(`button`),this._dismissButton.className=`flex-shrink-0 p-1 rounded hover:bg-black/10 dark:hover:bg-white/10`,this._dismissButton.setAttribute(`aria-label`,`Dismiss alert`),this._dismissButton.setAttribute(`type`,`button`);let e=document.createElement(`mint-icon`);e.setAttribute(`name`,`close`),e.className=`w-4 h-4 text-gray-700 dark:text-gray-300`,this._dismissButton.appendChild(e),this._dismissHandler=e=>{e.preventDefault(),e.stopPropagation(),this.dispatchEvent(new CustomEvent(`dismissed`,{bubbles:!0,composed:!0})),this.remove()},this._dismissButton.addEventListener(`click`,this._dismissHandler),this._headerWrapper.appendChild(this._dismissButton)}this._bodyWrapper=document.createElement(`div`),this._bodyWrapper.className=`px-4 py-3 bg-white dark:bg-mint-elevated`,i.forEach(e=>{this._bodyWrapper.appendChild(e)}),this.appendChild(this._headerWrapper),this.appendChild(this._bodyWrapper)}};customElements.get(`mint-alert`)||customElements.define(`mint-alert`,A);var j=class extends HTMLElement{static get observedAttributes(){return[`configuration`,`virtual-scroll`,`virtual-scroll-root`,`virtual-row-height`,`virtual-max-height`,`fixed-header`,`fixed-controls`]}constructor(){super(),this._configuration=null,this._rows=[],this._search=``,this._currentPage=1,this._perPage=15,this._totalRows=0,this._lastPage=0,this._offset=0,this._loaded=!1,this._fetching=!1,this._loading=!1,this._loadingPage=null,this._fetchError=null,this._searching=!1,this._sorting=!1,this._sortingColumn=null,this._type=`provided`,this._searchTimeoutId=null,this._sortTimeoutId=null,this._searchColumns=[],this._exportColumns={},this._columns=[],this._tableId=``,this._searchInput=null,this._tableContainer=null,this._paginationContainer=null,this._skeletonContainer=null,this._inMintCard=!1,this._virtualBodyScrollEl=null,this._virtualScrollHandler=null,this._virtualWindowRaf=null,this._virtualLastRangeStart=-1,this._virtualLastRangeEnd=-1,this._virtualLastRangeCacheSig=``,this._virtualResizeObserver=null,this._virtualWindowResizeHandler=null,this._virtualRowCache=new Map,this._virtualRangeFetching=!1,this._mobileListMql=null,this._boundMobileListMqlListener=null,this._virtualFetchGeneration=0,this._virtualAjaxPrefetchTimer=null,this._fixedChromeResizeObserver=null}get inMintCard(){return this._inMintCard}get configuration(){return this._configuration}set configuration(e){e&&typeof e==`object`&&!Array.isArray(e)?(this._configuration=e,this._tableId=this._configuration.id||`mint-resource-table-${Date.now()}`,this._perPage=this._configuration.perPage||15,this._type=typeof this._configuration.data==`string`?`ajax`:`provided`,this._loaded=!1,this._currentPage=1,this._offset=0,this._type===`provided`&&Array.isArray(this._configuration.data)&&(this._rows=[...this._configuration.data],this._totalRows=this._configuration.data.length),this._initializeColumns(),this.isConnected&&this.render()):e==null?this._configuration=null:this._parseConfiguration()}connectedCallback(){this.classList.add(`box-border`,`m-0`,`p-0`,`border-0`,`align-baseline`,`block`,`w-full`),this._inMintCard=this.parentElement?.tagName?.toLowerCase()===`mint-card`,this._configuration||this._parseConfiguration(),this._initializeColumns(),this._loadPageFromUrl(),this._attachRowClickHandler(),this.render()}disconnectedCallback(){this._searchTimeoutId&&clearTimeout(this._searchTimeoutId),this._detachVirtualScroll(),this._detachFixedChromeResize(),this._detachMobileListMql(),this._rowClickHandler&&=(this.removeEventListener(`click`,this._rowClickHandler,!0),null),this._scrollHandler&&=(window.removeEventListener(`scroll`,this._scrollHandler),null)}attributeChangedCallback(e,t,n){e===`configuration`&&t!==n?(!this._configuration||typeof n==`string`)&&(this._parseConfiguration(),this.render()):t!==n&&(e===`virtual-scroll`||e===`virtual-scroll-root`||e===`virtual-row-height`||e===`virtual-max-height`||e===`fixed-header`||e===`fixed-controls`)&&this._configuration&&this.isConnected&&this.render()}refresh(){this._configuration&&(this._type===`ajax`?this._fetchData(void 0,!0,this._perPage,this._offset):this.render())}_parseConfiguration(){let e=this.getAttribute(`configuration`);if(!e){console.error(`mint-resource-table: configuration attribute is required`);return}try{this._configuration=JSON.parse(e),this._tableId=this._configuration.id||`mint-resource-table-${Date.now()}`,this._perPage=this._configuration.perPage||15,this._type=typeof this._configuration.data==`string`?`ajax`:`provided`,this._loaded=!1,this._currentPage=this._getPageFromUrl()||1,this._offset=(this._currentPage-1)*this._perPage,this._type===`provided`&&Array.isArray(this._configuration.data)&&(this._rows=[...this._configuration.data],this._totalRows=this._configuration.data.length),this._initializeColumns()}catch(e){console.error(`mint-resource-table: Invalid configuration JSON`,e)}}_initializeColumns(){this._configuration&&(this._searchColumns=[],this._exportColumns={},this._columns=[],this._configuration.columns.forEach(e=>{e.searchable&&e.data&&this._searchColumns.push(e.data),e.export&&e.data&&(this._exportColumns[e.data]=e.label),e.data&&this._columns.push(e.data)}),this._configuration.sortBy||(this._configuration.sortBy=`id`),this._configuration.sort||(this._configuration.sort=`asc`))}async _fetchData(e,t=!0,n,r){if(!this._configuration)return;let i=e||(typeof this._configuration.data==`string`?this._configuration.data:null);if(!i||this._fetching||this._loading)return;t&&(this._fetching=!0,this._loaded?this._updatePagination():this.render()),this._loading=!0;let a=n||this._perPage,o=r===void 0?this._offset:r;this._virtualScrollActive()&&this._type===`ajax`&&o===0&&(this._virtualFetchGeneration++,this._virtualRowCache.clear(),this._virtualInvalidate());try{let e=new URLSearchParams({perPage:a.toString(),offset:o.toString(),search:this._search,sortBy:this._configuration.sortBy||`id`,sort:this._configuration.sort||`asc`,searchColumns:this._searchColumns.join(`,`),columns:this._columns.join(`,`)}),t={};this._configuration.headers&&(t.headers=this._configuration.headers);let n=await fetch(`${i}?${e.toString()}`,t);if(!n.ok)throw Error(`HTTP error! status: ${n.status}`);let r=await n.json(),s=r.content?.rows||[],c=r.content?.total||0,l=s;this._configuration.predefinedData?(l=[...this._configuration.predefinedData,...s],this._totalRows=c+this._configuration.predefinedData.length):this._totalRows=c,this._rows=l;let u=Math.floor(o/a)+1;r.content?.current_page!==void 0&&r.content.current_page===u?this._currentPage=r.content.current_page:this._currentPage=u,this._offset=(this._currentPage-1)*a,this._lastPage=r.content?.last_page||1,this._fetching=!1,this._loaded=!0,this._loading=!1,this._fetchError=null,this._searching=!1;let d=this._sorting;d&&this._updateSortIcons(),this._sorting=!1,this._sortingColumn=null,d&&this._updateSortIcons(),this.dispatchEvent(new CustomEvent(`loaded`,{detail:{rows:this._rows}})),this._updateSearchIcon();let f=`tbody[data-mint-rt-tbody="${this._tableId}"]`,p=!!this.querySelector(f);if(this._virtualScrollActive()&&this._type===`ajax`)p||this.render(),s.forEach((e,t)=>{this._virtualRowCache.set(o+t,e)}),this._virtualInvalidate(),o===0?queueMicrotask(()=>this._scrollVirtualTableTopIntoView()):this._scheduleVirtualWindowSync(),this._loadingPage,this._loadingPage=null,this._updatePagination(),setTimeout(()=>{let e=this._paginationMountedRoot();e&&e.querySelectorAll(`mint-button[data-action="page"]`).forEach(e=>{`render`in e&&typeof e.render==`function`&&e.render()})},0);else if(this.querySelector(`#${this._tableId}`)?.closest(`table`)?.querySelector(`tbody`)){if(d){let e=this._loading,t=this._fetching;this._loading=!1,this._fetching=!1,this._updateTableBody(),this._loading=e,this._fetching=t}else this._updateTableBody();this._loadingPage,this._loadingPage=null,this._updatePagination(),setTimeout(()=>{let e=this._paginationMountedRoot();e&&e.querySelectorAll(`mint-button[data-action="page"]`).forEach(e=>{`render`in e&&typeof e.render==`function`&&e.render()})},0)}else this.render()}catch(e){this._fetching=!1,this._loading=!1,this._loadingPage=null,this._loaded=!0,this._searching=!1,this._fetchError=e instanceof Error?e.message:`Failed to fetch data`,console.error(`mint-resource-table: Error fetching data`,e),this._updateSearchIcon(),this.querySelector(`#${this._tableId}`)?.closest(`table`)?.querySelector(`tbody`)?(this._updateTableBody(),this._loadingPage=null,this._updatePagination()):this.render()}}_getRows(){if(!this._configuration)return[];if(this._type===`ajax`)return this._rows;let e=[...this._rows],t=this._configuration.sortBy||`id`,n=this._configuration.sort||`asc`;if(this._search){let t=this._search.toLowerCase().trim().split(/\s+/);e=e.filter(e=>{let n=Object.values(e).map(e=>String(e).toLowerCase()).join(` `);return t.every(e=>n.includes(e))})}if(e.sort((e,r)=>{let i=e[t],a=r[t];if(i==null&&a==null)return 0;if(i==null)return 1;if(a==null)return-1;let o=typeof i==`number`?i:typeof i==`string`&&!isNaN(Number(i))&&i.trim()!==``?Number(i):null,s=typeof a==`number`?a:typeof a==`string`&&!isNaN(Number(a))&&a.trim()!==``?Number(a):null;if(o!==null&&s!==null){let e=o-s;return n===`asc`?e:-e}let c=i instanceof Date?i:typeof i==`string`?new Date(i):null,l=a instanceof Date?a:typeof a==`string`?new Date(a):null;if(c&&l&&!isNaN(c.getTime())&&!isNaN(l.getTime())){let e=c.getTime()-l.getTime();return n===`asc`?e:-e}let u=String(i).localeCompare(String(a),void 0,{numeric:!0,sensitivity:`base`});return n===`asc`?u:-u}),this._perPage){let t=Math.ceil(e.length/this._perPage);this._lastPage=t,e.forEach((e,t)=>{e.page=Math.ceil((t+1)/this._perPage)}),this._currentPage>t&&t>0&&(this._currentPage=t)}return e.filter(e=>!this._perPage||e.page===this._currentPage)}_getAllFilteredRowsSorted(){if(!this._configuration||this._type!==`provided`)return[];let e=[...this._rows],t=this._configuration.sortBy||`id`,n=this._configuration.sort||`asc`;if(this._search){let t=this._search.toLowerCase().trim().split(/\s+/);e=e.filter(e=>{let n=Object.values(e).map(e=>String(e).toLowerCase()).join(` `);return t.every(e=>n.includes(e))})}if(e.sort((e,r)=>{let i=e[t],a=r[t];if(i==null&&a==null)return 0;if(i==null)return 1;if(a==null)return-1;let o=typeof i==`number`?i:typeof i==`string`&&!isNaN(Number(i))&&i.trim()!==``?Number(i):null,s=typeof a==`number`?a:typeof a==`string`&&!isNaN(Number(a))&&a.trim()!==``?Number(a):null;if(o!==null&&s!==null){let e=o-s;return n===`asc`?e:-e}let c=i instanceof Date?i:typeof i==`string`?new Date(i):null,l=a instanceof Date?a:typeof a==`string`?new Date(a):null;if(c&&l&&!isNaN(c.getTime())&&!isNaN(l.getTime())){let e=c.getTime()-l.getTime();return n===`asc`?e:-e}let u=String(i).localeCompare(String(a),void 0,{numeric:!0,sensitivity:`base`});return n===`asc`?u:-u}),this._perPage){let t=Math.ceil(e.length/this._perPage);this._lastPage=t,e.forEach((e,t)=>{e.page=Math.ceil((t+1)/this._perPage)}),this._currentPage>t&&t>0&&(this._currentPage=t)}return e.filter(e=>!this._perPage||e.page===this._currentPage)}_virtualInvalidate(){this._virtualLastRangeStart=-1,this._virtualLastRangeEnd=-1,this._virtualLastRangeCacheSig=``}_getRowDataForEventIndex(e){if(this._configuration){if(!this._virtualScrollActive())return this._getRows()[e];if(this._type===`provided`)return this._getAllFilteredRowsSorted()[e];if(this._type===`ajax`)return this._virtualRowCache.get(e)}}getRowByIndex(e){return this._getRowDataForEventIndex(e)}_virtualScrollActive(){return this._configuration?(this.getAttribute(`virtual-scroll`)||``).toLowerCase().trim()===`true`:!1}_virtualScrollRoot(){let e=(this.getAttribute(`virtual-scroll-root`)||``).toLowerCase().trim();return e===`table-body`||e===`body`||this._configuration?.virtualScrollRoot===`table-body`?`table-body`:`document`}_virtualBodyScrollDisablesDocumentFixedChrome(){return this._virtualScrollActive()&&this._virtualScrollRoot()===`table-body`}_fixedHeader(){if(this._virtualBodyScrollDisablesDocumentFixedChrome()||!this.hasAttribute(`fixed-header`))return!1;let e=(this.getAttribute(`fixed-header`)||``).toLowerCase().trim();return e!==`false`&&e!==`0`}_fixedControls(){if(this._virtualBodyScrollDisablesDocumentFixedChrome()||!this.hasAttribute(`fixed-controls`))return!1;let e=(this.getAttribute(`fixed-controls`)||``).toLowerCase().trim();return e!==`false`&&e!==`0`}_virtualRowHeightPx(){let e=parseInt(this.getAttribute(`virtual-row-height`)||``,10);if(!isNaN(e)&&e>0)return e;let t=this._configuration?.virtualRowHeight;return typeof t==`number`&&t>0?t:48}_virtualRowHeightPxForSync(e){let t=this._virtualRowHeightPx();if(!this._configuration)return t;if(e){let e=this._mobileThumbnailColumn();if(e){let n=this._thumbnailMobilePx(e);return Math.max(t,n+36)}return Math.max(t,80)}let n=this._mobileThumbnailColumn();if(n){let e=this._thumbnailDesktopPx(n);return Math.max(t,e+28)}return t}_virtualMaxHeightCss(){let e=this.getAttribute(`virtual-max-height`);if(e&&e.trim())return e.trim();let t=this._configuration?.virtualMaxHeight;return t&&String(t).trim()?String(t).trim():`min(70dvh, 28rem)`}_virtualColspan(){return this._configuration?Math.max(1,this._configuration.columns.filter(e=>!e.hidden).length):1}_ensureMobileListMql(){typeof window>`u`||!window.matchMedia||this._mobileListMql||(this._mobileListMql=window.matchMedia(`(max-width: 767px)`),this._boundMobileListMqlListener=()=>{this._configuration&&this.isConnected&&this.render()},this._mobileListMql.addEventListener(`change`,this._boundMobileListMqlListener))}_detachMobileListMql(){this._mobileListMql&&this._boundMobileListMqlListener&&this._mobileListMql.removeEventListener(`change`,this._boundMobileListMqlListener),this._mobileListMql=null,this._boundMobileListMqlListener=null}_useMobileListLayout(){return!!this._mobileListMql?.matches}_paginationHostPlaceholderHtml(){if(!this._configuration?.perPage||this._virtualScrollActive())return``;let e=this._lastPage||Math.ceil(this._rows.length/this._perPage);if((this._lastPage>0?this._lastPage:e)<=1)return``;let t=[`mint-rt-pagination-host`,`w-full min-w-0 overflow-x-auto overflow-y-hidden overscroll-x-contain`,`flex justify-center [-webkit-overflow-scrolling:touch] md:justify-end`,this._inMintCard?`border-t border-gray-200 px-3.5 pb-3.5 pt-3 dark:border-mint-divider md:border-t-0 md:pt-0`:`border-t border-gray-200 px-2 py-3 dark:border-mint-divider md:border-t-0 md:py-0 md:mt-4`].join(` `);return`<div id="mint-rt-pagination-host-${this._tableId}" data-mint-rt-pagination-wrap="" class="${t}"></div>`}_getPaginationHostEl(){return this.querySelector(`#mint-rt-pagination-host-${this._tableId}`)}_paginationMountedRoot(){return this._getPaginationHostEl()||this.querySelector(`nav[data-mint-rt-pagination-nav]`)?.parentElement||this.querySelector(`nav`)?.closest(`.flex.justify-end`)}_paginationPageButtonLi(e){let t=this._currentPage===e,n=this._loadingPage===e;return`<li class="shrink-0"><mint-button variant="solid" size="sm"${t?` active="true"`:``}${this._loading||this._fetching?` disabled="true"`:``}${n?` loading="true"`:``} data-action="page" data-page="${e}">${n?``:`${e}`}</mint-button></li>`}_paginationHtmlCompactMiddle(e){let t=``,n=this._currentPage;if(e<=5){for(let n=1;n<=e;n++)t+=this._paginationPageButtonLi(n);return t}let r=[...new Set([1,e,n-1,n,n+1].map(t=>Math.min(e,Math.max(1,t))))].sort((e,t)=>e-t),i=0;for(let e of r)i>0&&e-i>1&&(t+=`<li class="shrink-0"><span class="px-1 text-gray-500 dark:text-gray-400" aria-hidden="true">…</span></li>`),t+=this._paginationPageButtonLi(e),i=e;return t}_paginationHtmlDesktopMiddle(e){let t=``,n=e>=10,r=Math.max(1,this._currentPage-1),i=Math.min(e,this._currentPage+1);if(n){for(let e=1;e<=3;e++)t+=this._paginationPageButtonLi(e);let n=i<=3,a=r>=e-2;if(!n&&!a){r>4&&(t+=`<li class="shrink-0"><span class="px-2">...</span></li>`);for(let e=r;e<=i;e++)e<=3||(t+=this._paginationPageButtonLi(e));i<e-3&&(t+=`<li class="shrink-0"><span class="px-2">...</span></li>`)}else (n&&!a||!n&&a&&e-2>4)&&(t+=`<li class="shrink-0"><span class="px-2">...</span></li>`);for(let o=e-2;o<=e;o++)o<=3||!n&&!a&&o>=r&&o<=i||(t+=this._paginationPageButtonLi(o))}else for(let n=1;n<=e;n++)t+=this._paginationPageButtonLi(n);return t}_buildPaginationNavMarkup(e){let t=this._currentPage===1||this._loading||this._fetching,n=`<nav data-mint-rt-pagination-nav="" class="w-max max-w-none shrink-0" aria-label="Pagination">`;n+=`<ul class="flex flex-nowrap items-center gap-1">`,n+=`<li class="shrink-0"><mint-button variant="solid" size="sm" icon="caret-left" ${t?`disabled="true"`:``} data-action="page-prev"></mint-button></li>`,n+=this._useMobileListLayout()?this._paginationHtmlCompactMiddle(e):this._paginationHtmlDesktopMiddle(e);let r=this._currentPage>=e||this._loading||this._fetching;return n+=`<li class="shrink-0"><mint-button variant="solid" size="sm" icon="caret-right" ${r?`disabled="true"`:``} data-action="page-next"></mint-button></li>`,n+=`</ul></nav>`,n}_hasSortableColumns(){return!!this._configuration?.columns.some(e=>!e.hidden&&e.sortable&&e.data)}_getMobileSortTriggerIconName(){return`sort-arrows`}_mobileSortPopoverAffordanceInnerHtml(e){return e===`spinner`?`<span class="inline-block h-4 w-4 shrink-0 animate-spin rounded-full border-2 border-gray-300 border-t-gray-700 dark:border-gray-600 dark:border-t-gray-200" aria-hidden="true"></span>`:e===`caret-up`||e===`caret-down`?`<mint-icon name="${e}" class="h-4 w-4 shrink-0 text-gray-500 dark:text-gray-400"></mint-icon>`:``}_buildMobileSortPopoverInnerHtml(){if(!this._configuration)return``;let e=`<div class="flex w-full min-w-[11rem] flex-col gap-0.5 p-1">`;return this._configuration.columns.forEach((t,n)=>{if(t.hidden||!t.sortable||!t.data)return;let r=t.raw?t.label:this._escapeHtml(t.label),i=this._getSortClass(t),a=this._mobileSortPopoverAffordanceInnerHtml(i),o=` type="button" variant="ghost" tone="neutral" size="sm" full-width="true" align="left" data-action="mobile-sort" data-column-key="${n}"`;e+=`<mint-button${o}>`,e+=`<span class="flex w-full min-w-0 flex-1 items-center justify-between gap-2">`,e+=`<span class="min-w-0 flex-1 truncate text-left">${r}</span>`,e+=`<span class="inline-flex shrink-0 items-center justify-end" data-mint-rt-mobile-sort-affordance="">${a}</span>`,e+=`</span></mint-button>`}),e+=`</div>`,e}_syncMobileSortPopoverIcons(){if(!this._configuration)return;let e=this.querySelector(`#mint-rt-mobile-sort-popover-${this._tableId}`);e&&this._configuration.columns.forEach((t,n)=>{if(t.hidden||!t.sortable||!t.data)return;let r=e.querySelector(`[data-action="mobile-sort"][data-column-key="${n}"]`);if(!r||r.tagName!==`MINT-BUTTON`)return;let i=r.querySelector(`[data-mint-rt-mobile-sort-affordance]`);if(!i)return;let a=this._getSortClass(t);i.innerHTML=this._mobileSortPopoverAffordanceInnerHtml(a),i.querySelectorAll(`mint-icon`).forEach(e=>{let t=e;typeof t.render==`function`&&t.render()})})}_closeMobileSortPopover(){let e=this.querySelector(`#mint-rt-mobile-sort-popover-${this._tableId}`);e&&typeof e.close==`function`?e.close():e&&e.removeAttribute(`open`)}_buildMobileSortToolbarHtml(){if(!this._hasSortableColumns())return``;let e=`mint-rt-mobile-sort-btn-${this._tableId}`,t=`mint-rt-mobile-sort-popover-${this._tableId}`,n=this._sorting?` loading="true"`:``,r=` icon="${this._escapeHtml(this._getMobileSortTriggerIconName())}"`,i=`<div class="flex shrink-0 items-center md:hidden">`;return i+=`<mint-button id="${e}" data-mint-rt-toolbar="mobile-sort" variant="solid" tone="neutral" size="sm"${n}${r}></mint-button>`,i+=`<mint-popover id="${t}" trigger-id="${e}" direction="down" padding="0">`,i+=this._buildMobileSortPopoverInnerHtml(),i+=`</mint-popover></div>`,i}_stripHtml(e){if(!e)return``;let t=document.createElement(`div`);return t.innerHTML=e,(t.textContent||t.innerText||``).replace(/\s+/g,` `).trim()}_visibleDataColumns(){return this._configuration?this._configuration.columns.filter(e=>!e.hidden):[]}_mobileThumbnailColumn(){return this._visibleDataColumns().find(e=>e.thumbnail)||null}_thumbnailDesktopPx(e){let t=typeof e.thumbnailDesktopPx==`number`&&e.thumbnailDesktopPx>0?e.thumbnailDesktopPx:void 0,n=this._configuration,r=n&&typeof n.thumbnailDesktopPx==`number`&&n.thumbnailDesktopPx>0?n.thumbnailDesktopPx:void 0;return Math.round(t??r??40)}_thumbnailMobilePx(e){let t=typeof e.thumbnailMobilePx==`number`&&e.thumbnailMobilePx>0?e.thumbnailMobilePx:void 0,n=this._configuration,r=n&&typeof n.thumbnailMobilePx==`number`&&n.thumbnailMobilePx>0?n.thumbnailMobilePx:void 0;return Math.round(t??r??56)}_wrapThumbnailDesktopBox(e,t){let n=this._thumbnailDesktopPx(t);return`<div class="flex shrink-0 items-stretch overflow-hidden rounded-md border border-gray-200 bg-gray-100 p-0 dark:border-mint-divider dark:bg-mint-hover [&>*]:m-0 [&>*]:min-h-0 [&>*]:min-w-0 [&>*]:w-full [&>*]:max-w-full [&>*]:p-0 [&>span]:flex [&>span]:h-full [&>span]:w-full [&>span]:min-h-0 [&>span]:min-w-0 [&>span]:items-stretch [&>span]:justify-stretch [&_img]:!m-0 [&_img]:!box-border [&_img]:!block [&_img]:!h-full [&_img]:!w-full [&_img]:!min-h-0 [&_img]:!min-w-0 [&_img]:!max-h-full [&_img]:!max-w-full [&_img]:!border-0 [&_img]:!p-0 [&_img]:!rounded-none [&_img]:!object-cover [&_img]:!object-center" style="${`width:${n}px;height:${n}px;min-width:${n}px;min-height:${n}px`}">${e}</div>`}_mobilePrimaryColumn(){let e=this._visibleDataColumns();return e.find(e=>e.primary)||e.find(e=>(e.data||typeof e.format==`function`)&&!e.thumbnail&&!e.actions)||e[0]||null}_mobileActionsDropdownColumn(){return this._visibleDataColumns().find(e=>e.actions&&e.actionStyle!==`buttons`)||null}_columnPlainSummaryText(e,t){if(!(!e.show||e.show(this,t))||e.actions||e.action)return``;try{if(e.raw){if(typeof e.format==`function`)return this._stripHtml(e.format(this,t));if(e.data)return String(t[e.data]??``)}else{if(typeof e.format==`function`)return this._stripHtml(e.format(this,t));if(e.data)return String(t[e.data]??``)}}catch{return``}return``}_buildTableCellInnerHtml(e,t,n,r=`table`){if(!this._configuration)return``;let i=n,a=``;if(!(!e.show||e.show(this,t)))return``;if(e.raw)if(e.action){if(!e.action.show||e.action.show(this,t)){let n=typeof e.action.label==`function`?e.action.label(this,t):e.action.label;a+=`<mint-button variant="solid" data-action="column-action" data-row-index="${i}" data-column-key="${this._configuration.columns.indexOf(e)}">${this._escapeHtml(String(n))}</mint-button>`}}else if(e.actions)if(e.actionStyle!==`buttons`){let n=`actions-popover-${this._tableId}-${i}`,r=`actions-button-${this._tableId}-${i}`;a+=`<mint-button id="${r}" variant="link" icon="ellipsis">`,a+=`</mint-button>`,a+=`<mint-popover id="${n}" trigger-id="${r}" direction="down">`,e.actions.forEach((n,r)=>{if(!n.show||n.show(this,t)){let o=typeof n.label==`function`?n.label(this,t):n.label;a+=`<div class="p-2 cursor-pointer hover:bg-gray-100 dark:hover:bg-mint-hover" data-action="row-action" data-row-index="${i}" data-action-index="${r}" data-column-key="${this._configuration.columns.indexOf(e)}">${this._escapeHtml(String(o))}</div>`}}),a+=`</mint-popover>`}else e.actions.forEach((n,r)=>{if(!n.show||n.show(this,t)){let o=n.label?typeof n.label==`function`?n.label(this,t):n.label:``,s=n.icon?` icon="${this._escapeHtml(n.icon)}"`:``,c=n.tone?` tone="${this._escapeHtml(n.tone)}"`:``;a+=`<mint-button variant="link" class="${n.classes||``}" data-action="row-action" data-row-index="${i}" data-action-index="${r}" data-column-key="${this._configuration.columns.indexOf(e)}"${s}${c}>`,o&&(a+=this._escapeHtml(String(o))),a+=`</mint-button>`}});else typeof e.format==`function`?a+=e.format(this,t):e.data&&(a+=this._escapeHtml(String(t[e.data]||``)));else if(e.action)(!e.action.show||e.action.show(this,t))&&(a+=`<mint-button variant="solid" data-action="column-action" data-row-index="${i}" data-column-key="${this._configuration.columns.indexOf(e)}">${e.action.label}</mint-button>`);else if(e.actions)if(e.actionStyle!==`buttons`){let n=`actions-popover-${this._tableId}-${i}`,r=`actions-button-${this._tableId}-${i}`;a+=`<mint-button id="${r}" variant="link" icon="ellipsis">`,a+=`</mint-button>`,a+=`<mint-popover id="${n}" trigger-id="${r}" direction="down">`,e.actions.forEach((n,r)=>{if(!n.show||n.show(this,t)){let o=typeof n.label==`function`?n.label(this,t):n.label;a+=`<div class="p-2 cursor-pointer hover:bg-gray-100 dark:hover:bg-mint-hover" data-action="row-action" data-row-index="${i}" data-action-index="${r}" data-column-key="${this._configuration.columns.indexOf(e)}">${this._escapeHtml(String(o))}</div>`}}),a+=`</mint-popover>`}else e.actions.forEach((n,r)=>{if(!n.show||n.show(this,t)){let o=n.label?typeof n.label==`function`?n.label(this,t):n.label:``,s=n.icon?` icon="${this._escapeHtml(n.icon)}"`:``,c=n.tone?` tone="${this._escapeHtml(n.tone)}"`:``;a+=`<mint-button variant="link" class="${n.classes||``}" data-action="row-action" data-row-index="${i}" data-action-index="${r}" data-column-key="${this._configuration.columns.indexOf(e)}"${s}${c}>`,o&&(a+=this._escapeHtml(String(o))),a+=`</mint-button>`}});else typeof e.format==`function`?a+=this._escapeHtml(e.format(this,t)):e.data&&(a+=this._escapeHtml(String(t[e.data]||``)));return r===`table`&&e.thumbnail&&a&&!e.actions&&!e.action?this._wrapThumbnailDesktopBox(a,e):a}_buildMobileListItemHtml(e,t,n,r=!1){if(!this._configuration)return``;let i=t,a=typeof this._configuration.onRowClick==`function`,o=this._mobileThumbnailColumn(),s=this._mobilePrimaryColumn(),c=this._mobileActionsDropdownColumn(),l=o?this._buildTableCellInnerHtml(o,e,i,`mobile`):``,u=s?this._buildTableCellInnerHtml(s,e,i,`mobile`):``,d=c?this._buildTableCellInnerHtml(c,e,i,`mobile`):``,f=[];for(let t of this._configuration.columns){if(t.hidden||o&&t===o||s&&t===s||c&&t===c)continue;let n=this._columnPlainSummaryText(t,e);n&&f.push(this._escapeHtml(n))}let p=f.join(`<span class="text-gray-300 dark:text-gray-600" aria-hidden="true"> · </span>`),m=[`list-none`,...r?[]:[`border-b`,`border-gray-200`,`dark:border-mint-divider`],`bg-white`,`dark:bg-mint-canvas`,a?`cursor-pointer hover:bg-gray-50 dark:hover:bg-mint-elevated`:``].filter(Boolean).join(` `),h=`<div class="flex items-center gap-3 py-3 pr-4${o?` pl-0`:` pl-4`}">`;if(o){let e=this._thumbnailMobilePx(o),t=`width:${e}px;height:${e}px;min-width:${e}px;min-height:${e}px`;h+=`<div class="flex shrink-0 items-stretch overflow-hidden rounded-md border border-gray-200 bg-gray-100 p-0 dark:border-mint-divider dark:bg-mint-hover [&>*]:m-0 [&>*]:min-h-0 [&>*]:min-w-0 [&>*]:w-full [&>*]:max-w-full [&>*]:p-0 [&>span]:flex [&>span]:h-full [&>span]:w-full [&>span]:min-h-0 [&>span]:min-w-0 [&>span]:items-stretch [&>span]:justify-stretch [&_img]:!m-0 [&_img]:!box-border [&_img]:!block [&_img]:!h-full [&_img]:!w-full [&_img]:!min-h-0 [&_img]:!min-w-0 [&_img]:!max-h-full [&_img]:!max-w-full [&_img]:!border-0 [&_img]:!p-0 [&_img]:!rounded-none [&_img]:!object-cover [&_img]:!object-center" style="${t}">${l}</div>`}h+=`<div class="flex min-w-0 flex-1 flex-col justify-center gap-1">`,h+=`<div class="flex items-start justify-between gap-2">`,h+=`<div class="min-w-0 text-sm font-semibold leading-snug text-gray-900 dark:text-white">${u}</div>`,d&&(h+=`<div class="shrink-0 -mr-1">${d}</div>`),h+=`</div>`,p&&(h+=`<div class="text-xs font-normal leading-snug text-gray-500 dark:text-gray-400">${p}</div>`),h+=`</div></div>`;let g=typeof n==`number`&&n>0?` style="box-sizing:border-box;min-height:${n}px;max-height:${n}px;height:${n}px;overflow:hidden"`:``;return`<li data-row-index="${i}" ${a?`data-row-clickable="true" `:``}class="${m}"${g}>${h}</li>`}_buildMobileListPlaceholderLi(e,t,n=!1){let r=this._mobileThumbnailColumn(),i=r?this._thumbnailMobilePx(r):56,a=`width:${i}px;height:${i}px;min-width:${i}px;min-height:${i}px`;return`<li data-row-index="${e}" data-mint-rt-placeholder="true" class="list-none${n?``:` border-b border-gray-200 dark:border-mint-divider`} bg-white dark:bg-mint-canvas" style="box-sizing:border-box;min-height:${t}px;max-height:${t}px;height:${t}px;overflow:hidden"><div class="flex h-full min-h-0 items-center gap-3 py-3 pl-0 pr-4"><div class="shrink-0 overflow-hidden rounded-md bg-gray-200 dark:bg-white/15" style="${a}"></div><div class="flex min-h-0 min-w-0 flex-1 flex-col justify-center gap-1 py-0.5"><div class="h-4 w-40 rounded bg-gray-200 dark:bg-white/15"></div><div class="h-3 w-full max-w-xs rounded bg-gray-200 dark:bg-white/15"></div></div></div></li>`}_renderColgroupHtml(){if(!this._configuration)return``;let e=this._configuration.columns.filter(e=>!e.hidden),t=[],n=0;for(let r of e){let e=r.width==null?``:String(r.width).trim();e?/^\d+(\.\d+)?$/.test(e)?(n+=parseFloat(e),t.push(`px`)):t.push(`lit`):t.push(`flex`)}let r=t.filter(e=>e===`flex`).length,i=t.includes(`lit`),a=``;r>0&&!i&&(a=n>0?`width:calc((100% - ${n}px) / ${r});min-width:0`:`width:${100/r}%;min-width:0`);let o=`<colgroup>`;return e.forEach((e,n)=>{let r=e.width==null?``:String(e.width).trim(),i=t[n],s=``;i===`px`?s=` style="width:${r}px;min-width:0"`:i===`lit`?s=` style="width:${this._escapeHtml(r)};min-width:0"`:a&&(s=` style="${a}"`),o+=`<col${s} />`}),o+=`</colgroup>`,o}_buildDataRowHtml(e,t,n,r=!1){if(!this._configuration)return``;let i=t,a=n,o=`box-sizing:border-box;min-height:${a}px;max-height:${a}px;height:${a}px;overflow:hidden`,s=``,c=typeof this._configuration.onRowClick==`function`,l=c?`cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800`:``,u=c?` data-row-clickable="true"`:``,d=l?` class="${l}"`:``;return s+=`<tr data-row-index="${i}"${r?` data-mint-rt-last-row=""`:``}${u}${d} style="${o}">`,this._configuration.columns.forEach(t=>{if(t.hidden)return;let n=!t.show||t.show(this,e),r=`${this._getStyle(t)}box-sizing:border-box;max-height:${a}px;overflow:hidden;vertical-align:middle;`;s+=`<td style="${r}" class="${this._getClasses(t,!0)}">`,s+=n?this._buildTableCellInnerHtml(t,e,i):``,s+=`</td>`}),s+=`</tr>`,s}_getVirtualRowCount(){return!this._virtualScrollActive()||!this._configuration?0:this._type===`provided`?this._getAllFilteredRowsSorted().length:this._type===`ajax`?this._totalRows:0}_getVirtualRowAt(e){return this._type===`provided`?this._getAllFilteredRowsSorted()[e]??null:this._type===`ajax`&&this._virtualRowCache.has(e)?this._virtualRowCache.get(e):null}_buildVirtualPlaceholderRowHtml(e,t,n=!1){if(!this._configuration)return``;let r=t,i=`box-sizing:border-box;min-height:${r}px;max-height:${r}px;height:${r}px;overflow:hidden`,a=`<tr data-row-index="${e}" data-mint-rt-placeholder="true"${n?` data-mint-rt-last-row=""`:``} class="bg-white dark:bg-mint-canvas" style="${i}">`;return this._configuration.columns.forEach(e=>{if(e.hidden)return;let t=`${this._getStyle(e)}box-sizing:border-box;max-height:${r}px;height:${r}px;overflow:hidden;vertical-align:middle;line-height:0;`;if(a+=`<td style="${t}" class="${this._getClasses(e,!0)}">`,e.thumbnail){let t=this._thumbnailDesktopPx(e);a+=`<div class="rounded-md bg-gray-200 dark:bg-white/15" style="width:${t}px;height:${t}px;max-width:100%;box-sizing:border-box"></div>`}else a+=`<div class="h-4 max-w-[95%] rounded bg-gray-200 dark:bg-white/15"></div>`;a+=`</td>`}),a+=`</tr>`,a}_virtualScrollStickyOverlapPx(e){let t=0;if(this._fixedControls()){let e=this.querySelector(`#mint-rt-fixed-controls-${this._tableId}`);if(e)t+=Math.ceil(e.getBoundingClientRect().height);else{let e=getComputedStyle(this).getPropertyValue(`--mint-rt-fixed-controls-h`).trim(),n=parseFloat(e);isNaN(n)||(t+=Math.ceil(n))}}if(this._fixedHeader()&&e){let n=e.querySelector(`thead`);n&&(t+=Math.ceil(n.getBoundingClientRect().height))}return t}_scrollVirtualTableTopIntoView(){if(!this._virtualScrollActive()||!this.isConnected)return;if(this._virtualScrollRoot()===`table-body`){let e=this._virtualBodyScrollEl?.isConnected?this._virtualBodyScrollEl:this.querySelector(`#mint-rt-vscroll-${this._tableId}`),t=this._useMobileListLayout()&&e?e.querySelector(`ul[data-mint-rt-mobile-list="${this._tableId}"]`):null,n=e?.querySelector(`mint-table.table-section`)||e?.querySelector(`mint-table`),r=n?.querySelector(`#${this._tableId}`)?.closest(`table`)||n?.querySelector(`table`),i=this._virtualScrollStickyOverlapPx(r),a=t||n;if(a&&i>0){let e=a.getBoundingClientRect(),t=window.scrollY+e.top-i;window.scrollTo({top:Math.max(0,t),behavior:`auto`})}e&&(e.scrollTop=0,this._virtualBodyScrollEl=e,this._virtualInvalidate(),this._scheduleVirtualWindowSync());return}let e=this.querySelector(`ul[data-mint-rt-mobile-list="${this._tableId}"]`),t=this.querySelector(`mint-table.table-section`),n=this.querySelector(`#${this._tableId}`)?.closest(`table`)||t?.querySelector(`table`),r=this._useMobileListLayout()&&e?e:t||n;if(!r)return;let i=this._virtualScrollStickyOverlapPx(n),a=r.getBoundingClientRect(),o=window.scrollY+a.top-i;window.scrollTo({top:Math.max(0,o),behavior:`auto`}),this._virtualInvalidate(),this._scheduleVirtualWindowSync()}_scheduleVirtualWindowSync(){this._virtualScrollActive()&&this._virtualWindowRaf===null&&(this._virtualWindowRaf=window.requestAnimationFrame(()=>{this._virtualWindowRaf=null,this._syncVirtualWindow()}))}_syncVirtualWindow(){if(!this._virtualScrollActive()||!this._configuration)return;let e=this._useMobileListLayout(),t=this.querySelector(`tbody[data-mint-rt-tbody="${this._tableId}"]`),n=this.querySelector(`ul[data-mint-rt-mobile-list="${this._tableId}"]`),r=e?n:t;if(!r)return;let i=this._getVirtualRowCount(),a=this._virtualRowHeightPxForSync(e),o=this._virtualColspan();if(i===0){e?this._fetchError?r.innerHTML=`<li class="list-none px-4 py-8 text-center text-sm text-red-500 dark:text-red-400">Failed to load data: ${this._escapeHtml(this._fetchError)}</li>`:r.innerHTML=`<li class="list-none px-4 py-8 text-center text-sm">No records found.</li>`:this._fetchError?r.innerHTML=`<tr><td colspan="${o}" class="text-center py-8 text-red-500 dark:text-red-400">Failed to load data: ${this._escapeHtml(this._fetchError)}</td></tr>`:r.innerHTML=`<tr><td colspan="${o}" class="text-center py-8">No records found.</td></tr>`,this._virtualLastRangeStart=-1,this._virtualLastRangeEnd=-1,this._virtualLastRangeCacheSig=``;return}let s=0,c=window.innerHeight;if(this._virtualScrollRoot()===`table-body`){let e=this._virtualBodyScrollEl;if((!e||!e.isConnected)&&(e=this.querySelector(`#mint-rt-vscroll-${this._tableId}`),this._virtualBodyScrollEl=e),!e)return;s=e.scrollTop,c=e.clientHeight||400}else{let e=r.getBoundingClientRect();s=Math.max(0,-e.top)}let l=Math.min(Math.max(0,Math.floor(s/a)),Math.max(0,i-1)),u=Math.ceil(c/a)+16,d=Math.max(0,l-8),f=Math.min(i,l+u),p=``;if(this._type===`ajax`)for(let e=d;e<f;e++)p+=this._virtualRowCache.has(e)?`1`:`0`;if(d===this._virtualLastRangeStart&&f===this._virtualLastRangeEnd&&(this._type!==`ajax`||p===this._virtualLastRangeCacheSig))return;this._virtualLastRangeStart=d,this._virtualLastRangeEnd=f,this._virtualLastRangeCacheSig=p;let m=d*a,h=Math.max(0,(i-f)*a),g=``;if(e){g+=`<li aria-hidden="true" class="pointer-events-none m-0 block list-none border-0 p-0" style="height:${m}px"></li>`;for(let e=d;e<f;e++){let t=this._getVirtualRowAt(e),n=i>0&&e===i-1;t?g+=this._buildMobileListItemHtml(t,e,a,n):g+=this._buildMobileListPlaceholderLi(e,a,n)}g+=`<li aria-hidden="true" class="pointer-events-none m-0 block list-none border-0 p-0" style="height:${h}px"></li>`}else{g+=`<tr data-mint-rt-spacer="top" aria-hidden="true"><td colspan="${o}" style="height:${m}px;padding:0;border:0;line-height:0;font-size:0"></td></tr>`;for(let e=d;e<f;e++){let t=this._getVirtualRowAt(e),n=i>0&&e===i-1;t?g+=this._buildDataRowHtml(t,e,a,n):g+=this._buildVirtualPlaceholderRowHtml(e,a,n)}g+=`<tr data-mint-rt-spacer="bottom" aria-hidden="true"><td colspan="${o}" style="height:${h}px;padding:0;border:0;line-height:0;font-size:0"></td></tr>`}if(r.innerHTML=g,this.querySelectorAll(`tbody[data-mint-rt-tbody="${this._tableId}"] mint-button[data-action], ul[data-mint-rt-mobile-list="${this._tableId}"] mint-button[data-action]`).forEach(e=>{e.render&&e.render()}),this._attachTableEventListeners(),this._attachRowClickHandler(),this._type===`ajax`&&this._virtualScrollActive()&&this._scheduleVirtualAjaxPrefetch(d,f),this._virtualScrollRoot()===`table-body`&&!e){let e=this._virtualBodyScrollEl;e?.isConnected&&requestAnimationFrame(()=>{if(!e.isConnected)return;let t=Math.max(0,e.scrollHeight-e.clientHeight);e.scrollTop>t&&(e.scrollTop=t)})}}_detachVirtualScroll(){this._virtualScrollHandler&&=(window.removeEventListener(`scroll`,this._virtualScrollHandler),this._virtualBodyScrollEl?.removeEventListener(`scroll`,this._virtualScrollHandler),null),this._virtualWindowResizeHandler&&=(window.removeEventListener(`resize`,this._virtualWindowResizeHandler),null),this._virtualResizeObserver&&=(this._virtualResizeObserver.disconnect(),null),this._virtualBodyScrollEl=null,this._virtualWindowRaf!==null&&(window.cancelAnimationFrame(this._virtualWindowRaf),this._virtualWindowRaf=null),this._virtualLastRangeStart=-1,this._virtualLastRangeEnd=-1,this._virtualLastRangeCacheSig=``,this._virtualAjaxPrefetchTimer!==null&&(window.clearTimeout(this._virtualAjaxPrefetchTimer),this._virtualAjaxPrefetchTimer=null),this._virtualRangeFetching=!1}_scheduleVirtualAjaxPrefetch(e,t){if(this._type!==`ajax`||!this._virtualScrollActive()||!this._configuration)return;let n=!1;for(let r=e;r<t;r++)if(!this._virtualRowCache.has(r)){n=!0;break}if(!n)return;this._virtualAjaxPrefetchTimer!==null&&window.clearTimeout(this._virtualAjaxPrefetchTimer);let r=e,i=t;this._virtualAjaxPrefetchTimer=window.setTimeout(()=>{this._virtualAjaxPrefetchTimer=null,this._fetchVirtualAjaxRange(r,i-r)},60)}async _fetchVirtualAjaxRange(e,t){if(!this._configuration||this._type!==`ajax`||!this._virtualScrollActive())return;let n=typeof this._configuration.data==`string`?this._configuration.data:null;if(!n||t<=0||this._virtualRangeFetching||e<0||e>=this._totalRows)return;this._virtualRangeFetching=!0;let r=this._virtualFetchGeneration,i=Math.min(e,Math.max(0,this._totalRows-1)),a=Math.min(150,Math.max(this._perPage,t,15),Math.max(1,this._totalRows-i));try{let e=new URLSearchParams({perPage:a.toString(),offset:i.toString(),search:this._search,sortBy:this._configuration.sortBy||`id`,sort:this._configuration.sort||`asc`,searchColumns:this._searchColumns.join(`,`),columns:this._columns.join(`,`)}),t={};this._configuration.headers&&(t.headers=this._configuration.headers);let o=await fetch(`${n}?${e.toString()}`,t);if(!o.ok)throw Error(`HTTP error! status: ${o.status}`);let s=await o.json();if(r!==this._virtualFetchGeneration)return;(s.content?.rows||[]).forEach((e,t)=>{let n=i+t;n<this._totalRows&&this._virtualRowCache.set(n,e)})}catch(e){console.error(`mint-resource-table: virtual range fetch failed`,e)}finally{this._virtualRangeFetching=!1,r===this._virtualFetchGeneration&&(this._virtualInvalidate(),this._scheduleVirtualWindowSync())}}_detachFixedChromeResize(){this._fixedChromeResizeObserver?.disconnect(),this._fixedChromeResizeObserver=null,this.style.removeProperty(`--mint-rt-fixed-controls-h`)}_syncFixedControlsChromeHeight(){if(!this._fixedHeader()||!this._fixedControls())return;this._fixedChromeResizeObserver?.disconnect(),this._fixedChromeResizeObserver=null;let e=this.querySelector(`#mint-rt-fixed-controls-${this._tableId}`);if(!e)return;let t=()=>{let t=Math.ceil(e.getBoundingClientRect().height);this.style.setProperty(`--mint-rt-fixed-controls-h`,`${t}px`)};t(),this._fixedChromeResizeObserver=new ResizeObserver(t),this._fixedChromeResizeObserver.observe(e)}_attachVirtualScrollListeners(){if(this._detachVirtualScroll(),!this._virtualScrollActive())return;let e=()=>{this._scheduleVirtualWindowSync()};this._virtualScrollHandler=e,this._virtualScrollRoot()===`table-body`?(this._virtualBodyScrollEl=this.querySelector(`#mint-rt-vscroll-${this._tableId}`),this._virtualBodyScrollEl?.addEventListener(`scroll`,e,{passive:!0}),this._virtualBodyScrollEl&&typeof ResizeObserver<`u`&&(this._virtualResizeObserver=new ResizeObserver(()=>this._scheduleVirtualWindowSync()),this._virtualResizeObserver.observe(this._virtualBodyScrollEl))):window.addEventListener(`scroll`,e,{passive:!0}),this._virtualWindowResizeHandler=()=>this._scheduleVirtualWindowSync(),window.addEventListener(`resize`,this._virtualWindowResizeHandler,{passive:!0}),this._scheduleVirtualWindowSync()}_toggleSort(e){if(!this._configuration||!e.data||!e.sortable)return;let t=e.data;if(this._sortTimeoutId!==null&&(clearTimeout(this._sortTimeoutId),this._sortTimeoutId=null),this._sorting=!0,this._sortingColumn=e,this._updateSortIcons(),this._type===`ajax`)this._sortTimeoutId=window.setTimeout(()=>{if(this._sortTimeoutId=null,!this._configuration||!t||!e.sortable)return;let n=this._configuration.sort||`asc`;this._configuration.sortBy?.toLowerCase()===t.toLowerCase()&&(n=n===`desc`?`asc`:`desc`),this._configuration.sort=n,this._configuration.sortBy=t,this._updateSortIcons(),this._offset=0,this._currentPage=1,this._fetching=!1,this._loading=!1,this._fetchData(void 0,!1,this._perPage,0)},10);else{let e=this._configuration.sort||`asc`;this._configuration.sortBy?.toLowerCase()===t.toLowerCase()&&(e=e===`desc`?`asc`:`desc`),this._configuration.sort=e,this._configuration.sortBy=t,this._currentPage=1,this._sorting=!1,this._sortingColumn=null,this._updateSortIcons(),this.render(),this._virtualScrollActive()&&queueMicrotask(()=>this._scrollVirtualTableTopIntoView())}}_getSortClass(e){return this._sorting&&this._sortingColumn===e?`spinner`:this._configuration?.sortBy?.toLowerCase()===e.data?.toLowerCase()?this._configuration?.sort?.toLowerCase()===`desc`?`caret-down`:`caret-up`:``}_updateSortIcons(){if(!this._configuration)return;this._configuration.columns.forEach((e,t)=>{if(!e.sortable||e.hidden)return;let n=this.querySelector(`th[data-column-key="${t}"]`);if(!n)return;let r=n.querySelector(`:scope > div.flex.items-center`);if(!r)return;let i=r.querySelector(`:scope > div.ml-2.flex.items-center`),a=this._getSortClass(e),o=()=>{if(!i){let e=document.createElement(`div`);e.className=`ml-2 flex items-center`,r.appendChild(e),i=e}return i},s=()=>{i&&=(i.remove(),null)};if(a===`spinner`){let e=o();if(e.querySelector(`mint-icon`)?.remove(),!e.querySelector(`mint-spinner`)){let t=document.createElement(`mint-spinner`);t.className=`w-4 h-4`,e.appendChild(t)}}else if(a===`caret-up`||a===`caret-down`){let e=o();e.querySelector(`mint-spinner`)?.remove();let t=e.querySelector(`mint-icon`);t||(t=document.createElement(`mint-icon`),e.appendChild(t)),t.setAttribute(`name`,a),t.className=`w-4 h-4`}else s()}),this._syncMobileSortPopoverIcons();let e=this.querySelector(`#mint-rt-mobile-sort-btn-${this._tableId}`);e&&(e.setAttribute(`icon`,this._getMobileSortTriggerIconName()),this._sorting?e.setAttribute(`loading`,`true`):e.removeAttribute(`loading`),typeof e.render==`function`&&e.render())}_showFetchingState(){}_triggerSearch(){this._searchTimeoutId&&clearTimeout(this._searchTimeoutId),this._searching=!0,this._type===`ajax`&&this._updateSearchIcon(),this._type!==`ajax`&&(this._currentPage=1),this._updateTableBody(),this._type!==`ajax`&&this._updatePagination(),this._searchTimeoutId=window.setTimeout(()=>{this._type===`ajax`?(this._offset=0,this._fetchData(void 0,!1,this._perPage,0)):(this._searching=!1,this._virtualScrollActive()&&queueMicrotask(()=>this._scrollVirtualTableTopIntoView()))},400)}_updateSearchIcon(){let e=this.querySelector(`#search-${this._tableId}`);if(!e)return;let t=this._type===`ajax`&&(this._searching||this._fetching);setTimeout(()=>{let n=e.querySelector(`.relative`)||e.querySelector(`div`);if(!n)return;let r=n.querySelector(`mint-icon`),i=n.querySelector(`mint-spinner`);if(t){if(r&&!i){let e=document.createElement(`mint-spinner`);e.className=`absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 pointer-events-none`,r.replaceWith(e)}else if(!r&&!i){let e=document.createElement(`mint-spinner`);e.className=`absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 pointer-events-none`,n.appendChild(e)}}else if(i){e.getAttribute(`icon`)||e.setAttribute(`icon`,`search`);let t=document.createElement(`mint-icon`);t.setAttribute(`name`,`search`),t.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`,i.replaceWith(t)}},0)}_updateTableBody(){if(!this._configuration)return;let e=this.querySelector(`tbody[data-mint-rt-tbody="${this._tableId}"]`),t=this.querySelector(`#${this._tableId}`)?.closest(`table`)?.querySelector(`tbody`);if(this._virtualScrollActive()&&(this._type===`provided`||this._type===`ajax`)){if(!(e||t)){this.render();return}let n=this.querySelector(`#search-${this._tableId}`),r=document.activeElement===n||n?.querySelector(`input`)===document.activeElement,i=this._search;if((this._fetching||this._loading)&&!this._loaded&&!this._sorting)return;if(this._virtualInvalidate(),this._syncVirtualWindow(),r&&n){let e=n.querySelector(`input`)||n._element;e?(e.value=i,setTimeout(()=>{e.focus(),e.setSelectionRange(i.length,i.length)},0)):n.value!==void 0&&(n.value=i,setTimeout(()=>{n.focus()},0))}return}let n=this._getRows(),r=t;if(!r){this.render();return}let i=this.querySelector(`#search-${this._tableId}`),a=document.activeElement===i||i?.querySelector(`input`)===document.activeElement,o=this._search,s=``,c=``;if((this._fetching||this._loading)&&!this._loaded&&!this._sorting)return;n.forEach((e,t)=>{c+=this._buildMobileListItemHtml(e,t,void 0,t===n.length-1);let r=typeof this._configuration.onRowClick==`function`,i=r?`cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800`:``;s+=`<tr data-row-index="${t}" ${r?`data-row-clickable="true"`:``}${i?` class="${i}"`:``}>`,this._configuration.columns.forEach(n=>{if(n.hidden)return;let r=!n.show||n.show(this,e);s+=`<td style="${this._getStyle(n)}" class="${this._getClasses(n,!0)}">`,r&&(s+=this._buildTableCellInnerHtml(n,e,t,`table`)),s+=`</td>`}),s+=`</tr>`}),n.length===0&&(this._fetchError?(s+=`<tr><td colspan="${this._configuration.columns.filter(e=>!e.hidden).length}" class="text-center py-8 text-red-500 dark:text-red-400">Failed to load data: ${this._escapeHtml(this._fetchError)}</td></tr>`,c+=`<li class="list-none px-4 py-8 text-center text-sm text-red-500 dark:text-red-400">Failed to load data: ${this._escapeHtml(this._fetchError)}</li>`):(s+=`<tr><td colspan="${this._configuration.columns.filter(e=>!e.hidden).length}" class="text-center py-8">No records found.</td></tr>`,c+=`<li class="list-none px-4 py-8 text-center text-sm">No records found.</li>`)),r.innerHTML=s;let l=this.querySelector(`ul[data-mint-rt-mobile-list="${this._tableId}"]`);if(l&&(l.innerHTML=c),this._attachTableEventListeners(),this._attachRowClickHandler(),a&&i){let e=i.querySelector(`input`)||i._element;e?(e.value=o,setTimeout(()=>{e.focus(),e.setSelectionRange(o.length,o.length)},0)):i.value!==void 0&&(i.value=o,setTimeout(()=>{i.focus()},0))}}_updatePagination(){if(!this._configuration)return;let e=this._lastPage||Math.ceil(this._rows.length/this._perPage),t=()=>{let e=this.querySelector(`mint-table`),t=e?.nextElementSibling;e&&t&&t.id!==`mint-rt-pagination-host-${this._tableId}`&&!t.classList.contains(`mint-rt-pagination-host`)&&t.querySelector?.(`[data-action="page"]`)&&t.remove()};if(!this._configuration.perPage||e<=1||this._virtualScrollActive()){this._getPaginationHostEl()?.replaceChildren(),t();return}let n=this._getPaginationHostEl();if(!n){let e=this.querySelector(`[data-mint-rt-mobile-list="${this._tableId}"]`)||this.querySelector(`mint-table`);if(!e){this.render();return}n=document.createElement(`div`),n.id=`mint-rt-pagination-host-${this._tableId}`,n.setAttribute(`data-mint-rt-pagination-wrap`,``),n.className=`mint-rt-pagination-host w-full min-w-0 overflow-x-auto overflow-y-hidden overscroll-x-contain flex justify-center [-webkit-overflow-scrolling:touch] md:justify-end `+(this._inMintCard?`border-t border-gray-200 px-3.5 pb-3.5 pt-3 dark:border-mint-divider md:border-t-0 md:pt-0`:`border-t border-gray-200 px-2 py-3 dark:border-mint-divider md:border-t-0 md:py-0 md:mt-4`),e.insertAdjacentElement(`afterend`,n)}let r=this._buildPaginationNavMarkup(e);n.innerHTML=r,setTimeout(()=>{this._attachPaginationListeners(),n.querySelectorAll(`mint-button[data-action="page"]`).forEach(e=>{let t=e.getAttribute(`data-page`),n=t&&this._loadingPage===parseInt(t),r=e._button||e.querySelector(`button`);if(r)if(n){let e=[],t=document.createTreeWalker(r,NodeFilter.SHOW_TEXT,null),n;for(;n=t.nextNode();)e.push(n);e.forEach(e=>e.parentNode?.removeChild(e));let i=r.querySelector(`.mint-button-content`);if(i){let e=i.textContent?.trim();e&&/^\d+$/.test(e)&&i.remove()}let a=r.querySelector(`span.mr-2`);a&&a.querySelector(`mint-spinner`)&&(a.classList.remove(`mr-2`),a.classList.add(`mr-0`))}else{let e=r.textContent?.trim();if(!e||!/^\d+$/.test(e)){let e=t||``,n=r.querySelector(`mint-spinner`);r.innerHTML=``,n&&r.appendChild(n),r.appendChild(document.createTextNode(e))}}if(`render`in e&&typeof e.render==`function`&&(e.render(),n&&r)){let e=r.querySelector(`span.mr-2`);e&&e.querySelector(`mint-spinner`)&&(e.classList.remove(`mr-2`),e.classList.add(`mr-0`))}}),n.querySelectorAll(`mint-button[data-action="page-prev"], mint-button[data-action="page-next"]`).forEach(e=>{`render`in e&&typeof e.render==`function`&&e.render()}),this._loadingPage!==null&&!this._loading&&!this._fetching&&this._updatePagination()},0)}_goToPage(e){let t=this._lastPage||Math.ceil(this._rows.length/this._perPage);e>t&&(e=t),e<1&&(e=1),e!==this._currentPage&&(this._currentPage=e,this._offset=(e-1)*this._perPage,this._updatePageInUrl(e),this._type===`ajax`?(this._loadingPage=e,this._updatePagination(),this._fetchData()):this.render())}_handleButtonClick(e){if(this._configuration)switch(e.type){case`export`:break;case`print`:window.print();break;case`csv`:this._downloadCSV();break;default:e.onClick&&e.onClick(this);break}}_downloadCSV(){if(!this._configuration)return;let e=this.querySelector(`#${this._tableId}`)||this.querySelector(`table`);if(!e)return;let t=`data:text/csv;charset=utf-8,`,n=e=>{let n=[];e.querySelectorAll(`th, td`).forEach(e=>{let t=e.getAttribute(`colspan`);if(t)for(let e=0;e<parseInt(t,10)-1;e++)n.push(``);n.push(`"`+e.textContent?.trim().replace(/"/g,`""`)+`"`)}),t+=n.join(`,`)+`
|
|
83
83
|
`};e.querySelectorAll(`tr`).forEach(e=>n(e));let r=encodeURI(t),i=document.createElement(`a`);i.setAttribute(`href`,r),i.setAttribute(`download`,`${this._configuration.export_name||this._tableId}.csv`),document.body.appendChild(i),i.click(),document.body.removeChild(i)}_getStyle(e){let t=``;return(e.nowrap||e.actions)&&(t+=`white-space: nowrap;`),e.offsetLeft&&(t+=`left: ${e.offsetLeft} !important;`),e.offsetRight&&(t+=`right: ${e.offsetRight} !important;`),e.width&&(t+=`min-width: ${e.width}px; max-width: ${e.width}px;`),t}_getClasses(e,t=!1){let n=[];return e.class&&n.push(e.class.trim()),e.sortable&&!t&&n.push(`cursor-pointer`),e.stickLeft&&n.push(`sticky-left`),e.stickRight&&n.push(`sticky-right`),n.join(` `)}_renderTheadHtml(e,t,n=!1,r=!1){if(!this._configuration)return``;let i=[`bg-white`,`dark:bg-mint-nav`];e&&(i.push(`sticky`,`z-40`),r?i.push(`top-[var(--mint-rt-fixed-controls-h,0px)]`):i.push(`top-0`)),t&&i.push(`border-b`,`border-gray-200`,`dark:border-mint-divider`);let a=`<thead class="${i.join(` `)}"><tr>`;return this._configuration.columns.forEach((e,t)=>{if(e.hidden)return;let r=n?``:` width="${e.width||``}"`,i=e.sortable?` data-mint-rt-sortable=""`:``;if(a+=`<th${r} style="${this._getStyle(e)}" class="${this._getClasses(e)}" data-column-key="${t}"${i}>`,e.showLabel!==!1){if(a+=`<div class="flex items-center">`,a+=`<div class="flex-1">${e.raw?e.label:this._escapeHtml(e.label)}</div>`,e.sortable){let t=this._getSortClass(e);t===`spinner`?a+=`<div class="ml-2 flex items-center"><mint-spinner class="w-4 h-4"></mint-spinner></div>`:(t===`caret-up`||t===`caret-down`)&&(a+=`<div class="ml-2 flex items-center"><mint-icon name="${t}" class="w-4 h-4"></mint-icon></div>`)}a+=`</div>`}a+=`</th>`}),a+=`</tr></thead>`,a}render(){if(!this._configuration){this.innerHTML=`<div class="p-4 text-red-500">Error: Invalid configuration</div>`;return}this._ensureMobileListMql();let e=String(this._configuration.id||``).trim();e&&(this.id=e),this._detachVirtualScroll(),this._detachFixedChromeResize(),this._virtualScrollActive()||this._virtualRowCache.clear();let t=!this._loaded||this._rows.length>0||this._search.length>0||this._searching,n=this._getRows();this._lastPage||Math.ceil(this._rows.length/this._perPage);let r=``;if(t){let e=this._fixedControls(),t=[`flex`,`items-center`,`min-w-0`,this._inMintCard?`p-3.5`:`mb-3`,e?`sticky top-0 z-50 bg-white dark:bg-mint-nav border-b border-gray-200 dark:border-mint-divider`:``].filter(Boolean).join(` `);if(r+=`<div id="mint-rt-fixed-controls-${this._tableId}" class="${t}">`,r+=`<div class="flex min-w-0 flex-1 items-center gap-2">`,r+=this._buildMobileSortToolbarHtml(),this._configuration.showSearch!==!1){let e=`search-${this._tableId}`,t=this._escapeHtml(this._configuration.searchPlaceholder||`Search...`);r+=`<mint-input id="${e}" type="search" label="" placeholder="${t}" class="min-w-0 flex-1" icon="search" value="${this._escapeHtml(this._search)}"></mint-input>`}r+=`<div class="hidden shrink-0 items-center gap-2 md:flex">`,this._configuration.buttons&&this._configuration.buttons.forEach(e=>{let t=e.icon?` icon="${this._escapeHtml(e.icon)}"`:``,n=e.tone?` tone="${this._escapeHtml(e.tone)}"`:``;r+=`<mint-button variant="solid" class="${e.class||``}" data-button-type="${e.type||`custom`}"${t}${n}>`,e.label&&(r+=this._escapeHtml(e.label)),r+=`</mint-button>`}),r+=`</div>`,r+=`</div>`,r+=`</div>`}if(this._type===`ajax`&&!this._loaded&&!this._fetchError&&!this._sorting){let e=this._fixedHeader()?` data-mint-rt-scroll-inner=""`:``,t=this._fixedHeader()&&this._fixedControls(),n=this._fixedHeader()?t?`sticky top-[var(--mint-rt-fixed-controls-h,0px)] z-40 `:`sticky top-0 z-40 `:`sticky top-0 z-20 `;r+=`<div class="min-w-0">`,r+=`<mint-table class="table-section`+(this._inMintCard?` rounded-t-none`:``)+`"`+e+`>`,r+=`<table id="${this._tableId}">`,r+=`<thead class="`+n+`bg-white dark:bg-mint-nav border-b border-gray-200 dark:border-mint-divider"><tr>`,this._configuration.columns.forEach((e,t)=>{if(e.hidden)return;let n=e.sortable?` data-mint-rt-sortable=""`:``;if(r+=`<th width="${e.width||``}" style="${this._getStyle(e)}" class="${this._getClasses(e)}" data-column-key="${t}"${n}>`,e.showLabel!==!1){if(r+=`<div class="flex items-center">`,r+=`<div class="flex-1">${e.raw?e.label:this._escapeHtml(e.label)}</div>`,e.sortable){let t=this._getSortClass(e);t===`spinner`?r+=`<div class="ml-2 flex items-center"><mint-spinner class="w-4 h-4"></mint-spinner></div>`:(t===`caret-up`||t===`caret-down`)&&(r+=`<div class="ml-2 flex items-center"><mint-icon name="${t}" class="w-4 h-4"></mint-icon></div>`)}r+=`</div>`}r+=`</th>`}),r+=`</tr></thead>`,r+=`<tbody>`;for(let e=0;e<4;e++)r+=`<tr>`,this._configuration.columns.forEach(e=>{if(!e.hidden){if(r+=`<td style="${this._getStyle(e)}" class="${this._getClasses(e,!0)}">`,e.thumbnail){let t=this._thumbnailDesktopPx(e);r+=`<div class="rounded-md bg-gray-200 dark:bg-white/15 animate-pulse" style="width:${t}px;height:${t}px;box-sizing:border-box"></div>`}else r+=`<div class="h-4 max-w-[95%] rounded bg-gray-200 dark:bg-white/15 animate-pulse"></div>`;r+=`</td>`}}),r+=`</tr>`;r+=`</tbody>`,r+=`</table>`,r+=`</mint-table>`,r+=`</div>`,r+=this._paginationHostPlaceholderHtml()}else if(n.length>0||this._search.length>0||this._searching||this._fetchError){let e=this._virtualScrollActive()&&(this._type===`provided`||this._type===`ajax`&&this._loaded&&!this._fetchError),t=e&&this._virtualScrollRoot()===`table-body`,i=this._escapeHtml(this._virtualMaxHeightCss()),a=t||this._fixedHeader(),o=this._fixedHeader()&&this._fixedControls(),s=a?` data-mint-rt-scroll-inner=""`:``,c=`table-section`+(this._inMintCard?` rounded-t-none`:``),l=`m-0 min-h-0 w-full list-none border-collapse overflow-x-hidden bg-white ${this._inMintCard?`px-3.5 py-3.5`:`py-3`} dark:bg-mint-canvas md:hidden`,u=``;if(t){let e=this._renderColgroupHtml();r+=`<div id="mint-rt-vscroll-${this._tableId}" class="overflow-y-auto overflow-x-auto min-h-0 w-full" style="max-height: ${i}; scrollbar-gutter: stable; overscroll-behavior-x: contain; overscroll-behavior-y: none; overflow-anchor: none;">`,r+=`<div class="hidden min-h-0 min-w-0 md:block">`,r+=`<mint-table class="${c}"${s}>`,r+=`<table id="${this._tableId}" class="w-full min-w-0 table-fixed">`,r+=e,r+=this._renderTheadHtml(!0,!0,!0,o)}else r+=`<div class="hidden min-h-0 min-w-0 md:block">`,r+=`<mint-table class="${c}"${s}>`,r+=`<table id="${this._tableId}">`,e&&(r+=this._renderColgroupHtml()),r+=this._renderTheadHtml(!0,!0,!!e,o);if(r+=`<tbody`+(e?` data-mint-rt-tbody="${this._tableId}"`:``)+`>`,!this._fetching&&!this._loading&&!e&&n.forEach((e,t)=>{u+=this._buildMobileListItemHtml(e,t,void 0,t===n.length-1);let i=typeof this._configuration.onRowClick==`function`,a=i?`cursor-pointer hover:bg-gray-50 dark:hover:bg-mint-elevated`:``;r+=`<tr data-row-index="${t}" ${i?`data-row-clickable="true"`:``}${a?` class="${a}"`:``}>`,this._configuration.columns.forEach(n=>{if(n.hidden)return;let i=!n.show||n.show(this,e);r+=`<td style="${this._getStyle(n)}" class="${this._getClasses(n,!0)}">`,i&&(r+=this._buildTableCellInnerHtml(n,e,t,`table`)),r+=`</td>`}),r+=`</tr>`}),!this._fetching&&!this._loading&&n.length===0&&!e)if(this._fetchError){let e=this._configuration.columns.filter(e=>!e.hidden).length;r+=`<tr><td colspan="${e}" class="text-center py-8 text-red-500 dark:text-red-400">Failed to load data: ${this._escapeHtml(this._fetchError)}</td></tr>`,u+=`<li class="list-none px-4 py-8 text-center text-sm text-red-500 dark:text-red-400">Failed to load data: ${this._escapeHtml(this._fetchError)}</li>`}else{let e=this._configuration.columns.filter(e=>!e.hidden).length;r+=`<tr><td colspan="${e}" class="text-center py-8">No records found.</td></tr>`,u+=`<li class="list-none px-4 py-8 text-center text-sm">No records found.</li>`}r+=`</tbody>`,r+=`</table>`,r+=`</mint-table>`,r+=`</div>`,r+=`<ul class="${l}" data-mint-rt-mobile-list="${this._tableId}">${e?``:u}</ul>`,e||(r+=this._paginationHostPlaceholderHtml()),t&&(r+=`</div>`)}else r+=`<slot name="empty"></slot>`;this._fixedHeader()?this.setAttribute(`data-mint-rt-fixed-header`,``):this.removeAttribute(`data-mint-rt-fixed-header`),this._fixedControls()?this.setAttribute(`data-mint-rt-fixed-controls`,``):this.removeAttribute(`data-mint-rt-fixed-controls`),this.innerHTML=r,this._updatePagination(),this.querySelectorAll(`mint-button[data-action]`).forEach(e=>{e.render&&e.render()}),this.querySelectorAll(`mint-button[data-mint-rt-toolbar]`).forEach(e=>{e.render&&e.render()}),this.querySelectorAll(`mint-button[data-button-type]`).forEach(e=>{e.render&&e.render()}),this._attachEventListeners(),this._type===`ajax`&&!this._loaded&&!this._fetching&&!this._loading&&this._fetchData()}_attachRowClickHandler(){this._rowClickHandler&&this.removeEventListener(`click`,this._rowClickHandler,!0);let e=e=>{let t=e.target;if(t.tagName===`MINT-BUTTON`||t.tagName===`BUTTON`||t.closest(`mint-button`)||t.closest(`button`)||t.closest(`mint-popover`)||t.closest(`[data-action]`))return;let n=t.closest(`tr[data-row-clickable="true"]`)||t.closest(`li[data-row-clickable="true"]`);if(!n)return;let r=n.getAttribute(`data-row-index`);if(!r)return;let i=parseInt(r),a=this._getRowDataForEventIndex(i);!a||!this._configuration?.onRowClick||(this._configuration.onRowClick.length===1?this._configuration.onRowClick(a):this._configuration.onRowClick(this,a))};this.addEventListener(`click`,e,!0),this._rowClickHandler=e}_attachPaginationListeners(){this.querySelectorAll(`[data-action="page"]`).forEach(e=>{e.addEventListener(`click`,()=>{if(e.getAttribute(`active`)===`true`)return;let t=parseInt(e.getAttribute(`data-page`)||`1`);t!==this._currentPage&&this._goToPage(t)})}),this.querySelectorAll(`[data-action="page-prev"]`).forEach(e=>{e.addEventListener(`click`,()=>{this._goToPage(this._currentPage-1)})}),this.querySelectorAll(`[data-action="page-next"]`).forEach(e=>{e.addEventListener(`click`,()=>{this._goToPage(this._currentPage+1)})})}_attachTableEventListeners(){this.querySelectorAll(`[data-action="row-action"]`).forEach(e=>{e.addEventListener(`click`,()=>{let t=parseInt(e.getAttribute(`data-row-index`)||`0`),n=parseInt(e.getAttribute(`data-action-index`)||`0`),r=parseInt(e.getAttribute(`data-column-key`)||`0`),i=this._getRowDataForEventIndex(t),a=this._configuration?.columns[r];a&&a.actions&&a.actions[n]&&i!==void 0&&a.actions[n].onClick(this,i)})}),this.querySelectorAll(`[data-action="column-action"]`).forEach(e=>{e.addEventListener(`click`,()=>{let t=parseInt(e.getAttribute(`data-row-index`)||`0`),n=parseInt(e.getAttribute(`data-column-key`)||`0`),r=this._getRowDataForEventIndex(t),i=this._configuration?.columns[n];i&&i.action&&r!==void 0&&i.action.onClick(this,r)})})}_attachEventListeners(){let e=this.querySelector(`#search-${this._tableId}`);if(e){let t=e.querySelector(`input`)||e._element;t?t.addEventListener(`input`,e=>{this._search=e.target.value,this._triggerSearch()}):e.addEventListener(`input`,t=>{this._search=e.value||t.target.value||``,this._triggerSearch()})}this._attachTableEventListeners(),this._attachRowClickHandler(),this.querySelectorAll(`th[data-column-key]`).forEach(e=>{e.addEventListener(`click`,()=>{let t=parseInt(e.getAttribute(`data-column-key`)||`0`),n=this._configuration?.columns[t];n&&this._toggleSort(n)})}),this.querySelectorAll(`[data-action="mobile-sort"]`).forEach(e=>{e.addEventListener(`click`,t=>{t.stopPropagation();let n=parseInt(e.getAttribute(`data-column-key`)||`0`,10),r=this._configuration?.columns[n];r&&(this._closeMobileSortPopover(),this._toggleSort(r))})}),this.querySelectorAll(`[data-button-type]`).forEach(e=>{e.addEventListener(`click`,()=>{let t=e.getAttribute(`data-button-type`),n=this._configuration?.buttons?.find(e=>(e.type||`custom`)===t);n&&this._handleButtonClick(n)})}),this._attachPaginationListeners(),this._virtualScrollActive()&&(this._type===`provided`||this._type===`ajax`)&&this._attachVirtualScrollListeners(),this._fixedHeader()&&this._fixedControls()&&queueMicrotask(()=>{this._syncFixedControlsChromeHeight(),requestAnimationFrame(()=>this._syncFixedControlsChromeHeight())})}_escapeHtml(e){let t=document.createElement(`div`);return t.textContent=e,t.innerHTML}_getPageFromUrl(){if(!this._tableId)return null;let e=new URLSearchParams(window.location.search).get(`mui.${this._tableId}`);if(!e)return null;let t=parseInt(e,10);return isNaN(t)||t<1?null:t}_updatePageInUrl(e){if(!this._tableId)return;let t=new URL(window.location.href),n=t.searchParams;n.set(`mui.${this._tableId}`,e.toString()),e===1&&n.set(`mui.${this._tableId}`,`1`),window.history.replaceState({},``,t.toString())}_loadPageFromUrl(){if(!this._configuration||!this._tableId)return;let e=this._getPageFromUrl();e!==null&&(this._currentPage=e,this._offset=(this._currentPage-1)*this._perPage)}};customElements.get(`mint-resource-table`)||customElements.define(`mint-resource-table`,j);var M=550,N=12,P={passive:!0},F=class extends HTMLElement{constructor(...e){super(...e),this._table=null,this._anchor=null,this._popover=null,this._menuRoot=null,this._baseId=``,this._touchTimer=null,this._touchStart=null,this._slotObserver=null,this._scrollCloseTargets=[],this._onScrollClose=()=>{this._closePopover()},this._onContextMenu=e=>{let t=e,n=this._rowTargetFromEventTarget(t.target);n&&(t.preventDefault(),this._openAtRowIndex(n.index,t.clientX,t.clientY))},this._onTouchStart=e=>{let t=e;if(!t.touches.length)return;let n=this._rowTargetFromEventTarget(t.target);if(!n)return;let r=t.touches[0];this._touchStart={x:r.clientX,y:r.clientY,rowIndex:n.index},this._touchTimer!==null&&(window.clearTimeout(this._touchTimer),this._touchTimer=null);let i=this._longPressMs();this._touchTimer=window.setTimeout(()=>{this._touchTimer=null,this._touchStart&&=(this._openAtRowIndex(this._touchStart.rowIndex,this._touchStart.x,this._touchStart.y),null)},i)},this._onTouchMove=e=>{if(!this._touchStart||this._touchTimer===null)return;let t=e.touches[0];if(!t)return;let n=t.clientX-this._touchStart.x,r=t.clientY-this._touchStart.y;n*n+r*r>N*N&&(this._clearTouchTimer(),this._touchStart=null)},this._onTouchEnd=()=>{this._clearTouchTimer(),this._touchStart=null}}static get observedAttributes(){return[`for`,`long-press-ms`]}connectedCallback(){this.classList.add(`contents`),this._baseId=this.id?.trim()||`mint-rt-ctx-${Math.random().toString(36).slice(2,10)}`,this._anchor=document.createElement(`div`),this._anchor.id=`${this._baseId}-anchor`,this._anchor.setAttribute(`aria-hidden`,`true`),this._anchor.className=`pointer-events-none fixed z-0 h-px w-px overflow-hidden p-0 m-0 border-0 opacity-0`,document.body.appendChild(this._anchor),this._popover=document.createElement(`mint-popover`),this._popover.setAttribute(`data-mint-rt-ctx-internal`,``),this._popover.id=`${this._baseId}-popover`,this._popover.setAttribute(`trigger-id`,this._anchor.id),this._popover.setAttribute(`direction`,`down`),this._popover.setAttribute(`padding`,`0`),this._popover.setAttribute(`distance`,`6px`),this._menuRoot=document.createElement(`div`),this._menuRoot.className=`flex min-w-[11rem] flex-col gap-0.5 py-1`,this._popover.appendChild(this._menuRoot),this.appendChild(this._popover),this._slotObserver=new MutationObserver(()=>{this._hideMenuSlotSources()}),this._slotObserver.observe(this,{childList:!0}),queueMicrotask(()=>{this._hideMenuSlotSources(),this._bindTable()})}disconnectedCallback(){this._slotObserver?.disconnect(),this._slotObserver=null,this._unbindTable(),this._anchor?.remove(),this._anchor=null,this._popover?.remove(),this._popover=null,this._menuRoot=null}attributeChangedCallback(){this.isConnected&&this._bindTable()}_longPressMs(){let e=parseInt(this.getAttribute(`long-press-ms`)||``,10);return!Number.isNaN(e)&&e>100?e:M}_resolveTable(){let e=this.getAttribute(`for`)?.trim();if(e){let t=document.getElementById(e);return t&&t.tagName===`MINT-RESOURCE-TABLE`?t:null}let t=this.previousElementSibling;return t&&t.tagName===`MINT-RESOURCE-TABLE`?t:this.parentElement?.querySelector?.(`mint-resource-table`)??null}_hideMenuSlotSources(){for(let e of Array.from(this.children))e===this._popover||e.hasAttribute(`data-mint-rt-ctx-internal`)||e.setAttribute(`hidden`,``)}_bindTable(){this._unbindTable(),this._table=this._resolveTable(),this._table&&(this._table.addEventListener(`contextmenu`,this._onContextMenu,!0),this._table.addEventListener(`touchstart`,this._onTouchStart,{passive:!0}),this._table.addEventListener(`touchmove`,this._onTouchMove,{passive:!0}),this._table.addEventListener(`touchend`,this._onTouchEnd,{passive:!0}),this._table.addEventListener(`touchcancel`,this._onTouchEnd,{passive:!0}))}_unbindTable(){this._closePopover(),this._table&&=(this._table.removeEventListener(`contextmenu`,this._onContextMenu,!0),this._table.removeEventListener(`touchstart`,this._onTouchStart),this._table.removeEventListener(`touchmove`,this._onTouchMove),this._table.removeEventListener(`touchend`,this._onTouchEnd),this._table.removeEventListener(`touchcancel`,this._onTouchEnd),null)}_rowTargetFromEventTarget(e){if(!e||!this._table)return null;let t=e.closest?.(`tr[data-row-index], li[data-row-index]`);if(!t||!this._table.contains(t)||t.hasAttribute(`data-mint-rt-spacer`)||t.getAttribute(`data-mint-rt-placeholder`)===`true`)return null;let n=t.getAttribute(`data-row-index`);if(n==null)return null;let r=parseInt(n,10);return Number.isNaN(r)?null:{index:r}}_clearTouchTimer(){this._touchTimer!==null&&(window.clearTimeout(this._touchTimer),this._touchTimer=null)}_positionAnchor(e,t){this._anchor&&(this._anchor.style.left=`${Math.round(e)}px`,this._anchor.style.top=`${Math.round(t)}px`)}_slotTemplateElements(){return Array.from(this.children).filter(e=>e!==this._popover&&e instanceof HTMLElement&&!e.hasAttribute(`data-mint-rt-ctx-internal`))}_elementIsScrollContainer(e){let t=getComputedStyle(e);return t.overflowX===`auto`||t.overflowX===`scroll`||t.overflowY===`auto`||t.overflowY===`scroll`}_collectScrollCloseTargets(e){let t=[],n=new Set,r=e=>{!e||n.has(e)||(n.add(e),t.push(e))};r(window),e.querySelectorAll(`[id^="mint-rt-vscroll-"]`).forEach(e=>{this._elementIsScrollContainer(e)&&r(e)});let i=e.querySelector(`mint-table`);for(;i&&i!==e;)this._elementIsScrollContainer(i)&&r(i),i=i.parentElement;return this._elementIsScrollContainer(e)&&r(e),t}_detachScrollCloseListeners(){for(let e of this._scrollCloseTargets)e.removeEventListener(`scroll`,this._onScrollClose,P);this._scrollCloseTargets=[]}_attachScrollCloseListeners(e){this._detachScrollCloseListeners(),this._scrollCloseTargets=this._collectScrollCloseTargets(e);for(let e of this._scrollCloseTargets)e.addEventListener(`scroll`,this._onScrollClose,P)}_closePopover(){if(this._detachScrollCloseListeners(),!this._popover?.hasAttribute(`open`))return;let e=this._popover;typeof e.close==`function`?e.close():this._popover.removeAttribute(`open`)}_openAtRowIndex(e,t,n){this._closePopover();let r=this._resolveTable();if(!r||typeof r.getRowByIndex!=`function`||!this._popover||!this._menuRoot)return;let i=this._popover,a=this._menuRoot,o=r.getRowByIndex(e);if(o===void 0)return;let s=this._slotTemplateElements();if(!s.length)return;this._positionAnchor(t,n),a.innerHTML=``,s.forEach(t=>{if(t.hasAttribute(`data-mint-rt-ctx-if-selection`)&&!(window.getSelection?.()?.toString?.()?.trim()??``))return;let n=t.cloneNode(!0);n.removeAttribute(`hidden`),n.addEventListener(`click`,t=>{t.stopPropagation();let r=n.getAttribute(`data-context-action`)||n.querySelector?.(`[data-context-action]`)?.getAttribute(`data-context-action`)||``,i=window.getSelection?.()?.toString?.()?.trim()??``;this.dispatchEvent(new CustomEvent(`context-action`,{bubbles:!0,composed:!0,detail:{action:r,row:o,rowIndex:e,selectedText:i}})),this._closePopover()}),a.appendChild(n);let r=n;typeof r.render==`function`&&queueMicrotask(()=>r.render())}),i.removeAttribute(`open`),i.offsetHeight,i.setAttribute(`open`,`true`);let c=i;typeof c.render==`function`&&queueMicrotask(()=>c.render());let l=this._resolveTable();l&&this._attachScrollCloseListeners(l)}};customElements.get(`mint-resource-table-context-menu`)||customElements.define(`mint-resource-table-context-menu`,F);var I=class extends HTMLElement{static get observedAttributes(){return[`id`,`heading`,`open`,`position`,`full-page`,`width`,`height`]}constructor(){super(),this._overlay=null,this._offCanvas=null,this._header=null,this._headingSlot=null,this._bodySlot=null,this._actionsSlot=null,this._closeButton=null,this._darkModeObserver=null,this._contentObserver=null,this._renderFrame=null}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(),this._observeContentMutations()}disconnectedCallback(){this._darkModeObserver&&=(this._darkModeObserver.disconnect(),null),this._contentObserver&&=(this._contentObserver.disconnect(),null),this._renderFrame!==null&&(cancelAnimationFrame(this._renderFrame),this._renderFrame=null)}attributeChangedCallback(e,t,n){t!==n&&this.render()}_scheduleRender(){this._renderFrame===null&&(this._renderFrame=requestAnimationFrame(()=>{this._renderFrame=null,this.render()}))}getId(){return this.getAttribute(`id`)||``}getHeading(){return this.getAttribute(`heading`)||``}getPosition(){let e=this.getAttribute(`position`)?.toLowerCase();return e===`top`||e===`bottom`||e===`left`||e===`right`?e:`right`}isFullPage(){return this.getAttribute(`full-page`)===`true`}getWidth(){return this.getAttribute(`width`)||`320px`}getHeight(){return this.getAttribute(`height`)||``}_normalizeCssValue(e){return/^\d+(\.\d+)?$/.test(e.trim())?`${e.trim()}px`:e.trim()}isOpen(){return this.getAttribute(`open`)===`true`}open(){this.setAttribute(`open`,`true`)}close(){this.removeAttribute(`open`)}render(){let e=this.getId(),t=this.getHeading(),n=this.isOpen(),r=this.getPosition(),i=this.isFullPage(),a=this.getHeight();e&&(this.id=e),this._overlay||(this._overlay=document.createElement(`div`),this._overlay.className=`fixed inset-0 bg-black/50 transition-opacity duration-200 z-40`,this._overlay.addEventListener(`click`,()=>this.close()),this.appendChild(this._overlay)),this._offCanvas||(this._offCanvas=document.createElement(`div`),this.appendChild(this._offCanvas));let o=this._getPositionClasses(r,i);this._offCanvas.className=o;let s=this._offCanvas.querySelector(`.off-canvas-content`);if(s||(s=document.createElement(`div`),s.className=`off-canvas-content bg-white dark:bg-mint-elevated dark:border dark:border-mint-divider shadow-xl flex flex-col pointer-events-auto`,s.style.transform=this._getTransformValue(r,!1),this._offCanvas.appendChild(s)),n?this._animateEnter():this._animateExit(),Array.from(s.classList).forEach(e=>{(e.startsWith(`w-`)||e.startsWith(`max-w-`)||e.startsWith(`md:w-`)||e.startsWith(`md:max-w-`)||e.startsWith(`sm:w-`)||e.startsWith(`sm:max-w-`))&&s.classList.remove(e)}),s.classList.remove(`h-full`,`max-h-[90vh]`,`max-h-screen`,`md:h-full`,`md:max-h-[90vh]`,`md:max-h-screen`,`sm:h-full`,`sm:max-h-[90vh]`),s.classList.remove(`has-custom-width`,`has-custom-height`),s.style.removeProperty(`--off-canvas-width`),s.style.removeProperty(`--off-canvas-height`),i)s.classList.add(`w-full`,`h-full`,`max-w-none`);else if(r===`top`||r===`bottom`)if(s.classList.add(`w-full`,`h-full`,`max-w-none`),a){let e=this._normalizeCssValue(a);s.style.setProperty(`--off-canvas-height`,e),s.classList.add(`has-custom-height`),this._ensureHeightStyle()}else s.classList.add(`md:max-h-[90vh]`,`md:h-auto`);else{s.classList.add(`w-full`,`h-full`,`max-w-none`);let e=this.getWidth(),t=this._normalizeCssValue(e);s.style.setProperty(`--off-canvas-width`,t),s.classList.add(`has-custom-width`),this._ensureWidthStyle()}this._header||(this._header=document.createElement(`div`),this._header.className=`flex items-center justify-between p-4 border-b border-gray-200 dark:border-mint-divider flex-shrink-0`,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 c=this._headingSlot.querySelector(`mint-text`);t?(c||(c=document.createElement(`mint-text`),c.setAttribute(`size`,`sub-heading`),c.setAttribute(`bold`,`true`),this._headingSlot.appendChild(c)),c.textContent=t):c&&c.remove(),Array.from(this.children).filter(e=>e!==this._overlay&&e!==this._offCanvas&&e!==this._headingSlot&&e.getAttribute(`slot`)===`heading`).forEach(e=>{this._headingSlot&&e.parentElement!==this._headingSlot&&this._headingSlot.appendChild(e)}),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(e=>e!==this._overlay&&e!==this._offCanvas&&e!==this._bodySlot&&e.getAttribute(`slot`)===`body`).forEach(e=>{this._bodySlot&&e.parentElement!==this._bodySlot&&this._bodySlot.appendChild(e)}),this._actionsSlot||(this._actionsSlot=document.createElement(`div`),this._actionsSlot.className=`p-4 border-t border-gray-200 dark:border-mint-divider flex-shrink-0`,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(e=>e!==this._overlay&&e!==this._offCanvas&&e!==this._actionsSlot&&e.getAttribute(`slot`)===`actions`).forEach(e=>{Array.from(e.children).forEach(e=>{e.parentElement!==l&&l.appendChild(e)}),e.parentElement&&e.remove()}),Array.from(this.children).forEach(e=>{e!==this._overlay&&e!==this._offCanvas&&e.getAttribute(`slot`)!==`heading`&&e.getAttribute(`slot`)!==`body`&&e.getAttribute(`slot`)!==`actions`&&e!==this._headingSlot&&e!==this._bodySlot&&e!==this._actionsSlot&&e.parentElement!==this._bodySlot&&this._bodySlot.appendChild(e)}),this._updateBackgroundColor()}_getPositionClasses(e,t){let n=`fixed z-50 pointer-events-none`;switch(e){case`top`:return`${n} inset-0 md:inset-x-0 md:top-0 md:bottom-auto ${t?`md:h-full`:`md:h-auto`}`;case`bottom`:return`${n} inset-0 md:inset-x-0 md:bottom-0 md:top-auto ${t?`md:h-full`:`md:h-auto`}`;case`left`:return`${n} inset-0 md:inset-y-0 md:left-0 md:right-auto ${t?`md:w-full`:`md:w-auto`}`;case`right`:return`${n} inset-0 md:inset-y-0 md:right-0 md:left-auto ${t?`md:w-full`:`md:w-auto`}`;default:return`${n} inset-0 md:inset-y-0 md:right-0 md:left-auto ${t?`md:w-full`:`md:w-auto`}`}}_getTransformValue(e,t){if(t)switch(e){case`top`:return`translateY(0)`;case`bottom`:return`translateY(0)`;case`left`:return`translateX(0)`;case`right`:return`translateX(0)`;default:return`translateX(0)`}else switch(e){case`top`:return`translateY(-100%)`;case`bottom`:return`translateY(100%)`;case`left`:return`translateX(-100%)`;case`right`:return`translateX(100%)`;default:return`translateX(100%)`}}_updateBackgroundColor(){if(!this._offCanvas)return;let e=document.documentElement.classList.contains(`dark`),t=this._offCanvas.querySelector(`.off-canvas-content`);t&&(e?(t.classList.remove(`bg-white`),t.classList.add(`bg-mint-elevated`,`border`,`border-mint-divider`)):(t.classList.remove(`bg-mint-elevated`,`border`,`border-mint-divider`),t.classList.add(`bg-white`)))}_observeDarkMode(){this._darkModeObserver||(this._darkModeObserver=new MutationObserver(()=>{this._updateBackgroundColor()}),this._darkModeObserver.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`]}))}_observeContentMutations(){this._contentObserver||=new MutationObserver(()=>{this._scheduleRender()}),this._contentObserver.disconnect(),this._contentObserver.observe(this,{childList:!0,attributes:!0,attributeFilter:[`slot`]})}_animateEnter(){let e=this._offCanvas?.querySelector(`.off-canvas-content`);if(!e)return;let t=this.getPosition();e.style.transform=this._getTransformValue(t,!1),e.style.transition=`transform 300ms ease-out`,this.classList.remove(`hidden`),requestAnimationFrame(()=>{requestAnimationFrame(()=>{e.style.transform=this._getTransformValue(t,!0)})})}_animateExit(){let e=this._offCanvas?.querySelector(`.off-canvas-content`);if(!e){this.classList.add(`hidden`);return}let t=this.getPosition();e.style.transition=`transform 300ms ease-in`,e.style.transform=this._getTransformValue(t,!1),setTimeout(()=>{this.classList.add(`hidden`),e.style.transform=``,e.style.transition=``},300)}_ensureWidthStyle(){if(!document.getElementById(`off-canvas-width-style`)){let e=document.createElement(`style`);e.id=`off-canvas-width-style`,e.textContent=`
|
|
84
84
|
@media (min-width: 768px) {
|
|
85
85
|
.off-canvas-content.has-custom-width {
|
package/dist/index.js
CHANGED
|
@@ -5150,11 +5150,12 @@ var T = class extends HTMLElement {
|
|
|
5150
5150
|
"enctype",
|
|
5151
5151
|
"data-form-data",
|
|
5152
5152
|
"loading",
|
|
5153
|
-
"headers"
|
|
5153
|
+
"headers",
|
|
5154
|
+
"submitting"
|
|
5154
5155
|
];
|
|
5155
5156
|
}
|
|
5156
5157
|
constructor() {
|
|
5157
|
-
super(), this._form = null, this._submitHandler = null, this._hostSubmitHandler = null, this._errors = {}, this._fieldBlurHandlers = /* @__PURE__ */ new Map(), this._fieldChangeHandlers = /* @__PURE__ */ new Map(), this._observer = null, this._formData = null, this._headers = null, this._buttonStates = /* @__PURE__ */ new Map(), this._reactiveDataProxy = null, this._reactiveDataObserver = null, this._lastDataSnapshot = null;
|
|
5158
|
+
super(), this._form = null, this._submitHandler = null, this._hostSubmitHandler = null, this._errors = {}, this._fieldBlurHandlers = /* @__PURE__ */ new Map(), this._fieldChangeHandlers = /* @__PURE__ */ new Map(), this._observer = null, this._formData = null, this._headers = null, this._buttonStates = /* @__PURE__ */ new Map(), this._attrSubmittingMintFields = /* @__PURE__ */ new Map(), this._attrSubmittingNativeFields = /* @__PURE__ */ new Map(), this._attrSubmittingMintButtons = /* @__PURE__ */ new Map(), this._attrSubmittingNativeButtons = /* @__PURE__ */ new Map(), this._reactiveDataProxy = null, this._reactiveDataObserver = null, this._lastDataSnapshot = null;
|
|
5158
5159
|
}
|
|
5159
5160
|
connectedCallback() {
|
|
5160
5161
|
this._render(), this._ensureSubmitHandler(), this._setupBlurValidation();
|
|
@@ -5166,12 +5167,12 @@ var T = class extends HTMLElement {
|
|
|
5166
5167
|
let e = this.getAttribute("data-form-data");
|
|
5167
5168
|
e && (this._parseFormData(e), this._applyFormData());
|
|
5168
5169
|
}
|
|
5169
|
-
this._propagateLoadingState();
|
|
5170
|
+
this._propagateLoadingState(), this._applySubmittingAttributeState();
|
|
5170
5171
|
});
|
|
5171
5172
|
});
|
|
5172
5173
|
}
|
|
5173
5174
|
disconnectedCallback() {
|
|
5174
|
-
this._form && this._submitHandler && this._form.removeEventListener("submit", this._submitHandler, !0), this._hostSubmitHandler && this.removeEventListener("submit", this._hostSubmitHandler), this._cleanupBlurValidation(), this._stopReactiveDataObserver();
|
|
5175
|
+
this._form && this._submitHandler && this._form.removeEventListener("submit", this._submitHandler, !0), this._hostSubmitHandler && this.removeEventListener("submit", this._hostSubmitHandler), this._restoreSubmittingAttributeState(), this._cleanupBlurValidation(), this._stopReactiveDataObserver();
|
|
5175
5176
|
}
|
|
5176
5177
|
reset() {
|
|
5177
5178
|
this._clearErrors(), this._formData ? this._applyFormData() : this.clear();
|
|
@@ -5186,7 +5187,9 @@ var T = class extends HTMLElement {
|
|
|
5186
5187
|
});
|
|
5187
5188
|
})) : e === "headers" ? this._parseHeaders(n) : e === "loading" ? this.isConnected && this._form ? requestAnimationFrame(() => {
|
|
5188
5189
|
this._propagateLoadingState();
|
|
5189
|
-
}) : this._propagateLoadingState() : this.
|
|
5190
|
+
}) : this._propagateLoadingState() : e === "submitting" ? this.isConnected && this._form ? requestAnimationFrame(() => {
|
|
5191
|
+
this._applySubmittingAttributeState();
|
|
5192
|
+
}) : this._applySubmittingAttributeState() : this._applyFormAttributes();
|
|
5190
5193
|
}
|
|
5191
5194
|
get data() {
|
|
5192
5195
|
return this._formData;
|
|
@@ -5853,6 +5856,49 @@ var T = class extends HTMLElement {
|
|
|
5853
5856
|
typeof e.syncFiles == "function" && e.syncFiles();
|
|
5854
5857
|
});
|
|
5855
5858
|
}
|
|
5859
|
+
_isSubmittingAttrActive() {
|
|
5860
|
+
let e = this.getAttribute("submitting");
|
|
5861
|
+
return e !== null && e !== "false";
|
|
5862
|
+
}
|
|
5863
|
+
_applySubmittingAttributeState() {
|
|
5864
|
+
if (this._form) {
|
|
5865
|
+
if (!this._isSubmittingAttrActive()) {
|
|
5866
|
+
this._restoreSubmittingAttributeState();
|
|
5867
|
+
return;
|
|
5868
|
+
}
|
|
5869
|
+
this._attrSubmittingMintFields.size > 0 || this._attrSubmittingNativeFields.size > 0 || this._attrSubmittingMintButtons.size > 0 || this._attrSubmittingNativeButtons.size > 0 || (this._form.querySelectorAll("mint-input, mint-select, mint-date-picker, mint-dropzone, mint-checkbox, mint-choice, mint-switch, mint-tags").forEach((e) => {
|
|
5870
|
+
let t = e.getAttribute("disabled") === "true";
|
|
5871
|
+
this._attrSubmittingMintFields.set(e, t), t || e.setAttribute("disabled", "true"), typeof e.render == "function" && e.render();
|
|
5872
|
+
}), this._form.querySelectorAll("input, textarea, select").forEach((e) => {
|
|
5873
|
+
if (e.closest("mint-input, mint-select, mint-date-picker, mint-dropzone, mint-checkbox, mint-choice, mint-switch, mint-tags, mint-button") || e instanceof HTMLInputElement && e.type === "hidden") return;
|
|
5874
|
+
let t = e.disabled;
|
|
5875
|
+
this._attrSubmittingNativeFields.set(e, t), t || (e.disabled = !0);
|
|
5876
|
+
}), Array.from(this.querySelectorAll("mint-button")).forEach((e) => {
|
|
5877
|
+
let t = e.getAttribute("disabled") === "true", n = e.getAttribute("loading") === "true";
|
|
5878
|
+
this._attrSubmittingMintButtons.set(e, {
|
|
5879
|
+
disabled: t,
|
|
5880
|
+
loading: n
|
|
5881
|
+
});
|
|
5882
|
+
let r = (e.getAttribute("type") || e.getAttribute("button-type") || "default") === "submit";
|
|
5883
|
+
t || e.setAttribute("disabled", "true"), r && !n && e.setAttribute("loading", "true"), typeof e.render == "function" && e.render();
|
|
5884
|
+
}), Array.from(this.querySelectorAll("button")).forEach((e) => {
|
|
5885
|
+
if (e.closest("mint-button")) return;
|
|
5886
|
+
let t = e.disabled;
|
|
5887
|
+
this._attrSubmittingNativeButtons.set(e, t), t || (e.disabled = !0);
|
|
5888
|
+
}));
|
|
5889
|
+
}
|
|
5890
|
+
}
|
|
5891
|
+
_restoreSubmittingAttributeState() {
|
|
5892
|
+
this._attrSubmittingMintFields.forEach((e, t) => {
|
|
5893
|
+
e ? t.setAttribute("disabled", "true") : t.removeAttribute("disabled"), typeof t.render == "function" && t.render();
|
|
5894
|
+
}), this._attrSubmittingMintFields.clear(), this._attrSubmittingNativeFields.forEach((e, t) => {
|
|
5895
|
+
t.disabled = e;
|
|
5896
|
+
}), this._attrSubmittingNativeFields.clear(), this._attrSubmittingMintButtons.forEach((e, t) => {
|
|
5897
|
+
e.disabled ? t.setAttribute("disabled", "true") : t.removeAttribute("disabled"), e.loading ? t.setAttribute("loading", "true") : t.removeAttribute("loading"), typeof t.render == "function" && t.render();
|
|
5898
|
+
}), this._attrSubmittingMintButtons.clear(), this._attrSubmittingNativeButtons.forEach((e, t) => {
|
|
5899
|
+
t.disabled = e;
|
|
5900
|
+
}), this._attrSubmittingNativeButtons.clear();
|
|
5901
|
+
}
|
|
5856
5902
|
_propagateLoadingState() {
|
|
5857
5903
|
if (!this._form) return;
|
|
5858
5904
|
let e = this.getAttribute("loading"), t = e !== null && e !== "false";
|
|
@@ -5883,14 +5929,15 @@ var T = class extends HTMLElement {
|
|
|
5883
5929
|
}
|
|
5884
5930
|
_restoreButtonsState() {
|
|
5885
5931
|
if (!this._form) return;
|
|
5886
|
-
let e = Array.from(this.querySelectorAll("mint-button")),
|
|
5887
|
-
|
|
5888
|
-
|
|
5889
|
-
|
|
5890
|
-
|
|
5891
|
-
|
|
5892
|
-
|
|
5893
|
-
|
|
5932
|
+
let e = this._isSubmittingAttrActive() && (this._attrSubmittingMintButtons.size > 0 || this._attrSubmittingNativeButtons.size > 0), t = Array.from(this.querySelectorAll("mint-button")), n = Array.from(this.querySelectorAll("button"));
|
|
5933
|
+
t.forEach((t) => {
|
|
5934
|
+
if (e && this._attrSubmittingMintButtons.has(t)) return;
|
|
5935
|
+
let n = this._buttonStates.get(t);
|
|
5936
|
+
n && (n.disabled ? t.setAttribute("disabled", "true") : t.removeAttribute("disabled"), n.loading ? t.setAttribute("loading", "true") : t.removeAttribute("loading"), typeof t.render == "function" && t.render());
|
|
5937
|
+
}), n.forEach((t) => {
|
|
5938
|
+
if (t.closest("mint-button") || e && this._attrSubmittingNativeButtons.has(t)) return;
|
|
5939
|
+
let n = this._buttonStates.get(t);
|
|
5940
|
+
n && (t.disabled = n.disabled);
|
|
5894
5941
|
}), this._buttonStates.clear();
|
|
5895
5942
|
}
|
|
5896
5943
|
_isReactiveObject(e) {
|