monobill-mintui 0.6.737 → 0.6.739

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.
Files changed (177) hide show
  1. package/bin/component-dependencies.json +2 -1
  2. package/dist/components/alert/browser.js +4 -4
  3. package/dist/components/alert/index.cjs +1 -1
  4. package/dist/components/alert/index.js +4 -4
  5. package/dist/components/back-button/browser.js +1 -1
  6. package/dist/components/back-button/index.cjs +1 -1
  7. package/dist/components/back-button/index.js +1 -1
  8. package/dist/components/bottom-navigation/browser.js +2 -2
  9. package/dist/components/bottom-navigation/index.cjs +1 -1
  10. package/dist/components/bottom-navigation/index.js +2 -2
  11. package/dist/components/button/browser.js +1 -1
  12. package/dist/components/button/index.cjs +1 -1
  13. package/dist/components/button/index.js +1 -1
  14. package/dist/components/checkbox/browser.js +1 -1
  15. package/dist/components/checkbox/index.cjs +1 -1
  16. package/dist/components/checkbox/index.js +1 -1
  17. package/dist/components/chip/browser.js +1 -1
  18. package/dist/components/chip/index.cjs +1 -1
  19. package/dist/components/chip/index.js +1 -1
  20. package/dist/components/chunks/ScrollFade-58GqgRLY.js +1 -0
  21. package/dist/components/chunks/ScrollFade-kpfpO4Zb.js +160 -0
  22. package/dist/components/chunks/{back-button-C_aLMNZE.js → back-button-CQ3ZKGa1.js} +1 -1
  23. package/dist/components/chunks/{back-button-CMZR-p_D.js → back-button-DpPfWpAh.js} +2 -2
  24. package/dist/components/chunks/{button-THsh4Svz.js → button-CIuVIyLf.js} +2 -2
  25. package/dist/components/chunks/{button-CELyLLtj.js → button-CgymemwA.js} +1 -1
  26. package/dist/components/chunks/{caret-down-DUfiCBEs.js → caret-down-CikQdiAu.js} +1 -1
  27. package/dist/components/chunks/caret-down-DZinO2Vg.js +1 -0
  28. package/dist/components/chunks/caret-right-CMZIcNYV.js +1 -0
  29. package/dist/components/chunks/{caret-right-CppgjbLX.js → caret-right-ZvpF7jIK.js} +1 -1
  30. package/dist/components/chunks/{checkbox-d5UlscqI.js → checkbox-98ctQydC.js} +1 -1
  31. package/dist/components/chunks/{checkbox-CZViKLNo.js → checkbox-B8VzPrhn.js} +2 -2
  32. package/dist/components/chunks/{chip-G6SRCgLq.js → chip-Cqm_NPF5.js} +3 -3
  33. package/dist/components/chunks/{chip-DJ_kZURn.js → chip-dVw8BZP7.js} +1 -1
  34. package/dist/components/chunks/{close-ChHICicN.js → close-DtRLefjU.js} +1 -1
  35. package/dist/components/chunks/close-DuS1TdUB.js +1 -0
  36. package/dist/components/chunks/{confirm-action-BSHfjDfA.js → confirm-action-8Yx0K5j1.js} +1 -1
  37. package/dist/components/chunks/{confirm-action-CRZMTjpd.js → confirm-action-C0XX_TyJ.js} +2 -2
  38. package/dist/components/chunks/{date-picker-CTtYAkmM.js → date-picker-BJ_82oRR.js} +1 -1
  39. package/dist/components/chunks/{date-picker-CUf5eJR3.js → date-picker-BuJJ8gvT.js} +5 -5
  40. package/dist/components/chunks/icon-Cmx9FTmb.js +1 -0
  41. package/dist/components/chunks/{icon-1cs-hcBy.js → icon-CuRTWM4k.js} +67 -57
  42. package/dist/components/chunks/icon-pgeP1zxb.js +51 -0
  43. package/dist/components/chunks/icon-rdeLRs-R.js +1 -0
  44. package/dist/components/chunks/{input-Bu4xPosP.js → input-BpcFd35m.js} +3 -3
  45. package/dist/components/chunks/{input-Zqw53jts.js → input-DJaqPjMg.js} +1 -1
  46. package/dist/components/chunks/{modal-CL5EStu0.js → modal-BJtuPK1b.js} +1 -1
  47. package/dist/components/chunks/{modal-ss_OTDJJ.js → modal-BzRle8yT.js} +2 -2
  48. package/dist/components/chunks/{popover-DD7uyRXy.js → popover-BcN2LEbO.js} +15 -3
  49. package/dist/components/chunks/popover-N3cKN8iW.js +1 -0
  50. package/dist/components/chunks/search-DA6dk5kF.js +1 -0
  51. package/dist/components/chunks/{search-DKHcIR2F.js → search-Dw9cb1wC.js} +1 -1
  52. package/dist/components/chunks/{select-CX9oOwl5.js → select-Ctps8gPL.js} +1 -1
  53. package/dist/components/chunks/{select-DOMW7Plx.js → select-DPERiupq.js} +3 -3
  54. package/dist/components/chunks/sortable-Bj0VTUqS.js +1 -0
  55. package/dist/components/chunks/{sortable-CQtdBuGw.js → sortable-DWfdFpgA.js} +59 -22
  56. package/dist/components/chunks/{table-HnSpIfny.js → table-C4xUMQw6.js} +1 -1
  57. package/dist/components/chunks/{table-IU2Vmjwk.js → table-k97RfsAA.js} +1 -1
  58. package/dist/components/chunks/{time-picker-C7pJvGSM.js → time-picker-Bl8KsaJj.js} +3 -3
  59. package/dist/components/chunks/{time-picker-BaoT0NtA.js → time-picker-D74vZTpL.js} +1 -1
  60. package/dist/components/chunks/{warning-gkij2FhS.js → warning-B1-z7ww9.js} +1 -1
  61. package/dist/components/chunks/{warning-Cf8ePVsQ.js → warning-CfJwI6nV.js} +1 -1
  62. package/dist/components/confirm-action/browser.js +1 -1
  63. package/dist/components/confirm-action/index.cjs +1 -1
  64. package/dist/components/confirm-action/index.js +1 -1
  65. package/dist/components/date-picker/browser.js +1 -1
  66. package/dist/components/date-picker/index.cjs +1 -1
  67. package/dist/components/date-picker/index.js +1 -1
  68. package/dist/components/datetime-picker/browser.js +3 -3
  69. package/dist/components/datetime-picker/index.cjs +1 -1
  70. package/dist/components/datetime-picker/index.js +3 -3
  71. package/dist/components/dropzone/browser.js +4 -4
  72. package/dist/components/dropzone/index.cjs +1 -1
  73. package/dist/components/dropzone/index.js +4 -4
  74. package/dist/components/editor/Editor.d.ts +29 -2
  75. package/dist/components/editor/Editor.d.ts.map +1 -1
  76. package/dist/components/editor/browser.js +583 -232
  77. package/dist/components/editor/index.cjs +14 -8
  78. package/dist/components/editor/index.d.ts +2 -0
  79. package/dist/components/editor/index.d.ts.map +1 -1
  80. package/dist/components/editor/index.js +583 -232
  81. package/dist/components/form/Form.d.ts +5 -1
  82. package/dist/components/form/Form.d.ts.map +1 -1
  83. package/dist/components/form/browser.js +52 -40
  84. package/dist/components/form/index.cjs +1 -1
  85. package/dist/components/form/index.js +52 -40
  86. package/dist/components/icon/browser.js +1 -1
  87. package/dist/components/icon/icons/index.d.ts +1 -0
  88. package/dist/components/icon/icons/index.d.ts.map +1 -1
  89. package/dist/components/icon/icons/play.d.ts +3 -0
  90. package/dist/components/icon/icons/play.d.ts.map +1 -0
  91. package/dist/components/icon/index.cjs +1 -1
  92. package/dist/components/icon/index.js +1 -1
  93. package/dist/components/input/browser.js +1 -1
  94. package/dist/components/input/index.cjs +1 -1
  95. package/dist/components/input/index.js +1 -1
  96. package/dist/components/link/browser.js +1 -1
  97. package/dist/components/link/index.cjs +1 -1
  98. package/dist/components/link/index.js +1 -1
  99. package/dist/components/modal/browser.js +1 -1
  100. package/dist/components/modal/index.cjs +1 -1
  101. package/dist/components/modal/index.js +1 -1
  102. package/dist/components/navigation/browser.js +4 -4
  103. package/dist/components/navigation/index.cjs +1 -1
  104. package/dist/components/navigation/index.js +4 -4
  105. package/dist/components/off-canvas/browser.js +2 -2
  106. package/dist/components/off-canvas/index.cjs +1 -1
  107. package/dist/components/off-canvas/index.js +2 -2
  108. package/dist/components/page/browser.js +4 -4
  109. package/dist/components/page/index.cjs +1 -1
  110. package/dist/components/page/index.js +4 -4
  111. package/dist/components/popover/Popover.d.ts +4 -0
  112. package/dist/components/popover/Popover.d.ts.map +1 -1
  113. package/dist/components/popover/browser.js +1 -1
  114. package/dist/components/popover/index.cjs +1 -1
  115. package/dist/components/popover/index.js +1 -1
  116. package/dist/components/resource-table/browser.js +11 -11
  117. package/dist/components/resource-table/index.cjs +1 -1
  118. package/dist/components/resource-table/index.js +11 -11
  119. package/dist/components/scroll-fade/ScrollFade.d.ts.map +1 -1
  120. package/dist/components/scroll-fade/browser.js +1 -1
  121. package/dist/components/scroll-fade/index.cjs +1 -1
  122. package/dist/components/scroll-fade/index.js +1 -1
  123. package/dist/components/search/browser.js +7 -7
  124. package/dist/components/search/index.cjs +1 -1
  125. package/dist/components/search/index.js +7 -7
  126. package/dist/components/select/browser.js +1 -1
  127. package/dist/components/select/index.cjs +1 -1
  128. package/dist/components/select/index.js +1 -1
  129. package/dist/components/side-navigation/browser.js +6 -6
  130. package/dist/components/side-navigation/index.cjs +1 -1
  131. package/dist/components/side-navigation/index.js +6 -6
  132. package/dist/components/sortable/Sortable.d.ts +8 -0
  133. package/dist/components/sortable/Sortable.d.ts.map +1 -1
  134. package/dist/components/sortable/browser.js +1 -1
  135. package/dist/components/sortable/index.cjs +1 -1
  136. package/dist/components/sortable/index.js +1 -1
  137. package/dist/components/switch/browser.js +2 -2
  138. package/dist/components/switch/index.cjs +1 -1
  139. package/dist/components/switch/index.js +2 -2
  140. package/dist/components/table/browser.js +1 -1
  141. package/dist/components/table/index.cjs +1 -1
  142. package/dist/components/table/index.js +1 -1
  143. package/dist/components/tabs/browser.js +1 -1
  144. package/dist/components/tabs/index.cjs +1 -1
  145. package/dist/components/tabs/index.js +1 -1
  146. package/dist/components/tags/Tags.d.ts.map +1 -1
  147. package/dist/components/tags/browser.js +8 -17
  148. package/dist/components/tags/index.cjs +1 -1
  149. package/dist/components/tags/index.js +8 -17
  150. package/dist/components/time-picker/browser.js +1 -1
  151. package/dist/components/time-picker/index.cjs +1 -1
  152. package/dist/components/time-picker/index.js +1 -1
  153. package/dist/components/tree/browser.js +5 -5
  154. package/dist/components/tree/index.cjs +1 -1
  155. package/dist/components/tree/index.js +5 -5
  156. package/dist/editor.css +1 -1
  157. package/dist/icons/play.svg +3 -0
  158. package/dist/index.cjs +19 -13
  159. package/dist/index.css +3 -3
  160. package/dist/index.js +1080 -595
  161. package/dist/navigation-search.json +8 -1
  162. package/dist/scroll-fade.css +1 -1
  163. package/dist/tags.css +1 -1
  164. package/package.json +1 -1
  165. package/dist/components/chunks/ScrollFade-DOnPtfC2.js +0 -85
  166. package/dist/components/chunks/ScrollFade-FBvsnQ1i.js +0 -1
  167. package/dist/components/chunks/caret-down-BiAVkpX7.js +0 -1
  168. package/dist/components/chunks/caret-right-8n-rhz51.js +0 -1
  169. package/dist/components/chunks/close-CuYimzX0.js +0 -1
  170. package/dist/components/chunks/icon-Bv1J3LwC.js +0 -51
  171. package/dist/components/chunks/icon-C-6HOPtI.js +0 -1
  172. package/dist/components/chunks/icon-aNwWb0hA.js +0 -1
  173. package/dist/components/chunks/popover-2Cnva3AN.js +0 -1
  174. package/dist/components/chunks/search-BXku4V9r.js +0 -1
  175. package/dist/components/chunks/sortable-Brecvk9d.js +0 -1
  176. /package/dist/components/chunks/{link-B_fNmwOk.js → link-B4Hdsb2b.js} +0 -0
  177. /package/dist/components/chunks/{link-BxTQfAW9.js → link-rv2WDJw2.js} +0 -0
@@ -1 +1 @@
1
- const e=require(`./icon-Bv1J3LwC.js`),t=require(`./register-element-tCL_F1YI.js`);require(`./icon-C-6HOPtI.js`),require(`./caret-down-BiAVkpX7.js`),e.a({name:`caret-up`,viewBox:`0 0 24 24`,path:`M5 15l7-7 7 7`,strokeLinecap:`round`,strokeLinejoin:`round`});var n=class extends HTMLElement{static get observedAttributes(){return[`type`,`placeholder`,`value`,`disabled`,`id`,`name`,`required`,`readonly`,`rows`,`min`,`max`,`step`,`decimal-places`,`thousands-separator`,`decimal-point`,`icon`,`label`,`info`,`error`,`error-message`,`loading`,`aria-label`,`aria-labelledby`,`aria-describedby`]}constructor(){super(),this._input=null,this._textarea=null,this._element=null,this._wrapper=null,this._icon=null,this._prependSlotContainer=null,this._appendSlotContainer=null,this._colorPicker=null,this._colorTextInput=null,this._colorContainer=null,this._colorPickerWrapper=null,this._numberSpinnerContainer=null,this._numberIncrementButton=null,this._numberDecrementButton=null,this._contentObserver=null,this._focusHandler=null,this._a11yId=``,this._blurHandler=null,this._clickHandler=null,this._clickOutsideHandler=null,this._renderFrame=null}connectedCallback(){this.classList.add(`mint-input-host`),this.render(),this._observeContentMutations()}disconnectedCallback(){this.removeEventListeners(),this._contentObserver&&=(this._contentObserver.disconnect(),null),this._renderFrame!==null&&(cancelAnimationFrame(this._renderFrame),this._renderFrame=null)}attributeChangedCallback(e,t,n){if(t!==n){if(e===`error`||e===`error-message`){this._renderErrorState(),this._syncControlAccessibility(),this._element&&(this._element.className=this.getInputClasses()),this._colorTextInput&&(this._colorTextInput.className=this.getInputClasses());return}if(e===`loading`){this.render();return}this.render()}}_scheduleRender(){this._renderFrame===null&&(this._renderFrame=requestAnimationFrame(()=>{this._renderFrame=null,this.render()}))}_observeContentMutations(){this._contentObserver||=new MutationObserver(e=>{e.some(e=>e.type===`childList`?e.target===this:e.type===`attributes`&&e.target.hasAttribute(`slot`))&&this._scheduleRender()}),this._contentObserver.disconnect(),this._contentObserver.observe(this,{childList:!0,attributes:!0,attributeFilter:[`slot`]})}getType(){return this.getAttribute(`type`)||`text`}getRows(){let e=this.getAttribute(`rows`);return e?parseInt(e,10):3}_getNormalizedType(){let e=this.getType();return e===`datetime`?`datetime-local`:e===`money`?`text`:e===`textarea`?`textarea`:e}_isTextarea(){return this.getType()===`textarea`}_isMoney(){return this.getType()===`money`}_getMoneyDecimalPlaces(){let e=this.getAttribute(`decimal-places`);return e===null||!/^\d+$/.test(e)?2:Math.min(20,Number(e))}_formatMoneyValue(e,t){let n=e.trim();if(!n)return``;let r=this._getMoneyDecimalPlaces(),i=this.getAttribute(`decimal-point`)??`.`,a=this.getAttribute(`thousands-separator`)??`,`,o=i||`.`,s=a===o?``:a,c=/^\(.*\)$/.test(n),l=c?n.slice(1,-1).trim():n;s&&(l=l.split(s).join(``)),l=l.replace(/[\s$€£¥₹₩₽¢]/g,``);let u=l.split(o);u.length>2&&u.splice(1,u.length-1,u.slice(1).join(``));let d=u[0]??``,f=u.length>1?u[1]:``,p=c||d.startsWith(`-`);if((d.startsWith(`+`)||d.startsWith(`-`))&&(d=d.slice(1)),!/^\d*$/.test(d)||!/^\d*$/.test(f))return null;let m=u.length>1;if(!d&&!f)return m&&t?`${p?`-`:``}0${o}${`0`.repeat(r)}`:!t&&(p||m)?p?`-`:`0${o}`:null;d=(d||`0`).replace(/^0+(?=\d)/,``);let h=f.slice(0,r),g=t?h.padEnd(r,`0`):h;if(t&&f.length>r){let e=10n**BigInt(r),t=BigInt(`${d}${g}`||`0`),n=f[r]>=`5`?t+1n:t;d=(n/e).toString(),g=r?(n%e).toString().padStart(r,`0`):``}let _=s?d.replace(/\B(?=(\d{3})+(?!\d))/g,s):d;return`${p?`-`:``}${_}${r>0&&(t||m)?`${o}${t?g:h}`:``}`}_formatMoneyInput(e){if(!this._isMoney()||!this._input)return;let t=this._input,n=t.value,r=t.selectionStart??n.length,i=n.slice(0,r),a=this.getAttribute(`decimal-point`)??`.`,o=i.indexOf(a||`.`),s=(o<0?i:i.slice(0,o)).replace(/\D/g,``).length,c=o<0?0:i.slice(o+(a||`.`).length).replace(/\D/g,``).length,l=o>=0,u=this._formatMoneyValue(n,e)??`0`;if(u!==n&&(t.value=u,document.activeElement===t)){let e=0;if(l){let t=u.indexOf(a||`.`);if(t>=0){e=t+(a||`.`).length;let n=0;for(;e<u.length&&n<c;)/\d/.test(u[e])&&n++,e++}else e=u.length}else{let t=0;for(u.startsWith(`-`)&&i.startsWith(`-`)&&(e=1);e<u.length&&t<s;)/\d/.test(u[e])&&t++,e++}t.setSelectionRange(e,e)}}_isColor(){return this.getType()===`color`}_isNumber(){return this.getType()===`number`}getPlaceholder(){return this.getAttribute(`placeholder`)||``}getValue(){return this._isColor()?this._colorTextInput?this._colorTextInput.value:this._colorPicker?this._colorPicker.value:this.getAttribute(`value`)||`#000000`:this._element?this._element.value:this.getAttribute(`value`)||``}set value(e){try{this._isColor()?(this._colorPicker&&(this._colorPicker.value=e||`#000000`),this._colorTextInput&&(this._colorTextInput.value=e||`#000000`)):this._element&&(this._element.value=e),e?this.setAttribute(`value`,e):this.removeAttribute(`value`)}catch{}}get value(){try{return this.getValue()||``}catch{return``}}isDisabled(){return this.getAttribute(`disabled`)===`true`}isReadonly(){return this.getAttribute(`readonly`)===`true`}isRequired(){return this.getAttribute(`required`)===`true`}hasError(){return this.getAttribute(`error`)===`true`}getErrorMessage(){return this.getAttribute(`error-message`)||``}getId(){return this.getAttribute(`id`)||``}getName(){return this.getAttribute(`name`)||``}getIcon(){return this.getAttribute(`icon`)||``}getLabel(){return this.getAttribute(`label`)||``}getInfo(){return this.getAttribute(`info`)||``}getInputClasses(){let e=this._isTextarea(),t=!!this.getIcon(),n=this.querySelector(`[slot="prepend"]`)!==null,r=this.querySelector(`[slot="append"]`)!==null,i=this._isColor(),a=this._isNumber(),o=this.hasError();return[`mint-input-control`,e&&`is-textarea`,t&&`has-icon`,i&&`is-color`,n&&`has-prepend`,r&&`has-append`,a&&`is-number`,o&&`has-error`].filter(Boolean).join(` `)}_syncSlotAdornments(e,t){if(!this._wrapper)return;if(e||this._isColor()){this._prependSlotContainer?.classList.add(`is-hidden`),this._appendSlotContainer?.classList.add(`is-hidden`);return}this._prependSlotContainer||(this._prependSlotContainer=document.createElement(`div`),this._prependSlotContainer.className=`mint-input-adornment mint-input-prepend-slot`,this._wrapper.appendChild(this._prependSlotContainer)),this._appendSlotContainer||(this._appendSlotContainer=document.createElement(`div`),this._appendSlotContainer.className=`mint-input-adornment mint-input-append-slot`,this._wrapper.appendChild(this._appendSlotContainer)),[...Array.from(this._prependSlotContainer.querySelectorAll(`[slot]`)),...Array.from(this._appendSlotContainer.querySelectorAll(`[slot]`)),...Array.from(this.querySelectorAll(`:scope > [slot="prepend"], :scope > [slot="append"]`))].forEach(e=>{e.getAttribute(`slot`)===`prepend`?this._prependSlotContainer.appendChild(e):e.getAttribute(`slot`)===`append`&&this._appendSlotContainer.appendChild(e)});let n=Array.from(this._prependSlotContainer.querySelectorAll(`[slot="prepend"]`)),r=Array.from(this._appendSlotContainer.querySelectorAll(`[slot="append"]`));this._prependSlotContainer.classList.toggle(`is-hidden`,n.length===0),this._appendSlotContainer.classList.toggle(`is-hidden`,r.length===0),t&&n.length?this._wrapper.style.setProperty(`--mint-input-icon-left`,`${this._prependSlotContainer.getBoundingClientRect().width+8}px`):this._wrapper.style.removeProperty(`--mint-input-icon-left`),this._element&&(n.length&&this._wrapper.insertBefore(this._prependSlotContainer,this._element),r.length&&this._element.insertAdjacentElement(`afterend`,this._appendSlotContainer))}isLoading(){return this.getAttribute(`loading`)===`true`}render(){this.getType();let e=this._getNormalizedType(),t=this._isTextarea(),n=this._isMoney(),r=this._isColor(),i=this.getPlaceholder(),a=this.isDisabled(),o=this.isReadonly(),s=this.isRequired(),c=this.getId(),l=this.getName(),u=this.getAttribute(`value`)||(r?`#000000`:``),d=this.getRows(),f=this.getIcon(),p=this.getLabel(),m=this.getInfo(),h=this.isLoading();if(r&&this._renderSkeleton(h),r){this._input&&=(this._input.remove(),null),this._textarea&&=(this._textarea.remove(),null),this._wrapper||(this._wrapper=document.createElement(`div`),this._wrapper.className=`mint-input-wrapper`,this.appendChild(this._wrapper)),this._colorContainer&&=(this._colorContainer.remove(),null),this._colorPickerWrapper&&!r&&(this._colorPickerWrapper.remove(),this._colorPickerWrapper=null),this._colorPickerWrapper||(this._colorPickerWrapper=document.createElement(`div`),this._colorPickerWrapper.className=`mint-color-picker-wrapper`,this._wrapper.appendChild(this._colorPickerWrapper),this._colorPicker=document.createElement(`input`),this._colorPicker.type=`color`,this._colorPicker.className=`mint-color-picker`,this._colorPickerWrapper.appendChild(this._colorPicker),this._focusHandler=e=>{this._colorPickerWrapper&&this._colorPicker&&this._colorPicker.matches(`:focus-visible`)&&requestAnimationFrame(()=>{this._colorPicker&&this._colorPicker.matches(`:focus-visible`)&&this._colorPickerWrapper?.classList.add(`is-focused`)})},this._blurHandler=()=>{this._colorPickerWrapper&&this._colorPickerWrapper.classList.remove(`is-focused`)},this._colorPicker.addEventListener(`focus`,this._focusHandler),this._colorPicker.addEventListener(`blur`,this._blurHandler),this._colorPicker.addEventListener(`input`,()=>{let e=this._colorPicker?.value||`#000000`;this._colorTextInput&&(this._colorTextInput.value=e),this.setAttribute(`value`,e),this.dispatchEvent(new CustomEvent(`input`,{detail:{value:e},bubbles:!0,cancelable:!0}))}),this._colorPicker.addEventListener(`change`,()=>{let e=this._colorPicker?.value||`#000000`;this.setAttribute(`value`,e),this.dispatchEvent(new CustomEvent(`change`,{detail:{value:e},bubbles:!0,cancelable:!0}))})),this._colorTextInput||(this._colorTextInput=document.createElement(`input`),this._colorTextInput.type=`text`,this._colorTextInput.className=this.getInputClasses(),this._colorTextInput.placeholder=i||`#000000`,this._colorTextInput.pattern=`^#[0-9A-Fa-f]{6}$`,this._wrapper.appendChild(this._colorTextInput),this._colorTextInput.addEventListener(`input`,()=>{let e=this._colorTextInput?.value||``;/^#[0-9A-Fa-f]{6}$/.test(e)&&(this._colorPicker&&(this._colorPicker.value=e),this.setAttribute(`value`,e),this.dispatchEvent(new CustomEvent(`input`,{detail:{value:e},bubbles:!0,cancelable:!0})))}),this._colorTextInput.addEventListener(`blur`,()=>{let e=this._colorTextInput?.value||``;/^#[0-9A-Fa-f]{6}$/.test(e)?(this._colorPicker&&(this._colorPicker.value=e),this.setAttribute(`value`,e)):this._colorPicker&&this._colorTextInput&&(this._colorTextInput.value=this._colorPicker.value),this.dispatchEvent(new CustomEvent(`change`,{detail:{value:this._colorPicker?.value||`#000000`},bubbles:!0,cancelable:!0}))}));let e=u||`#000000`;if(this._colorPicker&&this._colorPicker.value!==e&&(this._colorPicker.value=e),this._colorTextInput&&this._colorTextInput.value!==e&&(this._colorTextInput.value=e),this._colorPicker&&(this._colorPicker.disabled=a),this._colorPickerWrapper&&(a?this._colorPickerWrapper.classList.add(`is-disabled`):this._colorPickerWrapper.classList.remove(`is-disabled`)),this._colorTextInput&&(this._colorTextInput.disabled=a,this._colorTextInput.readOnly=o,this._colorTextInput.required=s),this._colorTextInput){let e=this._colorTextInput;c?e.id=c:e.removeAttribute(`id`),l?e.name=l:e.removeAttribute(`name`),e.setAttribute(`aria-invalid`,this.hasError()?`true`:`false`),this._element=e}this._renderErrorState();let t=this.querySelector(`.mint-input-label-container`);if(p||m){t||(t=document.createElement(`div`),t.className=`mint-input-label-container`,this._wrapper&&this._wrapper.parentElement===this?this.insertBefore(t,this._wrapper):this.insertBefore(t,this.firstChild));let e=t.querySelector(`.mint-input-label`);if(p){e||(e=document.createElement(`label`),e.className=`mint-input-label`,t.insertBefore(e,t.firstChild)),e.textContent=p;let n=c||this._colorTextInput?.id;if(n)e.setAttribute(`for`,n);else{let t=`mint-input-${Math.random().toString(36).substr(2,9)}`;this._colorTextInput&&(this._colorTextInput.id=t),e.setAttribute(`for`,t)}a?e.classList.add(`is-disabled`):e.classList.remove(`is-disabled`)}else e&&e.remove();let n=t.querySelector(`.mint-input-info`);m?(n||(n=document.createElement(`span`),n.className=`mint-input-info`,t.appendChild(n)),n.textContent=m,a?n.classList.add(`is-disabled`):n.classList.remove(`is-disabled`)):n&&n.remove()}else t&&t.remove();return}if(this._wrapper||(this._wrapper=document.createElement(`div`),this._wrapper.className=`mint-input-wrapper`,this.appendChild(this._wrapper)),this._colorContainer&&(this._colorContainer.remove(),this._colorContainer=null,this._colorPicker=null,this._colorTextInput=null),this._colorPickerWrapper&&!r&&(this._colorPickerWrapper.remove(),this._colorPickerWrapper=null,this._colorPicker=null,this._colorTextInput=null),f&&!t?this._icon?this._icon.setAttribute(`name`,f):(this._icon=document.createElement(`mint-icon`),this._icon.setAttribute(`name`,f),this._icon.className=`mint-input-icon`,this._wrapper.appendChild(this._icon)):this._icon&&=(this._icon.remove(),null),this._syncSlotAdornments(t,!!f),this._isNumber()&&!t){if(!this._numberSpinnerContainer){this._numberSpinnerContainer=document.createElement(`div`),this._numberSpinnerContainer.className=`mint-input-spinner`,this._wrapper.appendChild(this._numberSpinnerContainer),this._numberIncrementButton=document.createElement(`button`),this._numberIncrementButton.type=`button`,this._numberIncrementButton.className=`mint-input-spinner-button`;let e=document.createElement(`mint-icon`);e.setAttribute(`name`,`caret-up`),e.className=`mint-input-spinner-icon`,this._numberIncrementButton.appendChild(e),this._numberSpinnerContainer.appendChild(this._numberIncrementButton),this._numberDecrementButton=document.createElement(`button`),this._numberDecrementButton.type=`button`,this._numberDecrementButton.className=`mint-input-spinner-button`;let t=document.createElement(`mint-icon`);t.setAttribute(`name`,`caret-down`),t.className=`mint-input-spinner-icon`,this._numberDecrementButton.appendChild(t),this._numberSpinnerContainer.appendChild(this._numberDecrementButton),this._numberIncrementButton.addEventListener(`click`,e=>{if(e.preventDefault(),e.stopPropagation(),this._input&&!this._input.disabled&&!this._input.readOnly){let e=parseFloat(this._input.value)||0,t=parseFloat(this._input.step)||1,n=this._input.min?parseFloat(this._input.min):void 0,r=this._input.max?parseFloat(this._input.max):void 0,i=e+t;r!==void 0&&i>r&&(i=r),n!==void 0&&i<n&&(i=n),this._input.value=i.toString(),this.setAttribute(`value`,i.toString()),this._input.dispatchEvent(new Event(`input`,{bubbles:!0})),this._input.dispatchEvent(new Event(`change`,{bubbles:!0}))}}),this._numberDecrementButton.addEventListener(`click`,e=>{if(e.preventDefault(),e.stopPropagation(),this._input&&!this._input.disabled&&!this._input.readOnly){let e=parseFloat(this._input.value)||0,t=parseFloat(this._input.step)||1,n=this._input.min?parseFloat(this._input.min):void 0,r=this._input.max?parseFloat(this._input.max):void 0,i=e-t;n!==void 0&&i<n&&(i=n),r!==void 0&&i>r&&(i=r),this._input.value=i.toString(),this.setAttribute(`value`,i.toString()),this._input.dispatchEvent(new Event(`input`,{bubbles:!0})),this._input.dispatchEvent(new Event(`change`,{bubbles:!0}))}})}this._numberIncrementButton&&(this._numberIncrementButton.disabled=a||o),this._numberDecrementButton&&(this._numberDecrementButton.disabled=a||o)}else this._numberSpinnerContainer&&(this._numberSpinnerContainer.remove(),this._numberSpinnerContainer=null,this._numberIncrementButton=null,this._numberDecrementButton=null);if(t){if(this._input&&=(this._input.remove(),null),this._textarea||(this._textarea=document.createElement(`textarea`),this._element=this._textarea,this._wrapper.appendChild(this._textarea),this.setupEventListeners()),this._element=this._textarea,this._textarea.placeholder=i,this._textarea.disabled=a,this._textarea.readOnly=o,this._textarea.required=s,this._textarea.rows=d,this._textarea.setAttribute(`aria-invalid`,this.hasError()?`true`:`false`),u!==this._textarea.value&&(this._textarea.value=u),c?this._textarea.id=c:this._textarea.removeAttribute(`id`),l?this._textarea.name=l:this._textarea.removeAttribute(`name`),this._textarea.className=this.getInputClasses(),this.firstChild&&this.firstChild!==this._wrapper&&this.firstChild.nodeType===Node.TEXT_NODE){let e=this.firstChild.textContent;e&&!this._textarea.value&&(this._textarea.value=e.trim()),this.removeChild(this.firstChild)}}else{this._textarea&&=(this._textarea.remove(),null),this._input||(this._input=document.createElement(`input`),this._element=this._input,this._wrapper.appendChild(this._input),this.setupEventListeners()),this._element=this._input,this._input.type=e,this._input.placeholder=i,this._input.disabled=a,this._input.readOnly=o,this._input.required=s,this._input.setAttribute(`aria-invalid`,this.hasError()?`true`:`false`),this._input.min=this.getAttribute(`min`)??``,this._input.max=this.getAttribute(`max`)??``,this._input.step=this.getAttribute(`step`)??``,n?(this._input.inputMode=`decimal`,this._input.removeAttribute(`pattern`)):(this._input.removeAttribute(`inputmode`),this._input.removeAttribute(`pattern`));let t=n&&document.activeElement===this._input;if(u!==this._input.value&&!t&&(this._input.value=u),c?this._input.id=c:this._input.removeAttribute(`id`),l?this._input.name=l:this._input.removeAttribute(`name`),this._input.className=this.getInputClasses(),this.firstChild&&this.firstChild!==this._wrapper&&this.firstChild.nodeType===Node.TEXT_NODE){let e=this.firstChild.textContent;e&&!this._input.value&&(this._input.value=e.trim()),this.removeChild(this.firstChild)}t||this._formatMoneyInput(!0)}let g=this.querySelector(`.mint-input-label-container`);if(p||m){g||(g=document.createElement(`div`),g.className=`mint-input-label-container`,this._wrapper&&this._wrapper.parentElement===this?this.insertBefore(g,this._wrapper):this.insertBefore(g,this.firstChild));let e=g.querySelector(`.mint-input-label`);if(p){e||(e=document.createElement(`label`),e.className=`mint-input-label`,g.insertBefore(e,g.firstChild)),e.textContent=p;let t=c||this._element?.id||this._colorTextInput?.id||this._input?.id||this._textarea?.id;if(t)e.setAttribute(`for`,t);else{let t=`mint-input-${Math.random().toString(36).substr(2,9)}`;this._element?this._element.id=t:this._colorTextInput?this._colorTextInput.id=t:this._input?this._input.id=t:this._textarea&&(this._textarea.id=t),e.setAttribute(`for`,t)}a?e.classList.add(`is-disabled`):e.classList.remove(`is-disabled`)}else e&&e.remove();let t=g.querySelector(`.mint-input-info`);m?(t||(t=document.createElement(`span`),t.className=`mint-input-info`,g.appendChild(t)),t.textContent=m,a?t.classList.add(`is-disabled`):t.classList.remove(`is-disabled`)):t&&t.remove()}else g&&g.remove();this._syncSlotAdornments(t,!!f),this._renderErrorState(),this._syncControlAccessibility(),this._renderSkeleton(h)}_renderErrorState(){let e=this.hasError(),t=this.getErrorMessage(),n=this.querySelector(`.mint-input-error`);e&&t?(n||(n=document.createElement(`div`),n.className=`mint-input-error`,this.appendChild(n)),n.textContent=t):n&&n.remove()}_syncControlAccessibility(){let e=this._element;if(!e)return;this._a11yId||=this.getId()||`mint-input-${Math.random().toString(36).slice(2,10)}`;let t=this.getAttribute(`aria-label`)?.trim(),n=!!this.querySelector(`.mint-input-label`);t?e.setAttribute(`aria-label`,t):!n&&this.getAttribute(`placeholder`)?.trim()?e.setAttribute(`aria-label`,this.getAttribute(`placeholder`).trim()):e.removeAttribute(`aria-label`);let r=this.querySelector(`.mint-input-info`),i=this.querySelector(`.mint-input-error`),a=(this.getAttribute(`aria-describedby`)||``).split(/\s+/).filter(Boolean);r&&(r.id=`${this._a11yId}-info`,a.push(r.id)),i&&(i.id=`${this._a11yId}-error`,a.push(i.id)),e.setAttribute(`aria-invalid`,String(this.hasError())),a.length?e.setAttribute(`aria-describedby`,Array.from(new Set(a)).join(` `)):e.removeAttribute(`aria-describedby`);let o=this.getAttribute(`aria-labelledby`)?.trim();o?e.setAttribute(`aria-labelledby`,o):e.removeAttribute(`aria-labelledby`)}setupEventListeners(){this._element&&(this._element.addEventListener(`beforeinput`,e=>{if(!this._isMoney()||!(e instanceof InputEvent)||!e.inputType.startsWith(`insert`))return;let t=this.getAttribute(`decimal-point`)??`.`,n=e.data??e.dataTransfer?.getData(`text/plain`)??``;if(!n)return;let r=this._input?.value.indexOf(t)??-1;if(t&&n===t&&r>=0){e.preventDefault();let n=r+t.length;this._input?.setSelectionRange(n,n);return}let i=t.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),a=t?RegExp(`[^0-9${i}]`,`g`):/[^0-9]/g;n.replace(a,``)!==n&&e.preventDefault()}),this._element.addEventListener(`input`,()=>{let e=this._element?.value||``;e?this.setAttribute(`value`,e):this.removeAttribute(`value`);let t=new Event(`input`,{bubbles:!0,cancelable:!0,composed:!0});this.dispatchEvent(t),this.dispatchEvent(new CustomEvent(`input`,{detail:{value:e},bubbles:!0,cancelable:!0,composed:!0}))}),this._element.addEventListener(`blur`,()=>{this._formatMoneyInput(!0);let e=this._element?.value||``;e?this.setAttribute(`value`,e):this.removeAttribute(`value`),this.dispatchEvent(new CustomEvent(`change`,{detail:{value:e},bubbles:!0,cancelable:!0}))}))}removeEventListeners(){this._colorPicker&&(this._focusHandler&&=(this._colorPicker.removeEventListener(`focus`,this._focusHandler),null),this._blurHandler&&=(this._colorPicker.removeEventListener(`blur`,this._blurHandler),null))}focus(){this._isColor()&&this._colorTextInput?this._colorTextInput.focus():this._element?.focus()}blur(){this._isColor()&&this._colorTextInput?this._colorTextInput.blur():this._element?.blur()}_renderSkeleton(e){this.classList.toggle(`is-loading`,e);let t=this.querySelector(`.mint-input-skeleton-container`),n=this._wrapper||this.querySelector(`.mint-input-wrapper`);if(e){t||(t=document.createElement(`div`),t.className=`mint-input-skeleton-container`,n?(n.classList.add(`mint-input-positioned`),n.appendChild(t)):(this.classList.add(`mint-input-positioned`),this.appendChild(t)));let e=t.querySelector(`.mint-input-skeleton`);e||(e=document.createElement(`div`),e.className=`mint-input-skeleton`,t.appendChild(e)),e.parentElement||t.appendChild(e)}}};customElements.get(`mint-input`)||t.t(`mint-input`,n),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return n}});
1
+ const e=require(`./icon-pgeP1zxb.js`),t=require(`./register-element-tCL_F1YI.js`);require(`./icon-rdeLRs-R.js`),require(`./caret-down-DZinO2Vg.js`),e.a({name:`caret-up`,viewBox:`0 0 24 24`,path:`M5 15l7-7 7 7`,strokeLinecap:`round`,strokeLinejoin:`round`});var n=class extends HTMLElement{static get observedAttributes(){return[`type`,`placeholder`,`value`,`disabled`,`id`,`name`,`required`,`readonly`,`rows`,`min`,`max`,`step`,`decimal-places`,`thousands-separator`,`decimal-point`,`icon`,`label`,`info`,`error`,`error-message`,`loading`,`aria-label`,`aria-labelledby`,`aria-describedby`]}constructor(){super(),this._input=null,this._textarea=null,this._element=null,this._wrapper=null,this._icon=null,this._prependSlotContainer=null,this._appendSlotContainer=null,this._colorPicker=null,this._colorTextInput=null,this._colorContainer=null,this._colorPickerWrapper=null,this._numberSpinnerContainer=null,this._numberIncrementButton=null,this._numberDecrementButton=null,this._contentObserver=null,this._focusHandler=null,this._a11yId=``,this._blurHandler=null,this._clickHandler=null,this._clickOutsideHandler=null,this._renderFrame=null}connectedCallback(){this.classList.add(`mint-input-host`),this.render(),this._observeContentMutations()}disconnectedCallback(){this.removeEventListeners(),this._contentObserver&&=(this._contentObserver.disconnect(),null),this._renderFrame!==null&&(cancelAnimationFrame(this._renderFrame),this._renderFrame=null)}attributeChangedCallback(e,t,n){if(t!==n){if(e===`error`||e===`error-message`){this._renderErrorState(),this._syncControlAccessibility(),this._element&&(this._element.className=this.getInputClasses()),this._colorTextInput&&(this._colorTextInput.className=this.getInputClasses());return}if(e===`loading`){this.render();return}this.render()}}_scheduleRender(){this._renderFrame===null&&(this._renderFrame=requestAnimationFrame(()=>{this._renderFrame=null,this.render()}))}_observeContentMutations(){this._contentObserver||=new MutationObserver(e=>{e.some(e=>e.type===`childList`?e.target===this:e.type===`attributes`&&e.target.hasAttribute(`slot`))&&this._scheduleRender()}),this._contentObserver.disconnect(),this._contentObserver.observe(this,{childList:!0,attributes:!0,attributeFilter:[`slot`]})}getType(){return this.getAttribute(`type`)||`text`}getRows(){let e=this.getAttribute(`rows`);return e?parseInt(e,10):3}_getNormalizedType(){let e=this.getType();return e===`datetime`?`datetime-local`:e===`money`?`text`:e===`textarea`?`textarea`:e}_isTextarea(){return this.getType()===`textarea`}_isMoney(){return this.getType()===`money`}_getMoneyDecimalPlaces(){let e=this.getAttribute(`decimal-places`);return e===null||!/^\d+$/.test(e)?2:Math.min(20,Number(e))}_formatMoneyValue(e,t){let n=e.trim();if(!n)return``;let r=this._getMoneyDecimalPlaces(),i=this.getAttribute(`decimal-point`)??`.`,a=this.getAttribute(`thousands-separator`)??`,`,o=i||`.`,s=a===o?``:a,c=/^\(.*\)$/.test(n),l=c?n.slice(1,-1).trim():n;s&&(l=l.split(s).join(``)),l=l.replace(/[\s$€£¥₹₩₽¢]/g,``);let u=l.split(o);u.length>2&&u.splice(1,u.length-1,u.slice(1).join(``));let d=u[0]??``,f=u.length>1?u[1]:``,p=c||d.startsWith(`-`);if((d.startsWith(`+`)||d.startsWith(`-`))&&(d=d.slice(1)),!/^\d*$/.test(d)||!/^\d*$/.test(f))return null;let m=u.length>1;if(!d&&!f)return m&&t?`${p?`-`:``}0${o}${`0`.repeat(r)}`:!t&&(p||m)?p?`-`:`0${o}`:null;d=(d||`0`).replace(/^0+(?=\d)/,``);let h=f.slice(0,r),g=t?h.padEnd(r,`0`):h;if(t&&f.length>r){let e=10n**BigInt(r),t=BigInt(`${d}${g}`||`0`),n=f[r]>=`5`?t+1n:t;d=(n/e).toString(),g=r?(n%e).toString().padStart(r,`0`):``}let _=s?d.replace(/\B(?=(\d{3})+(?!\d))/g,s):d;return`${p?`-`:``}${_}${r>0&&(t||m)?`${o}${t?g:h}`:``}`}_formatMoneyInput(e){if(!this._isMoney()||!this._input)return;let t=this._input,n=t.value,r=t.selectionStart??n.length,i=n.slice(0,r),a=this.getAttribute(`decimal-point`)??`.`,o=i.indexOf(a||`.`),s=(o<0?i:i.slice(0,o)).replace(/\D/g,``).length,c=o<0?0:i.slice(o+(a||`.`).length).replace(/\D/g,``).length,l=o>=0,u=this._formatMoneyValue(n,e)??`0`;if(u!==n&&(t.value=u,document.activeElement===t)){let e=0;if(l){let t=u.indexOf(a||`.`);if(t>=0){e=t+(a||`.`).length;let n=0;for(;e<u.length&&n<c;)/\d/.test(u[e])&&n++,e++}else e=u.length}else{let t=0;for(u.startsWith(`-`)&&i.startsWith(`-`)&&(e=1);e<u.length&&t<s;)/\d/.test(u[e])&&t++,e++}t.setSelectionRange(e,e)}}_isColor(){return this.getType()===`color`}_isNumber(){return this.getType()===`number`}getPlaceholder(){return this.getAttribute(`placeholder`)||``}getValue(){return this._isColor()?this._colorTextInput?this._colorTextInput.value:this._colorPicker?this._colorPicker.value:this.getAttribute(`value`)||`#000000`:this._element?this._element.value:this.getAttribute(`value`)||``}set value(e){try{this._isColor()?(this._colorPicker&&(this._colorPicker.value=e||`#000000`),this._colorTextInput&&(this._colorTextInput.value=e||`#000000`)):this._element&&(this._element.value=e),e?this.setAttribute(`value`,e):this.removeAttribute(`value`)}catch{}}get value(){try{return this.getValue()||``}catch{return``}}isDisabled(){return this.getAttribute(`disabled`)===`true`}isReadonly(){return this.getAttribute(`readonly`)===`true`}isRequired(){return this.getAttribute(`required`)===`true`}hasError(){return this.getAttribute(`error`)===`true`}getErrorMessage(){return this.getAttribute(`error-message`)||``}getId(){return this.getAttribute(`id`)||``}getName(){return this.getAttribute(`name`)||``}getIcon(){return this.getAttribute(`icon`)||``}getLabel(){return this.getAttribute(`label`)||``}getInfo(){return this.getAttribute(`info`)||``}getInputClasses(){let e=this._isTextarea(),t=!!this.getIcon(),n=this.querySelector(`[slot="prepend"]`)!==null,r=this.querySelector(`[slot="append"]`)!==null,i=this._isColor(),a=this._isNumber(),o=this.hasError();return[`mint-input-control`,e&&`is-textarea`,t&&`has-icon`,i&&`is-color`,n&&`has-prepend`,r&&`has-append`,a&&`is-number`,o&&`has-error`].filter(Boolean).join(` `)}_syncSlotAdornments(e,t){if(!this._wrapper)return;if(e||this._isColor()){this._prependSlotContainer?.classList.add(`is-hidden`),this._appendSlotContainer?.classList.add(`is-hidden`);return}this._prependSlotContainer||(this._prependSlotContainer=document.createElement(`div`),this._prependSlotContainer.className=`mint-input-adornment mint-input-prepend-slot`,this._wrapper.appendChild(this._prependSlotContainer)),this._appendSlotContainer||(this._appendSlotContainer=document.createElement(`div`),this._appendSlotContainer.className=`mint-input-adornment mint-input-append-slot`,this._wrapper.appendChild(this._appendSlotContainer)),[...Array.from(this._prependSlotContainer.querySelectorAll(`[slot]`)),...Array.from(this._appendSlotContainer.querySelectorAll(`[slot]`)),...Array.from(this.querySelectorAll(`:scope > [slot="prepend"], :scope > [slot="append"]`))].forEach(e=>{e.getAttribute(`slot`)===`prepend`?this._prependSlotContainer.appendChild(e):e.getAttribute(`slot`)===`append`&&this._appendSlotContainer.appendChild(e)});let n=Array.from(this._prependSlotContainer.querySelectorAll(`[slot="prepend"]`)),r=Array.from(this._appendSlotContainer.querySelectorAll(`[slot="append"]`));this._prependSlotContainer.classList.toggle(`is-hidden`,n.length===0),this._appendSlotContainer.classList.toggle(`is-hidden`,r.length===0),t&&n.length?this._wrapper.style.setProperty(`--mint-input-icon-left`,`${this._prependSlotContainer.getBoundingClientRect().width+8}px`):this._wrapper.style.removeProperty(`--mint-input-icon-left`),this._element&&(n.length&&this._wrapper.insertBefore(this._prependSlotContainer,this._element),r.length&&this._element.insertAdjacentElement(`afterend`,this._appendSlotContainer))}isLoading(){return this.getAttribute(`loading`)===`true`}render(){this.getType();let e=this._getNormalizedType(),t=this._isTextarea(),n=this._isMoney(),r=this._isColor(),i=this.getPlaceholder(),a=this.isDisabled(),o=this.isReadonly(),s=this.isRequired(),c=this.getId(),l=this.getName(),u=this.getAttribute(`value`)||(r?`#000000`:``),d=this.getRows(),f=this.getIcon(),p=this.getLabel(),m=this.getInfo(),h=this.isLoading();if(r&&this._renderSkeleton(h),r){this._input&&=(this._input.remove(),null),this._textarea&&=(this._textarea.remove(),null),this._wrapper||(this._wrapper=document.createElement(`div`),this._wrapper.className=`mint-input-wrapper`,this.appendChild(this._wrapper)),this._colorContainer&&=(this._colorContainer.remove(),null),this._colorPickerWrapper&&!r&&(this._colorPickerWrapper.remove(),this._colorPickerWrapper=null),this._colorPickerWrapper||(this._colorPickerWrapper=document.createElement(`div`),this._colorPickerWrapper.className=`mint-color-picker-wrapper`,this._wrapper.appendChild(this._colorPickerWrapper),this._colorPicker=document.createElement(`input`),this._colorPicker.type=`color`,this._colorPicker.className=`mint-color-picker`,this._colorPickerWrapper.appendChild(this._colorPicker),this._focusHandler=e=>{this._colorPickerWrapper&&this._colorPicker&&this._colorPicker.matches(`:focus-visible`)&&requestAnimationFrame(()=>{this._colorPicker&&this._colorPicker.matches(`:focus-visible`)&&this._colorPickerWrapper?.classList.add(`is-focused`)})},this._blurHandler=()=>{this._colorPickerWrapper&&this._colorPickerWrapper.classList.remove(`is-focused`)},this._colorPicker.addEventListener(`focus`,this._focusHandler),this._colorPicker.addEventListener(`blur`,this._blurHandler),this._colorPicker.addEventListener(`input`,()=>{let e=this._colorPicker?.value||`#000000`;this._colorTextInput&&(this._colorTextInput.value=e),this.setAttribute(`value`,e),this.dispatchEvent(new CustomEvent(`input`,{detail:{value:e},bubbles:!0,cancelable:!0}))}),this._colorPicker.addEventListener(`change`,()=>{let e=this._colorPicker?.value||`#000000`;this.setAttribute(`value`,e),this.dispatchEvent(new CustomEvent(`change`,{detail:{value:e},bubbles:!0,cancelable:!0}))})),this._colorTextInput||(this._colorTextInput=document.createElement(`input`),this._colorTextInput.type=`text`,this._colorTextInput.className=this.getInputClasses(),this._colorTextInput.placeholder=i||`#000000`,this._colorTextInput.pattern=`^#[0-9A-Fa-f]{6}$`,this._wrapper.appendChild(this._colorTextInput),this._colorTextInput.addEventListener(`input`,()=>{let e=this._colorTextInput?.value||``;/^#[0-9A-Fa-f]{6}$/.test(e)&&(this._colorPicker&&(this._colorPicker.value=e),this.setAttribute(`value`,e),this.dispatchEvent(new CustomEvent(`input`,{detail:{value:e},bubbles:!0,cancelable:!0})))}),this._colorTextInput.addEventListener(`blur`,()=>{let e=this._colorTextInput?.value||``;/^#[0-9A-Fa-f]{6}$/.test(e)?(this._colorPicker&&(this._colorPicker.value=e),this.setAttribute(`value`,e)):this._colorPicker&&this._colorTextInput&&(this._colorTextInput.value=this._colorPicker.value),this.dispatchEvent(new CustomEvent(`change`,{detail:{value:this._colorPicker?.value||`#000000`},bubbles:!0,cancelable:!0}))}));let e=u||`#000000`;if(this._colorPicker&&this._colorPicker.value!==e&&(this._colorPicker.value=e),this._colorTextInput&&this._colorTextInput.value!==e&&(this._colorTextInput.value=e),this._colorPicker&&(this._colorPicker.disabled=a),this._colorPickerWrapper&&(a?this._colorPickerWrapper.classList.add(`is-disabled`):this._colorPickerWrapper.classList.remove(`is-disabled`)),this._colorTextInput&&(this._colorTextInput.disabled=a,this._colorTextInput.readOnly=o,this._colorTextInput.required=s),this._colorTextInput){let e=this._colorTextInput;c?e.id=c:e.removeAttribute(`id`),l?e.name=l:e.removeAttribute(`name`),e.setAttribute(`aria-invalid`,this.hasError()?`true`:`false`),this._element=e}this._renderErrorState();let t=this.querySelector(`.mint-input-label-container`);if(p||m){t||(t=document.createElement(`div`),t.className=`mint-input-label-container`,this._wrapper&&this._wrapper.parentElement===this?this.insertBefore(t,this._wrapper):this.insertBefore(t,this.firstChild));let e=t.querySelector(`.mint-input-label`);if(p){e||(e=document.createElement(`label`),e.className=`mint-input-label`,t.insertBefore(e,t.firstChild)),e.textContent=p;let n=c||this._colorTextInput?.id;if(n)e.setAttribute(`for`,n);else{let t=`mint-input-${Math.random().toString(36).substr(2,9)}`;this._colorTextInput&&(this._colorTextInput.id=t),e.setAttribute(`for`,t)}a?e.classList.add(`is-disabled`):e.classList.remove(`is-disabled`)}else e&&e.remove();let n=t.querySelector(`.mint-input-info`);m?(n||(n=document.createElement(`span`),n.className=`mint-input-info`,t.appendChild(n)),n.textContent=m,a?n.classList.add(`is-disabled`):n.classList.remove(`is-disabled`)):n&&n.remove()}else t&&t.remove();return}if(this._wrapper||(this._wrapper=document.createElement(`div`),this._wrapper.className=`mint-input-wrapper`,this.appendChild(this._wrapper)),this._colorContainer&&(this._colorContainer.remove(),this._colorContainer=null,this._colorPicker=null,this._colorTextInput=null),this._colorPickerWrapper&&!r&&(this._colorPickerWrapper.remove(),this._colorPickerWrapper=null,this._colorPicker=null,this._colorTextInput=null),f&&!t?this._icon?this._icon.setAttribute(`name`,f):(this._icon=document.createElement(`mint-icon`),this._icon.setAttribute(`name`,f),this._icon.className=`mint-input-icon`,this._wrapper.appendChild(this._icon)):this._icon&&=(this._icon.remove(),null),this._syncSlotAdornments(t,!!f),this._isNumber()&&!t){if(!this._numberSpinnerContainer){this._numberSpinnerContainer=document.createElement(`div`),this._numberSpinnerContainer.className=`mint-input-spinner`,this._wrapper.appendChild(this._numberSpinnerContainer),this._numberIncrementButton=document.createElement(`button`),this._numberIncrementButton.type=`button`,this._numberIncrementButton.className=`mint-input-spinner-button`;let e=document.createElement(`mint-icon`);e.setAttribute(`name`,`caret-up`),e.className=`mint-input-spinner-icon`,this._numberIncrementButton.appendChild(e),this._numberSpinnerContainer.appendChild(this._numberIncrementButton),this._numberDecrementButton=document.createElement(`button`),this._numberDecrementButton.type=`button`,this._numberDecrementButton.className=`mint-input-spinner-button`;let t=document.createElement(`mint-icon`);t.setAttribute(`name`,`caret-down`),t.className=`mint-input-spinner-icon`,this._numberDecrementButton.appendChild(t),this._numberSpinnerContainer.appendChild(this._numberDecrementButton),this._numberIncrementButton.addEventListener(`click`,e=>{if(e.preventDefault(),e.stopPropagation(),this._input&&!this._input.disabled&&!this._input.readOnly){let e=parseFloat(this._input.value)||0,t=parseFloat(this._input.step)||1,n=this._input.min?parseFloat(this._input.min):void 0,r=this._input.max?parseFloat(this._input.max):void 0,i=e+t;r!==void 0&&i>r&&(i=r),n!==void 0&&i<n&&(i=n),this._input.value=i.toString(),this.setAttribute(`value`,i.toString()),this._input.dispatchEvent(new Event(`input`,{bubbles:!0})),this._input.dispatchEvent(new Event(`change`,{bubbles:!0}))}}),this._numberDecrementButton.addEventListener(`click`,e=>{if(e.preventDefault(),e.stopPropagation(),this._input&&!this._input.disabled&&!this._input.readOnly){let e=parseFloat(this._input.value)||0,t=parseFloat(this._input.step)||1,n=this._input.min?parseFloat(this._input.min):void 0,r=this._input.max?parseFloat(this._input.max):void 0,i=e-t;n!==void 0&&i<n&&(i=n),r!==void 0&&i>r&&(i=r),this._input.value=i.toString(),this.setAttribute(`value`,i.toString()),this._input.dispatchEvent(new Event(`input`,{bubbles:!0})),this._input.dispatchEvent(new Event(`change`,{bubbles:!0}))}})}this._numberIncrementButton&&(this._numberIncrementButton.disabled=a||o),this._numberDecrementButton&&(this._numberDecrementButton.disabled=a||o)}else this._numberSpinnerContainer&&(this._numberSpinnerContainer.remove(),this._numberSpinnerContainer=null,this._numberIncrementButton=null,this._numberDecrementButton=null);if(t){if(this._input&&=(this._input.remove(),null),this._textarea||(this._textarea=document.createElement(`textarea`),this._element=this._textarea,this._wrapper.appendChild(this._textarea),this.setupEventListeners()),this._element=this._textarea,this._textarea.placeholder=i,this._textarea.disabled=a,this._textarea.readOnly=o,this._textarea.required=s,this._textarea.rows=d,this._textarea.setAttribute(`aria-invalid`,this.hasError()?`true`:`false`),u!==this._textarea.value&&(this._textarea.value=u),c?this._textarea.id=c:this._textarea.removeAttribute(`id`),l?this._textarea.name=l:this._textarea.removeAttribute(`name`),this._textarea.className=this.getInputClasses(),this.firstChild&&this.firstChild!==this._wrapper&&this.firstChild.nodeType===Node.TEXT_NODE){let e=this.firstChild.textContent;e&&!this._textarea.value&&(this._textarea.value=e.trim()),this.removeChild(this.firstChild)}}else{this._textarea&&=(this._textarea.remove(),null),this._input||(this._input=document.createElement(`input`),this._element=this._input,this._wrapper.appendChild(this._input),this.setupEventListeners()),this._element=this._input,this._input.type=e,this._input.placeholder=i,this._input.disabled=a,this._input.readOnly=o,this._input.required=s,this._input.setAttribute(`aria-invalid`,this.hasError()?`true`:`false`),this._input.min=this.getAttribute(`min`)??``,this._input.max=this.getAttribute(`max`)??``,this._input.step=this.getAttribute(`step`)??``,n?(this._input.inputMode=`decimal`,this._input.removeAttribute(`pattern`)):(this._input.removeAttribute(`inputmode`),this._input.removeAttribute(`pattern`));let t=n&&document.activeElement===this._input;if(u!==this._input.value&&!t&&(this._input.value=u),c?this._input.id=c:this._input.removeAttribute(`id`),l?this._input.name=l:this._input.removeAttribute(`name`),this._input.className=this.getInputClasses(),this.firstChild&&this.firstChild!==this._wrapper&&this.firstChild.nodeType===Node.TEXT_NODE){let e=this.firstChild.textContent;e&&!this._input.value&&(this._input.value=e.trim()),this.removeChild(this.firstChild)}t||this._formatMoneyInput(!0)}let g=this.querySelector(`.mint-input-label-container`);if(p||m){g||(g=document.createElement(`div`),g.className=`mint-input-label-container`,this._wrapper&&this._wrapper.parentElement===this?this.insertBefore(g,this._wrapper):this.insertBefore(g,this.firstChild));let e=g.querySelector(`.mint-input-label`);if(p){e||(e=document.createElement(`label`),e.className=`mint-input-label`,g.insertBefore(e,g.firstChild)),e.textContent=p;let t=c||this._element?.id||this._colorTextInput?.id||this._input?.id||this._textarea?.id;if(t)e.setAttribute(`for`,t);else{let t=`mint-input-${Math.random().toString(36).substr(2,9)}`;this._element?this._element.id=t:this._colorTextInput?this._colorTextInput.id=t:this._input?this._input.id=t:this._textarea&&(this._textarea.id=t),e.setAttribute(`for`,t)}a?e.classList.add(`is-disabled`):e.classList.remove(`is-disabled`)}else e&&e.remove();let t=g.querySelector(`.mint-input-info`);m?(t||(t=document.createElement(`span`),t.className=`mint-input-info`,g.appendChild(t)),t.textContent=m,a?t.classList.add(`is-disabled`):t.classList.remove(`is-disabled`)):t&&t.remove()}else g&&g.remove();this._syncSlotAdornments(t,!!f),this._renderErrorState(),this._syncControlAccessibility(),this._renderSkeleton(h)}_renderErrorState(){let e=this.hasError(),t=this.getErrorMessage(),n=this.querySelector(`.mint-input-error`);e&&t?(n||(n=document.createElement(`div`),n.className=`mint-input-error`,this.appendChild(n)),n.textContent=t):n&&n.remove()}_syncControlAccessibility(){let e=this._element;if(!e)return;this._a11yId||=this.getId()||`mint-input-${Math.random().toString(36).slice(2,10)}`;let t=this.getAttribute(`aria-label`)?.trim(),n=!!this.querySelector(`.mint-input-label`);t?e.setAttribute(`aria-label`,t):!n&&this.getAttribute(`placeholder`)?.trim()?e.setAttribute(`aria-label`,this.getAttribute(`placeholder`).trim()):e.removeAttribute(`aria-label`);let r=this.querySelector(`.mint-input-info`),i=this.querySelector(`.mint-input-error`),a=(this.getAttribute(`aria-describedby`)||``).split(/\s+/).filter(Boolean);r&&(r.id=`${this._a11yId}-info`,a.push(r.id)),i&&(i.id=`${this._a11yId}-error`,a.push(i.id)),e.setAttribute(`aria-invalid`,String(this.hasError())),a.length?e.setAttribute(`aria-describedby`,Array.from(new Set(a)).join(` `)):e.removeAttribute(`aria-describedby`);let o=this.getAttribute(`aria-labelledby`)?.trim();o?e.setAttribute(`aria-labelledby`,o):e.removeAttribute(`aria-labelledby`)}setupEventListeners(){this._element&&(this._element.addEventListener(`beforeinput`,e=>{if(!this._isMoney()||!(e instanceof InputEvent)||!e.inputType.startsWith(`insert`))return;let t=this.getAttribute(`decimal-point`)??`.`,n=e.data??e.dataTransfer?.getData(`text/plain`)??``;if(!n)return;let r=this._input?.value.indexOf(t)??-1;if(t&&n===t&&r>=0){e.preventDefault();let n=r+t.length;this._input?.setSelectionRange(n,n);return}let i=t.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),a=t?RegExp(`[^0-9${i}]`,`g`):/[^0-9]/g;n.replace(a,``)!==n&&e.preventDefault()}),this._element.addEventListener(`input`,()=>{let e=this._element?.value||``;e?this.setAttribute(`value`,e):this.removeAttribute(`value`);let t=new Event(`input`,{bubbles:!0,cancelable:!0,composed:!0});this.dispatchEvent(t),this.dispatchEvent(new CustomEvent(`input`,{detail:{value:e},bubbles:!0,cancelable:!0,composed:!0}))}),this._element.addEventListener(`blur`,()=>{this._formatMoneyInput(!0);let e=this._element?.value||``;e?this.setAttribute(`value`,e):this.removeAttribute(`value`),this.dispatchEvent(new CustomEvent(`change`,{detail:{value:e},bubbles:!0,cancelable:!0}))}))}removeEventListeners(){this._colorPicker&&(this._focusHandler&&=(this._colorPicker.removeEventListener(`focus`,this._focusHandler),null),this._blurHandler&&=(this._colorPicker.removeEventListener(`blur`,this._blurHandler),null))}focus(){this._isColor()&&this._colorTextInput?this._colorTextInput.focus():this._element?.focus()}blur(){this._isColor()&&this._colorTextInput?this._colorTextInput.blur():this._element?.blur()}_renderSkeleton(e){this.classList.toggle(`is-loading`,e);let t=this.querySelector(`.mint-input-skeleton-container`),n=this._wrapper||this.querySelector(`.mint-input-wrapper`);if(e){t||(t=document.createElement(`div`),t.className=`mint-input-skeleton-container`,n?(n.classList.add(`mint-input-positioned`),n.appendChild(t)):(this.classList.add(`mint-input-positioned`),this.appendChild(t)));let e=t.querySelector(`.mint-input-skeleton`);e||(e=document.createElement(`div`),e.className=`mint-input-skeleton`,t.appendChild(e)),e.parentElement||t.appendChild(e)}}};customElements.get(`mint-input`)||t.t(`mint-input`,n),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return n}});
@@ -1 +1 @@
1
- require(`./icon-Bv1J3LwC.js`);const e=require(`./register-element-tCL_F1YI.js`);require(`./text-CfvRRKGZ.js`),require(`./button-CELyLLtj.js`),require(`./stack-CK2o4-As.js`);var t=new Set,n=null;function r(e){if(!t.has(e)){if(t.size===0){let e=document.documentElement;n={scrollY:window.scrollY||window.pageYOffset||0,rootOverflow:e.style.overflow,rootOverscrollBehavior:e.style.overscrollBehavior},e.style.overflow=`hidden`,e.style.overscrollBehavior=`none`}t.add(e)}}function i(e){if(!t.delete(e)||t.size>0||!n)return;let r=n;n=null;let i=document.documentElement;i.style.overflow=r.rootOverflow,i.style.overscrollBehavior=r.rootOverscrollBehavior,window.scrollTo({left:0,top:r.scrollY,behavior:`instant`})}var a=class extends HTMLElement{static get observedAttributes(){return[`id`,`heading`,`open`,`size`]}constructor(){super(),this._overlay=null,this._modal=null,this._header=null,this._headingSlot=null,this._bodySlot=null,this._actionsSlot=null,this._closeButton=null,this._triggerElement=null,this._triggerPoint=null,this._renderedOpen=!1,this._lastPointerPoint=null,this._pointerDownHandler=null,this._darkModeObserver=null,this._exitTimer=null,this._backdropTimer=null}connectedCallback(){this.isOpen()||this.classList.add(`mint-hidden`),this.render(),this._observeDarkMode(),this._pointerDownHandler=e=>{this._lastPointerPoint={x:e.clientX,y:e.clientY,target:e.target,time:Date.now()}},document.addEventListener(`pointerdown`,this._pointerDownHandler,!0)}disconnectedCallback(){i(this),this._pointerDownHandler&&=(document.removeEventListener(`pointerdown`,this._pointerDownHandler,!0),null),this._exitTimer&&=(clearTimeout(this._exitTimer),null),this._backdropTimer&&=(clearTimeout(this._backdropTimer),null),this._darkModeObserver&&=(this._darkModeObserver.disconnect(),null)}attributeChangedCallback(e,t,n){t!==n&&(e===`open`&&n!==null&&!this._triggerElement&&(this._triggerElement=this._findTriggerElement(),this._triggerPoint=this._findTriggerPoint(this._triggerElement)),this.render())}getId(){return this.getAttribute(`id`)||``}getHeading(){return this.getAttribute(`heading`)||``}getSize(){let e=this.getAttribute(`size`);return e===`small`||e===`large`?e:`default`}isOpen(){return this.hasAttribute(`open`)}open(e){this._triggerElement=this._findTriggerElement(e),this._triggerPoint=this._findTriggerPoint(this._triggerElement),this.setAttribute(`open`,``)}close(){this.removeAttribute(`open`)}render(){let e=this.getId(),t=this.getHeading(),n=this.isOpen(),i=this.getSize();if(e&&(this.id=e),this._overlay||(this._overlay=document.createElement(`div`),this._overlay.className=`mint-modal-overlay`,this._overlay.addEventListener(`click`,()=>this.close()),this.appendChild(this._overlay)),this._modal||(this._modal=document.createElement(`div`),this._modal.className=`mint-modal-shell`,this.appendChild(this._modal)),n){let e=this._modal.querySelector(`.modal-content`);e||(e=document.createElement(`div`),e.className=`modal-content`,this._modal.appendChild(e)),this._renderedOpen||(this._renderedOpen=!0,r(this),this._animateEnter())}else this._renderedOpen&&(this._renderedOpen=!1,this._animateExit());let a=this._modal.querySelector(`.modal-content`);a||(a=document.createElement(`div`),a.className=`modal-content`,this._modal.appendChild(a)),a.classList.remove(`modal-content--small`,`modal-content--large`),i!==`default`&&a.classList.add(`modal-content--${i}`),this._header||(this._header=document.createElement(`div`),this._header.className=`mint-modal-header`,a.appendChild(this._header)),this._headingSlot||(this._headingSlot=document.createElement(`div`),this._headingSlot.className=`mint-modal-heading`,this._headingSlot.setAttribute(`slot`,`heading`),this._header.appendChild(this._headingSlot));let o=this._headingSlot.querySelector(`mint-text`);t?(o||(o=document.createElement(`mint-text`),o.setAttribute(`size`,`sub-heading`),o.setAttribute(`bold`,``),this._headingSlot.appendChild(o)),o.textContent=t):o&&o.remove(),Array.from(this.children).filter(e=>e!==this._overlay&&e!==this._modal&&e!==this._headingSlot&&e.getAttribute(`slot`)===`heading`).forEach(e=>{e.parentElement!==this._headingSlot&&this._headingSlot.appendChild(e)}),this._closeButton||(this._closeButton=document.createElement(`mint-button`),this._closeButton.classList.add(`mint-modal-close-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=`mint-modal-body`,this._bodySlot.setAttribute(`slot`,`body`),a.appendChild(this._bodySlot)),Array.from(this.children).filter(e=>e!==this._overlay&&e!==this._modal&&e!==this._bodySlot&&e.getAttribute(`slot`)===`body`).forEach(e=>{e.parentElement!==this._bodySlot&&this._bodySlot.appendChild(e)});let s=Array.from(this.children).filter(e=>e!==this._overlay&&e!==this._modal&&e!==this._actionsSlot&&e.getAttribute(`slot`)===`actions`),c=this._actionsSlot?.querySelector(`mint-stack`),l=!!c&&c.children.length>0;if(s.length||l){this._actionsSlot||(this._actionsSlot=document.createElement(`div`),this._actionsSlot.className=`p-4 border-t border-gray-200 dark:border-mint-divider`,this._actionsSlot.setAttribute(`slot`,`actions`),a.appendChild(this._actionsSlot));let e=this._actionsSlot.querySelector(`mint-stack`);e||(e=document.createElement(`mint-stack`),e.setAttribute(`direction`,`horizontal`),e.setAttribute(`align-content`,`right`),e.className=`mint-actions-stack`,this._actionsSlot.appendChild(e)),s.forEach(t=>{Array.from(t.children).forEach(t=>e.appendChild(t)),t.remove()})}else this._actionsSlot&&=(this._actionsSlot.remove(),null);Array.from(this.children).forEach(e=>{e!==this._overlay&&e!==this._modal&&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()}_updateBackgroundColor(){if(!this._modal)return;document.documentElement?.classList.contains(`dark`)||document.documentElement?.dataset.mintTheme;let e=this._modal.querySelector(`.modal-content`);e&&(e.style.background=`var(--mint-color-surface-raised)`)}_observeDarkMode(){if(!this._darkModeObserver){if(this._darkModeObserver=new MutationObserver(()=>{this._updateBackgroundColor()}),!document.documentElement)return;this._darkModeObserver.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`,`data-mint-theme`]})}}_animateEnter(){let e=this._modal?.querySelector(`.modal-content`);e&&(this._exitTimer&&=(clearTimeout(this._exitTimer),null),this._backdropTimer&&=(clearTimeout(this._backdropTimer),null),this.classList.remove(`mint-modal-closing`),this.classList.remove(`mint-modal-open`),this.classList.add(`mint-modal-open`),this.classList.remove(`mint-hidden`),e.style.transform=`none`,e.style.opacity=`0`,e.style.transition=`none`,e.getBoundingClientRect(),requestAnimationFrame(()=>{this.isOpen()&&(e.style.transition=`opacity 200ms ease-out`,e.style.opacity=`1`,this._backdropTimer=window.setTimeout(()=>{e.style.transition=``,e.style.opacity=``,e.style.transform=``,this._backdropTimer=null},220))}))}_findTriggerElement(e){if(typeof e==`string`){let t=document.getElementById(e);return t&&!this.contains(t)?t:null}if(e instanceof HTMLElement)return e.isConnected&&!this.contains(e)?e:null;let t=this.getAttribute(`trigger-id`);if(t){let e=document.getElementById(t);if(e&&!this.contains(e))return e}let n=document.activeElement;return n instanceof HTMLElement&&n.isConnected&&n!==document.body&&!this.contains(n)?n:null}_findTriggerPoint(e){if(!e)return null;let t=this._lastPointerPoint;if(!t||Date.now()-t.time>1e3)return null;let n=t.target instanceof Node?t.target:null;return n===e||n&&e.contains(n)?{x:t.x,y:t.y}:null}_animateExit(){this.classList.remove(`mint-modal-open`),this._backdropTimer&&=(clearTimeout(this._backdropTimer),null);let e=this._modal?.querySelector(`.modal-content`);if(!e){this.classList.add(`mint-hidden`),this.classList.remove(`mint-modal-closing`),i(this);return}this._exitTimer&&clearTimeout(this._exitTimer),this.classList.add(`mint-modal-closing`),e.style.transition=`opacity 200ms ease-in`,e.style.opacity=`0`,this._exitTimer=setTimeout(()=>{this._exitTimer=null,!this.isOpen()&&(this.classList.add(`mint-hidden`),this.classList.remove(`mint-modal-closing`),e.style.transform=``,e.style.opacity=``,e.style.transition=``,i(this))},200)}};typeof customElements<`u`&&!customElements.get(`mint-modal`)&&e.t(`mint-modal`,a),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return a}});
1
+ require(`./icon-pgeP1zxb.js`);const e=require(`./register-element-tCL_F1YI.js`);require(`./text-CfvRRKGZ.js`),require(`./button-CgymemwA.js`),require(`./stack-CK2o4-As.js`);var t=new Set,n=null;function r(e){if(!t.has(e)){if(t.size===0){let e=document.documentElement;n={scrollY:window.scrollY||window.pageYOffset||0,rootOverflow:e.style.overflow,rootOverscrollBehavior:e.style.overscrollBehavior},e.style.overflow=`hidden`,e.style.overscrollBehavior=`none`}t.add(e)}}function i(e){if(!t.delete(e)||t.size>0||!n)return;let r=n;n=null;let i=document.documentElement;i.style.overflow=r.rootOverflow,i.style.overscrollBehavior=r.rootOverscrollBehavior,window.scrollTo({left:0,top:r.scrollY,behavior:`instant`})}var a=class extends HTMLElement{static get observedAttributes(){return[`id`,`heading`,`open`,`size`]}constructor(){super(),this._overlay=null,this._modal=null,this._header=null,this._headingSlot=null,this._bodySlot=null,this._actionsSlot=null,this._closeButton=null,this._triggerElement=null,this._triggerPoint=null,this._renderedOpen=!1,this._lastPointerPoint=null,this._pointerDownHandler=null,this._darkModeObserver=null,this._exitTimer=null,this._backdropTimer=null}connectedCallback(){this.isOpen()||this.classList.add(`mint-hidden`),this.render(),this._observeDarkMode(),this._pointerDownHandler=e=>{this._lastPointerPoint={x:e.clientX,y:e.clientY,target:e.target,time:Date.now()}},document.addEventListener(`pointerdown`,this._pointerDownHandler,!0)}disconnectedCallback(){i(this),this._pointerDownHandler&&=(document.removeEventListener(`pointerdown`,this._pointerDownHandler,!0),null),this._exitTimer&&=(clearTimeout(this._exitTimer),null),this._backdropTimer&&=(clearTimeout(this._backdropTimer),null),this._darkModeObserver&&=(this._darkModeObserver.disconnect(),null)}attributeChangedCallback(e,t,n){t!==n&&(e===`open`&&n!==null&&!this._triggerElement&&(this._triggerElement=this._findTriggerElement(),this._triggerPoint=this._findTriggerPoint(this._triggerElement)),this.render())}getId(){return this.getAttribute(`id`)||``}getHeading(){return this.getAttribute(`heading`)||``}getSize(){let e=this.getAttribute(`size`);return e===`small`||e===`large`?e:`default`}isOpen(){return this.hasAttribute(`open`)}open(e){this._triggerElement=this._findTriggerElement(e),this._triggerPoint=this._findTriggerPoint(this._triggerElement),this.setAttribute(`open`,``)}close(){this.removeAttribute(`open`)}render(){let e=this.getId(),t=this.getHeading(),n=this.isOpen(),i=this.getSize();if(e&&(this.id=e),this._overlay||(this._overlay=document.createElement(`div`),this._overlay.className=`mint-modal-overlay`,this._overlay.addEventListener(`click`,()=>this.close()),this.appendChild(this._overlay)),this._modal||(this._modal=document.createElement(`div`),this._modal.className=`mint-modal-shell`,this.appendChild(this._modal)),n){let e=this._modal.querySelector(`.modal-content`);e||(e=document.createElement(`div`),e.className=`modal-content`,this._modal.appendChild(e)),this._renderedOpen||(this._renderedOpen=!0,r(this),this._animateEnter())}else this._renderedOpen&&(this._renderedOpen=!1,this._animateExit());let a=this._modal.querySelector(`.modal-content`);a||(a=document.createElement(`div`),a.className=`modal-content`,this._modal.appendChild(a)),a.classList.remove(`modal-content--small`,`modal-content--large`),i!==`default`&&a.classList.add(`modal-content--${i}`),this._header||(this._header=document.createElement(`div`),this._header.className=`mint-modal-header`,a.appendChild(this._header)),this._headingSlot||(this._headingSlot=document.createElement(`div`),this._headingSlot.className=`mint-modal-heading`,this._headingSlot.setAttribute(`slot`,`heading`),this._header.appendChild(this._headingSlot));let o=this._headingSlot.querySelector(`mint-text`);t?(o||(o=document.createElement(`mint-text`),o.setAttribute(`size`,`sub-heading`),o.setAttribute(`bold`,``),this._headingSlot.appendChild(o)),o.textContent=t):o&&o.remove(),Array.from(this.children).filter(e=>e!==this._overlay&&e!==this._modal&&e!==this._headingSlot&&e.getAttribute(`slot`)===`heading`).forEach(e=>{e.parentElement!==this._headingSlot&&this._headingSlot.appendChild(e)}),this._closeButton||(this._closeButton=document.createElement(`mint-button`),this._closeButton.classList.add(`mint-modal-close-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=`mint-modal-body`,this._bodySlot.setAttribute(`slot`,`body`),a.appendChild(this._bodySlot)),Array.from(this.children).filter(e=>e!==this._overlay&&e!==this._modal&&e!==this._bodySlot&&e.getAttribute(`slot`)===`body`).forEach(e=>{e.parentElement!==this._bodySlot&&this._bodySlot.appendChild(e)});let s=Array.from(this.children).filter(e=>e!==this._overlay&&e!==this._modal&&e!==this._actionsSlot&&e.getAttribute(`slot`)===`actions`),c=this._actionsSlot?.querySelector(`mint-stack`),l=!!c&&c.children.length>0;if(s.length||l){this._actionsSlot||(this._actionsSlot=document.createElement(`div`),this._actionsSlot.className=`p-4 border-t border-gray-200 dark:border-mint-divider`,this._actionsSlot.setAttribute(`slot`,`actions`),a.appendChild(this._actionsSlot));let e=this._actionsSlot.querySelector(`mint-stack`);e||(e=document.createElement(`mint-stack`),e.setAttribute(`direction`,`horizontal`),e.setAttribute(`align-content`,`right`),e.className=`mint-actions-stack`,this._actionsSlot.appendChild(e)),s.forEach(t=>{Array.from(t.children).forEach(t=>e.appendChild(t)),t.remove()})}else this._actionsSlot&&=(this._actionsSlot.remove(),null);Array.from(this.children).forEach(e=>{e!==this._overlay&&e!==this._modal&&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()}_updateBackgroundColor(){if(!this._modal)return;document.documentElement?.classList.contains(`dark`)||document.documentElement?.dataset.mintTheme;let e=this._modal.querySelector(`.modal-content`);e&&(e.style.background=`var(--mint-color-surface-raised)`)}_observeDarkMode(){if(!this._darkModeObserver){if(this._darkModeObserver=new MutationObserver(()=>{this._updateBackgroundColor()}),!document.documentElement)return;this._darkModeObserver.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`,`data-mint-theme`]})}}_animateEnter(){let e=this._modal?.querySelector(`.modal-content`);e&&(this._exitTimer&&=(clearTimeout(this._exitTimer),null),this._backdropTimer&&=(clearTimeout(this._backdropTimer),null),this.classList.remove(`mint-modal-closing`),this.classList.remove(`mint-modal-open`),this.classList.add(`mint-modal-open`),this.classList.remove(`mint-hidden`),e.style.transform=`none`,e.style.opacity=`0`,e.style.transition=`none`,e.getBoundingClientRect(),requestAnimationFrame(()=>{this.isOpen()&&(e.style.transition=`opacity 200ms ease-out`,e.style.opacity=`1`,this._backdropTimer=window.setTimeout(()=>{e.style.transition=``,e.style.opacity=``,e.style.transform=``,this._backdropTimer=null},220))}))}_findTriggerElement(e){if(typeof e==`string`){let t=document.getElementById(e);return t&&!this.contains(t)?t:null}if(e instanceof HTMLElement)return e.isConnected&&!this.contains(e)?e:null;let t=this.getAttribute(`trigger-id`);if(t){let e=document.getElementById(t);if(e&&!this.contains(e))return e}let n=document.activeElement;return n instanceof HTMLElement&&n.isConnected&&n!==document.body&&!this.contains(n)?n:null}_findTriggerPoint(e){if(!e)return null;let t=this._lastPointerPoint;if(!t||Date.now()-t.time>1e3)return null;let n=t.target instanceof Node?t.target:null;return n===e||n&&e.contains(n)?{x:t.x,y:t.y}:null}_animateExit(){this.classList.remove(`mint-modal-open`),this._backdropTimer&&=(clearTimeout(this._backdropTimer),null);let e=this._modal?.querySelector(`.modal-content`);if(!e){this.classList.add(`mint-hidden`),this.classList.remove(`mint-modal-closing`),i(this);return}this._exitTimer&&clearTimeout(this._exitTimer),this.classList.add(`mint-modal-closing`),e.style.transition=`opacity 200ms ease-in`,e.style.opacity=`0`,this._exitTimer=setTimeout(()=>{this._exitTimer=null,!this.isOpen()&&(this.classList.add(`mint-hidden`),this.classList.remove(`mint-modal-closing`),e.style.transform=``,e.style.opacity=``,e.style.transition=``,i(this))},200)}};typeof customElements<`u`&&!customElements.get(`mint-modal`)&&e.t(`mint-modal`,a),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return a}});
@@ -1,7 +1,7 @@
1
- import "./icon-1cs-hcBy.js";
1
+ import "./icon-CuRTWM4k.js";
2
2
  import { t as e } from "./register-element-BFYmIynH.js";
3
3
  import "./text-C-6UCBp-.js";
4
- import "./button-THsh4Svz.js";
4
+ import "./button-CIuVIyLf.js";
5
5
  import "./stack-CKUu8IVZ.js";
6
6
  //#region src/components/modal/Modal.js
7
7
  var t = /* @__PURE__ */ new Set(), n = null;
@@ -1,5 +1,5 @@
1
1
  import { t as e } from "./register-element-BFYmIynH.js";
2
- import { n as t } from "./ScrollFade-DOnPtfC2.js";
2
+ import { n as t } from "./ScrollFade-kpfpO4Zb.js";
3
3
  //#region src/components/popover/Popover.js
4
4
  var n = new Set([
5
5
  "up",
@@ -30,7 +30,7 @@ var i = class extends HTMLElement {
30
30
  ];
31
31
  }
32
32
  constructor() {
33
- super(), this._trigger = null, this._triggerLookupTimer = null, this._clickHandler = null, this._hoverEnterHandler = null, this._hoverLeaveHandler = null, this._outsideHandler = null, this._escapeHandler = null, this._positionHandler = null, this._scrollHandler = null, this._resizeObserver = null, this._hoverCloseTimer = null, this._closeAnimationTimer = null, this._blobAnimation = null, this._disposeScrollFade = null;
33
+ super(), this._trigger = null, this._triggerLookupTimer = null, this._clickHandler = null, this._hoverEnterHandler = null, this._hoverLeaveHandler = null, this._outsideHandler = null, this._escapeHandler = null, this._positionHandler = null, this._scrollHandler = null, this._resizeObserver = null, this._hoverCloseTimer = null, this._closeAnimationTimer = null, this._blobAnimation = null, this._disposeScrollFade = null, this._selectPopoverPlaceholder = null;
34
34
  }
35
35
  connectedCallback() {
36
36
  this.render(), this._disposeScrollFade?.();
@@ -100,6 +100,18 @@ var i = class extends HTMLElement {
100
100
  _syncLayerZIndex() {
101
101
  this.style.zIndex = String(this._getLayerZIndex());
102
102
  }
103
+ _portalSelectPopover() {
104
+ if (!this.classList.contains("mint-select-popover") || this.parentElement === document.body) return;
105
+ let e = this.parentNode;
106
+ if (!e) return;
107
+ let t = document.createComment("mint-select-popover");
108
+ e.insertBefore(t, this), this._selectPopoverPlaceholder = t, document.body.appendChild(this), this._syncLayerZIndex();
109
+ }
110
+ _restoreSelectPopover() {
111
+ if (!this._selectPopoverPlaceholder) return;
112
+ let e = this._selectPopoverPlaceholder;
113
+ this._selectPopoverPlaceholder = null, e.parentNode ? e.parentNode.replaceChild(this, e) : this.parentElement === document.body && this.remove();
114
+ }
103
115
  _scheduleHoverClose() {
104
116
  clearTimeout(this._hoverCloseTimer), this._hoverCloseTimer = setTimeout(() => {
105
117
  !this._trigger?.matches(":hover") && !this.matches(":hover") && this.close();
@@ -262,7 +274,7 @@ var i = class extends HTMLElement {
262
274
  }
263
275
  render() {
264
276
  let e = this.isOpen();
265
- this._syncLayerZIndex();
277
+ e ? this._portalSelectPopover() : this._restoreSelectPopover(), this._syncLayerZIndex();
266
278
  let t = this.hasAttribute("data-open") || this.dataset.state === "closing", n = this.hasAttribute("data-open");
267
279
  if (this.toggleAttribute("data-open", e), this.setAttribute("aria-hidden", String(!e)), this._trigger && this._trigger.setAttribute("aria-expanded", String(e)), e) {
268
280
  clearTimeout(this._closeAnimationTimer);
@@ -0,0 +1 @@
1
+ const e=require(`./register-element-tCL_F1YI.js`),t=require(`./ScrollFade-58GqgRLY.js`);var n=new Set([`up`,`down`,`left`,`right`]);function r(e){let t=e.getBoundingClientRect(),n=Math.max(0,t.top),r=Math.min(window.innerWidth,t.right),i=Math.min(window.innerHeight,t.bottom),a=Math.max(0,t.left);for(let t=e.parentElement;t&&t!==document.body;t=t.parentElement){let e=getComputedStyle(t),o=t.getBoundingClientRect();/(auto|scroll|hidden|clip)/.test(e.overflowY)&&(n=Math.max(n,o.top),i=Math.min(i,o.bottom)),/(auto|scroll|hidden|clip)/.test(e.overflowX)&&(a=Math.max(a,o.left),r=Math.min(r,o.right))}return i>n&&r>a}var i=class extends HTMLElement{static get observedAttributes(){return[`direction`,`open`,`trigger-id`,`trigger-toggle`,`trigger-align`,`align-selected`,`padding`,`hover`,`distance`]}constructor(){super(),this._trigger=null,this._triggerLookupTimer=null,this._clickHandler=null,this._hoverEnterHandler=null,this._hoverLeaveHandler=null,this._outsideHandler=null,this._escapeHandler=null,this._positionHandler=null,this._scrollHandler=null,this._resizeObserver=null,this._hoverCloseTimer=null,this._closeAnimationTimer=null,this._blobAnimation=null,this._disposeScrollFade=null,this._selectPopoverPlaceholder=null}connectedCallback(){this.render(),this._disposeScrollFade?.();let e=this.classList.contains(`mint-select-popover`),n=this.classList.contains(`mint-editor-overflow-popover`),r=e?this.querySelector(`.mint-select-options`):null;this._disposeScrollFade=t.n(r||this,`vertical`,n?`1.5rem`:`3rem`,r?`mask`:`overlay`),this._setupTrigger()}disconnectedCallback(){this._removeTrigger(),this._removeOpenListeners(),this._disposeScrollFade?.(),this._disposeScrollFade=null,clearTimeout(this._hoverCloseTimer),clearTimeout(this._closeAnimationTimer),this._blobAnimation?.cancel()}attributeChangedCallback(e,t,n){t===n||!this.isConnected||((e===`trigger-id`||e===`trigger-toggle`||e===`hover`)&&this._setupTrigger(),this.render())}getDirection(){let e=this.getAttribute(`direction`)||`down`;return n.has(e)?e:`down`}getTriggerId(){return this.getAttribute(`trigger-id`)||``}_findTrigger(e){let t=this.getRootNode();return t instanceof ShadowRoot?t.querySelector(`#${CSS.escape(e)}`):document.getElementById(e)}isOpen(){return this.hasAttribute(`open`)&&this.getAttribute(`open`)!==`false`}isHoverEnabled(){return this.hasAttribute(`hover`)&&this.getAttribute(`hover`)!==`false`}isTriggerToggleEnabled(){return this.getAttribute(`trigger-toggle`)!==`false`}open(){this.setAttribute(`open`,`true`)}close(){this.removeAttribute(`open`)}_removeTrigger(){clearTimeout(this._triggerLookupTimer),this._triggerLookupTimer=null,this._trigger&&(this._clickHandler&&this._trigger.removeEventListener(`click`,this._clickHandler),this._hoverEnterHandler&&this._trigger.removeEventListener(`mouseenter`,this._hoverEnterHandler),this._hoverLeaveHandler&&this._trigger.removeEventListener(`mouseleave`,this._hoverLeaveHandler),this._hoverEnterHandler&&this.removeEventListener(`mouseenter`,this._hoverEnterHandler),this._hoverLeaveHandler&&this.removeEventListener(`mouseleave`,this._hoverLeaveHandler),this._trigger.removeAttribute(`aria-haspopup`),this._trigger.removeAttribute(`aria-expanded`),this._trigger=null,this._clickHandler=this._hoverEnterHandler=this._hoverLeaveHandler=null)}_setupTrigger(){this._removeTrigger();let e=this.getTriggerId();if(e){if(this._trigger=this._findTrigger(e),!this._trigger){this._triggerLookupTimer=setTimeout(()=>{this.isConnected&&this.getTriggerId()===e&&!this._trigger&&this._setupTrigger()},40);return}this._syncLayerZIndex(),this._trigger.setAttribute(`aria-haspopup`,`true`),this._trigger.setAttribute(`aria-expanded`,String(this.isOpen())),this.isTriggerToggleEnabled()&&(this._clickHandler=e=>{this._trigger?.tagName===`A`&&e.preventDefault(),this.isOpen()?this.close():this.open()},this._trigger.addEventListener(`click`,this._clickHandler)),this.isHoverEnabled()&&(this._hoverEnterHandler=()=>{clearTimeout(this._hoverCloseTimer),this.open()},this._hoverLeaveHandler=()=>this._scheduleHoverClose(),this._trigger.addEventListener(`mouseenter`,this._hoverEnterHandler),this._trigger.addEventListener(`mouseleave`,this._hoverLeaveHandler),this.addEventListener(`mouseenter`,this._hoverEnterHandler),this.addEventListener(`mouseleave`,this._hoverLeaveHandler))}}_getLayerZIndex(){let e=900,t=this._trigger||this.parentElement;for(;t&&t!==document.documentElement;){let n=Number.parseInt(getComputedStyle(t).zIndex,10);Number.isFinite(n)&&(e=Math.max(e,n)),t=t.parentElement}return Math.max(901,e+1)}_syncLayerZIndex(){this.style.zIndex=String(this._getLayerZIndex())}_portalSelectPopover(){if(!this.classList.contains(`mint-select-popover`)||this.parentElement===document.body)return;let e=this.parentNode;if(!e)return;let t=document.createComment(`mint-select-popover`);e.insertBefore(t,this),this._selectPopoverPlaceholder=t,document.body.appendChild(this),this._syncLayerZIndex()}_restoreSelectPopover(){if(!this._selectPopoverPlaceholder)return;let e=this._selectPopoverPlaceholder;this._selectPopoverPlaceholder=null,e.parentNode?e.parentNode.replaceChild(this,e):this.parentElement===document.body&&this.remove()}_scheduleHoverClose(){clearTimeout(this._hoverCloseTimer),this._hoverCloseTimer=setTimeout(()=>{!this._trigger?.matches(`:hover`)&&!this.matches(`:hover`)&&this.close()},140)}_removeOpenListeners(){this._outsideHandler&&document.removeEventListener(`click`,this._outsideHandler),this._escapeHandler&&document.removeEventListener(`keydown`,this._escapeHandler),this._positionHandler&&window.removeEventListener(`resize`,this._positionHandler),this._scrollHandler&&window.removeEventListener(`scroll`,this._scrollHandler,!0),this._resizeObserver?.disconnect(),this._resizeObserver=null,this._outsideHandler=this._escapeHandler=this._positionHandler=this._scrollHandler=null}_setOpenListeners(){if(!this._outsideHandler){if(this._outsideHandler=e=>{let t=e.composedPath();t.includes(this)||t.includes(this._trigger)||(e.target instanceof Element?e.target:null)?.closest(`[data-keep-popover-open]`)||this.close()},this._escapeHandler=e=>{e.key===`Escape`&&(this.close(),this._trigger?.focus?.())},this._positionHandler=()=>{this.isOpen()&&(this._position(),this._alignSelectedOptionToTrigger())},this._scrollHandler=e=>{if(!this.isOpen())return;let t=e.target;if(!(t instanceof Node&&(t===this||this.contains(t)))){if(this.classList.contains(`mint-select-popover`)){!this._trigger||!r(this._trigger)?this.close():(this._position({allowViewportFlip:!1,clampToViewport:!1}),this._alignSelectedOptionToTrigger());return}this._position({allowViewportFlip:!1,clampToViewport:!1}),this._alignSelectedOptionToTrigger()}},typeof ResizeObserver<`u`&&this._trigger){this._resizeObserver=new ResizeObserver(()=>{this.isOpen()&&(this._position(),this._alignSelectedOptionToTrigger())}),this.classList.contains(`mint-select-popover`)||this._resizeObserver.observe(this);let e=this._trigger,t=0;for(;e&&e!==document.documentElement&&t<8;)this._resizeObserver.observe(e),e=e.parentElement,t+=1}setTimeout(()=>{this.isOpen()&&this._outsideHandler&&document.addEventListener(`click`,this._outsideHandler)},0),document.addEventListener(`keydown`,this._escapeHandler),window.addEventListener(`resize`,this._positionHandler),window.addEventListener(`scroll`,this._scrollHandler,!0)}}_getFixedPositionContext(){for(let e=this.parentElement;e&&e!==document.documentElement;e=e.parentElement){let t=getComputedStyle(e),n=`${t.contain} ${t.willChange}`;if(!(t.transform!==`none`||t.perspective!==`none`||t.filter!==`none`||t.backdropFilter!==`none`||[`layout`,`paint`,`strict`,`content`,`transform`,`perspective`,`filter`].some(e=>n.includes(e))))continue;let r=e.getBoundingClientRect(),i=r.width/(e.offsetWidth||r.width)||1,a=r.height/(e.offsetHeight||r.height)||1;return{scaleX:i,scaleY:a,originLeft:r.left+(parseFloat(t.borderLeftWidth)||0)*i,originTop:r.top+(parseFloat(t.borderTopWidth)||0)*a}}return{scaleX:1,scaleY:1,originLeft:0,originTop:0}}_position({allowViewportFlip:e=!0,clampToViewport:t=!0}={}){let n=this._findTrigger(this.getTriggerId());n&&n!==this._trigger&&this._setupTrigger();let r=n||this._trigger;if(!r)return;let i=r.getBoundingClientRect(),a=this._getFixedPositionContext(),o={width:this.offsetWidth*a.scaleX,height:this.offsetHeight*a.scaleY},s=this._distancePx(),c=s*a.scaleX,l=s*a.scaleY,u=e?this.getDirection():this.dataset.direction||this.getDirection(),d=0,f=0,p=this.getAttribute(`trigger-align`)||`center`;if(u===`down`||u===`up`){let t=i.bottom+l,n=i.top-o.height-l;e&&u===`down`&&t+o.height>innerHeight-12&&n>=12?u=`up`:e&&u===`up`&&n<12&&t+o.height<=innerHeight-12&&(u=`down`);let r=this.hasAttribute(`align-selected`)?this.querySelector(`[role="option"][aria-selected="true"]`):null;if(r){let e=r.closest(`[role="listbox"]`);if(e&&e.scrollHeight>e.clientHeight+1){let t=Math.max(0,e.scrollHeight-e.clientHeight),n=r.offsetTop-Math.max(0,(e.clientHeight-r.offsetHeight)/2);e.scrollTop=Math.max(0,Math.min(t,n))}}if(d=u===`down`?t:n,r&&this.classList.contains(`mint-select-popover`)){let e=this.getBoundingClientRect(),t=r.getBoundingClientRect().top-e.top;d=i.top-t}f=p===`start`?i.left:p===`end`?i.right-o.width:i.left+(i.width-o.width)/2}else{let t=i.right+c,n=i.left-o.width-c;e&&u===`right`&&t+o.width>innerWidth-12&&n>=12?u=`left`:e&&u===`left`&&n<12&&t+o.width<=innerWidth-12&&(u=`right`),f=u===`right`?t:n,d=p===`start`?i.top:p===`end`?i.bottom-o.height:i.top+(i.height-o.height)/2}let m=t&&!this.classList.contains(`mint-select-popover`)?Math.max(12,Math.min(d,innerHeight-o.height-12)):d,h=t?Math.max(12,Math.min(f,innerWidth-o.width-12)):f,g=(m-a.originTop)/a.scaleY,_=(h-a.originLeft)/a.scaleX;this.style.top=`${g}px`,this.style.left=`${_}px`,this.dataset.direction=u,this.style.setProperty(`--mint-popover-origin-x`,`${(i.left+i.width/2-h)/a.scaleX}px`),this.style.setProperty(`--mint-popover-origin-y`,`${(i.top+i.height/2-m)/a.scaleY}px`)}_alignSelectedOptionToTrigger(){if(!this.classList.contains(`mint-select-popover`)||!this._trigger)return;let e=this.querySelector(`[role="option"][aria-selected="true"]`);if(!e)return;let t=this._trigger.getBoundingClientRect(),n=e.closest(`[role="listbox"]`),r=window.visualViewport,i=r?.offsetTop??0,a=r?.height??window.innerHeight,o=Math.max(0,a-24);this.style.maxHeight=`${o}px`,this.style.overflowY=`auto`;let s=this.getBoundingClientRect(),c=e.getBoundingClientRect(),l=i+12,u=Math.max(l,i+a-12-s.height),d=Math.max(l,Math.min(t.top-(c.top-s.top),u));if(n){let r=t.top-d,o=c.top-s.top;n.scrollTop+=o-r,s=this.getBoundingClientRect(),c=e.getBoundingClientRect();let u=t.top-(c.top-s.top),f=Math.max(l,i+a-12-s.height);d=Math.max(l,Math.min(u,f))}this.style.top=`${d}px`}_distancePx(){let e=(this.getAttribute(`distance`)||`8px`).trim(),t=Number.parseFloat(e);return Number.isFinite(t)?e.endsWith(`rem`)?t*(parseFloat(getComputedStyle(document.documentElement).fontSize)||16):Math.max(0,t):8}_animateBlob(e){if(this._blobAnimation?.cancel(),this._blobAnimation=null,typeof this.animate!=`function`)return 0;let t=getComputedStyle(this).borderRadius||`.75rem`;if(matchMedia(`(prefers-reduced-motion: reduce)`).matches)return 0;let n=e?380:280,r=[{transform:`scale(.035, .035)`,borderRadius:`50%`,opacity:.94,offset:0},{transform:`scale(.3, .42)`,borderRadius:`50%`,opacity:1,offset:.58},{transform:`scale(1.035, .96)`,borderRadius:`1rem`,offset:.9},{transform:`scale(1)`,borderRadius:t,offset:1}],i=e?r:[...r].reverse().map(({offset:e,...t})=>({...t,offset:1-e}));return this._blobAnimation=this.animate(i,{duration:n,easing:e?`cubic-bezier(.2, .8, .2, 1)`:`cubic-bezier(.4, 0, .8, .2)`,fill:`both`}),n}render(){let e=this.isOpen();e?this._portalSelectPopover():this._restoreSelectPopover(),this._syncLayerZIndex();let t=this.hasAttribute(`data-open`)||this.dataset.state===`closing`,n=this.hasAttribute(`data-open`);if(this.toggleAttribute(`data-open`,e),this.setAttribute(`aria-hidden`,String(!e)),this._trigger&&this._trigger.setAttribute(`aria-expanded`,String(e)),e){clearTimeout(this._closeAnimationTimer);let e=!n||this.dataset.state===`closing`;e&&(this._blobAnimation?.cancel(),this._blobAnimation=null),this.dataset.state=`open`,this._setOpenListeners(),this._position(),this._alignSelectedOptionToTrigger(),e&&!this.classList.contains(`mint-select-popover`)&&this._animateBlob(!0),requestAnimationFrame(()=>requestAnimationFrame(()=>{this.isOpen()&&(this._position(),this._alignSelectedOptionToTrigger())}))}else if(this._removeOpenListeners(),t){this.dataset.state=`closing`;let e=this._animateBlob(!1);e?this._closeAnimationTimer=setTimeout(()=>{this.dataset.state===`closing`&&(this._blobAnimation?.cancel(),this._blobAnimation=null,this.dataset.state=`closed`)},e):this.dataset.state=`closed`}else this.dataset.state=`closed`}};typeof customElements<`u`&&!customElements.get(`mint-popover`)&&e.t(`mint-popover`,i),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return i}});
@@ -0,0 +1 @@
1
+ require(`./icon-pgeP1zxb.js`).a({name:`search`,viewBox:`0 0 24 24`,path:`M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z`,strokeLinecap:`round`,strokeLinejoin:`round`});
@@ -1,4 +1,4 @@
1
- import { a as e } from "./icon-1cs-hcBy.js";
1
+ import { a as e } from "./icon-CuRTWM4k.js";
2
2
  e({
3
3
  name: "search",
4
4
  viewBox: "0 0 24 24",
@@ -1 +1 @@
1
- require(`./icon-Bv1J3LwC.js`);const e=require(`./register-element-tCL_F1YI.js`);require(`./icon-C-6HOPtI.js`),require(`./popover-2Cnva3AN.js`);var t=`data-mint-native-select-part`,n=class extends HTMLElement{static get observedAttributes(){return[`name`,`value`,`disabled`,`id`,`required`,`label`,`info`,`error`,`error-message`,`multiple`,`loading`,`aria-label`,`aria-labelledby`,`aria-describedby`]}constructor(){super(),this._select=null,this._wrapper=null,this._prependNodes=[],this._appendNodes=[],this._caretUpIcon=null,this._caretDownIcon=null,this._changeHandler=null,this._optionObserver=null,this._childrenObserver=null,this._hostOptionsObserverRaf=null,this._generatedControlId=`mint-native-select-${Math.random().toString(36).slice(2,10)}`}connectedCallback(){this.classList.add(`mint-native-select-host`),this.getLabel()||console.error(`mint-native-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=>{if(e.some(e=>{let t=e.target;if(this._select&&(t===this._select||this._select.contains(t)))return!1;let n=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`)),r=e.type===`attributes`&&e.target.nodeType===Node.ELEMENT_NODE&&(e.target.tagName===`OPTION`||e.target.tagName===`OPTGROUP`);return n||r})){if(this._hostOptionsObserverRaf!==null)return;this._hostOptionsObserverRaf=requestAnimationFrame(()=>{this._hostOptionsObserverRaf=null,this.isConnected&&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),this._hostOptionsObserverRaf!==null&&(cancelAnimationFrame(this._hostOptionsObserverRaf),this._hostOptionsObserverRaf=null)}isLoading(){let e=this.getAttribute(`loading`);return e!==null&&e!==`false`}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`),this._syncSelectAccessibility());return}if(e===`loading`){this.render();return}if(e===`value`){if(this._select)if(this.isMultiple()){let e=[];try{let t=n?JSON.parse(n):[];e=Array.isArray(t)?t.map(e=>String(e)):[]}catch{e=n?[String(n)]:[]}Array.from(this._select.options).forEach(t=>{t.selected=e.includes(t.value)})}else this._select.value=n||``;return}this.render()}}getName(){return this.getAttribute(`name`)||``}getValue(){if(this.isMultiple()&&this._select){let e=Array.from(this._select.selectedOptions).map(e=>e.value);return JSON.stringify(e)}return this.hasAttribute(`value`)?this.getAttribute(`value`)||``:this._select?this._select.value:``}setValue(e){if(this.isMultiple()){let t=Array.isArray(e)?e.map(e=>String(e)):e==null||e===``?[]:[String(e)];this.setAttribute(`value`,JSON.stringify(t)),this._select&&Array.from(this._select.options).forEach(e=>{e.selected=t.includes(e.value)});return}let t=e==null?``:String(e);this.setAttribute(`value`,t),this._select&&(this._select.value=t)}get value(){try{return this.getValue()||``}catch{return``}}set value(e){try{if(this.isMultiple()){this.setValue(e);return}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(){let e=this.getAttribute(`disabled`);return e!==null&&e!==`false`}isMultiple(){let e=this.getAttribute(`multiple`);return e!==null&&e!==`false`}isRequired(){let e=this.getAttribute(`required`);return e!==null&&e!==`false`}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(){return[`mint-native-select-control`,this.isMultiple()?`is-multiple`:``,this.hasError()?`has-error`:``].filter(Boolean).join(` `)}render(){this._hostOptionsObserverRaf!==null&&(cancelAnimationFrame(this._hostOptionsObserverRaf),this._hostOptionsObserverRaf=null);let e=this.isLoading(),n=this.isMultiple(),r=this.getValue();this._collectAdornments();let i=[];this._select&&Array.from(this._select.children).forEach(e=>{(e.tagName===`OPTION`||e.tagName===`OPTGROUP`)&&i.push(e.cloneNode(!0))}),Array.from(this.children).forEach(e=>{e instanceof HTMLElement&&e.hasAttribute(t)&&e.remove()}),this._wrapper=null,this._select=null;let a=Array.from(this.children).filter(e=>e.tagName===`OPTION`||e.tagName===`OPTGROUP`).map(e=>e.cloneNode(!0)),o=this.getLabel(),s=this.getInfo(),c=this.getId()||this._generatedControlId,l=this.getName(),u=this.isDisabled(),d=this.hasError();if(o){let e=document.createElement(`label`);e.setAttribute(t,`label`),e.className=`mint-native-select-label`,c&&e.setAttribute(`for`,c);let n=document.createTextNode(o);e.appendChild(n),this.appendChild(e)}this._wrapper=document.createElement(`div`),this._wrapper.setAttribute(t,`wrapper`),this._wrapper.className=`mint-native-select-control-wrap`,this.appendChild(this._wrapper);let f=this._makeAdornment(`prepend`,this._prependNodes);f&&this._wrapper.appendChild(f),this._select=document.createElement(`select`),this._select.className=this.getSelectClasses(),c&&(this._select.id=c),l&&(this._select.name=l),u&&(this._select.disabled=!0),this._select.required=this.isRequired(),n&&(this._select.multiple=!0),this._select.setAttribute(`aria-invalid`,d?`true`:`false`);let p=this.getAttribute(`aria-label`)?.trim(),m=this.getAttribute(`aria-labelledby`)?.trim();m?this._select.setAttribute(`aria-labelledby`,m):o?this._select.removeAttribute(`aria-label`):this._select.setAttribute(`aria-label`,p||`Select an option`);let h=a.length>0?a:i;if(h.length>0&&h.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(n){let e=[];try{let t=r?JSON.parse(r):[];e=Array.isArray(t)?t.map(e=>String(e)):[]}catch{e=r?[String(r)]:[]}Array.from(this._select.options).forEach(t=>{t.selected=e.includes(t.value)})}else this._select.value=r||``;this._changeHandler&&this._select&&this._select.removeEventListener(`change`,this._changeHandler),this._changeHandler=e=>{let t=e.target,r=n?Array.from(t.selectedOptions).map(e=>e.value):t.value,i=n?JSON.stringify(r):String(r||``);(this.getAttribute(`value`)||``)!==i&&(i?this.setAttribute(`value`,i):this.removeAttribute(`value`));let a=new Event(`input`,{bubbles:!0,cancelable:!0,composed:!0});this.dispatchEvent(a),this.dispatchEvent(new CustomEvent(`input`,{detail:{value:r},bubbles:!0,cancelable:!0,composed:!0})),this.dispatchEvent(new CustomEvent(`change`,{detail:{value:r},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(()=>{if(this._select)if(n){let t=[];try{let n=JSON.parse(e);t=Array.isArray(n)?n.map(e=>String(e)):[]}catch{t=[String(e)]}Array.from(this._select.options).forEach(e=>{e.selected=t.includes(e.value)})}else 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});let g=document.createElement(`div`);if(g.className=`mint-native-select-control-main`,g.appendChild(this._select),this._wrapper.appendChild(g),n)this._caretUpIcon=null,this._caretDownIcon=null;else{let e=document.createElement(`div`);e.className=`mint-native-select-caret`,this._caretUpIcon=document.createElement(`mint-icon`),this._caretUpIcon.setAttribute(`name`,`caret-up`),this._caretUpIcon.className=`mint-native-select-caret-up`,this._caretUpIcon.setAttribute(`aria-hidden`,`true`),e.appendChild(this._caretUpIcon),this._caretDownIcon=document.createElement(`mint-icon`),this._caretDownIcon.setAttribute(`name`,`caret-down`),this._caretDownIcon.className=`mint-native-select-caret-down`,this._caretDownIcon.setAttribute(`aria-hidden`,`true`),e.appendChild(this._caretDownIcon),g.appendChild(e)}let _=this._makeAdornment(`append`,this._appendNodes);if(_&&this._wrapper.appendChild(_),s){let e=document.createElement(`div`);e.setAttribute(t,`info`),e.className=`mint-native-select-info`,e.textContent=s,this.appendChild(e)}this._renderErrorState(),this._syncSelectAccessibility(),this._renderSkeleton(e)}_collectAdornments(){let e=[...this._prependNodes,...this._appendNodes,...Array.from(this.querySelectorAll(`:scope > [slot="prepend"], :scope > [slot="append"]`))];this._prependNodes=e.filter(e=>e.getAttribute(`slot`)===`prepend`),this._appendNodes=e.filter(e=>e.getAttribute(`slot`)===`append`),this._prependNodes.forEach(e=>this.appendChild(e)),this._appendNodes.forEach(e=>this.appendChild(e))}_makeAdornment(e,t){if(!t.length)return null;let n=document.createElement(`span`);return n.className=`mint-native-select-adornment mint-native-select-${e}-slot`,t.forEach(e=>n.appendChild(e)),n}_renderSkeleton(e){let t=this.querySelector(`.mint-native-select-skeleton-container`),n=this._wrapper;if(e){t||(t=document.createElement(`div`),t.className=`mint-native-select-skeleton-container`,t.setAttribute(`aria-hidden`,`true`),n?n.appendChild(t):this.appendChild(t));let e=t.querySelector(`.mint-native-select-skeleton`);e||(e=document.createElement(`div`),t.appendChild(e));let r=this.isMultiple();e.classList.toggle(`is-multiple`,r),e.style.height=r?`5rem`:`2rem`,t.style.display=`block`,this._select&&(this._select.style.opacity=`0`,this._select.style.pointerEvents=`none`,this._select.setAttribute(`aria-busy`,`true`))}else t&&(t.style.display=`none`),this._select&&(this._select.style.opacity=`1`,this._select.style.pointerEvents=`auto`,this._select.removeAttribute(`aria-busy`))}_renderErrorState(){let e=this.hasError(),n=this.getErrorMessage(),r=this.querySelector(`.mint-native-select-error`);e&&n?(r?r.hasAttribute(t)||r.setAttribute(t,`error`):(r=document.createElement(`div`),r.setAttribute(t,`error`),r.className=`mint-native-select-error`,this.appendChild(r)),r.textContent=n):r&&r.remove()}_syncSelectAccessibility(){if(!this._select)return;let e=this._select.id||this._generatedControlId,n=(this.getAttribute(`aria-describedby`)||``).split(/\s+/).filter(Boolean),r=this.querySelector(`[${t}="info"]`),i=this.querySelector(`.mint-native-select-error`);r&&(r.id=`${e}-info`,n.push(r.id)),i&&(i.id=`${e}-error`,n.push(i.id)),n.length?this._select.setAttribute(`aria-describedby`,Array.from(new Set(n)).join(` `)):this._select.removeAttribute(`aria-describedby`)}};customElements.get(`mint-native-select`)||e.t(`mint-native-select`,n);var r=`data-mint-select-part`,i=class extends HTMLElement{constructor(...e){super(...e),this._native=null,this._trigger=null,this._popover=null,this._list=null,this._prependNodes=[],this._appendNodes=[],this._observer=null,this._syncing=!1,this._typeahead=``,this._typeaheadTimer=null,this._pointerSelectedOption=null,this._id=`mint-select-${Math.random().toString(36).slice(2,10)}`}static get observedAttributes(){return[`name`,`value`,`values`,`multiple`,`disabled`,`id`,`required`,`label`,`info`,`error`,`error-message`,`loading`,`placeholder`,`aria-label`,`aria-labelledby`,`aria-describedby`,`form`]}connectedCallback(){this.classList.add(`mint-select-host`),this.render(),this._observer?.disconnect(),this._observer=new MutationObserver(e=>{this._syncing||e.some(e=>{let t=e.target instanceof Element?e.target:e.target.parentElement;return t===this||t?.closest(`[${r}]`)?!1:e.type===`attributes`?[`value`,`label`,`disabled`,`selected`].includes(e.attributeName):t instanceof HTMLOptionElement||t instanceof HTMLOptGroupElement||[...e.addedNodes,...e.removedNodes].some(e=>e instanceof HTMLOptionElement||e instanceof HTMLOptGroupElement)})&&this.render()}),this._observer.observe(this,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`value`,`label`,`disabled`,`selected`]})}disconnectedCallback(){this._observer?.disconnect(),this._observer=null,this._typeaheadTimer!==null&&window.clearTimeout(this._typeaheadTimer)}attributeChangedCallback(e,t,n){if(!(t===n||!this.isConnected)){if(e===`values`&&this._native&&this.isMultiple()){this._applyValues(this.parseValues(n)),this.updateDisplay();return}if(e===`multiple`&&this._native){this.render();return}if(e===`value`&&this._native){this.isMultiple()?this._applyValues(n?[n]:[]):this._native.value=n||``,this.updateDisplay();return}this.render()}}get value(){return this.isMultiple()?this.values:this._native?.value||this.getAttribute(`value`)||``}set value(e){this.setValue(e)}get values(){return this._native&&this.isMultiple()?Array.from(this._native.selectedOptions,e=>e.value):this.parseValues(this.getAttribute(`values`))}set values(e){this.setValue(e)}getValue(){return this.value}setValue(e){if(this.isMultiple()){let t=Array.isArray(e)?e.map(String):e==null||e===``?[]:[String(e)];this.setAttribute(`values`,JSON.stringify(t)),this._applyValues(t)}else{let t=e==null?``:String(e);this.setAttribute(`value`,t),this._native&&(this._native.value=t)}this.updateDisplay()}isDisabled(){return this.hasAttribute(`disabled`)&&this.getAttribute(`disabled`)!==`false`}isLoading(){let e=this.getAttribute(`loading`);return e!==null&&e!==`false`}isRequired(){return this.hasAttribute(`required`)&&this.getAttribute(`required`)!==`false`}isMultiple(){return this.hasAttribute(`multiple`)&&this.getAttribute(`multiple`)!==`false`}hasError(){return this.getAttribute(`error`)===`true`}parseValues(e){if(!e)return[];try{let t=JSON.parse(e);if(Array.isArray(t)){if(t.length===1&&typeof t[0]==`string`&&t[0].trim().startsWith(`[`))try{let e=JSON.parse(t[0]);if(Array.isArray(e))return e.map(String)}catch{}return t.map(String)}}catch{}return[e]}_applyValues(e){if(!this._native)return;let t=new Set(e);Array.from(this._native.options).forEach(e=>{e.selected=t.has(e.value)})}options(){return Array.from(this.querySelectorAll(`:scope > option, :scope > optgroup > option`))}selectedOption(){return this._native?.selectedOptions[0]||this.options().find(e=>e.value===this.value)}render(){let e=this._native?.value||this.getAttribute(`value`)||``,t=this._native?.multiple?Array.from(this._native.selectedOptions,e=>e.value):[],n=t.length?t:this.parseValues(this.getAttribute(`values`));this._syncing=!0,this._collectAdornments(),Array.from(this.children).forEach(e=>{e.hasAttribute(r)&&e.remove()});let i=this.getAttribute(`label`)?.trim()||``,a=this.getAttribute(`id`)||this._id;if(i){let e=document.createElement(`label`);e.setAttribute(r,`label`),e.className=`mint-select-label`,e.htmlFor=`${a}-trigger`,e.textContent=i,this.append(e)}let o=document.createElement(`div`);o.setAttribute(r,`wrap`),o.className=`mint-select-control-wrap`,o.style.position=`relative`,this.append(o);let s=this._makeAdornment(`prepend`,this._prependNodes);s&&o.append(s);let c=document.createElement(`button`);c.type=`button`,c.id=`${a}-trigger`,c.className=`mint-select-trigger`,c.disabled=this.isDisabled()||this.isLoading(),c.setAttribute(`role`,`combobox`),c.setAttribute(`aria-busy`,String(this.isLoading())),c.setAttribute(`aria-haspopup`,`listbox`),c.setAttribute(`aria-expanded`,`false`),c.setAttribute(`aria-required`,String(this.isRequired())),c.setAttribute(`aria-invalid`,String(this.hasError()));let l=this.getAttribute(`aria-labelledby`),u=this.getAttribute(`aria-label`)?.trim();if(l?c.setAttribute(`aria-labelledby`,l):!i&&u?c.setAttribute(`aria-label`,u):i&&c.setAttribute(`aria-labelledby`,`${a}-label`),i){let e=this.querySelector(`[${r}="label"]`);e&&(e.id=`${a}-label`)}let d=document.createElement(`span`);d.className=`mint-select-value`,c.append(d);let f=document.createElement(`span`);f.className=`mint-select-caret`,f.setAttribute(`aria-hidden`,`true`),f.innerHTML=`<mint-icon name="caret-up"></mint-icon><mint-icon name="caret-down"></mint-icon>`,c.append(f),o.append(c);let p=this._makeAdornment(`append`,this._appendNodes);p&&o.append(p);let m=null;this.isLoading()?(m=document.createElement(`div`),m.className=`mint-select-skeleton`,m.setAttribute(`aria-hidden`,`true`),m.style.cssText=`position:absolute;inset:0;z-index:1;border:1px solid var(--mint-color-border,#dfe6e0);border-radius:.5rem;background:var(--mint-color-surface-muted,#e8eee9);animation:mint-select-pulse 1.4s ease-in-out infinite;`,o.append(m),c.style.visibility=`hidden`,this.setAttribute(`aria-busy`,`true`)):this.removeAttribute(`aria-busy`);let h=document.createElement(`select`);h.setAttribute(r,`native`),h.className=`mint-select-native-control`,h.id=`${a}-native`,h.name=this.getAttribute(`name`)||``,h.multiple=this.isMultiple(),this.hasAttribute(`form`)&&h.setAttribute(`form`,this.getAttribute(`form`)||``),h.required=this.isRequired(),h.disabled=this.isDisabled(),h.tabIndex=-1,h.setAttribute(`aria-hidden`,`true`),h.setAttribute(`aria-invalid`,String(this.hasError()));let g=[this.getAttribute(`aria-describedby`),i?`${a}-label`:``,this.getAttribute(`info`)?`${a}-info`:``,this.getAttribute(`error-message`)?`${a}-error`:``].filter(Boolean).join(` `);if(g&&h.setAttribute(`aria-describedby`,g),this.options().forEach(e=>h.append(e.cloneNode(!0))),!h.options.length){let e=document.createElement(`option`);e.value=``,e.textContent=this.getAttribute(`placeholder`)||`Select an option`,e.disabled=!0,h.append(e)}if(h.multiple){let t=n.length?n:this.parseValues(this.getAttribute(`values`)).length?this.parseValues(this.getAttribute(`values`)):e?[e]:[];t.length&&Array.from(h.options).forEach(e=>{e.selected=t.includes(e.value)})}else h.value=e;o.append(h),this._native=h,this._trigger=c;let _=document.createElement(`mint-popover`);_.className=`mint-select-popover`,_.setAttribute(r,`popover`),_.setAttribute(`trigger-id`,c.id),_.setAttribute(`trigger-toggle`,`false`),_.setAttribute(`direction`,`down`),_.setAttribute(`trigger-align`,`start`),_.setAttribute(`align-selected`,`true`),_.setAttribute(`distance`,`4`),_.setAttribute(`padding`,`0`),_.setAttribute(`aria-label`,i?`${i} options`:`Select options`);let v=document.createElement(`div`);v.className=`mint-select-options`,v.id=`${a}-listbox`,v.setAttribute(`role`,`listbox`),v.setAttribute(`aria-multiselectable`,String(this.isMultiple())),c.setAttribute(`aria-controls`,v.id),_.append(v),this.append(_),this._popover=_,this._list=v,this.renderOptions(),this.updateDisplay(),this.bindEvents();let y=this.getAttribute(`info`);if(y){let e=document.createElement(`div`);e.setAttribute(r,`info`),e.className=`mint-select-info`,e.id=`${a}-info`,e.textContent=y,this.append(e)}let b=this.getAttribute(`error-message`);if(this.hasError()&&b){let e=document.createElement(`div`);e.setAttribute(r,`error`),e.className=`mint-select-error`,e.id=`${a}-error`,e.textContent=b,this.append(e)}this._syncing=!1}renderOptions(){this._list&&(this._list.replaceChildren(),Array.from(this.children).filter(e=>e.tagName===`OPTION`||e.tagName===`OPTGROUP`).forEach(e=>{if(e instanceof HTMLOptGroupElement){let t=document.createElement(`div`);t.className=`mint-select-group-label`,t.setAttribute(`role`,`presentation`),t.textContent=e.label,this._list.append(t),Array.from(e.children).forEach(t=>this.addOption(t,e.disabled))}else this.addOption(e,!1)}))}_collectAdornments(){let e=[...this._prependNodes,...this._appendNodes,...Array.from(this.querySelectorAll(`:scope > [slot="prepend"], :scope > [slot="append"]`))];this._prependNodes=e.filter(e=>e.getAttribute(`slot`)===`prepend`),this._appendNodes=e.filter(e=>e.getAttribute(`slot`)===`append`),this._prependNodes.forEach(e=>this.append(e)),this._appendNodes.forEach(e=>this.append(e))}_makeAdornment(e,t){if(!t.length)return null;let n=document.createElement(`span`);return n.className=`mint-select-adornment mint-select-${e}-slot`,t.forEach(e=>n.append(e)),n}addOption(e,t){if(!this._list)return;let n=document.createElement(`button`);n.type=`button`,n.className=`mint-select-option`,n.dataset.value=e.value,n.setAttribute(`role`,`option`),n.setAttribute(`aria-selected`,String(this.isMultiple()?this.values.includes(e.value):e.value===this.value)),n.disabled=e.disabled||t||this.isDisabled(),n.tabIndex=-1;let r=document.createElement(`span`);r.textContent=e.label||e.textContent||``,n.append(r);let i=document.createElement(`mint-icon`);i.setAttribute(`name`,`check`),i.setAttribute(`aria-hidden`,`true`),i.className=`mint-select-option-check`,n.append(i),this._list.append(n)}updateDisplay(){if(!this._native||!this._trigger)return;let e=this.selectedOption(),t=this.values,n=this.isMultiple()?t.map(e=>this.options().find(t=>t.value===e)?.label||e):[],r=this._trigger.querySelector(`.mint-select-value`);r&&(r.textContent=this.isMultiple()?n.join(`, `)||this.getAttribute(`placeholder`)||`Select an option`:e?.getAttribute(`data-display-label`)||e?.label||e?.textContent?.trim()||this.getAttribute(`placeholder`)||`Select an option`,r.classList.toggle(`is-placeholder`,this.isMultiple()?t.length===0:!e||e.value===``)),this._trigger.setAttribute(`aria-invalid`,String(this.hasError())),this._trigger.setAttribute(`aria-haspopup`,`listbox`),this._list?.setAttribute(`aria-multiselectable`,String(this.isMultiple())),this._list?.querySelectorAll(`[role="option"]`).forEach(e=>e.setAttribute(`aria-selected`,String(this.isMultiple()?t.includes(e.dataset.value||``):e.dataset.value===this._native.value)))}bindEvents(){!this._trigger||!this._popover||!this._native||!this._list||(this._trigger.onclick=()=>{this._popover.style.setProperty(`--mint-select-popover-width`,`${this._trigger.getBoundingClientRect().width}px`),this._popover.hasAttribute(`open`)?this._popover.close():this.openPopover()},this._trigger.onkeydown=e=>{let t=Array.from(this._list.querySelectorAll(`[role="option"]:not(:disabled)`));if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault(),this._popover.hasAttribute(`open`)||this.openPopover();let n=t.findIndex(e=>e.dataset.value===(this.isMultiple()?this.values[0]:this._native.value));t[e.key===`ArrowDown`?Math.min(t.length-1,n+1):Math.max(0,n<=0?0:n-1)]?.focus()}else if(e.key===`Enter`||e.key===` `)if(this._popover.hasAttribute(`open`)){e.preventDefault();let t=this._list.querySelector(`[role="option"]:focus`);t?this.selectOption(t.dataset.value||``):this.openPopover()}else e.key===` `&&(e.preventDefault(),this.openPopover());else e.key===`Escape`&&this._popover.hasAttribute(`open`)?(e.preventDefault(),this._popover.close(),this._trigger.focus()):e.key.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey&&this.typeahead(e.key)},this._list.onpointerdown=e=>{let t=e.target.closest(`[role="option"]`);if(!t||t.disabled)return;e.preventDefault();let n=t.dataset.value||``;this._pointerSelectedOption={value:n,time:Date.now()},this.selectOption(n)},this._list.onclick=e=>{let t=e.target.closest(`[role="option"]`);if(!t||t.disabled)return;let n=t.dataset.value||``,r=this._pointerSelectedOption?.value===n&&Date.now()-this._pointerSelectedOption.time<1e3;this._pointerSelectedOption=null,r||this.selectOption(n)},this._list.onkeydown=e=>{let t=Array.from(this._list.querySelectorAll(`[role="option"]:not(:disabled)`)),n=t.indexOf(e.target),r=n;if(e.key===`ArrowDown`)r=Math.min(t.length-1,n+1);else if(e.key===`ArrowUp`)r=Math.max(0,n-1);else if(e.key===`Home`)r=0;else if(e.key===`End`)r=t.length-1;else if(e.key===`Escape`){e.preventDefault(),this._popover.close(),this._trigger.focus();return}else if(e.key===`Enter`||e.key===` `){e.preventDefault(),this.selectOption(e.target.dataset.value||``);return}else if(e.key.length===1){this.typeahead(e.key);return}else return;e.preventDefault(),t[r]?.focus()},this._native.onchange=()=>{this.isMultiple()?this.setAttribute(`values`,JSON.stringify(this.values)):this.setAttribute(`value`,this._native.value),this.updateDisplay(),this.dispatchSelectionEvents()})}openPopover(){this._popover&&this._popover.open()}selectOption(e){if(this._native){if(this.isMultiple()){let t=new Set(this.values);t.has(e)?t.delete(e):t.add(e);let n=[...t];this._applyValues(n),this.setAttribute(`values`,JSON.stringify(n)),this.updateDisplay(),this.dispatchSelectionEvents();return}this._native.value=e,this.setAttribute(`value`,e),this.updateDisplay(),this._popover?.close(),this._trigger?.focus(),this.dispatchSelectionEvents()}}dispatchSelectionEvents(){let e=this.isMultiple()?this.values:this._native?.value||``,t=this.isMultiple()?{value:e,values:e}:{value:e};this.dispatchEvent(new CustomEvent(`input`,{bubbles:!0,composed:!0,detail:t})),this.dispatchEvent(new CustomEvent(`change`,{bubbles:!0,composed:!0,detail:t}))}typeahead(e){this._typeahead+=e.toLocaleLowerCase(),this._typeaheadTimer!==null&&window.clearTimeout(this._typeaheadTimer),this._typeaheadTimer=window.setTimeout(()=>{this._typeahead=``},700);let t=Array.from(this._list?.querySelectorAll(`[role="option"]:not(:disabled)`)||[]).find(e=>e.textContent?.trim().toLocaleLowerCase().startsWith(this._typeahead));t&&(this._popover?.hasAttribute(`open`)||this.openPopover(),t.focus())}};customElements.get(`mint-select`)||e.t(`mint-select`,i),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return i}});
1
+ require(`./icon-pgeP1zxb.js`);const e=require(`./register-element-tCL_F1YI.js`);require(`./icon-rdeLRs-R.js`),require(`./popover-N3cKN8iW.js`);var t=`data-mint-native-select-part`,n=class extends HTMLElement{static get observedAttributes(){return[`name`,`value`,`disabled`,`id`,`required`,`label`,`info`,`error`,`error-message`,`multiple`,`loading`,`aria-label`,`aria-labelledby`,`aria-describedby`]}constructor(){super(),this._select=null,this._wrapper=null,this._prependNodes=[],this._appendNodes=[],this._caretUpIcon=null,this._caretDownIcon=null,this._changeHandler=null,this._optionObserver=null,this._childrenObserver=null,this._hostOptionsObserverRaf=null,this._generatedControlId=`mint-native-select-${Math.random().toString(36).slice(2,10)}`}connectedCallback(){this.classList.add(`mint-native-select-host`),this.getLabel()||console.error(`mint-native-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=>{if(e.some(e=>{let t=e.target;if(this._select&&(t===this._select||this._select.contains(t)))return!1;let n=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`)),r=e.type===`attributes`&&e.target.nodeType===Node.ELEMENT_NODE&&(e.target.tagName===`OPTION`||e.target.tagName===`OPTGROUP`);return n||r})){if(this._hostOptionsObserverRaf!==null)return;this._hostOptionsObserverRaf=requestAnimationFrame(()=>{this._hostOptionsObserverRaf=null,this.isConnected&&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),this._hostOptionsObserverRaf!==null&&(cancelAnimationFrame(this._hostOptionsObserverRaf),this._hostOptionsObserverRaf=null)}isLoading(){let e=this.getAttribute(`loading`);return e!==null&&e!==`false`}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`),this._syncSelectAccessibility());return}if(e===`loading`){this.render();return}if(e===`value`){if(this._select)if(this.isMultiple()){let e=[];try{let t=n?JSON.parse(n):[];e=Array.isArray(t)?t.map(e=>String(e)):[]}catch{e=n?[String(n)]:[]}Array.from(this._select.options).forEach(t=>{t.selected=e.includes(t.value)})}else this._select.value=n||``;return}this.render()}}getName(){return this.getAttribute(`name`)||``}getValue(){if(this.isMultiple()&&this._select){let e=Array.from(this._select.selectedOptions).map(e=>e.value);return JSON.stringify(e)}return this.hasAttribute(`value`)?this.getAttribute(`value`)||``:this._select?this._select.value:``}setValue(e){if(this.isMultiple()){let t=Array.isArray(e)?e.map(e=>String(e)):e==null||e===``?[]:[String(e)];this.setAttribute(`value`,JSON.stringify(t)),this._select&&Array.from(this._select.options).forEach(e=>{e.selected=t.includes(e.value)});return}let t=e==null?``:String(e);this.setAttribute(`value`,t),this._select&&(this._select.value=t)}get value(){try{return this.getValue()||``}catch{return``}}set value(e){try{if(this.isMultiple()){this.setValue(e);return}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(){let e=this.getAttribute(`disabled`);return e!==null&&e!==`false`}isMultiple(){let e=this.getAttribute(`multiple`);return e!==null&&e!==`false`}isRequired(){let e=this.getAttribute(`required`);return e!==null&&e!==`false`}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(){return[`mint-native-select-control`,this.isMultiple()?`is-multiple`:``,this.hasError()?`has-error`:``].filter(Boolean).join(` `)}render(){this._hostOptionsObserverRaf!==null&&(cancelAnimationFrame(this._hostOptionsObserverRaf),this._hostOptionsObserverRaf=null);let e=this.isLoading(),n=this.isMultiple(),r=this.getValue();this._collectAdornments();let i=[];this._select&&Array.from(this._select.children).forEach(e=>{(e.tagName===`OPTION`||e.tagName===`OPTGROUP`)&&i.push(e.cloneNode(!0))}),Array.from(this.children).forEach(e=>{e instanceof HTMLElement&&e.hasAttribute(t)&&e.remove()}),this._wrapper=null,this._select=null;let a=Array.from(this.children).filter(e=>e.tagName===`OPTION`||e.tagName===`OPTGROUP`).map(e=>e.cloneNode(!0)),o=this.getLabel(),s=this.getInfo(),c=this.getId()||this._generatedControlId,l=this.getName(),u=this.isDisabled(),d=this.hasError();if(o){let e=document.createElement(`label`);e.setAttribute(t,`label`),e.className=`mint-native-select-label`,c&&e.setAttribute(`for`,c);let n=document.createTextNode(o);e.appendChild(n),this.appendChild(e)}this._wrapper=document.createElement(`div`),this._wrapper.setAttribute(t,`wrapper`),this._wrapper.className=`mint-native-select-control-wrap`,this.appendChild(this._wrapper);let f=this._makeAdornment(`prepend`,this._prependNodes);f&&this._wrapper.appendChild(f),this._select=document.createElement(`select`),this._select.className=this.getSelectClasses(),c&&(this._select.id=c),l&&(this._select.name=l),u&&(this._select.disabled=!0),this._select.required=this.isRequired(),n&&(this._select.multiple=!0),this._select.setAttribute(`aria-invalid`,d?`true`:`false`);let p=this.getAttribute(`aria-label`)?.trim(),m=this.getAttribute(`aria-labelledby`)?.trim();m?this._select.setAttribute(`aria-labelledby`,m):o?this._select.removeAttribute(`aria-label`):this._select.setAttribute(`aria-label`,p||`Select an option`);let h=a.length>0?a:i;if(h.length>0&&h.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(n){let e=[];try{let t=r?JSON.parse(r):[];e=Array.isArray(t)?t.map(e=>String(e)):[]}catch{e=r?[String(r)]:[]}Array.from(this._select.options).forEach(t=>{t.selected=e.includes(t.value)})}else this._select.value=r||``;this._changeHandler&&this._select&&this._select.removeEventListener(`change`,this._changeHandler),this._changeHandler=e=>{let t=e.target,r=n?Array.from(t.selectedOptions).map(e=>e.value):t.value,i=n?JSON.stringify(r):String(r||``);(this.getAttribute(`value`)||``)!==i&&(i?this.setAttribute(`value`,i):this.removeAttribute(`value`));let a=new Event(`input`,{bubbles:!0,cancelable:!0,composed:!0});this.dispatchEvent(a),this.dispatchEvent(new CustomEvent(`input`,{detail:{value:r},bubbles:!0,cancelable:!0,composed:!0})),this.dispatchEvent(new CustomEvent(`change`,{detail:{value:r},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(()=>{if(this._select)if(n){let t=[];try{let n=JSON.parse(e);t=Array.isArray(n)?n.map(e=>String(e)):[]}catch{t=[String(e)]}Array.from(this._select.options).forEach(e=>{e.selected=t.includes(e.value)})}else 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});let g=document.createElement(`div`);if(g.className=`mint-native-select-control-main`,g.appendChild(this._select),this._wrapper.appendChild(g),n)this._caretUpIcon=null,this._caretDownIcon=null;else{let e=document.createElement(`div`);e.className=`mint-native-select-caret`,this._caretUpIcon=document.createElement(`mint-icon`),this._caretUpIcon.setAttribute(`name`,`caret-up`),this._caretUpIcon.className=`mint-native-select-caret-up`,this._caretUpIcon.setAttribute(`aria-hidden`,`true`),e.appendChild(this._caretUpIcon),this._caretDownIcon=document.createElement(`mint-icon`),this._caretDownIcon.setAttribute(`name`,`caret-down`),this._caretDownIcon.className=`mint-native-select-caret-down`,this._caretDownIcon.setAttribute(`aria-hidden`,`true`),e.appendChild(this._caretDownIcon),g.appendChild(e)}let _=this._makeAdornment(`append`,this._appendNodes);if(_&&this._wrapper.appendChild(_),s){let e=document.createElement(`div`);e.setAttribute(t,`info`),e.className=`mint-native-select-info`,e.textContent=s,this.appendChild(e)}this._renderErrorState(),this._syncSelectAccessibility(),this._renderSkeleton(e)}_collectAdornments(){let e=[...this._prependNodes,...this._appendNodes,...Array.from(this.querySelectorAll(`:scope > [slot="prepend"], :scope > [slot="append"]`))];this._prependNodes=e.filter(e=>e.getAttribute(`slot`)===`prepend`),this._appendNodes=e.filter(e=>e.getAttribute(`slot`)===`append`),this._prependNodes.forEach(e=>this.appendChild(e)),this._appendNodes.forEach(e=>this.appendChild(e))}_makeAdornment(e,t){if(!t.length)return null;let n=document.createElement(`span`);return n.className=`mint-native-select-adornment mint-native-select-${e}-slot`,t.forEach(e=>n.appendChild(e)),n}_renderSkeleton(e){let t=this.querySelector(`.mint-native-select-skeleton-container`),n=this._wrapper;if(e){t||(t=document.createElement(`div`),t.className=`mint-native-select-skeleton-container`,t.setAttribute(`aria-hidden`,`true`),n?n.appendChild(t):this.appendChild(t));let e=t.querySelector(`.mint-native-select-skeleton`);e||(e=document.createElement(`div`),t.appendChild(e));let r=this.isMultiple();e.classList.toggle(`is-multiple`,r),e.style.height=r?`5rem`:`2rem`,t.style.display=`block`,this._select&&(this._select.style.opacity=`0`,this._select.style.pointerEvents=`none`,this._select.setAttribute(`aria-busy`,`true`))}else t&&(t.style.display=`none`),this._select&&(this._select.style.opacity=`1`,this._select.style.pointerEvents=`auto`,this._select.removeAttribute(`aria-busy`))}_renderErrorState(){let e=this.hasError(),n=this.getErrorMessage(),r=this.querySelector(`.mint-native-select-error`);e&&n?(r?r.hasAttribute(t)||r.setAttribute(t,`error`):(r=document.createElement(`div`),r.setAttribute(t,`error`),r.className=`mint-native-select-error`,this.appendChild(r)),r.textContent=n):r&&r.remove()}_syncSelectAccessibility(){if(!this._select)return;let e=this._select.id||this._generatedControlId,n=(this.getAttribute(`aria-describedby`)||``).split(/\s+/).filter(Boolean),r=this.querySelector(`[${t}="info"]`),i=this.querySelector(`.mint-native-select-error`);r&&(r.id=`${e}-info`,n.push(r.id)),i&&(i.id=`${e}-error`,n.push(i.id)),n.length?this._select.setAttribute(`aria-describedby`,Array.from(new Set(n)).join(` `)):this._select.removeAttribute(`aria-describedby`)}};customElements.get(`mint-native-select`)||e.t(`mint-native-select`,n);var r=`data-mint-select-part`,i=class extends HTMLElement{constructor(...e){super(...e),this._native=null,this._trigger=null,this._popover=null,this._list=null,this._prependNodes=[],this._appendNodes=[],this._observer=null,this._syncing=!1,this._typeahead=``,this._typeaheadTimer=null,this._pointerSelectedOption=null,this._id=`mint-select-${Math.random().toString(36).slice(2,10)}`}static get observedAttributes(){return[`name`,`value`,`values`,`multiple`,`disabled`,`id`,`required`,`label`,`info`,`error`,`error-message`,`loading`,`placeholder`,`aria-label`,`aria-labelledby`,`aria-describedby`,`form`]}connectedCallback(){this.classList.add(`mint-select-host`),this.render(),this._observer?.disconnect(),this._observer=new MutationObserver(e=>{this._syncing||e.some(e=>{let t=e.target instanceof Element?e.target:e.target.parentElement;return t===this||t?.closest(`[${r}]`)?!1:e.type===`attributes`?[`value`,`label`,`disabled`,`selected`].includes(e.attributeName):t instanceof HTMLOptionElement||t instanceof HTMLOptGroupElement||[...e.addedNodes,...e.removedNodes].some(e=>e instanceof HTMLOptionElement||e instanceof HTMLOptGroupElement)})&&this.render()}),this._observer.observe(this,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`value`,`label`,`disabled`,`selected`]})}disconnectedCallback(){this._observer?.disconnect(),this._observer=null,this._typeaheadTimer!==null&&window.clearTimeout(this._typeaheadTimer)}attributeChangedCallback(e,t,n){if(!(t===n||!this.isConnected)){if(e===`values`&&this._native&&this.isMultiple()){this._applyValues(this.parseValues(n)),this.updateDisplay();return}if(e===`multiple`&&this._native){this.render();return}if(e===`value`&&this._native){this.isMultiple()?this._applyValues(n?[n]:[]):this._native.value=n||``,this.updateDisplay();return}this.render()}}get value(){return this.isMultiple()?this.values:this._native?.value||this.getAttribute(`value`)||``}set value(e){this.setValue(e)}get values(){return this._native&&this.isMultiple()?Array.from(this._native.selectedOptions,e=>e.value):this.parseValues(this.getAttribute(`values`))}set values(e){this.setValue(e)}getValue(){return this.value}setValue(e){if(this.isMultiple()){let t=Array.isArray(e)?e.map(String):e==null||e===``?[]:[String(e)];this.setAttribute(`values`,JSON.stringify(t)),this._applyValues(t)}else{let t=e==null?``:String(e);this.setAttribute(`value`,t),this._native&&(this._native.value=t)}this.updateDisplay()}isDisabled(){return this.hasAttribute(`disabled`)&&this.getAttribute(`disabled`)!==`false`}isLoading(){let e=this.getAttribute(`loading`);return e!==null&&e!==`false`}isRequired(){return this.hasAttribute(`required`)&&this.getAttribute(`required`)!==`false`}isMultiple(){return this.hasAttribute(`multiple`)&&this.getAttribute(`multiple`)!==`false`}hasError(){return this.getAttribute(`error`)===`true`}parseValues(e){if(!e)return[];try{let t=JSON.parse(e);if(Array.isArray(t)){if(t.length===1&&typeof t[0]==`string`&&t[0].trim().startsWith(`[`))try{let e=JSON.parse(t[0]);if(Array.isArray(e))return e.map(String)}catch{}return t.map(String)}}catch{}return[e]}_applyValues(e){if(!this._native)return;let t=new Set(e);Array.from(this._native.options).forEach(e=>{e.selected=t.has(e.value)})}options(){return Array.from(this.querySelectorAll(`:scope > option, :scope > optgroup > option`))}selectedOption(){return this._native?.selectedOptions[0]||this.options().find(e=>e.value===this.value)}render(){let e=this._native?.value||this.getAttribute(`value`)||``,t=this._native?.multiple?Array.from(this._native.selectedOptions,e=>e.value):[],n=t.length?t:this.parseValues(this.getAttribute(`values`));this._syncing=!0,this._collectAdornments(),Array.from(this.children).forEach(e=>{e.hasAttribute(r)&&e.remove()});let i=this.getAttribute(`label`)?.trim()||``,a=this.getAttribute(`id`)||this._id;if(i){let e=document.createElement(`label`);e.setAttribute(r,`label`),e.className=`mint-select-label`,e.htmlFor=`${a}-trigger`,e.textContent=i,this.append(e)}let o=document.createElement(`div`);o.setAttribute(r,`wrap`),o.className=`mint-select-control-wrap`,o.style.position=`relative`,this.append(o);let s=this._makeAdornment(`prepend`,this._prependNodes);s&&o.append(s);let c=document.createElement(`button`);c.type=`button`,c.id=`${a}-trigger`,c.className=`mint-select-trigger`,c.disabled=this.isDisabled()||this.isLoading(),c.setAttribute(`role`,`combobox`),c.setAttribute(`aria-busy`,String(this.isLoading())),c.setAttribute(`aria-haspopup`,`listbox`),c.setAttribute(`aria-expanded`,`false`),c.setAttribute(`aria-required`,String(this.isRequired())),c.setAttribute(`aria-invalid`,String(this.hasError()));let l=this.getAttribute(`aria-labelledby`),u=this.getAttribute(`aria-label`)?.trim();if(l?c.setAttribute(`aria-labelledby`,l):!i&&u?c.setAttribute(`aria-label`,u):i&&c.setAttribute(`aria-labelledby`,`${a}-label`),i){let e=this.querySelector(`[${r}="label"]`);e&&(e.id=`${a}-label`)}let d=document.createElement(`span`);d.className=`mint-select-value`,c.append(d);let f=document.createElement(`span`);f.className=`mint-select-caret`,f.setAttribute(`aria-hidden`,`true`),f.innerHTML=`<mint-icon name="caret-up"></mint-icon><mint-icon name="caret-down"></mint-icon>`,c.append(f),o.append(c);let p=this._makeAdornment(`append`,this._appendNodes);p&&o.append(p);let m=null;this.isLoading()?(m=document.createElement(`div`),m.className=`mint-select-skeleton`,m.setAttribute(`aria-hidden`,`true`),m.style.cssText=`position:absolute;inset:0;z-index:1;border:1px solid var(--mint-color-border,#dfe6e0);border-radius:.5rem;background:var(--mint-color-surface-muted,#e8eee9);animation:mint-select-pulse 1.4s ease-in-out infinite;`,o.append(m),c.style.visibility=`hidden`,this.setAttribute(`aria-busy`,`true`)):this.removeAttribute(`aria-busy`);let h=document.createElement(`select`);h.setAttribute(r,`native`),h.className=`mint-select-native-control`,h.id=`${a}-native`,h.name=this.getAttribute(`name`)||``,h.multiple=this.isMultiple(),this.hasAttribute(`form`)&&h.setAttribute(`form`,this.getAttribute(`form`)||``),h.required=this.isRequired(),h.disabled=this.isDisabled(),h.tabIndex=-1,h.setAttribute(`aria-hidden`,`true`),h.setAttribute(`aria-invalid`,String(this.hasError()));let g=[this.getAttribute(`aria-describedby`),i?`${a}-label`:``,this.getAttribute(`info`)?`${a}-info`:``,this.getAttribute(`error-message`)?`${a}-error`:``].filter(Boolean).join(` `);if(g&&h.setAttribute(`aria-describedby`,g),this.options().forEach(e=>h.append(e.cloneNode(!0))),!h.options.length){let e=document.createElement(`option`);e.value=``,e.textContent=this.getAttribute(`placeholder`)||`Select an option`,e.disabled=!0,h.append(e)}if(h.multiple){let t=n.length?n:this.parseValues(this.getAttribute(`values`)).length?this.parseValues(this.getAttribute(`values`)):e?[e]:[];t.length&&Array.from(h.options).forEach(e=>{e.selected=t.includes(e.value)})}else h.value=e;o.append(h),this._native=h,this._trigger=c;let _=document.createElement(`mint-popover`);_.className=`mint-select-popover`,_.setAttribute(r,`popover`),_.setAttribute(`trigger-id`,c.id),_.setAttribute(`trigger-toggle`,`false`),_.setAttribute(`direction`,`down`),_.setAttribute(`trigger-align`,`start`),_.setAttribute(`align-selected`,`true`),_.setAttribute(`distance`,`4`),_.setAttribute(`padding`,`0`),_.setAttribute(`aria-label`,i?`${i} options`:`Select options`);let v=document.createElement(`div`);v.className=`mint-select-options`,v.id=`${a}-listbox`,v.setAttribute(`role`,`listbox`),v.setAttribute(`aria-multiselectable`,String(this.isMultiple())),c.setAttribute(`aria-controls`,v.id),_.append(v),this.append(_),this._popover=_,this._list=v,this.renderOptions(),this.updateDisplay(),this.bindEvents();let y=this.getAttribute(`info`);if(y){let e=document.createElement(`div`);e.setAttribute(r,`info`),e.className=`mint-select-info`,e.id=`${a}-info`,e.textContent=y,this.append(e)}let b=this.getAttribute(`error-message`);if(this.hasError()&&b){let e=document.createElement(`div`);e.setAttribute(r,`error`),e.className=`mint-select-error`,e.id=`${a}-error`,e.textContent=b,this.append(e)}this._syncing=!1}renderOptions(){this._list&&(this._list.replaceChildren(),Array.from(this.children).filter(e=>e.tagName===`OPTION`||e.tagName===`OPTGROUP`).forEach(e=>{if(e instanceof HTMLOptGroupElement){let t=document.createElement(`div`);t.className=`mint-select-group-label`,t.setAttribute(`role`,`presentation`),t.textContent=e.label,this._list.append(t),Array.from(e.children).forEach(t=>this.addOption(t,e.disabled))}else this.addOption(e,!1)}))}_collectAdornments(){let e=[...this._prependNodes,...this._appendNodes,...Array.from(this.querySelectorAll(`:scope > [slot="prepend"], :scope > [slot="append"]`))];this._prependNodes=e.filter(e=>e.getAttribute(`slot`)===`prepend`),this._appendNodes=e.filter(e=>e.getAttribute(`slot`)===`append`),this._prependNodes.forEach(e=>this.append(e)),this._appendNodes.forEach(e=>this.append(e))}_makeAdornment(e,t){if(!t.length)return null;let n=document.createElement(`span`);return n.className=`mint-select-adornment mint-select-${e}-slot`,t.forEach(e=>n.append(e)),n}addOption(e,t){if(!this._list)return;let n=document.createElement(`button`);n.type=`button`,n.className=`mint-select-option`,n.dataset.value=e.value,n.setAttribute(`role`,`option`),n.setAttribute(`aria-selected`,String(this.isMultiple()?this.values.includes(e.value):e.value===this.value)),n.disabled=e.disabled||t||this.isDisabled(),n.tabIndex=-1;let r=document.createElement(`span`);r.textContent=e.label||e.textContent||``,n.append(r);let i=document.createElement(`mint-icon`);i.setAttribute(`name`,`check`),i.setAttribute(`aria-hidden`,`true`),i.className=`mint-select-option-check`,n.append(i),this._list.append(n)}updateDisplay(){if(!this._native||!this._trigger)return;let e=this.selectedOption(),t=this.values,n=this.isMultiple()?t.map(e=>this.options().find(t=>t.value===e)?.label||e):[],r=this._trigger.querySelector(`.mint-select-value`);r&&(r.textContent=this.isMultiple()?n.join(`, `)||this.getAttribute(`placeholder`)||`Select an option`:e?.getAttribute(`data-display-label`)||e?.label||e?.textContent?.trim()||this.getAttribute(`placeholder`)||`Select an option`,r.classList.toggle(`is-placeholder`,this.isMultiple()?t.length===0:!e||e.value===``)),this._trigger.setAttribute(`aria-invalid`,String(this.hasError())),this._trigger.setAttribute(`aria-haspopup`,`listbox`),this._list?.setAttribute(`aria-multiselectable`,String(this.isMultiple())),this._list?.querySelectorAll(`[role="option"]`).forEach(e=>e.setAttribute(`aria-selected`,String(this.isMultiple()?t.includes(e.dataset.value||``):e.dataset.value===this._native.value)))}bindEvents(){!this._trigger||!this._popover||!this._native||!this._list||(this._trigger.onclick=()=>{this._popover.style.setProperty(`--mint-select-popover-width`,`${this._trigger.getBoundingClientRect().width}px`),this._popover.hasAttribute(`open`)?this._popover.close():this.openPopover()},this._trigger.onkeydown=e=>{let t=Array.from(this._list.querySelectorAll(`[role="option"]:not(:disabled)`));if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault(),this._popover.hasAttribute(`open`)||this.openPopover();let n=t.findIndex(e=>e.dataset.value===(this.isMultiple()?this.values[0]:this._native.value));t[e.key===`ArrowDown`?Math.min(t.length-1,n+1):Math.max(0,n<=0?0:n-1)]?.focus()}else if(e.key===`Enter`||e.key===` `)if(this._popover.hasAttribute(`open`)){e.preventDefault();let t=this._list.querySelector(`[role="option"]:focus`);t?this.selectOption(t.dataset.value||``):this.openPopover()}else e.key===` `&&(e.preventDefault(),this.openPopover());else e.key===`Escape`&&this._popover.hasAttribute(`open`)?(e.preventDefault(),this._popover.close(),this._trigger.focus()):e.key.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey&&this.typeahead(e.key)},this._list.onpointerdown=e=>{let t=e.target.closest(`[role="option"]`);if(!t||t.disabled)return;e.preventDefault();let n=t.dataset.value||``;this._pointerSelectedOption={value:n,time:Date.now()},this.selectOption(n)},this._list.onclick=e=>{let t=e.target.closest(`[role="option"]`);if(!t||t.disabled)return;let n=t.dataset.value||``,r=this._pointerSelectedOption?.value===n&&Date.now()-this._pointerSelectedOption.time<1e3;this._pointerSelectedOption=null,r||this.selectOption(n)},this._list.onkeydown=e=>{let t=Array.from(this._list.querySelectorAll(`[role="option"]:not(:disabled)`)),n=t.indexOf(e.target),r=n;if(e.key===`ArrowDown`)r=Math.min(t.length-1,n+1);else if(e.key===`ArrowUp`)r=Math.max(0,n-1);else if(e.key===`Home`)r=0;else if(e.key===`End`)r=t.length-1;else if(e.key===`Escape`){e.preventDefault(),this._popover.close(),this._trigger.focus();return}else if(e.key===`Enter`||e.key===` `){e.preventDefault(),this.selectOption(e.target.dataset.value||``);return}else if(e.key.length===1){this.typeahead(e.key);return}else return;e.preventDefault(),t[r]?.focus()},this._native.onchange=()=>{this.isMultiple()?this.setAttribute(`values`,JSON.stringify(this.values)):this.setAttribute(`value`,this._native.value),this.updateDisplay(),this.dispatchSelectionEvents()})}openPopover(){this._popover&&this._popover.open()}selectOption(e){if(this._native){if(this.isMultiple()){let t=new Set(this.values);t.has(e)?t.delete(e):t.add(e);let n=[...t];this._applyValues(n),this.setAttribute(`values`,JSON.stringify(n)),this.updateDisplay(),this.dispatchSelectionEvents();return}this._native.value=e,this.setAttribute(`value`,e),this.updateDisplay(),this._popover?.close(),this._trigger?.focus(),this.dispatchSelectionEvents()}}dispatchSelectionEvents(){let e=this.isMultiple()?this.values:this._native?.value||``,t=this.isMultiple()?{value:e,values:e}:{value:e};this.dispatchEvent(new CustomEvent(`input`,{bubbles:!0,composed:!0,detail:t})),this.dispatchEvent(new CustomEvent(`change`,{bubbles:!0,composed:!0,detail:t}))}typeahead(e){this._typeahead+=e.toLocaleLowerCase(),this._typeaheadTimer!==null&&window.clearTimeout(this._typeaheadTimer),this._typeaheadTimer=window.setTimeout(()=>{this._typeahead=``},700);let t=Array.from(this._list?.querySelectorAll(`[role="option"]:not(:disabled)`)||[]).find(e=>e.textContent?.trim().toLocaleLowerCase().startsWith(this._typeahead));t&&(this._popover?.hasAttribute(`open`)||this.openPopover(),t.focus())}};customElements.get(`mint-select`)||e.t(`mint-select`,i),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return i}});
@@ -1,7 +1,7 @@
1
- import "./icon-1cs-hcBy.js";
1
+ import "./icon-CuRTWM4k.js";
2
2
  import { t as e } from "./register-element-BFYmIynH.js";
3
- import "./icon-aNwWb0hA.js";
4
- import "./popover-DD7uyRXy.js";
3
+ import "./icon-Cmx9FTmb.js";
4
+ import "./popover-BcN2LEbO.js";
5
5
  //#region src/components/select/NativeSelect.ts
6
6
  var t = "data-mint-native-select-part", n = class extends HTMLElement {
7
7
  static get observedAttributes() {
@@ -0,0 +1 @@
1
+ const e=require(`./register-element-tCL_F1YI.js`);var t=`mint-sortable-placeholder`,n=`mint-sortable-dragging`,r=class e extends HTMLElement{static get observedAttributes(){return[`direction`,`gap`,`text-align`,`align-content`,`scroll-max-height`,`disabled`,`handle-selector`,`drag-threshold`,`scroll-sensitivity`,`scroll-speed`,`animation-duration`,`item-key-attribute`,`group`]}constructor(){super(),this._pointerId=null,this._dragEl=null,this._dragOriginalStyle=``,this._placeholder=null,this._listRoot=this,this._startIndex=0,this._pointerStartX=0,this._pointerStartY=0,this._pendingDragStart=null,this._pendingPointerEvent=null,this._moveRaf=null,this._gridSlots=[],this._scrollRaf=null,this._scrollRoot=null,this._lastDragPointer=null,this._previewResizeRaf=null,this._childObserver=null,this._pointerBoundRoot=null,this._restoreAfter=null,this._originListRoot=null,this._originNextSibling=null,this._dropList=null,this._dropAtEnd=!1,this._dropRejected=!1,this._sortStatus=null,this._flipCleanupTimers=new WeakMap,this._lastPreviewRoot=null,this._lastPreviewIndex=-1,this._keyboardKeydownHandler=e=>this._onKeyboardReorder(e),this._onPendingPointerMove=e=>{let t=e,n=this._pendingDragStart;!n||t.pointerId!==n.pointerId||Math.hypot(t.clientX-n.clientX,t.clientY-n.clientY)<this._getDragThreshold()||(this._clearPendingDragStart(),t.preventDefault(),this._startDrag(t,n.item))},this._onPendingPointerEnd=e=>{let t=e;this._pendingDragStart?.pointerId===t.pointerId&&this._clearPendingDragStart()},this._onListPointerDown=e=>{let t=e;if(this._isDisabled()||this._pointerId!==null||this._pendingDragStart||t.button!==0)return;let n=t.target;if(!n||!this.contains(n))return;let r=(n instanceof Element?n:n.parentElement)?.closest(`mint-sortable`);if(r&&r!==this)return;let i=this._closestSortableItem(n);if(!i||!this._listRoot.contains(i)||i.hasAttribute(`data-sortable-disabled`))return;let a=this._getHandleSelector();if(a){let e=t.target.closest(a);if(!e||!i.contains(e))return}if(this._getDragThreshold()>0){this._pendingDragStart={pointerId:t.pointerId,item:i,clientX:t.clientX,clientY:t.clientY},window.addEventListener(`pointermove`,this._onPendingPointerMove,{passive:!1}),window.addEventListener(`pointerup`,this._onPendingPointerEnd),window.addEventListener(`pointercancel`,this._onPendingPointerEnd);return}t.preventDefault(),this._startDrag(t,i)},this._runAutoScrollFrame=()=>{this._scrollRaf=null;let e=this._scrollRoot,t=this._lastDragPointer;if(!e||!t||!this._dragEl||!this._placeholder)return;let n=this.getDirection(),r=getComputedStyle(e),i=/(auto|scroll)/.test(r.overflowX)&&e.scrollWidth>e.clientWidth,a=/(auto|scroll)/.test(r.overflowY)&&e.scrollHeight>e.clientHeight,o=e.getBoundingClientRect(),s=this._getScrollSensitivity(),c=this._getScrollSpeed(),l=0,u=0;if((n===`horizontal`||n===`grid`)&&i&&(t.clientX<o.left+s&&e.scrollLeft>0?l=-c:t.clientX>o.right-s&&e.scrollLeft+e.clientWidth<e.scrollWidth&&(l=c)),(n===`vertical`||n===`grid`)&&a&&(t.clientY<o.top+s&&e.scrollTop>0?u=-c:t.clientY>o.bottom-s&&e.scrollTop+e.clientHeight<e.scrollHeight&&(u=c)),l===0&&u===0)return;let d=e.scrollLeft,f=e.scrollTop;e.scrollLeft+=l,e.scrollTop+=u,(e.scrollLeft!==d||e.scrollTop!==f)&&(this._maybeMovePlaceholder(t),this._scrollRaf=requestAnimationFrame(this._runAutoScrollFrame))},this._boundPointerMove=this._onPointerMove.bind(this),this._boundPointerUp=this._onPointerUp.bind(this),this._boundPointerCancel=this._onPointerCancel.bind(this)}connectedCallback(){this.classList.add(`mint-sortable`),this._syncInnerStackAttributes(),this._applyHostScrollAndLayout(),this.addEventListener(`keydown`,this._keyboardKeydownHandler),this._observeInnerStack()}disconnectedCallback(){this._unobserveInnerStack(),this.removeEventListener(`keydown`,this._keyboardKeydownHandler),this._teardownDrag(),this._pointerBoundRoot&&=(this._pointerBoundRoot.removeEventListener(`pointerdown`,this._onListPointerDown),null)}attributeChangedCallback(e,t,n){t!==n&&(this._syncInnerStackAttributes(),this._applyHostScrollAndLayout())}_observeInnerStack(){this._childObserver||(this._childObserver=new MutationObserver(()=>{this._pointerId===null&&(this._syncInnerStackAttributes(),this._applyHostScrollAndLayout())}),this._childObserver.observe(this,{childList:!0}))}_unobserveInnerStack(){this._childObserver&&=(this._childObserver.disconnect(),null)}_getInnerStack(){for(let e=0;e<this.children.length;e++){let t=this.children[e];if(t.nodeType===Node.ELEMENT_NODE&&t.tagName===`MINT-STACK`)return t}return null}_resolveListRoot(){return this._getInnerStack()??this}_getItemKeyAttribute(){return this.getAttribute(`item-key-attribute`)?.trim()||`data-sortable-id`}_collectOrderedKeys(){let e=this._resolveListRoot(),n=this._getItemKeyAttribute(),r=[];for(let i=0;i<e.children.length;i++){let a=e.children[i];if(a.nodeType!==Node.ELEMENT_NODE)continue;let o=a;o.classList.contains(t)||o.hasAttribute(`data-mint-sortable-status`)||r.push(o.getAttribute(n)??``)}return r}_syncInnerStackAttributes(){let e=this._getInnerStack();if(!e)return;let t=this.getDirection(),n=this.getGap(),r=this.getTextAlign();e.setAttribute(`direction`,t),e.setAttribute(`gap`,String(n)),r?e.setAttribute(`text-align`,r):e.removeAttribute(`text-align`);let i=this.getAlignContent();i?e.setAttribute(`align-content`,i):e.removeAttribute(`align-content`)}_applyHostScrollAndLayout(){this._listRoot=this._resolveListRoot();let e=this.getAttribute(`scroll-max-height`);e?(this.style.maxHeight=e,this.style.overflowY=`auto`,this.style.overflowX=`hidden`,this.classList.add(`mint-sortable-scrollable`)):(this.style.maxHeight=``,this.style.overflowY=``,this.style.overflowX=``,this.classList.remove(`mint-sortable-scrollable`));let t=this._getInnerStack();this.classList.toggle(`mint-sortable-has-inner-stack`,!!t);let n=this.getDirection(),r=this.getAlignContent(),i=Math.min(12,Math.max(1,Math.round(this.getGap()))),a=this.getTextAlign();this.style.setProperty(`--mint-sortable-direction`,n===`horizontal`?`row`:`column`),this.style.setProperty(`--mint-sortable-gap`,`${i*.25}rem`),this.style.setProperty(`--mint-sortable-text-align`,a||`initial`),this.style.setProperty(`--mint-sortable-button-justify`,a===`left`?`flex-start`:a===`right`?`flex-end`:`center`);let o=r?r===`left`?`flex-start`:r===`right`?`flex-end`:`center`:``,s=n===`vertical`&&o||`stretch`,c=n===`horizontal`&&o||`flex-start`;this.style.setProperty(`--mint-sortable-cross-align`,s),this.style.setProperty(`--mint-sortable-main-align`,c),this._ensureListPointerBinding(),this._syncKeyboardAccessibility()}_syncKeyboardAccessibility(){let e=this._resolveListRoot();e.hasAttribute(`role`)||e.setAttribute(`role`,`list`),this._sortStatus||(this._sortStatus=document.createElement(`div`),this._sortStatus.className=`mint-sortable-status`,this._sortStatus.setAttribute(`role`,`status`),this._sortStatus.setAttribute(`aria-live`,`polite`),this._sortStatus.setAttribute(`aria-atomic`,`true`),this._sortStatus.setAttribute(`data-mint-sortable-status`,``),this.appendChild(this._sortStatus)),this._getLayoutChildren().forEach(e=>{e.classList.contains(t)||(e.hasAttribute(`role`)||e.setAttribute(`role`,`listitem`),e.hasAttribute(`tabindex`)||(e.tabIndex=0),e.setAttribute(`aria-keyshortcuts`,`Alt+ArrowUp Alt+ArrowDown`),e.hasAttribute(`aria-roledescription`)||e.setAttribute(`aria-roledescription`,`sortable item`))})}_onKeyboardReorder(e){if(this._isDisabled()||!e.altKey||![`ArrowUp`,`ArrowDown`].includes(e.key))return;let n=e.target instanceof Element?e.target:null,r=n?.closest(`mint-sortable`);if(r&&r!==this)return;let i=n?this._closestSortableItem(n):null;if(!i||i.hasAttribute(`data-sortable-disabled`))return;let a=this._getLayoutChildren().filter(e=>!e.classList.contains(t)),o=a.indexOf(i),s=o+(e.key===`ArrowUp`?-1:1);if(o<0||s<0||s>=a.length)return;e.preventDefault();let c=a[s];e.key===`ArrowUp`?this._listRoot.insertBefore(i,c):this._listRoot.insertBefore(c,i),i.focus({preventScroll:!0});let l=this._collectOrderedKeys(),u=this._indexOfItem(i),d=i.getAttribute(`aria-label`)||i.textContent?.trim().replace(/\s+/g,` `)||`Item`;this._sortStatus&&(this._sortStatus.textContent=`${d} moved to position ${u+1} of ${a.length}.`);let f=this.getAttribute(`data-tree-parent-id`)||null,p={oldIndex:o,newIndex:u,keys:l,itemId:i.getAttribute(this._getItemKeyAttribute())||``,oldParentId:f,newParentId:f,sourceContainerId:this.id||null,destinationContainerId:this.id||null};this.dispatchEvent(new CustomEvent(`mint-sortable-change`,{bubbles:!0,composed:!0,detail:p})),this.dispatchEvent(new CustomEvent(`mint-sortable-order`,{bubbles:!0,composed:!0,detail:{keys:l}}))}getDirection(){let e=this.getAttribute(`direction`)||`vertical`;return e===`horizontal`||e===`grid`?e:`vertical`}getGap(){let e=this.getAttribute(`gap`)||`3`,t=parseFloat(e);return Number.isFinite(t)?t:3}getTextAlign(){let e=this.getAttribute(`text-align`)||``;return[`left`,`center`,`right`,`justify`].includes(e)?e:``}getAlignContent(){let e=(this.getAttribute(`align-content`)||``).trim().toLowerCase();return e===`left`||e===`right`||e===`center`?e:``}_isDisabled(){return this.hasAttribute(`disabled`)&&this.getAttribute(`disabled`)!==`false`}_getHandleSelector(){let e=this.getAttribute(`handle-selector`);return e&&e.trim()?e.trim():null}_getDragThreshold(){let e=parseFloat(this.getAttribute(`drag-threshold`)||`0`);return Number.isFinite(e)?Math.max(0,e):0}_clearPendingDragStart(){this._pendingDragStart&&=(window.removeEventListener(`pointermove`,this._onPendingPointerMove),window.removeEventListener(`pointerup`,this._onPendingPointerEnd),window.removeEventListener(`pointercancel`,this._onPendingPointerEnd),null)}_getScrollSensitivity(){let e=parseFloat(this.getAttribute(`scroll-sensitivity`)||`48`);return Number.isFinite(e)?e:48}_getScrollSpeed(){let e=parseFloat(this.getAttribute(`scroll-speed`)||`12`);return Number.isFinite(e)?e:12}_getAnimationDurationMs(){let e=parseFloat(this.getAttribute(`animation-duration`)||`220`);return Number.isFinite(e)?Math.max(0,e):220}_ensureListPointerBinding(){let e=this._resolveListRoot();this._pointerBoundRoot!==e&&(this._pointerBoundRoot&&this._pointerBoundRoot.removeEventListener(`pointerdown`,this._onListPointerDown),e.addEventListener(`pointerdown`,this._onListPointerDown),this._pointerBoundRoot=e,this._listRoot=e)}_closestSortableItem(e){let r=e;for(;r&&r!==this._listRoot;){if(r.nodeType===Node.ELEMENT_NODE){let e=r;if(e.classList.contains(t)||e.classList.contains(n))return null;if(r.parentElement===this._listRoot)return e}r=r.parentElement}return null}_startDrag(e,r){this._listRoot=this._resolveListRoot(),this._restoreAfter=r.nextElementSibling,this._originListRoot=this._listRoot,this._originNextSibling=r.nextElementSibling,this._dropList=this,this._dropAtEnd=!1,this._dropRejected=!1,this._dragEl=r,this._dragOriginalStyle=r.style.cssText,this._pointerId=e.pointerId,this._startIndex=this._indexOfItem(r),this._gridSlots=this.getDirection()===`grid`?Array.from(this._listRoot.children).filter(e=>e.nodeType===Node.ELEMENT_NODE&&!e.hasAttribute(`data-mint-sortable-status`)).map((e,t)=>({element:e,rect:e.getBoundingClientRect(),index:t})):[];let i=r.getBoundingClientRect();this._pointerStartX=e.clientX,this._pointerStartY=e.clientY,this._lastDragPointer={clientX:e.clientX,clientY:e.clientY};let a=document.createElement(`div`);if(a.className=t,this.getDirection()!==`grid`)a.style.minHeight=`${i.height}px`,a.style.minWidth=`${i.width}px`;else{let e=window.getComputedStyle(r);e.gridArea===`auto`?(a.style.gridColumn=e.gridColumn,a.style.gridRow=e.gridRow):a.style.gridArea=e.gridArea,a.style.alignSelf=e.alignSelf,a.style.justifySelf=e.justifySelf}a.setAttribute(`aria-hidden`,`true`),this._placeholder=a,this._listRoot.insertBefore(a,r),r.classList.add(n),r.style.position=`fixed`;let o=this.getDirection()===`grid`;r.style.left=`${o?e.clientX:i.left}px`,r.style.top=`${o?e.clientY:i.top}px`,r.style.width=`${i.width}px`,r.style.height=`${i.height}px`,r.style.margin=`0`,r.style.zIndex=`10000`,r.style.boxSizing=`border-box`,r.style.pointerEvents=`none`,r.style.touchAction=`none`,r.style.transform=o?`translate3d(0, 0, 0) translate(-50%, -50%) scale(1.015)`:`translate3d(0, 0, 0) scale(1.015)`,r.style.transformOrigin=o?`center center`:`top left`,r.style.willChange=`transform`,document.body.appendChild(r),r.setPointerCapture(e.pointerId);let s=this._collectOrderedKeys(),c={index:this._startIndex,itemId:r.getAttribute(this._getItemKeyAttribute())||``,keys:s,sourceContainerId:this.id||null};this.dispatchEvent(new CustomEvent(`mint-sortable-start`,{bubbles:!0,composed:!0,detail:c})),this.dispatchEvent(new CustomEvent(`sort-start`,{bubbles:!0,composed:!0,detail:c})),window.addEventListener(`pointermove`,this._boundPointerMove,{passive:!1}),window.addEventListener(`pointerup`,this._boundPointerUp),window.addEventListener(`pointercancel`,this._boundPointerCancel)}_indexOfItem(e){let n=0;for(let r=0;r<this._listRoot.children.length;r++){let i=this._listRoot.children[r];if(i.nodeType!==Node.ELEMENT_NODE)continue;let a=i;if(!a.classList.contains(t)){if(a===e)return n;n++}}return-1}_getLayoutChildren(){return Array.from(this._listRoot.children).filter(e=>e.nodeType===Node.ELEMENT_NODE&&!e.hasAttribute(`data-mint-sortable-status`))}_onPointerMove(e){e.pointerId!==this._pointerId||!this._dragEl||!this._placeholder||(e.preventDefault(),this._pendingPointerEvent=e,this._moveRaf===null&&(this._moveRaf=requestAnimationFrame(()=>{this._moveRaf=null;let e=this._pendingPointerEvent;this._pendingPointerEvent=null,e&&e.pointerId===this._pointerId&&this._processPointerMove(e)})))}_processPointerMove(e){if(!this._dragEl||!this._placeholder)return;let t=e.clientX-this._pointerStartX,n=e.clientY-this._pointerStartY;this._dragEl.style.transform=this.getDirection()===`grid`?`translate3d(${t}px, ${n}px, 0) translate(-50%, -50%) scale(1.015)`:`translate3d(${t}px, ${n}px, 0) scale(1.015)`,this.dispatchEvent(new CustomEvent(`mint-sortable-drag`,{bubbles:!0,composed:!0,detail:{item:this._dragEl,source:this,clientX:e.clientX,clientY:e.clientY}})),this._autoScroll(e),this._maybeMovePlaceholder(e)}_resolveDropList(t){let n=document.elementFromPoint(t.clientX,t.clientY),r=n?.closest(`[data-mint-sortable-drop-container]`);this._dropAtEnd=!!r?.hasAttribute(`data-mint-sortable-drop-end`);let i=r?.getAttribute(`data-mint-sortable-drop-container`),a=i?document.getElementById(i):null,o=a?.matches(`mint-sortable`)?a:n?.closest(`mint-sortable`),s=o instanceof e?o:this,c=this.getAttribute(`group`)?.trim(),l=!!(c&&s.getAttribute(`group`)?.trim()===c),u=!!(this._dragEl&&(s===this._dragEl||this._dragEl.contains(s))),d=s===this||l&&s.isConnected&&!u,f=new CustomEvent(`mint-sortable-drag-over`,{bubbles:!0,composed:!0,cancelable:!0,detail:{item:this._dragEl,source:this,target:s,clientX:t.clientX,clientY:t.clientY}});return this.dispatchEvent(f),this._dropRejected=!d||f.defaultPrevented,this._dropRejected?this:s}_autoScroll(e){this._lastDragPointer={clientX:e.clientX,clientY:e.clientY};let t=this.getDirection(),n=this;for(;n&&n!==document.body;){let e=getComputedStyle(n),r=/(auto|scroll)/.test(e.overflowX)&&n.scrollWidth>n.clientWidth,i=/(auto|scroll)/.test(e.overflowY)&&n.scrollHeight>n.clientHeight;if(t===`horizontal`&&r||t===`vertical`&&i||t===`grid`&&(r||i))break;n=n.parentElement}if(!n||n===document.body){this._scrollRoot=null,this._scrollRaf!==null&&cancelAnimationFrame(this._scrollRaf),this._scrollRaf=null;return}this._scrollRoot=n,this._scrollRaf===null&&(this._scrollRaf=requestAnimationFrame(this._runAutoScrollFrame))}_maybeMovePlaceholder(e){let t=this._placeholder,n=this._dragEl;if(!t||!n)return;let r=this._resolveDropList(e),i=r._resolveListRoot();if(i===n||n.contains(i))return;let a=t.parentElement!==i;a&&r._flipAnimate(()=>i.appendChild(t)),this._dropList=r;let o=r.getDirection();if(o===`grid`){this._moveGridPlaceholder(r,i,t,n,e);return}let s=o===`horizontal`,c=s?e.clientX:e.clientY,l=this.hasAttribute(`data-mint-sortable-full-crossing`);if(this._dropAtEnd&&r!==this){(t.parentElement!==i||i.lastElementChild!==t)&&r._flipAnimate(()=>i.appendChild(t)),this._dispatchPreview(r,i,t,n);return}let u=Array.from(i.children).filter(e=>e.nodeType===Node.ELEMENT_NODE&&e!==n&&e!==t),d=null;for(let e of u){let n=e.getBoundingClientRect(),r=s?n.left:n.top,a=s?n.left+n.width:n.top+n.height;if(l){if(c<r){d=e;break}if(c<=a&&Array.prototype.indexOf.call(i.children,t)<Array.prototype.indexOf.call(i.children,e)){d=e;break}}else if(c<(s?n.left+n.width/2:n.top+n.height/2)){d=e;break}}let f=Array.from(i.children).filter(e=>e.nodeType===Node.ELEMENT_NODE&&e!==n),p=f.length>0&&f[f.length-1]===t;if(!(d?!(t.nextSibling===d&&t.parentNode===i):!p)){a&&this._dispatchPreview(r,i,t,n);return}r._flipAnimate(()=>{d?i.insertBefore(t,d):i.appendChild(t)}),this._dispatchPreview(r,i,t,n)}_moveGridPlaceholder(e,t,n,r,i){let a=Array.from(t.children).filter(e=>e.nodeType===Node.ELEMENT_NODE&&e!==r&&e!==n&&!e.hasAttribute(`data-mint-sortable-status`)),o=t===this._originListRoot?this._gridSlots.filter(e=>e.element===r||e.element.parentElement===t):a.map((e,t)=>({element:e,rect:e.getBoundingClientRect(),index:t})),s=null;for(let e of o){let{rect:t}=e;if(i.clientX>=t.left&&i.clientX<=t.right&&i.clientY>=t.top&&i.clientY<=t.bottom){s=e;break}}if(!s)return;let c=null;{let{rect:e}=s,n=(i.clientX-(e.left+e.width/2))/Math.max(e.width,1),o=(i.clientY-(e.top+e.height/2))/Math.max(e.height,1),l=s.index===0?!0:Math.abs(n)>=Math.abs(o)?n<=0:o<=0,u=s.index+(l?0:1);t===this._originListRoot&&s.element!==r&&s.index>=this._startIndex&&u--,s.element===r&&(u=this._startIndex),u=Math.max(0,Math.min(a.length,u)),c=a[u]??null}if(!(c?!(n.nextSibling===c&&n.parentNode===t):!(t.lastElementChild===n&&n.parentNode===t))){this._dispatchPreview(e,t,n,r);return}e._flipAnimate(()=>{c?t.insertBefore(n,c):t.appendChild(n),this._dispatchPreview(e,t,n,r)})}_dispatchPreview(e,t,n,r){let i=Array.from(t.children).filter(e=>e.nodeType===Node.ELEMENT_NODE&&e!==r&&!e.hasAttribute(`data-mint-sortable-status`)),a=i.indexOf(n);if(a<0||this._lastPreviewRoot===t&&this._lastPreviewIndex===a)return;this._lastPreviewRoot=t,this._lastPreviewIndex=a;let o=this._getItemKeyAttribute(),s=i.map(e=>e===n?r.getAttribute(o)||``:e.getAttribute(o)||``),c={itemId:r.getAttribute(o)||``,oldIndex:this._startIndex,newIndex:a,keys:s,sourceContainerId:this.id||null,destinationContainerId:e.id||null};this.dispatchEvent(new CustomEvent(`mint-sortable-preview`,{bubbles:!0,composed:!0,detail:c})),this._resizeDragToPlaceholder(r,n)}_resizeDragToPlaceholder(e,t){this._previewResizeRaf!==null&&cancelAnimationFrame(this._previewResizeRaf),this._previewResizeRaf=requestAnimationFrame(()=>{if(this._previewResizeRaf=null,this._dragEl!==e||this._placeholder!==t||!t.isConnected)return;let n=t.offsetWidth,r=t.offsetHeight;!n||!r||(e.style.transition=`width 160ms ease, height 160ms ease`,e.style.width=`${n}px`,e.style.height=`${r}px`,e.style.transformOrigin=this.getDirection()===`grid`?`center center`:`top left`)})}_flipAnimate(e){let t=this._dragEl,n=this._getAnimationDurationMs(),r=this._getLayoutChildren().filter(e=>e!==t),i=new Map;if(r.forEach(e=>{let t=this._flipCleanupTimers.get(e);t!==void 0&&(window.clearTimeout(t),this._flipCleanupTimers.delete(e)),i.set(e,e.getBoundingClientRect()),e.style.transition=`none`,e.style.transform=``,e.style.transformOrigin=``}),r.length&&r[0].offsetHeight,e(),n<=0||window.matchMedia(`(prefers-reduced-motion: reduce)`).matches){r.forEach(e=>{e.style.transition=``,e.style.transform=``,e.style.transformOrigin=``});return}r.forEach(e=>{let t=i.get(e);if(!t)return;let r=e.getBoundingClientRect(),a=t.left-r.left,o=t.top-r.top,s=t.width>0&&r.width>0?t.width/r.width:1,c=t.height>0&&r.height>0?t.height/r.height:1;Math.abs(a)<.5&&Math.abs(o)<.5&&Math.abs(s-1)<.005&&Math.abs(c-1)<.005||(e.style.transition=`none`,e.style.transformOrigin=`top left`,e.style.transform=`translate(${a}px, ${o}px) scale(${s}, ${c})`,requestAnimationFrame(()=>{e.style.transition=`transform ${n}ms cubic-bezier(0.22, 1, 0.36, 1)`,e.style.transform=``;let t=()=>{e.removeEventListener(`transitionend`,t),e.style.transition=``,e.style.transform=``,e.style.transformOrigin=``,this._flipCleanupTimers.delete(e)};e.addEventListener(`transitionend`,t,{once:!0}),this._flipCleanupTimers.set(e,window.setTimeout(t,n+40))}))})}_onPointerUp(e){e.pointerId===this._pointerId&&(this._moveRaf!==null&&(cancelAnimationFrame(this._moveRaf),this._moveRaf=null),this._pendingPointerEvent=null,this._processPointerMove(e),this._finishDrag(!1))}_onPointerCancel(e){e.pointerId===this._pointerId&&this._finishDrag(!0)}_finishDrag(e){let t=this._dragEl,r=this._placeholder;if(!t||this._pointerId===null){this._teardownDrag();return}this._previewResizeRaf!==null&&(cancelAnimationFrame(this._previewResizeRaf),this._previewResizeRaf=null),this._scrollRaf!==null&&(cancelAnimationFrame(this._scrollRaf),this._scrollRaf=null),this._moveRaf!==null&&(cancelAnimationFrame(this._moveRaf),this._moveRaf=null),this._pendingPointerEvent=null;try{t.releasePointerCapture(this._pointerId)}catch{}window.removeEventListener(`pointermove`,this._boundPointerMove),window.removeEventListener(`pointerup`,this._boundPointerUp),window.removeEventListener(`pointercancel`,this._boundPointerCancel);let i=this._dropList??this,a=i._resolveListRoot();!e&&!this._dropRejected&&this._dropAtEnd&&i!==this&&r?.parentNode===a&&a.appendChild(r);let o=this.getAttribute(`data-tree-parent-id`)||null,s=i.getAttribute(`data-tree-parent-id`)||null,c=this._startIndex,l=r?.parentNode===a?Array.from(a.children).filter(e=>e.nodeType===Node.ELEMENT_NODE&&e!==t&&!e.hasAttribute(`data-mint-sortable-status`)).indexOf(r):c,u=new CustomEvent(`mint-sortable-before-drop`,{bubbles:!0,composed:!0,cancelable:!0,detail:{item:t,source:this,target:i,oldIndex:c,newIndex:l,oldParentId:o,newParentId:s}});e||this.dispatchEvent(u);let d=e||this._dropRejected||u.defaultPrevented;if(d){let e=this._originListRoot??this._listRoot,n=this._originNextSibling??this._restoreAfter;n&&n.parentNode===e?e.insertBefore(t,n):e.appendChild(t)}else r?.parentNode&&r.parentNode.insertBefore(t,r);r?.remove(),this._placeholder=null,t.classList.remove(n),t.style.cssText=this._dragOriginalStyle,this._dragOriginalStyle=``;let f=d?c:i._indexOfItem(t);this._pointerId=null,this._scrollRoot=null,this._lastDragPointer=null,this._dragEl=null,this._restoreAfter=null,this._originListRoot=null,this._originNextSibling=null,this._dropList=null,this._dropAtEnd=!1,this._dropRejected=!1,this._lastPreviewRoot=null,this._lastPreviewIndex=-1,this._gridSlots=[];let p=this._collectOrderedKeys(),m=i._collectOrderedKeys(),h=!d&&(!d&&o!==s||f!==c),g=t.getAttribute(this._getItemKeyAttribute())||``,_={oldIndex:c,newIndex:f,cancelled:d,keys:p,sourceKeys:p,destinationKeys:m,oldParentId:o,newParentId:s,sourceContainerId:this.id||null,destinationContainerId:i.id||null,itemId:g};this.dispatchEvent(new CustomEvent(`mint-sortable-end`,{bubbles:!0,composed:!0,detail:_})),this.dispatchEvent(new CustomEvent(`sort-stop`,{bubbles:!0,composed:!0,detail:_})),h&&(this.dispatchEvent(new CustomEvent(`mint-sortable-change`,{bubbles:!0,composed:!0,detail:_})),this.dispatchEvent(new CustomEvent(`mint-sortable-order`,{bubbles:!0,composed:!0,detail:{keys:p,sourceKeys:p,destinationKeys:m,oldParentId:o,newParentId:s,itemId:g}})))}_teardownDrag(){if(this._clearPendingDragStart(),this._previewResizeRaf!==null&&(cancelAnimationFrame(this._previewResizeRaf),this._previewResizeRaf=null),this._scrollRaf!==null&&(cancelAnimationFrame(this._scrollRaf),this._scrollRaf=null),this._moveRaf!==null&&(cancelAnimationFrame(this._moveRaf),this._moveRaf=null),this._pendingPointerEvent=null,window.removeEventListener(`pointermove`,this._boundPointerMove),window.removeEventListener(`pointerup`,this._boundPointerUp),window.removeEventListener(`pointercancel`,this._boundPointerCancel),this._dragEl){try{this._pointerId!==null&&this._dragEl.releasePointerCapture(this._pointerId)}catch{}let e=this._originListRoot??this._listRoot,t=this._originNextSibling??this._restoreAfter;this._dragEl.parentElement!==e&&(t&&t.parentNode===e?e.insertBefore(this._dragEl,t):e.appendChild(this._dragEl)),this._dragEl.classList.remove(n),this._dragEl.style.cssText=this._dragOriginalStyle,this._dragOriginalStyle=``}this._placeholder?.remove(),this._placeholder=null,this._scrollRoot=null,this._lastDragPointer=null,this._dragEl=null,this._pointerId=null,this._restoreAfter=null,this._originListRoot=null,this._originNextSibling=null,this._dropList=null,this._dropRejected=!1,this._lastPreviewRoot=null,this._lastPreviewIndex=-1,this._gridSlots=[]}};customElements.get(`mint-sortable`)||e.t(`mint-sortable`,r),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return r}});