@webority/ui-elements 0.37.0 → 0.39.0

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 (116) hide show
  1. package/dist/WuiAutocomplete-Comrnbmf.js +13 -0
  2. package/dist/WuiCommandPalette-CKna1GlO.js +2 -0
  3. package/dist/WuiConsentBanner-CFll7vxN.js +201 -0
  4. package/dist/WuiContextMenu-CBy0O4HT.js +1 -0
  5. package/dist/WuiCountrySelect-oLBUHvMM.js +1 -0
  6. package/dist/WuiDatePicker-nB1B3eWW.js +31 -0
  7. package/dist/WuiDateRange-Di5YE9mg.js +25 -0
  8. package/dist/WuiDock-BD2HgMmP.js +1 -0
  9. package/dist/WuiImageCrop-Cr3D2iPo.js +17 -0
  10. package/dist/WuiMultiSelect-BUw-7apM.js +25 -0
  11. package/dist/WuiOtp-BbO_75RB.js +14 -0
  12. package/dist/WuiPhone-GJglNelp.js +15 -0
  13. package/dist/WuiSelect-DvtN4qC2.js +14 -0
  14. package/dist/WuiSlider-Br6V2amU.js +49 -0
  15. package/dist/WuiSortable-Bd7Fz5Ox.js +1 -0
  16. package/dist/WuiTagInput-DzEZooIn.js +6 -0
  17. package/dist/WuiTimePicker-Bolpp93P.js +9 -0
  18. package/dist/WuiTour-DiKZEWeb.js +15 -0
  19. package/dist/WuiTree-SA0QU9AF.js +1 -0
  20. package/dist/WuiWizardStep-DIHxrXn9.js +1 -0
  21. package/dist/anchorOverlay-WcDeH46q.js +1 -0
  22. package/dist/calendarMath-BC2wGCD-.js +1 -0
  23. package/dist/countries-CvmZ2xpG.js +1 -0
  24. package/dist/elementBase-BlsR4tqa.js +1 -0
  25. package/dist/elements/autocomplete.js +1 -6
  26. package/dist/elements/command-palette.js +1 -6
  27. package/dist/elements/consent-banner.js +1 -6
  28. package/dist/elements/context-menu.js +1 -6
  29. package/dist/elements/country-select.js +1 -6
  30. package/dist/elements/date-range.js +1 -6
  31. package/dist/elements/datepicker.js +1 -6
  32. package/dist/elements/dock.js +1 -6
  33. package/dist/elements/image-crop.js +1 -6
  34. package/dist/elements/kanban.js +1 -6
  35. package/dist/elements/multiselect.js +1 -6
  36. package/dist/elements/otp.js +1 -6
  37. package/dist/elements/phone.js +1 -6
  38. package/dist/elements/select.js +1 -6
  39. package/dist/elements/slider.js +1 -6
  40. package/dist/elements/sortable.js +1 -6
  41. package/dist/elements/status-icon.js +1 -6
  42. package/dist/elements/taginput.js +1 -6
  43. package/dist/elements/timepicker.js +1 -6
  44. package/dist/elements/tour.js +1 -6
  45. package/dist/elements/tree.js +1 -6
  46. package/dist/elements/wizard.js +1 -5
  47. package/dist/examples.mobile.json-GS1_MGh9.js +1 -0
  48. package/dist/fileViewerImage-Y9QBn2Rj.js +6 -0
  49. package/dist/fileViewerMedia-CaJaVnjE.js +1 -0
  50. package/dist/fileViewerPdf-BN0zuehw.js +19 -0
  51. package/dist/fileViewerUi-DasgDsU-.js +1 -0
  52. package/dist/focusOrigin-2imUSs-u.js +1 -0
  53. package/dist/formMirror-BgY7zkC3.js +1 -0
  54. package/dist/formatters-BAE__8ye.js +1 -0
  55. package/dist/helpers.js +1 -5
  56. package/dist/iconGlyphs.g-CUm_mfze.js +1 -0
  57. package/dist/kanban-CdELdS3U.js +1 -0
  58. package/dist/listboxKeyNav-DMIvs9d6.js +1 -0
  59. package/dist/max-CNrKnpEj.js +17 -0
  60. package/dist/optionLabel-DsX2fhWs.js +1 -0
  61. package/dist/statusIcons-2X4iGkKL.js +10 -0
  62. package/dist/textMatch-wdY7XLIc.js +1 -0
  63. package/dist/themeTransition-lkmQm8FR.js +1 -0
  64. package/dist/tokenCommit-BKckxgtg.js +2 -0
  65. package/dist/ui-calendar.global.js +1 -1
  66. package/dist/ui-calendar.js +1 -9905
  67. package/dist/ui-chart.js +21 -34563
  68. package/dist/ui-chat-core.js +10 -347
  69. package/dist/ui-chat.js +10 -1066
  70. package/dist/ui-elements.global.js +52 -53
  71. package/dist/ui-elements.js +1 -692
  72. package/dist/ui-file-viewer.js +1 -311
  73. package/dist/ui-rich-text.js +193 -16887
  74. package/dist/wuiHttp-BC8co934.js +1 -0
  75. package/package.json +5 -7
  76. package/dist/WuiAutocomplete-ByxnwJNQ.js +0 -283
  77. package/dist/WuiCommandPalette-CtZ04JxZ.js +0 -130
  78. package/dist/WuiConsentBanner-oVe-jxCO.js +0 -399
  79. package/dist/WuiContextMenu-Bx_U2X3t.js +0 -211
  80. package/dist/WuiCountrySelect-CUAwKnL9.js +0 -28
  81. package/dist/WuiDatePicker-DkNbc-z7.js +0 -325
  82. package/dist/WuiDateRange-BocnVO6L.js +0 -233
  83. package/dist/WuiDock-BSDY9g8Q.js +0 -57
  84. package/dist/WuiImageCrop-1yaAONTk.js +0 -462
  85. package/dist/WuiMultiSelect-BrCGRNCt.js +0 -416
  86. package/dist/WuiOtp-D8-4Pqil.js +0 -128
  87. package/dist/WuiPhone-BvbhiP2r.js +0 -731
  88. package/dist/WuiSelect-BXrpiuXG.js +0 -214
  89. package/dist/WuiSlider-BcU0psYf.js +0 -256
  90. package/dist/WuiSortable-JjJqstSU.js +0 -280
  91. package/dist/WuiTagInput-D1ay3OcL.js +0 -158
  92. package/dist/WuiTimePicker-C7n-VFGt.js +0 -370
  93. package/dist/WuiTour-R5O9l--J.js +0 -205
  94. package/dist/WuiTree-DXP7pGeI.js +0 -393
  95. package/dist/WuiWizardStep-BU5w9_Ds.js +0 -221
  96. package/dist/anchorOverlay-DluGZ8ef.js +0 -23
  97. package/dist/calendarMath-BAF2Jkg_.js +0 -42
  98. package/dist/countries-B-M_LTgS.js +0 -1234
  99. package/dist/elementBase-Bg1xpvup.js +0 -9
  100. package/dist/examples.mobile.json-BMXTGiGC.js +0 -250
  101. package/dist/fileViewerImage-Dky4nQZS.js +0 -185
  102. package/dist/fileViewerMedia-DPk_YcvC.js +0 -133
  103. package/dist/fileViewerPdf-BnIsj-J-.js +0 -15799
  104. package/dist/fileViewerUi-R6hlcShk.js +0 -272
  105. package/dist/formMirror-jGf5M4gk.js +0 -29
  106. package/dist/formatters-DusKbTyV.js +0 -138
  107. package/dist/iconGlyphs.g-Cpg1BUHm.js +0 -215
  108. package/dist/kanban-BIiEMkTK.js +0 -985
  109. package/dist/listboxKeyNav-zts_8d5e.js +0 -36
  110. package/dist/max-BDKx469G.js +0 -14478
  111. package/dist/optionLabel-Dn-I7zyp.js +0 -16
  112. package/dist/statusIcons-C3zjycpa.js +0 -37
  113. package/dist/textMatch-DEUjlkdy.js +0 -27
  114. package/dist/themeTransition-BpCuMnjk.js +0 -589
  115. package/dist/tokenCommit-VWz-2jEf.js +0 -20
  116. package/dist/wuiHttp-oeHs7X_c.js +0 -118
@@ -0,0 +1,13 @@
1
+ import{t as e}from"./elementBase-BlsR4tqa.js";import{n as t,r as n,t as r}from"./anchorOverlay-WcDeH46q.js";import{n as i,t as a}from"./focusOrigin-2imUSs-u.js";import{t as o}from"./formMirror-BgY7zkC3.js";import{t as s}from"./iconGlyphs.g-CUm_mfze.js";import{n as c,t as l}from"./listboxKeyNav-DMIvs9d6.js";import{n as u,r as d,t as f}from"./optionLabel-DsX2fhWs.js";var p=class extends e{static formAssociated=!0;_accessibleName(){return this.getAttribute(`aria-label`)||this.getAttribute(`placeholder`)||`Select`}static get observedAttributes(){return[`value`,`placeholder`,`disabled`,`min-chars`,`debounce`,`remote`,`size`,`aria-label`,`allow-custom`,`aria-invalid`]}constructor(){super(),this._value=``,this._label=``,this._optionsProp=null,this._loading=!1,this._active=-1,this._timer=null,this._reqSeq=0,this._pendingSearch=null,this._typeahead=``,this._typeaheadTimer=null;try{this._internals=this.attachInternals()}catch{this._internals=null}}connectedCallback(){if(!this._rendered){this._defaultCaptured||=(this._defaultValue=this._value,!0),this.render();return}if(this._bindGlobal?.(),this._pendingSearch){let{query:e,seq:t}=this._pendingSearch;clearTimeout(this._timer),this._timer=setTimeout(()=>this._fireSearch(e,t),this._debounceMs)}}formResetCallback(){this.value=this._defaultValue||``}attributeChangedCallback(e,t,n){if(e===`value`){this.value=n;return}if(e===`aria-invalid`){this._syncInvalid();return}this._rendered&&this.render()}_syncInvalid(){let e=this.querySelector(`.search-select-control`);e&&(this.hasAttribute(`aria-invalid`)?e.setAttribute(`aria-invalid`,`true`):e.removeAttribute(`aria-invalid`))}get value(){return this._value}set value(e){this._value=e==null?``:String(e),o(this,this._value);let t=this._readOptions().find(e=>String(e.value)===this._value);this._label=t?h(t.label):``,this._syncInput(),this._renderOptions(``)}set options(e){this._optionsProp=Array.isArray(e)?e:[];let t=this._readOptions().find(e=>String(e.value)===this._value);t&&(this._label=h(t.label)),this._renderOptions(),this._syncInput()}get options(){return this._readOptions()}set loading(e){this._loading=!!e,this._renderLoading(),this._renderOptions()}get loading(){return this._loading}get _remote(){return this.hasAttribute(`remote`)}get _allowCustom(){return this.hasAttribute(`allow-custom`)}_matchesKnownOption(e){let t=e.toLowerCase();return this._readOptions().some(e=>h(e.label).toLowerCase()===t||String(e.value??``).toLowerCase()===t)}get _minChars(){return Math.max(0,Number(this.getAttribute(`min-chars`))||+!!this._remote)}get _debounceMs(){let e=this.getAttribute(`debounce`);if(e==null||e===``)return 250;let t=Number(e);return Number.isFinite(t)&&t>=0?t:250}_snapshotDeclared(){if(this._declared)return;let e=[...this.querySelectorAll(`:scope > wui-option`)];e.length&&(this._declared=e.map(e=>({value:e.getAttribute(`value`)??e.textContent.trim(),label:e.innerHTML,icon:e.getAttribute(`icon`)||void 0,[f]:!0,selected:e.hasAttribute(`selected`)})))}_readOptions(){return this._optionsProp?this._optionsProp:(this._snapshotDeclared(),this._declared||[])}render(){this._snapshotDeclared();let e=this.getAttribute(`placeholder`)||`Search…`,t=this.getAttribute(`size`),n=t===`sm`?` search-select-sm`:t===`lg`?` search-select-lg`:``;this.id||=`wui-autocomplete-${Math.random().toString(36).slice(2,9)}`;let r=`${this.id}-listbox`;this._listboxId=r,this.innerHTML=`
2
+ <div class="search-select${n}">
3
+ <div class="input search-select-control search-select-ac" role="combobox" aria-haspopup="listbox" aria-expanded="false" aria-controls="${m(r)}" aria-label="${m(this._accessibleName())}"${this.hasAttribute(`aria-invalid`)?` aria-invalid="true"`:``}>
4
+ <input class="search-select-input search-select-ac-input" placeholder="${m(e)}" aria-autocomplete="list" autocomplete="off"${this.hasAttribute(`disabled`)?` disabled`:``} />
5
+ <span class="search-select-spinner spinner-border spinner-border-sm" role="status" aria-hidden="true" hidden></span>
6
+ <button type="button" class="search-select-clear" aria-label="Clear" hidden>${s(`x`)}</button>
7
+ </div>
8
+ <div class="search-select-menu search-select-menu-fixed" role="listbox" id="${m(r)}" tabindex="-1" hidden>
9
+ <div class="search-select-options"></div>
10
+ <div class="search-select-empty" hidden>No matches</div>
11
+ <div class="search-select-hint" hidden>Type to search…</div>
12
+ </div>
13
+ </div>`,this._rendered=!0,o(this,this._value),this._wire(),this._syncInput(),this._renderOptions()}_refs(){return{control:this.querySelector(`.search-select-control`),input:this.querySelector(`.search-select-ac-input`),menu:this.querySelector(`.search-select-menu`),spinner:this.querySelector(`.search-select-spinner`),clear:this.querySelector(`.search-select-clear`),optionsWrap:this.querySelector(`.search-select-options`),empty:this.querySelector(`.search-select-empty`),hint:this.querySelector(`.search-select-hint`)}}_optionEls(){return[...this.querySelectorAll(`.search-select-option`)]}_syncInput(){let{input:e,clear:t}=this._refs();e&&document.activeElement!==e&&(e.value=this._label),t&&(t.hidden=!this._value&&!e?.value)}_renderLoading(){let{spinner:e}=this._refs();e&&(e.hidden=!this._loading)}_renderOptions(e){let t=this._refs();if(!t.optionsWrap)return;let n=e??(t.input?t.input.value:``),r=n.trim().toLowerCase(),i=this._readOptions();!this._remote&&r&&(i=i.filter(e=>h(e.label).toLowerCase().includes(r)));let a=n.trim(),o=this._allowCustom&&a&&!this._matchesKnownOption(a)?[...i,{value:a,custom:!0}]:i,s=this._listboxId||`${this.id||`wui-autocomplete`}-listbox`;t.optionsWrap.innerHTML=o.map((e,t)=>{let n=`${s}-opt-${t}`;if(e.custom){let t=`Add “${u(e.value)}”`;return`<button type="button" role="option" id="${m(n)}" class="search-select-option search-select-option-custom" data-value="${m(e.value)}" data-custom="true" aria-selected="false">${t}</button>`}let r=String(e.value)===String(this._value);return`<button type="button" role="option" id="${m(n)}" class="search-select-option${r?` selected`:``}" data-value="${m(e.value)}" aria-selected="${r}">${d(e)}</button>`}).join(``),this._active=-1,t.control?.removeAttribute(`aria-activedescendant`);let c=r.length<this._minChars;t.hint&&(t.hint.hidden=!(this._remote&&c&&!i.length)),t.empty&&(t.empty.hidden=this._loading||o.length>0||this._remote&&c),this._reanchor?.()}_wire(){this._teardown();let e=this._refs();if(!e.control||!e.input)return;let s=()=>r(e.control,e.menu,{matchWidth:!0}),u=()=>this._optionEls().filter(e=>!e.hidden),d=(t,{reveal:n=!0}={})=>{let r=u();this._active=t,c(e.optionsWrap,t>=0&&r[t]||null),t>=0&&r[t]?(n&&r[t].scrollIntoView({block:`nearest`}),e.control.setAttribute(`aria-activedescendant`,r[t].id)):e.control.removeAttribute(`aria-activedescendant`)},f=()=>!e.menu.hidden,p=()=>{f()&&s()},m=()=>{e.menu.hidden=!1,e.control.setAttribute(`aria-expanded`,`true`),e.control.classList.add(`open`),s(),t(this,p),this._renderOptions()},g=()=>{e.menu.hidden=!0,e.control.setAttribute(`aria-expanded`,`false`),e.control.classList.remove(`open`),d(-1),clearTimeout(this._typeaheadTimer),this._typeaheadTimer=null,this._typeahead=``,this._syncInput(),n(this)},_=t=>{let n=t.dataset.custom===`true`;this._value=t.dataset.value,this._label=n?t.dataset.value:h(t.innerHTML),o(this,this._value),e.input.value=this._label,this.dispatchEvent(new CustomEvent(`change`,{bubbles:!0,detail:{isCustom:n}})),g(),e.input.focus()},v=t=>{this._value=t,this._label=t,o(this,t),e.input.value=t,this.dispatchEvent(new CustomEvent(`change`,{bubbles:!0,detail:{isCustom:!0}})),g()},y=()=>{let t=e.input.value;if(e.clear&&(e.clear.hidden=!t),f()||m(),this._remote){if(this._renderOptions(t),clearTimeout(this._timer),t.trim().length<this._minChars){this._pendingSearch=null;return}let e=++this._reqSeq;this._pendingSearch={query:t,seq:e},this._timer=setTimeout(()=>this._fireSearch(t,e),this._debounceMs)}else this._renderOptions(t)};this._navHandler=l({getVisibleOptions:u,getActive:()=>this._active,setActive:e=>d(e),onEnter:(t,n)=>{if(n[this._active])_(n[this._active]);else if(this._allowCustom){let t=e.input.value.trim();t&&!this._matchesKnownOption(t)&&v(t)}},onEscape:()=>{this._navHandler.clearTypeahead(),g()}});let b=e=>{let t=e.target?.tagName===`INPUT`||e.target?.tagName===`TEXTAREA`;if(e.key===`ArrowDown`){e.preventDefault(),f()||m();let t=u();d(Math.min(this._active+1,t.length-1));return}else if(e.key===`ArrowUp`){e.preventDefault(),d(Math.max(this._active-1,0));return}else if((e.key===`Home`||e.key===`End`||e.key===`PageDown`||e.key===`PageUp`)&&(!f()||t))return;else if(e.key.length===1&&(e.ctrlKey||e.metaKey||e.altKey||!f()||e.target?.tagName===`INPUT`||e.target?.tagName===`TEXTAREA`)&&(!f()||e.target?.tagName===`INPUT`||e.target?.tagName===`TEXTAREA`))return;this._navHandler.handler(e)};i(),e.input.addEventListener(`focus`,()=>{a()&&m()}),e.control.addEventListener(`click`,t=>{e.input.disabled||t.target.closest(`.search-select-clear`)||(t.target!==e.input&&e.input.focus(),f()||m())}),e.input.addEventListener(`input`,y),e.input.addEventListener(`keydown`,b),e.menu.addEventListener(`keydown`,b),e.input.addEventListener(`blur`,t=>{if(!this._allowCustom||t.relatedTarget&&this.contains(t.relatedTarget))return;let n=e.input.value.trim();!n||n===this._label||this._matchesKnownOption(n)||v(n)}),e.optionsWrap.addEventListener(`click`,e=>{let t=e.target.closest(`.search-select-option`);t&&_(t)}),e.optionsWrap.addEventListener(`mousemove`,e=>{let t=e.target.closest(`.search-select-option`);t&&!t.classList.contains(`is-active`)&&d(this._optionEls().indexOf(t),{reveal:!1})}),e.optionsWrap.addEventListener(`mouseleave`,()=>d(-1)),e.clear?.addEventListener(`click`,()=>{this._value=``,this._label=``,o(this,``),e.input.value=``,e.clear.hidden=!0,this._renderOptions(``),this.dispatchEvent(new Event(`change`,{bubbles:!0})),e.input.focus(),f()||m()}),this._bindGlobal=()=>{this._teardown(),this._onDocClick=e=>{f()&&!this.contains(e.target)&&g()},document.addEventListener(`click`,this._onDocClick),f()&&t(this,p)},this._bindGlobal()}_fireSearch(e,t){this._pendingSearch=null,this.dispatchEvent(new CustomEvent(`search`,{bubbles:!0,detail:{query:e,seq:t}}))}_teardown(){this._onDocClick&&=(document.removeEventListener(`click`,this._onDocClick),null),n(this),clearTimeout(this._timer),this._navHandler?.teardown()}disconnectedCallback(){this._teardown()}},m=e=>String(e??``).replace(/&/g,`&amp;`).replace(/"/g,`&quot;`).replace(/</g,`&lt;`),h=e=>String(e??``).replace(/<[^>]*>/g,``);export{p as t};
@@ -0,0 +1,2 @@
1
+ import{t as e}from"./elementBase-BlsR4tqa.js";import{n as t}from"./optionLabel-DsX2fhWs.js";import{t as n}from"./textMatch-wdY7XLIc.js";var r=`[role="option"]`,i=`No results`,a=class extends e{static get observedAttributes(){return[`filter`,`highlight`,`empty-text`]}constructor(){super(),this._activeId=null,this._lastQuery=null,this._lastIds=null,this._userChose=!1,this._onKeyDown=e=>this._handleKeyDown(e),this._onClick=e=>{let t=this._optionFrom(e.target);t&&this._select(t)},this._onMouseDown=e=>{this._optionFrom(e.target,!0)&&e.preventDefault()},this._onMouseMove=e=>{let t=this._optionFrom(e.target);t&&t.id!==this._activeId&&(this._userChose=!0,this._setActive(t,!1))},this._onInput=e=>{!this.hasAttribute(`filter`)||e.target!==this._input()||(this._applyFilter(),this.refresh())}}connectedCallback(){this._teardown(),this.addEventListener(`keydown`,this._onKeyDown),this.addEventListener(`click`,this._onClick),this.addEventListener(`mousedown`,this._onMouseDown),this.addEventListener(`mousemove`,this._onMouseMove),this.addEventListener(`input`,this._onInput),this.hasAttribute(`filter`)&&this._applyFilter(),this.refresh()}disconnectedCallback(){this._teardown()}attributeChangedCallback(){this.isConnected&&(this.hasAttribute(`filter`)&&this._applyFilter(),this.refresh())}get filter(){return this.hasAttribute(`filter`)}set filter(e){this.toggleAttribute(`filter`,!!e)}get highlight(){return this.getAttribute(`highlight`)!==`false`}set highlight(e){this.setAttribute(`highlight`,e?`true`:`false`)}get emptyText(){return this.getAttribute(`empty-text`)??i}set emptyText(e){this.setAttribute(`empty-text`,String(e??``))}refresh(){let e=this._input(),t=e?e.value:``,n=t!==this._lastQuery;this._lastQuery=t;let r=this._selectableOptions(),i=r.map(e=>e.id).join(`
2
+ `),a=i!==this._lastIds;this._lastIds=i;let o=!n&&(this._userChose||!a)?r.find(e=>e.id===this._activeId):null;o||(this._userChose=!1),this._setActive(o??r[0]??null,n)}_input(){return this.querySelector(`[role="combobox"]`)}_optionFrom(e,t=!1){let n=e?.closest?.(r);return n&&this.contains(n)&&!this._isHidden(n)&&(t||!this._isDisabled(n))?n:null}_isDisabled(e){return e.getAttribute(`aria-disabled`)===`true`}_isHidden(e){return e.hidden||!!e.closest(`[role="group"]`)?.hidden}_selectableOptions(){return[...this.querySelectorAll(r)].filter(e=>!this._isHidden(e)&&!this._isDisabled(e))}_setActive(e,t){this._activeId=e?e.id:null;for(let t of this.querySelectorAll(r))t.setAttribute(`aria-selected`,t===e?`true`:`false`);let n=this._input();n&&(e?n.setAttribute(`aria-activedescendant`,e.id):n.removeAttribute(`aria-activedescendant`)),e&&t&&e.scrollIntoView({block:`nearest`})}_move(e){let t=this._selectableOptions();if(!t.length)return;let n=t.findIndex(e=>e.id===this._activeId),r=n<0?e>0?0:t.length-1:(n+e+t.length)%t.length;this._userChose=!0,this._setActive(t[r],!0)}_handleKeyDown(e){if(e.target===this._input()){if(e.key===`ArrowDown`||e.key===`ArrowUp`)e.preventDefault(),this._move(e.key===`ArrowDown`?1:-1);else if(e.key===`Enter`&&!e.isComposing){let t=this._selectableOptions().find(e=>e.id===this._activeId);if(!t)return;e.preventDefault(),this._select(t)}}}_select(e){this.dispatchEvent(new CustomEvent(`wui-command-palette:select`,{bubbles:!0,cancelable:!0,detail:{key:e.dataset.key??null,groupKey:e.dataset.groupKey??null,id:e.id}}))&&e.dataset.href&&this._navigate(e.dataset.href)}_navigate(e){window.location.assign(e)}_applyFilter(){let e=this._input(),i=(e?e.value:``).trim(),a=i.toLowerCase(),o=this.highlight,s=0;for(let e of this.querySelectorAll(r)){let r=e.querySelector(`.wui-cmd-item-label`),c=e.dataset.label??r?.textContent??``,l=!a||c.toLowerCase().includes(a);e.hidden=!l,l&&s++,r&&(r.innerHTML=n(c,o?i:``).map(e=>e.match?`<mark class="wui-cmd-mark">${t(e.text)}</mark>`:t(e.text)).join(``))}for(let e of this.querySelectorAll(`[role="group"]`))e.hidden=![...e.querySelectorAll(r)].some(e=>!e.hidden);let c=this.querySelector(`[role="listbox"]`);c&&(c.hidden=s===0);let l=this.querySelector(`.wui-cmd-empty`);l&&(l.textContent=a&&s===0?this.emptyText:``)}_teardown(){this.removeEventListener(`keydown`,this._onKeyDown),this.removeEventListener(`click`,this._onClick),this.removeEventListener(`mousedown`,this._onMouseDown),this.removeEventListener(`mousemove`,this._onMouseMove),this.removeEventListener(`input`,this._onInput)}};export{a as t};
@@ -0,0 +1,201 @@
1
+ import{t as e}from"./elementBase-BlsR4tqa.js";var t={"--color-primary":`#4F46E5`,"--color-primary-hover":`#4338CA`,"--color-text":`#071437`,"--color-text-muted":`#4B5675`,"--color-border":`#EBEDF3`,"--color-surface":`#FFFFFF`,"--wui-radius-lg":`14px`,"--wui-shadow-overlay-lg":`0 24px 60px -16px rgba(7, 20, 55, 0.28)`,"--wui-z-fixed":`1030`},n=e=>`var(${e}, ${t[e]})`,r=`
2
+ :host {
3
+ all: initial;
4
+ position: fixed;
5
+ bottom: 20px;
6
+ left: 20px;
7
+ right: auto;
8
+ z-index: ${n(`--wui-z-fixed`)};
9
+ display: block;
10
+ width: 420px;
11
+ max-width: calc(100vw - 40px);
12
+ font-family: inherit;
13
+ font-size: 16px;
14
+ line-height: 1.5;
15
+ color: ${n(`--color-text`)};
16
+ }
17
+ :host([position="bottom-right"]) {
18
+ right: 20px;
19
+ left: auto;
20
+ }
21
+ :host(:not([open])) {
22
+ pointer-events: none;
23
+ }
24
+ *, *::before, *::after {
25
+ box-sizing: border-box;
26
+ }
27
+ [hidden] {
28
+ display: none !important;
29
+ }
30
+
31
+ .wui-consent-banner-panel {
32
+ padding: 20px;
33
+ background: ${n(`--color-surface`)};
34
+ border: 1px solid ${n(`--color-border`)};
35
+ border-radius: ${n(`--wui-radius-lg`)};
36
+ box-shadow: ${n(`--wui-shadow-overlay-lg`)};
37
+ text-align: start;
38
+ pointer-events: auto;
39
+ }
40
+ .wui-consent-banner-heading {
41
+ margin: 0 0 8px;
42
+ font-size: 18px;
43
+ font-weight: 600;
44
+ line-height: 1.3;
45
+ color: ${n(`--color-text`)};
46
+ }
47
+ .wui-consent-banner-description {
48
+ margin: 0 0 16px;
49
+ font-size: 14px;
50
+ line-height: 1.5;
51
+ color: ${n(`--color-text-muted`)};
52
+ }
53
+ .wui-consent-banner-policy {
54
+ color: ${n(`--color-primary`)};
55
+ font-weight: 500;
56
+ }
57
+
58
+ .wui-consent-banner-settings {
59
+ display: grid;
60
+ gap: 12px;
61
+ max-height: 50vh;
62
+ margin: 0 0 16px;
63
+ padding: 12px 0;
64
+ overflow-y: auto;
65
+ border-top: 1px solid ${n(`--color-border`)};
66
+ border-bottom: 1px solid ${n(`--color-border`)};
67
+ }
68
+ .wui-consent-banner-category-description {
69
+ margin: 2px 0 0;
70
+ padding-inline-start: 2.5em;
71
+ font-size: 12px;
72
+ line-height: 1.4;
73
+ color: ${n(`--color-text-muted`)};
74
+ }
75
+
76
+ .form-check {
77
+ display: flex;
78
+ align-items: center;
79
+ gap: 0.5em;
80
+ margin: 0;
81
+ font-size: 14px;
82
+ }
83
+ .form-check-input {
84
+ appearance: none;
85
+ flex: none;
86
+ width: 2em;
87
+ height: 1em;
88
+ margin: 0;
89
+ border: 1px solid rgba(0, 0, 0, 0.25);
90
+ border-radius: 2em;
91
+ background: ${n(`--color-surface`)} radial-gradient(circle, rgba(0, 0, 0, 0.25) 0.35em, transparent 0.4em) left / 1em 1em no-repeat;
92
+ cursor: pointer;
93
+ transition: background-position 0.15s ease-in-out;
94
+ }
95
+ .form-check-input:checked {
96
+ border-color: ${n(`--color-primary`)};
97
+ background: ${n(`--color-primary`)} radial-gradient(circle, #fff 0.35em, transparent 0.4em) right / 1em 1em no-repeat;
98
+ }
99
+ .form-check-input:disabled {
100
+ opacity: 0.5;
101
+ cursor: default;
102
+ }
103
+ .form-check-input:focus-visible {
104
+ outline: 2px solid ${n(`--color-primary`)};
105
+ outline-offset: 2px;
106
+ }
107
+ .form-check-label {
108
+ cursor: pointer;
109
+ }
110
+
111
+ .wui-consent-banner-actions {
112
+ display: flex;
113
+ flex-wrap: wrap;
114
+ align-items: center;
115
+ justify-content: flex-end;
116
+ gap: 8px;
117
+ }
118
+ .btn {
119
+ display: inline-block;
120
+ padding: 0.25rem 0.5rem;
121
+ border: 1px solid transparent;
122
+ border-radius: 0.375rem;
123
+ background: transparent;
124
+ font: inherit;
125
+ font-size: 0.875rem;
126
+ font-weight: 500;
127
+ line-height: 1.5;
128
+ text-align: center;
129
+ white-space: nowrap;
130
+ cursor: pointer;
131
+ }
132
+ .btn:focus-visible {
133
+ outline: 2px solid ${n(`--color-primary`)};
134
+ outline-offset: 2px;
135
+ }
136
+ .btn-primary {
137
+ background: ${n(`--color-primary`)};
138
+ border-color: ${n(`--color-primary`)};
139
+ color: #fff;
140
+ }
141
+ .btn-primary:hover {
142
+ background: ${n(`--color-primary-hover`)};
143
+ border-color: ${n(`--color-primary-hover`)};
144
+ }
145
+ .btn-outline-secondary {
146
+ border-color: ${n(`--color-text-muted`)};
147
+ color: ${n(`--color-text-muted`)};
148
+ }
149
+ .btn-outline-secondary:hover {
150
+ background: ${n(`--color-text-muted`)};
151
+ color: #fff;
152
+ }
153
+ .btn-link {
154
+ font-weight: 400;
155
+ color: ${n(`--color-primary`)};
156
+ text-decoration: underline;
157
+ }
158
+ .btn-link:hover {
159
+ color: ${n(`--color-primary-hover`)};
160
+ }
161
+ .wui-consent-banner-settings-toggle {
162
+ margin-inline-end: auto;
163
+ padding-inline: 0;
164
+ }
165
+ .wui-consent-banner-save {
166
+ flex: 1 1 100%;
167
+ }
168
+
169
+ @media (max-width: 480px) {
170
+ :host,
171
+ :host([position="bottom-right"]) {
172
+ left: 12px;
173
+ right: 12px;
174
+ bottom: 12px;
175
+ width: auto;
176
+ max-width: none;
177
+ }
178
+ }
179
+ `,i=`wui-consent-save`,a=`[data-consent-settings]`,o={heading:`Cookies on this site`,description:`We use cookies to understand how the site is used and to measure our campaigns. You can change your choice at any time.`,policyLabel:`Cookie policy`,essentialLabel:`Essential cookies`,essentialDescription:`Required for the site to work and stay secure. Always on.`,analyticsLabel:`Analytics cookies`,analyticsDescription:`Help us understand how visitors use the site.`,functionalLabel:`Functional cookies`,functionalDescription:`Remember choices you make, such as your preferences.`,marketingLabel:`Marketing cookies`,marketingDescription:`Measure how well our campaigns work.`,settingsLabel:`Cookie settings`,rejectLabel:`Reject all`,acceptLabel:`Accept all`,saveLabel:`Save preferences`},s=[`analytics`,`functional`,`marketing`],c=0,l=class extends e{static get observedAttributes(){return[`heading`,`description`,`policy-href`,`policy-label`,`analytics-description`,`functional-description`,`marketing-description`]}constructor(){super(),c+=1,this._uid=`wui-consent-${c}`,this._preferences={analytics:!1,functional:!1,marketing:!1},this._settings=!1,this._onDocumentClick=e=>{e.target instanceof Element&&e.target.closest(a)&&(e.preventDefault(),this.open({settings:!0,focus:!0}))}}get position(){return this.getAttribute(`position`)===`bottom-right`?`bottom-right`:`bottom-left`}set position(e){this.setAttribute(`position`,String(e??`bottom-left`))}get standalone(){return this.hasAttribute(`standalone`)}set standalone(e){this.toggleAttribute(`standalone`,e===!0||e===``||e===`true`)}get heading(){return this.getAttribute(`heading`)||o.heading}set heading(e){this.setAttribute(`heading`,String(e??``))}get description(){return this.getAttribute(`description`)||o.description}set description(e){this.setAttribute(`description`,String(e??``))}get policyHref(){return this.getAttribute(`policy-href`)||``}set policyHref(e){this.setAttribute(`policy-href`,String(e??``))}get policyLabel(){return this.getAttribute(`policy-label`)||o.policyLabel}set policyLabel(e){this.setAttribute(`policy-label`,String(e??``))}get analyticsDescription(){return this.getAttribute(`analytics-description`)||o.analyticsDescription}set analyticsDescription(e){this.setAttribute(`analytics-description`,String(e??``))}get functionalDescription(){return this.getAttribute(`functional-description`)||o.functionalDescription}set functionalDescription(e){this.setAttribute(`functional-description`,String(e??``))}get marketingDescription(){return this.getAttribute(`marketing-description`)||o.marketingDescription}set marketingDescription(e){this.setAttribute(`marketing-description`,String(e??``))}get preferences(){return{...this._preferences}}set preferences(e){this._preferences={analytics:e?.analytics===!0,functional:e?.functional===!0,marketing:e?.marketing===!0},this._applyPreferences()}get isOpen(){return this.hasAttribute(`open`)}connectedCallback(){this._rendered||this.render(),document.addEventListener(`click`,this._onDocumentClick)}disconnectedCallback(){document.removeEventListener(`click`,this._onDocumentClick)}attributeChangedCallback(){this._rendered&&this.render()}render(){let e=this.isOpen,t=this._uid,n=this.policyHref?` <a class="wui-consent-banner-policy" href="${f(this.policyHref)}">${d(this.policyLabel)}</a>`:``,i=this._root();i.innerHTML=`${i===this?``:`<style>${r}</style>`}
180
+ <div class="wui-consent-banner-panel" role="dialog" aria-labelledby="${t}-heading" aria-describedby="${t}-description" hidden>
181
+ <h2 class="wui-consent-banner-heading" id="${t}-heading">${d(this.heading)}</h2>
182
+ <p class="wui-consent-banner-description" id="${t}-description">${d(this.description)}${n}</p>
183
+ <div class="wui-consent-banner-settings" hidden>
184
+ ${u(t,`essential`,o.essentialLabel,o.essentialDescription,!0)}
185
+ ${u(t,`analytics`,o.analyticsLabel,this.analyticsDescription,!1)}
186
+ ${u(t,`functional`,o.functionalLabel,this.functionalDescription,!1)}
187
+ ${u(t,`marketing`,o.marketingLabel,this.marketingDescription,!1)}
188
+ </div>
189
+ <div class="wui-consent-banner-actions">
190
+ <button type="button" class="btn btn-sm btn-link wui-consent-banner-settings-toggle" aria-expanded="false">${o.settingsLabel}</button>
191
+ <button type="button" class="btn btn-sm btn-outline-secondary wui-consent-banner-reject">${o.rejectLabel}</button>
192
+ <button type="button" class="btn btn-sm btn-primary wui-consent-banner-accept">${o.acceptLabel}</button>
193
+ <button type="button" class="btn btn-sm btn-primary wui-consent-banner-save" hidden>${o.saveLabel}</button>
194
+ </div>
195
+ </div>`,this._rendered=!0,this._wire(),this._applyPreferences(),this._showSettings(this._settings),e&&(this._panel().hidden=!1)}open({settings:e=!1,focus:t=!1}={}){this._rendered||this.render(),this._applyPreferences(),this._showSettings(e),this._panel().hidden=!1,this.setAttribute(`open`,``),t&&(e?this._root().querySelector(`.wui-consent-banner-category input:not([disabled])`):this._root().querySelector(`.wui-consent-banner-accept`))?.focus()}close(){let e=this._panel();e&&(e.hidden=!0),this.removeAttribute(`open`),this._showSettings(!1)}_root(){return this.shadowRoot?this.shadowRoot:this.standalone?this.attachShadow({mode:`open`}):this}_panel(){return this._root().querySelector(`.wui-consent-banner-panel`)}_wire(){let e=this._root();e.querySelector(`.wui-consent-banner-accept`)?.addEventListener(`click`,()=>this._save({analytics:!0,functional:!0,marketing:!0})),e.querySelector(`.wui-consent-banner-reject`)?.addEventListener(`click`,()=>this._save({analytics:!1,functional:!1,marketing:!1})),e.querySelector(`.wui-consent-banner-save`)?.addEventListener(`click`,()=>this._save(this._switchValues())),e.querySelector(`.wui-consent-banner-settings-toggle`)?.addEventListener(`click`,()=>this._showSettings(!this._settings))}_save(e){this._preferences={...e},this.dispatchEvent(new CustomEvent(i,{bubbles:!0,composed:!0,detail:{...e}})),this.close()}_switchValues(){let e={};for(let t of s)e[t]=this._root().querySelector(`input[data-category="${t}"]`)?.checked===!0;return e}_applyPreferences(){for(let e of s){let t=this._root().querySelector(`input[data-category="${e}"]`);t&&(t.checked=this._preferences[e])}}_showSettings(e){this._settings=e;let t=this._root(),n=t.querySelector(`.wui-consent-banner-settings`);if(!n)return;n.hidden=!e,t.querySelector(`.wui-consent-banner-settings-toggle`)?.setAttribute(`aria-expanded`,e?`true`:`false`);let r=t.querySelector(`.wui-consent-banner-save`);r&&(r.hidden=!e);for(let n of[`.wui-consent-banner-reject`,`.wui-consent-banner-accept`]){let r=t.querySelector(n);r&&(r.hidden=e)}}};function u(e,t,n,r,i){let a=`${e}-${t}`;return`<div class="wui-consent-banner-category">
196
+ <div class="form-check form-switch">
197
+ <input class="form-check-input" type="checkbox" role="switch" id="${a}" data-category="${t}"${i?` checked disabled`:``} />
198
+ <label class="form-check-label" for="${a}">${d(n)}</label>
199
+ </div>
200
+ <p class="wui-consent-banner-category-description">${d(r)}</p>
201
+ </div>`}var d=e=>String(e??``).replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`),f=e=>String(e??``).replace(/&/g,`&amp;`).replace(/"/g,`&quot;`).replace(/</g,`&lt;`);export{l as t};
@@ -0,0 +1 @@
1
+ import{t as e}from"./elementBase-BlsR4tqa.js";import{t}from"./anchorOverlay-WcDeH46q.js";import{t as n}from"./listboxKeyNav-DMIvs9d6.js";var r=`[role="menuitem"]`,i=`input, textarea, select, [contenteditable=""], [contenteditable="true"]`,a=`data-open`,o=500,s=10,c=400,l=null,u=null,d=new WeakMap;function f(e,t,n){let r=d.get(e);if(r){if(r.region===t||t.contains(r.region))return!1;r.cancel()}return d.set(e,{region:t,cancel:n}),!0}var p=e=>e instanceof Element?e:e?.parentElement??null,m=class extends e{static get observedAttributes(){return[`disabled`]}constructor(){super(),this._region=null,this._origin=null,this._returnFocus=null,this._press=null,this._swallowClick=!1,this._nav=n({getVisibleOptions:()=>this._items(),getActive:()=>this._items().indexOf(document.activeElement),setActive:e=>this._items()[e]?.focus({preventScroll:!0})}),this._onContextMenu=e=>this._handleContextMenu(e),this._onContextMenuCapture=e=>{this.isOpen&&!this._inPanel(e.target)&&!this._isKeyEcho()&&this.close()},this._onDocKeyDown=e=>this._handleDocKeyDown(e),this._onPointerDown=e=>this._handlePointerDown(e),this._onPressMove=e=>{this._press&&Math.hypot(e.clientX-this._press.x,e.clientY-this._press.y)>s&&this._cancelPress()},this._onPressEnd=()=>this._cancelPress(),this._onClickCapture=e=>{!this._swallowClick||!this._region?.contains(e.target)||(this._swallowClick=!1,e.preventDefault(),e.stopImmediatePropagation())},this._onKeyDown=e=>{this._inPanel(e.target)&&this._handleMenuKey(e)},this._onClick=e=>this._handleClick(e),this._onMouseMove=e=>{let t=p(e.target)?.closest(r);t&&this._inPanel(t)&&!this._isDisabled(t)&&t!==document.activeElement&&t.focus({preventScroll:!0})},this._onDismiss=e=>{e.type===`scroll`&&this._inPanel(e.target)||this.close()},this._onPointerDownCapture=e=>{this._swallowClick=!1,this.isOpen&&!this._inPanel(e.target)&&this.close()}}connectedCallback(){this._teardown(),document.addEventListener(`contextmenu`,this._onContextMenuCapture,!0),document.addEventListener(`contextmenu`,this._onContextMenu),document.addEventListener(`keydown`,this._onDocKeyDown),document.addEventListener(`pointerdown`,this._onPointerDownCapture,!0),document.addEventListener(`pointerdown`,this._onPointerDown),document.addEventListener(`click`,this._onClickCapture,!0),this.addEventListener(`keydown`,this._onKeyDown),this.addEventListener(`click`,this._onClick),this.addEventListener(`mousemove`,this._onMouseMove)}disconnectedCallback(){this._teardown()}attributeChangedCallback(){this.disabled&&this.close()}get target(){return this.getAttribute(`target`)}set target(e){e==null||e===``?this.removeAttribute(`target`):this.setAttribute(`target`,String(e))}get disabled(){return this.hasAttribute(`disabled`)}set disabled(e){this.toggleAttribute(`disabled`,!!e)}get isOpen(){return this._panel()?.hasAttribute(a)??!1}open(e,n,{region:r=this,origin:i=r,keyboard:o=!1}={}){let s=this._panel();if(s){if(l&&l!==this&&l.close(!0),!this.isOpen){let e=document.activeElement;this._returnFocus=e&&e!==document.body&&!this._inPanel(e)?e:null}this._region=r,this._origin=i,u=null,s.setAttribute(a,``),l=this,t({getBoundingClientRect:()=>({left:e,right:e,top:n,bottom:n,width:0,height:0})},s,{clampHeight:!0}),window.addEventListener(`scroll`,this._onDismiss,!0),window.addEventListener(`resize`,this._onDismiss),window.addEventListener(`blur`,this._onDismiss),((o?this._items()[0]:null)??s).focus({preventScroll:!0}),this.dispatchEvent(new CustomEvent(`wui-context-menu:open`,{bubbles:!0,detail:{region:r,origin:i,x:e,y:n}}))}}close(e=!1){let t=this._panel();if(!t?.hasAttribute(a))return;t.removeAttribute(a),l===this&&(l=null),window.removeEventListener(`scroll`,this._onDismiss,!0),window.removeEventListener(`resize`,this._onDismiss),window.removeEventListener(`blur`,this._onDismiss),this._nav.teardown();let n=this._returnFocus;this._returnFocus=null,e&&n?.isConnected&&n.focus({preventScroll:!0})}_panel(){return[...this.children].find(e=>e.getAttribute(`role`)===`menu`)??null}_inPanel(e){return!!e&&!!this._panel()?.contains(e)}_items(){return[...this._panel()?.querySelectorAll(r)??[]].filter(e=>!this._isDisabled(e))}_isDisabled(e){return e.getAttribute(`aria-disabled`)===`true`}_regionFor(e){let t=p(e);if(!t||this.disabled||!this._panel()||this._inPanel(t)||t.closest(i))return null;let n=this.target;return n?t.closest(n):this.contains(t)?this:null}_isKeyEcho(){return u?.menu===this&&this.isOpen&&performance.now()-u.at<c}_handleContextMenu(e){if(this._inPanel(e.target)){e.preventDefault();return}if(e.defaultPrevented&&!d.has(e))return;let t=this._regionFor(e.target);if(t){if(this._isKeyEcho()){e.preventDefault();return}e.shiftKey||f(e,t,()=>this.close(!0))&&(e.preventDefault(),this.open(e.clientX,e.clientY,{region:t,origin:p(e.target)}))}}_handleDocKeyDown(e){if(e.defaultPrevented&&!d.has(e)||!(e.key===`ContextMenu`||e.key===`F10`&&e.shiftKey)||this._inPanel(e.target))return;let t=this._regionFor(e.target);if(!t||!f(e,t,()=>this.close(!0)))return;e.preventDefault();let n=p(e.target),r=n.getBoundingClientRect();this.open(r.left+Math.min(16,r.width/2),r.bottom,{region:t,origin:n,keyboard:!0}),u={menu:this,at:performance.now()}}_handlePointerDown(e){if(e.pointerType!==`touch`)return;let t=this._regionFor(e.target);if(!t||!f(e,t,()=>this._cancelPress()))return;this._cancelPress();let{clientX:n,clientY:r}=e,i=p(e.target);this._press={x:n,y:r,timer:setTimeout(()=>{this._cancelPress(),this._swallowClick=!0,this.open(n,r,{region:t,origin:i})},o)},document.addEventListener(`pointermove`,this._onPressMove,{passive:!0}),document.addEventListener(`pointerup`,this._onPressEnd),document.addEventListener(`pointercancel`,this._onPressEnd),window.addEventListener(`scroll`,this._onPressEnd,!0)}_cancelPress(){this._press&&(clearTimeout(this._press.timer),this._press=null,document.removeEventListener(`pointermove`,this._onPressMove),document.removeEventListener(`pointerup`,this._onPressEnd),document.removeEventListener(`pointercancel`,this._onPressEnd),window.removeEventListener(`scroll`,this._onPressEnd,!0))}_handleMenuKey(e){if(this.isOpen)if(e.key===`Escape`)e.preventDefault(),e.stopPropagation(),this.close(!0);else if(e.key===`Tab`)this.close(!0);else if(e.key===`ArrowDown`||e.key===`ArrowUp`)e.preventDefault(),this._step(e.key===`ArrowDown`?1:-1);else if(e.key===` `){let t=p(e.target)?.closest(r);e.preventDefault(),t&&t.click()}else this._nav.handler(e)}_step(e){let t=this._items();if(!t.length)return;let n=t.indexOf(document.activeElement);t[n<0?e>0?0:t.length-1:(n+e+t.length)%t.length].focus({preventScroll:!0})}_handleClick(e){let t=p(e.target)?.closest(r);if(!(!t||!this._inPanel(t))){if(this._isDisabled(t)){e.preventDefault(),e.stopPropagation();return}this.close(!0),this.dispatchEvent(new CustomEvent(`wui-context-menu:select`,{bubbles:!0,detail:{key:t.dataset.key??null,item:t,region:this._region,origin:this._origin}}))}}_teardown(){this.close(),this._cancelPress(),document.removeEventListener(`contextmenu`,this._onContextMenuCapture,!0),document.removeEventListener(`contextmenu`,this._onContextMenu),document.removeEventListener(`keydown`,this._onDocKeyDown),document.removeEventListener(`pointerdown`,this._onPointerDownCapture,!0),document.removeEventListener(`pointerdown`,this._onPointerDown),document.removeEventListener(`click`,this._onClickCapture,!0),this.removeEventListener(`keydown`,this._onKeyDown),this.removeEventListener(`click`,this._onClick),this.removeEventListener(`mousemove`,this._onMouseMove)}};export{m as t};
@@ -0,0 +1 @@
1
+ import{t as e}from"./countries-CvmZ2xpG.js";import{t}from"./WuiSelect-DvtN4qC2.js";var n=e=>{if(e==null)return null;let t=String(e).split(`,`).map(e=>e.trim().toUpperCase()).filter(Boolean);return t.length?new Set(t):null},r=t=>{let r=n(t);return e.filter(([e])=>!r||r.has(e)).map(([e,t])=>({value:e,label:t,flag:e}))},i=class extends t{static get observedAttributes(){return[...t.observedAttributes,`countries`]}_readOptions(){let e=this.getAttribute(`countries`);return this._countryCache?.attr!==e&&(this._countryCache={attr:e,options:r(e)}),this._countryCache.options}};export{i as t};
@@ -0,0 +1,31 @@
1
+ import{t as e}from"./elementBase-BlsR4tqa.js";import{n as t,r as n,t as r}from"./anchorOverlay-WcDeH46q.js";import{t as i}from"./formMirror-BgY7zkC3.js";import{t as a}from"./iconGlyphs.g-CUm_mfze.js";import{n as o}from"./optionLabel-DsX2fhWs.js";import{a as s,c,i as l,n as u,o as d,r as f,s as p,t as m}from"./calendarMath-BC2wGCD-.js";var h=class extends e{static formAssociated=!0;static get observedAttributes(){return[`value`,`min`,`max`,`placeholder`,`disabled`,`first-day`,`display-format`,`size`,`aria-label`,`aria-describedby`,`aria-invalid`]}constructor(){super();try{this._internals=this.attachInternals()}catch{this._internals=null}this._value=``;let e=new Date(2e3,0,1);this._viewY=e.getFullYear(),this._viewM=e.getMonth(),this._mode=`days`,this._focus=null,this._slide=``}connectedCallback(){if(!this._rendered){this.render();return}this._bindGlobal?.()}attributeChangedCallback(e,t,n){if(e===`aria-invalid`){this._syncInvalid();return}this._rendered&&(e===`value`?(this._value=n||``,this._syncFormValue(),this._syncTrigger()):e===`display-format`?this._syncTrigger():e===`first-day`?this.querySelector(`.datepicker-pop`)?.hidden||this._renderView():this.render())}_syncInvalid(){let e=this.querySelector(`.datepicker-trigger`);e&&(this.hasAttribute(`aria-invalid`)?e.setAttribute(`aria-invalid`,`true`):e.removeAttribute(`aria-invalid`))}formResetCallback(){this.value=this._defaultValue||``}get value(){return this._value}set value(e){this._value=e||``,i(this,this._value),this._syncTrigger()}_firstDay(){return s(this)}render(){this._defaultValue===void 0&&(this._defaultValue=this.getAttribute(`value`)||``,this._value=this._defaultValue||this._value);let e=this.getAttribute(`placeholder`)||`Enter Date`,t=p(this._value);t&&(this._viewY=t.y,this._viewM=t.m);let n=this.getAttribute(`size`),r=n===`sm`?` input-sm`:n===`lg`?` input-lg`:``,s=this.getAttribute(`aria-label`),c=this.getAttribute(`aria-describedby`);this.innerHTML=`
2
+ <div class="datepicker">
3
+ <button type="button" class="input datepicker-trigger${r}${t?` has-value`:``}" aria-haspopup="dialog" aria-expanded="false"${this.hasAttribute(`aria-invalid`)?` aria-invalid="true"`:``}${this.hasAttribute(`disabled`)?` disabled`:``}${s?` aria-label="${o(s)}"`:``}${c?` aria-describedby="${o(c)}"`:``}>
4
+ <span data-trigger-label class="${t?``:`search-select-placeholder`}">${o(t?d(this._value,this.getAttribute(`display-format`)):e)}</span>
5
+ ${a(`calendar-dots`)}
6
+ </button>
7
+ <div class="datepicker-pop" role="dialog" aria-modal="false" hidden></div>
8
+ </div>`,this._rendered=!0,i(this,this._value),this._wire()}_syncFormValue(){i(this,this._value)}_syncTrigger(){let e=this.querySelector(`.datepicker-trigger`),t=this.querySelector(`[data-trigger-label]`);if(!t)return;let n=p(this._value);t.textContent=n?d(this._value,this.getAttribute(`display-format`)):this.getAttribute(`placeholder`)||`Enter Date`,t.classList.toggle(`search-select-placeholder`,!n),e?.classList.toggle(`has-value`,!!n)}_limits(){let e=p(this.getAttribute(`min`)),t=p(this.getAttribute(`max`)),n=e?new Date(e.y,e.m,e.d).getTime():-1/0,r=t?new Date(t.y,t.m,t.d).getTime():1/0;return{dayDisabled:(e,t,i)=>{let a=new Date(e,t,i).getTime();return a<n||a>r},monthDisabled:(e,t)=>{let i=new Date(e,t,1).getTime();return new Date(e,t,l(e,t)).getTime()<n||i>r},yearDisabled:e=>{let t=new Date(e,0,1).getTime();return new Date(e,11,31).getTime()<n||t>r}}}_renderView(){let e=this.querySelector(`.datepicker-pop`);e&&(this._mode===`months`?e.innerHTML=this._monthsHtml():this._mode===`years`?e.innerHTML=this._yearsHtml():e.innerHTML=this._daysHtml(),this._focusActive())}_daysHtml(){let e=this._firstDay(),t=(new Date(this._viewY,this._viewM,1).getDay()-e+7)%7,n=l(this._viewY,this._viewM),r=p(this._value),i=new Date,{dayDisabled:o}=this._limits(),s=this._focus||r||{y:this._viewY,m:this._viewM,d:1},d=(e,t,n,a)=>{let l=c(e,t,n),u=r&&r.y===e&&r.m===t&&r.d===n,d=i.getFullYear()===e&&i.getMonth()===t&&i.getDate()===n,f=s.y===e&&s.m===t&&s.d===n,p=o(e,t,n);return`<button type="button" class="${[`datepicker-day`,a?`is-outside`:``,d?`is-today`:``,u?`is-selected`:``].filter(Boolean).join(` `)}" data-iso="${l}" role="gridcell" tabindex="${f&&!p?`0`:`-1`}"${u?` aria-selected="true"`:``}${p?` disabled aria-disabled="true"`:``}>${n}</button>`},h=``,g=f(this._viewY,this._viewM-1),_=l(g.y,g.m);for(let e=t-1;e>=0;e--)h+=d(g.y,g.m,_-e,!0);for(let e=1;e<=n;e++)h+=d(this._viewY,this._viewM,e,!1);let v=f(this._viewY,this._viewM+1),y=(7-(t+n)%7)%7;for(let e=1;e<=y;e++)h+=d(v.y,v.m,e,!0);let b=o(i.getFullYear(),i.getMonth(),i.getDate()),x=u.map((t,n)=>u[(n+e)%7]).map(e=>`<span>${e}</span>`).join(``);return`
9
+ <div class="datepicker-head">
10
+ <button type="button" class="datepicker-nav-btn" data-nav="-1" aria-label="Previous month">${a(`chevron-left`)}</button>
11
+ <button type="button" class="datepicker-month" data-view="months" aria-label="Choose month and year">${m[this._viewM]} ${this._viewY}</button>
12
+ <button type="button" class="datepicker-nav-btn" data-nav="1" aria-label="Next month">${a(`chevron-right`)}</button>
13
+ </div>
14
+ <div class="datepicker-weekdays">${x}</div>
15
+ <div class="datepicker-grid${this._slide?` ${this._slide}`:``}" role="grid">${h}</div>
16
+ <div class="datepicker-foot">
17
+ <button type="button" class="datepicker-link" data-today${b?` disabled`:``}>Today</button>
18
+ <button type="button" class="datepicker-link" data-clear>Clear</button>
19
+ </div>`}_monthsHtml(){let e=p(this._value),t=new Date,{monthDisabled:n}=this._limits(),r=``;for(let i=0;i<12;i++){let a=e&&e.y===this._viewY&&e.m===i,o=t.getFullYear()===this._viewY&&t.getMonth()===i,s=n(this._viewY,i),c=[`datepicker-cell`,o?`is-today`:``,a?`is-selected`:``].filter(Boolean).join(` `);r+=`<button type="button" class="${c}" data-month="${i}"${s?` disabled`:``}>${m[i].slice(0,3)}</button>`}return`
20
+ <div class="datepicker-head">
21
+ <button type="button" class="datepicker-nav-btn" data-nav-year="-1" aria-label="Previous year">${a(`chevron-left`)}</button>
22
+ <button type="button" class="datepicker-month" data-view="years" aria-label="Choose year">${this._viewY}</button>
23
+ <button type="button" class="datepicker-nav-btn" data-nav-year="1" aria-label="Next year">${a(`chevron-right`)}</button>
24
+ </div>
25
+ <div class="datepicker-cells">${r}</div>`}_yearsHtml(){let e=p(this._value),t=new Date().getFullYear(),{yearDisabled:n}=this._limits(),r=this._viewY-(this._viewY%10+10)%10-1,i=``;for(let a=0;a<12;a++){let o=r+a,s=e&&e.y===o,c=t===o,l=n(o),u=[`datepicker-cell`,c?`is-today`:``,s?`is-selected`:``].filter(Boolean).join(` `);i+=`<button type="button" class="${u}" data-year="${o}"${l?` disabled`:``}>${o}</button>`}return`
26
+ <div class="datepicker-head">
27
+ <button type="button" class="datepicker-nav-btn" data-nav-decade="-1" aria-label="Previous decade">${a(`chevron-left`)}</button>
28
+ <span class="datepicker-month">${r+1} to ${r+10}</span>
29
+ <button type="button" class="datepicker-nav-btn" data-nav-decade="1" aria-label="Next decade">${a(`chevron-right`)}</button>
30
+ </div>
31
+ <div class="datepicker-cells">${i}</div>`}_focusActive(){let e=this.querySelector(`.datepicker-pop`),t=e?.querySelector(`[tabindex="0"]`)||e?.querySelector(`.is-selected`)||e?.querySelector(`.datepicker-day:not(:disabled), .datepicker-cell:not(:disabled)`);t&&e.contains(document.activeElement)&&t.focus()}_position(e,t){r(e,t,{clampHeight:!0})}_setFocus(e,t,n,r){let{y:i,m:a}=f(e,t);this._focus={y:i,m:a,d:n};let o=i!==this._viewY||a!==this._viewM;this._viewY=i,this._viewM=a,this._slide=o&&r||``,this._renderView(),this._slide=``,this.querySelector(`.datepicker-day[data-iso="${c(i,a,n)}"]`)?.focus()}_onKey(e){if(this._mode!==`days`){e.key===`Escape`&&this._close();return}let t=this._focus||p(this._value)||{y:this._viewY,m:this._viewM,d:1},n=(n,r)=>{e.preventDefault();let i=new Date(t.y,t.m,t.d+n);this._setFocus(i.getFullYear(),i.getMonth(),i.getDate(),r)};switch(e.key){case`ArrowLeft`:return n(-1,`slide-prev`);case`ArrowRight`:return n(1,`slide-next`);case`ArrowUp`:return n(-7,`slide-prev`);case`ArrowDown`:return n(7,`slide-next`);case`Home`:return n(-((new Date(t.y,t.m,t.d).getDay()-this._firstDay()+7)%7),`slide-prev`);case`End`:return n(6-(new Date(t.y,t.m,t.d).getDay()-this._firstDay()+7)%7,`slide-next`);case`PageUp`:{e.preventDefault();let n=f(t.y,t.m-(e.shiftKey?12:1));return this._setFocus(n.y,n.m,Math.min(t.d,l(n.y,n.m)),`slide-prev`)}case`PageDown`:{e.preventDefault();let n=f(t.y,t.m+(e.shiftKey?12:1));return this._setFocus(n.y,n.m,Math.min(t.d,l(n.y,n.m)),`slide-next`)}case`Enter`:case` `:e.preventDefault(),this._limits().dayDisabled(t.y,t.m,t.d)||(this.value=c(t.y,t.m,t.d),this.dispatchEvent(new Event(`change`,{bubbles:!0})),this._close());return;case`Escape`:return this._close();default:}}_wire(){this._teardown();let e=this.querySelector(`.datepicker-trigger`),r=this.querySelector(`.datepicker-pop`),i=this.querySelector(`.datepicker`);if(!e||!r)return;let a=()=>!r.hidden,o=()=>{a()&&this._position(e,r)};this._open=()=>{let n=new Date,a=p(this._value);(a||!this._viewNavigated)&&(this._viewY=n.getFullYear(),this._viewM=n.getMonth()),this._mode=`days`;let s=n.getFullYear()===this._viewY&&n.getMonth()===this._viewM,c=a&&a.y===this._viewY&&a.m===this._viewM;this._focus=c?a:{y:this._viewY,m:this._viewM,d:s?n.getDate():1},this._renderView(),r.hidden=!1,i?.classList.add(`open`),this._position(e,r),t(this,o),e.setAttribute(`aria-expanded`,`true`),r.querySelector(`[tabindex="0"]`)?.focus()},this._close=()=>{r.hidden=!0,i?.classList.remove(`open`),e.setAttribute(`aria-expanded`,`false`),n(this),e.focus()},e.addEventListener(`click`,()=>a()?this._close():this._open()),r.addEventListener(`click`,e=>{this._popClick=!0;let t=e.target.closest(`[data-nav]`);if(t){this._viewNavigated=!0,this._slide=Number(t.dataset.nav)<0?`slide-prev`:`slide-next`;let e=f(this._viewY,this._viewM+Number(t.dataset.nav));this._viewY=e.y,this._viewM=e.m,this._focus={y:e.y,m:e.m,d:1},this._renderView(),this._slide=``;return}let n=e.target.closest(`[data-nav-year]`);if(n){this._viewY+=Number(n.dataset.navYear),this._renderView();return}let r=e.target.closest(`[data-nav-decade]`);if(r){this._viewY+=Number(r.dataset.navDecade)*10,this._renderView();return}let i=e.target.closest(`[data-view]`);if(i){this._mode=i.dataset.view,this._renderView();return}let a=e.target.closest(`[data-month]`);if(a&&!a.disabled){this._viewNavigated=!0,this._viewM=Number(a.dataset.month),this._mode=`days`,this._focus={y:this._viewY,m:this._viewM,d:1},this._renderView();return}let o=e.target.closest(`[data-year]`);if(o&&!o.disabled){this._viewNavigated=!0,this._viewY=Number(o.dataset.year),this._mode=`months`,this._renderView();return}if(e.target.closest(`[data-today]`)){let e=new Date;if(this._limits().dayDisabled(e.getFullYear(),e.getMonth(),e.getDate()))return;this.value=c(e.getFullYear(),e.getMonth(),e.getDate()),this.dispatchEvent(new Event(`change`,{bubbles:!0})),this._close();return}if(e.target.closest(`[data-clear]`)){this.value=``,this.dispatchEvent(new Event(`change`,{bubbles:!0})),this._close();return}let s=e.target.closest(`.datepicker-day[data-iso]`);s&&!s.disabled&&(this.value=s.dataset.iso,this.dispatchEvent(new Event(`change`,{bubbles:!0})),this._close())}),this._onKeyBound=e=>{a()&&this._onKey(e)},r.addEventListener(`keydown`,this._onKeyBound),this._bindGlobal=()=>{this._teardown(),this._onDocClick=e=>{let t=this._popClick;this._popClick=!1,a()&&!t&&!this.contains(e.target)&&this._close()},document.addEventListener(`click`,this._onDocClick),this._onDocKey=e=>{a()&&e.key===`Escape`&&this._close()},document.addEventListener(`keydown`,this._onDocKey),a()&&t(this,o)},this._bindGlobal(),this._syncFormValue()}_teardown(){this._onDocClick&&=(document.removeEventListener(`click`,this._onDocClick),null),this._onDocKey&&=(document.removeEventListener(`keydown`,this._onDocKey),null),n(this)}disconnectedCallback(){this._teardown()}};export{h as t};
@@ -0,0 +1,25 @@
1
+ import{t as e}from"./elementBase-BlsR4tqa.js";import{n as t,r as n,t as r}from"./anchorOverlay-WcDeH46q.js";import{t as i}from"./iconGlyphs.g-CUm_mfze.js";import{n as a}from"./optionLabel-DsX2fhWs.js";import{a as o,c as s,i as c,n as l,o as u,r as d,s as f,t as p}from"./calendarMath-BC2wGCD-.js";var m=class extends e{static formAssociated=!0;static get observedAttributes(){return[`start`,`end`,`min`,`max`,`placeholder`,`disabled`,`first-day`,`size`,`aria-label`,`aria-describedby`,`name`,`start-name`,`end-name`,`aria-invalid`]}constructor(){super();try{this._internals=this.attachInternals()}catch{this._internals=null}this._start=``,this._end=``,this._hover=``;let e=new Date(2e3,0,1);this._viewY=e.getFullYear(),this._viewM=e.getMonth()}connectedCallback(){if(!this._rendered){this.render();return}this._bindGlobal?.()}attributeChangedCallback(e,t,n){if(e===`aria-invalid`){this._syncInvalid();return}this._rendered&&(e===`start`||e===`end`?(this._start=this.getAttribute(`start`)||``,this._end=this.getAttribute(`end`)||``,this._syncTrigger(),this._syncMirrors()):this.render())}_syncInvalid(){let e=this.querySelector(`.daterange-trigger`);e&&(this.hasAttribute(`aria-invalid`)?e.setAttribute(`aria-invalid`,`true`):e.removeAttribute(`aria-invalid`))}get value(){return{start:this._start,end:this._end}}set value(e){this._start=e?.start||``,this._end=e?.end||``,this._syncTrigger(),this._syncMirrors()}_firstDay(){return o(this)}_label(){let e=this.getAttribute(`placeholder`)||`Start to End`;return!this._start&&!this._end?{text:e,empty:!0}:{text:`${u(this._start)||`Start`} to ${u(this._end)||`End`}`,empty:!1}}render(){this._defaultStart===void 0&&(this._defaultStart=this.getAttribute(`start`)||``,this._defaultEnd=this.getAttribute(`end`)||``,this._start=this._defaultStart||this._start,this._end=this._defaultEnd||this._end);let e=f(this._start);e&&(this._viewY=e.y,this._viewM=e.m);let t=this.getAttribute(`size`),n=t===`sm`?` input-sm`:t===`lg`?` input-lg`:``,{text:r,empty:o}=this._label(),s=this.getAttribute(`aria-label`),c=this.getAttribute(`aria-describedby`);this.innerHTML=`
2
+ <div class="daterange">
3
+ <button type="button" class="input daterange-trigger${n}${o?``:` has-value`}" aria-haspopup="dialog" aria-expanded="false"${this.hasAttribute(`aria-invalid`)?` aria-invalid="true"`:``}${this.hasAttribute(`disabled`)?` disabled`:``}${s?` aria-label="${a(s)}"`:``}${c?` aria-describedby="${a(c)}"`:``}>
4
+ <span data-range-label class="${o?`search-select-placeholder`:``}">${a(r)}</span>
5
+ ${i(`calendar`)}
6
+ </button>
7
+ <div class="daterange-pop" role="dialog" aria-modal="false" hidden></div>
8
+ </div>`,this._rendered=!0,this._syncMirrors(),this._wire()}formResetCallback(){this.value={start:this._defaultStart||``,end:this._defaultEnd||``}}_syncTrigger(){let e=this.querySelector(`.daterange-trigger`),t=this.querySelector(`[data-range-label]`);if(!t)return;let{text:n,empty:r}=this._label();t.textContent=n,t.classList.toggle(`search-select-placeholder`,r),e?.classList.toggle(`has-value`,!r)}_syncMirrors(){let e=this.getAttribute(`start-name`)||this.getAttribute(`name`),t=this.getAttribute(`end-name`);this._mirror(`start`,e,this._start),this._mirror(`end`,t,this._end)}_mirror(e,t,n){if(!t)return;let r=this.querySelector(`input[type="hidden"][data-range-mirror="${e}"]`);r||(r=document.createElement(`input`),r.type=`hidden`,r.setAttribute(`data-range-mirror`,e),this.appendChild(r)),r.name=t,r.value=n||``,r.disabled=this.hasAttribute(`disabled`)}_limits(){let e=f(this.getAttribute(`min`)),t=f(this.getAttribute(`max`)),n=e?new Date(e.y,e.m,e.d).getTime():-1/0,r=t?new Date(t.y,t.m,t.d).getTime():1/0;return(e,t,i)=>{let a=new Date(e,t,i).getTime();return a<n||a>r}}_monthHtml(e,t){let n=this._firstDay(),r=(new Date(e,t,1).getDay()-n+7)%7,i=c(e,t),a=this._limits(),o=l.map((e,t)=>l[(t+n)%7]).map(e=>`<span>${e}</span>`).join(``),u=(e,t,n,r)=>{let i=s(e,t,n),o=a(e,t,n);return`<button type="button" class="${[`datepicker-day`,r?`is-outside`:``].filter(Boolean).join(` `)}" data-iso="${i}"${o?` disabled`:``}>${n}</button>`},f=``,m=d(e,t-1),h=c(m.y,m.m);for(let e=r-1;e>=0;e--)f+=u(m.y,m.m,h-e,!0);for(let n=1;n<=i;n++)f+=u(e,t,n,!1);let g=d(e,t+1),_=(7-(r+i)%7)%7;for(let e=1;e<=_;e++)f+=u(g.y,g.m,e,!0);return`
9
+ <div class="daterange-cal">
10
+ <div class="datepicker-month-label">${p[t]} ${e}</div>
11
+ <div class="datepicker-weekdays">${o}</div>
12
+ <div class="datepicker-grid" role="grid">${f}</div>
13
+ </div>`}_renderView(){let e=this.querySelector(`.daterange-pop`);if(!e)return;let t=d(this._viewY,this._viewM+1);e.innerHTML=`
14
+ <div class="daterange-head">
15
+ <button type="button" class="datepicker-nav-btn" data-nav="-1" aria-label="Previous month">${i(`chevron-left`)}</button>
16
+ <button type="button" class="datepicker-nav-btn" data-nav="1" aria-label="Next month">${i(`chevron-right`)}</button>
17
+ </div>
18
+ <div class="daterange-cals">
19
+ ${this._monthHtml(this._viewY,this._viewM)}
20
+ ${this._monthHtml(t.y,t.m)}
21
+ </div>
22
+ <div class="datepicker-foot">
23
+ <span class="daterange-hint" data-range-hint></span>
24
+ <button type="button" class="datepicker-link" data-clear>Clear</button>
25
+ </div>`,this._paint()}_paint(){let e=this.querySelector(`.daterange-pop`);if(!e)return;let t=this._start?new Date(this._start).getTime():null,n=this._end;t&&!this._end&&this._hover&&new Date(this._hover).getTime()>=t&&(n=this._hover);let r=n?new Date(n).getTime():null;for(let n of e.querySelectorAll(`.datepicker-day[data-iso]`)){let e=new Date(n.dataset.iso).getTime(),i=t!=null&&e===t,a=r!=null&&e===r,o=t!=null&&r!=null&&e>t&&e<r;n.classList.toggle(`is-range-start`,i),n.classList.toggle(`is-range-end`,a),n.classList.toggle(`in-range`,o)}let i=e.querySelector(`[data-range-hint]`);i&&(i.textContent=this._start?this._end?`${u(this._start)} to ${u(this._end)}`:`Pick an end date`:`Pick a start date`)}_position(e,t){r(e,t,{clampHeight:!0})}_pick(e){if(!this._start||this._start&&this._end){this._start=e,this._end=``,this._hover=``,this._syncTrigger(),this._syncMirrors(),this._paint();return}if(new Date(e).getTime()<new Date(this._start).getTime()){this._start=e,this._syncTrigger(),this._syncMirrors(),this._paint(),this.dispatchEvent(new Event(`change`,{bubbles:!0}));return}this._end=e,this._syncTrigger(),this._syncMirrors(),this._paint(),this.dispatchEvent(new Event(`change`,{bubbles:!0})),this._close()}_wire(){this._teardown();let e=this.querySelector(`.daterange-trigger`),r=this.querySelector(`.daterange-pop`),i=this.querySelector(`.daterange`);if(!e||!r)return;let a=()=>!r.hidden,o=()=>{a()&&this._position(e,r)};this._open=()=>{let n=f(this._start);if(n)this._viewY=n.y,this._viewM=n.m;else{let e=new Date;this._viewY=e.getFullYear(),this._viewM=e.getMonth()}this._renderView(),r.hidden=!1,i?.classList.add(`open`),this._position(e,r),t(this,o),e.setAttribute(`aria-expanded`,`true`)},this._close=()=>{r.hidden=!0,this._hover=``,i?.classList.remove(`open`),e.setAttribute(`aria-expanded`,`false`),n(this)},e.addEventListener(`click`,()=>a()?this._close():this._open()),r.addEventListener(`click`,e=>{this._popClick=!0;let t=e.target.closest(`[data-nav]`);if(t){let e=d(this._viewY,this._viewM+Number(t.dataset.nav));this._viewY=e.y,this._viewM=e.m,this._renderView();return}if(e.target.closest(`[data-clear]`)){this._start=``,this._end=``,this._hover=``,this._syncTrigger(),this._syncMirrors(),this._renderView(),this.dispatchEvent(new Event(`change`,{bubbles:!0}));return}let n=e.target.closest(`.datepicker-day[data-iso]`);n&&!n.disabled&&this._pick(n.dataset.iso)}),r.addEventListener(`mouseover`,e=>{let t=e.target.closest(`.datepicker-day[data-iso]`);t&&this._start&&!this._end&&(this._hover=t.dataset.iso,this._paint())}),this._bindGlobal=()=>{this._teardown(),this._onDocClick=e=>{let t=this._popClick;this._popClick=!1,a()&&!t&&!this.contains(e.target)&&this._close()},document.addEventListener(`click`,this._onDocClick),this._onDocKey=e=>{a()&&e.key===`Escape`&&this._close()},document.addEventListener(`keydown`,this._onDocKey),a()&&t(this,o)},this._bindGlobal(),this._syncMirrors()}_teardown(){this._onDocClick&&=(document.removeEventListener(`click`,this._onDocClick),null),this._onDocKey&&=(document.removeEventListener(`keydown`,this._onDocKey),null),n(this)}disconnectedCallback(){this._teardown()}};export{m as t};
@@ -0,0 +1 @@
1
+ import{t as e}from"./elementBase-BlsR4tqa.js";var t=class extends e{static get observedAttributes(){return[`static`,`max-scale`,`radius`]}constructor(){super(),this._pointerMoveListener=null,this._pointerLeaveListener=null,this._frame=0,this._pointerX=0}connectedCallback(){this._wire()}disconnectedCallback(){this._teardown()}attributeChangedCallback(e,t,n){e===`static`&&this.isConnected&&this._wire()}_maxScale(){return n(this.getAttribute(`max-scale`),1.6)}_radius(){return n(this.getAttribute(`radius`),100)}_magnifyEnabled(){return!(this.hasAttribute(`static`)||typeof matchMedia==`function`&&(matchMedia(`(pointer: coarse)`).matches||matchMedia(`(prefers-reduced-motion: reduce)`).matches))}_applyMagnification(){this._frame=0;let e=this._maxScale(),t=this._radius();for(let n of this.querySelectorAll(`.dock-item`)){let r=n.getBoundingClientRect(),i=Math.abs(this._pointerX-(r.left+r.width/2)),a=Math.max(0,1-i/t),o=1+(e-1)*a;n.style.setProperty(`--wui-dock-mag`,o.toFixed(3))}}_resetMagnification(){this._frame&&=(cancelAnimationFrame(this._frame),0);for(let e of this.querySelectorAll(`.dock-item`))e.style.removeProperty(`--wui-dock-mag`)}_wire(){this._teardown(),this._magnifyEnabled()&&(this._pointerMoveListener=e=>{this._pointerX=e.clientX,this._frame||=requestAnimationFrame(()=>this._applyMagnification())},this._pointerLeaveListener=()=>this._resetMagnification(),this.addEventListener(`pointermove`,this._pointerMoveListener),this.addEventListener(`pointerleave`,this._pointerLeaveListener))}_teardown(){this._pointerMoveListener&&=(this.removeEventListener(`pointermove`,this._pointerMoveListener),null),this._pointerLeaveListener&&=(this.removeEventListener(`pointerleave`,this._pointerLeaveListener),null),this._resetMagnification()}},n=(e,t)=>{let n=Number.parseFloat(e);return Number.isFinite(n)?n:t};export{t};
@@ -0,0 +1,17 @@
1
+ import{t as e}from"./elementBase-BlsR4tqa.js";var t=4096,n=[.92,.8,.65,.5],r=.8,i=8;function a(e){if(e==null||e===``||e===`free`)return null;let t=typeof e==`number`?e:Number(e);return Number.isFinite(t)&&t>0?t:null}function o(e,t,n){if(!n)return{x:0,y:0,w:e,h:t};let r=e,i=r/n;return i>t&&(i=t,r=i*n),{x:(e-r)/2,y:(t-i)/2,w:r,h:i}}function s(e,t,n){return{...e,x:Math.min(Math.max(e.x,0),Math.max(t-e.w,0)),y:Math.min(Math.max(e.y,0),Math.max(n-e.h,0))}}function c(e,t,n,r,i){return s({...e,x:e.x+t,y:e.y+n},r,i)}function l(e,t){return Math.min(32,e,t)}function u(e,t){return t.w/e.w}function d(e,t){return Math.max(4,u(e,t))}function f(e,t,n,r,i){let a=Math.min(Math.max(n,1),d(e,t)),o=e.h/e.w,c=Math.min(r,i/o),u=Math.min(Math.max(l(r,i),l(r,i)/o),c),f=Math.min(Math.max(t.w/a,u),c),p=f*o,m=e.x+e.w/2,h=e.y+e.h/2;return s({x:m-f/2,y:h-p/2,w:f,h:p},r,i)}var p=[`nw`,`ne`,`sw`,`se`];function m(e,t,n,r,i,a){let o=l(i,a),s=t.endsWith(`w`),c=t.startsWith(`n`),u=s?e.x+e.w:e.x,d=c?e.y+e.h:e.y,f=Math.min(Math.max(n,0),i),p=Math.min(Math.max(r,0),a);return f=s?Math.min(f,u-o):Math.max(f,u+o),p=c?Math.min(p,d-o):Math.max(p,d+o),{x:Math.min(f,u),y:Math.min(p,d),w:Math.abs(f-u),h:Math.abs(p-d)}}function h(e,n=t){let r=Math.min(1,n/Math.max(e.w,e.h));return{width:Math.max(1,Math.round(e.w*r)),height:Math.max(1,Math.round(e.h*r))}}function g(e,t){let n=t/Math.max(e.w,e.h);return{width:Math.max(1,Math.round(e.w*n)),height:Math.max(1,Math.round(e.h*n))}}function _(e,t,n){return n%180==0?{w:e,h:t}:{w:t,h:e}}function v(e,t,n){return s({x:n-(e.y+e.h),y:e.x,w:e.h,h:e.w},n,t)}function y(e){return String(e||``).split(/[\s,]+/).map(Number).filter(e=>Number.isInteger(e)&&e>0)}var b=[`image/png`,`image/jpeg`,`image/webp`],x={"image/png":`.png`,"image/jpeg":`.jpg`,"image/webp":`.webp`};function S(e){let t=String(e||``).toLowerCase();return b.includes(t)?t:`image/png`}function C(e,t){let n=String(e||`image`),r=x[t];return(t===`image/jpeg`?/\.jpe?g$/i.test(n):n.toLowerCase().endsWith(r))?n:`${n.replace(/\.[^./\\]+$/,``)||`image`}${r}`}async function w(e,{width:t,height:a,type:o,maxBytes:s}){let c=o,l=t,u=a,d=null;for(let t=0;t<=i;t++){let i=c===`image/png`?[void 0]:t===0?n:[n[1]];for(let t of i){if(d=await e(l,u,c,t),!d||(d.type&&d.type!==c&&(c=d.type),!(s>0)||d.size<=s))return d;if(c===`image/png`)break}l=Math.max(1,Math.round(l*r)),u=Math.max(1,Math.round(u*r))}return d}var T=.05,E=.2,D={w:320,h:240},O={nw:`top left`,ne:`top right`,sw:`bottom left`,se:`bottom right`},k=`<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true"><path d="M5 12h14"/></svg>`,A=`<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true"><path d="M5 12h14M12 5v14"/></svg>`,j=`<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8"/><path d="M21 3v5h-5"/></svg>`,M=`<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"/><path d="M3 3v5h5"/></svg>`,N=(e,t)=>Math.hypot(e.x-t.x,e.y-t.y),P=class extends e{static get observedAttributes(){return[`src`,`aspect`,`round`,`rotatable`,`previews`]}constructor(){super(),this._rect=null,this._base=null,this._natural=null,this._source=null,this._rotation=0,this._drag=null,this._pointers=new Map,this._pinch=null,this._previewPending=!1,this._resizeObserver=null}get src(){return this.getAttribute(`src`)||``}set src(e){e==null||e===``?this.removeAttribute(`src`):this.setAttribute(`src`,String(e))}get aspect(){return a(this.getAttribute(`aspect`))}set aspect(e){e==null||e===``?this.removeAttribute(`aspect`):this.setAttribute(`aspect`,String(e))}get round(){return this.hasAttribute(`round`)}set round(e){this.toggleAttribute(`round`,!!e)}get rotatable(){return this.hasAttribute(`rotatable`)}set rotatable(e){this.toggleAttribute(`rotatable`,!!e)}get previews(){return this.getAttribute(`previews`)||``}set previews(e){e==null||e===``?this.removeAttribute(`previews`):this.setAttribute(`previews`,Array.isArray(e)?e.join(` `):String(e))}get rect(){return this._rect?{...this._rect}:null}get rotation(){return this._rotation}set rotation(e){if(!this._rect)return;let t=(Math.round(Number(e)/90)*90%360+360)%360;if(!Number.isNaN(t))for(;this._rotation!==t;)this.rotate()}get zoom(){return this._rect?u(this._rect,this._base):1}set zoom(e){this._rect&&(this._rect=f(this._rect,this._base,Number(e)||1,this._natural.w,this._natural.h),this._paint(),this._announce())}connectedCallback(){if(!this._rendered){this.render();return}this._observe()}disconnectedCallback(){this._resizeObserver?.disconnect(),this._resizeObserver=null}attributeChangedCallback(e){this._rendered&&(e===`src`?this._loadImage():e===`aspect`?(this._rebuildHandles(),this._resetRect()):e===`rotatable`?this._tools.hidden=!this.rotatable:e===`previews`?this._renderPreviews():this._applyRound())}render(){this.innerHTML=`<div>
2
+ <div class="wui-crop-stage" tabindex="0" role="group" aria-label="Crop area. Drag the frame or use the arrow keys to move it, and plus or minus to zoom.">
3
+ <img class="wui-crop-img" alt="" draggable="false">
4
+ <div class="wui-crop-frame"></div>
5
+ </div>
6
+ <div class="wui-crop-controls">
7
+ <button type="button" class="wui-crop-zoombtn" data-zoom="out" aria-label="Zoom out">${k}</button>
8
+ <input type="range" class="form-range wui-crop-zoom" min="1" max="4" step="0.01" value="1" aria-label="Zoom">
9
+ <button type="button" class="wui-crop-zoombtn" data-zoom="in" aria-label="Zoom in">${A}</button>
10
+ </div>
11
+ <div class="wui-crop-tools" hidden>
12
+ <button type="button" class="wui-crop-toolbtn" data-crop-action="rotate" aria-label="Rotate 90 degrees clockwise">${j}<span>Rotate</span></button>
13
+ <button type="button" class="wui-crop-toolbtn" data-crop-action="reset" aria-label="Reset the crop">${M}<span>Reset</span></button>
14
+ </div>
15
+ <div class="wui-crop-previews" aria-hidden="true" hidden></div>
16
+ <div class="visually-hidden" data-wui-crop-live aria-live="polite"></div>
17
+ </div>`,this._stage=this.querySelector(`.wui-crop-stage`),this._img=this.querySelector(`.wui-crop-img`),this._frame=this.querySelector(`.wui-crop-frame`),this._slider=this.querySelector(`.wui-crop-zoom`),this._tools=this.querySelector(`.wui-crop-tools`),this._previewBox=this.querySelector(`.wui-crop-previews`),this._live=this.querySelector(`[data-wui-crop-live]`),this._rendered=!0,this._tools.hidden=!this.rotatable,this._applyRound(),this._rebuildHandles(),this._renderPreviews(),this._wire(),this._observe(),this._loadImage()}_applyRound(){this._frame.classList.toggle(`wui-crop-frame--round`,this.round),this._previewBox.classList.toggle(`wui-crop-previews--round`,this.round)}_rebuildHandles(){for(let e of this._frame.querySelectorAll(`.wui-crop-handle`))e.remove();if(!this.aspect)for(let e of p){let t=document.createElement(`button`);t.type=`button`,t.className=`wui-crop-handle wui-crop-handle--${e}`,t.dataset.handle=e,t.setAttribute(`aria-label`,`Resize ${O[e]} corner`),this._frame.appendChild(t)}}_renderPreviews(){let e=y(this.previews);this._previewBox.replaceChildren(),this._previewBox.hidden=e.length===0;for(let t of e){let e=document.createElement(`canvas`);e.className=`wui-crop-preview`,e.dataset.size=String(t),e.style.width=`${t}px`,e.style.height=`${t}px`,this._previewBox.appendChild(e)}this._schedulePreviews()}_loadImage(){this._rect=null,this._natural=null,this._source=null,this._rotation=0,this._drag=null,this._pinch=null,this._pointers.clear();let e=this.src;this._img.hidden=!e,this._frame.hidden=!0,e&&(this._img.onload=()=>{this._source={w:this._img.naturalWidth,h:this._img.naturalHeight},this._natural={...this._source},this._resetRect(),this.dispatchEvent(new Event(`load`))},this._img.onerror=()=>{this._frame.hidden=!0,this.dispatchEvent(new Event(`error`))},this._img.src=e)}_resetRect(){this._natural&&(this._base=o(this._natural.w,this._natural.h,this.aspect),this._rect={...this._base},this._frame.hidden=!1,this._paint())}_observe(){typeof ResizeObserver>`u`||this._resizeObserver||(this._resizeObserver=new ResizeObserver(()=>this._paint()),this._resizeObserver.observe(this._stage))}_view(){let e=this._stage.clientWidth||D.w,t=this._stage.clientHeight||D.h,n=Math.min(e/this._natural.w,t/this._natural.h),r=this._natural.w*n,i=this._natural.h*n;return{scale:n,left:(e-r)/2,top:(t-i)/2,iw:r,ih:i}}_paint(){if(!this._rect)return;let e=this._view(),t=this._rotation%180!=0,n=t?e.ih:e.iw,r=t?e.iw:e.ih;Object.assign(this._img.style,{left:`${e.left+(e.iw-n)/2}px`,top:`${e.top+(e.ih-r)/2}px`,width:`${n}px`,height:`${r}px`,transform:this._rotation?`rotate(${this._rotation}deg)`:``});let i=this._rect;Object.assign(this._frame.style,{left:`${e.left+i.x*e.scale}px`,top:`${e.top+i.y*e.scale}px`,width:`${i.w*e.scale}px`,height:`${i.h*e.scale}px`});let a=u(i,this._base),o=d(i,this._base);this._slider.max=String(o),this._slider.value=String(Math.min(Math.max(a,1),o)),this._slider.setAttribute(`aria-valuetext`,`${Math.round(a*100)}%`),this._schedulePreviews()}_schedulePreviews(){if(!this._rect||this._previewBox.hidden||this._previewPending)return;this._previewPending=!0;let e=()=>{this._previewPending=!1,this._drawPreviews()};typeof requestAnimationFrame==`function`?requestAnimationFrame(e):e()}_drawPreviews(){if(!this._rect)return;let e=s(this._rect,this._natural.w,this._natural.h),t=typeof window<`u`&&window.devicePixelRatio||1;for(let n of this._previewBox.children){let r=Number(n.dataset.size),i=Math.max(1,Math.round(r*e.h/e.w));n.style.width=`${r}px`,n.style.height=`${i}px`,n.width=Math.round(r*t),n.height=Math.round(i*t);let a=n.getContext(`2d`);a&&this._drawCrop(a,e,n.width,n.height)}}_drawCrop(e,t,n,r){if(!this._rotation){e.drawImage(this._img,t.x,t.y,t.w,t.h,0,0,n,r);return}let i=this._source;e.save(),e.scale(n/t.w,r/t.h),e.translate(-t.x,-t.y),e.translate(this._natural.w/2,this._natural.h/2),e.rotate(this._rotation*Math.PI/180),e.drawImage(this._img,-i.w/2,-i.h/2,i.w,i.h),e.restore()}_announce(){this.dispatchEvent(new CustomEvent(`change`,{bubbles:!0,detail:this.rect}))}_say(){let e=this._rect,t=this._rotation?`, turned ${this._rotation} degrees`:``,n=`Frame ${Math.round(e.w)} by ${Math.round(e.h)} pixels, ${Math.round(e.x)} from the left, ${Math.round(e.y)} from the top, zoom ${Math.round(u(e,this._base)*100)}%${t}.`;this._live.textContent=n===this._live.textContent?`${n} `:n}rotate(){if(!this._rect)return;let e=v(this._rect,this._natural.w,this._natural.h);this._rotation=(this._rotation+90)%360,this._natural=_(this._source.w,this._source.h,this._rotation),this._base=o(this._natural.w,this._natural.h,this.aspect);let t=this.aspect;this._rect=t&&t!==1?{...this._base}:e,this._paint(),this._announce()}reset(){this._source&&(this._rotation=0,this._natural={...this._source},this._resetRect(),this._announce())}_wire(){let e=this._stage;e.addEventListener(`pointerdown`,t=>{if(!this._rect||t.button>0)return;if(this._pointers.set(t.pointerId,{x:t.clientX,y:t.clientY}),e.setPointerCapture?.(t.pointerId),this._pointers.size===2){let[e,n]=[...this._pointers.values()];this._drag=null,this._pinch={distance:N(e,n)||1,zoom:this.zoom,done:!1},t.preventDefault();return}if(this._pinch)return;let n=t.target.closest?.(`.wui-crop-handle`);this._drag={id:t.pointerId,corner:n?n.dataset.handle:null,x:t.clientX,y:t.clientY,start:{...this._rect}},n||e.focus(),t.preventDefault()}),e.addEventListener(`pointermove`,t=>{if(this._pointers.has(t.pointerId)&&this._pointers.set(t.pointerId,{x:t.clientX,y:t.clientY}),this._pinch){if(this._pinch.done||this._pointers.size<2||!this._pointers.has(t.pointerId))return;let[e,n]=[...this._pointers.values()],r=this._pinch.zoom*N(e,n)/this._pinch.distance;this._rect=f(this._rect,this._base,r,this._natural.w,this._natural.h),this._paint();return}let n=this._drag;if(!n||n.id!==t.pointerId)return;let r=this._view(),{w:i,h:a}=this._natural;if(n.corner){let o=e.getBoundingClientRect(),s=(t.clientX-o.left-e.clientLeft-r.left)/r.scale,c=(t.clientY-o.top-e.clientTop-r.top)/r.scale;this._rect=m(this._rect,n.corner,s,c,i,a)}else this._rect=c(n.start,(t.clientX-n.x)/r.scale,(t.clientY-n.y)/r.scale,i,a);this._paint()});let t=t=>{if(this._pointers.delete(t.pointerId)&&e.releasePointerCapture?.(t.pointerId),this._pinch){!this._pinch.done&&this._pointers.size<2&&(this._pinch.done=!0,this._announce()),this._pointers.size===0&&(this._pinch=null);return}let n=this._drag;!n||n.id!==t.pointerId||(this._drag=null,this._announce())};e.addEventListener(`pointerup`,t),e.addEventListener(`pointercancel`,t),e.addEventListener(`keydown`,e=>this._onKey(e)),e.addEventListener(`wheel`,e=>{!this._rect||!this.contains(document.activeElement)||(e.preventDefault(),this.zoom*=e.deltaY<0?1.1:1/1.1)},{passive:!1});for(let e of[`input`,`change`])this._slider.addEventListener(e,e=>e.stopPropagation());this._slider.addEventListener(`input`,()=>{this.zoom=Number(this._slider.value)});for(let e of this.querySelectorAll(`.wui-crop-zoombtn`))e.addEventListener(`click`,()=>{this.zoom*=e.dataset.zoom===`in`?1.25:.8});this.querySelector(`[data-crop-action="rotate"]`).addEventListener(`click`,()=>this.rotate()),this.querySelector(`[data-crop-action="reset"]`).addEventListener(`click`,()=>this.reset())}_onKey(e){if(!this._rect||e.altKey||e.ctrlKey||e.metaKey)return;let{w:t,h:n}=this._natural;if(e.key===`+`||e.key===`=`)this.zoom*=1.25,this._say();else if(e.key===`-`||e.key===`_`)this.zoom*=.8,this._say();else if((e.key===`r`||e.key===`R`)&&this.rotatable)this.rotate(),this._say();else if(e.key.startsWith(`Arrow`)){let r=e.shiftKey?E:T,i=e.key===`ArrowRight`?1:e.key===`ArrowLeft`?-1:0,a=e.key===`ArrowDown`?1:e.key===`ArrowUp`?-1:0,o=e.target.closest?.(`.wui-crop-handle`)?.dataset.handle;if(o){let e=this._rect,s=(o.endsWith(`w`)?e.x:e.x+e.w)+i*r*e.w,c=(o.startsWith(`n`)?e.y:e.y+e.h)+a*r*e.h;this._rect=m(e,o,s,c,t,n)}else this._rect=c(this._rect,i*r*this._rect.w,a*r*this._rect.h,t,n);this._paint(),this._announce(),this._say()}else return;e.preventDefault()}async toBlob({type:e,maxBytes:t=0,size:n=0}={}){if(!this._rect)return null;let r=S(e),i=s(this._rect,this._natural.w,this._natural.h),{width:a,height:o}=n>0?g(i,n):h(i);return w((e,t,n,r)=>new Promise(a=>{let o=document.createElement(`canvas`);o.width=e,o.height=t;let s=o.getContext(`2d`);if(!s){a(null);return}n===`image/jpeg`&&(s.fillStyle=`#fff`,s.fillRect(0,0,e,t)),this._drawCrop(s,i,e,t),o.toBlob(a,n,r)}),{width:a,height:o,type:r,maxBytes:t})}async toFile({name:e,type:t,maxBytes:n=0,size:r=0}={}){let i=await this.toBlob({type:t,maxBytes:n,size:r});return i?new File([i],C(e,i.type),{type:i.type}):null}};export{P as t};
@@ -0,0 +1,25 @@
1
+ import{t as e}from"./elementBase-BlsR4tqa.js";import{n as t,r as n,t as r}from"./anchorOverlay-WcDeH46q.js";import{n as i,t as a}from"./focusOrigin-2imUSs-u.js";import{n as o}from"./formMirror-BgY7zkC3.js";import{t as s}from"./iconGlyphs.g-CUm_mfze.js";import{n as c,t as l}from"./listboxKeyNav-DMIvs9d6.js";import{n as u,r as d,t as f}from"./optionLabel-DsX2fhWs.js";import{i as p,t as m}from"./tokenCommit-BKckxgtg.js";var h=class extends e{static formAssociated=!0;_accessibleName(){return this.getAttribute(`aria-label`)||this.getAttribute(`placeholder`)||`Select`}static get observedAttributes(){return[`placeholder`,`search-placeholder`,`searchable`,`disabled`,`icon`,`size`,`collapse-chips`,`aria-label`,`aria-invalid`,`allow-custom`,`custom-pattern`,`custom-invalid-message`]}constructor(){super(),this._values=[],this._optionsProp=null,this._active=-1,this._typeahead=``,this._typeaheadTimer=null,this._customError=``;try{this._internals=this.attachInternals()}catch{this._internals=null}}connectedCallback(){if(!this._rendered){if(!this._valuesInit&&!this._optionsProp&&!this._values.length){let e=this.getAttribute(`value`);if(e!=null&&e!==``)this._values=e.split(`,`).map(e=>e.trim()).filter(Boolean);else{let e=[...this.querySelectorAll(`:scope > wui-option[selected]`)].map(e=>e.getAttribute(`value`)??e.textContent.trim());e.length&&(this._values=e.map(String))}}this._valuesInit=!0,this._defaultCaptured||=(this._defaultValues=this._values.slice(),!0),this.render();return}this._bindGlobal?.()}formResetCallback(){this.values=(this._defaultValues||[]).slice();let e=this.querySelector(`[data-input]`);e&&(e.value=``),this._setCustomError(``)}attributeChangedCallback(e){if(e===`aria-invalid`){this._syncInvalid();return}e===`custom-pattern`||e===`custom-invalid-message`||this._rendered&&this.render()}_syncInvalid(){let e=this.querySelector(`.search-select-control`);e&&(this.hasAttribute(`aria-invalid`)||this._customError?e.setAttribute(`aria-invalid`,`true`):e.removeAttribute(`aria-invalid`))}get values(){return this._values.slice()}set values(e){this._values=Array.isArray(e)?e.map(String):[],o(this,this._values),this._rendered&&(this._renderControl(),this._renderOptions(this._query()))}set options(e){if(this._optionsProp=Array.isArray(e)?e:null,this._rendered&&this._allowCustom){this._renderControl(),this._renderOptions(this._query());return}this.isConnected&&this.render()}get options(){return this._readOptions()}get validateCustom(){return this._validateCustom??null}set validateCustom(e){this._validateCustom=typeof e==`function`?e:null}get _allowCustom(){return this.hasAttribute(`allow-custom`)}_query(){let e=this.querySelector(this._allowCustom?`[data-input]`:`.search-select-input`);return e?e.value:``}_snapshotDeclared(){if(this._declared)return;let e=[...this.querySelectorAll(`:scope > wui-option`)];e.length&&(this._declared=e.map(e=>{let t={value:e.getAttribute(`value`)??e.textContent.trim(),label:e.innerHTML,icon:e.getAttribute(`icon`)||void 0,[f]:!0,selected:e.hasAttribute(`selected`)};for(let[n,r]of _){let i=e.getAttribute(n);i&&(t[r]=i)}return e.hasAttribute(`disabled`)&&(t.disabled=!0),t}))}_readOptions(){return this._optionsProp?this._optionsProp:(this._snapshotDeclared(),this._declared||[])}_labelFor(e){let t=this._readOptions().find(t=>String(t.value)===String(e));return t?t.label:e}_labelHtmlFor(e){let t=this._readOptions().find(t=>String(t.value)===String(e));return t?d(t):u(e)}render(){this._snapshotDeclared();let e=this._allowCustom,t=this.hasAttribute(`searchable`)&&!e,n=this.getAttribute(`search-placeholder`)||`Search…`,r=this.getAttribute(`icon`),i=this.getAttribute(`size`),a=i===`sm`?` search-select-sm`:i===`lg`?` search-select-lg`:``;o(this,this._values),this.id||=`wui-multiselect-${Math.random().toString(36).slice(2,9)}`;let c=`${this.id}-listbox`;this._listboxId=c;let l=this.hasAttribute(`disabled`);if(e){let e=`${this.id}-custom-error`;this.innerHTML=`
2
+ <div class="search-select${a}">
3
+ <div class="input search-select-control search-select-multi"${this.hasAttribute(`aria-invalid`)?` aria-invalid="true"`:``}${l?` aria-disabled="true"`:``}>
4
+ ${r?s(r,{className:`search-select-icon`}):``}
5
+ <div class="ms-chips" data-chips><input type="text" class="ms-input" data-input role="combobox" aria-autocomplete="list" aria-haspopup="listbox" aria-expanded="false" aria-controls="${w(c)}" aria-label="${w(this._accessibleName())}" aria-describedby="${w(e)}" autocomplete="off"${l?` disabled`:``} /></div>
6
+ ${s(`chevron-down`,{className:`search-select-caret`})}
7
+ </div>
8
+ <div class="search-select-menu search-select-menu-fixed" role="listbox" id="${w(c)}" aria-multiselectable="true" tabindex="-1" hidden>
9
+ <div class="search-select-options"></div>
10
+ </div>
11
+ </div>
12
+ <div class="field-error wui-ms-custom-error" id="${w(e)}" aria-live="polite" hidden></div>`}else this.innerHTML=`
13
+ <div class="search-select${a}">
14
+ <div class="input search-select-control search-select-multi" role="combobox" aria-haspopup="listbox" aria-expanded="false" aria-controls="${w(c)}" aria-label="${w(this._accessibleName())}"${this.hasAttribute(`aria-invalid`)?` aria-invalid="true"`:``}${l?` aria-disabled="true"`:` tabindex="0"`}>
15
+ ${r?s(r,{className:`search-select-icon`}):``}
16
+ <div class="ms-chips" data-chips></div>
17
+ ${s(`chevron-down`,{className:`search-select-caret`})}
18
+ </div>
19
+ <div class="search-select-menu search-select-menu-fixed" role="listbox" id="${w(c)}" aria-multiselectable="true" tabindex="-1" hidden>
20
+ ${t?`<div class="search-select-search">${s(`search`)}<input class="search-select-input" placeholder="${w(n)}" aria-autocomplete="list" /><button type="button" class="search-select-clear" aria-label="Clear search" hidden>${s(`x`)}</button></div>`:``}
21
+ <div class="search-select-options"></div>
22
+ <div class="search-select-empty" hidden>No matches</div>
23
+ </div>
24
+ </div>`;this._rendered=!0,this._customError=``,o(this,this._values),this._renderControl(),this._renderOptions(),this._wire()}_renderControl(){let e=this.querySelector(`[data-chips]`);if(!e)return;let t=this.getAttribute(`placeholder`)||`Select…`,n=this._allowCustom?e.querySelector(`[data-input]`):null,r=this._values.map(e=>`<span class="chip chip-sm"><span class="chip-label">${this._labelHtmlFor(e)}</span><button type="button" class="chip-remove" data-remove="${w(e)}" aria-label="Remove ${w(T(this._labelFor(e)))}">${s(`x`)}</button></span>`).join(``);if(n){for(let t of[...e.querySelectorAll(`:scope > .chip`)])t.remove();n.insertAdjacentHTML(`beforebegin`,r),n.placeholder=this._values.length?``:t,this._collapseChips();return}if(!this._values.length){e.innerHTML=`<span class="search-select-placeholder">${u(t)}</span>`;return}e.innerHTML=r,this._collapseChips()}_collapseChips(){let e=this.querySelector(`[data-chips]`);if(!e||!this.hasAttribute(`collapse-chips`)||!this._values.length)return;e.querySelector(`.chip-more`)?.remove();let t=[...e.querySelectorAll(`:scope > .chip:not(.chip-more)`)];for(let e of t)e.style.display=``;if(!t.length)return;let n=e.clientWidth,r=e=>e.offsetLeft+e.offsetWidth;if(r(t[t.length-1])<=n)return;let i=document.createElement(`span`);i.className=`chip chip-sm chip-more`,i.textContent=`+${t.length}`,t[t.length-1].after(i);let a=i.offsetWidth+6,o=0;for(let e of t)if(r(e)<=n-a)o+=1;else break;o<1&&(o=1);for(let e=o;e<t.length;e+=1)t[e].style.display=`none`;i.textContent=`+${t.length-o}`}_matches(e,t){return T(e.label).toLowerCase().includes(t)||String(e.description??``).toLowerCase().includes(t)}_optionNamed(e){let t=e.trim().toLowerCase();return this._readOptions().find(e=>String(e.value??``).toLowerCase()===t||T(e.label).trim().toLowerCase()===t)}_renderOptions(e){let t=this.querySelector(`.search-select-options`),n=this.querySelector(`.search-select-empty`);if(!t)return;let r=(e||``).trim(),i=r.toLowerCase(),a=this._readOptions();i&&(a=a.filter(e=>this._matches(e,i)));let o=this._listboxId||`${this.id||`wui-multiselect`}-listbox`,c=this._allowCustom&&r&&!this._optionNamed(r),l=a.map((e,t)=>{let n=this._values.includes(String(e.value)),r=`${o}-opt-${t}`;return v(e)?x(e,r,n):`<button type="button" role="option" id="${w(r)}" class="search-select-option${n?` selected`:``}" data-value="${w(e.value)}" aria-selected="${n}"><span class="ms-opt-label">${d(e)}</span><span class="ms-check">${s(`check`)}</span></button>`});c&&l.push(`<button type="button" role="option" id="${w(`${o}-opt-${a.length}`)}" class="search-select-option search-select-option-custom" data-value="${w(r)}" data-custom="true" aria-selected="false">Add “${u(r)}”</button>`),t.innerHTML=l.join(``),n&&(n.hidden=a.length>0),this._active=-1,this._combobox()?.removeAttribute(`aria-activedescendant`),this._allowCustom&&this._syncCustomMenu?.(),this._reanchor?.()}_combobox(){return this._allowCustom?this.querySelector(`[data-input]`):this.querySelector(`.search-select-control`)}_setCustomError(e){this._customError=e||``;let t=this.querySelector(`.wui-ms-custom-error`),n=this.querySelector(`[data-input]`);t&&(t.textContent=this._customError,t.hidden=!this._customError),n&&(this._customError?n.setAttribute(`aria-invalid`,`true`):n.removeAttribute(`aria-invalid`)),this._syncInvalid()}_customRefusal(e){let t=this.getAttribute(`custom-invalid-message`)||`Enter a valid value.`,n=this.getAttribute(`custom-pattern`);if(n){let r=C(n);if(r&&!r.test(e))return t}let r=this._validateCustom;if(r){let n=r(e);return n===!0?``:typeof n==`string`&&n?n:t}return``}_commitTyped(e){let t=e.trim().replace(/,+$/,``).trim();if(!t)return``;let n=this._optionNamed(t),r;if(n){if(n.disabled)return n.disabledHint||this.getAttribute(`custom-invalid-message`)||`That option is not available.`;r=String(n.value)}else{let e=this._customRefusal(t);if(e)return e;r=t}let i=r.toLowerCase();return this._values.some(e=>e.toLowerCase()===i)||(this._values=[...this._values,r]),``}_wire(){this._teardown();let e=this.querySelector(`.search-select-control`),s=this.querySelector(`.search-select-menu`),u=this.querySelector(`.search-select-input`),d=this.querySelector(`.search-select-clear`),f=this.querySelector(`.search-select-options`),h=this._allowCustom,_=h?this.querySelector(`[data-input]`):null,v=_||e;if(!e||!s)return;let y=()=>this.hasAttribute(`disabled`),b=()=>r(e,s,{matchWidth:!0}),x=()=>[...this.querySelectorAll(`.search-select-option`)],S=()=>x().filter(e=>!e.hidden),C=(e,{reveal:t=!0}={})=>{let n=S();this._active=e,c(f,e>=0&&n[e]||null),e>=0&&n[e]?(t&&n[e].scrollIntoView({block:`nearest`}),v.setAttribute(`aria-activedescendant`,n[e].id)):v.removeAttribute(`aria-activedescendant`)},w=!1,T=()=>h?w:!s.hidden,E=()=>{let t=w&&x().length>0,n=s.hidden;s.hidden=!t,v.setAttribute(`aria-expanded`,String(t)),e.classList.toggle(`open`,t),t&&n&&b()};this._syncCustomMenu=h?E:null;let D=()=>{T()&&b()},O=()=>{if(!y()){if(t(this,D),h){w=!0,E();return}s.hidden=!1,e.setAttribute(`aria-expanded`,`true`),e.classList.add(`open`),b(),u&&(u.value=``,this._renderOptions(``),u.focus())}},k=()=>{h?(w=!1,E()):(s.hidden=!0,e.setAttribute(`aria-expanded`,`false`),e.classList.remove(`open`)),C(-1),clearTimeout(this._typeaheadTimer),this._typeaheadTimer=null,this._typeahead=``,n(this)},A=()=>{o(this,this._values),this.dispatchEvent(new Event(`change`,{bubbles:!0}))},j=e=>{let t=String(e);if(this._values.includes(t))this._values=this._values.filter(e=>e!==t);else if(h&&this._values.some(e=>e.toLowerCase()===t.toLowerCase()))return;else this._values=[...this._values,t];this._renderControl(),this._renderOptions(this._query()),A()},M=e=>{this._values=this._values.filter(t=>t!==String(e)),this._renderControl(),this._renderOptions(this._query()),A()},N=(e,{quiet:t=!1}={})=>{let n=this._values.length,r=m(e,g)?p(e,g):[e],i=[],a=``;for(let e of r){let t=this._commitTyped(e);t&&(i.push(e.trim()),a||=t)}t&&i.length||(_.value=i.join(`, `),this._setCustomError(a),this._values.length!==n&&(this._renderControl(),A()),this._renderOptions(_.value))},P=e=>{if(!(!e||e.getAttribute(`aria-disabled`)===`true`)){if(e.dataset.custom===`true`){N(e.dataset.value);return}j(e.dataset.value),_?.value&&(_.value=``,this._setCustomError(``),this._renderOptions(``))}};e.addEventListener(`click`,e=>{if(y())return;let t=e.target.closest(`[data-remove]`);if(t){e.stopPropagation(),M(t.dataset.remove),_?.focus();return}if(_){let t=T();e.target!==_&&_.focus(),e.target===_||!t?O():k();return}T()?k():O()}),f.addEventListener(`click`,e=>{let t=e.target.closest(`.search-select-option`);t&&(P(t),(_||u)?.focus())}),f.addEventListener(`mousemove`,e=>{let t=e.target.closest(`.search-select-option`);t&&!t.classList.contains(`is-active`)&&C(S().indexOf(t),{reveal:!1})}),f.addEventListener(`mouseleave`,()=>C(-1)),f.addEventListener(`error`,e=>{e.target?.classList?.contains(`avatar-img`)&&e.target.remove()},!0),u?.addEventListener(`input`,()=>{this._renderOptions(u.value),d&&(d.hidden=!u.value),C(-1)}),this._navHandler=l({getVisibleOptions:S,getActive:()=>this._active,setActive:e=>C(e),onEnter:e=>{e?P(e):_?.value.trim()&&N(_.value)},onEscape:()=>{this._navHandler.clearTypeahead(),k(),_||e.focus()}});let F=e=>{let t=_||u;if(e.key===`Backspace`&&!t?.value&&this._values.length){M(this._values[this._values.length-1]);return}this._navHandler.handler(e)};if(u?.addEventListener(`keydown`,F),d?.addEventListener(`click`,()=>{u.value=``,this._renderOptions(``),d.hidden=!0,u.focus()}),_){let t=e=>{e.target!==_&&e.preventDefault()};f.addEventListener(`mousedown`,t),e.addEventListener(`mousedown`,t),i(),_.addEventListener(`focus`,()=>{a()&&O()}),_.addEventListener(`input`,()=>{this._customError&&this._setCustomError(``),this._renderOptions(_.value),O()}),_.addEventListener(`keydown`,e=>{if(e.key===`,`&&_.value.trim()){e.preventDefault(),N(_.value);return}if(e.key===`Enter`){if(this._active<0&&!_.value.trim())return;this._navHandler.handler(e);return}(e.key===`ArrowDown`||e.key===`ArrowUp`)&&!T()&&O(),F(e)}),_.addEventListener(`paste`,e=>{let t=e.clipboardData?.getData(`text/plain`)??``;m(t,g)&&(e.preventDefault(),N(`${_.value}${t}`))}),_.addEventListener(`blur`,e=>{e.relatedTarget&&this.contains(e.relatedTarget)||(_.value.trim()&&N(_.value,{quiet:!0}),k())})}else e.addEventListener(`keydown`,e=>{if(T()){F(e);return}(e.key===`ArrowDown`||e.key===`Enter`||e.key===` `)&&(e.preventDefault(),O())});this._bindGlobal=()=>{this._teardown(),!this._ro&&typeof ResizeObserver<`u`&&(this._ro=new ResizeObserver(()=>this._collapseChips()),this._ro.observe(this)),this._onDocClick=e=>{T()&&!this.contains(e.target)&&k()},document.addEventListener(`click`,this._onDocClick),T()&&t(this,D)},this._bindGlobal()}_teardown(){this._onDocClick&&=(document.removeEventListener(`click`,this._onDocClick),null),n(this),this._navHandler?.teardown()}disconnectedCallback(){this._teardown(),this._ro?.disconnect(),this._ro=null}},g=[`,`,`;`,`
25
+ `,` `],_=[[`description`,`description`],[`avatar`,`avatar`],[`initials`,`initials`],[`disabled-hint`,`disabledHint`]],v=e=>!!(e.description||e.avatar||e.initials||e.disabled||e.disabledHint),y=e=>{let t=String(e??``).trim();return/^(https?:)?\/\//i.test(t)||/^\/(?!\/)/.test(t)||/^data:image\/(png|jpe?g|gif|webp|avif);/i.test(t)?t:``},b=e=>{let t=y(e.avatar);return!t&&!e.initials?``:`<span class="avatar wui-opt-avatar" aria-hidden="true"><span class="avatar-face">${u(e.initials??``)}</span>${t?`<img class="avatar-img" src="${w(t)}" alt="" />`:``}</span>`},x=(e,t,n)=>{let r=!!e.disabled,i=e.description?`<span class="wui-opt-desc">${u(e.description)}</span>`:``,a=e.disabledHint&&r?`<span class="wui-opt-hint">${u(e.disabledHint)}</span>`:``;return`<button type="button" role="option" id="${w(t)}" class="search-select-option wui-opt-rich${n?` selected`:``}" data-value="${w(e.value)}" aria-selected="${n}"${r?` aria-disabled="true"`:``}><span class="ms-opt-label"><span class="wui-opt-name">${d(e)}</span>${i}</span>${a}${b(e)}<span class="ms-check">${s(`check`)}</span></button>`},S=new Map,C=e=>{if(S.has(e))return S.get(e);let t=null;try{t=RegExp(`^(?:${e})$`,`u`)}catch{console.warn(`<wui-multiselect> custom-pattern is not a valid regular expression and is ignored: ${e}`)}return S.set(e,t),t},w=e=>String(e??``).replace(/&/g,`&amp;`).replace(/"/g,`&quot;`).replace(/</g,`&lt;`),T=e=>String(e??``).replace(/<[^>]*>/g,``);export{h as t};
@@ -0,0 +1,14 @@
1
+ import{t as e}from"./elementBase-BlsR4tqa.js";import{t}from"./formMirror-BgY7zkC3.js";var n=/[^0-9]/g,r=/[^0-9a-zA-Z]/g,i=class extends e{static formAssociated=!0;static get observedAttributes(){return[`value`,`length`,`mode`,`disabled`,`aria-label`]}get length(){let e=Number.parseInt(this.getAttribute(`length`)??`6`,10);return Number.isFinite(e)&&e>0?e:6}set length(e){this.setAttribute(`length`,String(e))}get mode(){return this.getAttribute(`mode`)===`alphanumeric`?`alphanumeric`:`numeric`}set mode(e){this.setAttribute(`mode`,String(e??`numeric`))}get value(){return this._value??``}set value(e){this._value=this._clean(e),t(this,this._value),this._paint()}_clean(e){return(e==null?``:String(e)).replace(this.mode===`alphanumeric`?r:n,``).slice(0,this.length)}constructor(){super();try{this._internals=this.attachInternals()}catch{this._internals=null}}connectedCallback(){this._rendered?this._onSelectionChange&&document.addEventListener(`selectionchange`,this._onSelectionChange):(this._defaultCaptured||=(this._defaultValue=this._value,!0),this.render())}formResetCallback(){this._value=this._defaultValue||``,t(this,this._value),this._paint()}attributeChangedCallback(e,n,r){this._rendered&&(e===`value`?(this._value=this._clean(r),t(this,this._value),this._paint()):this.render())}render(){this._value=this._clean(this.getAttribute(`value`)??this._value);let e=this.length,n=this.mode===`numeric`,r=this.hasAttribute(`disabled`),i=Array.from({length:e},()=>`<span class="otp-slot" aria-hidden="true"></span>`).join(``),a=this.getAttribute(`aria-label`),o=a?` aria-label="${a.replace(/"/g,`&quot;`)}"`:``;this.innerHTML=`
2
+ <div class="otp">
3
+ <input
4
+ class="otp-field"
5
+ type="text"
6
+ autocomplete="one-time-code"
7
+ inputmode="${n?`numeric`:`text`}"
8
+ ${n?`pattern="[0-9]*"`:``}${o}
9
+ autocapitalize="off"
10
+ autocorrect="off"
11
+ spellcheck="false"
12
+ ${r?`disabled`:``} />
13
+ <div class="otp-slots" aria-hidden="true">${i}</div>
14
+ </div>`,this._rendered=!0,t(this,this._value),this._wire(),this._paint()}_refs(){return{input:this.querySelector(`.otp-field`),slots:[...this.querySelectorAll(`.otp-slot`)]}}_paint(){let{input:e,slots:t}=this._refs();if(!e||!t.length)return;e.value!==this._value&&(e.value=this._value);let n=e.selectionStart??this._value.length,r=Math.min(n,t.length-1),i=document.activeElement===e;t.forEach((e,t)=>{e.textContent=this._value[t]??``,e.classList.toggle(`filled`,!!this._value[t]),e.classList.toggle(`active`,i&&t===r)})}_wire(){let{input:e}=this._refs();if(!e)return;let n=e=>{let n=this._clean(e),r=n!==this._value;this._value=n,t(this,this._value),this._paint(),r&&this.dispatchEvent(new Event(`change`,{bubbles:!0})),r&&n.length===this.length&&this.dispatchEvent(new CustomEvent(`complete`,{bubbles:!0,detail:n}))};e.addEventListener(`input`,()=>{let t=e.value;if(this._value.length===this.length&&t.length>this._value.length&&t.startsWith(this._value)){let e=this._clean(t.slice(this._value.length));if(e){n(e);return}}n(t)}),e.addEventListener(`paste`,e=>{let t=e.clipboardData?.getData(`text`);t!=null&&(e.preventDefault(),n(t))});for(let t of[`keyup`,`click`,`blur`,`select`])e.addEventListener(t,()=>this._paint());e.addEventListener(`focus`,()=>{this._value.length===this.length&&e.select(),this._paint()}),this._onSelectionChange&&document.removeEventListener(`selectionchange`,this._onSelectionChange),this._onSelectionChange=()=>{document.activeElement===e&&this._paint()},document.addEventListener(`selectionchange`,this._onSelectionChange)}disconnectedCallback(){this._onSelectionChange&&document.removeEventListener(`selectionchange`,this._onSelectionChange)}};export{i as t};
@@ -0,0 +1,15 @@
1
+ import{t as e}from"./elementBase-BlsR4tqa.js";import{n as t,r as n,t as r}from"./anchorOverlay-WcDeH46q.js";import{t as i}from"./formMirror-BgY7zkC3.js";import{t as a}from"./iconGlyphs.g-CUm_mfze.js";import{n as o}from"./listboxKeyNav-DMIvs9d6.js";import{n as s,t as c}from"./countries-CvmZ2xpG.js";var l={AD:[`Europe/Andorra`],AE:[`Asia/Dubai`],AF:[`Asia/Kabul`],AG:[`America/Antigua`],AI:[`America/Anguilla`],AL:[`Europe/Tirane`],AM:[`Asia/Yerevan`],AO:[`Africa/Luanda`],AR:[`America/Argentina/Buenos_Aires`,`America/Argentina/Catamarca`,`America/Argentina/ComodRivadavia`,`America/Argentina/Cordoba`,`America/Argentina/Jujuy`,`America/Argentina/La_Rioja`,`America/Argentina/Mendoza`,`America/Argentina/Rio_Gallegos`,`America/Argentina/Salta`,`America/Argentina/San_Juan`,`America/Argentina/San_Luis`,`America/Argentina/Tucuman`,`America/Argentina/Ushuaia`,`America/Buenos_Aires`,`America/Catamarca`,`America/Cordoba`,`America/Jujuy`,`America/Mendoza`,`America/Rosario`],AS:[`Pacific/Pago_Pago`,`Pacific/Samoa`,`US/Samoa`],AT:[`Europe/Vienna`],AU:[`Antarctica/Macquarie`,`Australia/Adelaide`,`Australia/Brisbane`,`Australia/Broken_Hill`,`Australia/Canberra`,`Australia/Currie`,`Australia/Darwin`,`Australia/Eucla`,`Australia/Hobart`,`Australia/LHI`,`Australia/Lindeman`,`Australia/Lord_Howe`,`Australia/Melbourne`,`Australia/NSW`,`Australia/North`,`Australia/Perth`,`Australia/Queensland`,`Australia/South`,`Australia/Sydney`,`Australia/Tasmania`,`Australia/Victoria`,`Australia/West`,`Australia/Yancowinna`],AW:[`America/Aruba`],AX:[`Europe/Mariehamn`],AZ:[`Asia/Baku`],BA:[`Europe/Sarajevo`],BB:[`America/Barbados`],BD:[`Asia/Dacca`,`Asia/Dhaka`],BE:[`Europe/Brussels`],BF:[`Africa/Ouagadougou`],BG:[`Europe/Sofia`],BH:[`Asia/Bahrain`],BI:[`Africa/Bujumbura`],BJ:[`Africa/Porto-Novo`],BL:[`America/St_Barthelemy`],BM:[`Atlantic/Bermuda`],BN:[`Asia/Brunei`],BO:[`America/La_Paz`],BQ:[`America/Kralendijk`],BR:[`America/Araguaina`,`America/Bahia`,`America/Belem`,`America/Boa_Vista`,`America/Campo_Grande`,`America/Cuiaba`,`America/Eirunepe`,`America/Fortaleza`,`America/Maceio`,`America/Manaus`,`America/Noronha`,`America/Porto_Acre`,`America/Porto_Velho`,`America/Recife`,`America/Rio_Branco`,`America/Santarem`,`America/Sao_Paulo`,`Brazil/DeNoronha`,`Brazil/East`,`Brazil/West`],BS:[`America/Nassau`],BT:[`Asia/Thimbu`,`Asia/Thimphu`],BW:[`Africa/Gaborone`],BY:[`Europe/Minsk`],BZ:[`America/Belize`],CA:`America/Atikokan.America/Blanc-Sablon.America/Cambridge_Bay.America/Coral_Harbour.America/Creston.America/Dawson.America/Dawson_Creek.America/Edmonton.America/Fort_Nelson.America/Glace_Bay.America/Goose_Bay.America/Halifax.America/Inuvik.America/Iqaluit.America/Moncton.America/Montreal.America/Nipigon.America/Pangnirtung.America/Rainy_River.America/Rankin_Inlet.America/Regina.America/Resolute.America/St_Johns.America/Swift_Current.America/Thunder_Bay.America/Toronto.America/Vancouver.America/Whitehorse.America/Winnipeg.America/Yellowknife.Canada/Atlantic.Canada/Central.Canada/Eastern.Canada/Mountain.Canada/Newfoundland.Canada/Pacific.Canada/Saskatchewan.Canada/Yukon`.split(`.`),CC:[`Indian/Cocos`],CD:[`Africa/Kinshasa`,`Africa/Lubumbashi`],CF:[`Africa/Bangui`],CG:[`Africa/Brazzaville`],CH:[`Europe/Zurich`],CI:[`Africa/Abidjan`],CK:[`Pacific/Rarotonga`],CL:[`America/Coyhaique`,`America/Punta_Arenas`,`America/Santiago`,`Chile/Continental`,`Chile/EasterIsland`,`Pacific/Easter`],CM:[`Africa/Douala`],CN:[`Asia/Chongqing`,`Asia/Harbin`,`Asia/Kashgar`,`Asia/Shanghai`,`Asia/Urumqi`],CO:[`America/Bogota`],CR:[`America/Costa_Rica`],CU:[`America/Havana`],CV:[`Atlantic/Cape_Verde`],CW:[`America/Curacao`],CX:[`Indian/Christmas`],CY:[`Asia/Famagusta`,`Asia/Nicosia`,`Europe/Nicosia`],CZ:[`Europe/Prague`],DE:[`Europe/Berlin`,`Europe/Busingen`],DJ:[`Africa/Djibouti`],DK:[`Europe/Copenhagen`],DM:[`America/Dominica`],DO:[`America/Santo_Domingo`],DZ:[`Africa/Algiers`],EC:[`America/Guayaquil`,`Pacific/Galapagos`],EE:[`Europe/Tallinn`],EG:[`Africa/Cairo`],EH:[`Africa/El_Aaiun`],ER:[`Africa/Asmara`,`Africa/Asmera`],ES:[`Africa/Ceuta`,`Atlantic/Canary`,`Europe/Madrid`],ET:[`Africa/Addis_Ababa`],FI:[`Europe/Helsinki`],FJ:[`Pacific/Fiji`],FK:[`Atlantic/Stanley`],FM:[`Pacific/Chuuk`,`Pacific/Kosrae`,`Pacific/Pohnpei`,`Pacific/Ponape`,`Pacific/Truk`,`Pacific/Yap`],FO:[`Atlantic/Faeroe`,`Atlantic/Faroe`],FR:[`Europe/Paris`],GA:[`Africa/Libreville`],GB:[`Europe/Belfast`,`Europe/London`],GD:[`America/Grenada`],GE:[`Asia/Tbilisi`],GF:[`America/Cayenne`],GG:[`Europe/Guernsey`],GH:[`Africa/Accra`],GI:[`Europe/Gibraltar`],GL:[`America/Danmarkshavn`,`America/Godthab`,`America/Nuuk`,`America/Scoresbysund`,`America/Thule`],GM:[`Africa/Banjul`],GN:[`Africa/Conakry`],GP:[`America/Guadeloupe`],GQ:[`Africa/Malabo`],GR:[`Europe/Athens`],GT:[`America/Guatemala`],GU:[`Pacific/Guam`],GW:[`Africa/Bissau`],GY:[`America/Guyana`],HK:[`Asia/Hong_Kong`],HN:[`America/Tegucigalpa`],HR:[`Europe/Zagreb`],HT:[`America/Port-au-Prince`],HU:[`Europe/Budapest`],ID:[`Asia/Jakarta`,`Asia/Jayapura`,`Asia/Makassar`,`Asia/Pontianak`,`Asia/Ujung_Pandang`],IE:[`Europe/Dublin`],IL:[`Asia/Jerusalem`,`Asia/Tel_Aviv`],IM:[`Europe/Isle_of_Man`],IN:[`Asia/Calcutta`,`Asia/Kolkata`],IO:[`Indian/Chagos`],IQ:[`Asia/Baghdad`],IR:[`Asia/Tehran`],IS:[`Atlantic/Reykjavik`],IT:[`Europe/Rome`],JE:[`Europe/Jersey`],JM:[`America/Jamaica`],JO:[`Asia/Amman`],JP:[`Asia/Tokyo`],KE:[`Africa/Nairobi`],KG:[`Asia/Bishkek`],KH:[`Asia/Phnom_Penh`],KI:[`Pacific/Enderbury`,`Pacific/Kanton`,`Pacific/Kiritimati`,`Pacific/Tarawa`],KM:[`Indian/Comoro`],KN:[`America/St_Kitts`],KP:[`Asia/Pyongyang`],KR:[`Asia/Seoul`],KW:[`Asia/Kuwait`],KY:[`America/Cayman`],KZ:[`Asia/Almaty`,`Asia/Aqtau`,`Asia/Aqtobe`,`Asia/Atyrau`,`Asia/Oral`,`Asia/Qostanay`,`Asia/Qyzylorda`],LA:[`Asia/Vientiane`],LB:[`Asia/Beirut`],LC:[`America/St_Lucia`],LI:[`Europe/Vaduz`],LK:[`Asia/Colombo`],LR:[`Africa/Monrovia`],LS:[`Africa/Maseru`],LT:[`Europe/Vilnius`],LU:[`Europe/Luxembourg`],LV:[`Europe/Riga`],LY:[`Africa/Tripoli`],MA:[`Africa/Casablanca`],MC:[`Europe/Monaco`],MD:[`Europe/Chisinau`,`Europe/Tiraspol`],ME:[`Europe/Podgorica`],MF:[`America/Marigot`],MG:[`Indian/Antananarivo`],MH:[`Pacific/Kwajalein`,`Pacific/Majuro`],MK:[`Europe/Skopje`],ML:[`Africa/Bamako`,`Africa/Timbuktu`],MM:[`Asia/Rangoon`,`Asia/Yangon`],MN:[`Asia/Choibalsan`,`Asia/Hovd`,`Asia/Ulaanbaatar`,`Asia/Ulan_Bator`],MO:[`Asia/Macao`,`Asia/Macau`],MP:[`Pacific/Saipan`],MQ:[`America/Martinique`],MR:[`Africa/Nouakchott`],MS:[`America/Montserrat`],MT:[`Europe/Malta`],MU:[`Indian/Mauritius`],MV:[`Indian/Maldives`],MW:[`Africa/Blantyre`],MX:[`America/Bahia_Banderas`,`America/Cancun`,`America/Chihuahua`,`America/Ciudad_Juarez`,`America/Ensenada`,`America/Hermosillo`,`America/Matamoros`,`America/Mazatlan`,`America/Merida`,`America/Mexico_City`,`America/Monterrey`,`America/Ojinaga`,`America/Santa_Isabel`,`America/Tijuana`,`Mexico/BajaNorte`,`Mexico/BajaSur`,`Mexico/General`],MY:[`Asia/Kuala_Lumpur`,`Asia/Kuching`],MZ:[`Africa/Maputo`],NA:[`Africa/Windhoek`],NC:[`Pacific/Noumea`],NE:[`Africa/Niamey`],NF:[`Pacific/Norfolk`],NG:[`Africa/Lagos`],NI:[`America/Managua`],NL:[`Europe/Amsterdam`],NO:[`Europe/Oslo`],NP:[`Asia/Kathmandu`,`Asia/Katmandu`],NR:[`Pacific/Nauru`],NU:[`Pacific/Niue`],NZ:[`Pacific/Auckland`,`Pacific/Chatham`],OM:[`Asia/Muscat`],PA:[`America/Panama`],PE:[`America/Lima`],PF:[`Pacific/Gambier`,`Pacific/Marquesas`,`Pacific/Tahiti`],PG:[`Pacific/Bougainville`,`Pacific/Port_Moresby`],PH:[`Asia/Manila`],PK:[`Asia/Karachi`],PL:[`Europe/Warsaw`],PM:[`America/Miquelon`],PR:[`America/Puerto_Rico`],PS:[`Asia/Gaza`,`Asia/Hebron`],PT:[`Atlantic/Azores`,`Atlantic/Madeira`,`Europe/Lisbon`],PW:[`Pacific/Palau`],PY:[`America/Asuncion`],QA:[`Asia/Qatar`],RE:[`Indian/Reunion`],RO:[`Europe/Bucharest`],RS:[`Europe/Belgrade`],RU:`Asia/Anadyr.Asia/Barnaul.Asia/Chita.Asia/Irkutsk.Asia/Kamchatka.Asia/Khandyga.Asia/Krasnoyarsk.Asia/Magadan.Asia/Novokuznetsk.Asia/Novosibirsk.Asia/Omsk.Asia/Sakhalin.Asia/Srednekolymsk.Asia/Tomsk.Asia/Ust-Nera.Asia/Vladivostok.Asia/Yakutsk.Asia/Yekaterinburg.Europe/Astrakhan.Europe/Kaliningrad.Europe/Kirov.Europe/Moscow.Europe/Samara.Europe/Saratov.Europe/Ulyanovsk.Europe/Volgograd`.split(`.`),RW:[`Africa/Kigali`],SA:[`Asia/Riyadh`],SB:[`Pacific/Guadalcanal`],SC:[`Indian/Mahe`],SD:[`Africa/Khartoum`],SE:[`Europe/Stockholm`],SG:[`Asia/Singapore`],SH:[`Atlantic/St_Helena`],SI:[`Europe/Ljubljana`],SJ:[`Arctic/Longyearbyen`,`Atlantic/Jan_Mayen`],SK:[`Europe/Bratislava`],SL:[`Africa/Freetown`],SM:[`Europe/San_Marino`],SN:[`Africa/Dakar`],SO:[`Africa/Mogadishu`],SR:[`America/Paramaribo`],SS:[`Africa/Juba`],ST:[`Africa/Sao_Tome`],SV:[`America/El_Salvador`],SX:[`America/Lower_Princes`],SY:[`Asia/Damascus`],SZ:[`Africa/Mbabane`],TC:[`America/Grand_Turk`],TD:[`Africa/Ndjamena`],TG:[`Africa/Lome`],TH:[`Asia/Bangkok`],TJ:[`Asia/Dushanbe`],TK:[`Pacific/Fakaofo`],TL:[`Asia/Dili`],TM:[`Asia/Ashgabat`,`Asia/Ashkhabad`],TN:[`Africa/Tunis`],TO:[`Pacific/Tongatapu`],TR:[`Asia/Istanbul`,`Europe/Istanbul`],TT:[`America/Port_of_Spain`],TV:[`Pacific/Funafuti`],TW:[`Asia/Taipei`],TZ:[`Africa/Dar_es_Salaam`],UA:[`Europe/Kiev`,`Europe/Kyiv`,`Europe/Simferopol`,`Europe/Uzhgorod`,`Europe/Zaporozhye`],UG:[`Africa/Kampala`],US:`America/Adak.America/Anchorage.America/Atka.America/Boise.America/Chicago.America/Denver.America/Detroit.America/Fort_Wayne.America/Indiana/Indianapolis.America/Indiana/Knox.America/Indiana/Marengo.America/Indiana/Petersburg.America/Indiana/Tell_City.America/Indiana/Vevay.America/Indiana/Vincennes.America/Indiana/Winamac.America/Indianapolis.America/Juneau.America/Kentucky/Louisville.America/Kentucky/Monticello.America/Knox_IN.America/Los_Angeles.America/Louisville.America/Menominee.America/Metlakatla.America/New_York.America/Nome.America/North_Dakota/Beulah.America/North_Dakota/Center.America/North_Dakota/New_Salem.America/Phoenix.America/Shiprock.America/Sitka.America/Yakutat.Pacific/Honolulu.US/Alaska.US/Aleutian.US/Arizona.US/Central.US/East-Indiana.US/Eastern.US/Hawaii.US/Indiana-Starke.US/Michigan.US/Mountain.US/Pacific`.split(`.`),UY:[`America/Montevideo`],UZ:[`Asia/Samarkand`,`Asia/Tashkent`],VA:[`Europe/Vatican`],VC:[`America/St_Vincent`],VE:[`America/Caracas`],VG:[`America/Tortola`],VI:[`America/St_Thomas`,`America/Virgin`],VN:[`Asia/Ho_Chi_Minh`,`Asia/Saigon`],VU:[`Pacific/Efate`],WF:[`Pacific/Wallis`],WS:[`Pacific/Apia`],YE:[`Asia/Aden`],YT:[`Indian/Mayotte`],ZA:[`Africa/Johannesburg`],ZM:[`Africa/Lusaka`],ZW:[`Africa/Harare`]},u=new Set(c.map(([e])=>e)),d=new Map;for(let[e,t]of Object.entries(l))for(let n of t)d.set(n,e);function f(e){let t=d.get(e);return t&&u.has(t)?t:null}function p(e){if(!e)return null;let t;try{t=new Intl.Locale(e).region}catch{return null}return t&&u.has(t)?t:null}function m(){let e;try{e=Intl.DateTimeFormat().resolvedOptions().timeZone}catch{e=void 0}let t=typeof navigator>`u`?void 0:navigator.language;return f(e)||p(t)||`IN`}function h(){return Promise.all([import(`./max-CNrKnpEj.js`),import(`./examples.mobile.json-GS1_MGh9.js`)]).then(([e,t])=>g(e,t.default||t))}function g(e,t){return{AsYouType:e.AsYouType,getExampleNumber:e.getExampleNumber,isValidPhoneNumber:e.isValidPhoneNumber,parsePhoneNumber:e.parsePhoneNumber,examples:t}}var _=e=>`wui-flag wui-flag-${String(e).toLowerCase()}`,v=null,y=null;function b(){return v?Promise.resolve(v):(y||=h().then(e=>(v=e,v)).catch(()=>null),y)}function x(e,t){let n=`+${s(e)}`;return t?.startsWith(n)?t.slice(n.length).trimStart():null}function S(e,t){if(!v||!t)return t;try{return x(e,new v.AsYouType(e).input(`+${s(e)}${t}`))||t}catch{return t}}function C(e,t){if(t<=0)return 0;let n=0;for(let r=0;r<e.length;r++)if(/[0-9]/.test(e[r])&&(n+=1,n===t))return r+1;return e.length}function w(e){if(!v)return null;try{return x(e,v.getExampleNumber(e,v.examples)?.formatInternational())||null}catch{return null}}function T(e){if(!v||!e)return null;try{if(!v.isValidPhoneNumber(e))return!1;let t=v.parsePhoneNumber(e)?.getType?.();return t===void 0||t===`MOBILE`||t===`FIXED_LINE_OR_MOBILE`}catch{return null}}function E(e){if(!v)return null;try{let t=v.getExampleNumber(e,v.examples);return t?.nationalNumber?t.nationalNumber.length:null}catch{return null}}function D(e,t,n){try{let r=v.parsePhoneNumber(t,e),i=r?.nationalNumber;return!i||r.country!==e||i.length>n||!t.endsWith(i)?null:i}catch{return null}}function O(e){if(!v||!e?.trim().startsWith(`+`))return null;try{let t=new v.AsYouType;t.input(e.trim());let n=t.getCountry();return n?{country:n,national:t.getNationalNumber()||``}:null}catch{return null}}var k=class extends e{static formAssociated=!0;static get observedAttributes(){return[`value`,`country`,`placeholder`,`disabled`,`required`,`aria-label`,`aria-describedby`]}constructor(){super();try{this._internals=this.attachInternals()}catch{this._internals=null}this._defaultCountry=m(),this._country=this._defaultCountry,this._national=``,this._active=-1,this._committedValue=``}connectedCallback(){if(!this._rendered){this.render();return}this._bindGlobal?.()}attributeChangedCallback(e,t,n){if(e===`value`){this.value=n;return}if(this._rendered){if(e===`aria-label`){let t=this.querySelector(`input[type=tel]`);t&&(n==null?t.removeAttribute(e):t.setAttribute(e,n));return}if(e===`aria-describedby`){this._syncDescribedBy();return}e===`country`&&(this._country=n||this._defaultCountry,this._suppressCountryRender)||this.render()}}formResetCallback(){this.value=this._defaultValue||``}get value(){return this._national?`+${s(this._country)}${this._national}`:``}set value(e){let t=String(e??``).trim(),n=O(t);if(n)this._country=n.country,this._national=n.national.replace(/[^0-9]/g,``);else if(t.startsWith(`+`)){let e=t.replace(/[^0-9]/g,``),n=String(s(this._country));n&&e.startsWith(n)&&(e=e.slice(n.length)),this._national=e}else this._national=t.replace(/[^0-9]/g,``);n&&this.getAttribute(`country`)!==this._country?this.setAttribute(`country`,this._country):this._rendered&&this.render(),this._committedValue=this.value,this._syncMirror()}_syncMirror(){i(this,this.value)}_syncDescribedBy(){let e=this.querySelector(`input[type=tel]`);if(!e)return;let t=[this.getAttribute(`aria-describedby`),this.querySelector(`[data-phone-error]`)?.id].filter(Boolean);t.length?e.setAttribute(`aria-describedby`,t.join(` `)):e.removeAttribute(`aria-describedby`)}_emitInput(){this.dispatchEvent(new Event(`input`,{bubbles:!0}))}_emitChange(){this._committedValue=this.value,this.dispatchEvent(new Event(`change`,{bubbles:!0}))}render(){this._defaultValue===void 0&&(this._defaultValue=this.getAttribute(`value`)||``),this._country=this.getAttribute(`country`)||this._country;let e=this.getAttribute(`placeholder`)||w(this._country)||`Enter phone number`;this.id||=`wui-phone-${Math.random().toString(36).slice(2,9)}`;let t=`${this.id}-listbox`;this._listboxId=t,this.innerHTML=`
2
+ <div class="phone-input-wrap">
3
+ <div class="phone-country-adornment">
4
+ <button type="button" class="country-toggle" aria-label="Choose country" aria-haspopup="listbox" aria-expanded="false" aria-controls="${A(t)}"${this.hasAttribute(`disabled`)?` disabled`:``}>
5
+ <span class="${_(this._country)}" data-flag aria-hidden="true"></span>
6
+ ${a(`chevron-down`,{className:`phone-chevron`})}
7
+ <span class="phone-dial" data-dial>+${s(this._country)}</span>
8
+ </button>
9
+ <div class="country-dropdown-menu" role="listbox" id="${A(t)}" tabindex="-1" hidden>
10
+ <div class="dropdown-search-wrapper"><span class="dropdown-search-icon">${a(`search`)}</span><input type="text" class="dropdown-search-input" placeholder="Search country or code" aria-label="Search countries" aria-controls="${A(t)}" aria-autocomplete="list" /></div>
11
+ <div class="country-list-scroll"><div class="country-empty" hidden>No countries found</div></div>
12
+ </div>
13
+ </div>
14
+ <input type="tel" class="input" placeholder="${A(e)}" value="${A(S(this._country,this._national))}"${this.getAttribute(`aria-label`)?` aria-label="${A(this.getAttribute(`aria-label`))}"`:``}${this.getAttribute(`aria-describedby`)?` aria-describedby="${A(this.getAttribute(`aria-describedby`))}"`:``}${this.hasAttribute(`required`)?` required aria-required="true"`:``}${this.hasAttribute(`disabled`)?` disabled`:``} />
15
+ </div>`,this._rendered=!0,i(this,this.value),this._wire()}_ensureItems(){let e=this.querySelector(`.country-list-scroll`);if(!e||e.querySelector(`.country-dropdown-item`))return;let t=this._listboxId,n=c.map(([e,n,r],i)=>`<button type="button" role="option" id="${A(`${t}-opt-${i}`)}" class="country-dropdown-item${e===this._country?` selected`:``}" data-iso="${e}" aria-selected="${e===this._country}"><span class="${_(e)}" aria-hidden="true"></span><span class="country-name-text">${n}<span class="country-code-text">+${r}</span></span></button>`).join(``);e.insertAdjacentHTML(`afterbegin`,n)}_itemEls(){return[...this.querySelectorAll(`.country-dropdown-item`)]}_visibleItems(){return this._itemEls().filter(e=>!e.hidden)}_wire(){this._teardown();let e=this.querySelector(`.country-toggle`),i=this.querySelector(`.phone-input-wrap`),a=this.querySelector(`.country-dropdown-menu`),c=this.querySelector(`.dropdown-search-input`),l=this.querySelector(`.country-list-scroll`),u=this.querySelector(`.country-empty`),d=this.querySelector(`input[type=tel]`),f=this.querySelector(`[data-flag]`),p=this.querySelector(`[data-dial]`);if(!e||!a)return;let m=()=>!a.hidden,h=()=>r(i||e,a),g=(e,{reveal:t=!0}={})=>{let n=this._visibleItems();this._active=e,o(l,e>=0&&n[e]||null),e>=0&&n[e]?(t&&n[e].scrollIntoView({block:`nearest`}),c?.setAttribute(`aria-activedescendant`,n[e].id)):c?.removeAttribute(`aria-activedescendant`)},v=()=>{m()&&h()},y=()=>{this._ensureItems(),a.hidden=!1,e.setAttribute(`aria-expanded`,`true`),c.value=``,k(``),h(),t(this,v),c.focus(),g(this._visibleItems().findIndex(e=>e.classList.contains(`selected`)))},x=()=>{a.hidden=!0,e.setAttribute(`aria-expanded`,`false`),g(-1),n(this)},k=e=>{let t=e.trim().toLowerCase(),n=0;for(let e of this._itemEls()){let r=!t||e.textContent.toLowerCase().includes(t);e.hidden=!r,r&&(n+=1)}u&&(u.hidden=n>0)},A=e=>{this._country=e,this.getAttribute(`country`)!==e&&(this._suppressCountryRender=!0,this.setAttribute(`country`,e),this._suppressCountryRender=!1),f&&(f.className=_(e)),p&&(p.textContent=`+${s(e)}`);for(let t of this._itemEls()){let n=t.dataset.iso===e;t.classList.toggle(`selected`,n),t.setAttribute(`aria-selected`,String(n))}!this.getAttribute(`placeholder`)&&d&&(d.placeholder=w(e)||`Enter phone number`),d&&this._national&&(d.value=S(e,this._national)),x(),this._syncMirror(),this._emitChange(),d?.focus()},j=t=>{let n=this._visibleItems();if(t.key===`ArrowDown`){if(t.preventDefault(),!m()){y();return}g(Math.min(this._active+1,n.length-1))}else if(t.key===`ArrowUp`){if(t.preventDefault(),!m())return;g(Math.max(this._active-1,0))}else t.key===`Enter`?(t.preventDefault(),m()&&n[this._active]&&A(n[this._active].dataset.iso)):t.key===`Escape`&&m()&&(t.preventDefault(),x(),e.focus())};e.addEventListener(`click`,()=>m()?x():y()),e.addEventListener(`keydown`,e=>{if(m()){j(e);return}(e.key===`ArrowDown`||e.key===`Enter`||e.key===` `)&&(e.preventDefault(),y())}),c.addEventListener(`input`,()=>{k(c.value);let e=this._visibleItems();g(e.length?0:-1)}),l.addEventListener(`click`,e=>{let t=e.target.closest(`.country-dropdown-item`);t&&A(t.dataset.iso)}),l.addEventListener(`mousemove`,e=>{let t=e.target.closest(`.country-dropdown-item`);t&&!t.classList.contains(`is-active`)&&g(this._visibleItems().indexOf(t),{reveal:!1})}),l.addEventListener(`mouseleave`,()=>g(-1)),a.addEventListener(`keydown`,j);let M=e=>{d.classList.toggle(`is-invalid`,e),e?d.setAttribute(`aria-invalid`,`true`):d.removeAttribute(`aria-invalid`);let t=this.querySelector(`[data-phone-error]`);if(e){t||(t=document.createElement(`div`),t.className=`field-error`,t.id=`${this.id}-phone-error`,t.setAttribute(`data-phone-error`,``),i.after(t));let e=w(this._country);t.textContent=e?`Enter a valid phone number, e.g. ${e}`:`Enter a valid phone number`}else t?.remove();this._syncDescribedBy()};d.addEventListener(`input`,e=>{e.stopPropagation();let t=d.selectionStart??d.value.length,n=d.value.slice(0,t).replace(/[^0-9]/g,``).length,r=d.value.replace(/[^0-9]/g,``),i=E(this._country);if(i&&r.length>i){let e=D(this._country,r,i);e?(n=Math.max(0,n-(r.length-e.length)),r=e):r=r.slice(0,i)}this._national=r;let a=S(this._country,this._national);if(d.value!==a){d.value=a;let e=C(a,Math.min(n,r.length));d.setSelectionRange(e,e)}this._syncMirror(),this._emitInput(),d.classList.contains(`is-invalid`)&&(!this._national||T(this.value)===!0)&&M(!1)}),d.addEventListener(`change`,e=>e.stopPropagation()),d.addEventListener(`blur`,()=>{M(this._national.length>0&&T(this.value)===!1),this.value!==this._committedValue&&this._emitChange()}),d.addEventListener(`paste`,e=>{let t=O(e.clipboardData?.getData(`text`));t&&(e.preventDefault(),this._national=t.national.replace(/[^0-9]/g,``),t.country===this._country?d.value=S(this._country,this._national):this.setAttribute(`country`,t.country),this._syncMirror(),this._emitInput(),this._emitChange(),this.querySelector(`input[type=tel]`)?.focus())}),this._bindGlobal=()=>{this._teardownGlobals?.(),this._onDocClick=e=>{m()&&!this.contains(e.target)&&x()},document.addEventListener(`click`,this._onDocClick),m()&&t(this,v)},this._teardownGlobals=()=>{this._onDocClick&&=(document.removeEventListener(`click`,this._onDocClick),null),n(this)},this._bindGlobal(),b().then(e=>{if(!(!e||!d.isConnected)&&(this._national&&(d.value=S(this._country,this._national)),!this.getAttribute(`placeholder`))){let e=w(this._country);e&&(d.placeholder=e)}}),this._syncMirror()}_teardown(){this._teardownGlobals?.()}disconnectedCallback(){this._teardown()}},A=e=>String(e??``).replace(/"/g,`&quot;`).replace(/</g,`&lt;`);export{k as t};